@@ -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+
518539int 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+
528566static int esp_callback_event_handler (struct target * target , enum target_event event , void * priv )
529567{
530568 switch (event ) {
0 commit comments