@@ -2642,30 +2642,32 @@ std::optional<lldb::addr_t> SwiftLanguageRuntime::TrySkipVirtualParentProlog(
2642
2642
return pc_value + prologue_size;
2643
2643
}
2644
2644
2645
- std::optional<lldb::addr_t > GetTaskAddrFromThreadLocalStorage (Thread &thread) {
2645
+ llvm::Expected<lldb::addr_t > GetTaskAddrFromThreadLocalStorage (Thread &thread) {
2646
+ #if SWIFT_THREADING_USE_DIRECT_TSD
2647
+ return llvm::createStringError (
2648
+ " getting the current task from a thread is not supported" );
2649
+ #else
2646
2650
// Compute the thread local storage address for this thread.
2647
- StructuredData::ObjectSP info_root_sp = thread.GetExtendedInfo ();
2648
- if (!info_root_sp)
2649
- return {};
2650
- StructuredData::ObjectSP node =
2651
- info_root_sp->GetObjectForDotSeparatedPath (" tsd_address" );
2652
- if (!node)
2653
- return {};
2654
- StructuredData::UnsignedInteger *raw_tsd_addr = node->GetAsUnsignedInteger ();
2655
- if (!raw_tsd_addr)
2656
- return {};
2657
- addr_t tsd_addr = raw_tsd_addr->GetUnsignedIntegerValue ();
2651
+ addr_t tsd_addr = LLDB_INVALID_ADDRESS;
2652
+ if (auto info_sp = thread.GetExtendedInfo ())
2653
+ if (auto *info_dict = info_sp->GetAsDictionary ())
2654
+ info_dict->GetValueForKeyAsInteger (" tsd_address" , tsd_addr);
2655
+
2656
+ if (tsd_addr == LLDB_INVALID_ADDRESS)
2657
+ return llvm::createStringError (" could not read current task from thread" );
2658
2658
2659
2659
// Offset of the Task pointer in a Thread's local storage.
2660
2660
Process &process = *thread.GetProcess ();
2661
2661
size_t ptr_size = process.GetAddressByteSize ();
2662
2662
uint64_t task_ptr_offset_in_tls =
2663
2663
swift::tls_get_key (swift::tls_key::concurrency_task) * ptr_size;
2664
2664
addr_t task_addr_location = tsd_addr + task_ptr_offset_in_tls;
2665
- Status error;
2666
- addr_t task_addr = process.ReadPointerFromMemory (task_addr_location, error);
2667
- if (error.Fail ())
2668
- return {};
2665
+ Status status;
2666
+ addr_t task_addr = process.ReadPointerFromMemory (task_addr_location, status);
2667
+ if (status.Fail ())
2668
+ return llvm::createStringError (" could not get current task from thread: %s" ,
2669
+ status.AsCString ());
2669
2670
return task_addr;
2671
+ #endif
2670
2672
}
2671
2673
} // namespace lldb_private
0 commit comments