Skip to content

Commit a4366d4

Browse files
committed
Have dbgeng quit() wait for interrupt, fix #92
1 parent 5e53b36 commit a4366d4

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

binjaplug.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,7 @@ def quit(self):
712712
finally:
713713
self.adapter = None
714714
self.remote_arch = None
715+
715716
self.memory_dirty()
716717

717718
# Clean up temporary dumped file

dbgeng.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import os
44
import re
5+
import time
56
import socket
67
import threading
78
from struct import pack, unpack
@@ -175,7 +176,7 @@ def thunk_stop_reason(self):
175176
#--------------------------------------------------------------------------
176177

177178
# session start/stop
178-
def exec(self, fpath, args):
179+
def exec(self, fpath, args, terminal=False):
179180
# form command line
180181
if '/' in fpath:
181182
fpath = fpath.replace('/', '\\')
@@ -198,11 +199,16 @@ def attach(self, pid):
198199

199200
def detach(self):
200201
self.dll.process_detach()
201-
pass
202202

203203
def quit(self):
204-
self.dll.quit()
205-
pass
204+
self.dll.break_into()
205+
206+
# target in I/O have measurable time before interrupt request moves them to BREAK state
207+
for i in range(20):
208+
if self.get_exec_status() == DEBUG_STATUS.BREAK:
209+
self.dll.quit()
210+
return
211+
time.sleep(.1)
206212

207213
# target info
208214
def target_arch(self):
@@ -263,7 +269,7 @@ def breakpoint_set(self, addr):
263269
bpid = c_ulong();
264270
rc = pfunc(addr, byref(bpid))
265271
if rc != 0:
266-
raise DebugAdapter.BreakpointSetError('dll returned %d' % rc)
272+
raise DebugAdapter.BreakpointSetError('bp at 0x%X, dll returned %d' % (addr, rc))
267273
self.bp_addr_to_id[addr] = bpid.value
268274

269275
def breakpoint_clear(self, addr):

dbgengadapt/dbgengadapt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ EASY_CTYPES_SPEC
783783
int quit(void)
784784
{
785785
int rc = ERROR_UNSPECIFIED;
786-
if(g_Client->TerminateCurrentProcess() != S_OK) {
786+
if(g_Client->TerminateProcesses() != S_OK) {
787787
printf_debug("ERROR: TerminateCurrentProcess() failed\n");
788788
goto cleanup;
789789
}

dbgengadapt/dbgengadapt.dll

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)