Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

Debugging With GNU Debugger GDB

  • Inicia sesión para ver los comentarios

  • Sé el primero en recomendar esto

Debugging With GNU Debugger GDB

  1. 1. Debugging With GNU Debugger GDB By Kyaw Thiha ICEH, ICWAPT, CWSE, Debugging with debug symbol file
  2. 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
  3. 3. Contents • Examine Memory • Modify CPU and Memory • Working with variables, functions in GDB
  4. 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. 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. 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. 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. 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. 9. Ripping Symbols Off a Binary • Objcopy • objcopy –only-keep-debug rip_from_binary_debug_file
  10. 10. Stripping Symbols off a Binary • Strip • --strip-debug –strip-unneeded binary_file
  11. 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. 12. What in Symbols File ? • Info file • Info sources • Info variable • Info scope function_name • Info function • maint print symbols file_name
  13. 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. 14. Disable / Enable / Delete Breakpoint • Enable xxxxxxxxxx • Disable xxxxxxxxx • Delete xxxxxxxxx
  15. 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. 16. Modify CPU and Memory • Modify Memory • Set {int} address = value • Modify CPU • set register = address
  17. 17. Working with variables, functions in GDB • Variables • Set new_variable = value • Set exiting_variable = net_variable • Functions • call function_name

×