GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VALUE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- LLDB_COMPRESSION_CFLAGS = "-DHAVE_LIBCOMPRESSION=1";
- LLDB_COMPRESSION_LDFLAGS = "-weak-lcompression";
+ LLDB_COMPRESSION_LDFLAGS = "-lcompression";
LLDB_COVERAGE_CFLAGS = "$(LLDB_COVERAGE_CFLAGS_$(LLDB_ENABLE_COVERAGE))";
LLDB_COVERAGE_CFLAGS_1 = "-fprofile-instr-generate -fcoverage-mapping";
LLDB_COVERAGE_LDFLAGS = "$(LLDB_COVERAGE_LDFLAGS_$(LLDB_ENABLE_COVERAGE))";
OTHER_CFLAGS = (
"-Wparentheses",
"$(LLDB_ZLIB_CFLAGS)",
- "$(LLDB_COMPRESSION_CFLAGS)",
"$(LLDB_COVERAGE_CFLAGS)",
"-Wimplicit-fallthrough",
);
OTHER_LDFLAGS = (
- "$(LLDB_COMPRESSION_LDFLAGS)",
+ "-lcompression",
"$(LLDB_ZLIB_LDFLAGS)",
"$(LLDB_COVERAGE_LDFLAGS)",
);
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VALUE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- LLDB_COMPRESSION_CFLAGS = "-DHAVE_LIBCOMPRESSION=1";
- LLDB_COMPRESSION_LDFLAGS = "-weak-lcompression";
+ LLDB_COMPRESSION_LDFLAGS = "-lcompression";
LLDB_COVERAGE_CFLAGS = "$(LLDB_COVERAGE_CFLAGS_$(LLDB_ENABLE_COVERAGE))";
LLDB_COVERAGE_CFLAGS_1 = "-fprofile-instr-generate -fcoverage-mapping";
LLDB_COVERAGE_LDFLAGS = "$(LLDB_COVERAGE_LDFLAGS_$(LLDB_ENABLE_COVERAGE))";
OTHER_CFLAGS = (
"-Wparentheses",
"$(LLDB_ZLIB_CFLAGS)",
- "$(LLDB_COMPRESSION_CFLAGS)",
"$(LLDB_COVERAGE_CFLAGS)",
"-Wimplicit-fallthrough",
);
OTHER_LDFLAGS = (
- "$(LLDB_COMPRESSION_LDFLAGS)",
+ "-lcompression",
"$(LLDB_ZLIB_LDFLAGS)",
"$(LLDB_COVERAGE_LDFLAGS)",
);
"-fno-rtti",
"-Wparentheses",
"$(LLDB_ZLIB_CFLAGS)",
- "$(LLDB_COMPRESSION_CFLAGS)",
"$(LLDB_GTESTS_CFLAGS)",
"-DGTEST_HAS_RTTI=0",
);
"-fno-rtti",
"-Wparentheses",
"$(LLDB_ZLIB_CFLAGS)",
- "$(LLDB_COMPRESSION_CFLAGS)",
"$(LLDB_GTESTS_CFLAGS)",
"-DGTEST_HAS_RTTI=0",
);
"-fno-rtti",
"-Wparentheses",
"$(LLDB_ZLIB_CFLAGS)",
- "$(LLDB_COMPRESSION_CFLAGS)",
"$(LLDB_GTESTS_CFLAGS)",
"-DGTEST_HAS_RTTI=0",
);
"-fno-rtti",
"-Wparentheses",
"$(LLDB_ZLIB_CFLAGS)",
- "$(LLDB_COMPRESSION_CFLAGS)",
"$(LLDB_GTESTS_CFLAGS)",
"-DGTEST_HAS_RTTI=0",
);
"-fno-rtti",
"-Wparentheses",
"$(LLDB_ZLIB_CFLAGS)",
- "$(LLDB_COMPRESSION_CFLAGS)",
"$(LLDB_GTESTS_CFLAGS)",
"-DGTEST_HAS_RTTI=0",
);
"-fno-rtti",
"-Wparentheses",
"$(LLDB_ZLIB_CFLAGS)",
- "$(LLDB_COMPRESSION_CFLAGS)",
"$(LLDB_GTESTS_CFLAGS)",
"-DGTEST_HAS_RTTI=0",
);
"-fno-rtti",
"-Wparentheses",
"$(LLDB_ZLIB_CFLAGS)",
- "$(LLDB_COMPRESSION_CFLAGS)",
"$(LLDB_GTESTS_CFLAGS)",
"-DGTEST_HAS_RTTI=0",
);
"-fno-rtti",
"-Wparentheses",
"$(LLDB_ZLIB_CFLAGS)",
- "$(LLDB_COMPRESSION_CFLAGS)",
"$(LLDB_GTESTS_CFLAGS)",
"-DGTEST_HAS_RTTI=0",
);
"$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)",
"$(inherited)",
);
- LLDB_COMPRESSION_CFLAGS = "";
- "LLDB_COMPRESSION_CFLAGS[sdk=macosx10.11]" = "-DHAVE_LIBCOMPRESSION=1";
- LLDB_COMPRESSION_LDFLAGS = "";
- "LLDB_COMPRESSION_LDFLAGS[sdk=macosx10.11]" = "-weak-lcompression";
+ LLDB_COMPRESSION_LDFLAGS = "-lcompression";
LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1";
LLDB_ZLIB_LDFLAGS = "-lz";
OTHER_CPLUSPLUSFLAGS = (
"$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)",
"$(inherited)",
);
- LLDB_COMPRESSION_CFLAGS = "";
- "LLDB_COMPRESSION_CFLAGS[sdk=macosx10.11]" = "-DHAVE_LIBCOMPRESSION=1";
- LLDB_COMPRESSION_LDFLAGS = "";
- "LLDB_COMPRESSION_LDFLAGS[sdk=macosx10.11]" = "-weak-lcompression";
+ LLDB_COMPRESSION_LDFLAGS = "-lcompression";
LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1";
LLDB_ZLIB_LDFLAGS = "-lz";
OTHER_CPLUSPLUSFLAGS = (
"LLDB_VERSION_STRING=lldb-${CURRENT_PROJECT_VERSION}",
);
HEADER_SEARCH_PATHS = /usr/include/libxml2;
- LLDB_COMPRESSION_CFLAGS = "";
- "LLDB_COMPRESSION_CFLAGS[sdk=macosx10.11]" = "-DHAVE_LIBCOMPRESSION=1";
- LLDB_COMPRESSION_LDFLAGS = "";
- "LLDB_COMPRESSION_LDFLAGS[sdk=macosx10.11]" = "-weak-lcompression";
+ LLDB_COMPRESSION_LDFLAGS = "-lcompression";
LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1";
LLDB_ZLIB_LDFLAGS = "-lz";
MACH_O_TYPE = staticlib;
"LLDB_VERSION_STRING=lldb-${CURRENT_PROJECT_VERSION}",
);
HEADER_SEARCH_PATHS = /usr/include/libxml2;
- LLDB_COMPRESSION_CFLAGS = "";
- "LLDB_COMPRESSION_CFLAGS[sdk=macosx10.11]" = "-DHAVE_LIBCOMPRESSION=1";
- LLDB_COMPRESSION_LDFLAGS = "";
- "LLDB_COMPRESSION_LDFLAGS[sdk=macosx10.11]" = "-weak-lcompression";
+ LLDB_COMPRESSION_LDFLAGS = "-lcompression";
LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1";
LLDB_ZLIB_LDFLAGS = "-lz";
MACH_O_TYPE = staticlib;
"LLDB_VERSION_STRING=lldb-${CURRENT_PROJECT_VERSION}",
);
HEADER_SEARCH_PATHS = /usr/include/libxml2;
- LLDB_COMPRESSION_CFLAGS = "";
- "LLDB_COMPRESSION_CFLAGS[sdk=macosx10.11]" = "-DHAVE_LIBCOMPRESSION=1";
- LLDB_COMPRESSION_LDFLAGS = "";
- "LLDB_COMPRESSION_LDFLAGS[sdk=macosx10.11]" = "-weak-lcompression";
+ LLDB_COMPRESSION_LDFLAGS = "-lcompression";
LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1";
LLDB_ZLIB_LDFLAGS = "-lz";
MACH_O_TYPE = staticlib;
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VALUE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- LLDB_COMPRESSION_CFLAGS = "-DHAVE_LIBCOMPRESSION=1";
- LLDB_COMPRESSION_LDFLAGS = "-weak-lcompression";
+ LLDB_COMPRESSION_LDFLAGS = "-lcompression";
LLDB_COVERAGE_CFLAGS = "$(LLDB_COVERAGE_CFLAGS_$(LLDB_ENABLE_COVERAGE))";
LLDB_COVERAGE_CFLAGS_1 = "-fprofile-instr-generate -fcoverage-mapping";
LLDB_COVERAGE_LDFLAGS = "$(LLDB_COVERAGE_LDFLAGS_$(LLDB_ENABLE_COVERAGE))";
OTHER_CFLAGS = (
"-Wparentheses",
"$(LLDB_ZLIB_CFLAGS)",
- "$(LLDB_COMPRESSION_CFLAGS)",
"$(LLDB_COVERAGE_CFLAGS)",
"-Wimplicit-fallthrough",
"-DNDEBUG",
);
OTHER_LDFLAGS = (
- "$(LLDB_COMPRESSION_LDFLAGS)",
+ "-lcompression",
"$(LLDB_ZLIB_LDFLAGS)",
"$(LLDB_COVERAGE_LDFLAGS)",
);
OTHER_CFLAGS = (
"-Wparentheses",
"$(LLDB_ZLIB_CFLAGS)",
- "$(LLDB_COMPRESSION_CFLAGS)",
"$(LLDB_COVERAGE_CFLAGS)",
"-Wimplicit-fallthrough",
"-fno-rtti",
"$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)",
"$(inherited)",
);
- LLDB_COMPRESSION_CFLAGS = "";
- "LLDB_COMPRESSION_CFLAGS[sdk=macosx10.11]" = "-DHAVE_LIBCOMPRESSION=1";
- LLDB_COMPRESSION_LDFLAGS = "";
- "LLDB_COMPRESSION_LDFLAGS[sdk=macosx10.11]" = "-weak-lcompression";
+ LLDB_COMPRESSION_LDFLAGS = "-lcompression";
LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1";
LLDB_ZLIB_LDFLAGS = "-lz";
OTHER_CPLUSPLUSFLAGS = (
OTHER_CFLAGS = (
"-Wparentheses",
"$(LLDB_ZLIB_CFLAGS)",
- "$(LLDB_COMPRESSION_CFLAGS)",
"$(LLDB_COVERAGE_CFLAGS)",
"-Wimplicit-fallthrough",
"-fno-rtti",
OTHER_CFLAGS = (
"-Wparentheses",
"$(LLDB_ZLIB_CFLAGS)",
- "$(LLDB_COMPRESSION_CFLAGS)",
"$(LLDB_COVERAGE_CFLAGS)",
"-Wimplicit-fallthrough",
"-fno-rtti",
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_VALUE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- LLDB_COMPRESSION_CFLAGS = "-DHAVE_LIBCOMPRESSION=1";
- LLDB_COMPRESSION_LDFLAGS = "-weak-lcompression";
+ LLDB_COMPRESSION_LDFLAGS = "-lcompression";
LLDB_COVERAGE_CFLAGS = "$(LLDB_COVERAGE_CFLAGS_$(LLDB_ENABLE_COVERAGE))";
LLDB_COVERAGE_CFLAGS_1 = "-fprofile-instr-generate -fcoverage-mapping";
LLDB_COVERAGE_LDFLAGS = "$(LLDB_COVERAGE_LDFLAGS_$(LLDB_ENABLE_COVERAGE))";
OTHER_CFLAGS = (
"-Wparentheses",
"$(LLDB_ZLIB_CFLAGS)",
- "$(LLDB_COMPRESSION_CFLAGS)",
"$(LLDB_COVERAGE_CFLAGS)",
"-Wimplicit-fallthrough",
);
OTHER_LDFLAGS = (
- "$(LLDB_COMPRESSION_LDFLAGS)",
+ "-lcompression",
"$(LLDB_ZLIB_LDFLAGS)",
"$(LLDB_COVERAGE_LDFLAGS)",
);
OTHER_CFLAGS = (
"-Wparentheses",
"$(LLDB_ZLIB_CFLAGS)",
- "$(LLDB_COMPRESSION_CFLAGS)",
"$(LLDB_COVERAGE_CFLAGS)",
"-Wimplicit-fallthrough",
"-fno-rtti",
"$(LLVM_BUILD_DIR)/$(LLVM_BUILD_DIR_ARCH)",
"$(inherited)",
);
- LLDB_COMPRESSION_CFLAGS = "";
- "LLDB_COMPRESSION_CFLAGS[sdk=macosx10.11]" = "-DHAVE_LIBCOMPRESSION=1";
- LLDB_COMPRESSION_LDFLAGS = "";
- "LLDB_COMPRESSION_LDFLAGS[sdk=macosx10.11]" = "-weak-lcompression";
+ LLDB_COMPRESSION_LDFLAGS = "-lcompression";
LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1";
LLDB_ZLIB_LDFLAGS = "-lz";
OTHER_CPLUSPLUSFLAGS = (
"LLDB_VERSION_STRING=lldb-${CURRENT_PROJECT_VERSION}",
);
HEADER_SEARCH_PATHS = /usr/include/libxml2;
- LLDB_COMPRESSION_CFLAGS = "";
- "LLDB_COMPRESSION_CFLAGS[sdk=macosx10.11]" = "-DHAVE_LIBCOMPRESSION=1";
- LLDB_COMPRESSION_LDFLAGS = "";
- "LLDB_COMPRESSION_LDFLAGS[sdk=macosx10.11]" = "-weak-lcompression";
+ LLDB_COMPRESSION_LDFLAGS = "-lcompression";
LLDB_ZLIB_CFLAGS = "-DHAVE_LIBZ=1";
LLDB_ZLIB_LDFLAGS = "-lz";
MACH_O_TYPE = staticlib;
#define DEBUGSERVER_BASENAME "lldb-server"
#endif
-#if defined(HAVE_LIBCOMPRESSION)
+#if defined(__APPLE__)
+#define HAVE_LIBCOMPRESSION
#include <compression.h>
#endif
#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_listen_url(), m_decompression_scratch_type(CompressionType::None),
+ m_decompression_scratch(nullptr)
+{
}
//----------------------------------------------------------------------
size_t decompressed_bytes = 0;
if (decompressed_bufsize != ULONG_MAX) {
- decompressed_buffer = (uint8_t *)malloc(decompressed_bufsize + 1);
+ decompressed_buffer = (uint8_t *)malloc(decompressed_bufsize);
if (decompressed_buffer == nullptr) {
m_bytes.erase(0, size_of_first_packet);
return false;
}
#if defined(HAVE_LIBCOMPRESSION)
- // libcompression is weak linked so check that compression_decode_buffer() is
- // available
if (m_compression_type == CompressionType::ZlibDeflate ||
m_compression_type == CompressionType::LZFSE ||
- m_compression_type == CompressionType::LZ4) {
+ m_compression_type == CompressionType::LZ4 ||
+ m_compression_type == CompressionType::LZMA) {
compression_algorithm compression_type;
if (m_compression_type == CompressionType::LZFSE)
compression_type = COMPRESSION_LZFSE;
else if (m_compression_type == CompressionType::LZMA)
compression_type = COMPRESSION_LZMA;
- // If we have the expected size of the decompressed payload, we can
- // allocate the right-sized buffer and do it. If we don't have that
- // information, we'll need to try decoding into a big buffer and if the
- // buffer wasn't big enough, increase it and try again.
+ if (m_decompression_scratch_type != m_compression_type) {
+ if (m_decompression_scratch) {
+ free (m_decompression_scratch);
+ m_decompression_scratch = nullptr;
+ }
+ size_t scratchbuf_size = 0;
+ if (m_compression_type == CompressionType::LZFSE)
+ scratchbuf_size = compression_decode_scratch_buffer_size (COMPRESSION_LZFSE);
+ else if (m_compression_type == CompressionType::LZ4)
+ scratchbuf_size = compression_decode_scratch_buffer_size (COMPRESSION_LZ4_RAW);
+ else if (m_compression_type == CompressionType::ZlibDeflate)
+ scratchbuf_size = compression_decode_scratch_buffer_size (COMPRESSION_ZLIB);
+ else if (m_compression_type == CompressionType::LZMA)
+ scratchbuf_size = compression_decode_scratch_buffer_size (COMPRESSION_LZMA);
+ else if (m_compression_type == CompressionType::LZFSE)
+ scratchbuf_size = compression_decode_scratch_buffer_size (COMPRESSION_LZFSE);
+ if (scratchbuf_size > 0) {
+ m_decompression_scratch = (void*) malloc (scratchbuf_size);
+ m_decompression_scratch_type = m_compression_type;
+ }
+ }
if (decompressed_bufsize != ULONG_MAX && decompressed_buffer != nullptr) {
decompressed_bytes = compression_decode_buffer(
- decompressed_buffer, decompressed_bufsize + 10,
- (uint8_t *)unescaped_content.data(), unescaped_content.size(), NULL,
- compression_type);
+ decompressed_buffer, decompressed_bufsize,
+ (uint8_t *)unescaped_content.data(), unescaped_content.size(),
+ m_decompression_scratch, compression_type);
}
}
#endif