From owner-p4-projects@FreeBSD.ORG Wed Mar 4 09:20:47 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 201171065673; Wed, 4 Mar 2009 09:20:47 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CE31E1065670 for ; Wed, 4 Mar 2009 09:20:46 +0000 (UTC) (envelope-from antab@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id BBFB28FC17 for ; Wed, 4 Mar 2009 09:20:46 +0000 (UTC) (envelope-from antab@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n249Kkpe068145 for ; Wed, 4 Mar 2009 09:20:46 GMT (envelope-from antab@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n249Kkit068143 for perforce@freebsd.org; Wed, 4 Mar 2009 09:20:46 GMT (envelope-from antab@FreeBSD.org) Date: Wed, 4 Mar 2009 09:20:46 GMT Message-Id: <200903040920.n249Kkit068143@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to antab@FreeBSD.org using -f From: Arnar Mar Sig To: Perforce Change Reviews Cc: Subject: PERFORCE change 158660 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Mar 2009 09:20:48 -0000 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 #include +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 #include #include +#include + +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