libunwind-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Libunwind-devel] cursor.is_interrupted() or is_...


From: Andrew Cagney
Subject: [Libunwind-devel] cursor.is_interrupted() or is_...
Date: Tue, 08 Jan 2008 10:42:08 -0500
User-agent: Thunderbird 2.0.0.9 (X11/20071115)

[see appended quote for background]

Broadly unwind frames come in two types:

- interrupted
For an interrupted frame the PC indicates the instruction that was about to be executed (were it not for the interrupt). The inner most frame, and the frame unwound from a signal-frame or jmpbuf-frame are examples.

- caller
The PC indicates the address at which the function return will resume. As noted below, this address may not necessarily be in the correct block or even function. For this case, some adjustment of the "PC" may be required when searching for debug info (and even unwind info).

what thoughts are there on adding a cursor method such as is_interrupted() or is_caller() or ...? The implementation would likely involve the addition of an extra bit field to the cursor.

thoughts?

Andrew

----

From The DWARF spec, v3:

6.4.4 Call Frame Calling Address

When unwinding frames, consumers frequently wish to obtain the address of the instruction which called a subroutine. This information is not always provided. Typically, however, one of
the registers in the virtual unwind table is the Return Address.

If a Return Address register is defined in the virtual unwind table, and its rule is undefined (for example, by DW_CFA_undefined), then there is no return address and no call address, and the
virtual unwind of stack activations is complete.

In most cases the return address is in the same context as the calling address, but that need not be the case, especially if the producer knows in some way the call never will return. The context of the 'return address' might be on a different line, in a different lexical block, or past the end of the calling subroutine. If a consumer were to assume that it was in the same context as the
calling address, the unwind might fail.

For architectures with constant-length instructions where the return address immediately follows the call instruction, a simple solution is to subtract the length of an instruction from the return address to obtain the calling instruction. For architectures with variable-length instructions (e.g. x86), this is not possible. However, subtracting 1 from the return address, although not guaranteed to provide the exact calling address, generally will produce an address within the
same context as the calling address, and that usually is sufficient.

----





reply via email to

[Prev in Thread] Current Thread [Next in Thread]