Computer Science
Debuggers
Debuggers are software tools used by programmers to identify and fix errors in computer programs. They allow users to pause the execution of a program, inspect the values of variables, and track the flow of the code. Debuggers are essential for troubleshooting and ensuring the correctness of software applications.
Written by Perlego with AI-assistance
Related key terms
1 of 5
4 Key excerpts on "Debuggers"
- eBook - PDF
- John Armstrong(Author)
- 2017(Publication Date)
- Chapman and Hall/CRC(Publisher)
Sometimes a program will crash without providing any clue as to where in the code the problem occurred. A debugger is a tool that helps alleviate this problem. Recall that the compiler turns your C++ code into machine code. Dur-ing this process, the code turns from something you wrote and understand into something that you didn’t write and don’t understand. This is a serious problem. To alleviate the problem, you can compile your code with additional debugging information that links your source code to the machine code that is being executed. If you have compiled your program with the necessary debugging informa-tion, then it is possible to run your program inside a debugger. The debugger will then allow you to step through your code line by line to see what is hap-pening. It will also translate between the machine code and your source code so you can understand what is going on. In addition you can tell the debug-ger to pause the execution whenever an error is detected. This allows you to gather detailed information about the cause of the error. We will describe how to use the Visual Studio debugger on Windows in Section 15.2, and how to use the GDB debugger on Unix in Section 15.3. Other Debuggers work in a similar way. You should consult their documentation. 15.1.5 Divide and conquer If you have a difficult bug to fix, it can be very useful to know the following algorithm for debugging code. (i) By considering which of your unit tests pass and which fail, decide which area of your code contains the error. (ii) Consider how to divide the code that contains the bug into two roughly equally sized pieces. What tests can you run to determine which of these two pieces actually contains the error? (iii) Write the tests. Repeat this process until you have fixed the bug. The important point is that one should not look at all your code and read through it. This approach is very time-consuming and unlikely to work. Instead, this approach uses a divide and conquer strategy. - eBook - PDF
How to Write Good Programs
A Guide for Students
- Perdita Stevens(Author)
- 2020(Publication Date)
- Cambridge University Press(Publisher)
Such frameworks have a learning curve, but once learned, they give you an easy way to turn all your debugging messages on, or off, together. Interactive Debugging Sometimes understanding your bug is easiest if you can interact with the program from the inside, rather than running it as though you were a normal user of the program. For example, if there is a function which, in normal operation, is called by another part of your program, with a complex argument, you may want to call it manually with a simple argument, or with a succession of different arguments, to clarify whether it does what it should. If you have an interactive prompt, you may be able to load your program at the prompt, and have considerable freedom to explore. This is the commonest way to debug Haskell code. It is also possible, although not quite so convenient, in Python (using the code module). A more sophisticated approach, requiring a little more invest- ment up front but with the potential to save you time in the long run, is to use a debugger. A debugger is a specific program whose aim is, as the name sug- gests, to help you get rid of bugs. Most languages have Debuggers available, but they’re often not taught in beginners’ programming courses, because they can be quite forbidding at first. A debugger might be a standalone tool, or might be built into your IDE if you’re using one. The basic features you need to be able to use are: • setting a breakpoint – that is, arranging that every time the flow of control gets to a certain line, the execution will stop, so that you can try: 112 9 How to Debug Your Program • single-stepping – that is, letting the program execute one line at a time, e.g. so that you can check which way it goes at an if statement; or • examining the values of variables. A little exploration of the interface will probably reveal how to use these. Many Debuggers have lots of more sophisticated features, but you don’t need them for now. - eBook - PDF
- Jack Ganssle(Author)
- 2012(Publication Date)
- Academic Press(Publisher)
Once the code was complete, the software engineer spent months isolating bugs using whatever tools were at hand. The process was often a game of wits, earning programmers reputations as practi-tioners of a mysterious art. Programming is now recognized as a com-plex activity to be managed like any other aspect of business. The day of the hacker is gone; programmers, whether working alone or as part of a large group, are now expected to carefully plan their use of resources. Accept the fact that your programs will initially have bugs—per-haps lots of bugs. Embedded systems of a useful size often start life almost hopelessly bug-ridden. Obviously, it's important to strive for perfection during design and coding, but even a respectable 1% error rate means hundreds of problems in a typical program. Once, the language was selected independently of the other devel-opment tools; there was relatively little interaction between them. Now it is important to consider how each component of the development environment will interact. As noted in Chapter 2, be sure that the lan-guage will interface cleanly to your debugging tools. The modern development environment consists of the following tightly coupled components: Debugging Tools 6 7 A host computer, typically a PC, is the platform on which all edit-ing, compilations, and linking takes place. A debugging engine gives you a window into the target system to see just what it is your code is doing. This component can range from a simple monitor program to an in-circuit emulator. A source-level debugger (SLD) is the debugging engine's control software package hosted on the PC. It dynamically links the debugging engine to the program's source code. The ubiquitous PC has become the de facto standard for development platforms. Even traditional development system vendors have unbun-dled their equipment to take advantage of the PC that is inevitably found on every engineer's desk. - eBook - ePub
Troubleshooting Java
Read, debug, and optimize JVM applications
- Laurentiu Spilca(Author)
- 2023(Publication Date)
- Manning(Publisher)
2 Understanding your app’s logic through debugging techniques
This chapter covers- When to use a debugger and when to avoid it
- Using a debugger to investigate code
Not long ago, during one of my piano lessons, I shared the sheet music of a song I wanted to learn with my piano teacher. I was so impressed when he just played the song while reading the music sheet for the first time. “How cool is that?” I thought. “How does someone gain this skill?”Then, I remembered some years ago I was in a peer-programming session with one of the newly hired juniors in the company I was working for. It was my turn at the keyboard, and we were investigating a relatively large and complex piece of code using a debugger. I started navigating through the code, pressing relatively quickly the keyboard keys that allowed me to step over, into, and out of specific lines of code. I was focused on the code but was quite calm and relaxed, almost forgetting I had someone near me (rude of me). I heard this person say, “Wow, stop a bit. You’re too fast. Can you even read that code?”I realized that situation was similar to my experience with my piano teacher. How can you gain this skill? The answer is easier than you thought: work hard and gain experience. While practicing is invaluable and takes a lot of time, I have some tips to share with you that will help you to improve your technique much faster. In this chapter, we discuss one of the most important tools used in understanding code: the debugger.DEFINITION A debugger is a tool that allows you to pause the execution on specific lines and manually execute each instruction while observing how the data changes.Using a debugger is like navigating with Google Maps: it helps you find your way through complex logic implemented in your code. It’s also the most used tool for understanding code.A debugger is usually the first tool a developer learns to use to help them understand what code does. Fortunately, all IDEs come with a debugger, so you don’t have to do anything special to have one. In this book, I use IntelliJ IDEA Community in my examples, but any other IDE is quite similar and offers (sometimes with a different look) the same options we’ll discuss. Although a debugger seems to be a tool most developers know how to use, you may find, in this chapter and in chapter 3, some new techniques for using one.
Index pages curate the most relevant extracts from our library of academic textbooks. They’ve been created using an in-house natural language model (NLM), each adding context and meaning to key research topics.



