aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Utility/Logging.cpp
blob: 67d5d3af2640cb74938a0aecfa3418f38eaa8ca4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//===-- Logging.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "lldb/Utility/Logging.h"
#include "lldb/Utility/Log.h"

#include "llvm/ADT/ArrayRef.h"

#include <cstdarg>

using namespace lldb_private;

static constexpr Log::Category g_categories[] = {
    {{"api"}, {"log API calls and return values"}, LLDBLog::API},
    {{"ast"}, {"log AST"}, LLDBLog::AST},
    {{"break"}, {"log breakpoints"}, LLDBLog::Breakpoints},
    {{"commands"}, {"log command argument parsing"}, LLDBLog::Commands},
    {{"comm"}, {"log communication activities"}, LLDBLog::Communication},
    {{"conn"}, {"log connection details"}, LLDBLog::Connection},
    {{"demangle"},
     {"log mangled names to catch demangler crashes"},
     LLDBLog::Demangle},
    {{"dyld"},
     {"log shared library related activities"},
     LLDBLog::DynamicLoader},
    {{"event"},
     {"log broadcaster, listener and event queue activities"},
     LLDBLog::Events},
    {{"expr"}, {"log expressions"}, LLDBLog::Expressions},
    {{"formatters"},
     {"log data formatters related activities"},
     LLDBLog::DataFormatters},
    {{"host"}, {"log host activities"}, LLDBLog::Host},
    {{"jit"}, {"log JIT events in the target"}, LLDBLog::JITLoader},
    {{"language"}, {"log language runtime events"}, LLDBLog::Language},
    {{"mmap"}, {"log mmap related activities"}, LLDBLog::MMap},
    {{"module"},
     {"log module activities such as when modules are created, destroyed, "
      "replaced, and more"},
     LLDBLog::Modules},
    {{"object"},
     {"log object construction/destruction for important objects"},
     LLDBLog::Object},
    {{"os"}, {"log OperatingSystem plugin related activities"}, LLDBLog::OS},
    {{"platform"}, {"log platform events and activities"}, LLDBLog::Platform},
    {{"process"}, {"log process events and activities"}, LLDBLog::Process},
    {{"script"}, {"log events about the script interpreter"}, LLDBLog::Script},
    {{"state"},
     {"log private and public process state changes"},
     LLDBLog::State},
    {{"step"}, {"log step related activities"}, LLDBLog::Step},
    {{"symbol"}, {"log symbol related issues and warnings"}, LLDBLog::Symbols},
    {{"system-runtime"}, {"log system runtime events"}, LLDBLog::SystemRuntime},
    {{"target"}, {"log target events and activities"}, LLDBLog::Target},
    {{"temp"}, {"log internal temporary debug messages"}, LLDBLog::Temporary},
    {{"thread"}, {"log thread events and activities"}, LLDBLog::Thread},
    {{"types"}, {"log type system related activities"}, LLDBLog::Types},
    {{"unwind"}, {"log stack unwind activities"}, LLDBLog::Unwind},
    {{"watch"}, {"log watchpoint related activities"}, LLDBLog::Watchpoints},
};

static Log::Channel g_log_channel(g_categories,
                                  LLDBLog::Process | LLDBLog::Thread |
                                      LLDBLog::DynamicLoader |
                                      LLDBLog::Breakpoints |
                                      LLDBLog::Watchpoints | LLDBLog::Step |
                                      LLDBLog::State | LLDBLog::Symbols |
                                      LLDBLog::Target | LLDBLog::Commands);

template <> Log::Channel &lldb_private::LogChannelFor<LLDBLog>() {
  return g_log_channel;
}

void lldb_private::InitializeLldbChannel() {
  Log::Register("lldb", g_log_channel);
}

Log *lldb_private::GetLogIfAllCategoriesSet(LLDBLog mask) {
  return GetLog(mask);
}

Log *lldb_private::GetLogIfAnyCategoriesSet(LLDBLog mask) {
  return GetLog(mask);
}