2. List of topics
● Bugs
● Fixing bugs
● GDB
● Ways of working
● Coredumps
● Main basic commands
Master on Free Software
3. What is a bug?
● Basically, an error in a program
● When a program performs as it shouldn't
perform
● All software have bugs
– Programming is complex
– Human task -> errors
Master on Free Software
4. Fixing bugs
● Have you ever debugged a program?
● Have you ever debugged a C program?
● A debugger allows you to check how a
program is executed or checking what
was doing when it crashed
● In gnome we use gdb for debugging
Master on Free Software
5. GDB
● GNU Debugger
● Text mode
– Other frontends: IDEs, emacs, DDD, XXGDB
● Trace the code
– See what is doing
– Inspect the data
Master on Free Software
6. GDB
● Requirements to debug an application
– Add debugging symbols -> not stripped
– Remove optimizations (-O0)
Master on Free Software
7. Ways of working
● debug a program, start and stop
● debug a running process
● debug a core file (cores activate)
Master on Free Software
8. Core dumps
● Dump of information of a process when it
crashes
– See while it crashed
– Inspect data
● ulimit -c <size of core>
● ./gdb <program> <core>
Master on Free Software
9. Commands
● Run: runs the program from start
● Continue: continues running a stopped program
● Backtrace: show the stack
● Break: add a breakpoint
● Delete: delete a breakpoint
● Next: runs the current line to next
● Step: same as Next, but if current is a function, enter
inside
● Print: print the content of a variable
● Display: same as Print, but more permanent
Master on Free Software
10. Other commands
● Watchpoints (slow)
● Handle signals
● Remote debug
● Use the refcard:
http://www.cs.dal.ca/studentservices/refcards/gdbref.pdf
Master on Free Software