gdb: SIGFPE within a loop
I have a SIGFPE happening within a loop. If I set a breakpoint or handle the SIGFPE with stop, nopass开发者_如何学运维, etc, i loose the frame variables after this line. In the case of a breakpoint, I need to first get there by executing n N
, where N
is a large number, so that the loop runs over the breakpoint within until such variable values occure that the SIGFPE is issued. After the execution by handling or breakpoint, I loose the frame variables, so I cannot reverse-search and further debug the program (variable out of context).
How do I handle a SIGFPE within a loop in a fast way?
Thanks!
New information: is it possible to stop a program with a logical watch point? I have gone into the responsible frame, and found that the variable in question attains a value of 350 (it should be way less than zero). Why doesn't
watch x0 > 100
stop the execution at this point?
You use watch
in wrong way.
http://www.ofb.net/gnu/gdb/gdb_30.html#SEC30
watch expr
Set a watchpoint for an expression. GDB will break when expr is written into by the program and its value changes.
So, you can't watch a x0>100
, but can watch a x0
, or array[59]
(argument of watch is address in memory)
For your task you can use conditional break. http://www.ofb.net/gnu/gdb/gdb_29.html#SEC29
break ... if cond
Set a breakpoint with condition cond; evaluate the expression cond each time the breakpoint is reached, and stop only if the value is nonzero--that is, if cond evaluates as true. `...' stands for one of the possible arguments described above (or no argument) specifying where to break. See section Break conditions, for more information on breakpoint conditions.
So
break main.c:345 if x0>100
精彩评论