I’ve talked a bit about debugging (using an actual debugger) in a few posts, but I don’t know if I’ve ever talked about the challenges that come with debugging.
First, in this context, debugging refers to using an actual piece of software versus various language features. Secondly, using a debugger has its learning curve just like any other piece of software.
And in this tweet, Julia Evans captures it perfectly:
how I got better at debugging pic.twitter.com/zKbPTeWkHn
— 🔎Julia Evans🔍 (@b0rk) August 24, 2016
Not bad, right?
Learn Your Debugger
For those who have yet to take a deep dive into debugging, there are five key things to understand that all debuggers implement.
- Breakpoints. These are places in the source code that you mark that tell the debugger to stop the execution of the source code. Think of them as a good place to start when you’re suspicious that there’s activity near this point in the program. Think of it as pressing pause on some media.
- Continue. If breakpoints stop the execution of the code at a given point, then continue is its counterpart in that it resumes the execution of the source. It’s like pressing ‘Play’ after you’ve paused a video or a song.
- Step In. Say that you set a breakpoint at the point where a method is called. A step in will allow you to step into the function that it’s going to execute so you can trace the code line-by-line to examine variable values and other things that are set at that point in time in the program.
- Step Out. During debugging, you may find yourself in a function that isn’t yielding any results regarding actually finding a bug. If that’s the case, then there’s no reason to stay in that method. So, at this point, this is where you’d want to step out of the function and back up to the last line you were before stepping into the function.
- Step Over. Let’s say that you set a breakpoint right above several method calls, but you don’t care to step into each and every one of those functions. Instead, you might be interested in just stepping into one of them. Stepping over a line of code will still let that code execute but saves you from having to go over each line ultimately saving you time while also allowing any relevant values to still be set (and viewed) within the debugger.
When trying to learn your debugger, learn these features first. From there, some debuggers will offer advanced features (some, but not all).
And if they do, then you can move forward with learning those features.
But if you take these five features to learn your debugger, then you’ll be able to take nearly any debugger worth its weight and be able to work within any environment.
Leave a Reply
You must be logged in to post a comment.