From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11266 invoked by alias); 8 Aug 2003 14:06:50 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 11257 invoked from network); 8 Aug 2003 14:06:49 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 8 Aug 2003 14:06:49 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id h78E6nt01724 for ; Fri, 8 Aug 2003 10:06:49 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h78E6nx27740 for ; Fri, 8 Aug 2003 10:06:49 -0400 Received: from localhost.redhat.com (romulus-int.sfbay.redhat.com [172.16.27.46]) by pobox.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h78E6m717976 for ; Fri, 8 Aug 2003 10:06:48 -0400 Received: by localhost.redhat.com (Postfix, from userid 469) id B24A92CB35; Fri, 8 Aug 2003 10:14:30 -0400 (EDT) From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16179.45126.487478.80668@localhost.redhat.com> Date: Fri, 08 Aug 2003 14:06:00 -0000 To: gdb-patches@sources.redhat.com Subject: Re: [PATCH] fix lookup_symbol foobar In-Reply-To: <16178.32321.697363.540270@localhost.redhat.com> References: <16178.32321.697363.540270@localhost.redhat.com> X-SW-Source: 2003-08/txt/msg00125.txt.bz2 Committed mainline & branch elena Elena Zannoni writes: > > This is an interesting buglet: > > [ezannoni@tomago gdb]$ cat ~/buglet.c > int a = 5; > int main (void) > { > int sum = 0; > printf ("hello\n"); > while ( a > 0) > { > sum += a; > a--; > } > printf ("sum is %d\n", sum); > printf ("bye\n"); > return 0; > } > > > [ezannoni@tomago gdb]$ gdb ~/buglet > GNU gdb Red Hat Linux (5.3.90-0.20030710.2rh) > Copyright 2003 Free Software Foundation, Inc. > GDB is free software, covered by the GNU General Public License, and you are > welcome to change it and/or distribute copies of it under certain conditions. > Type "show copying" to see the conditions. > There is absolutely no warranty for GDB. Type "show warranty" for details. > This GDB was configured as "i386-redhat-linux-gnu"... > Setting up the environment for debugging gdb. > .gdbinit:5: Error in sourced command file: > Function "internal_error" not defined. > (gdb) l > 1 int a = 5; > 2 int main (void) > 3 { > 4 int sum = 0; > 5 printf ("hello\n"); > 6 while ( a > 0) > 7 { > 8 sum += a; > 9 a--; > 10 } > (gdb) p a > $1 = 5 > (gdb) p sum > No symbol "sum" in current context. > (gdb) ptype a > type = int > (gdb) ptype sum > No symbol "sum" in current context. > (gdb) info addr a > Symbol "a" is static storage at address 0x80494b4. > (gdb) info addr sum > Symbol "sum" is a field of the local class variable `this' > > Whoops. > > This is because lookup_symbol in address_info() returns null, and also > doesn't initialize *is_a_field_of_this to anything. > > I suspect a similar situation can happen in any of the callers of > lookup_symbol that set the is_a_field_of_this to a non-null value. > > David, you are the one that played around with all this, looks ok to > you? > > elena > > > 2003-08-07 Elena Zannoni > > * symtab.c (lookup_symbol_aux): Make sure that is_a_field_of_this > contains something meaningful at all times. > > > > diff -u -p -r1.113 symtab.c > --- symtab.c 12 Jun 2003 15:52:08 -0000 1.113 > +++ symtab.c 7 Aug 2003 15:33:08 -0000 > @@ -945,6 +945,14 @@ lookup_symbol_aux (const char *name, con > { > struct symbol *sym; > > + /* Make sure we do something sensible with is_a_field_of_this, since > + the callers that set this parameter to some non-null value will > + certainly use it later and expect it to be either 0 or 1. > + If we don't set it, the contents of is_a_field_of_this are > + undefined. */ > + if (is_a_field_of_this != NULL) > + *is_a_field_of_this = 0; > + > /* Search specified block and its superiors. Don't search > STATIC_BLOCK or GLOBAL_BLOCK. */ > > @@ -961,7 +969,6 @@ lookup_symbol_aux (const char *name, con > { > struct value *v = current_language->la_value_of_this (0); > > - *is_a_field_of_this = 0; > if (v && check_field (v, name)) > { > *is_a_field_of_this = 1;