Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger Extension Fixes & Improvements #4281

Merged
merged 2 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/plugins/dbg/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ EXT_COMMAND(
}

Registration Registration = Registration::FromLink(LinkAddr);
Dml("\t<link cmd=\"!quicregistration 0x%I64X\">0x%I64X</link>\t\"%s\"\n",
Dml("\t<link cmd=\"!quicregistration 0x%I64X\">0x%I64X</link>\t%s\t\t\"%s\"\n",
Registration.Addr,
Registration.Addr,
Registration.GetWorkersState(),
Registration.GetAppName().Data);
HasAtLeastOne = true;
}
Expand Down
56 changes: 50 additions & 6 deletions src/plugins/dbg/quictypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,28 @@ struct Listener : Struct {
}
};

struct CxPlatWorker : Struct {

CxPlatWorker(ULONG64 Addr) : Struct("msquic!CXPLAT_WORKER", Addr) { }

ULONG64 Thread() {
return ReadPointer("Thread");
}
};

struct CxPlatExecutionContext : Struct {

CxPlatExecutionContext(ULONG64 Addr) : Struct("msquic!CXPLAT_EXECUTION_CONTEXT", Addr) { }

ULONG64 CxPlatContext() {
return ReadPointer("CxPlatContext");
}

CxPlatWorker GetCxPlatWorker() {
return CxPlatWorker(CxPlatContext());
}
};

struct Worker : Struct {

Worker(ULONG64 Addr) : Struct("msquic!QUIC_WORKER", Addr) { }
Expand All @@ -1315,25 +1337,32 @@ struct Worker : Struct {
return ReadType<BOOLEAN>("IsActive");
}

bool HasWorkQueue() {
return !GetConnections().IsEmpty() || !GetOperations().IsEmpty();
}

PSTR StateStr() {
bool HasWorkQueue = !GetConnections().IsEmpty() || !GetOperations().IsEmpty();
if (IsActive()) {
return HasWorkQueue ? "ACTIVE (+queue)" : "ACTIVE";
return HasWorkQueue() ? "ACTIVE (+queue)" : "ACTIVE (no queue)";
} else {
return HasWorkQueue ? "QUEUE" : "IDLE";
return HasWorkQueue() ? "QUEUE" : "IDLE (no queue)";
}
}

UINT16 PartitionIndex() {
return ReadType<UINT16>("PartitionIndex");
}

UINT32 ThreadID() {
return ReadType<UINT32>("ThreadID");
CxPlatExecutionContext GetCxPlatExecutionContext() {
return CxPlatExecutionContext(AddrOf("ExecutionContext"));
}

ULONG64 Thread() {
return ReadPointer("Thread");
ULONG64 thread = ReadPointer("Thread");
if (!thread) {
thread = GetCxPlatExecutionContext().GetCxPlatWorker().Thread();
}
return thread;
}

LinkedList GetConnections() {
Expand Down Expand Up @@ -1429,6 +1458,21 @@ struct Registration : Struct {
String GetAppName() {
return String(AddrOf("AppName"));
}

PSTR GetWorkersState() {
auto Workers = GetWorkerPool();
UCHAR WorkerCount = Workers.WorkerCount();
bool HasQueuedWorker = false;
for (UCHAR i = 0; i < WorkerCount; i++) {
if (Workers.GetWorker(i).IsActive()) {
return " ACTIVE";
}
if (Workers.GetWorker(i).HasWorkQueue()) {
HasQueuedWorker = true;
}
}
return HasQueuedWorker ? "QUEUED" : " IDLE";
}
};

struct LookupHashTable : Struct {
Expand Down
5 changes: 2 additions & 3 deletions src/plugins/dbg/worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ EXT_COMMAND(
"\n"
"\tState %s\n"
"\tPartition %u\n"
"\tThread 0x%X (<link cmd=\"~~[0x%X]s\">UM</link>/<link cmd=\"!thread 0x%I64X\">KM</link>)\n",
"\tThread <link cmd=\"!thread 0x%I64X\">0x%X</link>\n",
Work.Addr,
Work.StateStr(),
Work.PartitionIndex(),
Work.ThreadID(),
Work.ThreadID(),
Work.Thread(),
Work.Thread());

Dml("\n<u>QUEUE</u>\n"
Expand Down
Loading