Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
We’ve set several breakpoints in our application, but what if we want to remove a few, or simply disable them? Luckily, Visual Studio ships with windows for managing breakpoints so we don’t have to remember where every breakpoint in our application is located.
- Open the Breakpoints Window using the menu (Debug -> Windows -> Breakpoints) to show all the breakpoints set in the solution
- In a large application, the breakpoints window will be extremely helpful because it is the central place where breakpoints can be managed
Sometimes we’ll want to create variables and call methods while debugging. We can use the Immediate Window to accomplish this.
- Open the Immediate Window via the menu (Debug > Windows > Immediate)
Call Stack Window
What if we’ve hit a breakpoint, but want to know what’s been executed previously? The Call Stack Window in Visual Studio will show us what’s been executed and will update as we step through code to different functions/methods.
- Open the Call Stack Window via the menu (Debug > Windows > Call Stack)
While being able to navigate around our code using breakpoints is handy, you might want to be able to navigate code that you don’t necessarily want to debug. Managing enable/disable states for breakpoints you’re using simply to navigate is a bit overkill. Once again, Visual Studio has a mechanism that will allow us to set places just for the purpose of navigation called Bookmarks.
- Open the Bookmark Window via the menu (View -> Bookmark Window)
- The Bookmarks Window will allow you to set bookmarks on lines of code that you want to revisit later. You can also organize the bookmarks into virtual folders to keep track of the different areas they represent.
We've set several breakpoints in our application, but
what if we want to remove a few or simply disable them.
The Breakpoints window provides a central place to manage all of our breakpoints.
This is super helpful in a large project.
To open the breakpoints window, click Debug>Window and then Breakpoints.
Notice, that it has all of our breakpoints listed here.
From here, we're able to quickly navigate to every breakpoint location in our code
simply by double clicking the rows.
You might wanna keep a breakpoint by temporarily avoid hitting it when
From this window,
you can use the checkboxes beside the breakpoints to enable or disable them.
Let's disable a bunch of these breakpoints now.
We can also create a special type of breakpoint from here called
a Function Breakpoint by clicking on the New button.
This Data Breakpoint type is only available when debugging C++ code
right now but we can create function breakpoints.
From here, we enter the name of the function.
This will cause the debugger to pause before entering any method named Prompt.
This is very helpful when debugging methods that might be overridden in
subclasses or when we want to break on all implementations of an interface.
This will cause the debugger to pause before running the base method or
any overridden methods.
I'll disable this right now.
Finally, I want to mention that from the Breakpoints window, you can export and
import sets of breakpoints.
That's the purpose of these two buttons up here.
This is one way to tell your fellow developers where exactly in the code
an issue can be found or if you need to switch to debugging an unrelated issue,
you can save off the breakpoints and then come back to them at a later time.
When a breakpoint is hit, we often want to know how the program got there.
That's the purpose of the Call Stack window.
This is one of the windows that's usually open when Visual Studio is in debug mode.
You can also open it by going to the debug windows menu.
Lets run the debugger until we hit one of these breakpoints here where we're setting
the song.name property.
We can look here on the Call Stack to see that we've stopped where we're setting
the Name property.
We can see that this is being called from within the AddSong method,
which in turn was called from the Main method.
To go to any one of these methods, we can just double click on them.
There are a bunch of options here when we right click on the call stack.
Here, we can change what is shown.
We can show or hide which assembly the method resides in or
we can also pick whether or not to show the parameter types, names and values.
This is helpful because the Call Stack can get quite full when everything is shown.
Notice that nothing calls the Main method or does it?
This is only showing code that is in this Visual Studio project.
We can see what calls the Main method by right-clicking and
clicking Show External Code.
You might be surprised to see that there are so
many things involved with starting your program.
Calling Main isn't the only place we run into external code.
We see it all the time when using code that's calling our code.
Such as in web applications or other types of software frameworks.
It's sometimes helpful to take a deeper look into the Call Stack to understand how
things are working.
You need to sign up for Treehouse in order to download course files.Sign up