JDevlieghere updated this revision to Diff 349033. JDevlieghere marked 3 inline comments as done. JDevlieghere added a comment.
Use in-class initializers CHANGES SINCE LAST ACTION https://reviews.llvm.org/D103349/new/ https://reviews.llvm.org/D103349 Files: lldb/include/lldb/Interpreter/CommandReturnObject.h lldb/source/Interpreter/CommandInterpreter.cpp lldb/source/Interpreter/CommandReturnObject.cpp lldb/test/Shell/Breakpoint/breakpoint-command.test lldb/test/Shell/ScriptInterpreter/Lua/nested_sessions.test
Index: lldb/test/Shell/ScriptInterpreter/Lua/nested_sessions.test =================================================================== --- lldb/test/Shell/ScriptInterpreter/Lua/nested_sessions.test +++ lldb/test/Shell/ScriptInterpreter/Lua/nested_sessions.test @@ -7,6 +7,5 @@ # CHECK-NEXT: foo foo # CHECK-NEXT: foo bar # CHECK-NEXT: foo bar -# CHECK-NEXT: foo bar # CHECK: script # CHECK-NEXT: bar bar Index: lldb/test/Shell/Breakpoint/breakpoint-command.test =================================================================== --- /dev/null +++ lldb/test/Shell/Breakpoint/breakpoint-command.test @@ -0,0 +1,5 @@ +# RUN: %build %p/Inputs/dummy-target.c -o %t.out +# RUN: %lldb %t.out -o 'b main' -o 'break command add 1 -o "script print(95000 + 126)"' -o 'r' + +# CHECK: 95125 +# CHECK-NOT: 95126 Index: lldb/source/Interpreter/CommandReturnObject.cpp =================================================================== --- lldb/source/Interpreter/CommandReturnObject.cpp +++ lldb/source/Interpreter/CommandReturnObject.cpp @@ -41,9 +41,7 @@ } CommandReturnObject::CommandReturnObject(bool colors) - : m_out_stream(colors), m_err_stream(colors), - m_status(eReturnStatusStarted), m_did_change_process_state(false), - m_interactive(true) {} + : m_out_stream(colors), m_err_stream(colors) {} void CommandReturnObject::AppendErrorWithFormat(const char *format, ...) { if (!format) @@ -152,6 +150,7 @@ m_status = eReturnStatusStarted; m_did_change_process_state = false; m_interactive = true; + m_hermetic = false; } bool CommandReturnObject::GetDidChangeProcessState() { @@ -165,3 +164,7 @@ bool CommandReturnObject::GetInteractive() const { return m_interactive; } void CommandReturnObject::SetInteractive(bool b) { m_interactive = b; } + +bool CommandReturnObject::GetHermetic() const { return m_hermetic; } + +void CommandReturnObject::SetHermetic(bool b) { m_hermetic = b; } Index: lldb/source/Interpreter/CommandInterpreter.cpp =================================================================== --- lldb/source/Interpreter/CommandInterpreter.cpp +++ lldb/source/Interpreter/CommandInterpreter.cpp @@ -2306,6 +2306,7 @@ CommandReturnObject tmp_result(m_debugger.GetUseColor()); tmp_result.SetInteractive(result.GetInteractive()); + tmp_result.SetHermetic(true); // We might call into a regex or alias command, in which case the // add_to_history will get lost. This m_command_source_depth dingus is the Index: lldb/include/lldb/Interpreter/CommandReturnObject.h =================================================================== --- lldb/include/lldb/Interpreter/CommandReturnObject.h +++ lldb/include/lldb/Interpreter/CommandReturnObject.h @@ -63,20 +63,28 @@ } void SetImmediateOutputFile(lldb::FileSP file_sp) { + if (m_hermetic) + return; lldb::StreamSP stream_sp(new StreamFile(file_sp)); m_out_stream.SetStreamAtIndex(eImmediateStreamIndex, stream_sp); } void SetImmediateErrorFile(lldb::FileSP file_sp) { + if (m_hermetic) + return; lldb::StreamSP stream_sp(new StreamFile(file_sp)); m_err_stream.SetStreamAtIndex(eImmediateStreamIndex, stream_sp); } void SetImmediateOutputStream(const lldb::StreamSP &stream_sp) { + if (m_hermetic) + return; m_out_stream.SetStreamAtIndex(eImmediateStreamIndex, stream_sp); } void SetImmediateErrorStream(const lldb::StreamSP &stream_sp) { + if (m_hermetic) + return; m_err_stream.SetStreamAtIndex(eImmediateStreamIndex, stream_sp); } @@ -142,16 +150,26 @@ void SetInteractive(bool b); + bool GetHermetic() const; + + void SetHermetic(bool b); + private: enum { eStreamStringIndex = 0, eImmediateStreamIndex = 1 }; StreamTee m_out_stream; StreamTee m_err_stream; - lldb::ReturnStatus m_status; - bool m_did_change_process_state; - bool m_interactive; // If true, then the input handle from the debugger will - // be hooked up + lldb::ReturnStatus m_status = lldb::eReturnStatusStarted; + + bool m_did_change_process_state = false; + + /// If true, then the input handle from the debugger will be hooked up. + bool m_interactive = true; + + /// If true, disallow immediate streams. Useful when using this return object + /// as a temporary. + bool m_hermetic = false; }; } // namespace lldb_private
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits