[Issue 12163] New: pdb debugging (win64): stepping loops points to incorrect lines

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Feb 14 16:50:36 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12163

           Summary: pdb debugging (win64): stepping loops points to
                    incorrect lines
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: turkeyman at gmail.com


--- Comment #0 from Manu <turkeyman at gmail.com> 2014-02-14 16:50:31 PST ---
This is extremely annoying, and really hinders the DMD debugging experience.

Example program:

0   void main()
1   {
2     int[] things = [1,2,3,4];
3
4     foreach(i; things)
5     {
6       if(i == 2)
7         continue;
8
9       if(i != 3)
10      {
11        int x = 0;
12      }
13    }
14
15    int last = 0;
16  }

Compile this for Win64, in VisualD, place a breakpoint on line 2, and begin
debugging.
Single-step through the program and watch the cursor carefully as it moves; the
cursor movement is very confusing.

While stepping (using only F10), the program execution is as follows:
 2     int[] things = [1,2,3,4];
 4     foreach(i; things)
 6       if(i == 2)        ; false
 9       if(i != 3)        ; false
 11        int x = 0;      ; WRONG! within if(false), should be 13
 4     foreach(i; things)
 6       if(i == 2)        ; true
                           ; MISSING: should step to 7 (continue;)
 11        int x = 0;      ; WRONG! within if(false), should be 13
 4     foreach(i; things)
 6       if(i == 2)        ; false
 9       if(i != 3)        ; true
 11        int x = 0;
                           ; MISSING: should step to 13
 4     foreach(i; things)
 6       if(i == 2)        ; false
 9       if(i != 3)        ; false
 11        int x = 0;      ; WRONG! within if(false), should be 13
 4     foreach(i; things)
 15    int last = 0;


The flow should be:
 2     int[] things = [1,2,3,4];
 4     foreach(i; things)
 6       if(i == 2)
 9       if(i != 3)
 13    }
 4     foreach(i; things)
 6       if(i == 2)
 7         continue;
 13    }
 4     foreach(i; things)
 6       if(i == 2)
 9       if(i != 3)
 11        int x = 0;
 13    }
 4     foreach(i; things)
 6       if(i == 2)
 9       if(i != 3)
 13    }
 4     foreach(i; things)
 15    int last = 0;

It seems the debug info is writing the last meaningful line  of the loop
regardless of it's nested depth, instead of the line of the closing '}' at the
end of each loop iteration.
This is very confusing when stepping complex constructs with deep nested
content.
It is also important to be able to place a breakpoint on the closing '}' to
catch a final opportunity to inspect the values within the loop iteration
before the next iteration begins.

Currently, the 'continue' line seems to just be skipped. The execution should
move there before jumping to the closing '}' so you can place breakpoints
allowing to inspect the loop iteration values that caused the case.

Without proper cursor movement, it's impossible to place breakpoints to inspect
the state that leads to many situations; one of the most important tasks for a
debugger.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list