2 * Copyright (c) 2015 The FreeBSD Foundation
5 * This software was developed by Semihalf under
6 * the sponsorship of the FreeBSD Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #include <sys/cdefs.h>
31 __FBSDID("$FreeBSD$");
32 #include <sys/param.h>
36 #include <vm/vm_map.h>
43 #include <ddb/db_variables.h>
45 #include <machine/cpu.h>
46 #include <machine/pcb.h>
47 #include <machine/stack.h>
48 #include <machine/vmparam.h>
51 db_frame(struct db_variable *vp, db_expr_t *valuep, int op)
55 if (kdb_frame == NULL)
58 reg = (long *)((uintptr_t)kdb_frame + (db_expr_t)vp->valuep);
66 #define DB_OFFSET(x) (db_expr_t *)offsetof(struct trapframe, x)
67 struct db_variable db_regs[] = {
68 { "ra", DB_OFFSET(tf_ra), db_frame },
69 { "sp", DB_OFFSET(tf_sp), db_frame },
70 { "gp", DB_OFFSET(tf_gp), db_frame },
71 { "tp", DB_OFFSET(tf_tp), db_frame },
72 { "t0", DB_OFFSET(tf_t[0]), db_frame },
73 { "t1", DB_OFFSET(tf_t[1]), db_frame },
74 { "t2", DB_OFFSET(tf_t[2]), db_frame },
75 { "t3", DB_OFFSET(tf_t[3]), db_frame },
76 { "t4", DB_OFFSET(tf_t[4]), db_frame },
77 { "t5", DB_OFFSET(tf_t[5]), db_frame },
78 { "t6", DB_OFFSET(tf_t[6]), db_frame },
79 { "s0", DB_OFFSET(tf_s[0]), db_frame },
80 { "s1", DB_OFFSET(tf_s[1]), db_frame },
81 { "s2", DB_OFFSET(tf_s[2]), db_frame },
82 { "s3", DB_OFFSET(tf_s[3]), db_frame },
83 { "s4", DB_OFFSET(tf_s[4]), db_frame },
84 { "s5", DB_OFFSET(tf_s[5]), db_frame },
85 { "s6", DB_OFFSET(tf_s[6]), db_frame },
86 { "s7", DB_OFFSET(tf_s[7]), db_frame },
87 { "s8", DB_OFFSET(tf_s[8]), db_frame },
88 { "s9", DB_OFFSET(tf_s[9]), db_frame },
89 { "s10", DB_OFFSET(tf_s[10]), db_frame },
90 { "s11", DB_OFFSET(tf_s[11]), db_frame },
91 { "a0", DB_OFFSET(tf_a[0]), db_frame },
92 { "a1", DB_OFFSET(tf_a[1]), db_frame },
93 { "a2", DB_OFFSET(tf_a[2]), db_frame },
94 { "a3", DB_OFFSET(tf_a[3]), db_frame },
95 { "a4", DB_OFFSET(tf_a[4]), db_frame },
96 { "a5", DB_OFFSET(tf_a[5]), db_frame },
97 { "a6", DB_OFFSET(tf_a[6]), db_frame },
98 { "a7", DB_OFFSET(tf_a[7]), db_frame },
99 { "sepc", DB_OFFSET(tf_sepc), db_frame },
100 { "sstatus", DB_OFFSET(tf_sstatus), db_frame },
101 { "sbadaddr", DB_OFFSET(tf_sbadaddr), db_frame },
102 { "scause", DB_OFFSET(tf_scause), db_frame },
105 struct db_variable *db_eregs = db_regs + nitems(db_regs);
108 db_show_mdpcpu(struct pcpu *pc)
113 * Read bytes from kernel address space for debugger.
116 db_read_bytes(vm_offset_t addr, size_t size, char *data)
123 prev_jb = kdb_jmpbuf(jb);
127 src = (const char *)addr;
131 (void)kdb_jmpbuf(prev_jb);
137 * Write bytes to kernel address space for debugger.
140 db_write_bytes(vm_offset_t addr, size_t size, char *data)
147 prev_jb = kdb_jmpbuf(jb);
156 /* Clean D-cache and invalidate I-cache */
157 cpu_dcache_wb_range(addr, (vm_size_t)size);
158 cpu_icache_sync_range(addr, (vm_size_t)size);
160 (void)kdb_jmpbuf(prev_jb);