This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[commit][python] source_python_script doesn't set python_gdbarch


Hi.

While reading python.c I noticed that source_python_script doesn't
use ensure_python_env.  I then tried this experiment:

$ cat foo.py:
import gdb
print gdb.target_charset()

(gdb) source foo.py
../../../src/gdb/gdbarch.c:3632: internal-error: gdbarch_auto_charset: Assertion `gdbarch != NULL' failed.
A problem internal to GDB has been detected,
[...]

Part of what ensure_python_env does is set python_gdbarch.
I've checked this patch in to fix it.

2010-04-07  Doug Evans  <dje@google.com>

	* python/python.c (source_python_script): Use ensure_python_env
	to prepare environment for script.

Index: python.c
===================================================================
RCS file: /cvs/src/src/gdb/python/python.c,v
retrieving revision 1.27
diff -u -p -r1.27 python.c
--- python.c	5 Mar 2010 20:18:17 -0000	1.27
+++ python.c	8 Apr 2010 04:51:02 -0000
@@ -367,14 +367,14 @@ gdbpy_parse_and_eval (PyObject *self, Py
 void
 source_python_script (FILE *stream, char *file)
 {
-  PyGILState_STATE state;
+  struct cleanup *cleanup;
 
-  state = PyGILState_Ensure ();
+  cleanup = ensure_python_env (get_current_arch (), current_language);
 
   PyRun_SimpleFile (stream, file);
 
   fclose (stream);
-  PyGILState_Release (state);
+  do_cleanups (cleanup);
 }
 
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]