From: Wu Zhou <woodzltc@cn.ibm.com>
To: Jim Blandy <jimb@redhat.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: Thu, 03 Nov 2005 10:16:00 -0000 [thread overview]
Message-ID: <Pine.LNX.4.63.0511031801530.7578@linux.site> (raw)
In-Reply-To: <vt2oe52npn7.fsf@theseus.home.>
On Wed, 2 Nov 2005, Jim Blandy wrote:
>
> Mark Kettenis <mark.kettenis@xs4all.nl> writes:
> > One could argue that the debug information generated by g77 is wrong,
> > because it doesn't reflect the actual implementation of FUNC_NAME. Or
> > perhaps GDB symbol reading code causes problems. Can you post a
> > concrete example of a function call that goes wrong, and add a bit of
> > explanation about the types involved for those of us who are not very
> > familiar with Fortran?
>
> The types in the debug information should not reflect the extra level
> of indirection; the fact that they're passed by reference is just part
> of the meaning of a Fortran function call. But the location
> expression should encode the extra level of indirection.
>
> Probably value_arg_coerce should be a language method. The C
> promotion rules aren't appropriate for Fortran anyway, and the Fortran
> version could take care of applying value_addr (or something like
> that), and turning the array of actuals into an array of pointers to
> the actuals.
Jim, it seems that you just said out what I am thinking of. Function
value_arg_coerce is said to perform the standard coercion that are
specified for arguments to be passed to C functions (you can see that in
the comment). But it is also used for Fortran functions (maybe all
other function GDB supports).
What is more, I find that when I pass "res_(b)" to gfortran code in gdb
command line, it will get the correct result. All the difference is that
gfortran handle the parameters as reference to the actuals. So
value_arg_coerce will call value_addr to convert args into the address of
them, so we can get the correct result.
However with gfortran, "print res_(2)" still doesn't get the correct
result. But it fail more gracefully, it reports the following error
message:
Attempt to take address of value not located in memory.
Which is well expected with reference to the code in value_arg_coerce.
So I am thinking of a somwhat different value_arg_coerce for Fortran code:
when the parameter type is a reference (for gfortran) or pointer (for
g77), we can call something like value_addr to changed the argument into
its address.
I did some tests today, but no success so far. Will take some more look
into this.
Any suggestion, comments on this? Thanks!
Regards
- Wu Zhou
next prev parent reply other threads:[~2005-11-03 10:16 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
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 [this message]
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=Pine.LNX.4.63.0511031801530.7578@linux.site \
--to=woodzltc@cn.ibm.com \
--cc=gdb@sources.redhat.com \
--cc=jimb@redhat.com \
--cc=mark.kettenis@xs4all.nl \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).