diff options
Diffstat (limited to 'libs/binder/Debug.cpp')
-rw-r--r-- | libs/binder/Debug.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/libs/binder/Debug.cpp b/libs/binder/Debug.cpp index 64c1ff68c0..86769551d7 100644 --- a/libs/binder/Debug.cpp +++ b/libs/binder/Debug.cpp @@ -14,7 +14,8 @@ * limitations under the License. */ -#include <binder/Debug.h> +#include "Debug.h" + #include <binder/ProcessState.h> #include <utils/misc.h> @@ -25,6 +26,22 @@ namespace android { +std::string hexString(const void* bytes, size_t len) { + if (bytes == nullptr) return "<null>"; + + const uint8_t* bytes8 = static_cast<const uint8_t*>(bytes); + const char chars[] = "0123456789abcdef"; + std::string result; + result.resize(len * 2); + + for (size_t i = 0; i < len; i++) { + result[2 * i] = chars[bytes8[i] >> 4]; + result[2 * i + 1] = chars[bytes8[i] & 0xf]; + } + + return result; +} + // --------------------------------------------------------------------- static const char indentStr[] = @@ -208,7 +225,7 @@ void printHexData(int32_t indent, const void *buf, size_t length, } for (offset = 0; ; offset += bytesPerLine, pos += bytesPerLine) { - long remain = length; + ssize_t remain = length; char* c = buffer; if (!oneLine && !cStyle) { |