From 98061512cd1334cb0db29bd5875bf395910a6494 Mon Sep 17 00:00:00 2001 From: midipix Date: Mon, 9 Sep 2019 02:58:10 +0000 Subject: mgdb: moved {i386|amd64}_winnt_fetch_registers() where they belong. --- overlay/mgdb/gdb/amd64-winnt-regcache.c | 45 +++++++++++++++++++++++++++++++ overlay/mgdb/gdb/amd64-winnt-tdep.c | 36 ------------------------- overlay/mgdb/gdb/config/i386/midipix64.mh | 5 +++- overlay/mgdb/gdb/i386-winnt-regcache.c | 22 +++++++++++++++ overlay/mgdb/gdb/i386-winnt-tdep.c | 12 --------- 5 files changed, 71 insertions(+), 49 deletions(-) create mode 100644 overlay/mgdb/gdb/amd64-winnt-regcache.c create mode 100644 overlay/mgdb/gdb/i386-winnt-regcache.c diff --git a/overlay/mgdb/gdb/amd64-winnt-regcache.c b/overlay/mgdb/gdb/amd64-winnt-regcache.c new file mode 100644 index 0000000..6ed35cb --- /dev/null +++ b/overlay/mgdb/gdb/amd64-winnt-regcache.c @@ -0,0 +1,45 @@ +/***************************************************************/ +/* mgdb: midipix-specific bits for gdb */ +/* Copyright (C) 2019 Z. Gilboa */ +/* Released under GPLv2 and GPLv3; see COPYING.MGDB. */ +/***************************************************************/ + +#include "defs.h" +#include "osabi.h" +#include "regcache.h" +#include "amd64-tdep.h" + +#include +#include + +struct regcache; + +static void amd64_winnt_supply_reg( + struct regcache * rcache, + int regnum, uintptr_t regval) +{ + regcache_raw_supply(rcache,regnum,®val); +} + +static void amd64_winnt_supply_pc_regs( + struct regcache * rcache, + mcontext_t * regctx) +{ + amd64_winnt_supply_reg(rcache,AMD64_RIP_REGNUM,regctx->uc_rip); +} + +int amd64_winnt_fetch_registers( + int pfd, struct regcache * rcache, + int regnum, pid_t tid) +{ + int ret; + mcontext_t regctx; + + if ((ret = __dbg_regs_fetch(pfd,tid,®ctx)) < 0) + return ret; + + if (regnum == AMD64_RIP_REGNUM) + amd64_winnt_supply_pc_regs(rcache,®ctx); + + return 0; +} diff --git a/overlay/mgdb/gdb/amd64-winnt-tdep.c b/overlay/mgdb/gdb/amd64-winnt-tdep.c index f663677..cf53d3d 100644 --- a/overlay/mgdb/gdb/amd64-winnt-tdep.c +++ b/overlay/mgdb/gdb/amd64-winnt-tdep.c @@ -6,14 +6,10 @@ #include "defs.h" #include "osabi.h" -#include "regcache.h" #include "frame-unwind.h" #include "windows-tdep.h" #include "amd64-windows-tdep.c" -#include -#include - #define amd64_winnt_push_dummy_call amd64_windows_push_dummy_call #define amd64_winnt_return_value amd64_windows_return_value #define amd64_winnt_skip_trampoline_code amd64_windows_skip_trampoline_code @@ -22,38 +18,6 @@ #define amd64_winnt_skip_main_prologue amd64_skip_main_prologue #define amd64_winnt_frame_unwind amd64_windows_frame_unwind -struct regcache; - -static void amd64_winnt_supply_reg( - struct regcache * rcache, - int regnum, uintptr_t regval) -{ - regcache_raw_supply(rcache,regnum,®val); -} - -static void amd64_winnt_supply_pc_regs( - struct regcache * rcache, - mcontext_t * regctx) -{ - amd64_winnt_supply_reg(rcache,AMD64_RIP_REGNUM,regctx->uc_rip); -} - -int amd64_winnt_fetch_registers( - int pfd, struct regcache * rcache, - int regnum, pid_t tid) -{ - int ret; - mcontext_t regctx; - - if ((ret = __dbg_regs_fetch(pfd,tid,®ctx)) < 0) - return ret; - - if (regnum == AMD64_RIP_REGNUM) - amd64_winnt_supply_pc_regs(rcache,®ctx); - - return 0; -} - static void amd64_winnt_init_abi (struct gdbarch_info info, struct gdbarch * gdbarch) { /* abi */ diff --git a/overlay/mgdb/gdb/config/i386/midipix64.mh b/overlay/mgdb/gdb/config/i386/midipix64.mh index 382f657..9160611 100644 --- a/overlay/mgdb/gdb/config/i386/midipix64.mh +++ b/overlay/mgdb/gdb/config/i386/midipix64.mh @@ -1 +1,4 @@ -NATDEPFILES= x86-nat.o x86-dregs.o winnt-nat.o +NATDEPFILES = x86-nat.o x86-dregs.o \ + i386-winnt-regcache.o \ + amd64-winnt-regcache.o \ + winnt-nat.o diff --git a/overlay/mgdb/gdb/i386-winnt-regcache.c b/overlay/mgdb/gdb/i386-winnt-regcache.c new file mode 100644 index 0000000..1c2fb3e --- /dev/null +++ b/overlay/mgdb/gdb/i386-winnt-regcache.c @@ -0,0 +1,22 @@ +/***************************************************************/ +/* mgdb: midipix-specific bits for gdb */ +/* Copyright (C) 2019 Z. Gilboa */ +/* Released under GPLv2 and GPLv3; see COPYING.MGDB. */ +/***************************************************************/ + +#include "defs.h" +#include "osabi.h" +#include "frame-unwind.h" +#include "i386-tdep.h" + +struct regcache; + +void i386_winnt_fetch_registers( + int pfd, struct regcache * rcache, + int regnum, pid_t tid) +{ + (void)pfd; + (void)rcache; + (void)regnum; + (void)tid; +} diff --git a/overlay/mgdb/gdb/i386-winnt-tdep.c b/overlay/mgdb/gdb/i386-winnt-tdep.c index 919fa30..d212959 100644 --- a/overlay/mgdb/gdb/i386-winnt-tdep.c +++ b/overlay/mgdb/gdb/i386-winnt-tdep.c @@ -9,18 +9,6 @@ #include "frame-unwind.h" #include "windows-tdep.h" -struct regcache; - -void i386_winnt_fetch_registers( - int pfd, struct regcache * rcache, - int regnum, pid_t tid) -{ - (void)pfd; - (void)rcache; - (void)regnum; - (void)tid; -} - static void i386_winnt_init_abi (struct gdbarch_info info, struct gdbarch * gdbarch) { /* abi */ -- cgit v1.2.3