Condividi tramite


Set a Breakpoint on a Function

Keyboard:  CTRL + B
Menu:  Debug -> New Breakpoint -> Break at Function
Command:  Debug.BreakatFunction
Versions:  2008,2010
Published:  4/30/2010
Code:  vstipDebug0020

"Normal" breakpoints are based on line and character position:

image

image

But what if you don't want to break on a specific line but instead break when you hit a particular function?  No problem!  There are three ways to do this:

One

Right-Click a function name and go to Breakpoint -> Insert Breakpoint

image

Two

In the Breakpoints Window, Click on the New button and choose "Break at Function" to bring up the New Breakpoint dialog.

image

Three

Press CTRL + B to bring up the New Breakpoint dialog.

New Breakpoint Dialog

image

 

Options Two and Three will take you to the New Breakpoint dialog.  Here you can type in the name of the function you want to break at then click OK.  Using any of these methods you will see something similar to the following when you are done:

image 

 

And there you have it!  Setting a breakpoint on a function.

Comments

  • Anonymous
    April 30, 2010
    My default VS 2010 shortcut was Ctrl + D, N, not Ctrl + B. Maybe because I am using VS 2010 RC.

  • Anonymous
    May 01, 2010
    user, the shortcuts can be different depending on which "mode" you selected as the default when you first started VS. In order for a breakpoint to work when it is set on a DLL for which you don't have debugging symbols, you need to have Tools>Options>Debugging>Native>Load DLL Exports enabled.  Otherwise, the breakpoint will be set but will never stop.  It took me quite a while to find that one the last time I tried to set a breakpoint on a DLL function when I didn't have symbols.