This commit updates the output of 'maint info jit' to print not just
the jit_code_entry address, but also the symfile address, and the
symfile size.
The new information could be obtained by looking into target memory at
the contents of the jit_code_entry, but, by storing this information
within gdb at the time the jit object is loaded, it is now possible to
check if the jit_code_entry has been modified in target memory behind
gdb's back.
Additionally, the symfile address is the same address that is now used
in the objfile names after commit
4a620b7e.
One test that relies on the output of 'maint info jit' was updated to
allow for the new output format.
inferior *inf = current_inferior ();
bool printed_header = false;
+ gdb::optional<ui_out_emit_table> table_emitter;
+
/* Print a line for each JIT-ed objfile. */
for (objfile *obj : inf->pspace->objfiles ())
{
if (!printed_header)
{
- printf_filtered ("Base address of known JIT-ed objfiles:\n");
+ table_emitter.emplace (current_uiout, 3, -1, "jit-created-objfiles");
+
+ /* The +2 allows for the leading '0x', then one character for
+ every 4-bits. */
+ int addr_width = 2 + (gdbarch_ptr_bit (obj->arch ()) / 4);
+
+ /* The std::max here selects between the width of an address (as
+ a string) and the width of the column header string. */
+ current_uiout->table_header (std::max (addr_width, 22), ui_left,
+ "jit_code_entry-address",
+ "jit_code_entry address");
+ current_uiout->table_header (std::max (addr_width, 15), ui_left,
+ "symfile-address", "symfile address");
+ current_uiout->table_header (20, ui_left,
+ "symfile-size", "symfile size");
+ current_uiout->table_body ();
+
printed_header = true;
}
- printf_filtered (" %s\n", paddress (obj->arch (), obj->jited_data->addr));
+ ui_out_emit_tuple tuple_emitter (current_uiout, "jit-objfile");
+
+ current_uiout->field_core_addr ("jit_code_entry-address", obj->arch (),
+ obj->jited_data->addr);
+ current_uiout->field_core_addr ("symfile-address", obj->arch (),
+ obj->jited_data->symfile_addr);
+ current_uiout->field_unsigned ("symfile-size",
+ obj->jited_data->symfile_size);
+ current_uiout->text ("\n");
}
}
at inferior address ENTRY. */
static void
-add_objfile_entry (struct objfile *objfile, CORE_ADDR entry)
+add_objfile_entry (struct objfile *objfile, CORE_ADDR entry,
+ CORE_ADDR symfile_addr, ULONGEST symfile_size)
{
gdb_assert (objfile->jited_data == nullptr);
- objfile->jited_data.reset (new jited_objfile_data (entry));
+ objfile->jited_data.reset (new jited_objfile_data (entry, symfile_addr,
+ symfile_size));
}
/* Helper function for reading the global JIT descriptor from remote
for (gdb_symtab &symtab : obj->symtabs)
finalize_symtab (&symtab, objfile);
- add_objfile_entry (objfile, priv_data->entry_addr);
+ add_objfile_entry (objfile, priv_data->entry_addr,
+ priv_data->entry.symfile_addr,
+ priv_data->entry.symfile_size);
delete obj;
}
&sai,
OBJF_SHARED | OBJF_NOT_FILENAME, NULL);
- add_objfile_entry (objfile, entry_addr);
+ add_objfile_entry (objfile, entry_addr, code_entry->symfile_addr,
+ code_entry->symfile_size);
}
/* This function registers code associated with a JIT code entry. It uses the
struct jited_objfile_data
{
- jited_objfile_data (CORE_ADDR addr)
- : addr (addr)
+ jited_objfile_data (CORE_ADDR addr, CORE_ADDR symfile_addr,
+ ULONGEST symfile_size)
+ : addr (addr),
+ symfile_addr (symfile_addr),
+ symfile_size (symfile_size)
{}
/* Address of struct jit_code_entry for this objfile. */
CORE_ADDR addr;
+
+ /* Value of jit_code_entry->symfile_addr for this objfile. */
+ CORE_ADDR symfile_addr;
+
+ /* Value of jit_code_entry->symfile_size for this objfile. */
+ ULONGEST symfile_size;
};
/* Re-establish the jit breakpoint(s). */
gdb_continue_to_breakpoint "continue to before fork" ".*break before fork.*"
# We should have one JIT object loaded.
- gdb_test "maint info jit" " ${::hex}" "jit-ed objfiles before fork"
+ gdb_test "maint info jit" \
+ [multi_line \
+ "jit_code_entry address\\s+symfile address\\s+symfile size\\s*" \
+ "${::hex}\\s+${::hex}\\s+${::decimal}\\s*"] \
+ "jit-ed objfiles before fork"
# Put a breakpoint just after the fork, continue there.
gdb_breakpoint [gdb_get_line_number "break after fork" $::main_srcfile]
# We should still have one JIT object loaded in whatever inferior we are
# currently stopped in, regardless of the mode.
- gdb_test "maint info jit" " ${::hex}" "jit-ed objfiles after fork"
+ gdb_test "maint info jit" \
+ [multi_line \
+ "jit_code_entry address\\s+symfile address\\s+symfile size\\s*" \
+ "${::hex}\\s+${::hex}\\s+${::decimal}\\s*"] \
+ "jit-ed objfiles after fork"
# Delete our breakpoints.
delete_breakpoints
# Switch to the child, verify there is a JIT-ed objfile.
gdb_test "inferior 2" "Switching to inferior 2.*"
- gdb_test "maint info jit" " ${::hex}" "jit-ed objfile in child"
+ gdb_test "maint info jit" \
+ [multi_line \
+ "jit_code_entry address\\s+symfile address\\s+symfile size\\s*" \
+ "${::hex}\\s+${::hex}\\s+${::decimal}\\s*"] \
+ "jit-ed objfile in child"
# Continue child past JIT unload, verify there are no more JIT-ed objfiles.
gdb_continue_to_breakpoint "continue to before return - child" ".*break before return.*"
# Go back to parent, the JIT-ed objfile should still be there.
gdb_test "inferior 1" "Switching to inferior 1.*"
- gdb_test "maint info jit" " ${::hex}" "jit-ed objfile in parent"
+ gdb_test "maint info jit" \
+ [multi_line \
+ "jit_code_entry address\\s+symfile address\\s+symfile size\\s*" \
+ "${::hex}\\s+${::hex}\\s+${::decimal}\\s*"] \
+ "jit-ed objfile in parent"
# Continue parent past JIT unload, verify there are no more JIT-ed objfiles.
gdb_continue_to_breakpoint "continue to before return - parent" ".*break before return.*"
# Switch to the parent, verify there is a JIT-ed objfile.
gdb_test "inferior 1" "Switching to inferior 1.*"
- gdb_test "maint info jit" " ${::hex}" "jit-ed objfile in parent"
+ gdb_test "maint info jit" \
+ [multi_line \
+ "jit_code_entry address\\s+symfile address\\s+symfile size\\s*" \
+ "${::hex}\\s+${::hex}\\s+${::decimal}\\s*"] \
+ "jit-ed objfile in parent"
# Continue parent past JIT unload, verify there are no more JIT-ed objfiles.
gdb_continue_to_breakpoint "continue to before return - parent" ".*break before return.*"
# Go back to child, the JIT-ed objfile should still be there.
gdb_test "inferior 2" "Switching to inferior 2.*"
- gdb_test "maint info jit" " ${::hex}" "jit-ed objfile in child"
+ gdb_test "maint info jit" \
+ [multi_line \
+ "jit_code_entry address\\s+symfile address\\s+symfile size\\s*" \
+ "${::hex}\\s+${::hex}\\s+${::decimal}\\s*"] \
+ "jit-ed objfile in child"
# Continue child past JIT unload, verify there are no more JIT-ed objfiles.
gdb_continue_to_breakpoint "continue to before return - child" ".*break before return.*"