return true;
}
-static void import(struct protolib *plib, struct library *lib, Dwfl *dwfl)
+static void import(struct protolib *plib, struct library *lib,
+ Dwfl_Module *dwfl_module)
{
// A map from DIE addresses (Dwarf_Off) to type structures (struct
// arg_type_info*). This is created and filled in at the start of each
Dwarf_Addr bias;
Dwarf_Die *die = NULL;
- while ((die = dwfl_nextcu(dwfl, die, &bias)) != NULL) {
+ while ((die = dwfl_module_nextcu(dwfl_module, die, &bias)) != NULL) {
if (dwarf_tag(die) == DW_TAG_compile_unit)
process_die_compileunit(plib, lib,
&type_dieoffset_hash, die);
bool import_DWARF_prototypes(struct library *lib)
{
struct protolib *plib = lib->protolib;
- Dwfl *dwfl = lib->dwfl;
debug(DEBUG_FUNCTION, "Importing DWARF prototypes from '%s'",
lib->soname);
}
}
- import(plib, lib, dwfl);
+ import(plib, lib, lib->dwfl_module);
lib->protolib = plib;
return true;
lib->type = type;
#if defined(HAVE_LIBDW)
- lib->dwfl = NULL;
+ lib->dwfl_module = NULL;
#endif
}
struct os_library_data os;
#if defined(HAVE_LIBDW)
- Dwfl *dwfl;
+ Dwfl_Module *dwfl_module;
#endif
};
#if defined(HAVE_LIBDW)
// DWARF data fills in the gaps in the .conf files, so I don't
// check for lib->protolib==NULL here
- if (lib->dwfl != NULL &&
+ if (lib->dwfl_module != NULL &&
(filter_matches_library(options.plt_filter, lib ) ||
filter_matches_library(options.static_filter, lib ) ||
filter_matches_library(options.export_filter, lib )))
#if defined(HAVE_LIBDW)
proc->dwfl = NULL; /* Initialize for leader only on first library. */
+ proc->should_attach_dwfl = 1; /* should try to attach the DWFL data */
#endif /* defined(HAVE_LIBDW) */
return 0;
#if defined(HAVE_LIBDW)
Dwfl *dwfl = NULL;
+ Dwfl_Module *dwfl_module = NULL;
/* Setup module tracking for libdwfl unwinding. */
struct process *leader = proc->leader;
if (dwfl != NULL) {
dwfl_report_begin_add(dwfl);
- if (dwfl_report_elf(dwfl, lib->soname,
- lib->pathname, -1,
- (GElf_Addr) lib->base,
- false) == NULL)
+ dwfl_module =
+ dwfl_report_elf(dwfl, lib->soname,
+ lib->pathname, -1,
+ (GElf_Addr) lib->base,
+ false);
+ if (dwfl_module == NULL)
fprintf(stderr,
"dwfl_report_elf %s@%p (%s) %d: %s\n",
lib->soname, lib->base, lib->pathname,
proc->pid, dwfl_errmsg (-1));
+
dwfl_report_end(dwfl, NULL, NULL);
if (options.bt_depth > 0) {
- if (leader->dwfl == NULL) {
+ if (proc->should_attach_dwfl) {
int r = dwfl_linux_proc_attach(dwfl,
leader->pid,
true);
- if (r == 0)
- leader->dwfl = dwfl;
- else {
+ proc->should_attach_dwfl = 0;
+ if (r != 0) {
const char *msg;
dwfl_end(dwfl);
if (r < 0)
}
}
- lib->dwfl = dwfl;
+ lib->dwfl_module = dwfl_module;
+ leader->dwfl = dwfl;
#endif /* defined(HAVE_LIBDW) */
#if defined(HAVE_LIBDW)
/* Unwind info for leader, NULL for non-leader procs. */
Dwfl *dwfl;
+
+ /* Whether we still need to attach the DWARF library to this process. We
+ * try only once, and never again, regardless of whether we succeeded or
+ * not. 0 = shouldn't attach */
+ int should_attach_dwfl;
+
#endif /* defined(HAVE_LIBDW) */
#if defined(HAVE_LIBUNWIND)