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 hello
to produce a native Windows PE32 executable,wineg++ -g hello.cpp -o hello
to produce alibwine
wrapper 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 hello
followed bytarget remote :2000
in 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 wine
followed 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.exe
script so that it sets the right environment but runsgdb
in the end: no symbols whatsoever,??
everywherewinedbg hello
with 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 ofMinGW
but 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?