From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Received: (qmail 26263 invoked from network); 11 Jan 2003 00:00:51 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by 209.249.29.67 with SMTP; 11 Jan 2003 00:00:51 -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 h0ANWiB30036 for ; Fri, 10 Jan 2003 18:32:44 -0500 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 h0B00da29765 for ; Fri, 10 Jan 2003 19:00:39 -0500 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 h0B00cS10421 for ; Fri, 10 Jan 2003 19:00:38 -0500 Received: by localhost.redhat.com (Postfix, from userid 469) id 9E3FBFF79; Fri, 10 Jan 2003 19:05:00 -0500 (EST) From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15903.24492.446475.747803@localhost.redhat.com> Date: Sat, 11 Jan 2003 00:00:00 -0000 To: David Carlton Cc: gdb-patches@sources.redhat.com Subject: Re: [rfa] allocate_objfile(NULL, 0) In-Reply-To: References: X-SW-Source: 2003-01/txt/msg00434.txt.bz2 David Carlton writes: > The function allocate_objfile takes some care to return a useful > objfile if its first argument (the bfd) is NULL. But it doesn't set > objfile->name in that case; there is code in GDB that loops over all > the objfiles and examines their names, which breaks in this case. > (See, for example, symbol_add_stub.) > > I ran into this problem when imitating the dynamics objfile in > jv-lang.c. So I'm pretty sure that, currently, if anybody tries to > debug Java code that requires that objfile to exist, GDB will seg > fault. > Can you expand a bit? Would it be possible to create a test case? > The enclosed patch modifies allocate_objfile to set the name to > "<>" in that situation. It removes the seg fault > that I saw. I ran the test suite on i686-pc-linux-gnu/GCC 3.1/DWARF-2 > and saw no new regressions. > > Is this patch okay? I don't know offhand who the appropriate > maintainer is. > I don't know about the '<<' '>>' usage. I wonder if gdb already has some other cases like this one. Maybe 'nameless'? > David Carlton > carlton@math.stanford.edu > > 2003-01-10 David Carlton > > * objfiles.c (allocate_objfile): Always set name. You are missing the copyright year. > > Index: objfiles.c > =================================================================== > RCS file: /cvs/src/src/gdb/objfiles.c,v > retrieving revision 1.22 > diff -u -p -r1.22 objfiles.c > --- objfiles.c 29 Jul 2002 22:55:26 -0000 1.22 > +++ objfiles.c 10 Jan 2003 23:31:56 -0000 > @@ -305,6 +305,10 @@ allocate_objfile (bfd *abfd, int flags) > objfile->name, bfd_errmsg (bfd_get_error ())); > } > } > + else > + { > + objfile->name = "<>"; > + } > > /* Initialize the section indexes for this objfile, so that we can > later detect if they are used w/o being properly assigned to. */