"gcs_features_locked",
};
-static int aarch64_stack_frame_destroyed_p (struct gdbarch *, CORE_ADDR);
+static bool aarch64_stack_frame_destroyed_p (struct gdbarch *, CORE_ADDR);
/* AArch64 prologue cache structure. */
struct aarch64_prologue_cache
/* Implement the stack_frame_destroyed_p gdbarch method. */
-static int
+static bool
aarch64_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
CORE_ADDR func_start, func_end;
if (!find_pc_partial_function (pc, NULL, &func_start, &func_end))
- return 0;
+ return false;
enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch);
ULONGEST insn_from_memory;
if (!safe_read_memory_unsigned_integer (pc, 4, byte_order_for_code,
&insn_from_memory))
- return 0;
+ return false;
uint32_t insn = insn_from_memory;
aarch64_inst inst;
if (aarch64_decode_insn (insn, &inst, 1, nullptr) != 0)
- return 0;
+ return false;
return streq (inst.opcode->name, "ret");
}
/* Implement core of the stack_frame_destroyed_p gdbarch method. */
-static int
+static bool
amd64_stack_frame_destroyed_p_1 (struct gdbarch *gdbarch, CORE_ADDR pc)
{
gdb_byte insn;
return pc > epilogue;
if (target_read_memory (pc, &insn, 1))
- return 0; /* Can't read memory at pc. */
+ return false; /* Can't read memory at pc. */
if (insn != 0xc3) /* 'ret' instruction. */
- return 0;
+ return false;
- return 1;
+ return true;
}
/* Normal frames, but in a function epilogue. */
follow any instruction such as 'leave' or 'pop %ebp' that destroys
the function's stack frame. */
-static int
+static bool
amd64_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
struct compunit_symtab *cust = find_compunit_symtab_for_pc (pc);
&& producer_is_llvm (cust->producer ()))
return amd64_stack_frame_destroyed_p_1 (gdbarch, pc);
- return 0;
+ return false;
}
static int
return false;
}
-int
+bool
generic_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
- return 0;
+ return false;
}
bool
CORE_ADDR pc,
const char *name);
-extern int generic_stack_frame_destroyed_p (struct gdbarch *gdbarch,
- CORE_ADDR pc);
+extern bool generic_stack_frame_destroyed_p (struct gdbarch *gdbarch,
+ CORE_ADDR pc);
extern bool default_code_of_frame_writable (struct gdbarch *gdbarch,
const frame_info_ptr &frame);
return arm_prologue_prev_register (this_frame, this_cache, regnum);
}
-static int arm_stack_frame_destroyed_p_1 (struct gdbarch *gdbarch,
- CORE_ADDR pc);
-static int thumb_stack_frame_destroyed_p (struct gdbarch *gdbarch,
- CORE_ADDR pc);
+static bool arm_stack_frame_destroyed_p_1 (struct gdbarch *gdbarch,
+ CORE_ADDR pc);
+static bool thumb_stack_frame_destroyed_p (struct gdbarch *gdbarch,
+ CORE_ADDR pc);
/* Implementation of function hook 'sniffer' in
'struct frame_uwnind' for epilogue unwinder. */
/* Implement the stack_frame_destroyed_p gdbarch method. */
-static int
+static bool
thumb_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch);
unsigned int insn, insn2;
- int found_return = 0, found_stack_adjust = 0;
+ int found_return = 0;
+ bool found_stack_adjust = false;
CORE_ADDR func_start, func_end;
CORE_ADDR scan_pc;
gdb_byte buf[4];
if (!find_pc_partial_function (pc, NULL, &func_start, &func_end))
- return 0;
+ return false;
/* The epilogue is a sequence of instructions along the following lines:
}
if (!found_return)
- return 0;
+ return false;
/* Since any instruction in the epilogue sequence, with the possible
exception of return itself, updates the stack pointer, we need to
too much about false positives. */
if (pc - 4 < func_start)
- return 0;
+ return false;
if (target_read_memory (pc - 4, buf, 4))
- return 0;
+ return false;
insn = extract_unsigned_integer (buf, 2, byte_order_for_code);
insn2 = extract_unsigned_integer (buf + 2, 2, byte_order_for_code);
if (thumb_instruction_restores_sp (insn2))
- found_stack_adjust = 1;
+ found_stack_adjust = true;
else if (insn == 0xe8bd) /* ldm.w sp!, <registers> */
- found_stack_adjust = 1;
+ found_stack_adjust = true;
else if (insn == 0xf85d /* ldr.w <Rt>, [sp], #4 */
&& (insn2 & 0x0fff) == 0x0b04)
- found_stack_adjust = 1;
+ found_stack_adjust = true;
else if ((insn & 0xffbf) == 0xecbd /* vldm sp!, <list> */
&& (insn2 & 0x0e00) == 0x0a00)
- found_stack_adjust = 1;
+ found_stack_adjust = true;
return found_stack_adjust;
}
-static int
+static bool
arm_stack_frame_destroyed_p_1 (struct gdbarch *gdbarch, CORE_ADDR pc)
{
enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch);
/* Implement the stack_frame_destroyed_p gdbarch method. */
-static int
+static bool
arm_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
if (arm_pc_is_thumb (gdbarch, pc))
/* Detect whether PC is at a point where the stack frame has been
destroyed. */
-static int
+static bool
csky_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
unsigned int insn;
CORE_ADDR func_start, func_end;
if (!find_pc_partial_function (pc, NULL, &func_start, &func_end))
- return 0;
+ return false;
bool fp_saved = false;
int insn_len;
return pc >= addr;
}
}
- return 0;
+ return false;
}
/* Implement the skip_prologue gdbarch hook. */
gdbarch->in_indirect_branch_thunk = in_indirect_branch_thunk;
}
-int
+bool
gdbarch_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR addr)
{
gdb_assert (gdbarch != NULL);
/* A target might have problems with watchpoints as soon as the stack
frame of the current function has been destroyed. This mostly happens
as the first action in a function's epilogue. stack_frame_destroyed_p()
- is defined to return a non-zero value if either the given addr is one
+ is defined to return true if either the given addr is one
instruction after the stack destroying instruction up to the trailing
return instruction or if we can figure out that the stack frame has
already been invalidated regardless of the value of addr. Targets
which don't suffer from that problem could just let this functionality
untouched. */
-typedef int (gdbarch_stack_frame_destroyed_p_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr);
-extern int gdbarch_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR addr);
+typedef bool (gdbarch_stack_frame_destroyed_p_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr);
+extern bool gdbarch_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR addr);
extern void set_gdbarch_stack_frame_destroyed_p (struct gdbarch *gdbarch, gdbarch_stack_frame_destroyed_p_ftype *stack_frame_destroyed_p);
/* Process an ELF symbol in the minimal symbol table in a backend-specific
A target might have problems with watchpoints as soon as the stack
frame of the current function has been destroyed. This mostly happens
as the first action in a function's epilogue. stack_frame_destroyed_p()
-is defined to return a non-zero value if either the given addr is one
+is defined to return true if either the given addr is one
instruction after the stack destroying instruction up to the trailing
return instruction or if we can figure out that the stack frame has
already been invalidated regardless of the value of addr. Targets
which don't suffer from that problem could just let this functionality
untouched.
""",
- type="int",
+ type="bool",
name="stack_frame_destroyed_p",
params=[("CORE_ADDR", "addr")],
predefault="generic_stack_frame_destroyed_p",
We do not assume that the epilogue is at the end of a function as we can
also have return sequences in the middle of a function. */
-static int
+static bool
hppa_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
status = target_read_memory (pc, buf, 4);
if (status != 0)
- return 0;
+ return false;
inst = extract_unsigned_integer (buf, 4, byte_order);
We are destroying a stack frame if the offset is negative. */
if ((inst & 0xffffc000) == 0x37de0000
&& hppa_extract_14 (inst) < 0)
- return 1;
+ return true;
/* ldw,mb D(sp),X or ldd,mb D(sp),X */
if (((inst & 0x0fc010e0) == 0x0fc010e0
|| (inst & 0x0fc010e0) == 0x0fc010e0)
&& hppa_extract_14 (inst) < 0)
- return 1;
+ return true;
/* bv %r0(%rp) or bv,n %r0(%rp) */
if (inst == 0xe840c000 || inst == 0xe840c002)
- return 1;
+ return true;
- return 0;
+ return false;
}
constexpr gdb_byte hppa_break_insn[] = {0x00, 0x01, 0x00, 0x04};
follow any instruction such as 'leave' or 'pop %ebp' that destroys
the function's stack frame. */
-static int
+static bool
i386_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
gdb_byte insn;
if (target_read_memory (pc, &insn, 1))
- return 0; /* Can't read memory at pc. */
+ return false; /* Can't read memory at pc. */
if (insn != 0xc3) /* 'ret' instruction. */
- return 0;
+ return false;
- return 1;
+ return true;
}
static int
/* Implement the stack_frame_destroyed_p gdbarch method (32-bit version).
This is a helper function for mips_stack_frame_destroyed_p. */
-static int
+static bool
mips32_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
CORE_ADDR func_addr = 0, func_end = 0;
if (addr < func_addr + 4)
addr = func_addr + 4;
if (pc < addr)
- return 0;
+ return false;
for (; pc < func_end; pc += MIPS_INSN32_SIZE)
{
&& high_word != 0x67bd /* daddiu $sp,$sp,offset */
&& inst != 0x03e00008 /* jr $ra */
&& inst != 0x00000000) /* nop */
- return 0;
+ return false;
}
- return 1;
+ return true;
}
- return 0;
+ return false;
}
/* Implement the stack_frame_destroyed_p gdbarch method (microMIPS version).
This is a helper function for mips_stack_frame_destroyed_p. */
-static int
+static bool
micromips_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
CORE_ADDR func_addr = 0;
int loc;
if (!find_pc_partial_function (pc, NULL, &func_addr, &func_end))
- return 0;
+ return false;
/* The microMIPS epilogue is max. 12 bytes long. */
addr = func_end - 12;
if (addr < func_addr + 2)
addr = func_addr + 2;
if (pc < addr)
- return 0;
+ return false;
for (; pc < func_end; pc += loc)
{
/* (D)ADDIU $sp, imm */
&& offset >= 0)
break;
- return 0;
+ return false;
default:
- return 0;
+ return false;
}
break;
if (sreg == 0 && dreg == 0)
/* MOVE $zero, $zero aka NOP */
break;
- return 0;
+ return false;
case 0x11: /* POOL16C: bits 010001 */
if (b5s5_op (insn) == 0x18
&& b0s5_reg (insn) == MIPS_RA_REGNUM))
/* JRC $ra */
break;
- return 0;
+ return false;
case 0x13: /* POOL16D: bits 010011 */
offset = micromips_decode_imm9 (b1s9_imm (insn));
/* ADDIUSP: bits 010011 1 */
&& offset > 0)
break;
- return 0;
+ return false;
default:
- return 0;
+ return false;
}
}
}
- return 1;
+ return true;
}
/* Implement the stack_frame_destroyed_p gdbarch method (16-bit version).
This is a helper function for mips_stack_frame_destroyed_p. */
-static int
+static bool
mips16_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
CORE_ADDR func_addr = 0, func_end = 0;
if (addr < func_addr + 4)
addr = func_addr + 4;
if (pc < addr)
- return 0;
+ return false;
for (; pc < func_end; pc += MIPS_INSN16_SIZE)
{
&& inst != 0xe820 /* jr $ra */
&& inst != 0xe8a0 /* jrc $ra */
&& inst != 0x6500) /* nop */
- return 0;
+ return false;
}
- return 1;
+ return true;
}
- return 0;
+ return false;
}
/* Implement the stack_frame_destroyed_p gdbarch method.
The epilogue is defined here as the area at the end of a function,
after an instruction which destroys the function's stack frame. */
-static int
+static bool
mips_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
if (mips_pc_is_mips16 (gdbarch, pc))
/* Implement the "stack_frame_destroyed_p" gdbarch method. */
-static int
+static bool
nds32_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR addr)
{
nds32_gdbarch_tdep *tdep = gdbarch_tdep<nds32_gdbarch_tdep> (gdbarch);
}
if (insn_type == INSN_NORMAL || insn_type == INSN_RESET_SP)
- return 0;
+ return false;
/* Search the required 'return' instruction within the following reasonable
instructions. */
ret_found = nds32_analyze_epilogue (gdbarch, addr, NULL);
if (ret_found == 0)
- return 0;
+ return false;
/* Scan backwards to make sure that the last instruction has adjusted
stack. Both a 16-bit and a 32-bit instruction will be tried. This is
insn_type = nds32_analyze_epilogue_insn16 (insn >> 16, NULL);
if (insn_type == INSN_RECOVER)
- return 1;
+ return true;
}
insn = read_memory_unsigned_integer (addr - 4, 4, BFD_ENDIAN_BIG);
insn_type = nds32_analyze_epilogue_insn32 (abi_use_fpr, insn, NULL);
if (insn_type == INSN_RECOVER || insn_type == INSN_RESET_SP)
- return 1;
+ return true;
}
- return 0;
+ return false;
}
/* Implement the "sniffer" frame_unwind method. */
/* Implement the stack_frame_destroyed_p gdbarch method. */
-static int
+static bool
rs6000_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
return rs6000_in_function_epilogue_frame_p (get_current_frame (),
/* Implement the stack_frame_destroyed_p gdbarch method. */
-static int
+static bool
s390_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
int word_size = gdbarch_ptr_bit (gdbarch) / 8;
&& !target_read_memory (pc - 4, insn, 4)
&& is_rs (insn, op_lm, &r1, &r3, &d2, &b2)
&& r3 == S390_SP_REGNUM - S390_R0_REGNUM)
- return 1;
+ return true;
if (word_size == 4
&& !target_read_memory (pc - 6, insn, 6)
&& is_rsy (insn, op1_lmy, op2_lmy, &r1, &r3, &d2, &b2)
&& r3 == S390_SP_REGNUM - S390_R0_REGNUM)
- return 1;
+ return true;
if (word_size == 8
&& !target_read_memory (pc - 6, insn, 6)
&& is_rsy (insn, op1_lmg, op2_lmg, &r1, &r3, &d2, &b2)
&& r3 == S390_SP_REGNUM - S390_R0_REGNUM)
- return 1;
+ return true;
- return 0;
+ return false;
}
/* Implement unwind_pc gdbarch method. */
either on the `ret' instruction itself or after an instruction which
destroys the function's stack frame. */
-static int
+static bool
sh_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
if (addr < func_addr + 4)
addr = func_addr + 4;
if (pc < addr)
- return 0;
+ return false;
/* First search forward until hitting an rts. */
while (addr < func_end
&& !IS_RTS (read_memory_unsigned_integer (addr, 2, byte_order)))
addr += 2;
if (addr >= func_end)
- return 0;
+ return false;
/* At this point we should find a mov.l @r15+,r14 instruction,
either before or after the rts. If not, then the function has
addr -= 2;
else if (!IS_RESTORE_FP (read_memory_unsigned_integer (addr + 2, 2,
byte_order)))
- return 0;
+ return false;
inst = read_memory_unsigned_integer (addr - 2, 2, byte_order);
addr -= 4;
if (pc >= addr)
- return 1;
+ return true;
}
- return 0;
+ return false;
}
\f
/* Implement the stack_frame_destroyed_p gdbarch method. */
-int
+bool
sparc_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
/* This function must return true if we are one instruction after an
extern struct sparc_frame_cache *
sparc32_frame_cache (const frame_info_ptr &this_frame, void **this_cache);
-extern int
- sparc_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc);
-
-\f
+extern bool sparc_stack_frame_destroyed_p (struct gdbarch *gdbarch,
+ CORE_ADDR pc);
extern void sparc_supply_rwindow (struct regcache *regcache,
CORE_ADDR sp, int regnum);
/* This is the implementation of gdbarch method stack_frame_destroyed_p. */
-static int
+static bool
tic6x_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
unsigned long inst = tic6x_fetch_instruction (gdbarch, pc);
INST_S_BIT (inst),
INST_X_BIT (inst));
if (src2 == TIC6X_RA_REGNUM)
- return 1;
+ return true;
}
- return 0;
+ return false;
}
/* This is the implementation of gdbarch method get_longjmp_target. */
/* This is the implementation of gdbarch method stack_frame_destroyed_p. */
-static int
+static bool
tilegx_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
CORE_ADDR func_addr = 0, func_end = 0;
/* FIXME: Find the actual epilogue. */
/* HACK: Just assume the final bundle is the "ret" instruction". */
if (pc > addr)
- return 1;
+ return true;
}
- return 0;
+ return false;
}
/* This is the implementation of gdbarch method get_longjmp_target. */
either on the `ret' instruction itself or after an instruction which
destroys the function's stack frame. */
-static int
+static bool
xstormy16_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
/* The Xstormy16 epilogue is max. 14 bytes long. */
if (pc < func_end - 7 * xstormy16_inst_size)
- return 0;
+ return false;
/* Check if we're on a `ret' instruction. Otherwise it's
too dangerous to proceed. */
inst = read_memory_unsigned_integer (addr,
xstormy16_inst_size, byte_order);
if (inst != 0x0003)
- return 0;
+ return false;
while ((addr -= xstormy16_inst_size) >= func_addr)
{
addr -= xstormy16_inst_size;
break;
}
- return 0;
+ return false;
}
if (pc > addr)
- return 1;
+ return true;
}
- return 0;
+ return false;
}
constexpr gdb_byte xstormy16_break_insn[] = { 0x06, 0x0 };