Differences between revisions 12 and 13
Revision 12 as of 2008-10-03 02:07:57
Size: 3592
Editor: c952d7c5
Comment:
Revision 13 as of 2008-10-05 00:10:02
Size: 3323
Editor: TomTromey
Comment: types and pretty-printing now implemented
Deletions are marked like this. Additions are marked like this.
Line 25: Line 25:
 * Breakpoints, blocks, frames, symbols, symbol tables, and values have Python representations. Some of these representations are not finalized.  * Breakpoints, blocks, frames, symbols, symbol tables, types, and values have Python representations. Some of these representations are not finalized.
Line 29: Line 29:
 * The gdb CLI can print using Python pretty-printers.
Line 38: Line 39:
 * Types need to be represented in Python.
 * It should be possible to override CLI printing of a value using Python. In particular code for this should be distributed with a library or executable and automatically found. Pretty-printing should be the default, with a new {{{/r}}} (raw) flag to print that bypasses the display.

PythonGdb

This page describes the work to integrate Python scripting into Gdb.

Getting the code / Helping

Discussions are going on in both the GDB and Archer mailing lists, and code for this effort is being held in the Archer git repository. See the ProjectArcher page for details on checking out Archer. The Python branch is named archer-tromey-python.

To get it, first clone the archer repository using one of the following commands:

  • git clone git://sourceware.org/git/archer.git

  • git clone ssh://sourceware.org/git/archer.git

Then you can checkout the python branch with:

cd archer; git checkout --track -b python origin/archer-tromey-python

If you are interested in helping out, and you have an FSF assignment on file, we can set you up with write access.

Things that work

  • You can create new gdb commands by subclassing gdb.Command

  • You can create new convenience functions by subclassing gdb.Function

  • Breakpoints, blocks, frames, symbols, symbol tables, types, and values have Python representations. Some of these representations are not finalized.
  • You can tell MI to use a Python function to change how a particular type of object is displayed.
  • Python code can be auto-loaded based on an objfile's file name. The file .gdb.py in the objfile's directory is read, if it exists. This works with the separate debuginfo feature as well.
  • gdb has a new -P flag. This enables using gdb as a python scripting interpreter, that is, starting scripts with #!.../gdb -P.

  • The gdb CLI can print using Python pretty-printers.

Example code

These are some scripts which work with the current code in the python-revisited branch:

Things we want to work

  • Expressions should be represented in Python.
  • There should be a Python class representing a language and all methods should be overrideable.
  • There should be a Python class representing a target and all methods should be overrideable.
  • We need more documentation for the Python API.
  • We need more test cases for the Python API.
  • We need a library of useful Python code, in particular useful user-defined functions. Maybe this library needs some kind of auto-loading support -- we want to keep startup time short.
  • Nice feature: be able to register a python signal handler for inferior signals. Would help in this usecase:
    • <LimCore> how to run gdb from command line, so that it will run ./foo.bin  with arguments: foo bar baz   and it will run it instantly without waiting for 'r'; And if program segfaults then it will do 'bt' without waiting for the command.  (and if program terminates normally then it will also just quit)

Big Goals

  • It should be possible to write support for a new language entirely in Python.
  • It should be possible to rewrite Insight in Python.
  • It should be possible to write useful "executables" purely in Python. This would mean modifying the gdb startup sequence (so a script could be used in a pipeline) and maybe adding command-line options. One example of a tool like this would be a generalized strace, like frysk's ftrace.

  • ... your idea here

None: PythonGdb (last edited 2013-12-04 18:03:08 by TomTromey)

All content (C) 2008 Free Software Foundation. For terms of use, redistribution, and modification, please see the WikiLicense page.