#include <stdbool.h>
#include <stdint.h>
#include <sys/kassert.h>
#include <sys/kconfig.h>
#include <sys/kdebug.h>
#include <sys/mp.h>
#include <machine/amd64.h>
#include <machine/amd64op.h>
#include <machine/atomic.h>
#include <machine/trap.h>
#include <machine/lapic.h>
#include <machine/mp.h>
Go to the source code of this file.
|
void | Debug_HaltCPUs () |
|
void | Debug_ResumeCPUs () |
|
void | Debug_HaltIPI (TrapFrame *tf) |
|
void | Debug_Breakpoint (TrapFrame *tf) |
|
static void | Debug_Registers (int argc, const char *argv[]) |
|
| REGISTER_DBGCMD (registers, "Show CPU registers", Debug_Registers) |
|
static void | Debug_Backtrace (int argc, const char *argv[]) |
|
| REGISTER_DBGCMD (backtrace, "Print backtrace", Debug_Backtrace) |
|
static void | Debug_SetBreakpoint (int argc, const char *argv[]) |
|
| REGISTER_DBGCMD (bkpt, "Set breakpoint", Debug_SetBreakpoint) |
|
static void | Debug_ClearBreakpoint (int argc, const char *argv[]) |
|
| REGISTER_DBGCMD (clrbkpt, "Clear breakpoint", Debug_ClearBreakpoint) |
|
static void | Debug_ListBreakpoints (int argc, const char *argv[]) |
|
| REGISTER_DBGCMD (bkpts, "List breakpoint", Debug_ListBreakpoints) |
|
static void | Debug_Reboot (int argc, const char *argv[]) |
|
| REGISTER_DBGCMD (reboot, "Reboot computer", Debug_Reboot) |
|
◆ Debug_Backtrace()
static void Debug_Backtrace |
( |
int |
argc, |
|
|
const char * |
argv[] |
|
) |
| |
|
static |
Definition at line 130 of file debug.c.
131{
136
137 if (argc == 2) {
140 kprintf(
"Invalid CPU number\n");
141 return;
142 }
144 }
145
148
149 kprintf(
"%-16s %-16s\n",
"IP Pointer",
"Base Pointer");
150 while (3) {
151 kprintf(
"%016llx %016llx\n", rip, rbp);
153 if (rbp == 0ULL || rip == 0ULL) {
154 break;
155 }
156 rbp = ptr[0];
157 rip = ptr[1];
158 }
159}
TrapFrame * frames[MAX_CPUS]
int kprintf(const char *fmt,...)
uint64_t Debug_StrToInt(const char *s)
◆ Debug_Breakpoint()
Definition at line 67 of file debug.c.
68{
70
71
73
74 }
75
76
78
79
81
82
85}
static volatile uint64_t debugLock
static INLINE uint64_t atomic_swap_uint64(volatile uint64_t *dst, uint64_t newval)
static void atomic_set_uint64(volatile uint64_t *dst, uint64_t newval)
◆ Debug_ClearBreakpoint()
static void Debug_ClearBreakpoint |
( |
int |
argc, |
|
|
const char * |
argv[] |
|
) |
| |
|
static |
Definition at line 195 of file debug.c.
196{
197 if (argc != 2) {
199 return;
200 }
201
203 switch (argv[1][0]) {
204 case '0':
205 flags &= ~DR7_DR0G;
206 break;
207 case '1':
208 flags &= ~DR7_DR1G;
209 break;
210 case '2':
211 flags &= ~DR7_DR2G;
212 break;
213 case '3':
214 flags &= ~DR7_DR3G;
215 break;
216 default:
217 kprintf(
"Specify a breakpoint between 0-3\n");
218 }
219
221}
static INLINE void write_dr7(uint64_t val)
static INLINE uint64_t read_dr7()
◆ Debug_HaltCPUs()
Definition at line 24 of file debug.c.
25{
27
29 return;
30
32
33
36 }
37}
static volatile uint64_t debugCmd
static volatile uint64_t debugHalted
static INLINE void pause()
int LAPIC_BroadcastNMI(int vector)
◆ Debug_HaltIPI()
Definition at line 51 of file debug.c.
52{
55
57
60 }
61
64}
void MP_SetState(int state)
◆ Debug_ListBreakpoints()
static void Debug_ListBreakpoints |
( |
int |
argc, |
|
|
const char * |
argv[] |
|
) |
| |
|
static |
Definition at line 226 of file debug.c.
227{
229
232 }
235 }
238 }
241 }
242}
static INLINE uint64_t read_dr1()
static INLINE uint64_t read_dr3()
static INLINE uint64_t read_dr0()
static INLINE uint64_t read_dr2()
◆ Debug_Reboot()
static void Debug_Reboot |
( |
int |
argc, |
|
|
const char * |
argv[] |
|
) |
| |
|
static |
Definition at line 247 of file debug.c.
248{
249
250
251
252
254}
static INLINE void write_cr3(uint64_t val)
◆ Debug_Registers()
static void Debug_Registers |
( |
int |
argc, |
|
|
const char * |
argv[] |
|
) |
| |
|
static |
Definition at line 88 of file debug.c.
89{
91
92 if (argc == 2) {
95 kprintf(
"Invalid CPU number\n");
96 return;
97 }
99 }
100
101 kprintf(
"Interrupt %d Error Code: %016llx\n",
103 kprintf(
"cr0: %016llx cr2: %016llx\n",
105 kprintf(
"cr3: %016llx cr4: %016llx\n",
107 kprintf(
"dr0: %016llx dr1: %016llx dr2: %016llx\n",
109 kprintf(
"dr3: %016llx dr6: %016llx dr7: %016llx\n",
111 kprintf(
"rip: %04x:%016llx rsp: %04x:%016llx\n",
113 kprintf(
"rflags: %016llx ds: %04x es: %04x fs: %04x gs: %04x\n",
115 kprintf(
"rax: %016llx rbx: %016llx rcx: %016llx\n",
117 kprintf(
"rdx: %016llx rsi: %016llx rdi: %016llx\n",
119 kprintf(
"rbp: %016llx r8: %016llx r9: %016llx\n",
121 kprintf(
"r10: %016llx r11: %016llx r12: %016llx\n",
123 kprintf(
"r13: %016llx r14: %016llx r15: %016llx\n",
125}
static INLINE uint16_t read_es()
static INLINE uint16_t read_ds()
static INLINE uint64_t read_cr2()
static INLINE uint16_t read_fs()
static INLINE uint64_t read_cr3()
static INLINE uint64_t read_dr6()
static INLINE uint16_t read_gs()
static INLINE uint64_t read_cr4()
static INLINE uint64_t read_cr0()
◆ Debug_ResumeCPUs()
void Debug_ResumeCPUs |
( |
| ) |
|
◆ Debug_SetBreakpoint()
static void Debug_SetBreakpoint |
( |
int |
argc, |
|
|
const char * |
argv[] |
|
) |
| |
|
static |
Definition at line 164 of file debug.c.
165{
166 if (argc != 2) {
168 return;
169 }
170
172
174
187 } else {
188 kprintf(
"No more breakpoints left!\n");
189 }
190}
static INLINE void write_dr0(uint64_t val)
static INLINE void write_dr1(uint64_t val)
static INLINE void write_dr2(uint64_t val)
static INLINE void write_dr3(uint64_t val)
◆ REGISTER_DBGCMD() [1/6]
◆ REGISTER_DBGCMD() [2/6]
◆ REGISTER_DBGCMD() [3/6]
◆ REGISTER_DBGCMD() [4/6]
◆ REGISTER_DBGCMD() [5/6]
REGISTER_DBGCMD |
( |
reboot |
, |
|
|
"Reboot computer" |
, |
|
|
Debug_Reboot |
|
|
) |
| |
◆ REGISTER_DBGCMD() [6/6]
◆ debugCmd
◆ debugHalted
◆ debugLock
◆ frames