I had to upload this video even though it's already on tube cuz the actual up loader doesn't concern about description so it's hard to find in top rank. This is CS50 video on GDB . for more info visit cs50.tv
Пікірлер: 105
@coudbook21773 жыл бұрын
Relevant gdb commands I've gathered over time: info gdb //Manual info locals //Vars in local scope info variables //Vars declared outside current scope info functions //Names and datatypes of all defined functions info b //List all breakpoints break funcName //Set breakpoint at function funcName (short: b funcName) break file::line //Set breakpoint at line in file layout next //Cycle through the layouts of gdb p var //Print the value of variable var p var = value //Force set value to a var run //Start the program start //Synonymous to (b main && run). Puts temporary b at main next //Execute the current line in source (short: n) step //Step into function call at current line (short: s) finish //Finish the execution of current function (short: fin) continue //Resume execution (After a breakpoint) (short: c) refresh //Repaint the interface (To fix corrupted interface) shell cmd //Run shell command cmd from gdb prompt python gdb.execute(cmd) //Run a gdb command cmd from python prompt set print pretty on //Enable pretty printing (Put in ~/.gdbinit) $ gdb -c core.num //Examine the dumped core file from a SIGSEGV(shell command) bt //Print backtrace break _exit //Breakpoint at exit of program whatis expr //Print datatype of expr ptype expr //Detailed print of datatype of expr watch var //Stop when var is modified watch -l foo //Watch foo loaction rwatch foo //Stop when foo is read watch foo if foo>10 //Watch foo conditionally delete //Delete all breakpoints delete breakpoint_no //Delete breakpoint breakpoint_no command breakpoint_no //Run user listed commands when breakpoint is hit (End list of commands with 'end') file executable //Load the executable for debugging from inside gdb quit //Quit (short: q) Feel free to correct/add any useful command you know.
Great explanation! You have really made me start to like this tool.
@jayeshparmar50248 жыл бұрын
very well explained, a quick grab for the beginners.
@Syke13373 жыл бұрын
2021 and this is still a great Quick Start vid.
@saurabhsoni50477 жыл бұрын
Wow ! That was Crisp & Clear :)
@4MyStudents3 жыл бұрын
gcc -g factorial.c -o factorial should be first line
@kaysoar9 жыл бұрын
fantastic tutorial, thank you!
@partharora165 жыл бұрын
This is an excellent tutorial to get started with gdb .
@tayfunozt8 жыл бұрын
neat and comprehensible to begin. thank you
@ds9quark10 жыл бұрын
fantastic explanation and delivery. Thank you.
@MrEkg986 жыл бұрын
I could have used this last night. Glad I looked up gnu debugger. I figured there was one but didn't know. I installed MSVC instead but decided to check just to be sure if gdb did exist. This is so much easier. I just have to get used to it. I was working on "the reference" last night. exercise 1-12. Couldn't figure out why my program kept newlining spaces. Well I found out it was because where I put the trigger to determine where a new word begins. I should have done it once it finds a new word. Not once the current word is done. Different ways of thinking I suppose. I suppose I could have done it the first way but it was easier for me to ignore spaces this way. Its my third time reading the book and I never got past this chapter. However I have read other C books to entirety. This one is different. This one makes you work a lot more. However how concise the exercises are they do give you hints in the previous chapters. So your not entirely blind. I should have seen this in the previous attempts at reading the book. Thanks for this tutorial. I am going to have to watch it again and again and again.
@ashishjha92626 жыл бұрын
Best video on the topic. Thanks!
@stephenpiper45656 жыл бұрын
Very nice intro to gdb in action on a real problem. thanks!
@waleedking73659 жыл бұрын
you forgot to mention one of the most important things in gdb ! x ! the examine function ! its used to examine the registers and see what they point to (the address) and you can get the output in different ways for example: x/x $eip for displaying the value of eip in hexadecimal x/o $eip for displaying the value of eip in octal x/u $eip for displaying the value of eip in unsigned base-10 decimal x/t $eip for displaying the value of eip in binary x/i $eip for examining the instruction and you can choose the size for example x/2xb $eip for displaying first 2 bytes in hexadecimal x/1xh $eip it gives the same amount of bytes but in one line (h stands for half word which is a short (2 bytes)) or you can use dw (double word 4bytes) and word is 4 bytes as well (w) and you can use the address of the register instead of referencing to it by $eip (info register eip/info registers) oh and you can use type g for giant (8bytes) so display system: o : octal u : unsigned t : binary x : hexadecimal and sizes: w : word (4 bytes) dw : double word(4 bytes) g : giant (8 bytes) h : half word (2 bytes) b : byte (1 byte) so the format is like that: x/ (the examine function) and it takes two arguments the (register/memory address/varible) + display type extra examples: x/x $esp x/o $ebp x/u $eip x/t $edi print $eip (it will make a variable for it and it will display the value and the address) x/2xw $1 and and by the way gdb uses little endian format so the bytes will be reversed for example : x/4xb $eip : 0x7c , 0x4f , 45 , 64 x/1xw $eip: 0x64454f7c why ? : if its not reversed like this : 0x7c4f4564 0x7c = 124 in decimal 0x4f = 79 in decimal 0x45 = 69 in decimal 0x64 = 40 in decimal so : if we do it without reversing it would be: 124*(256^3) + 79*(256^2) + 69*(256^1) + 40*(256^0) = 2085569832 incorrect but 40*(256^3) + 69*(256^2) + 79*(256^1) + 124*(256^0) = 675630972 correct so hope that helped :) i was just bored and though of explaining something and if anyone needs helps add me on Skype waleedking111 and send me a message
@Pulseczar14 ай бұрын
I'm not sure examining registers falls into the category of basic use of GDB.
@nna100210 жыл бұрын
Thank you teaching us. Looking forward to learn more.
@s1q2699 жыл бұрын
Thank you for this great video! I Enjoyed it. Well explained ;)
Very Good Video Bro.. But can u tell me whts the difference between Continue and next command ? Sometimes u have used next and later u used continue.
@BijuManjeri10 жыл бұрын
Nice presentation man.. :)
@meaniljangra7 жыл бұрын
NIce video.
@Rizzan86 жыл бұрын
When I set "break main", enter "r", enter "n" the debugger runs until the end of program.
@chandrasekhar222710 жыл бұрын
wow great work thanks a lot. ur body language is so funny lol
@RakeshKumar-vm9xo8 жыл бұрын
"Good explanation..."
@und3rgr0undfr34k3 жыл бұрын
awesome!
@turuncueller5 жыл бұрын
thank you
@marcelstrzalka6 жыл бұрын
how can I get similar syntax highlighting for C in vim?
@ProfBeckmann2 жыл бұрын
thanks boss
@Trippze8 жыл бұрын
doesnt eclipse have something like this built in?
@giupnhanh945910 жыл бұрын
good video
@aloky2475 жыл бұрын
Could someone let me know the content of his ~vimrc? I would like to get the same color and line number please..
@nicolasorellanacelis96723 жыл бұрын
Que lejos has llegado Jolimbo.
@paumo84593 жыл бұрын
JOLIMBOOOOOO
@BlensonPaul8 жыл бұрын
two likes -just because you started with how to quit? it is most imprtant indeed.. (y)(y) nice tutorial :-)
@Pulseczar14 ай бұрын
I'm not sure how you make a GDB tutorial without telling people to compile with the -g flag, and make sure you aren't employing optimization. So, don't use any -O compiler flags while debugging. Other than that, it's a good tutorial on the basics.
@aashutoshpanchagalle77463 жыл бұрын
can you please help me gdb-4.16 which Ubuntu version support
@StormWolf017 жыл бұрын
The quality of this tutorial is good, but it's really slow.
@RamonChiNangWong0784 жыл бұрын
Thanks, I've forgot how to use debuggers for 15 odd years (thanks Borland C/C++) also tutorial start at 2:35
@KiranMenon9 жыл бұрын
Good 1
@gregoryfenn14622 жыл бұрын
Why is 'quit' shortened to 'q'? How lazy are we meant to be? I get that commands that are typed hundreds of times per session should be as short as possible but a command that it used once a session at most doesn't need to be that short.
@bonbonpony3 жыл бұрын
04:02 If only I could do that with my GDB... :/ (i.e. fade out all that unnecessary junk and let just the current line of source code and perhaps the command line just below it to show clearly) 04:57 Here's another place where this difference in shades of grey would help a lot visually, if the current line of code were highlighted.
@CanMetan9 жыл бұрын
Hmm. I saw some good options in GDB that some of the IDEs do not have. Though it seems I'll debug faster with regular IDEs. Am I wrong guys? More difficult to read, can't "watch" class/struct type variables, 2 key strokes to iterate the code etc. All in all, it seems more difficult to debug with this compared to Eclipse etc.
@lucaswilson8989 жыл бұрын
Kazathul The only problem with eclipse is that it runs in a window. Therefore, you can't run it on servers. If you use the console to compile and run your program frequently, using either becomes the same speed. I prefer the console because a) it lets me see what is actually going on when I compile and execute and b) it's not really any slower than a gui ide because I use the console so frequently.
@CanMetan9 жыл бұрын
Lucas Wilson Oh that makes sense in that case. But why would you even code from the server? Why not develop from your computer and upload to the server? Can you think of another example where gdb is better beside ssh?
@lucaswilson8989 жыл бұрын
Kazathul This is really just a question of whether gui (highly automated) or console (more manual management) is better. When I'm working on a small project, I prefer the console because it is much faster. "touch main.cpp etc.cpp etc.h ...; gedit *& cp /my/gen/makefile ." I make my small project and then I'm done. For major projects, I like the organization and automation Eclipse provides. I can easily see all of my program. Also, I don't have to memorize all the gdb commands.
@lucaswilson8989 жыл бұрын
Kazathul Another reason: coding from pure console (vim, g++, gdb, make, etc) makes you feel and look like a badass, so it's perfect for large egos.
@CanMetan9 жыл бұрын
Lucas Wilson Well I'm earning my ego from the resulting projects : ) Bravado against other developers is doomed to fail. At least supposed to for smart people. Thanks for the feedback. I guess I'll give this a shot. I really would like to use Vim (for the same reasons) the only reason I'm shying away is the debugging feature. I use git etc from terminal anyway. Let's see how this goes.
@Alturnator3 жыл бұрын
Providing a link to the original video would've been the right thing to do.
@SayWhaaaaaaaaaaaaaaaaaaaaaaat8 жыл бұрын
how it's shows source code if it's compiled to binary, how it's even knows exact variable names?
@runenight2808 жыл бұрын
+Tomas Av. debug data, a binary is not simply just an array of instructions (well, not modern ones at least).
@SayWhaaaaaaaaaaaaaaaaaaaaaaat8 жыл бұрын
+Matthew I But 99% of applications do not include debug data :) thats why there is "Release" mode in IDEs :D
@runenight2808 жыл бұрын
Release mode is just for optimizations, some compilers can still actually optimize and still generate debug data (gcc, etc.)
@bigmofo11226 жыл бұрын
But can gdb help me report misogynist attack and rape threats?
@bonbonpony3 жыл бұрын
Nope. For that you need another tool called SJW :J
@bitcode_Ай бұрын
hello fellow virgins
@miguelcorreia703410 жыл бұрын
Hello , i would like make a question, my lldb on OSX Mavericks show code in assembly , so i don't no how chance it to C code , Plz Can you help me solve it?
@DaryxFox9 жыл бұрын
You need to compile with symbols. Pass '-g' to gcc, or use 'make debug'. Xcode should do this automatically when you build the 'Debug' target.
@jongxina35954 жыл бұрын
great tutorial but damn that body language is a bit disturbing.
@donghuang92564 жыл бұрын
I really have fun now
@myfreetime1238 жыл бұрын
I saw the bug at the start of this video.
@hellterminator8 жыл бұрын
Thanks for that. I was just about to comment how using uninitialized values is a bad idea. For some reason it didn't occur to me that there would be a bug showcased in a video about a debugger.
@rishabhsethi296 жыл бұрын
Looks like he is booting too much
@paulmadore37010 жыл бұрын
Bro please stop moving your shoulders.
@quanathan10 жыл бұрын
hahahahhahah
@AhmedHadiPADI_scuba_instructor7 жыл бұрын
lololololololol made me dance while watching him but love his explanation
@guddubhagat17596 жыл бұрын
now this comment shows where you were focused rather than on the stuff he was explaining !
@rasmiranjanbabu5 жыл бұрын
Paul Madore it happens, concentrate on gdb
@bbblader9119 ай бұрын
Can't unsee this
@agentstona2 жыл бұрын
dafuq bro your intro video sound is terrible i was wearing my head phones ........It almost made me deaf...............
@johnjohnson58187 жыл бұрын
Quit moving around. Just stand there and talk. Better, don't appear in the video. Simply show your source code and narrate.
@jasonthomas29086 жыл бұрын
Still, I haven't see a video by you that's this good, shoulders moving or not