mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 14:45:59 +01:00
Fix not finding function symbols for hooking (#2292)
Fixes no useful feedback about failing subcommand. Fixes function hooks breaking when running under a path containing spaces. Replaced old usages with this function where possible. Complex shell usages now use `execAndGetShell` which is equal to the old function.
This commit is contained in:
parent
78826c6d18
commit
642030f959
3 changed files with 25 additions and 5 deletions
|
@ -2,8 +2,10 @@
|
||||||
lib,
|
lib,
|
||||||
stdenv,
|
stdenv,
|
||||||
pkg-config,
|
pkg-config,
|
||||||
|
makeWrapper,
|
||||||
meson,
|
meson,
|
||||||
ninja,
|
ninja,
|
||||||
|
binutils,
|
||||||
cairo,
|
cairo,
|
||||||
git,
|
git,
|
||||||
hyprland-protocols,
|
hyprland-protocols,
|
||||||
|
@ -29,6 +31,7 @@
|
||||||
legacyRenderer ? false,
|
legacyRenderer ? false,
|
||||||
nvidiaPatches ? false,
|
nvidiaPatches ? false,
|
||||||
withSystemd ? true,
|
withSystemd ? true,
|
||||||
|
wrapRuntimeDeps ? true,
|
||||||
version ? "git",
|
version ? "git",
|
||||||
commit,
|
commit,
|
||||||
}: let
|
}: let
|
||||||
|
@ -56,6 +59,7 @@ in
|
||||||
meson
|
meson
|
||||||
ninja
|
ninja
|
||||||
pkg-config
|
pkg-config
|
||||||
|
makeWrapper
|
||||||
];
|
];
|
||||||
|
|
||||||
outputs = [
|
outputs = [
|
||||||
|
@ -115,6 +119,10 @@ in
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
ln -s ${wlroots}/include/wlr $dev/include/hyprland/wlroots
|
ln -s ${wlroots}/include/wlr $dev/include/hyprland/wlroots
|
||||||
|
${lib.optionalString wrapRuntimeDeps ''
|
||||||
|
wrapProgram $out/bin/Hyprland \
|
||||||
|
--suffix PATH : ${lib.makeBinPath [ binutils pciutils ]}
|
||||||
|
''}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru.providedSessions = ["hyprland"];
|
passthru.providedSessions = ["hyprland"];
|
||||||
|
|
|
@ -25,6 +25,7 @@ in {
|
||||||
inherit (final) udis86 hyprland-protocols;
|
inherit (final) udis86 hyprland-protocols;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
hyprland-unwrapped = final.hyprland.override {wrapRuntimeDeps = false;};
|
||||||
hyprland-debug = final.hyprland.override {debug = true;};
|
hyprland-debug = final.hyprland.override {debug = true;};
|
||||||
hyprland-hidpi = final.hyprland.override {hidpiXWayland = true;};
|
hyprland-hidpi = final.hyprland.override {hidpiXWayland = true;};
|
||||||
hyprland-nvidia = final.hyprland.override {nvidiaPatches = true;};
|
hyprland-nvidia = final.hyprland.override {nvidiaPatches = true;};
|
||||||
|
|
|
@ -280,11 +280,11 @@ APICALL std::vector<SFunctionMatch> HyprlandAPI::findFunctionsByName(HANDLE hand
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
static const auto SYMBOLS = execAndGet(("llvm-nm -D -j " + FPATH.string()).c_str());
|
static const auto SYMBOLS = execAndGet(("llvm-nm -D -j \"" + FPATH.string() + "\"").c_str());
|
||||||
static const auto SYMBOLSDEMANGLED = execAndGet(("llvm-nm -D -j --demangle " + FPATH.string()).c_str());
|
static const auto SYMBOLSDEMANGLED = execAndGet(("llvm-nm -D -j --demangle \"" + FPATH.string() + "\"").c_str());
|
||||||
#else
|
#else
|
||||||
static const auto SYMBOLS = execAndGet(("nm -D -j " + FPATH.string()).c_str());
|
static const auto SYMBOLS = execAndGet(("nm -D -j \"" + FPATH.string() + "\"").c_str());
|
||||||
static const auto SYMBOLSDEMANGLED = execAndGet(("nm -D -j --demangle=auto " + FPATH.string()).c_str());
|
static const auto SYMBOLSDEMANGLED = execAndGet(("nm -D -j --demangle=auto \"" + FPATH.string() + "\"").c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto demangledFromID = [&](size_t id) -> std::string {
|
auto demangledFromID = [&](size_t id) -> std::string {
|
||||||
|
@ -301,6 +301,17 @@ APICALL std::vector<SFunctionMatch> HyprlandAPI::findFunctionsByName(HANDLE hand
|
||||||
return SYMBOLSDEMANGLED.substr(pos, SYMBOLSDEMANGLED.find('\n', pos + 1) - pos);
|
return SYMBOLSDEMANGLED.substr(pos, SYMBOLSDEMANGLED.find('\n', pos + 1) - pos);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (SYMBOLS.empty()) {
|
||||||
|
Debug::log(ERR, "Unable to search for function \"%s\": no symbols found in binary (is \"%s\" in path?)", name.c_str(),
|
||||||
|
#ifdef __clang__
|
||||||
|
"llvm-nm"
|
||||||
|
#else
|
||||||
|
"nm"
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<SFunctionMatch> matches;
|
std::vector<SFunctionMatch> matches;
|
||||||
|
|
||||||
std::istringstream inStream(SYMBOLS);
|
std::istringstream inStream(SYMBOLS);
|
||||||
|
@ -319,4 +330,4 @@ APICALL std::vector<SFunctionMatch> HyprlandAPI::findFunctionsByName(HANDLE hand
|
||||||
}
|
}
|
||||||
|
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue