This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [rfa] allocate_objfile(NULL, 0)


On Tue, 4 Feb 2003 13:08:53 -0500, Elena Zannoni <ezannoni@redhat.com> 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  <carlton@math.stanford.edu>

	* 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 = "<<anonymous objfile>>";
     }
 
   /* 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)
 {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]