Skip to content

Commit f4fb5e6

Browse files
felipepiovezanaugusto2112
authored andcommitted
[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 dfab7c3 commit f4fb5e6

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
@@ -100,6 +100,7 @@ class ProcessProperties : public Properties {
100100
void SetStopOnSharedLibraryEvents(bool stop);
101101
bool GetDisableLangRuntimeUnwindPlans() const;
102102
void SetDisableLangRuntimeUnwindPlans(bool disable);
103+
void DisableLanguageRuntimeUnwindPlansCallback();
103104
bool GetDetachKeepsStopped() const;
104105
void SetDetachKeepsStopped(bool keep_stopped);
105106
bool GetWarningsOptimization() const;

lldb/source/Target/Process.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ ProcessProperties::ProcessProperties(lldb_private::Process *process)
171171
m_collection_sp->SetValueChangedCallback(
172172
ePropertyPythonOSPluginPath,
173173
[this] { m_process->LoadOperatingSystemPlugin(true); });
174+
m_collection_sp->SetValueChangedCallback(
175+
ePropertyDisableLangRuntimeUnwindPlans,
176+
[this] { DisableLanguageRuntimeUnwindPlansCallback(); });
174177
}
175178

176179
m_experimental_properties_up =
@@ -285,6 +288,15 @@ void ProcessProperties::SetDisableLangRuntimeUnwindPlans(bool disable) {
285288
m_process->Flush();
286289
}
287290

291+
void ProcessProperties::DisableLanguageRuntimeUnwindPlansCallback() {
292+
if (!m_process)
293+
return;
294+
for (auto thread_sp : m_process->Threads()) {
295+
thread_sp->ClearStackFrames();
296+
thread_sp->DiscardThreadPlans(/*force*/ true);
297+
}
298+
}
299+
288300
bool ProcessProperties::GetDetachKeepsStopped() const {
289301
const uint32_t idx = ePropertyDetachKeepsStopped;
290302
return GetPropertyAtIndexAs<bool>(

0 commit comments

Comments
 (0)