190 likes | 341 Views
The Usage of Linux Debugging Techniques Ramya B.B. Agenda. What is Debugger ? Significance, options, tools and scenario Working with GDB Working with DDD KDB - Introduction Linux Trace Toolkit . What is a Debugger ?. Insect repellant – software tool
E N D
Agenda • What is Debugger ? • Significance, options, tools and scenario • Working with GDB • Working with DDD • KDB - Introduction • Linux Trace Toolkit
What is a Debugger ? • Insect repellant – software tool • Detect the source of program errors • Step through the malfunctioning portion of the program to examine data and check operational conditions.
Significance of Debugging • Working procedure of the program • Problems using printf statements • Localizing error • Tracing the bug
Options to Debug Stepping Breakpoint Watch points Catch points
Linux Debugging Tools • GDB – GNU debugger • DDD – Data Display Debugger • KDB – Kernel Debugger • LTT – Linux Tool Trace Kit • ……….. etc
Debugging scenario • Testing • Localization • Correction • Verification
Working with GDB • Allow you to see what is going on “inside” program while it executes • 4 things to help you catch bugs 1 Start your program with specifying anything that might affect its behavior. 2 Make your program stop on specified conditions. 3 Examine when your program has stopped. 4 Change things in your program
GDB Session • Compile the program : gcc –g < file name > • Open the gdb session : gdb <filename> • gdb Commands • break [line number ] - set breakpoint at specified line • run - run program • print expr/variable - print the result of expr/var • c - continue execution • next, step - next instruction/line • watch - watch an expression • info locals - local variables • help - built-in help • Delete breakpoints - delete the breakpoints
GDB-Example • (gdb) break 2 • Breakpoint 1 at 0x8048406: file a.c, line 2. • (gdb) run • The program being debugged has been started already. • Start it from the beginning? (y or n) y • Starting program: /root/ramya/a • Breakpoint 1, main () at a.c:3 • 3 printf ("%s", fd); • (gdb) n • Program received signal SIGSEGV, Segmentation fault. • 0x42080b43 in strlen () from /lib/i686/libc.so.6 • (gdb) n • Single stepping until exit from function strlen, • which has no line number information. • Program terminated with signal SIGSEGV, Segmentation fault. • The program no longer exists. • (gdb) quit
Working with DDD • DDD – Data Display Debugger • Is a GUI clone of GDB • Provides all functionalities of GDB • Compile using –g Start the session with • ddd <filename>
KDB- Introduction • KDB – Kernel Debugger • Does not require additional machine • Patch to kernel code • Download the patches and compile with the kernel debugger support
KDB Commands • Memory display & modification md – displays memory starting address mdr – displays the raw contents of the memory mm – modifies the memory contents mmW – changes W bytes starting at the address
KDB Commands • Register Display and Modification rd – displays processor register rd c – displays control register rd d – displays debug register rd u – displays register set of current task rm – modifies content of register ef - displays a exception frame at the specified address
KDB Commands • Breakpoints bp -- applies breakpoint at the address bpa – applies breakpoints on all processors in SMP system bd – disables a breakpoint be – enables a breakpoint bl – list the current set of breakpoints bc – clears the breakpoint
Linux Trace Toolkit • Provides information about dynamic behavior of system • Full featured GUI • Linux kernel tracing capabilities with many trace points. • Micro-second event time-stamps. • Support for real time application interface
References • GDB [1]sources.redhat.com/gdb/current/onlinedocs/gdb_toc.html • DDD [1] www.gnu.org/manual/ddd/ • KDB [1] http://kgdb.sourceforge.net/ [2] www-106.ibm.com/developerworks/linux/library/ l-kdbug/ • LTT [1] //http://www.opersys.com/LTT/index.html
Thank You Ramya B.B. Wipro Technologies ramya.balaraj@wipro.com