Skip to content

Commit 51d021f

Browse files
authored
Move WinDbg Extension to GitHub (#126)
1 parent 882a941 commit 51d021f

18 files changed

+2686
-0
lines changed

src/tools/dbg/analyze.cpp

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*++
2+
3+
Copyright (c) Microsoft Corporation.
4+
Licensed under the MIT License.
5+
6+
Abstract:
7+
8+
QUIC Debugger Extension Command 'analyze'. This command is for analyzing
9+
possible issues on a QUIC handle.
10+
11+
--*/
12+
13+
#include "quictypes.h"
14+
15+
EXT_COMMAND(
16+
quicanalyze,
17+
"Analyze issues of a handle",
18+
"{;e,r;addr;The address of the handle}"
19+
)
20+
{
21+
QuicHandle Handle(GetUnnamedArgU64(0));
22+
auto Type = Handle.Type();
23+
24+
if (Type == QUIC_HANDLE_TYPE_CLIENT || Type == QUIC_HANDLE_TYPE_CHILD) {
25+
AnalyzeConnection(Handle.Addr);
26+
} else if (Type == QUIC_HANDLE_TYPE_STREAM) {
27+
AnalyzeStream(Handle.Addr);
28+
} else {
29+
Dml("Not supported for handle type: %s", Handle.TypeStr());
30+
}
31+
32+
Dml("\n");
33+
}
34+
35+
void EXT_CLASS::AnalyzeConnection(UINT64 Addr)
36+
{
37+
Connection Conn(Addr);
38+
39+
QUIC_CONNECTION_STATE state = Conn.State();
40+
if (state.Freed) {
41+
Dml("The connection has been freed.\n");
42+
} else if (state.HandleClosed) {
43+
Dml("The connection has been closed by the application and is in the process of being deleted.\n");
44+
} else if (state.HandleShutdown) {
45+
Dml("The connection has completed the shutdown process and is ready to be closed by the application.\n");
46+
} else if (state.ClosedLocally || state.ClosedRemotely) {
47+
Dml("The connection is in the process of shutting down.");
48+
if (state.ClosedLocally) {
49+
Dml(" It has been closed locally.");
50+
}
51+
if (state.ClosedRemotely) {
52+
Dml(" It has been closed remotely.");
53+
}
54+
Dml("\n");
55+
} else if (state.Connected) {
56+
Dml("The connection is connected.\n");
57+
} else if (state.Started) {
58+
Dml("The connection is in the process of performing the handshake.\n");
59+
} else if (state.Initialized) {
60+
Dml("The connection has been allocated and successfully initialized.\n");
61+
} else if (state.Allocated) {
62+
Dml("The connection has been allocated.\n");
63+
} else {
64+
Dml("The connection is invalid.\n");
65+
}
66+
67+
//
68+
// TODO ...
69+
//
70+
}
71+
72+
void EXT_CLASS::AnalyzeStream(UINT64 Addr)
73+
{
74+
Stream Strm(Addr);
75+
76+
QUIC_STREAM_FLAGS flags = Strm.Flags();
77+
if (flags.Freed) {
78+
Dml("The stream has been freed.\n");
79+
} else if (flags.HandleClosed) {
80+
Dml("The stream has been closed by the application.\n");
81+
} else if (flags.HandleShutdown) {
82+
Dml("The stream has completed the shutdown process and is ready to be closed by the application.\n");
83+
} else {
84+
auto LocallyClosed = flags.LocalCloseFin || flags.LocalCloseReset;
85+
auto RemotelyClosed = flags.RemoteCloseFin || flags.RemoteCloseReset;
86+
87+
if (RemotelyClosed) {
88+
if (flags.RemoteCloseAcked) {
89+
Dml("The stream's receive pipe has been closed and acknowledged.\n");
90+
} else {
91+
Dml("The stream's receive pipe has been closed but not yet acknowledged.\n");
92+
}
93+
} else {
94+
Dml("The stream's receive pipe is open.\n");
95+
}
96+
97+
if (LocallyClosed) {
98+
if (flags.LocalCloseAcked) {
99+
Dml("The stream's send pipe has been closed and acknowledged.\n");
100+
} else {
101+
Dml("The stream's send pipe has been closed but not yet acknowledged.\n");
102+
}
103+
} else {
104+
Dml("The stream's send pipe is open.\n");
105+
}
106+
}
107+
108+
UINT32 SendRequestsCount = 0;
109+
ULONG64 SendRequestsPtr = Strm.SendRequests();
110+
while (SendRequestsPtr != 0) {
111+
SendRequest Request(SendRequestsPtr);
112+
SendRequestsPtr = Request.Next();
113+
SendRequestsCount++;
114+
}
115+
Dml("The stream has %u send requests pending.\n", SendRequestsCount);
116+
}

src/tools/dbg/binding.cpp

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*++
2+
3+
Copyright (c) Microsoft Corporation.
4+
Licensed under the MIT License.
5+
6+
Abstract:
7+
8+
QUIC Debugger Extension Command 'binding'. This command is for querying the
9+
state of a single binding.
10+
11+
--*/
12+
13+
#include "quictypes.h"
14+
15+
EXT_COMMAND(
16+
quicbinding,
17+
"Shows all information about a Binding",
18+
"{;e,r;addr;The address of the Binding}"
19+
)
20+
{
21+
Binding Binding(GetUnnamedArgU64(0));
22+
auto Lookup = Binding.GetLookup();
23+
auto DatapathBinding = Binding.GetDatapathBinding();
24+
25+
Dml("\n<b>BINDING</b> (<link cmd=\"dt msquic!QUIC_BINDING 0x%I64X\">raw</link>)\n"
26+
"\n"
27+
"\tExclusive %s\n"
28+
"\tConnected %s\n"
29+
"\tRefCount %u\n"
30+
"\tCidCount %u\n"
31+
"\tPartitionCount %u\n"
32+
"\tLocalAddress %s\n"
33+
"\tRemoteAddress %s\n"
34+
"\n",
35+
Binding.Addr,
36+
Binding.Exclusive() ? "true" : "false",
37+
Binding.Connected() ? "true" : "false",
38+
Binding.RefCount(),
39+
Lookup.CidCount(),
40+
Lookup.PartitionCount(),
41+
DatapathBinding.GetLocalAddress().IpString,
42+
DatapathBinding.GetRemoteAddress().IpString);
43+
44+
bool HasAtLeastOne = false;
45+
auto Listeners = Binding.GetListeners();
46+
while (!CheckControlC()) {
47+
ULONG64 LinkAddr = Listeners.Next();
48+
if (LinkAddr == 0) {
49+
break;
50+
}
51+
52+
ULONG64 ListenerAddr = LinkEntryToType(LinkAddr, "msquic!QUIC_LISTENER", "Link");
53+
Dml("\t<link cmd=\"!quiclistener 0x%I64X\">Listener 0x%I64X</link>\n",
54+
ListenerAddr,
55+
ListenerAddr);
56+
HasAtLeastOne = true;
57+
}
58+
59+
if (!HasAtLeastOne) {
60+
Dml("\tNo Listeners\n");
61+
}
62+
63+
Dml("\n");
64+
65+
UCHAR PartitionCount = Lookup.PartitionCount();
66+
if (PartitionCount == 0) {
67+
Connection Conn(Lookup.GetLookupPtr());
68+
Dml("\t<link cmd=\"!quicconnection 0x%I64X\">Connection 0x%I64X</link> [%s]\n",
69+
Conn.Addr,
70+
Conn.Addr,
71+
Conn.TypeStr());
72+
} else {
73+
for (UCHAR i = 0; i < PartitionCount; i++) {
74+
HashTable Hash(Lookup.GetLookupTable(i).GetTablePtr());
75+
Dml("\t<link cmd=\"!hashtable 0x%I64X\">Hash Table %d</link> (%u entries)\n",
76+
Hash.Addr,
77+
i,
78+
Hash.NumEntries());
79+
ULONG64 EntryPtr;
80+
while (!CheckControlC() && Hash.GetNextEntry(&EntryPtr)) {
81+
CidHashEntry Entry(EntryPtr);
82+
Connection Conn(Entry.GetConnection());
83+
Dml("\t <link cmd=\"!quicconnection 0x%I64X\">Connection 0x%I64X</link> [%s]\n",
84+
Conn.Addr,
85+
Conn.Addr,
86+
Conn.TypeStr());
87+
}
88+
}
89+
}
90+
91+
Dml("\n");
92+
}

0 commit comments

Comments
 (0)