Skip to content

Commit f7fe371

Browse files
Merge pull request #11100 from felipepiovezan/felipe/unwinder_callback_62
🍒 [lldb] Clear Frames when changing `disable-language-runtime-unwindplans` (llvm#151208)
2 parents 851a661 + 3c902c1 commit f7fe371

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-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>(
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SWIFT_SOURCES := main.swift
2+
SWIFTFLAGS_EXTRAS := -parse-as-library
3+
include Makefile.rules
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import lldb
2+
from lldbsuite.test.decorators import *
3+
import lldbsuite.test.lldbtest as lldbtest
4+
import lldbsuite.test.lldbutil as lldbutil
5+
6+
class TestDisableLanguageUnwinder(lldbtest.TestBase):
7+
8+
@swiftTest
9+
@skipIf(oslist=['windows', 'linux'])
10+
def test(self):
11+
"""Test async unwind"""
12+
self.build()
13+
src = lldb.SBFileSpec('main.swift')
14+
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
15+
self, 'break here', src)
16+
17+
self.assertIn("syncFunc", thread.GetFrameAtIndex(0).GetFunctionName())
18+
self.assertIn("callSyncFunc", thread.GetFrameAtIndex(1).GetFunctionName())
19+
self.assertIn("main", thread.GetFrameAtIndex(2).GetFunctionName())
20+
21+
self.runCmd("settings set target.process.disable-language-runtime-unwindplans true")
22+
23+
self.assertIn("syncFunc", thread.GetFrameAtIndex(0).GetFunctionName())
24+
self.assertIn("callSyncFunc", thread.GetFrameAtIndex(1).GetFunctionName())
25+
self.assertNotIn("main", thread.GetFrameAtIndex(2).GetFunctionName())
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
func syncFunc() {
2+
print("break here")
3+
}
4+
5+
func callSyncFunc() async {
6+
syncFunc()
7+
}
8+
9+
@main struct Main {
10+
static func main() async {
11+
await callSyncFunc()
12+
}
13+
}

0 commit comments

Comments
 (0)