4 ms·
> Trying to have some debugger program like gdb and then talking to it from emacs or a terminal or something will be a big pain. If you're already familiar wit
by alexhutcheson 6y ago
> Trying to have some debugger program like gdb and then talking to it from emacs or a terminal or something will be a big pain.
If you're already familiar with Emacs commands, then the M-x gdb interface is as good as any debugger interface in an IDE.
If you're not already an Emacs user, then the TUI[1] (gdb -tui) is surprisingly good - much better than the "old school" approach I was taught in college of just interacting via the gdb prompt.
> Debuggers work well for what, windows and websites?
I spend most of my time on a large C++ project that does neither of these things, and I still use gdb a lot. In my experience, it's most useful for unit tests - you identify a bug, write a unit test that triggers the bug, and run the unit test under gdb to poke around and understand what's going on.
gdb and lldb don't work great when run on the whole program, mainly because it's hard to specify the actual behavior you want when debugging a system where multiple threads are executing concurrently. Almost all of our unit tests are single-threaded, so this isn't a problem when debugging unit tests.
If you're working on a C or C++ program and using a supported processor, I also highly recommend trying out rr[2], the record and replay debugger, which you mentioned in your comment. Unlike gdb, it's reasonably easy to use and understand even if your program has lots of concurrency, and it pretty much eliminates the need to do "printf" debugging, since you can print variables from any line in your program without recompiling and re-running. You can still use the Emacs or TUI gdb interfaces when using "rr replay".
[1] https://sourceware.org/gdb/current/onlinedocs/gdb/TUI.html#TUI https://sourceware.org/gdb/current/onlinedocs/gdb/TUI.html#T...
[2] https://rr-project.org/ https://rr-project.org/
- yakubin 6y ago>> Debuggers work well for what, windows and websites? > I spend most of my time on a large C++ project that does neither of these things, and I still use gdb a lot. I think that, when GP wrote "windows", they meant the operating system. And when they wrote "debuggers work well", they meant the quality of debuggers, not whether using a debugger is a good idea. Quality of Windows debuggers is generally on a whole other level than on Linux. Chromium DevTools also has a nice debugger. I don't know about Java.
- dan-robertson 6y agoBy windows, I really meant visual studio at its peak.
- mijoharas 6y agoI need to throw a million +1's at the `rr` suggestion. it's really great. It's a shame that it doesn't work on ARM processors, but there are good fundamental reasons why it doesn't (it's basically impossible iirc[0]) EDIT - just to mention, rr is mostly compatible with gdb, so frontends such as gdb-many-windows in emacs can work with it. In terms of U.I's I found `gdb-many-windows` to be the nicest i found. While I hate almost everything about the platform, I have to concede that visual studio's debugging integration is actually really good. The only thing I found annoying was that I needed to use Visual Studio for it! (emacs on windows could be annoying enough that I got used to it eventually, but still preferred my linux environment. This is back when working on a cross platform C++ project if that much weren't already clear). [0] https://github.com/rr-debugger/rr/issues/1373#issuecomment-151642482 https://github.com/rr-debugger/rr/issues/1373#issuecomment-1...
- pflanze 6y agoThe last part of that page mentions that it has recently been made to work on aarch64 given the right CPU and all code including libraries built so they avoid using the offending instructions.
- mst 6y agoCame here to mention this but happy to've been beaten to it. However I'd also like to say "reading that entire thread from the linked comment down is fascinating and I'd recommend it".
- mijoharas 6y agoOh thanks for the update! I'd dug into this a fair bit, but not for a few years, that's fantastic news!
- dan-robertson 6y agoI spend my life in emacs (comments passim) but I put it to you that M-x gdb is mostly unpleasant, as is gdb --tui. Both pale in comparison to visual studio 10-15 years ago. The OP and the post which the OP is following up to both mention those debugger interfaces.