From: Simon Marchi Date: Fri, 27 Feb 2026 20:05:17 +0000 (-0500) Subject: gdb: change gdbarch_get_longjmp_target to return bool X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61bef6f99b89eff8996f92a1baba4064cbb19ec6;p=thirdparty%2Fbinutils-gdb.git gdb: change gdbarch_get_longjmp_target to return bool Change-Id: Ib3470d7af11c28335aacd011c9c97f60ad9a9803 Approved-By: Tom Tromey --- diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 6bd974d1f98..de0d7ddb73b 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -2842,7 +2842,7 @@ aarch64_return_value (struct gdbarch *gdbarch, struct value *func_value, /* Implement the "get_longjmp_target" gdbarch method. */ -static int +static bool aarch64_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) { CORE_ADDR jb_addr; @@ -2855,10 +2855,10 @@ aarch64_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) if (target_read_memory (jb_addr + tdep->jb_pc * tdep->jb_elt_size, buf, X_REGISTER_SIZE)) - return 0; + return false; *pc = extract_unsigned_integer (buf, X_REGISTER_SIZE, byte_order); - return 1; + return true; } /* Implement the "gen_return_address" gdbarch method. */ diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c index e89884602db..e2a1929b9dc 100644 --- a/gdb/alpha-tdep.c +++ b/gdb/alpha-tdep.c @@ -820,7 +820,7 @@ alpha_deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc) which we extract the PC (JB_PC) that we will land at. The PC is copied into the "pc". This routine returns true on success. */ -static int +static bool alpha_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) { struct gdbarch *gdbarch = get_frame_arch (frame); @@ -833,10 +833,10 @@ alpha_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) if (target_read_memory (jb_addr + (tdep->jb_pc * tdep->jb_elt_size), raw_buffer, tdep->jb_elt_size)) - return 0; + return false; *pc = extract_unsigned_integer (raw_buffer, tdep->jb_elt_size, byte_order); - return 1; + return true; } diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 25889603620..60e38687e47 100755 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -3443,7 +3443,7 @@ const struct regset amd64_fpregset = address is copied into PC. This routine returns non-zero on success. */ -static int +static bool amd64_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) { gdb_byte buf[8]; @@ -3456,17 +3456,17 @@ amd64_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) /* If JB_PC_OFFSET is -1, we have no way to find out where the longjmp will land. */ if (jb_pc_offset == -1) - return 0; + return false; get_frame_register (frame, AMD64_RDI_REGNUM, buf); jb_addr= extract_typed_address (buf, builtin_type (gdbarch)->builtin_data_ptr); if (target_read_memory (jb_addr + jb_pc_offset, buf, len)) - return 0; + return false; *pc = extract_typed_address (buf, builtin_type (gdbarch)->builtin_func_ptr); - return 1; + return true; } static const int amd64_record_regmap[] = diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c index 9559d64bb14..ff283014e52 100644 --- a/gdb/arc-tdep.c +++ b/gdb/arc-tdep.c @@ -1007,7 +1007,7 @@ arc_store_return_value (struct gdbarch *gdbarch, struct type *type, /* Implement the "get_longjmp_target" gdbarch method. */ -static int +static bool arc_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) { arc_debug_printf ("called"); @@ -1019,11 +1019,11 @@ arc_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) CORE_ADDR jb_addr = get_frame_register_unsigned (frame, ARC_FIRST_ARG_REGNUM); if (target_read_memory (jb_addr + pc_offset, buf, ARC_REGISTER_SIZE)) - return 0; /* Failed to read from memory. */ + return false; /* Failed to read from memory. */ *pc = extract_unsigned_integer (buf, ARC_REGISTER_SIZE, gdbarch_byte_order (gdbarch)); - return 1; + return true; } /* Implement the "return_value" gdbarch method. */ diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 4b77b223edc..dabae0aec0f 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -9300,7 +9300,7 @@ arm_return_value (struct gdbarch *gdbarch, struct value *function, } -static int +static bool arm_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) { struct gdbarch *gdbarch = get_frame_arch (frame); @@ -9313,10 +9313,10 @@ arm_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) if (target_read_memory (jb_addr + tdep->jb_pc * tdep->jb_elt_size, buf, ARM_INT_REGISTER_SIZE)) - return 0; + return false; *pc = extract_unsigned_integer (buf, ARM_INT_REGISTER_SIZE, byte_order); - return 1; + return true; } /* A call to cmse secure entry function "foo" at "a" is modified by GNU ld as "b". diff --git a/gdb/gdbarch-gen.c b/gdb/gdbarch-gen.c index f5f3893311b..2906249d8b4 100644 --- a/gdb/gdbarch-gen.c +++ b/gdb/gdbarch-gen.c @@ -2340,7 +2340,7 @@ gdbarch_get_longjmp_target_p (struct gdbarch *gdbarch) return gdbarch->get_longjmp_target != NULL; } -int +bool gdbarch_get_longjmp_target (struct gdbarch *gdbarch, const frame_info_ptr &frame, CORE_ADDR *pc) { gdb_assert (gdbarch != NULL); diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h index cb4fb63be61..c8048888bae 100644 --- a/gdb/gdbarch-gen.h +++ b/gdb/gdbarch-gen.h @@ -375,14 +375,14 @@ extern bool gdbarch_cannot_store_register (struct gdbarch *gdbarch, int regnum); extern void set_gdbarch_cannot_store_register (struct gdbarch *gdbarch, gdbarch_cannot_store_register_ftype *cannot_store_register); /* Determine the address where a longjmp will land and save this address - in PC. Return nonzero on success. + in PC. Return true on success. FRAME corresponds to the longjmp frame. */ extern bool gdbarch_get_longjmp_target_p (struct gdbarch *gdbarch); -typedef int (gdbarch_get_longjmp_target_ftype) (const frame_info_ptr &frame, CORE_ADDR *pc); -extern int gdbarch_get_longjmp_target (struct gdbarch *gdbarch, const frame_info_ptr &frame, CORE_ADDR *pc); +typedef bool (gdbarch_get_longjmp_target_ftype) (const frame_info_ptr &frame, CORE_ADDR *pc); +extern bool gdbarch_get_longjmp_target (struct gdbarch *gdbarch, const frame_info_ptr &frame, CORE_ADDR *pc); extern void set_gdbarch_get_longjmp_target (struct gdbarch *gdbarch, gdbarch_get_longjmp_target_ftype *get_longjmp_target); typedef int (gdbarch_convert_register_p_ftype) (struct gdbarch *gdbarch, int regnum, struct type *type); diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py index 59a5dda7b6e..d2d902b11f6 100644 --- a/gdb/gdbarch_components.py +++ b/gdb/gdbarch_components.py @@ -728,11 +728,11 @@ Method( Function( comment=""" Determine the address where a longjmp will land and save this address -in PC. Return nonzero on success. +in PC. Return true on success. FRAME corresponds to the longjmp frame. """, - type="int", + type="bool", name="get_longjmp_target", params=[("const frame_info_ptr &", "frame"), ("CORE_ADDR *", "pc")], predicate=True, diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index b74b8bd3994..07eeba4c3c4 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -2562,10 +2562,10 @@ i386_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp) /* Figure out where the longjmp will land. Slurp the args out of the stack. We expect the first arg to be a pointer to the jmp_buf structure from which we extract the address that we will land at. - This address is copied into PC. This routine returns non-zero on + This address is copied into PC. This routine returns true on success. */ -static int +static bool i386_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) { gdb_byte buf[4]; @@ -2578,19 +2578,19 @@ i386_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) /* If JB_PC_OFFSET is -1, we have no way to find out where the longjmp will land. */ if (jb_pc_offset == -1) - return 0; + return false; get_frame_register (frame, I386_ESP_REGNUM, buf); sp = extract_unsigned_integer (buf, 4, byte_order); if (target_read_memory (sp + 4, buf, 4)) - return 0; + return false; jb_addr = extract_unsigned_integer (buf, 4, byte_order); if (target_read_memory (jb_addr + jb_pc_offset, buf, 4)) - return 0; + return false; *pc = extract_unsigned_integer (buf, 4, byte_order); - return 1; + return true; } diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c index 544b9cb39ed..8613062482d 100644 --- a/gdb/m68k-tdep.c +++ b/gdb/m68k-tdep.c @@ -1050,7 +1050,7 @@ m68k_dummy_id (struct gdbarch *gdbarch, const frame_info_ptr &this_frame) we extract the pc (JB_PC) that we will land at. The pc is copied into PC. This routine returns true on success. */ -static int +static bool m68k_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) { gdb_byte *buf; @@ -1062,7 +1062,7 @@ m68k_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) if (tdep->jb_pc < 0) { internal_error (_("m68k_get_longjmp_target: not implemented")); - return 0; + return false; } buf = (gdb_byte *) alloca (gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT); @@ -1070,7 +1070,7 @@ m68k_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) if (target_read_memory (sp + SP_ARG0, /* Offset of first arg on stack. */ buf, gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT)) - return 0; + return false; jb_addr = extract_unsigned_integer (buf, gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT, byte_order); @@ -1078,11 +1078,11 @@ m68k_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) if (target_read_memory (jb_addr + tdep->jb_pc * tdep->jb_elt_size, buf, gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT), byte_order) - return 0; + return false; *pc = extract_unsigned_integer (buf, gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT, byte_order); - return 1; + return true; } diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c index b498bf76655..9fa2b1c2354 100644 --- a/gdb/mips-linux-tdep.c +++ b/gdb/mips-linux-tdep.c @@ -85,13 +85,13 @@ enum /* Figure out where the longjmp will land. We expect the first arg to be a pointer to the jmp_buf structure from which we extract the pc (MIPS_LINUX_JB_PC) that we will land - at. The pc is copied into PC. This routine returns 1 on + at. The pc is copied into PC. This routine returns true on success. */ #define MIPS_LINUX_JB_ELEMENT_SIZE 4 #define MIPS_LINUX_JB_PC 0 -static int +static bool mips_linux_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) { CORE_ADDR jb_addr; @@ -105,13 +105,13 @@ mips_linux_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) + MIPS_LINUX_JB_PC * MIPS_LINUX_JB_ELEMENT_SIZE), buf.data (), gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT)) - return 0; + return false; *pc = extract_unsigned_integer (buf.data (), gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT, byte_order); - return 1; + return true; } /* Transform the bits comprising a 32-bit register to the right size @@ -245,7 +245,7 @@ mips_fill_gregset_wrapper (const struct regset *regset, #define MIPS64_LINUX_JB_PC 0 -static int +static bool mips64_linux_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) { CORE_ADDR jb_addr; @@ -260,13 +260,13 @@ mips64_linux_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) if (target_read_memory (jb_addr + MIPS64_LINUX_JB_PC * element_size, buf, gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT)) - return 0; + return false; *pc = extract_unsigned_integer (buf, gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT, byte_order); - return 1; + return true; } /* Register set support functions. These operate on standard 64-bit diff --git a/gdb/mips-netbsd-tdep.c b/gdb/mips-netbsd-tdep.c index 7ddf3b5d39a..a5bcde20e46 100644 --- a/gdb/mips-netbsd-tdep.c +++ b/gdb/mips-netbsd-tdep.c @@ -253,7 +253,7 @@ static const unsigned char sigtramp_retcode_mipseb[RETCODE_SIZE] = #define NBSD_MIPS_JB_OFFSET(gdbarch) (NBSD_MIPS_JB_PC * \ NBSD_MIPS_JB_ELEMENT_SIZE (gdbarch)) -static int +static bool mipsnbsd_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) { struct gdbarch *gdbarch = get_frame_arch (frame); @@ -267,11 +267,11 @@ mipsnbsd_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) if (target_read_memory (jb_addr + NBSD_MIPS_JB_OFFSET (gdbarch), buf, NBSD_MIPS_JB_ELEMENT_SIZE (gdbarch))) - return 0; + return false; *pc = extract_unsigned_integer (buf, NBSD_MIPS_JB_ELEMENT_SIZE (gdbarch), byte_order); - return 1; + return true; } static bool diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c index 90ed8355775..3da3c3b6195 100644 --- a/gdb/nds32-tdep.c +++ b/gdb/nds32-tdep.c @@ -1823,7 +1823,7 @@ nds32_return_value (struct gdbarch *gdbarch, struct value *func_type, /* Implement the "get_longjmp_target" gdbarch method. */ -static int +static bool nds32_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) { gdb_byte buf[4]; @@ -1834,10 +1834,10 @@ nds32_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) jb_addr = get_frame_register_unsigned (frame, NDS32_R0_REGNUM); if (target_read_memory (jb_addr + 11 * 4, buf, 4)) - return 0; + return false; *pc = extract_unsigned_integer (buf, 4, byte_order); - return 1; + return true; } /* Validate the given TDESC, and fixed-number some registers in it. diff --git a/gdb/sparc64-linux-tdep.c b/gdb/sparc64-linux-tdep.c index 03a6ccbd38b..cb7ce41e5cb 100644 --- a/gdb/sparc64-linux-tdep.c +++ b/gdb/sparc64-linux-tdep.c @@ -306,7 +306,7 @@ sparc64_linux_get_syscall_number (struct gdbarch *gdbarch, /* Implement the "get_longjmp_target" gdbarch method. */ -static int +static bool sparc64_linux_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) { struct gdbarch *gdbarch = get_frame_arch (frame); @@ -335,7 +335,7 @@ sparc64_linux_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) then we need to jump over the instruction at the delay slot. */ if (target_read_memory (jb_addr + 32 + (18 * 8), buf, 8)) - return 0; + return false; *pc = extract_unsigned_integer (buf, 8, gdbarch_byte_order (gdbarch)); @@ -343,7 +343,7 @@ sparc64_linux_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) *pc += 4; /* delay slot insn */ *pc += 4; /* call insn */ - return 1; + return true; } diff --git a/gdb/tic6x-tdep.c b/gdb/tic6x-tdep.c index 1730a75cd47..3661ec12110 100644 --- a/gdb/tic6x-tdep.c +++ b/gdb/tic6x-tdep.c @@ -1099,7 +1099,7 @@ tic6x_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc) /* This is the implementation of gdbarch method get_longjmp_target. */ -static int +static bool tic6x_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) { struct gdbarch *gdbarch = get_frame_arch (frame); @@ -1113,11 +1113,11 @@ tic6x_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) /* JMP_BUF contains 13 elements of type int, and return address is stored in the last slot. */ if (target_read_memory (jb_addr + 12 * 4, buf, 4)) - return 0; + return false; *pc = extract_unsigned_integer (buf, 4, byte_order); - return 1; + return true; } /* This is the implementation of gdbarch method diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c index f30c7366385..c9458fd526b 100644 --- a/gdb/tilegx-tdep.c +++ b/gdb/tilegx-tdep.c @@ -773,7 +773,7 @@ tilegx_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc) /* This is the implementation of gdbarch method get_longjmp_target. */ -static int +static bool tilegx_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) { struct gdbarch *gdbarch = get_frame_arch (frame); @@ -787,11 +787,11 @@ tilegx_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc) has a size of 8 bytes. The return address is stored in the 25th slot. */ if (target_read_memory (jb_addr + 25 * 8, buf, 8)) - return 0; + return false; *pc = extract_unsigned_integer (buf, 8, byte_order); - return 1; + return true; } /* by assigning the 'faultnum' reg in kernel pt_regs with this value,