| 176 | self._DebugEventCode_dispatch = dbg_evt_dispatch |
| 177 | |
| 178 | def _debug_event_generator(self): |
| 179 | while True: |
| 180 | debug_event = gdef.DEBUG_EVENT() |
| 181 | try: |
| 182 | winproxy.WaitForDebugEvent(debug_event) |
| 183 | except KeyboardInterrupt as e: |
| 184 | # So we will go out of the loop because of a Ctrl+c |
| 185 | # BP trigger will not be called. |
| 186 | # So AT LEAST quit loop with a coherent context |
| 187 | # Fix thread PC if we just triggered a BP |
| 188 | if (debug_event.dwDebugEventCode == gdef.EXCEPTION_DEBUG_EVENT and |
| 189 | debug_event.u.Exception.ExceptionRecord.ExceptionCode in [gdef.EXCEPTION_BREAKPOINT, gdef.STATUS_WX86_BREAKPOINT]): |
| 190 | # This is a breakpoint: One of ours ? |
| 191 | bp_addr = debug_event.u.Exception.ExceptionRecord.ExceptionAddress |
| 192 | if bp_addr in self.breakpoints[debug_event.dwProcessId]: |
| 193 | # Leave the thread in a coherent state for detach |
| 194 | # Should it be done in detach ? |
| 195 | # And just stock the "Interrupted debug_event" here ? |
| 196 | thread = self.threads[debug_event.dwThreadId] |
| 197 | ctx = thread.context |
| 198 | ctx.pc -= 1 |
| 199 | thread.set_context(ctx) |
| 200 | raise |
| 201 | finally: # If user Ctrl+c -> we could raise just at the return of WaitForDebugEvent |
| 202 | self._current_debug_event = debug_event |
| 203 | yield debug_event |
| 204 | |
| 205 | def _finish_debug_event(self, event, action): |
| 206 | if action not in [windef.DBG_CONTINUE, windef.DBG_EXCEPTION_NOT_HANDLED]: |