Skip to content

Commit 03bb10b

Browse files
[lldb] Clear Frames when changing disable-language-runtime-unwindplans (#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.
1 parent 4e596fc commit 03bb10b

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
@@ -166,6 +166,9 @@ ProcessProperties::ProcessProperties(lldb_private::Process *process)
166166
m_collection_sp->SetValueChangedCallback(
167167
ePropertyPythonOSPluginPath,
168168
[this] { m_process->LoadOperatingSystemPlugin(true); });
169+
m_collection_sp->SetValueChangedCallback(
170+
ePropertyDisableLangRuntimeUnwindPlans,
171+
[this] { DisableLanguageRuntimeUnwindPlansCallback(); });
169172
}
170173

171174
m_experimental_properties_up =
@@ -280,6 +283,15 @@ void ProcessProperties::SetDisableLangRuntimeUnwindPlans(bool disable) {
280283
m_process->Flush();
281284
}
282285

286+
void ProcessProperties::DisableLanguageRuntimeUnwindPlansCallback() {
287+
if (!m_process)
288+
return;
289+
for (auto thread_sp : m_process->Threads()) {
290+
thread_sp->ClearStackFrames();
291+
thread_sp->DiscardThreadPlans(/*force*/ true);
292+
}
293+
}
294+
283295
bool ProcessProperties::GetDetachKeepsStopped() const {
284296
const uint32_t idx = ePropertyDetachKeepsStopped;
285297
return GetPropertyAtIndexAs<bool>(

0 commit comments

Comments
 (0)