public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* General search for symbols...
@ 2003-04-02 14:10 Stephen Biggs
  2003-04-02 16:22 ` Hans-Peter Nilsson
  0 siblings, 1 reply; 12+ messages in thread
From: Stephen Biggs @ 2003-04-02 14:10 UTC (permalink / raw)
  To: GCC list

I am trying to port GCC to another machine.

Given that I have a file <new gcc
path>/gcc/config/<machine>/<machine>.c, how would I, within any of the
functions in that file find out if a certain symbol has been defined by
a "#define" statement in the C source that is being compiled?

E.g., the source file consists of one line:
#define DEFINED_CONSTANT_2

Note: my call to print_node CRASHES the compiler.

I have tried various versions of:

  if((decl = getdecls()))
    print_node(stderr,"tree: ",decl,4);  /* this CRASHES!!! */

  for ( ; decl; decl = TREE_CHAIN (decl))
  {
    if (TREE_CODE (decl) == IDENTIFIER_NODE)
    {
      if(!strcmp(IDENTIFIER_POINTER(decl),"DEFINED_CONSTANT_1"))
        fprintf(stderr,"DEFINED_CONSTANT_1" found, code 
%d\n",TREE_CODE(decl));
      else if(!strcmp(IDENTIFIER_POINTER(decl),"DEFINED_CONSTANT_2"))
        fprintf(stderr,"DEFINED_CONSTANT_2 found, code
%d\n",TREE_CODE(decl));
    }
  }



^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: General search for symbols...
@ 2003-04-02 15:07 Ilia Dyatchkov
  0 siblings, 0 replies; 12+ messages in thread
From: Ilia Dyatchkov @ 2003-04-02 15:07 UTC (permalink / raw)
  To: xyzzy; +Cc: gcc


>I am trying to port GCC to another machine.
>Given that I have a file <new gcc
>path>/gcc/config/<machine>/<machine>.c, how would I, within any of the
>functions in that file find out if a certain symbol has been defined by
>a "#define" statement in the C source that is being compiled?
>
>E.g., the source file consists of one line:
>#define DEFINED_CONSTANT_2
>
>Note: my call to print_node CRASHES the compiler.
>
>I have tried various versions of:
>
>  if((decl = getdecls()))
>    print_node(stderr,"tree: ",decl,4);  /* this CRASHES!!! */

Try debug_tree(decl);

>
>  for ( ; decl; decl = TREE_CHAIN (decl))
>  {
>    if (TREE_CODE (decl) == IDENTIFIER_NODE)
>    {
>      if(!strcmp(IDENTIFIER_POINTER(decl),"DEFINED_CONSTANT_1"))
>        fprintf(stderr,"DEFINED_CONSTANT_1" found, code 
>%d\n",TREE_CODE(decl));
>      else if(!strcmp(IDENTIFIER_POINTER(decl),"DEFINED_CONSTANT_2"))
>        fprintf(stderr,"DEFINED_CONSTANT_2 found, code
>%d\n",TREE_CODE(decl));
>    }
>  }


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2003-04-10 19:29 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-02 14:10 General search for symbols Stephen Biggs
2003-04-02 16:22 ` Hans-Peter Nilsson
2003-04-03  7:18   ` Stephen Biggs
2003-04-04  2:13     ` Hans-Peter Nilsson
2003-04-04  9:35       ` Zack Weinberg
2003-04-04 18:51         ` Joe Buck
2003-04-10  9:37           ` Zack Weinberg
2003-04-10 19:36             ` Mike Stump
2003-04-10 20:03               ` Zack Weinberg
2003-04-10 20:12                 ` Mike Stump
2003-04-09  8:43       ` Stephen Biggs
2003-04-02 15:07 Ilia Dyatchkov

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).