Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

278 lines
7.9 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Symbol interface implementations.
  4. //
  5. // Copyright (C) Microsoft Corporation, 2000-2002.
  6. //
  7. //----------------------------------------------------------------------------
  8. #ifndef __DBGSYM_HPP__
  9. #define __DBGSYM_HPP__
  10. class DebugSymbolGroup;
  11. class SymbolGroupFormat;
  12. //----------------------------------------------------------------------------
  13. //
  14. // SymbolGroupEntry.
  15. //
  16. //----------------------------------------------------------------------------
  17. enum SymbolGroupFormatKind
  18. {
  19. SGFORMAT_TYPED_DATA,
  20. SGFORMAT_EXPRESSION,
  21. SGFORMAT_EXTENSION,
  22. SGFORMAT_TEXT,
  23. };
  24. // Used for locals when locals are added on change of scope.
  25. #define SYMBOL_IN_SCOPE 0x00000001
  26. // This means another same-named symbol is in inner scope
  27. // blocking this symbol. Although its still a valid member of
  28. // local symbolgroup, but can't be seen by code at IP.
  29. #define SYMBOL_ECLIPSED 0x00000002
  30. class SymbolGroupEntry
  31. {
  32. public:
  33. SymbolGroupEntry(void);
  34. ~SymbolGroupEntry(void);
  35. SymbolGroupEntry* m_Parent;
  36. SymbolGroupEntry* m_Next;
  37. SymbolGroupFormat* m_Format;
  38. PSTR m_Expr;
  39. PSTR m_Cast;
  40. DEBUG_SYMBOL_PARAMETERS m_Params;
  41. ULONG m_Flags;
  42. TypedData m_BaseData;
  43. SymbolGroupFormatKind m_BaseFormatKind;
  44. };
  45. class SymbolGroupFormat
  46. {
  47. public:
  48. SymbolGroupFormat(SymbolGroupEntry* Entry,
  49. SymbolGroupFormatKind Kind);
  50. virtual ~SymbolGroupFormat(void);
  51. virtual ULONG CreateChildren(DebugSymbolGroup* Group) = 0;
  52. virtual ULONG Refresh(TypedDataAccess AllowAccess) = 0;
  53. virtual ULONG Write(PCSTR Value) = 0;
  54. virtual void OutputValue(void) = 0;
  55. virtual void OutputOffset(void) = 0;
  56. virtual void OutputType(void) = 0;
  57. virtual void TestImages(void);
  58. SymbolGroupEntry* m_Entry;
  59. SymbolGroupFormatKind m_Kind;
  60. // If there's an expression error the basic
  61. // expression could not be evaluated and this
  62. // entry is just a placeholder for an error message.
  63. ULONG m_ExprErr;
  64. // If there's a value error the basic expression
  65. // was evaluated properly but the value could
  66. // not be retrieved and is invalid. If m_ExprErr
  67. // is set m_ValueErr should be set to match.
  68. ULONG m_ValueErr;
  69. };
  70. class TypedDataSymbolGroupFormat
  71. : public SymbolGroupFormat
  72. {
  73. public:
  74. TypedDataSymbolGroupFormat(SymbolGroupEntry* Entry) :
  75. SymbolGroupFormat(Entry, SGFORMAT_TYPED_DATA) {}
  76. TypedDataSymbolGroupFormat(SymbolGroupEntry* Entry,
  77. SymbolGroupFormatKind Kind) :
  78. SymbolGroupFormat(Entry, Kind) {}
  79. virtual ULONG CreateChildren(DebugSymbolGroup* Group);
  80. ULONG AddChild(SymbolGroupEntry** AddAfter, PSTR Name, TypedData* Data);
  81. static ULONG CreateChildrenCb(PVOID Context, PSTR Name, TypedData* Child);
  82. virtual ULONG Refresh(TypedDataAccess AllowAccess);
  83. virtual ULONG Write(PCSTR Value);
  84. virtual void OutputValue(void);
  85. virtual void OutputOffset(void);
  86. virtual void OutputType(void);
  87. virtual void TestImages(void);
  88. SymbolGroupEntry* RefreshChildren(void);
  89. static ULONG RefreshChildrenCb(PVOID Context, PSTR Name, TypedData* Child);
  90. void UpdateParams(void);
  91. TypedData m_CastType;
  92. TypedData m_CastData;
  93. };
  94. class ExprSymbolGroupFormat
  95. : public TypedDataSymbolGroupFormat
  96. {
  97. public:
  98. ExprSymbolGroupFormat(SymbolGroupEntry* Entry) :
  99. TypedDataSymbolGroupFormat(Entry, SGFORMAT_EXPRESSION) {}
  100. virtual ULONG Refresh(TypedDataAccess AllowAccess);
  101. };
  102. class ExtSymbolGroupFormat
  103. : public SymbolGroupFormat
  104. {
  105. public:
  106. ExtSymbolGroupFormat(SymbolGroupEntry* Entry, DebugClient* Client);
  107. virtual ~ExtSymbolGroupFormat(void);
  108. virtual ULONG CreateChildren(DebugSymbolGroup* Group);
  109. virtual ULONG Refresh(TypedDataAccess AllowAccess);
  110. virtual ULONG Write(PCSTR Value);
  111. virtual void OutputValue(void);
  112. virtual void OutputOffset(void);
  113. virtual void OutputType(void);
  114. DebugClient* m_Client;
  115. PSTR m_Output;
  116. };
  117. class TextSymbolGroupFormat
  118. : public SymbolGroupFormat
  119. {
  120. public:
  121. TextSymbolGroupFormat(SymbolGroupEntry* Entry, PSTR Text, BOOL Own);
  122. virtual ~TextSymbolGroupFormat(void);
  123. virtual ULONG CreateChildren(DebugSymbolGroup* Group);
  124. virtual ULONG Refresh(TypedDataAccess AllowAccess);
  125. virtual ULONG Write(PCSTR Value);
  126. virtual void OutputValue(void);
  127. virtual void OutputOffset(void);
  128. virtual void OutputType(void);
  129. PSTR m_Text;
  130. BOOL m_Own;
  131. };
  132. //----------------------------------------------------------------------------
  133. //
  134. // DebugSymbolGroup.
  135. //
  136. //----------------------------------------------------------------------------
  137. class DebugSymbolGroup : public IDebugSymbolGroup
  138. {
  139. public:
  140. DebugSymbolGroup(DebugClient *CreatedBy, ULONG ScopeGroup);
  141. ~DebugSymbolGroup(void);
  142. // IUnknown.
  143. STDMETHOD(QueryInterface)(
  144. THIS_
  145. IN REFIID InterfaceId,
  146. OUT PVOID* Interface
  147. );
  148. STDMETHOD_(ULONG, AddRef)(
  149. THIS
  150. );
  151. STDMETHOD_(ULONG, Release)(
  152. THIS
  153. );
  154. // IDebugSymbolGroup.
  155. STDMETHOD(GetNumberSymbols)(
  156. THIS_
  157. OUT PULONG Number
  158. );
  159. STDMETHOD(AddSymbol)(
  160. THIS_
  161. IN PCSTR Name,
  162. OUT PULONG Index
  163. );
  164. STDMETHOD(RemoveSymbolByName)(
  165. THIS_
  166. IN PCSTR Name
  167. );
  168. STDMETHOD(RemoveSymbolByIndex)(
  169. THIS_
  170. IN ULONG Index
  171. );
  172. STDMETHOD(GetSymbolName)(
  173. THIS_
  174. IN ULONG Index,
  175. OUT OPTIONAL PSTR Buffer,
  176. IN ULONG BufferSize,
  177. OUT OPTIONAL PULONG NameSize
  178. );
  179. STDMETHOD(GetSymbolParameters)(
  180. THIS_
  181. IN ULONG Start,
  182. IN ULONG Count,
  183. OUT /* size_is(Count) */ PDEBUG_SYMBOL_PARAMETERS Params
  184. );
  185. STDMETHOD(ExpandSymbol)(
  186. THIS_
  187. IN ULONG Index,
  188. IN BOOL Expand
  189. );
  190. STDMETHOD(OutputSymbols)(
  191. THIS_
  192. IN ULONG OutputControl,
  193. IN ULONG Flags,
  194. IN ULONG Start,
  195. IN ULONG Count
  196. );
  197. STDMETHOD(WriteSymbol)(
  198. THIS_
  199. IN ULONG Index,
  200. IN PCSTR Value
  201. );
  202. STDMETHOD(OutputAsType)(
  203. THIS_
  204. IN ULONG Index,
  205. IN PCSTR Type
  206. );
  207. SymbolGroupEntry* FindEntryByIndex(ULONG Index);
  208. SymbolGroupEntry* FindEntryByExpr(SymbolGroupEntry* Parent,
  209. SymbolGroupEntry* After,
  210. PCSTR Expr);
  211. ULONG FindEntryIndex(SymbolGroupEntry* Entry);
  212. void DeleteEntry(SymbolGroupEntry* Entry);
  213. void DeleteChildren(SymbolGroupEntry* Parent);
  214. void LinkEntry(IN SymbolGroupEntry* Entry,
  215. IN OUT PULONG Index);
  216. HRESULT NewEntry(IN PCSTR Expr,
  217. IN OPTIONAL PSYMBOL_INFO SymInfo,
  218. OUT SymbolGroupEntry** EntryRet);
  219. HRESULT SetEntryExpansion(IN SymbolGroupEntry* Entry,
  220. IN BOOL Expand);
  221. HRESULT AddCurrentLocals(void);
  222. ULONG FindLocalInsertionIndex(SymbolGroupEntry* Entry);
  223. static BOOL CALLBACK AddAllScopedSymbols(PSYMBOL_INFO SymInfo,
  224. ULONG Size,
  225. PVOID Context);
  226. void TestImages(void);
  227. void ShowAll(void);
  228. DebugClient* m_Client;
  229. ULONG m_ScopeGroup;
  230. ULONG m_Refs;
  231. ULONG m_NumEntries;
  232. // Entry list is kept sorted by parent/child relationship
  233. // so all children of a parent follow it directly in the
  234. // order they were found.
  235. SymbolGroupEntry* m_Entries;
  236. BOOL m_LastClassExpanded;
  237. };
  238. #endif // #ifndef __DBGSYM_HPP__