summaryrefslogtreecommitdiffstats
path: root/lldb/tools/debugserver/source/DNBLog.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/tools/debugserver/source/DNBLog.cpp
parentd5aa73376966339caad04013510626ec2e42c760 (diff)
downloadbcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz
bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip
*** 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/tools/debugserver/source/DNBLog.cpp')
-rw-r--r--lldb/tools/debugserver/source/DNBLog.cpp452
1 files changed, 181 insertions, 271 deletions
diff --git a/lldb/tools/debugserver/source/DNBLog.cpp b/lldb/tools/debugserver/source/DNBLog.cpp
index 18d8d2ad3a6..c3d42a2a84d 100644
--- a/lldb/tools/debugserver/source/DNBLog.cpp
+++ b/lldb/tools/debugserver/source/DNBLog.cpp
@@ -16,362 +16,272 @@
static int g_debug = 0;
static int g_verbose = 0;
-#if defined (DNBLOG_ENABLED)
+#if defined(DNBLOG_ENABLED)
-#include <stdio.h>
+#include "PThreadMutex.h"
+#include <mach/mach.h>
+#include <pthread.h>
#include <stdarg.h>
+#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
-#include <mach/mach.h>
-#include <pthread.h>
-#include "PThreadMutex.h"
uint32_t g_log_bits = 0;
static DNBCallbackLog g_log_callback = NULL;
static void *g_log_baton = NULL;
+int DNBLogGetDebug() { return g_debug; }
-int
-DNBLogGetDebug ()
-{
- return g_debug;
-}
-
+void DNBLogSetDebug(int g) { g_debug = g; }
-void
-DNBLogSetDebug (int g)
-{
- g_debug = g;
-}
+int DNBLogGetVerbose() { return g_verbose; }
-int
-DNBLogGetVerbose ()
-{
- return g_verbose;
-}
+void DNBLogSetVerbose(int v) { g_verbose = v; }
-void
-DNBLogSetVerbose (int v)
-{
- g_verbose = v;
-}
+bool DNBLogCheckLogBit(uint32_t bit) { return (g_log_bits & bit) != 0; }
-bool
-DNBLogCheckLogBit (uint32_t bit)
-{
- return (g_log_bits & bit) != 0;
+uint32_t DNBLogSetLogMask(uint32_t mask) {
+ uint32_t old = g_log_bits;
+ g_log_bits = mask;
+ return old;
}
-uint32_t
-DNBLogSetLogMask (uint32_t mask)
-{
- uint32_t old = g_log_bits;
- g_log_bits = mask;
- return old;
-}
+uint32_t DNBLogGetLogMask() { return g_log_bits; }
-uint32_t
-DNBLogGetLogMask ()
-{
- return g_log_bits;
+void DNBLogSetLogCallback(DNBCallbackLog callback, void *baton) {
+ g_log_callback = callback;
+ g_log_baton = baton;
}
-void
-DNBLogSetLogCallback (DNBCallbackLog callback, void *baton)
-{
- g_log_callback = callback;
- g_log_baton = baton;
-}
+DNBCallbackLog DNBLogGetLogCallback() { return g_log_callback; }
-DNBCallbackLog
-DNBLogGetLogCallback ()
-{
- return g_log_callback;
-}
+bool DNBLogEnabled() { return g_log_callback != NULL; }
-bool
-DNBLogEnabled ()
-{
- return g_log_callback != NULL;
+bool DNBLogEnabledForAny(uint32_t mask) {
+ if (g_log_callback)
+ return (g_log_bits & mask) != 0;
+ return false;
}
+static inline void _DNBLogVAPrintf(uint32_t flags, const char *format,
+ va_list args) {
+ static PThreadMutex g_LogThreadedMutex(PTHREAD_MUTEX_RECURSIVE);
+ PTHREAD_MUTEX_LOCKER(locker, g_LogThreadedMutex);
-bool
-DNBLogEnabledForAny (uint32_t mask)
-{
- if (g_log_callback)
- return (g_log_bits & mask) != 0;
- return false;
-}
-static inline void
-_DNBLogVAPrintf(uint32_t flags, const char *format, va_list args)
-{
- static PThreadMutex g_LogThreadedMutex(PTHREAD_MUTEX_RECURSIVE);
- PTHREAD_MUTEX_LOCKER(locker, g_LogThreadedMutex);
-
- if (g_log_callback)
- g_log_callback(g_log_baton, flags, format, args);
+ if (g_log_callback)
+ g_log_callback(g_log_baton, flags, format, args);
}
-void
-_DNBLog(uint32_t flags, const char *format, ...)
-{
- va_list args;
- va_start (args, format);
- _DNBLogVAPrintf(flags, format, args);
- va_end (args);
+void _DNBLog(uint32_t flags, const char *format, ...) {
+ va_list args;
+ va_start(args, format);
+ _DNBLogVAPrintf(flags, format, args);
+ va_end(args);
}
//----------------------------------------------------------------------
// Print debug strings if and only if the global g_debug is set to
// a non-zero value.
//----------------------------------------------------------------------
-void
-_DNBLogDebug (const char *format, ...)
-{
- if (DNBLogEnabled () && g_debug)
- {
- va_list args;
- va_start (args, format);
- _DNBLogVAPrintf(DNBLOG_FLAG_DEBUG, format, args);
- va_end (args);
- }
+void _DNBLogDebug(const char *format, ...) {
+ if (DNBLogEnabled() && g_debug) {
+ va_list args;
+ va_start(args, format);
+ _DNBLogVAPrintf(DNBLOG_FLAG_DEBUG, format, args);
+ va_end(args);
+ }
}
-
//----------------------------------------------------------------------
// Print debug strings if and only if the global g_debug is set to
// a non-zero value.
//----------------------------------------------------------------------
-void
-_DNBLogDebugVerbose (const char *format, ...)
-{
- if (DNBLogEnabled () && g_debug && g_verbose)
- {
- va_list args;
- va_start (args, format);
- _DNBLogVAPrintf(DNBLOG_FLAG_DEBUG | DNBLOG_FLAG_VERBOSE, format, args);
- va_end (args);
- }
+void _DNBLogDebugVerbose(const char *format, ...) {
+ if (DNBLogEnabled() && g_debug && g_verbose) {
+ va_list args;
+ va_start(args, format);
+ _DNBLogVAPrintf(DNBLOG_FLAG_DEBUG | DNBLOG_FLAG_VERBOSE, format, args);
+ va_end(args);
+ }
}
-
static uint32_t g_message_id = 0;
//----------------------------------------------------------------------
// Prefix the formatted log string with process and thread IDs and
// suffix it with a newline.
//----------------------------------------------------------------------
-void
-_DNBLogThreaded (const char *format, ...)
-{
- if (DNBLogEnabled ())
- {
- //PTHREAD_MUTEX_LOCKER(locker, GetLogThreadedMutex());
-
- char *arg_msg = NULL;
- va_list args;
- va_start (args, format);
- ::vasprintf (&arg_msg, format, args);
- va_end (args);
-
- if (arg_msg != NULL)
- {
- static struct timeval g_timeval = { 0 , 0 };
- static struct timeval tv;
- static struct timeval delta;
- gettimeofday(&tv, NULL);
- if (g_timeval.tv_sec == 0)
- {
- delta.tv_sec = 0;
- delta.tv_usec = 0;
- }
- else
- {
- timersub (&tv, &g_timeval, &delta);
- }
- g_timeval = tv;
-
- // Calling "mach_port_deallocate()" bumps the reference count on the thread
- // port, so we need to deallocate it. mach_task_self() doesn't bump the ref
- // count.
- thread_port_t thread_self = mach_thread_self();
-
- _DNBLog (DNBLOG_FLAG_THREADED, "%u +%lu.%06u sec [%4.4x/%4.4x]: %s",
- ++g_message_id,
- delta.tv_sec,
- delta.tv_usec,
- getpid(),
- thread_self,
- arg_msg);
-
- mach_port_deallocate(mach_task_self(), thread_self);
- free (arg_msg);
- }
+void _DNBLogThreaded(const char *format, ...) {
+ if (DNBLogEnabled()) {
+ // PTHREAD_MUTEX_LOCKER(locker, GetLogThreadedMutex());
+
+ char *arg_msg = NULL;
+ va_list args;
+ va_start(args, format);
+ ::vasprintf(&arg_msg, format, args);
+ va_end(args);
+
+ if (arg_msg != NULL) {
+ static struct timeval g_timeval = {0, 0};
+ static struct timeval tv;
+ static struct timeval delta;
+ gettimeofday(&tv, NULL);
+ if (g_timeval.tv_sec == 0) {
+ delta.tv_sec = 0;
+ delta.tv_usec = 0;
+ } else {
+ timersub(&tv, &g_timeval, &delta);
+ }
+ g_timeval = tv;
+
+ // Calling "mach_port_deallocate()" bumps the reference count on the
+ // thread
+ // port, so we need to deallocate it. mach_task_self() doesn't bump the
+ // ref
+ // count.
+ thread_port_t thread_self = mach_thread_self();
+
+ _DNBLog(DNBLOG_FLAG_THREADED, "%u +%lu.%06u sec [%4.4x/%4.4x]: %s",
+ ++g_message_id, delta.tv_sec, delta.tv_usec, getpid(),
+ thread_self, arg_msg);
+
+ mach_port_deallocate(mach_task_self(), thread_self);
+ free(arg_msg);
}
+ }
}
//----------------------------------------------------------------------
// Prefix the formatted log string with process and thread IDs and
// suffix it with a newline.
//----------------------------------------------------------------------
-void
-_DNBLogThreadedIf (uint32_t log_bit, const char *format, ...)
-{
- if (DNBLogEnabled () && (log_bit & g_log_bits) == log_bit)
- {
- //PTHREAD_MUTEX_LOCKER(locker, GetLogThreadedMutex());
-
- char *arg_msg = NULL;
- va_list args;
- va_start (args, format);
- ::vasprintf (&arg_msg, format, args);
- va_end (args);
-
- if (arg_msg != NULL)
- {
- static struct timeval g_timeval = { 0 , 0 };
- static struct timeval tv;
- static struct timeval delta;
- gettimeofday(&tv, NULL);
- if (g_timeval.tv_sec == 0)
- {
- delta.tv_sec = 0;
- delta.tv_usec = 0;
- }
- else
- {
- timersub (&tv, &g_timeval, &delta);
- }
- g_timeval = tv;
-
- // Calling "mach_port_deallocate()" bumps the reference count on the thread
- // port, so we need to deallocate it. mach_task_self() doesn't bump the ref
- // count.
- thread_port_t thread_self = mach_thread_self();
-
- _DNBLog (DNBLOG_FLAG_THREADED, "%u +%lu.%06u sec [%4.4x/%4.4x]: %s",
- ++g_message_id,
- delta.tv_sec,
- delta.tv_usec,
- getpid(),
- thread_self,
- arg_msg);
-
- mach_port_deallocate(mach_task_self(), thread_self);
-
- free (arg_msg);
- }
+void _DNBLogThreadedIf(uint32_t log_bit, const char *format, ...) {
+ if (DNBLogEnabled() && (log_bit & g_log_bits) == log_bit) {
+ // PTHREAD_MUTEX_LOCKER(locker, GetLogThreadedMutex());
+
+ char *arg_msg = NULL;
+ va_list args;
+ va_start(args, format);
+ ::vasprintf(&arg_msg, format, args);
+ va_end(args);
+
+ if (arg_msg != NULL) {
+ static struct timeval g_timeval = {0, 0};
+ static struct timeval tv;
+ static struct timeval delta;
+ gettimeofday(&tv, NULL);
+ if (g_timeval.tv_sec == 0) {
+ delta.tv_sec = 0;
+ delta.tv_usec = 0;
+ } else {
+ timersub(&tv, &g_timeval, &delta);
+ }
+ g_timeval = tv;
+
+ // Calling "mach_port_deallocate()" bumps the reference count on the
+ // thread
+ // port, so we need to deallocate it. mach_task_self() doesn't bump the
+ // ref
+ // count.
+ thread_port_t thread_self = mach_thread_self();
+
+ _DNBLog(DNBLOG_FLAG_THREADED, "%u +%lu.%06u sec [%4.4x/%4.4x]: %s",
+ ++g_message_id, delta.tv_sec, delta.tv_usec, getpid(),
+ thread_self, arg_msg);
+
+ mach_port_deallocate(mach_task_self(), thread_self);
+
+ free(arg_msg);
}
+ }
}
-
-
//----------------------------------------------------------------------
// Printing of errors that are not fatal.
//----------------------------------------------------------------------
-void
-_DNBLogError (const char *format, ...)
-{
- if (DNBLogEnabled ())
- {
- char *arg_msg = NULL;
- va_list args;
- va_start (args, format);
- ::vasprintf (&arg_msg, format, args);
- va_end (args);
-
- if (arg_msg != NULL)
- {
- _DNBLog (DNBLOG_FLAG_ERROR, "error: %s", arg_msg);
- free (arg_msg);
- }
+void _DNBLogError(const char *format, ...) {
+ if (DNBLogEnabled()) {
+ char *arg_msg = NULL;
+ va_list args;
+ va_start(args, format);
+ ::vasprintf(&arg_msg, format, args);
+ va_end(args);
+
+ if (arg_msg != NULL) {
+ _DNBLog(DNBLOG_FLAG_ERROR, "error: %s", arg_msg);
+ free(arg_msg);
}
+ }
}
//----------------------------------------------------------------------
// Printing of errors that ARE fatal. Exit with ERR exit code
// immediately.
//----------------------------------------------------------------------
-void
-_DNBLogFatalError (int err, const char *format, ...)
-{
- if (DNBLogEnabled ())
- {
- char *arg_msg = NULL;
- va_list args;
- va_start (args, format);
- ::vasprintf (&arg_msg, format, args);
- va_end (args);
-
- if (arg_msg != NULL)
- {
- _DNBLog (DNBLOG_FLAG_ERROR | DNBLOG_FLAG_FATAL, "error: %s", arg_msg);
- free (arg_msg);
- }
- ::exit (err);
+void _DNBLogFatalError(int err, const char *format, ...) {
+ if (DNBLogEnabled()) {
+ char *arg_msg = NULL;
+ va_list args;
+ va_start(args, format);
+ ::vasprintf(&arg_msg, format, args);
+ va_end(args);
+
+ if (arg_msg != NULL) {
+ _DNBLog(DNBLOG_FLAG_ERROR | DNBLOG_FLAG_FATAL, "error: %s", arg_msg);
+ free(arg_msg);
}
+ ::exit(err);
+ }
}
-
//----------------------------------------------------------------------
// Printing of warnings that are not fatal only if verbose mode is
// enabled.
//----------------------------------------------------------------------
-void
-_DNBLogVerbose (const char *format, ...)
-{
- if (DNBLogEnabled () && g_verbose)
- {
- va_list args;
- va_start (args, format);
- _DNBLogVAPrintf(DNBLOG_FLAG_VERBOSE, format, args);
- va_end (args);
- }
+void _DNBLogVerbose(const char *format, ...) {
+ if (DNBLogEnabled() && g_verbose) {
+ va_list args;
+ va_start(args, format);
+ _DNBLogVAPrintf(DNBLOG_FLAG_VERBOSE, format, args);
+ va_end(args);
+ }
}
//----------------------------------------------------------------------
// Printing of warnings that are not fatal only if verbose mode is
// enabled.
//----------------------------------------------------------------------
-void
-_DNBLogWarningVerbose (const char *format, ...)
-{
- if (DNBLogEnabled () && g_verbose)
- {
- char *arg_msg = NULL;
- va_list args;
- va_start (args, format);
- ::vasprintf (&arg_msg, format, args);
- va_end (args);
-
- if (arg_msg != NULL)
- {
- _DNBLog (DNBLOG_FLAG_WARNING | DNBLOG_FLAG_VERBOSE, "warning: %s", arg_msg);
- free (arg_msg);
- }
+void _DNBLogWarningVerbose(const char *format, ...) {
+ if (DNBLogEnabled() && g_verbose) {
+ char *arg_msg = NULL;
+ va_list args;
+ va_start(args, format);
+ ::vasprintf(&arg_msg, format, args);
+ va_end(args);
+
+ if (arg_msg != NULL) {
+ _DNBLog(DNBLOG_FLAG_WARNING | DNBLOG_FLAG_VERBOSE, "warning: %s",
+ arg_msg);
+ free(arg_msg);
}
+ }
}
//----------------------------------------------------------------------
// Printing of warnings that are not fatal.
//----------------------------------------------------------------------
-void
-_DNBLogWarning (const char *format, ...)
-{
- if (DNBLogEnabled ())
- {
- char *arg_msg = NULL;
- va_list args;
- va_start (args, format);
- ::vasprintf (&arg_msg, format, args);
- va_end (args);
-
- if (arg_msg != NULL)
- {
- _DNBLog (DNBLOG_FLAG_WARNING, "warning: %s", arg_msg);
- free (arg_msg);
- }
+void _DNBLogWarning(const char *format, ...) {
+ if (DNBLogEnabled()) {
+ char *arg_msg = NULL;
+ va_list args;
+ va_start(args, format);
+ ::vasprintf(&arg_msg, format, args);
+ va_end(args);
+
+ if (arg_msg != NULL) {
+ _DNBLog(DNBLOG_FLAG_WARNING, "warning: %s", arg_msg);
+ free(arg_msg);
}
+ }
}
#endif
OpenPOWER on IntegriCloud