[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gdb] How to break from loop in gdb command language?
From: |
Skip Montanaro |
Subject: |
[Gdb] How to break from loop in gdb command language? |
Date: |
Tue, 6 Sep 2005 03:06:15 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
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
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gdb] How to break from loop in gdb command language?,
Skip Montanaro <=