From 50d85766cc26ae2f5be066970d313422fd579961 Mon Sep 17 00:00:00 2001 From: Unreal Karaulov Date: Tue, 12 Dec 2023 11:05:45 +0300 Subject: [PATCH] Find debug issue. Added signal linux --- src/editor/Gui.cpp | 94 ++++++++++++++++++++++++++++++++++------------ src/main.cpp | 11 ++++++ 2 files changed, 80 insertions(+), 25 deletions(-) diff --git a/src/editor/Gui.cpp b/src/editor/Gui.cpp index cc77dbd1..e5e56d4a 100644 --- a/src/editor/Gui.cpp +++ b/src/editor/Gui.cpp @@ -3267,38 +3267,82 @@ void Gui::drawDebugWidget() ImGui::Text(fmt::format(fmt::runtime(get_localized_string(LANG_0369)), app->pickMode).c_str()); } - if (ImGui::CollapsingHeader("DEBUG INFO", ImGuiTreeNodeFlags_DefaultOpen)) + if (ImGui::CollapsingHeader("DEBUG INFO", ImGuiTreeNodeFlags_None)) { + static bool finderror = true; ImGui::Text(fmt::format("Mouse: {} {}", mousePos.x, mousePos.y).c_str()); - ImGui::Text(fmt::format("Mouse left {} right {}", app->curLeftMouse, app->curRightMouse).c_str()); - std::string keysStr; - for (int key = GLFW_KEY_SPACE; key <= GLFW_KEY_LAST; key++) { - if (app->pressed[key]) { - const char* keyName = glfwGetKeyName(key, 0); - if (keyName != nullptr) { - keysStr += fmt::format("{} ", keyName); + + if (app && imgui_io) + { + if (finderror) + { + print_log("DBG1\n"); + } + ImGui::Text(fmt::format("Mouse left {} right {}", app->curLeftMouse, app->curRightMouse).c_str()); + std::string keysStr; + for (int key = GLFW_KEY_SPACE; key <= GLFW_KEY_LAST; key++) { + if (app->pressed[key]) { + const char* keyName = glfwGetKeyName(key, 0); + if (keyName != nullptr) { + keysStr += fmt::format("{} ", keyName); + } } } - } - ImGui::Text("KEYS: %s", keysStr.c_str()); - ImGui::Text(fmt::format("Time: {}", app->curTime).c_str()); - ImGui::Text(fmt::format("canControl:{}\noldControl:{}\nNo WantTextInput:{}", app->canControl,app->oldControl, !imgui_io->WantTextInput).c_str()); - ImGui::Text(fmt::format("No WantCaptureMouseUnlessPopupClose:{}", !imgui_io->WantCaptureMouseUnlessPopupClose).c_str()); - ImGui::Text(fmt::format("No WantCaptureMouse:{}", !imgui_io->WantCaptureMouse).c_str()); - ImGui::Text(fmt::format("BlockMoving:{}", app->blockMoving).c_str()); - ImGui::Text(fmt::format("MoveDir: [{}]", app->getMoveDir().toString()).c_str()); + if (finderror) + { + print_log("DBG2\n"); + } + ImGui::Text("KEYS: %s", keysStr.c_str()); + if (finderror) + { + print_log("DBG3\n"); + } + ImGui::Text(fmt::format("Time: {}", (float)app->curTime).c_str()); + if (finderror) + { + print_log("DBG4\n"); + } + ImGui::Text(fmt::format("canControl:{}\noldControl:{}\nNo WantTextInput:{}", app->canControl, app->oldControl, !imgui_io->WantTextInput).c_str()); - static float movemulttime = app->curTime; - static float movemult = (float)(app->curTime - app->oldTime) * app->moveSpeed; + if (finderror) + { + print_log("DBG5\n"); + } + ImGui::Text(fmt::format("No WantCaptureMouseUnlessPopupClose:{}", !imgui_io->WantCaptureMouseUnlessPopupClose).c_str()); + ImGui::Text(fmt::format("No WantCaptureMouse:{}", !imgui_io->WantCaptureMouse).c_str()); + ImGui::Text(fmt::format("BlockMoving:{}", app->blockMoving).c_str()); + ImGui::Text(fmt::format("MoveDir: [{}]", app->getMoveDir().toString()).c_str()); - if (fabs(app->curTime - movemulttime) > 0.5f) - { - movemult = (float)(app->curTime - app->oldTime) * app->moveSpeed; - movemulttime = app->curTime; - } + if (finderror) + { + print_log("DBG6\n"); + } + static float movemulttime = app->curTime; + static float movemult = (float)(app->curTime - app->oldTime) * app->moveSpeed; + + if (finderror) + { + print_log("DBG7\n"); + } + if (fabs(app->curTime - movemulttime) > 0.5) + { + movemult = (float)(app->curTime - app->oldTime) * app->moveSpeed; + movemulttime = app->curTime; + } + if (finderror) + { + print_log("DBG8\n"); + } + ImGui::Text(fmt::format("MoveDir mult: [{}]", movemult).c_str()); + ImGui::Text(fmt::format("MoveSpeed: [{}]", app->moveSpeed).c_str()); - ImGui::Text(fmt::format("MoveDir mult: [{}]", movemult).c_str()); - ImGui::Text(fmt::format("MoveSpeed: [{}]", app->moveSpeed).c_str()); + if (finderror) + { + print_log("DBG9\n"); + } + + finderror = false; + } } if (ImGui::CollapsingHeader(get_localized_string(LANG_1100).c_str(), ImGuiTreeNodeFlags_DefaultOpen)) diff --git a/src/main.cpp b/src/main.cpp index 8876e3e1..ac8f90ee 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -102,6 +102,8 @@ bool g_verbose = false; #ifdef WIN32 #include +#else +#include #endif void hideConsoleWindow() @@ -868,6 +870,11 @@ LONG CALLBACK unhandled_handler(EXCEPTION_POINTERS* e) return EXCEPTION_CONTINUE_SEARCH; } #endif +#else +void signalHandler(int signal) { + print_log("Caught signal: {}", signal); + +} #endif int main(int argc, char* argv[]) { @@ -892,6 +899,10 @@ int main(int argc, char* argv[]) AddVectoredExceptionHandler(1, unhandled_handler); #endif DisableProcessWindowsGhosting(); +#else + signal(SIGSEGV, signalHandler); + signal(SIGFPE, signalHandler); + signal(SIGBUS, signalHandler); #endif if (argv && argv[0] && argv[0][0] != '\0')