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 . . . . . . . . . . . . . . . . . . . . . .. . . .. .. . . .. . .. .. . . .. . .. . .. .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. .
Plan Introduction to GDB Python Pierre-Marie de Rodat Introduction Usage examples . . Conclusion Introduction 1 . . . . . . . . . . . . . . . . . . . . . . .. .. . . .. . .. . .. . .. . .. . .. .. . .. . . .. .. . . .. . .. .. . .. . .. . .. . .. . .. .
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 . . . . . . . . . . . . . . . . . . . . . .. . . .. .. . . .. . .. .. . . .. . .. . .. .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. .
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 . . . . . . . . . . . . . . . . . . . . . .. . . .. .. . . .. . .. .. . . .. . .. . .. .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. .
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 . . . . . . . . . . . . . . . . . . . . . .. . . .. .. . . .. . .. .. . . .. . .. . .. .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. .
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 . . . . . . . . . . . . . . . . . . . . . . . .. . . .. . . .. .. . . .. .. . .. . .. . .. . . .. .. . . .. . .. . .. .. . .. . .. . .. . .. . .. .
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 . . . . . . . . . . . . . . . . . . . . . . . .. . . .. . . .. .. . . .. .. . .. . .. . .. . . .. .. . . .. . .. . .. .. . .. . .. . .. . .. . .. .
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 . . . . . . . . . . . . . . . . . . . . . . . .. . . .. . . .. .. . . .. .. . .. . .. . .. . . .. .. . . .. . .. . .. .. . .. . .. . .. . .. . .. .
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 . . . . . . . . . . . . . . . . . . . . . . . .. . . .. . . .. .. . . .. .. . .. . .. . .. . . .. .. . . .. . .. . .. .. . .. . .. . .. . .. . .. .
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 . . . . . . . . . . . . . . . . . . . . . . . .. . . .. . . .. .. . . .. .. . .. . .. . .. . . .. .. . . .. . .. . .. .. . .. . .. . .. . .. . .. .
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 . . . . . . . . . . . . . . . . . . . . . . . .. . . .. . . .. .. . . .. .. . .. . .. . .. . . .. .. . . .. . .. . .. .. . .. . .. . .. . .. . .. .
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 . . . . . . . . . . . . . . . . . . . . . . . .. . . .. . . .. .. . . .. .. . .. . .. . .. . . .. .. . . .. . .. . .. .. . .. . .. . .. . .. . .. .
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 . . . . . . . . . . . . . . . . . . . . . . . .. . . .. . . .. .. . . .. .. . .. . .. . .. . . .. .. . . .. . .. . .. .. . .. . .. . .. . .. . .. .
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 . . . . . . . . . . . . . . . . . . . . . . .. .. . . .. .. . .. . . .. . .. .. . .. . .. . . .. . .. . .. .. . .. . .. . .. . .. . .. . .. .
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