aboutsummaryrefslogtreecommitdiff
path: root/source/Host/macosx/ThisThread.cpp
blob: 95c7f2bf1e38b15e6f17077c7a430d520f07f96f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//===-- ThisThread.cpp ------------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "lldb/Host/ThisThread.h"

#include <pthread.h>

using namespace lldb_private;

void
ThisThread::SetName(llvm::StringRef name)
{
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
    ::pthread_setname_np(name);
#endif
}

void
ThisThread::GetName(llvm::SmallVectorImpl<char> &name)
{
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
    char pthread_name[1024];
    dispatch_queue_t current_queue = ::dispatch_get_current_queue();
    if (current_queue != NULL)
    {
        const char *queue_name = dispatch_queue_get_label(current_queue);
        if (queue_name && queue_name[0])
        {
            name = queue_name;
        }
    }
#endif
}