[Info-vax] Fortran Debug Step odd behavior on continuation lines

abrsvc dansabrservices at yahoo.com
Sat Aug 29 12:34:08 EDT 2020


On Saturday, 29 August 2020 11:23:19 UTC-4, Dave Froble  wrote:
> On 8/29/2020 11:07 AM, Tom Wade wrote:
> > Hi,
> >
> > I've noticed the following odd behavior when single stepping through a
> > Fortran program with continuation lines.  I've always worked around it,
> > as it never caused me any real problems, but I finally had the time to
> > put it down, so that someone might explain what I've been doing wrong
> > all these years.
> >
> > Consider the following trivial program, compiled /debug/noopt and
> > launched with screen mode debugging.
> >
> > ─ SRC: module TEST
> > -scroll-source───────────────────────────────────────────────
> > ->   1:         Program Test
> >      2:
> >      3:         Implicit        None
> >      4:         Integer         i, j
> >      5:
> >      6:         i = 0
> >      7:         j = 0
> >      8:         i = i +
> >      9:      &      j +
> >     10:      &      5
> >     11:         Call Exit
> >     12:         End
> >
> > If you STEP (or hit KP0), the Debugger steps through the program line by
> > line.  First step goes to line 6, second to line 7 etc until it gets to
> > 8.  At 8, I would expect the Debugger to step to 11, as 9 & 10 are
> > continuation lines, effectively part of the same statement.  Instead it
> > steps to 9. The really strange thing is the next step jumps back to 8.
> > The one after that goes to 9, the next one back to 8 again, and the next
> > one goes to 11 (skipping 9 & 10).  The value of i only changes when it
> > arrives at 11.
> >
> > Not a real problem, but I guess finally my curiosity got the better of
> > me.  Anyone else seen or can understand this ?
> >
> > OpenVMS Alpha 8.4
> > HP Fortran V8.2-104679
> > HP Fortran 77 V7.6-198 (/old_f77)
> > (but it's been around for as long as I remember, and that's quite  a
> > while!).
> >
> > Tom Wade
> > tom dot wade at tomwade got eu
> >
> 
> At the risk of John getting a good laugh ...
> 
> The way I learned it so many years ago is that when a compiler comes 
> upon a complex operation, it parses it and pushes each step onto a 
> stack, then pops each off the stack when processing.
> 
> So, your line 10 was last onto the stack, so the first popped off, then 
> line 9, and finally it completes the operation.
> 
> -- 
> David Froble                       Tel: 724-529-0450
> Dave Froble Enterprises, Inc.      E-Mail: davef at tsoft-inc.com
> DFE Ultralights, Inc.
> 170 Grimplin Road
> Vanderbilt, PA  15486

I would compile the source again and request the machine code listing.  Look carefully at the code generated as even with no-opt, there will be some folding of instructions "out of order" with the code lines.  For example, loading registers with the values for the operation.  That may trigger what appears to be random lines when stepping through the code.  The debugger will try to tie the actual instruction to the source code line.  Here with continuation lines, there are 3 "source" lines associated with the "real" source line which would be all of the continuation lines concatenated together.

I recall seeing this even more when stepping by instruction.  The code would appear to bounce all over the place (as expected with Alpha instruction streams).

Dan



More information about the Info-vax mailing list