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