title: Why doesn't gdb "u" command exit the loop?
body: <p>I've got a very simple main function, with a for loop inside it, like below:</p>
  
  <pre><code>#include&lt;stdio.h&gt; 
  int main() 
  { 
     for(int i=0;i&lt;30;++i) 
       printf("%d\n",i); 
     return 0; 
  } 
  </code></pre>
  
  <p>I tried to compile it like:</p>
  
  <pre><code>gcc 4.c -g 
  </code></pre>
  
  <p>Then I debug it with gdb:</p>
  
  <pre><code>$ gdb a.out 
  GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04)... 
  Reading symbols from a.out...done. 
  (gdb) list 
  1    #include&lt;stdio.h&gt; 
  2    int main() 
  3    { 
  4      for(int i=0;i&lt;30;++i) 
  5        printf("%d\n",i); 
  6      return 0; 
  7    } 
  (gdb) b 5 
  Breakpoint 1 at 0x400537: file 4.c, line 5. 
  (gdb) b 6 
  Breakpoint 2 at 0x400555: file 4.c, line 6. 
  (gdb) r 
  Starting program: /home/a/cpp/a.out  
  
  Breakpoint 1, main () at 4.c:5 
  5        printf("%d\n",i); 
  (gdb) p i 
  $1 = 0 
  (gdb) u 
  0 
  4      for(int i=0;i&lt;30;++i) 
  (gdb) u //not exiting for loop?
  
  Breakpoint 1, main () at 4.c:5 
  5        printf("%d\n",i); 
  (gdb)  
  1 
  4      for(int i=0;i&lt;30;++i) 
  (gdb) u 
  </code></pre>
  
  <p>Seems the "u" command doesn't help to execute the whole for loop and come to next break point, but something like a "n" command.</p>
  
  <p>Why? Any misunderstanding from my description?
  Thanks.</p>