Skip to content

Commit a007a6d

Browse files
committed
[lldb] Convert "LLDB" log channel to the new API
1 parent 574ad2a commit a007a6d

File tree

214 files changed

+960
-1118
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

214 files changed

+960
-1118
lines changed

lldb/include/lldb/Interpreter/ScriptedInterface.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ class ScriptedInterface {
3434
static Ret ErrorWithMessage(llvm::StringRef caller_name,
3535
llvm::StringRef error_msg, Status &error,
3636
LLDBLog log_caterogy = LLDBLog::Process) {
37-
LLDB_LOGF(GetLogIfAllCategoriesSet(log_caterogy), "%s ERROR = %s",
38-
caller_name.data(), error_msg.data());
37+
LLDB_LOGF(GetLog(log_caterogy), "%s ERROR = %s", caller_name.data(),
38+
error_msg.data());
3939
error.SetErrorString(llvm::Twine(caller_name + llvm::Twine(" ERROR = ") +
4040
llvm::Twine(error_msg))
4141
.str());

lldb/include/lldb/Utility/Logging.h

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -52,43 +52,6 @@ enum class LLDBLog : Log::MaskType {
5252

5353
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
5454

55-
// Log Bits specific to logging in lldb
56-
#define LIBLLDB_LOG_PROCESS ::lldb_private::LLDBLog::Process
57-
#define LIBLLDB_LOG_THREAD ::lldb_private::LLDBLog::Thread
58-
#define LIBLLDB_LOG_DYNAMIC_LOADER ::lldb_private::LLDBLog::DynamicLoader
59-
#define LIBLLDB_LOG_EVENTS ::lldb_private::LLDBLog::Events
60-
#define LIBLLDB_LOG_BREAKPOINTS ::lldb_private::LLDBLog::Breakpoints
61-
#define LIBLLDB_LOG_WATCHPOINTS ::lldb_private::LLDBLog::Watchpoints
62-
#define LIBLLDB_LOG_STEP ::lldb_private::LLDBLog::Step
63-
#define LIBLLDB_LOG_EXPRESSIONS ::lldb_private::LLDBLog::Expressions
64-
#define LIBLLDB_LOG_TEMPORARY ::lldb_private::LLDBLog::Temporary
65-
#define LIBLLDB_LOG_STATE ::lldb_private::LLDBLog::State
66-
#define LIBLLDB_LOG_OBJECT ::lldb_private::LLDBLog::Object
67-
#define LIBLLDB_LOG_COMMUNICATION ::lldb_private::LLDBLog::Communication
68-
#define LIBLLDB_LOG_CONNECTION ::lldb_private::LLDBLog::Connection
69-
#define LIBLLDB_LOG_HOST ::lldb_private::LLDBLog::Host
70-
#define LIBLLDB_LOG_UNWIND ::lldb_private::LLDBLog::Unwind
71-
#define LIBLLDB_LOG_API ::lldb_private::LLDBLog::API
72-
#define LIBLLDB_LOG_SCRIPT ::lldb_private::LLDBLog::Script
73-
#define LIBLLDB_LOG_COMMANDS ::lldb_private::LLDBLog::Commands
74-
#define LIBLLDB_LOG_TYPES ::lldb_private::LLDBLog::Types
75-
#define LIBLLDB_LOG_SYMBOLS ::lldb_private::LLDBLog::Symbols
76-
#define LIBLLDB_LOG_MODULES ::lldb_private::LLDBLog::Modules
77-
#define LIBLLDB_LOG_TARGET ::lldb_private::LLDBLog::Target
78-
#define LIBLLDB_LOG_MMAP ::lldb_private::LLDBLog::MMap
79-
#define LIBLLDB_LOG_OS ::lldb_private::LLDBLog::OS
80-
#define LIBLLDB_LOG_PLATFORM ::lldb_private::LLDBLog::Platform
81-
#define LIBLLDB_LOG_SYSTEM_RUNTIME ::lldb_private::LLDBLog::SystemRuntime
82-
#define LIBLLDB_LOG_JIT_LOADER ::lldb_private::LLDBLog::JITLoader
83-
#define LIBLLDB_LOG_LANGUAGE ::lldb_private::LLDBLog::Language
84-
#define LIBLLDB_LOG_DATAFORMATTERS ::lldb_private::LLDBLog::DataFormatters
85-
#define LIBLLDB_LOG_DEMANGLE ::lldb_private::LLDBLog::Demangle
86-
#define LIBLLDB_LOG_AST ::lldb_private::LLDBLog::AST
87-
88-
Log *GetLogIfAllCategoriesSet(LLDBLog mask);
89-
90-
Log *GetLogIfAnyCategoriesSet(LLDBLog mask);
91-
9255
void InitializeLldbChannel();
9356

9457
template <> Log::Channel &LogChannelFor<LLDBLog>();

lldb/source/API/SBDebugger.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ lldb::SBTarget SBDebugger::CreateTarget(const char *filename,
760760
sb_error.SetErrorString("invalid debugger");
761761
}
762762

763-
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
763+
Log *log = GetLog(LLDBLog::API);
764764
LLDB_LOGF(log,
765765
"SBDebugger(%p)::CreateTarget (filename=\"%s\", triple=%s, "
766766
"platform_name=%s, add_dependent_modules=%u, error=%s) => "
@@ -788,7 +788,7 @@ SBDebugger::CreateTargetWithFileAndTargetTriple(const char *filename,
788788
sb_target.SetSP(target_sp);
789789
}
790790

791-
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
791+
Log *log = GetLog(LLDBLog::API);
792792
LLDB_LOGF(log,
793793
"SBDebugger(%p)::CreateTargetWithFileAndTargetTriple "
794794
"(filename=\"%s\", triple=%s) => SBTarget(%p)",
@@ -802,7 +802,7 @@ SBTarget SBDebugger::CreateTargetWithFileAndArch(const char *filename,
802802
const char *arch_cstr) {
803803
LLDB_INSTRUMENT_VA(this, filename, arch_cstr);
804804

805-
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
805+
Log *log = GetLog(LLDBLog::API);
806806

807807
SBTarget sb_target;
808808
TargetSP target_sp;
@@ -858,7 +858,7 @@ SBTarget SBDebugger::CreateTarget(const char *filename) {
858858
if (error.Success())
859859
sb_target.SetSP(target_sp);
860860
}
861-
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
861+
Log *log = GetLog(LLDBLog::API);
862862
LLDB_LOGF(log,
863863
"SBDebugger(%p)::CreateTarget (filename=\"%s\") => SBTarget(%p)",
864864
static_cast<void *>(m_opaque_sp.get()), filename,
@@ -873,7 +873,7 @@ SBTarget SBDebugger::GetDummyTarget() {
873873
if (m_opaque_sp) {
874874
sb_target.SetSP(m_opaque_sp->GetDummyTarget().shared_from_this());
875875
}
876-
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
876+
Log *log = GetLog(LLDBLog::API);
877877
LLDB_LOGF(log, "SBDebugger(%p)::GetDummyTarget() => SBTarget(%p)",
878878
static_cast<void *>(m_opaque_sp.get()),
879879
static_cast<void *>(sb_target.GetSP().get()));
@@ -894,7 +894,7 @@ bool SBDebugger::DeleteTarget(lldb::SBTarget &target) {
894894
}
895895
}
896896

897-
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
897+
Log *log = GetLog(LLDBLog::API);
898898
LLDB_LOGF(log, "SBDebugger(%p)::DeleteTarget (SBTarget(%p)) => %i",
899899
static_cast<void *>(m_opaque_sp.get()),
900900
static_cast<void *>(target.m_opaque_sp.get()), result);
@@ -977,7 +977,7 @@ uint32_t SBDebugger::GetNumTargets() {
977977
SBTarget SBDebugger::GetSelectedTarget() {
978978
LLDB_INSTRUMENT_VA(this);
979979

980-
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
980+
Log *log = GetLog(LLDBLog::API);
981981

982982
SBTarget sb_target;
983983
TargetSP target_sp;
@@ -1001,7 +1001,7 @@ SBTarget SBDebugger::GetSelectedTarget() {
10011001
void SBDebugger::SetSelectedTarget(SBTarget &sb_target) {
10021002
LLDB_INSTRUMENT_VA(this, sb_target);
10031003

1004-
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1004+
Log *log = GetLog(LLDBLog::API);
10051005

10061006
TargetSP target_sp(sb_target.GetSP());
10071007
if (m_opaque_sp) {
@@ -1019,7 +1019,7 @@ void SBDebugger::SetSelectedTarget(SBTarget &sb_target) {
10191019
SBPlatform SBDebugger::GetSelectedPlatform() {
10201020
LLDB_INSTRUMENT_VA(this);
10211021

1022-
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1022+
Log *log = GetLog(LLDBLog::API);
10231023

10241024
SBPlatform sb_platform;
10251025
DebuggerSP debugger_sp(m_opaque_sp);
@@ -1036,7 +1036,7 @@ SBPlatform SBDebugger::GetSelectedPlatform() {
10361036
void SBDebugger::SetSelectedPlatform(SBPlatform &sb_platform) {
10371037
LLDB_INSTRUMENT_VA(this, sb_platform);
10381038

1039-
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1039+
Log *log = GetLog(LLDBLog::API);
10401040

10411041
DebuggerSP debugger_sp(m_opaque_sp);
10421042
if (debugger_sp) {
@@ -1123,7 +1123,7 @@ void SBDebugger::DispatchInput(void *baton, const void *data, size_t data_len) {
11231123
void SBDebugger::DispatchInput(const void *data, size_t data_len) {
11241124
LLDB_INSTRUMENT_VA(this, data, data_len);
11251125

1126-
// Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1126+
// Log *log(GetLog (LLDBLog::API));
11271127
//
11281128
// if (log)
11291129
// LLDB_LOGF(log, "SBDebugger(%p)::DispatchInput (data=\"%.*s\",
@@ -1312,7 +1312,7 @@ void SBDebugger::SetTerminalWidth(uint32_t term_width) {
13121312
const char *SBDebugger::GetPrompt() const {
13131313
LLDB_INSTRUMENT_VA(this);
13141314

1315-
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
1315+
Log *log = GetLog(LLDBLog::API);
13161316

13171317
LLDB_LOGF(log, "SBDebugger(%p)::GetPrompt () => \"%s\"",
13181318
static_cast<void *>(m_opaque_sp.get()),

lldb/source/API/SBFrame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ lldb::SBValue SBFrame::EvaluateExpression(const char *expr,
10331033
const SBExpressionOptions &options) {
10341034
LLDB_INSTRUMENT_VA(this, expr, options);
10351035

1036-
Log *expr_log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
1036+
Log *expr_log = GetLog(LLDBLog::Expressions);
10371037

10381038
SBValue expr_result;
10391039

lldb/source/API/SBStream.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void SBStream::RedirectToFile(const char *path, bool append) {
9898
llvm::Expected<FileUP> file =
9999
FileSystem::Instance().Open(FileSpec(path), open_options);
100100
if (!file) {
101-
LLDB_LOG_ERROR(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API), file.takeError(),
101+
LLDB_LOG_ERROR(GetLog(LLDBLog::API), file.takeError(),
102102
"Cannot open {1}: {0}", path);
103103
return;
104104
}

lldb/source/API/SBTarget.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,8 +1116,7 @@ bool SBTarget::FindBreakpointsByName(const char *name,
11161116
llvm::Expected<std::vector<BreakpointSP>> expected_vector =
11171117
target_sp->GetBreakpointList().FindBreakpointsByName(name);
11181118
if (!expected_vector) {
1119-
LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS),
1120-
"invalid breakpoint name: {}",
1119+
LLDB_LOG(GetLog(LLDBLog::Breakpoints), "invalid breakpoint name: {}",
11211120
llvm::toString(expected_vector.takeError()));
11221121
return false;
11231122
}
@@ -2195,7 +2194,7 @@ lldb::SBValue SBTarget::EvaluateExpression(const char *expr,
21952194
const SBExpressionOptions &options) {
21962195
LLDB_INSTRUMENT_VA(this, expr, options);
21972196

2198-
Log *expr_log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
2197+
Log *expr_log = GetLog(LLDBLog::Expressions);
21992198
SBValue expr_result;
22002199
ValueObjectSP expr_value_sp;
22012200
TargetSP target_sp(GetSP());

lldb/source/Breakpoint/Breakpoint.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ void Breakpoint::ClearAllBreakpointSites() {
487487

488488
void Breakpoint::ModulesChanged(ModuleList &module_list, bool load,
489489
bool delete_locations) {
490-
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
490+
Log *log = GetLog(LLDBLog::Breakpoints);
491491
LLDB_LOGF(log,
492492
"Breakpoint::ModulesChanged: num_modules: %zu load: %i "
493493
"delete_locations: %i\n",
@@ -646,7 +646,7 @@ static bool SymbolContextsMightBeEquivalent(SymbolContext &old_sc,
646646

647647
void Breakpoint::ModuleReplaced(ModuleSP old_module_sp,
648648
ModuleSP new_module_sp) {
649-
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
649+
Log *log = GetLog(LLDBLog::Breakpoints);
650650
LLDB_LOGF(log, "Breakpoint::ModulesReplaced for %s\n",
651651
old_module_sp->GetSpecificationDescription().c_str());
652652
// First find all the locations that are in the old module

lldb/source/Breakpoint/BreakpointLocation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ const char *BreakpointLocation::GetConditionText(size_t *hash) const {
233233

234234
bool BreakpointLocation::ConditionSaysStop(ExecutionContext &exe_ctx,
235235
Status &error) {
236-
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS);
236+
Log *log = GetLog(LLDBLog::Breakpoints);
237237

238238
std::lock_guard<std::mutex> guard(m_condition_mutex);
239239

@@ -393,7 +393,7 @@ bool BreakpointLocation::ValidForThisThread(Thread &thread) {
393393

394394
bool BreakpointLocation::ShouldStop(StoppointCallbackContext *context) {
395395
bool should_stop = true;
396-
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS);
396+
Log *log = GetLog(LLDBLog::Breakpoints);
397397

398398
// Do this first, if a location is disabled, it shouldn't increment its hit
399399
// count.
@@ -450,7 +450,7 @@ bool BreakpointLocation::ResolveBreakpointSite() {
450450
process->CreateBreakpointSite(shared_from_this(), m_owner.IsHardware());
451451

452452
if (new_id == LLDB_INVALID_BREAK_ID) {
453-
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS);
453+
Log *log = GetLog(LLDBLog::Breakpoints);
454454
if (log)
455455
log->Warning("Failed to add breakpoint site at 0x%" PRIx64,
456456
m_address.GetOpcodeLoadAddress(&m_owner.GetTarget()));

lldb/source/Breakpoint/BreakpointResolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ void BreakpointResolver::AddLocation(SearchFilter &filter,
292292
const SymbolContext &sc,
293293
bool skip_prologue,
294294
llvm::StringRef log_ident) {
295-
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
295+
Log *log = GetLog(LLDBLog::Breakpoints);
296296
Address line_start = sc.line_entry.range.GetBaseAddress();
297297
if (!line_start.IsValid()) {
298298
LLDB_LOGF(log,

lldb/source/Breakpoint/BreakpointResolverAddress.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ Searcher::CallbackReturn BreakpointResolverAddress::SearchCallback(
143143
if (bp_loc_sp && !breakpoint.IsInternal()) {
144144
StreamString s;
145145
bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
146-
Log *log(
147-
lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
146+
Log *log = GetLog(LLDBLog::Breakpoints);
148147
LLDB_LOGF(log, "Added location: %s\n", s.GetData());
149148
}
150149
} else {

lldb/source/Breakpoint/BreakpointResolverFileLine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void BreakpointResolverFileLine::FilterContexts(SymbolContextList &sc_list,
127127
if (is_relative)
128128
relative_path = m_location_spec.GetFileSpec().GetDirectory().GetStringRef();
129129

130-
Log * log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS);
130+
Log *log = GetLog(LLDBLog::Breakpoints);
131131
for(uint32_t i = 0; i < sc_list.GetSize(); ++i) {
132132
SymbolContext sc;
133133
sc_list.GetContextAtIndex(i, sc);

lldb/source/Breakpoint/BreakpointResolverName.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ BreakpointResolverName::BreakpointResolverName(const BreakpointSP &bkpt,
3333
if (m_match_type == Breakpoint::Regexp) {
3434
m_regex = RegularExpression(name_cstr);
3535
if (!m_regex.IsValid()) {
36-
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
36+
Log *log = GetLog(LLDBLog::Breakpoints);
3737

3838
if (log)
3939
log->Warning("function name regexp: \"%s\" did not compile.",
@@ -252,7 +252,7 @@ void BreakpointResolverName::AddNameLookup(ConstString name,
252252
Searcher::CallbackReturn
253253
BreakpointResolverName::SearchCallback(SearchFilter &filter,
254254
SymbolContext &context, Address *addr) {
255-
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
255+
Log *log = GetLog(LLDBLog::Breakpoints);
256256

257257
if (m_class_name) {
258258
if (log)

lldb/source/Breakpoint/Watchpoint.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ Watchpoint::Watchpoint(Target &target, lldb::addr_t addr, uint32_t size,
4040
auto type_system_or_err =
4141
target.GetScratchTypeSystemForLanguage(eLanguageTypeC);
4242
if (auto err = type_system_or_err.takeError()) {
43-
LLDB_LOG_ERROR(
44-
lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_WATCHPOINTS),
45-
std::move(err), "Failed to set type.");
43+
LLDB_LOG_ERROR(GetLog(LLDBLog::Watchpoints), std::move(err),
44+
"Failed to set type.");
4645
} else {
4746
m_type = type_system_or_err->GetBuiltinTypeForEncodingAndBitSize(
4847
eEncodingUint, 8 * size);

lldb/source/Commands/CommandObjectTarget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ class CommandObjectTargetModulesSearchPathsAdd : public CommandObjectParsed {
10341034
const char *to = command.GetArgumentAtIndex(i + 1);
10351035

10361036
if (from[0] && to[0]) {
1037-
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
1037+
Log *log = GetLog(LLDBLog::Host);
10381038
if (log) {
10391039
LLDB_LOGF(log,
10401040
"target modules search path adding ImageSearchPath "

lldb/source/Core/AddressResolverFileLine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ AddressResolverFileLine::SearchCallback(SearchFilter &filter,
4040
SymbolContextList sc_list;
4141
CompileUnit *cu = context.comp_unit;
4242

43-
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
43+
Log *log = GetLog(LLDBLog::Breakpoints);
4444

4545
// TODO: Handle SourceLocationSpec column information
4646
cu->ResolveSymbolContext(m_src_location_spec, eSymbolContextEverything,

0 commit comments

Comments
 (0)