================ @@ -176,10 +170,24 @@ HistoryThreads MemoryHistoryASan::GetHistoryThreads(lldb::addr_t address) { options.SetAutoApplyFixIts(false); options.SetLanguage(eLanguageTypeObjC_plus_plus); + // The ASan compiler-rt runtime already massages the return addresses into + // call addresses, so we don't want LLDB's unwinder to try to locate the + // previous instruction again as this might lead to us reporting a different + // line. + auto pc_type = TracePCType::Calls; + if (auto m = GetPreferredAsanModule(process_sp->GetTarget())) { SymbolContextList sc_list; sc_list.Append(SymbolContext(std::move(m))); options.SetPreferredSymbolContexts(std::move(sc_list)); + } else if (process_sp->GetTarget() + .GetArchitecture() + .GetTriple() + .isOSDarwin()) { + // Darwin, but not ASan compiler-rt implies libsanitizers which collects + // return addresses. It also discards a few non-user frames at the top of + // the stack. + pc_type = TracePCType::ReturnsNoZerothFrame; } ---------------- JDevlieghere wrote:
Could we refactor `GetPreferredAsanModule` to abstract over this, instead of having no module + darwin _imply_ libsantizers? This could return a: ``` struct { TracePCType pc_type; ModuleSP asan_module; } ``` https://github.com/llvm/llvm-project/pull/154247 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits