syscalls: fix latent brk/obreak bug.
[gem5.git] / src / sim / debug.cc
index 84ab1074d924916d6fb039e7d5cd0ecf4d1c246b..57ca0458ce3b45013531fb876ec81de4c5f1782c 100644 (file)
@@ -29,6 +29,7 @@
  *          Steve Reinhardt
  */
 
+#include <Python.h>
 #include <sys/types.h>
 #include <signal.h>
 #include <unistd.h>
@@ -38,7 +39,6 @@
 
 #include "sim/debug.hh"
 #include "sim/eventq.hh"
-#include "sim/param.hh"
 #include "sim/sim_events.hh"
 
 using namespace std;
@@ -57,24 +57,20 @@ debug_break()
 // Debug event: place a breakpoint on the process function and
 // schedule the event to break at a particular cycle
 //
-class DebugBreakEvent : public Event
+struct DebugBreakEvent : public Event
 {
-  public:
-
-    DebugBreakEvent(EventQueue *q, Tick _when);
-
-    void process();    // process event
-    virtual const char *description();
+    DebugBreakEvent();
+    void process();     // process event
+    virtual const char *description() const;
 };
 
 //
 // constructor: schedule at specified time
 //
-DebugBreakEvent::DebugBreakEvent(EventQueue *q, Tick _when)
-    : Event(q, Debug_Break_Pri)
+DebugBreakEvent::DebugBreakEvent()
+    : Event(Debug_Break_Pri)
 {
     setFlags(AutoDelete);
-    schedule(_when);
 }
 
 //
@@ -88,7 +84,7 @@ DebugBreakEvent::process()
 
 
 const char *
-DebugBreakEvent::description()
+DebugBreakEvent::description() const
 {
     return "debug break";
 }
@@ -100,12 +96,46 @@ DebugBreakEvent::description()
 void
 schedBreakCycle(Tick when)
 {
-    new DebugBreakEvent(&mainEventQueue, when);
+    mainEventQueue.schedule(new DebugBreakEvent, when);
+    warn("need to stop all queues");
 }
 
 void
 eventqDump()
 {
     mainEventQueue.dump();
+    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;
+
+int
+getRemoteGDBPort()
+{
+    return remote_gdb_base_port;
+}
+
+// Set remote GDB base port.  0 means disable remote GDB.
+// Callable from python.
+void
+setRemoteGDBPort(int port)
+{
+    remote_gdb_base_port = port;
 }