9.2 - Debugging - GDB Tutorial

preview_player
Показать описание
We demonstrate how to use GDB to debug a C program.

0:00 GDB
0:15 Introduction
0:48 Getting started
1:21 GDB commands
1:35 Demonstration
2:32 Infinite loop
6:10 Infinite loop 2
10:10 Infinite loop 3
11:56 Incorrect sum
16:18 Invalid CLAs
19:10 Seg fault
21:09 Seg fault 2
Рекомендации по теме
Комментарии
Автор

Relevant gdb commands I've gathered over time:

info gdb
info locals //Vars in local scope
info variables //Vars declared outside current scope
info functions //Names and datatypes of all defined functions
info b all breakpoints
break funcName //Set breakpoint at function funcName (short: b funcName)
break file::line //Set breakpoint at line in file
layout through the layouts of gdb
p var the value of variable var
p var = value //Force set value to a var
run //Start the program
start to (b main && run). Puts temporary b at main
next the current line in source (short: n)
step into function call at current line (short: s)
the execution of current function (short: fin)
execution (After a breakpoint) (short: c)
refresh //Repaint the interface (To fix corrupted interface)
shell cmd 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)
backtrace
break _exit //Breakpoint at exit of program
whatis datatype of expr
ptype print of datatype of expr
watch var when var is modified
watch -l foo //Watch foo loaction
rwatch when foo is read
watch foo if foo>10 //Watch foo conditionally
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 (short: q)

Feel free to correct/add any useful command you know.

coudbook
Автор

Thank god for actual educators creating youtube tutorials! Thanks Chris!

benbernardy
Автор

one of the most under-rated gdb tutorial

anonymousnoman
Автор

Going to college in useless, unless you get a teacher such as this gentleman. The best gdb introduction on the net, thank you guru

MMABeijing
Автор

Finally a program with more bugs than mines.

embeddedbastler
Автор

After 5 years, still the best and most detailed quick tutorial about GDB on YouTube.

Автор

hands down best GDB video WOW so in depth and so much insight

santiagorestrepo
Автор

" I wonder what's the sum of first ten million numbers?
It's a segmentation faul"

Lmao ded

ir
Автор

15:23 it took me so long to finally see it. Remembering that it gave the total of 29, I was pretty confident that it wasn't giving a wrong result because of uninitialized total.

I looked it over many times and even read "total plus-equals arr[i]" every time I read it. Then when you showed it taking on each value in the array I looked at it again. Very cheeky.

After you showed that the array was good, that total started out with the value 0, I paused the video and could absolutely not see the mistake.

PhilippeCarphin
Автор

I was getting No file executable error for sometime but referring to your video the issue is resolved. Thank you so much.

anuradhaedachali
Автор

Explained like a true champion, very well through guide, thanks Chris

IronWill-men
Автор

I have used gdb server first time. Good tutorial. Great thanks from Slovak Republic !

ondrejsakala
Автор

Dude the keyboard clicks and voice... accidentally top-notch asmr.

malusmundus-
Автор

Thank you so much Chris, the way you walked us through the complete code and debugging was really helpful.

raunakpillai
Автор

Thanks for your video, it's helpfull because you show all the basic command that we need to know when we use GDB, but all the explanation you give to debug YOUR program it's not really the topic. Anway it helps me. Thank you

Jackyskan
Автор

Thanks Dr. Bourke! I've been programming for over 30 years in C and was looking for a good gdb instructional vid to pass on to a Windows C programmer new to linux. Yours is the best I found. You hit on most of the common errors as well as some of the best practices. Kudos!

earlr
Автор

Thanks a lot Chris. This video is totally educative.

Mnj
Автор

Thank you kind sir. you explained it simple but in great detail.

saeed
Автор

Loved the layout next command. I didn't know you could see the code while stepping through.

ahmadfaiq
Автор

I'm happy that I've found a good channel like your. Video liked and channel subscribed

celsozacarias