This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: (update)Would you please help me about arm-elf-gdb. (fwd)


Hi Keith.

> ...
> It seems can run the timer interrupt function, and return correctly,
> but until now I have found two problems.
>
> 1. when in function "return -1;", it will not return -1, but return 0; sometimes.
>         if I disable timer interrupt, it will return -1 correctly.
>         I think when run "return -1;" and one timer interrupt occured, the register 0
>         will change to 0.

You need to save the "scratch" registers before calling the timer interrupt function, and restore them after it. These
"scratch" registers are named a1, a2, a3, a4 and ip (equivalent to r0, r1, r2, r3 and r12). These registers are not saved
but are used (very often with the -O2 optimisation, very rare with the -O0) by the code generated by the compiler. For
example, parameters and return values of leaf function are transmitted through the "scratch" registers

>
>
>         example:
>
>         int _get_tick( void )
>         {
>                 ...
>                 if(..)
>                 {
>                         return tick; //will not stop at here
>                 }
>                 return -1;                      //will return from here, but sometimes return 0;
>         }
>
>         //call position
>         int ti;
>
>         ti = _get_tick();
>         if( ti!=-1 )
>         {
>                 ...                                     //sometimes ti is not -1, and stop here
>         }
>         //end
>
>
> 2. In a function, it will return before function end and return sentence.
>         I set the break at all return point in the function, but it will not stop, but
>         returned, I'm not sure where does it return.
>         If I disable timer interrupt, it runs all right, If i run it next by next, it
>         runs all right.
>
>         example:
>
>         int _get_timer( void )
>         {
>                 ...
>                 if(..)
>                 {
>                         ...
>                         return 0;  //will not stop here but returned
>                 }
>                 else
>                 {
>                         ...
>                 }
>                 return x;               //will not stop here but returned I'm not sure where it returned
>         }
>         //end

Your "interrupt" simulation does not save the current lr before using it to backup the current pc. But the lr is the
return address of the current function that was interrupted. How can it does to return correctly ?

>

To resume, your model should save the a1, a2, a3, a4, ip and lr registers (equivalent to r0, r1, r2, r3, r12 and r14).

Good luck.
Pierre.




------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]