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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Extract the return value in finish_command on Xtensa.


Daniel Jacobowitz wrote:
On Wed, Jul 14, 2004 at 03:38:34PM -0400, Andrew Cagney wrote:

I am working on a port of GDB to the Xtensa architecture.

Unfortunately, it is impossible on Xtensa to extract the return value once the 'callee' has returned to the 'caller' without analyzing the call instruction (if there was one). Depending on the call instruction, the return value can be in register a6, a10, oder a14.

Puzzled expression. The ABI should specify which return-value convention will be used?


I suspect you'll need to explain a little more about your architecture.

What Daniel said is basically correct. Xtensa uses register windows much like Sparc but with the difference that is doesn't always shift 8 registers but a variable number of registers (4, 8, or 12). That number is encoded in the call instruction (call4, call8, or call12).
The shift walue is also encoded in the return address, so the return instruction knows how many registers it has to shift backwards.


The 'callee' always returns the return value in a2. For the caller the return value thus is in either a6 (call4), a10 (call8), or a14 (call12).

The calling function obviously knows what call instruction it used to extract the return value. The easiest way for GDB to find the return register would be to look at the return address of the 'callee', but once that function has returned, the information is lost. Because this problem only arises for the finish command, GDB could save the return address (from the 'callee' frame) before it resumes the target and then use that value to extract the return value.

Thanks,
Chris


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