1c34698a8SPavel Labath //===-- LLDBLog.cpp -------------------------------------------------------===//
2c34698a8SPavel Labath //
3c34698a8SPavel Labath // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4c34698a8SPavel Labath // See https://llvm.org/LICENSE.txt for license information.
5c34698a8SPavel Labath // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6c34698a8SPavel Labath //
7c34698a8SPavel Labath //===----------------------------------------------------------------------===//
8c34698a8SPavel Labath 
9c34698a8SPavel Labath #include "lldb/Utility/LLDBLog.h"
10c34698a8SPavel Labath #include "lldb/Utility/Log.h"
11c34698a8SPavel Labath #include "llvm/ADT/ArrayRef.h"
12c34698a8SPavel Labath #include <cstdarg>
13c34698a8SPavel Labath 
14c34698a8SPavel Labath using namespace lldb_private;
15c34698a8SPavel Labath 
16c34698a8SPavel Labath static constexpr Log::Category g_categories[] = {
17c34698a8SPavel Labath     {{"api"}, {"log API calls and return values"}, LLDBLog::API},
18c34698a8SPavel Labath     {{"ast"}, {"log AST"}, LLDBLog::AST},
19c34698a8SPavel Labath     {{"break"}, {"log breakpoints"}, LLDBLog::Breakpoints},
20c34698a8SPavel Labath     {{"commands"}, {"log command argument parsing"}, LLDBLog::Commands},
21c34698a8SPavel Labath     {{"comm"}, {"log communication activities"}, LLDBLog::Communication},
22c34698a8SPavel Labath     {{"conn"}, {"log connection details"}, LLDBLog::Connection},
23c34698a8SPavel Labath     {{"demangle"},
24c34698a8SPavel Labath      {"log mangled names to catch demangler crashes"},
25c34698a8SPavel Labath      LLDBLog::Demangle},
26c34698a8SPavel Labath     {{"dyld"},
27c34698a8SPavel Labath      {"log shared library related activities"},
28c34698a8SPavel Labath      LLDBLog::DynamicLoader},
29c34698a8SPavel Labath     {{"event"},
30c34698a8SPavel Labath      {"log broadcaster, listener and event queue activities"},
31c34698a8SPavel Labath      LLDBLog::Events},
32c34698a8SPavel Labath     {{"expr"}, {"log expressions"}, LLDBLog::Expressions},
33c34698a8SPavel Labath     {{"formatters"},
34c34698a8SPavel Labath      {"log data formatters related activities"},
35c34698a8SPavel Labath      LLDBLog::DataFormatters},
36c34698a8SPavel Labath     {{"host"}, {"log host activities"}, LLDBLog::Host},
37c34698a8SPavel Labath     {{"jit"}, {"log JIT events in the target"}, LLDBLog::JITLoader},
38c34698a8SPavel Labath     {{"language"}, {"log language runtime events"}, LLDBLog::Language},
39c34698a8SPavel Labath     {{"mmap"}, {"log mmap related activities"}, LLDBLog::MMap},
40c34698a8SPavel Labath     {{"module"},
41c34698a8SPavel Labath      {"log module activities such as when modules are created, destroyed, "
42c34698a8SPavel Labath       "replaced, and more"},
43c34698a8SPavel Labath      LLDBLog::Modules},
44c34698a8SPavel Labath     {{"object"},
45c34698a8SPavel Labath      {"log object construction/destruction for important objects"},
46c34698a8SPavel Labath      LLDBLog::Object},
47c34698a8SPavel Labath     {{"os"}, {"log OperatingSystem plugin related activities"}, LLDBLog::OS},
48c34698a8SPavel Labath     {{"platform"}, {"log platform events and activities"}, LLDBLog::Platform},
49c34698a8SPavel Labath     {{"process"}, {"log process events and activities"}, LLDBLog::Process},
50c34698a8SPavel Labath     {{"script"}, {"log events about the script interpreter"}, LLDBLog::Script},
51c34698a8SPavel Labath     {{"state"},
52c34698a8SPavel Labath      {"log private and public process state changes"},
53c34698a8SPavel Labath      LLDBLog::State},
54c34698a8SPavel Labath     {{"step"}, {"log step related activities"}, LLDBLog::Step},
55c34698a8SPavel Labath     {{"symbol"}, {"log symbol related issues and warnings"}, LLDBLog::Symbols},
56c34698a8SPavel Labath     {{"system-runtime"}, {"log system runtime events"}, LLDBLog::SystemRuntime},
57c34698a8SPavel Labath     {{"target"}, {"log target events and activities"}, LLDBLog::Target},
58c34698a8SPavel Labath     {{"temp"}, {"log internal temporary debug messages"}, LLDBLog::Temporary},
59c34698a8SPavel Labath     {{"thread"}, {"log thread events and activities"}, LLDBLog::Thread},
60c34698a8SPavel Labath     {{"types"}, {"log type system related activities"}, LLDBLog::Types},
61c34698a8SPavel Labath     {{"unwind"}, {"log stack unwind activities"}, LLDBLog::Unwind},
62c34698a8SPavel Labath     {{"watch"}, {"log watchpoint related activities"}, LLDBLog::Watchpoints},
63*7b81192dSJeffrey Tan     {{"on-demand"},
64*7b81192dSJeffrey Tan      {"log symbol on-demand related activities"},
65*7b81192dSJeffrey Tan      LLDBLog::OnDemand},
66c34698a8SPavel Labath };
67c34698a8SPavel Labath 
68c34698a8SPavel Labath static Log::Channel g_log_channel(g_categories,
69c34698a8SPavel Labath                                   LLDBLog::Process | LLDBLog::Thread |
70c34698a8SPavel Labath                                       LLDBLog::DynamicLoader |
71c34698a8SPavel Labath                                       LLDBLog::Breakpoints |
72c34698a8SPavel Labath                                       LLDBLog::Watchpoints | LLDBLog::Step |
73c34698a8SPavel Labath                                       LLDBLog::State | LLDBLog::Symbols |
74c34698a8SPavel Labath                                       LLDBLog::Target | LLDBLog::Commands);
75c34698a8SPavel Labath 
LogChannelFor()76c34698a8SPavel Labath template <> Log::Channel &lldb_private::LogChannelFor<LLDBLog>() {
77c34698a8SPavel Labath   return g_log_channel;
78c34698a8SPavel Labath }
79c34698a8SPavel Labath 
InitializeLldbChannel()80c34698a8SPavel Labath void lldb_private::InitializeLldbChannel() {
81c34698a8SPavel Labath   Log::Register("lldb", g_log_channel);
82c34698a8SPavel Labath }
83