summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2019-09-08 14:24:03 +0000
committermidipix <writeonce@midipix.org>2019-09-08 14:47:59 +0000
commit09150e53b3d4442c6e7afd3696691c16baaea8f0 (patch)
tree1d9bdf5f0327b2105e10e5f95d516b3575ef6844
parent41c20f89884f8480fe15768ffaf82b95348103b2 (diff)
downloadchainport-09150e53b3d4442c6e7afd3696691c16baaea8f0.tar.bz2
chainport-09150e53b3d4442c6e7afd3696691c16baaea8f0.tar.xz
mgdb: amd64_winnt_fetch_registers(): initial implementation and integration.
-rw-r--r--overlay/mgdb/gdb/amd64-winnt-tdep.c36
-rw-r--r--overlay/mgdb/gdb/i386-winnt-tdep.c12
-rw-r--r--overlay/mgdb/gdb/winnt-nat.c33
3 files changed, 78 insertions, 3 deletions
diff --git a/overlay/mgdb/gdb/amd64-winnt-tdep.c b/overlay/mgdb/gdb/amd64-winnt-tdep.c
index cf53d3d..f663677 100644
--- a/overlay/mgdb/gdb/amd64-winnt-tdep.c
+++ b/overlay/mgdb/gdb/amd64-winnt-tdep.c
@@ -6,10 +6,14 @@
#include "defs.h"
#include "osabi.h"
+#include "regcache.h"
#include "frame-unwind.h"
#include "windows-tdep.h"
#include "amd64-windows-tdep.c"
+#include <signal.h>
+#include <sys/debug.h>
+
#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
@@ -18,6 +22,38 @@
#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,&regval);
+}
+
+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,&regctx)) < 0)
+ return ret;
+
+ if (regnum == AMD64_RIP_REGNUM)
+ amd64_winnt_supply_pc_regs(rcache,&regctx);
+
+ return 0;
+}
+
static void amd64_winnt_init_abi (struct gdbarch_info info, struct gdbarch * gdbarch)
{
/* abi */
diff --git a/overlay/mgdb/gdb/i386-winnt-tdep.c b/overlay/mgdb/gdb/i386-winnt-tdep.c
index d212959..919fa30 100644
--- a/overlay/mgdb/gdb/i386-winnt-tdep.c
+++ b/overlay/mgdb/gdb/i386-winnt-tdep.c
@@ -9,6 +9,18 @@
#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 */
diff --git a/overlay/mgdb/gdb/winnt-nat.c b/overlay/mgdb/gdb/winnt-nat.c
index d32464c..449b740 100644
--- a/overlay/mgdb/gdb/winnt-nat.c
+++ b/overlay/mgdb/gdb/winnt-nat.c
@@ -30,6 +30,8 @@
#define winnt_perror(msg,pid) \
error("%s(): %s (pid %d).",__FUNCTION__,msg,pid)
+struct regcache;
+
struct winnt_process {
int pfd;
pid_t pid;
@@ -42,6 +44,14 @@ static size_t pcnt;
static winnt_process * plist;
static char * outbuf;
+extern void amd64_winnt_fetch_registers(
+ int pfd, struct regcache * rcache,
+ int regnum, pid_t tid);
+
+extern void i386_winnt_fetch_registers(
+ int pfd, struct regcache * rcache,
+ int regnum, pid_t tid);
+
static winnt_process * winnt_plist_expand (void)
{
struct winnt_process * pnew;
@@ -122,9 +132,26 @@ static void winnt_fetch_registers (
struct regcache * rcache,
int regnum)
{
- (void)t;
- (void)rcache;
- (void)regnum;
+ pid_t pid;
+ pid_t tid;
+ struct winnt_process * pidinfo;
+
+ pid = inferior_ptid.pid;
+ tid = inferior_ptid.tid;
+
+ if (!(pidinfo = winnt_process_record(pid)))
+ winnt_perror("internal error: record not found",pid);
+
+ if (sizeof(uintptr_t) == 8)
+ amd64_winnt_fetch_registers(
+ pidinfo->pfd,
+ rcache,regnum,
+ tid);
+ else
+ i386_winnt_fetch_registers(
+ pidinfo->pfd,
+ rcache,regnum,
+ tid);
}
static void winnt_store_registers (