Faster Css using the api instead of Cz with tmpseek ##bin

* Perf results are unnoticeable, on a 8MB binary (0.590 vs 0.580)
This commit is contained in:
pancake 2023-06-04 06:26:53 +02:00
parent eb6f28b174
commit 052c8058d2
4 changed files with 13 additions and 66 deletions

View File

@ -748,15 +748,17 @@ static int cmd_meta_vartype_comment(RCore *core, const char *input) {
typedef struct {
RCore *core;
ut64 addr;
ut8 *buf;
} StringSearchOptions;
static int cb_strhit(R_NULLABLE RSearchKeyword *kw, void *user, ut64 where) {
StringSearchOptions *sso = (StringSearchOptions*)user;
#if R2_590
r_core_cmd_call_at (sso->core, "Cz", where);
#if 1
const char *name = (const char *)(sso->buf + (where - sso->addr));
size_t n = strlen (name) + 1;
r_meta_set (sso->core->anal, R_META_TYPE_STRING, where, n, name);
#else
r_core_cmdf (sso->core, "Cz@0x%08"PFMT64x, where);
// TODO: r_meta_set (core->anal, type, addr, n, name);
#endif
return true;
}
@ -933,7 +935,8 @@ static int cmd_meta_others(RCore *core, const char *input) {
r_search_set_string_limits (ss, minstr, maxstr);
StringSearchOptions sso = {
.addr = addr,
.core = core
.core = core,
.buf = buf
};
// r_print_hexdump (core->print, addr, buf, range, 8,1,1);
r_search_set_callback (ss, cb_strhit, &sso);

View File

@ -47,6 +47,7 @@ typedef struct r_search_keyword_t {
int type;
ut64 last; // last hit hint
int align; // per-keyword alignment rule
// XXX string search dont have a way to report the kw hit size
} RSearchKeyword;
typedef struct r_search_uds_t {
@ -58,6 +59,9 @@ typedef struct r_search_uds_t {
typedef struct r_search_hit_t {
RSearchKeyword *kw;
ut64 addr;
#if R2_590
size_t size;
#endif
} RSearchHit;
typedef int (*RSearchCallback) (R_NULLABLE RSearchKeyword *kw, void *user, ut64 where); // TODO: depricate, b/c lacks match len

View File

@ -142,66 +142,6 @@ DEBUG: (section .dynstr) Css 674 @ 0x484
DEBUG: RCoreCmd: Css 674 @ 0x484
DEBUG: RCoreCmd: Cz@0x00000484
DEBUG: RCoreCmd: o;om
DEBUG: RCoreCmd: Cz@0x00000485
DEBUG: RCoreCmd: Cz@0x00000494
DEBUG: RCoreCmd: Cz@0x000004a3
DEBUG: RCoreCmd: Cz@0x000004ab
DEBUG: RCoreCmd: Cz@0x000004b2
DEBUG: RCoreCmd: Cz@0x000004b7
DEBUG: RCoreCmd: Cz@0x000004bc
DEBUG: RCoreCmd: Cz@0x000004c2
DEBUG: RCoreCmd: Cz@0x000004c8
DEBUG: RCoreCmd: Cz@0x000004d0
DEBUG: RCoreCmd: Cz@0x000004d6
DEBUG: RCoreCmd: Cz@0x000004dd
DEBUG: RCoreCmd: Cz@0x000004e3
DEBUG: RCoreCmd: Cz@0x000004e8
DEBUG: RCoreCmd: Cz@0x000004ee
DEBUG: RCoreCmd: Cz@0x000004f5
DEBUG: RCoreCmd: Cz@0x000004fc
DEBUG: RCoreCmd: Cz@0x00000503
DEBUG: RCoreCmd: Cz@0x0000050a
DEBUG: RCoreCmd: Cz@0x00000511
DEBUG: RCoreCmd: Cz@0x00000516
DEBUG: RCoreCmd: Cz@0x0000051d
DEBUG: RCoreCmd: Cz@0x00000522
DEBUG: RCoreCmd: Cz@0x00000527
DEBUG: RCoreCmd: Cz@0x0000053b
DEBUG: RCoreCmd: Cz@0x0000054d
DEBUG: RCoreCmd: Cz@0x0000055c
DEBUG: RCoreCmd: Cz@0x00000569
DEBUG: RCoreCmd: Cz@0x00000576
DEBUG: RCoreCmd: Cz@0x00000583
DEBUG: RCoreCmd: Cz@0x00000596
DEBUG: RCoreCmd: Cz@0x000005ab
DEBUG: RCoreCmd: Cz@0x000005b0
DEBUG: RCoreCmd: Cz@0x000005b8
DEBUG: RCoreCmd: Cz@0x000005c0
DEBUG: RCoreCmd: Cz@0x000005cc
DEBUG: RCoreCmd: Cz@0x000005d7
DEBUG: RCoreCmd: Cz@0x000005e1
DEBUG: RCoreCmd: Cz@0x000005e7
DEBUG: RCoreCmd: Cz@0x000005ee
DEBUG: RCoreCmd: Cz@0x000005f6
DEBUG: RCoreCmd: Cz@0x000005fd
DEBUG: RCoreCmd: Cz@0x00000604
DEBUG: RCoreCmd: Cz@0x0000060b
DEBUG: RCoreCmd: Cz@0x00000613
DEBUG: RCoreCmd: Cz@0x0000061a
DEBUG: RCoreCmd: Cz@0x00000623
DEBUG: RCoreCmd: Cz@0x0000062a
DEBUG: RCoreCmd: Cz@0x00000630
DEBUG: RCoreCmd: Cz@0x00000637
DEBUG: RCoreCmd: Cz@0x00000643
DEBUG: RCoreCmd: Cz@0x00000648
DEBUG: RCoreCmd: Cz@0x0000065c
DEBUG: RCoreCmd: Cz@0x0000068c
DEBUG: RCoreCmd: Cz@0x000006d1
DEBUG: RCoreCmd: Cz@0x000006db
DEBUG: RCoreCmd: Cz@0x000006e1
DEBUG: RCoreCmd: Cz@0x0000070b
DEBUG: RCoreCmd: Cz@0x00000713
DEBUG: RCoreCmd: Cz@0x0000071c
DEBUG: (section .dynamic) Cd 4[48] @ 0x12000
DEBUG: RCoreCmd: Cd 4[48] @ 0x12000
DEBUG: (cannot find opening [) in (48])

File diff suppressed because one or more lines are too long