This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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: [rfc] dwarf2 backtrace from setcontext


Richard Henderson <rth@redhat.com> writes:

> On Mon, Jan 12, 2004 at 06:19:19PM -0500, Daniel Jacobowitz wrote:
>>   It seems to me that the best solution would be a new rule, either
>>   val_expression(E) or the simpler val_cfa_offset(N).  Then the unwind
>>   information can accurately describe the stack pointer.
>
> That would certainly work for me.
>
>> That would probably work for this example - I can't see any reason that
>> GDB would care.  And for setcontext it makes a certain sense, since you
>> do seem to have "fallen through" into a different backtrace.
>
> I'll recommend we do that for glibc then.

Like the following?

Andreas

============================================================
Index: sysdeps/unix/sysv/linux/x86_64/setcontext.S
--- x86_64/setcontext.S	31 Aug 2002 08:05:51 -0000	1.2
+++ x86_64/setcontext.S	22 Jan 2004 07:24:29 -0000
@@ -1,5 +1,5 @@
 /* Install given context.
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Andreas Jaeger <aj@suse.de>, 2002.
 
@@ -35,6 +35,7 @@
 ENTRY(__setcontext)
 	/* Save argument since syscall will destroy it.  */
 	pushq	%rdi
+	cfi_adjust_cfa_offset(8)
 
 	/* Set the signal mask with
 	   rt_sigprocmask (SIG_SETMASK, mask, NULL, _NSIG/8).  */
@@ -45,6 +46,7 @@ ENTRY(__setcontext)
 	movq	$__NR_rt_sigprocmask, %rax
 	syscall
 	popq	%rdi			/* Reload %rdi, adjust stack.  */
+	cfi_adjust_cfa_offset(-8)
 	cmpq	$-4095, %rax		/* Check %rax for error.  */
 	jae	SYSCALL_ERROR_LABEL	/* Jump to error handler if error.  */
 
@@ -57,6 +59,9 @@ ENTRY(__setcontext)
 
 	/* Load the new stack pointer, the preserved registers and
 	   registers used for passing args.  */
+	/* End FDE here, we fall into another context.  */
+	cfi_endproc
+	
 	movq	oRSP(%rdi), %rsp
 	movq	oRBX(%rdi), %rbx
 	movq	oRBP(%rdi), %rbp
@@ -78,6 +83,9 @@ ENTRY(__setcontext)
 
 	/* Setup finally  %rdi.  */
 	movq	oRDI(%rdi), %rdi
+
+	/* We changed %rdi, fix cfi.  */
+	cfi_startproc
 
 	/* Clear rax to indicate success.  */
 	xorq	%rax, %rax

-- 
 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

Attachment: pgp00000.pgp
Description: PGP signature


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