Date: Wed, 4 Mar 2009 09:20:46 GMT From: Arnar Mar Sig <antab@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 158660 for review Message-ID: <200903040920.n249Kkit068143@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=158660 Change 158660 by antab@antab_farm on 2009/03/04 09:19:58 Implement whats needed for WITNESS and enable it. Affected files ... .. //depot/projects/avr32/src/sys/avr32/avr32/db_trace.c#3 edit .. //depot/projects/avr32/src/sys/avr32/avr32/stack_machdep.c#2 edit .. //depot/projects/avr32/src/sys/avr32/avr32/support.S#9 edit .. //depot/projects/avr32/src/sys/avr32/conf/NGW100#11 edit Differences ... ==== //depot/projects/avr32/src/sys/avr32/avr32/db_trace.c#3 (text+ko) ==== @@ -42,6 +42,8 @@ #include <machine/pcb.h> #include <machine/debug.h> +static void db_backtrace(struct thread *thr, struct db_frame *frame); + int db_md_set_watchpoint(db_expr_t addr, db_expr_t size) { @@ -64,25 +66,32 @@ void db_trace_self(void) { - db_trace_thread(curthread, -1); + register_t fp; + + __asm__ __volatile__("mov %0, r7" : "=r" (fp)); + db_backtrace(curthread, (struct db_frame *)fp); } int db_trace_thread(struct thread *thr, int count) { - struct db_frame *frame, head; struct pcb *ctx; + + ctx = kdb_thr_ctx(thr); + db_backtrace(thr, (struct db_frame *)ctx->pcb_regs.regs.r7); + return (0); +} + +static void +db_backtrace(struct thread *thr, struct db_frame *frame) +{ c_db_sym_t sym; const char *name; db_expr_t value; db_expr_t offset; int i; - ctx = kdb_thr_ctx(thr); i = 0; - head.lr = ctx->pcb_regs.regs.pc; - head.fp = (struct db_frame *)ctx->pcb_regs.regs.r7; - frame = &head; do { db_printf("#%-2d 0x%x in ", i++, frame->lr); @@ -99,14 +108,14 @@ frame = frame->fp; if (frame == NULL) { - return (0); + return; } } while ((vm_offset_t)frame >= thr->td_kstack && (vm_offset_t)frame <= thr->td_kstack + (KSTACK_PAGES * PAGE_SIZE)); db_printf("Frame pointer %p not in stack\n", frame); - return (0); + return; } void ==== //depot/projects/avr32/src/sys/avr32/avr32/stack_machdep.c#2 (text+ko) ==== @@ -7,7 +7,28 @@ #include <sys/proc.h> #include <sys/stack.h> #include <machine/debug.h> +#include <machine/db_machdep.h> + +static void +stack_capture(struct thread *td, struct stack *st, struct db_frame *frame) +{ + stack_zero(st); + for (; frame != NULL; frame = frame->fp) { + if ((vm_offset_t)frame < td->td_kstack && + (vm_offset_t)frame > td->td_kstack + + (KSTACK_PAGES * PAGE_SIZE)) { + break; + } + if (frame->lr == NULL) { + break; + } + if (stack_put(st, frame->lr) == -1) { + break; + } + } +} + void stack_save_td(struct stack *st, struct thread *td) { @@ -17,5 +38,12 @@ void stack_save(struct stack *st) { - avr32_impl(); + register_t fp; + + if (curthread == NULL) { + panic("stack_save: curthread == NULL"); + } + + __asm__ __volatile__("mov %0, r7" : "=r" (fp)); + stack_capture(curthread, st, (struct db_frame *)fp); } ==== //depot/projects/avr32/src/sys/avr32/avr32/support.S#9 (text+ko) ==== ==== //depot/projects/avr32/src/sys/avr32/conf/NGW100#11 (text+ko) ==== @@ -36,7 +36,7 @@ options DIAGNOSTIC options INVARIANTS #Enable calls of extra sanity checking options INVARIANT_SUPPORT #Extra sanity checks of internal structures, required by INVARIANTS -#options WITNESS #Enable checks to detect deadlocks and cycles +options WITNESS #Enable checks to detect deadlocks and cycles #options WITNESS_SKIPSPIN #Don't run witness on spinlocks for speed #options WITNESS_KDB
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903040920.n249Kkit068143>
