feat(npc): add mtrace
This commit is contained in:
parent
4c07b66093
commit
9f64a88f8d
12 changed files with 110 additions and 123 deletions
|
@ -37,11 +37,13 @@ private:
|
|||
Handler{{"si", "step-instruction"}, &SDBHandlers::cmd_step},
|
||||
Handler{{"info-r"}, &SDBHandlers::cmd_info_registers},
|
||||
Handler{{"p", "print"}, &SDBHandlers::cmd_print},
|
||||
Handler{{"disas", "disassemble"}, &SDBHandlers::cmd_disassemble},
|
||||
};
|
||||
int cmd_continue(const cr::Console::Arguments &input);
|
||||
int cmd_step(const std::vector<std::string> &input);
|
||||
int cmd_info_registers(const std::vector<std::string> &input);
|
||||
int cmd_print(const std::vector<std::string> &input);
|
||||
int cmd_disassemble(const std::vector<std::string> &input);
|
||||
int exec_catch(uint64_t);
|
||||
|
||||
public:
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <components.hpp>
|
||||
#include <console.hpp>
|
||||
#include <cstdint>
|
||||
#include <disasm.hpp>
|
||||
#include <sdb.hpp>
|
||||
#include <stdexcept>
|
||||
|
@ -18,6 +19,8 @@ std::ostream &operator<<(std::ostream &os, const TrmInterface &d) {
|
|||
return os;
|
||||
};
|
||||
|
||||
Disassembler d{"riscv32-linux-pc-gnu"};
|
||||
|
||||
namespace SDB {
|
||||
|
||||
int SDBHandlers::exec_catch(uint64_t n) {
|
||||
|
@ -83,6 +86,21 @@ int SDBHandlers::cmd_print(const std::vector<std::string> &input) {
|
|||
return SDB_SUCCESS;
|
||||
}
|
||||
|
||||
int SDBHandlers::cmd_disassemble(const std::vector<std::string> &input) {
|
||||
word_t buf[2];
|
||||
word_t addr = parse_expr(input[1].c_str());
|
||||
this->funcs.memcpy(addr, &buf, sizeof(word_t), TRM_FROM_MACHINE);
|
||||
// TODO: Difftest only
|
||||
std::cout << "dut: \n"
|
||||
<< d.disassemble(addr, (uint8_t *)&buf[0], sizeof(word_t))
|
||||
<< std::endl
|
||||
<< "ref: \n"
|
||||
<< d.disassemble(addr, (uint8_t *)&buf[0], sizeof(word_t))
|
||||
<< std::endl;
|
||||
;
|
||||
return SDB_SUCCESS;
|
||||
}
|
||||
|
||||
void SDBHandlers::register_handlers(cr::Console *c) {
|
||||
for (auto &h : this->all_handlers) {
|
||||
for (auto &name : h.names) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue