Skip to content

Commit 858373d

Browse files
committed
target/espressif: add command to disable lazy breakpoints
1 parent 994e17d commit 858373d

File tree

16 files changed

+72
-19
lines changed

16 files changed

+72
-19
lines changed

src/target/espressif/esp.c

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ int esp_common_init(struct target *target, struct esp_common *esp,
4242
esp->flash_brps.brps = calloc(ESP_FLASH_BREAKPOINTS_MAX_NUM, sizeof(struct esp_flash_breakpoint));
4343
if (!esp->flash_brps.brps)
4444
return ERROR_FAIL;
45+
esp->breakpoint_lazy_process = true;
4546

4647
if (target->coreid == 0)
4748
target_register_event_callback(esp_callback_event_handler, esp);
@@ -245,7 +246,7 @@ int esp_common_flash_breakpoint_add(struct target *target, struct esp_common *es
245246
if (ret != ERROR_OK)
246247
return ret;
247248

248-
if (flash_bps->ops->breakpoint_lazy_process) {
249+
if (esp->breakpoint_lazy_process) {
249250
flash_bps->brps[slot].action = ESP_BP_ACT_ADD;
250251
flash_bps->brps[slot].status = ESP_BP_STAT_PEND;
251252
esp_common_dump_bp_slot("BP-ADD(new)", flash_bps, slot);
@@ -267,7 +268,7 @@ int esp_common_flash_breakpoint_remove(struct target *target, struct esp_common
267268
}
268269

269270
if (slot == ESP_FLASH_BREAKPOINTS_MAX_NUM) {
270-
if (esp->flash_brps.ops->breakpoint_lazy_process) {
271+
if (esp->breakpoint_lazy_process) {
271272
/* This is not an error since breakpoints are already removed inside qxfer-thread-read-end event */
272273
return ERROR_OK;
273274
}
@@ -276,7 +277,7 @@ int esp_common_flash_breakpoint_remove(struct target *target, struct esp_common
276277
}
277278

278279
/* Mark that z1 package received for this slot */
279-
if (esp->flash_brps.ops->breakpoint_lazy_process) {
280+
if (esp->breakpoint_lazy_process) {
280281
flash_bps[slot].action = ESP_BP_ACT_REM;
281282
flash_bps[slot].status = ESP_BP_STAT_PEND;
282283
esp_common_dump_bp_slot("BP-REMOVE", &esp->flash_brps, slot);
@@ -380,7 +381,7 @@ int esp_common_handle_gdb_detach(struct target *target)
380381
if (ret != ERROR_OK)
381382
return ret;
382383

383-
if (esp->flash_brps.ops->breakpoint_lazy_process) {
384+
if (esp->breakpoint_lazy_process) {
384385
esp_common_flash_breakpoints_get_ready_to_remove(esp);
385386
ret = esp_common_process_lazy_flash_breakpoints(target);
386387
} else {
@@ -403,7 +404,7 @@ int esp_common_handle_flash_breakpoints(struct target *target)
403404
{
404405
struct esp_common *esp = target_to_esp_common(target);
405406

406-
if (!esp->flash_brps.ops->breakpoint_lazy_process)
407+
if (!esp->breakpoint_lazy_process)
407408
return ERROR_OK;
408409

409410
if (!esp_common_any_pending_flash_breakpoint(esp))
@@ -515,6 +516,26 @@ int esp_common_process_flash_breakpoints_handler(struct target *target)
515516
return esp_common_handle_flash_breakpoints(target);
516517
}
517518

519+
int esp_common_disable_lazy_breakpoints_handler(struct target *target)
520+
{
521+
/* Before disabling, add/remove pending breakpoints */
522+
int ret = esp_common_process_flash_breakpoints_handler(target);
523+
if (ret != ERROR_OK)
524+
return ret;
525+
526+
if (target->smp) {
527+
struct target_list *head;
528+
foreach_smp_target(head, target->smp_targets) {
529+
target_to_esp_common(target)->breakpoint_lazy_process = false;
530+
}
531+
return ERROR_OK;
532+
}
533+
534+
target_to_esp_common(target)->breakpoint_lazy_process = false;
535+
536+
return ERROR_OK;
537+
}
538+
518539
int esp_common_process_flash_breakpoints_command(struct command_invocation *cmd)
519540
{
520541
if (CMD_ARGC != 0)
@@ -525,6 +546,23 @@ int esp_common_process_flash_breakpoints_command(struct command_invocation *cmd)
525546
return esp_common_process_flash_breakpoints_handler(target);
526547
}
527548

549+
int esp_common_disable_lazy_breakpoints_command(struct command_invocation *cmd)
550+
{
551+
if (CMD_ARGC != 0)
552+
return ERROR_COMMAND_SYNTAX_ERROR;
553+
554+
struct target *target = get_current_target(CMD_CTX);
555+
556+
int ret = esp_common_disable_lazy_breakpoints_handler(target);
557+
558+
if (ret == ERROR_OK)
559+
command_print(CMD, "disabled");
560+
else
561+
command_print(CMD, "failed");
562+
563+
return ret;
564+
}
565+
528566
static int esp_callback_event_handler(struct target *target, enum target_event event, void *priv)
529567
{
530568
switch (event) {

src/target/espressif/esp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ struct esp_flash_breakpoint_ops {
115115
int (*breakpoint_remove)(struct target *target,
116116
struct esp_flash_breakpoint *bp,
117117
size_t num_bps);
118-
bool breakpoint_lazy_process;
119118
};
120119

121120
struct esp_flash_breakpoints {
@@ -128,6 +127,7 @@ struct esp_common {
128127
const struct esp_algorithm_hw *algo_hw;
129128
struct esp_dbg_stubs dbg_stubs;
130129
struct esp_panic_reason panic_reason;
130+
bool breakpoint_lazy_process;
131131
};
132132

133133
struct esp_ops {
@@ -151,6 +151,7 @@ bool esp_common_flash_breakpoint_exists(struct esp_common *esp,
151151
struct breakpoint *breakpoint);
152152
int esp_common_handle_gdb_detach(struct target *target);
153153
int esp_common_process_flash_breakpoints_command(struct command_invocation *cmd);
154+
int esp_common_disable_lazy_breakpoints_command(struct command_invocation *cmd);
154155
int esp_dbgstubs_table_read(struct target *target, struct esp_dbg_stubs *dbg_stubs);
155156

156157
void esp_common_assist_debug_monitor_disable(struct target *target, uint32_t address, uint32_t *value);

src/target/espressif/esp32.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,6 @@ static const struct esp_flash_breakpoint_ops esp32_flash_brp_ops = {
440440
.breakpoint_prepare = esp_algo_flash_breakpoint_prepare,
441441
.breakpoint_add = esp_algo_flash_breakpoint_add,
442442
.breakpoint_remove = esp_algo_flash_breakpoint_remove,
443-
.breakpoint_lazy_process = true,
444443
};
445444

446445
static const struct esp_xtensa_smp_chip_ops esp32_chip_ops = {

src/target/espressif/esp32c2.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ static const struct esp_flash_breakpoint_ops esp32c2_flash_brp_ops = {
119119
.breakpoint_prepare = esp_algo_flash_breakpoint_prepare,
120120
.breakpoint_add = esp_algo_flash_breakpoint_add,
121121
.breakpoint_remove = esp_algo_flash_breakpoint_remove,
122-
.breakpoint_lazy_process = true,
123122
};
124123

125124
static int esp32c2_target_create(struct target *target, Jim_Interp *interp)

src/target/espressif/esp32c3.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ static const struct esp_flash_breakpoint_ops esp32c3_flash_brp_ops = {
135135
.breakpoint_prepare = esp_algo_flash_breakpoint_prepare,
136136
.breakpoint_add = esp_algo_flash_breakpoint_add,
137137
.breakpoint_remove = esp_algo_flash_breakpoint_remove,
138-
.breakpoint_lazy_process = true,
139138
};
140139

141140
static int esp32c3_target_create(struct target *target, Jim_Interp *interp)

src/target/espressif/esp32c5.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ static const struct esp_flash_breakpoint_ops esp32c5_flash_brp_ops = {
4545
.breakpoint_prepare = esp_algo_flash_breakpoint_prepare,
4646
.breakpoint_add = esp_algo_flash_breakpoint_add,
4747
.breakpoint_remove = esp_algo_flash_breakpoint_remove,
48-
.breakpoint_lazy_process = true,
4948
};
5049

5150
static const char *esp32c5_csrs[] = {

src/target/espressif/esp32c6.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ static const struct esp_flash_breakpoint_ops esp32c6_flash_brp_ops = {
138138
.breakpoint_prepare = esp_algo_flash_breakpoint_prepare,
139139
.breakpoint_add = esp_algo_flash_breakpoint_add,
140140
.breakpoint_remove = esp_algo_flash_breakpoint_remove,
141-
.breakpoint_lazy_process = true,
142141
};
143142

144143
static const char *esp32c6_csrs[] = {

src/target/espressif/esp32c61.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ static const struct esp_flash_breakpoint_ops esp32c61_flash_brp_ops = {
4545
.breakpoint_prepare = esp_algo_flash_breakpoint_prepare,
4646
.breakpoint_add = esp_algo_flash_breakpoint_add,
4747
.breakpoint_remove = esp_algo_flash_breakpoint_remove,
48-
.breakpoint_lazy_process = true,
4948
};
5049

5150
static const char *esp32c61_csrs[] = {

src/target/espressif/esp32h2.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ static const struct esp_flash_breakpoint_ops esp32h2_flash_brp_ops = {
130130
.breakpoint_prepare = esp_algo_flash_breakpoint_prepare,
131131
.breakpoint_add = esp_algo_flash_breakpoint_add,
132132
.breakpoint_remove = esp_algo_flash_breakpoint_remove,
133-
.breakpoint_lazy_process = true,
134133
};
135134

136135
static const char *esp32h2_csrs[] = {

src/target/espressif/esp32p4.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ static const struct esp_flash_breakpoint_ops esp32p4_flash_brp_ops = {
168168
.breakpoint_prepare = esp_algo_flash_breakpoint_prepare,
169169
.breakpoint_add = esp_algo_flash_breakpoint_add,
170170
.breakpoint_remove = esp_algo_flash_breakpoint_remove,
171-
.breakpoint_lazy_process = true,
172171
};
173172

174173
static const char *esp32p4_csrs[] = {

0 commit comments

Comments
 (0)