Skip to content

Commit

Permalink
Rename RDebugTracepoint -> RDebugTracepointItem
Browse files Browse the repository at this point in the history
  • Loading branch information
jukuisma authored and trufae committed Jan 31, 2025
1 parent 27f0861 commit 3a17978
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 28 deletions.
2 changes: 1 addition & 1 deletion libr/core/agraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -2409,7 +2409,7 @@ static void fold_asm_trace(RCore *core, RAGraph *g) {
continue;
}
ut64 addr = r_num_get (NULL, n->title);
RDebugTracepoint *tp = r_debug_trace_get (core->dbg, addr);
RDebugTracepointItem *tp = r_debug_trace_get (core->dbg, addr);
n->is_mini = (tp == NULL);
}
g->need_update_dim = 1;
Expand Down
6 changes: 3 additions & 3 deletions libr/core/canal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1829,7 +1829,7 @@ static int core_anal_graph_construct_nodes(RCore *core, RAnalFunction *fcn, int
snprintf (key, sizeof (key), "bb.0x%08"PFMT64x".size", bbi->addr);
sdb_num_set (DB, key, bbi->size, 0); // bb.<addr>.size=<num>
} else if (is_json) {
RDebugTracepoint *t = r_debug_trace_get (core->dbg, bbi->addr);
RDebugTracepointItem *t = r_debug_trace_get (core->dbg, bbi->addr);
pj_o (pj);
pj_kn (pj, "offset", bbi->addr);
pj_kn (pj, "size", bbi->size);
Expand Down Expand Up @@ -3416,11 +3416,11 @@ static int fcn_print_detail(RCore *core, RAnalFunction *fcn) {
return 0;
}

R_VEC_TYPE(RVecDebugTracepoint, RDebugTracepoint);
R_VEC_TYPE(RVecDebugTracepoint, RDebugTracepointItem);

static bool is_fcn_traced(RDebugTrace *traced, RAnalFunction *fcn) {
int tag = traced->tag;
RDebugTracepoint *trace;
RDebugTracepointItem *trace;
R_VEC_FOREACH (traced->traces, trace) {
if (!trace->tag || (tag & trace->tag)) {
if (r_anal_function_contains (fcn, trace->addr)) {
Expand Down
2 changes: 1 addition & 1 deletion libr/core/cmd_anal.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3316,7 +3316,7 @@ static void print_bb(PJ *pj, const RAnalBlock *b, const RAnalFunction *fcn, cons
}

static bool anal_fcn_list_bb(RCore *core, const char *input, bool one) {
RDebugTracepoint *tp = NULL;
RDebugTracepointItem *tp = NULL;
RListIter *iter;
RAnalBlock *b;
int mode = 0;
Expand Down
8 changes: 4 additions & 4 deletions libr/core/cmd_debug.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5415,19 +5415,19 @@ static ut8 *getFileData(RCore *core, const char *arg, int *sz) {
return out;
}

R_VEC_TYPE(RVecDebugTracepoint, RDebugTracepoint);
R_VEC_TYPE(RVecDebugTracepoint, RDebugTracepointItem);

static int cmd_debug(void *data, const char *input) {
RCore *core = (RCore *)data;
RDebugTracepoint *t;
RDebugTracepointItem *t;
bool do_follow = false;
const char *ptr;
ut64 addr;
int min;
RListIter *iter;
RList *list;
RDebugPid *p;
RDebugTracepoint *trace;
RDebugTracepointItem *trace;
RAnalOp *op;
int ret = 0;
ut64 old_seek = core->offset;
Expand Down Expand Up @@ -5580,7 +5580,7 @@ static int cmd_debug(void *data, const char *input) {
}
RAnalOp *op = r_core_op_anal (core, addr, R_ARCH_OP_MASK_HINT);
if (op) {
RDebugTracepoint *tp = r_debug_trace_add (core->dbg, addr, op->size);
RDebugTracepointItem *tp = r_debug_trace_add (core->dbg, addr, op->size);
if (tp) {
tp->count = count;
r_anal_trace_bb (core->anal, addr);
Expand Down
4 changes: 2 additions & 2 deletions libr/core/disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3424,7 +3424,7 @@ static void ds_print_offset(RDisasmState *ds) {
// label = r_core_get_reloff (ds->core, ds->show_reloff_to, at, &delta);
}
if (ds->show_trace) {
RDebugTracepoint *tp = r_debug_trace_get (ds->core->dbg, ds->at);
RDebugTracepointItem *tp = r_debug_trace_get (ds->core->dbg, ds->at);
show_trace = (tp? !!tp->count: false);
}
if (ds->hint && ds->hint->high) {
Expand Down Expand Up @@ -3478,7 +3478,7 @@ static void ds_print_op_size(RDisasmState *ds) {
}

static void ds_print_trace(RDisasmState *ds) {
RDebugTracepoint *tp = NULL;
RDebugTracepointItem *tp = NULL;
if (ds->show_trace && ds->show_trace_stats) {
tp = r_debug_trace_get (ds->core->dbg, ds->at);
r_cons_printf ("%02x:%04x ", tp?tp->times:0, tp?tp->count:0);
Expand Down
22 changes: 11 additions & 11 deletions libr/debug/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <r_util/r_str.h>
#include <sdb/ht_pu.h>

R_VEC_TYPE(RVecDebugTracepoint, RDebugTracepoint);
R_VEC_TYPE(RVecDebugTracepoint, RDebugTracepointItem);

R_API RDebugTrace *r_debug_trace_new(void) {
RDebugTrace *t = R_NEW0 (RDebugTrace);
Expand Down Expand Up @@ -203,7 +203,7 @@ R_API void r_debug_trace_at(RDebug *dbg, const char *str) {
dbg->trace->addresses = R_STR_ISNOTEMPTY (str)? strdup (str): NULL;
}

R_API RDebugTracepoint *r_debug_trace_get(RDebug *dbg, ut64 addr) {
R_API RDebugTracepointItem *r_debug_trace_get(RDebug *dbg, ut64 addr) {
R_RETURN_VAL_IF_FAIL (dbg && dbg->trace, NULL);
const int tag = dbg->trace->tag;
r_strf_var (key, 64, "%d.%"PFMT64x, tag, addr);
Expand All @@ -229,7 +229,7 @@ static void r_debug_trace_list_json(RDebug *dbg) {
pj_kn (pj, "tag", tag);
pj_ka (pj, "traces");

RDebugTracepoint *trace;
RDebugTracepointItem *trace;
R_VEC_FOREACH (dbg->trace->traces, trace) {
if (!trace->tag || (tag & trace->tag)) {
pj_o (pj);
Expand All @@ -251,7 +251,7 @@ static void r_debug_trace_list_json(RDebug *dbg) {

static void r_debug_trace_list_quiet(RDebug *dbg) {
int tag = dbg->trace->tag;
RDebugTracepoint *trace;
RDebugTracepointItem *trace;
R_VEC_FOREACH (dbg->trace->traces, trace) {
if (!trace->tag || (tag & trace->tag)) {
dbg->cb_printf ("0x%"PFMT64x"\n", trace->addr);
Expand All @@ -274,7 +274,7 @@ static void r_debug_trace_list_table(RDebug *dbg, ut64 offset, RTable *t) {
bool flag = false;
int tag = dbg->trace->tag;

RDebugTracepoint *trace;
RDebugTracepointItem *trace;
R_VEC_FOREACH (dbg->trace->traces, trace) {
if (!trace->tag || (tag & trace->tag)) {
RListInfo *info = RVecListInfo_emplace_back (&info_vec);
Expand Down Expand Up @@ -308,7 +308,7 @@ static void r_debug_trace_list_table(RDebug *dbg, ut64 offset, RTable *t) {

static void r_debug_trace_list_make(RDebug *dbg) {
int tag = dbg->trace->tag;
RDebugTracepoint *trace;
RDebugTracepointItem *trace;
R_VEC_FOREACH (dbg->trace->traces, trace) {
if (!trace->tag || (tag & trace->tag)) {
dbg->cb_printf ("dt+ 0x%"PFMT64x" %d\n", trace->addr, trace->times);
Expand All @@ -318,7 +318,7 @@ static void r_debug_trace_list_make(RDebug *dbg) {

static void r_debug_trace_list_default(RDebug *dbg) {
int tag = dbg->trace->tag;
RDebugTracepoint *trace;
RDebugTracepointItem *trace;
R_VEC_FOREACH (dbg->trace->traces, trace) {
if (!trace->tag || (tag & trace->tag)) {
dbg->cb_printf ("0x%08"PFMT64x" size=%d count=%d times=%d tag=%d\n",
Expand Down Expand Up @@ -360,17 +360,17 @@ static bool r_debug_trace_is_traceable(RDebug *dbg, ut64 addr) {
return true;
}

R_API RDebugTracepoint *r_debug_trace_add(RDebug *dbg, ut64 addr, int size) {
R_API RDebugTracepointItem *r_debug_trace_add(RDebug *dbg, ut64 addr, int size) {
R_RETURN_VAL_IF_FAIL (dbg, NULL);
const int tag = dbg->trace->tag;
if (!r_debug_trace_is_traceable (dbg, addr)) {
return NULL;
}
r_anal_trace_bb (dbg->anal, addr);
int last_times = 1;
RDebugTracepoint *last = r_debug_trace_get (dbg, addr);
RDebugTracepointItem *last = r_debug_trace_get (dbg, addr);
if (last) {
RDebugTracepoint *endtp = RVecDebugTracepoint_last (dbg->trace->traces);
RDebugTracepointItem *endtp = RVecDebugTracepoint_last (dbg->trace->traces);
if (last == endtp) {
// avoid tracing the same instruction twice
return NULL;
Expand All @@ -379,7 +379,7 @@ R_API RDebugTracepoint *r_debug_trace_add(RDebug *dbg, ut64 addr, int size) {
}
int pos = RVecDebugTracepoint_length (dbg->trace->traces) + 1;
// emplacedback pointers are not constant, so we may rely on the index instead of ptr
RDebugTracepoint *tp = RVecDebugTracepoint_emplace_back (dbg->trace->traces);
RDebugTracepointItem *tp = RVecDebugTracepoint_emplace_back (dbg->trace->traces);
if (R_LIKELY (tp)) {
tp->stamp = r_time_now ();
tp->addr = addr;
Expand Down
11 changes: 5 additions & 6 deletions libr/include/r_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,8 @@ typedef struct r_debug_trace_t {
HtPP *ht; // use rbtree like the iocache?
} RDebugTrace;

// R2_590 rename to traceitem for consistency?
#define r_debug_tracepoint_free(x) free((x))
typedef struct r_debug_tracepoint_t {
#define r_debug_tracepoint_item_free(x) free((x))
typedef struct r_debug_tracepoint_item_t {
ut64 addr;
ut64 tags; // XXX
int tag; // XXX
Expand All @@ -253,7 +252,7 @@ typedef struct r_debug_tracepoint_t {
ut64 refaddr;
int direction
#endif
} RDebugTracepoint;
} RDebugTracepointItem;

typedef struct r_debug_t RDebug;

Expand Down Expand Up @@ -588,9 +587,9 @@ R_API void r_debug_trace_reset(RDebug *dbg);
R_API bool r_debug_trace_pc(RDebug *dbg, ut64 pc);
R_API void r_debug_trace_op(RDebug *dbg, RAnalOp *op);
R_API void r_debug_trace_at(RDebug *dbg, const char *str);
R_API RDebugTracepoint *r_debug_trace_get(RDebug *dbg, ut64 addr);
R_API RDebugTracepointItem *r_debug_trace_get(RDebug *dbg, ut64 addr);
R_API void r_debug_trace_list(RDebug *dbg, int mode, ut64 offset, RTable *t);
R_API RDebugTracepoint *r_debug_trace_add(RDebug *dbg, ut64 addr, int size);
R_API RDebugTracepointItem *r_debug_trace_add(RDebug *dbg, ut64 addr, int size);
R_API RDebugTrace *r_debug_trace_new(void);
R_API void r_debug_trace_free(RDebugTrace *dbg);
R_API int r_debug_trace_tag(RDebug *dbg, int tag);
Expand Down

0 comments on commit 3a17978

Please sign in to comment.