From aef6781dbba2f1ce4cd9eac1328c498e2b4f84a8 Mon Sep 17 00:00:00 2001 From: midipix Date: Sat, 14 Sep 2019 02:27:36 +0000 Subject: mgdb: enable the perk library interface. --- overlay/mgdb/gdb/config/i386/midipix64.mh | 2 ++ overlay/mgdb/gdb/winnt-nat.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/overlay/mgdb/gdb/config/i386/midipix64.mh b/overlay/mgdb/gdb/config/i386/midipix64.mh index 9160611..0d2753f 100644 --- a/overlay/mgdb/gdb/config/i386/midipix64.mh +++ b/overlay/mgdb/gdb/config/i386/midipix64.mh @@ -2,3 +2,5 @@ NATDEPFILES = x86-nat.o x86-dregs.o \ i386-winnt-regcache.o \ amd64-winnt-regcache.o \ winnt-nat.o + +LOADLIBES = -lperk diff --git a/overlay/mgdb/gdb/winnt-nat.c b/overlay/mgdb/gdb/winnt-nat.c index 2d9999d..0f615e5 100644 --- a/overlay/mgdb/gdb/winnt-nat.c +++ b/overlay/mgdb/gdb/winnt-nat.c @@ -8,6 +8,7 @@ #include "osabi.h" #include "config.h" #include "target.h" +#include "main.h" #include "utils.h" #include "inferior.h" #include "gdbthread.h" @@ -22,6 +23,8 @@ #include #include +#include + #define WINNT_OUTBUF_SIZE 65536 #define winnt_error(msg) \ @@ -46,6 +49,7 @@ struct winnt_process { static size_t pcnt; static winnt_process * plist; static char * outbuf; +static struct pe_driver_ctx * pe_dctx; extern void amd64_winnt_fetch_registers( int pfd, struct regcache * rcache, @@ -731,6 +735,19 @@ static char * winnt_pid_to_str (struct target_ops * t, ptid_t ptid) return outbuf; } +static int winnt_perk_init(void) +{ + char * argv[2]; + + if (pe_dctx) + return 0; + + argv[0] = (char *)get_gdb_program_name(); + argv[1] = 0; + + return pe_get_driver_ctx(argv,0,0,0,&pe_dctx); +} + static target_ops * winnt_target_alloc (void) { target_ops * t = inf_child_target(); @@ -766,6 +783,9 @@ static target_ops * winnt_target_alloc (void) x86_use_watchpoints(t); + if (winnt_perk_init() < 0) + return 0; + return ((outbuf = (char *)calloc(1,WINNT_OUTBUF_SIZE))) ? t : 0; } -- cgit v1.2.3