The root cause is SerialPortDebugCommunicationLib returns NULL debug port handle causing the CompressData() doesn't send the compressed data. The fix doesn't rely on the debug port handle value and uses Send parameter to indicate whether to send the compressed data.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ruiyu Ni <ruiyu...@intel.com> CC: Jeff Fan <jeff....@intel.com> --- SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c index 3daa633..9d7a65f 100644 --- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c +++ b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c @@ -1473,29 +1473,30 @@ CopyMemByWidth ( @param[in] Data The data buffer. @param[in] Length The length of the data buffer. + @param[in] Send TRUE to send the compressed data buffer. @param[out] CompressedLength Return the length of the compressed data buffer. It may be larger than the Length in some cases. @param[out] CompressedCrc Return the CRC of the compressed data buffer. - @param[in] Handle The debug channel handle to send the compressed data buffer. **/ VOID -CompressDataThenSend ( +CompressData ( IN UINT8 *Data, IN UINT8 Length, + IN BOOLEAN Send, OUT UINTN *CompressedLength, OPTIONAL - OUT UINT16 *CompressedCrc, OPTIONAL - IN DEBUG_PORT_HANDLE Handle OPTIONAL + OUT UINT16 *CompressedCrc OPTIONAL ) { - UINTN Index; - UINT8 LastChar; - UINT8 LastCharCount; - UINT8 CurrentChar; - UINTN CompressedIndex; + UINTN Index; + UINT8 LastChar; + UINT8 LastCharCount; + UINT8 CurrentChar; + UINTN CompressedIndex; + DEBUG_PORT_HANDLE Handle; ASSERT (Length > 0); - - LastChar = Data[0] + 1; // Just ensure it's different from the first byte. + Handle = GetDebugPortHandle (); + LastChar = Data[0] + 1; // Just ensure it's different from the first byte. LastCharCount = 0; for (Index = 0, CompressedIndex = 0; Index <= Length; Index++) { @@ -1510,7 +1511,7 @@ CompressDataThenSend ( if (CompressedCrc != NULL) { *CompressedCrc = CalculateCrc16 (&LastChar, 1, *CompressedCrc); } - if (Handle != NULL) { + if (Send) { DebugPortWriteBuffer (Handle, &LastChar, 1); } @@ -1522,7 +1523,7 @@ CompressDataThenSend ( *CompressedCrc = CalculateCrc16 (&LastChar, 1, *CompressedCrc); *CompressedCrc = CalculateCrc16 (&LastCharCount, 1, *CompressedCrc); } - if (Handle != NULL) { + if (Send) { DebugPortWriteBuffer (Handle, &LastChar, 1); DebugPortWriteBuffer (Handle, &LastChar, 1); DebugPortWriteBuffer (Handle, &LastCharCount, 1); @@ -1605,11 +1606,11 @@ ReadMemoryAndSendResponsePacket ( // // Get the compressed data size without modifying the packet. // - CompressDataThenSend ( + CompressData ( (UINT8 *) (DebugHeader + 1), CurrentDataSize, + FALSE, &CompressedDataSize, - NULL, NULL ); } else { @@ -1622,12 +1623,12 @@ ReadMemoryAndSendResponsePacket ( // Compute the CRC of the packet head without modifying the packet. // DebugHeader->Crc = CalculateCrc16 ((UINT8 *) DebugHeader, sizeof (DEBUG_PACKET_HEADER), 0); - CompressDataThenSend ( + CompressData ( (UINT8 *) (DebugHeader + 1), CurrentDataSize, + FALSE, NULL, - &DebugHeader->Crc, - NULL + &DebugHeader->Crc ); // // Send out the packet head. @@ -1636,12 +1637,12 @@ ReadMemoryAndSendResponsePacket ( // // Compress and send out the packet data. // - CompressDataThenSend ( + CompressData ( (UINT8 *) (DebugHeader + 1), CurrentDataSize, + TRUE, NULL, - NULL, - Handle + NULL ); } else { -- 1.9.5.msysgit.1 ------------------------------------------------------------------------------ One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel