massive feat: added a GDB stub for debugging
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
@@ -4,11 +4,19 @@
|
||||
#include "bus.hh"
|
||||
#include "cpu/psr.hh"
|
||||
#include "thumb/instruction.hh"
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
#include <cstdint>
|
||||
#ifdef GDB_DEBUG
|
||||
#include <unordered_set>
|
||||
#endif
|
||||
|
||||
namespace matar {
|
||||
|
||||
#ifdef GDB_DEBUG
|
||||
class GdbRsp;
|
||||
#endif
|
||||
|
||||
class Cpu {
|
||||
public:
|
||||
Cpu(std::shared_ptr<Bus>) noexcept;
|
||||
@@ -16,24 +24,12 @@ class Cpu {
|
||||
void step();
|
||||
void chg_mode(const Mode to);
|
||||
|
||||
bool is_flushed = false;
|
||||
inline void flush_pipeline() {
|
||||
is_flushed = true;
|
||||
if (cpsr.state() == State::Arm) {
|
||||
opcodes[0] = bus->read_word(pc, false);
|
||||
advance_pc_arm();
|
||||
opcodes[1] = bus->read_word(pc);
|
||||
advance_pc_arm();
|
||||
} else {
|
||||
opcodes[0] = bus->read_halfword(pc, false);
|
||||
advance_pc_thumb();
|
||||
opcodes[1] = bus->read_halfword(pc);
|
||||
advance_pc_thumb();
|
||||
}
|
||||
sequential = true;
|
||||
};
|
||||
inline bool is_halted() { return halted; }
|
||||
inline void resume() { halted = false; }
|
||||
|
||||
private:
|
||||
bool halted = false;
|
||||
|
||||
friend void arm::Instruction::exec(Cpu& cpu);
|
||||
friend void thumb::Instruction::exec(Cpu& cpu);
|
||||
|
||||
@@ -93,5 +89,26 @@ class Cpu {
|
||||
|
||||
inline void advance_pc_arm() { pc += arm::INSTRUCTION_SIZE; };
|
||||
inline void advance_pc_thumb() { pc += thumb::INSTRUCTION_SIZE; }
|
||||
|
||||
bool is_flushed = false;
|
||||
inline void flush_pipeline() {
|
||||
if (cpsr.state() == State::Arm) {
|
||||
opcodes[0] = bus->read_word(pc, false);
|
||||
advance_pc_arm();
|
||||
opcodes[1] = bus->read_word(pc);
|
||||
advance_pc_arm();
|
||||
} else {
|
||||
opcodes[0] = bus->read_halfword(pc, false);
|
||||
advance_pc_thumb();
|
||||
opcodes[1] = bus->read_halfword(pc);
|
||||
advance_pc_thumb();
|
||||
}
|
||||
sequential = true;
|
||||
};
|
||||
|
||||
#ifdef GDB_DEBUG
|
||||
friend class GdbRsp;
|
||||
std::unordered_set<uint32_t> breakpoints = {};
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user