mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 06:05:59 +01:00
Unbreak CrashReporter on FreeBSD (#1589)
This commit is contained in:
parent
784cdd7638
commit
474ada9267
6 changed files with 49 additions and 0 deletions
|
@ -69,6 +69,12 @@ file(GLOB_RECURSE SRCFILES "src/*.cpp")
|
||||||
|
|
||||||
add_executable(Hyprland ${SRCFILES})
|
add_executable(Hyprland ${SRCFILES})
|
||||||
|
|
||||||
|
include(CheckLibraryExists)
|
||||||
|
check_library_exists(execinfo backtrace "" HAVE_LIBEXECINFO)
|
||||||
|
if(HAVE_LIBEXECINFO)
|
||||||
|
target_link_libraries(Hyprland PRIVATE execinfo)
|
||||||
|
endif()
|
||||||
|
|
||||||
IF(LEGACY_RENDERER MATCHES true)
|
IF(LEGACY_RENDERER MATCHES true)
|
||||||
message(STATUS "Using the legacy GLES2 renderer!")
|
message(STATUS "Using the legacy GLES2 renderer!")
|
||||||
add_definitions( -DLEGACY_RENDERER )
|
add_definitions( -DLEGACY_RENDERER )
|
||||||
|
|
|
@ -52,6 +52,7 @@ if not have_xwayland
|
||||||
add_project_arguments('-DNO_XWAYLAND', language: 'cpp')
|
add_project_arguments('-DNO_XWAYLAND', language: 'cpp')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
backtrace_dep = cpp_compiler.find_library('execinfo', required: false)
|
||||||
systemd_dep = dependency('libsystemd', required: get_option('systemd'))
|
systemd_dep = dependency('libsystemd', required: get_option('systemd'))
|
||||||
|
|
||||||
if get_option('systemd').enabled()
|
if get_option('systemd').enabled()
|
||||||
|
|
|
@ -4,6 +4,10 @@
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__)
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string getRandomMessage() {
|
std::string getRandomMessage() {
|
||||||
|
|
||||||
const std::vector<std::string> MESSAGES = {"Sorry, didn't mean to...",
|
const std::vector<std::string> MESSAGES = {"Sorry, didn't mean to...",
|
||||||
|
@ -47,7 +51,11 @@ void CrashReporter::createAndSaveCrash() {
|
||||||
finalCrashReport +=
|
finalCrashReport +=
|
||||||
getFormat("\tSystem name: %s\n\tNode name: %s\n\tRelease: %s\n\tVersion: %s\n\n", unameInfo.sysname, unameInfo.nodename, unameInfo.release, unameInfo.version);
|
getFormat("\tSystem name: %s\n\tNode name: %s\n\tRelease: %s\n\tVersion: %s\n\n", unameInfo.sysname, unameInfo.nodename, unameInfo.release, unameInfo.version);
|
||||||
|
|
||||||
|
#if defined(__DragonFly__) || defined(__FreeBSD__)
|
||||||
|
const std::string GPUINFO = execAndGet("pciconf -lv | fgrep -A4 vga");
|
||||||
|
#else
|
||||||
const std::string GPUINFO = execAndGet("lspci -vnn | grep VGA");
|
const std::string GPUINFO = execAndGet("lspci -vnn | grep VGA");
|
||||||
|
#endif
|
||||||
|
|
||||||
finalCrashReport += "GPU:\n\t" + GPUINFO;
|
finalCrashReport += "GPU:\n\t" + GPUINFO;
|
||||||
|
|
||||||
|
@ -61,12 +69,40 @@ void CrashReporter::createAndSaveCrash() {
|
||||||
|
|
||||||
btSize = backtrace(bt, 1024);
|
btSize = backtrace(bt, 1024);
|
||||||
btSymbols = backtrace_symbols(bt, btSize);
|
btSymbols = backtrace_symbols(bt, btSize);
|
||||||
|
|
||||||
|
#if defined(KERN_PROC_PATHNAME)
|
||||||
|
int mib[] = {
|
||||||
|
CTL_KERN,
|
||||||
|
#if defined(__NetBSD__)
|
||||||
|
KERN_PROC_ARGS,
|
||||||
|
-1,
|
||||||
|
KERN_PROC_PATHNAME,
|
||||||
|
#else
|
||||||
|
KERN_PROC,
|
||||||
|
KERN_PROC_PATHNAME,
|
||||||
|
-1,
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
u_int miblen = sizeof(mib) / sizeof(mib[0]);
|
||||||
|
char exe[PATH_MAX] = "";
|
||||||
|
size_t sz = sizeof(exe);
|
||||||
|
sysctl(mib, miblen, &exe, &sz, NULL, 0);
|
||||||
|
const auto FPATH = std::filesystem::canonical(exe);
|
||||||
|
#elif defined(__OpenBSD__)
|
||||||
|
// Neither KERN_PROC_PATHNAME nor /proc are supported
|
||||||
|
const auto FPATH = std::filesystem::canonical("/usr/local/bin/Hyprland");
|
||||||
|
#else
|
||||||
const auto FPATH = std::filesystem::canonical("/proc/self/exe");
|
const auto FPATH = std::filesystem::canonical("/proc/self/exe");
|
||||||
|
#endif
|
||||||
|
|
||||||
for (size_t i = 0; i < btSize; ++i) {
|
for (size_t i = 0; i < btSize; ++i) {
|
||||||
finalCrashReport += getFormat("\t#%i | %s\n", i, btSymbols[i]);
|
finalCrashReport += getFormat("\t#%i | %s\n", i, btSymbols[i]);
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
const auto CMD = getFormat("llvm-addr2line -e %s -f 0x%lx", FPATH.c_str(), (uint64_t)bt[i]);
|
||||||
|
#else
|
||||||
const auto CMD = getFormat("addr2line -e %s -f 0x%lx", FPATH.c_str(), (uint64_t)bt[i]);
|
const auto CMD = getFormat("addr2line -e %s -f 0x%lx", FPATH.c_str(), (uint64_t)bt[i]);
|
||||||
|
#endif
|
||||||
const auto ADDR2LINE = replaceInString(execAndGet(CMD.c_str()), "\n", "\n\t\t");
|
const auto ADDR2LINE = replaceInString(execAndGet(CMD.c_str()), "\n", "\n\t\t");
|
||||||
finalCrashReport += "\t\t" + ADDR2LINE.substr(0, ADDR2LINE.length() - 2);
|
finalCrashReport += "\t\t" + ADDR2LINE.substr(0, ADDR2LINE.length() - 2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -412,7 +412,11 @@ void logSystemInfo() {
|
||||||
|
|
||||||
Debug::log(NONE, "\n");
|
Debug::log(NONE, "\n");
|
||||||
|
|
||||||
|
#if defined(__DragonFly__) || defined(__FreeBSD__)
|
||||||
|
const std::string GPUINFO = execAndGet("pciconf -lv | fgrep -A4 vga");
|
||||||
|
#else
|
||||||
const std::string GPUINFO = execAndGet("lspci -vnn | grep VGA");
|
const std::string GPUINFO = execAndGet("lspci -vnn | grep VGA");
|
||||||
|
#endif
|
||||||
Debug::log(LOG, "GPU information:\n%s\n", GPUINFO.c_str());
|
Debug::log(LOG, "GPU information:\n%s\n", GPUINFO.c_str());
|
||||||
|
|
||||||
if (GPUINFO.contains("NVIDIA")) {
|
if (GPUINFO.contains("NVIDIA")) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "Vector2D.hpp"
|
#include "Vector2D.hpp"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
Vector2D::Vector2D(double xx, double yy) {
|
Vector2D::Vector2D(double xx, double yy) {
|
||||||
x = xx;
|
x = xx;
|
||||||
|
|
|
@ -14,6 +14,7 @@ executable('Hyprland', src,
|
||||||
dependency('xkbcommon'),
|
dependency('xkbcommon'),
|
||||||
dependency('libinput'),
|
dependency('libinput'),
|
||||||
xcb_dep,
|
xcb_dep,
|
||||||
|
backtrace_dep,
|
||||||
systemd_dep,
|
systemd_dep,
|
||||||
|
|
||||||
dependency('pixman-1'),
|
dependency('pixman-1'),
|
||||||
|
|
Loading…
Reference in a new issue