| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: mips_stacktrace.c,v 1.7 2020/09/24 03:17:18 mrg Exp $ */ | | 1 | /* $NetBSD: mips_stacktrace.c,v 1.8 2021/03/29 03:09:42 simonb Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1988 University of Utah. | | 4 | * Copyright (c) 1988 University of Utah. |
5 | * Copyright (c) 1992, 1993 | | 5 | * Copyright (c) 1992, 1993 |
6 | * The Regents of the University of California. All rights reserved. | | 6 | * The Regents of the University of California. All rights reserved. |
7 | * | | 7 | * |
8 | * This code is derived from software contributed to Berkeley by | | 8 | * This code is derived from software contributed to Berkeley by |
9 | * the Systems Programming Group of the University of Utah Computer | | 9 | * the Systems Programming Group of the University of Utah Computer |
10 | * Science Department and Ralph Campbell. | | 10 | * Science Department and Ralph Campbell. |
11 | * | | 11 | * |
12 | * Redistribution and use in source and binary forms, with or without | | 12 | * Redistribution and use in source and binary forms, with or without |
13 | * modification, are permitted provided that the following conditions | | 13 | * modification, are permitted provided that the following conditions |
14 | * are met: | | 14 | * are met: |
| @@ -30,27 +30,27 @@ | | | @@ -30,27 +30,27 @@ |
30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
34 | * SUCH DAMAGE. | | 34 | * SUCH DAMAGE. |
35 | * | | 35 | * |
36 | * from: NetBSD: trap.c,v 1.255 2020/07/13 09:00:40 simonb Exp | | 36 | * from: NetBSD: trap.c,v 1.255 2020/07/13 09:00:40 simonb Exp |
37 | * from: Utah Hdr: trap.c 1.32 91/04/06 | | 37 | * from: Utah Hdr: trap.c 1.32 91/04/06 |
38 | * | | 38 | * |
39 | * @(#)trap.c 8.5 (Berkeley) 1/11/94 | | 39 | * @(#)trap.c 8.5 (Berkeley) 1/11/94 |
40 | */ | | 40 | */ |
41 | | | 41 | |
42 | #include <sys/cdefs.h> | | 42 | #include <sys/cdefs.h> |
43 | __KERNEL_RCSID(0, "$NetBSD: mips_stacktrace.c,v 1.7 2020/09/24 03:17:18 mrg Exp $"); | | 43 | __KERNEL_RCSID(0, "$NetBSD: mips_stacktrace.c,v 1.8 2021/03/29 03:09:42 simonb Exp $"); |
44 | | | 44 | |
45 | #ifdef _KERNEL_OPT | | 45 | #ifdef _KERNEL_OPT |
46 | #include "opt_ddb.h" | | 46 | #include "opt_ddb.h" |
47 | #include "opt_kgdb.h" | | 47 | #include "opt_kgdb.h" |
48 | #endif | | 48 | #endif |
49 | | | 49 | |
50 | #include <sys/param.h> | | 50 | #include <sys/param.h> |
51 | #include <sys/systm.h> | | 51 | #include <sys/systm.h> |
52 | #include <sys/proc.h> | | 52 | #include <sys/proc.h> |
53 | | | 53 | |
54 | #include <mips/locore.h> | | 54 | #include <mips/locore.h> |
55 | #include <mips/mips_opcode.h> | | 55 | #include <mips/mips_opcode.h> |
56 | #include <mips/regnum.h> | | 56 | #include <mips/regnum.h> |
| @@ -181,47 +181,47 @@ static const struct { void *addr; const | | | @@ -181,47 +181,47 @@ static const struct { void *addr; const |
181 | Name(mips64r2_user_gen_exception), | | 181 | Name(mips64r2_user_gen_exception), |
182 | Name(mips64r2_systemcall), | | 182 | Name(mips64r2_systemcall), |
183 | Name(mips64r2_kern_intr), | | 183 | Name(mips64r2_kern_intr), |
184 | Name(mips64r2_user_intr), | | 184 | Name(mips64r2_user_intr), |
185 | #endif /* MIPS64R2 */ | | 185 | #endif /* MIPS64R2 */ |
186 | | | 186 | |
187 | Name(cpu_idle), | | 187 | Name(cpu_idle), |
188 | Name(cpu_switchto), | | 188 | Name(cpu_switchto), |
189 | #endif /* _KERNEL */ | | 189 | #endif /* _KERNEL */ |
190 | {0, 0} | | 190 | {0, 0} |
191 | }; | | 191 | }; |
192 | | | 192 | |
193 | | | 193 | |
194 | static bool | | 194 | bool |
195 | kdbpeek(vaddr_t addr, unsigned *valp) | | 195 | kdbpeek(vaddr_t addr, unsigned *valp) |
196 | { | | 196 | { |
197 | if (addr & 3) { | | 197 | if (addr & 3) { |
198 | printf("kdbpeek: unaligned address %#"PRIxVADDR"\n", addr); | | 198 | printf("kdbpeek: unaligned address %#"PRIxVADDR"\n", addr); |
199 | /* We might have been called from DDB, so do not go there. */ | | 199 | /* We might have been called from DDB, so do not go there. */ |
200 | return false; | | 200 | return false; |
201 | } else if (addr == 0) { | | 201 | } else if (addr == 0) { |
202 | printf("kdbpeek: NULL\n"); | | 202 | printf("kdbpeek: NULL\n"); |
203 | return false; | | 203 | return false; |
204 | } else { | | 204 | } else { |
205 | #if _KERNEL | | 205 | #if _KERNEL |
206 | *valp = *(unsigned *)addr; | | 206 | *valp = *(unsigned *)addr; |
207 | #else | | 207 | #else |
208 | db_read_bytes((db_addr_t)addr, sizeof(unsigned), (char *)valp); | | 208 | db_read_bytes((db_addr_t)addr, sizeof(unsigned), (char *)valp); |
209 | #endif | | 209 | #endif |
210 | return true; | | 210 | return true; |
211 | } | | 211 | } |
212 | } | | 212 | } |
213 | | | 213 | |
214 | static mips_reg_t | | 214 | mips_reg_t |
215 | kdbrpeek(vaddr_t addr, size_t n) | | 215 | kdbrpeek(vaddr_t addr, size_t n) |
216 | { | | 216 | { |
217 | mips_reg_t rc = 0; | | 217 | mips_reg_t rc = 0; |
218 | | | 218 | |
219 | if (addr & (n - 1)) { | | 219 | if (addr & (n - 1)) { |
220 | printf("kdbrpeek: unaligned address %#"PRIxVADDR"\n", addr); | | 220 | printf("kdbrpeek: unaligned address %#"PRIxVADDR"\n", addr); |
221 | #if _KERNEL | | 221 | #if _KERNEL |
222 | /* We might have been called from DDB, so do not go there. */ | | 222 | /* We might have been called from DDB, so do not go there. */ |
223 | stacktrace(); | | 223 | stacktrace(); |
224 | #endif | | 224 | #endif |
225 | rc = -1; | | 225 | rc = -1; |
226 | } else if (addr == 0) { | | 226 | } else if (addr == 0) { |
227 | printf("kdbrpeek: NULL\n"); | | 227 | printf("kdbrpeek: NULL\n"); |