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
This commit is contained in:
parent
80a5c93036
commit
b6d2555ec5
2 changed files with 35 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue