dwfl_ptr.get()->dwfl);
}
-void
-dwflpp::iterate_over_modules(int (* callback)(Dwfl_Module *, void **,
- const char *, Dwarf_Addr,
- void *),
- void *data)
+template<> void
+dwflpp::iterate_over_modules<void>(int (*callback)(Dwfl_Module*,
+ void**,
+ const char*,
+ Dwarf_Addr,
+ void*),
+ void *data)
{
dwfl_getmodules (dwfl_ptr.get()->dwfl, callback, data, 0);
bool function_name_matches(const std::string& pattern);
bool function_scope_matches(const std::vector<std::string>& scopes);
- void iterate_over_modules(int (* callback)(Dwfl_Module *, void **,
- const char *, Dwarf_Addr,
- void *),
- void *data);
+ template<typename T>
+ void iterate_over_modules(int (* callback)(Dwfl_Module*,
+ void**,
+ const char*,
+ Dwarf_Addr,
+ T*),
+ T *data)
+ {
+ /* We're using templates here to enforce type-safety between the data arg
+ * we're requested to pass to callback, and the data arg that the callback
+ * actually takes. Rather than putting the implementation here, we simply
+ * call the <void> specialization, which does the real work.
+ * As a result, we need to cast the data arg in the callback signature
+ * and the one passed to void* (which is what elfutils also works with).
+ * */
+ iterate_over_modules<void>((int (*)(Dwfl_Module*,
+ void**,
+ const char*,
+ Dwarf_Addr,
+ void *))callback,
+ (void*)data);
+ }
void iterate_over_cus (int (*callback)(Dwarf_Die * die, void * arg),
void * data, bool want_types);
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 iterate_over_globals (Dwarf_Die *,
int (* callback)(Dwarf_Die *, bool,
const std::string&, void *),
Dwarf_Addr pr15123_retry_addr (Dwarf_Addr pc, Dwarf_Die* var);
};
+template<> void
+dwflpp::iterate_over_modules<void>(int (*callback)(Dwfl_Module*,
+ void**,
+ const char*,
+ Dwarf_Addr,
+ void*),
+ void *data);
+
#endif // DWFLPP_H
/* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */
void **,
const char *name,
Dwarf_Addr addr,
- void *arg)
+ base_query *q)
{
- base_query *q = static_cast<base_query *>(arg);
-
try
{
module_info* mi = q->sess.module_cache->cache[name];
}
dwarf_cast_query q (*dw, module, *e, lvalue, userspace_p, result);
- dw->iterate_over_modules(&query_module, &q);
+ dw->iterate_over_modules<base_query>(&query_module, &q);
}
if (!result)
}
dwarf_atvar_query q (*dw, module, *e, userspace_p, lvalue, result, tick);
- dw->iterate_over_modules(&query_module, &q);
+ dw->iterate_over_modules<base_query>(&query_module, &q);
if (result)
{
// V1 probes always need dwarf info
// V2+ probes need dwarf info in case of a variable reference
if (have_debuginfo_uprobe(need_debug_info))
- dw.iterate_over_modules(&query_module, &q);
+ dw.iterate_over_modules<base_query>(&query_module, &q);
// For V2+ probes, if variable references weren't used or failed (PR14369),
// then try with the more direct approach. Unresolved $vars might still
if (get_param(parameters, TOK_MARK, dummy_mark_name))
{
sdt_query sdtq(base, location, *dw, filled_parameters, finished_results, user_lib);
- dw->iterate_over_modules(&query_module, &sdtq);
+ dw->iterate_over_modules<base_query>(&query_module, &sdtq);
// We need to update modules_seen with the modules we've visited
modules_seen.insert(sdtq.visited_modules.begin(),
return;
}
- dw->iterate_over_modules(&query_module, &q);
+ dw->iterate_over_modules<base_query>(&query_module, &q);
// We need to update modules_seen with the modules we've visited
modules_seen.insert(q.visited_modules.begin(),
tracepoint_query q(*dw, tracepoint, base, location, finished_results);
unsigned results_pre = finished_results.size();
- dw->iterate_over_modules(&query_module, &q);
+ dw->iterate_over_modules<base_query>(&query_module, &q);
unsigned results_post = finished_results.size();
// Did we fail to find a match? Let's suggest something!
void **,
const char *,
Dwarf_Addr,
- void *arg)
+ struct dwflpp *dwflpp)
{
- ((struct dwflpp*)arg)->focus_on_module(mod, NULL);
+ dwflpp->focus_on_module(mod, NULL);
return DWARF_CB_OK;
}
if (! is_user_module (modname)) continue;
struct dwflpp *mod_dwflpp = new dwflpp(s, modname, false);
- mod_dwflpp->iterate_over_modules (&query_module, mod_dwflpp);
+ mod_dwflpp->iterate_over_modules(&query_module, mod_dwflpp);
if (mod_dwflpp->module) // existing binary
{
assert (mod_dwflpp->module_name != "");