Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/ddb Unbreak db_cpu_*. Allows backtraces on i386 to prog...
details: https://anonhg.NetBSD.org/src/rev/0d9f5df74f8e
branches: trunk
changeset: 328665:0d9f5df74f8e
user: jakllsch <jakllsch%NetBSD.org@localhost>
date: Sat Apr 12 19:01:49 2014 +0000
description:
Unbreak db_cpu_*. Allows backtraces on i386 to progress beyond the
first function by not doing a NULL-deref in the debugger.
Bug located by me. Patch implementation by riastradh@. Hi rmind@.
diffstat:
sys/ddb/db_cpu.c | 34 +++++++++++++++++++++++++---------
1 files changed, 25 insertions(+), 9 deletions(-)
diffs (71 lines):
diff -r f3938fdaef2a -r 0d9f5df74f8e sys/ddb/db_cpu.c
--- a/sys/ddb/db_cpu.c Sat Apr 12 18:30:39 2014 +0000
+++ b/sys/ddb/db_cpu.c Sat Apr 12 19:01:49 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: db_cpu.c,v 1.5 2013/11/24 21:58:38 rmind Exp $ */
+/* $NetBSD: db_cpu.c,v 1.6 2014/04/12 19:01:49 jakllsch Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_cpu.c,v 1.5 2013/11/24 21:58:38 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_cpu.c,v 1.6 2014/04/12 19:01:49 jakllsch Exp $");
#ifndef _KERNEL
#include <stdbool.h>
@@ -42,23 +42,37 @@
#include <ddb/ddb.h>
-static struct cpu_info **cpu_info_addr;
+static int db_ncpu;
+static struct cpu_info **db_cpu_infos;
+
+static void
+db_cpu_init(void)
+{
+ db_expr_t addr;
+
+ db_value_of_name("ncpu", &addr);
+ db_read_bytes((db_addr_t)addr, sizeof(db_ncpu), (char *)&db_ncpu);
+
+ db_value_of_name("cpu_infos", &addr);
+ db_read_bytes((db_addr_t)addr, sizeof(db_cpu_infos),
+ (char *)&db_cpu_infos);
+}
static struct cpu_info *
-db_cpu_index(u_int idx)
+db_cpu_by_index(u_int idx)
{
- db_addr_t slot_addr = (db_addr_t)(cpu_info_addr + idx);
struct cpu_info *ci;
- db_read_bytes(slot_addr, sizeof(ci), (char *)&ci);
+ db_read_bytes((db_addr_t)&db_cpu_infos[idx], sizeof(ci), (char *)&ci);
return ci;
}
struct cpu_info *
db_cpu_first(void)
{
- db_value_of_name("cpu_infos", (db_expr_t *)&cpu_info_addr);
- return db_cpu_index(0);
+
+ db_cpu_init();
+ return db_cpu_by_index(0);
}
struct cpu_info *
@@ -67,5 +81,7 @@
u_int idx;
db_read_bytes((db_addr_t)&ci->ci_index, sizeof(idx), (char *)&idx);
- return db_cpu_index(idx + 1);
+ if ((idx + 1) >= ncpu)
+ return NULL;
+ return db_cpu_by_index(idx + 1);
}
Home |
Main Index |
Thread Index |
Old Index