forked from OSchip/llvm-project
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
This commit is contained in:
parent
451f30e89f
commit
36a216eefc
|
@ -227,8 +227,18 @@ GDBRemoteCommunicationClient::QueryNoAckModeSupported ()
|
|||
m_send_acks = true;
|
||||
m_supports_not_sending_acks = eLazyBoolNo;
|
||||
|
||||
// This is the first real packet that we'll send in a debug session and it may take a little
|
||||
// longer than normal to receive a reply. Wait at least 6 seconds for a reply to this packet.
|
||||
|
||||
const uint32_t minimum_timeout = 6;
|
||||
uint32_t old_timeout = GetPacketTimeoutInMicroSeconds() / lldb_private::TimeValue::MicroSecPerSec;
|
||||
SetPacketTimeout (std::max (old_timeout, minimum_timeout));
|
||||
|
||||
StringExtractorGDBRemote response;
|
||||
if (SendPacketAndWaitForResponse("QStartNoAckMode", response, false) == PacketResult::Success)
|
||||
PacketResult packet_send_result = SendPacketAndWaitForResponse("QStartNoAckMode", response, false);
|
||||
SetPacketTimeout (old_timeout);
|
||||
|
||||
if (packet_send_result == PacketResult::Success)
|
||||
{
|
||||
if (response.IsOKResponse())
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue