This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: I want to know the information about the function arguments
- From: David Malcolm <dmalcolm at redhat dot com>
- To: Martin Jambor <mjambor at suse dot cz>, 冠人 王 <guanjen375 at yahoo dot com dot tw>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Wed, 06 Jun 2018 09:00:39 -0400
- Subject: Re: I want to know the information about the function arguments
- References: <1445820821.870222.1528269245322.ref@mail.yahoo.com> <1445820821.870222.1528269245322@mail.yahoo.com> <ri6h8mgkwf9.fsf@suse.cz>
On Wed, 2018-06-06 at 13:04 +0200, Martin Jambor wrote:
> Hi,
>
> On Wed, Jun 06 2018, 冠人 王 via gcc wrote:
> > When I modify the gcc source code, sometimes I do not know what
> > parameters does the function call.
> > For example,
> > bool warn_if_unused_value(const tree exp,location_t locus){
> > function declaration ...
> > }
> > I want to know what "exp" and "locus" are by using fprintf such as
> > fprintf(stderr,"%s\n%s\n",exp,locus) --> I know it does not work
> > since exp and locus is not strings
> > How should I do to know the content of variable "exp" and "locus" ?
>
> For trees, look for example at:
>
> - debug_tree (tree);
> - print_node (FILE *, const char *, tree, int);
> - print_node_brief (FILE *, const char *, const_tree, int);
>
> For location_t, I *think* you need to expand it yourself first. Look
> at
> how it is being done for example in tree-dump.c.
>
> Generally speaking, for any given type, try searching for functions
> with
> "debug" or "dump" in their names that dump any particular type.
For a location_t, you can try adding a call to "inform" e.g.
inform (locus, "some message");
This will emit a "note" diagnostic at the source location that "locus"
represents.
Alternatively, if you're already debugging the compiler in gdb, you can
call "inform" directly:
(gdb) call inform (locus, "")
and it will emit a "note" diagnostic describing "locus".
FWIW, I've written some notes on debugging GCC here:
https://dmalcolm.fedorapeople.org/gcc/newbies-guide/debugging.html
Hope this is helpful; good luck!
Dave