aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp
diff options
context:
space:
mode:
authorKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
committerKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
commitb9c1b51e45b845debb76d8658edabca70ca56079 (patch)
treedfcb5a13ef2b014202340f47036da383eaee74aa /lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp
parentd5aa73376966339caad04013510626ec2e42c760 (diff)
downloadllvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip
llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz
llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.bz2
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has *** two obvious implications: Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751
Diffstat (limited to 'lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp')
-rw-r--r--lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp311
1 files changed, 149 insertions, 162 deletions
diff --git a/lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp b/lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp
index b259804..7f07bd5 100644
--- a/lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp
+++ b/lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp
@@ -1,4 +1,5 @@
-//===-- ProcessPOSIXLog.cpp ---------------------------------------*- C++ -*-===//
+//===-- ProcessPOSIXLog.cpp ---------------------------------------*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -11,199 +12,185 @@
#include <mutex>
-#include "lldb/Interpreter/Args.h"
#include "lldb/Core/StreamFile.h"
+#include "lldb/Interpreter/Args.h"
#include "ProcessPOSIXLog.h"
using namespace lldb;
using namespace lldb_private;
-
// We want to avoid global constructors where code needs to be run so here we
// control access to our static g_log_sp by hiding it in a singleton function
-// that will construct the static g_log_sp the first time this function is
+// 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 = NULL;
+static Log *GetLog() {
+ if (!g_log_enabled)
+ return NULL;
+ return g_log;
}
-void
-ProcessPOSIXLog::Initialize(ConstString name)
-{
- static std::once_flag g_once_flag;
-
- std::call_once(g_once_flag, [name](){
- Log::Callbacks log_callbacks = {
- DisableLog,
- EnableLog,
- ListLogCategories
- };
-
- Log::RegisterLogChannel (name, log_callbacks);
- RegisterPluginName(name);
- });
-}
+void ProcessPOSIXLog::Initialize(ConstString name) {
+ static std::once_flag g_once_flag;
-Log *
-ProcessPOSIXLog::GetLogIfAllCategoriesSet (uint32_t mask)
-{
- Log *log(GetLog ());
- if (log && mask)
- {
- uint32_t log_mask = log->GetMask().Get();
- if ((log_mask & mask) != mask)
- return NULL;
- }
- return log;
+ std::call_once(g_once_flag, [name]() {
+ Log::Callbacks log_callbacks = {DisableLog, EnableLog, ListLogCategories};
+
+ Log::RegisterLogChannel(name, log_callbacks);
+ RegisterPluginName(name);
+ });
}
-static uint32_t
-GetFlagBits (const char *arg)
-{
- if (::strcasecmp (arg, "all") == 0 ) return POSIX_LOG_ALL;
- else if (::strcasecmp (arg, "async") == 0 ) return POSIX_LOG_ASYNC;
- else if (::strncasecmp (arg, "break", 5) == 0 ) return POSIX_LOG_BREAKPOINTS;
- else if (::strncasecmp (arg, "comm", 4) == 0 ) return POSIX_LOG_COMM;
- else if (::strcasecmp (arg, "default") == 0 ) return POSIX_LOG_DEFAULT;
- else if (::strcasecmp (arg, "packets") == 0 ) return POSIX_LOG_PACKETS;
- else if (::strcasecmp (arg, "memory") == 0 ) return POSIX_LOG_MEMORY;
- else if (::strcasecmp (arg, "data-short") == 0 ) return POSIX_LOG_MEMORY_DATA_SHORT;
- else if (::strcasecmp (arg, "data-long") == 0 ) return POSIX_LOG_MEMORY_DATA_LONG;
- else if (::strcasecmp (arg, "process") == 0 ) return POSIX_LOG_PROCESS;
- else if (::strcasecmp (arg, "ptrace") == 0 ) return POSIX_LOG_PTRACE;
- else if (::strcasecmp (arg, "registers") == 0 ) return POSIX_LOG_REGISTERS;
- else if (::strcasecmp (arg, "step") == 0 ) return POSIX_LOG_STEP;
- else if (::strcasecmp (arg, "thread") == 0 ) return POSIX_LOG_THREAD;
- else if (::strcasecmp (arg, "verbose") == 0 ) return POSIX_LOG_VERBOSE;
- else if (::strncasecmp (arg, "watch", 5) == 0 ) return POSIX_LOG_WATCHPOINTS;
- return 0;
+Log *ProcessPOSIXLog::GetLogIfAllCategoriesSet(uint32_t mask) {
+ Log *log(GetLog());
+ if (log && mask) {
+ uint32_t log_mask = log->GetMask().Get();
+ if ((log_mask & mask) != mask)
+ return NULL;
+ }
+ return log;
}
-void
-ProcessPOSIXLog::DisableLog (const char **args, Stream *feedback_strm)
-{
- Log *log (GetLog ());
- if (log)
- {
- uint32_t flag_bits = 0;
-
- flag_bits = log->GetMask().Get();
- for (; args[0]; args++)
- {
- const char *arg = args[0];
- uint32_t bits = GetFlagBits(arg);
-
- if (bits)
- {
- flag_bits &= ~bits;
- }
- else
- {
- feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
- ListLogCategories (feedback_strm);
- }
- }
-
- log->GetMask().Reset (flag_bits);
- if (flag_bits == 0)
- g_log_enabled = false;
- }
-
- return;
+static uint32_t GetFlagBits(const char *arg) {
+ if (::strcasecmp(arg, "all") == 0)
+ return POSIX_LOG_ALL;
+ else if (::strcasecmp(arg, "async") == 0)
+ return POSIX_LOG_ASYNC;
+ else if (::strncasecmp(arg, "break", 5) == 0)
+ return POSIX_LOG_BREAKPOINTS;
+ else if (::strncasecmp(arg, "comm", 4) == 0)
+ return POSIX_LOG_COMM;
+ else if (::strcasecmp(arg, "default") == 0)
+ return POSIX_LOG_DEFAULT;
+ else if (::strcasecmp(arg, "packets") == 0)
+ return POSIX_LOG_PACKETS;
+ else if (::strcasecmp(arg, "memory") == 0)
+ return POSIX_LOG_MEMORY;
+ else if (::strcasecmp(arg, "data-short") == 0)
+ return POSIX_LOG_MEMORY_DATA_SHORT;
+ else if (::strcasecmp(arg, "data-long") == 0)
+ return POSIX_LOG_MEMORY_DATA_LONG;
+ else if (::strcasecmp(arg, "process") == 0)
+ return POSIX_LOG_PROCESS;
+ else if (::strcasecmp(arg, "ptrace") == 0)
+ return POSIX_LOG_PTRACE;
+ else if (::strcasecmp(arg, "registers") == 0)
+ return POSIX_LOG_REGISTERS;
+ else if (::strcasecmp(arg, "step") == 0)
+ return POSIX_LOG_STEP;
+ else if (::strcasecmp(arg, "thread") == 0)
+ return POSIX_LOG_THREAD;
+ else if (::strcasecmp(arg, "verbose") == 0)
+ return POSIX_LOG_VERBOSE;
+ else if (::strncasecmp(arg, "watch", 5) == 0)
+ return POSIX_LOG_WATCHPOINTS;
+ return 0;
}
-Log *
-ProcessPOSIXLog::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, const char **args, Stream *feedback_strm)
-{
- // Try see if there already is a log - that way we can reuse its settings.
- // We could reuse the log in toto, but we don't know that the stream is the same.
+void ProcessPOSIXLog::DisableLog(const char **args, Stream *feedback_strm) {
+ Log *log(GetLog());
+ if (log) {
uint32_t flag_bits = 0;
- if (g_log)
- flag_bits = g_log->GetMask().Get();
-
- // Now make a new log with this stream if one was provided
- if (log_stream_sp)
- {
- if (g_log)
- g_log->SetStream(log_stream_sp);
- else
- g_log = new Log(log_stream_sp);
+
+ flag_bits = log->GetMask().Get();
+ for (; args[0]; args++) {
+ const char *arg = args[0];
+ uint32_t bits = GetFlagBits(arg);
+
+ if (bits) {
+ flag_bits &= ~bits;
+ } else {
+ feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
+ ListLogCategories(feedback_strm);
+ }
}
+ log->GetMask().Reset(flag_bits);
+ if (flag_bits == 0)
+ g_log_enabled = false;
+ }
+
+ return;
+}
+
+Log *ProcessPOSIXLog::EnableLog(StreamSP &log_stream_sp, uint32_t log_options,
+ const char **args, Stream *feedback_strm) {
+ // Try see if there already is a log - that way we can reuse its settings.
+ // We could reuse the log in toto, but we don't know that the stream is the
+ // same.
+ uint32_t flag_bits = 0;
+ if (g_log)
+ flag_bits = g_log->GetMask().Get();
+
+ // Now make a new log with this stream if one was provided
+ if (log_stream_sp) {
if (g_log)
- {
- bool got_unknown_category = false;
- for (; args[0]; args++)
- {
- const char *arg = args[0];
- uint32_t bits = GetFlagBits(arg);
-
- if (bits)
- {
- flag_bits |= bits;
- }
- else
- {
- feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
- if (got_unknown_category == false)
- {
- got_unknown_category = true;
- ListLogCategories (feedback_strm);
- }
- }
+ g_log->SetStream(log_stream_sp);
+ else
+ g_log = new Log(log_stream_sp);
+ }
+
+ if (g_log) {
+ bool got_unknown_category = false;
+ for (; args[0]; args++) {
+ const char *arg = args[0];
+ uint32_t bits = GetFlagBits(arg);
+
+ if (bits) {
+ flag_bits |= bits;
+ } else {
+ feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
+ if (got_unknown_category == false) {
+ got_unknown_category = true;
+ ListLogCategories(feedback_strm);
}
- if (flag_bits == 0)
- flag_bits = POSIX_LOG_DEFAULT;
- g_log->GetMask().Reset(flag_bits);
- g_log->GetOptions().Reset(log_options);
- g_log_enabled = true;
+ }
}
- return g_log;
+ if (flag_bits == 0)
+ flag_bits = POSIX_LOG_DEFAULT;
+ g_log->GetMask().Reset(flag_bits);
+ g_log->GetOptions().Reset(log_options);
+ g_log_enabled = true;
+ }
+ return g_log;
}
-void
-ProcessPOSIXLog::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"
- " communication - log communication activity\n"
- " default - enable the default set of logging categories for liblldb\n"
- " packets - log gdb remote packets\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"
+void ProcessPOSIXLog::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"
+ " communication - log communication activity\n"
+ " default - enable the default set of logging categories for liblldb\n"
+ " packets - log gdb remote packets\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"
#ifndef LLDB_CONFIGURATION_BUILDANDINTEGRATION
- " ptrace - log all calls to ptrace\n"
+ " ptrace - log all calls to ptrace\n"
#endif
- " registers - log register read/writes\n"
- " thread - log thread events and activities\n"
- " step - log step related activities\n"
- " verbose - enable verbose logging\n"
- " watch - log watchpoint related activities\n", ProcessPOSIXLog::m_pluginname);
+ " registers - log register read/writes\n"
+ " thread - log thread events and activities\n"
+ " step - log step related activities\n"
+ " verbose - enable verbose logging\n"
+ " watch - log watchpoint related activities\n",
+ ProcessPOSIXLog::m_pluginname);
}
-
-void
-ProcessPOSIXLog::LogIf (uint32_t mask, const char *format, ...)
-{
- Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (mask));
- if (log)
- {
- va_list args;
- va_start (args, format);
- log->VAPrintf (format, args);
- va_end (args);
- }
+void ProcessPOSIXLog::LogIf(uint32_t mask, const char *format, ...) {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(mask));
+ if (log) {
+ va_list args;
+ va_start(args, format);
+ log->VAPrintf(format, args);
+ va_end(args);
+ }
}
int ProcessPOSIXLog::m_nestinglevel;