How to put a breakpoint to after last line of a loop in GDB?
My current approach as a global¹ and extandable² solution is declaring a NOOP and placing breakpoint at that line: 

5: #define NOOP ({;})
...
31:    spiExchange(&amp;SPID1, 2, txbuffer, rxbuffer);
32:    NOOP; // put a breakpoint at this point
33:  }
...



(gdb) break main.c:32


The NOOP macro will be removed by optimization, so optimization shouln't be used in order this approach to work. 


  ¹: "Global" means this approach is not tailored to be applied to a loop but can also be applied to after last line of an if or a switch statement. 
  
  ²: "Extandable" means you may add code after line 31 that might change rxbuffer contents. With this approach you don't have to relocate your breakpoint in such cases. 


Edit

If #define NOOP ({;}) does not work for you for some reason, you may change NOOP definition temporarily by whatever works for you, eg: 

//#define NOOP ({;})
#define NOOP chThdYield()
#define NOOP someSleepFunction(0)