Hacker News new | past | comments | ask | show | jobs | submit login

I don't think I've ever used a debugger for anything. I just print the values to the screen. I don't even know why people need debuggers, when just outputting relevant values is so much more straight forward.



Oh, ho ho ho manical laughter. It is true that outputting relevant values is much more straight, but the power of a debugger; using the call stack, conditional breakpoints, value inspection is transcendental..

Using the debugger is a skill. Don't knock it till you try it.


Especially when you have a debugger that lets you step backwards!

https://en.wikipedia.org/wiki/Time_travel_debugging


I never needed any of that and I'm an assembly programmer for 35+ years.

Pascal, x86 assembly, arm assembly, Python ... and sometimes even a mix of them running together.


Because you can not only inspect the relevant values, but also the whole call stack to see how the erroneous value was generated. You can step through the program to see what path control followed and quickly work out what’s causing yous problem.

I mostly use browser debuggers and even then I only use a small fraction of their capabilities, but honestly they are just more effective that printing values.


To add to this: not only does it allow you to step through and follow the control flow of a program. In some hairy cases there are issues which are very difficult to answer with printf debugging.

Let's say a variable is being overwritten and you can't figure out why. It could be some dark corner of the code you missed or it could even be memory corruption. A debugger will let you put a conditional breakpoint on that memory address being written, which will then give you all the context needed to see what's going on. This has helped me solve quite a few really tricky bugs.

There's also the simple case of debugging a tricky crash. Before learning to use a debugger (some twenty years ago) I had to do printf with all kinds of local variables guessing at what might be the cause. Attaching a debugger you mostly just run the program, it gets an access violation, and the debugger breaks showing you the generated exception, the stack, the exact statement which caused the crash (though this mostly requires debugging with optimizations turned off), and you can just hover over any variable to check their values. Most crash bugs which would have been very tricky with printf now take seconds to diagnose because you have the full context of the program just as it was when it crashed, right at your fingertips.

Since this is a comment on a shader program there's also the matter of GPU debuggers which I just have to mention in order to say: you can't really do typical printf debugging for most shaders and graphics debuggers are like magic.


How would you debug a program that you don't have source code access to? Or even a program that has a fairly long compile/link cycle?


I don't debug programs that aren't mine.

Why would you even ask?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: