gdb: add a debugging function that enters the python interpreter.
authorNathan Binkert <nate@binkert.org>
Fri, 10 Oct 2008 17:15:01 +0000 (10:15 -0700)
committerNathan Binkert <nate@binkert.org>
Fri, 10 Oct 2008 17:15:01 +0000 (10:15 -0700)
src/sim/debug.cc

index 3684f6767df666b27dedd39d2edcb19e52636c78..57ca0458ce3b45013531fb876ec81de4c5f1782c 100644 (file)
@@ -29,6 +29,7 @@
  *          Steve Reinhardt
  */
 
+#include <Python.h>
 #include <sys/types.h>
 #include <signal.h>
 #include <unistd.h>
@@ -106,6 +107,21 @@ eventqDump()
     warn("need to dump all queues");
 }
 
+void
+py_interact()
+{
+    PyObject *globals;
+    PyObject *locals;
+
+    globals = PyEval_GetGlobals();
+    Py_INCREF(globals);
+    locals = PyDict_New();
+    PyRun_String("import code", Py_file_input, globals, locals);
+    PyRun_String("code.interact(local=globals())", Py_file_input,
+                 globals, locals);
+    Py_DECREF(globals);
+    Py_DECREF(locals);
+}
 
 int remote_gdb_base_port = 7000;