summaryrefslogtreecommitdiffstats
path: root/adb/adb_utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'adb/adb_utils.cpp')
-rw-r--r--adb/adb_utils.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/adb/adb_utils.cpp b/adb/adb_utils.cpp
index f10c143..0ce5ece 100644
--- a/adb/adb_utils.cpp
+++ b/adb/adb_utils.cpp
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#define TRACE_TAG TRACE_ADB
+
#include "adb_utils.h"
#include <stdlib.h>
@@ -21,6 +23,11 @@
#include <sys/types.h>
#include <unistd.h>
+#include <algorithm>
+
+#include <base/stringprintf.h>
+
+#include "adb_trace.h"
#include "sysdeps.h"
bool getcwd(std::string* s) {
@@ -50,3 +57,25 @@ std::string escape_arg(const std::string& s) {
result.push_back('\'');
return result;
}
+
+void dump_hex(const void* data, size_t byte_count) {
+ byte_count = std::min(byte_count, size_t(16));
+
+ const uint8_t* p = reinterpret_cast<const uint8_t*>(data);
+
+ std::string line;
+ for (size_t i = 0; i < byte_count; ++i) {
+ android::base::StringAppendF(&line, "%02x", p[i]);
+ }
+ line.push_back(' ');
+
+ for (size_t i = 0; i < byte_count; ++i) {
+ int c = p[i];
+ if (c < 32 || c > 127) {
+ c = '.';
+ }
+ line.push_back(c);
+ }
+
+ DR("%s\n", line.c_str());
+}