diff options
author | Jason Molenda <jmolenda@apple.com> | 2014-07-24 01:36:24 +0000 |
---|---|---|
committer | Jason Molenda <jmolenda@apple.com> | 2014-07-24 01:36:24 +0000 |
commit | 36a216eefc8c1d46bc6704cd355d55abbea33c41 (patch) | |
tree | 2b16c8c5227111fbbe53742cb110d0301f5818ea /lldb/tools/debugserver | |
parent | 451f30e89f882e796cbba744fc4f340b7ddbf43f (diff) | |
download | bcm5719-llvm-36a216eefc8c1d46bc6704cd355d55abbea33c41.tar.gz bcm5719-llvm-36a216eefc8c1d46bc6704cd355d55abbea33c41.zip |
Increase the gdb-remote packet timeout for the first packet we send
to the remote side (QStartNoAckMode) - it may take a little longer
than normal to get a reply.
In debugserver, hardcode the priority for several threads so they
aren't de-prioritized when a user app is using system resources.
Also, set the names of the threads.
<rdar://problem/17509866>
llvm-svn: 213828
Diffstat (limited to 'lldb/tools/debugserver')
-rw-r--r-- | lldb/tools/debugserver/source/DNB.cpp | 32 | ||||
-rw-r--r-- | lldb/tools/debugserver/source/MacOSX/MachProcess.mm | 9 | ||||
-rw-r--r-- | lldb/tools/debugserver/source/MacOSX/MachTask.mm | 19 | ||||
-rw-r--r-- | lldb/tools/debugserver/source/RNBContext.cpp | 19 | ||||
-rw-r--r-- | lldb/tools/debugserver/source/RNBRemote.cpp | 19 | ||||
-rw-r--r-- | lldb/tools/debugserver/source/debugserver.cpp | 17 |
6 files changed, 115 insertions, 0 deletions
diff --git a/lldb/tools/debugserver/source/DNB.cpp b/lldb/tools/debugserver/source/DNB.cpp index abd1661af52..304c655921d 100644 --- a/lldb/tools/debugserver/source/DNB.cpp +++ b/lldb/tools/debugserver/source/DNB.cpp @@ -26,6 +26,11 @@ #include <vector> #include <libproc.h> +#if defined (__APPLE__) +#include <pthread.h> +#include <sched.h> +#endif + #define TRY_KQUEUE 1 #ifdef TRY_KQUEUE @@ -141,6 +146,19 @@ kqueue_thread (void *arg) { int kq_id = (int) (intptr_t) arg; +#if defined (__APPLE__) + pthread_setname_np ("kqueue thread"); +#if defined (__arm__) || defined (__arm64__) || defined (__aarch64__) + struct sched_param thread_param; + int thread_sched_policy; + if (pthread_getschedparam(pthread_self(), &thread_sched_policy, &thread_param) == 0) + { + thread_param.sched_priority = 47; + pthread_setschedparam(pthread_self(), thread_sched_policy, &thread_param); + } +#endif +#endif + struct kevent death_event; while (1) { @@ -265,6 +283,20 @@ waitpid_thread (void *arg) { const pid_t pid = (pid_t)(intptr_t)arg; int status; + +#if defined (__APPLE__) + pthread_setname_np ("waitpid thread"); +#if defined (__arm__) || defined (__arm64__) || defined (__aarch64__) + struct sched_param thread_param; + int thread_sched_policy; + if (pthread_getschedparam(pthread_self(), &thread_sched_policy, &thread_param) == 0) + { + thread_param.sched_priority = 47; + pthread_setschedparam(pthread_self(), thread_sched_policy, &thread_param); + } +#endif +#endif + while (1) { pid_t child_pid = waitpid(pid, &status, 0); diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm index 565a4ef5627..98cf95eded4 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm +++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm @@ -22,6 +22,7 @@ #include <sys/stat.h> #include <sys/sysctl.h> #include <unistd.h> +#include <pthread.h> #include "MacOSX/CFUtils.h" #include "SysSignal.h" @@ -1445,6 +1446,10 @@ MachProcess::STDIOThread(void *arg) MachProcess *proc = (MachProcess*) arg; DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s ( arg = %p ) thread starting...", __FUNCTION__, arg); +#if defined (__APPLE__) + pthread_setname_np ("stdio monitoring thread"); +#endif + // We start use a base and more options so we can control if we // are currently using a timeout on the mach_msg. We do this to get a // bunch of related exceptions on our exception port so we can process @@ -1611,6 +1616,10 @@ MachProcess::ProfileThread(void *arg) MachProcess *proc = (MachProcess*) arg; DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s ( arg = %p ) thread starting...", __FUNCTION__, arg); +#if defined (__APPLE__) + pthread_setname_np ("performance profiling thread"); +#endif + while (proc->IsProfilingEnabled()) { nub_state_t state = proc->GetState(); diff --git a/lldb/tools/debugserver/source/MacOSX/MachTask.mm b/lldb/tools/debugserver/source/MacOSX/MachTask.mm index fa7bf249e36..c14b377f118 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachTask.mm +++ b/lldb/tools/debugserver/source/MacOSX/MachTask.mm @@ -23,6 +23,11 @@ #include <mach/mach_vm.h> #import <sys/sysctl.h> +#if defined (__APPLE__) +#include <pthread.h> +#include <sched.h> +#endif + // C++ Includes #include <iomanip> #include <sstream> @@ -640,6 +645,7 @@ bool MachTask::StartExceptionThread(DNBError &err) { DNBLogThreadedIf(LOG_EXCEPTIONS, "MachTask::%s ( )", __FUNCTION__); + task_t task = TaskPortForProcessID(err); if (MachTask::IsValid(task)) { @@ -731,6 +737,19 @@ MachTask::ExceptionThread (void *arg) MachProcess *mach_proc = mach_task->Process(); DNBLogThreadedIf(LOG_EXCEPTIONS, "MachTask::%s ( arg = %p ) starting thread...", __FUNCTION__, arg); +#if defined (__APPLE__) + pthread_setname_np ("exception monitoring thread"); +#if defined (__arm__) || defined (__arm64__) || defined (__aarch64__) + struct sched_param thread_param; + int thread_sched_policy; + if (pthread_getschedparam(pthread_self(), &thread_sched_policy, &thread_param) == 0) + { + thread_param.sched_priority = 47; + pthread_setschedparam(pthread_self(), thread_sched_policy, &thread_param); + } +#endif +#endif + // We keep a count of the number of consecutive exceptions received so // we know to grab all exceptions without a timeout. We do this to get a // bunch of related exceptions on our exception port so we can process diff --git a/lldb/tools/debugserver/source/RNBContext.cpp b/lldb/tools/debugserver/source/RNBContext.cpp index b9189df9d1c..960d6d99c9d 100644 --- a/lldb/tools/debugserver/source/RNBContext.cpp +++ b/lldb/tools/debugserver/source/RNBContext.cpp @@ -16,6 +16,11 @@ #include <sys/stat.h> #include <sstream> +#if defined (__APPLE__) +#include <pthread.h> +#include <sched.h> +#endif + #include "RNBRemote.h" #include "DNB.h" #include "DNBLog.h" @@ -145,6 +150,20 @@ RNBContext::ThreadFunctionProcessStatus(void *arg) nub_process_t pid = ctx.ProcessID(); DNBLogThreadedIf(LOG_RNB_PROC, "RNBContext::%s (arg=%p, pid=%4.4x): thread starting...", __FUNCTION__, arg, pid); ctx.Events().SetEvents (RNBContext::event_proc_thread_running); + +#if defined (__APPLE__) + pthread_setname_np ("child process status watcher thread"); +#if defined (__arm__) || defined (__arm64__) || defined (__aarch64__) + struct sched_param thread_param; + int thread_sched_policy; + if (pthread_getschedparam(pthread_self(), &thread_sched_policy, &thread_param) == 0) + { + thread_param.sched_priority = 47; + pthread_setschedparam(pthread_self(), thread_sched_policy, &thread_param); + } +#endif +#endif + bool done = false; while (!done) { diff --git a/lldb/tools/debugserver/source/RNBRemote.cpp b/lldb/tools/debugserver/source/RNBRemote.cpp index c731fbea02b..aa5bcd130f6 100644 --- a/lldb/tools/debugserver/source/RNBRemote.cpp +++ b/lldb/tools/debugserver/source/RNBRemote.cpp @@ -20,6 +20,11 @@ #include <sys/stat.h> #include <sys/sysctl.h> +#if defined (__APPLE__) +#include <pthread.h> +#include <sched.h> +#endif + #include "DNB.h" #include "DNBDataRef.h" #include "DNBLog.h" @@ -755,6 +760,20 @@ RNBRemote::ThreadFunctionReadRemoteData(void *arg) RNBRemoteSP remoteSP(g_remoteSP); if (remoteSP.get() != NULL) { + +#if defined (__APPLE__) + pthread_setname_np ("read gdb-remote packets thread"); +#if defined (__arm__) || defined (__arm64__) || defined (__aarch64__) + struct sched_param thread_param; + int thread_sched_policy; + if (pthread_getschedparam(pthread_self(), &thread_sched_policy, &thread_param) == 0) + { + thread_param.sched_priority = 47; + pthread_setschedparam(pthread_self(), thread_sched_policy, &thread_param); + } +#endif +#endif + RNBRemote* remote = remoteSP.get(); PThreadEvent& events = remote->Context().Events(); events.SetEvents (RNBContext::event_read_thread_running); diff --git a/lldb/tools/debugserver/source/debugserver.cpp b/lldb/tools/debugserver/source/debugserver.cpp index 07d674dde25..c46d63d8b42 100644 --- a/lldb/tools/debugserver/source/debugserver.cpp +++ b/lldb/tools/debugserver/source/debugserver.cpp @@ -25,6 +25,10 @@ #include <sys/types.h> #include <crt_externs.h> // for _NSGetEnviron() +#if defined (__APPLE__) +#include <sched.h> +#endif + #include "CFString.h" #include "DNB.h" #include "DNBLog.h" @@ -877,6 +881,19 @@ main (int argc, char *argv[]) { const char *argv_sub_zero = argv[0]; // save a copy of argv[0] for error reporting post-launch +#if defined (__APPLE__) + pthread_setname_np ("main thread"); +#if defined (__arm__) || defined (__arm64__) || defined (__aarch64__) + struct sched_param thread_param; + int thread_sched_policy; + if (pthread_getschedparam(pthread_self(), &thread_sched_policy, &thread_param) == 0) + { + thread_param.sched_priority = 47; + pthread_setschedparam(pthread_self(), thread_sched_policy, &thread_param); + } +#endif +#endif + g_isatty = ::isatty (STDIN_FILENO); // ::printf ("uid=%u euid=%u gid=%u egid=%u\n", |