gdb: rework meaning of selected/used
This commit is contained in:
parent
bd670cf87c
commit
e57b546dd4
@ -57,15 +57,16 @@ typedef struct Breakpoint
|
|||||||
bool persistent;
|
bool persistent;
|
||||||
} Breakpoint;
|
} Breakpoint;
|
||||||
|
|
||||||
typedef enum GDBFlags
|
enum
|
||||||
{
|
{
|
||||||
GDB_FLAG_SELECTED = 1,
|
GDB_FLAG_SELECTED = 1,
|
||||||
GDB_FLAG_USED = 2,
|
GDB_FLAG_USED = 2,
|
||||||
|
GDB_FLAG_ALLOCATED_MASK = GDB_FLAG_SELECTED | GDB_FLAG_USED,
|
||||||
GDB_FLAG_NOACK = 4,
|
GDB_FLAG_NOACK = 4,
|
||||||
GDB_FLAG_PROCESS_CONTINUING = 8,
|
GDB_FLAG_PROCESS_CONTINUING = 8,
|
||||||
GDB_FLAG_TERMINATE_PROCESS = 16,
|
GDB_FLAG_TERMINATE_PROCESS = 16,
|
||||||
GDB_FLAG_ATTACHED_AT_START = 32,
|
GDB_FLAG_ATTACHED_AT_START = 32,
|
||||||
} GDBFlags;
|
};
|
||||||
|
|
||||||
typedef enum GDBState
|
typedef enum GDBState
|
||||||
{
|
{
|
||||||
@ -91,7 +92,7 @@ typedef struct GDBContext
|
|||||||
RecursiveLock lock;
|
RecursiveLock lock;
|
||||||
u16 localPort;
|
u16 localPort;
|
||||||
|
|
||||||
GDBFlags flags;
|
u32 flags;
|
||||||
GDBState state;
|
GDBState state;
|
||||||
|
|
||||||
u32 pid;
|
u32 pid;
|
||||||
|
@ -114,7 +114,7 @@ GDBContext *GDB_SelectAvailableContext(GDBServer *server, u16 minPort, u16 maxPo
|
|||||||
|
|
||||||
// Get a context
|
// Get a context
|
||||||
u32 id;
|
u32 id;
|
||||||
for(id = 0; id < MAX_DEBUG && (server->ctxs[id].flags & GDB_FLAG_SELECTED); id++);
|
for(id = 0; id < MAX_DEBUG && (server->ctxs[id].flags & GDB_FLAG_ALLOCATED_MASK); id++);
|
||||||
if(id < MAX_DEBUG)
|
if(id < MAX_DEBUG)
|
||||||
ctx = &server->ctxs[id];
|
ctx = &server->ctxs[id];
|
||||||
else
|
else
|
||||||
@ -129,7 +129,7 @@ GDBContext *GDB_SelectAvailableContext(GDBServer *server, u16 minPort, u16 maxPo
|
|||||||
bool portUsed = false;
|
bool portUsed = false;
|
||||||
for(id = 0; id < MAX_DEBUG; id++)
|
for(id = 0; id < MAX_DEBUG; id++)
|
||||||
{
|
{
|
||||||
if((server->ctxs[id].flags & GDB_FLAG_SELECTED) && server->ctxs[id].localPort == port)
|
if((server->ctxs[id].flags & GDB_FLAG_ALLOCATED_MASK) && server->ctxs[id].localPort == port)
|
||||||
portUsed = true;
|
portUsed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ GDBContext *GDB_FindAllocatedContextByPid(GDBServer *server, u32 pid)
|
|||||||
GDBContext *ctx = NULL;
|
GDBContext *ctx = NULL;
|
||||||
for(u32 i = 0; i < MAX_DEBUG; i++)
|
for(u32 i = 0; i < MAX_DEBUG; i++)
|
||||||
{
|
{
|
||||||
if((server->ctxs[i].flags & GDB_FLAG_SELECTED) && server->ctxs[i].pid == pid)
|
if((server->ctxs[i].flags & GDB_FLAG_ALLOCATED_MASK) && server->ctxs[i].pid == pid)
|
||||||
ctx = &server->ctxs[i];
|
ctx = &server->ctxs[i];
|
||||||
}
|
}
|
||||||
GDB_UnlockAllContexts(server);
|
GDB_UnlockAllContexts(server);
|
||||||
@ -216,7 +216,7 @@ void GDB_ReleaseClient(GDBServer *server, GDBContext *ctx)
|
|||||||
RecursiveLock_Lock(&ctx->lock);
|
RecursiveLock_Lock(&ctx->lock);
|
||||||
ctx->localPort = 0;
|
ctx->localPort = 0;
|
||||||
ctx->enableExternalMemoryAccess = false;
|
ctx->enableExternalMemoryAccess = false;
|
||||||
ctx->flags = (GDBFlags)0;
|
ctx->flags = 0;
|
||||||
ctx->state = GDB_STATE_DISCONNECTED;
|
ctx->state = GDB_STATE_DISCONNECTED;
|
||||||
|
|
||||||
ctx->catchThreadEvents = false;
|
ctx->catchThreadEvents = false;
|
||||||
@ -266,7 +266,7 @@ int GDB_DoPacket(GDBContext *ctx)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
RecursiveLock_Lock(&ctx->lock);
|
RecursiveLock_Lock(&ctx->lock);
|
||||||
GDBFlags oldFlags = ctx->flags;
|
u32 oldFlags = ctx->flags;
|
||||||
|
|
||||||
if(ctx->state == GDB_STATE_DISCONNECTED)
|
if(ctx->state == GDB_STATE_DISCONNECTED)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -73,7 +73,7 @@ void debuggerSetNextApplicationDebugHandle(Handle debug)
|
|||||||
GDB_LockAllContexts(&gdbServer);
|
GDB_LockAllContexts(&gdbServer);
|
||||||
nextApplicationGdbCtx->debug = debug;
|
nextApplicationGdbCtx->debug = debug;
|
||||||
if (debug == 0)
|
if (debug == 0)
|
||||||
nextApplicationGdbCtx->flags = (GDBFlags)0;
|
nextApplicationGdbCtx->flags = 0;
|
||||||
else
|
else
|
||||||
nextApplicationGdbCtx->flags |= GDB_FLAG_ATTACHED_AT_START;
|
nextApplicationGdbCtx->flags |= GDB_FLAG_ATTACHED_AT_START;
|
||||||
nextApplicationGdbCtx = NULL;
|
nextApplicationGdbCtx = NULL;
|
||||||
|
Reference in New Issue
Block a user