[Lldb-commits] [lldb] r296329 - Log: Fix a regression in handling log options
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Mon Feb 27 03:05:39 PST 2017
Author: labath
Date: Mon Feb 27 05:05:39 2017
New Revision: 296329
URL: http://llvm.org/viewvc/llvm-project?rev=296329&view=rev
Log:
Log: Fix a regression in handling log options
The channel refactor introduced a regression where we were not honoring
the log options passed when enabling the channel. Fix that and add a
test.
Modified:
lldb/trunk/include/lldb/Core/Log.h
lldb/trunk/source/Core/Log.cpp
lldb/trunk/unittests/Core/LogTest.cpp
Modified: lldb/trunk/include/lldb/Core/Log.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Log.h?rev=296329&r1=296328&r2=296329&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Log.h (original)
+++ lldb/trunk/include/lldb/Core/Log.h Mon Feb 27 05:05:39 2017
@@ -86,7 +86,7 @@ public:
// Calls to Enable and disable need to be serialized externally.
void Enable(Log &log, const std::shared_ptr<llvm::raw_ostream> &stream_sp,
- uint32_t flags);
+ uint32_t options, uint32_t flags);
// Calls to Enable and disable need to be serialized externally.
void Disable(uint32_t flags);
Modified: lldb/trunk/source/Core/Log.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Log.cpp?rev=296329&r1=296328&r2=296329&view=diff
==============================================================================
--- lldb/trunk/source/Core/Log.cpp (original)
+++ lldb/trunk/source/Core/Log.cpp Mon Feb 27 05:05:39 2017
@@ -89,9 +89,10 @@ static uint32_t GetFlags(Stream &stream,
void Log::Channel::Enable(Log &log,
const std::shared_ptr<llvm::raw_ostream> &stream_sp,
- uint32_t flags) {
+ uint32_t options, uint32_t flags) {
log.GetMask().Set(flags);
if (log.GetMask().Get()) {
+ log.GetOptions().Set(options);
log.SetStream(stream_sp);
log_ptr.store(&log, std::memory_order_release);
}
@@ -283,7 +284,8 @@ bool Log::EnableLogChannel(
uint32_t flags = categories && categories[0]
? GetFlags(error_stream, *iter, categories)
: iter->second.channel.default_flags;
- iter->second.channel.Enable(iter->second.log, log_stream_sp, flags);
+ iter->second.channel.Enable(iter->second.log, log_stream_sp, log_options,
+ flags);
return true;
}
Modified: lldb/trunk/unittests/Core/LogTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Core/LogTest.cpp?rev=296329&r1=296328&r2=296329&view=diff
==============================================================================
--- lldb/trunk/unittests/Core/LogTest.cpp (original)
+++ lldb/trunk/unittests/Core/LogTest.cpp Mon Feb 27 05:05:39 2017
@@ -130,6 +130,20 @@ TEST_F(LogChannelTest, Enable) {
EXPECT_NE(nullptr, test_channel.GetLogIfAll(FOO | BAR));
}
+TEST_F(LogChannelTest, EnableOptions) {
+ EXPECT_EQ(nullptr, test_channel.GetLogIfAll(FOO));
+ std::string message;
+ std::shared_ptr<llvm::raw_string_ostream> stream_sp(
+ new llvm::raw_string_ostream(message));
+ StreamString err;
+ EXPECT_TRUE(Log::EnableLogChannel(stream_sp, LLDB_LOG_OPTION_VERBOSE, "chan",
+ nullptr, err));
+
+ Log *log = test_channel.GetLogIfAll(FOO);
+ ASSERT_NE(nullptr, log);
+ EXPECT_TRUE(log->GetVerbose());
+}
+
TEST_F(LogChannelTest, Disable) {
EXPECT_EQ(nullptr, test_channel.GetLogIfAll(FOO));
const char *cat12[] = {"foo", "bar", nullptr};
More information about the lldb-commits
mailing list