KEMBAR78
Debugging With GNU Debugger GDB | PPTX
Debugging With GNU
Debugger GDB
By
Kyaw Thiha
ICEH, ICWAPT, CWSE,
Debugging with debug symbol file
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
Contents
• Examine Memory
• Modify CPU and Memory
• Working with variables, functions in GDB
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,
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
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
What are Debugger Symbols ?
• Kyaw Thiha (handsome)
• Young (25)
• Skinny (120 lb)
• IT ( Information Security)
• Myanmar (Yangon)
• Kyaw Thiha
• Young
• skinny
• IT
• Myanmar
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
Ripping Symbols Off a Binary
• Objcopy
• objcopy –only-keep-debug rip_from_binary_debug_file
Stripping Symbols off a Binary
• Strip
• --strip-debug –strip-unneeded binary_file
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
What in Symbols File ?
• Info file
• Info sources
• Info variable
• Info scope function_name
• Info function
• maint print symbols file_name
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
Disable / Enable / Delete
Breakpoint
• Enable xxxxxxxxxx
• Disable xxxxxxxxx
• Delete xxxxxxxxx
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)
Modify CPU and Memory
• Modify Memory
• Set {int} address = value
• Modify CPU
• set register = address
Working with variables,
functions in GDB
• Variables
• Set new_variable = value
• Set exiting_variable = net_variable
• Functions
• call function_name
Debugging With GNU Debugger GDB

Debugging With GNU Debugger GDB

  • 1.
    Debugging With GNU DebuggerGDB By Kyaw Thiha ICEH, ICWAPT, CWSE, Debugging with debug symbol file
  • 2.
    Contents • What isDebugging • 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
  • 3.
    Contents • Examine Memory •Modify CPU and Memory • Working with variables, functions in GDB
  • 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 DebuggerSymbols ? • 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 DebuggerSymbols ? • Kyaw Thiha (handsome) • Young (25) • Skinny (120 lb) • IT ( Information Security) • Myanmar (Yangon) • Kyaw Thiha • Young • skinny • IT • Myanmar
  • 8.
    Debugging Symbols • GCCuse –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 Offa Binary • Objcopy • objcopy –only-keep-debug rip_from_binary_debug_file
  • 10.
    Stripping Symbols offa Binary • Strip • --strip-debug –strip-unneeded binary_file
  • 11.
    Adding Debug Symbolsto 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 SymbolsFile ? • 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
  • 14.
    Disable / Enable/ Delete Breakpoint • Enable xxxxxxxxxx • Disable xxxxxxxxx • Delete xxxxxxxxx
  • 15.
    Examine Memory • usagex • 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 andMemory • Modify Memory • Set {int} address = value • Modify CPU • set register = address
  • 17.
    Working with variables, functionsin GDB • Variables • Set new_variable = value • Set exiting_variable = net_variable • Functions • call function_name