How to execute finish and then another command from inside commands?

前端 未结 5 1446
长情又很酷
长情又很酷 2020-12-16 15:01

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;         


        
5条回答
  •  心在旅途
    2020-12-16 15:48

    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)
    

提交回复
热议问题