Indicate that a packet was truncated.

Test: make checkbuild, check adb log
Bug: None
Change-Id: I0006ed284697f01966fdd79ca0b05dbc6d2eecf0
This commit is contained in:
Dan Albert 2017-06-27 13:26:14 -07:00
parent c70bf5836c
commit 9893f93950
1 changed files with 10 additions and 1 deletions

View File

@ -157,7 +157,12 @@ bool mkdirs(const std::string& path) {
}
std::string dump_hex(const void* data, size_t byte_count) {
byte_count = std::min(byte_count, size_t(16));
size_t truncate_len = 16;
bool truncated = false;
if (byte_count > truncate_len) {
byte_count = truncate_len;
truncated = true;
}
const uint8_t* p = reinterpret_cast<const uint8_t*>(data);
@ -172,6 +177,10 @@ std::string dump_hex(const void* data, size_t byte_count) {
line.push_back(isprint(ch) ? ch : '.');
}
if (truncated) {
line += " [truncated]";
}
return line;
}