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

Method attach

pydevd_attach_to_process/winappdbg/debug.py:213–265  ·  view source on GitHub ↗

Attaches to an existing process for debugging. @see: L{detach}, L{execv}, L{execl} @type dwProcessId: int @param dwProcessId: Global ID of a process to attach to. @rtype: L{Process} @return: A new Process object. Normally you don't need to use it

(self, dwProcessId)

Source from the content-addressed store, hash-verified

211 pass
212
213 def attach(self, dwProcessId):
214 """
215 Attaches to an existing process for debugging.
216
217 @see: L{detach}, L{execv}, L{execl}
218
219 @type dwProcessId: int
220 @param dwProcessId: Global ID of a process to attach to.
221
222 @rtype: L{Process}
223 @return: A new Process object. Normally you don't need to use it now,
224 it's best to interact with the process from the event handler.
225
226 @raise WindowsError: Raises an exception on error.
227 Depending on the circumstances, the debugger may or may not have
228 attached to the target process.
229 """
230
231 # Get the Process object from the snapshot,
232 # if missing create a new one.
233 try:
234 aProcess = self.system.get_process(dwProcessId)
235 except KeyError:
236 aProcess = Process(dwProcessId)
237
238 # Warn when mixing 32 and 64 bits.
239 # This also allows the user to stop attaching altogether,
240 # depending on how the warnings are configured.
241 if System.bits != aProcess.get_bits():
242 msg = "Mixture of 32 and 64 bits is considered experimental. Use at your own risk!"
243 warnings.warn(msg, MixedBitsWarning)
244
245 # Attach to the process.
246 win32.DebugActiveProcess(dwProcessId)
247
248 # Add the new PID to the set of debugees.
249 self.__attachedDebugees.add(dwProcessId)
250
251 # Match the system kill-on-exit flag to our own.
252 self.__setSystemKillOnExitMode()
253
254 # If the Process object was not in the snapshot, add it now.
255 if not self.system.has_process(dwProcessId):
256 self.system._add_process(aProcess)
257
258 # Scan the process threads and loaded modules.
259 # This is prefered because the thread and library events do not
260 # properly give some information, like the filename for each module.
261 aProcess.scan_threads()
262 aProcess.scan_modules()
263
264 # Return the Process object, like the execv() and execl() methods.
265 return aProcess
266
267 def execv(self, argv, **kwargs):
268 """

Callers 1

do_attachMethod · 0.80

Calls 9

get_bitsMethod · 0.95
ProcessClass · 0.90
has_processMethod · 0.80
_add_processMethod · 0.80
scan_threadsMethod · 0.80
get_processMethod · 0.45
addMethod · 0.45
scan_modulesMethod · 0.45

Tested by

no test coverage detected