Skip to content

Commit a2e3af5

Browse files
committed
Revert "[lldb/Interpreter] Discard ScriptedThreadPlan::GetStopDescription return value (#96985)"
This reverts commit 1130e92. Very likely causes build problems on Windows and with LLVM_NO_DEAD_STRIP=ON, see #96985 (review)
1 parent d893ed7 commit a2e3af5

File tree

9 files changed

+32
-28
lines changed

9 files changed

+32
-28
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::Error GetStopDescription(lldb::StreamSP &stream) {
33-
return llvm::Error::success();
32+
virtual llvm::Expected<bool> GetStopDescription(lldb_private::Stream *s) {
33+
return true;
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-
lldb::StreamSP GetOpaqueTypeFromSBStream(const lldb::SBStream &stream) const;
578+
Stream *GetOpaqueTypeFromSBStream(const lldb::SBStream &stream) const;
579579

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

lldb/source/Interpreter/ScriptInterpreter.cpp

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

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

117114
return nullptr;
118115
}

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ 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+
2938
template <>
3039
StructuredData::ArraySP
3140
ScriptedPythonInterface::ExtractValueFromPythonObject<StructuredData::ArraySP>(
@@ -65,8 +74,7 @@ Event *ScriptedPythonInterface::ExtractValueFromPythonObject<Event *>(
6574
}
6675

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

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

Lines changed: 3 additions & 4 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(lldb::StreamSP arg) {
345-
return python::SWIGBridge::ToSWIGWrapper(arg.get());
344+
python::PythonObject Transform(Stream *arg) {
345+
return python::SWIGBridge::ToSWIGWrapper(arg);
346346
}
347347

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

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

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

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

102-
return llvm::Error::success();
102+
return true;
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::Error GetStopDescription(lldb::StreamSP &stream) override;
43+
llvm::Expected<bool> GetStopDescription(lldb_private::Stream *s) override;
4444
};
4545
} // namespace lldb_private
4646

lldb/source/Target/ThreadPlanPython.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,13 @@ void ThreadPlanPython::GetDescription(Stream *s, lldb::DescriptionLevel level) {
182182
if (m_implementation_sp) {
183183
ScriptInterpreter *script_interp = GetScriptInterpreter();
184184
if (script_interp) {
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),
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(),
189188
"Can't call ScriptedThreadPlan::GetStopDescription.");
190189
s->Printf("Python thread plan implemented by class %s.",
191190
m_class_name.c_str());
192-
} else
193-
s->PutCString(
194-
reinterpret_cast<StreamString *>(stream.get())->GetData());
191+
}
195192
}
196193
return;
197194
}

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

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

10-
1110
class StepScriptedTestCase(TestBase):
1211
NO_DEBUG_INFO_TESTCASE = True
1312

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

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()
2526
def test_scripted_step_out(self):
2627
"""Tests stepping with the scripted thread plan laying over an another
2728
scripted thread plan for stepping out."""
@@ -62,10 +63,12 @@ def test_misspelled_plan_name(self):
6263
# Make sure we didn't let the process run:
6364
self.assertEqual(stop_id, process.GetStopID(), "Process didn't run")
6465

66+
@expectedFailureAll()
6567
def test_checking_variable(self):
6668
"""Test that we can call SBValue API's from a scripted thread plan - using SBAPI's to step"""
6769
self.do_test_checking_variable(False)
6870

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

0 commit comments

Comments
 (0)