summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2005-10-12 13:45:21 -0400
committerNathan Binkert <binkertn@umich.edu>2005-10-12 13:45:21 -0400
commitb6d2555ec500494d531e94001c723cbc4c06225c (patch)
tree7ee5b36f965992054a82929707e45bd9c57a3ca7 /base
parent80a5c9303649121a18933610acd375ea091247ad (diff)
downloadgem5-b6d2555ec500494d531e94001c723cbc4c06225c.tar.xz
Make it easier to attach the remote debugger.
base/remote_gdb.cc: Keep track of a vector of all of the usable debuggers and provide a current_debugger variable that can be set from gdb to specify which remote debugger is desired. If debugger() is called and the current_debugger is not attached, call accept on its listener so we can still attach a remote debugger from the gdb prompt if we had forgotten to before. Print out more information when the simulator starts so we can distinguish debuggers more easily. base/remote_gdb.hh: Have a remote debugger instance keep track of its listener. Number the remote debuggers so it's easier to figure out which is which. --HG-- extra : convert_revision : 97119597ac3772ea4df6da3b3a4827f50253a51f
Diffstat (limited to 'base')
-rw-r--r--base/remote_gdb.cc37
-rw-r--r--base/remote_gdb.hh7
2 files changed, 35 insertions, 9 deletions
diff --git a/base/remote_gdb.cc b/base/remote_gdb.cc
index 3af73179a..1f3a60bbf 100644
--- a/base/remote_gdb.cc
+++ b/base/remote_gdb.cc
@@ -134,13 +134,19 @@
using namespace std;
#ifdef DEBUG
-RemoteGDB *theDebugger = NULL;
+vector<RemoteGDB *> debuggers;
+int current_debugger = -1;
void
debugger()
{
- if (theDebugger)
- theDebugger->trap(ALPHA_KENTRY_IF);
+ if (current_debugger >= 0 && current_debugger < debuggers.size()) {
+ RemoteGDB *gdb = debuggers[current_debugger];
+ if (!gdb->isattached())
+ gdb->listener->accept();
+ if (gdb->isattached())
+ gdb->trap(ALPHA_KENTRY_IF);
+ }
}
#endif
@@ -161,7 +167,10 @@ GDBListener::Event::process(int revent)
GDBListener::GDBListener(RemoteGDB *g, int p)
: event(NULL), gdb(g), port(p)
-{}
+{
+ assert(!gdb->listener);
+ gdb->listener = this;
+}
GDBListener::~GDBListener()
{
@@ -183,9 +192,21 @@ GDBListener::listen()
port++;
}
- cerr << "Listening for remote gdb connection on port " << port << endl;
event = new Event(this, listener.getfd(), POLLIN);
pollQueue.schedule(event);
+
+#ifdef DEBUG
+ gdb->number = debuggers.size();
+ debuggers.push_back(gdb);
+#endif
+
+#ifdef DEBUG
+ ccprintf(cerr, "%d: %s: listening for remote gdb #%d on port %d\n",
+ curTick, name(), gdb->number, port);
+#else
+ ccprintf(cerr, "%d: %s: listening for remote gdb on port %d\n",
+ curTick, name(), port);
+#endif
}
void
@@ -228,7 +249,8 @@ RemoteGDB::Event::process(int revent)
}
RemoteGDB::RemoteGDB(System *_system, ExecContext *c)
- : event(NULL), fd(-1), active(false), attached(false),
+ : event(NULL), listener(NULL), number(-1), fd(-1),
+ active(false), attached(false),
system(_system), pmem(_system->physmem), context(c)
{
memset(gdbregs, 0, sizeof(gdbregs));
@@ -260,9 +282,6 @@ RemoteGDB::attach(int f)
attached = true;
DPRINTFN("remote gdb attached\n");
-#ifdef DEBUG
- theDebugger = this;
-#endif
}
void
diff --git a/base/remote_gdb.hh b/base/remote_gdb.hh
index f9a220a5d..652a58317 100644
--- a/base/remote_gdb.hh
+++ b/base/remote_gdb.hh
@@ -40,8 +40,13 @@ class System;
class ExecContext;
class PhysicalMemory;
+class GDBListener;
class RemoteGDB
{
+ private:
+ friend void debugger();
+ friend class GDBListener;
+
protected:
class Event : public PollEvent
{
@@ -55,6 +60,8 @@ class RemoteGDB
friend class Event;
Event *event;
+ GDBListener *listener;
+ int number;
protected:
int fd;