From: Raphael Isemann Date: Fri, 25 Jan 2019 08:21:47 +0000 (+0000) Subject: Refactor HAVE_LIBCOMPRESSION and related code in GDBRemoteCommunication X-Git-Tag: llvmorg-9.0.0-rc1~13733 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=46508f6f1165795ac85a5bedd876cb117dc23dbe;p=platform%2Fupstream%2Fllvm.git Refactor HAVE_LIBCOMPRESSION and related code in GDBRemoteCommunication Summary: The field `m_decompression_scratch_type` is only used when `HAVE_LIBCOMPRESSION` is defined, which caused a warning which I fixed in rLLDB350675 by just marking the variable as always used. This patch fixes this in a better way by only defining the variable (and the related `m_decompression_scratch` variable) when `HAVE_LIBCOMPRESSION` is defined. This also required changing the way we handle `HAVE_LIBCOMPRESSION` works, as this was previously always defined on macOS within the source file but not in the header. Now it's always defined from within our config header when CMake defines it or when we are on macOS. The field initialization was moved to the header to prevent that we have `#ifdef` within our initializer list. Reviewers: #lldb, jasonmolenda, sgraenitz, labath Reviewed By: labath Subscribers: labath, beanz, mgorny, lldb-commits, dblaikie Differential Revision: https://reviews.llvm.org/D57011 llvm-svn: 352175 --- diff --git a/lldb/include/lldb/Host/Config.h b/lldb/include/lldb/Host/Config.h index 9a7320f7229e..a16d739892be 100644 --- a/lldb/include/lldb/Host/Config.h +++ b/lldb/include/lldb/Host/Config.h @@ -25,6 +25,8 @@ #define HAVE_SIGACTION 1 +#define HAVE_LIBCOMPRESSION 1 + #else #error This file is only used by the Xcode build. diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index a617e7c80d3b..8133ee567f16 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -41,8 +41,7 @@ #define DEBUGSERVER_BASENAME "lldb-server" #endif -#if defined(__APPLE__) -#define HAVE_LIBCOMPRESSION +#if defined(HAVE_LIBCOMPRESSION) #include #endif @@ -67,10 +66,7 @@ GDBRemoteCommunication::GDBRemoteCommunication(const char *comm_name, #endif m_echo_number(0), m_supports_qEcho(eLazyBoolCalculate), m_history(512), m_send_acks(true), m_compression_type(CompressionType::None), - m_listen_url(), m_decompression_scratch_type(CompressionType::None), - m_decompression_scratch(nullptr) { - // Unused unless HAVE_LIBCOMPRESSION is defined. - (void)m_decompression_scratch_type; + m_listen_url() { } //---------------------------------------------------------------------- @@ -81,8 +77,10 @@ GDBRemoteCommunication::~GDBRemoteCommunication() { Disconnect(); } +#if defined(HAVE_LIBCOMPRESSION) if (m_decompression_scratch) free (m_decompression_scratch); +#endif // Stop the communications read thread which is used to parse all incoming // packets. This function will block until the read thread returns. diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h index 094cc94b0c1d..4ef222406143 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h @@ -18,6 +18,7 @@ #include #include "lldb/Core/Communication.h" +#include "lldb/Host/Config.h" #include "lldb/Host/HostThread.h" #include "lldb/Utility/Args.h" #include "lldb/Utility/Listener.h" @@ -217,8 +218,10 @@ private: HostThread m_listen_thread; std::string m_listen_url; - CompressionType m_decompression_scratch_type; - void *m_decompression_scratch; +#if defined(HAVE_LIBCOMPRESSION) + CompressionType m_decompression_scratch_type = CompressionType::None; + void *m_decompression_scratch = nullptr; +#endif DISALLOW_COPY_AND_ASSIGN(GDBRemoteCommunication); };