This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: (update)Would you please help me about arm-elf-gdb. (fwd)
- To: Keith Seitz <keiths at cygnus dot com>
- Subject: Re: (update)Would you please help me about arm-elf-gdb. (fwd)
- From: "Pierre Saucourt-Harmel (r54698)" <pierre dot saucourt-harmel at motorola dot com>
- Date: Fri, 20 Apr 2001 18:29:15 +0200
- CC: gdb at sources dot redhat dot com, song dot qiang-hua at inventec-inc dot com
- Organization: Motorola
- References: <Pine.SOL.3.91.1010420074232.2271A-100000@ryobi.cygnus.com>
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.