l i n u x - u s e r s - g r o u p - o f - d a v i s
Next Meeting:
July 7: Social gathering
Next Installfest:
Latest News:
Jun. 14: June LUGOD meeting cancelled
Page last updated:
2002 Sep 20 12:29

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] gdb: until doesn't work as advertised?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

On Thu, Sep 19, 2002 at 05:02:35PM -0700, Peter Jay Salzman wrote:
> begin msimons@moria.simons-clan.com <msimons@moria.simons-clan.com> 
> 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:

  This sample is good.  The only difference I saw between this and the
other emails are explict commands on each line (instead of just using
return to repeat the previous command).

> p@satan% gdb until_demo
> (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.
> 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.

  You set a breakpoint inside the loop.  The description for "until" 
doesn't say that it will disable all breakpoints until a higher code
address is reached.  It will run the program until a higher line or (for
good reason), another break condition is hit... (breakpoint, watchpoint,
signal, whatever).

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

  You might noticed if you try the above with "next" that you also 
see the "while (i)" line each time the loop happens... a loop looks more 
like (with the stared lines being different from "until"):
** 8	   while (i) {
** (gdb) 

Breakpoint 1, main () at bar.c:9
9	      i--;
10	      j++;
11	   }

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

  Okay tested, I agree, until with a number argument does run until that
line number is reached or the function being run returns.

  So another suggestion about the breakpoint with commands, test this out:
break 9
printf "%d\n", i

  ... or for even more meyham.
break 10
  printf "i = %d, j = %d\n", i, j
  if (j < 40 && i == 1)
    set variable i=i+1
vox-tech mailing list

LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
O'Reilly and Associates
For numerous book donations.