+2020-07-22 Simon Marchi <simon.marchi@polymtl.ca>
+ Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
+
+ * jit.c (jit_read_descriptor): Define the descriptor address once,
+ use twice.
+ (jit_breakpoint_deleted): Move the declaration of the loop variable
+ `iter` into the loop header.
+ (jit_breakpoint_re_set_internal): Move the declaration of the local
+ variable `objf_data` to the first point of definition.
+ (jit_event_handler): Move the declaration of local variables
+ `code_entry`, `entry_addr`, and `objf` to their first point of use.
+ Rename `objf` to `jited`.
+
2020-07-22 Simon Marchi <simon.marchi@polymtl.ca>
* jit.h (struct jiter_objfile_data) <jiter_objfile_data, objfile>:
jiter_objfile_data *objf_data = jiter->jiter_data.get ();
gdb_assert (objf_data != nullptr);
+ CORE_ADDR addr = MSYMBOL_VALUE_ADDRESS (jiter, objf_data->descriptor);
+
if (jit_debug)
fprintf_unfiltered (gdb_stdlog,
"jit_read_descriptor, descriptor_addr = %s\n",
- paddress (gdbarch, MSYMBOL_VALUE_ADDRESS (jiter,
- objf_data->descriptor)));
+ paddress (gdbarch, addr));
/* Figure out how big the descriptor is on the remote and how to read it. */
ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
desc_buf = (gdb_byte *) alloca (desc_size);
/* Read the descriptor. */
- err = target_read_memory (MSYMBOL_VALUE_ADDRESS (jiter,
- objf_data->descriptor),
- desc_buf, desc_size);
+ err = target_read_memory (addr, desc_buf, desc_size);
if (err)
{
printf_unfiltered (_("Unable to read JIT descriptor from "
static void
jit_breakpoint_deleted (struct breakpoint *b)
{
- struct bp_location *iter;
-
if (b->type != bp_jit_event)
return;
- for (iter = b->loc; iter != NULL; iter = iter->next)
+ for (bp_location *iter = b->loc; iter != nullptr; iter = iter->next)
{
for (objfile *objf : iter->pspace->objfiles ())
{
static void
jit_breakpoint_re_set_internal (struct gdbarch *gdbarch, program_space *pspace)
{
- jiter_objfile_data *objf_data;
-
for (objfile *the_objfile : pspace->objfiles ())
{
/* Lookup the registration symbol. If it is missing, then we
|| BMSYMBOL_VALUE_ADDRESS (desc_symbol) == 0)
continue;
- objf_data = get_jiter_objfile_data (reg_symbol.objfile);
+ jiter_objfile_data *objf_data
+ = get_jiter_objfile_data (reg_symbol.objfile);
objf_data->register_code = reg_symbol.minsym;
objf_data->descriptor = desc_symbol.minsym;
jit_event_handler (gdbarch *gdbarch, objfile *jiter)
{
struct jit_descriptor descriptor;
- struct jit_code_entry code_entry;
- CORE_ADDR entry_addr;
- struct objfile *objf;
/* If we get a JIT breakpoint event for this objfile, it is necessarily a
JITer. */
/* Read the descriptor from remote memory. */
if (!jit_read_descriptor (gdbarch, &descriptor, jiter))
return;
- entry_addr = descriptor.relevant_entry;
+ CORE_ADDR entry_addr = descriptor.relevant_entry;
/* Do the corresponding action. */
switch (descriptor.action_flag)
{
case JIT_NOACTION:
break;
+
case JIT_REGISTER:
- jit_read_code_entry (gdbarch, entry_addr, &code_entry);
- jit_register_code (gdbarch, entry_addr, &code_entry);
- break;
+ {
+ jit_code_entry code_entry;
+ jit_read_code_entry (gdbarch, entry_addr, &code_entry);
+ jit_register_code (gdbarch, entry_addr, &code_entry);
+ break;
+ }
+
case JIT_UNREGISTER:
- objf = jit_find_objf_with_entry_addr (entry_addr);
- if (objf == NULL)
- printf_unfiltered (_("Unable to find JITed code "
- "entry at address: %s\n"),
- paddress (gdbarch, entry_addr));
- else
- objf->unlink ();
+ {
+ objfile *jited = jit_find_objf_with_entry_addr (entry_addr);
+ if (jited == nullptr)
+ printf_unfiltered (_("Unable to find JITed code "
+ "entry at address: %s\n"),
+ paddress (gdbarch, entry_addr));
+ else
+ jited->unlink ();
+
+ break;
+ }
- break;
default:
error (_("Unknown action_flag value in JIT descriptor!"));
break;