diff options
author | midipix <writeonce@midipix.org> | 2019-09-08 17:20:06 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2019-09-08 17:22:53 +0000 |
commit | 90cf691b801a339ebd8b834fd874ec332ea69d78 (patch) | |
tree | 2066ed0a9fdbcda6fda19009724018b3c8980a99 /overlay/mgdb/gdb | |
parent | ba7fbe803e053e3bfbf41732036467f84c2d393b (diff) | |
download | chainport-90cf691b801a339ebd8b834fd874ec332ea69d78.tar.bz2 chainport-90cf691b801a339ebd8b834fd874ec332ea69d78.tar.xz |
mgdb: winnt_wait(): handle event->evttype, added winnt_wait_event().
Diffstat (limited to 'overlay/mgdb/gdb')
-rw-r--r-- | overlay/mgdb/gdb/winnt-nat.c | 64 |
1 files changed, 46 insertions, 18 deletions
diff --git a/overlay/mgdb/gdb/winnt-nat.c b/overlay/mgdb/gdb/winnt-nat.c index ab7dc83..267395b 100644 --- a/overlay/mgdb/gdb/winnt-nat.c +++ b/overlay/mgdb/gdb/winnt-nat.c @@ -431,11 +431,7 @@ static void winnt_detach (struct target_ops * t, const char * args, int from_tty winnt_mourn_inferior(t); } -static ptid_t winnt_wait( - struct target_ops * t, - ptid_t ptid, - struct target_waitstatus * waitstatus, - int target_options) +static struct __dbg_event * winnt_wait_event(ptid_t ptid) { struct __dbg_event event; struct winnt_process * pdbg; @@ -449,50 +445,82 @@ static ptid_t winnt_wait( if (ptid.pid < 0) for (pdbg=plist, pcap=&plist[pcnt]; pdbg<pcap; pdbg++) if (pdbg->event.systid) - return ptid_build( - pdbg->event.syspid,0, - pdbg->event.systid); + return &pdbg->event; if (ptid.pid > 0) { if (!(pidinfo = winnt_process_record(event.syspid))) winnt_perror("internal error: record not found",event.syspid); if (pidinfo->event.systid) - return ptid_build( - pidinfo->event.syspid,0, - pidinfo->event.systid); + return &pidinfo->event; } if (pcnt*sizeof(*pfds) < sizeof(pollfdbuf)) pfds = pollfdbuf; else if (!(pfds = (struct pollfd *)calloc(pcnt,sizeof(*pfds)))) - return null_ptid; + return 0; nfds = (ptid.pid > 0) ? winnt_poll_one_init(pfds,ptid.pid) : winnt_poll_init(pfds); if (poll(pfds,nfds,-1) < 0) - return null_ptid; + return 0; for (i=0, pfd=0; i<nfds && !pfd; i++) if (pfds[i].revents & POLLIN) pfd = &pfds[i]; if (!pfd) - return null_ptid; + return 0; if (__dbg_event_query_one(pfd->fd,&event) < 0) - return null_ptid; + return 0; if (!(pidinfo = winnt_process_record(event.syspid))) winnt_perror("internal error: record not found",event.syspid); memcpy(&pidinfo->event,&event,sizeof(event)); - return ptid_build( - event.syspid,0, - event.systid); + return &pidinfo->event; +} + +static ptid_t winnt_wait( + struct target_ops * t, + ptid_t ptid, + struct target_waitstatus * waitstatus, + int target_options) +{ + struct __dbg_event * event; + + if (!(event = winnt_wait_event(ptid))) + return null_ptid; + + switch (event->evttype) { + case __DBG_STATE_EXCEPTION: + case __DBG_STATE_BREAKPOINT: + case __DBG_STATE_SINGLE_STEP: + waitstatus->kind = TARGET_WAITKIND_STOPPED; + break; + + case __DBG_STATE_CREATE_PROCESS: + case __DBG_STATE_CREATE_THREAD: + case __DBG_STATE_IDLE: + case __DBG_STATE_REPLY_PENDING: + case __DBG_STATE_DLL_LOAD: + case __DBG_STATE_DLL_UNLOAD: + case __DBG_STATE_EXIT_THREAD: + case __DBG_STATE_EXIT_PROCESS: + waitstatus->kind = TARGET_WAITKIND_SPURIOUS; + break; + } + + inferior_ptid.pid = event->syspid; + inferior_ptid.tid = event->systid; + + target_terminal_ours(); + + return inferior_ptid; } static void winnt_resume ( |