This is the mail archive of the mailing list for the Archer project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: source command for python scripts

Tom> (gdb) python execfile('')

Thiago> I was wondering if it would be useful to have a command in GDB to source
Thiago> Python scripts, something like "source -p". But the command above
Thiago> is short enough that we wouldn't need a separate command. What do you
Thiago> think?

How about the appended?  :-)

This isn't quite as nice as "source -p", but it was simpler to

A couple ideas I've had for improved commands-in-python:

* Make it possible to rename existing gdb commands, or have Python
  objects wrap the underlying command structure.
  This would let us write a new "source" (e.g.) in Python that could
  delegate to the old "source" when needed.
  I have a use for this with "backtrace" too...
  For this to work well I think we'd also need to fix the existing gdb
  crash involving redefining commands with aliases.

* Put interesting commands into a Python module, like gdb.commands.
  Ship a bunch of them with gdb -- but not activated.  Then users
  could pick the ones they like:

  python import gdb.commands.PSource
  python import gdb.commands.FancyBacktrace


import gdb

class PSource(gdb.Command):
    "Read a file and evaluate its contents as Python code."

    def __init__(self):
        super(PSource, self).__init__("psource",

    def invoke(self, arg, from_tty):


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]