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 14105 invoked from network); 10 Jan 2003 23:41:23 -0000 Received: from unknown (HELO jackfruit.Stanford.EDU) (171.64.38.136) by 209.249.29.67 with SMTP; 10 Jan 2003 23:41:23 -0000 Received: (from carlton@localhost) by jackfruit.Stanford.EDU (8.11.6/8.11.6) id h0ANfBD03923; Fri, 10 Jan 2003 15:41:11 -0800 X-Authentication-Warning: jackfruit.Stanford.EDU: carlton set sender to carlton@math.stanford.edu using -f To: gdb-patches@sources.redhat.com Subject: [rfa] allocate_objfile(NULL, 0) From: David Carlton Date: Fri, 10 Jan 2003 23:41:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-01/txt/msg00433.txt.bz2 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. 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. David Carlton carlton@math.stanford.edu 2003-01-10 David Carlton * objfiles.c (allocate_objfile): Always set name. 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. */