mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-27 03:48:33 +00:00
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. llvm-svn: 296329
This commit is contained in:
parent
6ac8403430
commit
88d081b505
@ -86,7 +86,7 @@ public:
|
|||||||
|
|
||||||
// Calls to Enable and disable need to be serialized externally.
|
// Calls to Enable and disable need to be serialized externally.
|
||||||
void Enable(Log &log, const std::shared_ptr<llvm::raw_ostream> &stream_sp,
|
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.
|
// Calls to Enable and disable need to be serialized externally.
|
||||||
void Disable(uint32_t flags);
|
void Disable(uint32_t flags);
|
||||||
|
@ -89,9 +89,10 @@ static uint32_t GetFlags(Stream &stream, const ChannelMap::value_type &entry,
|
|||||||
|
|
||||||
void Log::Channel::Enable(Log &log,
|
void Log::Channel::Enable(Log &log,
|
||||||
const std::shared_ptr<llvm::raw_ostream> &stream_sp,
|
const std::shared_ptr<llvm::raw_ostream> &stream_sp,
|
||||||
uint32_t flags) {
|
uint32_t options, uint32_t flags) {
|
||||||
log.GetMask().Set(flags);
|
log.GetMask().Set(flags);
|
||||||
if (log.GetMask().Get()) {
|
if (log.GetMask().Get()) {
|
||||||
|
log.GetOptions().Set(options);
|
||||||
log.SetStream(stream_sp);
|
log.SetStream(stream_sp);
|
||||||
log_ptr.store(&log, std::memory_order_release);
|
log_ptr.store(&log, std::memory_order_release);
|
||||||
}
|
}
|
||||||
@ -283,7 +284,8 @@ bool Log::EnableLogChannel(
|
|||||||
uint32_t flags = categories && categories[0]
|
uint32_t flags = categories && categories[0]
|
||||||
? GetFlags(error_stream, *iter, categories)
|
? GetFlags(error_stream, *iter, categories)
|
||||||
: iter->second.channel.default_flags;
|
: 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,6 +130,20 @@ TEST_F(LogChannelTest, Enable) {
|
|||||||
EXPECT_NE(nullptr, test_channel.GetLogIfAll(FOO | BAR));
|
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) {
|
TEST_F(LogChannelTest, Disable) {
|
||||||
EXPECT_EQ(nullptr, test_channel.GetLogIfAll(FOO));
|
EXPECT_EQ(nullptr, test_channel.GetLogIfAll(FOO));
|
||||||
const char *cat12[] = {"foo", "bar", nullptr};
|
const char *cat12[] = {"foo", "bar", nullptr};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user