sim, arch, base: Refactor the base remote GDB class.
[gem5.git] / src / sim / debug.cc
index bfb28198d646ebe2b1f539d7793debbc45158479..b8291c86205c495160301b7bb0bdde9c62360fdd 100644 (file)
  *          Steve Reinhardt
  */
 
-#include <Python.h>
+#include "sim/debug.hh"
 
 #include <string>
 #include <vector>
 
 #include "base/debug.hh"
-#include "sim/debug.hh"
+#include "cpu/pc_event.hh"
 #include "sim/eventq_impl.hh"
+#include "sim/global_event.hh"
 #include "sim/sim_events.hh"
 #include "sim/sim_exit.hh"
+#include "sim/system.hh"
 
 using namespace std;
 
@@ -46,9 +48,9 @@ using namespace std;
 // Debug event: place a breakpoint on the process function and
 // schedule the event to break at a particular cycle
 //
-struct DebugBreakEvent : public Event
+struct DebugBreakEvent : public GlobalEvent
 {
-    DebugBreakEvent();
+    DebugBreakEvent(Tick when);
     void process();     // process event
     virtual const char *description() const;
 };
@@ -56,8 +58,8 @@ struct DebugBreakEvent : public Event
 //
 // constructor: schedule at specified time
 //
-DebugBreakEvent::DebugBreakEvent()
-    : Event(Debug_Break_Pri, AutoDelete)
+DebugBreakEvent::DebugBreakEvent(Tick when)
+    : GlobalEvent(when, Debug_Break_Pri, AutoDelete)
 {
 }
 
@@ -84,10 +86,24 @@ DebugBreakEvent::description() const
 void
 schedBreak(Tick when)
 {
-    mainEventQueue.schedule(new DebugBreakEvent, when);
+    new DebugBreakEvent(when);
     warn("need to stop all queues");
 }
 
+void
+schedRelBreak(Tick delta)
+{
+    schedBreak(curTick() + delta);
+}
+
+void
+breakAtKernelFunction(const char* funcName)
+{
+    System* curSystem = System::systemList[0];
+    curSystem->addKernelFuncEvent<BreakPCEvent>(funcName,
+                                                "GDB scheduled break", true);
+}
+
 ///
 /// Function to cause the simulator to take a checkpoint from the debugger
 ///
@@ -102,24 +118,9 @@ takeCheckpoint(Tick when)
 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);
+    for (uint32_t i = 0; i < numMainEventQueues; ++i) {
+        mainEventQueue[i]->dump();
+    }
 }
 
 int remote_gdb_base_port = 7000;