I'm not sure about the difference between next and step in gdb.
According to the notes, next will skip over routine calls to the
following cals, but step will step into the routine call. However, in
the notes, unless I'm misunderstanding the examples, they both go into
the routine anyways. So what's the differecne?
Thanks in advance.
Basil.
next actually executes the entire routine, while step would move you to
the first executable line of the routine. So, if you had code like:
void foo() {
for ( int i = 0; i < v.size(); i++ ) {
...
}
}
int main() {
foo();
}
and were on the line in main() that invokes foo(), next would move you to
the next line (in this case, the closing brace of main()), while step would
put you on the for-loop in foo().
You could try it and see...
--
--
Caroline Kierstead, Undergraduate Operations Coordinator
David R. Cheriton School of Computer Science
University of Waterloo, DC3122 (519) 888-4567 x36226
Maybe I'm misunderstanding you, but it seems your example contradicts
the first thing you said.
At the top, you said next does the entire routine while step does the
first line, then at bottom you say
next would pass the routine call but step would go into it. Please
clarify. Thanks.
If you had a breakpoint on the call to foo() in main(), next would run
foo() to completion and put you at the subsequence statement, which is the
closing brace to main. step, on the other hand, would have put you on
the for-loop in foo(). Could have been worded more clearly, I guess.