|
| 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 | +} |
0 commit comments