@@ -5392,7 +5392,9 @@ static int riscv013_step_or_resume_current_hart(struct target *target,
5392
5392
LOG_TARGET_ERROR (target , "Hart is not halted!" );
5393
5393
return ERROR_FAIL ;
5394
5394
}
5395
- LOG_TARGET_DEBUG (target , "resuming (for step?=%d)" , step );
5395
+
5396
+ LOG_TARGET_DEBUG (target , "resuming (operation=%s)" ,
5397
+ step ? "single-step" : "resume" );
5396
5398
5397
5399
if (riscv_reg_flush_all (target ) != ERROR_OK )
5398
5400
return ERROR_FAIL ;
@@ -5425,16 +5427,26 @@ static int riscv013_step_or_resume_current_hart(struct target *target,
5425
5427
return ERROR_OK ;
5426
5428
}
5427
5429
5430
+ LOG_TARGET_ERROR (target , "Failed to %s. dmstatus=0x%08x" ,
5431
+ step ? "single-step" : "resume" , dmstatus );
5432
+
5428
5433
dm_write (target , DM_DMCONTROL , dmcontrol );
5434
+ LOG_TARGET_ERROR (target ,
5435
+ " cancelling the resume request (dmcontrol.resumereq <- 0)" );
5429
5436
5430
- LOG_TARGET_ERROR (target , "unable to resume" );
5431
5437
if (dmstatus_read (target , & dmstatus , true) != ERROR_OK )
5432
5438
return ERROR_FAIL ;
5433
- LOG_TARGET_ERROR (target , " dmstatus=0x%08x" , dmstatus );
5439
+
5440
+ LOG_TARGET_ERROR (target , " dmstatus after cancellation=0x%08x" , dmstatus );
5434
5441
5435
5442
if (step ) {
5436
- LOG_TARGET_ERROR (target , " was stepping, halting" );
5437
- riscv_halt (target );
5443
+ LOG_TARGET_ERROR (target ,
5444
+ " trying to recover from a failed single-step, by requesting halt" );
5445
+ if (riscv_halt (target ) == ERROR_OK )
5446
+ LOG_TARGET_ERROR (target , " halt completed after failed single-step" );
5447
+ else
5448
+ LOG_TARGET_ERROR (target , " could not halt, something is wrong with the taget" );
5449
+ // TODO: returning ERROR_OK is questionable, this code needs to be revised
5438
5450
return ERROR_OK ;
5439
5451
}
5440
5452
0 commit comments