diff options
author | Pavel Labath <labath@google.com> | 2015-03-20 09:43:20 +0000 |
---|---|---|
committer | Pavel Labath <labath@google.com> | 2015-03-20 09:43:20 +0000 |
commit | 8ac06996bf6e602888692df1836eeec02966db16 (patch) | |
tree | 82d7c0738411b864f679e09f333b382741b9094f /lldb/source/Core/Debugger.cpp | |
parent | 0068cb2499653e8874c2a24d3efbb0b1c0871a91 (diff) | |
download | bcm5719-llvm-8ac06996bf6e602888692df1836eeec02966db16.tar.gz bcm5719-llvm-8ac06996bf6e602888692df1836eeec02966db16.zip |
Support for truncate/append on log files
Summary:
Presently, if a log file already exists, lldb simply starts overwriting bits of it, without
truncating or anything. This patch makes it use eFileOptionFileTruncate by default. It also adds
an --append option, which will append to the file without truncating. A test is included.
Reviewers: clayborg
Subscribers: lldb-commits
Differential Revision: http://reviews.llvm.org/D8450
llvm-svn: 232801
Diffstat (limited to 'lldb/source/Core/Debugger.cpp')
-rw-r--r-- | lldb/source/Core/Debugger.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index f93da0eb5cd..7134d418ead 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -1331,7 +1331,12 @@ Debugger::EnableLog (const char *channel, const char **categories, const char *l log_stream_sp = pos->second.lock(); if (!log_stream_sp) { - log_stream_sp.reset (new StreamFile (log_file)); + uint32_t options = File::eOpenOptionWrite | File::eOpenOptionCanCreate + | File::eOpenOptionCloseOnExec | File::eOpenOptionAppend; + if (! (log_options & LLDB_LOG_OPTION_APPEND)) + options |= File::eOpenOptionTruncate; + + log_stream_sp.reset (new StreamFile (log_file, options)); m_log_streams[log_file] = log_stream_sp; } } |