Live data from Hacker News

Debugging with GDB

sourceware.org

21–30 of 77 posts

Re: Debugging with GDB

#21

I generally stick pretty close to the classic "old but still good" tools, but GDB is something I really could not get a handle on (probably because it isn't a daily-use tool for me).

What do you use for debugging instead?

Print statements, haha.

My code is for linear algebra stuff, so it is pretty much a straight shot through/filling in some RCI loop most of the time, I usually just have to find which OpenMP or MPI barrier is misbehaving.

Re: Debugging with GDB

#24
post #17

Unrelated but does anyone have tips on debugging async code in Nodejs. My work has a gigantic Nodejs monorepo and frankly I am struggling so pointers would be appreciated. There is dependency injection & layers of async / await abstraction. Not fun, when I model my code / unit test against a working sample and some method 25+ layers down does not work as expected as it does not have expected input when the stack fram…

You can use the debugger from Chrome dev tools to debug Node.js. Just run node with the `—-inspect-brk` flag, open `about://inspect` in Chrome, and select your app under remote targets. This has saved me tons of debugging time. See also: https://nodejs.org/en/docs/guides/debugging-getting-started/

Re: Debugging with GDB

#25

I learned a lot of debugging using GDB from Greg Laws CPPCon talk https://www.youtube.com/watch?v=-n9Fkq1e6sg . With that being said, one of the things I've heard is that debugging on Linux is a poorer experience than it is on Windows. I believe that RAD Game Tools tried to create a debugger for Linux that was better, but the project failed for some reason. I hope with the increased interest in Linux, GDB or another…

Interesting, the last time GDB hit the front page the consensus seemed to be it was far ahead of all the competition. Having never seriously used a debugger it seems like it’s an opinion to me.

Re: Debugging with GDB

#27

Are there any easier to use C debuggers than GDB? All I really need to do is watch my variables change with each line.

QtCreator has a very capable debug view. No need to have a Qt project, simply start a binary and step-in into it, or attach to a running process.

Most of IDEs have a similar capability to be able to use debug view without setting up a project.

Re: Debugging with GDB

#28
Disclaimer: I work for undo.io (see my username) on time travel debugging. We use GDB as the front end but the engine underneath is proprietary.

The GDB Documentation is really nice (as GNU project docs tend to be) and I've made lots of use of them. The fact that they've also documented things like the serial comms protocol is a level further still.

Some related stuff we (Undo) have produced about GDB and might be interesting to the audience here...

Articles about less-known parts of GDB functionality: https://undo.io/resources/gdb-watchpoint/

Greg Law's quick talk on little-known features of GDB: https://undo.io/resources/cppcon-2015-greg-law-give-me-15-mi...

Greg's bigger talk on GDB: https://www.youtube.com/watch?v=-n9Fkq1e6sg

Re: Debugging with GDB

#29
post #8

How difficult is it to setup an editor like sublime text with gdb? I'm curious if it can be an alternative to visual studio, meaning a window showing the stack, locals, watch, etc?

I used Geany editor (well, it's called a lightweight IDE) with a Debugger plugin. There's also another debug plugin for it, forgot the name, slightly more capable.

All of these are capable of the basic single-threaded debug operations. Multithreaded is not as robust, but it's quite a cookie per se.

For the basics the TUI is very much alright, as long as you remember the hotkeys.

Re: Debugging with GDB

#30
post #2

Took me some time to get familiar with it but GDB is well documented and fulfills its duty. It looks ancient but it is powerful. Do not underestimate the power of the print command! And the advanced stuff like revers-debugging, multi-threading (all-stop mode - which is the default - and the non-stop mode), binary manipulation (yep, it is possible), and remote debugging. Nowadays accompanied by stuff like debuginfod.…

> Do not underestimate the power of the print command!

Still waiting for it to print the contents of a QList or QString, or pull actual data in cases where I see .

Post reply on HN