[Lldb-commits] [PATCH] D105038: [lldb/Interpreter] Fix session-save-on-quit when using ^D
Med Ismail Bennani via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Jun 28 08:55:19 PDT 2021
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.bennani at 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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105038.354917.patch
Type: text/x-patch
Size: 2065 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210628/51f8987d/attachment-0001.bin>
More information about the lldb-commits
mailing list