radare2/test/new/db/cmd/cmd_print
Riccardo Schirone c1c54be39e Change macro syntax to use ; instead of ,
This change is to ease the switch to the new parser and make the syntax
more consistent and easy. As things were before this patch, ',' could be
part of an argument of a command, but at the same time it was used as a
separator when defining a new macro. This difference in how `,` is
interpreter, makes parsing commands harder, as grep specifiers,
arguments, etc. should be parsed differently based on whether they are
inside a macro body or not.

By switching to using `;` as separator in the macro body, arguments,
grep specifiers, etc. can be parsed as they would be outside of a macro
body, making the new parser more consistent and easier.
2020-03-11 00:11:01 +01:00

34 KiB

NAME=p2 hello-linux-x86_64
FILE=../bins/elf/analysis/hello-linux-x86_64
EXPECT=<<EOF
----..==----##..
--==####..####..
==..##..------==
--==####..####--
==..==##--##==##
..----####--====
==..==..########
##..##==--==##--
EOF
CMDS=p2 16
RUN
 
NAME=p= 0xff 0x00
FILE=-
BROKEN=1
EXPECT=<<EOF
___________________________________________________
00 00ff | __________________________________________________|
01 0000 ||
EOF
CMDS=<<EOF
b 2
wx 0xff
p= 2@0
EOF
RUN
 
NAME=p=b 0xff 0x00
FILE=-
EXPECT=<<EOF
0x00000000 000 00ff |###################################################
0x00000001 001 0000 |#
EOF
CMDS=<<EOF
b 2
wx 0xff
e zoom.in=raw
p=b 2 2@0
EOF
RUN
 
NAME=p= - crash
FILE=-
EXPECT=<<EOF
0x00000000 000 0000 |#
EOF
CMDS=<<EOF
e zoom.in = block
p=p" 1 " 1 EN
EOF
RUN
 
NAME=p=d
FILE=../bins/elf/arm1.bin
EXPECT=<<EOF
min: 0 0x0
max: 127 0x7f
unique (count): 6 0x6
range (max-min): 127 0x7f
size (of block): 10 0xa
EOF
ARGS=-n
CMDS=p=d 10 @ 0
RUN
 
NAME=p=e 5
FILE=../bins/elf/arm1.bin
EXPECT=<<EOF
0x00000000 000 009f |########
0x0001bec1 001 00c3 |#
0x00037d82 002 00c3 |#
0x00053c43 003 00c3 |#######################################
0x0006fb04 004 0051 |################
EOF
CMDS=p=e 5@0
RUN
 
NAME=p=e 5 0x100
FILE=../bins/elf/arm1.bin
EXPECT=<<EOF
0x00000000 000 007f |#########################
0x00000033 001 006b |###
0x00000066 002 007a |#########################
0x00000099 003 006a |#####################
0x000000cc 004 005f |###################
EOF
ARGS=-n
CMDS=<<EOF
e zoom.in = block
p=e 5 0x100
EOF
RUN
 
NAME=p=e 5 0x100 1
FILE=../bins/elf/arm1.bin
EXPECT=<<EOF
0x00000000 000 006b |###
0x00000033 001 007a |#########################
0x00000066 002 006a |#####################
0x00000099 003 005f |###################
0x000000cc 004 0059 |##################
EOF
ARGS=-n
CMDS=<<EOF
e zoom.in = block
p=e 5 0x100 1
EOF
RUN
 
NAME=p=p 5
FILE=../bins/elf/arm1.bin
EXPECT=<<EOF
0x00000000 000 0032 |##########
0x0001bec1 001 0031 |#
0x00037d82 002 0035 |###
0x00053c43 003 0040 |###########
0x0006fb04 004 0076 |########################
EOF
ARGS=-n
CMDS=p=p 5@0
RUN
 
NAME=p=p 5 0x100
FILE=../bins/elf/arm1.bin
EXPECT=<<EOF
0x00000000 000 0032 |#########
0x00000033 001 0019 |#
0x00000066 002 001e |#
0x00000099 003 001e |##
0x000000cc 004 0028 |########
EOF
ARGS=-n
CMDS=<<EOF
e zoom.in = block
p=p 5 0x100
EOF
RUN
 
NAME=p=p 5 0x100 1
FILE=../bins/elf/arm1.bin
EXPECT=<<EOF
0x00000000 000 0019 |#
0x00000033 001 001e |#
0x00000066 002 001e |##
0x00000099 003 0028 |#######
0x000000cc 004 001e |######
EOF
ARGS=-n
CMDS=<<EOF
e zoom.in = block
p=p 5 0x100 1
EOF
RUN
 
NAME=p8 10
FILE=malloc://1024
EXPECT=<<EOF
90909090909090909090
EOF
CMDS=wx 90909090909090909090 ; p8 10
RUN
 
NAME=p8 -10
FILE=malloc://1024
EXPECT=<<EOF
90909090909090909090
EOF
CMDS=wx 90909090909090909090 ; s 10 ; p8 -10
RUN
 
NAME=pi 3
FILE=malloc://512
EXPECT=<<EOF
mov eax, 1
cmp rdx, rcx
jg 0xa
EOF
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
wx b8010000004839ca7f
pi 3
EOF
RUN
 
NAME=pij 3
FILE=malloc://512
EXPECT=<<EOF
[{"offset":0,"val":1,"esil":"1,rax,=","refptr":false,"fcn_addr":0,"fcn_last":0,"size":5,"opcode":"mov eax, 1","disasm":"mov eax, 1","bytes":"b801000000","family":"cpu","type":"mov","reloc":false,"type_num":9,"type2_num":0},{"offset":5,"esil":"rcx,rdx,==,$z,zf,:=,64,$b,cf,:=,$p,pf,:=,63,$s,sf,:=,63,$o,of,:=","refptr":false,"fcn_addr":0,"fcn_last":0,"size":3,"opcode":"cmp rdx, rcx","disasm":"cmp rdx, rcx","bytes":"4839ca","family":"cpu","type":"cmp","reloc":false,"type_num":15,"type2_num":0},{"offset":8,"esil":"sf,of,!,^,zf,!,&,?{,10,rip,=,}","refptr":false,"fcn_addr":0,"fcn_last":0,"size":2,"opcode":"jg 0xa","disasm":"jg 0xa","bytes":"7f00","family":"cpu","type":"cjmp","reloc":false,"type_num":2147483649,"type2_num":0,"jump":10,"fail":10}]
EOF
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
wx b8010000004839ca7f
pij 3
EOF
RUN
 
NAME=pi 6
FILE=malloc://512
EXPECT=<<EOF
mov eax, 1
cmp rdx, rcx
jg 0xa
mov eax, 1
cmp rdx, rcx
jg 0x14
EOF
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
wx b8010000004839ca7f00b8010000004839ca7f00
pi 6
EOF
RUN
 
NAME=pi -5 @ 0x0040050f
FILE=../bins/elf/analysis/main
EXPECT=<<EOF
pop rbp
jmp sym.register_tm_clones
push rbp
mov rbp, rsp
mov edi, str.Hello_World
EOF
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
pi -5 @ 0x0040050f
EOF
RUN
 
NAME=pi -5 @ 0x0040050f (anal)
FILE=../bins/elf/analysis/main
EXPECT=<<EOF
pop rbp
jmp sym.register_tm_clones
push rbp
mov rbp, rsp
mov edi, str.Hello_World
EOF
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
aaa
pi -5 @ 0x0040050f
EOF
RUN
 
NAME=pij -5 @ 0x0040050f
FILE=../bins/elf/analysis/main
EXPECT=<<EOF
[{"offset":4195590,"esil":"rbp,8,rsp,-,=[8],8,rsp,-=","refptr":false,"fcn_addr":0,"fcn_last":0,"size":1,"opcode":"push rbp","disasm":"push rbp","bytes":"55","family":"cpu","type":"rpush","reloc":false,"type_num":268435468,"type2_num":0,"flags":["main","sym.main"]},{"offset":4195591,"esil":"rsp,rbp,=","refptr":false,"fcn_addr":0,"fcn_last":0,"size":3,"opcode":"mov rbp, rsp","disasm":"mov rbp, rsp","bytes":"4889e5","family":"cpu","type":"mov","reloc":false,"type_num":9,"type2_num":0},{"offset":4195594,"ptr":4195780,"val":4195780,"esil":"4195780,rdi,=","refptr":false,"fcn_addr":0,"fcn_last":0,"size":5,"opcode":"mov edi, 0x4005c4","disasm":"mov edi, str.Hello_World","bytes":"bfc4054000","family":"cpu","type":"mov","reloc":false,"type_num":9,"type2_num":0}]
EOF
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
pij -3 @ 0x0040050f
EOF
RUN
 
NAME=pi -5
FILE=../bins/elf/analysis/main
EXPECT=<<EOF
pop rbp
jmp sym.register_tm_clones
push rbp
mov rbp, rsp
mov edi, str.Hello_World
EOF
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
s 0x0040050f
pi -5
EOF
RUN
 
NAME=pif bsz
FILE=malloc://1024
EXPECT=<<EOF
pop rbx
pop r12
pop r13
pop r14
pop r15
pop rbp
ret
EOF
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
wx 5b415c415d415e415f5dc3
af
b 2
pif
EOF
RUN
 
NAME=pi~?
FILE=malloc://1024
EXPECT=<<EOF
200
200
200
EOF
CMDS=<<EOF
pi 200~?
pi 200~?
pd 200~?
EOF
RUN
 
NAME=tmpbits
FILE=-
EXPECT=<<EOF
00
64
EOF
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
p8 1 @b:32
e asm.bits
EOF
RUN
 
NAME=tmpbits
FILE=-
EXPECT=<<EOF
00
32
EOF
CMDS=<<EOF
e asm.arch=x86
e asm.bits=32
p8 1 @b:64
e asm.bits
EOF
RUN
 
NAME=pi 3
FILE=malloc://512
EXPECT=<<EOF
mov eax, 1
cmp rdx, rcx
jg 0xa
EOF
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
wx b8010000004839ca7f
pi 3
EOF
RUN
 
NAME=pij 3 (2)
FILE=malloc://512
EXPECT=<<EOF
[{"offset":0,"val":1,"esil":"1,rax,=","refptr":false,"fcn_addr":0,"fcn_last":0,"size":5,"opcode":"mov eax, 1","disasm":"mov eax, 1","bytes":"b801000000","family":"cpu","type":"mov","reloc":false,"type_num":9,"type2_num":0},{"offset":5,"esil":"rcx,rdx,==,$z,zf,:=,64,$b,cf,:=,$p,pf,:=,63,$s,sf,:=,63,$o,of,:=","refptr":false,"fcn_addr":0,"fcn_last":0,"size":3,"opcode":"cmp rdx, rcx","disasm":"cmp rdx, rcx","bytes":"4839ca","family":"cpu","type":"cmp","reloc":false,"type_num":15,"type2_num":0},{"offset":8,"esil":"sf,of,!,^,zf,!,&,?{,10,rip,=,}","refptr":false,"fcn_addr":0,"fcn_last":0,"size":2,"opcode":"jg 0xa","disasm":"jg 0xa","bytes":"7f00","family":"cpu","type":"cjmp","reloc":false,"type_num":2147483649,"type2_num":0,"jump":10,"fail":10}]
EOF
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
wx b8010000004839ca7f
pij 3
EOF
RUN
 
NAME=pi 6
FILE=malloc://512
EXPECT=<<EOF
mov eax, 1
cmp rdx, rcx
jg 0xa
mov eax, 1
cmp rdx, rcx
jg 0x14
EOF
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
wx b8010000004839ca7f00b8010000004839ca7f00
pi 6
EOF
RUN
 
NAME=pi -3 @ 3
FILE=malloc://512
EXPECT=<<EOF
add byte [rax], al
cmp rdx, rcx
jg 0xa
EOF
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
wx b8010000004839ca7f00
pi -3 @ 10
EOF
RUN
 
NAME=pij -3 @ 3
FILE=malloc://512
EXPECT=<<EOF
[
{
"offset": 3,
"esil": "al,rax,+=[1],7,$o,of,:=,7,$s,sf,:=,$z,zf,:=,7,$c,cf,:=,$p,pf,:=",
"refptr": true,
"fcn_addr": 0,
"fcn_last": 0,
"size": 2,
"opcode": "add byte [rax], al",
"disasm": "add byte [rax], al",
"bytes": "0000",
"family": "cpu",
"type": "add",
"reloc": false,
"type_num": 17,
"type2_num": 0
},
{
"offset": 5,
"esil": "rcx,rdx,==,$z,zf,:=,64,$b,cf,:=,$p,pf,:=,63,$s,sf,:=,63,$o,of,:=",
"refptr": false,
"fcn_addr": 0,
"fcn_last": 0,
"size": 3,
"opcode": "cmp rdx, rcx",
"disasm": "cmp rdx, rcx",
"bytes": "4839ca",
"family": "cpu",
"type": "cmp",
"reloc": false,
"type_num": 15,
"type2_num": 0
},
{
"offset": 8,
"esil": "sf,of,!,^,zf,!,&,?{,10,rip,=,}",
"refptr": false,
"fcn_addr": 0,
"fcn_last": 0,
"size": 2,
"opcode": "jg 0xa",
"disasm": "jg 0xa",
"bytes": "7f00",
"family": "cpu",
"type": "cjmp",
"reloc": false,
"type_num": 2147483649,
"type2_num": 0,
"jump": 10,
"fail": 10
}
]
EOF
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
wx b8010000004839ca7f00
pij -3 @ 10~{}
EOF
RUN
 
NAME=pi -10
FILE=malloc://1024
EXPECT=<<EOF
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
EOF
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
wx 90909090909090909090 ; s 10 ; pi -10
EOF
RUN
 
NAME=pif bsz
FILE=malloc://1024
EXPECT=<<EOF
pop rbx
pop r12
pop r13
pop r14
pop r15
pop rbp
ret
EOF
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
wx 5b415c415d415e415f5dc3
af
b 2
pif
EOF
RUN
 
NAME=pi~?
FILE=malloc://1024
EXPECT=<<EOF
200
200
200
EOF
CMDS=<<EOF
pi 200~?
pi 200~?
pd 200~?
EOF
RUN
 
NAME=tmpbits
FILE=-
EXPECT=<<EOF
00
64
EOF
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
p8 1 @b:32
e asm.bits
EOF
RUN
 
NAME=tmpbits
FILE=-
EXPECT=<<EOF
00
32
EOF
CMDS=<<EOF
e asm.arch=x86
e asm.bits=32
p8 1 @b:64
e asm.bits
EOF
RUN
 
NAME=pm hello.c
FILE=../bins/src/hello.c
EXPECT=<<EOF
0x00000000 1 C source code
EOF
CMDS=pm
RUN
 
NAME=pm elf/main
FILE=../bins/elf/analysis/main
EXPECT=<<EOF
0x00000000 1 ELF 64-bit LSB executable, x86-64, version 1
EOF
ARGS=-n
CMDS=pm
RUN
 
NAME=pm mach0/fatmach0-3true
FILE=../bins/mach0/fatmach0-3true
EXPECT=<<EOF
0x00000000 1 Fat-Mach-O
EOF
ARGS=-n
CMDS=pm
RUN
 
NAME=pm java/Hello.class
FILE=../bins/java/Hello.class
EXPECT=<<EOF
0x00000000 1 Java CLASS
EOF
ARGS=-n
CMDS=pm
RUN
 
NAME=pm pe/a.exe
FILE=../bins/pe/a.exe
EXPECT=<<EOF
0x00000000 1 PE for MS Windows (console) Intel 80386 32-bit
EOF
ARGS=-n
CMDS=pm
RUN
 
NAME=print raw lines
FILE=../bins/other/projects/resetc64
EXPECT=<<EOF
+1
5
EOF
CMDS=<<EOF
sl 5
prl 1~[0]
e lines.abs=true
prl 1~[0]
EOF
RUN
 
NAME=pib from beginning of bb
FILE=../bins/elf/analysis/x64-loop
EXPECT=<<EOF
push rbp
mov rbp, rsp
sub rsp, 0x20
mov dword [var_14h], edi
mov qword [var_20h], rsi
mov dword [var_4h], 0
jmp 0x400523
EOF
CMDS=<<EOF
s main
af
pib
EOF
RUN
 
NAME=pib inside bb
FILE=../bins/elf/analysis/x64-loop
EXPECT=<<EOF
sub rsp, 0x20
mov dword [var_14h], edi
mov qword [var_20h], rsi
mov dword [var_4h], 0
jmp 0x400523
EOF
CMDS=<<EOF
s main
af
so 2
pib
EOF
RUN
 
NAME=pI size > bocksize
FILE=malloc://1024
EXPECT=<<EOF
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
EOF
CMDS=<<EOF
e asm.arch=x86
e asm.bits=64
wx 90909090909090909090
b 1
pI 10
EOF
RUN
 
NAME=p- with "r2 --"
FILE=--
EXPECT=<<EOF
EOF
CMDS=p-
RUN
 
NAME=p- with malloc://512
FILE=malloc://512
EXPECT=<<EOF
0x00000000 [^_____________________________________________] 0x00000200
EOF
CMDS=p-
RUN
 
NAME=psW 32 widestring
FILE=../bins/elf/crackme0x00b
EXPECT=<<EOF
w0wgreat
EOF
CMDS=psW @ obj.pass.1964
RUN
 
NAME=psW 32 widestring leading zeros
FILE=../bins/elf/crackme0x00b
EXPECT=<<EOF
w0wgreat
EOF
CMDS=psW @ 0x0804a03e
RUN
 
NAME=ps leading zeros
BROKEN=1
FILE=../bins/elf/crackme0x00b
EXPECT=<<EOF
w
EOF
CMDS=ps @ 0x0804a03e
RUN
 
NAME=io.unalloc, io.unalloc.ch and prc
FILE=../bins/elf/analysis/tiny.elf
CMDS=<<EOF
. ../bins/other/palette.r2
(print; prc 0x00010032-0x0000fffa @ 0x0000fffa)
e io.unalloc=true
e scr.color=0
.(print)
?e
e scr.color=3
e io.unalloc.ch=
.(print)
?e
e io.unalloc.ch=?
.(print)
EOF
EXPECT=<<EOF
0x0000fffa ????????????se,,,,,,
0x0001000a .. ..
0x0001001a en....OO,,OO;; ..
0x0001002a ..
 
0x0000fffa ............se
0x0001000a
0x0001001a en
0x0001002a
 
0x0000fffa ????????????se
0x0001000a
0x0001001a en
0x0001002a
EOF
RUN
 
NAME=prc text color
FILE=-
CMDS=<<EOF
. ../bins/other/palette.r2
.. ../bins/src/prc_256.py
e scr.color=3
prc 256
EOF
EXPECT=<<EOF
0x00000000 000102030405060708090a0b0c0d0e0f
0x00000010 101112131415161718191a1b1c1d1e1f
0x00000020 202122232425262728292a2b2c2d2e2f
0x00000030 303132333435363738393a3b3c3d3e3f
0x00000040 404142434445464748494a4b4c4d4e4f
0x00000050 505152535455565758595a5b5c5d5e5f
0x00000060 606162636465666768696a6b6c6d6e6f
0x00000070 707172737475767778797a7b7c7d7e7f
0x00000080 808182838485868788898a8b8c8d8e8f
0x00000090 909192939495969798999a9b9c9d9e9f
0x000000a0 a0a1a2a3a4a5a6a7a8a9aaabacadaeaf
0x000000b0 b0b1b2b3b4b5b6b7b8b9babbbcbdbebf
0x000000c0 c0c1c2c3c4c5c6c7c8c9cacbcccdcecf
0x000000d0 d0d1d2d3d4d5d6d7d8d9dadbdcdddedf
0x000000e0 e0e1e2e3e4e5e6e7e8e9eaebecedeeef
0x000000f0 f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff
EOF
RUN