summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2019-09-15 17:01:38 +0000
committermidipix <writeonce@midipix.org>2019-09-16 07:07:34 +0000
commitb3b28e32623963e72eee2849dca3b57b0cc215f8 (patch)
treee808a5b3dd777acdac0c682e84da1ed26ab8f77a
parenta310e779ee60e4054794f09a32131f0142535624 (diff)
downloadchainport-b3b28e32623963e72eee2849dca3b57b0cc215f8.tar.bz2
chainport-b3b28e32623963e72eee2849dca3b57b0cc215f8.tar.xz
mgdb: x86_dr_low support: initial implementation and integration.
-rw-r--r--overlay/mgdb/gdb/winnt-nat.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/overlay/mgdb/gdb/winnt-nat.c b/overlay/mgdb/gdb/winnt-nat.c
index e326578..ed3fa53 100644
--- a/overlay/mgdb/gdb/winnt-nat.c
+++ b/overlay/mgdb/gdb/winnt-nat.c
@@ -35,6 +35,8 @@
#define winnt_perror(msg,pid) \
error("%s(): %s (pid %d).",__FUNCTION__,msg,pid)
+#define WINNT_DR_STATE_DIRTY (0x1)
+
struct regcache;
struct winnt_process {
@@ -47,6 +49,8 @@ struct winnt_process {
struct __dbg_module_info * modules;
struct __dbg_event event;
char * solibs;
+ uintptr_t dr_cache[8];
+ uint32_t dr_state;
};
static size_t pcnt;
@@ -857,6 +861,61 @@ static int winnt_perk_init(void)
return pe_get_driver_ctx(argv,0,0,0,&pe_dctx);
}
+#define WINNT_DR_HANDLER(handler) \
+ winnt_dr_ ## handler
+
+#define WINNT_SET_DR_LOW_HANDLER(handler) \
+ x86_dr_low.handler = WINNT_DR_HANDLER(handler)
+
+static void winnt_dr_set_addr(int idx, uintptr_t any)
+{
+ pid_t pid;
+ struct winnt_process * pidinfo;
+
+ pid = ptid_get_pid(inferior_ptid);
+ pidinfo = winnt_process_record(pid);
+
+ pidinfo->dr_cache[idx] = any;
+ pidinfo->dr_state = WINNT_DR_STATE_DIRTY;
+}
+
+static uintptr_t winnt_dr_get_addr(int idx)
+{
+ pid_t pid;
+ struct winnt_process * pidinfo;
+
+ pid = ptid_get_pid(inferior_ptid);
+ pidinfo = winnt_process_record(pid);
+
+ return pidinfo->dr_cache[idx];
+}
+
+static void winnt_dr_set_control(unsigned long ctrl)
+{
+ winnt_dr_set_addr(7,ctrl);
+}
+
+static unsigned long winnt_dr_get_control(void)
+{
+ return winnt_dr_get_addr(7);
+}
+
+static unsigned long winnt_dr_get_status(void)
+{
+ return winnt_dr_get_addr(6);
+}
+
+static void winnt_init_dr_low(void)
+{
+ WINNT_SET_DR_LOW_HANDLER(set_control);
+ WINNT_SET_DR_LOW_HANDLER(get_control);
+ WINNT_SET_DR_LOW_HANDLER(get_status);
+ WINNT_SET_DR_LOW_HANDLER(set_addr);
+ WINNT_SET_DR_LOW_HANDLER(get_addr);
+
+ x86_set_debug_register_length(sizeof(uintptr_t));
+}
+
static target_ops * winnt_target_alloc (void)
{
target_ops * t = inf_child_target();
@@ -892,6 +951,8 @@ static target_ops * winnt_target_alloc (void)
x86_use_watchpoints(t);
+ winnt_init_dr_low();
+
if (winnt_perk_init() < 0)
return 0;