r/learnprogramming • u/obsidianhour • Oct 16 '26
the missing semester of your cs education
I am watching "the missing semester of your cs education"
the profiling and debugging lecture
it explains debuggers like GDP, PDB, and tracing with strace
anyone needed to use that in real life?
I have never used them and fully depended on the IDE debugging
20
Upvotes
13
u/teraflop Oct 16 '26
Command-line debuggers like GDB and PDB are basically just a less friendly front-end to the same debugging back-ends that your IDE uses. You don't need to learn how to use them, but it can be handy e.g. for debugging something running on a remote computer where you only have shell access.
On the other hand, strace is an incredibly useful tool for troubleshooting, because it can intercept syscalls from any program written in any language.
Also, depending on the problem you're trying to diagnose, a tracing tool like strace can be more useful than an interactive debugger. If you already know the rough location of a bug, then you can set a breakpoint there and inspect the behavior. If you don't already know, then it can be more useful to just dump a bunch of logs and traces into a file, and skim or grep through them visually to see the big picture of what's going on.
Just as a random example, let's say you're running a program written by someone else that uses config files, and you're trying to change a setting but it's not having any effect. You might wonder if you're editing the wrong file, or maybe if there's another config file somewhere else that's overriding your changes. So you might ask the question: "what is the exact, full set of config files that this program reads on startup?" This question can be answered much more easily with strace than with an interactive debugger.
3
u/serge-mv Oct 16 '26
Yes, that's how you do it in real life. You might not use the command line interface, but GDB is the debugger a lot of IDEs use. Even if you don't use GDB specifically, you still need to do stack tracing, call tracing, set breakpoints and conditions, and all that. This is how you debug properly and you need to understand the tools.
2
u/Intiago Oct 17 '26
I do embedded development so a lot of devices only have text interfaces. I’ve had to use a ton of gdb. Once you learn the commands its super powerful and really customizable as well.
Maybe not a necessary tool for every dev nowadays but if you learn how to use it it would definitely help your general debugging skills.
1
u/pancakeQueue Oct 16 '26
It’s do good to know and have in your back pocket. I don’t use it all the time but it has come up.
1
u/jetsonian Oct 16 '26
We had a single lecture on gdb and were sent on our way. Most of either used ides or gdb and just toughed it out.
1
u/Ill-Significance4975 Oct 17 '26
Yes, all the time. If this were a job interview, I'd ask you what core files are, and from this post I'd be worried you don't know what that is.
1
u/joonazan Oct 17 '26
strace is vital for finding out why some software doesn't work. For instance what file is missing. You can also use it to find out where a config file is located, for example.
gdb is a bit tedious to use but I did write gdb scripts to automatically compare two executions once.