Some more likely hints in RCore.cmd from valgrind ##perf

This commit is contained in:
pancake 2023-01-21 13:03:35 +01:00 committed by pancake
parent 4c808dfc98
commit b0a40267c6
7 changed files with 32 additions and 30 deletions

View File

@ -344,7 +344,7 @@ R_API const char *r_anal_data_kind(RAnal *a, ut64 addr, const ut8 *buf, int len)
int num = 0;
int i, j;
RAnalData *data;
len = R_MIN (len, 128); // dim the scan to 16 byte only otherwise its too slow
len = R_MIN (len, 32); // smoler dim causes some tests to fail
int word = a->config->bits / 8;
for (i = j = 0; i < len; j++) {
if (R_UNLIKELY (str && !buf[i])) {

View File

@ -540,7 +540,10 @@ static int fcn_recurse(RAnal *anal, RAnalFunction *fcn, ut64 addr, ut64 len, int
char *sp_reg = NULL;
char *op_dst = NULL;
char *op_src = NULL;
if (R_UNLIKELY ((depth < 1) && (depth != -1))) {
if (depth < -1) {
// only happens when we want to analyze 1 basic block
return R_ANAL_RET_ERROR; // MUST BE TOO DEEP
} else if (R_UNLIKELY ((depth < 0) && (depth != -1))) {
R_LOG_WARN ("Analysis of 0x%08"PFMT64x" stopped at 0x%08"PFMT64x", use a higher anal.depth to continue", fcn->addr, addr);
return R_ANAL_RET_ERROR;
}

View File

@ -3569,17 +3569,17 @@ static int r_core_cmd_subst(RCore *core, char *cmd) {
char *colon = NULL, *icmd = NULL;
bool tmpseek = false;
bool original_tmpseek = core->tmpseek;
if (r_str_startswith (cmd, "\"\"")) {
if (R_UNLIKELY (r_str_startswith (cmd, "\"\""))) {
return r_core_cmd_call (core, cmd + 2);
}
if (r_str_startswith (cmd, "?t\"\"")) {
if (R_UNLIKELY (r_str_startswith (cmd, "?t\"\""))) {
char *c = r_str_newf ("?t\"\"%s", cmd + 4);
int res = r_core_cmd_call (core, c);
free (c);
return res;
}
if (r_str_startswith (cmd, "GET /cmd/")) {
if (R_UNLIKELY (r_str_startswith (cmd, "GET /cmd/"))) {
memmove (cmd, cmd + 9, strlen (cmd + 9) + 1);
char *http = strstr (cmd, "HTTP");
if (http) {
@ -3611,7 +3611,7 @@ static int r_core_cmd_subst(RCore *core, char *cmd) {
r_str_trim_tail (cmd);
R_CRITICAL_LEAVE (core);
// lines starting with # are ignored (never reach cmd_hash()), except #! and #?
if (!*cmd) {
if (R_UNLIKELY (!*cmd)) {
if (core->cmdrepeat > 0) {
lastcmd_repeat (core, true);
ret = r_core_cmd_nullcallback (core);
@ -3623,7 +3623,7 @@ static int r_core_cmd_subst(RCore *core, char *cmd) {
}
if (*cmd) {
char *hash = (char *) r_str_firstbut_escape (cmd, '#', "'\"");
if (hash && hash != cmd) {
if (R_UNLIKELY (hash && hash != cmd)) {
*hash = 0;
r_str_trim_tail (cmd);
}
@ -4253,7 +4253,7 @@ escape_redir:
next2:
/* sub commands */
ptr = r_core_cmd_find_subcmd_begin (cmd);
if (ptr) {
if (R_UNLIKELY (ptr)) {
bool backquote = false;
if (*ptr == '`') {
backquote = true;
@ -4324,7 +4324,7 @@ escape_backtick:
// TODO must honor " and `
if (*cmd != '"' && *cmd) {
const char *s = strstr (cmd, "~?");
if (s) {
if (R_UNLIKELY (s)) {
bool showHelp = false;
if (cmd == s) {
// ~?
@ -5758,18 +5758,18 @@ static int run_cmd_depth(RCore *core, char *cmd) {
char *rcmd;
int ret = false;
if (core->cons->context->cmd_depth < 1) {
if (R_UNLIKELY (core->cons->context->cmd_depth < 1)) {
R_LOG_ERROR ("That '%s' was too deep", cmd);
return false;
}
core->cons->context->cmd_depth--;
for (rcmd = cmd;;) {
char *ptr = strchr (rcmd, '\n');
if (ptr) {
if (R_UNLIKELY (ptr)) {
*ptr = '\0';
}
ret = r_core_cmd_subst (core, rcmd);
if (ret == -1) {
if (R_UNLIKELY (ret == -1)) {
R_LOG_ERROR ("Invalid command '%s' (0x%02x)", rcmd, *rcmd);
break;
}

View File

@ -21,7 +21,7 @@ wx dff80000 12000000 34000000
pd 1
EOF
EXPECT=<<EOF
0x00000000 dff80000 ldr.w r0, [0x00000004] ; [0x4:4]=18 ; 4
0x00000000 dff80000 ldr.w r0, [0x00000004] ; [0x4:4]=18
EOF
RUN
@ -62,9 +62,9 @@ wx 0149 014a 014b 0000 1111 2222 3333 4444 5555 6666
pd 3
EOF
EXPECT=<<EOF
0x00000000 0149 ldr r1, [0x00000008] ; [0x8:4]=0x22221111 ; 8
0x00000002 014a ldr r2, [0x00000008] ; [0x8:4]=0x22221111 ; 8
0x00000004 014b ldr r3, [0x0000000c] ; [0xc:4]=0x44443333 ; 12
0x00000000 0149 ldr r1, [0x00000008] ; [0x8:4]=0x22221111
0x00000002 014a ldr r2, [0x00000008] ; [0x8:4]=0x22221111
0x00000004 014b ldr r3, [0x0000000c] ; [0xc:4]=0x44443333 ; "33DDUUff"
EOF
RUN
@ -78,9 +78,9 @@ wx 0249 024a 024b 7944 7a44 7b44 1111 2222 3333 4444 5555 6666 7777
pd 6
EOF
EXPECT=<<EOF
0x00000000 0249 ldr r1, [0x0000000c] ; [0xc:4]=0x22221111 ; 12 ; r1=0x22221111
0x00000002 024a ldr r2, [0x0000000c] ; [0xc:4]=0x22221111 ; 12 ; r2=0x22221111
0x00000004 024b ldr r3, [0x00000010] ; [0x10:4]=0x44443333 ; 16 ; r3=0x44443333
0x00000000 0249 ldr r1, [0x0000000c] ; [0xc:4]=0x22221111 ; r1=0x22221111
0x00000002 024a ldr r2, [0x0000000c] ; [0xc:4]=0x22221111 ; r2=0x22221111
0x00000004 024b ldr r3, [0x00000010] ; [0x10:4]=0x44443333 ; r3=0x44443333
0x00000006 7944 add r1, pc ; r1=0x2222111b
0x00000008 7a44 add r2, pc ; r2=0x2222111d
0x0000000a 7b44 add r3, pc ; r3=0x44443341
@ -97,7 +97,7 @@ pd 1 @ 0x2
EOF
EXPECT=<<EOF
0x00000002 01a0 adr r0, 4 ; "Radare2 test string"
; 0x8 ; 8
; 0x8
EOF
RUN
@ -142,7 +142,7 @@ pd 1 @ 0x2
EOF
EXPECT=<<EOF
0x00000002 01a0 adr r0, 4 ; "Radare2 test\r\n"
; 0x8 ; 8
; 0x8
EOF
RUN
@ -649,7 +649,7 @@ EXPECT=<<EOF
| 0x00010424 04b08de2 add fp, sp, 4
| 0x00010428 08d04de2 sub sp, sp, 8
| 0x0001042c 08000be5 str r0, [var_8h] ; 8 ; arg1
| 0x00010430 14009fe5 ldr r0, [0x0001044c] ; [0x1044c:4]=0x104f0
| 0x00010430 14009fe5 ldr r0, [0x0001044c] ; [0x1044c:4]=0x104f0 "%d"
| 0x00010434 08101be5 ldr r1, [var_8h] ; 8
| 0x00010438 a2ffffeb bl sym.imp.printf
| 0x0001043c 0030a0e3 mov r3, 0
@ -941,7 +941,7 @@ EXPECT=<<EOF
;-- main:
0x0000050c 80b5 push {r7, lr}
0x0000050e 00af add r7, sp, 0
0x00000510 034b ldr r3, [0x00000520] ; [0x520:4]=94 ; 1312
0x00000510 034b ldr r3, [0x00000520] ; [0x520:4]=94
0x00000512 7b44 add r3, pc ; 0x574 ; "Hello world!"
0x00000514 1846 mov r0, r3
0x00000516 fff75aef blx sym.imp.puts

View File

@ -187,8 +187,7 @@ size: 11
| 0x004017c3 83c108 add ecx, 8
\ 0x004017c6 3d00100000 cmp eax, 0x1000
EOF
EXPECT_ERR=<<EOF
EOF
EXPECT_ERR=
RUN
NAME=afb+ with wrong size

View File

@ -1381,10 +1381,10 @@ pd 1
pdJ 1
EOF
EXPECT=<<EOF
0x080484aa b8e1850408 mov eax, 0x80485e1 ; eax=0x80485e1 "%ls"
[{"offset":134513834,"text":" 0x080484aa b8e1850408 mov eax, 0x80485e1 ; eax=0x80485e1 \"%ls\""}]
0x080484aa b8e1850408 mov eax, 0x80485e1 ; eax=0x80485e1 "%ls"
[{"offset":134513834,"text":" \u001b[32m0x080484aa\u001b[0m \u001b[37mb8\u001b[37me1\u001b[37m85\u001b[37m04\u001b[37m08\u001b[0m \u001b[37mmov\u001b[36m eax\u001b[0m,\u001b[36m\u001b[36m \u001b[33m0x80485e1\u001b[0m\u001b[0m\u001b[0m\u001b[31m ; eax=0x80485e1 \u001b[7m\"%ls\"\u001b[27m\u001b[0m"}]
0x080484aa b8e1850408 mov eax, 0x80485e1 ; "%ls" ; eax=0x80485e1 -> 0x736c25
[{"offset":134513834,"text":" 0x080484aa b8e1850408 mov eax, 0x80485e1 ; \"%ls\" ; eax=0x80485e1 -> 0x736c25"}]
0x080484aa b8e1850408 mov eax, 0x80485e1 ; "%ls" ; eax=0x80485e1 -> 0x736c25
[{"offset":134513834,"text":" \u001b[32m0x080484aa\u001b[0m \u001b[37mb8\u001b[37me1\u001b[37m85\u001b[37m04\u001b[37m08\u001b[0m \u001b[37mmov\u001b[36m eax\u001b[0m,\u001b[36m\u001b[36m \u001b[33m0x80485e1\u001b[0m\u001b[0m\u001b[31m \u001b[31m; \"%ls\"\u001b[0m\u001b[31m ; eax=0x80485e1 -> 0x736c25\u001b[0m"}]
EOF
RUN

View File

@ -187,7 +187,7 @@ EXPECT=<<EOF
0x00000466 6f46 mov r7, sp
0x00000468 82b0 sub sp, 8
0x0000046a 69ec1623 stcl p3, c2, [sb], -0x58
0x0000046e 0548 ldr r0, [0x00000484] ; [0x484:4]=28 ; 1156
0x0000046e 0548 ldr r0, [0x00000484] ; [0x484:4]=28
EOF
RUN