Merge "Indicate that a packet was truncated." am: 046160959c am: e76c8020ba
am: c83ec67ec3
Change-Id: I61c12bc6fbcd205c2421831a64ffb783249a2222
diff --git a/adb_utils.cpp b/adb_utils.cpp
index bb26e70..b236fb3 100644
--- a/adb_utils.cpp
+++ b/adb_utils.cpp
@@ -157,7 +157,12 @@
}
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 @@
line.push_back(isprint(ch) ? ch : '.');
}
+ if (truncated) {
+ line += " [truncated]";
+ }
+
return line;
}