Revert "[lldb] Introduce ScriptedFrameProvider for real threads" (#167662)
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
This commit is contained in:
1 parent
5e4f177142
commit
b7bc4a2103
43 files changed
+78
-1917
No files matched your search
@@ -330,112 +330,6 @@ public:
|
||||
return m_object_instance_sp;
|
||||
}
|
||||
|
||||
/// Call a static method on a Python class without creating an instance.
|
||||
///
|
||||
/// This method resolves a Python class by name and calls a static method
|
||||
/// on it, returning the result. This is useful for calling class-level
|
||||
/// methods that don't require an instance.
|
||||
///
|
||||
/// \param class_name The fully-qualified name of the Python class.
|
||||
/// \param method_name The name of the static method to call.
|
||||
/// \param error Output parameter to receive error information if the call
|
||||
/// fails.
|
||||
/// \param args Arguments to pass to the static method.
|
||||
///
|
||||
/// \return The return value of the static method call, or an error value.
|
||||
template <typename T = StructuredData::ObjectSP, typename... Args>
|
||||
T CallStaticMethod(llvm::StringRef class_name, llvm::StringRef method_name,
|
||||
Status &error, Args &&...args) {
|
||||
using namespace python;
|
||||
using Locker = ScriptInterpreterPythonImpl::Locker;
|
||||
|
||||
std::string caller_signature =
|
||||
llvm::Twine(LLVM_PRETTY_FUNCTION + llvm::Twine(" (") +
|
||||
llvm::Twine(class_name) + llvm::Twine(".") +
|
||||
llvm::Twine(method_name) + llvm::Twine(")"))
|
||||
.str();
|
||||
|
||||
if (class_name.empty())
|
||||
return ErrorWithMessage<T>(caller_signature, "missing script class name",
|
||||
error);
|
||||
|
||||
Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN,
|
||||
Locker::FreeLock);
|
||||
|
||||
// Get the interpreter dictionary.
|
||||
auto dict =
|
||||
PythonModule::MainModule().ResolveName<python::PythonDictionary>(
|
||||
m_interpreter.GetDictionaryName());
|
||||
if (!dict.IsAllocated())
|
||||
return ErrorWithMessage<T>(
|
||||
caller_signature,
|
||||
llvm::formatv("could not find interpreter dictionary: {0}",
|
||||
m_interpreter.GetDictionaryName())
|
||||
.str(),
|
||||
error);
|
||||
|
||||
// Resolve the class.
|
||||
auto class_obj =
|
||||
PythonObject::ResolveNameWithDictionary<python::PythonCallable>(
|
||||
class_name, dict);
|
||||
if (!class_obj.IsAllocated())
|
||||
return ErrorWithMessage<T>(
|
||||
caller_signature,
|
||||
llvm::formatv("could not find script class: {0}", class_name).str(),
|
||||
error);
|
||||
|
||||
// Get the static method from the class.
|
||||
if (!class_obj.HasAttribute(method_name))
|
||||
return ErrorWithMessage<T>(
|
||||
caller_signature,
|
||||
llvm::formatv("class {0} does not have method {1}", class_name,
|
||||
method_name)
|
||||
.str(),
|
||||
error);
|
||||
|
||||
PythonCallable method =
|
||||
class_obj.GetAttributeValue(method_name).AsType<PythonCallable>();
|
||||
if (!method.IsAllocated())
|
||||
return ErrorWithMessage<T>(caller_signature,
|
||||
llvm::formatv("method {0}.{1} is not callable",
|
||||
class_name, method_name)
|
||||
.str(),
|
||||
error);
|
||||
|
||||
// Transform the arguments.
|
||||
std::tuple<Args...> original_args = std::forward_as_tuple(args...);
|
||||
auto transformed_args = TransformArgs(original_args);
|
||||
|
||||
// Call the static method.
|
||||
llvm::Expected<PythonObject> expected_return_object =
|
||||
llvm::make_error<llvm::StringError>("Not initialized.",
|
||||
llvm::inconvertibleErrorCode());
|
||||
std::apply(
|
||||
[&method, &expected_return_object](auto &&...args) {
|
||||
llvm::consumeError(expected_return_object.takeError());
|
||||
expected_return_object = method(args...);
|
||||
},
|
||||
transformed_args);
|
||||
|
||||
if (llvm::Error e = expected_return_object.takeError()) {
|
||||
error = Status::FromError(std::move(e));
|
||||
return ErrorWithMessage<T>(
|
||||
caller_signature, "python static method could not be called", error);
|
||||
}
|
||||
|
||||
PythonObject py_return = std::move(expected_return_object.get());
|
||||
|
||||
// Re-assign reference and pointer arguments if needed.
|
||||
if (sizeof...(Args) > 0)
|
||||
if (!ReassignPtrsOrRefsArgs(original_args, transformed_args))
|
||||
return ErrorWithMessage<T>(
|
||||
caller_signature,
|
||||
"couldn't re-assign reference and pointer arguments", error);
|
||||
|
||||
// Extract value from Python object (handles unallocated case).
|
||||
return ExtractValueFromPythonObject<T>(py_return, error);
|
||||
}
|
||||
|
||||
protected:
|
||||
template <typename T = StructuredData::ObjectSP>
|
||||
T ExtractValueFromPythonObject(python::PythonObject &p, Status &error) {
|
||||
@@ -452,7 +346,7 @@ protected:
|
||||
llvm::Twine(method_name) + llvm::Twine(")"))
|
||||
.str();
|
||||
if (!m_object_instance_sp)
|
||||
return ErrorWithMessage<T>(caller_signature, "python object ill-formed",
|
||||
return ErrorWithMessage<T>(caller_signature, "Python object ill-formed",
|
||||
error);
|
||||
|
||||
Locker py_lock(&m_interpreter, Locker::AcquireLock | Locker::NoSTDIN,
|
||||
@@ -464,7 +358,7 @@ protected:
|
||||
if (!implementor.IsAllocated())
|
||||
return llvm::is_contained(GetAbstractMethods(), method_name)
|
||||
? ErrorWithMessage<T>(caller_signature,
|
||||
"python implementor not allocated",
|
||||
"Python implementor not allocated.",
|
||||
error)
|
||||
: T{};
|
||||
|
||||
@@ -485,20 +379,20 @@ protected:
|
||||
if (llvm::Error e = expected_return_object.takeError()) {
|
||||
error = Status::FromError(std::move(e));
|
||||
return ErrorWithMessage<T>(caller_signature,
|
||||
"python method could not be called", error);
|
||||
"Python method could not be called.", error);
|
||||
}
|
||||
|
||||
PythonObject py_return = std::move(expected_return_object.get());
|
||||
|
||||
// Now that we called the python method with the transformed arguments,
|
||||
// we need to iterate again over both the original and transformed
|
||||
// we need to interate again over both the original and transformed
|
||||
// parameter pack, and transform back the parameter that were passed in
|
||||
// the original parameter pack as references or pointers.
|
||||
if (sizeof...(Args) > 0)
|
||||
if (!ReassignPtrsOrRefsArgs(original_args, transformed_args))
|
||||
return ErrorWithMessage<T>(
|
||||
caller_signature,
|
||||
"couldn't re-assign reference and pointer arguments", error);
|
||||
"Couldn't re-assign reference and pointer arguments.", error);
|
||||
|
||||
if (!py_return.IsAllocated())
|
||||
return {};
|
||||
@@ -704,11 +598,6 @@ lldb::StreamSP
|
||||
ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::StreamSP>(
|
||||
python::PythonObject &p, Status &error);
|
||||
|
||||
template <>
|
||||
lldb::ThreadSP
|
||||
ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::ThreadSP>(
|
||||
python::PythonObject &p, Status &error);
|
||||
|
||||
template <>
|
||||
lldb::StackFrameSP
|
||||
ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::StackFrameSP>(
|
||||
|
||||
Reference in new issue
Block a user