summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/netbsd/HostThreadNetBSD.cpp
blob: e8c106b7f229b8063df7d9cc0104aeaf2a07ae0a (plain)
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
40
41
42
43
//===-- HostThreadNetBSD.cpp -----------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

// lldb Includes
#include "lldb/Host/netbsd/HostThreadNetBSD.h"
#include "lldb/Host/Host.h"

// C includes
#include <errno.h>
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
#include <sys/sysctl.h>
#include <sys/user.h>

// C++ includes
#include <string>

using namespace lldb_private;

HostThreadNetBSD::HostThreadNetBSD() {}

HostThreadNetBSD::HostThreadNetBSD(lldb::thread_t thread)
    : HostThreadPosix(thread) {}

void HostThreadNetBSD::SetName(lldb::thread_t thread, llvm::StringRef &name) {
  ::pthread_setname_np(thread, "%s", const_cast<char *>(name.data()));
}

void HostThreadNetBSD::GetName(lldb::thread_t thread,
                               llvm::SmallVectorImpl<char> &name) {
  char buf[PTHREAD_MAX_NAMELEN_NP];
  ::pthread_getname_np(thread, buf, PTHREAD_MAX_NAMELEN_NP);

  name.clear();
  name.append(buf, buf + strlen(buf));
}
OpenPOWER on IntegriCloud