aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/break.c
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2017-11-24 10:07:32 +0100
committerBjörn Gustavsson <[email protected]>2017-11-24 10:07:32 +0100
commit213443f024244df9508a1f6ac114d4b4a053589a (patch)
tree2f6d74bdfed2e849ab56adb318c5883e632b656d /erts/emulator/beam/break.c
parent7a696f54179c0522b1acd53506e2486876132569 (diff)
parentc17978f689ca8f9dd36f76fa8fcf448664921301 (diff)
downloadotp-213443f024244df9508a1f6ac114d4b4a053589a.tar.gz
otp-213443f024244df9508a1f6ac114d4b4a053589a.tar.bz2
otp-213443f024244df9508a1f6ac114d4b4a053589a.zip
Merge branch 'maint'
* maint: Use base64 encoding in crash dumps Correct parsing of sub binaries Generalize passing of options for decoding
Diffstat (limited to 'erts/emulator/beam/break.c')
-rw-r--r--erts/emulator/beam/break.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/erts/emulator/beam/break.c b/erts/emulator/beam/break.c
index d9ee940662..2bfb481771 100644
--- a/erts/emulator/beam/break.c
+++ b/erts/emulator/beam/break.c
@@ -488,9 +488,7 @@ loaded(fmtfn_t to, void *to_arg)
static void
dump_attributes(fmtfn_t to, void *to_arg, byte* ptr, int size)
{
- while (size-- > 0) {
- erts_print(to, to_arg, "%02X", *ptr++);
- }
+ erts_print_base64(to, to_arg, ptr, size);
erts_print(to, to_arg, "\n");
}
@@ -848,7 +846,7 @@ erl_crash_dump_v(char *file, int line, char* fmt, va_list args)
}
time(&now);
- erts_cbprintf(to, to_arg, "=erl_crash_dump:0.4\n%s", ctime(&now));
+ erts_cbprintf(to, to_arg, "=erl_crash_dump:0.5\n%s", ctime(&now));
if (file != NULL)
erts_cbprintf(to, to_arg, "The error occurred in file %s, line %d\n", file, line);
@@ -959,3 +957,28 @@ erl_crash_dump_v(char *file, int line, char* fmt, va_list args)
erts_fprintf(stderr,"done\n");
}
+void
+erts_print_base64(fmtfn_t to, void *to_arg, byte* src, Uint size)
+{
+ static const byte base64_chars[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+ while (size >= 3) {
+ erts_putc(to, to_arg, base64_chars[src[0] >> 2]);
+ erts_putc(to, to_arg, base64_chars[((src[0] & 0x03) << 4) | (src[1] >> 4)]);
+ erts_putc(to, to_arg, base64_chars[((src[1] & 0x0f) << 2) | (src[2] >> 6)]);
+ erts_putc(to, to_arg, base64_chars[src[2] & 0x3f]);
+ size -= 3;
+ src += 3;
+ }
+ if (size == 1) {
+ erts_putc(to, to_arg, base64_chars[src[0] >> 2]);
+ erts_putc(to, to_arg, base64_chars[(src[0] & 0x03) << 4]);
+ erts_print(to, to_arg, "==");
+ } else if (size == 2) {
+ erts_putc(to, to_arg, base64_chars[src[0] >> 2]);
+ erts_putc(to, to_arg, base64_chars[((src[0] & 0x03) << 4) | (src[1] >> 4)]);
+ erts_putc(to, to_arg, base64_chars[(src[1] & 0x0f) << 2]);
+ erts_putc(to, to_arg, '=');
+ }
+}