MSP430Target.h
Go to the documentation of this file.
1 #pragma once
2 #include "../../GDBServerFoundation/GDBServer.h"
3 #include "../../GDBServerFoundation/GDBStub.h"
4 #include "../../GDBServerFoundation/IGDBTarget.h"
5 #include <MSP430_Debug.h>
6 
7 #include "registers-msp430.h"
8 #include <vector>
9 #include "settings.h"
10 
11 enum MSP430_MSG;
12 
13 namespace MSP430Proxy
14 {
15  using namespace GDBServerFoundation;
16 
18 
21  class MSP430GDBTarget : public ISyncGDBTarget, public IFLASHProgrammer
22  {
23  protected:
24  DEVICE_T m_DeviceInfo;
25 
26  private:
27  bool m_bClosePending, m_bValid;
28  std::vector<bool> m_UsedBreakpoints;
29 
30  bool m_bFLASHErased;
31 
32  protected:
33  bool m_BreakInPending, m_bFLASHCommandsUsed;
34 
35  protected:
36  virtual bool WaitForJTAGEvent();
37  void ReportLastMSP430Error(const char *pHint);
38  virtual bool DoResumeTarget(RUN_MODES_t mode);
39 
40  public:
42  : m_bClosePending(false)
43  , m_bValid(false)
44  , m_BreakInPending(false)
45  , m_bFLASHErased(false)
46  , m_bFLASHCommandsUsed(false)
47  {
48  }
49 
50  ~MSP430GDBTarget();
51 
53  virtual bool Initialize(const GlobalSettings &settings);
54 
55  virtual GDBStatus GetLastStopRecord(TargetStopRecord *pRec);
56  virtual GDBStatus ResumeAndWait(int threadID);
57  virtual GDBStatus Step(int threadID);
58  virtual GDBStatus SendBreakInRequestAsync();
59 
60  virtual const PlatformRegisterList *GetRegisterList()
61  {
63  }
64 
65  public: //Register accessing API
66  virtual GDBStatus ReadFrameRelatedRegisters(int threadID, RegisterSetContainer &registers);
67  virtual GDBStatus ReadTargetRegisters(int threadID, RegisterSetContainer &registers);
68  virtual GDBStatus WriteTargetRegisters(int threadID, const RegisterSetContainer &registers);
69 
70  public: //Memory accessing API
71  virtual GDBStatus ReadTargetMemory(ULONGLONG Address, void *pBuffer, size_t *pSizeInBytes);
72  virtual GDBStatus WriteTargetMemory(ULONGLONG Address, const void *pBuffer, size_t sizeInBytes);
73 
74  public: //Optional methods, can be left unimplemented
75  virtual GDBStatus GetDynamicLibraryList(std::vector<DynamicLibraryRecord> &libraries);
76  virtual GDBStatus GetThreadList(std::vector<ThreadRecord> &threads);
77  virtual GDBStatus SetThreadModeForNextCont(int threadID, DebugThreadMode mode, OUT bool *pNeedRestoreCall, IN OUT INT_PTR *pRestoreCookie);
78  virtual GDBStatus Terminate();
79 
80  virtual GDBStatus CreateBreakpoint(BreakpointType type, ULONGLONG Address, unsigned kind, OUT INT_PTR *pCookie);
81  virtual GDBStatus RemoveBreakpoint(BreakpointType type, ULONGLONG Address, INT_PTR Cookie);
82 
83  virtual GDBStatus ExecuteRemoteCommand(const std::string &command, std::string &output);
84 
85  virtual IFLASHProgrammer *GetFLASHProgrammer() {return this;}
86 
87  public:
88  virtual GDBStatus GetEmbeddedMemoryRegions(std::vector<EmbeddedMemoryRegion> &regions);
89  virtual GDBStatus EraseFLASH(ULONGLONG addr, size_t length);
90  virtual GDBStatus WriteFLASH(ULONGLONG addr, const void *pBuffer, size_t length);
91  virtual GDBStatus CommitFLASHWrite();
92  };
93 }