Re: Updated procstat(1)



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
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • using -ftracer stops buildworld at shutdown.c
    ... When the C runtime executes a longjmp, the flow of control passes back ... In the process, the stack (which ... prevented from being optimized by declaring them as volatile. ... *** Error code 1 ...
    (freebsd-hackers)
  • Re: Clear Stack
    ... To unwind the stack, just raise an exception that's handled by a procedure ... Reserve a dedicated error code for this ... In all your local error handlers, test for this explicit error code. ... That reserved error code will eventually find its way to your root ...
    (microsoft.public.vb.general.discussion)
  • Re: integer pthread_t vs. DCE threads
    ... that the stack is difficult to impossible to sensibly virtualize and ... the library needs to put down ... This is one of the problems with globals. ... replaced with a meaningless error code. ...
    (comp.programming.threads)
  • Re: LAM/MPI MPICH-2 Compatibility
    ... Here is the error code that I have obtained: ... which says that, for example, the first "process is dead" message ... consistent with the messages about call stack, ...
    (comp.parallel.mpi)
  • Re: is there a way to do this...
    ... I don't have a complete code of your error code, ... int main ... void change ... Prev by Date: ...
    (comp.lang.c)