Skip to content

Commit

Permalink
Find debug issue. Added signal linux
Browse files Browse the repository at this point in the history
  • Loading branch information
UnrealKaraulov committed Dec 12, 2023
1 parent 973514e commit 50d8576
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 25 deletions.
94 changes: 69 additions & 25 deletions src/editor/Gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
11 changes: 11 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ bool g_verbose = false;

#ifdef WIN32
#include <Windows.h>
#else
#include <csignal>
#endif

void hideConsoleWindow()
Expand Down Expand Up @@ -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[])
{
Expand All @@ -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')
Expand Down

0 comments on commit 50d8576

Please sign in to comment.