static void amd64obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); amd64_init_abi (info, gdbarch); obsd_init_abi (info, gdbarch); /* Initialize general-purpose register set details. */ tdep->gregset_reg_offset = amd64obsd_r_reg_offset; tdep->gregset_num_regs = ARRAY_SIZE (amd64obsd_r_reg_offset); tdep->sizeof_gregset = 24 * 8; tdep->jb_pc_offset = 7 * 8; tdep->sigtramp_p = amd64obsd_sigtramp_p; tdep->sigcontext_addr = amd64obsd_sigcontext_addr; tdep->sc_reg_offset = amd64obsd_sc_reg_offset; tdep->sc_num_regs = ARRAY_SIZE (amd64obsd_sc_reg_offset); /* OpenBSD provides a user-level threads implementation. */ bsd_uthread_set_supply_uthread (gdbarch, amd64obsd_supply_uthread); bsd_uthread_set_collect_uthread (gdbarch, amd64obsd_collect_uthread); /* OpenBSD uses SVR4-style shared libraries. */ set_solib_svr4_fetch_link_map_offsets (gdbarch, svr4_lp64_fetch_link_map_offsets); /* Unwind kernel trap frames correctly. */ frame_unwind_prepend_unwinder (gdbarch, &amd64obsd_trapframe_unwind); }
static void i386obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); /* Obviously OpenBSD is BSD-based. */ i386bsd_init_abi (info, gdbarch); /* OpenBSD has a different `struct reg'. */ tdep->gregset_reg_offset = i386obsd_r_reg_offset; tdep->gregset_num_regs = ARRAY_SIZE (i386obsd_r_reg_offset); tdep->sizeof_gregset = 16 * 4; /* OpenBSD uses -freg-struct-return by default. */ tdep->struct_return = reg_struct_return; /* OpenBSD uses a different memory layout. */ tdep->sigtramp_start = i386obsd_sigtramp_start_addr; tdep->sigtramp_end = i386obsd_sigtramp_end_addr; tdep->sigtramp_p = i386obsd_sigtramp_p; /* OpenBSD has a `struct sigcontext' that's different from the original 4.3 BSD. */ tdep->sc_reg_offset = i386obsd_sc_reg_offset; tdep->sc_num_regs = ARRAY_SIZE (i386obsd_sc_reg_offset); /* OpenBSD provides a user-level threads implementation. */ bsd_uthread_set_supply_uthread (gdbarch, i386obsd_supply_uthread); bsd_uthread_set_collect_uthread (gdbarch, i386obsd_collect_uthread); /* Unwind kernel trap frames correctly. */ frame_unwind_prepend_unwinder (gdbarch, &i386obsd_trapframe_unwind); }
static void ppcfbsd_kernel_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); frame_unwind_prepend_unwinder(gdbarch, &ppcfbsd_trapframe_unwind); set_solib_ops(gdbarch, &kld_so_ops); #ifdef __powerpc__ if (tdep->wordsize == sizeof(register_t)) { fbsd_vmcore_set_supply_pcb(gdbarch, ppcfbsd_supply_pcb); fbsd_vmcore_set_cpu_pcb_addr(gdbarch, kgdb_trgt_stop_pcb); } #endif /* FreeBSD doesn't support the 128-bit `long double' from the psABI. */ set_gdbarch_long_double_bit (gdbarch, 64); set_gdbarch_long_double_format (gdbarch, floatformats_ieee_double); if (tdep->wordsize == 4) { set_gdbarch_return_value (gdbarch, ppc_sysv_abi_broken_return_value); } if (tdep->wordsize == 8) { set_gdbarch_convert_from_func_ptr_addr (gdbarch, ppc64_convert_from_func_ptr_addr); set_gdbarch_elf_make_msymbol_special (gdbarch, ppc64_elf_make_msymbol_special); } }
static void i386nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); /* Obviously NetBSD is BSD-based. */ i386bsd_init_abi (info, gdbarch); /* NetBSD has a different `struct reg'. */ tdep->gregset_reg_offset = i386nbsd_r_reg_offset; tdep->gregset_num_regs = ARRAY_SIZE (i386nbsd_r_reg_offset); tdep->sizeof_gregset = 16 * 4; /* NetBSD uses -freg-struct-return by default. */ tdep->struct_return = reg_struct_return; /* NetBSD uses tramp_frame sniffers for signal trampolines. */ tdep->sigcontext_addr= 0; tdep->sigtramp_start = 0; tdep->sigtramp_end = 0; tdep->sigtramp_p = 0; tdep->sc_reg_offset = 0; tdep->sc_num_regs = 0; tramp_frame_prepend_unwinder (gdbarch, &i386nbsd_sigtramp_sc16); tramp_frame_prepend_unwinder (gdbarch, &i386nbsd_sigtramp_sc2); tramp_frame_prepend_unwinder (gdbarch, &i386nbsd_sigtramp_si2); tramp_frame_prepend_unwinder (gdbarch, &i386nbsd_sigtramp_si31); tramp_frame_prepend_unwinder (gdbarch, &i386nbsd_sigtramp_si4); /* Unwind kernel trap frames correctly. */ frame_unwind_prepend_unwinder (gdbarch, &i386nbsd_trapframe_unwind); }
void tramp_frame_prepend_unwinder (struct gdbarch *gdbarch, const struct tramp_frame *tramp_frame) { struct frame_data *data; struct frame_unwind *unwinder; int i; /* Check that the instruction sequence contains a sentinel. */ for (i = 0; i < ARRAY_SIZE (tramp_frame->insn); i++) { if (tramp_frame->insn[i].bytes == TRAMP_SENTINEL_INSN) break; } gdb_assert (i < ARRAY_SIZE (tramp_frame->insn)); gdb_assert (tramp_frame->insn_size <= sizeof (tramp_frame->insn[0].bytes)); data = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct frame_data); unwinder = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct frame_unwind); data->tramp_frame = tramp_frame; unwinder->type = tramp_frame->frame_type; unwinder->unwind_data = data; unwinder->sniffer = tramp_frame_sniffer; unwinder->this_id = tramp_frame_this_id; unwinder->prev_register = tramp_frame_prev_register; frame_unwind_prepend_unwinder (gdbarch, unwinder); }
static void amd64fbsd_kernel_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch) { amd64_init_abi(info, gdbarch); frame_unwind_prepend_unwinder(gdbarch, &amd64fbsd_trapframe_unwind); set_solib_ops(gdbarch, &kld_so_ops); fbsd_vmcore_set_supply_pcb(gdbarch, amd64fbsd_supply_pcb); fbsd_vmcore_set_cpu_pcb_addr(gdbarch, kgdb_trgt_stop_pcb); }
static void arm_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); linux_init_abi (info, gdbarch); tdep->lowest_pc = 0x8000; if (info.byte_order == BFD_ENDIAN_BIG) { if (tdep->arm_abi == ARM_ABI_AAPCS) tdep->arm_breakpoint = eabi_linux_arm_be_breakpoint; else tdep->arm_breakpoint = arm_linux_arm_be_breakpoint; tdep->thumb_breakpoint = arm_linux_thumb_be_breakpoint; tdep->thumb2_breakpoint = arm_linux_thumb2_be_breakpoint; } else { if (tdep->arm_abi == ARM_ABI_AAPCS) tdep->arm_breakpoint = eabi_linux_arm_le_breakpoint; else tdep->arm_breakpoint = arm_linux_arm_le_breakpoint; tdep->thumb_breakpoint = arm_linux_thumb_le_breakpoint; tdep->thumb2_breakpoint = arm_linux_thumb2_le_breakpoint; } tdep->arm_breakpoint_size = sizeof (arm_linux_arm_le_breakpoint); tdep->thumb_breakpoint_size = sizeof (arm_linux_thumb_le_breakpoint); tdep->thumb2_breakpoint_size = sizeof (arm_linux_thumb2_le_breakpoint); if (tdep->fp_model == ARM_FLOAT_AUTO) tdep->fp_model = ARM_FLOAT_FPA; switch (tdep->fp_model) { case ARM_FLOAT_FPA: tdep->jb_pc = ARM_LINUX_JB_PC_FPA; break; case ARM_FLOAT_SOFT_FPA: case ARM_FLOAT_SOFT_VFP: case ARM_FLOAT_VFP: tdep->jb_pc = ARM_LINUX_JB_PC_EABI; break; default: internal_error (__FILE__, __LINE__, _("arm_linux_init_abi: Floating point model not supported")); break; } if (is_target_linux_android ()) tdep->jb_pc = ARM_ANDROID_JB_PC; tdep->jb_elt_size = ARM_LINUX_JB_ELEMENT_SIZE; set_solib_svr4_fetch_link_map_offsets (gdbarch, svr4_ilp32_fetch_link_map_offsets); /* Single stepping. */ set_gdbarch_software_single_step (gdbarch, arm_linux_software_single_step); /* Shared library handling. */ set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target); set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver); /* Enable TLS support. */ set_gdbarch_fetch_tls_load_module_address (gdbarch, svr4_fetch_objfile_link_map); if (is_target_linux_android ()) /* This is incomplete, we can't singlestep through the handler back to the interrupted code, address 0xffff0500 is inaccessible. This is really a temp hack until there's libc additions to put the trampoline code in user space. */ frame_unwind_prepend_unwinder (gdbarch, &arm_android_sigreturn_tramp_frame); else { /* This indentation is on purpose to minimize whitespace changes. */ tramp_frame_prepend_unwinder (gdbarch, &arm_linux_sigreturn_tramp_frame); tramp_frame_prepend_unwinder (gdbarch, &arm_linux_rt_sigreturn_tramp_frame); tramp_frame_prepend_unwinder (gdbarch, &arm_eabi_linux_sigreturn_tramp_frame); tramp_frame_prepend_unwinder (gdbarch, &arm_eabi_linux_rt_sigreturn_tramp_frame); tramp_frame_prepend_unwinder (gdbarch, &arm_linux_restart_syscall_tramp_frame); tramp_frame_prepend_unwinder (gdbarch, &arm_kernel_linux_restart_syscall_tramp_frame); } /* Core file support. */ set_gdbarch_regset_from_core_section (gdbarch, arm_linux_regset_from_core_section); set_gdbarch_get_siginfo_type (gdbarch, linux_get_siginfo_type); /* Displaced stepping. */ set_gdbarch_displaced_step_copy_insn (gdbarch, arm_linux_displaced_step_copy_insn); set_gdbarch_displaced_step_fixup (gdbarch, arm_displaced_step_fixup); set_gdbarch_displaced_step_free_closure (gdbarch, simple_displaced_step_free_closure); set_gdbarch_displaced_step_location (gdbarch, displaced_step_at_entry_point); tdep->syscall_next_pc = arm_linux_syscall_next_pc; }
static void kgdb_trgt_open(char *filename, int from_tty) { struct cleanup *old_chain; struct kthr *kt; struct inferior *inf8; struct program_space *pspace; kvm_t *nkvm; char *temp; int first_inferior = 1; target_preopen (from_tty); if (!filename) error ("No vmcore file specified."); if (!exec_bfd) error ("Can't open a vmcore without a kernel"); filename = tilde_expand (filename); if (filename[0] != '/') { temp = concat (current_directory, "/", filename, NULL); xfree(filename); filename = temp; } old_chain = make_cleanup (xfree, filename); nkvm = kvm_openfiles(bfd_get_filename(exec_bfd), filename, NULL, write_files ? O_RDWR : O_RDONLY, kvm_err); if (nkvm == NULL) error ("Failed to open vmcore: %s", kvm_err); /* Don't free the filename now and close any previous vmcore. */ discard_cleanups(old_chain); unpush_target(&kgdb_trgt_ops); kvm = nkvm; vmcore = filename; old_chain = make_cleanup(kgdb_core_cleanup, NULL); push_target (&kgdb_trgt_ops); discard_cleanups (old_chain); kgdb_dmesg(); init_thread_list(); kt = kgdb_thr_init(); while (kt != NULL) { if (!in_inferior_list(kt->pid)) { if (first_inferior) { first_inferior = 0; inf8 = current_inferior(); inf8->pid = kt->pid; inferior_appeared (inf8, kt->pid); pspace = current_program_space; pspace->ebfd = 0; pspace->ebfd_mtime = 0; } else { inf8 = add_inferior(kt->pid); pspace = add_program_space(new_address_space()); pspace->symfile_object_file = symfile_objfile; pspace->objfiles = object_files; } inf8->pspace = pspace; inf8->aspace = pspace->aspace; } add_thread(ptid_build(kt->pid, 0, kt->tid)); kt = kgdb_thr_next(kt); } if (curkthr != 0) inferior_ptid = ptid_build(curkthr->pid, 0, curkthr->tid); frame_unwind_prepend_unwinder(get_frame_arch(get_current_frame()), &kgdb_trgt_trapframe_unwind); /* XXX: fetch registers? */ kld_init(); reinit_frame_cache(); select_frame (get_current_frame()); print_stack_frame(get_selected_frame(NULL), frame_relative_level(get_selected_frame(NULL)), 1); }