GDB Debugging Full Example: Ncurses
brendangregg.com
brendangregg.com
There's nothing quite like watching someone who's an expert both in gdb and the problem domain as they do their thing.
The top photo is of our immersion room staging environment. The versions deployed to production (at a handful of sites worldwide) have a little more polish :-)
It's like watching Iron Man wielding Thor's hammer.
Which is not to compare Brendan to Iron Man, but it's as weird as that would be.
Speaking of which, as I understand it, dbx is to gdb as adb is to mdb. So other than syntax, what IS difference between the adb and dbx families, as you've clearly used both?
# rr record date
rr: Saving the execution of `date' to trace directory `/root/.local/share/rr/date-30'.
[FATAL /build/rr-jR8ti5/rr-4.1.0/src/PerfCounters.cc:195:start_counter() errno: 2 'No such file or directory']
-> Unable to open performance counter with 'perf_event_open'; are perf events enabled? Try 'perf record'.
Aborted
oh-oh... # gdb `which rr`
[...]
(gdb) r record date
Starting program: /usr/bin/rr record date
[...]
[FATAL /build/rr-jR8ti5/rr-4.1.0/src/PerfCounters.cc:195:start_counter() errno: 2 'No such file or directory']
-> Unable to open performance counter with 'perf_event_open'; are perf events enabled? Try 'perf record'.
Thread 1 "rr" received signal SIGABRT, Aborted.
0x00007ffff6d6b418 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 0x00007ffff6d6b418 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1 0x00007ffff6d6d01a in __GI_abort () at abort.c:89
#2 0x00000000005a9133 in FatalOstream::~FatalOstream() ()
#3 0x00000000006303fc in ?? ()
#4 0x0000000000630679 in PerfCounters::reset(long) ()
#5 0x00000000006cbd8f in Task::resume_execution(ResumeRequest, WaitRequest, TicksRequest, int) ()
#6 0x0000000000638be9 in RecordSession::task_continue(Task*, RecordSession::StepState const&) ()
#7 0x000000000063d70e in RecordSession::record_step() ()
#8 0x00000000006354b6 in ?? ()
#9 0x00000000006356f2 in RecordCommand::run(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&) ()
#10 0x000000000061f44d in main ()
I did a bit more gdb debugging (one debugger debugging another, although it's a bit hard as rr is stripped and doesn't have a debuginfo package!), and it looks like it's trying to use PMCs.No PMCs here: EC2 Xen guest. So rr won't work, for me or EC2's 1+ million other customers. Perhaps rr can switch to software events?
...And thanks for the awesome write-up, makes something intimidating for a beginner like myself (gdb) seem somehow less so. Feeling inspired.
I was trying to make it not intimidating by just writing what I knew, and _not_ researching all the odds and ends, instead, just saying "I don't know" etc as appropriate. Plus including my mistakes.
Not being flippant, just wondering because there've been a ton of links about it lately.
But this is often the case with Linux kernel and GNU tool features: they don't appear to have any marketing or sales professionals telling everyone about new features (unlike commercial offerings), which leaves us with many "hidden gems" (as people would say) in Linux + GNU. ftrace is another example.
Guilty as charged. I did just now.
But to be fair, I'd rather use a gdb frontend like realgud in Emacs.