www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - Debugging with GDB 8 on Windows

reply Siemargl <inqnone gmail.com> writes:
As i have read, as of LDC 1.23, dwarf debug info supported.

I try to use gdb, but not successfully - breakpoints cannot be 
set on function name, and not working completely.

I tested gdb 8.2 and 8.3 x64 (and lldb - mention in him topic).

I test gdb with FPC3.2 x64 example and it works fine, so its not 
a my machine or gdb problem.
-------- fpc session -------
(gdb) b main
Breakpoint 1 at 0x1000016a2: file _test.pas, line 6.
(gdb) r
Starting program: E:\_bin\FPC3.2\bin\i386-win32\_test.exe
[New Thread 109812.0x19af4]
[New Thread 109812.0x199b0]
[New Thread 109812.0x1b378]

Thread 1 hit Breakpoint 1, main () at _test.pas:6
6           x := 3.0;
(gdb)

------- ldc session ---------
ldc2 --version
LDC - the LLVM D compiler (1.24.0): based on DMD v2.094.1 and LLVM 11.0.0 built with LDC - the LLVM D compiler (1.24.0) Default target: x86_64-pc-windows-msvc Host CPU: ivybridge
ldc2 -gdwarf -m64 --d-debug --O0 dbg.d
lld-link: warning: section name .debug_abbrev is longer than 8 characters and will use a non-standard string table lld-link: warning: section name .debug_info is longer than 8 characters and will use a non-standard string table lld-link: warning: section name .debug_line is longer than 8 characters and will use a non-standard string table lld-link: warning: section name .debug_loc is longer than 8 characters and will use a non-standard string table lld-link: warning: section name .debug_pubnames is longer than 8 characters and will use a non-standard string table lld-link: warning: section name .debug_pubtypes is longer than 8 characters and will use a non-standard string table lld-link: warning: section name .debug_ranges is longer than 8 characters and will use a non-standard string table lld-link: warning: section name .debug_str is longer than 8 characters and will use a non-standard string table
gdb64.exe dbg.exe
GNU gdb (GDB) 8.3.1 Copyright (C) 2019 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-w64-mingw32". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from dbg.exe... (gdb) l 1 import std.stdio; 2 3 void testfun(int x) 4 { 5 x += 1; 6 } 7 8 int main() 9 { 10 auto y = 3; (gdb) 11 auto z = y + 1; 12 testfun(z); 13 14 writeln("done"); 15 return 0; 16 } 17 (gdb) b main Function "main" not defined. Make breakpoint pending on future shared library load? (y or [n]) n (gdb) b _Dmain Function "_Dmain" not defined. Make breakpoint pending on future shared library load? (y or [n]) n (gdb) b testfun Function "testfun" not defined. Make breakpoint pending on future shared library load? (y or [n]) (gdb) b dbg.d:8 Breakpoint 1 at 0x14000102a: file dbg.d, line 10. (gdb) r Starting program: E:\VSProjects\testjunk\ldc_win_debug\dbg.exe [New Thread 111576.0x1944c] [New Thread 111576.0x1a8dc] [New Thread 111576.0x1b040] Warning: Cannot insert breakpoint 1. Cannot access memory at address 0x14000102a Command aborted. (gdb)
Feb 17 2021
parent reply Johan Engelen <j j.nl> writes:
On Wednesday, 17 February 2021 at 20:22:09 UTC, Siemargl wrote:
 As i have read, as of LDC 1.23, dwarf debug info supported.

 I try to use gdb, but not successfully - breakpoints cannot be 
 set on function name, and not working completely.

 ...

ldc2 -gdwarf -m64 --d-debug --O0 dbg.d
Just to be sure, can you try with adding `-g` to that? -Johan
Feb 18 2021
parent reply Siemargl <inqnone gmail.com> writes:
On Thursday, 18 February 2021 at 11:16:24 UTC, Johan Engelen 
wrote:
 On Wednesday, 17 February 2021 at 20:22:09 UTC, Siemargl wrote:
 As i have read, as of LDC 1.23, dwarf debug info supported.

 I try to use gdb, but not successfully - breakpoints cannot be 
 set on function name, and not working completely.

 ...

ldc2 -gdwarf -m64 --d-debug --O0 dbg.d
Just to be sure, can you try with adding `-g` to that? -Johan
I tried -g -gdwarf -gc, but also read in pull request code, that -gdwarf implied -g. Also i tried build without mingw libs, renaming folder lib64/mingw, and with msvc toolset and with mingw toolset. But, even if msvc toolset installed (and mingw libs renamed) - -gdwarf always use lld-link
Feb 18 2021
parent kinke <noone nowhere.com> writes:
On Thursday, 18 February 2021 at 13:01:30 UTC, Siemargl wrote:
 But, even if msvc toolset installed (and mingw libs renamed) - 
 -gdwarf always use lld-link
It's enforced by LDC, simply because the MS linker errors out when seeing DWARF debuginfos.
Feb 19 2021