forked from sysprogs/msp430-gdbproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMSP430Target.h
104 lines (85 loc) · 3.54 KB
/
MSP430Target.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#pragma once
#include "GDBServerFoundation/GDBServer.h"
#include "GDBServerFoundation/GDBStub.h"
#include "GDBServerFoundation/IGDBTarget.h"
#include "TI/Inc/MSP430_Debug.h"
#include "registers-msp430.h"
#include <vector>
#include "settings.h"
enum MSP430_MSG;
namespace MSP430Proxy
{
using namespace GDBServerFoundation;
//! Implements debugging functionality without the EEM API (not supporting data breakpoints and software breakpoints).
/*!
\remarks After creating an instance of this class please call the Initialize() method.
*/
class MSP430GDBTarget : public ISyncGDBTarget, public IFLASHProgrammer
{
protected:
DEVICE_T m_DeviceInfo;
bool m_bVerbose;
private:
bool m_bClosePending, m_bValid;
std::vector<bool> m_UsedBreakpoints;
bool m_bFLASHErased, m_bDetached;
bool m_b32BitRegisterMode;
bool m_bEraseInfoMem;
protected:
bool m_BreakInPending, m_bFLASHCommandsUsed;
protected:
virtual bool WaitForJTAGEvent();
void ReportLastMSP430Error(const char *pHint);
virtual bool DoResumeTarget(RUN_MODES_t mode);
protected:
MSP430GDBTarget()
: m_bClosePending(false)
, m_bValid(false)
, m_bVerbose(false)
, m_BreakInPending(false)
, m_bFLASHErased(false)
, m_bDetached(false)
, m_bFLASHCommandsUsed(false)
, m_b32BitRegisterMode(false)
, m_bEraseInfoMem(false)
{
}
public:
~MSP430GDBTarget();
//! Starts debugging session
virtual bool Initialize(const GlobalSettings &settings);
virtual GDBStatus GetLastStopRecord(TargetStopRecord *pRec);
virtual GDBStatus ResumeAndWait(int threadID);
virtual GDBStatus Step(int threadID);
virtual GDBStatus SendBreakInRequestAsync();
virtual const PlatformRegisterList *GetRegisterList()
{
if (m_b32BitRegisterMode)
return &GDBServerFoundation::MSP430_32bitRegs::RegisterList;
else
return &GDBServerFoundation::MSP430::RegisterList;
}
public: //Register accessing API
virtual GDBStatus ReadFrameRelatedRegisters(int threadID, RegisterSetContainer ®isters);
virtual GDBStatus ReadTargetRegisters(int threadID, RegisterSetContainer ®isters);
virtual GDBStatus WriteTargetRegisters(int threadID, const RegisterSetContainer ®isters);
public: //Memory accessing API
virtual GDBStatus ReadTargetMemory(ULONGLONG Address, void *pBuffer, size_t *pSizeInBytes);
virtual GDBStatus WriteTargetMemory(ULONGLONG Address, const void *pBuffer, size_t sizeInBytes);
public: //Optional methods, can be left unimplemented
virtual GDBStatus GetDynamicLibraryList(std::vector<DynamicLibraryRecord> &libraries);
virtual GDBStatus GetThreadList(std::vector<ThreadRecord> &threads);
virtual GDBStatus SetThreadModeForNextCont(int threadID, DebugThreadMode mode, OUT bool *pNeedRestoreCall, IN OUT INT_PTR *pRestoreCookie);
virtual GDBStatus Terminate();
virtual GDBStatus CreateBreakpoint(BreakpointType type, ULONGLONG Address, unsigned kind, OUT INT_PTR *pCookie);
virtual GDBStatus RemoveBreakpoint(BreakpointType type, ULONGLONG Address, INT_PTR Cookie);
virtual GDBStatus ExecuteRemoteCommand(const std::string &command, std::string &output);
virtual IFLASHProgrammer *GetFLASHProgrammer() {return this;}
public:
virtual GDBStatus GetEmbeddedMemoryRegions(std::vector<EmbeddedMemoryRegion> ®ions);
virtual GDBStatus EraseFLASH(ULONGLONG addr, size_t length);
virtual GDBStatus WriteFLASH(ULONGLONG addr, const void *pBuffer, size_t length);
virtual GDBStatus CommitFLASHWrite();
virtual void CloseSessionSafely() {}
};
}