================
@@ -1455,16 +1455,34 @@ StackFrameListSP Thread::GetStackFrameList() {
Target &target = process_sp->GetTarget();
const auto &descriptors = target.GetScriptedFrameProviderDescriptors();
- // Find first descriptor that applies to this thread.
+ // Collect all descriptors that apply to this thread.
+ std::vector<const ScriptedFrameProviderDescriptor *>
+ applicable_descriptors;
for (const auto &entry : descriptors) {
const ScriptedFrameProviderDescriptor &descriptor = entry.second;
if (descriptor.IsValid() && descriptor.AppliesToThread(*this)) {
- if (llvm::Error error = LoadScriptedFrameProvider(descriptor)) {
- LLDB_LOG_ERROR(GetLog(LLDBLog::Thread), std::move(error),
- "Failed to load scripted frame provider: {0}");
- }
- break; // Use first matching descriptor (success or failure).
+ applicable_descriptors.push_back(&descriptor);
+ }
+ }
+
+ // Sort by priority (lower number = higher priority).
+ std::sort(applicable_descriptors.begin(), applicable_descriptors.end(),
+ [](const ScriptedFrameProviderDescriptor *a,
+ const ScriptedFrameProviderDescriptor *b) {
+ // nullopt (no priority) sorts last (UINT32_MAX).
+ uint32_t priority_a = a->GetPriority().value_or(UINT32_MAX);
+ uint32_t priority_b = b->GetPriority().value_or(UINT32_MAX);
+ return priority_a < priority_b;
+ });
+
+ // Load the highest priority provider that successfully instantiates.
+ for (const auto *descriptor : applicable_descriptors) {
+ if (llvm::Error error = LoadScriptedFrameProvider(*descriptor)) {
----------------
bulbazord wrote:
Can you check if they load before adding them to the applicable_descriptors
list? No reason to sort a descriptor if it doesn't load. Maybe that's not how
they work?
https://github.com/llvm/llvm-project/pull/172848
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits