CppCon 2016: Greg Law “GDB - A Lot More Than You Knew"

Поділитися
Вставка
  • Опубліковано 17 лис 2024

КОМЕНТАРІ • 43

  • @ximalas
    @ximalas 7 років тому +11

    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.

  • @ericcurtin1990
    @ericcurtin1990 7 років тому +15

    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!

    • @Davidbrcz
      @Davidbrcz 7 років тому +5

      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.

    • @dartme18
      @dartme18 7 років тому +2

      cgdb for the win.

  • @gowrishankars9743
    @gowrishankars9743 2 роки тому +3

    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.

    • @greglaw9145
      @greglaw9145 2 роки тому

      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)

  • @justinbassett8229
    @justinbassett8229 7 років тому +5

    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.

    • @axlslak
      @axlslak 3 роки тому

      thank you for that.

    • @sayori3939
      @sayori3939 8 місяців тому

      Funny how oj every gdb video i always find some helpful command like this

  • @johangamb
    @johangamb 7 років тому +38

    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.

  • @AGBuzz182
    @AGBuzz182 2 роки тому +7

    This video has made me understand why people dislike gdb. Thanks.

  • @koenighaunstetten
    @koenighaunstetten 7 років тому +11

    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.

  • @kippie80
    @kippie80 3 роки тому +2

    Super usefull after 40 min mark!! On finding occasionsl bugs

  • @ViatcheslavBugayov
    @ViatcheslavBugayov 7 років тому +1

    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.

  • @lrochfort
    @lrochfort 7 років тому +2

    Most of the keystrokes are emacs navigation and window organisation keystrokes.

  • @mrlithium69
    @mrlithium69 7 років тому +9

    Who woulda known i could just hit Ctrl X A

  • @ldmnyblzs
    @ldmnyblzs 6 років тому +2

    So is there a part 2 to this?

  • @mrlithium69
    @mrlithium69 7 років тому +6

    Should be called: "Making GDB suck less with Python"

  • @michaelkohlhaas4427
    @michaelkohlhaas4427 7 років тому +5

    A vim guy trying to use a program with Emacs bindings. Funny!!!

  • @kippie80
    @kippie80 3 роки тому +2

    I don't see the value of using python. BTW: Can't stand Python! It is FORTRAN to me.

  • @origamibulldoser1618
    @origamibulldoser1618 8 років тому +9

    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?!

    • @llothar68
      @llothar68 8 років тому

      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

    • @origamibulldoser1618
      @origamibulldoser1618 8 років тому

      I use update 3 without a hitch. you may want to try a reinstall / repair.

    • @llothar68
      @llothar68 8 років тому

      ***** 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.

    • @ShalomCraimer
      @ShalomCraimer 8 років тому +5

      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.

    • @edgerique
      @edgerique 8 років тому +2

      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.