Re: [PATCH] sys.argv and ipython (interactive python) support in GDB/Python

Phil Muldoon
2011-07-01T10:59:37Z

Taisuke Yamada <tai@rakugaki.org> writes:

Thanks for the patch!

> diff --git a/gdb/python/python.c b/gdb/python/python.c
> index 90d5dc8..c9f2ce9 100644
> --- a/gdb/python/python.c
> +++ b/gdb/python/python.c
> @@ -1010,7 +1010,9 @@ Enables or disables printing of Python stack traces."),
> SLASH_STRING, "python", NULL));
> #endif
>
> + char *argv[] = { "gdb", NULL };

As Kevin noted, this needs to be placed in the declarations part of the
function.

> Py_Initialize ();
> + PySys_SetArgvEx (1, argv, 0);

This can throw an error. Though, it seems unlikely it would. I'm also
a little confused about the documentation about PySys_SetArgvEx.

"These parameters are similar to those passed to the program's
main() function with the difference that the first entry should refer to
the script file to be executed rather than the executable hosting the
Python interpreter. If there isn't a script that will be run,
the first entry in argv can be an empty string. If this function fails
to initialize sys.argv, a fatal condition is signalled using
Py_FatalError()."

Isn't your first argument of argv the executable GDB?

I should know this, but the documentation notes "New in version
2.6.6". I think we support 2.6.6, but one of the maintainers would have
to reply here.

Lastly, even though this patch is about two lines, I believe it is not a
trivial change, and probably needs a ChangeLog entry.

Cheers,

Phil