[vox-tech] gdb: until doesn't work as advertised?

Peter Jay Salzman vox-tech@lists.lugod.org
Thu, 19 Sep 2002 17:02:35 -0700


begin msimons@moria.simons-clan.com <msimons@moria.simons-clan.com> 
> On Thu, Sep 19, 2002 at 04:33:44PM -0700, Peter Jay Salzman wrote:
> > until
> > -----
> > Continue running until a source line past the current line, in the
> > current stack frame, is reached. This command is used to avoid single
> > stepping through a loop more than once. It is like the next command,
> > except that when until encounters a jump, it automatically continues
> > execution until the program counter is greater than the address of the
> > jump. This means that when you reach the end of a loop after single
> > stepping though it, until makes your program continue execution until it
> > exits the loop.
> 
>   Being that I know what until does, I think the text above is very 
> clearly written and I doubt this mail will improve on it.  

i agree the above is clearly written.  the real problem, i guess, is
that i should've given you a sample of what i'm talking about.  :)  so
here it is:




p@satan% gdb until_demo
gdb: Symbol `emacs_ctlx_keymap' has different size in shared object,
consider re-linking
(gdb) l
1       #include <stdio.h>
2
3       int main(void)
4       {
5               int i=0, j=0;
6               scanf("%d", &i);
7
8               while (i) {
9                       i--;
10                      j++;
(gdb) break 9
Breakpoint 1 at 0x8048420: file until_demo.c, line 9.
(gdb) commands
Type commands for when breakpoint 1 is hit, one per line.
End with a line saying just "end".
>print i
>end
(gdb) r
Starting program: /home/p/writing/ddd/src/until_demo 
10

Breakpoint 1, main () at until_demo.c:9
9                       i--;
$1 = 10
(gdb) until
10                      j++;
(gdb) 
11              }
(gdb) 

Breakpoint 1, main () at until_demo.c:9
9                       i--;
$2 = 9
(gdb) 
10                      j++;
(gdb) 
11              }
(gdb) 

Breakpoint 1, main () at until_demo.c:9
9                       i--;
$3 = 8
(gdb) 
10                      j++;
(gdb) 
11              }
(gdb) 

Breakpoint 1, main () at until_demo.c:9
9                       i--;
$4 = 7
(gdb) 
10                      j++;
(gdb) 
11              }
(gdb) 

Breakpoint 1, main () at until_demo.c:9
9                       i--;
$5 = 6
(gdb) 
10                      j++;
(gdb) 


so you see, until doesn't seem to step out of this loop.   from looking
at this, it looks like until is behaving exactly like next.

agreed?



>   "until" steps to the next line of code (preventing the debugger from 
> going back to a previous line in the same function because
> of a jump), you don't give until a line number, it's more like "run
> until the next line of code happens".

just like next and step, until _can_ take a numerical argument.
see below.

> > then use until, then gdb will go through the loop 5 times, just like how
> > next would.   i let the user input what "i" is so that gcc wouldn't
> > unroll the loop.  but until STILL isn't working as advertised.
> 
>   Please send a sample use of gdb where "until" goes through the loop 
> more than once.
 
done.  :)


> > also, "until 12" doesn't leave the while loop either, however, "until
> > 12" does.
> 
>   I'm lost, the sentence above does not make sense.  
 
"until 12" resumes execution until line 12 is reached of the current
stack frame _or_ just after the current stack frame goes out of scope.

pete

-- 
Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D