mib created this revision. mib added reviewers: JDevlieghere, teemperor. mib added a project: LLDB. mib requested review of this revision. Herald added a subscriber: lldb-commits.
Previously, when `interpreter.save-session-on-quit` was enabled, lldb would save the session transcript only when running the `quit` command. This patch changes that so the transcripts are saved when the debugger object is destroyed if the setting is enabled. rdar://72902650 Signed-off-by: Med Ismail Bennani <medismail.benn...@gmail.com> Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D105038 Files: lldb/source/Commands/CommandObjectQuit.cpp lldb/source/Core/Debugger.cpp lldb/source/Interpreter/CommandInterpreter.cpp Index: lldb/source/Interpreter/CommandInterpreter.cpp =================================================================== --- lldb/source/Interpreter/CommandInterpreter.cpp +++ lldb/source/Interpreter/CommandInterpreter.cpp @@ -2974,6 +2974,7 @@ return error_out("Unable to write to destination file", "Bytes written do not match transcript size."); + result.SetStatus(eReturnStatusSuccessContinuingResult); result.AppendMessageWithFormat("Session's transcripts saved to %s\n", output_file->c_str()); Index: lldb/source/Core/Debugger.cpp =================================================================== --- lldb/source/Core/Debugger.cpp +++ lldb/source/Core/Debugger.cpp @@ -23,6 +23,7 @@ #include "lldb/Host/Terminal.h" #include "lldb/Host/ThreadLauncher.h" #include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/OptionValue.h" #include "lldb/Interpreter/OptionValueProperties.h" #include "lldb/Interpreter/OptionValueSInt64.h" @@ -604,6 +605,17 @@ if (!debugger_sp) return; + CommandInterpreter &cmd_interpreter = debugger_sp->GetCommandInterpreter(); + + if (cmd_interpreter.GetSaveSessionOnQuit()) { + CommandReturnObject result(/*colors*/ true); + cmd_interpreter.SaveTranscript(result); + if (result.Succeeded()) + debugger_sp->GetOutputStream() << result.GetOutputData() << '\n'; + else + debugger_sp->GetErrorStream() << result.GetErrorData() << '\n'; + } + debugger_sp->Clear(); if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) { Index: lldb/source/Commands/CommandObjectQuit.cpp =================================================================== --- lldb/source/Commands/CommandObjectQuit.cpp +++ lldb/source/Commands/CommandObjectQuit.cpp @@ -101,8 +101,5 @@ m_interpreter.BroadcastEvent(event_type); result.SetStatus(eReturnStatusQuit); - if (m_interpreter.GetSaveSessionOnQuit()) - m_interpreter.SaveTranscript(result); - return true; }
Index: lldb/source/Interpreter/CommandInterpreter.cpp =================================================================== --- lldb/source/Interpreter/CommandInterpreter.cpp +++ lldb/source/Interpreter/CommandInterpreter.cpp @@ -2974,6 +2974,7 @@ return error_out("Unable to write to destination file", "Bytes written do not match transcript size."); + result.SetStatus(eReturnStatusSuccessContinuingResult); result.AppendMessageWithFormat("Session's transcripts saved to %s\n", output_file->c_str()); Index: lldb/source/Core/Debugger.cpp =================================================================== --- lldb/source/Core/Debugger.cpp +++ lldb/source/Core/Debugger.cpp @@ -23,6 +23,7 @@ #include "lldb/Host/Terminal.h" #include "lldb/Host/ThreadLauncher.h" #include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/OptionValue.h" #include "lldb/Interpreter/OptionValueProperties.h" #include "lldb/Interpreter/OptionValueSInt64.h" @@ -604,6 +605,17 @@ if (!debugger_sp) return; + CommandInterpreter &cmd_interpreter = debugger_sp->GetCommandInterpreter(); + + if (cmd_interpreter.GetSaveSessionOnQuit()) { + CommandReturnObject result(/*colors*/ true); + cmd_interpreter.SaveTranscript(result); + if (result.Succeeded()) + debugger_sp->GetOutputStream() << result.GetOutputData() << '\n'; + else + debugger_sp->GetErrorStream() << result.GetErrorData() << '\n'; + } + debugger_sp->Clear(); if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) { Index: lldb/source/Commands/CommandObjectQuit.cpp =================================================================== --- lldb/source/Commands/CommandObjectQuit.cpp +++ lldb/source/Commands/CommandObjectQuit.cpp @@ -101,8 +101,5 @@ m_interpreter.BroadcastEvent(event_type); result.SetStatus(eReturnStatusQuit); - if (m_interpreter.GetSaveSessionOnQuit()) - m_interpreter.SaveTranscript(result); - return true; }
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits