File tree Expand file tree Collapse file tree 4 files changed +23
-23
lines changed
InstrumentationRuntime/Utility Expand file tree Collapse file tree 4 files changed +23
-23
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ ReportRetriever::RetrieveReportData(const ProcessSP process_sp) {
8383 options.SetAutoApplyFixIts (false );
8484 options.SetLanguage (eLanguageTypeObjC_plus_plus);
8585
86- if (auto m = GetPreferredAsanModule (process_sp->GetTarget ())) {
86+ if (auto [m, _] = GetPreferredAsanModule (process_sp->GetTarget ()); m ) {
8787 SymbolContextList sc_list;
8888 sc_list.Append (SymbolContext (std::move (m)));
8989 options.SetPreferredSymbolContexts (std::move (sc_list));
Original file line number Diff line number Diff line change 1313
1414namespace lldb_private {
1515
16- lldb::ModuleSP GetPreferredAsanModule (const Target &target) {
17- // Currently only supported on Darwin.
16+ std::tuple<lldb::ModuleSP, HistoryPCType>
17+ GetPreferredAsanModule (const Target &target) {
18+ // Currently only Darwin provides ASan runtime support as part of the OS
19+ // (libsanitizers).
1820 if (!target.GetArchitecture ().GetTriple ().isOSDarwin ())
19- return nullptr ;
21+ return { nullptr , HistoryPCType::Calls} ;
2022
2123 lldb::ModuleSP module ;
2224 llvm::Regex pattern (R"( libclang_rt\.asan_.*_dynamic\.dylib)" );
@@ -29,7 +31,16 @@ lldb::ModuleSP GetPreferredAsanModule(const Target &target) {
2931 return IterationAction::Continue;
3032 });
3133
32- return module ;
34+ // `Calls` - The ASan compiler-rt runtime already massages the return
35+ // addresses into call addresses, so we don't want LLDB's unwinder to try to
36+ // locate the previous instruction again as this might lead to us reporting
37+ // a different line.
38+ // `ReturnsNoZerothFrame` - Darwin, but not ASan compiler-rt implies
39+ // libsanitizers which collects return addresses. It also discards a few
40+ // non-user frames at the top of the stack.
41+ auto pc_type =
42+ (module ? HistoryPCType::Calls : HistoryPCType::ReturnsNoZerothFrame);
43+ return {module , pc_type};
3344}
3445
3546} // namespace lldb_private
Original file line number Diff line number Diff line change 99#ifndef LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_UTILITY_UTILITY_H
1010#define LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_UTILITY_UTILITY_H
1111
12+ #include < tuple>
13+
1214#include " lldb/lldb-forward.h"
15+ #include " lldb/lldb-private-enumerations.h"
1316
1417namespace lldb_private {
1518
16- class Target ;
17-
1819// / On Darwin, if LLDB loaded libclang_rt, it's coming from a locally built
1920// / compiler-rt, and we should prefer it in favour of the system sanitizers
2021// / when running InstrumentationRuntime utility expressions that use symbols
2122// / from the sanitizer libraries. This helper searches the target for such a
2223// / dylib. Returns nullptr if no such dylib was found.
23- lldb::ModuleSP GetPreferredAsanModule (const Target &target);
24+ std::tuple<lldb::ModuleSP, HistoryPCType>
25+ GetPreferredAsanModule (const Target &target);
2426
2527} // namespace lldb_private
2628
Original file line number Diff line number Diff line change @@ -170,24 +170,11 @@ HistoryThreads MemoryHistoryASan::GetHistoryThreads(lldb::addr_t address) {
170170 options.SetAutoApplyFixIts (false );
171171 options.SetLanguage (eLanguageTypeObjC_plus_plus);
172172
173- // The ASan compiler-rt runtime already massages the return addresses into
174- // call addresses, so we don't want LLDB's unwinder to try to locate the
175- // previous instruction again as this might lead to us reporting a different
176- // line.
177- auto pc_type = HistoryPCType::Calls;
178-
179- if (auto m = GetPreferredAsanModule (process_sp->GetTarget ())) {
173+ auto [m, pc_type] = GetPreferredAsanModule (process_sp->GetTarget ());
174+ if (m) {
180175 SymbolContextList sc_list;
181176 sc_list.Append (SymbolContext (std::move (m)));
182177 options.SetPreferredSymbolContexts (std::move (sc_list));
183- } else if (process_sp->GetTarget ()
184- .GetArchitecture ()
185- .GetTriple ()
186- .isOSDarwin ()) {
187- // Darwin, but not ASan compiler-rt implies libsanitizers which collects
188- // return addresses. It also discards a few non-user frames at the top of
189- // the stack.
190- pc_type = HistoryPCType::ReturnsNoZerothFrame;
191178 }
192179
193180 ExpressionResults expr_result = UserExpression::Evaluate (
You can’t perform that action at this time.
0 commit comments