From owner-freebsd-hackers@FreeBSD.ORG Wed Nov 28 04:37:06 2007 Return-Path: Delivered-To: hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E746516A41A; Wed, 28 Nov 2007 04:37:06 +0000 (UTC) (envelope-from wxs@atarininja.org) Received: from syn.atarininja.org (syn.csh.rit.edu [129.21.60.158]) by mx1.freebsd.org (Postfix) with ESMTP id C97C413C467; Wed, 28 Nov 2007 04:37:06 +0000 (UTC) (envelope-from wxs@atarininja.org) Received: by syn.atarininja.org (Postfix, from userid 1001) id 3533D5C2E; Tue, 27 Nov 2007 23:21:52 -0500 (EST) Date: Tue, 27 Nov 2007 23:21:52 -0500 From: Wesley Shields To: Robert Watson Message-ID: <20071128042152.GB95446@atarininja.org> References: <20071127171228.N94692@fledge.watson.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20071127171228.N94692@fledge.watson.org> User-Agent: Mutt/1.5.16 (2007-06-09) Cc: hackers@FreeBSD.org Subject: Re: Updated procstat(1) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Nov 2007 04:37:07 -0000 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. wxs@ack /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