@@ -5392,7 +5392,9 @@ static int riscv013_step_or_resume_current_hart(struct target *target,
53925392 LOG_TARGET_ERROR (target , "Hart is not halted!" );
53935393 return ERROR_FAIL ;
53945394 }
5395- LOG_TARGET_DEBUG (target , "resuming (for step?=%d)" , step );
5395+
5396+ LOG_TARGET_DEBUG (target , "resuming (operation=%s)" ,
5397+ step ? "single-step" : "resume" );
53965398
53975399 if (riscv_reg_flush_all (target ) != ERROR_OK )
53985400 return ERROR_FAIL ;
@@ -5425,16 +5427,26 @@ static int riscv013_step_or_resume_current_hart(struct target *target,
54255427 return ERROR_OK ;
54265428 }
54275429
5430+ LOG_TARGET_ERROR (target , "Failed to %s. dmstatus=0x%08x" ,
5431+ step ? "single-step" : "resume" , dmstatus );
5432+
54285433 dm_write (target , DM_DMCONTROL , dmcontrol );
5434+ LOG_TARGET_ERROR (target ,
5435+ " cancelling the resume request (dmcontrol.resumereq <- 0)" );
54295436
5430- LOG_TARGET_ERROR (target , "unable to resume" );
54315437 if (dmstatus_read (target , & dmstatus , true) != ERROR_OK )
54325438 return ERROR_FAIL ;
5433- LOG_TARGET_ERROR (target , " dmstatus=0x%08x" , dmstatus );
5439+
5440+ LOG_TARGET_ERROR (target , " dmstatus after cancellation=0x%08x" , dmstatus );
54345441
54355442 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
54385450 return ERROR_OK ;
54395451 }
54405452
0 commit comments