gdb "hangs" on delay loop

Gene Smith <[email protected]> Fri, 01 May 2009 15:03:10 -0400
Newsgroups gmane.comp.gdb.general
Message-ID <[email protected]>
With -O0 opt level, gdb refuses to step (S) over a delay loop like this:

code1; //<-- steps over this OK
for(c=0; c<10000; c++);   //<--- hangs here
code2;

If I control-c and examine c it seems to be increasing slowly.

When I change the code structure like this:

code1;
for(c=0; c<10000; )
	c++;
code2;

then I can step.

This is with embedded arm. See the same thing with arm-insight and 
arm-gdb. Haven't tried this with native.

Is this to be expected?