SDL2 & GDB: software received signal ?, Unknown signal

Let's start by describing what happens:

I play with the SDL2 library on Windows. I can compile programs using it, and when I run .exe it works fine. Problems arise when I try to debug it using GDB - when the code enters the SDL_Init or SDL_OpenAudio functions (which can create new streams), GDB stops, the message "programmed signal", unknown signal "is displayed, and when I resume execution, the program crashes .

There seems to be a bug in GDB ( https://www.mail-archive.com/ cygwin@cygwin.com /msg149735.html ) related to thread naming, and it should be fixed in version 7.11 of GDB. 1-1.

At first I used GCC 5.1.0 (TDM) with GDB 7.6.1, so I decided to upgrade to a new version. It seems that TDM has not provided any updates since two years ago, so I installed MinGW-w64 (I don’t remember now, but it could be version 7.11 of GDB). It did not help, GDB will work.

Next, I searched for a new version of GDB and found 7.12 (www dot equation dot com / servlet / equation.cmd? Fa = gdb). It does not work, perhaps the fix did not reach this version.

Apparently, this error should only be present in the GDR version on x86, so I installed the x64 version of TDM (GCC 5.1.0 and GDB 7.9.1). The program compiled fine, but GDB still catches an unknown signal and program crashes.

Now I can not debug any program using SDL2. So the question is, what can I do to make it work again?


Possible solutions:

  • Visual Studio - Eclipse ( , , ), IDE, .
  • GDB - , , Windows , GDB 7.12 .
  • Linux - , Visual Studio.
  • SDL 1.2 - ...
  • -... , GDB. .
  • ?
  • ?

:

#include <SDL2/SDL.h>

// Normally I'd use #undef main
int WinMain(int, char**)
    {
    SDL_Init(SDL_INIT_EVERYTHING);

    return 0;
    }

: g++ gdbtest.cpp -lSDL2main -lSDL2

SDL2: 2.0.5 ( Windows, MinGW, 32- )


: a.exe

:

GDB:

: GDB ,

+6
2

, , . , GDB (, , ) . , . SDL2 SDL_SYS_SetupThread, SDL2-2.0.5/src/thread/windows/SDL_systhread.c: 168:

RaiseException(0x406D1388, 0, sizeof(inf) / sizeof(ULONG), (const ULONG_PTR*) &inf);

- (, ). - :

SDL_SetHint(SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING, "1");

- - SDL_SYS_SetupThread SDL_GetHintBoolean, , , SDL_HINT_WINDOWS _... false.

, , , - , .

+3

, ( ). , :

  • #include <SDL2/SDL.h>: #include "SDL.h" include -I, include SDL. , , sdl2-config , , -I - .
  • // Normally I'd use #undef main: , . , . SDL2 " " , .
  • g++ gdbtest.cpp -lSDL2main -lSDL2: Windows , : -lmingw32 -lSDL2main -lSDL2 -mwindows.
  • return 0: , SDL_Quit() .

, , SDL_Init, gdb ( , , ), , , SDL_INIT_EVERYTHING,

SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_HAPTIC | SDL_INIT_HAPTIC | SDL_INIT_EVENTS

:

SDL_INIT_TIMER | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER

gdb a.exe .

, , , GDB , , , . https://bugzilla.libsdl.org/, simillar , .

+3

Source: https://habr.com/ru/post/1017087/


All Articles