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

Joel Brobecker
2010-01-15T07:21:11Z

> This patch implements such tri-state setting:
>
> (gdb) help set script-extension
> Set mode for script filename extension recognition.
> off == no filename extension recognition (all sourced files are GDB scripts)
> soft == evaluate script according to filename extension, fallback to GDB script
> hard == evaluate script according to filename extension, error if not supported
>

> 2009-06-01 Tom Tromey <tromey@redhat.com>
> Thiago Jung Bauermann <bauerman@br.ibm.com>
>
> * python/python.c (source_python_script): New function.
> * python/python.h (source_python_script): Declare.
> * cli/cli-cmds.c (find_argument): New function.
> (source_command): Use find_argument. Handle -p argument. Use
> make_cleanup_restore_integer.
> (source_verbose_cleanup): Remove.
> (source_python): New global.
> Include python.h.
> (init_cli_cmds): Update.
>
> 2009-06-01 Tom Tromey <tromey@redhat.com>
>
> * gdb.texinfo (File Options): Document -x on .py files.
> (Command Files): Document source -p.
>
> 2009-06-01 Tom Tromey <tromey@redhat.com>
> Thiago Jung Bauermann <bauerman@br.ibm.com>
>
> * gdb.base/help.exp: Update "source" help text.
> * gdb.python/source2.py: New file.
> * gdb.python/source1: New file.
> * gdb.python/python.exp: Test "source" command.

This was approved a long time ago, with s/hard/strict/. Did we just
forget to apply it? I'm playing with python, right now, and it was
just brutal trying to find a way to "source" a file.

Refresher for those like me who are not completely fluent in Python.
It's:

(gdb) python "execfile your-file.py"

--
Joel