changeset bd68c6838b9f in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=bd68c6838b9f
description:
        sim: Ensure GDB interrupts the simulation at an instruction boundary.

        Use the comInstEventQueue to ensure GDB interrupts the simulation at an
        instruction boundary and not in the middle of a macroop, memory access, 
etc.

diffstat:

 src/base/remote_gdb.cc |  24 ++++++++++++++++++++----
 src/base/remote_gdb.hh |  15 +++++++++++++++
 2 files changed, 35 insertions(+), 4 deletions(-)

diffs (77 lines):

diff -r 1eec33d2fc52 -r bd68c6838b9f src/base/remote_gdb.cc
--- a/src/base/remote_gdb.cc    Fri Dec 05 01:47:35 2014 -0800
+++ b/src/base/remote_gdb.cc    Fri Dec 05 01:51:49 2014 -0800
@@ -1,4 +1,5 @@
 /*
+ * Copyright 2014 Google, Inc.
  * Copyright (c) 2002-2005 The Regents of The University of Michigan
  * All rights reserved.
  *
@@ -129,6 +130,7 @@
 #include "base/socket.hh"
 #include "base/trace.hh"
 #include "config/the_isa.hh"
+#include "cpu/base.hh"
 #include "cpu/static_inst.hh"
 #include "cpu/thread_context.hh"
 #include "debug/GDBAll.hh"
@@ -246,14 +248,28 @@
 void
 BaseRemoteGDB::Event::process(int revent)
 {
-    if (revent & POLLIN)
-        gdb->trap(SIGILL);
-    else if (revent & POLLNVAL)
+    BaseCPU *cpu = gdb->context->getCpuPtr();
+    EventQueue *eq = cpu->comInstEventQueue[gdb->context->threadId()];
+    if (revent & POLLIN) {
+        gdb->trapEvent.type(SIGILL);
+        // Here "ticks" aren't simulator ticks which measure time, they're
+        // instructions committed by the CPU.
+        eq->schedule(&gdb->trapEvent, eq->getCurTick());
+    } else if (revent & POLLNVAL) {
+        if (gdb->trapEvent.scheduled())
+            eq->deschedule(&gdb->trapEvent);
         gdb->detach();
+    }
+}
+
+void
+BaseRemoteGDB::TrapEvent::process()
+{
+    gdb->trap(_type);
 }
 
 BaseRemoteGDB::BaseRemoteGDB(System *_system, ThreadContext *c, size_t 
cacheSize)
-    : event(NULL), listener(NULL), number(-1), fd(-1),
+    : event(NULL), trapEvent(this), listener(NULL), number(-1), fd(-1),
       active(false), attached(false),
       system(_system), context(c),
       gdbregs(cacheSize)
diff -r 1eec33d2fc52 -r bd68c6838b9f src/base/remote_gdb.hh
--- a/src/base/remote_gdb.hh    Fri Dec 05 01:47:35 2014 -0800
+++ b/src/base/remote_gdb.hh    Fri Dec 05 01:51:49 2014 -0800
@@ -115,8 +115,23 @@
         void process(int revent);
     };
 
+    class TrapEvent : public ::Event
+    {
+      protected:
+        int _type;
+        BaseRemoteGDB *gdb;
+
+      public:
+        TrapEvent(BaseRemoteGDB *g) : gdb(g)
+        {}
+
+        void type(int t) { _type = t; }
+        void process();
+    };
+
     friend class Event;
     Event *event;
+    TrapEvent trapEvent;
     GDBListener *listener;
     int number;
 
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to