1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4 // ===========================================================================
8 // ===========================================================================
17 // -------------------------------------------------------------------------
19 // -------------------------------------------------------------------------
21 class SymReader : public ISymUnmanagedReader
31 m_fInitialized = false;
32 m_fInitializeFromStream = false;
33 memset(&m_DataPointers, 0, sizeof(PDBDataPointers));
37 static HRESULT NewSymReader( REFCLSID clsid, void** ppObj );
40 //-----------------------------------------------------------
42 //-----------------------------------------------------------
43 ULONG STDMETHODCALLTYPE AddRef()
45 return (InterlockedIncrement((LONG *) &m_refCount));
48 ULONG STDMETHODCALLTYPE Release()
50 LONG refCount = InterlockedDecrement((LONG *) &m_refCount);
56 STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject);
58 // ISymUnmanagedReader
60 STDMETHOD(GetDocument)(__in LPWSTR url,
64 ISymUnmanagedDocument **pRetVal);
65 STDMETHOD(GetDocuments)(ULONG32 cDocs,
67 ISymUnmanagedDocument *pDocs[]);
68 STDMETHOD(GetUserEntryPoint)(mdMethodDef *pRetVal);
69 STDMETHOD(GetMethod)(mdMethodDef method,
70 ISymUnmanagedMethod **pRetVal);
71 STDMETHOD(GetMethodByVersion)(mdMethodDef method,
73 ISymUnmanagedMethod **pRetVal);
74 STDMETHOD(GetVariables)(mdToken parent,
77 ISymUnmanagedVariable *pVars[]);
78 STDMETHOD(GetGlobalVariables)(ULONG32 cVars,
80 ISymUnmanagedVariable *pVars[]);
81 STDMETHOD(GetMethodFromDocumentPosition)(ISymUnmanagedDocument *document,
84 ISymUnmanagedMethod **pRetVal);
85 STDMETHOD(GetSymAttribute)(mdToken parent,
89 __out_bcount_part_opt(cBuffer, *pcBuffer) BYTE buffer[]);
90 STDMETHOD(GetNamespaces)(ULONG32 cNameSpaces,
91 ULONG32 *pcNameSpaces,
92 ISymUnmanagedNamespace *namespaces[]);
93 STDMETHOD(Initialize)(IUnknown *importer,
94 const WCHAR* szFileName,
95 const WCHAR* szsearchPath,
97 STDMETHOD(UpdateSymbolStore)(const WCHAR *filename,
100 STDMETHOD(ReplaceSymbolStore)(const WCHAR *filename,
103 STDMETHOD(GetSymbolStoreFileName)(ULONG32 cchName,
105 __out_ecount_part_opt(cchName, *pcchName) WCHAR szName[]);
107 STDMETHOD(GetMethodsFromDocumentPosition)(ISymUnmanagedDocument* document,
112 ISymUnmanagedMethod* pRetVal[]);
114 STDMETHOD(GetDocumentVersion)(ISymUnmanagedDocument *pDoc, int* version, BOOL* pbCurrent);
116 STDMETHOD(GetMethodVersion)(ISymUnmanagedMethod* pMethod, int* version);
118 //-----------------------------------------------------------
119 // Methods not exposed via a COM interface.
120 //-----------------------------------------------------------
122 HRESULT GetDocument(UINT32 DocumentEntry, SymDocument **ppDocument);
126 HRESULT InitializeFromFile(const WCHAR* szFileName,
127 const WCHAR* szsearchPath);
129 HRESULT InitializeFromStream(IStream * pIStream);
131 HRESULT VerifyPEDebugInfo(const WCHAR* szFileName);
133 HRESULT ValidateData();
135 HRESULT ValidateBytes(UINT32 bytesIndex, UINT32 bytesLength);
142 WCHAR m_szPath[ _MAX_PATH ];
143 WCHAR m_szStoredSymbolName[ _MAX_PATH ];
146 SymDocument **m_pDocs;
147 IUnknown *m_pImporter;
148 PDBDataPointers m_DataPointers;
150 // Are we initialized yet?
153 // Did we initialize from stream
154 bool m_fInitializeFromStream;
157 /* ------------------------------------------------------------------------- *
159 * ------------------------------------------------------------------------- */
161 class SymDocument : public ISymUnmanagedDocument
165 SymDocument(SymReader *pReader,
166 PDBDataPointers *pData,
167 UINT32 CountOfMethods,
168 UINT32 DocumentEntry)
172 m_DocumentEntry = DocumentEntry;
173 m_CountOfMethods = CountOfMethods;
178 virtual ~SymDocument()
185 //-----------------------------------------------------------
187 //-----------------------------------------------------------
188 ULONG STDMETHODCALLTYPE AddRef()
190 return (InterlockedIncrement((LONG *) &m_refCount));
193 ULONG STDMETHODCALLTYPE Release()
195 LONG refCount = InterlockedDecrement((LONG *) &m_refCount);
201 STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject);
203 // ISymUnmanagedDocument
205 STDMETHOD(GetURL)(ULONG32 cchUrl,
207 __out_ecount_part_opt(cchUrl, *pcchUrl) WCHAR szUrl[]);
208 STDMETHOD(GetDocumentType)(GUID *pRetVal);
209 STDMETHOD(GetLanguage)(GUID *pRetVal);
210 STDMETHOD(GetLanguageVendor)(GUID *pRetVal);
211 STDMETHOD(GetCheckSumAlgorithmId)(GUID *pRetVal);
212 STDMETHOD(GetCheckSum)(ULONG32 cData,
215 STDMETHOD(FindClosestLine)(ULONG32 line, ULONG32 *pRetVal);
216 STDMETHOD(HasEmbeddedSource)(BOOL *pRetVal);
217 STDMETHOD(GetSourceLength)(ULONG32 *pRetVal);
218 STDMETHOD(GetSourceRange)(ULONG32 startLine,
222 ULONG32 cSourceBytes,
223 ULONG32 *pcSourceBytes,
226 //-----------------------------------------------------------
227 // Methods not exposed via a COM interface.
228 //-----------------------------------------------------------
229 UINT32 GetDocumentEntry()
231 return m_DocumentEntry;
238 SymReader *m_pReader;
241 PDBDataPointers *m_pData;
243 // Entry into the document array
244 UINT32 m_DocumentEntry;
246 // Total number of methods in the ildb
247 UINT32 m_CountOfMethods;
251 /* ------------------------------------------------------------------------- *
253 * ------------------------------------------------------------------------- */
255 class SymMethod : public ISymUnmanagedMethod
259 SymMethod(SymReader *pSymReader, PDBDataPointers *pData, UINT32 MethodEntry)
262 m_MethodEntry = MethodEntry;
264 m_pReader = pSymReader;
265 pSymReader->AddRef();
275 //-----------------------------------------------------------
277 //-----------------------------------------------------------
278 ULONG STDMETHODCALLTYPE AddRef()
280 return (InterlockedIncrement((LONG *) &m_refCount));
283 ULONG STDMETHODCALLTYPE Release()
285 LONG refCount = InterlockedDecrement((LONG *) &m_refCount);
291 STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject);
293 // ISymUnmanagedMethod
295 STDMETHOD(GetToken)(mdMethodDef *pRetVal);
296 STDMETHOD(GetSequencePointCount)(ULONG32 *pRetVal);
298 STDMETHOD(GetRootScope)(ISymUnmanagedScope **pRetVal);
299 STDMETHOD(GetScopeFromOffset)(ULONG32 offset,
300 ISymUnmanagedScope **pRetVal);
301 STDMETHOD(GetOffset)(ISymUnmanagedDocument *document,
305 STDMETHOD(GetRanges)(ISymUnmanagedDocument *document,
311 STDMETHOD(GetParameters)(ULONG32 cParams,
313 ISymUnmanagedVariable *params[]);
314 STDMETHOD(GetNamespace)(ISymUnmanagedNamespace **pRetVal);
315 STDMETHOD(GetSourceStartEnd)(ISymUnmanagedDocument *docs[2],
319 STDMETHOD(GetSequencePoints)(ULONG32 cpoints,
322 ISymUnmanagedDocument *documents[],
326 ULONG32 endcolumns[]);
330 // AddRef/Release support
334 PDBDataPointers *m_pData;
337 SymReader *m_pReader;
339 // Entry into the SymMethodInfo array
340 UINT32 m_MethodEntry;
344 /* ------------------------------------------------------------------------- *
346 * ------------------------------------------------------------------------- */
348 class SymScope : public ISymUnmanagedScope
353 ISymUnmanagedMethod *pSymMethod,
354 PDBDataPointers *pData,
358 m_pSymMethod = pSymMethod;
359 m_pSymMethod->AddRef();
361 m_MethodEntry = MethodEntry;
362 m_ScopeEntry = ScopeEntry;
367 RELEASE(m_pSymMethod);
371 //-----------------------------------------------------------
373 //-----------------------------------------------------------
374 ULONG STDMETHODCALLTYPE AddRef()
376 return (InterlockedIncrement((LONG *) &m_refCount));
379 ULONG STDMETHODCALLTYPE Release()
381 LONG refCount = InterlockedDecrement((LONG *) &m_refCount);
387 STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject);
389 // ISymUnmanagedScope
391 STDMETHOD(GetMethod)(ISymUnmanagedMethod **pRetVal);
392 STDMETHOD(GetParent)(ISymUnmanagedScope **pRetVal);
393 STDMETHOD(GetChildren)(ULONG32 cChildren,
395 ISymUnmanagedScope *children[]);
396 STDMETHOD(GetStartOffset)(ULONG32 *pRetVal);
397 STDMETHOD(GetEndOffset)(ULONG32 *pRetVal);
398 STDMETHOD(GetLocalCount)(ULONG32 *pRetVal);
399 STDMETHOD(GetLocals)(ULONG32 cLocals,
401 ISymUnmanagedVariable *locals[]);
402 STDMETHOD(GetNamespaces)(ULONG32 cNameSpaces,
403 ULONG32 *pcNameSpaces,
404 ISymUnmanagedNamespace *namespaces[]);
409 UINT32 m_refCount; // Add/Ref Release
411 ISymUnmanagedMethod *m_pSymMethod;
414 PDBDataPointers *m_pData;
415 // Entry into the SymMethodInfo array
416 UINT32 m_MethodEntry;
417 // Entry into the scope array
421 /* ------------------------------------------------------------------------- *
423 * ------------------------------------------------------------------------- */
425 class SymReaderVar : public ISymUnmanagedVariable
429 SymReaderVar(SymScope *pScope, PDBDataPointers *pData, UINT32 VarEntry)
432 m_VarEntry = VarEntry;
437 virtual ~SymReaderVar()
443 //-----------------------------------------------------------
445 //-----------------------------------------------------------
446 ULONG STDMETHODCALLTYPE AddRef()
448 return (InterlockedIncrement((LONG *) &m_refCount));
451 ULONG STDMETHODCALLTYPE Release()
453 LONG refCount = InterlockedDecrement((LONG *) &m_refCount);
459 STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject);
461 // ISymUnmanagedReaderVar
463 STDMETHOD(GetName)(ULONG32 cchName,
465 __out_ecount_part_opt(cchName, *pcchName) WCHAR szName[]);
466 STDMETHOD(GetAttributes)(ULONG32 *pRetVal);
467 STDMETHOD(GetSignature)(ULONG32 cSig,
470 STDMETHOD(GetAddressKind)(ULONG32 *pRetVal);
471 STDMETHOD(GetAddressField1)(ULONG32 *pRetVal);
472 STDMETHOD(GetAddressField2)(ULONG32 *pRetVal);
473 STDMETHOD(GetAddressField3)(ULONG32 *pRetVal);
474 STDMETHOD(GetStartOffset)(ULONG32 *pRetVal);
475 STDMETHOD(GetEndOffset)(ULONG32 *pRetVal);
480 UINT32 m_refCount; // Add/Ref Release
483 PDBDataPointers *m_pData;
485 // Scope of the variable
488 // Entry into the SymMethodInfo array
492 class SymReaderNamespace : public ISymUnmanagedNamespace
496 SymReaderNamespace(SymScope *pScope, PDBDataPointers *pData, UINT32 NamespaceEntry)
499 m_NamespaceEntry = NamespaceEntry;
504 virtual ~SymReaderNamespace()
509 //-----------------------------------------------------------
511 //-----------------------------------------------------------
512 ULONG STDMETHODCALLTYPE AddRef()
514 return (InterlockedIncrement((LONG *) &m_refCount));
517 ULONG STDMETHODCALLTYPE Release()
519 LONG refCount = InterlockedDecrement((LONG *) &m_refCount);
525 STDMETHOD(QueryInterface)(REFIID riid, void** ppvObject);
528 //-----------------------------------------------------------
529 // ISymUnmanagedNamespace support
530 //-----------------------------------------------------------
531 STDMETHOD(GetName)(ULONG32 cchName,
533 __out_ecount_part_opt(cchName, *pcchName) WCHAR szName[]);
534 STDMETHOD(GetNamespaces)(ULONG32 cNamespaces,
535 ULONG32 *pcNamespaces,
536 ISymUnmanagedNamespace* namespaces[]);
537 STDMETHOD(GetVariables)(ULONG32 cchName,
539 ISymUnmanagedVariable *pVars[]);
542 UINT32 m_refCount; // Add/Ref Release
548 PDBDataPointers *m_pData;
549 // Entry into the NameSpace array
550 UINT32 m_NamespaceEntry;