www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21770] New: Wrong breakpoint location for gdb


          Issue ID: 21770
           Summary: Wrong breakpoint location for gdb
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: hsteoh quickfur.ath.cx

import std;
void fun(void delegate() dg) {
void main() {
        int x = 123;
        string y = "abc";
                y ~= "d";

Compile with `dmd -g prog.d`. In gdb, set a breakpoint for prog.main:

(gdb) break prog.main
Breakpoint 1 at 0xe1c34: file prog.d, line 10.
(gdb) run
Starting program: /tmp/prog 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, prog.main().__lambda3() (__capture=0x7ffff7cad000) at prog.d:10
10                      x++;

This is wrong; the breakpoint for prog.main should break at the `writeln` line,
or one of the variable initializers. But instead, it breaks inside the delegate
body. A backtrace shows that `fun` has already been called.

Expected behaviour: breaking at a function should break at the beginning of the
function, not in the middle, and certainly not inside the body of a delegate!

Mar 25 2021