diff --git a/libr/core/disasm.c b/libr/core/disasm.c index 421229b0cb587..dc3e4799f7d55 100644 --- a/libr/core/disasm.c +++ b/libr/core/disasm.c @@ -3736,15 +3736,25 @@ static void ds_print_bytes(RDisasmState *ds) { // R2R db/cmd/cmd_disassembly nstr = r_print_hexpair (ds->print, str, n); if (r_str_ansi_len (nstr) > nb) { + if (nb % 2) { + nb--; + if (ds->show_bytes_align) { + r_cons_printf (" "); + } + } char *p = (char *)r_str_ansi_chrn (nstr, nb); - if (p) { + if (p) { off = true; + if (!core->print->bytespace) { + p--; + } p[0] = '.'; - if (core->print->bytespace) { - p[1] = '.'; + p[1] = '.'; + if (ds->show_bytes_align) { p[2] = '\0'; } else { - p[1] = '\0'; + p[2] = ' '; + p[3] = '\0'; } } } @@ -3779,7 +3789,7 @@ static void ds_print_bytes(RDisasmState *ds) { if (core->print->bytespace) { const int d = off? 2: 1; const char *air = off? " ":""; - r_cons_printf ("%s%s%s %s", (extra[0] && extra[1])? extra + d: extra, str, pad, air); + r_cons_printf ("%s%s%s %s", (extra[0] && extra[1])? extra + d: extra, str, pad, air); } else { r_cons_printf ("%s%s%s ", (extra[0])? extra + 1: extra, str, pad); } diff --git a/test/db/anal/bpf_64 b/test/db/anal/bpf_64 index 1fe8e8c6d7ce5..68f47865b7e8f 100644 --- a/test/db/anal/bpf_64 +++ b/test/db/anal/bpf_64 @@ -118,11 +118,11 @@ CMDS=pd 5 EXPECT=<>>[<<+<' - 0x000009b3 48b83e3e3e5b. movabs rax, 0x3c2b3c3c5b3e3e3e + 0x000009b3 48b83e3e3e.. movabs rax, 0x3c2b3c3c5b3e3e3e -[{"offset":2483,"text":" ; '>>>[<<+<'"},{"offset":2483,"text":" 0x000009b3 48b83e3e3e5b. movabs rax, 0x3c2b3c3c5b3e3e3e"}] +[{"offset":2483,"text":" ; '>>>[<<+<'"},{"offset":2483,"text":" 0x000009b3 48b83e3e3e.. movabs rax, 0x3c2b3c3c5b3e3e3e"}] EOF RUN @@ -2101,9 +2101,9 @@ EXPECT=<dH\x8b\x04%(" +| 0x00005af3 4c8d05660c.. lea r8, [0x00016760] +| 0x00005afa 488d0def0b.. lea rcx, [0x000166f0] +| 0x00005b01 488d3d68e5.. lea rdi, [main] ; 0x4070 ; "AWAVAUATU\x89\xfdSH\x89\xf3H\x83\xecXH\x8b>dH\x8b\x04%(" \ 0x00005b08 ff150ac30100 call qword [reloc.__libc_start_main] ; [0x21e18:8]=0 EOF RUN diff --git a/test/db/cmd/cmd_pd2 b/test/db/cmd/cmd_pd2 index ad77aa7758951..193238b646f3a 100644 --- a/test/db/cmd/cmd_pd2 +++ b/test/db/cmd/cmd_pd2 @@ -805,8 +805,8 @@ e scr.color=1 pd 1 EOF EXPECT=<dH\x8b\x04%(" +| 0x00005af3 4c8d05660c.. lea r8, [fcn.00016760] ; 0x16760 +| 0x00005afa 488d0def0b.. lea rcx, [fcn.000166f0] ; 0x166f0 +| 0x00005b01 488d3d68e5.. lea rdi, main ; 0x4070 ; "AWAVAUATU\x89\xfdSH\x89\xf3H\x83\xecXH\x8b>dH\x8b\x04%(" \ 0x00005b08 ff150ac30100 call qword [reloc.__libc_start_main] ; [0x21e18:8]=0 0x00005b0e f4 hlt 0x00005b0f 90 nop ; CALL XREF from entry.fini0 @ 0x5ba8(x) / 34: fcn.00005b0e (); -| 0x00005b10 488d3d51c701. lea rdi, loc._edata ; loc.__bss_start +| 0x00005b10 488d3d51c7.. lea rdi, loc._edata ; loc.__bss_start |  ; 0x22268 -| 0x00005b17 488d054ac701. lea rax, loc._edata ; loc.__bss_start +| 0x00005b17 488d054ac7.. lea rax, loc._edata ; loc.__bss_start |  ; 0x22268 | 0x00005b1e 4839f8 cmp rax, rdi EOF diff --git a/test/db/cmd/display_flag b/test/db/cmd/display_flag index a1c8e520cd129..3b5d1442766cf 100644 --- a/test/db/cmd/display_flag +++ b/test/db/cmd/display_flag @@ -30,7 +30,7 @@ pd 1 @ 9 EOF EXPECT=< | 0x00005800 4889442470 mov qword [var_70h], rax | 0x00005805 4889542468 mov qword [var_68h], rdx | 0x0000580a 488b442470 mov rax, qword [var_70h] -| 0x0000580f 48898424d800. mov qword [var_d8h], rax +| 0x0000580f 48898424d8.. mov qword [var_d8h], rax | 0x00005817 488b4c2468 mov rcx, qword [var_68h] -| 0x0000581c 48898c24e000. mov qword [var_e0h], rcx -| 0x00005824 488d9424d800. lea rdx, [var_d8h] -| 0x0000582c 488dbc24a800. lea rdi, [var_a8h] ; int64_t arg1 +| 0x0000581c 48898c24e0.. mov qword [var_e0h], rcx +| 0x00005824 488d9424d8.. lea rdx, [var_d8h] +| 0x0000582c 488dbc24a8.. lea rdi, [var_a8h] ; int64_t arg1 | 0x00005834 488b742478 mov rsi, qword [var_78h] ; int64_t arg2 | 0x00005839 41b802000000 mov r8d, 2 | 0x0000583f 4889542460 mov qword [var_60h], rdx @@ -299,29 +299,29 @@ EXPECT=< -| 0x0000587a 488b05f72a03. mov rax, qword [0x00038378] ; [0x38378:8]=0x38358 -| 0x00005881 488d8c248000. lea rcx, [numbers] -| 0x00005889 48898c243001. mov qword [var_130h], rcx -| 0x00005891 488b8c243001. mov rcx, qword [var_130h] -| 0x00005899 48898c242002. mov qword [var_220h], rcx +| 0x0000587a 488b05f72a.. mov rax, qword [0x00038378] ; [0x38378:8]=0x38358 +| 0x00005881 488d8c2480.. lea rcx, [numbers] +| 0x00005889 48898c2430.. mov qword [var_130h], rcx +| 0x00005891 488b8c2430.. mov rcx, qword [var_130h] +| 0x00005899 48898c2420.. mov qword [var_220h], rcx | 0x000058a1 4889cf mov rdi, rcx ; int64_t arg1 -| 0x000058a4 488d35250f00. lea rsi, [sym.core::array::__impl_core::fmt::Debug_for__T_____::fmt::h894a83bd2e78b654] ; 0x67d0 ; "H\x83\xecHH\x89|$8H\x89t$@\xb8\n" ; int64_t arg2 +| 0x000058a4 488d35250f.. lea rsi, [sym.core::array::__impl_core::fmt::Debug_for__T_____::fmt::h894a83bd2e78b654] ; 0x67d0 ; "H\x83\xecHH\x89|$8H\x89t$@\xb8\n" ; int64_t arg2 | 0x000058ab 4889442458 mov qword [var_58h], rax | 0x000058b0 e89b1a0000 call sym core::fmt::ArgumentV1::new::h4b3dd9450748c5fc ; dbg.new<[i32; 10]> | 0x000058b5 4889442450 mov qword [var_50h], rax | 0x000058ba 4889542448 mov qword [var_48h], rdx | 0x000058bf 488b442450 mov rax, qword [var_50h] -| 0x000058c4 488984242001. mov qword [var_120h], rax +| 0x000058c4 4889842420.. mov qword [var_120h], rax | 0x000058cc 488b4c2448 mov rcx, qword [var_48h] -| 0x000058d1 48898c242801. mov qword [var_128h], rcx -| 0x000058d9 488d94242001. lea rdx, [var_120h] -| 0x000058e1 488dbc24f000. lea rdi, [var_f0h] ; int64_t arg1 +| 0x000058d1 48898c2428.. mov qword [var_128h], rcx +| 0x000058d9 488d942420.. lea rdx, [var_120h] +| 0x000058e1 488dbc24f0.. lea rdi, [var_f0h] ; int64_t arg1 | 0x000058e9 488b742458 mov rsi, qword [var_58h] ; int64_t arg2 | 0x000058ee 41b802000000 mov r8d, 2 | 0x000058f4 4889542440 mov qword [var_40h], rdx @@ -329,16 +329,16 @@ EXPECT=<(&mut [i32] values); -| 0x00005277 4889bc249000. mov qword [values], rdi ; arg1 -| 0x0000527f 4889b4249800. mov qword [var_98h], rsi ; arg2 +| 0x00005270 4881ecb800.. sub rsp, 0xb8 ; void bubble_sort(&mut [i32] values); +| 0x00005277 4889bc2490.. mov qword [values], rdi ; arg1 +| 0x0000527f 4889b42498.. mov qword [var_98h], rsi ; arg2 | 0x00005287 48897c2448 mov qword [var_48h], rdi ; arg1 | 0x0000528c 4889742440 mov qword [var_40h], rsi ; arg2 | 0x00005291 e8ea090000 call sym core::slice::_::len::hbaf7153778228b73 ; dbg.len @@ -390,12 +390,12 @@ EXPECT=< 0x000052af c644245f00 mov byte [swapped], 0 | 0x000052b4 488b442450 mov rax, qword [n] -| 0x000052b9 48c744246001. mov qword [var_60h], 1 +| 0x000052b9 48c7442460.. mov qword [var_60h], 1 | 0x000052c2 4889442468 mov qword [var_68h], rax | 0x000052c7 488b7c2460 mov rdi, qword [var_60h] ; int64_t arg1 | 0x000052cc 488b742468 mov rsi, qword [var_68h] ; int64_t arg2 @@ -409,9 +409,9 @@ EXPECT=<>::next::h707e8283b20ce50a ; dbg.next -| 0x000052fe 488994248800. mov qword [var_88h], rdx -| 0x00005306 488984248000. mov qword [var_80h], rax -| 0x0000530e 488b84248000. mov rax, qword [var_80h] +| 0x000052fe 4889942488.. mov qword [var_88h], rdx +| 0x00005306 4889842480.. mov qword [var_80h], rax +| 0x0000530e 488b842480.. mov rax, qword [var_80h] | 0x00005316 4885c0 test rax, rax | ,=< 0x00005319 7404 je 0x531f | ,==< 0x0000531b eb00 jmp 0x531d @@ -486,14 +486,14 @@ EXPECT=< 0x10000108a 488d357f3a00. lea rsi, [0x100004b10] ; section.4.__TEXT.__cstring + `-> 0x10000108a 488d357f3a.. lea rsi, [0x100004b10] ; section.4.__TEXT.__cstring ,=< 0x100001083 7f05 jg jeje.lolo - `-> 0x10000108a 488d357f3a00. lea rsi, section.4.__TEXT.__cstring ; 0x100004b10 + `-> 0x10000108a 488d357f3a.. lea rsi, section.4.__TEXT.__cstring ; 0x100004b10 EOF RUN diff --git a/test/db/cmd/projects b/test/db/cmd/projects index f1a5f07645f76..3661e8946ef46 100644 --- a/test/db/cmd/projects +++ b/test/db/cmd/projects @@ -71,7 +71,7 @@ EXPECT=< 0x00010b6a d08650 movl (r6)+, r0 | :| 0x00010b6d fb0060 calls $0x0, (r0) diff --git a/test/db/formats/mangling/bin b/test/db/formats/mangling/bin index 3ba91f859a6db..c0228d412c2c4 100644 --- a/test/db/formats/mangling/bin +++ b/test/db/formats/mangling/bin @@ -80,7 +80,7 @@ NAME=C++ demangle relocs FILE=bins/elf/libstdc++.so.6 CMDS=pd 1 @0x00091004 EXPECT=<