diff options
| author | Alastair Reid | 2018-06-27 22:06:10 +0100 |
|---|---|---|
| committer | Alastair Reid | 2018-06-27 22:06:18 +0100 |
| commit | d0c42e9526fe3b116afccb1e8f7864c8115f05e7 (patch) | |
| tree | 1c073a566f45b7453707d055d38038c4a9c195d1 /lib | |
| parent | 028c67766b0bcbd453dbdeab609267bdce56b290 (diff) | |
RTS/Main: tweaking cycle counter handling
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/rts.c | 11 | ||||
| -rw-r--r-- | lib/rts.h | 5 |
2 files changed, 13 insertions, 3 deletions
@@ -7,6 +7,8 @@ #include"elf.h" static uint64_t g_elf_entry; +static uint64_t g_cycle_count = 0; +static uint64_t g_cycle_limit; void sail_match_failure(sail_string msg) { @@ -23,6 +25,7 @@ unit sail_assert(bool b, sail_string msg) unit sail_exit(unit u) { + fprintf(stderr, "[Sail] Exiting after %lld cycles\n", g_cycle_count); exit(EXIT_SUCCESS); return UNIT; } @@ -344,9 +347,6 @@ void elf_tohost(mpz_t *rop, const unit u) /* ***** Cycle limit ***** */ -static uint64_t g_cycle_count = 0; -static uint64_t g_cycle_limit; - /* NB Also increments cycle_count */ bool cycle_limit_reached(const unit u) { @@ -362,6 +362,11 @@ unit cycle_count(const unit u) return UNIT; } +void get_cycle_count(sail_int *rop, const unit u) +{ + mpz_init_set_ui(*rop, g_cycle_count); +} + /* ***** Argument Parsing ***** */ static struct option options[] = { @@ -109,10 +109,15 @@ void trace_end(void); * Functions for counting and limiting cycles */ +// increment cycle count and test if over limit bool cycle_limit_reached(const unit); +// increment cycle count and abort if over unit cycle_count(const unit); +// read cycle count +void get_cycle_count(sail_int *rop, const unit); + /* * Functions to get info from ELF files. */ |
