1 //===-- HostInfoNetBSD.cpp -------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "lldb/Host/netbsd/HostInfoNetBSD.h"
16 #include <sys/sysctl.h>
17 #include <sys/types.h>
18 #include <sys/utsname.h>
21 using namespace lldb_private;
23 llvm::VersionTuple HostInfoNetBSD::GetOSVersion() {
26 ::memset(&un, 0, sizeof(un));
28 return llvm::VersionTuple();
30 /* Accept versions like 7.99.21 and 6.1_STABLE */
31 uint32_t major, minor, update;
32 int status = ::sscanf(un.release, "%" PRIu32 ".%" PRIu32 ".%" PRIu32, &major,
36 return llvm::VersionTuple(major);
38 return llvm::VersionTuple(major, minor);
40 return llvm::VersionTuple(major, minor, update);
42 return llvm::VersionTuple();
45 bool HostInfoNetBSD::GetOSBuildString(std::string &s) {
46 int mib[2] = {CTL_KERN, KERN_OSREV};
49 size_t osrev_len = sizeof(osrev);
51 if (::sysctl(mib, 2, &osrev, &osrev_len, NULL, 0) == 0) {
52 ::snprintf(osrev_str, sizeof(osrev_str), "%-10.10d", osrev);
61 bool HostInfoNetBSD::GetOSKernelDescription(std::string &s) {
64 ::memset(&un, 0, sizeof(un));
75 FileSpec HostInfoNetBSD::GetProgramFileSpec() {
76 static FileSpec g_program_filespec;
78 if (!g_program_filespec) {
79 static const int name[] = {
80 CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME,
82 char path[MAXPATHLEN];
86 if (sysctl(name, __arraycount(name), path, &len, NULL, 0) != -1) {
87 g_program_filespec.SetFile(path, FileSpec::Style::native);
90 return g_program_filespec;