12 #include <linux/string.h>
13 #include <linux/kernel.h>
18 #include <linux/sched.h>
32 static char *kdb_rwtypes[] = {
34 "Instruction(Register)",
40 static char *kdb_bptype(
kdb_bp_t *bp)
45 return kdb_rwtypes[bp->
bp_type];
48 static int kdb_parsebp(
int argc,
const char **argv,
int *nextargp,
kdb_bp_t *bp)
50 int nextarg = *nextargp;
54 if ((argc + 1) != nextarg) {
55 if (
strnicmp(argv[nextarg],
"datar",
sizeof(
"datar")) == 0)
56 bp->
bp_type = BP_ACCESS_WATCHPOINT;
57 else if (
strnicmp(argv[nextarg],
"dataw",
sizeof(
"dataw")) == 0)
58 bp->
bp_type = BP_WRITE_WATCHPOINT;
59 else if (
strnicmp(argv[nextarg],
"inst",
sizeof(
"inst")) == 0)
60 bp->
bp_type = BP_HARDWARE_BREAKPOINT;
68 if ((argc + 1) != nextarg) {
84 if ((argc + 1) != nextarg)
92 static int _kdb_bp_remove(
kdb_bp_t *bp)
116 kdb_setsinglestep(regs);
142 kdb_handle_bp(regs, bp);
154 kdb_printf(
"%s: failed to set breakpoint at 0x%lx\n",
156 #ifdef CONFIG_DEBUG_RODATA
158 kdb_printf(
"Software breakpoints are unavailable.\n"
159 " Change the kernel CONFIG_DEBUG_RODATA=n\n"
160 " OR use hw breaks: help bph\n");
188 _kdb_bp_install(regs, bp);
240 static void kdb_printbp(
kdb_bp_t *bp,
int i)
251 kdb_printf(
"\taddr at %016lx, hardtype=%d installed=%d\n",
279 static int kdb_bp(
int argc,
const char **argv)
284 char *symname =
NULL;
293 for (bpno = 0, bp = kdb_breakpoints; bpno <
KDB_MAXBPT;
297 kdb_printbp(bp, bpno);
304 diag =
kdbgetaddrarg(argc, argv, &nextarg, &
template.bp_addr,
308 if (!
template.bp_addr)
314 for (bpno = 0, bp = kdb_breakpoints; bpno <
KDB_MAXBPT; bpno++, bp++) {
319 if (bpno == KDB_MAXBPT)
320 return KDB_TOOMANYBPT;
322 if (
strcmp(argv[0],
"bph") == 0) {
323 template.bp_type = BP_HARDWARE_BREAKPOINT;
324 diag = kdb_parsebp(argc, argv, &nextarg, &
template);
328 template.bp_type = BP_BREAKPOINT;
337 for (i = 0, bp_check = kdb_breakpoints; i <
KDB_MAXBPT;
340 bp_check->
bp_addr ==
template.bp_addr) {
341 kdb_printf(
"You already have a breakpoint at "
342 kdb_bfd_vma_fmt0
"\n",
template.bp_addr);
347 template.bp_enabled = 1;
355 kdb_printbp(bp, bpno);
379 static int kdb_bc(
int argc,
const char **argv)
394 if (
strcmp(argv[0],
"be") == 0)
396 else if (
strcmp(argv[0],
"bd") == 0)
404 if (
strcmp(argv[1],
"*") == 0) {
416 if (addr < KDB_MAXBPT) {
417 bp = &kdb_breakpoints[
addr];
418 lowbp = highbp =
addr;
421 for (i = 0, bp = kdb_breakpoints; i <
KDB_MAXBPT;
436 for (bp = &kdb_breakpoints[lowbp], i = lowbp;
449 kdb_bfd_vma_fmt
" cleared\n",
460 kdb_bfd_vma_fmt
" enabled",
472 kdb_bfd_vma_fmt
" disabled\n",
477 if (bp->
bp_delay && (cmd == KDBCMD_BC || cmd == KDBCMD_BD)) {
483 return (!done) ? KDB_BPTNOTFOUND : 0;
515 static int kdb_ss(
int argc,
const char **argv)
519 ssb = (
strcmp(argv[0],
"ssb") == 0);
543 memset(&kdb_breakpoints,
'\0',
sizeof(kdb_breakpoints));
545 for (i = 0, bp = kdb_breakpoints; i <
KDB_MAXBPT; i++, bp++)