I am doing remote debugging with gdb and gdbserver on an ARM9 platform. Both these programs are compiled on an Ubuntu system with gdbserver compiled using a cross-compiler.
In general, the program under debug is able to stop at the set breakpoints. However, single-stepping using next or step works most of the time except at some locations of the code. In particular, the one that I find consistently giving me problems are switch blocks. For eg.
1 inchar = getchar();
2
3 switch (inchar)
4 {
5 case 'a':
6 ....
7 break;
8 case 'b':
9 ....
10 break;
11 case 'c':
12 ....
13 break;
14 }
If I set a breakpoint at line 1, the program stops at this line without issues. But if I subsequently used next or step, after hitting line 3, the next step will not cause the program to stop at either of the cases. Instead, it continues to run until the next breakpoint is hit or until I do a ctrl-c.
However, if I put a breakpoint at line 6 (for eg), without the breakpoint at line 1, the program can stop correctly at this line.
Has anyone encountered this? Where does the problem lie? How can I fix this behaviour?
Thanks.
-Oxwithx > 0)? - alk-Og? (details here: gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html) - alk