application exit error handing
This commit is contained in:
@@ -15,7 +15,7 @@ SRCS = util.cpp args.cpp mem.cpp pipeline.cpp warp.cpp core.cpp decode.cpp execu
|
||||
|
||||
# Debugigng
|
||||
ifdef DEBUG
|
||||
CXXFLAGS += $(DBG_FLAGS)
|
||||
CXXFLAGS += -DDEBUG_LEVEL=3
|
||||
else
|
||||
CXXFLAGS += -DNDEBUG
|
||||
endif
|
||||
|
||||
@@ -91,6 +91,8 @@ void Core::clear() {
|
||||
|
||||
inst_in_schedule_.valid = true;
|
||||
warps_[0]->setTmask(0, true);
|
||||
|
||||
ebreak_ = false;
|
||||
}
|
||||
|
||||
void Core::step() {
|
||||
@@ -377,4 +379,12 @@ void Core::writeToStdOut(Addr addr, Word data) {
|
||||
std::cout << std::dec << "#" << tid << ": " << ss_buf.str() << std::flush;
|
||||
ss_buf.str("");
|
||||
}
|
||||
}
|
||||
|
||||
void Core::trigger_ebreak() {
|
||||
ebreak_ = true;
|
||||
}
|
||||
|
||||
bool Core::check_ebreak() const {
|
||||
return ebreak_;
|
||||
}
|
||||
@@ -70,7 +70,10 @@ public:
|
||||
|
||||
Word dcache_read(Addr, Size);
|
||||
|
||||
void dcache_write(Addr, Word, Size);
|
||||
void dcache_write(Addr, Word, Size);
|
||||
|
||||
void trigger_ebreak();
|
||||
bool check_ebreak() const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -101,6 +104,8 @@ private:
|
||||
RAM shared_mem_;
|
||||
#endif
|
||||
|
||||
bool ebreak_;
|
||||
|
||||
Pipeline inst_in_schedule_;
|
||||
Pipeline inst_in_fetch_;
|
||||
Pipeline inst_in_decode_;
|
||||
|
||||
12
simX/debug.h
12
simX/debug.h
@@ -1,11 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
//#define USE_DEBUG 3
|
||||
#ifndef DEBUG_LEVEL
|
||||
#define DEBUG_LEVEL 3
|
||||
#endif
|
||||
|
||||
#define DEBUG_HEADER << "DEBUG "
|
||||
//#define DEBUG_HEADER << "DEBUG " << __FILE__ << ':' << std::dec << __LINE__ << ": "
|
||||
|
||||
#ifdef USE_DEBUG
|
||||
#ifndef NDEBUG
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
@@ -13,19 +15,19 @@
|
||||
#define DX(x) x
|
||||
|
||||
#define D(lvl, x) do { \
|
||||
if ((lvl) <= USE_DEBUG) { \
|
||||
if ((lvl) <= DEBUG_LEVEL) { \
|
||||
std::cout DEBUG_HEADER << x << std::endl; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define DPH(lvl, x) do { \
|
||||
if ((lvl) <= USE_DEBUG) { \
|
||||
if ((lvl) <= DEBUG_LEVEL) { \
|
||||
std::cout DEBUG_HEADER << x; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define DPN(lvl, x) do { \
|
||||
if ((lvl) <= USE_DEBUG) { \
|
||||
if ((lvl) <= DEBUG_LEVEL) { \
|
||||
std::cout << x; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
@@ -402,9 +402,7 @@ void Warp::execute(const Instr &instr, Pipeline *pipeline) {
|
||||
case 0:
|
||||
if (csr_addr < 2) {
|
||||
// ECALL/EBREAK
|
||||
tmask_.reset();
|
||||
active_ = tmask_.any();
|
||||
pipeline->stall_warp = true;
|
||||
core_->trigger_ebreak();
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
|
||||
@@ -67,24 +67,33 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
bool running;
|
||||
int exitcode = 0;
|
||||
do {
|
||||
running = false;
|
||||
for (auto& core : cores) {
|
||||
core->step();
|
||||
if (core->running())
|
||||
if (core->running()) {
|
||||
running = true;
|
||||
}
|
||||
if (core->check_ebreak()) {
|
||||
exitcode = core->getIRegValue(3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (running);
|
||||
|
||||
if (riscv_test) {
|
||||
bool status = (1 == cores[0]->getIRegValue(3));
|
||||
if (status) {
|
||||
if (1 == exitcode) {
|
||||
std::cout << "Passed." << std::endl;
|
||||
exitcode = 0;
|
||||
} else {
|
||||
std::cout << "Failed." << std::endl;
|
||||
return -1;
|
||||
std::cout << "Failed." << std::endl;
|
||||
}
|
||||
} else {
|
||||
if (exitcode != 0) {
|
||||
std::cout << "*** error: exitcode=" << exitcode << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return exitcode;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user