Module Name: src Committed By: nakayama Date: Fri Jul 21 20:56:10 UTC 2017
Modified Files: src/sys/arch/sparc/conf: files.sparc src/sys/arch/sparc/sparc: db_interface.c Added Files: src/sys/arch/sparc/sparc: db_machdep.c Log Message: Move the ddb registers and empty command table used for crash(8) into db_machdep.c like other archs. To generate a diff of this commit: cvs rdiff -u -r1.156 -r1.157 src/sys/arch/sparc/conf/files.sparc cvs rdiff -u -r1.93 -r1.94 src/sys/arch/sparc/sparc/db_interface.c cvs rdiff -u -r0 -r1.1 src/sys/arch/sparc/sparc/db_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/sparc/conf/files.sparc diff -u src/sys/arch/sparc/conf/files.sparc:1.156 src/sys/arch/sparc/conf/files.sparc:1.157 --- src/sys/arch/sparc/conf/files.sparc:1.156 Sat Apr 30 05:24:45 2016 +++ src/sys/arch/sparc/conf/files.sparc Fri Jul 21 20:56:10 2017 @@ -1,4 +1,4 @@ -# $NetBSD: files.sparc,v 1.156 2016/04/30 05:24:45 macallan Exp $ +# $NetBSD: files.sparc,v 1.157 2017/07/21 20:56:10 nakayama Exp $ # @(#)files.sparc 8.1 (Berkeley) 7/19/93 # sparc-specific configuration info @@ -317,6 +317,7 @@ file arch/sparc/sparc/trap.c file arch/sparc/sparc/vm_machdep.c file arch/sparc/sparc/db_interface.c ddb | kgdb +file arch/sparc/sparc/db_machdep.c ddb file arch/sparc/sparc/db_trace.c ddb file arch/sparc/sparc/db_disasm.c ddb Index: src/sys/arch/sparc/sparc/db_interface.c diff -u src/sys/arch/sparc/sparc/db_interface.c:1.93 src/sys/arch/sparc/sparc/db_interface.c:1.94 --- src/sys/arch/sparc/sparc/db_interface.c:1.93 Wed Dec 14 18:50:56 2016 +++ src/sys/arch/sparc/sparc/db_interface.c Fri Jul 21 20:56:10 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: db_interface.c,v 1.93 2016/12/14 18:50:56 mrg Exp $ */ +/* $NetBSD: db_interface.c,v 1.94 2017/07/21 20:56:10 nakayama Exp $ */ /* * Mach Operating System @@ -33,7 +33,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.93 2016/12/14 18:50:56 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.94 2017/07/21 20:56:10 nakayama Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -113,8 +113,6 @@ db_write_bytes(vaddr_t addr, size_t size } #endif -db_regs_t *ddb_regp; - #if defined(DDB) /* @@ -132,81 +130,6 @@ cpu_Debugger(void) #if defined(DDB) || defined(_KMEMUSER) -static long nil; - -/* - * Machine register set. - */ -#define dbreg(xx) (long *)offsetof(db_regs_t, db_tf.tf_ ## xx) -#define dbregfr(xx) (long *)offsetof(db_regs_t, db_fr.fr_ ## xx) - -static int db_sparc_regop(const struct db_variable *, db_expr_t *, int); - -const struct db_variable db_regs[] = { - { "psr", dbreg(psr), db_sparc_regop, NULL, }, - { "pc", dbreg(pc), db_sparc_regop, NULL, }, - { "npc", dbreg(npc), db_sparc_regop, NULL, }, - { "y", dbreg(y), db_sparc_regop, NULL, }, - { "wim", dbreg(global[0]), db_sparc_regop, NULL, }, /* see reg.h */ - { "g0", &nil, FCN_NULL, NULL, }, - { "g1", dbreg(global[1]), db_sparc_regop, NULL, }, - { "g2", dbreg(global[2]), db_sparc_regop, NULL, }, - { "g3", dbreg(global[3]), db_sparc_regop, NULL, }, - { "g4", dbreg(global[4]), db_sparc_regop, NULL, }, - { "g5", dbreg(global[5]), db_sparc_regop, NULL, }, - { "g6", dbreg(global[6]), db_sparc_regop, NULL, }, - { "g7", dbreg(global[7]), db_sparc_regop, NULL, }, - { "o0", dbreg(out[0]), db_sparc_regop, NULL, }, - { "o1", dbreg(out[1]), db_sparc_regop, NULL, }, - { "o2", dbreg(out[2]), db_sparc_regop, NULL, }, - { "o3", dbreg(out[3]), db_sparc_regop, NULL, }, - { "o4", dbreg(out[4]), db_sparc_regop, NULL, }, - { "o5", dbreg(out[5]), db_sparc_regop, NULL, }, - { "o6", dbreg(out[6]), db_sparc_regop, NULL, }, - { "o7", dbreg(out[7]), db_sparc_regop, NULL, }, - { "l0", dbregfr(local[0]), db_sparc_regop, NULL, }, - { "l1", dbregfr(local[1]), db_sparc_regop, NULL, }, - { "l2", dbregfr(local[2]), db_sparc_regop, NULL, }, - { "l3", dbregfr(local[3]), db_sparc_regop, NULL, }, - { "l4", dbregfr(local[4]), db_sparc_regop, NULL, }, - { "l5", dbregfr(local[5]), db_sparc_regop, NULL, }, - { "l6", dbregfr(local[6]), db_sparc_regop, NULL, }, - { "l7", dbregfr(local[7]), db_sparc_regop, NULL, }, - { "i0", dbregfr(arg[0]), db_sparc_regop, NULL, }, - { "i1", dbregfr(arg[1]), db_sparc_regop, NULL, }, - { "i2", dbregfr(arg[2]), db_sparc_regop, NULL, }, - { "i3", dbregfr(arg[3]), db_sparc_regop, NULL, }, - { "i4", dbregfr(arg[4]), db_sparc_regop, NULL, }, - { "i5", dbregfr(arg[5]), db_sparc_regop, NULL, }, - { "i6", dbregfr(fp), db_sparc_regop, NULL, }, - { "i7", dbregfr(pc), db_sparc_regop, NULL, }, -}; -const struct db_variable * const db_eregs = - db_regs + sizeof(db_regs)/sizeof(db_regs[0]); - -static int -db_sparc_regop (const struct db_variable *vp, db_expr_t *val, int opcode) -{ - db_expr_t *regaddr = - (db_expr_t *)(((uint8_t *)DDB_REGS) + ((size_t)vp->valuep)); - - switch (opcode) { - case DB_VAR_GET: - *val = *regaddr; - break; - case DB_VAR_SET: - *regaddr = *val; - break; - default: -#ifdef _KERNEL - panic("db_sparc_regop: unknown op %d", opcode); -#else - printf("db_sparc_regop: unknown op %d\n", opcode); -#endif - } - return 0; -} - int db_active = 0; extern char *trap_type[]; Added files: Index: src/sys/arch/sparc/sparc/db_machdep.c diff -u /dev/null src/sys/arch/sparc/sparc/db_machdep.c:1.1 --- /dev/null Fri Jul 21 20:56:10 2017 +++ src/sys/arch/sparc/sparc/db_machdep.c Fri Jul 21 20:56:10 2017 @@ -0,0 +1,128 @@ +/* $NetBSD: db_machdep.c,v 1.1 2017/07/21 20:56:10 nakayama Exp $ */ + +/* + * Mach Operating System + * Copyright (c) 1991,1990 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or software.distribut...@cs.cmu.edu + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + * + * From: db_interface.c,v 2.4 1991/02/05 17:11:13 mrt (CMU) + */ + +/* + * Interface to new debugger. + */ + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.1 2017/07/21 20:56:10 nakayama Exp $"); + +#ifdef _KERNEL_OPT +#include "opt_ddb.h" +#endif + +#include <sys/param.h> +#include <machine/db_machdep.h> +#include <ddb/db_user.h> +#include <ddb/db_command.h> +#include <ddb/db_variables.h> + +/* + * Machine register set. + */ +#define dbreg(xx) (long *)offsetof(db_regs_t, db_tf.tf_ ## xx) +#define dbregfr(xx) (long *)offsetof(db_regs_t, db_fr.fr_ ## xx) + +static int db_sparc_regop(const struct db_variable *, db_expr_t *, int); + +db_regs_t *ddb_regp; +static long nil; + +const struct db_variable db_regs[] = { + { "psr", dbreg(psr), db_sparc_regop, NULL, }, + { "pc", dbreg(pc), db_sparc_regop, NULL, }, + { "npc", dbreg(npc), db_sparc_regop, NULL, }, + { "y", dbreg(y), db_sparc_regop, NULL, }, + { "wim", dbreg(global[0]), db_sparc_regop, NULL, }, /* see reg.h */ + { "g0", &nil, FCN_NULL, NULL, }, + { "g1", dbreg(global[1]), db_sparc_regop, NULL, }, + { "g2", dbreg(global[2]), db_sparc_regop, NULL, }, + { "g3", dbreg(global[3]), db_sparc_regop, NULL, }, + { "g4", dbreg(global[4]), db_sparc_regop, NULL, }, + { "g5", dbreg(global[5]), db_sparc_regop, NULL, }, + { "g6", dbreg(global[6]), db_sparc_regop, NULL, }, + { "g7", dbreg(global[7]), db_sparc_regop, NULL, }, + { "o0", dbreg(out[0]), db_sparc_regop, NULL, }, + { "o1", dbreg(out[1]), db_sparc_regop, NULL, }, + { "o2", dbreg(out[2]), db_sparc_regop, NULL, }, + { "o3", dbreg(out[3]), db_sparc_regop, NULL, }, + { "o4", dbreg(out[4]), db_sparc_regop, NULL, }, + { "o5", dbreg(out[5]), db_sparc_regop, NULL, }, + { "o6", dbreg(out[6]), db_sparc_regop, NULL, }, + { "o7", dbreg(out[7]), db_sparc_regop, NULL, }, + { "l0", dbregfr(local[0]), db_sparc_regop, NULL, }, + { "l1", dbregfr(local[1]), db_sparc_regop, NULL, }, + { "l2", dbregfr(local[2]), db_sparc_regop, NULL, }, + { "l3", dbregfr(local[3]), db_sparc_regop, NULL, }, + { "l4", dbregfr(local[4]), db_sparc_regop, NULL, }, + { "l5", dbregfr(local[5]), db_sparc_regop, NULL, }, + { "l6", dbregfr(local[6]), db_sparc_regop, NULL, }, + { "l7", dbregfr(local[7]), db_sparc_regop, NULL, }, + { "i0", dbregfr(arg[0]), db_sparc_regop, NULL, }, + { "i1", dbregfr(arg[1]), db_sparc_regop, NULL, }, + { "i2", dbregfr(arg[2]), db_sparc_regop, NULL, }, + { "i3", dbregfr(arg[3]), db_sparc_regop, NULL, }, + { "i4", dbregfr(arg[4]), db_sparc_regop, NULL, }, + { "i5", dbregfr(arg[5]), db_sparc_regop, NULL, }, + { "i6", dbregfr(fp), db_sparc_regop, NULL, }, + { "i7", dbregfr(pc), db_sparc_regop, NULL, }, +}; +const struct db_variable * const db_eregs = + db_regs + sizeof(db_regs)/sizeof(db_regs[0]); + +static int +db_sparc_regop(const struct db_variable *vp, db_expr_t *val, int opcode) +{ + db_expr_t *regaddr = + (db_expr_t *)(((uint8_t *)DDB_REGS) + ((size_t)vp->valuep)); + + switch (opcode) { + case DB_VAR_GET: + *val = *regaddr; + break; + case DB_VAR_SET: + *regaddr = *val; + break; + default: +#ifdef _KERNEL + panic("db_sparc_regop: unknown op %d", opcode); +#else + printf("db_sparc_regop: unknown op %d\n", opcode); +#endif + } + return 0; +} + +#ifndef DDB +const struct db_command db_machine_command_table[] = { + { DDB_ADD_CMD(NULL, NULL, 0, NULL,NULL,NULL) } +}; +#endif /* DDB */