Fix glitch + tests asm.bytes.{align,space} ##disasm
This commit is contained in:
parent
2446852fff
commit
3bc3d3daf7
|
@ -3523,6 +3523,7 @@ static void ds_print_bytes(RDisasmState *ds) {
|
|||
if (ds->show_flag_in_bytes) {
|
||||
flagstr = r_flag_get_liststr (core->flags, ds->at);
|
||||
}
|
||||
bool off = false;
|
||||
int nb = R_MIN (100, ds->nb);
|
||||
if (flagstr) {
|
||||
if (nb > 3 && strlen (flagstr) >= nb) {
|
||||
|
@ -3582,20 +3583,27 @@ static void ds_print_bytes(RDisasmState *ds) {
|
|||
}
|
||||
}
|
||||
#endif
|
||||
if (r_str_ansi_len (str) > nb) {
|
||||
char *p = (char *)r_str_ansi_chrn (str, nb);
|
||||
if (p) {
|
||||
p[0] = '.';
|
||||
p[1] = '\0';
|
||||
}
|
||||
}
|
||||
ds->print->cur_enabled = (ds->cursor != -1);
|
||||
if (ds->show_bytes_opcolor) {
|
||||
ds->print->nbcolor = (ds->analop.nopcode > 1)? ds->analop.nopcode: 1;
|
||||
} else {
|
||||
ds->print->nbcolor = 0;
|
||||
}
|
||||
// R2R db/cmd/cmd_disassembly
|
||||
nstr = r_print_hexpair (ds->print, str, n);
|
||||
if (r_str_ansi_len (nstr) > nb) {
|
||||
char *p = (char *)r_str_ansi_chrn (nstr, nb);
|
||||
if (p) {
|
||||
off = true;
|
||||
p[0] = '.';
|
||||
if (core->print->bytespace) {
|
||||
p[1] = '.';
|
||||
p[2] = '\0';
|
||||
} else {
|
||||
p[1] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
ds->print->nbcolor = 0;
|
||||
if (ds->print->bytespace) {
|
||||
k = (nb + (nb / 2)) - r_str_ansi_len (nstr) + 2;
|
||||
|
@ -3624,7 +3632,13 @@ static void ds_print_bytes(RDisasmState *ds) {
|
|||
}
|
||||
}
|
||||
if (ds->show_bytes_align) {
|
||||
r_cons_printf ("%s%s%s ", (*extra)? extra + 1: extra, str, pad);
|
||||
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);
|
||||
} else {
|
||||
r_cons_printf ("%s%s%s ", (extra[0])? extra + 1: extra, str, pad);
|
||||
}
|
||||
} else {
|
||||
r_cons_printf ("%s%s %s", pad, str, extra);
|
||||
}
|
||||
|
|
|
@ -107,6 +107,7 @@ if not capstone_dep.found() or not get_option('use_sys_capstone')
|
|||
'arch/XCore/XCoreInstPrinter.c',
|
||||
'arch/XCore/XCoreMapping.c',
|
||||
'arch/XCore/XCoreModule.c',
|
||||
'Mapping.c',
|
||||
'cs.c',
|
||||
'MCInst.c',
|
||||
'MCInstrDesc.c',
|
||||
|
|
|
@ -58,8 +58,8 @@ ahi 10
|
|||
pd 1
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
[32m[7m0x00000000[0m [33m48[36m81[36mec[33m48[36m06[32m00[36m.[0m [33msub[36m rsp[0m,[36m[36m [33m0x648[0m[0m[0m
|
||||
[32m[7m0x00000000[0m [33m48[36m81[36mec[33m48[36m06[32m00[36m.[0m [33msub[36m rsp[0m,[36m[36m [33m1608[0m[0m[0m
|
||||
[32m[7m0x00000000[0m [33m48[36m81[36mec[33m48[36m06[32m00[32m. [33msub[36m rsp[0m,[36m[36m [33m0x648[0m[0m[0m
|
||||
[32m[7m0x00000000[0m [33m48[36m81[36mec[33m48[36m06[32m00[32m. [33msub[36m rsp[0m,[36m[36m [33m1608[0m[0m[0m
|
||||
EOF
|
||||
RUN
|
||||
|
||||
|
|
|
@ -258,3 +258,72 @@ EXPECT=<<EOF
|
|||
3
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=byte spacing and align in disasm
|
||||
FILE=-
|
||||
CMDS=<<EOF
|
||||
e asm.arch=x86
|
||||
e asm.bits=32
|
||||
e scr.utf8=0
|
||||
e asm.lines.jmp=1
|
||||
e asm.comments=0
|
||||
wx 803d1ca0040833740ceb1c83c004a318a0088ffd2a118a00408b1085d275eb
|
||||
e asm.bytes.space=0
|
||||
e asm.bytes.align=0
|
||||
pd 10
|
||||
?e --
|
||||
e asm.bytes.align = true
|
||||
pd 10
|
||||
?e --
|
||||
e asm.bytes.space = true
|
||||
pd 10
|
||||
?e --
|
||||
e asm.bytes.align = true
|
||||
pd 10
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
0x00000000 803d1ca00408. cmp byte [0x804a01c], 0x33
|
||||
,=< 0x00000007 740c je 0x15
|
||||
,==< 0x00000009 eb1c jmp 0x27
|
||||
|| 0x0000000b 83c004 add eax, 4
|
||||
|| 0x0000000e a318a0088f mov dword [0x8f08a018], eax
|
||||
|| 0x00000013 fd std
|
||||
|| 0x00000014 2a11 sub dl, byte [ecx]
|
||||
| 0x00000016 8a00 mov al, byte [eax]
|
||||
| 0x00000018 40 inc eax
|
||||
| 0x00000019 8b10 mov edx, dword [eax]
|
||||
--
|
||||
0x00000000 803d1ca00408. cmp byte [0x804a01c], 0x33
|
||||
,=< 0x00000007 740c je 0x15
|
||||
,==< 0x00000009 eb1c jmp 0x27
|
||||
|| 0x0000000b 83c004 add eax, 4
|
||||
|| 0x0000000e a318a0088f mov dword [0x8f08a018], eax
|
||||
|| 0x00000013 fd std
|
||||
|| 0x00000014 2a11 sub dl, byte [ecx]
|
||||
| 0x00000016 8a00 mov al, byte [eax]
|
||||
| 0x00000018 40 inc eax
|
||||
| 0x00000019 8b10 mov edx, dword [eax]
|
||||
--
|
||||
0x00000000 80 3d 1c a0 .. cmp byte [0x804a01c], 0x33
|
||||
,=< 0x00000007 74 0c je 0x15
|
||||
,==< 0x00000009 eb 1c jmp 0x27
|
||||
|| 0x0000000b 83 c0 04 add eax, 4
|
||||
|| 0x0000000e a3 18 a0 08 .. mov dword [0x8f08a018], eax
|
||||
|| 0x00000013 fd std
|
||||
|| 0x00000014 2a 11 sub dl, byte [ecx]
|
||||
| 0x00000016 8a 00 mov al, byte [eax]
|
||||
| 0x00000018 40 inc eax
|
||||
| 0x00000019 8b 10 mov edx, dword [eax]
|
||||
--
|
||||
0x00000000 80 3d 1c a0 .. cmp byte [0x804a01c], 0x33
|
||||
,=< 0x00000007 74 0c je 0x15
|
||||
,==< 0x00000009 eb 1c jmp 0x27
|
||||
|| 0x0000000b 83 c0 04 add eax, 4
|
||||
|| 0x0000000e a3 18 a0 08 .. mov dword [0x8f08a018], eax
|
||||
|| 0x00000013 fd std
|
||||
|| 0x00000014 2a 11 sub dl, byte [ecx]
|
||||
| 0x00000016 8a 00 mov al, byte [eax]
|
||||
| 0x00000018 40 inc eax
|
||||
| 0x00000019 8b 10 mov edx, dword [eax]
|
||||
EOF
|
||||
RUN
|
||||
|
|
|
@ -806,7 +806,7 @@ pd 1
|
|||
EOF
|
||||
EXPECT=<<EOF
|
||||
0x00005e6e 488d3d339b01. lea rdi, section..fini_array ; 0x1f9a8
|
||||
[32m0x00005e6e[0m [33m48[36m8d[33m3d[33m33[36m9b[36m01[36m.[0m [36mlea[36m rdi[0m,[36m[36m section..fini_array[0m[0m[31m [31m; 0x1f9a8[0m
|
||||
[32m0x00005e6e[0m [33m48[36m8d[33m3d[33m33[36m9b[36m01[32m. [36mlea[36m rdi[0m,[36m[36m section..fini_array[0m[0m[31m [31m; 0x1f9a8[0m
|
||||
EOF
|
||||
RUN
|
||||
|
||||
|
|
|
@ -63,9 +63,9 @@ EXPECT=<<EOF
|
|||
[36m|[0m [32mentry0[0m+0x9 [33m48[36m83[36me4[36mf0[0m [33mand[36m rsp[0m,[36m[36m [33m0xfffffffffffffff0[0m[0m[0m
|
||||
[36m|[0m [32mentry0[0m+0xd [33m50[0m [35mpush[36m rax[0m[0m[0m
|
||||
[36m|[0m [32mentry0[0m+0xe [33m54[0m [35mpush[36m rsp[0m[0m[0m
|
||||
[36m|[0m [32mentry0[0m+0xf [33m4c[36m8b[36m05[36me6[36m93[36m01[36m.[0m [36mmov[36m r8[0m,[36m qword[36m [0m[[36msection..got[0m][36m[0m[0m[31m [31m; [[31m0x1f220[31m:8]=0x16ee0[0m
|
||||
[36m|[0m [32mentry0[0m+0x16 [33m48[36m8b[36m0d[36me7[36m93[36m01[36m.[0m [36mmov[36m rcx[0m,[36m qword[36m [0m[[33m0x0001f228[0m][36m[0m[0m[31m [31m; [[31m0x1f228[31m:8]=0x16e60[0m
|
||||
[36m|[0m [32mentry0[0m+0x1d [33m48[36m8b[33m3d[36me8[36m93[36m01[36m.[0m [36mmov[36m rdi[0m,[36m qword[36m [0m[[33m0x0001f230[0m][36m[0m[0m[31m [31m; [[31m0x1f230[31m:8]=0x3bd0 main[0m
|
||||
[36m|[0m [32mentry0[0m+0xf [33m4c[36m8b[36m05[36me6[36m93[36m01[32m. [36mmov[36m r8[0m,[36m qword[36m [0m[[36msection..got[0m][36m[0m[0m[31m [31m; [[31m0x1f220[31m:8]=0x16ee0[0m
|
||||
[36m|[0m [32mentry0[0m+0x16 [33m48[36m8b[36m0d[36me7[36m93[36m01[32m. [36mmov[36m rcx[0m,[36m qword[36m [0m[[33m0x0001f228[0m][36m[0m[0m[31m [31m; [[31m0x1f228[31m:8]=0x16e60[0m
|
||||
[36m|[0m [32mentry0[0m+0x1d [33m48[36m8b[33m3d[36me8[36m93[36m01[32m. [36mmov[36m rdi[0m,[36m qword[36m [0m[[33m0x0001f230[0m][36m[0m[0m[31m [31m; [[31m0x1f230[31m:8]=0x3bd0 main[0m
|
||||
EOF
|
||||
RUN
|
||||
|
||||
|
|
|
@ -397,17 +397,17 @@ EXPECT=<<EOF
|
|||
[38;2;58;150;221m|[0m [38;2;19;161;14m0x00005aed[0m [38;2;193;156;0m48[38;2;58;150;221m83[38;2;58;150;221me4[38;2;58;150;221mf0[0m [38;2;193;156;0mand[38;2;58;150;221m rsp[0m,[38;2;58;150;221m[38;2;58;150;221m [38;2;193;156;0m0xfffffffffffffff0[0m[0m[0m
|
||||
[38;2;58;150;221m|[0m [38;2;19;161;14m0x00005af1[0m [38;2;193;156;0m50[0m [38;2;136;23;152mpush[38;2;58;150;221m rax[0m[0m[0m
|
||||
[38;2;58;150;221m|[0m [38;2;19;161;14m0x00005af2[0m [38;2;193;156;0m54[0m [38;2;136;23;152mpush[38;2;58;150;221m rsp[0m[0m[0m
|
||||
[38;2;58;150;221m|[0m [38;2;19;161;14m0x00005af3[0m [38;2;193;156;0m4c[38;2;58;150;221m8d[38;2;58;150;221m05[38;2;193;156;0m66[38;2;58;150;221m0c[38;2;58;150;221m01[38;2;58;150;221m.[0m [38;2;58;150;221mlea[38;2;58;150;221m r8[0m,[38;2;58;150;221m[38;2;58;150;221m [0m[[38;2;58;150;221mfcn.00016760[0m][38;2;58;150;221m[0m[0m[38;2;197;15;31m [38;2;197;15;31m; 0x16760[0m
|
||||
[38;2;58;150;221m|[0m [38;2;19;161;14m0x00005afa[0m [38;2;193;156;0m48[38;2;58;150;221m8d[38;2;58;150;221m0d[38;2;58;150;221mef[38;2;58;150;221m0b[38;2;58;150;221m01[38;2;58;150;221m.[0m [38;2;58;150;221mlea[38;2;58;150;221m rcx[0m,[38;2;58;150;221m[38;2;58;150;221m [0m[[38;2;58;150;221mfcn.000166f0[0m][38;2;58;150;221m[0m[0m[38;2;197;15;31m [38;2;197;15;31m; 0x166f0[0m
|
||||
[38;2;58;150;221m|[0m [38;2;19;161;14m0x00005b01[0m [38;2;193;156;0m48[38;2;58;150;221m8d[38;2;193;156;0m3d[38;2;193;156;0m68[38;2;58;150;221me5[38;2;197;15;31mff[38;2;58;150;221m.[0m [38;2;58;150;221mlea[38;2;58;150;221m rdi[0m,[38;2;58;150;221m[38;2;58;150;221m main[0m[0m[38;2;197;15;31m [38;2;197;15;31m; 0x4070[38;2;197;15;31m [38;2;197;15;31m; "AWAVAUATU\x89\xfdSH\x89\xf3H\x83\xecXH\x8b>dH\x8b\x04%("[0m
|
||||
[38;2;58;150;221m|[0m [38;2;19;161;14m0x00005af3[0m [38;2;193;156;0m4c[38;2;58;150;221m8d[38;2;58;150;221m05[38;2;193;156;0m66[38;2;58;150;221m0c[38;2;58;150;221m01[38;2;19;161;14m. [38;2;58;150;221mlea[38;2;58;150;221m r8[0m,[38;2;58;150;221m[38;2;58;150;221m [0m[[38;2;58;150;221mfcn.00016760[0m][38;2;58;150;221m[0m[0m[38;2;197;15;31m [38;2;197;15;31m; 0x16760[0m
|
||||
[38;2;58;150;221m|[0m [38;2;19;161;14m0x00005afa[0m [38;2;193;156;0m48[38;2;58;150;221m8d[38;2;58;150;221m0d[38;2;58;150;221mef[38;2;58;150;221m0b[38;2;58;150;221m01[38;2;19;161;14m. [38;2;58;150;221mlea[38;2;58;150;221m rcx[0m,[38;2;58;150;221m[38;2;58;150;221m [0m[[38;2;58;150;221mfcn.000166f0[0m][38;2;58;150;221m[0m[0m[38;2;197;15;31m [38;2;197;15;31m; 0x166f0[0m
|
||||
[38;2;58;150;221m|[0m [38;2;19;161;14m0x00005b01[0m [38;2;193;156;0m48[38;2;58;150;221m8d[38;2;193;156;0m3d[38;2;193;156;0m68[38;2;58;150;221me5[38;2;197;15;31mff[38;2;197;15;31m. [38;2;58;150;221mlea[38;2;58;150;221m rdi[0m,[38;2;58;150;221m[38;2;58;150;221m main[0m[0m[38;2;197;15;31m [38;2;197;15;31m; 0x4070[38;2;197;15;31m [38;2;197;15;31m; "AWAVAUATU\x89\xfdSH\x89\xf3H\x83\xecXH\x8b>dH\x8b\x04%("[0m
|
||||
[38;2;58;150;221m\[0m [38;2;19;161;14m0x00005b08[0m [38;2;197;15;31mff[38;2;58;150;221m15[38;2;58;150;221m0a[38;2;58;150;221mc3[38;2;58;150;221m01[38;2;19;161;14m00[0m [38;2;19;161;14mcall qword[38;2;58;150;221m [0m[[38;2;58;150;221mreloc.__libc_start_main[0m][38;2;58;150;221m[0m[0m[38;2;197;15;31m [38;2;197;15;31m; [0x21e18:8]=0[0m
|
||||
[38;2;19;161;14m0x00005b0e[0m [38;2;58;150;221mf4[0m [1;38;2;197;15;31mhlt[0m[0m[0m
|
||||
[38;2;19;161;14m0x00005b0f[0m [38;2;58;150;221m90[0m [38;2;0;55;218mnop[0m[0m[0m
|
||||
[38;2;197;15;31m[38;2;197;15;31m; CALL XREF from entry.fini0 @ [38;2;197;15;31m0x5ba8(x)[38;2;197;15;31m[0m
|
||||
[38;2;58;150;221m/[0m 34: [38;2;197;15;31mfcn.00005b0e[0m ();
|
||||
[38;2;58;150;221m|[0m [38;2;19;161;14m0x00005b10[0m [38;2;193;156;0m48[38;2;58;150;221m8d[38;2;193;156;0m3d[38;2;193;156;0m51[38;2;58;150;221mc7[38;2;58;150;221m01[38;2;58;150;221m.[0m [38;2;58;150;221mlea[38;2;58;150;221m rdi[0m,[38;2;58;150;221m[38;2;58;150;221m loc._edata[0m[0m[38;2;197;15;31m [38;2;197;15;31m; loc.__bss_start
|
||||
[38;2;58;150;221m|[0m [38;2;19;161;14m0x00005b10[0m [38;2;193;156;0m48[38;2;58;150;221m8d[38;2;193;156;0m3d[38;2;193;156;0m51[38;2;58;150;221mc7[38;2;58;150;221m01[38;2;19;161;14m. [38;2;58;150;221mlea[38;2;58;150;221m rdi[0m,[38;2;58;150;221m[38;2;58;150;221m loc._edata[0m[0m[38;2;197;15;31m [38;2;197;15;31m; loc.__bss_start
|
||||
[38;2;58;150;221m|[0m [38;2;197;15;31m [38;2;197;15;31m; 0x22268[0m
|
||||
[38;2;58;150;221m|[0m [38;2;19;161;14m0x00005b17[0m [38;2;193;156;0m48[38;2;58;150;221m8d[38;2;58;150;221m05[38;2;193;156;0m4a[38;2;58;150;221mc7[38;2;58;150;221m01[38;2;58;150;221m.[0m [38;2;58;150;221mlea[38;2;58;150;221m rax[0m,[38;2;58;150;221m[38;2;58;150;221m loc._edata[0m[0m[38;2;197;15;31m [38;2;197;15;31m; loc.__bss_start
|
||||
[38;2;58;150;221m|[0m [38;2;19;161;14m0x00005b17[0m [38;2;193;156;0m48[38;2;58;150;221m8d[38;2;58;150;221m05[38;2;193;156;0m4a[38;2;58;150;221mc7[38;2;58;150;221m01[38;2;19;161;14m. [38;2;58;150;221mlea[38;2;58;150;221m rax[0m,[38;2;58;150;221m[38;2;58;150;221m loc._edata[0m[0m[38;2;197;15;31m [38;2;197;15;31m; loc.__bss_start
|
||||
[38;2;58;150;221m|[0m [38;2;197;15;31m [38;2;197;15;31m; 0x22268[0m
|
||||
[38;2;58;150;221m|[0m [38;2;19;161;14m0x00005b1e[0m [38;2;193;156;0m48[38;2;193;156;0m39[38;2;58;150;221mf8[0m [38;2;193;156;0mcmp[38;2;58;150;221m rax[0m,[38;2;58;150;221m rdi[0m[0m[0m
|
||||
EOF
|
||||
|
|
Loading…
Reference in New Issue