[Lldb-commits] [lldb] c5e417a - [lldb] Fix 'session save' command on Windows
Vladislav Dzhidzhoev via lldb-commits
lldb-commits at lists.llvm.org
Fri May 31 08:19:17 PDT 2024
Author: Vladislav Dzhidzhoev
Date: 2024-05-31T17:18:21+02:00
New Revision: c5e417a812d86226b087346cadb05d3aae9fe1d0
URL: https://github.com/llvm/llvm-project/commit/c5e417a812d86226b087346cadb05d3aae9fe1d0
DIFF: https://github.com/llvm/llvm-project/commit/c5e417a812d86226b087346cadb05d3aae9fe1d0.diff
LOG: [lldb] Fix 'session save' command on Windows
1. Use dashes (-) instead of colons (:) as time separator in a session log
file name since Windows doesn't support saving files with names containing
colons.
2. Temporary file creation code is changed in the test:
On Windows, the temporary file should be closed before 'session save'
writes session log to it. NamedTemporaryFile() can preserve the file
after closing it with delete_on_close=False option.
However, this option is only available since Python 3.12. Thus
mkstemp() is used for temporary file creation as the more compatible
option.
Added:
Modified:
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/test/API/commands/session/save/TestSessionSave.py
Removed:
################################################################################
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 7f21f382adb83..6a61882df093d 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -3235,6 +3235,8 @@ bool CommandInterpreter::SaveTranscript(
if (output_file == std::nullopt || output_file->empty()) {
std::string now = llvm::to_string(std::chrono::system_clock::now());
std::replace(now.begin(), now.end(), ' ', '_');
+ // Can't have file name with colons on Windows
+ std::replace(now.begin(), now.end(), ':', '-');
const std::string file_name = "lldb_session_" + now + ".log";
FileSpec save_location = GetSaveSessionDirectory();
diff --git a/lldb/test/API/commands/session/save/TestSessionSave.py b/lldb/test/API/commands/session/save/TestSessionSave.py
index 98985c66010bb..aa99bcd56aed4 100644
--- a/lldb/test/API/commands/session/save/TestSessionSave.py
+++ b/lldb/test/API/commands/session/save/TestSessionSave.py
@@ -19,7 +19,6 @@ def raw_transcript_builder(self, cmd, res):
raw += res.GetError()
return raw
- @skipIfWindows
@no_debug_info_test
def test_session_save(self):
raw = ""
@@ -61,8 +60,7 @@ def test_session_save(self):
self.assertFalse(res.Succeeded())
raw += self.raw_transcript_builder(cmd, res)
- tf = tempfile.NamedTemporaryFile()
- output_file = tf.name
+ output_file = self.getBuildArtifact('my-session')
res = lldb.SBCommandReturnObject()
interpreter.HandleCommand("session save " + output_file, res)
@@ -95,7 +93,6 @@ def test_session_save(self):
for line in lines:
self.assertIn(line, content)
- @skipIfWindows
@no_debug_info_test
def test_session_save_on_quit(self):
raw = ""
More information about the lldb-commits
mailing list