RFC: add ability to "source" Python code

Eli Zaretskii eliz@gnu.org
Fri Feb 13 15:23:00 GMT 2009


> Date: Thu, 12 Feb 2009 18:22:46 -0800
> From: Joel Brobecker <brobecker@adacore.com>
> Cc: tromey@redhat.com, bauerman@br.ibm.com, drow@false.org,
> 	pedro@codesourcery.com, gdb-patches@sourceware.org
> 
> > > Anyway, how about a compromise, then, and require the -p switch to
> > > source python scripts? The incompatibility is that
> > > 
> > >    (gdb) source -p foo
> > > 
> > > would no longer work for file "-p foo". I think that's an acceptable
> > > "incompatibilty". Would you agree?
> > 
> > This is a misunderstanding: I didn't mind the -p switch, I mind the
> > fact that it throws an error if Python is not compiled in.  Eliminate
> > the error, and you have me on board.
> 
> Cool! So, just to make sure I understand what you're saying, you would
> agree to the following change:
> 
> Add a -p switch to the "source" command that signifies that we're sourcing
> a python script instead of a GDB script. We drop the part where we're
> using the filename extension to guess the file language, thus preserving
> the current behavior.

Yes.  I would even agree to retaining the language guesswork by
file-name extension, provided that (a) there's a user option to turn
that on and off, and (b) that option is off and stays off when Python
is not compiled in.

> Finally, what should we do if trying to source a python script with
> a debugger that does not have python linked in? Treat the -p switch
> as part of the script filename? (I would find this really odd)

Ideally, it should work as it does today, but if that's too hard to
implement, how about simply ignoring -p in that case?  That is, let
"source -p foo" behave like "source foo".

On the slim chance that this somewhat heated discussion was due to a
similar misunderstanding, I dare to quote what I originally wrote:

    However, I don't think I like the idea of GDB barfing if Python
    support is not compiled in.  I think it should simply try to interpret
    the file as GDB scripting commands.

and

    To clarify, I think "source" without Python compiled should behave
    exactly as it did before this patch: treat foo.py as any other file
    name and treat -p as it does today (i.e. source "-p foo.gdb" if it
    exists).

Now I add to this the suggestion to have a user variable as described
above.  Hopefully, somewhere in between we will be able to find a
compromise that won't cause any of us to storm out of the premises ;-)



More information about the Gdb-patches mailing list