This is the mail archive of the gdb-patches@sourceware.org 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]

[patch] OBJF_NOT_FILENAME [Re: [RFC] Record objfile->original_name as an absolute path]


On Fri, 27 Sep 2013 21:37:35 +0200, Tom Tromey wrote:
> I've wanted an objfile flag for a while that would indicate whether the
> underlying BFD corresponds to a file or some other thing.
> Right now I think you can see lookups of bogusly-named files coming from
> the Python auto-loader.

That's true, for example for gdb.base/jit.exp:

open("<in-memory>-gdb.gdb", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/debug<in-memory>-gdb.gdb", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/share/gdb/auto-load<in-memory>-gdb.gdb", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
etc.

I will integrate it with add-ons to the Doug's patch.

No regressions on {x86_64,x86_64-m32,i686}-fedora21pre-linux-gnu.


Thanks,
Jan


gdb/
2013-10-08  Jan Kratochvil  <jan.kratochvil@redhat.com>

	New flag OBJF_NOT_FILENAME.
	* auto-load.c (auto_load_objfile_script): Check also OBJF_NOT_FILENAME.
	* jit.c (jit_object_close_impl): Use OBJF_NOT_FILENAME for
	allocate_objfile.
	(jit_bfd_try_read_symtab): Use OBJF_NOT_FILENAME for
	symbol_file_add_from_bfd.
	* jv-lang.c (get_dynamics_objfile): Use OBJF_NOT_FILENAME for
	allocate_objfile.
	* objfiles.c (allocate_objfile): Assert OBJF_NOT_FILENAME if NAME is
	NULL.
	* objfiles.h (OBJF_NOT_FILENAME): New.

diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index 6d0d6d9..4eb7cdd 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -840,7 +840,7 @@ auto_load_objfile_script (struct objfile *objfile,
 void
 load_auto_scripts_for_objfile (struct objfile *objfile)
 {
-  if (!global_auto_load)
+  if (!global_auto_load || (objfile->flags & OBJF_NOT_FILENAME) != 0)
     return;
 
   if (auto_load_gdb_scripts)
diff --git a/gdb/jit.c b/gdb/jit.c
index c7edd4a..ba0be5e 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -785,7 +785,8 @@ jit_object_close_impl (struct gdb_symbol_callbacks *cb,
 
   priv_data = cb->priv_data;
 
-  objfile = allocate_objfile (NULL, "<< JIT compiled code >>", 0);
+  objfile = allocate_objfile (NULL, "<< JIT compiled code >>",
+			      OBJF_NOT_FILENAME);
   objfile->per_bfd->gdbarch = target_gdbarch ();
 
   terminate_minimal_symbol_table (objfile);
@@ -926,7 +927,7 @@ JITed symbol file is not an object file, ignoring it.\n"));
   /* This call does not take ownership of SAI.  */
   make_cleanup_bfd_unref (nbfd);
   objfile = symbol_file_add_from_bfd (nbfd, bfd_get_filename (nbfd), 0, sai,
-				      OBJF_SHARED, NULL);
+				      OBJF_SHARED | OBJF_NOT_FILENAME, NULL);
 
   do_cleanups (old_cleanups);
   add_objfile_entry (objfile, entry_addr);
diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c
index 0d07bbd..63bcc98 100644
--- a/gdb/jv-lang.c
+++ b/gdb/jv-lang.c
@@ -118,7 +118,8 @@ get_dynamics_objfile (struct gdbarch *gdbarch)
 
       /* Mark it as shared so that it is cleared when the inferior is
 	 re-run.  */
-      dynamics_objfile = allocate_objfile (NULL, NULL, OBJF_SHARED);
+      dynamics_objfile = allocate_objfile (NULL, NULL,
+					   OBJF_SHARED | OBJF_NOT_FILENAME);
       dynamics_objfile->per_bfd->gdbarch = gdbarch;
 
       data = XCNEW (struct jv_per_objfile_data);
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index a10540a..d1f3121 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -289,6 +289,7 @@ allocate_objfile (bfd *abfd, const char *name, int flags)
   if (name == NULL)
     {
       gdb_assert (abfd == NULL);
+      gdb_assert ((flags & OBJF_NOT_FILENAME) != 0);
       name = "<<anonymous objfile>>";
     }
   objfile->original_name = obstack_copy0 (&objfile->objfile_obstack, name,
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 8586e5a..281a698 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -429,6 +429,11 @@ struct objfile
 
 #define OBJF_MAINLINE (1 << 5)
 
+/* ORIGINAL_NAME and OBFD->FILENAME correspong to text description unrelated to
+   filesystem names.  It can be for example "<image in memory>".  */
+
+#define OBJF_NOT_FILENAME (1 << 6)
+
 /* Declarations for functions defined in objfiles.c */
 
 extern struct objfile *allocate_objfile (bfd *, const char *name, int);


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