summaryrefslogtreecommitdiff
path: root/overlay/mgdb/gdb/amd64-winnt-regcache.c
diff options
context:
space:
mode:
Diffstat (limited to 'overlay/mgdb/gdb/amd64-winnt-regcache.c')
-rw-r--r--overlay/mgdb/gdb/amd64-winnt-regcache.c45
1 files changed, 45 insertions, 0 deletions
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 <signal.h>
+#include <sys/debug.h>
+
+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;
+}