mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-22 19:09:31 +08:00
gdb/jit: apply minor cleanup and modernization
gdb/ChangeLog: 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`.
This commit is contained in:

committed by
Tankut Baris Aktemur

parent
c1072906f1
commit
2340e834df
@ -1,3 +1,16 @@
|
|||||||
|
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>
|
2020-07-22 Simon Marchi <simon.marchi@polymtl.ca>
|
||||||
|
|
||||||
* jit.h (struct jiter_objfile_data) <jiter_objfile_data, objfile>:
|
* jit.h (struct jiter_objfile_data) <jiter_objfile_data, objfile>:
|
||||||
|
37
gdb/jit.c
37
gdb/jit.c
@ -289,11 +289,12 @@ jit_read_descriptor (gdbarch *gdbarch,
|
|||||||
jiter_objfile_data *objf_data = jiter->jiter_data.get ();
|
jiter_objfile_data *objf_data = jiter->jiter_data.get ();
|
||||||
gdb_assert (objf_data != nullptr);
|
gdb_assert (objf_data != nullptr);
|
||||||
|
|
||||||
|
CORE_ADDR addr = MSYMBOL_VALUE_ADDRESS (jiter, objf_data->descriptor);
|
||||||
|
|
||||||
if (jit_debug)
|
if (jit_debug)
|
||||||
fprintf_unfiltered (gdb_stdlog,
|
fprintf_unfiltered (gdb_stdlog,
|
||||||
"jit_read_descriptor, descriptor_addr = %s\n",
|
"jit_read_descriptor, descriptor_addr = %s\n",
|
||||||
paddress (gdbarch, MSYMBOL_VALUE_ADDRESS (jiter,
|
paddress (gdbarch, addr));
|
||||||
objf_data->descriptor)));
|
|
||||||
|
|
||||||
/* Figure out how big the descriptor is on the remote and how to read it. */
|
/* Figure out how big the descriptor is on the remote and how to read it. */
|
||||||
ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
|
ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
|
||||||
@ -302,9 +303,7 @@ jit_read_descriptor (gdbarch *gdbarch,
|
|||||||
desc_buf = (gdb_byte *) alloca (desc_size);
|
desc_buf = (gdb_byte *) alloca (desc_size);
|
||||||
|
|
||||||
/* Read the descriptor. */
|
/* Read the descriptor. */
|
||||||
err = target_read_memory (MSYMBOL_VALUE_ADDRESS (jiter,
|
err = target_read_memory (addr, desc_buf, desc_size);
|
||||||
objf_data->descriptor),
|
|
||||||
desc_buf, desc_size);
|
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
printf_unfiltered (_("Unable to read JIT descriptor from "
|
printf_unfiltered (_("Unable to read JIT descriptor from "
|
||||||
@ -867,12 +866,10 @@ jit_find_objf_with_entry_addr (CORE_ADDR entry_addr)
|
|||||||
static void
|
static void
|
||||||
jit_breakpoint_deleted (struct breakpoint *b)
|
jit_breakpoint_deleted (struct breakpoint *b)
|
||||||
{
|
{
|
||||||
struct bp_location *iter;
|
|
||||||
|
|
||||||
if (b->type != bp_jit_event)
|
if (b->type != bp_jit_event)
|
||||||
return;
|
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 ())
|
for (objfile *objf : iter->pspace->objfiles ())
|
||||||
{
|
{
|
||||||
@ -894,8 +891,6 @@ jit_breakpoint_deleted (struct breakpoint *b)
|
|||||||
static void
|
static void
|
||||||
jit_breakpoint_re_set_internal (struct gdbarch *gdbarch, program_space *pspace)
|
jit_breakpoint_re_set_internal (struct gdbarch *gdbarch, program_space *pspace)
|
||||||
{
|
{
|
||||||
jiter_objfile_data *objf_data;
|
|
||||||
|
|
||||||
for (objfile *the_objfile : pspace->objfiles ())
|
for (objfile *the_objfile : pspace->objfiles ())
|
||||||
{
|
{
|
||||||
/* Lookup the registration symbol. If it is missing, then we
|
/* Lookup the registration symbol. If it is missing, then we
|
||||||
@ -912,7 +907,8 @@ jit_breakpoint_re_set_internal (struct gdbarch *gdbarch, program_space *pspace)
|
|||||||
|| BMSYMBOL_VALUE_ADDRESS (desc_symbol) == 0)
|
|| BMSYMBOL_VALUE_ADDRESS (desc_symbol) == 0)
|
||||||
continue;
|
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->register_code = reg_symbol.minsym;
|
||||||
objf_data->descriptor = desc_symbol.minsym;
|
objf_data->descriptor = desc_symbol.minsym;
|
||||||
|
|
||||||
@ -1265,9 +1261,6 @@ void
|
|||||||
jit_event_handler (gdbarch *gdbarch, objfile *jiter)
|
jit_event_handler (gdbarch *gdbarch, objfile *jiter)
|
||||||
{
|
{
|
||||||
struct jit_descriptor descriptor;
|
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
|
/* If we get a JIT breakpoint event for this objfile, it is necessarily a
|
||||||
JITer. */
|
JITer. */
|
||||||
@ -1276,27 +1269,35 @@ jit_event_handler (gdbarch *gdbarch, objfile *jiter)
|
|||||||
/* Read the descriptor from remote memory. */
|
/* Read the descriptor from remote memory. */
|
||||||
if (!jit_read_descriptor (gdbarch, &descriptor, jiter))
|
if (!jit_read_descriptor (gdbarch, &descriptor, jiter))
|
||||||
return;
|
return;
|
||||||
entry_addr = descriptor.relevant_entry;
|
CORE_ADDR entry_addr = descriptor.relevant_entry;
|
||||||
|
|
||||||
/* Do the corresponding action. */
|
/* Do the corresponding action. */
|
||||||
switch (descriptor.action_flag)
|
switch (descriptor.action_flag)
|
||||||
{
|
{
|
||||||
case JIT_NOACTION:
|
case JIT_NOACTION:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JIT_REGISTER:
|
case JIT_REGISTER:
|
||||||
|
{
|
||||||
|
jit_code_entry code_entry;
|
||||||
jit_read_code_entry (gdbarch, entry_addr, &code_entry);
|
jit_read_code_entry (gdbarch, entry_addr, &code_entry);
|
||||||
jit_register_code (gdbarch, entry_addr, &code_entry);
|
jit_register_code (gdbarch, entry_addr, &code_entry);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case JIT_UNREGISTER:
|
case JIT_UNREGISTER:
|
||||||
objf = jit_find_objf_with_entry_addr (entry_addr);
|
{
|
||||||
if (objf == NULL)
|
objfile *jited = jit_find_objf_with_entry_addr (entry_addr);
|
||||||
|
if (jited == nullptr)
|
||||||
printf_unfiltered (_("Unable to find JITed code "
|
printf_unfiltered (_("Unable to find JITed code "
|
||||||
"entry at address: %s\n"),
|
"entry at address: %s\n"),
|
||||||
paddress (gdbarch, entry_addr));
|
paddress (gdbarch, entry_addr));
|
||||||
else
|
else
|
||||||
objf->unlink ();
|
jited->unlink ();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
error (_("Unknown action_flag value in JIT descriptor!"));
|
error (_("Unknown action_flag value in JIT descriptor!"));
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user