Session 3
Session 3
debugging tools:
iterative debugging
debgging techniques :
break points
debugging cycle:
debugging types:
difference bwtween printting and logging : Logging the messages are written in log
files ! we can open these
files and analyse what's written in logging files !!! not effective because it
needs to change the code and recompile not recommended!
break points:
watch points: ask the program to stop at a certain condition !
back trace
core dump
GDB debugger!
_________________________________________________________________________
interactive debugging : send request to debugger and the debugger responds ! but
this debuggig tool is not always possible !
why? => program can crush no running program to debug !
=> when the program is running wihout a debugger ! (on a machine or...)
=> no pemission to access !
postmortemm debugging using coredemp binary files that are generated by corrupted
programs that have bugs and have the most important info about the execution
of the progam and can be analized offline and can be done on a different
computer !
coredump are binary files geneated by the OS!
call stack :
________________________________________________________________________________
Use the GDB the GNU debugger :
we need the debug symboles to debug the pogram like : the name of the fnction ,
location ...
add -g
gcc -g fact.c -o fact.exe // add the -g when compiling to add the information to
the binay !
we candebug without the bina smboesbut we cannot get the visuale info !
(gdb)break fa
gdb./fact debug.exe
(gdb)beak 5
gdb) run
(gdb) s
(gdb) pint
comileagain
______________________________________________________________________________
make the diffenece eteen the two types of the binary files :
file fact_debug.exe the file command can be detect the debug info => with debug
info !
back trace :
os sends the segmentation violation signal to the process and the pocess ends the
execution diectly!
crush =! bugs
./prog2.exe
gdb prog2.exe
run
to now what is the last einstrunction executed before the crush we do back trace
(gdb)bt command
we can intall the version of standard librar with the standard symboles!