@@ -46,7 +46,7 @@ static void handle_signal(int sig)
4646
4747htif_t ::htif_t ()
4848 : mem(this ), entry(DRAM_BASE), sig_addr(0 ), sig_len(0 ),
49- tohost_addr (0 ), fromhost_addr(0 ), exitcode( 0 ), stopped(false ),
49+ tohost_addr (0 ), fromhost_addr(0 ), stopped(false ),
5050 syscall_proxy(this )
5151{
5252 signal (SIGINT, &handle_signal);
@@ -116,7 +116,7 @@ std::map<std::string, uint64_t> htif_t::load_payload(const std::string& payload,
116116 else
117117 throw std::runtime_error (
118118 " could not open " + payload + " ; searched paths:\n " +
119- " \t . (current directory)\n " +
119+ " \t . (current directory)\n " +
120120 " \t " + PREFIX TARGET_DIR + " (based on configured --prefix and --with-target)"
121121 );
122122 }
@@ -207,6 +207,14 @@ const char* htif_t::get_symbol(uint64_t addr)
207207 return it->second .c_str ();
208208}
209209
210+ bool htif_t::should_exit () const {
211+ return signal_exit || exitcode.has_value ();
212+ }
213+
214+ void htif_t::htif_exit (int exit_code) {
215+ exitcode = exit_code;
216+ }
217+
210218void htif_t::stop ()
211219{
212220 if (!sig_file.empty () && sig_len) // print final torture test signature
@@ -253,11 +261,11 @@ int htif_t::run()
253261 std::bind (enq_func, &fromhost_queue, std::placeholders::_1);
254262
255263 if (tohost_addr == 0 ) {
256- while (!signal_exit )
264+ while (!should_exit () )
257265 idle ();
258266 }
259267
260- while (!signal_exit && exitcode == 0 )
268+ while (!should_exit () )
261269 {
262270 uint64_t tohost;
263271
@@ -305,7 +313,7 @@ bool htif_t::done()
305313
306314int htif_t::exit_code ()
307315{
308- return exitcode >> 1 ;
316+ return exitcode. value_or ( 0 ) >> 1 ;
309317}
310318
311319void htif_t::parse_arguments (int argc, char ** argv)
0 commit comments