58 (*breakpoint_p) = malloc(
sizeof(
struct breakpoint));
59 (*breakpoint_p)->address =
address;
60 (*breakpoint_p)->asid = 0;
61 (*breakpoint_p)->length =
length;
62 (*breakpoint_p)->type =
type;
63 (*breakpoint_p)->is_set =
false;
64 (*breakpoint_p)->orig_instr = malloc(
length);
65 (*breakpoint_p)->next =
NULL;
73 reason =
"resource not available";
76 reason =
"target running";
79 reason =
"unknown reason";
81 LOG_ERROR(
"can't add breakpoint: %s", reason);
82 free((*breakpoint_p)->orig_instr);
89 " of length 0x%8.8x, (BPID: %" PRIu32
")",
92 (*breakpoint_p)->address, (*breakpoint_p)->length,
93 (*breakpoint_p)->unique_id);
113 LOG_ERROR(
"Duplicate Breakpoint asid: 0x%08" PRIx32
" (BP %" PRIu32
")",
121 (*breakpoint_p) = malloc(
sizeof(
struct breakpoint));
122 (*breakpoint_p)->address = 0;
123 (*breakpoint_p)->asid =
asid;
124 (*breakpoint_p)->length =
length;
125 (*breakpoint_p)->type =
type;
126 (*breakpoint_p)->is_set =
false;
127 (*breakpoint_p)->orig_instr = malloc(
length);
128 (*breakpoint_p)->next =
NULL;
133 free((*breakpoint_p)->orig_instr);
135 *breakpoint_p =
NULL;
139 LOG_DEBUG(
"added %s Context breakpoint at 0x%8.8" PRIx32
" of length 0x%8.8x, (BPID: %" PRIu32
")",
141 (*breakpoint_p)->asid, (*breakpoint_p)->length,
142 (*breakpoint_p)->unique_id);
163 LOG_ERROR(
"Duplicate Hybrid Breakpoint asid: 0x%08" PRIx32
" (BP %" PRIu32
")",
175 (*breakpoint_p) = malloc(
sizeof(
struct breakpoint));
176 (*breakpoint_p)->address =
address;
177 (*breakpoint_p)->asid =
asid;
178 (*breakpoint_p)->length =
length;
179 (*breakpoint_p)->type =
type;
180 (*breakpoint_p)->is_set =
false;
181 (*breakpoint_p)->orig_instr = malloc(
length);
182 (*breakpoint_p)->next =
NULL;
189 free((*breakpoint_p)->orig_instr);
191 *breakpoint_p =
NULL;
195 "added %s Hybrid breakpoint at address " TARGET_ADDR_FMT " of length 0x%8.8x, (BPID: %" PRIu32
")",
197 (*breakpoint_p)->address,
198 (*breakpoint_p)->length,
199 (*breakpoint_p)->unique_id);
332 unsigned int num_breakpoints = 0;
339 if (!num_breakpoints)
362 LOG_DEBUG(
"Delete all breakpoints for target: %s",
410 " already has watchpoint %d",
422 (*watchpoint_p) = calloc(1,
sizeof(
struct watchpoint));
423 (*watchpoint_p)->address =
address;
424 (*watchpoint_p)->length =
length;
425 (*watchpoint_p)->value =
value;
426 (*watchpoint_p)->mask =
mask;
427 (*watchpoint_p)->rw =
rw;
435 reason =
"resource not available";
438 reason =
"target running";
441 reason =
"unrecognized error";
447 *watchpoint_p =
NULL;
452 " of length 0x%8.8" PRIx32
" (WPID: %d)",
455 (*watchpoint_p)->address,
456 (*watchpoint_p)->length,
457 (*watchpoint_p)->unique_id);
526 unsigned int num_watchpoints = 0;
533 if (num_watchpoints == 0)
542 LOG_DEBUG(
"Delete all watchpoints for target: %s",
558 *
rw = hit_watchpoint->
rw;
static const char *const watchpoint_rw_strings[]
void watchpoint_clear_target(struct target *target)
void breakpoint_remove_all(struct target *target)
void breakpoint_clear_target(struct target *target)
static void breakpoint_clear_target_internal(struct target *target)
int watchpoint_hit(struct target *target, enum watchpoint_rw *rw, target_addr_t *address)
static int hybrid_breakpoint_add_internal(struct target *target, target_addr_t address, uint32_t asid, uint32_t length, enum breakpoint_type type)
static int breakpoint_remove_internal(struct target *target, target_addr_t address)
static int context_breakpoint_add_internal(struct target *target, uint32_t asid, uint32_t length, enum breakpoint_type type)
int hybrid_breakpoint_add(struct target *target, target_addr_t address, uint32_t asid, uint32_t length, enum breakpoint_type type)
static int bpwp_unique_id
static const char *const breakpoint_type_strings[]
static void watchpoint_free(struct target *target, struct watchpoint *watchpoint_to_remove)
static int watchpoint_remove_internal(struct target *target, target_addr_t address)
static int watchpoint_add_internal(struct target *target, target_addr_t address, uint32_t length, enum watchpoint_rw rw, uint32_t value, uint32_t mask)
int context_breakpoint_add(struct target *target, uint32_t asid, uint32_t length, enum breakpoint_type type)
void watchpoint_remove(struct target *target, target_addr_t address)
void breakpoint_remove(struct target *target, target_addr_t address)
int breakpoint_add(struct target *target, target_addr_t address, uint32_t length, enum breakpoint_type type)
static int breakpoint_add_internal(struct target *target, target_addr_t address, uint32_t length, enum breakpoint_type type)
int watchpoint_add(struct target *target, target_addr_t address, uint32_t length, enum watchpoint_rw rw, uint32_t value, uint32_t mask)
static void breakpoint_remove_all_internal(struct target *target)
struct breakpoint * breakpoint_find(struct target *target, target_addr_t address)
static void breakpoint_free(struct target *target, struct breakpoint *breakpoint_to_remove)
#define list_first_entry(ptr, type, member)
list_first_entry - get the first element from a list
#define LOG_ERROR(expr ...)
#define LOG_DEBUG(expr ...)
static uint32_t lh(unsigned int rd, unsigned int base, uint16_t offset) __attribute__((unused))
#define foreach_smp_target(pos, head)
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_DUPLICATE_BREAKPOINT
static const char * target_name(struct target *target)
Returns the instance-specific name of the specified target.
#define ERROR_TARGET_RESOURCE_NOT_AVAILABLE