Hi,
 
I already turned off the optimization, and there is no return in my main.
 
my code looks like this:
 
int main(void) {


   int a = 1;
   int i = 1;

   vTask1(a);
   vTask2(i);

}

 
void vTask1 (int x){
   int i;
   for(i = 0; i<10;i++)
      x++;
}
 

void vTask2 (int x){
  int i;
  while(1)
  {
  for(i = 0; i<10;i++)
    x++;
  }
}
 
 
I reduced it a lot to find the error, but it always jumps to the same address. 
So as you can see I dont return from main...
 


Date: Mon, 20 Dec 2010 15:45:28 +0100
From: [email protected]
To: [email protected]
Subject: Re: [Openocd-development] Help needed for SAM3S4C


Am 12/20/2010 02:32 PM, schrieb Kenan Özdemir: 

Hi,
 
somehow my code is not working. Recently I tried to figure out, why there are 
these unexpected jumps in my programcode. After a look at the Disassembly, I 
found something strange..
 
My first lines in main are these:
 
int a = 1;
int i  = 1;
 
and the Disassembly says for these two lines:
 

int a = 1;
0x00400106 <main()+6>: ldrb.w r4, [r1], #1
0x0040010a <main()+10>: subs r0, r0, r4
int i = 1;
0x0040010c <main()+12>: beq.n 0x4000fa <frame_dummy+22>
0x0040010e <main()+14>: pop {r4}0x00400110 <main()+16>: bx lr
 
why do I have this jump in int i = 1 ?? 
Probably because the compiler optimized the i=1 away completely, as the value 
is never used. Optimization may also lead to small differences in the mapping 
between source code line number and assembler code.

If you want line-accurate debugging, it may be necessary to turn off compiler 
opzimization (-O0) completely.

BTW: "bx lr" looks like the code is returning from main() - which it should 
never do in an embedded environment. 

cu
Michael


_______________________________________________ Openocd-development mailing 
list [email protected] 
https://lists.berlios.de/mailman/listinfo/openocd-development                   
                    
_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to