Re: RFC: add ability to "source" Python code

Eli Zaretskii
2009-02-17T04:12:47Z

> Date: Mon, 16 Feb 2009 16:07: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
>
> Let's see what everyone thinks. I have several issues that I'd like
> to discuss before we can finalize a proposal:

My responses below.

> 1. If we have filename-extension detection (controlled by a setting),
> do we need the "-p" switch at all? If we agreed that it's an
> acceptable limitation that python scripts in GDB should have
> a .py extension, then we don't really need the .py switch,
> do we? This in turn would side-step the question of what to do
> with -p when python wasn't compiled in.

I'm okay with this, but I think Tom had some valid reasons for having
Python scripts that don't have a certain extension.

> Or maybe, how about changing the semantics of that setting
> to apply to files that are detected as python (regardless of
> how the detection is performed): In one case these files are
> sourced as python script, but on the other, these files are
> still treated as GDB scripts. When GDB was built with python,
> then this switch can be used to turn the new feature off,
> whereas if no python was available, the setting would be stuck
> to the value where files are sourced as GDB scripts.

Fine with me.

> Now that I've written all this and that it has given me a chance
> to think this over a little more, I like the idea of falling back
> to GDB scripts less and less. So much so that I'm wondering whether
> using a different command than "source" might be better? "pysource"
> for instance?

I think there is already a way to do that: the `python' command. I
think the `source' proposal was intended to treat Python scripts more
similar to GDB scripts, and I generally agree with that idea,
i.e. that we should have a single command that sources scripts.