Skip to content

Commit aefee04

Browse files
committed
Fix breakpoint oneshot, delete access violation
1 parent 018168f commit aefee04

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

pybag/dbgeng/breakpoints.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,19 @@ def __call__(self, *args):
3636
else:
3737
ret = DbgEng.DEBUG_STATUS_NO_CHANGE
3838

39+
if rawbp.GetFlags() & DbgEng.DEBUG_BREAKPOINT_ONE_SHOT:
40+
self._remove_stale(bpid)
41+
3942
count -= 1
4043
if count == 0:
41-
# We can disable here and but not delete
42-
rawbp.RemoveFlags(DbgEng.DEBUG_BREAKPOINT_ENABLED)
44+
self._remove(rawbp, bpid)
45+
4346
return ret
4447

48+
4549
def set(self, expr, handler=None, type=None, windbgcmd=None, oneshot=False,
4650
passcount=None, threadid=None, size=None, access=None,
4751
count=0xffffffff):
48-
4952
existingid = self.find(expr)
5053
if existingid != -1:
5154
# Just enable
@@ -70,9 +73,7 @@ def set(self, expr, handler=None, type=None, windbgcmd=None, oneshot=False,
7073
if threadid:
7174
bp.SetMatchThreadId(threadid)
7275
if oneshot:
73-
count = 1
74-
# comtypes can't properly handle true one shot
75-
#bp.AddFlags(DbgEng.DEBUG_BREAKPOINT_ONE_SHOT)
76+
bp.AddFlags(DbgEng.DEBUG_BREAKPOINT_ONE_SHOT)
7677
self._bp[id] = (count,handler)
7778
if not bp.GetFlags() & DbgEng.DEBUG_BREAKPOINT_DEFERRED:
7879
self.enable(id)
@@ -121,7 +122,7 @@ def find_expr(self, expr):
121122
try:
122123
bp = self._control.GetBreakpointById(bpid)
123124
except exception.E_NOINTERFACE_Error:
124-
self.breakpoints._remove_stale(bpid)
125+
self._remove_stale(bpid)
125126
continue
126127

127128
bpexpr = bp.GetOffsetExpression()
@@ -137,7 +138,7 @@ def find_offset(self, offset):
137138
try:
138139
bp = self._control.GetBreakpointById(bpid)
139140
except exception.E_NOINTERFACE_Error:
140-
self.breakpoints._remove_stale(bpid)
141+
self._remove_stale(bpid)
141142
continue
142143

143144
bpoff = bp.GetOffset()

pybag/dbgeng/idebugbreakpoint.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44
from . import core as DbgEng
55
from . import exception
66

7+
def fakeRelease(*args):
8+
# we don't want to reference the object
9+
return
10+
711
class DebugBreakpoint(object):
812
def __init__(self, bp):
913
self._bp = bp
1014
exception.wrap_comclass(self._bp)
15+
self._bp.Release = fakeRelease
1116

1217
# IDebugBreakpoint
1318

pybag/pydbg.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ def be(self, id):
540540
self.breakpoints.enable(id)
541541

542542
def bp(self, expr=None, handler=None, windbgcmd=None, oneshot=False,
543-
passcount=None, threadid=None):
543+
passcount=None, threadid=None, count=0xffffffff):
544544
"""bp(expr,handler,windbgcmd) -> Breakpoint on expression"""
545545
if expr is None:
546546
expr = self.reg.get_pc()
@@ -554,7 +554,8 @@ def bp(self, expr=None, handler=None, windbgcmd=None, oneshot=False,
554554
windbgcmd,
555555
oneshot,
556556
passcount,
557-
threadid)
557+
threadid,
558+
count=count)
558559

559560
def ba(self, expr=None, handler=None, windbgcmd=None, oneshot=False,
560561
passcount=None, threadid=None, size=None, access=None):

0 commit comments

Comments
 (0)