Home > Back-end >  debug WINE 32bit C/C app in vscode using gdbserver
debug WINE 32bit C/C app in vscode using gdbserver

Time:06-09

Problem

Trying to debug win hello world app cross compiled using i686-w64-mingw32-g -posix in VSCode. But VSCode fails to attach to dbgserver.

Repo

VSCode project repo is located HERE.

Setup

Cross compile win app on nix

Compiler is configured to use i686-w64-mingw32-gcc-posix and i686-w64-mingw32-g -posix for C and CXX code respectively.

Building cmake project generates ./build/hello.exe which can be run using command wine ./build/hello.exe.

Attach gdb to gdbserver

As per suggestion running gdbserver using command wine Z:/usr/share/win32/gdbserver.exe localhost:3456 /workspace/build/hello.exe and attaching debugger using command /usr/bin/i686-w64-mingw32-gdb --eval-command='target remote 127.0.0.1:3456' /workspace/build/hello.exe. For convenience sh script /usr/bin/gdbserver was added launching wine Z:/usr/share/win32/gdbserver.exe $@.

works fine. Debugger loads symbols, prints following output:

...
Type "apropos word" to search for commands related to "word"...
Reading symbols from /workspace/build/hello.exe...done.
Remote debugging using 127.0.0.1:3456
Reading C:/windows/system32/ntdll.dll from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Reading C:/windows/system32/kernel32.dll from remote target...
Reading C:/windows/system32/kernelbase.dll from remote target...
Reading C:/windows/system32/msvcrt.dll from remote target...
0x7bc51a41 in DbgBreakPoint@0 () from target:C:/windows/system32/ntdll.dll
(gdb) 

At this point everything looks fine.

Configure VSCode

To set up VSCode debugger launch.json file was added with custom paths and parameters to run gdb and gdbserver as indicated HERE.

Debugging using VSCode

Launching debug configurations initiates a process but doesn't seem to progress to an expected debugging scenario. As soon as debug server launch timeout is reached Unable to start debugging. No process is associated with this object. message pops up and debugging stops.

It is worth noting that before timeout is reached running /usr/bin/i686-w64-mingw32-gdb --eval-command='target remote 127.0.0.1:3456' /workspace/build/hello.exe attaches debugger to gdbserver process initiated by VSCode.

CodePudding user response:

Some gdbserver configs were missing

After changes dbgserver running wine app works fine. Boiler plate project for 32 bit wine app acn be found HERE.

  • Related