1
1
#include <assert.h>
2
2
#include "mini-gdbstub/include/gdbstub.h"
3
3
#include "riscv_private.h"
4
+ #include "breakpoint.h"
4
5
5
6
static size_t rv_read_reg (void * args , int regno )
6
7
{
@@ -31,7 +32,7 @@ static gdb_action_t rv_cont(void *args)
31
32
const uint32_t cycles_per_step = 1 ;
32
33
33
34
for (; !rv_has_halted (rv );) {
34
- if (rv -> breakpoint_specified && ( rv_get_pc (rv ) == rv -> breakpoint_addr ) ) {
35
+ if (breakpoint_map_find ( rv -> breakpoint_map , rv_get_pc (rv )) != NULL ) {
35
36
break ;
36
37
}
37
38
rv_step (rv , cycles_per_step );
@@ -50,12 +51,10 @@ static gdb_action_t rv_stepi(void *args)
50
51
static bool rv_set_bp (void * args , size_t addr , bp_type_t type )
51
52
{
52
53
struct riscv_t * rv = (struct riscv_t * ) args ;
53
- if (type != BP_SOFTWARE || rv -> breakpoint_specified )
54
+ if (type != BP_SOFTWARE )
54
55
return false;
55
56
56
- rv -> breakpoint_specified = true;
57
- rv -> breakpoint_addr = addr ;
58
- return true;;
57
+ return breakpoint_map_insert (rv -> breakpoint_map , addr );
59
58
}
60
59
61
60
static bool rv_del_bp (void * args , size_t addr , bp_type_t type )
@@ -64,11 +63,7 @@ static bool rv_del_bp(void *args, size_t addr, bp_type_t type)
64
63
if (type != BP_SOFTWARE )
65
64
return false;
66
65
/* When there is no matched breakpoint, no further action is taken */
67
- if (!rv -> breakpoint_specified || addr != rv -> breakpoint_addr )
68
- return true;
69
-
70
- rv -> breakpoint_specified = false;
71
- rv -> breakpoint_addr = 0 ;
66
+ breakpoint_map_del (rv -> breakpoint_map , addr );
72
67
return true;
73
68
}
74
69
0 commit comments