Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Note
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here
After you have registered your programs with the appropriate port, you must attach the debugger to the program you want to debug.
Choosing How to Attach
There are three ways in which the session debug manager (SDM) attempts to attach to the program being debugged.
For programs that are launched by the debug engine through the LaunchSuspended method (typical of interpreted languages, for example), the SDM obtains the IDebugProgramNodeAttach2 interface from the IDebugProgramNode2 object associated with the program being attached to. If the SDM can obtain the
IDebugProgramNodeAttach2interface, the SDM then calls the OnAttach method. TheIDebugProgramNodeAttach2::OnAttachmethod returnsS_OKto indicate that it did not attach to the program and that other attempts can be made to attach to the program.If the SDM can obtain the IDebugProgramEx2 interface from the program being attached to, the SDM calls the Attach method. This approach is typical for programs that were launched remotely by the port supplier.
If the program cannot be attached through the
IDebugProgramNodeAttach2::OnAttachorIDebugProgramEx2::Attachmethods, the SDM loads the debug engine (if not already loaded) by calling theCoCreateInstancefunction and then calls the Attach method. This approach is typical for programs launched locally by a port supplier.It is also possible for a custom port supplier to call the
IDebugEngine2::Attachmethod in the custom port supplier's implementation of theIDebugProgramEx2::Attachmethod. Typically in this case, the custom port supplier launches the debug engine on the remote machine.Attachment is achieved when the session debug manager (SDM) calls the Attach method.
If you run your DE in the same process as the application to be debugged, then you must implement the following methods of IDebugProgramNode2:
-
After the
IDebugEngine2::Attachmethod is called, follow these steps in your implementation of theIDebugEngine2::Attachmethod:
Send an IDebugEngineCreateEvent2 event object to the SDM. For more information, see Sending Events.
Call the GetProgramId method on the IDebugProgram2 object that was passed to the
IDebugEngine2::Attachmethod.This returns a
GUIDthat is used to identify the program. TheGUIDmust be stored in the object that represents the local program to the DE, and it must be returned when theIDebugProgram2::GetProgramIdmethod is called on theIDebugProgram2interface.Note
If you implement the
IDebugProgramNodeAttach2interface, the program'sGUIDis passed to theIDebugProgramNodeAttach2::OnAttachmethod. ThisGUIDis used for the program'sGUIDreturned by theIDebugProgram2::GetProgramIdmethod.Send an IDebugProgramCreateEvent2 event object to notify the SDM that the local
IDebugProgram2object was created to represent the program to the DE. For details, see Sending Events.Note
This is not the same
IDebugProgram2object that was passed into theIDebugEngine2::Attachmethod. The previously passedIDebugProgram2object is recognized by the port only and is a separate object.
See Also
Launch-based Attachment
Sending Events
LaunchSuspended
IDebugProgram2
IDebugProgramCreateEvent2
IDebugProgramNodeAttach2
OnAttach
IDebugProgramNode2
GetProgramId
IDebugProgramEx2
Attach
Attach