Skip to content

Commit 6cb45ae

Browse files
authored
Reland "[lldb/Interpreter] Discard ScriptedThreadPlan::GetStopDescription return value (#96985)" (#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]>
1 parent 72c801f commit 6cb45ae

File tree

10 files changed

+32
-32
lines changed

10 files changed

+32
-32
lines changed

lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadPlanInterface.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class ScriptedThreadPlanInterface : public ScriptedInterface {
2929

3030
virtual lldb::StateType GetRunState() { return lldb::eStateStepping; }
3131

32-
virtual llvm::Expected<bool> GetStopDescription(lldb_private::Stream *s) {
33-
return true;
32+
virtual llvm::Error GetStopDescription(lldb::StreamSP &stream) {
33+
return llvm::Error::success();
3434
}
3535
};
3636
} // namespace lldb_private

lldb/include/lldb/Interpreter/ScriptInterpreter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ class ScriptInterpreter : public PluginInterface {
575575

576576
Event *GetOpaqueTypeFromSBEvent(const lldb::SBEvent &event) const;
577577

578-
Stream *GetOpaqueTypeFromSBStream(const lldb::SBStream &stream) const;
578+
lldb::StreamSP GetOpaqueTypeFromSBStream(const lldb::SBStream &stream) const;
579579

580580
lldb::BreakpointSP
581581
GetOpaqueTypeFromSBBreakpoint(const lldb::SBBreakpoint &breakpoint) const;

lldb/include/lldb/Utility/StreamString.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
namespace lldb_private {
2222

23+
class ScriptInterpreter;
24+
2325
class StreamString : public Stream {
2426
public:
2527
StreamString(bool colors = false);
@@ -45,6 +47,8 @@ class StreamString : public Stream {
4547
void FillLastLineToColumn(uint32_t column, char fill_char);
4648

4749
protected:
50+
friend class ScriptInterpreter;
51+
4852
std::string m_packet;
4953
size_t WriteImpl(const void *s, size_t length) override;
5054
};

lldb/source/Interpreter/ScriptInterpreter.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,13 @@ ScriptInterpreter::GetOpaqueTypeFromSBEvent(const lldb::SBEvent &event) const {
106106
return event.m_opaque_ptr;
107107
}
108108

109-
Stream *ScriptInterpreter::GetOpaqueTypeFromSBStream(
109+
lldb::StreamSP ScriptInterpreter::GetOpaqueTypeFromSBStream(
110110
const lldb::SBStream &stream) const {
111-
if (stream.m_opaque_up)
112-
return const_cast<lldb::SBStream &>(stream).m_opaque_up.get();
111+
if (stream.m_opaque_up) {
112+
lldb::StreamSP s = std::make_shared<lldb_private::StreamString>();
113+
*s << reinterpret_cast<StreamString *>(stream.m_opaque_up.get())->m_packet;
114+
return s;
115+
}
113116

114117
return nullptr;
115118
}

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,6 @@ ScriptedPythonInterface::ScriptedPythonInterface(
2626
ScriptInterpreterPythonImpl &interpreter)
2727
: ScriptedInterface(), m_interpreter(interpreter) {}
2828

29-
template <>
30-
void ScriptedPythonInterface::ReverseTransform(
31-
lldb_private::Stream *&original_arg, python::PythonObject transformed_arg,
32-
Status &error) {
33-
Stream *s = ExtractValueFromPythonObject<Stream *>(transformed_arg, error);
34-
*original_arg = *s;
35-
original_arg->PutCString(static_cast<StreamString *>(s)->GetData());
36-
}
37-
3829
template <>
3930
StructuredData::ArraySP
4031
ScriptedPythonInterface::ExtractValueFromPythonObject<StructuredData::ArraySP>(
@@ -74,7 +65,8 @@ Event *ScriptedPythonInterface::ExtractValueFromPythonObject<Event *>(
7465
}
7566

7667
template <>
77-
Stream *ScriptedPythonInterface::ExtractValueFromPythonObject<Stream *>(
68+
lldb::StreamSP
69+
ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::StreamSP>(
7870
python::PythonObject &p, Status &error) {
7971
if (lldb::SBStream *sb_stream = reinterpret_cast<lldb::SBStream *>(
8072
python::LLDBSWIGPython_CastPyObjectToSBStream(p.get())))

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ class ScriptedPythonInterface : virtual public ScriptedInterface {
341341
return python::SWIGBridge::ToSWIGWrapper(arg);
342342
}
343343

344-
python::PythonObject Transform(Stream *arg) {
345-
return python::SWIGBridge::ToSWIGWrapper(arg);
344+
python::PythonObject Transform(lldb::StreamSP arg) {
345+
return python::SWIGBridge::ToSWIGWrapper(arg.get());
346346
}
347347

348348
python::PythonObject Transform(lldb::DataExtractorSP arg) {
@@ -447,7 +447,8 @@ Event *ScriptedPythonInterface::ExtractValueFromPythonObject<Event *>(
447447
python::PythonObject &p, Status &error);
448448

449449
template <>
450-
Stream *ScriptedPythonInterface::ExtractValueFromPythonObject<Stream *>(
450+
lldb::StreamSP
451+
ScriptedPythonInterface::ExtractValueFromPythonObject<lldb::StreamSP>(
451452
python::PythonObject &p, Status &error);
452453

453454
template <>

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,15 @@ lldb::StateType ScriptedThreadPlanPythonInterface::GetRunState() {
9191
static_cast<uint32_t>(lldb::eStateStepping)));
9292
}
9393

94-
llvm::Expected<bool>
95-
ScriptedThreadPlanPythonInterface::GetStopDescription(lldb_private::Stream *s) {
94+
llvm::Error
95+
ScriptedThreadPlanPythonInterface::GetStopDescription(lldb::StreamSP &stream) {
9696
Status error;
97-
Dispatch("stop_description", error, s);
97+
Dispatch("stop_description", error, stream);
9898

9999
if (error.Fail())
100100
return error.ToError();
101101

102-
return true;
102+
return llvm::Error::success();
103103
}
104104

105105
#endif

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ScriptedThreadPlanPythonInterface : public ScriptedThreadPlanInterface,
4040

4141
lldb::StateType GetRunState() override;
4242

43-
llvm::Expected<bool> GetStopDescription(lldb_private::Stream *s) override;
43+
llvm::Error GetStopDescription(lldb::StreamSP &stream) override;
4444
};
4545
} // namespace lldb_private
4646

lldb/source/Target/ThreadPlanPython.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,16 @@ void ThreadPlanPython::GetDescription(Stream *s, lldb::DescriptionLevel level) {
182182
if (m_implementation_sp) {
183183
ScriptInterpreter *script_interp = GetScriptInterpreter();
184184
if (script_interp) {
185-
auto desc_or_err = m_interface->GetStopDescription(s);
186-
if (!desc_or_err || !*desc_or_err) {
187-
LLDB_LOG_ERROR(GetLog(LLDBLog::Thread), desc_or_err.takeError(),
185+
lldb::StreamSP stream = std::make_shared<lldb_private::StreamString>();
186+
llvm::Error err = m_interface->GetStopDescription(stream);
187+
if (err) {
188+
LLDB_LOG_ERROR(GetLog(LLDBLog::Thread), std::move(err),
188189
"Can't call ScriptedThreadPlan::GetStopDescription.");
189190
s->Printf("Python thread plan implemented by class %s.",
190191
m_class_name.c_str());
191-
}
192+
} else
193+
s->PutCString(
194+
reinterpret_cast<StreamString *>(stream.get())->GetData());
192195
}
193196
return;
194197
}

lldb/test/API/functionalities/step_scripted/TestStepScripted.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from lldbsuite.test.decorators import *
88
from lldbsuite.test.lldbtest import *
99

10+
1011
class StepScriptedTestCase(TestBase):
1112
NO_DEBUG_INFO_TESTCASE = True
1213

@@ -15,14 +16,12 @@ def setUp(self):
1516
self.main_source_file = lldb.SBFileSpec("main.c")
1617
self.runCmd("command script import Steps.py")
1718

18-
@expectedFailureAll()
1919
def test_standard_step_out(self):
2020
"""Tests stepping with the scripted thread plan laying over a standard
2121
thread plan for stepping out."""
2222
self.build()
2323
self.step_out_with_scripted_plan("Steps.StepOut")
2424

25-
@expectedFailureAll()
2625
def test_scripted_step_out(self):
2726
"""Tests stepping with the scripted thread plan laying over an another
2827
scripted thread plan for stepping out."""
@@ -63,12 +62,10 @@ def test_misspelled_plan_name(self):
6362
# Make sure we didn't let the process run:
6463
self.assertEqual(stop_id, process.GetStopID(), "Process didn't run")
6564

66-
@expectedFailureAll()
6765
def test_checking_variable(self):
6866
"""Test that we can call SBValue API's from a scripted thread plan - using SBAPI's to step"""
6967
self.do_test_checking_variable(False)
7068

71-
@expectedFailureAll()
7269
def test_checking_variable_cli(self):
7370
"""Test that we can call SBValue API's from a scripted thread plan - using cli to step"""
7471
self.do_test_checking_variable(True)

0 commit comments

Comments
 (0)