From e2eeb9f870afc5b23f029664148d90c562f5b4d4 Mon Sep 17 00:00:00 2001 From: kubistika Date: Tue, 4 Jun 2019 10:28:03 +0300 Subject: [PATCH] rdpgfx: Add WITH_DEBUG_RDPGFX option --- channels/rdpgfx/client/rdpgfx_main.c | 62 ++++++++++++-------------- channels/rdpgfx/rdpgfx_common.h | 6 +++ channels/rdpgfx/server/rdpgfx_main.c | 2 + ci/cmake-preloads/config-linux-all.txt | 1 + cmake/ConfigOptions.cmake | 1 + config.h.in | 1 + 6 files changed, 40 insertions(+), 33 deletions(-) diff --git a/channels/rdpgfx/client/rdpgfx_main.c b/channels/rdpgfx/client/rdpgfx_main.c index 3628d041d..930ef6276 100644 --- a/channels/rdpgfx/client/rdpgfx_main.c +++ b/channels/rdpgfx/client/rdpgfx_main.c @@ -74,7 +74,7 @@ static UINT rdpgfx_send_caps_advertise_pdu(RdpgfxClientContext* context, header.pduLength += RDPGFX_CAPSET_BASE_SIZE + capsSet->length; } - WLog_Print(gfx->log, WLOG_DEBUG, "SendCapsAdvertisePdu %"PRIu16"", pdu->capsSetCount); + DEBUG_RDPGFX(gfx->log, "SendCapsAdvertisePdu %"PRIu16"", pdu->capsSetCount); s = Stream_New(NULL, header.pduLength); if (!s) @@ -305,7 +305,7 @@ static UINT rdpgfx_recv_caps_confirm_pdu(RDPGFX_CHANNEL_CALLBACK* callback, Stream_Read_UINT32(s, capsSet.length); /* capsDataLength (4 bytes) */ Stream_Read_UINT32(s, capsSet.flags); /* capsData (4 bytes) */ gfx->ConnectionCaps = capsSet; - WLog_Print(gfx->log, WLOG_DEBUG, "RecvCapsConfirmPdu: version: 0x%08"PRIX32" flags: 0x%08"PRIX32"", + DEBUG_RDPGFX(gfx->log, "RecvCapsConfirmPdu: version: 0x%08"PRIX32" flags: 0x%08"PRIX32"", capsSet.version, capsSet.flags); if (!context) @@ -344,7 +344,7 @@ static UINT rdpgfx_send_frame_acknowledge_pdu(RdpgfxClientContext* context, header.flags = 0; header.cmdId = RDPGFX_CMDID_FRAMEACKNOWLEDGE; header.pduLength = RDPGFX_HEADER_SIZE + 12; - WLog_Print(gfx->log, WLOG_DEBUG, "SendFrameAcknowledgePdu: %"PRIu32"", pdu->frameId); + DEBUG_RDPGFX(gfx->log, "SendFrameAcknowledgePdu: %"PRIu32"", pdu->frameId); s = Stream_New(NULL, header.pduLength); if (!s) @@ -378,7 +378,7 @@ static UINT rdpgfx_send_qoe_frame_acknowledge_pdu(RDPGFX_CHANNEL_CALLBACK* callb header.flags = 0; header.cmdId = RDPGFX_CMDID_QOEFRAMEACKNOWLEDGE; header.pduLength = RDPGFX_HEADER_SIZE + 12; - WLog_Print(gfx->log, WLOG_DEBUG, "SendQoeFrameAcknowledgePdu: %"PRIu32"", pdu->frameId); + DEBUG_RDPGFX(gfx->log, "SendQoeFrameAcknowledgePdu: %"PRIu32"", pdu->frameId); s = Stream_New(NULL, header.pduLength); if (!s) @@ -463,15 +463,13 @@ static UINT rdpgfx_recv_reset_graphics_pdu(RDPGFX_CHANNEL_CALLBACK* callback, } Stream_Seek(s, pad); /* pad (total size is 340 bytes) */ - WLog_Print(gfx->log, WLOG_DEBUG, - "RecvResetGraphicsPdu: width: %"PRIu32" height: %"PRIu32" count: %"PRIu32"", + DEBUG_RDPGFX(gfx->log, "RecvResetGraphicsPdu: width: %"PRIu32" height: %"PRIu32" count: %"PRIu32"", pdu.width, pdu.height, pdu.monitorCount); for (index = 0; index < pdu.monitorCount; index++) { monitor = &(pdu.monitorDefArray[index]); - WLog_Print(gfx->log, WLOG_DEBUG, - "RecvResetGraphicsPdu: monitor left:%"PRIi32" top:%"PRIi32" right:%"PRIi32" left:%"PRIi32" flags:0x%"PRIx32"", + DEBUG_RDPGFX(gfx->log, "RecvResetGraphicsPdu: monitor left:%"PRIi32" top:%"PRIi32" right:%"PRIi32" left:%"PRIi32" flags:0x%"PRIx32"", monitor->left, monitor->top, monitor->right, monitor->bottom, monitor->flags); } @@ -566,7 +564,7 @@ static UINT rdpgfx_recv_cache_import_reply_pdu(RDPGFX_CHANNEL_CALLBACK* callback Stream_Read_UINT16(s, pdu.cacheSlots[index]); /* cacheSlot (2 bytes) */ } - WLog_Print(gfx->log, WLOG_DEBUG, "RecvCacheImportReplyPdu: importedEntriesCount: %"PRIu16"", + DEBUG_RDPGFX(gfx->log, "RecvCacheImportReplyPdu: importedEntriesCount: %"PRIu16"", pdu.importedEntriesCount); if (context) @@ -604,8 +602,7 @@ static UINT rdpgfx_recv_create_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, Stream_Read_UINT16(s, pdu.width); /* width (2 bytes) */ Stream_Read_UINT16(s, pdu.height); /* height (2 bytes) */ Stream_Read_UINT8(s, pdu.pixelFormat); /* RDPGFX_PIXELFORMAT (1 byte) */ - WLog_Print(gfx->log, WLOG_DEBUG, - "RecvCreateSurfacePdu: surfaceId: %"PRIu16" width: %"PRIu16" height: %"PRIu16" pixelFormat: 0x%02"PRIX8"", + DEBUG_RDPGFX(gfx->log, "RecvCreateSurfacePdu: surfaceId: %"PRIu16" width: %"PRIu16" height: %"PRIu16" pixelFormat: 0x%02"PRIX8"", pdu.surfaceId, pdu.width, pdu.height, pdu.pixelFormat); if (context) @@ -639,7 +636,7 @@ static UINT rdpgfx_recv_delete_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, } Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */ - WLog_Print(gfx->log, WLOG_DEBUG, "RecvDeleteSurfacePdu: surfaceId: %"PRIu16"", pdu.surfaceId); + DEBUG_RDPGFX(gfx->log, "RecvDeleteSurfacePdu: surfaceId: %"PRIu16"", pdu.surfaceId); if (context) { @@ -673,7 +670,7 @@ static UINT rdpgfx_recv_start_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback, Stream_Read_UINT32(s, pdu.timestamp); /* timestamp (4 bytes) */ Stream_Read_UINT32(s, pdu.frameId); /* frameId (4 bytes) */ - WLog_Print(gfx->log, WLOG_DEBUG, "RecvStartFramePdu: frameId: %"PRIu32" timestamp: 0x%08"PRIX32"", + DEBUG_RDPGFX(gfx->log, "RecvStartFramePdu: frameId: %"PRIu32" timestamp: 0x%08"PRIX32"", pdu.frameId, pdu.timestamp); gfx->StartDecodingTime = GetTickCountPrecise(); @@ -710,7 +707,7 @@ static UINT rdpgfx_recv_end_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback, } Stream_Read_UINT32(s, pdu.frameId); /* frameId (4 bytes) */ - WLog_Print(gfx->log, WLOG_DEBUG, "RecvEndFramePdu: frameId: %"PRIu32"", pdu.frameId); + DEBUG_RDPGFX(gfx->log, "RecvEndFramePdu: frameId: %"PRIu32"", pdu.frameId); if (context) { @@ -824,8 +821,8 @@ static UINT rdpgfx_recv_wire_to_surface_1_pdu(RDPGFX_CHANNEL_CALLBACK* callback, pdu.bitmapData = Stream_Pointer(s); Stream_Seek(s, pdu.bitmapDataLength); - WLog_Print(gfx->log, WLOG_DEBUG, - "RecvWireToSurface1Pdu: surfaceId: %"PRIu16" codecId: %s (0x%04"PRIX16") pixelFormat: 0x%02"PRIX8" " + + DEBUG_RDPGFX(gfx->log, "RecvWireToSurface1Pdu: surfaceId: %"PRIu16" codecId: %s (0x%04"PRIX16") pixelFormat: 0x%02"PRIX8" " "destRect: left: %"PRIu16" top: %"PRIu16" right: %"PRIu16" bottom: %"PRIu16" bitmapDataLength: %"PRIu32"", pdu.surfaceId, rdpgfx_get_codec_id_string(pdu.codecId), pdu.codecId, pdu.pixelFormat, @@ -893,11 +890,12 @@ static UINT rdpgfx_recv_wire_to_surface_2_pdu(RDPGFX_CHANNEL_CALLBACK* callback, Stream_Read_UINT32(s, pdu.bitmapDataLength); /* bitmapDataLength (4 bytes) */ pdu.bitmapData = Stream_Pointer(s); Stream_Seek(s, pdu.bitmapDataLength); - WLog_Print(gfx->log, WLOG_DEBUG, + DEBUG_RDPGFX(gfx->log, "RecvWireToSurface2Pdu: surfaceId: %"PRIu16" codecId: %s (0x%04"PRIX16") " "codecContextId: %"PRIu32" pixelFormat: 0x%02"PRIX8" bitmapDataLength: %"PRIu32"", pdu.surfaceId, rdpgfx_get_codec_id_string(pdu.codecId), pdu.codecId, pdu.codecContextId, pdu.pixelFormat, pdu.bitmapDataLength); + cmd.surfaceId = pdu.surfaceId; cmd.codecId = pdu.codecId; cmd.contextId = pdu.codecContextId; @@ -958,8 +956,8 @@ static UINT rdpgfx_recv_delete_encoding_context_pdu(RDPGFX_CHANNEL_CALLBACK* Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */ Stream_Read_UINT32(s, pdu.codecContextId); /* codecContextId (4 bytes) */ - WLog_Print(gfx->log, WLOG_DEBUG, - "RecvDeleteEncodingContextPdu: surfaceId: %"PRIu16" codecContextId: %"PRIu32"", + + DEBUG_RDPGFX(gfx->log, "RecvDeleteEncodingContextPdu: surfaceId: %"PRIu16" codecContextId: %"PRIu32"", pdu.surfaceId, pdu.codecContextId); if (context) @@ -1029,8 +1027,7 @@ static UINT rdpgfx_recv_solid_fill_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStrea return error; } } - - WLog_Print(gfx->log, WLOG_DEBUG, "RecvSolidFillPdu: surfaceId: %"PRIu16" fillRectCount: %"PRIu16"", + DEBUG_RDPGFX(gfx->log, "RecvSolidFillPdu: surfaceId: %"PRIu16" fillRectCount: %"PRIu16"", pdu.surfaceId, pdu.fillRectCount); if (context) @@ -1103,8 +1100,7 @@ static UINT rdpgfx_recv_surface_to_surface_pdu(RDPGFX_CHANNEL_CALLBACK* } } - WLog_Print(gfx->log, WLOG_DEBUG, - "RecvSurfaceToSurfacePdu: surfaceIdSrc: %"PRIu16" surfaceIdDest: %"PRIu16" " + DEBUG_RDPGFX(gfx->log, "RecvSurfaceToSurfacePdu: surfaceIdSrc: %"PRIu16" surfaceIdDest: %"PRIu16" " "left: %"PRIu16" top: %"PRIu16" right: %"PRIu16" bottom: %"PRIu16" destPtsCount: %"PRIu16"", pdu.surfaceIdSrc, pdu.surfaceIdDest, pdu.rectSrc.left, pdu.rectSrc.top, pdu.rectSrc.right, pdu.rectSrc.bottom, @@ -1151,7 +1147,7 @@ static UINT rdpgfx_recv_surface_to_cache_pdu(RDPGFX_CHANNEL_CALLBACK* callback, return error; } - WLog_Print(gfx->log, WLOG_DEBUG, + DEBUG_RDPGFX(gfx->log, "RecvSurfaceToCachePdu: surfaceId: %"PRIu16" cacheKey: 0x%016"PRIX64" cacheSlot: %"PRIu16" " "left: %"PRIu16" top: %"PRIu16" right: %"PRIu16" bottom: %"PRIu16"", pdu.surfaceId, pdu.cacheKey, pdu.cacheSlot, @@ -1220,7 +1216,7 @@ static UINT rdpgfx_recv_cache_to_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, } } - WLog_Print(gfx->log, WLOG_DEBUG, + DEBUG_RDPGFX(gfx->log, "RdpGfxRecvCacheToSurfacePdu: cacheSlot: %"PRIu16" surfaceId: %"PRIu16" destPtsCount: %"PRIu16"", pdu.cacheSlot, pdu.surfaceId, pdu.destPtsCount); @@ -1259,7 +1255,7 @@ static UINT rdpgfx_recv_map_surface_to_output_pdu(RDPGFX_CHANNEL_CALLBACK* Stream_Read_UINT16(s, pdu.reserved); /* reserved (2 bytes) */ Stream_Read_UINT32(s, pdu.outputOriginX); /* outputOriginX (4 bytes) */ Stream_Read_UINT32(s, pdu.outputOriginY); /* outputOriginY (4 bytes) */ - WLog_Print(gfx->log, WLOG_DEBUG, + DEBUG_RDPGFX(gfx->log, "RecvMapSurfaceToOutputPdu: surfaceId: %"PRIu16" outputOriginX: %"PRIu32" outputOriginY: %"PRIu32"", pdu.surfaceId, pdu.outputOriginX, pdu.outputOriginY); @@ -1294,7 +1290,7 @@ static UINT rdpgfx_recv_map_surface_to_scaled_output_pdu(RDPGFX_CHANNEL_CALLBACK Stream_Read_UINT32(s, pdu.outputOriginY); /* outputOriginY (4 bytes) */ Stream_Read_UINT32(s, pdu.targetWidth); /* targetWidth (4 bytes) */ Stream_Read_UINT32(s, pdu.targetHeight); /* targetHeight (4 bytes) */ - WLog_Print(gfx->log, WLOG_DEBUG, + DEBUG_RDPGFX(gfx->log, "RecvMapSurfaceToScaledOutputPdu: surfaceId: %"PRIu16" outputOriginX: %"PRIu32" outputOriginY: %"PRIu32" targetWidth: %"PRIu32" targetHeight: %"PRIu32, pdu.surfaceId, pdu.outputOriginX, pdu.outputOriginY, pdu.targetWidth, pdu.targetHeight); @@ -1333,7 +1329,7 @@ static UINT rdpgfx_recv_map_surface_to_window_pdu(RDPGFX_CHANNEL_CALLBACK* callb Stream_Read_UINT64(s, pdu.windowId); /* windowId (8 bytes) */ Stream_Read_UINT32(s, pdu.mappedWidth); /* mappedWidth (4 bytes) */ Stream_Read_UINT32(s, pdu.mappedHeight); /* mappedHeight (4 bytes) */ - WLog_Print(gfx->log, WLOG_DEBUG, + DEBUG_RDPGFX(gfx->log, "RecvMapSurfaceToWindowPdu: surfaceId: %"PRIu16" windowId: 0x%016"PRIX64" mappedWidth: %"PRIu32" mappedHeight: %"PRIu32"", pdu.surfaceId, pdu.windowId, pdu.mappedWidth, pdu.mappedHeight); @@ -1368,7 +1364,7 @@ static UINT rdpgfx_recv_map_surface_to_scaled_window_pdu(RDPGFX_CHANNEL_CALLBACK Stream_Read_UINT32(s, pdu.mappedHeight); /* mappedHeight (4 bytes) */ Stream_Read_UINT32(s, pdu.targetWidth); /* targetWidth (4 bytes) */ Stream_Read_UINT32(s, pdu.targetHeight); /* targetHeight (4 bytes) */ - WLog_Print(gfx->log, WLOG_DEBUG, + DEBUG_RDPGFX(gfx->log, "RecvMapSurfaceToScaledWindowPdu: surfaceId: %"PRIu16" windowId: 0x%016"PRIX64" mappedWidth: %"PRIu32" mappedHeight: %"PRIu32" targetWidth: %"PRIu32" targetHeight: %"PRIu32"", pdu.surfaceId, pdu.windowId, pdu.mappedWidth, pdu.mappedHeight, pdu.targetWidth, pdu.targetHeight); @@ -1403,7 +1399,7 @@ static UINT rdpgfx_recv_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) return error; } - WLog_Print(gfx->log, WLOG_DEBUG, + DEBUG_RDPGFX(gfx->log, "cmdId: %s (0x%04"PRIX16") flags: 0x%04"PRIX16" pduLength: %"PRIu32"", rdpgfx_get_cmd_id_string(header.cmdId), header.cmdId, header.flags, header.pduLength); @@ -1655,7 +1651,7 @@ static UINT rdpgfx_on_close(IWTSVirtualChannelCallback* pChannelCallback) RDPGFX_CHANNEL_CALLBACK* callback = (RDPGFX_CHANNEL_CALLBACK*) pChannelCallback; RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin; RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface; - WLog_Print(gfx->log, WLOG_DEBUG, "OnClose"); + DEBUG_RDPGFX(gfx->log, "OnClose"); free(callback); gfx->UnacknowledgedFrames = 0; gfx->TotalDecodedFrames = 0; @@ -1763,7 +1759,7 @@ static UINT rdpgfx_plugin_initialize(IWTSPlugin* pPlugin, error = pChannelMgr->CreateListener(pChannelMgr, RDPGFX_DVC_CHANNEL_NAME, 0, (IWTSListenerCallback*) gfx->listener_callback, &(gfx->listener)); gfx->listener->pInterface = gfx->iface.pInterface; - WLog_Print(gfx->log, WLOG_DEBUG, "Initialize"); + DEBUG_RDPGFX(gfx->log, "Initialize"); return error; } @@ -1780,7 +1776,7 @@ static UINT rdpgfx_plugin_terminated(IWTSPlugin* pPlugin) RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) pPlugin; RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface; UINT error = CHANNEL_RC_OK; - WLog_Print(gfx->log, WLOG_DEBUG, "Terminated"); + DEBUG_RDPGFX(gfx->log, "Terminated"); if (gfx->listener_callback) { diff --git a/channels/rdpgfx/rdpgfx_common.h b/channels/rdpgfx/rdpgfx_common.h index 3a3b2803f..4a7d6eca4 100644 --- a/channels/rdpgfx/rdpgfx_common.h +++ b/channels/rdpgfx/rdpgfx_common.h @@ -43,5 +43,11 @@ FREERDP_LOCAL UINT rdpgfx_write_rect16(wStream* s, const RECTANGLE_16* rect16); FREERDP_LOCAL UINT rdpgfx_read_color32(wStream* s, RDPGFX_COLOR32* color32); FREERDP_LOCAL UINT rdpgfx_write_color32(wStream* s, const RDPGFX_COLOR32* color32); +#ifdef WITH_DEBUG_RDPGFX +#define DEBUG_RDPGFX(_LOGGER,...) WLog_Print(_LOGGER, WLOG_DEBUG, __VA_ARGS__) +#else +#define DEBUG_RDPGFX(_LOGGER,...) do { } while (0) +#endif + #endif /* FREERDP_CHANNEL_RDPGFX_COMMON_H */ diff --git a/channels/rdpgfx/server/rdpgfx_main.c b/channels/rdpgfx/server/rdpgfx_main.c index 56ec37784..989f421b3 100644 --- a/channels/rdpgfx/server/rdpgfx_main.c +++ b/channels/rdpgfx/server/rdpgfx_main.c @@ -1318,9 +1318,11 @@ static UINT rdpgfx_server_receive_pdu(RdpgfxServerContext* context, wStream* s) return error; } +#ifdef WITH_DEBUG_RDPGFX WLog_DBG(TAG, "cmdId: %s (0x%04"PRIX16") flags: 0x%04"PRIX16" pduLength: %"PRIu32"", rdpgfx_get_cmd_id_string(header.cmdId), header.cmdId, header.flags, header.pduLength); +#endif switch (header.cmdId) { diff --git a/ci/cmake-preloads/config-linux-all.txt b/ci/cmake-preloads/config-linux-all.txt index 16d3f9ff8..cceaddf30 100644 --- a/ci/cmake-preloads/config-linux-all.txt +++ b/ci/cmake-preloads/config-linux-all.txt @@ -20,6 +20,7 @@ set (WITH_DEBUG_CAPABILITIES OFF CACHE BOOL "enable debug") set (WITH_DEBUG_CERTIFICATE OFF CACHE BOOL "enable debug") set (WITH_DEBUG_CHANNELS OFF CACHE BOOL "enable debug") set (WITH_DEBUG_CLIPRDR OFF CACHE BOOL "enable debug") +set (WITH_DEBUG_RDPGFX OFF CACHE BOOL "enable debug") set (WITH_DEBUG_DVC OFF CACHE BOOL "enable debug") set (WITH_DEBUG_KBD OFF CACHE BOOL "enable debug") set (WITH_DEBUG_LICENSE OFF CACHE BOOL "enable debug") diff --git a/cmake/ConfigOptions.cmake b/cmake/ConfigOptions.cmake index 8e8459b7f..0a8b3a5f8 100644 --- a/cmake/ConfigOptions.cmake +++ b/cmake/ConfigOptions.cmake @@ -105,6 +105,7 @@ option(WITH_DEBUG_CERTIFICATE "Print certificate related debug messages." ${DEFA option(WITH_DEBUG_CAPABILITIES "Print capability negotiation debug messages." ${DEFAULT_DEBUG_OPTION}) option(WITH_DEBUG_CHANNELS "Print channel manager debug messages." ${DEFAULT_DEBUG_OPTION}) option(WITH_DEBUG_CLIPRDR "Print clipboard redirection debug messages" ${DEFAULT_DEBUG_OPTION}) +option(WITH_DEBUG_RDPGFX "Print RDPGFX debug messages" ${DEFAULT_DEBUG_OPTION}) option(WITH_DEBUG_DVC "Print dynamic virtual channel debug messages." ${DEFAULT_DEBUG_OPTION}) option(WITH_DEBUG_TSMF "Print TSMF virtual channel debug messages." ${DEFAULT_DEBUG_OPTION}) option(WITH_DEBUG_KBD "Print keyboard related debug messages." ${DEFAULT_DEBUG_OPTION}) diff --git a/config.h.in b/config.h.in index 2877eea2a..7b55240c2 100644 --- a/config.h.in +++ b/config.h.in @@ -140,6 +140,7 @@ #cmakedefine WITH_DEBUG_CAPABILITIES #cmakedefine WITH_DEBUG_CHANNELS #cmakedefine WITH_DEBUG_CLIPRDR +#cmakedefine WITH_DEBUG_RDPGFX #cmakedefine WITH_DEBUG_DVC #cmakedefine WITH_DEBUG_TSMF #cmakedefine WITH_DEBUG_KBD