Re: gdb "hangs" on delay loop
Gene Smith <[email protected]> Tue, 05 May 2009 11:39:00 -0400
| Newsgroups | gmane.comp.gdb.general |
|---|---|
| Message-ID | <[email protected]> |
Charles Manning wrote: > On Saturday 02 May 2009 07:03:10 Gene Smith wrote: >> 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? > > The stepping in ARM, and perhaps other CPUs, is prone to getting stuck like > this. > > To get out of this either: > * restructure code > * set break at the next line and continue. > * -if you're brave - try improve gdb :-). > It seems to be "stepping" 10000 times in the background to get over this instruction so it will take a while. I think I verified this by setting c to 9995 and it took just a short time to step to the next source line. I think another "improvement" would be to eliminate erratic stepping when optimization is applied (if that is possible).