diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2022-02-02 10:54:03 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2022-02-04 11:07:37 -0500 |
commit | 4a620b7e30fe58c3f53ad7a2044728e850b921d2 (patch) | |
tree | 307ff7e55a30c639584aa1699d557e433d8b7aa3 /gdb/jit.c | |
parent | 480157863bac93e56f97f93d5d90818a47debbf6 (diff) | |
download | gdb-4a620b7e30fe58c3f53ad7a2044728e850b921d2.zip gdb-4a620b7e30fe58c3f53ad7a2044728e850b921d2.tar.gz gdb-4a620b7e30fe58c3f53ad7a2044728e850b921d2.tar.bz2 |
gdb: include jit_code_entry::symfile_addr value in names of objfiles created by jit reader API
This commit includes the JIT object's symfile 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.
The address is the one that the debugged program has put in
jit_code_entry::symfile_addr, and that the JIT reader's read function
receives. As we can see in gdb.base/jit-reader-host.c and
gdb.base/jit-reader.c, that may not be the actual value of where the
JIT-ed code is. But it is a value chosen by the author of the JIT
engine and the JIT reader, so including this value in the objfile name
may help them correlate the JIT objfiles created by with their logs /
data structures.
To access this field, we need to pass down a reference to the
jit_code_entry. So make jit_dbg_reader_data a structure (instead of an
alias for a CORE_ADDR) that includes the address of the code entry in
the inferior's address space (the previous meaning of
jit_dbg_reader_data) plus a reference to the jit_code_entry as read into
GDB's address space. And while at it, pass down the gdbarch, so that we
don't have to call target_gdbarch.
Co-Authored-By: Jan Vrany <jan.vrany@labware.com>
Change-Id: Ib26c4d1bd8de503d651aff89ad2e500cb312afa5
Diffstat (limited to 'gdb/jit.c')
-rw-r--r-- | gdb/jit.c | 41 |
1 files changed, 27 insertions, 14 deletions
@@ -380,7 +380,16 @@ struct gdb_object /* The type of the `private' data passed around by the callback functions. */ -typedef CORE_ADDR jit_dbg_reader_data; +struct jit_dbg_reader_data +{ + /* Address of the jit_code_entry in the inferior's address space. */ + CORE_ADDR entry_addr; + + /* The code entry, copied in our address space. */ + const jit_code_entry &entry; + + struct gdbarch *gdbarch; +}; /* The reader calls into this function to read data off the targets address space. */ @@ -623,19 +632,20 @@ static void jit_object_close_impl (struct gdb_symbol_callbacks *cb, struct gdb_object *obj) { - struct objfile *objfile; - jit_dbg_reader_data *priv_data; - - priv_data = (jit_dbg_reader_data *) cb->priv_data; + jit_dbg_reader_data *priv_data = (jit_dbg_reader_data *) cb->priv_data; + std::string objfile_name + = string_printf ("<< JIT compiled code at %s >>", + paddress (priv_data->gdbarch, + priv_data->entry.symfile_addr)); - objfile = objfile::make (nullptr, "<< JIT compiled code >>", - OBJF_NOT_FILENAME); - objfile->per_bfd->gdbarch = target_gdbarch (); + objfile *objfile = objfile::make (nullptr, objfile_name.c_str (), + OBJF_NOT_FILENAME); + objfile->per_bfd->gdbarch = priv_data->gdbarch; for (gdb_symtab &symtab : obj->symtabs) finalize_symtab (&symtab, objfile); - add_objfile_entry (objfile, *priv_data); + add_objfile_entry (objfile, priv_data->entry_addr); delete obj; } @@ -645,11 +655,16 @@ jit_object_close_impl (struct gdb_symbol_callbacks *cb, inferior address space. */ static int -jit_reader_try_read_symtab (struct jit_code_entry *code_entry, +jit_reader_try_read_symtab (gdbarch *gdbarch, jit_code_entry *code_entry, CORE_ADDR entry_addr) { int status; - jit_dbg_reader_data priv_data; + jit_dbg_reader_data priv_data + { + entry_addr, + *code_entry, + gdbarch + }; struct gdb_reader_funcs *funcs; struct gdb_symbol_callbacks callbacks = { @@ -665,8 +680,6 @@ jit_reader_try_read_symtab (struct jit_code_entry *code_entry, &priv_data }; - priv_data = entry_addr; - if (!loaded_jit_reader) return 0; @@ -779,7 +792,7 @@ jit_register_code (struct gdbarch *gdbarch, paddress (gdbarch, code_entry->symfile_addr), pulongest (code_entry->symfile_size)); - success = jit_reader_try_read_symtab (code_entry, entry_addr); + success = jit_reader_try_read_symtab (gdbarch, code_entry, entry_addr); if (!success) jit_bfd_try_read_symtab (code_entry, entry_addr, gdbarch); |