introduction to GDB a tutorial - Harvard CS50

  Рет қаралды 243,029

loveuala

loveuala

11 жыл бұрын

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
@coudbook2177
@coudbook2177 3 жыл бұрын
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.
@marsag3118
@marsag3118 6 жыл бұрын
That's how KZfaq should be used.
@nokpiadariusconstantino1333
@nokpiadariusconstantino1333 2 жыл бұрын
Zvnshsksnhsnhwpenhd dvgwbtwieg dgsmhdlsnbdlkwebjwkwjel dndn
@Winged4Ever
@Winged4Ever 10 жыл бұрын
Great explanation! You have really made me start to like this tool.
@jayeshparmar5024
@jayeshparmar5024 8 жыл бұрын
very well explained, a quick grab for the beginners.
@Syke1337
@Syke1337 3 жыл бұрын
2021 and this is still a great Quick Start vid.
@saurabhsoni5047
@saurabhsoni5047 7 жыл бұрын
Wow ! That was Crisp & Clear :)
@4MyStudents
@4MyStudents 3 жыл бұрын
gcc -g factorial.c -o factorial should be first line
@kaysoar
@kaysoar 9 жыл бұрын
fantastic tutorial, thank you!
@partharora16
@partharora16 5 жыл бұрын
This is an excellent tutorial to get started with gdb .
@tayfunozt
@tayfunozt 8 жыл бұрын
neat and comprehensible to begin. thank you
@ds9quark
@ds9quark 10 жыл бұрын
fantastic explanation and delivery. Thank you.
@MrEkg98
@MrEkg98 6 жыл бұрын
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.
@ashishjha9262
@ashishjha9262 6 жыл бұрын
Best video on the topic. Thanks!
@stephenpiper4565
@stephenpiper4565 6 жыл бұрын
Very nice intro to gdb in action on a real problem. thanks!
@waleedking7365
@waleedking7365 9 жыл бұрын
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
@Pulseczar1
@Pulseczar1 4 ай бұрын
I'm not sure examining registers falls into the category of basic use of GDB.
@nna1002
@nna1002 10 жыл бұрын
Thank you teaching us. Looking forward to learn more.
@s1q269
@s1q269 9 жыл бұрын
Thank you for this great video! I Enjoyed it. Well explained ;)
@anthonywu4605
@anthonywu4605 6 жыл бұрын
very helpful intro to gdb, thanks!
@amitrastogi1405
@amitrastogi1405 5 ай бұрын
Great explanation. Thanks!
@lloyd7miller
@lloyd7miller 6 жыл бұрын
great video, clear and to the point
@akhishesh
@akhishesh 5 жыл бұрын
Very Concise and precise
@LLLLLLEON216
@LLLLLLEON216 6 жыл бұрын
This is super helpful. Thanks!
@garv_chawla
@garv_chawla 4 жыл бұрын
Great explanation and presentation style.
@development7378
@development7378 5 жыл бұрын
Well explained. Nice job
@MsUltraKawaii
@MsUltraKawaii 10 жыл бұрын
Great video! Thank you!
@prajjwalsingh6490
@prajjwalsingh6490 2 жыл бұрын
Thanks, great explanation for beginners.
@zoltanfridrich1934
@zoltanfridrich1934 8 ай бұрын
Excellent tutorial!
@VarghaHokmran
@VarghaHokmran 8 жыл бұрын
Very well explanation, Thanks.
@abhisekvit
@abhisekvit 10 жыл бұрын
It was a great tutorial.Thanks
@Aham_Bharatiya_Asmi
@Aham_Bharatiya_Asmi 5 жыл бұрын
Excellent man! Thanks! it was really helpful!
@nokpiadariusconstantino1333
@nokpiadariusconstantino1333 2 жыл бұрын
Rvuwoebuwlvd. Snywkhbgwbhj sfsbgsbgsjgbhjsbgwngwkhwkwv
@EmmanuelBrandt
@EmmanuelBrandt 5 жыл бұрын
excellent intro thanks
@jatinkeshav24
@jatinkeshav24 5 жыл бұрын
Brilliant !
@Nampjg
@Nampjg 4 жыл бұрын
excellent explanation !
@DaveDugganITPro
@DaveDugganITPro 9 жыл бұрын
excellent presentation - thank you
@RafaelRAlves-ml2lr
@RafaelRAlves-ml2lr 8 жыл бұрын
Good video, thank you.
@drum1974s
@drum1974s 6 жыл бұрын
That was very helpful dude
@TheTechnicalman
@TheTechnicalman 5 жыл бұрын
Very nice , thanks.
@smarttrupti2007
@smarttrupti2007 7 ай бұрын
Amazing video👍
@shanigaramnagarjun8792
@shanigaramnagarjun8792 3 жыл бұрын
you are too good at teaching
@ahmedjama1000
@ahmedjama1000 8 жыл бұрын
very helpful and straight to the point thank you
@nokpiadariusconstantino1333
@nokpiadariusconstantino1333 2 жыл бұрын
SvbshsnhsnGbssvbzhsBhqosjpwjwooqoqjvdvdv
@purnact3741
@purnact3741 8 жыл бұрын
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.
@BijuManjeri
@BijuManjeri 10 жыл бұрын
Nice presentation man.. :)
@meaniljangra
@meaniljangra 7 жыл бұрын
NIce video.
@Rizzan8
@Rizzan8 6 жыл бұрын
When I set "break main", enter "r", enter "n" the debugger runs until the end of program.
@chandrasekhar2227
@chandrasekhar2227 10 жыл бұрын
wow great work thanks a lot. ur body language is so funny lol
@RakeshKumar-vm9xo
@RakeshKumar-vm9xo 8 жыл бұрын
"Good explanation..."
@und3rgr0undfr34k
@und3rgr0undfr34k 3 жыл бұрын
awesome!
@turuncueller
@turuncueller 5 жыл бұрын
thank you
@marcelstrzalka
@marcelstrzalka 6 жыл бұрын
how can I get similar syntax highlighting for C in vim?
@ProfBeckmann
@ProfBeckmann 2 жыл бұрын
thanks boss
@Trippze
@Trippze 8 жыл бұрын
doesnt eclipse have something like this built in?
@giupnhanh9459
@giupnhanh9459 10 жыл бұрын
good video
@aloky247
@aloky247 5 жыл бұрын
Could someone let me know the content of his ~vimrc? I would like to get the same color and line number please..
@nicolasorellanacelis9672
@nicolasorellanacelis9672 3 жыл бұрын
Que lejos has llegado Jolimbo.
@paumo8459
@paumo8459 3 жыл бұрын
JOLIMBOOOOOO
@BlensonPaul
@BlensonPaul 8 жыл бұрын
two likes -just because you started with how to quit? it is most imprtant indeed.. (y)(y) nice tutorial :-)
@Pulseczar1
@Pulseczar1 4 ай бұрын
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.
@aashutoshpanchagalle7746
@aashutoshpanchagalle7746 3 жыл бұрын
can you please help me gdb-4.16 which Ubuntu version support
@StormWolf01
@StormWolf01 7 жыл бұрын
The quality of this tutorial is good, but it's really slow.
@RamonChiNangWong078
@RamonChiNangWong078 4 жыл бұрын
Thanks, I've forgot how to use debuggers for 15 odd years (thanks Borland C/C++) also tutorial start at 2:35
@KiranMenon
@KiranMenon 9 жыл бұрын
Good 1
@gregoryfenn1462
@gregoryfenn1462 2 жыл бұрын
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.
@bonbonpony
@bonbonpony 3 жыл бұрын
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.
@CanMetan
@CanMetan 9 жыл бұрын
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.
@lucaswilson898
@lucaswilson898 9 жыл бұрын
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.
@CanMetan
@CanMetan 9 жыл бұрын
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?
@lucaswilson898
@lucaswilson898 9 жыл бұрын
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.
@lucaswilson898
@lucaswilson898 9 жыл бұрын
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.
@CanMetan
@CanMetan 9 жыл бұрын
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.
@Alturnator
@Alturnator 3 жыл бұрын
Providing a link to the original video would've been the right thing to do.
@SayWhaaaaaaaaaaaaaaaaaaaaaaat
@SayWhaaaaaaaaaaaaaaaaaaaaaaat 8 жыл бұрын
how it's shows source code if it's compiled to binary, how it's even knows exact variable names?
@runenight280
@runenight280 8 жыл бұрын
+Tomas Av. debug data, a binary is not simply just an array of instructions (well, not modern ones at least).
@SayWhaaaaaaaaaaaaaaaaaaaaaaat
@SayWhaaaaaaaaaaaaaaaaaaaaaaat 8 жыл бұрын
+Matthew I But 99% of applications do not include debug data :) thats why there is "Release" mode in IDEs :D
@runenight280
@runenight280 8 жыл бұрын
Release mode is just for optimizations, some compilers can still actually optimize and still generate debug data (gcc, etc.)
@bigmofo1122
@bigmofo1122 6 жыл бұрын
But can gdb help me report misogynist attack and rape threats?
@bonbonpony
@bonbonpony 3 жыл бұрын
Nope. For that you need another tool called SJW :J
@bitcode_
@bitcode_ Ай бұрын
hello fellow virgins
@miguelcorreia7034
@miguelcorreia7034 10 жыл бұрын
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?
@DaryxFox
@DaryxFox 9 жыл бұрын
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.
@jongxina3595
@jongxina3595 4 жыл бұрын
great tutorial but damn that body language is a bit disturbing.
@donghuang9256
@donghuang9256 4 жыл бұрын
I really have fun now
@myfreetime123
@myfreetime123 8 жыл бұрын
I saw the bug at the start of this video.
@hellterminator
@hellterminator 8 жыл бұрын
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.
@rishabhsethi29
@rishabhsethi29 6 жыл бұрын
Looks like he is booting too much
@paulmadore370
@paulmadore370 10 жыл бұрын
Bro please stop moving your shoulders.
@quanathan
@quanathan 10 жыл бұрын
hahahahhahah
@AhmedHadiPADI_scuba_instructor
@AhmedHadiPADI_scuba_instructor 7 жыл бұрын
lololololololol made me dance while watching him but love his explanation
@guddubhagat1759
@guddubhagat1759 6 жыл бұрын
now this comment shows where you were focused rather than on the stuff he was explaining !
@rasmiranjanbabu
@rasmiranjanbabu 5 жыл бұрын
Paul Madore it happens, concentrate on gdb
@bbblader911
@bbblader911 9 ай бұрын
Can't unsee this
@agentstona
@agentstona 2 жыл бұрын
dafuq bro your intro video sound is terrible i was wearing my head phones ........It almost made me deaf...............
@johnjohnson5818
@johnjohnson5818 7 жыл бұрын
Quit moving around. Just stand there and talk. Better, don't appear in the video. Simply show your source code and narrate.
@jasonthomas2908
@jasonthomas2908 6 жыл бұрын
Still, I haven't see a video by you that's this good, shoulders moving or not
GDB Tutorial
55:12
CS 246
Рет қаралды 61 М.
Omega Boy Past 3 #funny #viral #comedy
00:22
CRAZY GREAPA
Рет қаралды 32 МЛН
顔面水槽をカラフルにしたらキモ過ぎたwwwww
00:59
はじめしゃちょー(hajime)
Рет қаралды 37 МЛН
Ну Лилит))) прода в онк: завидные котики
00:51
How They Hack: Buffer Overflow & GDB Analysis - James Lyne
16:06
An Introduction to GDB for Debugging C Programs - COMP211 - Fall 2020
1:03:55
Comparing C to machine language
10:02
Ben Eater
Рет қаралды 5 МЛН
GDB Beginner Masterclass
23:31
Mike Shah
Рет қаралды 9 М.
Quick Intro to gdb
20:17
MyGeekAdventures
Рет қаралды 197 М.
you need to stop using print debugging (do THIS instead)
7:07
Low Level Learning
Рет қаралды 402 М.
01 Ghidra Reverse Engineering Tutorial - Simple Crackme 1 (RUS)
30:13
Искандер Шафиков
Рет қаралды 15 М.
Wait, but Who's Debugging the Debugger?!
59:53
Tsoding Daily
Рет қаралды 33 М.
CppCon 2016: Greg Law “GDB - A Lot More Than You Knew"
59:09
Debugging Embedded Systems With GDB?
13:51
Jacob Sorber
Рет қаралды 42 М.
Дени против умной колонки😁
0:40
Deni & Mani
Рет қаралды 9 МЛН
Huawei который почти как iPhone
0:53
Romancev768
Рет қаралды 537 М.
Apple, как вас уделал Тюменский бренд CaseGuru? Конец удивил #caseguru #кейсгуру #наушники
0:54
CaseGuru / Наушники / Пылесосы / Смарт-часы /
Рет қаралды 4,5 МЛН
What’s your charging level??
0:14
Татьяна Дука
Рет қаралды 7 МЛН
Индуктивность и дроссель.
1:00
Hi Dev! – Электроника
Рет қаралды 1,5 МЛН
How Neuralink Works 🧠
0:28
Zack D. Films
Рет қаралды 32 МЛН