File tree Expand file tree Collapse file tree 4 files changed +17
-9
lines changed Expand file tree Collapse file tree 4 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -1074,9 +1074,11 @@ static bool runtime_profiler(riscv_t *rv, block_t *block)
1074
1074
typedef void (* exec_block_func_t )(riscv_t * rv , uintptr_t );
1075
1075
#endif
1076
1076
1077
- void rv_step (riscv_t * rv , int32_t cycles )
1077
+ void rv_step (riscv_t * rv )
1078
1078
{
1079
1079
assert (rv );
1080
+ vm_attr_t * attr = PRIV (rv );
1081
+ uint32_t cycles = attr -> cycle_per_step ;
1080
1082
1081
1083
/* find or translate a block for starting PC */
1082
1084
const uint64_t cycles_target = rv -> csr_cycle + cycles ;
Original file line number Diff line number Diff line change @@ -79,13 +79,15 @@ static inline bool rv_is_interrupt(riscv_t *rv)
79
79
static gdb_action_t rv_cont (void * args )
80
80
{
81
81
riscv_t * rv = (riscv_t * ) args ;
82
- const uint32_t cycles_per_step = 1 ;
82
+ assert (rv );
83
+ vm_attr_t * attr = PRIV (rv );
84
+ attr -> cycle_per_step = 1 ;
83
85
84
86
for (; !rv_has_halted (rv ) && !rv_is_interrupt (rv );) {
85
87
if (breakpoint_map_find (rv -> breakpoint_map , rv_get_pc (rv )))
86
88
break ;
87
89
88
- rv_step (rv , cycles_per_step );
90
+ rv_step (rv );
89
91
}
90
92
91
93
/* Clear the interrupt if it's pending */
@@ -97,7 +99,11 @@ static gdb_action_t rv_cont(void *args)
97
99
static gdb_action_t rv_stepi (void * args )
98
100
{
99
101
riscv_t * rv = (riscv_t * ) args ;
100
- rv_step (rv , 1 );
102
+ assert (rv );
103
+ vm_attr_t * attr = PRIV (rv );
104
+ attr -> cycle_per_step = 1 ;
105
+
106
+ rv_step (rv );
101
107
return ACT_RESUME ;
102
108
}
103
109
Original file line number Diff line number Diff line change @@ -276,19 +276,19 @@ static void rv_run_and_trace(riscv_t *rv)
276
276
277
277
vm_attr_t * attr = PRIV (rv );
278
278
assert (attr && attr -> data .user && attr -> data .user -> elf_program );
279
+ attr -> cycle_per_step = 1 ;
279
280
280
281
const char * prog_name = attr -> data .user -> elf_program ;
281
282
elf_t * elf = elf_new ();
282
283
assert (elf && elf_open (elf , prog_name ));
283
- const uint32_t cycles_per_step = 1 ;
284
284
285
285
for (; !rv_has_halted (rv );) { /* run until the flag is done */
286
286
/* trace execution */
287
287
uint32_t pc = rv_get_pc (rv );
288
288
const char * sym = elf_find_symbol (elf , pc );
289
289
printf ("%08x %s\n" , pc , (sym ? sym : "" ));
290
290
291
- rv_step (rv , cycles_per_step ); /* step instructions */
291
+ rv_step (rv ); /* step instructions */
292
292
}
293
293
294
294
elf_delete (elf );
@@ -316,8 +316,8 @@ void rv_run(riscv_t *rv)
316
316
#endif
317
317
else {
318
318
/* default main loop */
319
- for (; !rv_has_halted (rv );) /* run until the flag is done */
320
- rv_step (rv , attr -> cycle_per_step ); /* step instructions */
319
+ for (; !rv_has_halted (rv );) /* run until the flag is done */
320
+ rv_step (rv ); /* step instructions */
321
321
}
322
322
323
323
if (attr -> run_flag & RV_RUN_PROFILE ) {
Original file line number Diff line number Diff line change @@ -166,7 +166,7 @@ void rv_debug(riscv_t *rv);
166
166
#endif
167
167
168
168
/* step the RISC-V emulator */
169
- void rv_step (riscv_t * rv , int32_t cycles );
169
+ void rv_step (riscv_t * rv );
170
170
171
171
/* set the program counter of a RISC-V emulator */
172
172
bool rv_set_pc (riscv_t * rv , riscv_word_t pc );
You can’t perform that action at this time.
0 commit comments