Bruce Mitchener | 910af4d | 2015-10-13 05:04:13 +0000 | [diff] [blame^] | 1 | //===-- HostThreadNetBSD.cpp -----------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // lldb Includes |
| 11 | #include "lldb/Host/netbsd/HostThreadNetBSD.h" |
| 12 | #include "lldb/Host/Host.h" |
| 13 | |
| 14 | // C includes |
| 15 | #include <errno.h> |
| 16 | #include <pthread.h> |
| 17 | #include <stdlib.h> |
| 18 | #include <string.h> |
| 19 | #include <sys/sysctl.h> |
| 20 | #include <sys/user.h> |
| 21 | |
| 22 | // C++ includes |
| 23 | #include <string> |
| 24 | |
| 25 | using namespace lldb_private; |
| 26 | |
| 27 | HostThreadNetBSD::HostThreadNetBSD() |
| 28 | { |
| 29 | } |
| 30 | |
| 31 | HostThreadNetBSD::HostThreadNetBSD(lldb::thread_t thread) |
| 32 | : HostThreadPosix(thread) |
| 33 | { |
| 34 | } |
| 35 | |
| 36 | void |
| 37 | HostThreadNetBSD::SetName(lldb::thread_t thread, llvm::StringRef &name) |
| 38 | { |
| 39 | ::pthread_setname_np(thread, "%s", const_cast<char*>(name.data())); |
| 40 | } |
| 41 | |
| 42 | void |
| 43 | HostThreadNetBSD::GetName(lldb::thread_t thread, llvm::SmallVectorImpl<char> &name) |
| 44 | { |
| 45 | char buf[PTHREAD_MAX_NAMELEN_NP]; |
| 46 | ::pthread_getname_np(thread, buf, PTHREAD_MAX_NAMELEN_NP); |
| 47 | |
| 48 | name.clear(); |
| 49 | name.append(buf, buf + strlen(buf)); |
| 50 | } |