Changeset a35b458 in mainline for kernel/arch/mips32/src/debugger.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/mips32/src/debugger.c
r3061bc1 ra35b458 138 138 { 139 139 unsigned int i; 140 140 141 141 for (i = 0; jmpinstr[i].andmask; i++) { 142 142 if ((instr & jmpinstr[i].andmask) == jmpinstr[i].value) 143 143 return true; 144 144 } 145 145 146 146 return false; 147 147 } … … 158 158 return 1; 159 159 } 160 160 161 161 irq_spinlock_lock(&bkpoint_lock, true); 162 162 163 163 /* Check, that the breakpoints do not conflict */ 164 164 unsigned int i; … … 176 176 return 0; 177 177 } 178 179 } 180 178 179 } 180 181 181 bpinfo_t *cur = NULL; 182 182 183 183 for (i = 0; i < BKPOINTS_MAX; i++) { 184 184 if (!breakpoints[i].address) { … … 187 187 } 188 188 } 189 189 190 190 if (!cur) { 191 191 printf("Too many breakpoints.\n"); … … 193 193 return 0; 194 194 } 195 195 196 196 printf("Adding breakpoint on address %p\n", (void *) argv->intval); 197 197 198 198 cur->address = (uintptr_t) argv->intval; 199 199 cur->instruction = ((sysarg_t *) cur->address)[0]; … … 205 205 cur->bkfunc = (void (*)(void *, istate_t *)) argv[1].intval; 206 206 } 207 207 208 208 if (is_jump(cur->instruction)) 209 209 cur->flags |= BKPOINT_ONESHOT; 210 210 211 211 cur->counter = 0; 212 212 213 213 /* Set breakpoint */ 214 214 *((sysarg_t *) cur->address) = 0x0d; 215 215 smc_coherence(cur->address); 216 216 217 217 irq_spinlock_unlock(&bkpoint_lock, true); 218 218 219 219 return 1; 220 220 } … … 229 229 return 0; 230 230 } 231 231 232 232 irq_spinlock_lock(&bkpoint_lock, true); 233 233 234 234 bpinfo_t *cur = &breakpoints[argv->intval]; 235 235 if (!cur->address) { … … 238 238 return 0; 239 239 } 240 240 241 241 if ((cur->flags & BKPOINT_INPROG) && (cur->flags & BKPOINT_ONESHOT)) { 242 242 printf("Cannot remove one-shot breakpoint in-progress\n"); … … 244 244 return 0; 245 245 } 246 246 247 247 ((uint32_t *) cur->address)[0] = cur->instruction; 248 248 smc_coherence(((uint32_t *) cur->address)[0]); 249 249 ((uint32_t *) cur->address)[1] = cur->nextinstruction; 250 250 smc_coherence(((uint32_t *) cur->address)[1]); 251 251 252 252 cur->address = (uintptr_t) NULL; 253 253 254 254 irq_spinlock_unlock(&bkpoint_lock, true); 255 255 return 1; … … 262 262 { 263 263 unsigned int i; 264 264 265 265 printf("[nr] [count] [address ] [inprog] [oneshot] [funccall] [in symbol\n"); 266 266 267 267 for (i = 0; i < BKPOINTS_MAX; i++) { 268 268 if (breakpoints[i].address) { 269 269 const char *symbol = symtab_fmt_name_lookup( 270 270 breakpoints[i].address); 271 271 272 272 printf("%-4u %7zu %p %-8s %-9s %-10s %s\n", i, 273 273 breakpoints[i].counter, (void *) breakpoints[i].address, … … 278 278 } 279 279 } 280 280 281 281 return 1; 282 282 } … … 290 290 { 291 291 unsigned int i; 292 292 293 293 for (i = 0; i < BKPOINTS_MAX; i++) 294 294 breakpoints[i].address = (uintptr_t) NULL; 295 295 296 296 #ifdef CONFIG_KCONSOLE 297 297 cmd_initialize(&bkpts_info); … … 299 299 log(LF_OTHER, LVL_WARN, "Cannot register command %s", 300 300 bkpts_info.name); 301 301 302 302 cmd_initialize(&delbkpt_info); 303 303 if (!cmd_register(&delbkpt_info)) 304 304 log(LF_OTHER, LVL_WARN, "Cannot register command %s", 305 305 delbkpt_info.name); 306 306 307 307 cmd_initialize(&addbkpt_info); 308 308 if (!cmd_register(&addbkpt_info)) 309 309 log(LF_OTHER, LVL_WARN, "Cannot register command %s", 310 310 addbkpt_info.name); 311 311 312 312 cmd_initialize(&addbkpte_info); 313 313 if (!cmd_register(&addbkpte_info)) … … 331 331 if (cp0_cause_read() & 0x80000000) 332 332 panic("Breakpoint in branch delay slot not supported."); 333 333 334 334 irq_spinlock_lock(&bkpoint_lock, false); 335 335 336 336 bpinfo_t *cur = NULL; 337 337 uintptr_t fireaddr = istate->epc; 338 338 unsigned int i; 339 339 340 340 for (i = 0; i < BKPOINTS_MAX; i++) { 341 341 /* Normal breakpoint */ … … 345 345 break; 346 346 } 347 347 348 348 /* Reinst only breakpoint */ 349 349 if ((breakpoints[i].flags & BKPOINT_REINST) && … … 353 353 } 354 354 } 355 355 356 356 if (cur) { 357 357 if (cur->flags & BKPOINT_REINST) { … … 359 359 ((uint32_t *) cur->address)[0] = 0x0d; 360 360 smc_coherence(((uint32_t *)cur->address)[0]); 361 361 362 362 /* Return back the second */ 363 363 ((uint32_t *) cur->address)[1] = cur->nextinstruction; 364 364 smc_coherence(((uint32_t *) cur->address)[1]); 365 365 366 366 cur->flags &= ~BKPOINT_REINST; 367 367 irq_spinlock_unlock(&bkpoint_lock, false); 368 368 return; 369 369 } 370 370 371 371 if (cur->flags & BKPOINT_INPROG) 372 372 printf("Warning: breakpoint recursion\n"); 373 373 374 374 if (!(cur->flags & BKPOINT_FUNCCALL)) { 375 375 printf("***Breakpoint %u: %p in %s.\n", i, … … 377 377 symtab_fmt_name_lookup(fireaddr)); 378 378 } 379 379 380 380 /* Return first instruction back */ 381 381 ((uint32_t *)cur->address)[0] = cur->instruction; … … 392 392 (void *) fireaddr, 393 393 symtab_fmt_name_lookup(fireaddr)); 394 394 395 395 /* Move on to next instruction */ 396 396 istate->epc += 4; 397 397 } 398 398 399 399 if (cur) 400 400 cur->counter++; 401 401 402 402 if (cur && (cur->flags & BKPOINT_FUNCCALL)) { 403 403 /* Allow zero bkfunc, just for counting */ … … 414 414 atomic_set(&haltstate, 1); 415 415 irq_spinlock_unlock(&bkpoint_lock, false); 416 416 417 417 kconsole("debug", "Debug console ready.\n", false); 418 418 419 419 irq_spinlock_lock(&bkpoint_lock, false); 420 420 atomic_set(&haltstate, 0); 421 421 #endif 422 422 } 423 423 424 424 if ((cur) && (cur->address == fireaddr) 425 425 && ((cur->flags & BKPOINT_INPROG))) { … … 427 427 if ((cur->flags & BKPOINT_ONESHOT)) 428 428 cur->address = (uintptr_t) NULL; 429 429 430 430 /* Remove in-progress flag */ 431 431 cur->flags &= ~BKPOINT_INPROG; 432 432 } 433 433 434 434 irq_spinlock_unlock(&bkpoint_lock, false); 435 435 }
Note:
See TracChangeset
for help on using the changeset viewer.