MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / __cleanup_process

Method __cleanup_process

pydevd_attach_to_process/winappdbg/debug.py:573–654  ·  view source on GitHub ↗

Perform the necessary cleanup of a process about to be killed or detached from. This private method is called by L{kill} and L{detach}. @type dwProcessId: int @param dwProcessId: Global ID of a process to kill. @type bIgnoreExceptions: bool

(self, dwProcessId, bIgnoreExceptions=False)

Source from the content-addressed store, hash-verified

571 aProcess.scan_modules()
572
573 def __cleanup_process(self, dwProcessId, bIgnoreExceptions=False):
574 """
575 Perform the necessary cleanup of a process about to be killed or
576 detached from.
577
578 This private method is called by L{kill} and L{detach}.
579
580 @type dwProcessId: int
581 @param dwProcessId: Global ID of a process to kill.
582
583 @type bIgnoreExceptions: bool
584 @param bIgnoreExceptions: C{True} to ignore any exceptions that may be
585 raised when killing the process.
586
587 @raise WindowsError: Raises an exception on error, unless
588 C{bIgnoreExceptions} is C{True}.
589 """
590 # If the process is being debugged...
591 if self.is_debugee(dwProcessId):
592 # Make sure a Process object exists or the following calls fail.
593 if not self.system.has_process(dwProcessId):
594 aProcess = Process(dwProcessId)
595 try:
596 aProcess.get_handle()
597 except WindowsError:
598 pass # fails later on with more specific reason
599 self.system._add_process(aProcess)
600
601 # Erase all breakpoints in the process.
602 try:
603 self.erase_process_breakpoints(dwProcessId)
604 except Exception:
605 if not bIgnoreExceptions:
606 raise
607 e = sys.exc_info()[1]
608 warnings.warn(str(e), RuntimeWarning)
609
610 # Stop tracing all threads in the process.
611 try:
612 self.stop_tracing_process(dwProcessId)
613 except Exception:
614 if not bIgnoreExceptions:
615 raise
616 e = sys.exc_info()[1]
617 warnings.warn(str(e), RuntimeWarning)
618
619 # The process is no longer a debugee.
620 try:
621 if dwProcessId in self.__attachedDebugees:
622 self.__attachedDebugees.remove(dwProcessId)
623 if dwProcessId in self.__startedDebugees:
624 self.__startedDebugees.remove(dwProcessId)
625 except Exception:
626 if not bIgnoreExceptions:
627 raise
628 e = sys.exc_info()[1]
629 warnings.warn(str(e), RuntimeWarning)
630

Callers 2

killMethod · 0.95
detachMethod · 0.95

Calls 12

is_debugeeMethod · 0.95
get_handleMethod · 0.95
ProcessClass · 0.90
has_processMethod · 0.80
_add_processMethod · 0.80
stop_tracing_processMethod · 0.80
_del_processMethod · 0.80
removeMethod · 0.45
clearMethod · 0.45
get_processMethod · 0.45
get_pidMethod · 0.45

Tested by

no test coverage detected