diff --git a/lldb/include/lldb/Core/Log.h b/lldb/include/lldb/Core/Log.h index 34396dde532bc..d6c676ee589d0 100644 --- a/lldb/include/lldb/Core/Log.h +++ b/lldb/include/lldb/Core/Log.h @@ -86,7 +86,7 @@ class Log final { // Calls to Enable and disable need to be serialized externally. void Enable(Log &log, const std::shared_ptr &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); diff --git a/lldb/source/Core/Log.cpp b/lldb/source/Core/Log.cpp index 24d7ce31cd294..89216f41a5bb8 100644 --- a/lldb/source/Core/Log.cpp +++ b/lldb/source/Core/Log.cpp @@ -89,9 +89,10 @@ static uint32_t GetFlags(Stream &stream, const ChannelMap::value_type &entry, void Log::Channel::Enable(Log &log, const std::shared_ptr &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; } diff --git a/lldb/unittests/Core/LogTest.cpp b/lldb/unittests/Core/LogTest.cpp index 0b9ed00bbba82..16670aafce495 100644 --- a/lldb/unittests/Core/LogTest.cpp +++ b/lldb/unittests/Core/LogTest.cpp @@ -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 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};