[PATCH] Fix AMD64 backtrace
Andreas Jaeger
aj@suse.de
Sun Jan 11 10:40:00 GMT 2004
Andreas Jaeger <aj@suse.de> writes:
> Jakub Jelinek <jakub@redhat.com> writes:
>
>> On Sat, Jan 10, 2004 at 08:49:49PM +0100, Andreas Jaeger wrote:
>>> Andreas Jaeger <aj@suse.de> writes:
>>>
>>> > Jakub Jelinek <jakub@redhat.com> writes:
>>> > [...]
>>> >>> libc/sysdeps/x86_64/__longjmp.S
>>> >
>>> > What's the best way to handle the destroying of the registers with
>>> > CFI? Should we just mark the registers with "cfi_undefined"?
>>>
>>> I'm appending a proposed patch for __longjmp.S. Or can anybody
>>> envision a better way doing this?
>>
>> Cannot you from the first movq ***,%rbx pretend you're
>> already at the jmpq %*rdx instruction, ie. unwind to the
>> longjmp target?
>> Write in the unwind info where to fetch %rbp, %r12..%r15,
>> ra etc. from?
>
> You mean something like the following?
>
> cfi_def_cfa(%rdi,0)
> cfi_offset(%rbx,JB_RBX*8)
> cfi_offset(%r12,JB_R12*8)
> ...
>
> I'm not sure what the right way is to handle this here at all ...
I've done it now completely:
ENTRY(__longjmp)
/* Restore registers. */
/* We add unwind information for the target here. */
cfi_def_cfa(%rdi, 0)
cfi_offset(%rbx,JB_RBX*8)
cfi_offset(%r12,JB_R12*8)
cfi_offset(%r13,JB_R13*8)
cfi_offset(%r14,JB_R14*8)
cfi_offset(%r15,JB_R15*8)
cfi_offset(%rsp,JB_RSP*8)
movq (JB_RBX*8)(%rdi),%rbx
movq (JB_RBP*8)(%rdi),%rbp
movq (JB_R12*8)(%rdi),%r12
movq (JB_R13*8)(%rdi),%r13
movq (JB_R14*8)(%rdi),%r14
movq (JB_R15*8)(%rdi),%r15
/* Set return value for setjmp. */
test %esi,%esi
mov $01,%eax
cmove %eax,%esi
mov %esi, %eax
movq (JB_PC*8)(%rdi),%rdx
movq (JB_RSP*8)(%rdi),%rsp
jmpq *%rdx
END (BP_SYM (__longjmp))
Does this look ok? In that case I'll commit it (and will fix
setcontext/swapcontext in a similar way)...
Andreas
--
Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj
SuSE Linux AG, Maxfeldstr. 5, 90409 Nürnberg, Germany
GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-hacker/attachments/20040111/9616abb9/attachment.sig>
More information about the Libc-hacker
mailing list