sim,misc: Rename M5OP_ANNOTATE to M5OP_RESERVED1.
[gem5.git] / src / sim / debug.cc
index c189117bddb20546e67d1fec54bd5fdc3f211fe5..484d4a6702b2ec40bc6419a25ff2f35ad10e35b9 100644 (file)
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Authors: Nathan Binkert
- *          Steve Reinhardt
  */
 
-#include <sys/types.h>
-#include <signal.h>
-#include <unistd.h>
+#include "sim/debug.hh"
 
 #include <string>
 #include <vector>
 
-#include "sim/debug.hh"
-#include "sim/eventq.hh"
+#include "base/debug.hh"
+#include "cpu/pc_event.hh"
+#include "sim/eventq_impl.hh"
+#include "sim/global_event.hh"
+#include "sim/kernel_workload.hh"
 #include "sim/sim_events.hh"
+#include "sim/sim_exit.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);
-
-    void process();    // process event
-    virtual const char *description();
+    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);
 }
 
 //
@@ -82,14 +67,14 @@ DebugBreakEvent::DebugBreakEvent(EventQueue *q, Tick _when)
 void
 DebugBreakEvent::process()
 {
-    debug_break();
+    Debug::breakpoint();
 }
 
 
 const char *
-DebugBreakEvent::description()
+DebugBreakEvent::description() const
 {
-    return "debug break";
+    return "debug breakpoint";
 }
 
 //
@@ -97,14 +82,50 @@ DebugBreakEvent::description()
 // (callable from debugger)
 //
 void
-schedBreakCycle(Tick when)
+schedBreak(Tick when)
+{
+    new DebugBreakEvent(when);
+    warn("need to stop all queues");
+}
+
+void
+schedRelBreak(Tick delta)
 {
-    new DebugBreakEvent(&mainEventQueue, when);
+    schedBreak(curTick() + delta);
+}
+
+///
+/// Function to cause the simulator to take a checkpoint from the debugger
+///
+void
+takeCheckpoint(Tick when)
+{
+    if (!when)
+        when = curTick() + 1;
+    exitSimLoop("checkpoint", 0, when, 0);
 }
 
 void
 eventqDump()
 {
-    mainEventQueue.dump();
+    for (uint32_t i = 0; i < numMainEventQueues; ++i) {
+        mainEventQueue[i]->dump();
+    }
+}
+
+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;
 }