From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4368 invoked by alias); 2 Apr 2003 14:19:39 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 4351 invoked from network); 2 Apr 2003 14:19:35 -0000 Received: from unknown (HELO tretyak.sun.mcst.ru) (81.89.69.194) by sources.redhat.com with SMTP; 2 Apr 2003 14:19:35 -0000 Received: from terra.lab.sun.mcst.ru (lab-gw.sun.mcst.ru [192.168.3.1]) by tretyak.sun.mcst.ru (8.11.6+Sun/8.11.6) with ESMTP id h32EIfk14493; Wed, 2 Apr 2003 18:18:41 +0400 (MSD) Received: from flea.lab.sun.mcst.ru (flea [192.168.2.34]) by terra.lab.sun.mcst.ru (8.10.2+Sun/8.9.3) with ESMTP id h32EIbL11568; Wed, 2 Apr 2003 18:18:37 +0400 (MSD) Received: from flea (flea [192.168.2.34]) by flea.lab.sun.mcst.ru (8.11.6+Sun/8.11.6) with SMTP id h32EIaI24737; Wed, 2 Apr 2003 18:18:37 +0400 (MSD) Message-Id: <200304021418.h32EIaI24737@flea.lab.sun.mcst.ru> Date: Wed, 02 Apr 2003 15:07:00 -0000 From: Ilia Dyatchkov Reply-To: Ilia Dyatchkov Subject: Re: General search for symbols... To: xyzzy@hotpop.com Cc: gcc@gcc.gnu.org MIME-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii Content-MD5: IiZLtJJa6/jKlosx2c5IkA== X-SW-Source: 2003-04/txt/msg00076.txt.bz2 >I am trying to port GCC to another machine. >Given that I have a file path>/gcc/config//.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)); > } > }