RFC: add ability to "source" Python code

Tom Tromey tromey@redhat.com
Tue Feb 10 01:29:00 GMT 2009


>>>>> "Pedro" == Pedro Alves <pedro@codesourcery.com> writes:

Pedro> Could you explain for the archives why this is better than having
Pedro> the script itself tell GDB that it's running python?  Either
Pedro> through something similar to a shebang, or starting the script with
Pedro> "python" (does that work?) ?  I think you've discussed this before,
Pedro> what were the limitations you found?

I think you may be thinking of invoking a python script using
"#!.../gdb -something".  This patch does not cover that case.  That is
a separate patch, which I haven't submitted.

Anyway, I think having "source" look at a #! line would not be very
helpful.  Most Python source files do not start with this.

Yes, you can write:

  python
  blah blah blah
  end

in a file and then source that.  IME, this is not always convenient.

In practice, though, I find I use the .py extension feature a lot more
than "-p".  I can remove the "-p" feature if that will make you and
Eli and Doug happy.

Pedro> Say that in the future we add support for another scripting language
Pedro> to GDB, and we want to keep the current python support working in
Pedro> parallel.  As a matter of example, let's call it "Python 3.0".  Would
Pedro> we want to add more "-p" switches to the source command?

I don't think Python 3.0 is a good example.  I think we'll only be
able to link GDB against a single version of Python.

If someone adds other scripting languages to GDB, then yes, I would
support new a option to "source".  I would also support having
"source" know about common file extensions for the new language.

Tom



More information about the Gdb-patches mailing list