I have a small piece of Windows code, basically one copied from the MSDN tutorial but adapted for C++. I can compile it now using one of the methods:
i686-w64-mingw32-g++ -g hello.cpp -o helloto produce a native Windows PE32 executable,wineg++ -g hello.cpp -o helloto produce alibwinewrapper pairhello.exe+hello.exe.so.
All I want now is to start the file in a debugger (gdb or an interface to it if possible) and stop at the entry point WinMain. I'm failing badly at this. What I have tried (NB: in the following, hello without extension is, quite unconventially, the Windows executable):
wine /usr/i686-w64-mingw32/sys-root/mingw/bin/gdbserver.exe :2000 hellofollowed bytarget remote :2000in a localgdb: finds no symbols at all, everything is??across 10+ stack frameswine /usr/i686-w64-mingw32/sys-root/mingw/bin/gdb.exe hello: hangs, does not accept any user input on the command linegdb winefollowed byrun hello:Missing separate debuginfos, use: dnf debuginfo-install wine-core-1.9.19-1.fc24.i686, which I did and the error remainsgdb hello.exe.so: causes a SIGSEGVmodifying the
hello.exescript so that it sets the right environment but runsgdbin the end: no symbols whatsoever,??everywherewinedbg hellowith and without--gdb: gets the farthest so far, starts with a black console window and lets me step in, but whatever is in my code is still??-ed out andWinMain(or anything containing that string) is not knownwinedbg hello.exe(for the output ofwineg++): the program loads fully, the debugger hangs waiting for it while it already runs in the backgroundrunning the application and attaching to it in
winedbg: does not fit the purpose (won't allow me to stop at the entry point) but otherwise works mostly like the last two points (works with the output ofMinGWbut does not show any internals ofhello.exe, does not work at all with the output ofwineg++).reading tons of official and unofficial tutorials, bug reports, SO questions...
I can't even remember the other combinations I tried. Surely it can't be that hard?