| 288 | } |
| 289 | |
| 290 | std::vector<NativeFrame> |
| 291 | AbstractUnwinder::gatherFrames(const std::vector<Frame>& frames) const |
| 292 | { |
| 293 | std::vector<NativeFrame> native_frames; |
| 294 | for (auto& frame : frames) { |
| 295 | LOG(DEBUG) << std::hex << std::showbase << "Resolving native information for frame @ " |
| 296 | << frame.pc; |
| 297 | Dwarf_Addr pc = frame.pc; |
| 298 | bool isactivation = frame.isActivation; |
| 299 | Dwarf_Addr pc_adjusted = pc - (isactivation ? 0 : 1); |
| 300 | |
| 301 | Dwfl_Module* mod = dwfl_addrmodule(Dwfl(), pc_adjusted); |
| 302 | const char* mod_name = |
| 303 | dwfl_module_info(mod, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr) |
| 304 | ?: "???"; |
| 305 | assert(mod_name != nullptr); |
| 306 | LOG(DEBUG) << "Module identified for pc " << std::hex << std::showbase << pc << ": " << mod_name; |
| 307 | const char* raw_symname = getNonInlineSymbolName(mod, pc); |
| 308 | if (!raw_symname) { |
| 309 | LOG(DEBUG) << std::hex << std::showbase << "Non-inline symbol name could not be resolved @ " |
| 310 | << pc; |
| 311 | continue; |
| 312 | } |
| 313 | |
| 314 | const std::string noninline_symbol = raw_symname; |
| 315 | |
| 316 | Dwarf_Addr bias = 0; |
| 317 | Dwarf_Die* cudie = dwarfModuleAddrDie(pc_adjusted, mod, &bias); |
| 318 | if (!cudie) { |
| 319 | LOG(DEBUG) << std::hex << std::showbase << "Main compilation unit for pc " << pc << " (" |
| 320 | << noninline_symbol << ")" |
| 321 | << " could not be found"; |
| 322 | native_frames.push_back({pc, demangleSymbol(noninline_symbol), "???", 0, 0, mod_name}); |
| 323 | continue; |
| 324 | } |
| 325 | |
| 326 | const auto pc_corrected = pc_adjusted - bias; |
| 327 | gatherInlineFrames(native_frames, noninline_symbol, pc, pc_corrected, cudie, mod_name); |
| 328 | } |
| 329 | return native_frames; |
| 330 | } |
| 331 | |
| 332 | Dwarf_Die* |
| 333 | AbstractUnwinder::dwarfModuleAddrDie(Dwarf_Addr pc_adjusted, Dwfl_Module* mod, Dwarf_Addr* bias) const |