Compare commits

...

74 Commits

Author SHA1 Message Date
flightlessmango 41f2cf74de shell: just unset LD_PRELOAD on all commands 1 day ago
flightlessmango 2937785446 params: fix read_cfg not overriding config options 1 day ago
flightlessmango eaa96ecfba shell: attempt to fix showing ld error 1 day ago
jackun 4a34502aeb
Add virtual dtor to CPUPowerData
ASan complains about allocated size mismatch in ctor/dtor.
Scott Meyers says: "Polymorphic base classes should declare virtual destructors. If a class has any virtual functions, it should have a virtual destructor."
2 days ago
flightlessmango 4307450c02 params: control: change errors to debug 4 days ago
flightlessmango a4393e0e42 Shell: read: only get last line 4 days ago
flightlessmango 511b7a6f2a Shell: add debug for cmd and output 5 days ago
Leopard1907 391c52271c Update blacklist.cpp 5 days ago
Leopard1907 e6b7304ec5 [blacklist] Add Ubisoft store 5 days ago
João Batista b217d75917 meson.build - v0.7.2 1 week ago
flightlessmango 7b80f733b6 workflow: build-package: actually fix bad credentials 1 week ago
flightlessmango 038478a96a workflow: build-package: create release if it doesn't exist 1 week ago
flightlessmango f22d3221a3 workflow: build-package: add auth debug 1 week ago
flightlessmango d8ed2331c3 workflow: build-package fix typo 1 week ago
flightlessmango 6312c46663 workflow: build-package: attempt to fix release upload 1 week ago
flightlessmango 78a892e1af Revert "test: amdgpu: convert metrics to host endian"
This reverts commit faa3b1c22f.
1 week ago
flightlessmango 63eaf1489a Revert "amdgpu: rework convertion of endian"
This reverts commit dc7ec94549.
1 week ago
flightlessmango 4cbcec30b8 intel: don't use of intel_gpu_top
It's too much of a hassle to use intel_gpu_top, let's just wait
until these values are exposed in sysfs and until then we will just
have gpu load
2 weeks ago
flightlessmango dc7ec94549 amdgpu: rework convertion of endian
We convert to host endian as we fetch the values from gpu_metrics
2 weeks ago
flightlessmango faa3b1c22f test: amdgpu: convert metrics to host endian 2 weeks ago
flightlessmango 0caded833e intel: don't disable if intel_gpu_top fails
Before we only had intel_gpu_top to rely on, but now
we can also get gpu load from fd.
2 weeks ago
Alex Maese 872a564889 Set current_preset to first preset when use_existing_preset is false 2 weeks ago
Alex Maese 5c1fe0a5e6 Fix issue where presets weren't applied when MANGOHUD_CONFIG is set
When MANGOHUD_CONFIG was set but didn't contain either read_cfg or
preset values, the preset was never applied
2 weeks ago
Alex Maese 6ab4624cfb Use 'debug' log level when presets.conf doesn't exist 3 weeks ago
Bill Li f0407636d3 pkgbuild: update source for sdplog to 1.14.1 3 weeks ago
Alesh Slovak 5d744d328a add various additional stats to log summary 3 weeks ago
Gonçalo Negrier Duarte 4ee8a9aac4 meson: verify if system lib are present before fallback to submodules
* if meson dosen't found spdlog with use_system_spdlog enabled
  meson will print a warning and fallback to the submodule
  instead of giving an error
* System vulkan-headers can't be use since mangohud don't use latest SDK
  The code is commented out for future use
* All the other submodules will use system dependency when found

Signed-off-by: Gonçalo Negrier Duarte <gonegrier.duarte@gmail.com>
3 weeks ago
flightlessmango 31f2ca5e30 meson: spdlog: try to sort out proper fallback 3 weeks ago
Alessandro Toia 57cd928c63 spdlog-wrap: update to version 1.14.1 4 weeks ago
Arias800 32c6cf0ebd Add nvidia shield 2017 controller 4 weeks ago
flightlessmango ec1b9c017f meson: spdlog: check if system is disabled 4 weeks ago
flightlessmango 55712618fa presets: 4: disable gpu_fan for steamdeck 4 weeks ago
flightlessmango a0a31b4f64 x11: check that DISPLAY env exists 1 month ago
Etaash Mathamsetty 4cad060334 fix locking in device_info 1 month ago
Błażej Szczygieł 121cf54d9b hud elements: clear ordered_functions when legacy_layout is disabled
fixes #1236
1 month ago
Alessandro Toia 7497b1da3f device: Use LOGI MOUSE/KB instead of device_name 1 month ago
Etaash Mathamsetty 0e92ec4790 fix device_data race condition with mutex 1 month ago
Milos Tijanic 44eb25e10e nvml: only query params that will actually be used 1 month ago
flightlessmango 046b6cecdd winesync: small font 2 months ago
flightlessmango b6291a51e6 refresh_rate: small font 2 months ago
flightlessmango ba220022d0 network: remove header and add arrow indicators 2 months ago
flightlessmango 8491ff5aa9 preset: 4: add network and remove present_mode 2 months ago
flightlessmango c363c96cd5 network: color: change to #e07b85 2 months ago
flightlessmango 23a2d53a3b time_no_label: don't enable with full 2 months ago
flightlessmango 4f43b260cc gamescope frame timing: app was not displaying correctly 2 months ago
Etaash Mathamsetty 6ec1f8c80e run angle check before regular dlsym 2 months ago
Etaash Mathamsetty d23b4cde8c promote debug statement to error 2 months ago
Sefa Eyeoglu 4d0b1e1fb8 blacklist: add monado-service
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
2 months ago
Etaash Mathamsetty 366c1a233f use simpler method to detect angle 2 months ago
Etaash Mathamsetty 86668eeb96 HACK: check EGL load directory and only hook the first loaded libEGL 2 months ago
Etaash Mathamsetty e99284aadd fix electron apps like minecraft-launcher 2 months ago
Etaash Mathamsetty 5912cce19f fix exception with std::stoi 2 months ago
flightlessmango 1e13c385fe build.sh: add steamos to arch 2 months ago
flightlessmango 291ffd263c shell: fix spdlog error typo for writing 2 months ago
flightlessmango ffff9b83b2 Revert "fix exception with std::stoi"
This reverts commit 054f4cc9e3.
2 months ago
flightlessmango 14b1d87ad8 Revert "fix electron apps like minecraft-launcher"
This reverts commit a65d1d8a2b.
2 months ago
flightlessmango f7d291bbe9 Revert "HACK: check EGL load directory and only hook the first loaded libEGL"
This reverts commit c39984da9e.
2 months ago
Etaash Mathamsetty c39984da9e HACK: check EGL load directory and only hook the first loaded libEGL 2 months ago
Etaash Mathamsetty a65d1d8a2b fix electron apps like minecraft-launcher 2 months ago
Etaash Mathamsetty 054f4cc9e3 fix exception with std::stoi 2 months ago
flightlessmango 66b103ac55 config: mutex: forgot brackets in render 2 months ago
flightlessmango 33b8924384 config: add a mutex for config
We want to wait to render before config has been fully loaded.
Otherwise this can sometimes cause a crash when we access config
options while they are being assigned.
2 months ago
flightlessmango 4aa92187a7 logging: fixed a crash when reloading config while logging 2 months ago
flightlessmango 976ae0f75a shell: fix more unused warnings 2 months ago
flightlessmango 77d6244cea cpu: temp: check that input gives a non-zero value 2 months ago
flightlessmango cdd8043489 param: shell: fix unused variable warning 2 months ago
flightlessman fb0b559d04 inject_glx: fix unititalized warning 2 months ago
flightlessmango 7f439879e0 blacklist: add steamwebhelper and EpicWebHelper 2 months ago
flightlessmango a41e8e0d1f meson: can't build mangoapp without x11 2 months ago
flightlessmango 01b81d068b meson: compile opengl files regardless of x11/wayland 2 months ago
flightlessmango 6e5581ba79 params: exec: make it right aligned 2 months ago
Alessandro Toia dbf0c91f47 build: add Pop!_OS to check dependencies 2 months ago
flightlessmango bcaccc8bd4 fix more ifdef typos 2 months ago
flightlessmango ad1d03d257 release: build package fix typo 2 months ago

@ -12,12 +12,14 @@ jobs:
- name: Install build tools
run: |
set -x
dpkg --add-architecture i386
sudo dpkg --add-architecture i386
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages focal main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt -y install gcc-multilib g++-multilib ninja-build python3-setuptools \
python3-wheel mesa-common-dev libxnvctrl-dev libdbus-1-dev \
python3-numpy python3-matplotlib unzip hub libxkbcommon-dev libwayland-dev wget unzip \
libxkbcommon-dev:i386 libwayland-dev:i386
libxkbcommon-dev:i386 libwayland-dev:i386 gh
sudo pip3 --no-input install 'meson>=0.60' mako
wget https://github.com/KhronosGroup/glslang/releases/download/SDK-candidate-26-Jul-2020/glslang-master-linux-Release.zip
unzip glslang-master-linux-Release.zip bin/glslangValidator
@ -35,32 +37,25 @@ jobs:
else
echo "##[set-output name=short-sha;]$(git rev-parse --short "$GITHUB_SHA")"
fi
echo "##[set-output name=artifact-metadata;]${ARTIFACT_NAME}"
id: git-vars
- name: Build release package
echo "##[set-output name=artifact-metadata;]$ARTIFACT_NAME"
- name: Build and package
run: |
./build-source.sh
./build.sh build -Dwerror=true package release
- name: Upload release
if: ${{ github.event_name == 'release' && github.event.action == 'published' }}
- name: Upload assets to release
if: github.event.action == 'published'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -x
assets=()
for asset in ./MangoHud-*-Source*.tar.*; do
assets+=("-a" "$asset")
done
for asset in ./build/MangoHud-*.tar.*; do
assets+=("-a" "$asset")
done
tag_name="${GITHUB_REF##*/}"
hub release edit "${assets[@]}" -m "" "$tag_name"
#hub release create "${assets[@]}" -m "$tag_name" "$tag_name"
for pkg in ./build/*.tar.*; do
gh release upload "$tag_name" "$pkg" --clobber
done
- name: Upload artifact
uses: actions/upload-artifact@v3
continue-on-error: true
with:
name: MangoHud-${{steps.git-vars.outputs.artifact-metadata}}
path: ${{runner.workspace}}/MangoHud/build/MangoHud-*tar.gz
retention-days: 30
retention-days: 30

@ -54,7 +54,7 @@ dependencies() {
for i in $DISTRO; do
echo "# Checking dependencies for \"$i\""
case $i in
*arch*|*manjaro*|*artix*)
*arch*|*manjaro*|*artix*|*SteamOS*)
MANAGER_QUERY="pacman -Q"
MANAGER_INSTALL="pacman -S"
DEPS="{${DEPS_ARCH}}"
@ -73,7 +73,7 @@ dependencies() {
break
;;
*debian*|*ubuntu*|*deepin*)
*debian*|*ubuntu*|*deepin*|*pop*)
MANAGER_QUERY="dpkg-query -s"
MANAGER_INSTALL="apt install"
DEPS="{${DEPS_DEBIAN}}"

@ -1,6 +1,6 @@
project('MangoHud',
['c', 'cpp'],
version : 'v0.7.1',
version : 'v0.7.2',
license : 'MIT',
meson_version: '>=0.60.0',
default_options : ['buildtype=release', 'c_std=c99', 'cpp_std=c++14', 'warning_level=2']
@ -166,9 +166,18 @@ else
dep_rt = null_dep
endif
vkh_sp = subproject('vulkan-headers')
vk_api_xml = vkh_sp.get_variable('vulkan_api_xml')
dep_vulkan = vkh_sp.get_variable('vulkan_headers_dep')
# Commented code can be used if mangohud start using latest SDK Vulkan-Headers
# Allowing user to build mangohud using system Vulkan-Headers
#if not dependency('VulkanHeaders').found()
vkh_sp = subproject('vulkan-headers')
vk_api_xml = vkh_sp.get_variable('vulkan_api_xml')
dep_vulkan = vkh_sp.get_variable('vulkan_headers_dep')
#else
# dep_vulkan = dependency('VulkanHeaders', required: true)
# vk_api_xml = files('/usr/share/vulkan/registry/vk.xml')
#endif
vk_enum_to_str = custom_target(
'vk_enum_to_str',
@ -213,36 +222,36 @@ if get_option('mangoapp')
'glfw=enabled',
]
endif
dearimgui_sp = subproject('imgui', default_options: imgui_options)
dearimgui_dep = dearimgui_sp.get_variable('imgui_dep')
dearimgui_dep = dependency('imgui', fallback: ['imgui'], required: true, default_options: imgui_options)
if is_unixy
implot_sp = subproject('implot', default_options: ['default_library=static'])
implot_dep = implot_sp.get_variable('implot_dep')
implot_dep = dependency('implot', fallback: ['implot'], required: true, default_options: ['default_library=static'])
else
implot_dep = null_dep
implot_lib = static_library('nulllib', [])
endif
spdlog_dep = cpp.find_library('spdlog', required: get_option('use_system_spdlog'))
if not spdlog_dep.found()
spdlog_sp = subproject('spdlog', default_options: [
'default_library=static',
'compile_library=true',
'werror=false',
'tests=disabled',
'external_fmt=disabled',
'std_format=disabled'
])
spdlog_dep = spdlog_sp.get_variable('spdlog_dep')
else
spdlog_dep = dependency('spdlog', required: true)
spdlog_options = [
'default_library=static',
'compile_library=true',
'werror=false',
'tests=disabled',
'external_fmt=disabled',
'std_format=disabled'
]
spdlog_dep = dependency('spdlog', required: false)
if get_option('use_system_spdlog').disabled() or not spdlog_dep.found()
if get_option('use_system_spdlog').enabled()
warning('spdlog depedency not found follwing back to submodule')
endif
spdlog_sp = subproject('spdlog', default_options: spdlog_options)
spdlog_dep = spdlog_sp.get_variable('spdlog_dep')
endif
if ['windows', 'mingw'].contains(host_machine.system())
minhook_sp = subproject('minhook')
minhook_dep = minhook_sp.get_variable('minhook_dep')
minhook_dep = dependency('minhook', fallback: ['minhook', 'minhook_dep'], required: true)
windows_deps = [
minhook_dep,
]
@ -278,6 +287,7 @@ if get_option('tests').enabled()
dep_vulkan,
cmocka_dep,
spdlog_dep,
implot_dep,
dearimgui_dep
],
include_directories: inc_common)

@ -1,7 +1,7 @@
# Maintainer: Simon Hallsten <flightlessmangoyt@gmail.com>
pkgname=('mangohud' 'lib32-mangohud')
pkgver=0.7.2.rc1
pkgver=0.7.2.rc3.r13.g5d744d3
pkgrel=1
pkgdesc="Vulkan and OpenGL overlay to display performance information"
arch=('x86_64')
@ -15,8 +15,8 @@ source=(
"mangohud-minhook"::"git+https://github.com/flightlessmango/minhook.git"
"imgui-1.89.9.tar.gz::https://github.com/ocornut/imgui/archive/refs/tags/v1.89.9.tar.gz"
"imgui_1.89.9-1_patch.zip::https://wrapdb.mesonbuild.com/v2/imgui_1.89.9-1/get_patch"
"spdlog-1.13.0.tar.gz::https://github.com/gabime/spdlog/archive/refs/tags/v1.13.0.tar.gz"
"spdlog_1.13.0-1_patch.zip::https://wrapdb.mesonbuild.com/v2/spdlog_1.13.0-1/get_patch"
"spdlog-1.14.1.tar.gz::https://github.com/gabime/spdlog/archive/refs/tags/v1.14.1.tar.gz"
"spdlog_1.14.1-1_patch.zip::https://wrapdb.mesonbuild.com/v2/spdlog_1.14.1-1/get_patch"
"nlohmann_json-3.10.5.zip::https://github.com/nlohmann/json/releases/download/v3.10.5/include.zip"
"vulkan-headers-1.2.158.tar.gz::https://github.com/KhronosGroup/Vulkan-Headers/archive/v1.2.158.tar.gz"
"vulkan-headers-1.2.158-2-wrap.zip::https://wrapdb.mesonbuild.com/v2/vulkan-headers_1.2.158-2/get_patch"
@ -29,8 +29,8 @@ sha256sums=(
'SKIP'
'1acc27a778b71d859878121a3f7b287cd81c29d720893d2b2bf74455bf9d52d6'
'9b21290c597d76bf8d4eeb3f9ffa024b11d9ea6c61e91d648ccc90b42843d584'
'534f2ee1a4dcbeb22249856edfb2be76a1cf4f708a20b0ac2ed090ee24cfdbc9'
'556b539cf582a46673ede4202ac037b891328dd5ea76862ffe05b060fc4f4775'
'1586508029a7d0670dfcb2d97575dcdc242d3868a259742b69f100801ab4e16b'
'ae878e732330ea1048f90d7e117c40c0cd2a6fb8ae5492c7955818ce3aaade6c'
'b94997df68856753b72f0d7a3703b7d484d4745c567f3584ef97c96c25a5798e'
"53361271cfe274df8782e1e47bdc9e61b7af432ba30acbfe31723f9df2c257f3"
"860358cf5e73f458cd1e88f8c38116d123ab421d5ce2e4129ec38eaedd820e17"
@ -53,7 +53,7 @@ prepare() {
# meson subprojects
ln -sv "$srcdir/imgui-1.89.9" subprojects
ln -sv "$srcdir/spdlog-1.13.0" subprojects
ln -sv "$srcdir/spdlog-1.14.1" subprojects
mkdir subprojects/nlohmann_json-3.10.5
ln -sv "$srcdir/include" subprojects/nlohmann_json-3.10.5/
ln -sv "$srcdir/single_include" subprojects/nlohmann_json-3.10.5/

@ -25,6 +25,7 @@ static std::vector<std::string> blacklist {
"EpicGamesLauncher.exe",
"IGOProxy.exe",
"IGOProxy64.exe",
"monado-service",
"Origin.exe",
"OriginThinSetupInternal.exe",
"steam",
@ -54,6 +55,9 @@ static std::vector<std::string> blacklist {
"iexplore.exe",
"rundll32.exe",
"Launcher", //Paradox Interactive Launcher
"steamwebhelper.exe",
"EpicWebHelper.exe",
"UplayWebCore.exe"
};

@ -469,7 +469,8 @@ static bool find_input(const std::string& path, const char* input_prefix, std::s
if (uscore != std::string::npos) {
file.erase(uscore, std::string::npos);
input = path + "/" + file + "_input";
return true;
//9 characters should not overflow the 32-bit int
return std::stoi(read_line(input).substr(0, 9)) > 0;
}
}
return false;

@ -56,6 +56,7 @@ enum {
};
struct CPUPowerData {
virtual ~CPUPowerData() = default;
int source;
};

@ -6,6 +6,7 @@
namespace fs = ghc::filesystem;
using namespace std;
std::mutex device_lock;
std::vector<device_batt> device_data;
std::vector<std::string> list;
bool device_found = false;
@ -18,6 +19,7 @@ int ds5_count = 0;
int switch_count = 0;
int bitdo_count = 0;
int logi_count = 0; //Logitech devices, mice & keyboards etc.
int shield_count = 0;
std::string xbox_paths [2]{"gip","xpadneo"};
@ -28,6 +30,7 @@ static bool operator<(const device_batt& a, const device_batt& b)
void device_update(const struct overlay_params& params){
std::unique_lock<std::mutex> l(device_lock);
fs::path path("/sys/class/power_supply");
list.clear();
xbox_count = 0;
@ -35,6 +38,7 @@ void device_update(const struct overlay_params& params){
ds5_count = 0;
switch_count = 0;
bitdo_count = 0;
shield_count = 0;
for (auto &p : fs::directory_iterator(path)) {
string fileName = p.path().filename();
//Gamepads
@ -71,7 +75,14 @@ void device_update(const struct overlay_params& params){
device_found = true;
bitdo_count += 1;
}
}
//CHECK NVIDIA SHIELD DEVICES
if (fileName.find("thunderstrike") != std::string::npos) {
list.push_back(p.path());
device_found = true;
shield_count += 1;
}
}
// Mice and Keyboards
//CHECK LOGITECH DEVICES
if (std::find(params.device_battery.begin(), params.device_battery.end(), "mouse") != params.device_battery.end()) {
@ -86,6 +97,7 @@ void device_update(const struct overlay_params& params){
void device_info () {
std::unique_lock<std::mutex> l(device_lock);
device_count = 0;
device_data.clear();
//gamepad counters
@ -94,6 +106,7 @@ void device_info () {
int ds5_counter = 0;
int switch_counter = 0;
int bitdo_counter = 0;
int shield_counter = 0;
for (auto &path : list ) {
//Set devices paths
@ -152,14 +165,25 @@ void device_info () {
device_data[device_count].name = "8BITDO PAD-" + to_string(bitdo_counter + 1);
bitdo_counter++;
}
//Shield devices
if (path.find("thunderstrike") != std::string::npos) {
if (shield_count == 1)
device_data[device_count].name = "SHIELD PAD";
else
device_data[device_count].name = "SHIELD PAD-" + to_string(shield_counter + 1);
shield_counter++;
}
}
// MICE AND KEYBOARDS
//Logitech Devices
if (check_mouse == true) {
if (path.find("hidpp_battery") != std::string::npos) {
if (std::getline(device_name, line)) {
device_data[device_count].name = line;
}
// Find a good way truncate name or retreive device type before using this
// if (std::getline(device_name, line)) {
// device_data[device_count].name = line;
// }
device_data[device_count].name = "LOGI MOUSE/KB";
}
}

@ -14,6 +14,7 @@ struct device_batt {
};
extern std::vector<device_batt> device_data;
extern std::mutex device_lock;
extern bool device_found;
extern int device_count;

@ -20,7 +20,7 @@ static void* get_egl_proc_address(const char* name) {
void *func = nullptr;
static void *(*pfn_eglGetProcAddress)(const char*) = nullptr;
if (!pfn_eglGetProcAddress) {
void *handle = real_dlopen("libEGL.so.1", RTLD_LAZY|RTLD_LOCAL);
void *handle = real_dlopen("libEGL.so.1", RTLD_LAZY);
if (!handle) {
SPDLOG_ERROR("Failed to open " MANGOHUD_ARCH " libEGL.so.1: {}", dlerror());
} else {
@ -35,7 +35,7 @@ static void* get_egl_proc_address(const char* name) {
func = get_proc_address( name );
if (!func) {
SPDLOG_DEBUG("Failed to get function '{}'", name);
SPDLOG_ERROR("Failed to get function '{}'", name);
}
return func;

@ -107,12 +107,7 @@ EXPORT_C_(void) glXDestroyContext(void *dpy, void *ctx)
EXPORT_C_(int) glXMakeCurrent(void* dpy, void* drawable, void* ctx) {
glx.Load();
SPDLOG_DEBUG("{}: {}, {}", __func__, drawable, ctx);
int ret;
// This is hack, proper fix should be implemented.
// MakeCurrent fails on the minecraft-launcher so we
// just bypass it and minecraft hooking works as it should
if (get_program_name() != "minecraft-launcher")
ret = glx.MakeCurrent(dpy, drawable, ctx);
int ret = glx.MakeCurrent(dpy, drawable, ctx);
if (!is_blacklisted()) {
if (ret) {

@ -15,6 +15,7 @@ EXPORT_C_(void*) dlsym(void * handle, const char * name)
find_egl_ptr = reinterpret_cast<decltype(find_egl_ptr)> (real_dlsym(RTLD_NEXT, "mangohud_find_egl_ptr"));
void* func = nullptr;
bool is_angle = real_dlsym(handle, "eglStreamPostD3DTextureANGLE");
void* real_func = real_dlsym(handle, name);
if (find_glx_ptr && real_func) {
@ -25,7 +26,7 @@ EXPORT_C_(void*) dlsym(void * handle, const char * name)
}
}
if (find_egl_ptr && real_func) {
if (find_egl_ptr && real_func && !is_angle) {
func = find_egl_ptr(name);
if (func) {
//fprintf(stderr,"%s: local: %s\n", __func__ , name);

@ -942,7 +942,6 @@ void HudElements::_exec(){
ImguiNextColumnFirstItem();
for (auto& item : HUDElements.exec_list){
if (item.pos == HUDElements.place){
ImguiNextColumnFirstItem();
right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%s", item.ret.c_str());
}
}
@ -1086,25 +1085,24 @@ void HudElements::gamescope_frame_timing(){
static double min_time = 0.0f;
static double max_time = 50.0f;
if (HUDElements.gamescope_debug_app.size() > 0 && HUDElements.gamescope_debug_app.back() > -1){
ImguiNextColumnFirstItem();
ImGui::Dummy(ImVec2(0.0f, real_font_size.y));
ImGui::PushFont(HUDElements.sw_stats->font1);
HUDElements.TextColored(HUDElements.colors.engine, "%s", "App");
ImGui::TableNextRow();
ImGui::Dummy(ImVec2(0.0f, real_font_size.y));
auto min = std::min_element(HUDElements.gamescope_debug_app.begin(),
HUDElements.gamescope_debug_app.end());
auto max = std::max_element(HUDElements.gamescope_debug_app.begin(),
HUDElements.gamescope_debug_app.end());
ImGui::PushFont(HUDElements.sw_stats->font1);
ImGui::Dummy(ImVec2(0.0f, real_font_size.y));
HUDElements.TextColored(HUDElements.colors.engine, "%s", "App");
ImGui::TableSetColumnIndex(ImGui::TableGetColumnCount() - 1);
right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width * 1.3, "min: %.1fms, max: %.1fms", min[0], max[0]);
ImGui::PopFont();
ImGui::Dummy(ImVec2(0.0f, real_font_size.y / 2));
ImguiNextColumnFirstItem();
ImGui::PopFont();
char hash[40];
snprintf(hash, sizeof(hash), "##%s", overlay_param_names[OVERLAY_PARAM_ENABLED_frame_timing]);
HUDElements.sw_stats->stat_selector = OVERLAY_PLOTS_frame_timing;
HUDElements.sw_stats->time_dividor = 1000000.0f; /* ns -> ms */
ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.0f, 0.0f, 0.0f, 0.0f));
if (ImGui::BeginChild("gamescope_app_window", ImVec2(ImGui::GetWindowContentRegionWidth(), 50))) {
ImGui::PlotLines("", HUDElements.gamescope_debug_app.data(),
@ -1146,6 +1144,7 @@ void HudElements::gamescope_frame_timing(){
void HudElements::device_battery()
{
#ifdef __linux__
std::unique_lock<std::mutex> l(device_lock);
if (!HUDElements.params->device_battery.empty()) {
if (device_found) {
for (int i = 0; i < device_count; i++) {
@ -1413,10 +1412,12 @@ void HudElements::hdr() {
void HudElements::refresh_rate() {
if (HUDElements.refresh > 0) {
ImGui::PushFont(HUDElements.sw_stats->font1);
ImguiNextColumnFirstItem();
HUDElements.TextColored(HUDElements.colors.engine, "%s", "Display Hz");
ImguiNextColumnOrNewRow();
right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%i", HUDElements.refresh);
ImGui::PopFont();
}
}
@ -1425,10 +1426,12 @@ void HudElements::winesync() {
HUDElements.winesync_ptr = std::make_unique<WineSync>();
if (HUDElements.winesync_ptr->valid()) {
ImGui::PushFont(HUDElements.sw_stats->font1);
ImguiNextColumnFirstItem();
HUDElements.TextColored(HUDElements.colors.engine, "%s", "WSYNC");
ImguiNextColumnOrNewRow();
right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%s", HUDElements.winesync_ptr->get_method().c_str());
ImGui::PopFont();
}
}
@ -1452,28 +1455,21 @@ void HudElements::network() {
if (!HUDElements.net)
HUDElements.net = std::make_unique<Net>();
ImguiNextColumnFirstItem();
HUDElements.TextColored(HUDElements.colors.network, "%s", "NET");
ImGui::TableNextColumn();
right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%s", "TX");
ImGui::TableNextColumn();
right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%s", "RX");
for (auto& iface : HUDElements.net->interfaces){
ImGui::TableNextRow();
ImGui::TableNextColumn();
HUDElements.TextColored(HUDElements.colors.network, "%s", iface.name.c_str());
HUDElements.TextColored(HUDElements.colors.network, "%.8s", iface.name.c_str());
ImGui::TableNextColumn();
right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%.0f", iface.txBps / 1000.f);
ImGui::SameLine(0,1.0f);
ImGui::PushFont(HUDElements.sw_stats->font1);
HUDElements.TextColored(HUDElements.colors.text, "KB/s");
HUDElements.TextColored(HUDElements.colors.text, "KB/s %s", ICON_FK_ARROW_UP);
ImGui::PopFont();
ImGui::TableNextColumn();
right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%.0f", iface.rxBps / 1000.f);
ImGui::SameLine(0,1.0f);
ImGui::PushFont(HUDElements.sw_stats->font1);
HUDElements.TextColored(HUDElements.colors.text, "KB/s");
HUDElements.TextColored(HUDElements.colors.text, "KB/s %s", ICON_FK_ARROW_DOWN);
ImGui::PopFont();
}
#endif
@ -1589,6 +1585,8 @@ void HudElements::legacy_elements(){
ordered_functions.push_back({vram, "vram", value});
if (params->enabled[OVERLAY_PARAM_ENABLED_ram])
ordered_functions.push_back({ram, "ram", value});
if (!params->network.empty())
ordered_functions.push_back({network, "network", value});
if (params->enabled[OVERLAY_PARAM_ENABLED_battery])
ordered_functions.push_back({battery, "battery", value});
if (params->enabled[OVERLAY_PARAM_ENABLED_fan])
@ -1597,8 +1595,6 @@ void HudElements::legacy_elements(){
ordered_functions.push_back({gamescope_fsr, "gamescope_fsr", value});
if (params->enabled[OVERLAY_PARAM_ENABLED_hdr])
ordered_functions.push_back({hdr, "hdr", value});
if (params->enabled[OVERLAY_PARAM_ENABLED_refresh_rate])
ordered_functions.push_back({refresh_rate, "refresh_rate", value});
if (params->enabled[OVERLAY_PARAM_ENABLED_throttling_status])
ordered_functions.push_back({throttling_status, "throttling_status", value});
if (params->enabled[OVERLAY_PARAM_ENABLED_fps])
@ -1652,13 +1648,12 @@ void HudElements::legacy_elements(){
ordered_functions.push_back({winesync, "winesync", value});
if (params->enabled[OVERLAY_PARAM_ENABLED_present_mode])
ordered_functions.push_back({present_mode, "present_mode", value});
if (!params->network.empty())
ordered_functions.push_back({network, "network", value});
if (params->enabled[OVERLAY_PARAM_ENABLED_refresh_rate])
ordered_functions.push_back({refresh_rate, "refresh_rate", value});
}
void HudElements::update_exec(){
#ifdef __LINUX__
#ifdef __linux__
if (!HUDElements.shell)
HUDElements.shell = std::make_unique<Shell>();

@ -54,7 +54,7 @@ class HudElements{
int refresh = 0;
std::unique_ptr<WineSync> winesync_ptr = nullptr;
std::unique_ptr<Net> net = nullptr;
#ifdef __LINUX__
#ifdef __linux__
std::unique_ptr<Shell> shell = nullptr;
#endif

@ -62,8 +62,6 @@ void Intel::intel_gpu_thread(){
if (exitcode == 1)
SPDLOG_INFO("Missing permissions for '{}'", "intel_gpu_top");
SPDLOG_INFO("Disabling gpu_stats");
HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_gpu_stats] = false;
}
}
@ -101,7 +99,6 @@ FILE* Intel::find_fd() {
if (found_driver){
if(strstr(line, "drm-engine-render")){
sscanf(line, "drm-engine-render: %" SCNu64 " ns", &val);
if (val > 0)
return file;
}
}

@ -32,7 +32,7 @@ class Intel {
runtime = true;
fdinfo = find_fd();
thread = std::thread(&Intel::intel_gpu_thread, this);
// thread = std::thread(&Intel::intel_gpu_thread, this);
}
void update() {
@ -42,10 +42,10 @@ class Intel {
gpu_info = gpu_info_intel;
}
~Intel(){
stop = true;
thread.join();
}
// ~Intel(){
// stop = true;
// thread.join();
// }
};
extern std::unique_ptr<Intel> intel;

@ -1,6 +1,7 @@
#include <sstream>
#include <iomanip>
#include <array>
#include <algorithm>
#include <spdlog/spdlog.h>
#include "logging.h"
#include "overlay.h"
@ -71,12 +72,24 @@ static void writeSummary(string filename){
SPDLOG_DEBUG("Writing summary log file [{}]", filename);
std::ofstream out(filename, ios::out | ios::app);
if (out){
out << "0.1% Min FPS," << "1% Min FPS," << "97% Percentile FPS," << "Average FPS," << "GPU Load," << "CPU Load" << "\n";
out << "0.1% Min FPS," << "1% Min FPS," << "97% Percentile FPS," << "Average FPS," << "GPU Load," << "CPU Load," << "Average Frame Time," << "Average GPU Temp," << "Average CPU Temp," << "Average VRAM Used," << "Average RAM Used," << "Average Swap Used," << "Peak GPU Load," << "Peak CPU Load," << "Peak GPU Temp," << "Peak CPU Temp," << "Peak VRAM Used," << "Peak RAM Used," << "Peak Swap Used" << "\n";
std::vector<logData> sorted = logArray;
std::sort(sorted.begin(), sorted.end(), compareByFps);
float total = 0.0f;
float total_cpu = 0.0f;
float total_gpu = 0.0f;
float total_cpu = 0.0f;
int total_gpu_temp = 0.0f;
int total_cpu_temp = 0.0f;
float total_vram = 0.0f;
float total_ram = 0.0f;
float total_swap = 0.0f;
int peak_gpu = 0.0f;
float peak_cpu = 0.0f;
int peak_gpu_temp = 0.0f;
int peak_cpu_temp = 0.0f;
float peak_vram = 0.0f;
float peak_ram = 0.0f;
float peak_swap = 0.0f;
float result;
float percents[2] = {0.001, 0.01};
for (auto percent : percents){
@ -91,21 +104,66 @@ static void writeSummary(string filename){
// 97th percentile
result = sorted.empty() ? 0.0f : 1000 / sorted[floor(0.97 * (sorted.size() - 1))].frametime;
out << fixed << setprecision(1) << result << ",";
// avg
// avg + peak
total = 0;
for (auto input : sorted){
total = total + input.frametime;
total_cpu = total_cpu + input.cpu_load;
total_gpu = total_gpu + input.gpu_load;
total_cpu = total_cpu + input.cpu_load;
total_gpu_temp = total_gpu_temp + input.gpu_temp;
total_cpu_temp = total_cpu_temp + input.cpu_temp;
total_vram = total_vram + input.gpu_vram_used;
total_ram = total_ram + input.ram_used;
total_swap = total_swap + input.swap_used;
peak_gpu = std::max(peak_gpu, input.gpu_load);
peak_cpu = std::max(peak_cpu, input.cpu_load);
peak_gpu_temp = std::max(peak_gpu_temp, input.gpu_temp);
peak_cpu_temp = std::max(peak_cpu_temp, input.cpu_temp);
peak_vram = std::max(peak_vram, input.gpu_vram_used);
peak_ram = std::max(peak_ram, input.ram_used);
peak_swap = std::max(peak_swap, input.swap_used);
}
// Average FPS
result = 1000 / (total / sorted.size());
out << fixed << setprecision(1) << result << ",";
// GPU
// GPU Load (Average)
result = total_gpu / sorted.size();
out << result << ",";
// CPU
// CPU Load (Average)
result = total_cpu / sorted.size();
out << result;
out << result << ",";
// Average Frame Time
result = total / sorted.size();
out << result << ",";
// Average GPU Temp
result = total_gpu_temp / sorted.size();
out << result << ",";
// Average CPU Temp
result = total_cpu_temp / sorted.size();
out << result << ",";
// Average VRAM Used
result = total_vram / sorted.size();
out << result << ",";
// Average RAM Used
result = total_ram / sorted.size();
out << result << ",";
// Average Swap Used
result = total_swap / sorted.size();
out << result << ",";
// Peak GPU Load
out << peak_gpu << ",";
// Peak CPU Load
out << peak_cpu << ",";
// Peak GPU Temp
out << peak_gpu_temp << ",";
// Peak CPU Temp
out << peak_cpu_temp << ",";
// Peak VRAM Used
out << peak_vram << ",";
// Peak RAM Used
out << peak_ram << ",";
// Peak Swap Used
out << peak_swap;
} else {
SPDLOG_ERROR("Failed to write log file");
}
@ -306,6 +364,9 @@ void Logger::calculate_benchmark_data(){
string label;
float mins[2] = {0.01f, 0.001f};
for (auto percent : mins){
if (sorted.empty())
continue;
size_t percentile_pos = sorted.size() * percent;
percentile_pos = std::min(percentile_pos, sorted.size() - 1);
float result = 1000 / sorted[percentile_pos];

@ -145,12 +145,12 @@ if is_unixy
'loaders/loader_x11.cpp',
'shared_x11.cpp',
)
endif
opengl_files += files(
'loaders/loader_glx.cpp',
'gl/inject_glx.cpp',
)
endif
if get_option('with_wayland').enabled()
pre_args += '-DHAVE_WAYLAND'
@ -278,6 +278,9 @@ if is_unixy
endif
if get_option('mangoapp')
if not get_option('with_x11').enabled()
error('mangoapp also needs \'with_x11\'')
endif
pre_args += '-DIMGUI_IMPL_OPENGL_LOADER_GLEW'
pre_args += '-DMANGOAPP'
mangoapp = executable(

@ -5,6 +5,7 @@
#include "overlay.h"
#include "overlay_params.h"
#include "nvctrl.h"
#include "logging.h"
nvmlReturn_t result;
nvmlDevice_t nvidiaDevice;
@ -52,16 +53,22 @@ bool getNVMLInfo(const struct overlay_params& params){
nvmlReturn_t response;
auto& nvml = get_libnvml_loader();
response = nvml.nvmlDeviceGetUtilizationRates(nvidiaDevice, &nvidiaUtilization);
nvml.nvmlDeviceGetTemperature(nvidiaDevice, NVML_TEMPERATURE_GPU, &nvidiaTemp);
nvml.nvmlDeviceGetMemoryInfo(nvidiaDevice, &nvidiaMemory);
nvml.nvmlDeviceGetClockInfo(nvidiaDevice, NVML_CLOCK_GRAPHICS, &nvidiaCoreClock);
nvml.nvmlDeviceGetClockInfo(nvidiaDevice, NVML_CLOCK_MEM, &nvidiaMemClock);
nvml.nvmlDeviceGetPowerUsage(nvidiaDevice, &nvidiaPowerUsage);
if (params.enabled[OVERLAY_PARAM_ENABLED_gpu_temp] || logger->is_active())
nvml.nvmlDeviceGetTemperature(nvidiaDevice, NVML_TEMPERATURE_GPU, &nvidiaTemp);
if (params.enabled[OVERLAY_PARAM_ENABLED_vram] || logger->is_active())
nvml.nvmlDeviceGetMemoryInfo(nvidiaDevice, &nvidiaMemory);
if (params.enabled[OVERLAY_PARAM_ENABLED_gpu_core_clock] || logger->is_active())
nvml.nvmlDeviceGetClockInfo(nvidiaDevice, NVML_CLOCK_GRAPHICS, &nvidiaCoreClock);
if (params.enabled[OVERLAY_PARAM_ENABLED_gpu_mem_clock] || logger->is_active())
nvml.nvmlDeviceGetClockInfo(nvidiaDevice, NVML_CLOCK_MEM, &nvidiaMemClock);
if (params.enabled[OVERLAY_PARAM_ENABLED_gpu_power] || logger->is_active())
nvml.nvmlDeviceGetPowerUsage(nvidiaDevice, &nvidiaPowerUsage);
deviceID = nvidiaPciInfo.pciDeviceId >> 16;
if (params.enabled[OVERLAY_PARAM_ENABLED_throttling_status])
nvml.nvmlDeviceGetCurrentClocksThrottleReasons(nvidiaDevice, &nvml_throttle_reasons);
nvml.nvmlDeviceGetFanSpeed(nvidiaDevice, &nvidiaFanSpeed);
if (params.enabled[OVERLAY_PARAM_ENABLED_gpu_fan] || logger->is_active())
nvml.nvmlDeviceGetFanSpeed(nvidiaDevice, &nvidiaFanSpeed);
if (response == NVML_ERROR_NOT_SUPPORTED) {
if (nvmlSuccess)

@ -666,6 +666,10 @@ void horizontal_separator(struct overlay_params& params) {
void render_imgui(swapchain_stats& data, struct overlay_params& params, ImVec2& window_size, bool is_vulkan)
{
{
std::unique_lock<std::mutex> lock(config_mtx);
config_cv.wait(lock, []{ return config_ready; });
}
// data.engine = EngineTypes::GAMESCOPE;
HUDElements.sw_stats = &data; HUDElements.params = &params;
HUDElements.is_vulkan = is_vulkan;

@ -41,6 +41,9 @@
#include "fps_metrics.h"
std::unique_ptr<fpsMetrics> fpsmetrics;
std::mutex config_mtx;
std::condition_variable config_cv;
bool config_ready = false;
#if __cplusplus >= 201703L
@ -108,8 +111,8 @@ parse_control(const char *str)
int ret = os_socket_listen_abstract(path.c_str(), 1);
if (ret < 0) {
SPDLOG_ERROR("Couldn't create socket pipe at '{}'", path);
SPDLOG_ERROR("ERROR: '{}'", strerror(errno));
SPDLOG_DEBUG("Couldn't create socket pipe at '{}'", path);
SPDLOG_DEBUG("ERROR: '{}'", strerror(errno));
return ret;
}
@ -620,6 +623,7 @@ set_parameters_from_options(struct overlay_params *params)
params->enabled[OVERLAY_PARAM_ENABLED_duration] = false;
params->enabled[OVERLAY_PARAM_ENABLED_core_bars] = false;
params->enabled[OVERLAY_PARAM_ENABLED_read_cfg] = read_cfg;
params->enabled[OVERLAY_PARAM_ENABLED_time_no_label] = false;
params->options.erase("full");
}
for (auto& it : params->options) {
@ -661,11 +665,11 @@ parse_overlay_env(struct overlay_params *params,
add_to_options(params, key, value);
initialize_preset(params);
}
presets(current_preset, params);
break;
}
}
presets(current_preset, params);
env = env_start;
while ((num = parse_string(env, key, value)) != 0) {
@ -754,7 +758,7 @@ static void set_param_defaults(struct overlay_params *params){
params->background_color = 0x020202;
params->text_color = 0xffffff;
params->media_player_color = 0xffffff;
params->network_color = 0xd66077;
params->network_color = 0xe07b85;
params->media_player_name = "";
params->font_scale = 1.0f;
params->wine_color = 0xeb5b5b;
@ -790,6 +794,9 @@ parse_overlay_config(struct overlay_params *params,
.preset = use_existing_preset ? params->preset : default_preset
};
set_param_defaults(params);
if (!use_existing_preset) {
current_preset = params->preset[0];
}
#ifdef HAVE_X11
params->toggle_hud = { XK_Shift_R, XK_F12 };
@ -853,10 +860,10 @@ parse_overlay_config(struct overlay_params *params,
set_parameters_from_options(params);
}
// TODO decide what to do for legacy_layout=0
// second pass, override config file settings with MANGOHUD_CONFIG
if (params->enabled[OVERLAY_PARAM_ENABLED_legacy_layout] && env && read_cfg) {
// If passing legacy_layout=0 to MANGOHUD_CONFIG anyway then clear first pass' results
if (params->enabled[OVERLAY_PARAM_ENABLED_legacy_layout])
HUDElements.ordered_functions.clear();
if (env && read_cfg) {
HUDElements.ordered_functions.clear();
parse_overlay_env(params, env, true);
}
@ -972,6 +979,7 @@ parse_overlay_config(struct overlay_params *params,
if (params->enabled[OVERLAY_PARAM_ENABLED_legacy_layout]) {
HUDElements.legacy_elements();
} else {
HUDElements.ordered_functions.clear();
for (auto& option : HUDElements.options) {
HUDElements.sort_elements(option);
}
@ -1001,6 +1009,12 @@ parse_overlay_config(struct overlay_params *params,
#endif
if (HUDElements.net)
HUDElements.net->should_reset = true;
{
std::lock_guard<std::mutex> lock(config_mtx);
config_ready = true;
config_cv.notify_one();
}
}
bool parse_preset_config(int preset, struct overlay_params *params){
@ -1015,7 +1029,7 @@ bool parse_preset_config(int preset, struct overlay_params *params){
stream.imbue(std::locale::classic());
if (!stream.good()) {
SPDLOG_ERROR("Failed to read presets file: '{}'", preset_path);
SPDLOG_DEBUG("Failed to read presets file: '{}'. Falling back to default presets", preset_path);
return false;
}
@ -1133,6 +1147,11 @@ void presets(int preset, struct overlay_params *params, bool inherit) {
add_to_options(params, "debug", "1");
add_to_options(params, "version", "0");
add_to_options(params, "frame_timing_detailed", "1");
add_to_options(params, "network", "1");
add_to_options(params, "present_mode", "0");
if ( deviceID == 0x1435 || deviceID == 0x163f )
add_to_options(params, "gpu_fan", "0");
break;
}

@ -6,6 +6,8 @@
#include <vector>
#include <unordered_map>
#include <cstdint>
#include <condition_variable>
#include <mutex>
#ifdef __cplusplus
extern "C" {
@ -330,9 +332,11 @@ void parse_overlay_config(struct overlay_params *params,
void presets(int preset, struct overlay_params *params, bool inherit=false);
bool parse_preset_config(int preset, struct overlay_params *params);
void add_to_options(struct overlay_params *params, std::string option, std::string value);
#ifdef __cplusplus
}
#endif
extern std::mutex config_mtx;
extern std::condition_variable config_cv;
extern bool config_ready;
#endif /* MANGOHUD_OVERLAY_PARAMS_H */

@ -35,8 +35,11 @@ bool init_x11() {
}
failed = !display;
if (failed)
if (failed && displayid)
SPDLOG_ERROR("XOpenDisplay failed to open display '{}'", displayid);
if (!displayid)
SPDLOG_DEBUG("DISPLAY env is not set");
return !!display;
}

@ -2,43 +2,49 @@
#include <thread>
#include <iostream>
#include <sys/wait.h>
#include <spdlog/spdlog.h>
#include "string_utils.h"
#include <array>
std::string Shell::readOutput() {
std::string output;
char buffer[256];
ssize_t bytesRead;
bool dataAvailable = false;
std::this_thread::sleep_for(std::chrono::milliseconds(50));
// Wait for up to 500 milliseconds for output to become available
for (int i = 0; i < 10; ++i) {
bytesRead = read(from_shell[0], buffer, sizeof(buffer) - 1);
if (bytesRead > 0) {
buffer[bytesRead] = '\0';
output += buffer;
dataAvailable = true;
break; // Break as soon as we get some data
} else {
std::this_thread::sleep_for(std::chrono::milliseconds(50));
}
std::array<char, 128> buffer;
std::string result;
ssize_t count;
while ((count = ::read(from_shell[0], buffer.data(), buffer.size())) > 0) {
result.append(buffer.data(), count);
}
// If we detected data, keep reading until no more is available
while (dataAvailable) {
bytesRead = read(from_shell[0], buffer, sizeof(buffer) - 1);
if (bytesRead > 0) {
buffer[bytesRead] = '\0';
output += buffer;
} else {
break; // No more data available
}
// Split the result into lines and return the last line
std::istringstream stream(result);
std::string line;
std::string last_line;
while (std::getline(stream, line)) {
last_line = line;
}
return output;
SPDLOG_DEBUG("Shell: recieved output: {}", last_line);
return last_line;
}
Shell::Shell() {
pipe(to_shell);
pipe(from_shell);
static bool failed;
if (pipe(to_shell) == -1) {
SPDLOG_ERROR("Failed to create to_shell pipe: {}", strerror(errno));
failed = true;
}
if (pipe(from_shell) == -1) {
SPDLOG_ERROR("Failed to create from_shell pipe: {}", strerror(errno));
failed = true;
}
// if either pipe fails, there's no point in continuing.
if (failed){
SPDLOG_ERROR("Shell has failed, will not be able to use exec");
return;
}
shell_pid = fork();
@ -58,15 +64,30 @@ Shell::Shell() {
// Set the read end of the from_shell pipe to non-blocking
setNonBlocking(from_shell[0]);
}
success = true;
}
std::string Shell::exec(std::string cmd) {
if (!success)
return "";
writeCommand(cmd);
return readOutput();
}
void Shell::writeCommand(std::string command) {
std::string command_without_preload = "LD_PRELOAD= " + command;
if (write(to_shell[1], command_without_preload.c_str(), command_without_preload.length()) == -1)
SPDLOG_ERROR("Failed to write to shell");
trim(command);
SPDLOG_DEBUG("Shell: wrote command: {}", command);
}
Shell::~Shell() {
write(to_shell[1], "exit\n", 5);
if (write(to_shell[1], "exit\n", 5) == -1)
SPDLOG_ERROR("Failed exit shell");
close(to_shell[1]);
close(from_shell[0]);
waitpid(shell_pid, nullptr, 0);

@ -13,6 +13,7 @@ private:
int to_shell[2];
int from_shell[2];
pid_t shell_pid;
bool success;
#ifdef __linux__
void setNonBlocking(int fd) {
@ -21,10 +22,7 @@ private:
}
#endif
void writeCommand(const std::string& command) {
write(to_shell[1], command.c_str(), command.length());
}
void writeCommand(std::string command);
std::string readOutput();
public:

@ -1,13 +1,13 @@
[wrap-file]
directory = spdlog-1.13.0
source_url = https://github.com/gabime/spdlog/archive/refs/tags/v1.13.0.tar.gz
source_filename = spdlog-1.13.0.tar.gz
source_hash = 534f2ee1a4dcbeb22249856edfb2be76a1cf4f708a20b0ac2ed090ee24cfdbc9
patch_filename = spdlog_1.13.0-1_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/spdlog_1.13.0-1/get_patch
patch_hash = 556b539cf582a46673ede4202ac037b891328dd5ea76862ffe05b060fc4f4775
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/spdlog_1.13.0-1/spdlog-1.13.0.tar.gz
wrapdb_version = 1.13.0-1
directory = spdlog-1.14.1
source_url = https://github.com/gabime/spdlog/archive/refs/tags/v1.14.1.tar.gz
source_filename = spdlog-1.14.1.tar.gz
source_hash = 1586508029a7d0670dfcb2d97575dcdc242d3868a259742b69f100801ab4e16b
patch_filename = spdlog_1.14.1-1_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/spdlog_1.14.1-1/get_patch
patch_hash = ae878e732330ea1048f90d7e117c40c0cd2a6fb8ae5492c7955818ce3aaade6c
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/spdlog_1.14.1-1/spdlog-1.14.1.tar.gz
wrapdb_version = 1.14.1-1
[provide]
spdlog = spdlog_dep

Loading…
Cancel
Save