Skip to content

[lldb] [NFC] Remove min pkt size for compression setting #81075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions lldb/docs/lldb-gdb-remote.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1998,16 +1998,12 @@ for this region.
// If the debug stub can support compression, it indictes this in the reply of the
// "qSupported" packet. e.g.
// LLDB SENDS: qSupported:xmlRegisters=i386,arm,mips
// STUB REPLIES: qXfer:features:read+;SupportedCompressions=lzfse,zlib-deflate,lz4,lzma;DefaultCompressionMinSize=384
// STUB REPLIES: qXfer:features:read+;SupportedCompressions=lzfse,zlib-deflate,lz4,lzma;
//
// If lldb knows how to use any of these compression algorithms, it can ask that this
// compression mode be enabled. It may optionally change the minimum packet size
// where compression is used. Typically small packets do not benefit from compression,
// as well as compression headers -- compression is most beneficial with larger packets.
// compression mode be enabled.
//
// QEnableCompression:type:zlib-deflate;
// or
// QEnableCompression:type:zlib-deflate;minsize:512;
//
// The debug stub should reply with an uncompressed "OK" packet to indicate that the
// request was accepted. All further packets the stub sends will use this compression.
Expand Down
25 changes: 1 addition & 24 deletions lldb/tools/debugserver/source/RNBRemote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3575,8 +3575,6 @@ rnb_err_t RNBRemote::HandlePacket_qSupported(const char *p) {

if (enable_compression) {
reply << "SupportedCompressions=lzfse,zlib-deflate,lz4,lzma;";
reply << "DefaultCompressionMinSize=" << std::dec << m_compression_minsize
<< ";";
}

#if (defined(__arm64__) || defined(__aarch64__))
Expand Down Expand Up @@ -4482,46 +4480,25 @@ rnb_err_t RNBRemote::HandlePacket_SetEnableAsyncProfiling(const char *p) {
return SendPacket("OK");
}

// QEnableCompression:type:<COMPRESSION-TYPE>;minsize:<MINIMUM PACKET SIZE TO
// COMPRESS>;
// QEnableCompression:type:<COMPRESSION-TYPE>;
//
// type: must be a type previously reported by the qXfer:features:
// SupportedCompressions list
//
// minsize: is optional; by default the qXfer:features:
// DefaultCompressionMinSize value is used
// debugserver may have a better idea of what a good minimum packet size to
// compress is than lldb.

rnb_err_t RNBRemote::HandlePacket_QEnableCompression(const char *p) {
p += sizeof("QEnableCompression:") - 1;

size_t new_compression_minsize = m_compression_minsize;
const char *new_compression_minsize_str = strstr(p, "minsize:");
if (new_compression_minsize_str) {
new_compression_minsize_str += strlen("minsize:");
errno = 0;
new_compression_minsize = strtoul(new_compression_minsize_str, NULL, 10);
if (errno != 0 || new_compression_minsize == ULONG_MAX) {
new_compression_minsize = m_compression_minsize;
}
}

if (strstr(p, "type:zlib-deflate;") != nullptr) {
EnableCompressionNextSendPacket(compression_types::zlib_deflate);
m_compression_minsize = new_compression_minsize;
return SendPacket("OK");
} else if (strstr(p, "type:lz4;") != nullptr) {
EnableCompressionNextSendPacket(compression_types::lz4);
m_compression_minsize = new_compression_minsize;
return SendPacket("OK");
} else if (strstr(p, "type:lzma;") != nullptr) {
EnableCompressionNextSendPacket(compression_types::lzma);
m_compression_minsize = new_compression_minsize;
return SendPacket("OK");
} else if (strstr(p, "type:lzfse;") != nullptr) {
EnableCompressionNextSendPacket(compression_types::lzfse);
m_compression_minsize = new_compression_minsize;
return SendPacket("OK");
}

Expand Down