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

Method detach

pydevd_attach_to_process/winappdbg/debug.py:723–793  ·  view source on GitHub ↗

Detaches from a process currently being debugged. @note: On Windows 2000 and below the process is killed. @see: L{attach}, L{detach_from_all} @type dwProcessId: int @param dwProcessId: Global ID of a process to detach from. @type bIgnoreExceptio

(self, dwProcessId, bIgnoreExceptions=False)

Source from the content-addressed store, hash-verified

721 self.kill(pid, bIgnoreExceptions=bIgnoreExceptions)
722
723 def detach(self, dwProcessId, bIgnoreExceptions=False):
724 """
725 Detaches from a process currently being debugged.
726
727 @note: On Windows 2000 and below the process is killed.
728
729 @see: L{attach}, L{detach_from_all}
730
731 @type dwProcessId: int
732 @param dwProcessId: Global ID of a process to detach from.
733
734 @type bIgnoreExceptions: bool
735 @param bIgnoreExceptions: C{True} to ignore any exceptions that may be
736 raised when detaching. C{False} to stop and raise an exception when
737 encountering an error.
738
739 @raise WindowsError: Raises an exception on error, unless
740 C{bIgnoreExceptions} is C{True}.
741 """
742
743 # Keep a reference to the process. We'll need it later.
744 try:
745 aProcess = self.system.get_process(dwProcessId)
746 except KeyError:
747 aProcess = Process(dwProcessId)
748
749 # Determine if there is support for detaching.
750 # This check should only fail on Windows 2000 and older.
751 try:
752 win32.DebugActiveProcessStop
753 can_detach = True
754 except AttributeError:
755 can_detach = False
756
757 # Continue the last event before detaching.
758 # XXX not sure about this...
759 try:
760 if can_detach and self.lastEvent and self.lastEvent.get_pid() == dwProcessId:
761 self.cont(self.lastEvent)
762 except Exception:
763 if not bIgnoreExceptions:
764 raise
765 e = sys.exc_info()[1]
766 warnings.warn(str(e), RuntimeWarning)
767
768 # Cleanup all data referring to the process.
769 self.__cleanup_process(dwProcessId, bIgnoreExceptions=bIgnoreExceptions)
770
771 try:
772 # Detach from the process.
773 # On Windows 2000 and before, kill the process.
774 if can_detach:
775 try:
776 win32.DebugActiveProcessStop(dwProcessId)
777 except Exception:
778 if not bIgnoreExceptions:
779 raise
780 e = sys.exc_info()[1]

Callers 7

killMethod · 0.95
detach_from_allMethod · 0.95
_notify_exit_processMethod · 0.95
kill_processMethod · 0.80
kill_threadMethod · 0.80
do_detachMethod · 0.80
_notify_ripMethod · 0.80

Calls 7

contMethod · 0.95
__cleanup_processMethod · 0.95
killMethod · 0.95
clearMethod · 0.95
ProcessClass · 0.90
get_processMethod · 0.45
get_pidMethod · 0.45

Tested by

no test coverage detected