- int status = gdb_wait_for_interrupt(client);
- if(status < 0) {
- fprintf(stderr, "cannot wait for int: %d\n", status);
- return 1;
- }
+ while(1) {
+ int status = gdb_check_for_interrupt(client);
+ if(status < 0) {
+ fprintf(stderr, "cannot check for int: %d\n", status);
+ return 1;
+ }
+
+ if(status == 1) {
+ stlink_force_debug(sl);
+ break;
+ }
+
+ stlink_status(sl);
+ if(sl->core_stat == STLINK_CORE_HALTED) {
+ break;
+ }