mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-28 15:41:38 +00:00
xrefs dir path fix
This commit is contained in:
parent
1e38b4521e
commit
61518c2646
@ -322,13 +322,6 @@ R_API RList* r_anal_get_fcns (RAnal *anal) {
|
||||
return anal->fcns;
|
||||
}
|
||||
|
||||
R_API bool r_anal_project_load(RAnal *anal, const char *prjfile) {
|
||||
if (prjfile && *prjfile) {
|
||||
return r_anal_xrefs_load (anal, prjfile);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
R_API bool r_anal_project_save(RAnal *anal, const char *prjfile) {
|
||||
if (prjfile && *prjfile) {
|
||||
return r_anal_xrefs_save (anal, prjfile);
|
||||
|
@ -28,51 +28,6 @@ static void XREFKEY(char * const key, const size_t key_len,
|
||||
snprintf (key, key_len, "%s.%s.0x%"PFMT64x, kind, _sdb_type, addr);
|
||||
}
|
||||
|
||||
R_API bool r_anal_xrefs_load(RAnal *anal, const char *prjfile) {
|
||||
char *path, *db;
|
||||
ut8 found = 0;
|
||||
SdbListIter *it;
|
||||
SdbNs *ns;
|
||||
|
||||
if (!prjfile || !*prjfile) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (prjfile[0] == '/') {
|
||||
db = r_str_newf ("%s.d", prjfile);
|
||||
if (!db) return false;
|
||||
path = strdup (db);
|
||||
} else {
|
||||
db = r_str_newf (R2_HOMEDIR"/projects/%s.d", prjfile);
|
||||
if (!db) return false;
|
||||
path = r_str_home (db);
|
||||
}
|
||||
|
||||
if (!path) {
|
||||
free (db);
|
||||
return false;
|
||||
}
|
||||
|
||||
ls_foreach (anal->sdb->ns, it, ns){
|
||||
if (ns->sdb == DB){
|
||||
ls_delete (anal->sdb->ns, it);
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) sdb_free (DB);
|
||||
DB = sdb_new (path, "xrefs", 0);
|
||||
if (!DB) {
|
||||
free (db);
|
||||
free (path);
|
||||
return false;
|
||||
}
|
||||
sdb_ns_set (anal->sdb, "xrefs", DB);
|
||||
free (path);
|
||||
free (db);
|
||||
return true;
|
||||
}
|
||||
|
||||
R_API bool r_anal_xrefs_save(RAnal *anal, const char *prjfile) {
|
||||
sdb_file (anal->sdb_xrefs, prjfile);
|
||||
return sdb_sync (anal->sdb_xrefs);
|
||||
|
@ -9,7 +9,7 @@ DEPS+=r_reg r_search r_syscall r_socket r_fs r_magic r_crypto
|
||||
OBJS=core.o cmd.o file.o config.o visual.o io.o yank.o libs.o graph.o
|
||||
OBJS+=hack.o vasm.o patch.o bin.o log.o syscmd.o rtr.o cmd_api.o
|
||||
OBJS+=anal.o project.o gdiff.o asm.o vmenus.o disasm.o plugin.o
|
||||
OBJS+=help.o task.o panels.o pseudo.o vmarks.o
|
||||
OBJS+=help.o task.o panels.o pseudo.o vmarks.o xrefs.o
|
||||
|
||||
CFLAGS+=-DCORELIB
|
||||
LDFLAGS+=${DL_LIBS}
|
||||
|
@ -2136,3 +2136,10 @@ R_API RBuffer *r_core_syscall (RCore *core, const char *name, const char *args)
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
R_API bool r_core_project_load(RCore *core, const char *prjfile) {
|
||||
if (prjfile && *prjfile) {
|
||||
return r_core_xrefs_load (core, prjfile);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ R_API int r_core_project_open(RCore *core, const char *prjfile) {
|
||||
r_core_bin_load (core, filepath, UT64_MAX);
|
||||
}
|
||||
// FIXME: If r_anal_project_load is not called before r_core_cmd_file, xrefs are not loaded correctly
|
||||
r_anal_project_load (core->anal, prjfile);
|
||||
r_core_project_load (core, prjfile);
|
||||
r_core_rop_load (core, prjfile);
|
||||
ret = r_core_cmd_file (core, prj);
|
||||
r_config_bump (core->config, "asm.arch");
|
||||
|
53
libr/core/xrefs.c
Normal file
53
libr/core/xrefs.c
Normal file
@ -0,0 +1,53 @@
|
||||
/* radare - LGPL - Copyright 2009-2014 - pancake, nibble, Darredevil */
|
||||
|
||||
#include <r_core.h>
|
||||
#include <sdb.h>
|
||||
|
||||
#define _DB core->anal->sdb_xrefs
|
||||
|
||||
R_API bool r_core_xrefs_load(RCore *core, const char *prjfile) {
|
||||
char *path, *db;
|
||||
ut8 found = 0;
|
||||
SdbListIter *it;
|
||||
SdbNs *ns;
|
||||
|
||||
const char *prjdir = r_config_get (core->config, "dir.projects");
|
||||
|
||||
if (!prjfile || !*prjfile) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (prjfile[0] == '/') {
|
||||
db = r_str_newf ("%s.d", prjfile);
|
||||
if (!db) return false;
|
||||
path = strdup (db);
|
||||
} else {
|
||||
db = r_str_newf ("%s/%s.d", prjdir, prjfile);
|
||||
if (!db) return false;
|
||||
path = r_file_abspath (db);
|
||||
}
|
||||
|
||||
if (!path) {
|
||||
free (db);
|
||||
return false;
|
||||
}
|
||||
|
||||
ls_foreach (core->anal->sdb->ns, it, ns){
|
||||
if (ns->sdb == _DB){
|
||||
ls_delete (core->anal->sdb->ns, it);
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) sdb_free (_DB);
|
||||
_DB = sdb_new (path, "xrefs", 0);
|
||||
if (!_DB) {
|
||||
free (db);
|
||||
free (path);
|
||||
return false;
|
||||
}
|
||||
sdb_ns_set (core->anal->sdb, "xrefs", _DB);
|
||||
free (path);
|
||||
free (db);
|
||||
return true;
|
||||
}
|
@ -1322,9 +1322,7 @@ R_API RAnalVarAccess *r_anal_var_access_get(RAnal *anal, RAnalVar *var, ut64 fro
|
||||
R_API RAnalVar *r_anal_var_get_byname (RAnal *anal, RAnalFunction *fcn, char kind, const char* name);
|
||||
|
||||
/* project */
|
||||
R_API bool r_anal_project_load(RAnal *anal, const char *prjfile);
|
||||
R_API bool r_anal_project_save(RAnal *anal, const char *prjfile);
|
||||
R_API bool r_anal_xrefs_load(RAnal *anal, const char *prjfile);
|
||||
R_API bool r_anal_xrefs_init (RAnal *anal);
|
||||
|
||||
#define R_ANAL_THRESHOLDFCN 0.7F
|
||||
|
@ -287,6 +287,10 @@ R_API ut32 r_core_file_cur_fd (RCore *core);
|
||||
|
||||
R_API void r_core_debug_rr (RCore *core, RReg *reg);
|
||||
|
||||
/* project */
|
||||
R_API bool r_core_project_load(RCore *core, const char *prjfile);
|
||||
R_API bool r_core_xrefs_load(RCore *core, const char *prjfile);
|
||||
|
||||
#define R_CORE_FOREIGN_ADDR -1
|
||||
R_API int r_core_yank(RCore *core, ut64 addr, int len);
|
||||
R_API int r_core_yank_string(RCore *core, ut64 addr, int maxlen);
|
||||
|
Loading…
Reference in New Issue
Block a user