On Tue, Nov 27, 2007 at 05:18:47PM +0000, Robert Watson wrote:
> The last of these required new kernel changes, including an MD component. 
> I've tested the MD parts only on i386, although I have quick hacks at what 
> they should look like on amd64, arm, powerpc, sparc64, sun4v.  I don't 
> promise these compile or work, but they might do.

The kernel build didn't work on AMD64...

cc -c -O2 -frename-registers -pipe -fno-strict-aliasing  -std=c99 -g -Wall 
-Wredundant-decls -Wnested-externs -Wstrict-prototypes  -Wmissing-prototypes 
-Wpointer-arith -Winline -Wcast-qual  -Wundef -Wno-pointer-sign 
-fformat-extensions -nostdinc  -I. -I/usr/src/sys -I/usr/src/sys/contrib/altq 
-D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -fno-common 
-finline-limit=8000 --param inline-unit-growth=100 --param 
large-function-growth=1000  -fno-omit-frame-pointer -mcmodel=kernel 
-mno-red-zone  -mfpmath=387 -mno-sse -mno-sse2 -mno-mmx -mno-3dnow  
-msoft-float -fno-asynchronous-unwind-tables -ffreestanding -Werror  
/usr/src/sys/amd64/amd64/db_trace.c
cc1: warnings being treated as errors
/usr/src/sys/amd64/amd64/db_trace.c: In function 'stack_save_td':
/usr/src/sys/amd64/amd64/db_trace.c:535: warning: type defaults to 'int' in 
declaration of 'rbp'
/usr/src/sys/amd64/amd64/db_trace.c:537: warning: implicit declaration of 
function 'TD_IS_SWWAPPED'
/usr/src/sys/amd64/amd64/db_trace.c:537: warning: nested extern declaration of 
'TD_IS_SWWAPPED'
*** Error code 1

Stop in /usr/obj/usr/src/sys/GENERIC.
*** Error code 1

Stop in /usr/src.
*** Error code 1

Stop in /usr/src.
[EMAIL PROTECTED] /usr/src % 

Here's an updated patch to sys/amd64/amd64/db_trace.c (it's a diff
against revision 1.81).  It changes "register rbp" to be "register_t
rbp" and fixes the extra "W" in TD_IS_SWAPPED.  The kernel built fine
after these changes.  I'll test it out tomorrow.

--- sys/amd64/amd64/db_trace.c.orig     2007-11-15 17:00:56.000000000 -0500
+++ sys/amd64/amd64/db_trace.c  2007-11-27 22:59:29.000000000 -0500
@@ -505,15 +505,13 @@
                    ctx->pcb_rip, count));
 }
 
-void
-stack_save(struct stack *st)
+static void
+stack_capture(struct stack *st, register_t rbp)
 {
        struct amd64_frame *frame;
        vm_offset_t callpc;
-       register_t rbp;
 
        stack_zero(st);
-       __asm __volatile("movq %%rbp,%0" : "=r" (rbp));
        frame = (struct amd64_frame *)rbp;
        while (1) {
                if (!INKERNEL((long)frame))
@@ -531,6 +529,29 @@
        }
 }
 
+void
+stack_save_td(struct stack *st, struct thread *td)
+{
+       register_t rbp;
+
+       if (TD_IS_SWAPPED(td))
+               panic("stack_save_td: swapped");
+       if (TD_IS_RUNNING(td))
+               panic("stack_save_td: running");
+
+       rbp = td->td_pcb->pcb_rbp;
+       stack_capture(st, rbp);
+}
+
+void
+stack_save(struct stack *st)
+{
+       register_t rbp;
+
+       __asm __volatile("movq %%rbp,%0" : "=r" (rbp));
+       stack_capture(st, rbp);
+}
+
 int
 amd64_set_watch(watchnum, watchaddr, size, access, d)
        int watchnum;

> I think procstat(1) is getting a lot closer to commitable state for 
> 8-CURRENT, but further feedback would be most welcome (including reports of 
> success on non-i386 architectures, and possibly patches to fix them).  For 
> FreeBSD developers with P4 access, you can also check out

Thank you for this.  I think procstat(1) is going to be very useful.

-- WXS
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to