}
-void
-dwflpp::iterate_over_cus (int (*callback)(Dwarf_Die * die, void * arg),
- void * data, bool want_types)
+template<> void
+dwflpp::iterate_over_cus<void>(int (*callback)(Dwarf_Die*, void*),
+ void *data,
+ bool want_types)
{
get_module_dwarf(false);
Dwarf *dw = module_dwarf;
}
int
-dwflpp::global_alias_caching_callback_cus(Dwarf_Die *die, void *arg)
+dwflpp::global_alias_caching_callback_cus(Dwarf_Die *die, dwflpp *dw)
{
mod_cu_type_cache_t *global_alias_cache;
- global_alias_cache = &static_cast<dwflpp *>(arg)->global_alias_cache;
+ global_alias_cache = &dw->global_alias_cache;
cu_type_cache_t *v = (*global_alias_cache)[die->addr];
if (v != 0)
int
-dwflpp::cu_function_caching_callback (Dwarf_Die* func, void *arg)
+dwflpp::cu_function_caching_callback (Dwarf_Die* func, cu_function_cache_t *v)
{
- cu_function_cache_t* v = static_cast<cu_function_cache_t*>(arg);
const char *name = dwarf_diename(func);
if (!name)
return DWARF_CB_OK;
int
-dwflpp::mod_function_caching_callback (Dwarf_Die* cu, void *arg)
+dwflpp::mod_function_caching_callback (Dwarf_Die* cu, cu_function_cache_t *v)
{
- dwarf_getfuncs (cu, cu_function_caching_callback, arg, 0);
+ // need to cast callback to func which accepts void*
+ dwarf_getfuncs (cu, (int (*)(Dwarf_Die*, void*))cu_function_caching_callback,
+ v, 0);
return DWARF_CB_OK;
}
{
v = new cu_function_cache_t;
cu_function_cache[cu->addr] = v;
- dwarf_getfuncs (cu, cu_function_caching_callback, v, 0);
+ // need to cast callback to func which accepts void*
+ dwarf_getfuncs (cu, (int (*)(Dwarf_Die*, void*))cu_function_caching_callback,
+ v, 0);
if (sess.verbose > 4)
clog << _F("function cache %s:%s size %zu", module_name.c_str(),
cu_name().c_str(), v->size()) << endl;
};
int
-dwflpp::external_function_cu_callback (Dwarf_Die* cu, void *arg)
+dwflpp::external_function_cu_callback (Dwarf_Die* cu, external_function_query *efq)
{
- external_function_query * efq = static_cast<external_function_query *>(arg);
efq->dw->focus_on_cu(cu);
return efq->dw->iterate_over_functions(external_function_func_callback,
efq, efq->name);
struct symbol_table;
struct base_query;
struct dwarf_query;
+struct external_function_query;
enum line_t { ABSOLUTE, RELATIVE, RANGE, WILDCARD };
enum info_status { info_unknown, info_present, info_absent };
(void*)data);
}
- void iterate_over_cus (int (*callback)(Dwarf_Die * die, void * arg),
- void * data, bool want_types);
+ template<typename T>
+ void iterate_over_cus(int (* callback)(Dwarf_Die*, T*),
+ T *data,
+ bool want_types)
+ {
+ // See comment block in iterate_over_modules()
+ iterate_over_cus<void>((int (*)(Dwarf_Die*, void*))callback,
+ (void*)data,
+ want_types);
+ }
bool func_is_inline();
mod_cu_type_cache_t global_alias_cache;
static int global_alias_caching_callback(Dwarf_Die *die, bool has_inner_types,
const std::string& prefix, void *arg);
- static int global_alias_caching_callback_cus(Dwarf_Die *die, void *arg);
-
+ static int global_alias_caching_callback_cus(Dwarf_Die *die, dwflpp *dw);
static int iterate_over_globals (Dwarf_Die *,
int (* callback)(Dwarf_Die *, bool,
const std::string&, void *),
void * data);
- static int mod_function_caching_callback (Dwarf_Die* func, void *arg);
- static int cu_function_caching_callback (Dwarf_Die* func, void *arg);
- static int external_function_cu_callback (Dwarf_Die* cu, void *arg);
+ static int mod_function_caching_callback (Dwarf_Die* func, cu_function_cache_t *v);
+ static int cu_function_caching_callback (Dwarf_Die* func, cu_function_cache_t *v);
+ static int external_function_cu_callback (Dwarf_Die* cu, external_function_query *efq);
static int external_function_func_callback (Dwarf_Die* func, void *arg);
bool has_single_line_record (dwarf_query * q, char const * srcfile, int lineno);
Dwarf_Addr,
void*),
void *data);
+template<> void
+dwflpp::iterate_over_cus<void>(int (*callback)(Dwarf_Die*, void*),
+ void *data,
+ bool want_types);
#endif // DWFLPP_H
static const string TOK_CALLEE("callee");;
static const string TOK_CALLEES("callees");;
-static int query_cu (Dwarf_Die * cudie, void * arg);
+static int query_cu (Dwarf_Die * cudie, dwarf_query *q);
static void query_addr(Dwarf_Addr addr, dwarf_query *q);
static void query_plt_statement(dwarf_query *q);
}
static int
-query_cu (Dwarf_Die * cudie, void * arg)
+query_cu (Dwarf_Die * cudie, dwarf_query * q)
{
- dwarf_query * q = static_cast<dwarf_query *>(arg);
assert (q->has_statement_str || q->has_function_str);
if (pending_interrupts) return DWARF_CB_ABORT;
void handle_query_module ();
void query_library (const char *) {}
void query_plt (const char *entry, size_t addr) {}
- static int atvar_query_cu (Dwarf_Die *cudie, void *data);
+ static int atvar_query_cu (Dwarf_Die *cudie, dwarf_atvar_query *q);
};
int
-dwarf_atvar_query::atvar_query_cu (Dwarf_Die * cudie, void * data)
+dwarf_atvar_query::atvar_query_cu (Dwarf_Die * cudie, dwarf_atvar_query *q)
{
- dwarf_atvar_query * q = static_cast<dwarf_atvar_query *>(data);
-
if (! q->e.cu_name.empty())
{
const char *die_name = dwarf_diename(cudie) ?: "";
void query_library (const char *) {}
void query_plt (const char *entry, size_t addr) {}
- static int tracepoint_query_cu (Dwarf_Die * cudie, void * arg);
+ static int tracepoint_query_cu (Dwarf_Die * cudie, tracepoint_query * q);
static int tracepoint_query_func (Dwarf_Die * func, void * arg);
};
int
-tracepoint_query::tracepoint_query_cu (Dwarf_Die * cudie, void * arg)
+tracepoint_query::tracepoint_query_cu (Dwarf_Die * cudie, tracepoint_query * q)
{
- tracepoint_query * q = static_cast<tracepoint_query *>(arg);
if (pending_interrupts) return DWARF_CB_ABORT;
return q->handle_query_cu(cudie);
}