LLDB  mainline
Logging.cpp
Go to the documentation of this file.
1 //===-- Logging.cpp ---------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "lldb/Utility/Logging.h"
10 #include "lldb/Utility/Log.h"
11 
12 #include "llvm/ADT/ArrayRef.h"
13 
14 #include <stdarg.h>
15 
16 using namespace lldb_private;
17 
18 static constexpr Log::Category g_categories[] = {
19  {{"api"}, {"log API calls and return values"}, LIBLLDB_LOG_API},
20  {{"break"}, {"log breakpoints"}, LIBLLDB_LOG_BREAKPOINTS},
21  {{"commands"}, {"log command argument parsing"}, LIBLLDB_LOG_COMMANDS},
22  {{"comm"}, {"log communication activities"}, LIBLLDB_LOG_COMMUNICATION},
23  {{"conn"}, {"log connection details"}, LIBLLDB_LOG_CONNECTION},
24  {{"demangle"}, {"log mangled names to catch demangler crashes"}, LIBLLDB_LOG_DEMANGLE},
25  {{"dyld"}, {"log shared library related activities"}, LIBLLDB_LOG_DYNAMIC_LOADER},
26  {{"event"}, {"log broadcaster, listener and event queue activities"}, LIBLLDB_LOG_EVENTS},
27  {{"expr"}, {"log expressions"}, LIBLLDB_LOG_EXPRESSIONS},
28  {{"formatters"}, {"log data formatters related activities"}, LIBLLDB_LOG_DATAFORMATTERS},
29  {{"host"}, {"log host activities"}, LIBLLDB_LOG_HOST},
30  {{"jit"}, {"log JIT events in the target"}, LIBLLDB_LOG_JIT_LOADER},
31  {{"language"}, {"log language runtime events"}, LIBLLDB_LOG_LANGUAGE},
32  {{"mmap"}, {"log mmap related activities"}, LIBLLDB_LOG_MMAP},
33  {{"module"}, {"log module activities such as when modules are created, destroyed, replaced, and more"}, LIBLLDB_LOG_MODULES},
34  {{"object"}, {"log object construction/destruction for important objects"}, LIBLLDB_LOG_OBJECT},
35  {{"os"}, {"log OperatingSystem plugin related activities"}, LIBLLDB_LOG_OS},
36  {{"platform"}, {"log platform events and activities"}, LIBLLDB_LOG_PLATFORM},
37  {{"process"}, {"log process events and activities"}, LIBLLDB_LOG_PROCESS},
38  {{"script"}, {"log events about the script interpreter"}, LIBLLDB_LOG_SCRIPT},
39  {{"state"}, {"log private and public process state changes"}, LIBLLDB_LOG_STATE},
40  {{"step"}, {"log step related activities"}, LIBLLDB_LOG_STEP},
41  {{"symbol"}, {"log symbol related issues and warnings"}, LIBLLDB_LOG_SYMBOLS},
42  {{"system-runtime"}, {"log system runtime events"}, LIBLLDB_LOG_SYSTEM_RUNTIME},
43  {{"target"}, {"log target events and activities"}, LIBLLDB_LOG_TARGET},
44  {{"temp"}, {"log internal temporary debug messages"}, LIBLLDB_LOG_TEMPORARY},
45  {{"thread"}, {"log thread events and activities"}, LIBLLDB_LOG_THREAD},
46  {{"types"}, {"log type system related activities"}, LIBLLDB_LOG_TYPES},
47  {{"unwind"}, {"log stack unwind activities"}, LIBLLDB_LOG_UNWIND},
48  {{"watch"}, {"log watchpoint related activities"}, LIBLLDB_LOG_WATCHPOINTS},
49 };
50 
52 
54  Log::Register("lldb", g_log_channel);
55 }
56 
58  return g_log_channel.GetLogIfAll(mask);
59 }
60 
62  return g_log_channel.GetLogIfAny(mask);
63 }
64 
65 
66 void lldb_private::LogIfAnyCategoriesSet(uint32_t mask, const char *format, ...) {
67  if (Log *log = GetLogIfAnyCategoriesSet(mask)) {
68  va_list args;
69  va_start(args, format);
70  log->VAPrintf(format, args);
71  va_end(args);
72  }
73 }
#define LIBLLDB_LOG_SYSTEM_RUNTIME
Definition: Logging.h:40
#define LIBLLDB_LOG_DATAFORMATTERS
Definition: Logging.h:43
#define LIBLLDB_LOG_OBJECT
Definition: Logging.h:25
#define LIBLLDB_LOG_PROCESS
Definition: Logging.h:15
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
void LogIfAnyCategoriesSet(uint32_t mask, const char *format,...)
Definition: Logging.cpp:66
void InitializeLldbChannel()
Definition: Logging.cpp:53
#define LIBLLDB_LOG_MMAP
Definition: Logging.h:37
#define LIBLLDB_LOG_PLATFORM
Definition: Logging.h:39
#define LIBLLDB_LOG_MODULES
Definition: Logging.h:35
#define LIBLLDB_LOG_DEMANGLE
Definition: Logging.h:44
#define LIBLLDB_LOG_UNWIND
Definition: Logging.h:29
#define LIBLLDB_LOG_LANGUAGE
Definition: Logging.h:42
#define LIBLLDB_LOG_WATCHPOINTS
Definition: Logging.h:20
static void Register(llvm::StringRef name, Channel &channel)
Definition: Log.cpp:180
Log * GetLogIfAll(uint32_t mask)
Definition: Log.h:76
#define LIBLLDB_LOG_SYMBOLS
Definition: Logging.h:34
#define LIBLLDB_LOG_API
Definition: Logging.h:30
#define LIBLLDB_LOG_EVENTS
Definition: Logging.h:18
#define LIBLLDB_LOG_TEMPORARY
Definition: Logging.h:23
#define LIBLLDB_LOG_HOST
Definition: Logging.h:28
Log * GetLogIfAllCategoriesSet(uint32_t mask)
Definition: Logging.cpp:57
#define LIBLLDB_LOG_THREAD
Definition: Logging.h:16
#define LIBLLDB_LOG_OS
Definition: Logging.h:38
#define LIBLLDB_LOG_BREAKPOINTS
Definition: Logging.h:19
#define LIBLLDB_LOG_STATE
Definition: Logging.h:24
#define LIBLLDB_LOG_TARGET
Definition: Logging.h:36
#define LIBLLDB_LOG_COMMANDS
Definition: Logging.h:32
#define LIBLLDB_LOG_DYNAMIC_LOADER
Definition: Logging.h:17
static constexpr Log::Category g_categories[]
Definition: Logging.cpp:18
Log * GetLogIfAnyCategoriesSet(uint32_t mask)
Definition: Logging.cpp:61
#define LIBLLDB_LOG_JIT_LOADER
Definition: Logging.h:41
#define LIBLLDB_LOG_CONNECTION
Definition: Logging.h:27
#define LIBLLDB_LOG_SCRIPT
Definition: Logging.h:31
#define LIBLLDB_LOG_EXPRESSIONS
Definition: Logging.h:22
#define LIBLLDB_LOG_TYPES
Definition: Logging.h:33
#define LIBLLDB_LOG_COMMUNICATION
Definition: Logging.h:26
#define LIBLLDB_LOG_STEP
Definition: Logging.h:21
static Log::Channel g_log_channel(g_categories, LIBLLDB_LOG_DEFAULT)
#define LIBLLDB_LOG_DEFAULT
Definition: Logging.h:46
Log * GetLogIfAny(uint32_t mask)
Definition: Log.h:87