All of lore.kernel.org
 help / color / mirror / Atom feed
* Fixes for .cfi directives for x86_64 kgdb
@ 2004-03-17 21:37 Jim Houston
  2004-03-17 23:53 ` Andi Kleen
  2004-03-23  0:17 ` [PATCH]Call frame debug info for 2.6 kernel George Anzinger
  0 siblings, 2 replies; 7+ messages in thread
From: Jim Houston @ 2004-03-17 21:37 UTC (permalink / raw)
  To: Andi Kleen; +Cc: Andrew Morton, amitkale, linux-kernel


Hi Andi, Andrew, Amit,

The attached patch fixes the .cfi directives for the common_interrupt
path for opteron.  It seems that the existing .cfi directives in this
path only work by accident.

I spent yesterday decoding a stack by hand and looking at the
dwarf unwind data using "readelf -wF".  I found that the  existing
.cfi directives describe registers sharing the same stack addresses
(not a good thing).

This patch makes the unwind data make sense and makes gdb/kgdb more
likely to produce a useful stack traces.

Jim Houston - Concurrent Computer Corp.

--

diff -urN -X dontdiff linux-2.6.4-rc2-mm1.orig/arch/x86_64/kernel/entry.S linux-2.6.4-rc2-mm1/arch/x86_64/kernel/entry.S
--- linux-2.6.4-rc2-mm1.orig/arch/x86_64/kernel/entry.S	2004-03-10 17:06:03.000000000 -0500
+++ linux-2.6.4-rc2-mm1/arch/x86_64/kernel/entry.S	2004-03-17 09:19:30.000000000 -0500
@@ -402,9 +402,9 @@
 /* 0(%rsp): interrupt number */ 
 	.macro interrupt func
 	CFI_STARTPROC	simple
-	CFI_DEF_CFA	rsp,(SS-ORIG_RAX)
-	CFI_OFFSET	rsp,(RSP-SS)
-	CFI_OFFSET	rip,(RIP-SS)
+	CFI_DEF_CFA	rsp,(SS-RDI)
+	CFI_REL_OFFSET	rsp,(RSP-ORIG_RAX)
+	CFI_REL_OFFSET	rip,(RIP-ORIG_RAX)
 	cld
 #ifdef CONFIG_DEBUG_INFO
 	SAVE_ALL	
diff -urN -X dontdiff linux-2.6.4-rc2-mm1.orig/include/asm-x86_64/calling.h linux-2.6.4-rc2-mm1/include/asm-x86_64/calling.h
--- linux-2.6.4-rc2-mm1.orig/include/asm-x86_64/calling.h	2004-03-10 17:05:42.000000000 -0500
+++ linux-2.6.4-rc2-mm1/include/asm-x86_64/calling.h	2004-03-17 09:19:30.000000000 -0500
@@ -35,26 +35,26 @@
 	subq  $9*8+\addskip,%rsp
 	CFI_ADJUST_CFA_OFFSET	9*8+\addskip
 	movq  %rdi,8*8(%rsp) 
-	CFI_OFFSET	rdi,8*8-(9*8+\addskip)
+	CFI_REL_OFFSET	rdi,8*8
 	movq  %rsi,7*8(%rsp) 
-	CFI_OFFSET	rsi,7*8-(9*8+\addskip)
+	CFI_REL_OFFSET	rsi,7*8
 	movq  %rdx,6*8(%rsp)
-	CFI_OFFSET	rdx,6*8-(9*8+\addskip)
+	CFI_REL_OFFSET	rdx,6*8
 	.if \norcx
 	.else
 	movq  %rcx,5*8(%rsp)
-	CFI_OFFSET	rcx,5*8-(9*8+\addskip)
+	CFI_REL_OFFSET	rcx,5*8
 	.endif
 	movq  %rax,4*8(%rsp) 
-	CFI_OFFSET	rax,4*8-(9*8+\addskip)
+	CFI_REL_OFFSET	rax,4*8
 	movq  %r8,3*8(%rsp) 
-	CFI_OFFSET	r8,3*8-(9*8+\addskip)
+	CFI_REL_OFFSET	r8,3*8
 	movq  %r9,2*8(%rsp) 
-	CFI_OFFSET	r9,2*8-(9*8+\addskip)
+	CFI_REL_OFFSET	r9,2*8
 	movq  %r10,1*8(%rsp) 
-	CFI_OFFSET	r10,1*8-(9*8+\addskip)
+	CFI_REL_OFFSET	r10,1*8
 	movq  %r11,(%rsp) 
-	CFI_OFFSET	r11,-(9*8+\addskip)
+	CFI_REL_OFFSET	r11,
 	.endm
 
 #define ARG_SKIP 9*8
@@ -100,17 +100,17 @@
 	subq $REST_SKIP,%rsp
 	CFI_ADJUST_CFA_OFFSET	REST_SKIP
 	movq %rbx,5*8(%rsp) 
-	CFI_OFFSET	rbx,5*8-(REST_SKIP)
+	CFI_REL_OFFSET	rbx,5*8
 	movq %rbp,4*8(%rsp) 
-	CFI_OFFSET	rbp,4*8-(REST_SKIP)
+	CFI_REL_OFFSET	rbp,4*8
 	movq %r12,3*8(%rsp) 
-	CFI_OFFSET	r12,3*8-(REST_SKIP)
+	CFI_REL_OFFSET	r12,3*8
 	movq %r13,2*8(%rsp) 
-	CFI_OFFSET	r13,2*8-(REST_SKIP)
+	CFI_REL_OFFSET	r13,2*8
 	movq %r14,1*8(%rsp) 
-	CFI_OFFSET	r14,1*8-(REST_SKIP)
+	CFI_REL_OFFSET	r14,1*8
 	movq %r15,(%rsp) 
-	CFI_OFFSET	r15,0*8-(REST_SKIP)
+	CFI_REL_OFFSET	r15,0*8
 	.endm		
 
 	.macro RESTORE_REST

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Fixes for .cfi directives for x86_64 kgdb
  2004-03-17 21:37 Fixes for .cfi directives for x86_64 kgdb Jim Houston
@ 2004-03-17 23:53 ` Andi Kleen
  2004-03-18 16:51   ` Jim Houston
  2004-03-23  0:17 ` [PATCH]Call frame debug info for 2.6 kernel George Anzinger
  1 sibling, 1 reply; 7+ messages in thread
From: Andi Kleen @ 2004-03-17 23:53 UTC (permalink / raw)
  To: jim.houston; +Cc: akpm, amitkale, linux-kernel

On 17 Mar 2004 16:37:15 -0500
Jim Houston <jim.houston@comcast.net> wrote:

> 
> Hi Andi, Andrew, Amit,
> 
> The attached patch fixes the .cfi directives for the common_interrupt
> path for opteron.  It seems that the existing .cfi directives in this
> path only work by accident.
> 
> I spent yesterday decoding a stack by hand and looking at the
> dwarf unwind data using "readelf -wF".  I found that the  existing
> .cfi directives describe registers sharing the same stack addresses
> (not a good thing).
> 
> This patch makes the unwind data make sense and makes gdb/kgdb more
> likely to produce a useful stack traces.

Thanks. I applied it. The calling.h part gave rejects, but I applied it
by hand. It would be nice if you could check in the final kernel if I didn't
make a mistake.

-Andi



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Fixes for .cfi directives for x86_64 kgdb
  2004-03-17 23:53 ` Andi Kleen
@ 2004-03-18 16:51   ` Jim Houston
  2004-03-19 13:17     ` Amit S. Kale
  0 siblings, 1 reply; 7+ messages in thread
From: Jim Houston @ 2004-03-18 16:51 UTC (permalink / raw)
  To: Andi Kleen; +Cc: akpm, amitkale, linux-kernel

On Wed, 2004-03-17 at 18:53, Andi Kleen wrote:
On 17 Mar 2004 16:37:15 -0500
> Jim Houston <jim.houston@comcast.net> wrote:
> > The attached patch fixes the .cfi directives for the common_interrupt
> > path for opteron.  It seems that the existing .cfi directives in this
> > path only work by accident.
> > 
> > This patch makes the unwind data make sense and makes gdb/kgdb more
> > likely to produce a useful stack traces.
> 
> Thanks. I applied it. The calling.h part gave rejects, but I applied it
> by hand. It would be nice if you could check in the final kernel if I didn't
> make a mistake.
> 

Hi Andi, Andrew, Amit,

The attached patch is updated to work with linux-2.6.5-rc1.

Jim Houston - Concurrent Computer Corp.

--

diff -urN linux-2.6.5-rc1-mm2.orig/arch/x86_64/kernel/entry.S linux-2.6.5-rc1-mm2/arch/x86_64/kernel/entry.S
--- linux-2.6.5-rc1-mm2.orig/arch/x86_64/kernel/entry.S	2004-03-18 09:37:13.830453136 -0500
+++ linux-2.6.5-rc1-mm2/arch/x86_64/kernel/entry.S	2004-03-18 09:37:29.237110968 -0500
@@ -403,9 +403,9 @@
 /* 0(%rsp): interrupt number */ 
 	.macro interrupt func
 	CFI_STARTPROC	simple
-	CFI_DEF_CFA	rsp,(SS-ORIG_RAX)
-	CFI_OFFSET	rsp,(RSP-SS)
-	CFI_OFFSET	rip,(RIP-SS)
+	CFI_DEF_CFA	rsp,(SS-RDI)
+	CFI_REL_OFFSET	rsp,(RSP-ORIG_RAX)
+	CFI_REL_OFFSET	rip,(RIP-ORIG_RAX)
 	cld
 #ifdef CONFIG_DEBUG_INFO
 	SAVE_ALL	
diff -urN linux-2.6.5-rc1-mm2.orig/include/asm-x86_64/calling.h linux-2.6.5-rc1-mm2/include/asm-x86_64/calling.h
--- linux-2.6.5-rc1-mm2.orig/include/asm-x86_64/calling.h	2004-03-18 09:36:21.635387992 -0500
+++ linux-2.6.5-rc1-mm2/include/asm-x86_64/calling.h	2004-03-18 09:36:05.978768160 -0500
@@ -35,28 +35,28 @@
 	subq  $9*8+\addskip,%rsp
 	CFI_ADJUST_CFA_OFFSET	9*8+\addskip
 	movq  %rdi,8*8(%rsp) 
-	CFI_OFFSET	rdi,8*8-(9*8+\addskip)
+	CFI_REL_OFFSET	rdi,8*8
 	movq  %rsi,7*8(%rsp) 
-	CFI_OFFSET	rsi,7*8-(9*8+\addskip)
+	CFI_REL_OFFSET	rsi,7*8
 	movq  %rdx,6*8(%rsp)
-	CFI_OFFSET	rdx,6*8-(9*8+\addskip)
+	CFI_REL_OFFSET	rdx,6*8
 	.if \norcx
 	.else
 	movq  %rcx,5*8(%rsp)
-	CFI_OFFSET	rcx,5*8-(9*8+\addskip)
+	CFI_REL_OFFSET	rcx,5*8
 	.endif
 	movq  %rax,4*8(%rsp) 
-	CFI_OFFSET	rax,4*8-(9*8+\addskip)
+	CFI_REL_OFFSET	rax,4*8
 	.if \nor891011
 	.else
 	movq  %r8,3*8(%rsp) 
-	CFI_OFFSET	r8,3*8-(9*8+\addskip)
+	CFI_REL_OFFSET	r8,3*8
 	movq  %r9,2*8(%rsp) 
-	CFI_OFFSET	r9,2*8-(9*8+\addskip)
+	CFI_REL_OFFSET	r9,2*8
 	movq  %r10,1*8(%rsp) 
-	CFI_OFFSET	r10,1*8-(9*8+\addskip)
+	CFI_REL_OFFSET	r10,1*8
 	movq  %r11,(%rsp) 
-	CFI_OFFSET	r11,-(9*8+\addskip)
+	CFI_REL_OFFSET	r11,
 	.endif
 	.endm
 
@@ -109,17 +109,17 @@
 	subq $REST_SKIP,%rsp
 	CFI_ADJUST_CFA_OFFSET	REST_SKIP
 	movq %rbx,5*8(%rsp) 
-	CFI_OFFSET	rbx,5*8-(REST_SKIP)
+	CFI_REL_OFFSET	rbx,5*8
 	movq %rbp,4*8(%rsp) 
-	CFI_OFFSET	rbp,4*8-(REST_SKIP)
+	CFI_REL_OFFSET	rbp,4*8
 	movq %r12,3*8(%rsp) 
-	CFI_OFFSET	r12,3*8-(REST_SKIP)
+	CFI_REL_OFFSET	r12,3*8
 	movq %r13,2*8(%rsp) 
-	CFI_OFFSET	r13,2*8-(REST_SKIP)
+	CFI_REL_OFFSET	r13,2*8
 	movq %r14,1*8(%rsp) 
-	CFI_OFFSET	r14,1*8-(REST_SKIP)
+	CFI_REL_OFFSET	r14,1*8
 	movq %r15,(%rsp) 
-	CFI_OFFSET	r15,0*8-(REST_SKIP)
+	CFI_REL_OFFSET	r15,0*8
 	.endm		
 
 	.macro RESTORE_REST

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Fixes for .cfi directives for x86_64 kgdb
  2004-03-18 16:51   ` Jim Houston
@ 2004-03-19 13:17     ` Amit S. Kale
  2004-03-19 19:23       ` Andi Kleen
  0 siblings, 1 reply; 7+ messages in thread
From: Amit S. Kale @ 2004-03-19 13:17 UTC (permalink / raw)
  To: jim.houston, Andi Kleen; +Cc: akpm, linux-kernel, KGDB bugreports

Thanks. Checked into kgdb.sourceforge.net cvs tree
-Amit

On Thursday 18 Mar 2004 10:21 pm, Jim Houston wrote:
> On Wed, 2004-03-17 at 18:53, Andi Kleen wrote:
> On 17 Mar 2004 16:37:15 -0500
>
> > Jim Houston <jim.houston@comcast.net> wrote:
> > > The attached patch fixes the .cfi directives for the common_interrupt
> > > path for opteron.  It seems that the existing .cfi directives in this
> > > path only work by accident.
> > >
> > > This patch makes the unwind data make sense and makes gdb/kgdb more
> > > likely to produce a useful stack traces.
> >
> > Thanks. I applied it. The calling.h part gave rejects, but I applied it
> > by hand. It would be nice if you could check in the final kernel if I
> > didn't make a mistake.
>
> Hi Andi, Andrew, Amit,
>
> The attached patch is updated to work with linux-2.6.5-rc1.
>
> Jim Houston - Concurrent Computer Corp.
>
> --
>
> diff -urN linux-2.6.5-rc1-mm2.orig/arch/x86_64/kernel/entry.S
> linux-2.6.5-rc1-mm2/arch/x86_64/kernel/entry.S ---
> linux-2.6.5-rc1-mm2.orig/arch/x86_64/kernel/entry.S	2004-03-18
> 09:37:13.830453136 -0500 +++
> linux-2.6.5-rc1-mm2/arch/x86_64/kernel/entry.S	2004-03-18
> 09:37:29.237110968 -0500 @@ -403,9 +403,9 @@
>  /* 0(%rsp): interrupt number */
>  	.macro interrupt func
>  	CFI_STARTPROC	simple
> -	CFI_DEF_CFA	rsp,(SS-ORIG_RAX)
> -	CFI_OFFSET	rsp,(RSP-SS)
> -	CFI_OFFSET	rip,(RIP-SS)
> +	CFI_DEF_CFA	rsp,(SS-RDI)
> +	CFI_REL_OFFSET	rsp,(RSP-ORIG_RAX)
> +	CFI_REL_OFFSET	rip,(RIP-ORIG_RAX)
>  	cld
>  #ifdef CONFIG_DEBUG_INFO
>  	SAVE_ALL
> diff -urN linux-2.6.5-rc1-mm2.orig/include/asm-x86_64/calling.h
> linux-2.6.5-rc1-mm2/include/asm-x86_64/calling.h ---
> linux-2.6.5-rc1-mm2.orig/include/asm-x86_64/calling.h	2004-03-18
> 09:36:21.635387992 -0500 +++
> linux-2.6.5-rc1-mm2/include/asm-x86_64/calling.h	2004-03-18
> 09:36:05.978768160 -0500 @@ -35,28 +35,28 @@
>  	subq  $9*8+\addskip,%rsp
>  	CFI_ADJUST_CFA_OFFSET	9*8+\addskip
>  	movq  %rdi,8*8(%rsp)
> -	CFI_OFFSET	rdi,8*8-(9*8+\addskip)
> +	CFI_REL_OFFSET	rdi,8*8
>  	movq  %rsi,7*8(%rsp)
> -	CFI_OFFSET	rsi,7*8-(9*8+\addskip)
> +	CFI_REL_OFFSET	rsi,7*8
>  	movq  %rdx,6*8(%rsp)
> -	CFI_OFFSET	rdx,6*8-(9*8+\addskip)
> +	CFI_REL_OFFSET	rdx,6*8
>  	.if \norcx
>  	.else
>  	movq  %rcx,5*8(%rsp)
> -	CFI_OFFSET	rcx,5*8-(9*8+\addskip)
> +	CFI_REL_OFFSET	rcx,5*8
>  	.endif
>  	movq  %rax,4*8(%rsp)
> -	CFI_OFFSET	rax,4*8-(9*8+\addskip)
> +	CFI_REL_OFFSET	rax,4*8
>  	.if \nor891011
>  	.else
>  	movq  %r8,3*8(%rsp)
> -	CFI_OFFSET	r8,3*8-(9*8+\addskip)
> +	CFI_REL_OFFSET	r8,3*8
>  	movq  %r9,2*8(%rsp)
> -	CFI_OFFSET	r9,2*8-(9*8+\addskip)
> +	CFI_REL_OFFSET	r9,2*8
>  	movq  %r10,1*8(%rsp)
> -	CFI_OFFSET	r10,1*8-(9*8+\addskip)
> +	CFI_REL_OFFSET	r10,1*8
>  	movq  %r11,(%rsp)
> -	CFI_OFFSET	r11,-(9*8+\addskip)
> +	CFI_REL_OFFSET	r11,
>  	.endif
>  	.endm
>
> @@ -109,17 +109,17 @@
>  	subq $REST_SKIP,%rsp
>  	CFI_ADJUST_CFA_OFFSET	REST_SKIP
>  	movq %rbx,5*8(%rsp)
> -	CFI_OFFSET	rbx,5*8-(REST_SKIP)
> +	CFI_REL_OFFSET	rbx,5*8
>  	movq %rbp,4*8(%rsp)
> -	CFI_OFFSET	rbp,4*8-(REST_SKIP)
> +	CFI_REL_OFFSET	rbp,4*8
>  	movq %r12,3*8(%rsp)
> -	CFI_OFFSET	r12,3*8-(REST_SKIP)
> +	CFI_REL_OFFSET	r12,3*8
>  	movq %r13,2*8(%rsp)
> -	CFI_OFFSET	r13,2*8-(REST_SKIP)
> +	CFI_REL_OFFSET	r13,2*8
>  	movq %r14,1*8(%rsp)
> -	CFI_OFFSET	r14,1*8-(REST_SKIP)
> +	CFI_REL_OFFSET	r14,1*8
>  	movq %r15,(%rsp)
> -	CFI_OFFSET	r15,0*8-(REST_SKIP)
> +	CFI_REL_OFFSET	r15,0*8
>  	.endm
>
>  	.macro RESTORE_REST


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Fixes for .cfi directives for x86_64 kgdb
  2004-03-19 13:17     ` Amit S. Kale
@ 2004-03-19 19:23       ` Andi Kleen
  2004-03-21 13:12         ` Amit S. Kale
  0 siblings, 1 reply; 7+ messages in thread
From: Andi Kleen @ 2004-03-19 19:23 UTC (permalink / raw)
  To: Amit S. Kale; +Cc: jim.houston, akpm, linux-kernel, kgdb-bugreport

On Fri, 19 Mar 2004 18:47:43 +0530
"Amit S. Kale" <amitkale@emsyssoft.com> wrote:

> Thanks. Checked into kgdb.sourceforge.net cvs tree

It's not very useful because that tree still has the broken
"interrupt threads" support.

-Andi

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Fixes for .cfi directives for x86_64 kgdb
  2004-03-19 19:23       ` Andi Kleen
@ 2004-03-21 13:12         ` Amit S. Kale
  0 siblings, 0 replies; 7+ messages in thread
From: Amit S. Kale @ 2004-03-21 13:12 UTC (permalink / raw)
  To: Andi Kleen; +Cc: jim.houston, akpm, linux-kernel, kgdb-bugreport

On Saturday 20 Mar 2004 12:53 am, Andi Kleen wrote:
> On Fri, 19 Mar 2004 18:47:43 +0530
>
> "Amit S. Kale" <amitkale@emsyssoft.com> wrote:
> > Thanks. Checked into kgdb.sourceforge.net cvs tree
>
> It's not very useful because that tree still has the broken
> "interrupt threads" support.

Does it show interrupt threads or not?
-Amit

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH]Call frame debug info for 2.6 kernel
  2004-03-17 21:37 Fixes for .cfi directives for x86_64 kgdb Jim Houston
  2004-03-17 23:53 ` Andi Kleen
@ 2004-03-23  0:17 ` George Anzinger
  1 sibling, 0 replies; 7+ messages in thread
From: George Anzinger @ 2004-03-23  0:17 UTC (permalink / raw)
  To: jim.houston; +Cc: Andi Kleen, Andrew Morton, amitkale, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1160 bytes --]

This patch adds call frame debug record generation for entry.S frames.  If used 
with KGDB and gdb 6.0 it allows correct "back trace" (bt) through interrupt, 
system call and trap frames.  Frames that point to user space are tied off, 
those that point to the kernel unwind to the kernel.  It also ties off the 
initial frame in head.S and the idle process stacks for cpus other than cpu0 
(which actually goes back to head.S).  The patch adds one (1) instruction to the 
executable kernel (a few lines to the debug space, however).

The patch requires a gdb that handles CFI expressions, although it takes pains 
to work around a bug in gdb 6.0's expression analizer (the work around is also 
compatable with a correctly working expression analizer as can be found in the 
CVS version of gdb).  AFAIK gdb 6.0 is the first gdb to handle CFI expressions 
so you must use it to make this patch useful.

Use of earlier gdb's with this patch will not be affected (either for good or bad).
-- 
George Anzinger   george@mvista.com
High-res-timers:  http://sourceforge.net/projects/high-res-timers/
Preemption patch: http://www.kernel.org/pub/linux/kernel/people/rml

[-- Attachment #2: kgdb-dwarf-2.6.4-1.0.patch.gz --]
[-- Type: application/x-gzip, Size: 11356 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-03-23  0:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-17 21:37 Fixes for .cfi directives for x86_64 kgdb Jim Houston
2004-03-17 23:53 ` Andi Kleen
2004-03-18 16:51   ` Jim Houston
2004-03-19 13:17     ` Amit S. Kale
2004-03-19 19:23       ` Andi Kleen
2004-03-21 13:12         ` Amit S. Kale
2004-03-23  0:17 ` [PATCH]Call frame debug info for 2.6 kernel George Anzinger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.