introduction to gdb python
play

Introduction to GDB Python Usage examples Conclusion Pierre-Marie - PowerPoint PPT Presentation

Introduction to GDB Python Pierre-Marie de Rodat Introduction Introduction to GDB Python Usage examples Conclusion Pierre-Marie de Rodat pmderodat@lse.epita.fr PM @ {rezosup, freenode, geeknode, . . . } http://lse.epita.fr February 12,


  1. Introduction to GDB Python Pierre-Marie de Rodat Introduction Introduction to GDB Python Usage examples Conclusion Pierre-Marie de Rodat pmderodat@lse.epita.fr PM @ {rezosup, freenode, geeknode, . . . } http://lse.epita.fr February 12, 2013 . . . . . . . . . . . . . . . . . . . . . .. . . .. .. . . .. . .. .. . . .. . .. . .. .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. .

  2. Plan Introduction to GDB Python Pierre-Marie de Rodat Introduction Usage examples . . Conclusion Introduction 1 . . . . . . . . . . . . . . . . . . . . . . .. .. . . .. . .. . .. . .. . .. . .. .. . .. . . .. .. . . .. . .. .. . .. . .. . .. . .. . .. .

  3. GDB Introduction to GDB Python Pierre-Marie de Rodat Introduction Usage examples Well known source-level debugger from the GNU Conclusion Project Can be scripted using a quite resticting specific language (one more to learn!) As far as I could read, it can only define macros . . . . . . . . . . . . . . . . . . . . . .. . . .. .. . . .. . .. .. . . .. . .. . .. .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. .

  4. GDB Introduction to GDB Python Pierre-Marie de Rodat Introduction Usage examples Well known source-level debugger from the GNU Conclusion Project Can be scripted using a quite resticting specific language (one more to learn!) As far as I could read, it can only define macros . . . . . . . . . . . . . . . . . . . . . .. . . .. .. . . .. . .. .. . . .. . .. . .. .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. .

  5. GDB Introduction to GDB Python Pierre-Marie de Rodat Introduction Usage examples Well known source-level debugger from the GNU Conclusion Project Can be scripted using a quite resticting specific language (one more to learn!) As far as I could read, it can only define macros . . . . . . . . . . . . . . . . . . . . . .. . . .. .. . . .. . .. .. . . .. . .. . .. .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. .

  6. PythonGDB Introduction to GDB Python Pierre-Marie de Rodat GDB 7 introduced Python scripting capabilities Introduction It can be accessed through a dedicated API ( gdb Usage examples module) Conclusion This API enables scripts to: Define pretty-printers for types defined in debugged programs ( inferiors ) Define new commands (like macros) Deal with symbols, stack frames, values type Inspect and modify inferiors memory Register callbacks for events (inferior termination, . . . ) Set breakpoints . . . . . . . . . . . . . . . . . . . . . . . .. . . .. . . .. .. . . .. .. . .. . .. . .. . . .. .. . . .. . .. . .. .. . .. . .. . .. . .. . .. .

  7. PythonGDB Introduction to GDB Python Pierre-Marie de Rodat GDB 7 introduced Python scripting capabilities Introduction It can be accessed through a dedicated API ( gdb Usage examples module) Conclusion This API enables scripts to: Define pretty-printers for types defined in debugged programs ( inferiors ) Define new commands (like macros) Deal with symbols, stack frames, values type Inspect and modify inferiors memory Register callbacks for events (inferior termination, . . . ) Set breakpoints . . . . . . . . . . . . . . . . . . . . . . . .. . . .. . . .. .. . . .. .. . .. . .. . .. . . .. .. . . .. . .. . .. .. . .. . .. . .. . .. . .. .

  8. PythonGDB Introduction to GDB Python Pierre-Marie de Rodat GDB 7 introduced Python scripting capabilities Introduction It can be accessed through a dedicated API ( gdb Usage examples module) Conclusion This API enables scripts to: Define pretty-printers for types defined in debugged programs ( inferiors ) Define new commands (like macros) Deal with symbols, stack frames, values type Inspect and modify inferiors memory Register callbacks for events (inferior termination, . . . ) Set breakpoints . . . . . . . . . . . . . . . . . . . . . . . .. . . .. . . .. .. . . .. .. . .. . .. . .. . . .. .. . . .. . .. . .. .. . .. . .. . .. . .. . .. .

  9. PythonGDB Introduction to GDB Python Pierre-Marie de Rodat GDB 7 introduced Python scripting capabilities Introduction It can be accessed through a dedicated API ( gdb Usage examples module) Conclusion This API enables scripts to: Define pretty-printers for types defined in debugged programs ( inferiors ) Define new commands (like macros) Deal with symbols, stack frames, values type Inspect and modify inferiors memory Register callbacks for events (inferior termination, . . . ) Set breakpoints . . . . . . . . . . . . . . . . . . . . . . . .. . . .. . . .. .. . . .. .. . .. . .. . .. . . .. .. . . .. . .. . .. .. . .. . .. . .. . .. . .. .

  10. PythonGDB Introduction to GDB Python Pierre-Marie de Rodat GDB 7 introduced Python scripting capabilities Introduction It can be accessed through a dedicated API ( gdb Usage examples module) Conclusion This API enables scripts to: Define pretty-printers for types defined in debugged programs ( inferiors ) Define new commands (like macros) Deal with symbols, stack frames, values type Inspect and modify inferiors memory Register callbacks for events (inferior termination, . . . ) Set breakpoints . . . . . . . . . . . . . . . . . . . . . . . .. . . .. . . .. .. . . .. .. . .. . .. . .. . . .. .. . . .. . .. . .. .. . .. . .. . .. . .. . .. .

  11. PythonGDB Introduction to GDB Python Pierre-Marie de Rodat GDB 7 introduced Python scripting capabilities Introduction It can be accessed through a dedicated API ( gdb Usage examples module) Conclusion This API enables scripts to: Define pretty-printers for types defined in debugged programs ( inferiors ) Define new commands (like macros) Deal with symbols, stack frames, values type Inspect and modify inferiors memory Register callbacks for events (inferior termination, . . . ) Set breakpoints . . . . . . . . . . . . . . . . . . . . . . . .. . . .. . . .. .. . . .. .. . .. . .. . .. . . .. .. . . .. . .. . .. .. . .. . .. . .. . .. . .. .

  12. PythonGDB Introduction to GDB Python Pierre-Marie de Rodat GDB 7 introduced Python scripting capabilities Introduction It can be accessed through a dedicated API ( gdb Usage examples module) Conclusion This API enables scripts to: Define pretty-printers for types defined in debugged programs ( inferiors ) Define new commands (like macros) Deal with symbols, stack frames, values type Inspect and modify inferiors memory Register callbacks for events (inferior termination, . . . ) Set breakpoints . . . . . . . . . . . . . . . . . . . . . . . .. . . .. . . .. .. . . .. .. . .. . .. . .. . . .. .. . . .. . .. . .. .. . .. . .. . .. . .. . .. .

  13. PythonGDB Introduction to GDB Python Pierre-Marie de Rodat GDB 7 introduced Python scripting capabilities Introduction It can be accessed through a dedicated API ( gdb Usage examples module) Conclusion This API enables scripts to: Define pretty-printers for types defined in debugged programs ( inferiors ) Define new commands (like macros) Deal with symbols, stack frames, values type Inspect and modify inferiors memory Register callbacks for events (inferior termination, . . . ) Set breakpoints . . . . . . . . . . . . . . . . . . . . . . . .. . . .. . . .. .. . . .. .. . .. . .. . .. . . .. .. . . .. . .. . .. .. . .. . .. . .. . .. . .. .

  14. Plan Introduction to GDB Python Pierre-Marie de Rodat Introduction . . Usage examples Usage examples 2 Loading scripts Loading scripts Defining a pretty-printer Defining breakpoints Defining a pretty-printer Convenience functions Defining breakpoints Conclusion Convenience functions . . . . . . . . . . . . . . . . . . . . . . .. .. . . .. .. . .. . . .. . .. .. . .. . .. . . .. . .. . .. .. . .. . .. . .. . .. . .. . .. .

  15. Loading scripts Introduction to GDB Python Pierre-Marie de Rodat Most simple way (by hand): Introduction Usage examples source my_script.py Loading scripts Defining a pretty-printer gdb my_program -ex"source my_script.py" Defining breakpoints Convenience functions Auto-loading (eg. for libraries): Conclusion Enable auto-load python-scripts Rename your script to objfile -gdb.py Fix security-related settings ( scripts-directory , safe-path , . . . ) Other strange ways ( .debug_gdb_scripts ) . . . . . . . . . . . . . . . . . . . . . . . .. . . .. . .. . .. . . .. . .. . .. .. . .. . .. . .. . . .. . .. . .. .. . .. . .. . .. . .. . .. .

Recommend


More recommend