Add CLLf command as an alias for 'list' and fix @@i ##dwarf

This commit is contained in:
pancake 2023-03-02 21:26:12 +01:00
parent df34a54407
commit cbdc372e4a
3 changed files with 51 additions and 1 deletions

View File

@ -5535,7 +5535,12 @@ R_API int r_core_cmd_foreach(RCore *core, const char *cmd, char *each) {
if (fcn) {
r_list_sort (fcn->bbs, bb_cmp);
r_list_foreach (fcn->bbs, iter, bb) {
r_core_seek (core, bb->addr, true);
r_core_cmd (core, cmd, 0);
for (i = 0; i < bb->op_pos_size; i++) {
if (!bb->op_pos[i]) {
break;
}
ut64 addr = bb->addr + bb->op_pos[i];
r_core_seek (core, addr, true);
r_core_cmd (core, cmd, 0);

View File

@ -72,7 +72,8 @@ static const char *help_msg_CL[] = {
"CL*", "", "same as above but in r2 commands format",
"CL.", "", "show list all code line information (virtual address <-> source file:line)",
"CL-", "*", "remove all the cached codeline information",
"CLL", "", "show source code line reading from file",
"CLL", "[f]", "show source code line associated to current offset",
"CLLf", "", "show source lines covered by the current function (see CLL@@i or list)",
"CL", " addr file:line", "register new file:line source details, r2 will slurp the line",
"CL", " addr base64:text", "register new source details for given address using base64",
NULL
@ -333,6 +334,11 @@ static int cmd_meta_lineinfo(RCore *core, const char *input) {
return 0;
}
if (*p == 'L') { // "CLL"
if (p[1] == 'f') {
r_core_cmd0 (core, "CLL@@i");
// same as CLL@@i = r_core_cmd0 (core, "list");
return 0;
}
ut64 at = core->offset;
if (p[1] == ' ') {
at = r_num_math (core->num, p + 2);

39
test/db/cmd/dwarf2 Normal file
View File

@ -0,0 +1,39 @@
NAME=mach0 function dwarf
FILE=bins/mach0/twocall
CMDS=<<EOF
CLL
?e --
af
CLLf
?e --
CL
EOF
EXPECT=<<EOF
0x100003f64 main() {
--
0x100003f64 main() {
0x100003f7c printf ("Hello\n");
0x100003f84 scanf ("Hello\n");
0x100003f8c }
--
file: /Users/pancake/prg/radare2/test/bins/mach0/twocall.c
line: 5
addr: 0x100003f98
file: /Users/pancake/prg/radare2/test/bins/mach0/twocall.c
line: 5
addr: 0x100003f8c
file: /Users/pancake/prg/radare2/test/bins/mach0/twocall.c
line: 2
addr: 0x100003f64
file: /Users/pancake/prg/radare2/test/bins/mach0/twocall.c
line: 3
addr: 0x100003f7c
file: /Users/pancake/prg/radare2/test/bins/mach0/twocall.c
line: 4
addr: 0x100003f84
file: /Users/pancake/prg/radare2/test/bins/mach0/twocall.c
line: 0
addr: 0x100003f70
EOF
RUN