Make DDB shows right register values on 32-bit sparc64 kernels.

- define db_expr_t as int64_t.
- %gsr is 32-bit, so use db_sparc_intop.
- sync arguments with function prototype.
- ansify.
This commit is contained in:
nakayama 2008-11-25 15:41:11 +00:00
parent 4f64126fc1
commit 4cb83f9c6e
5 changed files with 52 additions and 46 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_machdep.h,v 1.25 2008/07/10 15:23:58 nakayama Exp $ */
/* $NetBSD: db_machdep.h,v 1.26 2008/11/25 15:41:11 nakayama Exp $ */
/*
* Mach Operating System
@ -41,8 +41,9 @@
#include <machine/reg.h>
/* use 64-bit types explicitly for 32-bit kernels */
typedef vaddr_t db_addr_t; /* address - unsigned */
typedef long db_expr_t; /* expression - signed */
typedef int64_t db_expr_t; /* expression - signed */
struct trapstate {
int64_t tstate;

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_disasm.c,v 1.14 2007/02/21 22:59:53 thorpej Exp $ */
/* $NetBSD: db_disasm.c,v 1.15 2008/11/25 15:41:12 nakayama Exp $ */
/*
* Copyright (c) 1994 David S. Miller, davem@nadzieja.rutgers.edu
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.14 2007/02/21 22:59:53 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.15 2008/11/25 15:41:12 nakayama Exp $");
#include <sys/param.h>
#include <machine/db_machdep.h>
@ -876,9 +876,7 @@ struct sparc_insn sparc_i[] = {
};
db_addr_t
db_disasm(loc, altfmt)
vaddr_t loc;
bool altfmt;
db_disasm(db_addr_t loc, bool altfmt)
{
struct sparc_insn* i_ptr = (struct sparc_insn *)&sparc_i;

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_interface.c,v 1.112 2008/08/08 17:09:28 skrll Exp $ */
/* $NetBSD: db_interface.c,v 1.113 2008/11/25 15:41:12 nakayama Exp $ */
/*
* Copyright (c) 1996-2002 Eduardo Horvath. All rights reserved.
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.112 2008/08/08 17:09:28 skrll Exp $");
__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.113 2008/11/25 15:41:12 nakayama Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@ -268,7 +268,7 @@ const struct db_variable db_regs[] = {
{ "f60", dbregfp(regs[60]), db_sparc_regop, 0 },
{ "f62", dbregfp(regs[62]), db_sparc_regop, 0 },
{ "fsr", dbregfp(fsr), db_sparc_regop, 0 },
{ "gsr", dbregfp(gsr), db_sparc_regop, 0 },
{ "gsr", dbregfp(gsr), db_sparc_intop, 0 },
};
const struct db_variable * const db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
@ -378,8 +378,21 @@ fill_ddb_regs_from_tf(struct trapframe64 *tf)
#endif
DDB_REGS->db_tf = *tf;
DDB_REGS->db_fr = *(struct frame64 *)
(uintptr_t)tf->tf_out[6];
#ifdef __arch64__
DDB_REGS->db_fr = *(struct frame64 *)(uintptr_t)tf->tf_out[6];
#else
{
struct frame32 *tf32 = (struct frame32 *)(uintptr_t)tf->tf_out[6];
int i;
for (i = 0; i < 8; i++)
DDB_REGS->db_fr.fr_local[i] = (uint32_t)tf32->fr_local[i];
for (i = 0; i < 6; i++)
DDB_REGS->db_fr.fr_arg[i] = (uint32_t)tf32->fr_arg[i];
DDB_REGS->db_fr.fr_fp = tf32->fr_fp;
DDB_REGS->db_fr.fr_pc = tf32->fr_pc;
}
#endif
if (fplwp) {
savefpstate(fplwp->l_md.md_fpstate);
@ -507,14 +520,11 @@ kdb_trap(int type, struct trapframe64 *tf)
* Read bytes from kernel address space for debugger.
*/
void
db_read_bytes(addr, size, data)
vaddr_t addr;
register size_t size;
register char *data;
db_read_bytes(db_addr_t addr, size_t size, char *data)
{
register char *src;
char *src;
src = (char *)addr;
src = (char *)(uintptr_t)addr;
while (size-- > 0) {
if (src >= (char *)VM_MIN_KERNEL_ADDRESS)
*data++ = probeget((paddr_t)(u_long)src++, ASI_P, 1);
@ -528,15 +538,12 @@ db_read_bytes(addr, size, data)
* Write bytes to kernel address space for debugger.
*/
void
db_write_bytes(addr, size, data)
vaddr_t addr;
register size_t size;
register const char *data;
db_write_bytes(db_addr_t addr, size_t size, const char *data)
{
register char *dst;
char *dst;
extern paddr_t pmap_kextract(vaddr_t va);
dst = (char *)addr;
dst = (char *)(uintptr_t)addr;
while (size-- > 0) {
if ((dst >= (char *)VM_MIN_KERNEL_ADDRESS+0x400000))
*dst = *data;
@ -611,7 +618,7 @@ db_pload_cmd(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
while (count--) {
if (db_print_position() == 0) {
/* Always print the address. */
db_printf("%16.16lx:\t", addr);
db_printf("%16.16lx:\t", (long)addr);
}
oldaddr=addr;
db_printf("%8.8lx\n", (long)ldxa(addr, asi));
@ -680,11 +687,11 @@ db_pmap_kernel(db_expr_t addr, bool have_addr, db_expr_t count, const char *modi
if ((data = pseg_get(&kernel_pmap_, (vaddr_t)addr))) {
db_printf("pmap_kernel(%p)->pm_segs[%lx][%lx][%lx]=>%qx\n",
(void *)addr, (u_long)va_to_seg(addr),
(void *)(uintptr_t)addr, (u_long)va_to_seg(addr),
(u_long)va_to_dir(addr), (u_long)va_to_pte(addr),
(unsigned long long)data);
} else {
db_printf("No mapping for %p\n", (void *)addr);
db_printf("No mapping for %p\n", (void *)(uintptr_t)addr);
}
return;
}
@ -712,7 +719,7 @@ db_pm_extract(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif
if (pmap_extract(pmap_kernel(), addr, &pa))
db_printf("pa = %llx\n", (long long)pa);
else
db_printf("%p not found\n", (void *)addr);
db_printf("%p not found\n", (void *)(uintptr_t)addr);
} else
db_printf("pmap_extract: no address\n");
}
@ -734,7 +741,7 @@ db_pmap_cmd(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
if (curlwp && curlwp->l_proc->p_vmspace)
pm = curlwp->l_proc->p_vmspace->vm_map.pmap;
if (have_addr)
pm = (struct pmap*)addr;
pm = (struct pmap*)(uintptr_t)addr;
db_printf("pmap %p: ctx %x refs %d physaddr %llx psegs %p\n",
pm, pmap_ctx(pm), pm->pm_refs,
@ -817,7 +824,7 @@ db_lwp_cmd(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
l = curlwp;
if (have_addr)
l = (struct lwp*) addr;
l = (struct lwp*)(uintptr_t)addr;
if (l == NULL) {
db_printf("no current lwp\n");
return;
@ -838,7 +845,7 @@ db_proc_cmd(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
if (curlwp)
p = curlwp->l_proc;
if (have_addr)
p = (struct proc*) addr;
p = (struct proc*)(uintptr_t)addr;
if (p == NULL) {
db_printf("no current process\n");
return;
@ -889,7 +896,7 @@ db_dump_pcb(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
pcb = curpcb;
if (have_addr)
pcb = (struct pcb*) addr;
pcb = (struct pcb*)(uintptr_t)addr;
db_printf("pcb@%p sp:%p pc:%p cwp:%d pil:%d nsaved:%x onfault:%p\nlastcall:%s\nfull windows:\n",
pcb, (void *)(long)pcb->pcb_sp, (void *)(long)pcb->pcb_pc, pcb->pcb_cwp,
@ -946,7 +953,7 @@ db_setpcb(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
#endif
if (p->p_vmspace->vm_map.pmap == pmap_kernel()) {
db_printf("PID %ld has a kernel context.\n",
addr);
(long)addr);
return;
}
ctx = pmap_ctx(p->p_vmspace->vm_map.pmap);
@ -962,11 +969,11 @@ db_setpcb(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
return;
}
db_printf("could not activate pmap for PID %ld.\n",
addr);
(long)addr);
return;
}
}
db_printf("PID %ld not found.\n", addr);
db_printf("PID %ld not found.\n", (long)addr);
}
static void
@ -1162,12 +1169,12 @@ db_cpu_cmd(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
if (ci->ci_index == addr)
break;
if (ci == NULL) {
db_printf("CPU %ld not configured\n", addr);
db_printf("CPU %ld not configured\n", (long)addr);
return;
}
if (ci != curcpu()) {
if (!mp_cpu_is_paused(ci->ci_index)) {
db_printf("CPU %ld not paused\n", addr);
db_printf("CPU %ld not paused\n", (long)addr);
return;
}
/* no locking needed - all other cpus are paused */

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_trace.c,v 1.40 2008/07/02 19:49:58 rmind Exp $ */
/* $NetBSD: db_trace.c,v 1.41 2008/11/25 15:41:12 nakayama Exp $ */
/*
* Copyright (c) 1996-2002 Eduardo Horvath. All rights reserved.
@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.40 2008/07/02 19:49:58 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.41 2008/11/25 15:41:12 nakayama Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@ -87,7 +87,7 @@ db_stack_trace_print(addr, have_addr, count, modif, pr)
struct lwp *l;
struct user *u;
if (lwpaddr) {
l = (struct lwp *)addr;
l = (struct lwp *)(uintptr_t)addr;
p = l->l_proc;
(*pr)("trace: pid %d ", p->p_pid);
} else {
@ -194,7 +194,7 @@ db_dump_window(db_expr_t addr, bool have_addr, db_expr_t count, const char *modi
else frame = (uint64_t)((struct frame32 *)(u_long)frame)->fr_fp;
}
db_printf("Window %lx ", addr);
db_printf("Window %lx ", (long)addr);
db_print_window(frame);
}
@ -356,7 +356,7 @@ db_dump_trap(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
}
/* Or an arbitrary trapframe */
if (have_addr)
tf = (struct trapframe64 *)addr;
tf = (struct trapframe64 *)(uintptr_t)addr;
db_printf("Trapframe %p:\ttstate: %llx\tpc: %llx\tnpc: %llx\n",
tf, (unsigned long long)tf->tf_tstate,
@ -429,7 +429,7 @@ db_dump_fpstate(db_expr_t addr, bool have_addr, db_expr_t count, const char *mod
fpstate = DDB_FP;
/* Or an arbitrary trapframe */
if (have_addr)
fpstate = (struct fpstate64 *)addr;
fpstate = (struct fpstate64 *)(uintptr_t)addr;
db_printf("fpstate %p: fsr = %llx gsr = %lx\nfpregs:\n",
fpstate, (unsigned long long)fpstate->fs_fsr,

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_command.c,v 1.123 2008/11/25 15:14:07 ad Exp $ */
/* $NetBSD: db_command.c,v 1.124 2008/11/25 15:41:12 nakayama Exp $ */
/*
* Mach Operating System
* Copyright (c) 1991,1990 Carnegie Mellon University
@ -58,7 +58,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.123 2008/11/25 15:14:07 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.124 2008/11/25 15:41:12 nakayama Exp $");
#include "opt_aio.h"
#include "opt_ddb.h"
@ -1242,7 +1242,7 @@ db_lock_print_cmd(db_expr_t addr, bool have_addr,
db_expr_t count, const char *modif)
{
lockdebug_lock_print((void *)addr, db_printf);
lockdebug_lock_print((void *)(uintptr_t)addr, db_printf);
}
/*