Download presentation
Presentation is loading. Please wait.
1
Using a Debugger 1-Jan-19
2
About Debuggers Bugs happen
Sometimes you can figure the problem out right away Sometimes you have to track down the problem A Debugger can be a big help Sometimes it’s exactly the tool you need Sometimes it isn’t Debuggers are all basically pretty much alike “If you know one, you know them all” BlueJ comes with a nice, simple debugger that gives you all the most important functionality Unfortunately, BlueJ’s debugger is crash-prone
3
What a debugger does A debugger lets you step through your code line by line, statement by statement At each step you can examine the values of all your variables You can set breakpoints, and tell the debugger to just “continue” (run full speed ahead) until it reaches the next breakpoint At the next breakpoint, you can resume stepping
4
Setting a breakpoint Click in the left margin to set or remove breakpoints
5
Reaching a breakpoint Run your program normally; it will automatically stop at each breakpoint
6
The Debugger window When you reach a breakpoint, the debugger window will open Or, you can open it yourself from the menus
7
Parts of the Debugger window
You can usually ignore Threads Your variables and their values, as it says This is how you got here
8
Viewing objects Double-click it to get this This isn’t very helpful
9
Debugger commands Step ahead one statement; but if it calls a method, step into the method Quit debugging and just run, until you hit another breakpoint Step ahead one statement Quit
10
Stepping into a method Here we are in the new method
This is how we got here
11
Cautions The BlueJ debugger is very flaky—use with care
Debuggers can be very helpful, but they are no substitute for thinking about the problem Often, print statements are still the better solution
12
The End
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.