The new test fails on x86 and arm64 public macOS bots: ``` 09:27:59 ====================================================================== 09:27:59 FAIL: test_append_frames (TestScriptedFrameProvider.ScriptedFrameProviderTestCase) 09:27:59 Test that we can add frames after real stack. 09:27:59 ---------------------------------------------------------------------- 09:27:59 Traceback (most recent call last): 09:27:59 File "/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/functionalities/scripted_frame_provider/TestScriptedFrameProvider.py", line 122, in test_append_frames 09:27:59 self.assertEqual(new_frame_count, original_frame_count + 1) 09:27:59 AssertionError: 5 != 6 09:27:59 Config=arm64-/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang 09:27:59 ====================================================================== 09:27:59 FAIL: test_applies_to_thread (TestScriptedFrameProvider.ScriptedFrameProviderTestCase) 09:27:59 Test that applies_to_thread filters which threads get the provider. 09:27:59 ---------------------------------------------------------------------- 09:27:59 Traceback (most recent call last): 09:27:59 File "/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/functionalities/scripted_frame_provider/TestScriptedFrameProvider.py", line 218, in test_applies_to_thread 09:27:59 self.assertEqual( 09:27:59 AssertionError: 5 != 1 : Thread with ID 1 should have 1 synthetic frame 09:27:59 Config=arm64-/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang 09:27:59 ====================================================================== 09:27:59 FAIL: test_prepend_frames (TestScriptedFrameProvider.ScriptedFrameProviderTestCase) 09:27:59 Test that we can add frames before real stack. 09:27:59 ---------------------------------------------------------------------- 09:27:59 Traceback (most recent call last): 09:27:59 File "/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/functionalities/scripted_frame_provider/TestScriptedFrameProvider.py", line 84, in test_prepend_frames 09:27:59 self.assertEqual(new_frame_count, original_frame_count + 2) 09:27:59 AssertionError: 5 != 7 09:27:59 Config=arm64-/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang 09:27:59 ====================================================================== 09:27:59 FAIL: test_remove_frame_provider_by_id (TestScriptedFrameProvider.ScriptedFrameProviderTestCase) 09:27:59 Test that RemoveScriptedFrameProvider removes a specific provider by ID. 09:27:59 ---------------------------------------------------------------------- 09:27:59 Traceback (most recent call last): 09:27:59 File "/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/functionalities/scripted_frame_provider/TestScriptedFrameProvider.py", line 272, in test_remove_frame_provider_by_id 09:27:59 self.assertEqual(thread.GetNumFrames(), 3, "Should have 3 synthetic frames") 09:27:59 AssertionError: 5 != 3 : Should have 3 synthetic frames 09:27:59 Config=arm64-/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang 09:27:59 ====================================================================== 09:27:59 FAIL: test_replace_all_frames (TestScriptedFrameProvider.ScriptedFrameProviderTestCase) 09:27:59 Test that we can replace the entire stack. 09:27:59 ---------------------------------------------------------------------- 09:27:59 Traceback (most recent call last): 09:27:59 File "/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/functionalities/scripted_frame_provider/TestScriptedFrameProvider.py", line 41, in test_replace_all_frames 09:27:59 self.assertEqual(thread.GetNumFrames(), 3, "Should have 3 synthetic frames") 09:27:59 AssertionError: 5 != 3 : Should have 3 synthetic frames 09:27:59 Config=arm64-/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang 09:27:59 ====================================================================== 09:27:59 FAIL: test_scripted_frame_objects (TestScriptedFrameProvider.ScriptedFrameProviderTestCase) 09:27:59 Test that provider can return ScriptedFrame objects. 09:27:59 ---------------------------------------------------------------------- 09:27:59 Traceback (most recent call last): 09:27:59 File "/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/functionalities/scripted_frame_provider/TestScriptedFrameProvider.py", line 159, in test_scripted_frame_objects 09:27:59 self.assertEqual(frame0.GetFunctionName(), "custom_scripted_frame_0") 09:27:59 AssertionError: 'thread_func(int)' != 'custom_scripted_frame_0' 09:27:59 - thread_func(int) 09:27:59 + custom_scripted_frame_0 09:27:59 09:27:59 Config=arm64-/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang 09:27:59 ---------------------------------------------------------------------- 09:27:59 Ran 6 tests in 14.242s 09:27:59 09:27:59 FAILED (failures=6) ``` Reverts llvm/llvm-project#161870
101 lines
3.5 KiB
C++
101 lines
3.5 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "lldb/Target/SyntheticFrameProvider.h"
|
|
#include "lldb/Core/PluginManager.h"
|
|
#include "lldb/Target/Thread.h"
|
|
#include "lldb/Utility/LLDBLog.h"
|
|
#include "lldb/Utility/Log.h"
|
|
#include "lldb/Utility/Status.h"
|
|
|
|
using namespace lldb;
|
|
using namespace lldb_private;
|
|
|
|
SyntheticFrameProvider::SyntheticFrameProvider(StackFrameListSP input_frames)
|
|
: m_input_frames(std::move(input_frames)) {}
|
|
|
|
SyntheticFrameProvider::~SyntheticFrameProvider() = default;
|
|
|
|
void SyntheticFrameProviderDescriptor::Dump(Stream *s) const {
|
|
if (!s)
|
|
return;
|
|
|
|
s->Printf(" Name: %s\n", GetName().str().c_str());
|
|
|
|
// Show thread filter information.
|
|
if (thread_specs.empty()) {
|
|
s->PutCString(" Thread Filter: (applies to all threads)\n");
|
|
} else {
|
|
s->Printf(" Thread Filter: %zu specification(s)\n", thread_specs.size());
|
|
for (size_t i = 0; i < thread_specs.size(); ++i) {
|
|
const ThreadSpec &spec = thread_specs[i];
|
|
s->Printf(" [%zu] ", i);
|
|
spec.GetDescription(s, lldb::eDescriptionLevelVerbose);
|
|
s->PutChar('\n');
|
|
}
|
|
}
|
|
}
|
|
|
|
llvm::Expected<SyntheticFrameProviderSP> SyntheticFrameProvider::CreateInstance(
|
|
StackFrameListSP input_frames,
|
|
const SyntheticFrameProviderDescriptor &descriptor) {
|
|
if (!input_frames)
|
|
return llvm::createStringError(
|
|
"cannot create synthetic frame provider: invalid input frames");
|
|
|
|
// Iterate through all registered ScriptedFrameProvider plugins.
|
|
ScriptedFrameProviderCreateInstance create_callback = nullptr;
|
|
for (uint32_t idx = 0;
|
|
(create_callback =
|
|
PluginManager::GetScriptedFrameProviderCreateCallbackAtIndex(
|
|
idx)) != nullptr;
|
|
++idx) {
|
|
auto provider_or_err = create_callback(input_frames, descriptor);
|
|
if (!provider_or_err) {
|
|
LLDB_LOG_ERROR(GetLog(LLDBLog::Target), provider_or_err.takeError(),
|
|
"Failed to create synthetic frame provider: {0}");
|
|
continue;
|
|
}
|
|
|
|
if (auto frame_provider_up = std::move(*provider_or_err))
|
|
return std::move(frame_provider_up);
|
|
}
|
|
|
|
return llvm::createStringError(
|
|
"cannot create synthetic frame provider: no suitable plugin found");
|
|
}
|
|
|
|
llvm::Expected<SyntheticFrameProviderSP> SyntheticFrameProvider::CreateInstance(
|
|
StackFrameListSP input_frames, llvm::StringRef plugin_name,
|
|
const std::vector<ThreadSpec> &thread_specs) {
|
|
if (!input_frames)
|
|
return llvm::createStringError(
|
|
"cannot create synthetic frame provider: invalid input frames");
|
|
|
|
// Look up the specific C++ plugin by name.
|
|
SyntheticFrameProviderCreateInstance create_callback =
|
|
PluginManager::GetSyntheticFrameProviderCreateCallbackForPluginName(
|
|
plugin_name);
|
|
|
|
if (!create_callback)
|
|
return llvm::createStringError(
|
|
"cannot create synthetic frame provider: C++ plugin '%s' not found",
|
|
plugin_name.str().c_str());
|
|
|
|
auto provider_or_err = create_callback(input_frames, thread_specs);
|
|
if (!provider_or_err)
|
|
return provider_or_err.takeError();
|
|
|
|
if (auto frame_provider_sp = std::move(*provider_or_err))
|
|
return std::move(frame_provider_sp);
|
|
|
|
return llvm::createStringError(
|
|
"cannot create synthetic frame provider: C++ plugin '%s' returned null",
|
|
plugin_name.str().c_str());
|
|
}
|