Microsoft Developer Network > 포럼 홈 > Visual Studio Extensibility > [MACRO][VS2008] Add a "When Hit" Breakpoint with a macro
질문하기질문하기
 

답변됨[MACRO][VS2008] Add a "When Hit" Breakpoint with a macro

  • 2009년 6월 30일 화요일 오전 8:38Patrice LamarcheMVP사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    Hi everyone,

    I would like to add some breakpoints from my macro. I manage to do this easily thanks to the EnvDte.Breakpoint interface. But I would like to create a "When hit" breakpoint and to associate this breakpoint with a macro (to execute the macro when the breakpoint is reached).

    I've not found any property/method in the objectmodel to help doing this. Do I miss something ?


답변

  • 2009년 7월 2일 목요일 오전 7:39Nancy ShaoMSFT, 중재자사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨코드 있음
    Hi Patrice,

    Base on my understanding, you want to subscribe to an event that is triggered when the debugger has hit a break point. If so, you can try to use  DebuggerEvents object to achieve this, the OnEnterBreakMode Event will be fired when entering  break mode. Please refer to following code snippet:

    // Place the following code in the Exec method of the add-in:
    EnvDTE.DebuggerEvents debugEvents = applicationObject.Events.DebuggerEvents;
    debugEvents.OnEnterBreakMode += 
    new _dispDebuggerEvents_OnEnterBreakModeEventHandler(DebuggerEvents.BreakHandler);
    
    // Place the following Event handler code in the add-in:
    // Needed to activate event handlers in Connect.Exec.
    public static void StartEvents(DTE dte)
    {
        System.Windows.Forms.MessageBox.Show("Events are attached.");
    }
    
    // OnEnterBreakMode Event.
    public static void BreakHandler(dbgEventReason reason, ref dbgExecutionAction execAction)
    {
        System.Windows.Forms.MessageBox.Show("Debugger enters break mode. " + 
                                             "Reason: " + reason.ToString());
    }
    

     

    For more information, please see this thread: SDK Package: wanting to subscribe to the c# debugger onBreakPointHit event.

    If I misunderstood you, or you have any questions, please let me know.

    Best Regards,
    Nancy


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.

모든 응답

  • 2009년 7월 2일 목요일 오전 7:39Nancy ShaoMSFT, 중재자사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨코드 있음
    Hi Patrice,

    Base on my understanding, you want to subscribe to an event that is triggered when the debugger has hit a break point. If so, you can try to use  DebuggerEvents object to achieve this, the OnEnterBreakMode Event will be fired when entering  break mode. Please refer to following code snippet:

    // Place the following code in the Exec method of the add-in:
    EnvDTE.DebuggerEvents debugEvents = applicationObject.Events.DebuggerEvents;
    debugEvents.OnEnterBreakMode += 
    new _dispDebuggerEvents_OnEnterBreakModeEventHandler(DebuggerEvents.BreakHandler);
    
    // Place the following Event handler code in the add-in:
    // Needed to activate event handlers in Connect.Exec.
    public static void StartEvents(DTE dte)
    {
        System.Windows.Forms.MessageBox.Show("Events are attached.");
    }
    
    // OnEnterBreakMode Event.
    public static void BreakHandler(dbgEventReason reason, ref dbgExecutionAction execAction)
    {
        System.Windows.Forms.MessageBox.Show("Debugger enters break mode. " + 
                                             "Reason: " + reason.ToString());
    }
    

     

    For more information, please see this thread: SDK Package: wanting to subscribe to the c# debugger onBreakPointHit event.

    If I misunderstood you, or you have any questions, please let me know.

    Best Regards,
    Nancy


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.