The break instruction in RISC-V does not have an immediate value field, so the kernel cannot identify the purpose of each trap exception through the opcode. This makes the existing identification schemes in other architecture unsuitable for the RISC-V kernel. To solve this problem, this patch adds kgdb_has_hit_break(), which can help RISC-V kernel identify the KGDB trap exception.
Showing the changes to kernel/debug/debug_core.c (1 of 1 file). Show all
Unified · Split
| @@ -417,6 +417,18 @@ int kgdb_isremovedbreak(unsigned long addr) · 416 unmodified lines | ||
| 417 | 417 | return 0; |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | +int kgdb_has_hit_break(unsigned long addr) | |
| 421 | +{ | |
| 422 | + int i; | |
| 423 | + | |
| 424 | + for (i = 0; i < KGDB_MAX_BREAKPOINTS; i++) { | |
| 425 | + if (kgdb_break[i].state == BP_ACTIVE && | |
| 426 | + kgdb_break[i].bpt_addr == addr) | |
| 427 | + return 1; | |
| 428 | + } | |
| 429 | + return 0; | |
| 430 | +} | |
| 431 | + | |
| 420 | 432 | int dbg_remove_all_break(void) |
| 421 | 433 | { |
| 422 | 434 | int error; |