diff options
author | Doug Evans <dje@google.com> | 2010-11-02 16:48:43 +0000 |
---|---|---|
committer | Doug Evans <dje@google.com> | 2010-11-02 16:48:43 +0000 |
commit | 9dea9163560f26f9adddd13254ad32f4aea3b1d6 (patch) | |
tree | 524bda94e28e26bc3ae3bc014c9b499887c70b7f | |
parent | ffa54e5c48223b42840f93e56a5eff69998ab4e1 (diff) | |
download | gdb-9dea9163560f26f9adddd13254ad32f4aea3b1d6.zip gdb-9dea9163560f26f9adddd13254ad32f4aea3b1d6.tar.gz gdb-9dea9163560f26f9adddd13254ad32f4aea3b1d6.tar.bz2 |
* top.c: #include "python/python.h".
(gdb_init): Add a comment regarding initialize_all_files.
Call finish_python_initialization at the end.
* python/python.h (finish_python_initialization): Declare.
* python/python.c (finish_python_initialization): New function.
(_initialize_python): Move python-implemented initialization there
and call it.
(GdbMethods): Use #ifdef HAVE_PYTHON for consistency.
-rw-r--r-- | gdb/ChangeLog | 11 | ||||
-rw-r--r-- | gdb/python/python.c | 31 | ||||
-rw-r--r-- | gdb/python/python.h | 2 | ||||
-rw-r--r-- | gdb/top.c | 12 |
4 files changed, 48 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index eb5d6d6..197a708 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,14 @@ +2010-11-02 Doug Evans <dje@google.com> + + * top.c: #include "python/python.h". + (gdb_init): Add a comment regarding initialize_all_files. + Call finish_python_initialization at the end. + * python/python.h (finish_python_initialization): Declare. + * python/python.c (finish_python_initialization): New function. + (_initialize_python): Move python-implemented initialization there + and call it. + (GdbMethods): Use #ifdef HAVE_PYTHON for consistency. + 2010-11-02 Jan Kratochvil <jan.kratochvil@redhat.com> Revert: diff --git a/gdb/python/python.c b/gdb/python/python.c index 78410c6..d4f8c3d 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -997,9 +997,26 @@ Enables or disables printing of Python stack traces."), gdbpy_doc_cst = PyString_FromString ("__doc__"); gdbpy_enabled_cst = PyString_FromString ("enabled"); - /* Remaining initialization is done in Python. - - create a couple objects which are used for Python's stdout and stderr - - provide function GdbSetPythonDirectory */ + /* Release the GIL while gdb runs. */ + PyThreadState_Swap (NULL); + PyEval_ReleaseLock (); + +#endif /* HAVE_PYTHON */ +} + +#ifdef HAVE_PYTHON + +/* Perform the remaining python initializations. + These must be done after GDB is at least mostly initialized. + E.g., The "info pretty-printer" command needs the "info" prefix + command installed. */ + +void +finish_python_initialization (void) +{ + struct cleanup *cleanup; + + cleanup = ensure_python_env (get_current_arch (), current_language); PyRun_SimpleString ("\ import os\n\ @@ -1055,16 +1072,14 @@ def GdbSetPythonDirectory (dir):\n\ GdbSetPythonDirectory (gdb.PYTHONDIR)\n\ "); - /* Release the GIL while gdb runs. */ - PyThreadState_Swap (NULL); - PyEval_ReleaseLock (); + do_cleanups (cleanup); +} #endif /* HAVE_PYTHON */ -} -#if HAVE_PYTHON +#ifdef HAVE_PYTHON static PyMethodDef GdbMethods[] = { diff --git a/gdb/python/python.h b/gdb/python/python.h index affd4a4..04d5c28 100644 --- a/gdb/python/python.h +++ b/gdb/python/python.h @@ -24,6 +24,8 @@ extern int gdbpy_global_auto_load; +extern void finish_python_initialization (void); + void eval_python_from_control_command (struct command_line *); void source_python_script (FILE *stream, const char *file); @@ -47,6 +47,7 @@ #include "main.h" #include "event-loop.h" #include "gdbthread.h" +#include "python/python.h" /* readline include files */ #include "readline/readline.h" @@ -1657,7 +1658,10 @@ gdb_init (char *argv0) init_cmd_lists (); /* This needs to be done first */ initialize_targets (); /* Setup target_terminal macros for utils.c */ initialize_utils (); /* Make errors and warnings possible */ + + /* Here is where we call all the _initialize_foo routines. */ initialize_all_files (); + /* This creates the current_program_space. Do this after all the _initialize_foo routines have had a chance to install their per-sspace data keys. Also do this before @@ -1684,4 +1688,12 @@ gdb_init (char *argv0) deprecated_init_ui_hook. */ if (deprecated_init_ui_hook) deprecated_init_ui_hook (argv0); + +#ifdef HAVE_PYTHON + /* Python initialization can require various commands to be installed. + For example "info pretty-printer" needs the "info" prefix to be + installed. Keep things simple and just do final python initialization + here. */ + finish_python_initialization (); +#endif } |