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;
|
using namespace std;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
RemoteGDB *theDebugger = NULL;
|
vector<RemoteGDB *> debuggers;
|
||||||
|
int current_debugger = -1;
|
||||||
|
|
||||||
void
|
void
|
||||||
debugger()
|
debugger()
|
||||||
{
|
{
|
||||||
if (theDebugger)
|
if (current_debugger >= 0 && current_debugger < debuggers.size()) {
|
||||||
theDebugger->trap(ALPHA_KENTRY_IF);
|
RemoteGDB *gdb = debuggers[current_debugger];
|
||||||
|
if (!gdb->isattached())
|
||||||
|
gdb->listener->accept();
|
||||||
|
if (gdb->isattached())
|
||||||
|
gdb->trap(ALPHA_KENTRY_IF);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -161,7 +167,10 @@ GDBListener::Event::process(int revent)
|
||||||
|
|
||||||
GDBListener::GDBListener(RemoteGDB *g, int p)
|
GDBListener::GDBListener(RemoteGDB *g, int p)
|
||||||
: event(NULL), gdb(g), port(p)
|
: event(NULL), gdb(g), port(p)
|
||||||
{}
|
{
|
||||||
|
assert(!gdb->listener);
|
||||||
|
gdb->listener = this;
|
||||||
|
}
|
||||||
|
|
||||||
GDBListener::~GDBListener()
|
GDBListener::~GDBListener()
|
||||||
{
|
{
|
||||||
|
@ -183,9 +192,21 @@ GDBListener::listen()
|
||||||
port++;
|
port++;
|
||||||
}
|
}
|
||||||
|
|
||||||
cerr << "Listening for remote gdb connection on port " << port << endl;
|
|
||||||
event = new Event(this, listener.getfd(), POLLIN);
|
event = new Event(this, listener.getfd(), POLLIN);
|
||||||
pollQueue.schedule(event);
|
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
|
void
|
||||||
|
@ -228,7 +249,8 @@ RemoteGDB::Event::process(int revent)
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoteGDB::RemoteGDB(System *_system, ExecContext *c)
|
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)
|
system(_system), pmem(_system->physmem), context(c)
|
||||||
{
|
{
|
||||||
memset(gdbregs, 0, sizeof(gdbregs));
|
memset(gdbregs, 0, sizeof(gdbregs));
|
||||||
|
@ -260,9 +282,6 @@ RemoteGDB::attach(int f)
|
||||||
|
|
||||||
attached = true;
|
attached = true;
|
||||||
DPRINTFN("remote gdb attached\n");
|
DPRINTFN("remote gdb attached\n");
|
||||||
#ifdef DEBUG
|
|
||||||
theDebugger = this;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -40,8 +40,13 @@ class System;
|
||||||
class ExecContext;
|
class ExecContext;
|
||||||
class PhysicalMemory;
|
class PhysicalMemory;
|
||||||
|
|
||||||
|
class GDBListener;
|
||||||
class RemoteGDB
|
class RemoteGDB
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
friend void debugger();
|
||||||
|
friend class GDBListener;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
class Event : public PollEvent
|
class Event : public PollEvent
|
||||||
{
|
{
|
||||||
|
@ -55,6 +60,8 @@ class RemoteGDB
|
||||||
|
|
||||||
friend class Event;
|
friend class Event;
|
||||||
Event *event;
|
Event *event;
|
||||||
|
GDBListener *listener;
|
||||||
|
int number;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int fd;
|
int fd;
|
||||||
|
|
Loading…
Reference in a new issue