catch sigterm to gracefully exit (fixes vcd)
This commit is contained in:
parent
7330deb13a
commit
6d47d18c2b
@ -1,5 +1,6 @@
|
||||
#include "htif_phy.h"
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <map>
|
||||
@ -10,6 +11,12 @@
|
||||
#include "Top.h" // chisel-generated code...
|
||||
#include "disasm.h"
|
||||
|
||||
static bool exit_now = false;
|
||||
void handle_sigterm(int signum)
|
||||
{
|
||||
exit_now = true;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int fromhost_fd = -1, tohost_fd = -1;
|
||||
@ -25,6 +32,8 @@ int main(int argc, char** argv)
|
||||
const char* failure = NULL;
|
||||
disassembler disasm;
|
||||
|
||||
signal(SIGTERM, handle_sigterm);
|
||||
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
std::string arg = argv[i];
|
||||
@ -90,7 +99,7 @@ int main(int argc, char** argv)
|
||||
|
||||
htif_phy_t htif_phy(tile.Top__io_host_in_bits.width(), fromhost_fd, tohost_fd);
|
||||
|
||||
while (max_cycles == 0 || trace_count < max_cycles)
|
||||
while (!exit_now)
|
||||
{
|
||||
// fprintf(stderr, "trace count: %ld\n", trace_count);
|
||||
// memory model
|
||||
@ -169,7 +178,7 @@ int main(int argc, char** argv)
|
||||
tile.clock_hi(LIT<1>(0));
|
||||
trace_count++;
|
||||
|
||||
if (trace_count == max_cycles)
|
||||
if (max_cycles != 0 && trace_count == max_cycles)
|
||||
{
|
||||
failure = "timeout";
|
||||
break;
|
||||
|
@ -79,7 +79,7 @@ output/%.out: output/%.hex emulator
|
||||
fesvr -c -testrun -m3000000 -l +loadmem=$< none 2> $@
|
||||
|
||||
output/%.vpd: output/%.hex emulator-debug
|
||||
fesvr -c./emulator-debug -testrun -m3000000 -l -v- +loadmem=$< none 2> $(patsubst %.vpd,%.out,$@) | vcd2vpd - $@ > /dev/null
|
||||
fesvr -c./emulator-debug -testrun -m3000000 -l -v- +loadmem=$< none 2> $(patsubst %.vpd,%.out,$@) | vcd2vpd - $@ > /dev/null && [ $$PIPESTATUS -eq 0 ]
|
||||
|
||||
run-asm-tests: $(addprefix output/, $(addsuffix .out, $(global_asm_tests) $(global_asm_vm_tests)))
|
||||
@echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' $^; echo;
|
||||
|
Loading…
Reference in New Issue
Block a user