Le réseau pour les développeurs > Forums - Accueil > Visual Studio Extensibility > [MACRO][VS2008] Add a "When Hit" Breakpoint with a macro
Poser une questionPoser une question
 

Traitée[MACRO][VS2008] Add a "When Hit" Breakpoint with a macro

  • mardi 30 juin 2009 08:38Patrice LamarcheMVPMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     
    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 ?


Réponses

  • jeudi 2 juillet 2009 07:39Nancy ShaoMSFT, ModérateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     TraitéeA du code
    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.

Toutes les réponses

  • jeudi 2 juillet 2009 07:39Nancy ShaoMSFT, ModérateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateurMédailles de l'utilisateur
     TraitéeA du code
    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.