How to break from loop in gdb command language?

Skip Montanaro <[email protected]>
Newsgroups gmane.comp.gdb.general
Message-ID <[email protected]>
Some time ago I implemented a routine in gdb's command language that mimics
the line number calculation performed by Python's virtual machine.  Not thinking,
I wrote it like so:

define lineno
    set $__co = f->f_code
    set $__lasti = f->f_lasti
    set $__sz = ((PyStringObject *)$__co->co_lnotab)->ob_size/2
    set $__p = (unsigned char *)((PyStringObject *)$__co->co_lnotab)->ob_sval
    set $__li = $__co->co_firstlineno
    set $__ad = 0
    while ($__sz-1 >= 0)
      set $__sz = $__sz - 1
      set $__ad = $__ad + *$__p
      set $__p = $__p + 1
      if ($__ad > $__lasti)
	break
      end
      set $__li = $__li + *$__p
      set $__p = $__p + 1
    end
    printf "%d", $__li
end

This is more-or-less a direct translation of what Python's C code does.

Unfortunately, the C code uses the break statement.  Not being at the
top of my game at the time I forgot that "break" means something
entirely different in GDB's command language than in C.  What's
the equivalent?  Set a flag and test?  What about an equivalent for C's
continue stmt?

Thanks,

Skip Montanaro
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.