From: Tankut Baris Aktemur Date: Mon, 22 Jun 2020 12:03:33 +0000 (+0200) Subject: gdb/jit: return bool in jit_breakpoint_re_set_internal and jit_read_descriptor X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bd920864f3dc2cad376989a642ab774aef6b2fce;p=binutils-gdb.git gdb/jit: return bool in jit_breakpoint_re_set_internal and jit_read_descriptor This is a minor refactoring that converts the return type of jit_read_descriptor and jit_breakpoint_re_set_internal functions from 'int' to 'bool'. The return value logic of jit_breakpoint_re_set_internal has been reversed. With this patch it now returns true if the jit breakpoint has been successfully initialized. gdb/ChangeLog: 2020-06-22 Tankut Baris Aktemur * jit.c (jit_read_descriptor): Use bool as the return type. (jit_breakpoint_re_set_internal): Use bool as the return type. Invert the return value logic; return true if the jit breakpoint has been successfully initialized. (jit_inferior_init): Update the call to jit_breakpoint_re_set_internal. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b4473f8bd1b..022b797d47b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2020-06-22 Tankut Baris Aktemur + + * jit.c (jit_read_descriptor): Use bool as the return type. + (jit_breakpoint_re_set_internal): Use bool as the return type. + Invert the return value logic; return true if the jit breakpoint + has been successfully initialized. + (jit_inferior_init): Update the call to + jit_breakpoint_re_set_internal. + 2020-06-22 Pedro Alves PR gdb/25939 diff --git a/gdb/jit.c b/gdb/jit.c index 1b5ef46469e..e8a843de390 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -329,9 +329,9 @@ get_jit_program_space_data () } /* Helper function for reading the global JIT descriptor from remote - memory. Returns 1 if all went well, 0 otherwise. */ + memory. Returns true if all went well, false otherwise. */ -static int +static bool jit_read_descriptor (struct gdbarch *gdbarch, struct jit_descriptor *descriptor, struct jit_program_space_data *ps_data) @@ -345,10 +345,10 @@ jit_read_descriptor (struct gdbarch *gdbarch, struct jit_objfile_data *objf_data; if (ps_data->objfile == NULL) - return 0; + return false; objf_data = get_jit_objfile_data (ps_data->objfile); if (objf_data->descriptor == NULL) - return 0; + return false; if (jit_debug) fprintf_unfiltered (gdb_stdlog, @@ -370,7 +370,7 @@ jit_read_descriptor (struct gdbarch *gdbarch, { printf_unfiltered (_("Unable to read JIT descriptor from " "remote memory\n")); - return 0; + return false; } /* Fix the endianness to match the host. */ @@ -381,7 +381,7 @@ jit_read_descriptor (struct gdbarch *gdbarch, descriptor->first_entry = extract_typed_address (&desc_buf[8 + ptr_size], ptr_type); - return 1; + return true; } /* Helper function for reading a JITed code entry from remote memory. */ @@ -950,9 +950,9 @@ jit_breakpoint_deleted (struct breakpoint *b) } /* (Re-)Initialize the jit breakpoint if necessary. - Return 0 if the jit breakpoint has been successfully initialized. */ + Return true if the jit breakpoint has been successfully initialized. */ -static int +static bool jit_breakpoint_re_set_internal (struct gdbarch *gdbarch, struct jit_program_space_data *ps_data) { @@ -968,13 +968,13 @@ jit_breakpoint_re_set_internal (struct gdbarch *gdbarch, reg_symbol = lookup_bound_minimal_symbol (jit_break_name); if (reg_symbol.minsym == NULL || BMSYMBOL_VALUE_ADDRESS (reg_symbol) == 0) - return 1; + return false; desc_symbol = lookup_minimal_symbol (jit_descriptor_name, NULL, reg_symbol.objfile); if (desc_symbol.minsym == NULL || BMSYMBOL_VALUE_ADDRESS (desc_symbol) == 0) - return 1; + return false; objf_data = get_jit_objfile_data (reg_symbol.objfile); objf_data->register_code = reg_symbol.minsym; @@ -994,7 +994,7 @@ jit_breakpoint_re_set_internal (struct gdbarch *gdbarch, paddress (gdbarch, addr)); if (ps_data->cached_code_address == addr) - return 0; + return true; /* Delete the old breakpoint. */ if (ps_data->jit_breakpoint != NULL) @@ -1004,7 +1004,7 @@ jit_breakpoint_re_set_internal (struct gdbarch *gdbarch, ps_data->cached_code_address = addr; ps_data->jit_breakpoint = create_jit_event_breakpoint (gdbarch, addr); - return 0; + return true; } /* The private data passed around in the frame unwind callback @@ -1252,7 +1252,7 @@ jit_inferior_init (struct gdbarch *gdbarch) jit_prepend_unwinder (gdbarch); ps_data = get_jit_program_space_data (); - if (jit_breakpoint_re_set_internal (gdbarch, ps_data) != 0) + if (!jit_breakpoint_re_set_internal (gdbarch, ps_data)) return; /* Read the descriptor so we can check the version number and load