int uname(struct utsname *info) { cpu_topology_node_info root; system_info systemInfo; const char *platform; const char *haikuRevision; uint32 count = 1; status_t error; if (!info) { __set_errno(B_BAD_VALUE); return -1; } get_system_info(&systemInfo); strlcpy(info->sysname, "Haiku", sizeof(info->sysname)); haikuRevision = __get_haiku_revision(); if (haikuRevision[0] != '\0') snprintf(info->version, sizeof(info->version), "%s ", haikuRevision); else info->version[0] = '\0'; strlcat(info->version, systemInfo.kernel_build_date, sizeof(info->version)); strlcat(info->version, " ", sizeof(info->version)); strlcat(info->version, systemInfo.kernel_build_time, sizeof(info->version)); snprintf(info->release, sizeof(info->release), "%" B_PRId64, systemInfo.kernel_version); error = get_cpu_topology_info(&root, &count); if (error != B_OK || count < 1) platform = "unknown"; else { switch (root.data.root.platform) { case B_CPU_x86: platform = "BePC"; break; case B_CPU_x86_64: platform = "x86_64"; break; case B_CPU_PPC: platform = "ppc"; break; case B_CPU_PPC_64: platform = "ppc64"; break; case B_CPU_M68K: platform = "m68k"; break; case B_CPU_ARM: /* The minimal ARM version emulated by QEMU * XXX: use armv6 (raspberry Pi)? * XXX: should we really use B_HOST_IS_LENDIAN here? * XXX: use real cpu version as on Linux? * cf. http://git.qemu.org/?p=qemu.git;a=blob;f=linux-user/uname.c */ #if B_HOST_IS_LENDIAN platform = "armv5tel"; #else platform = "armv5teb"; #endif break; case B_CPU_ARM_64: platform = "aarch64"; break; case B_CPU_ALPHA: platform = "alpha"; break; case B_CPU_MIPS: platform = "mips"; break; case B_CPU_SH: platform = "sh4"; break; case B_CPU_UNKNOWN: default: platform = "unknown"; break; } } strlcpy(info->machine, platform, sizeof(info->machine)); if (gethostname(info->nodename, sizeof(info->nodename)) != 0) strlcpy(info->nodename, "unknown", sizeof(info->nodename)); return 0; }
status_t DebugReportGenerator::_GenerateReportHeader(BFile& _output) { AutoLocker< ::Team> locker(fTeam); BString data; data.SetToFormat("Debug information for team %s (%" B_PRId32 "):\n", fTeam->Name(), fTeam->ID()); WRITE_AND_CHECK(_output, data); cpu_platform platform = B_CPU_UNKNOWN; cpu_vendor cpuVendor = B_CPU_VENDOR_UNKNOWN; uint32 cpuModel = 0; uint32 topologyNodeCount = 0; cpu_topology_node_info* topology = NULL; get_cpu_topology_info(NULL, &topologyNodeCount); if (topologyNodeCount != 0) { topology = new(std::nothrow) cpu_topology_node_info[topologyNodeCount]; if (topology == NULL) return B_NO_MEMORY; BPrivate::ArrayDeleter<cpu_topology_node_info> deleter(topology); get_cpu_topology_info(topology, &topologyNodeCount); for (uint32 i = 0; i < topologyNodeCount; i++) { switch (topology[i].type) { case B_TOPOLOGY_ROOT: platform = topology[i].data.root.platform; break; case B_TOPOLOGY_PACKAGE: cpuVendor = topology[i].data.package.vendor; break; case B_TOPOLOGY_CORE: cpuModel = topology[i].data.core.model; break; default: break; } } } SystemInfo sysInfo; if (fDebuggerInterface->GetSystemInfo(sysInfo) == B_OK) { const system_info &info = sysInfo.GetSystemInfo(); data.SetToFormat("CPU(s): %" B_PRId32 "x %s %s\n", info.cpu_count, get_cpu_vendor_string(cpuVendor), get_cpu_model_string(platform, cpuVendor, cpuModel)); WRITE_AND_CHECK(_output, data); char maxSize[32]; char usedSize[32]; data.SetToFormat("Memory: %s total, %s used\n", BPrivate::string_for_size((int64)info.max_pages * B_PAGE_SIZE, maxSize, sizeof(maxSize)), BPrivate::string_for_size((int64)info.used_pages * B_PAGE_SIZE, usedSize, sizeof(usedSize))); WRITE_AND_CHECK(_output, data); const utsname& name = sysInfo.GetSystemName(); data.SetToFormat("Haiku revision: %s (%s)\n", name.version, name.machine); WRITE_AND_CHECK(_output, data); } return B_OK; }