diff options
author | Tom Yang <zhenyutyang@gmail.com> | 2024-10-05 00:29:44 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-05 00:29:44 -0700 |
commit | 835b5e278e525dc628d4d0c085eb272996aed466 (patch) | |
tree | 8fc751d0b67707f00b55ebeba82f2c0836b5e51a | |
parent | 554eaec63908ed20c35c8cc85304a3d44a63c634 (diff) | |
download | llvm-835b5e278e525dc628d4d0c085eb272996aed466.zip llvm-835b5e278e525dc628d4d0c085eb272996aed466.tar.gz llvm-835b5e278e525dc628d4d0c085eb272996aed466.tar.bz2 |
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 <toyang@fb.com>
4 files changed, 40 insertions, 2 deletions
diff --git a/lldb/source/Commands/CommandObjectSession.cpp b/lldb/source/Commands/CommandObjectSession.cpp index c381ba4..ac7eec5 100644 --- a/lldb/source/Commands/CommandObjectSession.cpp +++ b/lldb/source/Commands/CommandObjectSession.cpp @@ -19,7 +19,9 @@ public: : CommandObjectParsed(interpreter, "session save", "Save the current session transcripts to a file.\n" "If no file if specified, transcripts will be " - "saved to a temporary file.", + "saved to a temporary file.\n" + "Note: transcripts will only be saved if " + "interpreter.save-transcript is true.\n", "session save [file]") { AddSimpleArgumentList(eArgTypePath, eArgRepeatOptional); } diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index d17aa6f..8d3a82e 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -3308,6 +3308,10 @@ bool CommandInterpreter::SaveTranscript( result.SetStatus(eReturnStatusSuccessFinishNoResult); result.AppendMessageWithFormat("Session's transcripts saved to %s\n", output_file->c_str()); + if (!GetSaveTranscript()) + result.AppendError( + "Note: the setting interpreter.save-transcript is set to false, so the " + "transcript might not have been recorded."); if (GetOpenTranscriptInEditor() && Host::IsInteractiveGraphicSession()) { const FileSpec file_spec; diff --git a/lldb/source/Interpreter/InterpreterProperties.td b/lldb/source/Interpreter/InterpreterProperties.td index a5fccbb..834f7be 100644 --- a/lldb/source/Interpreter/InterpreterProperties.td +++ b/lldb/source/Interpreter/InterpreterProperties.td @@ -16,7 +16,7 @@ let Definition = "interpreter" in { def SaveSessionOnQuit: Property<"save-session-on-quit", "Boolean">, Global, DefaultFalse, - Desc<"If true, LLDB will save the session's transcripts before quitting.">; + Desc<"If true, LLDB will save the session's transcripts before quitting. Note: transcripts will only be saved if interpreter.save-transcript is true.">; def OpenTranscriptInEditor: Property<"open-transcript-in-editor", "Boolean">, Global, DefaultTrue, diff --git a/lldb/test/API/commands/session/save/TestSessionSave.py b/lldb/test/API/commands/session/save/TestSessionSave.py index aa99bcd..0f064e6 100644 --- a/lldb/test/API/commands/session/save/TestSessionSave.py +++ b/lldb/test/API/commands/session/save/TestSessionSave.py @@ -85,6 +85,8 @@ class SessionSaveTestCase(TestBase): interpreter.HandleCommand("session save", res) self.assertTrue(res.Succeeded()) raw += self.raw_transcript_builder(cmd, res) + # Also check that we don't print an error message about an empty transcript. + self.assertNotIn("interpreter.save-transcript is set to false", res.GetError()) with open(os.path.join(td.name, os.listdir(td.name)[0]), "r") as file: content = file.read() @@ -94,6 +96,36 @@ class SessionSaveTestCase(TestBase): self.assertIn(line, content) @no_debug_info_test + def test_session_save_no_transcript_warning(self): + interpreter = self.dbg.GetCommandInterpreter() + + self.runCmd("settings set interpreter.save-transcript false") + + # These commands won't be saved, so are arbitrary. + commands = [ + "p 1", + "settings set interpreter.save-session-on-quit true", + "fr v", + "settings set interpreter.echo-comment-commands true", + ] + + for command in commands: + res = lldb.SBCommandReturnObject() + interpreter.HandleCommand(command, res) + + output_file = self.getBuildArtifact("my-session") + + res = lldb.SBCommandReturnObject() + interpreter.HandleCommand("session save " + output_file, res) + self.assertTrue(res.Succeeded()) + # We should warn about the setting being false. + self.assertIn("interpreter.save-transcript is set to false", res.GetError()) + self.assertTrue( + os.path.getsize(output_file) == 0, + "Output file should be empty since we didn't save the transcript.", + ) + + @no_debug_info_test def test_session_save_on_quit(self): raw = "" interpreter = self.dbg.GetCommandInterpreter() |