This is a reduced example of the structure of my code:
void increment(int j);
int main()
{
int i = 0;
while(1) {
i = increment(i);
}
return 0;
Have you actually tried to compile this? Your increment() function is declared void, but needs to be int. After changing that, it worked fine for me:
% gdb test
GNU gdb (Ubuntu/Linaro 7.3-0ubuntu2) 7.3-2011.08
[...]
Reading symbols from test...done.
(gdb) b increment
Breakpoint 1 at 0x4004bb: file test.c, line 5.
(gdb) r
Starting program: test
Breakpoint 1, increment (j=0) at test.c:5
5 return j+1;
(gdb) fin
Run till exit from #0 increment (j=0) at test.c:5
0x00000000004004dc in main () at test.c:11
11 i = increment(i);
Value returned is $1 = 1
(gdb) n
12 }
(gdb) p i
$2 = 1
(gdb)