Skip to content

Commit af68570

Browse files
authored
Merge pull request #10456 from swiftlang/cherrypick-swift/release/6.2-e84a80408523
[🍒 swift/release/6.2] [lldb] Make sure the process is stopped when computing the symbol context (llvm#134757)
2 parents 274658c + 8ed72ef commit af68570

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

lldb/source/Core/Statusline.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "lldb/Host/StreamFile.h"
1313
#include "lldb/Interpreter/CommandInterpreter.h"
1414
#include "lldb/Symbol/SymbolContext.h"
15+
#include "lldb/Target/Process.h"
1516
#include "lldb/Target/StackFrame.h"
1617
#include "lldb/Utility/AnsiTerminal.h"
1718
#include "lldb/Utility/StreamString.h"
@@ -119,19 +120,25 @@ void Statusline::Redraw(bool update) {
119120
return;
120121
}
121122

122-
StreamString stream;
123-
ExecutionContext exe_ctx =
124-
m_debugger.GetCommandInterpreter().GetExecutionContext();
123+
ExecutionContext exe_ctx = m_debugger.GetSelectedExecutionContext();
125124

126125
// For colors and progress events, the format entity needs access to the
127126
// debugger, which requires a target in the execution context.
128127
if (!exe_ctx.HasTargetScope())
129128
exe_ctx.SetTargetPtr(&m_debugger.GetSelectedOrDummyTarget());
130129

131130
SymbolContext symbol_ctx;
132-
if (auto frame_sp = exe_ctx.GetFrameSP())
133-
symbol_ctx = frame_sp->GetSymbolContext(eSymbolContextEverything);
131+
if (ProcessSP process_sp = exe_ctx.GetProcessSP()) {
132+
// Check if the process is stopped, and if it is, make sure it remains
133+
// stopped until we've computed the symbol context.
134+
Process::StopLocker stop_locker;
135+
if (stop_locker.TryLock(&process_sp->GetRunLock())) {
136+
if (auto frame_sp = exe_ctx.GetFrameSP())
137+
symbol_ctx = frame_sp->GetSymbolContext(eSymbolContextEverything);
138+
}
139+
}
134140

141+
StreamString stream;
135142
if (auto *format = m_debugger.GetStatuslineFormat())
136143
FormatEntity::Format(*format, stream, &symbol_ctx, &exe_ctx, nullptr,
137144
nullptr, false, false);

0 commit comments

Comments
 (0)