GDB is REALLY easy! Find Bugs in Your Code with Only A Few Commands

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 พ.ย. 2024

ความคิดเห็น • 136

  • @rashidz97100
    @rashidz97100 3 ปีที่แล้ว +221

    Need more low level channels like this. Thank you!

    • @LowLevelTV
      @LowLevelTV  3 ปีที่แล้ว +27

      Glad you like them!

  • @desmondnel5706
    @desmondnel5706 ปีที่แล้ว +60

    One of the clearest, least daunting videos about GDB. I actually feel I could do it.

    • @TheEvertw
      @TheEvertw 11 หลายเดือนก่อน +2

      You can, mate, you can!

    • @cybernit3
      @cybernit3 หลายเดือนก่อน +1

      Ya, I like that he slowly explains, not like other videos where s/he goes too fast.

  • @torf1746
    @torf1746 8 หลายเดือนก่อน +3

    first time using GDB, and this video gave me the tools do everything I normally need in my IDE debugger just fine. Already fixed 2 or 3 bugs in the past few days that would've been a pain in the ass with only print debugging.

  • @abdulrahmanXSO25
    @abdulrahmanXSO25 วันที่ผ่านมา

    Oh!
    What a piece of GOLD I ignored many times!
    Very precious and concise...
    Thank you!

  • @BorisGrishenco
    @BorisGrishenco 2 ปีที่แล้ว +33

    Best videos about C and embedded programming. I love the way you put motivation on the table. And I really appropriate the short length of the video and effort put into it.

  • @MariaNicolae
    @MariaNicolae ปีที่แล้ว +5

    Thank you so much for this. Friendship ended with debug print statements, now gdb is my best friend.

  • @rtothec1234
    @rtothec1234 13 วันที่ผ่านมา +1

    If you guys are not seeing the source C program like it shows while the program is running enter:
    *Ctrl+x* then the number *2* key to split your view as code and assembly
    Then you can see your C program with the relevant line highlighted.

  • @Dygear
    @Dygear 3 ปีที่แล้ว +5

    Ah, gdb my old friend. We don't talk much, but when we do the conversation is invaluable. I tracked down a bug in my php code with gdb for a long lived demon process that was crashing from time to time. Running that program in gdb for a few days until it finally reproduced the error that wasn't making it to the error handler made everything so much clearer. (This was a long time ago, and there was a bug in curl that was causing it, I since moved over to using the native file_get_contents functions for http requests and the bug went away.)

  • @evgusk
    @evgusk 2 ปีที่แล้ว +1

    Never used gdb alone. Always with a front-end. Very interesting to see how to use it directly. thnx!

  • @spendermacleod9189
    @spendermacleod9189 หลายเดือนก่อน

    Thank you so much for this video. I never knew the TUI even existed until you showed it. Viewing my code line by line and seeing what's actually happening at the assembly level really helps me debug my code. Please do more videos on GDB. Great job LLL!!!

  • @BobBeatski71
    @BobBeatski71 2 ปีที่แล้ว +11

    That was a really useful succinct introduction to getting going with GDB. Thanks !

    • @LowLevelTV
      @LowLevelTV  2 ปีที่แล้ว +1

      Glad it was helpful!

  • @kkenzuro
    @kkenzuro 3 ปีที่แล้ว +111

    I noticed a minor mistake when you explaining the failure instruction. This is AT&T assembly syntax (not Intel) so "mov %eax, (%rdx)" means moving the value in %eax to the one referenced by (%rdx), not the other way around.

    • @BobBeatski71
      @BobBeatski71 2 ปีที่แล้ว +3

      How can you tell if the code is AT&T or Intel order ?

    • @kkenzuro
      @kkenzuro 2 ปีที่แล้ว +27

      @@BobBeatski71 the Intel syntax doesn't have "%" or "()" so that instruction would probably look like "mov rdx,eax". And you can set your GDB or objdump to show disassembly code in either syntax.

    • @BobBeatski71
      @BobBeatski71 2 ปีที่แล้ว +3

      @@kkenzuro A little Googling got me the info I needed. The AT&T format of disassembly is very similar to Motorola 68K style so now reading the decode is rather more straightforward. Thanks !

    • @DatBoi_TheGudBIAS
      @DatBoi_TheGudBIAS หลายเดือนก่อน +1

      ​@@BobBeatski71simple. Intel syntax is beautiful and untiutive, AT&T is HORRIBLE and should be banned

  • @dertom1895
    @dertom1895 ปีที่แล้ว +3

    Thanks a lot! Always wanted to know how to use gdb manually and this is a perfect starting point! 👍

  • @klimmesil9585
    @klimmesil9585 2 ปีที่แล้ว +9

    This is really good quality content for beginners. I'm showing this to my classmates that struggle with gdb, and they all seem to like it too. You go straight to the point, give a good concrete example and you speak well. Thank you!

  • @TheEvertw
    @TheEvertw 11 หลายเดือนก่อน

    GDB is invaluable, especially for its ability to handle core dumps.

  • @chandulanethmal8528
    @chandulanethmal8528 ปีที่แล้ว

    Clear and very supportive explanation!

  • @anthonyheak3479
    @anthonyheak3479 10 หลายเดือนก่อน

    Great tutorial, learned something new, thanks!

  • @a.v7998
    @a.v7998 7 หลายเดือนก่อน

    Great Tutorial man. Its so intresting to see the assembly code!

  • @darrensapalo
    @darrensapalo 27 วันที่ผ่านมา

    Excellent work. 🎉

  • @TheDeclancox
    @TheDeclancox 6 หลายเดือนก่อน

    Nice, succinct and to the point! Thank you!

  • @alol-alol
    @alol-alol 3 ปีที่แล้ว +7

    Great video! gdb is one of those tools I know I should know much better. Please keep this stuff coming!

    • @LowLevelTV
      @LowLevelTV  3 ปีที่แล้ว +2

      You got it!

    • @alol-alol
      @alol-alol 3 ปีที่แล้ว

      @@LowLevelTV btw, if you start a Patreon or a TH-cam membership, I’ll definitely subscribe!

  • @Fernando-du5uj
    @Fernando-du5uj ปีที่แล้ว

    Wow. Thank you so freaking much, buddy.

  • @VictorHugoVideos
    @VictorHugoVideos ปีที่แล้ว

    Great video that explains the main features of gdb. Unfortunately, from my experience, as soon as the code gets bigger it becomes harder and harder to use... Easier to call valgrind and put prints everywhere...

  • @ServitorSkull
    @ServitorSkull 7 หลายเดือนก่อน

    Thank you so much! Nice and simple :)

  • @TheTrek01
    @TheTrek01 2 ปีที่แล้ว +1

    Great video - if you link the second video on GDB (mentioned in this video) - that be awesome

  • @birdofhermes6152
    @birdofhermes6152 ปีที่แล้ว

    Thanks for the ref trick

  • @Yas-gs8cm
    @Yas-gs8cm ปีที่แล้ว

    Just knowing I coded ALL these years without a debugger instantly made me 2 times older.

  • @derHutschi
    @derHutschi 11 หลายเดือนก่อน

    Thanks for the tutorial 🤩
    should probably get back in to C in my freetime
    PS: liked and subscribed
    (during my university time I had one semester of C but later in job I only had/could to do Java and later PHP which was one reason I've switched to server admin 😅)

  • @grymmjack
    @grymmjack 9 หลายเดือนก่อน

    THANK YOU!

  • @imad9948
    @imad9948 3 ปีที่แล้ว

    very helpful, thank you Low Level

  • @Aucacoyan
    @Aucacoyan 3 หลายเดือนก่อน

    Thank you!

  • @eduardabramovich1216
    @eduardabramovich1216 11 หลายเดือนก่อน

    Could you create a complete series on reversing with GDB?

  • @kellybmackenzie
    @kellybmackenzie ปีที่แล้ว

    Thank you so much, this helped me so much!!

  • @Ms.Robot.
    @Ms.Robot. 3 ปีที่แล้ว

    Thanks! This was exactly what I needed. ❤️
    I subscribed
    I hope you do more forensic engineering

  • @deutschWallah
    @deutschWallah 2 ปีที่แล้ว

    this is great! Thanks a lot.

  • @matheuslbatista
    @matheuslbatista ปีที่แล้ว +1

    Hey, great video! I'm a noob so... How can I do that on windows? via cmd? Is it possible?

  • @FabioLima-sk9sq
    @FabioLima-sk9sq 2 ปีที่แล้ว

    The explanation was simple and didactic. The audio is clear, it's helps a lot to flow of the idea.
    Help me a lot for beginner in GDB, thank you !!

    • @LowLevelTV
      @LowLevelTV  2 ปีที่แล้ว +2

      Glad it helped!

  • @Zw1d
    @Zw1d 5 วันที่ผ่านมา

    I liked this.

  • @m4rt_
    @m4rt_ 2 ปีที่แล้ว +1

    6:00 that's not an intel instruction, that's an at&t instruction

  • @chillbro2275
    @chillbro2275 2 ปีที่แล้ว

    cool man!!! gdb is really awesome. This opened my eyes and was well explained. And i think you may have solved my question about openjdk vs openjdk-devel. I suppose i could debug in gdb if i use the -devel version. But if i use IDEA i can just debug within it... that's my guess.
    oh i just found out that the jdk comes with jdb debugging tool!

  • @TKcKoucher
    @TKcKoucher 8 หลายเดือนก่อน

    Good content!!

  • @fusca14tube
    @fusca14tube 3 ปีที่แล้ว +1

    Excellent!

  • @eshgholah
    @eshgholah 3 ปีที่แล้ว +1

    Thanks for the great tutorial. 👍. What kind of Linux distro are you running? It looks very clean and nice.

    • @LowLevelTV
      @LowLevelTV  3 ปีที่แล้ว +1

      Ubuntu 20.04 with i3, feh and compton :)

    • @eshgholah
      @eshgholah 3 ปีที่แล้ว

      @@LowLevelTV 🙏🙏🙏

  • @katxolht
    @katxolht หลายเดือนก่อน

    thank you for showing this! I tried using GDB following your example, but after typing break main, the line number does not match with what's in source code. Any idea why? (for ref I'm running it in docker container attached to vs code)

  • @aldoconte6392
    @aldoconte6392 10 หลายเดือนก่อน

    What do you recommend for multi thread programs ?

  • @AymanFakri-ou8ro
    @AymanFakri-ou8ro 7 หลายเดือนก่อน

    thank you :)

  • @Luix
    @Luix 2 ปีที่แล้ว

    what do you recommend to start leaning C for a person that knows java or golang?

  • @eFeXuy
    @eFeXuy 3 ปีที่แล้ว +1

    Cool. Can GDB debug for architectures other than the cpu is running? like ARM on a X86 cpu?

    • @LowLevelTV
      @LowLevelTV  3 ปีที่แล้ว +1

      You can use gdb-multiarch on qemu, I'll probably do a tutorial on that in the coming weeks

  • @louistao-q8i
    @louistao-q8i 8 หลายเดือนก่อน

    which commend you use to display the source code?

  • @aaronkim557
    @aaronkim557 6 หลายเดือนก่อน

    i had a bad habit of only using replit, so switching to linux is very confusing to me. Can you explain how you have your code in the left and command on the right?

  • @PainnAddict
    @PainnAddict ปีที่แล้ว

    What is his linux distro or DE setup it looks so clean ?

  • @AdamS-lo9mr
    @AdamS-lo9mr 10 หลายเดือนก่อน

    is there a way to have a separate run path and source path?

  • @diegonayalazo
    @diegonayalazo 3 ปีที่แล้ว

    Thanks

  • @m1geo
    @m1geo ปีที่แล้ว

    So, both "stepping into" and "stepping over" run the code, but stepping over doesn't go line-by-line into the called function. Somehow I had missed that. I thought it may have been an instruction to ignore (as in, not run at all) that call/instruction.

  • @ThorstenStaerk
    @ThorstenStaerk 12 วันที่ผ่านมา

    when I say break main, the breakpoint is not applied at "endbr64" but three lines below... I have no idea why, it drives me crazy :)

  • @-TheBugLord
    @-TheBugLord ปีที่แล้ว

    How do you get that pretty interface in gdb?

  • @dillingerlee2536
    @dillingerlee2536 3 หลายเดือนก่อน

    I want to debug my binary files written in 16 bit Assembly. Any idea how to make it so I can view my Assembly code in GDB? In this tutorial you add debug info to a C program to make the code visible. Is there a way to do the same to an ASM program?
    You don't have to type NEXTI a second time in GDB. You can just hit Enter 😉

  • @AlaaAreesPhoenix
    @AlaaAreesPhoenix ปีที่แล้ว

    Thanks a lot sir , but i am having an issue with the gdb tui my cmd on windows says tui is not supported when u try to enable it

  • @RaspberryPieman
    @RaspberryPieman 2 ปีที่แล้ว

    Great video - I am really inspired now to discover more. I would like to debug a little assembly code program, I am running on 64bit Raspberry Pi Buster O/S. I am using these commands to assemble/compile to program: as sample.asm -o sample.o ... then gcc -g sample.o sample -nostdlib The program runs fine, but if I try to debug using gdb, it complains that no debugging symbols found in sample. What must I do to the as or gcc commands to get gdb to accept it?

    • @Karukkuvelbro
      @Karukkuvelbro หลายเดือนก่อน

      try running 'file file-name' to find whether your executable contains debugging information

  • @42ott90
    @42ott90 5 วันที่ผ่านมา

    what if i have somthing like scanf ? can i out input un gdb ?

  • @jalmarihuitsikko7211
    @jalmarihuitsikko7211 9 หลายเดือนก่อน

    Hello, necromancer here. I tried this example code but my gcc does not warn about pointer on debian wsl. Is it because of settings or what? If I type int *d = 2; it shows warning.

  • @AmanSingh-sp6bi
    @AmanSingh-sp6bi 3 ปีที่แล้ว +1

    ( 2:25 ) argc=21845. Why is it this random value and not 1 ( as argv[0]='a.out' ) ?
    Whose job is it to set that value, bash or the OS?

    • @LowLevelTV
      @LowLevelTV  3 ปีที่แล้ว +1

      That's a great question, I'm actually not sure. 21845 is 0x5555 in hex, so it may be a bug in GDB with 64-bit programs? I'll keep digging.

    • @BenjaminEggerstedt
      @BenjaminEggerstedt 3 ปีที่แล้ว +2

      @@LowLevelTV I tried this in Win10 WSL (Ubuntu) and it comes up with 0x0, thus it is likely just some bug.

    • @dandan-gf4jk
      @dandan-gf4jk 3 ปีที่แล้ว

      At that line the argc was uninitialized, that's just how it works

    • @AmanSingh-sp6bi
      @AmanSingh-sp6bi 3 ปีที่แล้ว +1

      @@dandan-gf4jk why would it be uninitialized? It is a function parameter and we are passing in only one argument so argc should be 1. If it isn't, it sounds like a bug.

    • @dandan-gf4jk
      @dandan-gf4jk 3 ปีที่แล้ว +1

      @@AmanSingh-sp6bi I just explained it to you, but if you don't trust me go ahead submit the bug to gdb and report back.

  • @draco5991rep
    @draco5991rep 2 ปีที่แล้ว

    I have the problem that gdb just jumps over my entire while loop, I specifically want to debug this while loop and I find no way to step into the while loop which is very very frustating.
    I'm using it over the Code:Blocks Gui, perhaps this is the thing causing all the issues. Code:blocks was recommended to me as a very good IDE to code C with, I still have to see the benefits, as for now it causing more issues than it solves ^^'

  • @KimberlyAhmad-r3n
    @KimberlyAhmad-r3n 2 หลายเดือนก่อน

    O'Connell Keys

  • @whyareyoulookingatthislol
    @whyareyoulookingatthislol 2 ปีที่แล้ว

    tui e is so OP

  • @sergey6661313
    @sergey6661313 3 หลายเดือนก่อน

    how to jump outsize of "fors" I always end up in the wrong place :(

  • @steevensonemile
    @steevensonemile ปีที่แล้ว

    i have lldb compatible to Mac M2. the commands are not the same.

  • @manojamrutharaj9071
    @manojamrutharaj9071 2 ปีที่แล้ว +1

    Hi, may I know the details of the environment that you are using for the demonstration? Thanks for this video.

  • @kyana5229
    @kyana5229 2 ปีที่แล้ว

    i’m in cs50 and used a function called get_string, when i did the compiler code, gcc -o substitution substitution.c -g, it gave me an error saying undefined reference to ‘get_string’

    • @LowLevelTV
      @LowLevelTV  2 ปีที่แล้ว

      You probably called the function before you defined it. At the top of the file put the function prototype so the compiler knows it exists.

  • @NosebergEatzbugsVonShekelstein
    @NosebergEatzbugsVonShekelstein 3 หลายเดือนก่อน

    "Tack"... where are you getting that?

  • @adamloepker8057
    @adamloepker8057 ปีที่แล้ว

    How the hell do you get the terminal giu while running gdb? I have not seen that before

  • @Sgt_Sot
    @Sgt_Sot ปีที่แล้ว +1

    My code is so catastrophic that GDB segfaults...

  • @crispytek6783
    @crispytek6783 ปีที่แล้ว

    hey I'm not able to see the source code even tho I have put the -g tag... I only get the logs :(

  • @ShirleyMiller-i9u
    @ShirleyMiller-i9u 2 หลายเดือนก่อน

    Lionel Greens

  • @zurnu74
    @zurnu74 4 หลายเดือนก่อน

    I'm on GDB tutorial number 4 and I still don't know how to return from a library file line to my own code

  • @TheoMehlhaff-n9n
    @TheoMehlhaff-n9n 2 หลายเดือนก่อน

    Jaime Knolls

  • @CassandraQuinn-d6x
    @CassandraQuinn-d6x 2 หลายเดือนก่อน

    Wolff Flats

  • @hajikelist
    @hajikelist ปีที่แล้ว

    🎉

  • @ibrahimosama5236
    @ibrahimosama5236 4 หลายเดือนก่อน

    where is the next video man come on

  • @Pulseczar1
    @Pulseczar1 10 หลายเดือนก่อน

    I would not include anything about assembly language in a tutorial that is supposed to cover the basics of GDB. You also go too fast when typing/entering commands, requiring the viewer to go back and pause the video to see what you did.

  • @GrayOdelette-u8b
    @GrayOdelette-u8b 2 หลายเดือนก่อน

    Darby Vista

  • @JulianMeredith-p4t
    @JulianMeredith-p4t 2 หลายเดือนก่อน

    Samantha Glen

  • @DMe-l7f
    @DMe-l7f ปีที่แล้ว

    cool

  • @Nonchalant2023
    @Nonchalant2023 ปีที่แล้ว

    This is great. I just wish you were a little slower, it' s too much info in one punch

  • @ronen124
    @ronen124 2 ปีที่แล้ว

    👍

  • @AllieOdell-o5z
    @AllieOdell-o5z 2 หลายเดือนก่อน

    Ahmad Summit

  • @BrianRosenblum-x2l
    @BrianRosenblum-x2l 2 หลายเดือนก่อน

    Tavares Stream

  • @AnthonyTernence-t5d
    @AnthonyTernence-t5d หลายเดือนก่อน

    Aufderhar Village

  • @HumphreyBarbara-m5l
    @HumphreyBarbara-m5l 2 หลายเดือนก่อน

    Turner Fort

  • @SherilynRougier-j3h
    @SherilynRougier-j3h 2 หลายเดือนก่อน

    Dicki Flat

  • @SanderScott-p4c
    @SanderScott-p4c หลายเดือนก่อน

    Kristina Pine

  • @DigitalNomadOnFIRE
    @DigitalNomadOnFIRE ปีที่แล้ว +1

    Or you know, use an IDE like VS 22 🤡

  • @kwazar6725
    @kwazar6725 ปีที่แล้ว

    Nobody needs low level nowadays. I used to do lots of low level coding. Os writing, drivers,... lots of cross platform... asm c c++ ... now script kiddies in jscript cobble together stuff.

    • @daltrooliveira7987
      @daltrooliveira7987 ปีที่แล้ว

      Yes they do but only big companies doing adult stuff like compilers, OS, libraries, browsers, DBMS, high performance software etc. Yes less people are using low level today because everybody is programming using a hight level abstraction over a low level implementation already done by some really smart guys like the author of this video, for example today everybody programms in javascript so they think that C++, assembly x64 is not useful but javascript is executed by in Chrome by the interpreter V8 Engine(parses and executes javascript) that was created in C++ by google developers then in the end javascript developers ended up running C++. Java developers code in java with is translated to bytecodes with is runned by the JVM(created using C++). Python interpreter are created with C++ and used in the backend of his interpreters the C++ libraries for performance. Linux, Windows, etc were created and and run C++, assembly code than if you boot you PC you execute with UEFI(firmware made with low level coding) as the first thing and then loads your OS. Then everybody is always using low level but is transparent to then. Yes most developers don't use low level because others developers usually much more smart and prepared already created stairs for the theirs children(the rest of the developers) to follow. Yes this make the life of the 99% of the developers much more easy. It is the same atitude as the people who are only live today because they taked vacines when were children but become adults and out of complete ignorance think that vacinnes are a bad thing when they woudn't even been alive today if were not because of the vaccines. I'm personally very greateful for both the really smart people who can create vaccines and low level so I can just make 'lego programming'(easy but 'build' software fast and earn money) and pay my debts in the end of the month.

    • @turdwarbler
      @turdwarbler 11 หลายเดือนก่อน

      hahaha, you are so wrong. I do low level every day.

    • @dadlord689
      @dadlord689 11 หลายเดือนก่อน

      I am working with C++ and for 6 years haven't seen a single reason to go low level. Write your code, fix a bug (it will be a logical one or nullptr) and have your fun with compiler can't link shit for whole day. And than half an hour of compilation, multiply it 2/10 times and your life is wasted for today.

    • @turdwarbler
      @turdwarbler 11 หลายเดือนก่อน

      @dadlord689 well you don't do the sort of job I do then. And if you think C++ isn't low level then think again. Haha

    • @dadlord689
      @dadlord689 11 หลายเดือนก่อน

      @@turdwarbler Well, I am just doing job. I would combine languages, do the job and forget it. Most languages and tools are just stone age type. Maybe ai will help crate something actually useful but overall it is just digging ground with a stick. Almost impossible to be anywhat productive as a single developer while you actually capable to architecture so much more per day. Heay, I don't mind anyone liking it.

  • @BenjaminLindner-b2y
    @BenjaminLindner-b2y 2 หลายเดือนก่อน

    59732 Ryann Cliffs