public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb: include address in names of objfiles created by jit reader API
@ 2022-02-02 12:03 Jan Vrany
  2022-02-02 16:09 ` Tom Tromey
  2022-02-02 16:17 ` Simon Marchi
  0 siblings, 2 replies; 9+ messages in thread
From: Jan Vrany @ 2022-02-02 12:03 UTC (permalink / raw)
  To: gdb-patches; +Cc: Jan Vrany

This commit includes jited object address in the names of objfiles
created by jit reader API (e.g., << JIT compiled code at 0x7ffd8a0c77a0 >>).
This allows one to at least differentiate one from another.
---
 gdb/jit.c                             | 8 ++++++--
 gdb/testsuite/gdb.base/jit-reader.exp | 4 ++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/gdb/jit.c b/gdb/jit.c
index 42776b95683..371cb8b1d48 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -624,12 +624,16 @@ jit_object_close_impl (struct gdb_symbol_callbacks *cb,
 		       struct gdb_object *obj)
 {
   struct objfile *objfile;
+  char objfile_name[64];
   jit_dbg_reader_data *priv_data;
 
   priv_data = (jit_dbg_reader_data *) cb->priv_data;
 
-  objfile = objfile::make (nullptr, "<< JIT compiled code >>",
-			   OBJF_NOT_FILENAME);
+  snprintf (objfile_name, sizeof (objfile_name) - 1,
+            "<< JIT compiled code at 0x%" PRIxPTR " >>",
+            reinterpret_cast<uintptr_t> (priv_data));
+  objfile_name[sizeof (objfile_name) - 1] = '\0';
+  objfile = objfile::make (nullptr, objfile_name, OBJF_NOT_FILENAME);
   objfile->per_bfd->gdbarch = target_gdbarch ();
 
   for (gdb_symtab &symtab : obj->symtabs)
diff --git a/gdb/testsuite/gdb.base/jit-reader.exp b/gdb/testsuite/gdb.base/jit-reader.exp
index bcc85640ec0..d94360cd7d9 100644
--- a/gdb/testsuite/gdb.base/jit-reader.exp
+++ b/gdb/testsuite/gdb.base/jit-reader.exp
@@ -230,11 +230,11 @@ proc jit_reader_test {} {
 
 	    if { ![skip_python_tests] } {
 		gdb_test "python print(gdb.objfiles())" \
-		    "$any<gdb.Objfile filename=<< JIT compiled code >>>$any" \
+		    "$any<gdb.Objfile filename=<< JIT compiled code at $hex >>>$any" \
 		    "python gdb.Objfile.__repr__ ()"
 
 		gdb_test "python print(list(map(lambda objf : objf.filename, gdb.objfiles())))" \
-		    "$any'<< JIT compiled code >>'$any" \
+		    "$any'<< JIT compiled code at $hex >>'$any" \
 		    "python gdb.Objfile.filename"
 	    }
 	}
-- 
2.30.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-02-04 16:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-02 12:03 [PATCH] gdb: include address in names of objfiles created by jit reader API Jan Vrany
2022-02-02 16:09 ` Tom Tromey
2022-02-02 16:17 ` Simon Marchi
2022-02-04 12:39   ` Jan Vrany
2022-02-04 13:15     ` Simon Marchi
2022-02-04 13:42       ` Jan Vrany
2022-02-04 14:52         ` Simon Marchi
2022-02-04 15:32           ` Jan Vrany
2022-02-04 16:09             ` Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).