[5bb8e45] | 1 | /*
|
---|
[df4ed85] | 2 | * Copyright (c) 2005 Ondrej Palkovsky
|
---|
[5bb8e45] | 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
[06e1e95] | 29 | /** @addtogroup mips32debug
|
---|
[b45c443] | 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
| 33 | */
|
---|
| 34 |
|
---|
[5bb8e45] | 35 | #include <arch/debugger.h>
|
---|
[1e1e5e1] | 36 | #include <arch/barrier.h>
|
---|
[5bb8e45] | 37 | #include <memstr.h>
|
---|
| 38 | #include <console/kconsole.h>
|
---|
| 39 | #include <console/cmd.h>
|
---|
| 40 | #include <print.h>
|
---|
| 41 | #include <panic.h>
|
---|
| 42 | #include <arch.h>
|
---|
| 43 | #include <arch/cp0.h>
|
---|
| 44 | #include <func.h>
|
---|
[e2b762ec] | 45 | #include <symtab.h>
|
---|
| 46 |
|
---|
[5bb8e45] | 47 | bpinfo_t breakpoints[BKPOINTS_MAX];
|
---|
[dc747e3] | 48 | SPINLOCK_INITIALIZE(bkpoint_lock);
|
---|
[5bb8e45] | 49 |
|
---|
[76fca31] | 50 | #ifdef CONFIG_KCONSOLE
|
---|
| 51 |
|
---|
[5bb8e45] | 52 | static int cmd_print_breakpoints(cmd_arg_t *argv);
|
---|
[0132630] | 53 | static cmd_info_t bkpts_info = {
|
---|
| 54 | .name = "bkpts",
|
---|
[5bb8e45] | 55 | .description = "Print breakpoint table.",
|
---|
| 56 | .func = cmd_print_breakpoints,
|
---|
| 57 | .argc = 0,
|
---|
| 58 | };
|
---|
| 59 |
|
---|
| 60 | static int cmd_del_breakpoint(cmd_arg_t *argv);
|
---|
| 61 | static cmd_arg_t del_argv = {
|
---|
| 62 | .type = ARG_TYPE_INT
|
---|
| 63 | };
|
---|
| 64 | static cmd_info_t delbkpt_info = {
|
---|
| 65 | .name = "delbkpt",
|
---|
| 66 | .description = "delbkpt <number> - Delete breakpoint.",
|
---|
| 67 | .func = cmd_del_breakpoint,
|
---|
| 68 | .argc = 1,
|
---|
| 69 | .argv = &del_argv
|
---|
| 70 | };
|
---|
| 71 |
|
---|
| 72 | static int cmd_add_breakpoint(cmd_arg_t *argv);
|
---|
| 73 | static cmd_arg_t add_argv = {
|
---|
| 74 | .type = ARG_TYPE_INT
|
---|
| 75 | };
|
---|
| 76 | static cmd_info_t addbkpt_info = {
|
---|
| 77 | .name = "addbkpt",
|
---|
[1e1e5e1] | 78 | .description = "addbkpt <&symbol> - new bkpoint. Break on J/Branch "
|
---|
| 79 | "insts unsupported.",
|
---|
[5bb8e45] | 80 | .func = cmd_add_breakpoint,
|
---|
| 81 | .argc = 1,
|
---|
| 82 | .argv = &add_argv
|
---|
| 83 | };
|
---|
| 84 |
|
---|
[07bd114e] | 85 | static cmd_arg_t adde_argv[] = {
|
---|
| 86 | { .type = ARG_TYPE_INT },
|
---|
| 87 | { .type = ARG_TYPE_INT }
|
---|
| 88 | };
|
---|
| 89 | static cmd_info_t addbkpte_info = {
|
---|
| 90 | .name = "addbkpte",
|
---|
[1e1e5e1] | 91 | .description = "addebkpte <&symbol> <&func> - new bkpoint. Call "
|
---|
| 92 | "func(or Nothing if 0).",
|
---|
[07bd114e] | 93 | .func = cmd_add_breakpoint,
|
---|
| 94 | .argc = 2,
|
---|
| 95 | .argv = adde_argv
|
---|
| 96 | };
|
---|
| 97 |
|
---|
| 98 | static struct {
|
---|
[7f1c620] | 99 | uint32_t andmask;
|
---|
| 100 | uint32_t value;
|
---|
[1e1e5e1] | 101 | } jmpinstr[] = {
|
---|
[07bd114e] | 102 | {0xf3ff0000, 0x41000000}, /* BCzF */
|
---|
| 103 | {0xf3ff0000, 0x41020000}, /* BCzFL */
|
---|
| 104 | {0xf3ff0000, 0x41010000}, /* BCzT */
|
---|
| 105 | {0xf3ff0000, 0x41030000}, /* BCzTL */
|
---|
| 106 | {0xfc000000, 0x10000000}, /* BEQ */
|
---|
| 107 | {0xfc000000, 0x50000000}, /* BEQL */
|
---|
| 108 | {0xfc1f0000, 0x04010000}, /* BEQL */
|
---|
| 109 | {0xfc1f0000, 0x04110000}, /* BGEZAL */
|
---|
| 110 | {0xfc1f0000, 0x04130000}, /* BGEZALL */
|
---|
| 111 | {0xfc1f0000, 0x04030000}, /* BGEZL */
|
---|
| 112 | {0xfc1f0000, 0x1c000000}, /* BGTZ */
|
---|
| 113 | {0xfc1f0000, 0x5c000000}, /* BGTZL */
|
---|
| 114 | {0xfc1f0000, 0x18000000}, /* BLEZ */
|
---|
| 115 | {0xfc1f0000, 0x58000000}, /* BLEZL */
|
---|
| 116 | {0xfc1f0000, 0x04000000}, /* BLTZ */
|
---|
| 117 | {0xfc1f0000, 0x04100000}, /* BLTZAL */
|
---|
| 118 | {0xfc1f0000, 0x04120000}, /* BLTZALL */
|
---|
| 119 | {0xfc1f0000, 0x04020000}, /* BLTZL */
|
---|
| 120 | {0xfc000000, 0x14000000}, /* BNE */
|
---|
| 121 | {0xfc000000, 0x54000000}, /* BNEL */
|
---|
| 122 | {0xfc000000, 0x08000000}, /* J */
|
---|
| 123 | {0xfc000000, 0x0c000000}, /* JAL */
|
---|
| 124 | {0xfc1f07ff, 0x00000009}, /* JALR */
|
---|
[1e1e5e1] | 125 | {0, 0} /* EndOfTable */
|
---|
[07bd114e] | 126 | };
|
---|
| 127 |
|
---|
[76fca31] | 128 |
|
---|
[07bd114e] | 129 | /** Test, if the given instruction is a jump or branch instruction
|
---|
| 130 | *
|
---|
| 131 | * @param instr Instruction code
|
---|
| 132 | * @return true - it is jump instruction, false otherwise
|
---|
[76fca31] | 133 | *
|
---|
[07bd114e] | 134 | */
|
---|
[7f1c620] | 135 | static bool is_jump(unative_t instr)
|
---|
[07bd114e] | 136 | {
|
---|
| 137 | int i;
|
---|
| 138 |
|
---|
[1e1e5e1] | 139 | for (i = 0; jmpinstr[i].andmask; i++) {
|
---|
[07bd114e] | 140 | if ((instr & jmpinstr[i].andmask) == jmpinstr[i].value)
|
---|
| 141 | return true;
|
---|
| 142 | }
|
---|
| 143 |
|
---|
| 144 | return false;
|
---|
| 145 | }
|
---|
| 146 |
|
---|
[5bb8e45] | 147 | /** Add new breakpoint to table */
|
---|
| 148 | int cmd_add_breakpoint(cmd_arg_t *argv)
|
---|
| 149 | {
|
---|
| 150 | bpinfo_t *cur = NULL;
|
---|
| 151 | ipl_t ipl;
|
---|
| 152 | int i;
|
---|
| 153 |
|
---|
| 154 | if (argv->intval & 0x3) {
|
---|
| 155 | printf("Not aligned instruction, forgot to use &symbol?\n");
|
---|
| 156 | return 1;
|
---|
| 157 | }
|
---|
| 158 | ipl = interrupts_disable();
|
---|
| 159 | spinlock_lock(&bkpoint_lock);
|
---|
| 160 |
|
---|
| 161 | /* Check, that the breakpoints do not conflict */
|
---|
[f4c2b6a] | 162 | for (i = 0; i < BKPOINTS_MAX; i++) {
|
---|
[7f1c620] | 163 | if (breakpoints[i].address == (uintptr_t)argv->intval) {
|
---|
[5bb8e45] | 164 | printf("Duplicate breakpoint %d.\n", i);
|
---|
[7f341820] | 165 | spinlock_unlock(&bkpoint_lock);
|
---|
[556f9892] | 166 | interrupts_restore(ipl);
|
---|
[5bb8e45] | 167 | return 0;
|
---|
[1e1e5e1] | 168 | } else if (breakpoints[i].address == (uintptr_t)argv->intval +
|
---|
| 169 | sizeof(unative_t) || breakpoints[i].address ==
|
---|
| 170 | (uintptr_t)argv->intval - sizeof(unative_t)) {
|
---|
| 171 | printf("Adjacent breakpoints not supported, conflict "
|
---|
| 172 | "with %d.\n", i);
|
---|
[7f341820] | 173 | spinlock_unlock(&bkpoint_lock);
|
---|
[556f9892] | 174 | interrupts_restore(ipl);
|
---|
[5bb8e45] | 175 | return 0;
|
---|
| 176 | }
|
---|
[7f341820] | 177 |
|
---|
[5bb8e45] | 178 | }
|
---|
| 179 |
|
---|
[1e1e5e1] | 180 | for (i = 0; i < BKPOINTS_MAX; i++)
|
---|
[5bb8e45] | 181 | if (!breakpoints[i].address) {
|
---|
| 182 | cur = &breakpoints[i];
|
---|
| 183 | break;
|
---|
| 184 | }
|
---|
| 185 | if (!cur) {
|
---|
| 186 | printf("Too many breakpoints.\n");
|
---|
| 187 | spinlock_unlock(&bkpoint_lock);
|
---|
| 188 | interrupts_restore(ipl);
|
---|
| 189 | return 0;
|
---|
| 190 | }
|
---|
[7f1c620] | 191 | cur->address = (uintptr_t) argv->intval;
|
---|
[5bb8e45] | 192 | printf("Adding breakpoint on address: %p\n", argv->intval);
|
---|
[7f1c620] | 193 | cur->instruction = ((unative_t *)cur->address)[0];
|
---|
| 194 | cur->nextinstruction = ((unative_t *)cur->address)[1];
|
---|
[07bd114e] | 195 | if (argv == &add_argv) {
|
---|
| 196 | cur->flags = 0;
|
---|
| 197 | } else { /* We are add extended */
|
---|
| 198 | cur->flags = BKPOINT_FUNCCALL;
|
---|
[1e1e5e1] | 199 | cur->bkfunc = (void (*)(void *, istate_t *)) argv[1].intval;
|
---|
[07bd114e] | 200 | }
|
---|
| 201 | if (is_jump(cur->instruction))
|
---|
| 202 | cur->flags |= BKPOINT_ONESHOT;
|
---|
| 203 | cur->counter = 0;
|
---|
[5bb8e45] | 204 |
|
---|
| 205 | /* Set breakpoint */
|
---|
[7f1c620] | 206 | *((unative_t *)cur->address) = 0x0d;
|
---|
[1e1e5e1] | 207 | smc_coherence(cur->address);
|
---|
[5bb8e45] | 208 |
|
---|
| 209 | spinlock_unlock(&bkpoint_lock);
|
---|
| 210 | interrupts_restore(ipl);
|
---|
| 211 |
|
---|
| 212 | return 1;
|
---|
| 213 | }
|
---|
| 214 |
|
---|
| 215 | /** Remove breakpoint from table */
|
---|
| 216 | int cmd_del_breakpoint(cmd_arg_t *argv)
|
---|
| 217 | {
|
---|
| 218 | bpinfo_t *cur;
|
---|
| 219 | ipl_t ipl;
|
---|
| 220 |
|
---|
[6c441cf8] | 221 | if (argv->intval > BKPOINTS_MAX) {
|
---|
[5bb8e45] | 222 | printf("Invalid breakpoint number.\n");
|
---|
| 223 | return 0;
|
---|
| 224 | }
|
---|
| 225 | ipl = interrupts_disable();
|
---|
| 226 | spinlock_lock(&bkpoint_lock);
|
---|
| 227 |
|
---|
| 228 | cur = &breakpoints[argv->intval];
|
---|
| 229 | if (!cur->address) {
|
---|
| 230 | printf("Breakpoint does not exist.\n");
|
---|
| 231 | spinlock_unlock(&bkpoint_lock);
|
---|
| 232 | interrupts_restore(ipl);
|
---|
| 233 | return 0;
|
---|
| 234 | }
|
---|
[07bd114e] | 235 | if ((cur->flags & BKPOINT_INPROG) && (cur->flags & BKPOINT_ONESHOT)) {
|
---|
| 236 | printf("Cannot remove one-shot breakpoint in-progress\n");
|
---|
| 237 | spinlock_unlock(&bkpoint_lock);
|
---|
| 238 | interrupts_restore(ipl);
|
---|
| 239 | return 0;
|
---|
| 240 | }
|
---|
[7f1c620] | 241 | ((uint32_t *)cur->address)[0] = cur->instruction;
|
---|
[1e1e5e1] | 242 | smc_coherence(((uint32_t *)cur->address)[0]);
|
---|
[7f1c620] | 243 | ((uint32_t *)cur->address)[1] = cur->nextinstruction;
|
---|
[1e1e5e1] | 244 | smc_coherence(((uint32_t *)cur->address)[1]);
|
---|
[5bb8e45] | 245 |
|
---|
| 246 | cur->address = NULL;
|
---|
| 247 |
|
---|
| 248 | spinlock_unlock(&bkpoint_lock);
|
---|
| 249 | interrupts_restore(ipl);
|
---|
| 250 | return 1;
|
---|
| 251 | }
|
---|
| 252 |
|
---|
| 253 | /** Print table of active breakpoints */
|
---|
| 254 | int cmd_print_breakpoints(cmd_arg_t *argv)
|
---|
| 255 | {
|
---|
[c053f615] | 256 | unsigned int i;
|
---|
| 257 |
|
---|
| 258 | printf("# Count Address INPROG ONESHOT FUNCCALL In symbol\n");
|
---|
| 259 | printf("-- ----- ---------- ------ ------- -------- ---------\n");
|
---|
| 260 |
|
---|
[a000878c] | 261 | for (i = 0; i < BKPOINTS_MAX; i++) {
|
---|
[5bb8e45] | 262 | if (breakpoints[i].address) {
|
---|
[a000878c] | 263 | const char *symbol = symtab_fmt_name_lookup(
|
---|
[e16e0d59] | 264 | breakpoints[i].address);
|
---|
[a000878c] | 265 |
|
---|
[c053f615] | 266 | printf("%-2u %-5d %#10zx %-6s %-7s %-8s %s\n", i,
|
---|
[1e1e5e1] | 267 | breakpoints[i].counter, breakpoints[i].address,
|
---|
| 268 | ((breakpoints[i].flags & BKPOINT_INPROG) ? "true" :
|
---|
| 269 | "false"), ((breakpoints[i].flags & BKPOINT_ONESHOT)
|
---|
| 270 | ? "true" : "false"), ((breakpoints[i].flags &
|
---|
| 271 | BKPOINT_FUNCCALL) ? "true" : "false"), symbol);
|
---|
[5bb8e45] | 272 | }
|
---|
[a000878c] | 273 | }
|
---|
| 274 |
|
---|
[5bb8e45] | 275 | return 1;
|
---|
| 276 | }
|
---|
| 277 |
|
---|
[76fca31] | 278 | #endif
|
---|
| 279 |
|
---|
[5bb8e45] | 280 | /** Initialize debugger */
|
---|
| 281 | void debugger_init()
|
---|
| 282 | {
|
---|
| 283 | int i;
|
---|
| 284 |
|
---|
[1e1e5e1] | 285 | for (i = 0; i < BKPOINTS_MAX; i++)
|
---|
[5bb8e45] | 286 | breakpoints[i].address = NULL;
|
---|
[76fca31] | 287 |
|
---|
| 288 | #ifdef CONFIG_KCONSOLE
|
---|
[0132630] | 289 | cmd_initialize(&bkpts_info);
|
---|
| 290 | if (!cmd_register(&bkpts_info))
|
---|
[76fca31] | 291 | printf("Cannot register command %s\n", bkpts_info.name);
|
---|
[5bb8e45] | 292 |
|
---|
| 293 | cmd_initialize(&delbkpt_info);
|
---|
| 294 | if (!cmd_register(&delbkpt_info))
|
---|
[76fca31] | 295 | printf("Cannot register command %s\n", delbkpt_info.name);
|
---|
[5bb8e45] | 296 |
|
---|
| 297 | cmd_initialize(&addbkpt_info);
|
---|
| 298 | if (!cmd_register(&addbkpt_info))
|
---|
[76fca31] | 299 | printf("Cannot register command %s\n", addbkpt_info.name);
|
---|
[07bd114e] | 300 |
|
---|
| 301 | cmd_initialize(&addbkpte_info);
|
---|
| 302 | if (!cmd_register(&addbkpte_info))
|
---|
[76fca31] | 303 | printf("Cannot register command %s\n", addbkpte_info.name);
|
---|
| 304 | #endif
|
---|
[5bb8e45] | 305 | }
|
---|
| 306 |
|
---|
| 307 | /** Handle breakpoint
|
---|
| 308 | *
|
---|
| 309 | * Find breakpoint in breakpoint table.
|
---|
| 310 | * If found, call kconsole, set break on next instruction and reexecute.
|
---|
| 311 | * If we are on "next instruction", set it back on the first and reexecute.
|
---|
| 312 | * If breakpoint not found in breakpoint table, call kconsole and start
|
---|
| 313 | * next instruction.
|
---|
| 314 | */
|
---|
[25d7709] | 315 | void debugger_bpoint(istate_t *istate)
|
---|
[5bb8e45] | 316 | {
|
---|
| 317 | bpinfo_t *cur = NULL;
|
---|
[7f1c620] | 318 | uintptr_t fireaddr = istate->epc;
|
---|
[5bb8e45] | 319 | int i;
|
---|
| 320 |
|
---|
| 321 | /* test branch delay slot */
|
---|
| 322 | if (cp0_cause_read() & 0x80000000)
|
---|
[f651e80] | 323 | panic("Breakpoint in branch delay slot not supported.");
|
---|
[5bb8e45] | 324 |
|
---|
| 325 | spinlock_lock(&bkpoint_lock);
|
---|
[1e1e5e1] | 326 | for (i = 0; i < BKPOINTS_MAX; i++) {
|
---|
[07bd114e] | 327 | /* Normal breakpoint */
|
---|
[1e1e5e1] | 328 | if (fireaddr == breakpoints[i].address &&
|
---|
| 329 | !(breakpoints[i].flags & BKPOINT_REINST)) {
|
---|
[5bb8e45] | 330 | cur = &breakpoints[i];
|
---|
[07bd114e] | 331 | break;
|
---|
| 332 | }
|
---|
| 333 | /* Reinst only breakpoint */
|
---|
[1e1e5e1] | 334 | if ((breakpoints[i].flags & BKPOINT_REINST) &&
|
---|
| 335 | (fireaddr == breakpoints[i].address + sizeof(unative_t))) {
|
---|
[07bd114e] | 336 | cur = &breakpoints[i];
|
---|
| 337 | break;
|
---|
| 338 | }
|
---|
[5bb8e45] | 339 | }
|
---|
| 340 | if (cur) {
|
---|
[07bd114e] | 341 | if (cur->flags & BKPOINT_REINST) {
|
---|
[5bb8e45] | 342 | /* Set breakpoint on first instruction */
|
---|
[7f1c620] | 343 | ((uint32_t *)cur->address)[0] = 0x0d;
|
---|
[1e1e5e1] | 344 | smc_coherence(((uint32_t *)cur->address)[0]);
|
---|
[5bb8e45] | 345 | /* Return back the second */
|
---|
[7f1c620] | 346 | ((uint32_t *)cur->address)[1] = cur->nextinstruction;
|
---|
[1e1e5e1] | 347 | smc_coherence(((uint32_t *)cur->address)[1]);
|
---|
[07bd114e] | 348 | cur->flags &= ~BKPOINT_REINST;
|
---|
[5bb8e45] | 349 | spinlock_unlock(&bkpoint_lock);
|
---|
| 350 | return;
|
---|
[07bd114e] | 351 | }
|
---|
| 352 | if (cur->flags & BKPOINT_INPROG)
|
---|
| 353 | printf("Warning: breakpoint recursion\n");
|
---|
| 354 |
|
---|
[e2b762ec] | 355 | if (!(cur->flags & BKPOINT_FUNCCALL)) {
|
---|
[1e1e5e1] | 356 | printf("***Breakpoint %d: %p in %s.\n", i, fireaddr,
|
---|
[e16e0d59] | 357 | symtab_fmt_name_lookup(istate->epc));
|
---|
[e2b762ec] | 358 | }
|
---|
[07bd114e] | 359 |
|
---|
| 360 | /* Return first instruction back */
|
---|
[7f1c620] | 361 | ((uint32_t *)cur->address)[0] = cur->instruction;
|
---|
[1e1e5e1] | 362 | smc_coherence(cur->address);
|
---|
[07bd114e] | 363 |
|
---|
| 364 | if (! (cur->flags & BKPOINT_ONESHOT)) {
|
---|
| 365 | /* Set Breakpoint on next instruction */
|
---|
[7f1c620] | 366 | ((uint32_t *)cur->address)[1] = 0x0d;
|
---|
[07bd114e] | 367 | cur->flags |= BKPOINT_REINST;
|
---|
| 368 | }
|
---|
| 369 | cur->flags |= BKPOINT_INPROG;
|
---|
[5bb8e45] | 370 | } else {
|
---|
[e16e0d59] | 371 | printf("***Breakpoint %d: %p in %s.\n", i, fireaddr,
|
---|
| 372 | symtab_fmt_name_lookup(fireaddr));
|
---|
| 373 |
|
---|
[5bb8e45] | 374 | /* Move on to next instruction */
|
---|
[25d7709] | 375 | istate->epc += 4;
|
---|
[5bb8e45] | 376 | }
|
---|
[9f3b880] | 377 | if (cur)
|
---|
| 378 | cur->counter++;
|
---|
[07bd114e] | 379 | if (cur && (cur->flags & BKPOINT_FUNCCALL)) {
|
---|
| 380 | /* Allow zero bkfunc, just for counting */
|
---|
| 381 | if (cur->bkfunc)
|
---|
[25d7709] | 382 | cur->bkfunc(cur, istate);
|
---|
[07bd114e] | 383 | } else {
|
---|
[76fca31] | 384 | #ifdef CONFIG_KCONSOLE
|
---|
[07bd114e] | 385 | /* This disables all other processors - we are not SMP,
|
---|
| 386 | * actually this gets us to cpu_halt, if scheduler() is run
|
---|
| 387 | * - we generally do not want scheduler to be run from debug,
|
---|
| 388 | * so this is a good idea
|
---|
| 389 | */
|
---|
[76fca31] | 390 | atomic_set(&haltstate, 1);
|
---|
[07bd114e] | 391 | spinlock_unlock(&bkpoint_lock);
|
---|
[76fca31] | 392 |
|
---|
[0b6eba5] | 393 | kconsole("debug", "Debug console ready.\n", false);
|
---|
[76fca31] | 394 |
|
---|
[07bd114e] | 395 | spinlock_lock(&bkpoint_lock);
|
---|
[76fca31] | 396 | atomic_set(&haltstate, 0);
|
---|
| 397 | #endif
|
---|
[07bd114e] | 398 | }
|
---|
| 399 | if (cur && cur->address == fireaddr && (cur->flags & BKPOINT_INPROG)) {
|
---|
| 400 | /* Remove one-shot breakpoint */
|
---|
| 401 | if ((cur->flags & BKPOINT_ONESHOT))
|
---|
| 402 | cur->address = NULL;
|
---|
| 403 | /* Remove in-progress flag */
|
---|
| 404 | cur->flags &= ~BKPOINT_INPROG;
|
---|
| 405 | }
|
---|
| 406 | spinlock_unlock(&bkpoint_lock);
|
---|
[5bb8e45] | 407 | }
|
---|
[b45c443] | 408 |
|
---|
[06e1e95] | 409 | /** @}
|
---|
[b45c443] | 410 | */
|
---|