Thread overview
gdb + Windows 64: No debugging symbols found
Dec 26, 2020
Mike Parker
Dec 26, 2020
Basile B.
December 26, 2020
We have:

    // app.d
    import std.stdio;

    void main()
    {
        writeln( "OK" );
    }

Build:
    dmd -m64 -g app.d

OS:
    Windows 10, x86_64
    MSYS2: gdb

Goal:
    gdb app.exe


Problem is:
    $ gdb ./app.exe
    GNU gdb (GDB) 9.2
    ...
    (No debugging symbols found in ./app.exe)

What is a right way to build .exe and debug with gdb ?

December 26, 2020
On Saturday, 26 December 2020 at 11:55:58 UTC, Виталий Фадеев wrote:

>
> Problem is:
>     $ gdb ./app.exe
>     GNU gdb (GDB) 9.2
>     ...
>     (No debugging symbols found in ./app.exe)
>
> What is a right way to build .exe and debug with gdb ?

The version of gdb that ships with MSYS is probably going to expect debug info in a different format than what dmd puts out on Windows (I assume it expects DWARF2).

When using -m32(always the default on Windows when invoking dmd directly), it outputs debug info in an old version of the CodeView format (which you'll probably need an older version of WinDbg to work with). Otherwise (-m64, -m32mscoff), it creates a PDB file usable with the Visual Studio debugger and other debuggers that understand the PDB format (which is basically a wrapper for modern CodeView debug info). If there's a Windows version of gdb that supports CodeView/PDB, I'm unaware of it.

I know some people use Mago:
https://github.com/rainers/mago

Some docs on PDB & CodeView:
https://llvm.org/docs/PDB/index.html

DMD and debug info on Windows:
https://dlang.org/windbg.html


December 26, 2020
On Saturday, 26 December 2020 at 11:55:58 UTC, Виталий Фадеев wrote:
> We have:
> [...]
> Problem is:
>     $ gdb ./app.exe
>     GNU gdb (GDB) 9.2
>     ...
>     (No debugging symbols found in ./app.exe)
>
> What is a right way to build .exe and debug with gdb ?

Try to build with latest version of LDC and use the -gdwarf option.
This will generate debug info that GDB can understand.
December 27, 2020
On Saturday, 26 December 2020 at 14:10:46 UTC, Basile B. wrote:
> On Saturday, 26 December 2020 at 11:55:58 UTC, Виталий Фадеев wrote:
>> We have:
>> [...]
>> Problem is:
>>     $ gdb ./app.exe
>>     GNU gdb (GDB) 9.2
>>     ...
>>     (No debugging symbols found in ./app.exe)
>>
>> What is a right way to build .exe and debug with gdb ?
>
> Try to build with latest version of LDC and use the -gdwarf option.
> This will generate debug info that GDB can understand.

Mike Parker, Basile B., thanks!