Skip to content

Commit dc10b40

Browse files
[lldb][swift] Add target option for caching task ptr locations
This is a useful fallback for debugging.
1 parent bc54055 commit dc10b40

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

lldb/include/lldb/Target/Target.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ class TargetProperties : public Properties {
201201

202202
bool GetSwiftUseTasksPlugin() const;
203203

204+
bool GetSwiftCacheTaskPtrLocation() const;
205+
204206
Args GetSwiftPluginServerForPath() const;
205207

206208
bool GetSwiftAutoImportFrameworks() const;

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntime.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3006,7 +3006,8 @@ TaskInspector::GetTaskAddrFromThreadLocalStorage(Thread &thread) {
30063006
// If the read from this TLS address is successful, cache the TLS address.
30073007
// Caching without a valid read is dangerous: earlier in the thread
30083008
// lifetime, the result of GetExtendedInfo can be invalid.
3009-
if (task_addr)
3009+
if (task_addr &&
3010+
real_thread.GetProcess()->GetTarget().GetSwiftCacheTaskPtrLocation())
30103011
m_tid_to_task_addr_location.try_emplace(real_thread.GetID(),
30113012
*task_addr_location);
30123013
return task_addr;

lldb/source/Target/Target.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4529,6 +4529,18 @@ bool TargetProperties::GetSwiftUseTasksPlugin() const {
45294529
return true;
45304530
}
45314531

4532+
bool TargetProperties::GetSwiftCacheTaskPtrLocation() const {
4533+
const Property *exp_property =
4534+
m_collection_sp->GetPropertyAtIndex(ePropertyExperimental);
4535+
OptionValueProperties *exp_values =
4536+
exp_property->GetValue()->GetAsProperties();
4537+
if (exp_values)
4538+
return exp_values
4539+
->GetPropertyAtIndexAs<bool>(ePropertySwiftCacheTaskPtrLocation)
4540+
.value_or(true);
4541+
return true;
4542+
}
4543+
45324544
Args TargetProperties::GetSwiftPluginServerForPath() const {
45334545
const uint32_t idx = ePropertySwiftPluginServerForPath;
45344546

lldb/source/Target/TargetProperties.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ let Definition = "target_experimental" in {
3434
def SwiftUseTasksPlugin: Property<"swift-tasks-plugin-enabled", "Boolean">,
3535
DefaultTrue,
3636
Desc<"Enables the swift plugin converting tasks into threads">;
37+
def SwiftCacheTaskPtrLocation: Property<"swift-cache-task-ptr-location", "Boolean">,
38+
DefaultTrue,
39+
Desc<"Enables caching of task pointers inside the swift tasks plugin">;
3740
}
3841

3942
let Definition = "target" in {

0 commit comments

Comments
 (0)