some valgrind bullshit

This commit is contained in:
2026-02-25 13:23:01 +01:00
parent 82d618f692
commit 58235ac52e
7 changed files with 78 additions and 6 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ cmake-build-release
/platform
/result
/.gdb_history
/valgrind.log

View File

@ -20,12 +20,12 @@ if(USE_TRACY)
option(TRACY_ENABLE "" ON)
option(TRACY_ON_DEMAND "" ON)
# Enable tracy macros in the application
# Enable tracy macros in the application. Uses a LOT of memory.
add_compile_definitions(TRACY)
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wfloat-equal -Wundef -Wshadow -Wpointer-arith -Wcast-align -Wno-unused-parameter -Wunreachable-code")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og -ggdb -fsanitize=undefined") # -fsanitize=address already fails on InitWindow()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O3 -ggdb -fsanitize=undefined") # -fsanitize=address already fails on InitWindow()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -march=native")
message("-- CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")

View File

@ -1 +1 @@
./cmake-build-debug/compile_commands.json
./cmake-build-release/compile_commands.json

View File

@ -287,6 +287,7 @@ rec {
abbr -a release "${buildRelease} && ./cmake-build-release/masssprings"
abbr -a rungdb "${buildDebug} && gdb --tui ./cmake-build-debug/masssprings"
abbr -a runtracy "tracy -a 127.0.0.1 &; ${buildRelease} && sudo -E ./cmake-build-release/masssprings"
abbr -a runvalgrind "${buildDebug} && valgrind --leak-check=full --show-reachable=no --show-leak-kinds=definite,indirect,possible --track-origins=no --suppressions=valgrind.supp --log-file=valgrind.log ./cmake-build-debug/masssprings && cat valgrind.log"
'';
in
builtins.concatStringsSep "\n" [

View File

@ -13,9 +13,9 @@
#include <tracy/Tracy.hpp>
#endif
// TODO: Graph interaction
// - Click states to display them in the board
// TODO: Add a move history and backspace to go back
// TODO: Click states to display them in the board
// NOTE: Tracy uses a huge amount of memory. For longer testing disable Tracy.
auto main(int argc, char *argv[]) -> int {
std::string preset_file;

View File

@ -86,7 +86,9 @@ auto StateManager::NextPath() -> void {
}
auto StateManager::FillGraph() -> void {
#ifdef TRACY
ZoneScoped;
#endif
ClearGraph();
@ -178,7 +180,9 @@ auto StateManager::FindWinningStates() -> void {
}
auto StateManager::FindTargetDistances() -> void {
#ifdef TRACY
ZoneScoped;
#endif
if (springs.size() == 0 || winning_states.size() == 0) {
return;

66
valgrind.supp Normal file
View File

@ -0,0 +1,66 @@
{
glib_malloc
Memcheck:Leak
...
obj:*/libglib-2.0.so*
}
{
gtk_leaks
Memcheck:Leak
...
obj:*/libgtk-3.so*
}
{
mesa_leaks
Memcheck:Leak
...
obj:*/libGLX*
}
{
glfw_leaks
Memcheck:Leak
...
obj:*/libglfw.so*
}
{
wayland_leaks
Memcheck:Leak
...
obj:*/libwayland*.so*
}
{
dbus_leaks
Memcheck:Leak
...
obj:*/libdbus*.so*
}
{
egl_leaks
Memcheck:Leak
...
obj:*/libEGL*.so*
}
{
x11_leaks
Memcheck:Leak
...
obj:*/libX11*
}
{
fontconfig_leaks
Memcheck:Leak
...
obj:*/libfontconfig.so*
}
{
pango_leaks
Memcheck:Leak
...
obj:*/libpango*.so*
}
{
nvidia_leaks
Memcheck:Leak
...
obj:*/libnvidia*.so*
}