Settings

Theme

Print is your best debugging tool

hamatti.org

3 points by Hamatti 4 years ago · 4 comments

Reader

Bostonian 4 years ago

You can add a line of code to print a few variables, but it may be easier to add a breakpoint at the same place and use the "info locals" and "info args" commands of gdb to display local variables and arguments.

When do people use print statements vs. gdb? I use print statements out of inertia but wonder if I should gdb more.

  • HamattiOP 4 years ago

    In my experience, print statements should be the starting point because they offer a fast and easy solution and can help you first of all confirm that you're looking at the right part of the code.

    One point when I switch from print to debugger is when I need to run the thing over and over again switching print statements on the way – at that point it makes sense to bring in a debugger tool, halt the execution and explore what's wrong.

pseingatl 4 years ago

How would you use this for LaTeX?

  • HamattiOP 4 years ago

    I haven't used LaTeX enough to really have an answer, sorry. Hopefully someone else who's a power user can comment!

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection