Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/mips Allow kdbpeek() to return failure. If it does, ...
details: https://anonhg.NetBSD.org/src/rev/af747ad159f6
branches: trunk
changeset: 359385:af747ad159f6
user: bouyer <bouyer%NetBSD.org@localhost>
date: Thu Feb 08 19:16:24 2018 +0000
description:
Allow kdbpeek() to return failure. If it does, stop the stack trace.
Prevents an infinite loop in ddb if something goes wrong.
diffstat:
sys/arch/mips/include/locore.h | 4 ++--
sys/arch/mips/mips/db_interface.c | 13 +++++++------
sys/arch/mips/mips/trap.c | 34 +++++++++++++++++++---------------
3 files changed, 28 insertions(+), 23 deletions(-)
diffs (147 lines):
diff -r 8e9dd530c2c7 -r af747ad159f6 sys/arch/mips/include/locore.h
--- a/sys/arch/mips/include/locore.h Thu Feb 08 18:58:59 2018 +0000
+++ b/sys/arch/mips/include/locore.h Thu Feb 08 19:16:24 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.h,v 1.102 2017/03/16 16:13:20 chs Exp $ */
+/* $NetBSD: locore.h,v 1.103 2018/02/08 19:16:24 bouyer Exp $ */
/*
* This file should not be included by MI code!!!
@@ -723,7 +723,7 @@
/* trap.c */
void netintr(void);
-int kdbpeek(vaddr_t);
+bool kdbpeek(vaddr_t, int *);
/* mips_dsp.c */
void dsp_init(void);
diff -r 8e9dd530c2c7 -r af747ad159f6 sys/arch/mips/mips/db_interface.c
--- a/sys/arch/mips/mips/db_interface.c Thu Feb 08 18:58:59 2018 +0000
+++ b/sys/arch/mips/mips/db_interface.c Thu Feb 08 19:16:24 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: db_interface.c,v 1.79 2016/07/11 16:15:36 matt Exp $ */
+/* $NetBSD: db_interface.c,v 1.80 2018/02/08 19:16:24 bouyer Exp $ */
/*
* Mach Operating System
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.79 2016/07/11 16:15:36 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.80 2018/02/08 19:16:24 bouyer Exp $");
#include "opt_multiprocessor.h"
#include "opt_cputype.h" /* which mips CPUs do we support? */
@@ -96,13 +96,14 @@
CTASSERT(sizeof(ddb_regs) == sizeof(struct reg));
#ifdef DDB_TRACE
-int
-kdbpeek(vaddr_t addr)
+bool
+kdbpeek(vaddr_t addr, int *valp)
{
if (addr == 0 || (addr & 3))
- return 0;
- return *(int *)addr;
+ return false;
+ *valp = *(int *)addr;
+ return true;
}
#endif
diff -r 8e9dd530c2c7 -r af747ad159f6 sys/arch/mips/mips/trap.c
--- a/sys/arch/mips/mips/trap.c Thu Feb 08 18:58:59 2018 +0000
+++ b/sys/arch/mips/mips/trap.c Thu Feb 08 19:16:24 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: trap.c,v 1.245 2017/12/22 22:59:25 maya Exp $ */
+/* $NetBSD: trap.c,v 1.246 2018/02/08 19:16:24 bouyer Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.245 2017/12/22 22:59:25 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.246 2018/02/08 19:16:24 bouyer Exp $");
#include "opt_cputype.h" /* which mips CPU levels do we support? */
#include "opt_ddb.h"
@@ -748,23 +748,20 @@
#if defined(DEBUG) || defined(DDB) || defined(KGDB) || defined(geo)
mips_reg_t kdbrpeek(vaddr_t, size_t);
-int
-kdbpeek(vaddr_t addr)
+bool
+kdbpeek(vaddr_t addr, int *valp)
{
- int rc;
-
if (addr & 3) {
printf("kdbpeek: unaligned address %#"PRIxVADDR"\n", addr);
/* We might have been called from DDB, so do not go there. */
- stacktrace();
- rc = -1 ;
+ return false;
} else if (addr == 0) {
printf("kdbpeek: NULL\n");
- rc = 0xdeadfeed;
+ return false;
} else {
- rc = *(int *)addr;
+ *valp = *(int *)addr;
+ return true;
}
- return rc;
}
mips_reg_t
@@ -909,7 +906,8 @@
sym = db_search_symbol(pc, DB_STGY_ANY, &diff);
if (sym != DB_SYM_NULL && diff == 0) {
/* check func(foo) __attribute__((__noreturn__)) case */
- instr = kdbpeek(pc - 2 * sizeof(int));
+ if (!kdbpeek(pc - 2 * sizeof(int), &instr))
+ return;
i.word = instr;
if (i.JType.op == OP_JAL) {
sym = db_search_symbol(pc - sizeof(int),
@@ -937,7 +935,8 @@
va -= sizeof(int);
if (va <= (vaddr_t)verylocore)
goto finish;
- instr = kdbpeek(va);
+ if (!kdbpeek(va, &instr))
+ return;
if (instr == MIPS_ERET)
goto mips3_eret;
} while (instr != MIPS_JR_RA && instr != MIPS_JR_K0);
@@ -946,8 +945,12 @@
mips3_eret:
va += sizeof(int);
/* skip over nulls which might separate .o files */
- while ((instr = kdbpeek(va)) == 0)
+ instr = 0;
+ while (instr == 0) {
+ if (!kdbpeek(va, &instr))
+ return;
va += sizeof(int);
+ }
#endif
subr = va;
@@ -961,7 +964,8 @@
/* stop if hit our current position */
if (va >= pc)
break;
- instr = kdbpeek(va);
+ if (!kdbpeek(va, &instr))
+ return;
i.word = instr;
switch (i.JType.op) {
case OP_SPECIAL:
Home |
Main Index |
Thread Index |
Old Index