]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - source/Plugins/Process/Windows/Common/ProcessWindowsLog.h
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / source / Plugins / Process / Windows / Common / ProcessWindowsLog.h
1 //===-- ProcessWindowsLog.h -------------------------------------*- C++ -*-===//
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
10 #ifndef liblldb_ProcessWindowsLog_h_
11 #define liblldb_ProcessWindowsLog_h_
12
13 #include "lldb/Core/Log.h"
14
15 #define WINDOWS_LOG_VERBOSE (1u << 0)
16 #define WINDOWS_LOG_PROCESS (1u << 1)     // Log process operations
17 #define WINDOWS_LOG_EXCEPTION (1u << 1)   // Log exceptions
18 #define WINDOWS_LOG_THREAD (1u << 2)      // Log thread operations
19 #define WINDOWS_LOG_MEMORY (1u << 3)      // Log memory reads/writes calls
20 #define WINDOWS_LOG_BREAKPOINTS (1u << 4) // Log breakpoint operations
21 #define WINDOWS_LOG_STEP (1u << 5)        // Log step operations
22 #define WINDOWS_LOG_REGISTERS (1u << 6)   // Log register operations
23 #define WINDOWS_LOG_EVENT (1u << 7)       // Low level debug events
24 #define WINDOWS_LOG_ALL (UINT32_MAX)
25
26 enum class LogMaskReq { All, Any };
27
28 class ProcessWindowsLog {
29   static const char *m_pluginname;
30
31 public:
32   // ---------------------------------------------------------------------
33   // Public Static Methods
34   // ---------------------------------------------------------------------
35   static void Initialize();
36
37   static void Terminate();
38
39   static void RegisterPluginName(const char *pluginName) {
40     m_pluginname = pluginName;
41   }
42
43   static void RegisterPluginName(lldb_private::ConstString pluginName) {
44     m_pluginname = pluginName.GetCString();
45   }
46
47   static bool TestLogFlags(uint32_t mask, LogMaskReq req);
48
49   static lldb_private::Log *GetLog();
50
51   static void DisableLog(const char **args,
52                          lldb_private::Stream *feedback_strm);
53
54   static lldb_private::Log *EnableLog(lldb::StreamSP &log_stream_sp,
55                                       uint32_t log_options, const char **args,
56                                       lldb_private::Stream *feedback_strm);
57
58   static void ListLogCategories(lldb_private::Stream *strm);
59 };
60
61 #define WINLOGF_IF(Flags, Req, Method, ...)                                    \
62   {                                                                            \
63     if (ProcessWindowsLog::TestLogFlags(Flags, Req)) {                         \
64       Log *log = ProcessWindowsLog::GetLog();                                  \
65       if (log)                                                                 \
66         log->Method(__VA_ARGS__);                                              \
67     }                                                                          \
68   }
69
70 #define WINLOG_IFANY(Flags, ...)                                               \
71   WINLOGF_IF(Flags, LogMaskReq::Any, Printf, __VA_ARGS__)
72 #define WINLOG_IFALL(Flags, ...)                                               \
73   WINLOGF_IF(Flags, LogMaskReq::All, Printf, __VA_ARGS__)
74 #define WINLOGV_IFANY(Flags, ...)                                              \
75   WINLOGF_IF(Flags, LogMaskReq::Any, Verbose, __VA_ARGS__)
76 #define WINLOGV_IFALL(Flags, ...)                                              \
77   WINLOGF_IF(Flags, LogMaskReq::All, Verbose, __VA_ARGS__)
78 #define WINLOGD_IFANY(Flags, ...)                                              \
79   WINLOGF_IF(Flags, LogMaskReq::Any, Debug, __VA_ARGS__)
80 #define WINLOGD_IFALL(Flags, ...)                                              \
81   WINLOGF_IF(Flags, LogMaskReq::All, Debug, __VA_ARGS__)
82 #define WINERR_IFANY(Flags, ...)                                               \
83   WINLOGF_IF(Flags, LogMaskReq::Any, Error, __VA_ARGS__)
84 #define WINERR_IFALL(Flags, ...)                                               \
85   WINLOGF_IF(Flags, LogMaskReq::All, Error, __VA_ARGS__)
86 #define WINWARN_IFANY(Flags, ...)                                              \
87   WINLOGF_IF(Flags, LogMaskReq::Any, Warning, __VA_ARGS__)
88 #define WINWARN_IFALL(Flags, ...)                                              \
89   WINLOGF_IF(Flags, LogMaskReq::All, Warning, __VA_ARGS__)
90
91 #endif // liblldb_ProcessWindowsLog_h_