gnu/60732: [PATCH] unbreak kgdb backtraces through traps

Peter Edwards pmedwards at eircom.net
Tue Dec 30 09:00:59 PST 2003


>Number:         60732
>Category:       gnu
>Synopsis:       [PATCH] unbreak kgdb backtraces through traps
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Dec 30 09:00:38 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Peter Edwards
>Release:        5.2-CURRENT
>Organization:
>Environment:
FreeBSD hippo 5.2-CURRENT FreeBSD 5.2-CURRENT #0: Mon Dec 29 21:20:38 GMT 2003     petere at hippo:/scratch/obj/scratch/src/sys/HIPPO  i386

>Description:
This has been bugging the hell out of me for ages: I finally cleaned up
my local patch enough to consider submitting it.

The usr/src/gnu/usr.bin/binutils/gdb directory contains some freebsd-specific code to enable kernel debugging, uthread manipulation
etc.

There's a set of files, fbsd-kgdb-${GDB_CPU}.h, that are supposed to
provide hooks to the gdb base code. However, these are never included.
For i386, the main loss is the definition of "FRAME_SAVED_PC", which
is designed to aid gdb unwind through a stack frame. Without this
definition, the topmost frame of a core from kernel panic under the actual trap() frame is lost: This is normally the most interesting frame 
>How-To-Repeat:
Find a way to kill your machine with a page fault (some available on request :-)) As an example, here's a backtrace for a panic I can reproduce at will: (note "calltrap" appears in frame 5)

#0  doadump () at /scratch/src/sys/kern/kern_shutdown.c:240
#1  0xc04c0489 in boot (howto=260) at /scratch/src/sys/kern/kern_shutdown.c:372
#2  0xc04c0868 in panic () at /scratch/src/sys/kern/kern_shutdown.c:550
#3  0xc05dc326 in trap_fatal (frame=0xd72e7c40, eva=0)
    at /scratch/src/sys/i386/i386/trap.c:821
#4  0xc05db903 in trap (frame=
      {tf_fs = 24, tf_es = -684851184, tf_ds = -1067712496, tf_edi = 0, tf_esi = -1067086800, tf_ebp = -684819296, tf_isp = -684819348, tf_ebx = -1000238144, tf_edx = -1050979712, tf_ecx = -1050979712, tf_eax = 20, tf_trapno = 12, tf_err = 0, tf_eip = -1068595426, tf_cs = 8, tf_eflags = 65683, tf_esp = -1050982468, tf_ss = 131})
    at /scratch/src/sys/i386/i386/trap.c:250
#5  0xc05c9898 in calltrap () at {standard input}:94
#6  0xc04e8fa4 in turnstile_wait (ts=0x0, lock=0xc06560e0, owner=0x0)
    at /scratch/src/sys/kern/subr_turnstile.c:510
#7  0xc04b5af5 in _mtx_lock_sleep (m=0xc06560e0, opts=0, file=0x0, line=0)
    at /scratch/src/sys/kern/kern_mutex.c:476
#8  0xc04aa4a4 in ithread_loop (arg=0xc15aa600) at /scratch/src/sys/kern/kern_intr.c:543
#9  0xc04a9130 in fork_exit (callout=0xc04aa2e0 <ithread_loop>, arg=0x0, frame=0x0)
    at /scratch/src/sys/kern/kern_fork.c:793


With the fix in place, I get this stack trace:

#0  doadump () at /scratch/src/sys/kern/kern_shutdown.c:240
#1  0xc04c0489 in boot (howto=260) at /scratch/src/sys/kern/kern_shutdown.c:372
#2  0xc04c0868 in panic () at /scratch/src/sys/kern/kern_shutdown.c:550
#3  0xc05dc326 in trap_fatal (frame=0xd72e7c40, eva=0)
    at /scratch/src/sys/i386/i386/trap.c:821
#4  0xc05db903 in trap (frame=
      {tf_fs = 24, tf_es = -684851184, tf_ds = -1067712496, tf_edi = 0, tf_esi = -1067086800, tf_ebp = -684819296, tf_isp = -684819348, tf_ebx = -1000238144, tf_edx = -1050979712, tf_ecx = -1050979712, tf_eax = 20, tf_trapno = 12, tf_err = 0, tf_eip = -1068595426, tf_cs = 8, tf_eflags = 65683, tf_esp = -1050982468, tf_ss = 131})
    at /scratch/src/sys/i386/i386/trap.c:250
#5  0xc04e871e in propagate_priority (td=0xc46193c0)
    at /scratch/src/sys/kern/subr_turnstile.c:230
#6  0xc04e8fa4 in turnstile_wait (ts=0xc438a640, lock=0xc06560e0, owner=0x0)
    at /scratch/src/sys/kern/subr_turnstile.c:510
#7  0xc04b5af5 in _mtx_lock_sleep (m=0xc06560e0, opts=0, file=0x0, line=0)
    at /scratch/src/sys/kern/kern_mutex.c:476
#8  0xc04aa4a4 in ithread_loop (arg=0xc15aa600) at /scratch/src/sys/kern/kern_intr.c:543
#9  0xc04a9130 in fork_exit (callout=0xc04aa2e0 <ithread_loop>, arg=0x0, frame=0x0)
    at /scratch/src/sys/kern/kern_fork.c:793

(This time frame 5 actually shows me the faulting code.)

    
>Fix:
I rejigged the makefile to create a tm.h that included the stock gdb version, and the freebsd kgdb-specific code (the target for nm.h sets a precident for this). For i386, this just envolved ripping out the bits that were not used anyway, and leaving in a working definition of FRAME_SAVED_PC.

For alpha, the existing version should work fine. The other platforms don't seem to have any support for FRAME_SAVED_PC yet anyway, so they shouldn't be affected. Here's the patch:

begin 644 gdb-frame-patch.txt
M26YD97 at Z($UA:V5F:6QE"CT]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]
M/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T*4D-3(&9I
M;&4Z("]U<W(O8W9S+T9R965"4T0M0U93+W-R8R]G;G4O=7-R+F)I;B]B:6YU
M=&EL<R]G9&(O36%K969I;&4L=@IR971R:65V:6YG(')E=FES:6]N(#$N-C@*
M9&EF9B`M=2`M<C$N-C@@36%K969I;&4*+2TM($UA:V5F:6QE"3<@4V5P(#(P
M,#,@,C`Z,S at Z,C, at +3`P,#`),2XV.`HK*RL at 36%K969I;&4),S`@1&5C(#(P
M,#,@,38Z,C<Z,38 at +3`P,#`*0$`@+3$R,2PQ,"`K,3(Q+#$X($!`"B`)96-H
M;R`G(VEN8VQU9&4@(B1[1T1"7T-057TO;FTM9F)S9"YH(B<)/B1[+E1!4D=%
M5'T*(`EE8VAO("<C:6YC;'5D92`B9F)S9"UK9V1B+F at B)PD)/CXD>RY405)'
M151]"B`*+2YF;W(@2"!I;B!T;2UF8G-D('AM+21[1T1"7T-057T*+21[2#I#
M+RTN*B0O+WTN:#H**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BYH+'8@,2XS(#(P,#(O,#DO
M,3@@,38Z,C`Z-#D@;V)R:65N($5X<"`D("HO"BT**R\J("1&<F5E0E-$)"`J
M+PH@(VEF;F1E9B!&0E-$7TM'1$)?23,X-E]("B`C9&5F:6YE($9"4T1?2T=$
M0E]),S at V7T@*(`HM+RH at 3VX@1G)E94)31"P@<VEG=')A;7`@:&%S('-I>F4@
M,'@Q."!A;F0@:7,@:6UM961I871E;'D at 8F5L;W<@=&AE"BT@("!P<U]S=')I
M;F=S('-T<G5C="!W:&EC:"!H87,@<VEZ92`P>#$P(&%N9"!I<R!A="!T:&4@
M=&]P(&]F('1H90HM("`@=7-E<B!S=&%C:RX@("HO"BT*+2-U;F1E9B`@4TE'
M5%)!35!?4U1!4E0*+2-D969I;F4 at 4TE'5%)!35!?4U1!4E0H<&,I"3!X8F9B
M9F1F9#@*+2-U;F1E9B`@4TE'5%)!35!?14Y$"BTC9&5F:6YE(%-)1U1204U0
M7T5.1"AP8RD),'AB9F)F9&9F,`HM(`HM(`HM+RH at 3W9E<G)I9&4 at 1E)!345?
M4T%6141?4$,@=&\@96YA8FQE('1H92!R96-O9VYI=&EO;B!O9B!S:6=N86P@
M:&%N9&QE<G,N("`J+PHM"BUE>'1E<FX at 0T]215]!1$12(&9B<V1?:V5R;E]F
M<F%M95]S879E9%]P8RAS=')U8W0 at 9G)A;65?:6YF;R`J9G(I.PHM"B`C=6YD
M968@($9204U%7U-!5D5$7U!#"B`C9&5F:6YE($9204U%7U-!5D5$7U!#*$92
M04U%*2!<"BT@("AK97)N96Q?9&5B=6=G:6YG(%P*+2`@("`_(&9B<V1?:V5R
M;E]F<F%M95]S879E9%]P8R`H1E)!344I(#H at 7`HM("`@("A&4D%-12DM/G-I
M9VYA;%]H86YD;&5R7V-A;&QE<B!<"BT@("`@("`_('-I9W1R86UP7W-A=F5D
M7W!C("A&4D%-12D at 7`HM("`@("`@.B!R96%D7VUE;6]R>5]I;G1E9V5R("@H
M1E)!344I+3YF<F%M92`K(#0L(#0I*0HM"BTO*B!/9F9S970@=&\@<V%V960@
M4$,@:6X@<VEG8V]N=&5X="P at 9G)O;2`\<WES+W-I9VYA;"YH/BX@("HO"BTC
M9&5F:6YE(%-)1T-/3E1%6%1?4$-?3T9&4T54(#(P"BL@("AK97)N96Q?9&5B
M=6=G:6YG(#\@7`HK("`)9F)S9%]K97)N7V9R86UE7W-A=F5D7W!C("A&4D%-
M12D at .B!<"BL):3,X-F)S9%]F<F%M95]S879E9%]P8RA&4D%-12DI"B`*("-E
<;F1I9B`O*B!&0E-$7TM'1$)?23,X-E](("HO"@``
`
end
     
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list