https://github.com/dzhidzhoev updated https://github.com/llvm/llvm-project/pull/93833
>From 15acc7cdf26c06c2be0d52d8341bce2870a55606 Mon Sep 17 00:00:00 2001 From: Vladislav Dzhidzhoev <vdzhidzh...@accesssoftek.com> Date: Fri, 10 May 2024 22:59:31 +0000 Subject: [PATCH] [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. --- lldb/source/Interpreter/CommandInterpreter.cpp | 2 ++ lldb/test/API/commands/session/save/TestSessionSave.py | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) 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..1be0feb81a1c4 100644 --- a/lldb/test/API/commands/session/save/TestSessionSave.py +++ b/lldb/test/API/commands/session/save/TestSessionSave.py @@ -1,6 +1,7 @@ """ Test the session save feature """ + import os import tempfile @@ -19,7 +20,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 +61,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 +94,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 = "" _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits