From a6b988dd91021cd4f530697e892cb380c4c136a5 Mon Sep 17 00:00:00 2001 From: midipix Date: Sat, 7 Sep 2019 02:01:44 +0000 Subject: mgdb: winnt_kill(): initial implementation and integration. --- overlay/mgdb/gdb/winnt-nat.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/overlay/mgdb/gdb/winnt-nat.c b/overlay/mgdb/gdb/winnt-nat.c index 0ba63c3..bf997c9 100644 --- a/overlay/mgdb/gdb/winnt-nat.c +++ b/overlay/mgdb/gdb/winnt-nat.c @@ -279,6 +279,16 @@ static void winnt_attach (struct target_ops * t, const char * args, int from_tty winnt_prepare(t,pid,pfd,from_tty); } +static void winnt_abandon (struct target_ops * t, winnt_process * pidinfo) +{ + inferior_ptid = null_ptid; + + x86_cleanup_dregs(); + inf_child_maybe_unpush_target(t); + + winnt_plist_remove(pidinfo->pid); +} + static void winnt_detach (struct target_ops * t, const char * args, int from_tty) { pid_t pid; @@ -296,13 +306,9 @@ static void winnt_detach (struct target_ops * t, const char * args, int from_tty if (close(pidinfo->pfd) < 0) winnt_perror ("failed to close process file descriptor",pid); - inferior_ptid = null_ptid; detach_inferior(pidinfo->syspid); - x86_cleanup_dregs(); - inf_child_maybe_unpush_target(t); - - winnt_plist_remove(pid); + winnt_abandon(t,pidinfo); } static ptid_t winnt_wait( @@ -354,7 +360,19 @@ static void winnt_resume ( static void winnt_kill (struct target_ops * t) { - /* current_inferior() */ + struct inferior * cinf; + struct winnt_process * pidinfo; + + if (!(cinf = current_inferior())) + winnt_error("failed to obtain current inferior"); + + if (!(pidinfo = winnt_process_record(cinf->pid))) + winnt_perror("internal error: record not found",cinf->pid); + + if (__dbg_kill(pidinfo->pfd) < 0) + winnt_perror("failed to kill current inferior",cinf->pid); + + winnt_abandon(t,pidinfo); } static void winnt_mourn_inferior (struct target_ops * t) -- cgit v1.2.3