You can switch between the TUI windows using C-x o, i.e. Ctrl+X, then hit the O key. If you think GDB is hard to use, try the DDD graphical frontend. DDD can also display data structures with arrows pointing to where the pointers are pointing.
cgdb is the tool for me. It is very like gdb tui mode but it has syntax highlighting. It also has vim-like keybindings, you can scroll through the whole file you are on, set breakpoints on any line using space. And of course use the plain old gdb commands. It's also been less buggy for me than gdb tui mode. Then again I rarely use a debugger, but when I do cgdb is the one for me!
Some of the gdb version do not support reverse-step debugging. In that case you could add a signal handler for SEGV and set a brake point over there. Once SEGV function hanlder is hit, just type "bt" then it will provide nice information.
You piqued by interest so I tried but it doesn't work, because the stack is smashed so the signal handler can't tell you either: read 1 "a.out" received signal SIGSEGV, Segmentation fault. 0x0000000012bc4ce9 in ?? () (gdb) bt #0 0x0000000012bc4ce9 in ?? () #1 0x0000000032558024 in ?? () #2 0x000000003a640607 in ?? () #3 0x000000005fb18442 in ?? () #4 0x00000000154e605c in ?? () #5 0x0000000000000000 in ?? () (gdb) si Thread 1 "a.out" hit Breakpoint 3, handler (signum=11) at bubble_sort.c:10 10 { (gdb) bt #0 handler (signum=11) at bubble_sort.c:10 #1 #2 0x0000000012bc4ce9 in ?? () #3 0x0000000032558024 in ?? () #4 0x000000003a640607 in ?? () #5 0x000000005fb18442 in ?? () #6 0x00000000154e605c in ?? () #7 0x0000000000000000 in ?? () (gdb)
I find that when I want to use the up and down arrows to go to previous commands in the TUI, it works best to first type `focus cmd`. Switching back is `focus src`. For instance, this makes exploring the structure of some struct easier.
For programmers nowadays though, you face the reality that a good proportion of the rest of your life will be spent finding and fixing bugs in other peoples code.
Interesting video, but I have to report that around 30:20 your asctime function in dump_student is producing a wrong output. It says "Sun Oct 2 09:30:00 2000" (which is the birthday of my daughter, so i remember it very well) and October 2, 2000 was a Monday. I guess asctime is wrong in decoding if 2000 was a leap year or not and obviously estimates that 2000 wasn't a leap year, because it can be divded by 100. But it missed the exception that its a leap year because it also can be divided by 400. ;-)
7 років тому+3
Wow, nice catch. I believe the problem is that in the `dob` structure (a `struct tm`), he's not initializing the `tm_wday` field (weekday), and the uninitialized value seems to be 0, which represents Sunday. That's fixed by adding a line: `.tm_wday = 1,` to the struct initialization. So it doesn't really have to do with the year being leap or not, rather that the `tm` structure wasn't initialized to a correct time.
Thank you, Greg, for the nice presentation! I have learned a lot from it. I wish you have commented on the error message appearing at 52:04: "Process does not support instruction 0xc5". This is a show-stopper for me, preventing me from using reverse debugging with GDB of virtually any code. But apparently, you managed to use the recording somehow in a batch mode. I cannot explain how it is possible if your GDB is susceptible to same problems as mine.
I came here to find out how to have GDB help med develop something on linux. You know what.. it's actually faster developing the entire thing on windows, cross platform, and then deploying after you've tested all your logic in a proper tool. This is .. fucking ... horrible. People _use_ this?!
I used to do the same, but Visual STudio 2015 Update 3 killed it for me. Have to wait until the IDE is fixed, thats why i use QtCreator + GDB now. Well it works - all i have to say about it. But it is weak, so many great debugging tools on windwos windbg on Linux only valgeind + gdb
***** I tried everything. It's obvious that i use something that kills the background code analyser for intellisense so that i can't even use Ctrl-K Ctrl-O because the header-source releation is lost. It hangs on exit and i have to delete the codeinsight data on disk to get the full features of VS again for a few minutes.
Having switched from Visual C# to GDB - I'm a happier developer. I can't give a good reason for it. Heck, Visual C# has a superior IDE (fantastic!) experience compared to Visual C++, and I still feel that way. The killer feature of GDB is being able to debug a client's application remotely, with nothing more than an SSH connection. This is especially useful for paranoid clients that are far away.
Origami Bulldoser people usually use front ends to it. I personally use cgdb which is a step up from gdb cos I find all other front ends kinda crappy. Development on linux can be just as fast as on windows if can put in the time to learn the tools which sadly are all cli. Idk why but Linux tool developers seem to have some phobia to GUI for some reason. The tools are very powerful tho : Python integration and reverse debugging. Just a pain to use.
You can switch between the TUI windows using C-x o, i.e. Ctrl+X, then hit the O key. If you think GDB is hard to use, try the DDD graphical frontend. DDD can also display data structures with arrows pointing to where the pointers are pointing.
cgdb is the tool for me. It is very like gdb tui mode but it has syntax highlighting. It also has vim-like keybindings, you can scroll through the whole file you are on, set breakpoints on any line using space. And of course use the plain old gdb commands.
It's also been less buggy for me than gdb tui mode.
Then again I rarely use a debugger, but when I do cgdb is the one for me!
I use cgdb as my main debbuger. On Hacker news, I also found this github.com/cs01/gdbgui which is a A browser-based frontend/gui for GDB.
cgdb for the win.
Some of the gdb version do not support reverse-step debugging. In that case you could add a signal handler for SEGV and set a brake point over there. Once SEGV function hanlder is hit, just type "bt" then it will provide nice information.
You piqued by interest so I tried but it doesn't work, because the stack is smashed so the signal handler can't tell you either:
read 1 "a.out" received signal SIGSEGV, Segmentation fault.
0x0000000012bc4ce9 in ?? ()
(gdb) bt
#0 0x0000000012bc4ce9 in ?? ()
#1 0x0000000032558024 in ?? ()
#2 0x000000003a640607 in ?? ()
#3 0x000000005fb18442 in ?? ()
#4 0x00000000154e605c in ?? ()
#5 0x0000000000000000 in ?? ()
(gdb) si
Thread 1 "a.out" hit Breakpoint 3, handler (signum=11) at bubble_sort.c:10
10 {
(gdb) bt
#0 handler (signum=11) at bubble_sort.c:10
#1
#2 0x0000000012bc4ce9 in ?? ()
#3 0x0000000032558024 in ?? ()
#4 0x000000003a640607 in ?? ()
#5 0x000000005fb18442 in ?? ()
#6 0x00000000154e605c in ?? ()
#7 0x0000000000000000 in ?? ()
(gdb)
I find that when I want to use the up and down arrows to go to previous commands in the TUI, it works best to first type `focus cmd`. Switching back is `focus src`. For instance, this makes exploring the structure of some struct easier.
thank you for that.
Funny how oj every gdb video i always find some helpful command like this
For programmers nowadays though, you face the reality that a good proportion of the rest of your life will be spent finding and fixing bugs in other peoples code.
Sadly true
This video has made me understand why people dislike gdb. Thanks.
Interesting video, but I have to report that around 30:20 your asctime function in dump_student is producing a wrong output. It says "Sun Oct 2 09:30:00 2000" (which is the birthday of my daughter, so i remember it very well) and October 2, 2000 was a Monday. I guess asctime is wrong in decoding if 2000 was a leap year or not and obviously estimates that 2000 wasn't a leap year, because it can be divded by 100. But it missed the exception that its a leap year because it also can be divided by 400. ;-)
Wow, nice catch. I believe the problem is that in the `dob` structure (a `struct tm`), he's not initializing the `tm_wday` field (weekday), and the uninitialized value seems to be 0, which represents Sunday. That's fixed by adding a line: `.tm_wday = 1,` to the struct initialization. So it doesn't really have to do with the year being leap or not, rather that the `tm` structure wasn't initialized to a correct time.
Super usefull after 40 min mark!! On finding occasionsl bugs
Thank you, Greg, for the nice presentation! I have learned a lot from it. I wish you have commented on the error message appearing at 52:04: "Process does not support instruction 0xc5". This is a show-stopper for me, preventing me from using reverse debugging with GDB of virtually any code. But apparently, you managed to use the recording somehow in a batch mode. I cannot explain how it is possible if your GDB is susceptible to same problems as mine.
Most of the keystrokes are emacs navigation and window organisation keystrokes.
Who woulda known i could just hit Ctrl X A
So is there a part 2 to this?
Should be called: "Making GDB suck less with Python"
A vim guy trying to use a program with Emacs bindings. Funny!!!
I don't see the value of using python. BTW: Can't stand Python! It is FORTRAN to me.
I came here to find out how to have GDB help med develop something on linux. You know what.. it's actually faster developing the entire thing on windows, cross platform, and then deploying after you've tested all your logic in a proper tool. This is .. fucking ... horrible. People _use_ this?!
I used to do the same, but Visual STudio 2015 Update 3 killed it for me. Have to wait until the IDE is fixed, thats why i use QtCreator + GDB now.
Well it works - all i have to say about it. But it is weak, so many great debugging tools on windwos windbg on Linux only valgeind + gdb
I use update 3 without a hitch. you may want to try a reinstall / repair.
***** I tried everything. It's obvious that i use something that kills the background code analyser for intellisense so that i can't even use Ctrl-K Ctrl-O because the header-source releation is lost. It hangs on exit and i have to delete the codeinsight data on disk to get the full features of VS again for a few minutes.
Having switched from Visual C# to GDB - I'm a happier developer. I can't give a good reason for it. Heck, Visual C# has a superior IDE (fantastic!) experience compared to Visual C++, and I still feel that way.
The killer feature of GDB is being able to debug a client's application remotely, with nothing more than an SSH connection. This is especially useful for paranoid clients that are far away.
Origami Bulldoser people usually use front ends to it. I personally use cgdb which is a step up from gdb cos I find all other front ends kinda crappy. Development on linux can be just as fast as on windows if can put in the time to learn the tools which sadly are all cli. Idk why but Linux tool developers seem to have some phobia to GUI for some reason. The tools are very powerful tho : Python integration and reverse debugging. Just a pain to use.