* Steve Reinhardt
*/
-#include <sys/types.h>
-#include <signal.h>
-#include <unistd.h>
-
#include <string>
#include <vector>
+#include "base/debug.hh"
#include "sim/debug.hh"
-#include "sim/eventq.hh"
+#include "sim/eventq_impl.hh"
+#include "sim/global_event.hh"
#include "sim/sim_events.hh"
+#include "sim/sim_exit.hh"
+#include "cpu/pc_event.hh"
+#include "sim/system.hh"
using namespace std;
-void
-debug_break()
-{
-#ifndef NDEBUG
- kill(getpid(), SIGTRAP);
-#else
- cprintf("debug_break suppressed, compiled with NDEBUG\n");
-#endif
-}
-
//
// 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 GlobalEvent
{
- public:
-
- DebugBreakEvent(EventQueue *q, Tick _when);
-
+ DebugBreakEvent(Tick when);
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(Tick when)
+ : GlobalEvent(when, Debug_Break_Pri, AutoDelete)
{
- setFlags(AutoDelete);
- schedule(_when);
}
//
void
DebugBreakEvent::process()
{
- debug_break();
+ Debug::breakpoint();
}
const char *
DebugBreakEvent::description() const
{
- return "debug break";
+ return "debug breakpoint";
}
//
// (callable from debugger)
//
void
-schedBreakCycle(Tick when)
+schedBreak(Tick when)
{
- new DebugBreakEvent(&mainEventQueue, when);
+ new DebugBreakEvent(when);
+ warn("need to stop all queues");
}
void
-eventqDump()
+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
+///
+void
+takeCheckpoint(Tick when)
{
- mainEventQueue.dump();
+ if (!when)
+ when = curTick() + 1;
+ exitSimLoop("checkpoint", 0, when, 0);
}
+void
+eventqDump()
+{
+ for (uint32_t i = 0; i < numMainEventQueues; ++i) {
+ mainEventQueue[i]->dump();
+ }
+}
int remote_gdb_base_port = 7000;