feat: process custom gdb commands

This commit is contained in:
xinyangli 2024-07-22 16:20:19 +08:00
parent 46c943dea9
commit 5228b6117d
Signed by: xin
SSH key fingerprint: SHA256:qZ/tzd8lYRtUFSrfBDBMcUqV4GHKxqeqRA3huItgvbk
9 changed files with 164 additions and 39 deletions

View file

@ -53,10 +53,11 @@ class Target {
public:
DiffTargetApi ops;
TargetMeta meta;
arch_info_t arch;
size_t argsize;
std::vector<uint8_t> args; // used as a buffer to store target specific values
bool *do_difftest;
arch_info_t *isa_arch_info;
size_t *dbg_state_size;
gdb_action_t last_res;
Target(){};
@ -68,4 +69,4 @@ public:
bool is_on_breakpoint(const gdb_action_t &res) const;
};
#endif
#endif

View file

@ -10,6 +10,8 @@ struct Config {
std::vector<std::string> refs_prefix;
std::filesystem::path dut;
std::string dut_prefix = "";
std::string gdbstub_addr = "/tmp/gdbstub-diffu.sock";
bool use_debugger = false;
int cli_parse(int argc, char **argv);
};

View file

@ -16,8 +16,19 @@ private:
// target used for read_reg, write_reg, read_mem, write_mem
Target *current_target = &dut;
bool halt_status = false;
inline void start_run() {
__atomic_store_n(&halt_status, false, __ATOMIC_RELAXED);
};
inline bool is_halt() {
return __atomic_load_n(&halt_status, __ATOMIC_RELAXED);
};
bool exec(size_t n, gdb_action_t *ret);
struct ExecRet {
bool at_breakpoint;
bool do_difftest;
};
ExecRet exec(size_t n, gdb_action_t *ret);
public:
Difftest(Target &&dut, std::vector<Target> &&refs);
@ -35,14 +46,16 @@ public:
bool del_bp(size_t addr, bp_type_t type);
bool check_all();
int sync_regs_to_ref(void);
arch_info_t get_arch() const {
std::cout << dut.arch.reg_num << std::endl;
return dut.arch;
}
inline void halt() {
__atomic_store_n(&halt_status, true, __ATOMIC_RELAXED);
};
arch_info_t get_arch() const { return *dut.isa_arch_info; }
static bool check(Target &dut, Target &ref) {
for (int r = 0; r < dut.arch.reg_num; r++) {
for (int r = 0; r < dut.isa_arch_info->reg_num; r++) {
size_t regdut = 0, regref = 0;
dut.ops.read_reg(dut.args.data(), r, &regdut);
ref.ops.read_reg(ref.args.data(), r, &regref);
@ -92,4 +105,4 @@ public:
Iterator end() { return Iterator(*this, refs.size(), false); }
};
#endif
#endif