static struct disassemble_info gdb_disassemble_info (struct gdbarch *gdbarch, struct ui_file *file) { struct disassemble_info di; init_disassemble_info (&di, file, fprintf_disasm); di.flavour = bfd_target_unknown_flavour; di.memory_error_func = dis_asm_memory_error; di.print_address_func = dis_asm_print_address; /* NOTE: cagney/2003-04-28: The original code, from the old Insight disassembler had a local optomization here. By default it would access the executable file, instead of the target memory (there was a growing list of exceptions though). Unfortunately, the heuristic was flawed. Commands like "disassemble &variable" didn't work as they relied on the access going to the target. Further, it has been supperseeded by trust-read-only-sections (although that should be superseeded by target_trust..._p()). */ di.read_memory_func = dis_asm_read_memory; di.arch = gdbarch_bfd_arch_info (gdbarch)->arch; di.mach = gdbarch_bfd_arch_info (gdbarch)->mach; di.endian = gdbarch_byte_order (gdbarch); di.endian_code = gdbarch_byte_order_for_code (gdbarch); di.application_data = gdbarch; disassemble_init_for_target (&di); return di; }
static LONGEST arm_linux_get_syscall_number (struct gdbarch *gdbarch, ptid_t ptid) { struct regcache *regs = get_thread_regcache (ptid); struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); ULONGEST pc; ULONGEST cpsr; ULONGEST t_bit = arm_psr_thumb_bit (gdbarch); int is_thumb; ULONGEST svc_number = -1; regcache_cooked_read_unsigned (regs, ARM_PC_REGNUM, &pc); regcache_cooked_read_unsigned (regs, ARM_PS_REGNUM, &cpsr); is_thumb = (cpsr & t_bit) != 0; if (is_thumb) { regcache_cooked_read_unsigned (regs, 7, &svc_number); } else { enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch); /* PC gets incremented before the syscall-stop, so read the previous instruction. */ unsigned long this_instr = read_memory_unsigned_integer (pc - 4, 4, byte_order_for_code); unsigned long svc_operand = (0x00ffffff & this_instr); if (svc_operand) { /* OABI */ svc_number = svc_operand - 0x900000; } else { /* EABI */ regcache_cooked_read_unsigned (regs, 7, &svc_number); } } return svc_number; }
static CORE_ADDR arm_linux_syscall_next_pc (struct frame_info *frame) { CORE_ADDR pc = get_frame_pc (frame); CORE_ADDR return_addr = 0; int is_thumb = arm_frame_is_thumb (frame); ULONGEST svc_number = 0; if (is_thumb) { svc_number = get_frame_register_unsigned (frame, 7); return_addr = pc + 2; } else { struct gdbarch *gdbarch = get_frame_arch (frame); enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch); unsigned long this_instr = read_memory_unsigned_integer (pc, 4, byte_order_for_code); unsigned long svc_operand = (0x00ffffff & this_instr); if (svc_operand) /* OABI. */ { svc_number = svc_operand - 0x900000; } else /* EABI. */ { svc_number = get_frame_register_unsigned (frame, 7); } return_addr = pc + 4; } arm_linux_sigreturn_return_addr (frame, svc_number, &return_addr, &is_thumb); /* Addresses for calling Thumb functions have the bit 0 set. */ if (is_thumb) return_addr |= 1; return return_addr; }
static void gdb_buffered_insn_length_init_dis (struct gdbarch *gdbarch, struct disassemble_info *di, const gdb_byte *insn, int max_len, CORE_ADDR addr) { init_disassemble_info (di, NULL, gdb_buffered_insn_length_fprintf); /* init_disassemble_info installs buffer_read_memory, etc. so we don't need to do that here. The cast is necessary until disassemble_info is const-ified. */ di->buffer = (gdb_byte *) insn; di->buffer_length = max_len; di->buffer_vma = addr; di->arch = gdbarch_bfd_arch_info (gdbarch)->arch; di->mach = gdbarch_bfd_arch_info (gdbarch)->mach; di->endian = gdbarch_byte_order (gdbarch); di->endian_code = gdbarch_byte_order_for_code (gdbarch); disassemble_init_for_target (di); }