Differences between revisions 19 and 20
Revision 19 as of 2010-09-14 07:48:52
Size: 4181
Editor: 210-121-92
Comment: Link to PythonGdbTutorial
Revision 20 as of 2010-10-08 18:14:04
Size: 3032
Editor: TomTromey
Comment: various updates and corrections; removed "what works" section -- see the manual instead
Deletions are marked like this. Additions are marked like this.
Line 7: Line 7:
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.
Almost all the code from the old development branch has been merged to GDB CVS. The simplest way to get the code is to check out from CVS. New work should be done using CVS HEAD as a baseline.
Line 24: Line 12:
 * If you try to use the Python scripts included in the branch, you'll have to start GDB from the {{{python-branch-build/gdb/}}} directory, since there's a {{{.gdbinit}}} file there which contains some magic sauce to make it work (this won't be necessary in the final upstream version).
   * Unless you're debugging GDB itself, you'll see errors like:
 * Unless you're debugging GDB itself, you'll see errors like:
Line 32: Line 19:
   You can safely ignore them. They come from debugging aids specific to debugging GDB under itself.
Line 34: Line 20:
== Things that work ==

 * You can create new gdb commands by subclassing {{{gdb.Command}}}
 * You can create new convenience functions by subclassing {{{gdb.Function}}}
 * You can create new gdb parameters by subclassing {{{gdb.Parameter}}}
 * Breakpoints, blocks, frames, symbols, symbol tables, types, and values have Python representations. Some of these representations are not finalized.
 * You can write a type-specific pretty-printer that will work with MI or the CLI; this lets you more intelligently display the contents of objects
 * Python code can be auto-loaded based on an objfile's file name. This works with the separate debuginfo feature as well. (See the manual for details.)
 * gdb has a new -P flag. This enables using gdb as a python scripting interpreter, that is, starting scripts with {{{#!.../gdb -P}}}.
 You can safely ignore these, or use {{{gdb -nx}}}. They come from debugging aids specific to debugging GDB under itself.
Line 46: Line 24:
There are some useful examples in the source tree. Look in {{{src/gdb/python/lib/gdb}}}. There are some useful examples in the source tree. Look in {{{src/gdb/python/lib/gdb}}}. (The old {{{archer-tromey-python}}} branch in the archer git repository still has some code here that has not been merged.)

== Current Roadmap ==

The medium-term roadmap we are working on is in [[http://sourceware.org/ml/gdb/2010-08/msg00139.html|this email message]].
Line 49: Line 31:

In addition to the medium-term roadmap, here are some other areas where we would appreciate help. There is some overlap.
Line 63: Line 47:
 See http://sourceware.org/bugzilla/show_bug.cgi?id=7221 as well.

PythonGdb

This page describes the work to integrate Python scripting into Gdb. For a short tutorial of new features see PythonGdbTutorial.

Getting the code / Helping

Almost all the code from the old development branch has been merged to GDB CVS. The simplest way to get the code is to check out from CVS. New work should be done using CVS HEAD as a baseline.

Hints

  • Most of the Python API is documented in <python-branch-src>/gdb/doc/gdb.texinfo. You can get a nice PDF file with make gdb.pdf.

  • Unless you're debugging GDB itself, you'll see errors like:
    • Function "internal_error" not defined.
      Make breakpoint pending on future shared library load? (y or [n])
      [answered N; input not from terminal]

    You can safely ignore these, or use gdb -nx. They come from debugging aids specific to debugging GDB under itself.

Example code

There are some useful examples in the source tree. Look in src/gdb/python/lib/gdb. (The old archer-tromey-python branch in the archer git repository still has some code here that has not been merged.)

Current Roadmap

The medium-term roadmap we are working on is in this email message.

Things we want to work

In addition to the medium-term roadmap, here are some other areas where we would appreciate help. There is some overlap.

  • Python code should be able to detect why the inferior has stopped.
  • 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)

    See http://sourceware.org/bugzilla/show_bug.cgi?id=7221 as well.

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.