Alexander Shaposhnikov | 696bd63 | 2016-11-26 05:23:44 +0000 | [diff] [blame] | 1 | //===-- Logging.cpp ---------------------------------------------*- C++ -*-===// |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Zachary Turner | 6f9e690 | 2017-03-03 20:56:28 +0000 | [diff] [blame] | 10 | #include "lldb/Utility/Logging.h" |
Zachary Turner | 6f9e690 | 2017-03-03 20:56:28 +0000 | [diff] [blame] | 11 | #include "lldb/Utility/Log.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 12 | |
Zachary Turner | 4479ac1 | 2017-04-06 18:12:24 +0000 | [diff] [blame] | 13 | #include "llvm/ADT/ArrayRef.h" // for ArrayRef |
| 14 | |
| 15 | #include <stdarg.h> // for va_end, va_list, va_start |
| 16 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 17 | using namespace lldb_private; |
| 18 | |
Pavel Labath | a2fc1e0 | 2017-02-22 11:51:12 +0000 | [diff] [blame] | 19 | static constexpr Log::Category g_categories[] = { |
| 20 | {{"api"}, {"log API calls and return values"}, LIBLLDB_LOG_API}, |
| 21 | {{"break"}, {"log breakpoints"}, LIBLLDB_LOG_BREAKPOINTS}, |
| 22 | {{"commands"}, {"log command argument parsing"}, LIBLLDB_LOG_COMMANDS}, |
| 23 | {{"comm"}, {"log communication activities"}, LIBLLDB_LOG_COMMUNICATION}, |
| 24 | {{"conn"}, {"log connection details"}, LIBLLDB_LOG_CONNECTION}, |
| 25 | {{"demangle"}, {"log mangled names to catch demangler crashes"}, LIBLLDB_LOG_DEMANGLE}, |
| 26 | {{"dyld"}, {"log shared library related activities"}, LIBLLDB_LOG_DYNAMIC_LOADER}, |
| 27 | {{"event"}, {"log broadcaster, listener and event queue activities"}, LIBLLDB_LOG_EVENTS}, |
| 28 | {{"expr"}, {"log expressions"}, LIBLLDB_LOG_EXPRESSIONS}, |
| 29 | {{"formatters"}, {"log data formatters related activities"}, LIBLLDB_LOG_DATAFORMATTERS}, |
| 30 | {{"host"}, {"log host activities"}, LIBLLDB_LOG_HOST}, |
| 31 | {{"jit"}, {"log JIT events in the target"}, LIBLLDB_LOG_JIT_LOADER}, |
| 32 | {{"language"}, {"log language runtime events"}, LIBLLDB_LOG_LANGUAGE}, |
| 33 | {{"mmap"}, {"log mmap related activities"}, LIBLLDB_LOG_MMAP}, |
| 34 | {{"module"}, {"log module activities such as when modules are created, destroyed, replaced, and more"}, LIBLLDB_LOG_MODULES}, |
| 35 | {{"object"}, {"log object construction/destruction for important objects"}, LIBLLDB_LOG_OBJECT}, |
| 36 | {{"os"}, {"log OperatingSystem plugin related activities"}, LIBLLDB_LOG_OS}, |
| 37 | {{"platform"}, {"log platform events and activities"}, LIBLLDB_LOG_PLATFORM}, |
| 38 | {{"process"}, {"log process events and activities"}, LIBLLDB_LOG_PROCESS}, |
| 39 | {{"script"}, {"log events about the script interpreter"}, LIBLLDB_LOG_SCRIPT}, |
| 40 | {{"state"}, {"log private and public process state changes"}, LIBLLDB_LOG_STATE}, |
| 41 | {{"step"}, {"log step related activities"}, LIBLLDB_LOG_STEP}, |
| 42 | {{"symbol"}, {"log symbol related issues and warnings"}, LIBLLDB_LOG_SYMBOLS}, |
| 43 | {{"system-runtime"}, {"log system runtime events"}, LIBLLDB_LOG_SYSTEM_RUNTIME}, |
| 44 | {{"target"}, {"log target events and activities"}, LIBLLDB_LOG_TARGET}, |
Jason Molenda | a4039a0 | 2017-04-03 22:23:01 +0000 | [diff] [blame] | 45 | {{"temp"}, {"log internal temporary debug messages"}, LIBLLDB_LOG_TEMPORARY}, |
Pavel Labath | a2fc1e0 | 2017-02-22 11:51:12 +0000 | [diff] [blame] | 46 | {{"thread"}, {"log thread events and activities"}, LIBLLDB_LOG_THREAD}, |
| 47 | {{"types"}, {"log type system related activities"}, LIBLLDB_LOG_TYPES}, |
| 48 | {{"unwind"}, {"log stack unwind activities"}, LIBLLDB_LOG_UNWIND}, |
| 49 | {{"watch"}, {"log watchpoint related activities"}, LIBLLDB_LOG_WATCHPOINTS}, |
| 50 | }; |
Greg Clayton | 5160ce5 | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 51 | |
Pavel Labath | a2fc1e0 | 2017-02-22 11:51:12 +0000 | [diff] [blame] | 52 | static Log::Channel g_log_channel(g_categories, LIBLLDB_LOG_DEFAULT); |
Eugene Zelenko | 8918372 | 2016-03-11 21:55:47 +0000 | [diff] [blame] | 53 | |
Pavel Labath | d813309 | 2017-10-23 19:41:17 +0000 | [diff] [blame] | 54 | void lldb_private::InitializeLldbChannel() { |
Pavel Labath | a2fc1e0 | 2017-02-22 11:51:12 +0000 | [diff] [blame] | 55 | Log::Register("lldb", g_log_channel); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 56 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 57 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 58 | Log *lldb_private::GetLogIfAllCategoriesSet(uint32_t mask) { |
Pavel Labath | a2fc1e0 | 2017-02-22 11:51:12 +0000 | [diff] [blame] | 59 | return g_log_channel.GetLogIfAll(mask); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | Log *lldb_private::GetLogIfAnyCategoriesSet(uint32_t mask) { |
Pavel Labath | a2fc1e0 | 2017-02-22 11:51:12 +0000 | [diff] [blame] | 63 | return g_log_channel.GetLogIfAny(mask); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 64 | } |
| 65 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 66 | |
Pavel Labath | a2fc1e0 | 2017-02-22 11:51:12 +0000 | [diff] [blame] | 67 | void lldb_private::LogIfAnyCategoriesSet(uint32_t mask, const char *format, ...) { |
| 68 | if (Log *log = GetLogIfAnyCategoriesSet(mask)) { |
| 69 | va_list args; |
| 70 | va_start(args, format); |
| 71 | log->VAPrintf(format, args); |
| 72 | va_end(args); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 73 | } |
Caroline Tice | 20ad3c4 | 2010-10-29 21:48:37 +0000 | [diff] [blame] | 74 | } |