return (cpsr & t_bit) != 0;
}
-/* Determine if FRAME is executing in Thumb mode. */
+/* Determine if FRAME is executing in Thumb mode. FRAME must be an ARM
+ frame. */
int
arm_frame_is_thumb (struct frame_info *frame)
{
- CORE_ADDR cpsr;
- ULONGEST t_bit = arm_psr_thumb_bit (get_frame_arch (frame));
+ /* Check the architecture of FRAME. */
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ gdb_assert (gdbarch_bfd_arch_info (gdbarch)->arch == bfd_arch_arm);
/* Every ARM frame unwinder can unwind the T bit of the CPSR, either
directly (from a signal frame or dummy frame) or by interpreting
the saved LR (from a prologue or DWARF frame). So consult it and
trust the unwinders. */
- cpsr = get_frame_register_unsigned (frame, ARM_PS_REGNUM);
+ CORE_ADDR cpsr = get_frame_register_unsigned (frame, ARM_PS_REGNUM);
+ /* Find and extract the thumb bit. */
+ ULONGEST t_bit = arm_psr_thumb_bit (gdbarch);
return (cpsr & t_bit) != 0;
}
static CORE_ADDR adjust_breakpoint_address (struct gdbarch *gdbarch,
CORE_ADDR bpaddr,
- enum bptype bptype);
+ enum bptype bptype,
+ struct program_space *pspace);
static int watchpoint_locations_match (struct bp_location *loc1,
struct bp_location *loc2);
static CORE_ADDR
adjust_breakpoint_address (struct gdbarch *gdbarch,
- CORE_ADDR bpaddr, enum bptype bptype)
+ CORE_ADDR bpaddr, enum bptype bptype,
+ struct program_space *pspace)
{
+ gdb_assert (pspace != nullptr);
+
if (bptype == bp_watchpoint
|| bptype == bp_hardware_watchpoint
|| bptype == bp_read_watchpoint
{
CORE_ADDR adjusted_bpaddr = bpaddr;
+ /* Some targets have architectural constraints on the placement
+ of breakpoint instructions. Obtain the adjusted address. */
if (gdbarch_adjust_breakpoint_address_p (gdbarch))
{
- /* Some targets have architectural constraints on the placement
- of breakpoint instructions. Obtain the adjusted address. */
- adjusted_bpaddr = gdbarch_adjust_breakpoint_address (gdbarch, bpaddr);
+ /* Targets that implement this adjustment function will likely
+ inspect either the symbol table, target memory at BPADDR, or
+ even state registers, so ensure a suitable thread (and its
+ associated program space) are currently selected. */
+ scoped_restore_current_pspace_and_thread restore_pspace_thread;
+ switch_to_program_space_and_thread (pspace);
+ adjusted_bpaddr
+ = gdbarch_adjust_breakpoint_address (gdbarch, bpaddr);
}
adjusted_bpaddr = address_significant (gdbarch, adjusted_bpaddr);
not want its scan of the location chain to find a breakpoint and
location that's only been partially initialized. */
adjusted_address = adjust_breakpoint_address (loc_gdbarch,
- sal.pc, type);
+ sal.pc, type,
+ sal.pspace);
/* Sort the locations by their ADDRESS. */
new_loc = allocate_location ();
scope_breakpoint->loc->address
= adjust_breakpoint_address (scope_breakpoint->loc->gdbarch,
scope_breakpoint->loc->requested_address,
- scope_breakpoint->type);
+ scope_breakpoint->type,
+ current_program_space);
}
}