IGDBTarget.h
Go to the documentation of this file.
1 #pragma once
2 #include <bzscore/string.h>
3 #include "signals.h"
4 #include "GDBRegisters.h"
5 #include <vector>
6 #include <string>
7 
8 namespace GDBServerFoundation
9 {
11  enum GDBStatus
12  {
18  kGDBNotSupported = 0x1000,
19  };
20 
23  {
32  };
33 
36  {
47  };
48 
51  {
58  };
59 
62  {
64  std::string FullPath;
66  /*
67  \attention For Windows DLLs this should be the actual base address + 0x1000
68  */
69  ULONGLONG LoadAddress;
70  };
71 
73  struct ThreadRecord
74  {
76  int ThreadID;
78  std::string UserFriendlyName;
79  };
80 
83  {
87  ULONGLONG Start;
89  ULONGLONG Length;
91 
94  unsigned ErasureBlockSize;
95 
98  {
99  }
100 
102  EmbeddedMemoryRegion(EmbeddedMemoryType type, ULONGLONG start, ULONGLONG length, unsigned erasureBlockSize = 0)
103  : Type(type)
104  , Start(start)
105  , Length(length)
106  , ErasureBlockSize(erasureBlockSize)
107  {
108  }
109  };
110 
112 
118  {
119  public:
121  virtual GDBStatus GetEmbeddedMemoryRegions(std::vector<EmbeddedMemoryRegion> &regions)=0;
123 
128  virtual GDBStatus EraseFLASH(ULONGLONG Address, size_t length)=0;
130 
134  virtual GDBStatus WriteFLASH(ULONGLONG Address, const void *pBuffer, size_t length)=0;
135 
137  virtual GDBStatus CommitFLASHWrite()=0;
138  };
139 
141 
145  {
146  public: //General target info
148 
154  virtual const PlatformRegisterList *GetRegisterList()=0;
155 
156  public: //Register accessing API
158 
181  virtual GDBStatus ReadFrameRelatedRegisters(int threadID, RegisterSetContainer &registers)=0;
182 
184 
187  virtual GDBStatus ReadTargetRegisters(int threadID, RegisterSetContainer &registers)=0;
188 
190 
211  virtual GDBStatus WriteTargetRegisters(int threadID, const RegisterSetContainer &registers)=0;
212 
213  public: //Memory accessing API
215  virtual GDBStatus ReadTargetMemory(ULONGLONG Address, void *pBuffer, size_t *pSizeInBytes)=0;
217  virtual GDBStatus WriteTargetMemory(ULONGLONG Address, const void *pBuffer, size_t sizeInBytes)=0;
218 
219  public: //Optional methods, return kGDBNotSupported if not implemented
221 
227  virtual GDBStatus GetDynamicLibraryList(std::vector<DynamicLibraryRecord> &libraries)=0;
228 
230 
235  virtual GDBStatus GetThreadList(std::vector<ThreadRecord> &threads)=0;
236 
238 
252  virtual GDBStatus SetThreadModeForNextCont(int threadID, DebugThreadMode mode, OUT bool *pNeedRestoreCall, IN OUT INT_PTR *pRestoreCookie)=0;
253 
255  virtual GDBStatus Terminate()=0;
256 
258 
267  virtual GDBStatus CreateBreakpoint(BreakpointType type, ULONGLONG Address, unsigned kind, OUT INT_PTR *pCookie)=0;
268 
270 
275  virtual GDBStatus RemoveBreakpoint(BreakpointType type, ULONGLONG Address, INT_PTR Cookie)=0;
276 
278  virtual GDBStatus ExecuteRemoteCommand(const std::string &command, std::string &output)=0;
279 
282  virtual ~IStoppedGDBTarget(){}
283  };
284 
287  {
296  };
297 
299 
305  {
308 
312  int ThreadID;
313 
315  union
316  {
320  int ExitCode;
321  } Extension;
322  };
323 
325 
330  {
331  public:
333 
337 
339 
343  virtual GDBStatus ResumeAndWait(int threadID)=0;
344 
346 
349  virtual GDBStatus Step(int threadID)=0;
350 
352 
357  };
358 
361  {
362  public:
363  virtual GDBStatus ReadFrameRelatedRegisters(int threadID, RegisterSetContainer &registers)
364  {
365  return kGDBNotSupported;
366  }
367 
368  virtual GDBStatus GetDynamicLibraryList(std::vector<DynamicLibraryRecord> &libraries)
369  {
370  return kGDBNotSupported;
371  }
372 
373  virtual GDBStatus GetThreadList(std::vector<ThreadRecord> &threads)
374  {
375  return kGDBNotSupported;
376  }
377 
378  virtual GDBStatus SetThreadModeForNextCont(int threadID, DebugThreadMode mode, OUT bool *pNeedRestoreCall, IN OUT INT_PTR *pRestoreCookie)
379  {
380  return kGDBNotSupported;
381  }
382 
384  {
385  return kGDBNotSupported;
386  }
387 
388  virtual GDBStatus CreateBreakpoint(BreakpointType type, ULONGLONG Address, unsigned kind, OUT INT_PTR *pCookie)
389  {
390  return kGDBNotSupported;
391  }
392 
393  virtual GDBStatus RemoveBreakpoint(BreakpointType type, ULONGLONG Address, INT_PTR Cookie)
394  {
395  return kGDBNotSupported;
396  }
397 
398  virtual GDBStatus ExecuteRemoteCommand(const std::string &command, std::string &output)
399  {
400  return kGDBNotSupported;
401  }
402 
404  {
405  return NULL;
406  }
407  };
408 
409 }