3 Finding problem root causes using advanced debugging techniques
This chapter covers
- Using conditional breakpoints to investigate specific scenarios
- Using breakpoints to log debug messages in the console
- Changing data while debugging to force the app to act in a specific way
- Rerunning a certain part of the code while debugging
In chapter 2, we discussed the most common ways to use a debugger. When debugging a piece of implemented logic, developers often use code navigation operations such as stepping over, stepping into, and stepping out of a line. Knowing how to properly use these operations helps you investigate a piece of code to better understand or find an issue.
But a debugger is a more powerful tool than many developers are aware of. Developers sometimes struggle when debugging code using only the basic navigation, whereas they could save a lot of time if they used some of the other (lesser-known) approaches a debugger offers.
In this chapter, you’ll learn how to get the most out of the features a debugger offers:
- Conditional breakpoints
- Breakpoints as log events
- Modifying in-memory data
- Dropping execution frames
We’ll discuss some beyond-basic ways to navigate the code you are investigating, and you’ll learn how and when to use these approaches. We’ll use code examples to discuss these investigation approaches so that you understand how you can use them to save time and when to avoid them.