From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15765 invoked by alias); 3 Aug 2009 20:08:31 -0000 Received: (qmail 15751 invoked by uid 22791); 3 Aug 2009 20:08:29 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_13,SPF_FAIL X-Spam-Check-By: sourceware.org Received: from mx20.gnu.org (HELO mx20.gnu.org) (199.232.41.8) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 03 Aug 2009 20:08:23 +0000 Received: from mail.codesourcery.com ([65.74.133.4]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MY3pV-00013H-9Z for gcc@gcc.gnu.org; Mon, 03 Aug 2009 16:08:21 -0400 Received: (qmail 13447 invoked from network); 3 Aug 2009 20:08:18 -0000 Received: from unknown (HELO ?192.168.2.100?) (wilson@127.0.0.2) by mail.codesourcery.com with ESMTPA; 3 Aug 2009 20:08:18 -0000 Subject: Re: extern variable From: Jim Wilson To: sumanth Cc: gcc@gcc.gnu.org In-Reply-To: <4A772E41.6090302@redpinesignals.com> References: <4A71B07A.1030600@redpinesignals.com> <4A75EA44.8050201@codesourcery.com> <4A76641A.1010503@redpinesignals.com> <1249315349.2559.12.camel@localhost> <4A772E41.6090302@redpinesignals.com> Content-Type: text/plain Date: Mon, 03 Aug 2009 20:10:00 -0000 Message-Id: <1249330097.2561.4.camel@localhost> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Detected-Operating-System: by mx20.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2009-08/txt/msg00043.txt.bz2 On Tue, 2009-08-04 at 00:06 +0530, sumanth wrote: > > mycompiler-gcc -g file1.c file2.c > > mycompiler-gdb a.out > >> when i print "a" in file1.c , i am able to see value 10; > >> when i print "a" int file2.c, it prints , no symbol defined. > Instead I can access it with " print _a" This sounds odd, as there is no variable a or _a in file2.c, and if you can see a variable in one file you should be able to see if with the same name in another file. Anyways, I think I already answered this with my first message when I pointed you at ASM_OUTPUT_* and ASM_GENERATE_INTERNAL_LABEL etc. If you compile with -g -S, and look at the assembly language, you will see that "_a" is being used in the debug info someplace for the variable name where "a" should be used instead. "_a" is correct for the variable address, but not the variable name. So you will have to step through your gcc port to figure out why the "_a" is incorrectly printed, and most likely it is a bug in one of the macros I have mentioned. Take a look at a port that handles this correctly to see what they do differently to make this work. Jim