SoftwareBreakpointManager.h
Go to the documentation of this file.
1 #pragma once
2 #include <vector>
3 #include <list>
4 
5 namespace MSP430Proxy
6 {
8 
18  {
19  public:
21  {
30  };
31 
32  private:
33  unsigned m_FlashStart, m_FlashEnd, m_FlashSize;
34  enum{MAIN_SEGMENT_SIZE = 512};
35 
37  struct SegmentRecord
38  {
39  unsigned BpState[MAIN_SEGMENT_SIZE / 2];
40  unsigned short OriginalInstructions[MAIN_SEGMENT_SIZE /2];
41 
42  int PendingBreakpointCount, InactiveBreakpointCount;
43 
44  SegmentRecord()
45  {
46  memset(BpState, 0, sizeof(BpState));
47  memset(OriginalInstructions, 0, sizeof(OriginalInstructions));
48  PendingBreakpointCount = InactiveBreakpointCount = 0;
49  }
50 
51  bool SetBreakpoint(unsigned offset);
52  bool RemoveBreakpoint(unsigned offset);
53  };
54 
55  std::vector<SegmentRecord> m_Segments;
56  unsigned short m_BreakInstruction;
57 
58  bool m_bInstantCleanup;
59 
60  struct TranslatedAddr
61  {
62  bool Valid;
63  unsigned Segment, Offset;
64  };
65 
66  private:
67  TranslatedAddr TranslateAddress(unsigned addr);
68 
69  public:
71  bool SetBreakpoint(unsigned addr);
73  bool RemoveBreakpoint(unsigned addr);
75  bool CommitBreakpoints();
76 
78  BreakpointState GetBreakpointState(unsigned addr);
79 
81  bool GetOriginalInstruction(unsigned addr, unsigned short *pInsn);
82 
83  public:
85 
88  void HideOrRestoreBreakpointsInMemorySnapshot(unsigned addr, void *pBlock, size_t length, bool hideBreakpoints);
89 
90  public:
92 
103  SoftwareBreakpointManager(unsigned flashStart, unsigned flashEnd, unsigned short breakInstruction, bool instantCleanup);
104  };
105 }
106