@@ -67,19 +67,19 @@ class CallbackHandler(object):
67
67
def __init__ (self ):
68
68
self .callbacks = {} # Key -> [callback list]
69
69
70
- def add_callback (self , name , callback ):
71
- """Add a callback to the key @name , iff the @callback isn't already
70
+ def add_callback (self , key , callback ):
71
+ """Add a callback to the key @key , iff the @callback isn't already
72
72
assigned to it"""
73
- if callback not in self .callbacks .get (name , []):
74
- self .callbacks [name ] = self .callbacks .get (name , []) + [callback ]
73
+ if callback not in self .callbacks .get (key , []):
74
+ self .callbacks [key ] = self .callbacks .get (key , []) + [callback ]
75
75
76
- def set_callback (self , name , * args ):
77
- "Set the list of callback for key 'name '"
78
- self .callbacks [name ] = list (args )
76
+ def set_callback (self , key , * args ):
77
+ "Set the list of callback for key 'key '"
78
+ self .callbacks [key ] = list (args )
79
79
80
- def get_callbacks (self , name ):
81
- "Return the list of callbacks associated to key 'name '"
82
- return self .callbacks .get (name , [])
80
+ def get_callbacks (self , key ):
81
+ "Return the list of callbacks associated to key 'key '"
82
+ return self .callbacks .get (key , [])
83
83
84
84
def remove_callback (self , callback ):
85
85
"""Remove the callback from the list.
@@ -101,24 +101,30 @@ def remove_callback(self, callback):
101
101
102
102
return empty_keys
103
103
104
- def has_callbacks (self , name ):
105
- return name in self .callbacks
104
+ def has_callbacks (self , key ):
105
+ return key in self .callbacks
106
106
107
- def call_callbacks (self , name , * args ):
108
- """Call callbacks associated to key 'name' with arguments args. While
107
+ def remove_key (self , key ):
108
+ """Remove and return all callbacks associated to @key"""
109
+ callbacks = self .callbacks .get (key , [])
110
+ del self .callbacks [key ]
111
+ return callbacks
112
+
113
+ def call_callbacks (self , key , * args ):
114
+ """Call callbacks associated to key 'key' with arguments args. While
109
115
callbacks return True, continue with next callback.
110
116
Iterator on other results."""
111
117
112
118
res = True
113
119
114
- for c in self .get_callbacks (name ):
120
+ for c in self .get_callbacks (key ):
115
121
res = c (* args )
116
122
if res is not True :
117
123
yield res
118
124
119
- def __call__ (self , name , * args ):
125
+ def __call__ (self , key , * args ):
120
126
"Wrapper for call_callbacks"
121
- return self .call_callbacks (name , * args )
127
+ return self .call_callbacks (key , * args )
122
128
123
129
124
130
class CallbackHandlerBitflag (CallbackHandler ):
@@ -299,6 +305,14 @@ def remove_breakpoints_by_callback(self, callback):
299
305
for key in empty_keys :
300
306
self .jit .remove_disassembly_splits (key )
301
307
308
+ def remove_breakpoints_by_address (self , address ):
309
+ """Remove all breakpoints associated with @address.
310
+ @address: address of breakpoints to remove
311
+ """
312
+ callbacks = self .breakpoints_handler .remove_key (address )
313
+ if callbacks :
314
+ self .jit .remove_disassembly_splits (address )
315
+
302
316
def add_exception_handler (self , flag , callback ):
303
317
"""Add a callback associated with an exception flag.
304
318
@flag: bitflag
0 commit comments