As an an engineer, regardless of your specific engineering sub-field, you are going to have to use a debugger at some point in your career. Interestingly enough, most people, whether it be the general public or engineers, don’t actually know what a debugger is. As Will Wadkins (one of the marketing interns) put it, “It’s one of those things you use all the time but can’t really put into words what it is.”
As an experiment, I went around and asked Digilent employees what they thought a debugger is. After thinking through the question thoroughly here are some of the answers I got:
“A tool that debugs software.” – Amber Mear, blog editor
“I always thought it was a program to edit scripts.” – Sam Logan, web developer
“Like a compiler but instead of looking at it before running it runs the code and stops line by line and allows you to see what has been completed.” – James Colvin, marketing intern
“It’s for when you are writing code and you want to make sure it works.” – Sam Knittel, staff accountant
These answers are all pretty good, but not technically correct. Most of these answers started with “Oh goodness”, or “Why would you ask that?” It’s just not something people think about. I find that in most of my classes that I attend as either a student or TA, most people only barely use their debugger and definitely can’t explain what it is. So I made it my mission to make sure everyone knows what an awesome tool it is!
So without further ado, what actually is a debugger?
A debugger is a tool within most IDEs (integrated development environments) that allows you to pause your code at any point or line. Within your code, you can put breakpoints where the debugger will stop running the code. Wherever the code stops, you are then given the opportunity to look at the values in your variables or registers. Alternatively, you can add watch variables (they may be called other things in different programs) that allow you to see the values at anytime in your debugging session.
There are many instances where this is extremely helpful. Say your program breaks during running and you have no idea why. A debugger allows you to run through the code line by line so you can find exactly what line breaks your code. Then you can see what your values are and what you are doing that is throwing the error.
Another place where a debugger is invaluable is when you are working with pointers. A common error in programming, at least that I saw when I was a computer science TA, is in printing memory locations. A debugger allows you to follow the particular pointer you are working with line by line, and it makes sure you are referencing or de-referencing it correctly (i.e., making sure you are manipulating the either the value or the memory location intentionally). I’ve seen far too many students get frustrated when they try to print out a data set and instead get memory locations.
What did you think a debugger was when you first heard about them? Comment and let us know! Do you have any other common products from engineering that you want to know more about?