* Steve Reinhardt
*/
+#include <Python.h>
#include <sys/types.h>
#include <signal.h>
#include <unistd.h>
#include "sim/debug.hh"
#include "sim/eventq.hh"
-#include "sim/param.hh"
#include "sim/sim_events.hh"
using namespace std;
// 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);
}
//
const char *
-DebugBreakEvent::description()
+DebugBreakEvent::description() const
{
return "debug break";
}
//
-// Parameter context for global debug options
+// handy function to schedule DebugBreakEvent on main event queue
+// (callable from debugger)
//
-class DebugContext : public ParamContext
+void
+schedBreakCycle(Tick when)
{
- public:
- DebugContext(const string &_iniSection)
- : ParamContext(_iniSection) {}
- void checkParams();
-};
-
-DebugContext debugParams("debug");
-
-VectorParam<Tick> break_cycles(&debugParams, "break_cycles",
- "cycle(s) to create breakpoint events");
+ mainEventQueue.schedule(new DebugBreakEvent, when);
+ warn("need to stop all queues");
+}
void
-DebugContext::checkParams()
+eventqDump()
{
- if (break_cycles.isValid()) {
- vector<Tick> &cycles = break_cycles;
-
- vector<Tick>::iterator i = cycles.begin();
- vector<Tick>::iterator end = cycles.end();
+ mainEventQueue.dump();
+ warn("need to dump all queues");
+}
- for (; i < end; ++i)
- new DebugBreakEvent(&mainEventQueue, *i);
- }
+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);
}
-//
-// handy function to schedule DebugBreakEvent on main event queue
-// (callable from debugger)
-//
-extern "C" void sched_break_cycle(Tick when)
+int remote_gdb_base_port = 7000;
+
+int
+getRemoteGDBPort()
{
- new DebugBreakEvent(&mainEventQueue, when);
+ return remote_gdb_base_port;
}
-extern "C" void eventq_dump()
+// Set remote GDB base port. 0 means disable remote GDB.
+// Callable from python.
+void
+setRemoteGDBPort(int port)
{
- mainEventQueue.dump();
+ remote_gdb_base_port = port;
}