9 ms·
Give me 15 minutes and I'll change your view of GDB (2015) [video]
- okket 9y agoPrevious discussion from a year ago: https://news.ycombinator.com/item?id=12101347 https://news.ycombinator.com/item?id=12101347 (169 comments)
- bennofs 9y agoI found rr to be much better for reverse debugging than gdb's record feature. For some reason, hardware watchpoints while reverse-continuing don't work for me when using gdb record but do when using rr.
- elsjaako 9y agoHe mentions this in his longer talk: https://www.youtube.com/watch?v=-n9Fkq1e6sg https://www.youtube.com/watch?v=-n9Fkq1e6sg
- zython 9y agoThe TUI in gdb is a great way to get started with gdb. Instead of writing your own hooks and commands you can visually step through the program and source code ( if you have debug symbols enabled) I think that more people should know about this feature.
- deleted 9y ago[deleted]
- frankzinger 9y agoAbsolutely. Many of the comments here deride the default gdb interface but the TUI is orders of magnitude more usable and I only learned of it recently. (I much prefer it over Emacs' interface, for example, something another commenter recommended.) And in single-key mode it's even better.
- yen223 9y agoI used to think GDB was a tool with the most broken interface I've ever seen, and which requires arcane commands to do the most trivial of debugging things. I still do, but I used to too. That early dig against Windows was particularly funny. There's no way I would pick that over Visual Studio's debugging tools.
- pjmlp 9y agoGDB already felt like that when we had C++ Builder, Visual C++, Zortech C++ visual debuggers on mid-90's versions of Mac and Windows. The only debuggers that could match them in usability and graphical debugging features were Motif based ones, being sold as a single product.
- exikyut 9y agoFrom a historical-software/UI perspective, I'm curious what that Motif software looks like, and how, er, findable it is. Studying old systems that have fallen by the wayside can often be instructive.
- pjmlp 9y agoStill found on Aix and HP-UX systems, which are the surviving ones. Solaris dropped it, and all other commercial big iron UNIXes are dead. You can get some screenshots here https://en.wikipedia.org/wiki/Common_Desktop_Environment https://en.wikipedia.org/wiki/Common_Desktop_Environment https://sourceforge.net/projects/cdesktopenv/ https://sourceforge.net/projects/cdesktopenv/
- exikyut 9y agoWoops, didn't notice this till now. I wasn't referring to Motif itself, rather the debugger programs. Contemporary UIs are always interesting to study! It's awesome that Motif and CDE are finally open source though.
- progman 9y agoThere are convenient graphical frontends for GDB. DDD for instance can create plots, diagrams, etc. https://www.gnu.org/software/ddd/ https://www.gnu.org/software/ddd/
- xvilka 9y agoradare2 recently added reversible debugging feature too: https://radare.gitbooks.io/radare2book/content/debugger/revdebug.html https://radare.gitbooks.io/radare2book/content/debugger/revd... Note, that you will need version from git, but anyway, new release of radare2 will be ready in less than a couple weeks.
- LeoNatan25 9y agoWinGDB exists and allows remote debugging in Visual Studio to remote machines using gdbserver. Used that in my previous job and was very convenient.
- mtve 9y agofor those who are still prefer documents over video, pdf slides are at https://github.com/CppCon/CppCon2016/tree/master/Tutorials/GDB%20-%20a%20lot%20more%20than%20you%20realized https://github.com/CppCon/CppCon2016/tree/master/Tutorials/G...
- kerneldeveloper 9y agoIf you want to use a powerful gdb visual interface, you may want to try DDD. However, DDD has an old-fashioned GUI which is very crude. I have tried several visual debugging tools, such as RedHat Insight, DDD, Nemiver and kdbg, but none of them is enough powerful or stable. As far as I know, DDD can't display non-English comments in source code. Now I'm using an awesome GDB init file to construct a convenient debugging interface. It's an open source project and you won't regret it: https://github.com/cyrus-and/gdb-dashboard https://github.com/cyrus-and/gdb-dashboard There is also a browser-based frontend for GDB: https://github.com/cs01/gdbgui https://github.com/cs01/gdbgui If you want to try more, search the keyword GDB on GitHub and sort by stars, then you will find many GDB enhancement tools.
- throwaway2016a 9y agoThere are only three comments so far so small sample size but am I the only one who actually likes working in GDB? Then again, I also use Vim as an IDE. But so do a lot of folks here.
- raarts 9y ago[2015]
- grassfedcode 9y agoJust wanted to mention gdbgui, a new front end to gdb that I developed which is similar to Chrome's debugger, has a gdb terminal which you can fall back to if you want to run gdb commands, and data structure/value plotting and visualizations similar to ddd. https://github.com/cs01/gdbgui https://github.com/cs01/gdbgui
- cheez 9y agoThis looks great! Did you know that you can also use Chrome's debugger to debug Node? I wonder how difficult it would be to use Chrome's debugger as a front end for gdb.
- grassfedcode 9y agoNever tried, but pygdbmi would probably get you halfway there. It uses python to parse structured data (key/value pairs) from gdb output. Gdbgui uses it on its backend. (Disclaimer: I am the developer) https://github.com/cs01/pygdbmi https://github.com/cs01/pygdbmi Also for golang: https://github.com/cyrus-and/gdb https://github.com/cyrus-and/gdb
- Asooka 9y agoAwesome! Does it support gdb startup scripts? I.e. the gdb -x option which instructs gdb to read and execute commands from a file and then drops you off in the normal prompt. I regularly use that, because it lets me keep and organise startup options for the programs I work on. I really don't want to have to type all the "set environment" &c stuff that's necessary for the programs I want to debug. Does it (can it) work with the gdb pretty-print API? On the console I can define pretty printers for my data types using python, so I can examine them easily. I almost never want to explore a struct by expanding its fields, I just have a bunch of python scripts that extract a summary of what's important. E.g. for a 3-component vector type I don't need or want something like { x = ... y = ... z = ... } I just have a pretty-printer that spits out "MY::Vector(x, y, z)". Similarly for a whole bunch of other classes. I especially don't want to look at STL objects by field, that's just insane. Honestly, after a couple of years of using GDB, the console interface isn't really a problem for me, and I've become quite attached to the many customisation and automation features it offers. While the commands and syntax are all kinds of gnarly, I don't think I can ever go back to a debugger where I have to do everything manually via direct control. Better, faster, more intuitive direct control is always a good thing, but I don't want it if it's at the expense of the programmability of the debugger.
- futurix 9y ago15 minutes!?! Gosh, even changing my views will be slow with GDB ;-)
- futurix 9y agoI'll take a textual article over video any time.
- 0xcde4c3db 9y agoThe "flipping back and forth" that he seems so impressed with, combined with the arcane key bindings (I know they're Emacs-inspired, but that's little help when the navigation model doesn't actually work like Emacs windows/buffers), is why I dropped TUI pretty quickly. Besides, I have 3 1080p monitors; a UI designed for a VT220 is not the best use of that setup. It also doesn't help that I've never gotten gdbserver to actually work reliably on my embedded Linux targets (which, to be fair, are not Cortex-A/Apple/Qualcomm chips, so probably being tested by ~nobody). I'd understand if some operations aren't supported due to missing debug hardware or emulation magic, but stuff tends to just start mysteriously breaking (e.g. not stopping on breakpoints, hanging when trying to print memory, crashing on resume/step, etc.).
- Wiegand_dawson 9y agoWhy not use cgdb?
- doostee 9y agoI much prefer the cgdb interface to gdb's tui. I've also used it with various embedded builds of gdb. It works great.
- ustokes 9y agoAgree. I started embedded coding on Linux + Qt-Creator. I have everything working, compiling and running on my ARM and AVR chips, but Debuging jsut does nto work. Just can't find any proper info on how to integrate GDB into Qt-Creator and be able to just Debug like in Visual Studio. If this is not possible, that this endeed is very stupid, starting/stopping servers on a remote target and the rest...
- dman 9y agoI don't think the situation is likely to improve much unless as a profession we become open to paying for quality tools.
- pjmlp 9y agoWe used to be open to paying for quality tools, then the FOSS generation took over, killing the business of selling tools to single developers. Nowadays the only way to make money selling developer tools is to sell them to enterprises, the only ones that value developer time vs money spent on tooling.
- pbhjpbhj 9y agoLooks like you need to talk to nocman https://news.ycombinator.com/item?id=14999140 https://news.ycombinator.com/item?id=14999140 or jcelerier https://news.ycombinator.com/item?id=14999140 https://news.ycombinator.com/item?id=14999140? Assuming http://doc.qt.io/qtcreator/creator-debugging.html http://doc.qt.io/qtcreator/creator-debugging.html (which someone else noted) didn't help.
- marquis_wyman 9y agoI still think that GDB sucks pretty much. Every time I wanted gdb to do something, I was just lost, I was not able to do it, and eventually gave up. That doesn't mean gdb was not able to do it, it was just that gdb was too complicated and obscure that it was impossible to me to use it. Gdb is not useless, because QT creator as a debugger is quite good, it it just uses gdb. But extending the functionality, like adding a print functions for my own class, just impossible.
- kali46 9y agoEver heard of a not so new tool called IDE? You are welcome.
- xaedes 9y agomy whole computer is my integrated development environment =)
- corndoge 9y agoA video targeted towards people who haven't spent fifteen minutes in gdb but already think it sucks. Cool beans, just what HN needs
- jdright 9y agoSome other very nice: https://github.com/snare/voltron https://github.com/snare/voltron https://github.com/cyrus-and/gdb-dashboard https://github.com/cyrus-and/gdb-dashboard I particularly like Voltro's view modularity and backends support. But dashboard is a really nice throwback (SoftICE) with its theme and sensible default layout.
- vidarh 9y agoVoltron seems interesting, but on the first application I tried it on, it caused my gdb to hang, and the views remained blank... Hopefully it'll mature fast.
- Graziano_M 9y agoGEF as well: https://github.com/hugsy/gef https://github.com/hugsy/gef Voltron adds awesome views, GEF adds a lot of handy functionality. I use both (often together)
- iopuy 9y agoIf you want a powerful debugger with a crappy interface that is widespread (and programming java) try jdb. It comes with the freaking jdk tool chain so it is basically everywhere, however, gdb can't hold a candle to the horrible experience it is to use jdb without a graphical frontend. The documentation is about a page and a half, that is all, classes must be fully qualified with packages (which can have dozens of levels) in all commands, and it does not use readline for input!!! No left or right arrow to move the cursor! /rant
- tbrock 9y agoThe reverse debugging portion of this video was mind blowing. I had no idea you could do that.
- vidarh 9y agoAs I've written on this subject before, I think current debuggers largely miss the point, though gdb misses the point in a whole different league. What I want from a debugger is 99% of the time met by gdb by running a program and running a backtrace and inspecting a few variables. Where gdb falls flat by default is in making me type in commands to get a register view, backtrace, disassembly of the current area, and the current stackframe. Most other debuggers do ok there. But even with gdb it's trivial to define a few macros to make that part easy. Where every debugger I've used falls flat is that for most harder problems, their functionality seems focused on heaping on functionality to let me do the job the debugger should have, instead of actually doing the things that would really save me time. I've increasingly instead turned to valgrind as my first choice, for the simple reason that a huge portion of the problems I deal with are low level (e.g. debugging my compiler, which involves debugging things like why my code generation doesn't correctly initialise a value on the stack. But this is the same problem I generally would like to be able to debug in higher level languages: Program crashes. Which value caused the crash, or caused the exception to be thrown? When was that value set? Where? What was the code paths that led to that value being set? Which variables contributed to it being set to that value? Fully automating this in the general case is not possible (it devolves to the halting problem if you don't put the debugged program in a "black box"), but making it easy for a human to guide it there should be the priority for a debugger. Being able to get a quick view, see that "huh, that value shouldn't be there", be able to tell the debugger "identify when that variable will change and re-run", and work your way back that way, would solve the vast majority of the tough debugging sessions I've had. Note that the above is not the same as just setting watch-points by tracing and checking. Handling of watches is usually crude in most debuggers. What I'd like is something similar to Valgrind - to do this well the debugger needs to at least analyse the code and intelligently pare down what it watches, and ideally dynamically translate the code into something sufficiently instrumented to let it run fast. For most debugging sessions where I've tried watches, I've had to give up because of how slow they can be, but if the issue is something valgrind can catch, it finds it fast. Support for replays might be an improvement, but it's still about providing tools for us to do the debuggers job instead of semi-automating vital functionality.
- roca 9y agoYou should try using rr. The combination of reverse execution and hardware data watchpoints enables new, much more direct, debugging strategies to answer the kinds of questions you posed.
- abbeyj 9y agoIf don't like the Ctrl-X,A shortcut to get into TUI mode there is a command line option (--tui) to get GDB to start up in TUI mode. I find that a lot easier to remember. I think cgdb (https://cgdb.github.io/ https://cgdb.github.io/) is even better than TUI mode though. Some nice things that it has that TUI mode doesn't: - Colorization of the source code window - The terminal display doesn't get confused when the debugged program prints to stdout - You can still use the up and down arrow keys for moving through your command history and don't have to resort to Ctrl-P and Ctrl-N. Scrolling the source code window also uses the up and down arrow keys but you have to switch the "focus" to the source code window first.
- Asooka 9y ago> - You can still use the up and down arrow keys for moving through your command history and don't have to resort to Ctrl-P and Ctrl-N. Scrolling the source code window also uses the up and down arrow keys but you have to switch the "focus" to the source code window first. Minor correction, that's the same as gdb tui. Use ^X,O to select which window has focus and you can use up and down arrow to go through your command history. The rest is definitely better in cgdb.
- pankajdoharey 9y agoI prefer valgrind over GDB.