locked
Add breakpoint to Visual Studio while debugging and in app. RRS feed

  • Question

  • I would like to add a breakpoint to visual studio while I'm actually debugging in the application itself. This is because I cannot exit the application to add the breakpoint without changing the application behavior(such as debugging mouse move events). A global hotkey would work fine(doesn't have to be Ctrl-F9).  Any way to get visual studio to do this or do I need to write a custom app that will register it's own hotkey and somehow set the breakpoint in visual studio?
    Wednesday, December 8, 2010 4:31 PM

Answers

  • >As I said, if I do that then I loose where I want to put the breakpoint. It's not a hard concept. Suppose you are trying to debug an onmousemove dealing with drag behavior. How do you expect to go into VS and add the breakpoint when this will cause the drag behavior to cease to exist and hence the breakpoint will be useless. If you add it before executing the program it can cause it to break at a different context then you want.

    So, you want to set a breakpoint while you're performing something
    like a drag/drop operation? I don't know how you'd do that.

    Can't you set a condition on the breakpoint such that it will break
    only in the condition you want?

    Failing that, I'd modify the code such that there is a clear statement
    that I could break on.

    Dave

    • Proposed as answer by Psalm3_3 Thursday, December 9, 2010 8:47 PM
    • Marked as answer by eryang Monday, December 20, 2010 10:02 AM
    Thursday, December 9, 2010 1:58 PM

All replies

  • >I would like to add a breakpoint to visual studio while I'm actually debugging in the application itself. This is because I cannot exit the application to add the breakpoint without changing the application behavior(such as debugging mouse move events). A global hotkey would work fine(doesn't have to be Ctrl-F9).  Any way to get visual studio to do this or do I need to write a custom app that will register it's own hotkey and somehow set the breakpoint in visual studio?

    Jon,

    I'm confused by what you're asking for. You normally don't have to
    close VS to add a new breakpoint, you just click on the line of code
    and press F9 (or whatever keystroke you have the breakpoint command
    mapped to).

    Dave

    Wednesday, December 8, 2010 5:24 PM
  •  

    As I said, if I do that then I loose where I want to put the breakpoint. It's not a hard concept. Suppose you are trying to debug an onmousemove dealing with drag behavior. How do you expect to go into VS and add the breakpoint when this will cause the drag behavior to cease to exist and hence the breakpoint will be useless. If you add it before executing the program it can cause it to break at a different context then you want.

     

    Ex: Suppose you are trying to debug the OnMouseMove event. For some reason there are some unexplained malfunction only at seemingly random times. How do you expect to debug such a case? If you add the breakpoint before the execution then you'll get cases that are most likely working. If you add it when the malfunction actually occurs then you can't actually get to it because the behavior changes(you are no longer in the OnMouseMove handle when you move to VS to add the BP).

    By having a global hotkey, I could still be in at the malfunction, hit the hotkey, and it will break exactly when I want.

    Thursday, December 9, 2010 1:03 PM
  • >As I said, if I do that then I loose where I want to put the breakpoint. It's not a hard concept. Suppose you are trying to debug an onmousemove dealing with drag behavior. How do you expect to go into VS and add the breakpoint when this will cause the drag behavior to cease to exist and hence the breakpoint will be useless. If you add it before executing the program it can cause it to break at a different context then you want.

    So, you want to set a breakpoint while you're performing something
    like a drag/drop operation? I don't know how you'd do that.

    Can't you set a condition on the breakpoint such that it will break
    only in the condition you want?

    Failing that, I'd modify the code such that there is a clear statement
    that I could break on.

    Dave

    • Proposed as answer by Psalm3_3 Thursday, December 9, 2010 8:47 PM
    • Marked as answer by eryang Monday, December 20, 2010 10:02 AM
    Thursday, December 9, 2010 1:58 PM
  • The easiest way I can see is to simply have a global hot key assuming VS can't do i). That way I can do exactly what I want... I just hit, say, ctrl-alt-shift-F9 and the small utility sends F9 to visual studio. All other keys get sent to the app just like normal(so as long as the app doesn't use that hot key everything should be fine).

     

    Thursday, December 9, 2010 11:43 PM
  • Hi JonSlaughter,

    Do you have any concern on this topic now? by the way, please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other community members reading the thread.


    Eric Yang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, December 13, 2010 7:00 AM