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

vox-tech@lists.lugod.org vox-tech@lists.lugod.org
Thu, 19 Sep 2002 19:45:53 -0400


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.  
  "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".  Whereas "next" is more like
"stop me at the next executable statement".


  perhaps two samples will help, here I'm using until to run through
the loop quickly...
====
Breakpoint 1, main () at bar.c:5
5	   int i=0, j=0;
(gdb) u
6	   scanf("%d", &i);
(gdb) 
5
8	   while (i) {
(gdb) 
9	      --i;
(gdb) 
10	      ++j;
(gdb) 
11	   }
(gdb) 
13	   return 0;
(gdb) p j
$3 = 5
(gdb) p i
$4 = 0
===

Now here is what happens when you use "next":
===
Breakpoint 1, main () at bar.c:5
5	   int i=0, j=0;
(gdb) n
6	   scanf("%d", &i);
(gdb) 
5
8	   while (i) {
(gdb) 
9	      --i;
(gdb) 
10	      ++j;
(gdb) 
11	   }
(gdb) 
8	   while (i) {
(gdb) 
9	      --i;
(gdb) 
10	      ++j;
(gdb) 
11	   }
(gdb) 
8	   while (i) {
(gdb) 
9	      --i;
(gdb) 
10	      ++j;
(gdb) 
11	   }
(gdb) 
8	   while (i) {
(gdb) 
9	      --i;
(gdb) 
10	      ++j;
(gdb) 
11	   }
(gdb) 
8	   while (i) {
(gdb) 
9	      --i;
(gdb) 
10	      ++j;
(gdb) 
11	   }
(gdb) 
8	   while (i) {
(gdb) 
13	   return 0;
(gdb) 
===

> 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.

> also, "until 12" doesn't leave the while loop either, however, "until
> 12" does.

  I'm lost, the sentence above does not make sense.  

    TTFN,
      Mike