From owner-svn-src-projects@FreeBSD.ORG Fri Jan 8 05:53:12 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 13592106566B; Fri, 8 Jan 2010 05:53:12 +0000 (UTC) (envelope-from neel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 01DA88FC0C; Fri, 8 Jan 2010 05:53:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o085rBNw082397; Fri, 8 Jan 2010 05:53:11 GMT (envelope-from neel@svn.freebsd.org) Received: (from neel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o085rBWu082396; Fri, 8 Jan 2010 05:53:11 GMT (envelope-from neel@svn.freebsd.org) Message-Id: <201001080553.o085rBWu082396@svn.freebsd.org> From: Neel Natu Date: Fri, 8 Jan 2010 05:53:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r201770 - projects/mips/sys/mips/mips X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jan 2010 05:53:12 -0000 Author: neel Date: Fri Jan 8 05:53:11 2010 New Revision: 201770 URL: http://svn.freebsd.org/changeset/base/201770 Log: Add a DDB command "show pcb" to dump out the contents of a thread's PCB. Approved by: imp (mentor) Modified: projects/mips/sys/mips/mips/vm_machdep.c Modified: projects/mips/sys/mips/mips/vm_machdep.c ============================================================================== --- projects/mips/sys/mips/mips/vm_machdep.c Fri Jan 8 02:46:34 2010 (r201769) +++ projects/mips/sys/mips/mips/vm_machdep.c Fri Jan 8 05:53:11 2010 (r201770) @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include "opt_cputype.h" +#include "opt_ddb.h" #include #include @@ -588,3 +589,99 @@ cpu_throw(struct thread *old, struct thr func_2args_asmmacro(&mips_cpu_throw, old, new); panic("mips_cpu_throw() returned"); } + +#ifdef DDB +#include + +#define DB_PRINT_REG(ptr, regname) \ + db_printf(" %-12s 0x%lx\n", #regname, (long)((ptr)->regname)) + +#define DB_PRINT_REG_ARRAY(ptr, arrname, regname) \ + db_printf(" %-12s 0x%lx\n", #regname, (long)((ptr)->arrname[regname])) + +DB_SHOW_COMMAND(pcb, ddb_dump_pcb) +{ + struct thread *td; + struct pcb *pcb; + struct trapframe *trapframe; + + /* Determine which thread to examine. */ + if (have_addr) + td = db_lookup_thread(addr, FALSE); + else + td = curthread; + + pcb = td->td_pcb; + + db_printf("Thread %d at %p\n", td->td_tid, td); + + db_printf("PCB at %p\n", pcb); + + trapframe = &pcb->pcb_regs; + db_printf("Trapframe at %p\n", trapframe); + DB_PRINT_REG(trapframe, zero); + DB_PRINT_REG(trapframe, ast); + DB_PRINT_REG(trapframe, v0); + DB_PRINT_REG(trapframe, v1); + DB_PRINT_REG(trapframe, a0); + DB_PRINT_REG(trapframe, a1); + DB_PRINT_REG(trapframe, a2); + DB_PRINT_REG(trapframe, a3); + DB_PRINT_REG(trapframe, t0); + DB_PRINT_REG(trapframe, t1); + DB_PRINT_REG(trapframe, t2); + DB_PRINT_REG(trapframe, t3); + DB_PRINT_REG(trapframe, t4); + DB_PRINT_REG(trapframe, t5); + DB_PRINT_REG(trapframe, t6); + DB_PRINT_REG(trapframe, t7); + DB_PRINT_REG(trapframe, s0); + DB_PRINT_REG(trapframe, s1); + DB_PRINT_REG(trapframe, s2); + DB_PRINT_REG(trapframe, s3); + DB_PRINT_REG(trapframe, s4); + DB_PRINT_REG(trapframe, s5); + DB_PRINT_REG(trapframe, s6); + DB_PRINT_REG(trapframe, s7); + DB_PRINT_REG(trapframe, t8); + DB_PRINT_REG(trapframe, t9); + DB_PRINT_REG(trapframe, k0); + DB_PRINT_REG(trapframe, k1); + DB_PRINT_REG(trapframe, gp); + DB_PRINT_REG(trapframe, sp); + DB_PRINT_REG(trapframe, s8); + DB_PRINT_REG(trapframe, ra); + DB_PRINT_REG(trapframe, sr); + DB_PRINT_REG(trapframe, mullo); + DB_PRINT_REG(trapframe, mulhi); + DB_PRINT_REG(trapframe, badvaddr); + DB_PRINT_REG(trapframe, cause); + DB_PRINT_REG(trapframe, pc); + + db_printf("PCB Context:\n"); + DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_S0); + DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_S1); + DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_S2); + DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_S3); + DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_S4); + DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_S5); + DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_S6); + DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_S7); + DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_SP); + DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_S8); + DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_RA); + DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_SR); + DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_GP); + DB_PRINT_REG_ARRAY(pcb, pcb_context, PCB_REG_PC); + + db_printf("PCB onfault = %d\n", pcb->pcb_onfault); + db_printf("md_saved_intr = 0x%0lx\n", (long)td->td_md.md_saved_intr); + db_printf("md_spinlock_count = %d\n", td->td_md.md_spinlock_count); + + if (td->td_frame != trapframe) { + db_printf("td->td_frame %p is not the same as pcb_regs %p\n", + td->td_frame, trapframe); + } +} + +#endif /* DDB */