-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Reland "[lldb/Interpreter] Discard ScriptedThreadPlan::GetStopDescription return value (#96985)" #97092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
medismailben
merged 1 commit into
llvm:main
from
medismailben:try-to-fix-scripted-thread-plan-tests
Jun 28, 2024
Merged
Reland "[lldb/Interpreter] Discard ScriptedThreadPlan::GetStopDescription return value (#96985)" #97092
medismailben
merged 1 commit into
llvm:main
from
medismailben:try-to-fix-scripted-thread-plan-tests
Jun 28, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…pDescription return value (llvm#96985)"" This reverts commit a2e3af5 and solves the build error in https://lab.llvm.org/buildbot/#/builders/141/builds/369. Signed-off-by: Med Ismail Bennani <[email protected]>
@llvm/pr-subscribers-lldb Author: Med Ismail Bennani (medismailben) ChangesThis reverts commit a2e3af5 and solves the build error in https://lab.llvm.org/buildbot/#/builders/141/builds/369. Full diff: https://github.com/llvm/llvm-project/pull/97092.diff 10 Files Affected:
diff --git a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h
index 9130f9412cb0b..ee634d15f2a9e 100644
--- a/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h
@@ -29,8 +29,8 @@ class ScriptedThreadPlanInterface : public ScriptedInterface {
virtual lldb::StateType GetRunState() { return lldb::eStateStepping; }
- virtual llvm::Expected<bool> GetStopDescription(lldb_private::Stream *s) {
- return true;
+ virtual llvm::Error GetStopDescription(lldb::StreamSP &stream) {
+ return llvm::Error::success();
}
};
} // namespace lldb_private
diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
index e821a7db2c674..14a52709c1e61 100644
--- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h
+++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
@@ -575,7 +575,7 @@ class ScriptInterpreter : public PluginInterface {
Event *GetOpaqueTypeFromSBEvent(const lldb::SBEvent &event) const;
- Stream *GetOpaqueTypeFromSBStream(const lldb::SBStream &stream) const;
+ lldb::StreamSP GetOpaqueTypeFromSBStream(const lldb::SBStream &stream) const;
lldb::BreakpointSP
GetOpaqueTypeFromSBBreakpoint(const lldb::SBBreakpoint &breakpoint) const;
diff --git a/lldb/include/lldb/Utility/StreamString.h b/lldb/include/lldb/Utility/StreamString.h
index 3d675caf8f3f4..3287f328a1be3 100644
--- a/lldb/include/lldb/Utility/StreamString.h
+++ b/lldb/include/lldb/Utility/StreamString.h
@@ -20,6 +20,8 @@
namespace lldb_private {
+class ScriptInterpreter;
+
class StreamString : public Stream {
public:
StreamString(bool colors = false);
@@ -45,6 +47,8 @@ class StreamString : public Stream {
void FillLastLineToColumn(uint32_t column, char fill_char);
protected:
+ friend class ScriptInterpreter;
+
std::string m_packet;
size_t WriteImpl(const void *s, size_t length) override;
};
diff --git a/lldb/source/Interpreter/ScriptInterpreter.cpp b/lldb/source/Interpreter/ScriptInterpreter.cpp
index 75b2a39a8d11b..fa23964a52ffe 100644
--- a/lldb/source/Interpreter/ScriptInterpreter.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreter.cpp
@@ -106,10 +106,13 @@ ScriptInterpreter::GetOpaqueTypeFromSBEvent(const lldb::SBEvent &event) const {
return event.m_opaque_ptr;
}
-Stream *ScriptInterpreter::GetOpaqueTypeFromSBStream(
+lldb::StreamSP ScriptInterpreter::GetOpaqueTypeFromSBStream(
const lldb::SBStream &stream) const {
- if (stream.m_opaque_up)
- return const_cast<lldb::SBStream &>(stream).m_opaque_up.get();
+ if (stream.m_opaque_up) {
+ lldb::StreamSP s = std::make_shared<lldb_private::StreamString>();
+ *s << reinterpret_cast<StreamString *>(stream.m_opaque_up.get())->m_packet;
+ return s;
+ }
return nullptr;
}
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp
index 7d072212676e1..699412e437a1a 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp
@@ -26,15 +26,6 @@ ScriptedPythonInterface::ScriptedPythonInterface(
ScriptInterpreterPythonImpl &interpreter)
: ScriptedInterface(), m_interpreter(interpreter) {}
-template <>
-void ScriptedPythonInterface::ReverseTransform(
- lldb_private::Stream *&original_arg, python::PythonObject transformed_arg,
- Status &error) {
- Stream *s = ExtractValueFromPythonObject<Stream *>(transformed_arg, error);
- *original_arg = *s;
- original_arg->PutCString(static_cast<StreamString *>(s)->GetData());
-}
-
template <>
StructuredData::ArraySP
ScriptedPythonInterface::ExtractValueFromPythonObject<StructuredData::ArraySP>(
@@ -74,7 +65,8 @@ Event *ScriptedPythonInterface::ExtractValueFromPythonObject<Event *>(
}
template <>
-Stream *ScriptedPythonInterface::ExtractValueFromPythonObject<Stream *>(
+lldb::StreamSP
+ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::StreamSP>(
python::PythonObject &p, Status &error) {
if (lldb::SBStream *sb_stream = reinterpret_cast<lldb::SBStream *>(
python::LLDBSWIGPython_CastPyObjectToSBStream(p.get())))
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
index 062bf1fcff4ac..e1a3156d10afd 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
@@ -341,8 +341,8 @@ class ScriptedPythonInterface : virtual public ScriptedInterface {
return python::SWIGBridge::ToSWIGWrapper(arg);
}
- python::PythonObject Transform(Stream *arg) {
- return python::SWIGBridge::ToSWIGWrapper(arg);
+ python::PythonObject Transform(lldb::StreamSP arg) {
+ return python::SWIGBridge::ToSWIGWrapper(arg.get());
}
python::PythonObject Transform(lldb::DataExtractorSP arg) {
@@ -447,7 +447,8 @@ Event *ScriptedPythonInterface::ExtractValueFromPythonObject<Event *>(
python::PythonObject &p, Status &error);
template <>
-Stream *ScriptedPythonInterface::ExtractValueFromPythonObject<Stream *>(
+lldb::StreamSP
+ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::StreamSP>(
python::PythonObject &p, Status &error);
template <>
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp
index b7e475812f22b..f23858c01277c 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp
@@ -91,15 +91,15 @@ lldb::StateType ScriptedThreadPlanPythonInterface::GetRunState() {
static_cast<uint32_t>(lldb::eStateStepping)));
}
-llvm::Expected<bool>
-ScriptedThreadPlanPythonInterface::GetStopDescription(lldb_private::Stream *s) {
+llvm::Error
+ScriptedThreadPlanPythonInterface::GetStopDescription(lldb::StreamSP &stream) {
Status error;
- Dispatch("stop_description", error, s);
+ Dispatch("stop_description", error, stream);
if (error.Fail())
return error.ToError();
- return true;
+ return llvm::Error::success();
}
#endif
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h
index 33f086786c47b..6ec89b9f59253 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h
@@ -40,7 +40,7 @@ class ScriptedThreadPlanPythonInterface : public ScriptedThreadPlanInterface,
lldb::StateType GetRunState() override;
- llvm::Expected<bool> GetStopDescription(lldb_private::Stream *s) override;
+ llvm::Error GetStopDescription(lldb::StreamSP &stream) override;
};
} // namespace lldb_private
diff --git a/lldb/source/Target/ThreadPlanPython.cpp b/lldb/source/Target/ThreadPlanPython.cpp
index 373555324ba6e..dfcb67eb19022 100644
--- a/lldb/source/Target/ThreadPlanPython.cpp
+++ b/lldb/source/Target/ThreadPlanPython.cpp
@@ -182,13 +182,16 @@ void ThreadPlanPython::GetDescription(Stream *s, lldb::DescriptionLevel level) {
if (m_implementation_sp) {
ScriptInterpreter *script_interp = GetScriptInterpreter();
if (script_interp) {
- auto desc_or_err = m_interface->GetStopDescription(s);
- if (!desc_or_err || !*desc_or_err) {
- LLDB_LOG_ERROR(GetLog(LLDBLog::Thread), desc_or_err.takeError(),
+ lldb::StreamSP stream = std::make_shared<lldb_private::StreamString>();
+ llvm::Error err = m_interface->GetStopDescription(stream);
+ if (err) {
+ LLDB_LOG_ERROR(GetLog(LLDBLog::Thread), std::move(err),
"Can't call ScriptedThreadPlan::GetStopDescription.");
s->Printf("Python thread plan implemented by class %s.",
m_class_name.c_str());
- }
+ } else
+ s->PutCString(
+ reinterpret_cast<StreamString *>(stream.get())->GetData());
}
return;
}
diff --git a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
index bb7479414dbbb..53901718019f9 100644
--- a/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
+++ b/lldb/test/API/functionalities/step_scripted/TestStepScripted.py
@@ -7,6 +7,7 @@
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
+
class StepScriptedTestCase(TestBase):
NO_DEBUG_INFO_TESTCASE = True
@@ -15,14 +16,12 @@ def setUp(self):
self.main_source_file = lldb.SBFileSpec("main.c")
self.runCmd("command script import Steps.py")
- @expectedFailureAll()
def test_standard_step_out(self):
"""Tests stepping with the scripted thread plan laying over a standard
thread plan for stepping out."""
self.build()
self.step_out_with_scripted_plan("Steps.StepOut")
- @expectedFailureAll()
def test_scripted_step_out(self):
"""Tests stepping with the scripted thread plan laying over an another
scripted thread plan for stepping out."""
@@ -63,12 +62,10 @@ def test_misspelled_plan_name(self):
# Make sure we didn't let the process run:
self.assertEqual(stop_id, process.GetStopID(), "Process didn't run")
- @expectedFailureAll()
def test_checking_variable(self):
"""Test that we can call SBValue API's from a scripted thread plan - using SBAPI's to step"""
self.do_test_checking_variable(False)
- @expectedFailureAll()
def test_checking_variable_cli(self):
"""Test that we can call SBValue API's from a scripted thread plan - using cli to step"""
self.do_test_checking_variable(True)
|
jimingham
approved these changes
Jun 28, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
lravenclaw
pushed a commit
to lravenclaw/llvm-project
that referenced
this pull request
Jul 3, 2024
…tion return value (llvm#96985)" (llvm#97092) This reverts commit a2e3af5 and solves the build error in https://lab.llvm.org/buildbot/#/builders/141/builds/369. Signed-off-by: Med Ismail Bennani <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This reverts commit a2e3af5 and solves the build error in https://lab.llvm.org/buildbot/#/builders/141/builds/369.