Thread overview
Debug with GDB on Windows
May 26
user1234
May 18

I am trying to debug on windows.

A simple hello world app compiled with

"c:\D\ldc2-1.38.0-windows-x64\bin\ldc2.exe" -gdwarf -O0 app.d

has debug symbols.

But the same app compiled with

 dub  build  -b debug --compiler="c:\D\ldc2-1.38.0-windows-x64\bin\ldc2.exe"  --force --root ../..

and dub.json

{
	"name" : "testd1",
	"description" : "Hello World - A minimal DUB bundle.",
	"dependencies" : {
	},
	"dflags": ["-gdwarf", "-O0", "-d-debug"]
}

has NO debug symbols. gdb reports

Reading symbols from ./testd1.exe...
(No debugging symbols found in ./testd1.exe)

If add additional option -vv to dflags the it is visible that ldc2 receives the gdwarf option. Probably the dub does some thing wrong? Or I am wrong. :-(

May 18

The dub build with --verbose option generates the output

Generating using build
Configuring dependent testd1, deps:
Performing "debug" build using c:\D\ldc2-1.38.0-windows-x64\bin\ldc2.exe for x86_64.
testd1 ~master: building configuration "application"...
c:\D\ldc2-1.38.0-windows-x64\bin\ldc2.exe -gdwarf -O0 -c -ofapplication-debug-windows-x86_64-ldc_v1.38.0-6D670FD1992E8FC1
1A1557D635DBD69E\testd1.obj -d-debug -g -w --oq -od=application-debug-windows-x86_64-ldc_v1.38.0-6D670FD1992E8FC11A1557D6
35DBD69E\/obj -d-version=Have_testd1 -IC:\TestD1\src C:\TestD1\src\app.d -vcolumns
Linking...
c:\D\ldc2-1.38.0-windows-x64\bin\ldc2.exe -ofapplication-debug-windows-x86_64-ldc_v1.38.0-6D670FD1992E8FC11A1557D635DBD69
E\testd1.exe application-debug-windows-x86_64-ldc_v1.38.0-6D670FD1992E8FC11A1557D635DBD69E\testd1.obj -g

Still unclear what is wrong.

May 26

On Saturday, 18 May 2024 at 22:57:23 UTC, Aleksey Gorelov wrote:

>

I am trying to debug on windows.

A simple hello world app compiled with

"c:\D\ldc2-1.38.0-windows-x64\bin\ldc2.exe" -gdwarf -O0 app.d

has debug symbols.

But the same app compiled with

 dub  build  -b debug --compiler="c:\D\ldc2-1.38.0-windows-x64\bin\ldc2.exe"  --force --root ../..

and dub.json

{
	"name" : "testd1",
	"description" : "Hello World - A minimal DUB bundle.",
	"dependencies" : {
	},
	"dflags": ["-gdwarf", "-O0", "-d-debug"]
}

has NO debug symbols. gdb reports

Reading symbols from ./testd1.exe...
(No debugging symbols found in ./testd1.exe)

If add additional option -vv to dflags the it is visible that ldc2 receives the gdwarf option. Probably the dub does some thing wrong? Or I am wrong. :-(

  • in the json, try dflags-ldc2 instead of dflags
  • try not to use the debug build but a custom one

I suspect that -g passed (automatically) after -gdwarf would have for effect to cancel the effect of the first, so maybe a ldc2 CLI bug.