From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19002 invoked by alias); 4 Feb 2003 22:21:31 -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 18995 invoked from network); 4 Feb 2003 22:21:30 -0000 Received: from unknown (HELO jackfruit.Stanford.EDU) (171.64.38.136) by 172.16.49.205 with SMTP; 4 Feb 2003 22:21:30 -0000 Received: (from carlton@localhost) by jackfruit.Stanford.EDU (8.11.6/8.11.6) id h14M1Ln25569; Tue, 4 Feb 2003 14:01:21 -0800 X-Authentication-Warning: jackfruit.Stanford.EDU: carlton set sender to carlton@math.stanford.edu using -f To: Elena Zannoni Cc: gdb-patches@sources.redhat.com, Tom Tromey Subject: Re: [rfa] allocate_objfile(NULL, 0) References: <15903.24492.446475.747803@localhost.redhat.com> <15936.437.642918.181857@localhost.redhat.com> From: David Carlton Date: Tue, 04 Feb 2003 22:21:00 -0000 In-Reply-To: <15936.437.642918.181857@localhost.redhat.com> Message-ID: User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Common Lisp) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-02/txt/msg00150.txt.bz2 On Tue, 4 Feb 2003 13:08:53 -0500, Elena Zannoni said: > I cannot come up with anything better at the moment, so OK, but... > could you add comments? Kind of summarize your mail and Tom's mail. Okay, I've added comments at the beginning of allocate_objfile and at its caller in the Java code mentioning the situation. I've committed the attached; I also committed it to 5.3, on the off chance that 5.3.1 ever happens. David Carlton carlton@math.stanford.edu 2003-02-04 David Carlton * objfiles.c (allocate_objfile): Always set name. Add comment at start of function. * jv-lang.c (get_dynamics_objfile): Add comment. Index: objfiles.c =================================================================== RCS file: /cvs/src/src/gdb/objfiles.c,v retrieving revision 1.26 diff -u -p -r1.26 objfiles.c --- objfiles.c 4 Feb 2003 18:07:01 -0000 1.26 +++ objfiles.c 4 Feb 2003 21:52:59 -0000 @@ -150,6 +150,15 @@ build_objfile_section_table (struct objf OBJF_SHARED are simply copied through to the new objfile flags member. */ +/* NOTE: carlton/2003-02-04: This function is called with args NULL, 0 + by jv-lang.c, to create an artificial objfile used to hold + information about dynamically-loaded Java classes. Unfortunately, + that branch of this function doesn't get tested very frequently, so + it's prone to breakage. (E.g. at one time the name was set to NULL + in that situation, which broke a loop over all names in the dynamic + library loader.) If you change this function, please try to leave + things in a consistent state even if abfd is NULL. */ + struct objfile * allocate_objfile (bfd *abfd, int flags) { @@ -312,6 +321,10 @@ allocate_objfile (bfd *abfd, int flags) error ("Can't find the file sections in `%s': %s", objfile->name, bfd_errmsg (bfd_get_error ())); } + } + else + { + objfile->name = "<>"; } /* Initialize the section indexes for this objfile, so that we can Index: jv-lang.c =================================================================== RCS file: /cvs/src/src/gdb/jv-lang.c,v retrieving revision 1.12 diff -u -p -r1.12 jv-lang.c --- jv-lang.c 11 Jul 2002 20:46:19 -0000 1.12 +++ jv-lang.c 4 Feb 2003 21:53:04 -0000 @@ -68,6 +68,12 @@ static struct objfile *dynamics_objfile static struct type *java_link_class_type (struct type *, struct value *); +/* FIXME: carlton/2003-02-04: This is the main or only caller of + allocate_objfile with first argument NULL; as a result, this code + breaks every so often. Somebody should write a test case that + exercises GDB in various ways (e.g. something involving loading a + dynamic library) after this code has been called. */ + static struct objfile * get_dynamics_objfile (void) {