X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Farm-tdep.c;h=54c6392ba7b3608d73182aede76bb494c48473bf;hb=fec68fb168d580c188358347f3834072a8960ddc;hp=28fc20c44142e3389340d5845ad127cfc024f7ee;hpb=833b7ab5008b769dca6db6d5ee1d21d33e730132;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 28fc20c441..54c6392ba7 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -1,6 +1,6 @@ /* Common target dependent code for GDB on ARM systems. - Copyright (C) 1988-2016 Free Software Foundation, Inc. + Copyright (C) 1988-2017 Free Software Foundation, Inc. This file is part of GDB. @@ -27,9 +27,10 @@ #include "gdbcmd.h" #include "gdbcore.h" #include "dis-asm.h" /* For register styles. */ +#include "disasm.h" #include "regcache.h" #include "reggroups.h" -#include "doublest.h" +#include "target-float.h" #include "value.h" #include "arch-utils.h" #include "osabi.h" @@ -68,6 +69,10 @@ #include "features/arm/arm-with-vfpv3.c" #include "features/arm/arm-with-neon.c" +#if GDB_SELF_TEST +#include "selftest.h" +#endif + static int arm_debug; /* Macros for setting and testing a bit in a minimal symbol that marks @@ -144,16 +149,6 @@ static const char *const arm_mode_strings[] = static const char *arm_fallback_mode_string = "auto"; static const char *arm_force_mode_string = "auto"; -/* Internal override of the execution mode. -1 means no override, - 0 means override to ARM mode, 1 means override to Thumb mode. - The effect is the same as if arm_force_mode has been set by the - user (except the internal override has precedence over a user's - arm_force_mode override). */ -static int arm_override_mode = -1; - -/* Number of different reg name sets (options). */ -static int num_disassembly_options; - /* The standard register names, and all the valid aliases for them. Note that `fp', `sp' and `pc' are not added in this alias list, because they have been added as builtin user registers in @@ -214,6 +209,9 @@ static const char *const arm_register_names[] = "f4", "f5", "f6", "f7", /* 20 21 22 23 */ "fps", "cpsr" }; /* 24 25 */ +/* Holds the current set of options to be passed to the disassembler. */ +static char *arm_disassembler_options; + /* Valid register name styles. */ static const char **valid_disassembly_styles; @@ -222,14 +220,11 @@ static const char *disassembly_style; /* This is used to keep the bfd arch_info in sync with the disassembly style. */ -static void set_disassembly_style_sfunc(char *, int, +static void set_disassembly_style_sfunc (const char *, int, struct cmd_list_element *); -static void set_disassembly_style (void); - -static void convert_from_extended (const struct floatformat *, const void *, - void *, int); -static void convert_to_extended (const struct floatformat *, void *, - const void *, int); +static void show_disassembly_style_sfunc (struct ui_file *, int, + struct cmd_list_element *, + const char *); static enum register_status arm_neon_quad_read (struct gdbarch *gdbarch, struct regcache *regcache, @@ -302,7 +297,7 @@ int arm_is_thumb (struct regcache *regcache) { ULONGEST cpsr; - ULONGEST t_bit = arm_psr_thumb_bit (get_regcache_arch (regcache)); + ULONGEST t_bit = arm_psr_thumb_bit (regcache->arch ()); cpsr = regcache_raw_get_unsigned (regcache, ARM_PS_REGNUM); @@ -404,8 +399,9 @@ arm_pc_is_thumb (struct gdbarch *gdbarch, CORE_ADDR memaddr) { struct bound_minimal_symbol sym; char type; - struct displaced_step_closure* dsc - = get_displaced_step_closure_by_addr(memaddr); + arm_displaced_step_closure *dsc + = ((arm_displaced_step_closure * ) + get_displaced_step_closure_by_addr (memaddr)); /* If checking the mode of displaced instruction in copy area, the mode should be determined by instruction on the original address. */ @@ -423,10 +419,6 @@ arm_pc_is_thumb (struct gdbarch *gdbarch, CORE_ADDR memaddr) if (IS_THUMB_ADDR (memaddr)) return 1; - /* Respect internal mode override if active. */ - if (arm_override_mode != -1) - return arm_override_mode; - /* If the user wants to override the symbol table, let him. */ if (strcmp (arm_force_mode_string, "arm") == 0) return 0; @@ -581,9 +573,9 @@ skip_prologue_function (struct gdbarch *gdbarch, CORE_ADDR pc, int is_thumb) implementation (this is hand-written ARM assembler in glibc). */ if (!is_thumb - && read_memory_unsigned_integer (pc, 4, byte_order_for_code) + && read_code_unsigned_integer (pc, 4, byte_order_for_code) == 0xe3e00a0f /* mov r0, #0xffff0fff */ - && read_memory_unsigned_integer (pc + 4, 4, byte_order_for_code) + && read_code_unsigned_integer (pc + 4, 4, byte_order_for_code) == 0xe240f01f) /* sub pc, r0, #31 */ return 1; } @@ -656,28 +648,25 @@ thumb_analyze_prologue (struct gdbarch *gdbarch, enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch); int i; pv_t regs[16]; - struct pv_area *stack; - struct cleanup *back_to; CORE_ADDR offset; CORE_ADDR unrecognized_pc = 0; for (i = 0; i < 16; i++) regs[i] = pv_register (i, 0); - stack = make_pv_area (ARM_SP_REGNUM, gdbarch_addr_bit (gdbarch)); - back_to = make_cleanup_free_pv_area (stack); + pv_area stack (ARM_SP_REGNUM, gdbarch_addr_bit (gdbarch)); while (start < limit) { unsigned short insn; - insn = read_memory_unsigned_integer (start, 2, byte_order_for_code); + insn = read_code_unsigned_integer (start, 2, byte_order_for_code); if ((insn & 0xfe00) == 0xb400) /* push { rlist } */ { int regno; int mask; - if (pv_area_store_would_trash (stack, regs[ARM_SP_REGNUM])) + if (stack.store_would_trash (regs[ARM_SP_REGNUM])) break; /* Bits 0-7 contain a mask for registers R0-R7. Bit 8 says @@ -690,7 +679,7 @@ thumb_analyze_prologue (struct gdbarch *gdbarch, { regs[ARM_SP_REGNUM] = pv_add_constant (regs[ARM_SP_REGNUM], -4); - pv_area_store (stack, regs[ARM_SP_REGNUM], 4, regs[regno]); + stack.store (regs[ARM_SP_REGNUM], 4, regs[regno]); } } else if ((insn & 0xff80) == 0xb080) /* sub sp, #imm */ @@ -744,10 +733,10 @@ thumb_analyze_prologue (struct gdbarch *gdbarch, offset = (insn & 0xff) << 2; addr = pv_add_constant (regs[ARM_SP_REGNUM], offset); - if (pv_area_store_would_trash (stack, addr)) + if (stack.store_would_trash (addr)) break; - pv_area_store (stack, addr, 4, regs[regno]); + stack.store (addr, 4, regs[regno]); } else if ((insn & 0xf800) == 0x6000) /* str rd, [rn, #off] */ { @@ -758,10 +747,10 @@ thumb_analyze_prologue (struct gdbarch *gdbarch, offset = bits (insn, 6, 10) << 2; addr = pv_add_constant (regs[rn], offset); - if (pv_area_store_would_trash (stack, addr)) + if (stack.store_would_trash (addr)) break; - pv_area_store (stack, addr, 4, regs[rd]); + stack.store (addr, 4, regs[rd]); } else if (((insn & 0xf800) == 0x7000 /* strb Rd, [Rn, #off] */ || (insn & 0xf800) == 0x8000) /* strh Rd, [Rn, #off] */ @@ -801,8 +790,8 @@ thumb_analyze_prologue (struct gdbarch *gdbarch, { unsigned short inst2; - inst2 = read_memory_unsigned_integer (start + 2, 2, - byte_order_for_code); + inst2 = read_code_unsigned_integer (start + 2, 2, + byte_order_for_code); if ((insn & 0xf800) == 0xf000 && (inst2 & 0xe800) == 0xe800) { @@ -837,7 +826,7 @@ thumb_analyze_prologue (struct gdbarch *gdbarch, pv_t addr = regs[bits (insn, 0, 3)]; int regno; - if (pv_area_store_would_trash (stack, addr)) + if (stack.store_would_trash (addr)) break; /* Calculate offsets of saved registers. */ @@ -845,7 +834,7 @@ thumb_analyze_prologue (struct gdbarch *gdbarch, if (inst2 & (1 << regno)) { addr = pv_add_constant (addr, -4); - pv_area_store (stack, addr, 4, regs[regno]); + stack.store (addr, 4, regs[regno]); } if (insn & 0x0020) @@ -866,12 +855,12 @@ thumb_analyze_prologue (struct gdbarch *gdbarch, else addr = pv_add_constant (addr, -offset); - if (pv_area_store_would_trash (stack, addr)) + if (stack.store_would_trash (addr)) break; - pv_area_store (stack, addr, 4, regs[regno1]); - pv_area_store (stack, pv_add_constant (addr, 4), - 4, regs[regno2]); + stack.store (addr, 4, regs[regno1]); + stack.store (pv_add_constant (addr, 4), + 4, regs[regno2]); if (insn & 0x0020) regs[bits (insn, 0, 3)] = addr; @@ -890,10 +879,10 @@ thumb_analyze_prologue (struct gdbarch *gdbarch, else addr = pv_add_constant (addr, -offset); - if (pv_area_store_would_trash (stack, addr)) + if (stack.store_would_trash (addr)) break; - pv_area_store (stack, addr, 4, regs[regno]); + stack.store (addr, 4, regs[regno]); if (inst2 & 0x0100) regs[bits (insn, 0, 3)] = addr; @@ -908,10 +897,10 @@ thumb_analyze_prologue (struct gdbarch *gdbarch, offset = inst2 & 0xfff; addr = pv_add_constant (regs[bits (insn, 0, 3)], offset); - if (pv_area_store_would_trash (stack, addr)) + if (stack.store_would_trash (addr)) break; - pv_area_store (stack, addr, 4, regs[regno]); + stack.store (addr, 4, regs[regno]); } else if ((insn & 0xffd0) == 0xf880 /* str{bh}.w Rt,[Rn,#imm] */ @@ -1094,10 +1083,7 @@ thumb_analyze_prologue (struct gdbarch *gdbarch, unrecognized_pc = start; if (cache == NULL) - { - do_cleanups (back_to); - return unrecognized_pc; - } + return unrecognized_pc; if (pv_is_register (regs[ARM_FP_REGNUM], ARM_SP_REGNUM)) { @@ -1119,10 +1105,9 @@ thumb_analyze_prologue (struct gdbarch *gdbarch, } for (i = 0; i < 16; i++) - if (pv_area_find_reg (stack, gdbarch, i, &offset)) + if (stack.find_reg (gdbarch, i, &offset)) cache->saved_regs[i].addr = offset; - do_cleanups (back_to); return unrecognized_pc; } @@ -1145,7 +1130,7 @@ arm_analyze_load_stack_chk_guard(CORE_ADDR pc, struct gdbarch *gdbarch, if (is_thumb) { unsigned short insn1 - = read_memory_unsigned_integer (pc, 2, byte_order_for_code); + = read_code_unsigned_integer (pc, 2, byte_order_for_code); if ((insn1 & 0xf800) == 0x4800) /* ldr Rd, #immed */ { @@ -1158,14 +1143,14 @@ arm_analyze_load_stack_chk_guard(CORE_ADDR pc, struct gdbarch *gdbarch, else if ((insn1 & 0xfbf0) == 0xf240) /* movw Rd, #const */ { unsigned short insn2 - = read_memory_unsigned_integer (pc + 2, 2, byte_order_for_code); + = read_code_unsigned_integer (pc + 2, 2, byte_order_for_code); low = EXTRACT_MOVW_MOVT_IMM_T (insn1, insn2); insn1 - = read_memory_unsigned_integer (pc + 4, 2, byte_order_for_code); + = read_code_unsigned_integer (pc + 4, 2, byte_order_for_code); insn2 - = read_memory_unsigned_integer (pc + 6, 2, byte_order_for_code); + = read_code_unsigned_integer (pc + 6, 2, byte_order_for_code); /* movt Rd, #const */ if ((insn1 & 0xfbc0) == 0xf2c0) @@ -1180,7 +1165,7 @@ arm_analyze_load_stack_chk_guard(CORE_ADDR pc, struct gdbarch *gdbarch, else { unsigned int insn - = read_memory_unsigned_integer (pc, 4, byte_order_for_code); + = read_code_unsigned_integer (pc, 4, byte_order_for_code); if ((insn & 0x0e5f0000) == 0x041f0000) /* ldr Rd, [PC, #immed] */ { @@ -1196,7 +1181,7 @@ arm_analyze_load_stack_chk_guard(CORE_ADDR pc, struct gdbarch *gdbarch, low = EXTRACT_MOVW_MOVT_IMM_A (insn); insn - = read_memory_unsigned_integer (pc + 4, 4, byte_order_for_code); + = read_code_unsigned_integer (pc + 4, 4, byte_order_for_code); if ((insn & 0x0ff00000) == 0x03400000) /* movt Rd, #const */ { @@ -1268,7 +1253,7 @@ arm_skip_stack_protector(CORE_ADDR pc, struct gdbarch *gdbarch) { unsigned int destreg; unsigned short insn - = read_memory_unsigned_integer (pc + offset, 2, byte_order_for_code); + = read_code_unsigned_integer (pc + offset, 2, byte_order_for_code); /* Step 2: ldr Rd, [Rn, #immed], encoding T1. */ if ((insn & 0xf800) != 0x6800) @@ -1277,8 +1262,8 @@ arm_skip_stack_protector(CORE_ADDR pc, struct gdbarch *gdbarch) return pc; destreg = bits (insn, 0, 2); - insn = read_memory_unsigned_integer (pc + offset + 2, 2, - byte_order_for_code); + insn = read_code_unsigned_integer (pc + offset + 2, 2, + byte_order_for_code); /* Step 3: str Rd, [Rn, #immed], encoding T1. */ if ((insn & 0xf800) != 0x6000) return pc; @@ -1289,7 +1274,7 @@ arm_skip_stack_protector(CORE_ADDR pc, struct gdbarch *gdbarch) { unsigned int destreg; unsigned int insn - = read_memory_unsigned_integer (pc + offset, 4, byte_order_for_code); + = read_code_unsigned_integer (pc + offset, 4, byte_order_for_code); /* Step 2: ldr Rd, [Rn, #immed], encoding A1. */ if ((insn & 0x0e500000) != 0x04100000) @@ -1298,7 +1283,7 @@ arm_skip_stack_protector(CORE_ADDR pc, struct gdbarch *gdbarch) return pc; destreg = bits (insn, 12, 15); /* Step 3: str Rd, [Rn, #immed], encoding A1. */ - insn = read_memory_unsigned_integer (pc + offset + 4, + insn = read_code_unsigned_integer (pc + offset + 4, 4, byte_order_for_code); if ((insn & 0x0e500000) != 0x04000000) return pc; @@ -1498,8 +1483,6 @@ arm_analyze_prologue (struct gdbarch *gdbarch, int regno; CORE_ADDR offset, current_pc; pv_t regs[ARM_FPS_REGNUM]; - struct pv_area *stack; - struct cleanup *back_to; CORE_ADDR unrecognized_pc = 0; /* Search the prologue looking for instructions that set up the @@ -1514,15 +1497,14 @@ arm_analyze_prologue (struct gdbarch *gdbarch, for (regno = 0; regno < ARM_FPS_REGNUM; regno++) regs[regno] = pv_register (regno, 0); - stack = make_pv_area (ARM_SP_REGNUM, gdbarch_addr_bit (gdbarch)); - back_to = make_cleanup_free_pv_area (stack); + pv_area stack (ARM_SP_REGNUM, gdbarch_addr_bit (gdbarch)); for (current_pc = prologue_start; current_pc < prologue_end; current_pc += 4) { unsigned int insn - = read_memory_unsigned_integer (current_pc, 4, byte_order_for_code); + = read_code_unsigned_integer (current_pc, 4, byte_order_for_code); if (insn == 0xe1a0c00d) /* mov ip, sp */ { @@ -1552,11 +1534,11 @@ arm_analyze_prologue (struct gdbarch *gdbarch, else if ((insn & 0xffff0fff) == 0xe52d0004) /* str Rd, [sp, #-4]! */ { - if (pv_area_store_would_trash (stack, regs[ARM_SP_REGNUM])) + if (stack.store_would_trash (regs[ARM_SP_REGNUM])) break; regs[ARM_SP_REGNUM] = pv_add_constant (regs[ARM_SP_REGNUM], -4); - pv_area_store (stack, regs[ARM_SP_REGNUM], 4, - regs[bits (insn, 12, 15)]); + stack.store (regs[ARM_SP_REGNUM], 4, + regs[bits (insn, 12, 15)]); continue; } else if ((insn & 0xffff0000) == 0xe92d0000) @@ -1566,7 +1548,7 @@ arm_analyze_prologue (struct gdbarch *gdbarch, { int mask = insn & 0xffff; - if (pv_area_store_would_trash (stack, regs[ARM_SP_REGNUM])) + if (stack.store_would_trash (regs[ARM_SP_REGNUM])) break; /* Calculate offsets of saved registers. */ @@ -1575,7 +1557,7 @@ arm_analyze_prologue (struct gdbarch *gdbarch, { regs[ARM_SP_REGNUM] = pv_add_constant (regs[ARM_SP_REGNUM], -4); - pv_area_store (stack, regs[ARM_SP_REGNUM], 4, regs[regno]); + stack.store (regs[ARM_SP_REGNUM], 4, regs[regno]); } } else if ((insn & 0xffff0000) == 0xe54b0000 /* strb rx,[r11,#-n] */ @@ -1617,12 +1599,12 @@ arm_analyze_prologue (struct gdbarch *gdbarch, [sp, -#c]! */ && gdbarch_tdep (gdbarch)->have_fpa_registers) { - if (pv_area_store_would_trash (stack, regs[ARM_SP_REGNUM])) + if (stack.store_would_trash (regs[ARM_SP_REGNUM])) break; regs[ARM_SP_REGNUM] = pv_add_constant (regs[ARM_SP_REGNUM], -12); regno = ARM_F0_REGNUM + ((insn >> 12) & 0x07); - pv_area_store (stack, regs[ARM_SP_REGNUM], 12, regs[regno]); + stack.store (regs[ARM_SP_REGNUM], 12, regs[regno]); } else if ((insn & 0xffbf0fff) == 0xec2d0200 /* sfmfd f0, 4, [sp!] */ @@ -1631,7 +1613,7 @@ arm_analyze_prologue (struct gdbarch *gdbarch, int n_saved_fp_regs; unsigned int fp_start_reg, fp_bound_reg; - if (pv_area_store_would_trash (stack, regs[ARM_SP_REGNUM])) + if (stack.store_would_trash (regs[ARM_SP_REGNUM])) break; if ((insn & 0x800) == 0x800) /* N0 is set */ @@ -1654,8 +1636,8 @@ arm_analyze_prologue (struct gdbarch *gdbarch, for (; fp_start_reg < fp_bound_reg; fp_start_reg++) { regs[ARM_SP_REGNUM] = pv_add_constant (regs[ARM_SP_REGNUM], -12); - pv_area_store (stack, regs[ARM_SP_REGNUM], 12, - regs[fp_start_reg++]); + stack.store (regs[ARM_SP_REGNUM], 12, + regs[fp_start_reg++]); } } else if ((insn & 0xff000000) == 0xeb000000 && cache == NULL) /* bl */ @@ -1735,7 +1717,7 @@ arm_analyze_prologue (struct gdbarch *gdbarch, cache->framesize = framesize; for (regno = 0; regno < ARM_FPS_REGNUM; regno++) - if (pv_area_find_reg (stack, gdbarch, regno, &offset)) + if (stack.find_reg (gdbarch, regno, &offset)) cache->saved_regs[regno].addr = offset; } @@ -1743,7 +1725,6 @@ arm_analyze_prologue (struct gdbarch *gdbarch, fprintf_unfiltered (gdb_stdlog, "Prologue scan stopped at %s\n", paddress (gdbarch, unrecognized_pc)); - do_cleanups (back_to); return unrecognized_pc; } @@ -1818,10 +1799,11 @@ arm_scan_prologue (struct frame_info *this_frame, the callee (or at the present moment if this is the innermost frame). The value stored there should be the address of the stmfd + 8. */ CORE_ADDR frame_loc; - LONGEST return_value; + ULONGEST return_value; frame_loc = get_frame_register_unsigned (this_frame, ARM_FP_REGNUM); - if (!safe_read_memory_integer (frame_loc, 4, byte_order, &return_value)) + if (!safe_read_memory_unsigned_integer (frame_loc, 4, byte_order, + &return_value)) return; else { @@ -2670,19 +2652,19 @@ arm_exidx_unwind_sniffer (const struct frame_unwind *self, ensure this, so that e.g. pthread cancellation works. */ if (arm_frame_is_thumb (this_frame)) { - LONGEST insn; + ULONGEST insn; - if (safe_read_memory_integer (get_frame_pc (this_frame) - 2, 2, - byte_order_for_code, &insn) + if (safe_read_memory_unsigned_integer (get_frame_pc (this_frame) - 2, + 2, byte_order_for_code, &insn) && (insn & 0xff00) == 0xdf00 /* svc */) exc_valid = 1; } else { - LONGEST insn; + ULONGEST insn; - if (safe_read_memory_integer (get_frame_pc (this_frame) - 4, 4, - byte_order_for_code, &insn) + if (safe_read_memory_unsigned_integer (get_frame_pc (this_frame) - 4, + 4, byte_order_for_code, &insn) && (insn & 0x0f000000) == 0x0f000000 /* svc */) exc_valid = 1; } @@ -3394,6 +3376,7 @@ arm_type_align (struct type *t) case TYPE_CODE_SET: case TYPE_CODE_RANGE: case TYPE_CODE_REF: + case TYPE_CODE_RVALUE_REF: case TYPE_CODE_CHAR: case TYPE_CODE_BOOL: return TYPE_LENGTH (t); @@ -4213,56 +4196,6 @@ arm_register_sim_regno (struct gdbarch *gdbarch, int regnum) internal_error (__FILE__, __LINE__, _("Bad REGNUM %d"), regnum); } -/* NOTE: cagney/2001-08-20: Both convert_from_extended() and - convert_to_extended() use floatformat_arm_ext_littlebyte_bigword. - It is thought that this is is the floating-point register format on - little-endian systems. */ - -static void -convert_from_extended (const struct floatformat *fmt, const void *ptr, - void *dbl, int endianess) -{ - DOUBLEST d; - - if (endianess == BFD_ENDIAN_BIG) - floatformat_to_doublest (&floatformat_arm_ext_big, ptr, &d); - else - floatformat_to_doublest (&floatformat_arm_ext_littlebyte_bigword, - ptr, &d); - floatformat_from_doublest (fmt, &d, dbl); -} - -static void -convert_to_extended (const struct floatformat *fmt, void *dbl, const void *ptr, - int endianess) -{ - DOUBLEST d; - - floatformat_to_doublest (fmt, ptr, &d); - if (endianess == BFD_ENDIAN_BIG) - floatformat_from_doublest (&floatformat_arm_ext_big, &d, dbl); - else - floatformat_from_doublest (&floatformat_arm_ext_littlebyte_bigword, - &d, dbl); -} - -/* Like insert_single_step_breakpoint, but make sure we use a breakpoint - of the appropriate mode (as encoded in the PC value), even if this - differs from what would be expected according to the symbol tables. */ - -void -arm_insert_single_step_breakpoint (struct gdbarch *gdbarch, - struct address_space *aspace, - CORE_ADDR pc) -{ - scoped_restore save_override_mode - = make_scoped_restore (&arm_override_mode, - (int) IS_THUMB_ADDR (pc)); - pc = gdbarch_addr_bits_remove (gdbarch, pc); - - insert_single_step_breakpoint (gdbarch, aspace, pc); -} - /* Given BUF, which is OLD_LEN bytes ending at ENDADDR, expand the buffer to be NEW_LEN bytes ending at ENDADDR. Return NULL if an error occurs. BUF is freed. */ @@ -4277,7 +4210,7 @@ extend_buffer_earlier (gdb_byte *buf, CORE_ADDR endaddr, new_buf = (gdb_byte *) xmalloc (new_len); memcpy (new_buf + bytes_to_read, buf, old_len); xfree (buf); - if (target_read_memory (endaddr - new_len, new_buf, bytes_to_read) != 0) + if (target_read_code (endaddr - new_len, new_buf, bytes_to_read) != 0) { xfree (new_buf); return NULL; @@ -4341,7 +4274,7 @@ arm_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR bpaddr) return bpaddr; buf = (gdb_byte *) xmalloc (buf_len); - if (target_read_memory (bpaddr - buf_len, buf, buf_len) != 0) + if (target_read_code (bpaddr - buf_len, buf, buf_len) != 0) return bpaddr; any = 0; for (i = 0; i < buf_len; i += 2) @@ -4481,7 +4414,7 @@ arm_adjust_breakpoint_address (struct gdbarch *gdbarch, CORE_ADDR bpaddr) location. */ ULONGEST -displaced_read_reg (struct regcache *regs, struct displaced_step_closure *dsc, +displaced_read_reg (struct regcache *regs, arm_displaced_step_closure *dsc, int regno) { ULONGEST ret; @@ -4519,7 +4452,7 @@ static int displaced_in_arm_mode (struct regcache *regs) { ULONGEST ps; - ULONGEST t_bit = arm_psr_thumb_bit (get_regcache_arch (regs)); + ULONGEST t_bit = arm_psr_thumb_bit (regs->arch ()); regcache_cooked_read_unsigned (regs, ARM_PS_REGNUM, &ps); @@ -4529,7 +4462,7 @@ displaced_in_arm_mode (struct regcache *regs) /* Write to the PC as from a branch instruction. */ static void -branch_write_pc (struct regcache *regs, struct displaced_step_closure *dsc, +branch_write_pc (struct regcache *regs, arm_displaced_step_closure *dsc, ULONGEST val) { if (!dsc->is_thumb) @@ -4548,7 +4481,7 @@ static void bx_write_pc (struct regcache *regs, ULONGEST val) { ULONGEST ps; - ULONGEST t_bit = arm_psr_thumb_bit (get_regcache_arch (regs)); + ULONGEST t_bit = arm_psr_thumb_bit (regs->arch ()); regcache_cooked_read_unsigned (regs, ARM_PS_REGNUM, &ps); @@ -4575,7 +4508,7 @@ bx_write_pc (struct regcache *regs, ULONGEST val) /* Write to the PC as if from a load instruction. */ static void -load_write_pc (struct regcache *regs, struct displaced_step_closure *dsc, +load_write_pc (struct regcache *regs, arm_displaced_step_closure *dsc, ULONGEST val) { if (DISPLACED_STEPPING_ARCH_VERSION >= 5) @@ -4587,7 +4520,7 @@ load_write_pc (struct regcache *regs, struct displaced_step_closure *dsc, /* Write to the PC as if from an ALU instruction. */ static void -alu_write_pc (struct regcache *regs, struct displaced_step_closure *dsc, +alu_write_pc (struct regcache *regs, arm_displaced_step_closure *dsc, ULONGEST val) { if (DISPLACED_STEPPING_ARCH_VERSION >= 7 && !dsc->is_thumb) @@ -4601,7 +4534,7 @@ alu_write_pc (struct regcache *regs, struct displaced_step_closure *dsc, this is controlled by the WRITE_PC argument. */ void -displaced_write_reg (struct regcache *regs, struct displaced_step_closure *dsc, +displaced_write_reg (struct regcache *regs, arm_displaced_step_closure *dsc, int regno, ULONGEST val, enum pc_write_style write_pc) { if (regno == ARM_PC_REGNUM) @@ -4685,7 +4618,7 @@ insn_references_pc (uint32_t insn, uint32_t bitmask) static int arm_copy_unmodified (struct gdbarch *gdbarch, uint32_t insn, - const char *iname, struct displaced_step_closure *dsc) + const char *iname, arm_displaced_step_closure *dsc) { if (debug_displaced) fprintf_unfiltered (gdb_stdlog, "displaced: copying insn %.8lx, " @@ -4700,7 +4633,7 @@ arm_copy_unmodified (struct gdbarch *gdbarch, uint32_t insn, static int thumb_copy_unmodified_32bit (struct gdbarch *gdbarch, uint16_t insn1, uint16_t insn2, const char *iname, - struct displaced_step_closure *dsc) + arm_displaced_step_closure *dsc) { if (debug_displaced) fprintf_unfiltered (gdb_stdlog, "displaced: copying insn %.4x %.4x, " @@ -4719,7 +4652,7 @@ thumb_copy_unmodified_32bit (struct gdbarch *gdbarch, uint16_t insn1, static int thumb_copy_unmodified_16bit (struct gdbarch *gdbarch, uint16_t insn, const char *iname, - struct displaced_step_closure *dsc) + arm_displaced_step_closure *dsc) { if (debug_displaced) fprintf_unfiltered (gdb_stdlog, "displaced: copying insn %.4x, " @@ -4735,7 +4668,7 @@ thumb_copy_unmodified_16bit (struct gdbarch *gdbarch, uint16_t insn, static void cleanup_preload (struct gdbarch *gdbarch, - struct regcache *regs, struct displaced_step_closure *dsc) + struct regcache *regs, arm_displaced_step_closure *dsc) { displaced_write_reg (regs, dsc, 0, dsc->tmp[0], CANNOT_WRITE_PC); if (!dsc->u.preload.immed) @@ -4744,7 +4677,7 @@ cleanup_preload (struct gdbarch *gdbarch, static void install_preload (struct gdbarch *gdbarch, struct regcache *regs, - struct displaced_step_closure *dsc, unsigned int rn) + arm_displaced_step_closure *dsc, unsigned int rn) { ULONGEST rn_val; /* Preload instructions: @@ -4763,7 +4696,7 @@ install_preload (struct gdbarch *gdbarch, struct regcache *regs, static int arm_copy_preload (struct gdbarch *gdbarch, uint32_t insn, struct regcache *regs, - struct displaced_step_closure *dsc) + arm_displaced_step_closure *dsc) { unsigned int rn = bits (insn, 16, 19); @@ -4783,7 +4716,7 @@ arm_copy_preload (struct gdbarch *gdbarch, uint32_t insn, struct regcache *regs, static int thumb2_copy_preload (struct gdbarch *gdbarch, uint16_t insn1, uint16_t insn2, - struct regcache *regs, struct displaced_step_closure *dsc) + struct regcache *regs, arm_displaced_step_closure *dsc) { unsigned int rn = bits (insn1, 0, 3); unsigned int u_bit = bit (insn1, 7); @@ -4833,7 +4766,7 @@ thumb2_copy_preload (struct gdbarch *gdbarch, uint16_t insn1, uint16_t insn2, static void install_preload_reg(struct gdbarch *gdbarch, struct regcache *regs, - struct displaced_step_closure *dsc, unsigned int rn, + arm_displaced_step_closure *dsc, unsigned int rn, unsigned int rm) { ULONGEST rn_val, rm_val; @@ -4858,7 +4791,7 @@ install_preload_reg(struct gdbarch *gdbarch, struct regcache *regs, static int arm_copy_preload_reg (struct gdbarch *gdbarch, uint32_t insn, struct regcache *regs, - struct displaced_step_closure *dsc) + arm_displaced_step_closure *dsc) { unsigned int rn = bits (insn, 16, 19); unsigned int rm = bits (insn, 0, 3); @@ -4882,7 +4815,7 @@ arm_copy_preload_reg (struct gdbarch *gdbarch, uint32_t insn, static void cleanup_copro_load_store (struct gdbarch *gdbarch, struct regcache *regs, - struct displaced_step_closure *dsc) + arm_displaced_step_closure *dsc) { ULONGEST rn_val = displaced_read_reg (regs, dsc, 0); @@ -4894,7 +4827,7 @@ cleanup_copro_load_store (struct gdbarch *gdbarch, static void install_copro_load_store (struct gdbarch *gdbarch, struct regcache *regs, - struct displaced_step_closure *dsc, + arm_displaced_step_closure *dsc, int writeback, unsigned int rn) { ULONGEST rn_val; @@ -4922,7 +4855,7 @@ install_copro_load_store (struct gdbarch *gdbarch, struct regcache *regs, static int arm_copy_copro_load_store (struct gdbarch *gdbarch, uint32_t insn, struct regcache *regs, - struct displaced_step_closure *dsc) + arm_displaced_step_closure *dsc) { unsigned int rn = bits (insn, 16, 19); @@ -4943,7 +4876,7 @@ arm_copy_copro_load_store (struct gdbarch *gdbarch, uint32_t insn, static int thumb2_copy_copro_load_store (struct gdbarch *gdbarch, uint16_t insn1, uint16_t insn2, struct regcache *regs, - struct displaced_step_closure *dsc) + arm_displaced_step_closure *dsc) { unsigned int rn = bits (insn1, 0, 3); @@ -4971,7 +4904,7 @@ thumb2_copy_copro_load_store (struct gdbarch *gdbarch, uint16_t insn1, static void cleanup_branch (struct gdbarch *gdbarch, struct regcache *regs, - struct displaced_step_closure *dsc) + arm_displaced_step_closure *dsc) { uint32_t status = displaced_read_reg (regs, dsc, ARM_PS_REGNUM); int branch_taken = condition_true (dsc->u.branch.cond, status); @@ -5002,7 +4935,7 @@ cleanup_branch (struct gdbarch *gdbarch, struct regcache *regs, static void install_b_bl_blx (struct gdbarch *gdbarch, struct regcache *regs, - struct displaced_step_closure *dsc, + arm_displaced_step_closure *dsc, unsigned int cond, int exchange, int link, long offset) { /* Implement "BL