Update radare2-shell-parser for new macro syntax and fix tests

This commit is contained in:
Riccardo Schirone 2020-03-13 13:21:11 +01:00 committed by radare
parent e82f738370
commit 0cd90b6b7e
16 changed files with 52 additions and 41 deletions

View File

@ -4624,6 +4624,12 @@ static struct tsr2cmd_edit *create_cmd_edit(struct tsr2cmd_state *state, TSNode
static void replace_whitespaces(char *s, char ch) {
while (*s) {
if (*s == '#') {
while (*s && *s != '\r' && *s != '\n') {
*s = ch;
s++;
}
}
if (isspace (*s)) {
*s = ch;
}
@ -5082,6 +5088,8 @@ DEFINE_HANDLE_TS_FCN(help_command) {
r_core_cmd_help (state->core, help_msg_at_at_at);
} else if (!strcmp (node_string, "|?")) {
r_core_cmd_help (state->core, help_msg_vertical_bar);
} else if (!strcmp (node_string, "~?")) {
r_cons_grep_help ();
} else if (!strcmp (node_string + strlen (node_string) - 2, "?*")) {
size_t node_len = strlen (node_string);
int detail = 0;
@ -5982,6 +5990,12 @@ DEFINE_HANDLE_TS_FCN(scr_tts_command) {
return res;
}
DEFINE_HANDLE_TS_FCN(task_command) {
// TODO: this should be handled differently, if the argument is a command.
// For now we just treat everything as an arged_command
return handle_ts_arged_command (state, node);
}
DEFINE_HANDLE_TS_FCN(number_command) {
ut64 addr = r_num_math (state->core->num, node_string);
r_core_seek (state->core, addr, 1);

View File

@ -3,6 +3,7 @@
HANDLER_RULE_OP (number_command)
HANDLER_RULE_OP (commands)
HANDLER_RULE_OP (arged_command)
HANDLER_RULE_OP (task_command)
HANDLER_RULE_OP (legacy_quoted_command)
HANDLER_RULE_OP (repeat_command)
HANDLER_RULE_OP (redirect_command)

View File

@ -34,7 +34,7 @@ TS_TIP=f049ba350f3f6019ce9a1cbb0975ebd154ef7ad3
# NOTE: when you update SHELLPARSER_TIP or SHELLPARSER_BRA, also update them in shlr/meson.build
SHELLPARSER_URL=https://github.com/ret2libc/radare2-shell-parser.git
SHELLPARSER_BRA=master
SHELLPARSER_TIP=1a49d280f067b59b1e500f993bf98eb03927dea0
SHELLPARSER_TIP=36130421da6a698cc65b7f4dd939a803310bbe24
ifeq ($(CS_RELEASE),1)
CS_VER=4.0.1

View File

@ -295,7 +295,7 @@ if get_option('use_treesitter')
endif
# NOTE: when you update SHELLPARSER_TIP or SHELLPARSER_BRA, also update them in shlr/Makefile
SHELLPARSER_TIP = '1a49d280f067b59b1e500f993bf98eb03927dea0'
SHELLPARSER_TIP = '36130421da6a698cc65b7f4dd939a803310bbe24'
SHELLPARSER_BRA = 'master'
shell_parser_user = 'ret2libc'

View File

@ -822,7 +822,7 @@ NAME=arm jump table
FILE=../bins/elf/analysis/callback.elf
CMDS=<<EOF
af @ sym.input_handler2
CC. @ 0x000105b8~?(7
CC. @ 0x000105b8~?\(7
EOF
EXPECT=<<EOF
1
@ -833,7 +833,7 @@ NAME=arm jump table
FILE=../bins/elf/analysis/mobile_bank.45115ff5f655d94fc26cb5244928b3fc
CMDS=<<EOF
af @ 0x11284
CC. @ 0x000112b0~?(8
CC. @ 0x000112b0~?\(8
EOF
EXPECT=<<EOF
1

View File

@ -1428,7 +1428,7 @@ EOF
CMDS=<<EOF
aaa
s 0x00401255
pd 1~?ExitProcess(UINT
pd 1~?ExitProcess\(UINT
EOF
RUN
@ -1452,7 +1452,7 @@ EOF
CMDS=<<EOF
aaa
s 0x08048469
pd 1~?strcmp(const
pd 1~?strcmp\(const
EOF
RUN

View File

@ -35,7 +35,7 @@ f@F:functions~483f4,48540
f@F:*~483f4,48540
afn mymain @ 0x08048540
afn @ 0x08048540
?e The main flag shouldn't be renamed, it comes from bin:
"?e The main flag shouldn't be renamed, it comes from bin:"
f@F:functions~483f4,48540
?e --
f@F:*~483f4,48540

View File

@ -78,7 +78,7 @@ false
false
EOF
CMDS=<<EOF
e scr.highlight= scr.highlight.grep =scr.rainbow =true
"e scr.highlight= scr.highlight.grep =scr.rainbow =true "
e scr.highlight
e scr.highlight.grep
e scr.rainbow

View File

@ -130,7 +130,7 @@ CMDS=<<EOF
f foo.one = 1
f foo.bar = 2
f foo.cow = 3
(;?v $$)() @@ foo*
(_;?v $$)() @@ foo*
EOF
RUN

View File

@ -64,14 +64,14 @@ NAME=o-[0]
FILE=malloc://1024
EXPECT=<<EOF
EOF
CMDS=o-`o~[0]`;o
CMDS=o- `o~[0]`;o
RUN
NAME=oj-
FILE=malloc://1024
EXPECT=<<EOF
EOF
CMDS=o-`oj~{[0].fd}`;o
CMDS=o- `oj~{[0].fd}`;o
RUN
NAME=o -

View File

@ -1838,7 +1838,7 @@ e asm.arch=x86
e asm.bits=32
e asm.bytes=false
s 0x1000
wz path"C:\\Program\n
"wz path\"C:\\Program\n"
f ansi_str
s 0x2000
"wa mov eax, 0x1000"
@ -1849,7 +1849,7 @@ e str.escbslash=false
pd 1
pdJ 1
s 0x3000
ww path"C:\\Program\r
"ww path\"C:\\Program\r"
f wide_str
s 0x4000
"wa mov ebx, 0x3000"

View File

@ -56,7 +56,7 @@ EXPECT=<<EOF
{"string":"...\"..\u00ef\u00bf\u00bd\u00ef\u00bf\u00bd\u00ef","offset":0,"section":"unknown","length":13,"type":"utf"}
EOF
CMDS=<<EOF
wz ..."..<2E><><EFBFBD><EFBFBD>...
"wz ...\"..<2E><><EFBFBD><EFBFBD>..."
psj 13
EOF
RUN

View File

@ -3,14 +3,10 @@ FILE=-
EXPECT=<<EOF
16
18
16
18
EOF
CMDS=<<EOF
@@?~?
@@@?~?
?@@?~?
?@@@?~?
EOF
RUN

View File

@ -9,29 +9,29 @@ s @ 0x42
EOF
RUN
NAME=@ e:
NAME=@e:
FILE=-
EXPECT=<<EOF
1
EOF
CMDS=<<EOF
e scr.color=false
e scr.color @ e:scr.color=true
e scr.color @e:scr.color=true
EOF
RUN
NAME=@ a:
NAME=@a:
FILE=-
EXPECT=<<EOF
arm
EOF
CMDS=<<EOF
e asm.arch=x86
e asm.arch @ a:arm
e asm.arch @a:arm
EOF
RUN
NAME=@ e: @ addr
NAME=@e: @ addr
FILE=-
EXPECT=<<EOF
1
@ -40,12 +40,12 @@ EOF
CMDS=<<EOF
e scr.color=false
s 0
e scr.color @ e:scr.color=true @ 0x1337
s @ e:scr.color=true @ 0x1337
e scr.color @e:scr.color=true @ 0x1337
s @e:scr.color=true @ 0x1337
EOF
RUN
NAME=@ addr @ e
NAME=@ addr @e
FILE=-
EXPECT=<<EOF
0
@ -54,14 +54,14 @@ EXPECT=<<EOF
0x1337
EOF
CMDS=<<EOF
e scr.color @ 0x42 @ e:scr.color=false
e scr.color @ 0x1337 @ e:scr.color=true
s @ 0x42 @ e:scr.color=false
s @ 0x1337 @ e:scr.color=true
e scr.color @ 0x42 @e:scr.color=false
e scr.color @ 0x1337 @e:scr.color=true
s @ 0x42 @e:scr.color=false
s @ 0x1337 @e:scr.color=true
EOF
RUN
NAME=@ a: @ addr @ e:
NAME=@a: @ addr @e:
FILE=-
EXPECT=<<EOF
x86
@ -72,12 +72,12 @@ arm
1
EOF
CMDS=<<EOF
e asm.arch @ a:x86 @ 0x42 @ e:scr.color=false
e asm.arch @ a:arm @ 0x1337 @ e:scr.color=true
s @ a:x86 @ 0x42 @ e:scr.color=false
s @ @ a:arm @ 0x1337 @ e:scr.color=true
e scr.color @ a:x86 @ 0x42 @ e:scr.color=false
e scr.color @ @ a:arm @ 0x1337 @ e:scr.color=true
e asm.arch @a:x86 @ 0x42 @e:scr.color=false
e asm.arch @a:arm @ 0x1337 @e:scr.color=true
s @a:x86 @ 0x42 @e:scr.color=false
s @a:arm @ 0x1337 @e:scr.color=true
e scr.color @a:x86 @ 0x42 @e:scr.color=false
e scr.color @a:arm @ 0x1337 @e:scr.color=true
EOF
RUN
@ -89,7 +89,7 @@ false
EOF
CMDS=<<EOF
e asm.pseudo=false
e asm.pseudo @ e:asm.pseudo=true,asm.pseudo=true
e asm.pseudo @e:asm.pseudo=true,asm.pseudo=true
e asm.pseudo
EOF
RUN
@ -102,7 +102,7 @@ false
EOF
CMDS=<<EOF
e asm.pseudo=false
e asm.pseudo @ e:asm.pseudo=true @ e:asm.pseudo=true
e asm.pseudo @e:asm.pseudo=true @e:asm.pseudo=true
e asm.pseudo
EOF
RUN

View File

@ -31,7 +31,7 @@ EXPECT=<<EOF
foo#bar
EOF
CMDS=<<EOF
w foo#bar
"w foo#bar"
psz
EOF
RUN

View File

@ -67,7 +67,7 @@ RUN
NAME=radiff2 -AC (elf files)
FILE=-
CMDS=!!radiff2 -AC ../bins/other/radiff2/true ../bins/other/radiff2/false~?(1.000000)
CMDS=!!radiff2 -AC ../bins/other/radiff2/true ../bins/other/radiff2/false~?\(1.000000\)
EXPECT=<<EOF
54
EOF