@@ -5385,7 +5385,9 @@ static int riscv013_step_or_resume_current_hart(struct target *target,
53855385 LOG_TARGET_ERROR (target , "Hart is not halted!" );
53865386 return ERROR_FAIL ;
53875387 }
5388- LOG_TARGET_DEBUG (target , "resuming (for step?=%d)" , step );
5388+
5389+ LOG_TARGET_DEBUG (target , "resuming (operation=%s)" ,
5390+ step ? "single-step" : "resume" );
53895391
53905392 if (riscv_reg_flush_all (target ) != ERROR_OK )
53915393 return ERROR_FAIL ;
@@ -5418,16 +5420,26 @@ static int riscv013_step_or_resume_current_hart(struct target *target,
54185420 return ERROR_OK ;
54195421 }
54205422
5423+ LOG_TARGET_ERROR (target , "Failed to %s. dmstatus=0x%08x" ,
5424+ step ? "single-step" : "resume" , dmstatus );
5425+
54215426 dm_write (target , DM_DMCONTROL , dmcontrol );
5427+ LOG_TARGET_ERROR (target ,
5428+ " cancelling the resume request (dmcontrol.resumereq <- 0)" );
54225429
5423- LOG_TARGET_ERROR (target , "unable to resume" );
54245430 if (dmstatus_read (target , & dmstatus , true) != ERROR_OK )
54255431 return ERROR_FAIL ;
5426- LOG_TARGET_ERROR (target , " dmstatus=0x%08x" , dmstatus );
5432+
5433+ LOG_TARGET_ERROR (target , " dmstatus after cancellation=0x%08x" , dmstatus );
54275434
54285435 if (step ) {
5429- LOG_TARGET_ERROR (target , " was stepping, halting" );
5430- riscv_halt (target );
5436+ LOG_TARGET_ERROR (target ,
5437+ " trying to recover from a failed single-step, by requesting halt" );
5438+ if (riscv_halt (target ) == ERROR_OK )
5439+ LOG_TARGET_ERROR (target , " halt completed after failed single-step" );
5440+ else
5441+ LOG_TARGET_ERROR (target , " could not halt, something is wrong with the taget" );
5442+ // TODO: returning ERROR_OK is questionable, this code needs to be revised
54315443 return ERROR_OK ;
54325444 }
54335445
0 commit comments