Skip to content

Commit 835b5e2

Browse files
zhytyTom Yang
and
Tom Yang
authored
Add warning message to session save when transcript isn't saved. (#109020)
Somewhat recently, we made the change to hide the behavior to save LLDB session history to the transcript buffer behind the flag `interpreter.save-transcript`. By default, `interpreter.save-transcript` is false. See #90703 for context. I'm making a small update here to our `session save` messaging and some help docs to clarify for users that aren't aware of this change. Maybe `interpreter.save-transcript` could be true by default as well. Any feedback welcome. # Tests ``` bin/lldb-dotest -p TestSessionSave ``` --------- Co-authored-by: Tom Yang <[email protected]>
1 parent 554eaec commit 835b5e2

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

lldb/source/Commands/CommandObjectSession.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ class CommandObjectSessionSave : public CommandObjectParsed {
1919
: CommandObjectParsed(interpreter, "session save",
2020
"Save the current session transcripts to a file.\n"
2121
"If no file if specified, transcripts will be "
22-
"saved to a temporary file.",
22+
"saved to a temporary file.\n"
23+
"Note: transcripts will only be saved if "
24+
"interpreter.save-transcript is true.\n",
2325
"session save [file]") {
2426
AddSimpleArgumentList(eArgTypePath, eArgRepeatOptional);
2527
}

lldb/source/Interpreter/CommandInterpreter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3308,6 +3308,10 @@ bool CommandInterpreter::SaveTranscript(
33083308
result.SetStatus(eReturnStatusSuccessFinishNoResult);
33093309
result.AppendMessageWithFormat("Session's transcripts saved to %s\n",
33103310
output_file->c_str());
3311+
if (!GetSaveTranscript())
3312+
result.AppendError(
3313+
"Note: the setting interpreter.save-transcript is set to false, so the "
3314+
"transcript might not have been recorded.");
33113315

33123316
if (GetOpenTranscriptInEditor() && Host::IsInteractiveGraphicSession()) {
33133317
const FileSpec file_spec;

lldb/source/Interpreter/InterpreterProperties.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ let Definition = "interpreter" in {
1616
def SaveSessionOnQuit: Property<"save-session-on-quit", "Boolean">,
1717
Global,
1818
DefaultFalse,
19-
Desc<"If true, LLDB will save the session's transcripts before quitting.">;
19+
Desc<"If true, LLDB will save the session's transcripts before quitting. Note: transcripts will only be saved if interpreter.save-transcript is true.">;
2020
def OpenTranscriptInEditor: Property<"open-transcript-in-editor", "Boolean">,
2121
Global,
2222
DefaultTrue,

lldb/test/API/commands/session/save/TestSessionSave.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ def test_session_save(self):
8585
interpreter.HandleCommand("session save", res)
8686
self.assertTrue(res.Succeeded())
8787
raw += self.raw_transcript_builder(cmd, res)
88+
# Also check that we don't print an error message about an empty transcript.
89+
self.assertNotIn("interpreter.save-transcript is set to false", res.GetError())
8890

8991
with open(os.path.join(td.name, os.listdir(td.name)[0]), "r") as file:
9092
content = file.read()
@@ -93,6 +95,36 @@ def test_session_save(self):
9395
for line in lines:
9496
self.assertIn(line, content)
9597

98+
@no_debug_info_test
99+
def test_session_save_no_transcript_warning(self):
100+
interpreter = self.dbg.GetCommandInterpreter()
101+
102+
self.runCmd("settings set interpreter.save-transcript false")
103+
104+
# These commands won't be saved, so are arbitrary.
105+
commands = [
106+
"p 1",
107+
"settings set interpreter.save-session-on-quit true",
108+
"fr v",
109+
"settings set interpreter.echo-comment-commands true",
110+
]
111+
112+
for command in commands:
113+
res = lldb.SBCommandReturnObject()
114+
interpreter.HandleCommand(command, res)
115+
116+
output_file = self.getBuildArtifact("my-session")
117+
118+
res = lldb.SBCommandReturnObject()
119+
interpreter.HandleCommand("session save " + output_file, res)
120+
self.assertTrue(res.Succeeded())
121+
# We should warn about the setting being false.
122+
self.assertIn("interpreter.save-transcript is set to false", res.GetError())
123+
self.assertTrue(
124+
os.path.getsize(output_file) == 0,
125+
"Output file should be empty since we didn't save the transcript.",
126+
)
127+
96128
@no_debug_info_test
97129
def test_session_save_on_quit(self):
98130
raw = ""

0 commit comments

Comments
 (0)