JDevlieghere updated this revision to Diff 472812. JDevlieghere marked an inline comment as done. JDevlieghere added a comment.
Rebase CHANGES SINCE LAST ACTION https://reviews.llvm.org/D135631/new/ https://reviews.llvm.org/D135631 Files: lldb/source/Core/Debugger.cpp lldb/test/Shell/Diagnostics/Inputs/TestCopyLogs.in lldb/test/Shell/Diagnostics/TestCopyLogs.test Index: lldb/test/Shell/Diagnostics/TestCopyLogs.test =================================================================== --- /dev/null +++ lldb/test/Shell/Diagnostics/TestCopyLogs.test @@ -0,0 +1,10 @@ +# RUN: rm -rf %t +# RUN: mkdir -p %t + +# Prevent lit from substituting 'lldb' +# RUN: %python -c 'print("log enable " + "".join(["l", "l", "d", "b"]) + " commands -f %t/commands.log")' > %t.in + +# RUN: %lldb -s %t.in -o 'diagnostics dump -d %t/diags' + +# RUN: cat %t/diags/commands.log | FileCheck %s +# CHECK: Processing command: diagnostics dump Index: lldb/test/Shell/Diagnostics/Inputs/TestCopyLogs.in =================================================================== --- /dev/null +++ lldb/test/Shell/Diagnostics/Inputs/TestCopyLogs.in @@ -0,0 +1 @@ +log enable lldb commands -f %t/commands.log Index: lldb/source/Core/Debugger.cpp =================================================================== --- lldb/source/Core/Debugger.cpp +++ lldb/source/Core/Debugger.cpp @@ -810,6 +810,22 @@ if (!GetOutputFile().GetIsTerminalWithColors()) SetUseColor(false); + if (Diagnostics::Enabled()) { + Diagnostics::Instance().AddCallback( + [&](const FileSpec &dir) -> llvm::Error { + for (auto &entry : m_stream_handlers) { + llvm::StringRef log_path = entry.first(); + llvm::StringRef file_name = llvm::sys::path::filename(log_path); + FileSpec destination = dir.CopyByAppendingPathComponent(file_name); + std::error_code ec = + llvm::sys::fs::copy_file(entry.first(), destination.GetPath()); + if (ec) + return llvm::errorCodeToError(ec); + } + return llvm::Error::success(); + }); + } + #if defined(_WIN32) && defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING) // Enabling use of ANSI color codes because LLDB is using them to highlight // text.
Index: lldb/test/Shell/Diagnostics/TestCopyLogs.test =================================================================== --- /dev/null +++ lldb/test/Shell/Diagnostics/TestCopyLogs.test @@ -0,0 +1,10 @@ +# RUN: rm -rf %t +# RUN: mkdir -p %t + +# Prevent lit from substituting 'lldb' +# RUN: %python -c 'print("log enable " + "".join(["l", "l", "d", "b"]) + " commands -f %t/commands.log")' > %t.in + +# RUN: %lldb -s %t.in -o 'diagnostics dump -d %t/diags' + +# RUN: cat %t/diags/commands.log | FileCheck %s +# CHECK: Processing command: diagnostics dump Index: lldb/test/Shell/Diagnostics/Inputs/TestCopyLogs.in =================================================================== --- /dev/null +++ lldb/test/Shell/Diagnostics/Inputs/TestCopyLogs.in @@ -0,0 +1 @@ +log enable lldb commands -f %t/commands.log Index: lldb/source/Core/Debugger.cpp =================================================================== --- lldb/source/Core/Debugger.cpp +++ lldb/source/Core/Debugger.cpp @@ -810,6 +810,22 @@ if (!GetOutputFile().GetIsTerminalWithColors()) SetUseColor(false); + if (Diagnostics::Enabled()) { + Diagnostics::Instance().AddCallback( + [&](const FileSpec &dir) -> llvm::Error { + for (auto &entry : m_stream_handlers) { + llvm::StringRef log_path = entry.first(); + llvm::StringRef file_name = llvm::sys::path::filename(log_path); + FileSpec destination = dir.CopyByAppendingPathComponent(file_name); + std::error_code ec = + llvm::sys::fs::copy_file(entry.first(), destination.GetPath()); + if (ec) + return llvm::errorCodeToError(ec); + } + return llvm::Error::success(); + }); + } + #if defined(_WIN32) && defined(ENABLE_VIRTUAL_TERMINAL_PROCESSING) // Enabling use of ANSI color codes because LLDB is using them to highlight // text.
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits