Using GDB in Visual Studio

Dear followers,

One of the target platform for GPAC is Windows. Developing for Windows in a comfortable manner requires Visual Studio, in particular for debugging. Microsoft recently announced great changes that will make Visual Studio users (including the GPAC developers) happy:

Edit: update from Microsoft on 2015/11/18.

Setup for local debugging

Install software:

  • Install Visual Studio 2015. Install the “Tools for Visual C++ Mobile Development” in a sub-menu (disabled by default).
  • Install gdb/gdbserver. Use MinGW-w64 binaries and put them in your PATH (you can rely on the excellent MSYS2 for a full development environment).
    /!\ Legacy MinGW and Cygwin gdb binaries are known to fail /!\

Build:

  • Use your usual build system and gcc or clang compiler. Don’t forget to enable debugging!

Debugging:

  • In your command-line, launch:
    gdbserver host:port path/to/executable
  • In Visual Studio:
    • Open the “command window” (either press CTRL+ALT+A or click: View menu -> Other Windows -> Command Window)
    • Launch:
      Debug.GDBLaunch /Executable:path\to\executable /GDBPath:path\to\gdb.exe /GDBServerAddress:host:port /TargetArchitecture:x64

That’s all! Once Debug.GDBLaunch is attached your program will run. Breakpoints are effective. And you can enjoy the Visual Studio debugging experience:

20150610_msvs_gdb

Setup for remote debugging

This is an extension of the gdbserver we used above.  It allows to debug mobile (android/iOS) or any platform (linux, …) executables from a remote

For specific remote parameters, see: