summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/Windows/ProcessWindowsLog.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2015-05-07 21:39:33 +0000
committerZachary Turner <zturner@google.com>2015-05-07 21:39:33 +0000
commit610e52912d31341d989ac21ff3d7380c513e0897 (patch)
tree73ad618c432219ab3399f87fae15eddb4e6e2188 /lldb/source/Plugins/Process/Windows/ProcessWindowsLog.cpp
parentd04893fa36ff1bae396acfd064cbfceaf135527d (diff)
downloadbcm5719-llvm-610e52912d31341d989ac21ff3d7380c513e0897.tar.gz
bcm5719-llvm-610e52912d31341d989ac21ff3d7380c513e0897.zip
Add logging to ProcessWindows.
llvm-svn: 236776
Diffstat (limited to 'lldb/source/Plugins/Process/Windows/ProcessWindowsLog.cpp')
-rw-r--r--lldb/source/Plugins/Process/Windows/ProcessWindowsLog.cpp106
1 files changed, 46 insertions, 60 deletions
diff --git a/lldb/source/Plugins/Process/Windows/ProcessWindowsLog.cpp b/lldb/source/Plugins/Process/Windows/ProcessWindowsLog.cpp
index ae03937fbd1..d641979b0b0 100644
--- a/lldb/source/Plugins/Process/Windows/ProcessWindowsLog.cpp
+++ b/lldb/source/Plugins/Process/Windows/ProcessWindowsLog.cpp
@@ -11,8 +11,8 @@
#include <mutex>
-#include "lldb/Interpreter/Args.h"
#include "lldb/Core/StreamFile.h"
+#include "lldb/Interpreter/Args.h"
#include "llvm/Support/ManagedStatic.h"
#include "ProcessWindows.h"
@@ -26,14 +26,7 @@ using namespace lldb_private;
// that will construct the static g_log_sp the first time this function is
// called.
static bool g_log_enabled = false;
-static Log * g_log = NULL;
-static Log *
-GetLog()
-{
- if (!g_log_enabled)
- return NULL;
- return g_log;
-}
+static Log * g_log = nullptr;
static llvm::ManagedStatic<std::once_flag> g_once_flag;
@@ -54,34 +47,44 @@ ProcessWindowsLog::Initialize()
});
}
+void
+ProcessWindowsLog::Terminate()
+{
+}
+
Log *
-ProcessWindowsLog::GetLogIfAllCategoriesSet(uint32_t mask)
+ProcessWindowsLog::GetLog()
{
- Log *log(GetLog());
- if (log && mask)
- {
- uint32_t log_mask = log->GetMask().Get();
- if ((log_mask & mask) != mask)
- return NULL;
- }
- return log;
+ return (g_log_enabled) ? g_log : nullptr;
+}
+
+bool
+ProcessWindowsLog::TestLogFlags(uint32_t mask, LogMaskReq req)
+{
+ Log *log = GetLog();
+ if (!log)
+ return false;
+
+ uint32_t log_mask = log->GetMask().Get();
+ if (req == LogMaskReq::All)
+ return ((log_mask & mask) == mask);
+ else
+ return (log_mask & mask);
}
static uint32_t
GetFlagBits(const char *arg)
{
- if (::strcasecmp (arg, "all") == 0 ) return WINDOWS_LOG_ALL;
- else if (::strcasecmp (arg, "async") == 0 ) return WINDOWS_LOG_ASYNC;
- else if (::strncasecmp (arg, "break", 5) == 0 ) return WINDOWS_LOG_BREAKPOINTS;
- else if (::strcasecmp (arg, "default") == 0 ) return WINDOWS_LOG_DEFAULT;
- else if (::strcasecmp (arg, "memory") == 0 ) return WINDOWS_LOG_MEMORY;
- else if (::strcasecmp (arg, "data-short") == 0 ) return WINDOWS_LOG_MEMORY_DATA_SHORT;
- else if (::strcasecmp (arg, "data-long") == 0 ) return WINDOWS_LOG_MEMORY_DATA_LONG;
- else if (::strcasecmp (arg, "process") == 0 ) return WINDOWS_LOG_PROCESS;
- else if (::strcasecmp (arg, "registers") == 0 ) return WINDOWS_LOG_REGISTERS;
- else if (::strcasecmp (arg, "step") == 0 ) return WINDOWS_LOG_STEP;
- else if (::strcasecmp (arg, "thread") == 0 ) return WINDOWS_LOG_THREAD;
- else if (::strcasecmp (arg, "verbose") == 0 ) return WINDOWS_LOG_VERBOSE;
+ if (::strcasecmp(arg, "all") == 0 ) return WINDOWS_LOG_ALL;
+ else if (::strcasecmp(arg, "break") == 0 ) return WINDOWS_LOG_BREAKPOINTS;
+ else if (::strcasecmp(arg, "event") == 0 ) return WINDOWS_LOG_EVENT;
+ else if (::strcasecmp(arg, "exception") == 0 ) return WINDOWS_LOG_EXCEPTION;
+ else if (::strcasecmp(arg, "memory") == 0 ) return WINDOWS_LOG_MEMORY;
+ else if (::strcasecmp(arg, "process") == 0 ) return WINDOWS_LOG_PROCESS;
+ else if (::strcasecmp(arg, "registers") == 0 ) return WINDOWS_LOG_REGISTERS;
+ else if (::strcasecmp(arg, "step") == 0 ) return WINDOWS_LOG_STEP;
+ else if (::strcasecmp(arg, "thread") == 0 ) return WINDOWS_LOG_THREAD;
+ else if (::strcasecmp(arg, "verbose") == 0 ) return WINDOWS_LOG_VERBOSE;
return 0;
}
@@ -159,7 +162,7 @@ ProcessWindowsLog::EnableLog(StreamSP &log_stream_sp, uint32_t log_options, cons
}
}
if (flag_bits == 0)
- flag_bits = WINDOWS_LOG_DEFAULT;
+ flag_bits = WINDOWS_LOG_ALL;
g_log->GetMask().Reset(flag_bits);
g_log->GetOptions().Reset(log_options);
g_log_enabled = true;
@@ -170,35 +173,18 @@ ProcessWindowsLog::EnableLog(StreamSP &log_stream_sp, uint32_t log_options, cons
void
ProcessWindowsLog::ListLogCategories(Stream *strm)
{
- strm->Printf ("Logging categories for '%s':\n"
- " all - turn on all available logging categories\n"
- " async - log asynchronous activity\n"
- " break - log breakpoints\n"
- " default - enable the default set of logging categories for liblldb\n"
- " memory - log memory reads and writes\n"
- " data-short - log memory bytes for memory reads and writes for short transactions only\n"
- " data-long - log memory bytes for memory reads and writes for all transactions\n"
- " process - log process events and activities\n"
- " registers - log register read/writes\n"
- " thread - log thread events and activities\n"
- " step - log step related activities\n"
- " verbose - enable verbose logging\n",
- ProcessWindowsLog::m_pluginname);
-}
-
-
-void
-ProcessWindowsLog::LogIf(uint32_t mask, const char *format, ...)
-{
- Log *log = GetLogIfAllCategoriesSet(mask);
- if (log)
- {
- va_list args;
- va_start(args, format);
- log->VAPrintf(format, args);
- va_end(args);
- }
+ strm->Printf("Logging categories for '%s':\n"
+ " all - turn on all available logging categories\n"
+ " break - log breakpoints\n"
+ " event - log low level debugger events\n"
+ " exception - log exception information\n"
+ " memory - log memory reads and writes\n"
+ " process - log process events and activities\n"
+ " registers - log register read/writes\n"
+ " thread - log thread events and activities\n"
+ " step - log step related activities\n"
+ " verbose - enable verbose logging\n",
+ ProcessWindowsLog::m_pluginname);
}
-int ProcessWindowsLog::m_nestinglevel = 0;
const char *ProcessWindowsLog::m_pluginname = "";
OpenPOWER on IntegriCloud