From owner-p4-projects@FreeBSD.ORG Sun Mar 21 21:15:56 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id AF5BC16A4D0; Sun, 21 Mar 2004 21:15:55 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 87AE216A4CE for ; Sun, 21 Mar 2004 21:15:55 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7E1D243D41 for ; Sun, 21 Mar 2004 21:15:55 -0800 (PST) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.10/8.12.10) with ESMTP id i2M5FtGe024282 for ; Sun, 21 Mar 2004 21:15:55 -0800 (PST) (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id i2M5FsCe024279 for perforce@freebsd.org; Sun, 21 Mar 2004 21:15:54 -0800 (PST) (envelope-from marcel@freebsd.org) Date: Sun, 21 Mar 2004 21:15:54 -0800 (PST) Message-Id: <200403220515.i2M5FsCe024279@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Subject: PERFORCE change 49512 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Mar 2004 05:15:56 -0000 http://perforce.freebsd.org/chv.cgi?CH=49512 Change 49512 by marcel@marcel_nfs on 2004/03/21 21:14:57 Make alpha compile. With this commit we have a kdb frontend and ddb and gdb backends. The structure seems to be right, but things don't work. Some but not all of the "#ifdef DDB" have been replaced, so we need to clean that up further. In short: in between the mess, there's something that looks like a structure. Note that amd64 has been put on the side for now. Once I have alpha, i386, ia64 and sparc64 in a fairly good shape, code will be stabilized. This means that I can more effectively work on amd64, because I need someone to help with testing. I think it's about time I'll make the debuggers thread aware. The approach I'm going to go for is to create a kdb_thread variable and use that as as the context. MD code can get to the trapframe and PCB by dereferencing kdb_thread. On SMP machines this also works well, because stopped CPUs only have to save the current context in the PCB. Once I've got that working with gdb(1), I should have a better picture of what we need from the MD code. This is also the time to flesh out the MD code and get to a point where the debugger is actually working. From there is all about the details... Affected files ... .. //depot/projects/gdb/sys/alpha/alpha/db_interface.c#4 edit .. //depot/projects/gdb/sys/alpha/alpha/machdep.c#5 edit Differences ... ==== //depot/projects/gdb/sys/alpha/alpha/db_interface.c#4 (text+ko) ==== @@ -78,18 +78,6 @@ static jmp_buf *db_nofault = 0; extern jmp_buf db_jmpbuf; -extern void gdb_handle_exception(db_regs_t *, int, int); - -#if 0 -extern char *trap_type[]; -extern int trap_types; -#endif - -int db_active; - -void ddbprinttrap(unsigned long, unsigned long, unsigned long, - unsigned long); - struct db_variable db_regs[] = { { "v0", &ddb_regs.tf_regs[FRAME_V0], FCN_NULL }, { "t0", &ddb_regs.tf_regs[FRAME_T0], FCN_NULL }, @@ -129,104 +117,10 @@ }; struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]); -/* - * Print trap reason. - */ void -ddbprinttrap(a0, a1, a2, entry) - unsigned long a0, a1, a2, entry; -{ - - /* XXX Implement. */ - - printf("ddbprinttrap(0x%lx, 0x%lx, 0x%lx, 0x%lx)\n", a0, a1, a2, - entry); -} - -#if 0 -/* - * ddb_trap - field a kernel trap - */ -int -ddb_trap(a0, a1, a2, entry, regs) - unsigned long a0, a1, a2, entry; - db_regs_t *regs; +db_cpu_trap(int entry, int code, struct trapframe *tf) { - int ddb_mode = !(boothowto & RB_GDB); - register_t s; - - /* - * Don't bother checking for usermode, since a benign entry - * by the kernel (call to kdb_enter() or a breakpoint) has - * already checked for usermode. If neither of those - * conditions exist, something Bad has happened. - */ - - if (entry != ALPHA_KENTRY_IF || - (a0 != ALPHA_IF_CODE_BUGCHK && a0 != ALPHA_IF_CODE_BPT - && a0 != ALPHA_IF_CODE_GENTRAP)) { -#if 0 - if (ddb_mode) { - db_printf("ddbprinttrap from 0x%lx\n", /* XXX */ - regs->tf_regs[FRAME_PC]); - ddbprinttrap(a0, a1, a2, entry); - /* - * Tell caller "We did NOT handle the trap." - * Caller should panic, or whatever. - */ - return (0); - } -#endif - if (db_nofault) { - jmp_buf *no_fault = db_nofault; - db_nofault = 0; - longjmp(*no_fault, 1); - } - } - - /* - * XXX Should switch to DDB's own stack, here. - */ - - ddb_regs = *regs; - - s = intr_disable(); - -#ifdef SMP -#ifdef DIAGNOSTIC - db_printf("stopping %x\n", PCPU_GET(other_cpus)); -#endif - stop_cpus(PCPU_GET(other_cpus)); -#ifdef DIAGNOSTIC - db_printf("stopped_cpus=%x\n", stopped_cpus); -#endif -#endif - - db_active++; - - if (ddb_mode) { - cndbctl(TRUE); /* DDB active, unblank video */ - db_trap(entry, a0); /* Where the work happens */ - cndbctl(FALSE); /* DDB inactive */ - } else - gdb_handle_exception(&ddb_regs, entry, a0); - - db_active--; - -#ifdef SMP - restart_cpus(stopped_cpus); -#endif - - intr_restore(s); - - *regs = ddb_regs; - - /* - * Tell caller "We HAVE handled the trap." - */ - return (1); } -#endif /* * Read bytes from kernel address space for debugger. ==== //depot/projects/gdb/sys/alpha/alpha/machdep.c#5 (text+ko) ==== @@ -91,7 +91,6 @@ __FBSDID("$FreeBSD: src/sys/alpha/alpha/machdep.c,v 1.218 2004/03/01 19:19:15 kensmith Exp $"); #include "opt_compat.h" -#include "opt_ddb.h" #include "opt_kstack_pages.h" #include "opt_msgbuf.h" #include "opt_maxmem.h" @@ -146,7 +145,6 @@ #include #include #include -#include #include #include #include @@ -170,10 +168,9 @@ static char cpu_model[128]; SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD, cpu_model, 0, ""); -#ifdef DDB +#ifdef KDB /* start and end of kernel symbol table */ void *ksym_start, *ksym_end; -db_regs_t ddb_regs; #endif int alpha_unaligned_print = 1; /* warn about unaligned accesses */ @@ -607,7 +604,7 @@ * stack). */ kernstart = trunc_page(kernel_text) - 2 * PAGE_SIZE; -#ifdef DDB +#ifdef KDB ksym_start = (void *)bootinfo.ssym; ksym_end = (void *)bootinfo.esym; kernend = (vm_offset_t)round_page(ksym_end); @@ -957,7 +954,6 @@ break; #endif -#if defined(DDB) case 'd': /* break into the kernel debugger ASAP */ case 'D': boothowto |= RB_KDB; @@ -966,7 +962,6 @@ case 'G': boothowto |= RB_GDB; break; -#endif case 'h': /* always halt, never reboot */ case 'H':