Changeset View
Changeset View
Standalone View
Standalone View
head/devel/gdb/files/kgdb/amd64fbsd-kern.c
Show All 21 Lines | |||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/types.h> | #include "defs.h" | ||||
#ifdef __amd64__ | #include "frame-unwind.h" | ||||
#include <machine/pcb.h> | |||||
#include <machine/frame.h> | |||||
#endif | |||||
#include <string.h> | |||||
#include <defs.h> | |||||
#include <frame-unwind.h> | |||||
#include "gdbcore.h" | #include "gdbcore.h" | ||||
#include "osabi.h" | #include "osabi.h" | ||||
#include <regcache.h> | #include "regcache.h" | ||||
#include "solib.h" | #include "solib.h" | ||||
#include "stack.h" | #include "stack.h" | ||||
#include "symtab.h" | #include "symtab.h" | ||||
#include "trad-frame.h" | #include "trad-frame.h" | ||||
#include <amd64-tdep.h> | #include "amd64-tdep.h" | ||||
#include "x86-xstate.h" | |||||
#ifdef __amd64__ | |||||
#include <machine/pcb.h> | |||||
#include <machine/frame.h> | |||||
#endif | |||||
#include "kgdb.h" | #include "kgdb.h" | ||||
static const int amd64fbsd_pcb_offset[] = { | static const int amd64fbsd_pcb_offset[] = { | ||||
-1, /* %rax */ | -1, /* %rax */ | ||||
6 * 8, /* %rbx */ | 6 * 8, /* %rbx */ | ||||
-1, /* %rcx */ | -1, /* %rcx */ | ||||
-1, /* %rdx */ | -1, /* %rdx */ | ||||
-1, /* %rsi */ | -1, /* %rsi */ | ||||
Show All 27 Lines | amd64fbsd_supply_pcb(struct regcache *regcache, CORE_ADDR pcb_addr) | ||||
gdb_byte buf[8]; | gdb_byte buf[8]; | ||||
int i; | int i; | ||||
for (i = 0; i < ARRAY_SIZE (amd64fbsd_pcb_offset); i++) | for (i = 0; i < ARRAY_SIZE (amd64fbsd_pcb_offset); i++) | ||||
if (amd64fbsd_pcb_offset[i] != -1) { | if (amd64fbsd_pcb_offset[i] != -1) { | ||||
if (target_read_memory(pcb_addr + amd64fbsd_pcb_offset[i], buf, | if (target_read_memory(pcb_addr + amd64fbsd_pcb_offset[i], buf, | ||||
sizeof buf) != 0) | sizeof buf) != 0) | ||||
continue; | continue; | ||||
regcache_raw_supply(regcache, i, buf); | regcache->raw_supply(i, buf); | ||||
} | } | ||||
regcache_raw_supply_unsigned(regcache, AMD64_CS_REGNUM, CODE_SEL); | regcache->raw_supply_unsigned(AMD64_CS_REGNUM, CODE_SEL); | ||||
regcache_raw_supply_unsigned(regcache, AMD64_SS_REGNUM, DATA_SEL); | regcache->raw_supply_unsigned(AMD64_SS_REGNUM, DATA_SEL); | ||||
} | } | ||||
static const int amd64fbsd_trapframe_offset[] = { | static const int amd64fbsd_trapframe_offset[] = { | ||||
6 * 8, /* %rax */ | 6 * 8, /* %rax */ | ||||
7 * 8, /* %rbx */ | 7 * 8, /* %rbx */ | ||||
3 * 8, /* %rcx */ | 3 * 8, /* %rcx */ | ||||
2 * 8, /* %rdx */ | 2 * 8, /* %rdx */ | ||||
1 * 8, /* %rsi */ | 1 * 8, /* %rsi */ | ||||
▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | |||||
amd64fbsd_trapframe_sniffer (const struct frame_unwind *self, | amd64fbsd_trapframe_sniffer (const struct frame_unwind *self, | ||||
struct frame_info *this_frame, | struct frame_info *this_frame, | ||||
void **this_prologue_cache) | void **this_prologue_cache) | ||||
{ | { | ||||
const char *name; | const char *name; | ||||
find_pc_partial_function (get_frame_func (this_frame), &name, NULL, NULL); | find_pc_partial_function (get_frame_func (this_frame), &name, NULL, NULL); | ||||
return (name && ((strcmp (name, "calltrap") == 0) | return (name && ((strcmp (name, "calltrap") == 0) | ||||
|| (strcmp (name, "fast_syscall_common") == 0) | |||||
|| (strcmp (name, "fork_trampoline") == 0) | || (strcmp (name, "fork_trampoline") == 0) | ||||
|| (strcmp (name, "mchk_calltrap") == 0) | || (strcmp (name, "mchk_calltrap") == 0) | ||||
|| (strcmp (name, "nmi_calltrap") == 0) | || (strcmp (name, "nmi_calltrap") == 0) | ||||
|| (name[0] == 'X' && name[1] != '_'))); | || (name[0] == 'X' && name[1] != '_'))); | ||||
} | } | ||||
static const struct frame_unwind amd64fbsd_trapframe_unwind = { | static const struct frame_unwind amd64fbsd_trapframe_unwind = { | ||||
SIGTRAMP_FRAME, | SIGTRAMP_FRAME, | ||||
default_frame_unwind_stop_reason, | default_frame_unwind_stop_reason, | ||||
amd64fbsd_trapframe_this_id, | amd64fbsd_trapframe_this_id, | ||||
amd64fbsd_trapframe_prev_register, | amd64fbsd_trapframe_prev_register, | ||||
NULL, | NULL, | ||||
amd64fbsd_trapframe_sniffer | amd64fbsd_trapframe_sniffer | ||||
}; | }; | ||||
static void | static void | ||||
amd64fbsd_kernel_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch) | amd64fbsd_kernel_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch) | ||||
{ | { | ||||
amd64_init_abi(info, gdbarch); | amd64_init_abi(info, gdbarch, | ||||
amd64_target_description (X86_XSTATE_SSE_MASK)); | |||||
frame_unwind_prepend_unwinder(gdbarch, &amd64fbsd_trapframe_unwind); | frame_unwind_prepend_unwinder(gdbarch, &amd64fbsd_trapframe_unwind); | ||||
set_solib_ops(gdbarch, &kld_so_ops); | set_solib_ops(gdbarch, &kld_so_ops); | ||||
fbsd_vmcore_set_supply_pcb(gdbarch, amd64fbsd_supply_pcb); | fbsd_vmcore_set_supply_pcb(gdbarch, amd64fbsd_supply_pcb); | ||||
fbsd_vmcore_set_cpu_pcb_addr(gdbarch, kgdb_trgt_stop_pcb); | fbsd_vmcore_set_cpu_pcb_addr(gdbarch, kgdb_trgt_stop_pcb); | ||||
} | } | ||||
void _initialize_amd64_kgdb_tdep(void); | |||||
void | void | ||||
_initialize_amd64_kgdb_tdep(void) | _initialize_amd64_kgdb_tdep(void) | ||||
{ | { | ||||
gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64, | gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64, | ||||
GDB_OSABI_FREEBSD_KERNEL, amd64fbsd_kernel_init_abi); | GDB_OSABI_FREEBSD_KERNEL, amd64fbsd_kernel_init_abi); | ||||
#ifdef __amd64__ | #ifdef __amd64__ | ||||
▲ Show 20 Lines • Show All 61 Lines • Show Last 20 Lines |