Changeset 1e1e5e1 in mainline
- Timestamp:
- 2008-06-14T12:15:27Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b22304b
- Parents:
- d7c9fcb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/mips32/src/debugger.c
rd7c9fcb r1e1e5e1 34 34 35 35 #include <arch/debugger.h> 36 #include <arch/barrier.h> 36 37 #include <memstr.h> 37 38 #include <console/kconsole.h> … … 73 74 static cmd_info_t addbkpt_info = { 74 75 .name = "addbkpt", 75 .description = "addbkpt <&symbol> - new bkpoint. Break on J/Branch insts unsupported.", 76 .description = "addbkpt <&symbol> - new bkpoint. Break on J/Branch " 77 "insts unsupported.", 76 78 .func = cmd_add_breakpoint, 77 79 .argc = 1, … … 85 87 static cmd_info_t addbkpte_info = { 86 88 .name = "addbkpte", 87 .description = "addebkpte <&symbol> <&func> - new bkpoint. Call func(or Nothing if 0).", 89 .description = "addebkpte <&symbol> <&func> - new bkpoint. Call " 90 "func(or Nothing if 0).", 88 91 .func = cmd_add_breakpoint, 89 92 .argc = 2, … … 94 97 uint32_t andmask; 95 98 uint32_t value; 96 } jmpinstr[] = {99 } jmpinstr[] = { 97 100 {0xf3ff0000, 0x41000000}, /* BCzF */ 98 101 {0xf3ff0000, 0x41020000}, /* BCzFL */ … … 118 121 {0xfc000000, 0x0c000000}, /* JAL */ 119 122 {0xfc1f07ff, 0x00000009}, /* JALR */ 120 {0, 0} /* EndOfTable */123 {0, 0} /* EndOfTable */ 121 124 }; 122 125 … … 130 133 int i; 131 134 132 for (i =0;jmpinstr[i].andmask;i++) {135 for (i = 0; jmpinstr[i].andmask; i++) { 133 136 if ((instr & jmpinstr[i].andmask) == jmpinstr[i].value) 134 137 return true; … … 158 161 spinlock_unlock(&bkpoints_lock); 159 162 return 0; 160 } else if (breakpoints[i].address == (uintptr_t)argv->intval + sizeof(unative_t) || \ 161 breakpoints[i].address == (uintptr_t)argv->intval - sizeof(unative_t)) { 162 printf("Adjacent breakpoints not supported, conflict with %d.\n", i); 163 } else if (breakpoints[i].address == (uintptr_t)argv->intval + 164 sizeof(unative_t) || breakpoints[i].address == 165 (uintptr_t)argv->intval - sizeof(unative_t)) { 166 printf("Adjacent breakpoints not supported, conflict " 167 "with %d.\n", i); 163 168 spinlock_unlock(&bkpoints_lock); 164 169 return 0; … … 167 172 } 168 173 169 for (i =0; i<BKPOINTS_MAX; i++)174 for (i = 0; i < BKPOINTS_MAX; i++) 170 175 if (!breakpoints[i].address) { 171 176 cur = &breakpoints[i]; … … 186 191 } else { /* We are add extended */ 187 192 cur->flags = BKPOINT_FUNCCALL; 188 cur->bkfunc = 193 cur->bkfunc = (void (*)(void *, istate_t *)) argv[1].intval; 189 194 } 190 195 if (is_jump(cur->instruction)) … … 194 199 /* Set breakpoint */ 195 200 *((unative_t *)cur->address) = 0x0d; 201 smc_coherence(cur->address); 196 202 197 203 spinlock_unlock(&bkpoint_lock); … … 200 206 return 1; 201 207 } 202 203 204 208 205 209 /** Remove breakpoint from table */ … … 230 234 } 231 235 ((uint32_t *)cur->address)[0] = cur->instruction; 236 smc_coherence(((uint32_t *)cur->address)[0]); 232 237 ((uint32_t *)cur->address)[1] = cur->nextinstruction; 238 smc_coherence(((uint32_t *)cur->address)[1]); 233 239 234 240 cur->address = NULL; … … 253 259 254 260 printf("%-2u %-5d %#10zx %-6s %-7s %-8s %s\n", i, 255 256 ((breakpoints[i].flags & BKPOINT_INPROG) ? "true" : "false"),257 ((breakpoints[i].flags & BKPOINT_ONESHOT) ? "true" : "false"),258 ((breakpoints[i].flags & BKPOINT_FUNCCALL) ? "true" : "false"),259 261 breakpoints[i].counter, breakpoints[i].address, 262 ((breakpoints[i].flags & BKPOINT_INPROG) ? "true" : 263 "false"), ((breakpoints[i].flags & BKPOINT_ONESHOT) 264 ? "true" : "false"), ((breakpoints[i].flags & 265 BKPOINT_FUNCCALL) ? "true" : "false"), symbol); 260 266 } 261 267 return 1; … … 267 273 int i; 268 274 269 for (i =0; i<BKPOINTS_MAX; i++)275 for (i = 0; i < BKPOINTS_MAX; i++) 270 276 breakpoints[i].address = NULL; 271 277 … … 306 312 307 313 spinlock_lock(&bkpoint_lock); 308 for (i =0; i<BKPOINTS_MAX; i++) {314 for (i = 0; i < BKPOINTS_MAX; i++) { 309 315 /* Normal breakpoint */ 310 if (fireaddr == breakpoints[i].address \311 &&!(breakpoints[i].flags & BKPOINT_REINST)) {316 if (fireaddr == breakpoints[i].address && 317 !(breakpoints[i].flags & BKPOINT_REINST)) { 312 318 cur = &breakpoints[i]; 313 319 break; 314 320 } 315 321 /* Reinst only breakpoint */ 316 if ((breakpoints[i].flags & BKPOINT_REINST) \317 &&(fireaddr == breakpoints[i].address + sizeof(unative_t))) {322 if ((breakpoints[i].flags & BKPOINT_REINST) && 323 (fireaddr == breakpoints[i].address + sizeof(unative_t))) { 318 324 cur = &breakpoints[i]; 319 325 break; … … 324 330 /* Set breakpoint on first instruction */ 325 331 ((uint32_t *)cur->address)[0] = 0x0d; 332 smc_coherence(((uint32_t *)cur->address)[0]); 326 333 /* Return back the second */ 327 334 ((uint32_t *)cur->address)[1] = cur->nextinstruction; 335 smc_coherence(((uint32_t *)cur->address)[1]); 328 336 cur->flags &= ~BKPOINT_REINST; 329 337 spinlock_unlock(&bkpoint_lock); … … 334 342 335 343 if (!(cur->flags & BKPOINT_FUNCCALL)) 336 printf("***Breakpoint %d: %p in %s.\n", i, 337 fireaddr,get_symtab_entry(istate->epc));344 printf("***Breakpoint %d: %p in %s.\n", i, fireaddr, 345 get_symtab_entry(istate->epc)); 338 346 339 347 /* Return first instruction back */ 340 348 ((uint32_t *)cur->address)[0] = cur->instruction; 349 smc_coherence(cur->address); 341 350 342 351 if (! (cur->flags & BKPOINT_ONESHOT)) {
Note:
See TracChangeset
for help on using the changeset viewer.