From: Daniel Jacobowitz <drow@false.org>
To: Wu Zhou <woodzltc@cn.ibm.com>
Cc: Mark Kettenis <mark.kettenis@xs4all.nl>, gdb@sources.redhat.com
Subject: Re: The root cause for SEGV in evaluating fortran function call, any solution or suggestion?
Date: Mon, 07 Nov 2005 00:09:00 -0000 [thread overview]
Message-ID: <20051107000949.GD19200@nevyn.them.org> (raw)
In-Reply-To: <Pine.LNX.4.63.0511041048590.22104@linux.site>
On Fri, Nov 04, 2005 at 11:18:00AM +0800, Wu Zhou wrote:
> > Allocating memory on the stack is actually quite eazy. Just
> > substract/add the amount of space you need from/to the stack pointer,
> > and use the new/old stack pointer as the address for the memory.
> > Whether you should substract or add depends on whether the stack grows
> > downward or upward. Use gdbarch_inner_than(gdbarch, 1, 2) to check.
> > There's quite a bit of code in infcall.c that uses this trick.
> >
>
> Thanks. I did some tests following this way. But didn't get any success.
> So I had to post here again to see if anybody can help me out.
>
> My basic idea is to create a value which hold the address to the original
> argument. This is done in valur_addr for these argument which is not lval
> and whose type is TYPE_CODE_INT. Then I use the above method to get a new
> value which hold the address to the original address. Although it doesn't
> report SEGV or "can not access memory" message, it didn't ouptut the
> correct result I expected. I expect 4 (which is 2 * 2), but it return
> different number for me every time I run it.
>
> Following is the changed I made to valur_arg_coerce and value_addr. Could
> anyone help me pointed out what is the reason why it fail. Thanks a lot!
It's not quite as simple as Mark makes it out to be - in concept, sure,
but not in execution. You have to _allocate_ the space on the stack;
not just find empty space off the side of the stack and write the
argument there.
By the type that we're calling value_arg_coerce, we've already
allocated some space on the stack, and saved the old stack pointer.
But we'll allocate more space on the stack below, when we push
arguments. And you have to be careful to keep the stack aligned
properly through all of this. Read through the surrounding bits of
infcall.c to see how this works for struct returns; that is the closest
analogue we have today.
Maybe if you pass the sp value by reference to value_arg_coerce and
adjust it there...
--
Daniel Jacobowitz
CodeSourcery, LLC
next prev parent reply other threads:[~2005-11-07 0:09 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-22 10:14 [GDB & Fortran] Anyone has success experience with printing the result of Fortran function calls? Wu Zhou
2005-11-02 2:39 ` The root cause for SEGV in evaluating fortran function call, any solution or suggestion? Wu Zhou
2005-11-02 14:53 ` Daniel Jacobowitz
2005-11-03 3:12 ` Wu Zhou
2005-11-03 21:34 ` Mark Kettenis
2005-11-04 3:15 ` Wu Zhou
2005-11-04 3:52 ` Wu Zhou
2005-11-07 0:09 ` Daniel Jacobowitz [this message]
2005-11-07 4:49 ` Wu Zhou
2005-11-07 5:01 ` Daniel Jacobowitz
2005-11-07 5:16 ` Wu Zhou
2005-11-10 0:55 ` Jim Blandy
2005-11-10 0:59 ` Daniel Jacobowitz
2005-11-11 9:59 ` Jim Blandy
2005-11-04 11:20 ` Dave Korn
2005-11-06 23:58 ` Daniel Jacobowitz
2005-11-02 15:51 ` Mark Kettenis
2005-11-03 2:50 ` Wu Zhou
2005-11-03 7:42 ` Jim Blandy
2005-11-03 10:16 ` Wu Zhou
2005-11-07 0:02 ` Daniel Jacobowitz
2005-11-10 0:49 ` Jim Blandy
2005-11-10 1:00 ` Daniel Jacobowitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20051107000949.GD19200@nevyn.them.org \
--to=drow@false.org \
--cc=gdb@sources.redhat.com \
--cc=mark.kettenis@xs4all.nl \
--cc=woodzltc@cn.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox