In building tracepoints, we try a late search for the kernel source tree
using DW_AT_comp_dir, and add extra includes based on that path. That
comp_dir is not always reliable though; for instance, Ubuntu leaves it
something like "/build/buildd/linux...", which is not an installed path.
(See also http://brainstorm.ubuntu.com/idea/11327)
* tapsets.cxx (tracepoint_builder::init_dw): Verify that the given
DW_AT_comp_dir actually exists before we use it.
assert_no_interrupts();
Dwarf_Attribute attr;
const char* name = dwarf_formstring (dwarf_attr (cudie, DW_AT_comp_dir, &attr));
- if (name)
+ if (name)
{
- if (s.verbose > 2)
- clog << _F("Located kernel source tree (DW_AT_comp_dir) at '%s'", name) << endl;
+ // check that the path actually exists locally before we try to use it
+ if (file_exists(name))
+ {
+ if (s.verbose > 2)
+ clog << _F("Located kernel source tree (DW_AT_comp_dir) at '%s'", name) << endl;
+ s.kernel_source_tree = name;
+ }
+ else
+ {
+ if (s.verbose > 2)
+ clog << _F("Ignoring inaccessible kernel source tree (DW_AT_comp_dir) at '%s'", name) << endl;
+ }
- s.kernel_source_tree = name;
break; // skip others; modern Kbuild uses same comp_dir for them all
}
}