Bug fix: check if vm exists
[avr-sim.git] / DebugInterface.h
blob61884e7bacb1379d1f80dbdb80c6405f49d7a58d
1 #ifndef AVR_DEBUGINTERFACE_H
2 #define AVR_DEBUGINTERFACE_H
4 #include "Types.h"
5 #include "Device.h"
6 #include <vector>
7 #include <iostream>
9 namespace avr {
11 class Core;
13 class DebugInterface {
14 public:
15 DebugInterface(Device & dev, Core & core);
16 ~DebugInterface();
18 public:
19 byte reg(int reg) const;
20 byte status() const;
21 word stackPointer() const;
22 dword programCounter() const;
24 public:
25 void setReg(int reg, byte val);
26 void setStatus(byte val);
27 void setStackPointer(word val);
28 void setProgramCounter(dword val);
30 public:
31 void reset();
32 void step();
33 bool stepDone() const;
35 public:
36 bool checkBreak(dword addr);
37 bool hasBreaked() const { return breaked; }
38 void insertBreak(dword addr);
39 void removeBreak(dword addr);
40 void deleteAllBreakpoints();
42 public:
43 const std::string & registerName(byte addr) const;
44 void trace(std::ostream & ostr, dword addr);
46 public:
47 const unsigned char *readRam(unsigned int offset, unsigned int size) const;
48 void writeRam(unsigned char *data, unsigned int offset, unsigned int size);
49 const unsigned char *readFlash(unsigned int offset, unsigned int size) const;
50 void writeFlash(unsigned char *data, unsigned int offset, unsigned int size);
51 const unsigned char *readEeprom(unsigned int offset, unsigned int size) const;
52 void writeEeprom(unsigned char *data, unsigned int offset, unsigned int size);
54 private:
55 Device & dev;
56 Core & core;
58 private:
59 typedef std::vector<dword> Breakpoints;
60 Breakpoints breakPoints;
61 bool breaked;
64 inline void DebugInterface::step() {
65 dev.step();
68 inline void DebugInterface::reset() {
69 dev.reset( SIM_RESET );
74 #endif /*AVR_DEBUGINTERFACE_H*/