Skip to content

Commit df8f29b

Browse files
[lldb] Clear Frames when changing disable-language-runtime-unwindplans (llvm#151208)
This patch uses the "setting changed" callback to clear previously cached stack frames when `target.process.disable-language-runtime-unwindplans` is changed. This is necessary so that changing the setting followed by a `backtrace` command produces an accurate backtrace. With this, a user can create a custom command like below in order to quickly inspect a backtrace created without language plugins. ``` debugger.HandleCommand("settings set target.process.disable-language-runtime-unwindplans true") debugger.HandleCommand("bt " + command) debugger.HandleCommand("settings set target.process.disable-language-runtime-unwindplans false") ``` In the future, we may consider implementing this as an option to `backtrace`. Currently, this process setting is the only way of affecting the unwinder, and changing the process setting as part of the backtrace implementation doesn't feel right. There are no upstream users of this flag, so we cannot write a test for it here. (cherry picked from commit 03bb10b)
1 parent 92e60fa commit df8f29b

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lldb/include/lldb/Target/Process.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class ProcessProperties : public Properties {
9898
void SetStopOnSharedLibraryEvents(bool stop);
9999
bool GetDisableLangRuntimeUnwindPlans() const;
100100
void SetDisableLangRuntimeUnwindPlans(bool disable);
101+
void DisableLanguageRuntimeUnwindPlansCallback();
101102
bool GetDetachKeepsStopped() const;
102103
void SetDetachKeepsStopped(bool keep_stopped);
103104
bool GetWarningsOptimization() const;

lldb/source/Target/Process.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ ProcessProperties::ProcessProperties(lldb_private::Process *process)
207207
m_collection_sp->SetValueChangedCallback(
208208
ePropertyPythonOSPluginPath,
209209
[this] { m_process->LoadOperatingSystemPlugin(true); });
210+
m_collection_sp->SetValueChangedCallback(
211+
ePropertyDisableLangRuntimeUnwindPlans,
212+
[this] { DisableLanguageRuntimeUnwindPlansCallback(); });
210213
}
211214

212215
m_experimental_properties_up =
@@ -321,6 +324,15 @@ void ProcessProperties::SetDisableLangRuntimeUnwindPlans(bool disable) {
321324
m_process->Flush();
322325
}
323326

327+
void ProcessProperties::DisableLanguageRuntimeUnwindPlansCallback() {
328+
if (!m_process)
329+
return;
330+
for (auto thread_sp : m_process->Threads()) {
331+
thread_sp->ClearStackFrames();
332+
thread_sp->DiscardThreadPlans(/*force*/ true);
333+
}
334+
}
335+
324336
bool ProcessProperties::GetDetachKeepsStopped() const {
325337
const uint32_t idx = ePropertyDetachKeepsStopped;
326338
return GetPropertyAtIndexAs<bool>(

0 commit comments

Comments
 (0)