45 bool found_breakpoint =
false;
49 found_breakpoint =
true;
88 (*breakpoint_p) = malloc(
sizeof(
struct breakpoint));
89 (*breakpoint_p)->address =
address;
90 (*breakpoint_p)->asid = 0;
91 (*breakpoint_p)->length =
length;
92 (*breakpoint_p)->type =
type;
93 (*breakpoint_p)->is_set =
false;
94 (*breakpoint_p)->orig_instr = malloc(
length);
95 (*breakpoint_p)->next =
NULL;
103 reason =
"resource not available";
106 reason =
"target not halted";
109 reason =
"unknown reason";
112 free((*breakpoint_p)->orig_instr);
114 *breakpoint_p =
NULL;
119 " of length 0x%8.8x, (BPID: %" PRIu32
")",
121 (*breakpoint_p)->address, (*breakpoint_p)->length,
122 (*breakpoint_p)->unique_id);
150 (*breakpoint_p) = malloc(
sizeof(
struct breakpoint));
151 (*breakpoint_p)->address = 0;
152 (*breakpoint_p)->asid =
asid;
153 (*breakpoint_p)->length =
length;
154 (*breakpoint_p)->type =
type;
155 (*breakpoint_p)->is_set =
false;
156 (*breakpoint_p)->orig_instr = malloc(
length);
157 (*breakpoint_p)->next =
NULL;
162 free((*breakpoint_p)->orig_instr);
164 *breakpoint_p =
NULL;
168 LOG_TARGET_DEBUG(
target,
"added %s Context breakpoint at 0x%8.8" PRIx32
" of length 0x%8.8x, (BPID: %" PRIu32
")",
170 (*breakpoint_p)->asid, (*breakpoint_p)->length,
171 (*breakpoint_p)->unique_id);
204 (*breakpoint_p) = malloc(
sizeof(
struct breakpoint));
205 (*breakpoint_p)->address =
address;
206 (*breakpoint_p)->asid =
asid;
207 (*breakpoint_p)->length =
length;
208 (*breakpoint_p)->type =
type;
209 (*breakpoint_p)->is_set =
false;
210 (*breakpoint_p)->orig_instr = malloc(
length);
211 (*breakpoint_p)->next =
NULL;
218 free((*breakpoint_p)->orig_instr);
220 *breakpoint_p =
NULL;
224 "added %s Hybrid breakpoint at address " TARGET_ADDR_FMT " of length 0x%8.8x, (BPID: %" PRIu32
")",
226 (*breakpoint_p)->address,
227 (*breakpoint_p)->length,
228 (*breakpoint_p)->unique_id);
366 unsigned int num_found_breakpoints = 0;
375 num_found_breakpoints++;
388 num_found_breakpoints++;
395 if (num_found_breakpoints == 0) {
517 " already has watchpoint %d",
529 (*watchpoint_p) = calloc(1,
sizeof(
struct watchpoint));
530 (*watchpoint_p)->address =
address;
531 (*watchpoint_p)->length =
length;
532 (*watchpoint_p)->value =
value;
533 (*watchpoint_p)->mask =
mask;
534 (*watchpoint_p)->rw =
rw;
542 reason =
"resource not available";
545 reason =
"target not halted";
548 reason =
"unrecognized error";
554 *watchpoint_p =
NULL;
559 " of length 0x%8.8x (WPID: %d)",
561 (*watchpoint_p)->address,
562 (*watchpoint_p)->length,
563 (*watchpoint_p)->unique_id);
608 unsigned int num_found_watchpoints = 0;
617 num_found_watchpoints++;
629 num_found_watchpoints++;
636 if (num_found_watchpoints == 0) {
654 unsigned int cnt = 0;
668 *
rw = hit_watchpoint->
rw;
static const char *const watchpoint_rw_strings[]
int watchpoint_add(struct target *target, target_addr_t address, unsigned int length, enum watchpoint_rw rw, uint64_t value, uint64_t mask)
static int breakpoint_watchpoint_remove_all(struct target *target, enum breakpoint_watchpoint bp_wp)
COMMAND_HELPER(detect_breakpoints_in_section, struct target *target, struct imagesection section)
static int watchpoint_free(struct target *target, struct watchpoint *watchpoint_to_remove)
static int breakpoint_add_internal(struct target *target, target_addr_t address, unsigned int length, enum breakpoint_type type)
int breakpoint_remove(struct target *target, target_addr_t address)
static int watchpoint_add_internal(struct target *target, target_addr_t address, unsigned int length, enum watchpoint_rw rw, uint64_t value, uint64_t mask)
int watchpoint_hit(struct target *target, enum watchpoint_rw *rw, target_addr_t *address)
static int breakpoint_remove_internal(struct target *target, target_addr_t address)
static int context_breakpoint_add_internal(struct target *target, uint32_t asid, unsigned int length, enum breakpoint_type type)
int watchpoint_remove(struct target *target, target_addr_t address)
int breakpoint_add(struct target *target, target_addr_t address, unsigned int length, enum breakpoint_type type)
static int bpwp_unique_id
static const char *const breakpoint_type_strings[]
int context_breakpoint_add(struct target *target, uint32_t asid, unsigned int length, enum breakpoint_type type)
static int watchpoint_remove_internal(struct target *target, target_addr_t address)
static int breakpoint_free(struct target *target, struct breakpoint *breakpoint_to_remove)
int watchpoint_remove_all(struct target *target)
int breakpoint_remove_all(struct target *target)
static int hybrid_breakpoint_add_internal(struct target *target, target_addr_t address, uint32_t asid, unsigned int length, enum breakpoint_type type)
static int breakpoint_remove_all_internal(struct target *target)
int hybrid_breakpoint_add(struct target *target, target_addr_t address, uint32_t asid, unsigned int length, enum breakpoint_type type)
static int watchpoint_remove_all_internal(struct target *target)
struct breakpoint * breakpoint_find(struct target *target, target_addr_t address)
#define ERROR_BREAKPOINT_OVERLAPPED
#define ERROR_BREAKPOINT_DUPLICATED
#define ERROR_WATCHPOINT_NOT_FOUND
#define ERROR_BREAKPOINT_NOT_FOUND
void command_print(struct command_invocation *cmd, const char *format,...)
uint32_t address
Starting address. Sector aligned.
#define ERROR_NOT_IMPLEMENTED
#define LOG_TARGET_ERROR(target, fmt_str,...)
#define LOG_TARGET_DEBUG(target, fmt_str,...)
#define foreach_smp_target(pos, head)
target_addr_t base_address
enum target_debug_reason debug_reason
struct list_head * smp_targets
struct breakpoint * breakpoints
struct watchpoint * watchpoints
int target_add_watchpoint(struct target *target, struct watchpoint *watchpoint)
Add the watchpoint for target.
int target_remove_breakpoint(struct target *target, struct breakpoint *breakpoint)
Remove the breakpoint for target.
int target_add_hybrid_breakpoint(struct target *target, struct breakpoint *breakpoint)
Add the ContextID & IVA breakpoint for target.
int target_add_breakpoint(struct target *target, struct breakpoint *breakpoint)
Add the breakpoint for target.
int target_hit_watchpoint(struct target *target, struct watchpoint **hit_watchpoint)
Find out the just hit watchpoint for target.
int target_remove_watchpoint(struct target *target, struct watchpoint *watchpoint)
Remove the watchpoint for target.
int target_add_context_breakpoint(struct target *target, struct breakpoint *breakpoint)
Add the ContextID breakpoint for target.
#define ERROR_TARGET_NOT_HALTED
#define ERROR_TARGET_RESOURCE_NOT_AVAILABLE
bool is_memory_regions_overlap(target_addr_t start1, unsigned int size1, target_addr_t start2, unsigned int size2)