summaryrefslogtreecommitdiffstats
path: root/lldb
diff options
context:
space:
mode:
Diffstat (limited to 'lldb')
-rw-r--r--lldb/source/Host/common/Host.cpp8
-rw-r--r--lldb/tools/debugserver/source/DNBLog.cpp23
2 files changed, 27 insertions, 4 deletions
diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp
index 4b23ff412ab..400f493d2c3 100644
--- a/lldb/source/Host/common/Host.cpp
+++ b/lldb/source/Host/common/Host.cpp
@@ -39,6 +39,7 @@
#include <dispatch/dispatch.h>
#include <libproc.h>
#include <mach-o/dyld.h>
+#include <mach/mach_port.h>
#include <sys/sysctl.h>
@@ -430,7 +431,12 @@ lldb::tid_t
Host::GetCurrentThreadID()
{
#if defined (__APPLE__)
- return ::mach_thread_self();
+ // 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();
+ mach_port_deallocate(mach_task_self(), thread_self);
+ return thread_self;
#elif defined(__FreeBSD__)
return lldb::tid_t(pthread_getthreadid_np());
#else
diff --git a/lldb/tools/debugserver/source/DNBLog.cpp b/lldb/tools/debugserver/source/DNBLog.cpp
index 664a03d657b..890e7e553ca 100644
--- a/lldb/tools/debugserver/source/DNBLog.cpp
+++ b/lldb/tools/debugserver/source/DNBLog.cpp
@@ -185,13 +185,21 @@ _DNBLogThreaded (const char *format, ...)
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(),
- mach_thread_self(),
+ thread_self,
arg_msg);
+
+ mach_port_deallocate(mach_task_self(), thread_self);
free (arg_msg);
}
}
@@ -230,13 +238,22 @@ _DNBLogThreadedIf (uint32_t log_bit, const char *format, ...)
timersub (&tv, &g_timeval, &delta);
}
g_timeval = tv;
- _DNBLog (DNBLOG_FLAG_THREADED, "%u +%lu.%06u sec [%4.4x/%4.4x]: %s",
+
+ // 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(),
- mach_thread_self(),
+ thread_self,
arg_msg);
+
+ mach_port_deallocate(mach_task_self(), thread_self);
+
free (arg_msg);
}
}
OpenPOWER on IntegriCloud