2. Contents
• What is Debugging
• What is Debugger?
• What are Debugger Symbols?
• Debugging Symbols
• Ripping Symbols off a Binary
• Adding Debug Symbols to a Binary
• What in Symbols Files
• Stripping Symbols off a Binary
• Setting a Breakpoint
• Disable / Enable / Delete Breakpoint
4. What is Debugging ?
• “De” + “Bug” = Debug
• finding and reducing the number of bugs, in a computer
program or a piece of electronic hardware,
• software and electronic systems have various common
debugging techniques have expanded with more methods
to detect anomalies, assess impact,
5. What is Debugger ?
• A special program used to find errors (bugs) in other
programs. A debugger allows a programmer to stop a
program at any point and examine and change the values of
variables.
• Examples –
-GNU Debugger
-Intel Debugger
-softIce
-WinDBG
6. What are Debugger Symbols ?
• information that expresses which programming-language
constructs generated a specific piece of machine code in a
given executable module.
• embedded in the binary itself or separate file
7. What are Debugger Symbols ?
• Kyaw Thiha (handsome)
• Young (25)
• Skinny (120 lb)
• IT ( Information Security)
• Myanmar (Yangon)
• Kyaw Thiha
• Young
• skinny
• IT
• Myanmar
8. Debugging Symbols
• GCC use –g option
• GCC -ggdb for GDB specific symbols
• Need to be explicitly mentioned at Compile time
• Type
-DWARF 2
-COFF
-XCOFF
-Stabs
9. Ripping Symbols Off a Binary
• Objcopy
• objcopy –only-keep-debug rip_from_binary_debug_file
11. Adding Debug Symbols to a
Binary
• Add it in the Binary itself
objcopy –add-gnu-debuglink= debug_file
• Load the symbol file within GDB
symbol-file file_name
12. What in Symbols File ?
• Info file
• Info sources
• Info variable
• Info scope function_name
• Info function
• maint print symbols file_name
13. Setting a Breakpoint
• What is a Breakpoint?
• intentional stopping or pausing place in a program, sometimes
simply referred to as a pause.
• Criteia can be “about to execute an instruction”
• Debugger allows to inspect / modify CPU , Register , Memory ,
Data etc.
• Setting a Breakpoint
• break Line_number/Function/address
• View Breakpoint
• Info breakpoints
15. Examine Memory
• usage x
• x/FMT address or print
• Address – Memory address
• FMT – is repeated count followed by format letter and count
letter.
• Format letter: o(octal) , x(hex), d(decimal), u(unsigned letter),
t(binary) , f(float) , etc
• Size letter: b(byte),h(halfword) , w(word) , g(giant, 8bytes)
16. Modify CPU and Memory
• Modify Memory
• Set {int} address = value
• Modify CPU
• set register = address
17. Working with variables,
functions in GDB
• Variables
• Set new_variable = value
• Set exiting_variable = net_variable
• Functions
• call function_name