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 // ===========================================================================
13 #pragma warning(disable:4786)
28 class SymDocumentWriter;
32 *PUBLIC void VariantSwap
34 * Swap the Variant members
37 * SrcInBigEndian = whether pvarg is in BIGENDIAN or not
38 * pvargDest = Destination variant
39 * pvarg = pointer to a VARIANT to swap
44 ***********************************************************************/
45 inline HRESULT VariantSwap(bool SrcInBigEndian, VARIANT FAR *pvargDest, VARIANT FAR* pvarg)
47 if (pvargDest == NULL || pvarg == NULL)
49 VARTYPE vt = VT_EMPTY;
55 *(UINT32*)pvargDest = VAL32(*(UINT32*)pvarg);
71 V_I1(pvargDest) = V_I1(pvarg);
80 V_I2(pvargDest) = VAL16(V_I2(pvarg));
87 V_I4(pvargDest) = VAL32(V_I4(pvarg));
95 V_I8(pvargDest) = VAL64(V_I8(pvarg));
99 DECIMAL_HI32(V_DECIMAL(pvargDest)) = VAL32(DECIMAL_HI32(V_DECIMAL(pvarg)));
100 DECIMAL_LO32(V_DECIMAL(pvargDest)) = VAL32(DECIMAL_LO32(V_DECIMAL(pvarg)));
101 DECIMAL_MID32(V_DECIMAL(pvargDest)) = VAL32(DECIMAL_MID32(V_DECIMAL(pvarg)));
104 // These aren't currently supported
107 case VT_DISPATCH: //9
109 case VT_VARIANT: //12
110 case VT_UNKNOWN: //13
112 case VT_HRESULT: //25
114 case VT_SAFEARRAY: //27
116 case VT_USERDEFINED://29
119 case VT_FILETIME: //64
122 case VT_STORAGE: //67
123 case VT_STREAMED_OBJECT: //68
124 case VT_STORED_OBJECT: //69
125 case VT_BLOB_OBJECT: //70
136 // Default space sizes for the various arrays. Make it too small in a
137 // checked build so we exercise the growing code.
139 #define DEF_LOCAL_SPACE 2
140 #define DEF_MISC_SPACE 64
142 #define DEF_LOCAL_SPACE 64
143 #define DEF_MISC_SPACE 1024
146 /* ------------------------------------------------------------------------- *
148 * ------------------------------------------------------------------------- */
152 UINT32 m_Scope; // index of parent scope
153 UINT32 m_Name; // index into misc byte array
154 ULONG32 m_Attributes; // Attributes
155 UINT32 m_Signature; // index into misc byte array
156 ULONG32 m_SignatureSize; // Signature size
157 ULONG32 m_AddrKind; // Address Kind
158 ULONG32 m_Addr1; // Additional info
161 ULONG32 m_StartOffset; // StartOffset
162 ULONG32 m_EndOffset; // EndOffset
164 BOOL m_IsParam; // parameter?
165 BOOL m_IsHidden; // Is not visible to the user
170 return VAL32(m_Scope);
172 void SetScope(UINT32 Scope)
174 m_Scope = VAL32(Scope);
179 return VAL32(m_Name);
181 void SetName(UINT32 Name)
183 m_Name = VAL32(Name);
188 return VAL32(m_Attributes);
190 void SetAttributes(ULONG32 Attributes)
192 m_Attributes = VAL32(Attributes);
197 return VAL32(m_Signature);
199 void SetSignature(UINT32 Signature)
201 m_Signature = VAL32(Signature);
203 ULONG32 SignatureSize()
205 return VAL32(m_SignatureSize);
207 void SetSignatureSize(ULONG32 SignatureSize)
209 m_SignatureSize = VAL32(SignatureSize);
214 return VAL32(m_AddrKind);
216 void SetAddrKind(ULONG32 AddrKind)
218 m_AddrKind = VAL32(AddrKind);
222 return VAL32(m_Addr1);
224 void SetAddr1(ULONG32 Addr1)
226 m_Addr1 = VAL32(Addr1);
231 return VAL32(m_Addr2);
233 void SetAddr2(ULONG32 Addr2)
235 m_Addr2 = VAL32(Addr2);
240 return VAL32(m_Addr3);
242 void SetAddr3(ULONG32 Addr3)
244 m_Addr3 = VAL32(Addr3);
247 ULONG32 StartOffset()
249 return VAL32(m_StartOffset);
251 void SetStartOffset(ULONG32 StartOffset)
253 m_StartOffset = VAL32(StartOffset);
257 return VAL32(m_EndOffset);
259 void SetEndOffset(ULONG EndOffset)
261 m_EndOffset = VAL32(EndOffset);
265 return VAL32(m_Sequence);
267 void SetSequence(ULONG32 Sequence)
269 m_Sequence = VAL32(Sequence);
274 return VAL32(m_IsParam);
276 void SetIsParam(BOOL IsParam)
282 return VAL32(m_IsHidden);
284 void SetIsHidden(BOOL IsHidden)
286 m_IsHidden = IsHidden;
290 /* ------------------------------------------------------------------------- *
291 * SymLexicalScope struct
292 * ------------------------------------------------------------------------- */
293 struct SymLexicalScope
297 UINT32 m_ParentScope; // parent index (-1 for no parent)
298 ULONG32 m_StartOffset; // start offset
299 ULONG32 m_EndOffset; // end offset
300 BOOL m_HasChildren; // scope has children
301 BOOL m_HasVars; // scope has vars?
305 return VAL32(m_ParentScope);
307 void SetParentScope(UINT32 ParentScope)
309 m_ParentScope = VAL32(ParentScope);
312 ULONG32 StartOffset()
314 return VAL32(m_StartOffset);
316 void SetStartOffset(ULONG32 StartOffset)
318 m_StartOffset = VAL32(StartOffset);
322 return VAL32(m_EndOffset);
324 void SetEndOffset(ULONG32 EndOffset)
326 m_EndOffset = VAL32(EndOffset);
330 return m_HasChildren;
332 void SetHasChildren(BOOL HasChildren)
334 m_HasChildren = HasChildren;
340 void SetHasVars(BOOL HasVars)
347 /* ------------------------------------------------------------------------- *
348 * SymUsingNamespace struct
349 * ------------------------------------------------------------------------- */
350 struct SymUsingNamespace
354 UINT32 m_ParentScope; // index of parent scope
355 UINT32 m_Name; // Index of name
359 return VAL32(m_ParentScope);
361 void SetParentScope(UINT32 ParentScope)
363 m_ParentScope = VAL32(ParentScope);
367 return VAL32(m_Name);
369 void SetName(UINT32 Name)
371 m_Name = VAL32(Name);
375 /* ------------------------------------------------------------------------- *
377 * ------------------------------------------------------------------------- */
382 VARIANT m_Value; // Constant Value
383 UINT32 m_ParentScope; // Parent scope
384 UINT32 m_Name; // Name index
385 UINT32 m_Signature; // Signature index
386 ULONG32 m_SignatureSize;// Signature size
387 UINT32 m_ValueBstr; // If the variant is a bstr, store the string
392 return VAL32(m_ParentScope);
394 void SetParentScope(UINT32 ParentScope)
396 m_ParentScope = VAL32(ParentScope);
400 return VAL32(m_Name);
402 void SetName(UINT32 Name)
404 m_Name = VAL32(Name);
408 return VAL32(m_Signature);
410 void SetSignature(UINT32 Signature)
412 m_Signature = VAL32(Signature);
414 ULONG32 SignatureSize()
416 return VAL32(m_SignatureSize);
418 void SetSignatureSize(ULONG32 SignatureSize)
420 m_SignatureSize = VAL32(SignatureSize);
422 VARIANT Value(UINT32 *pValueBstr)
424 *pValueBstr = VAL32(m_ValueBstr);
426 VARIANT VariantValue;
427 VariantInit(&VariantValue);
428 // VT_BSTR's are dealt with ValueBStr
431 V_VT(&VariantValue) = VT_BSTR;
435 VariantSwap(false, &VariantValue, &m_Value);
442 void SetValue(VARIANT VariantValue, UINT32 ValueBstr)
444 m_Value = VariantValue;
445 m_ValueBstr = VAL32(ValueBstr);
447 // VT_BSTR's are dealt with ValueBStr
450 V_VT(&m_Value) = VAL16(VT_BSTR);
454 VariantSwap(true, &m_Value, &VariantValue);
460 /* ------------------------------------------------------------------------- *
461 * SymMethodInfo struct
462 * ------------------------------------------------------------------------- */
467 mdMethodDef m_MethodToken; // Method token
469 // Start/End Entries into the respective tables
470 // End values are extents - one past the last index (and so may actually be an index off
471 // the end of the array). Start may equal end if the method has none of the item.
472 UINT32 m_StartScopes;
478 UINT32 m_StartConstant;
479 UINT32 m_EndConstant;
480 UINT32 m_StartDocuments;
481 UINT32 m_EndDocuments;
482 UINT32 m_StartSequencePoints;
483 UINT32 m_EndSequencePoints;
486 static int __cdecl compareMethods(const void *elem1, const void *elem2 );
488 mdMethodDef MethodToken()
490 return VAL32(m_MethodToken);
492 void SetMethodToken(mdMethodDef MethodToken)
494 m_MethodToken = VAL32(MethodToken);
498 return VAL32(m_StartScopes);
500 void SetStartScopes(UINT32 StartScopes)
502 m_StartScopes = VAL32(StartScopes);
506 return VAL32(m_EndScopes);
508 void SetEndScopes(UINT32 EndScopes)
510 m_EndScopes = VAL32(EndScopes);
514 return VAL32(m_StartVars);
516 void SetStartVars(UINT32 StartVars)
518 m_StartVars = VAL32(StartVars);
522 return VAL32(m_EndVars);
524 void SetEndVars(UINT32 EndVars)
526 m_EndVars = VAL32(EndVars);
530 return VAL32(m_StartUsing);
532 void SetStartUsing(UINT32 StartUsing)
534 m_StartUsing = VAL32(StartUsing);
538 return VAL32(m_EndUsing);
540 void SetEndUsing(UINT32 EndUsing)
542 m_EndUsing = VAL32(EndUsing);
544 UINT32 StartConstant()
546 return VAL32(m_StartConstant);
548 void SetStartConstant(UINT32 StartConstant)
550 m_StartConstant = VAL32(StartConstant);
554 return VAL32(m_EndConstant);
556 void SetEndConstant(UINT32 EndConstant)
558 m_EndConstant = VAL32(EndConstant);
560 UINT32 StartDocuments()
562 return VAL32(m_StartDocuments);
564 void SetStartDocuments(UINT32 StartDocuments)
566 m_StartDocuments = VAL32(StartDocuments);
568 UINT32 EndDocuments()
570 return VAL32(m_EndDocuments);
572 void SetEndDocuments(UINT32 EndDocuments)
574 m_EndDocuments = VAL32(EndDocuments);
576 UINT32 StartSequencePoints()
578 return VAL32(m_StartSequencePoints);
580 void SetStartSequencePoints(UINT32 StartSequencePoints)
582 m_StartSequencePoints = VAL32(StartSequencePoints);
584 UINT32 EndSequencePoints()
586 return VAL32(m_EndSequencePoints);
588 void SetEndSequencePoints(UINT32 EndSequencePoints)
590 m_EndSequencePoints = VAL32(EndSequencePoints);
594 /* ------------------------------------------------------------------------- *
596 * ------------------------------------------------------------------------- */
599 mdMethodDef m_MethodToken; // New Method token
600 UINT32 MethodEntry; // Method Entry
603 /* ------------------------------------------------------------------------- *
604 * SequencePoint struct
605 * ------------------------------------------------------------------------- */
606 struct SequencePoint {
618 bool IsWithin(ULONG32 line, ULONG32 column);
619 bool IsWithinLineOnly(ULONG32 line);
620 bool IsGreaterThan(ULONG32 line, ULONG32 column);
621 bool IsLessThan(ULONG32 line, ULONG32 column);
623 static int __cdecl compareAuxLines(const void *elem1, const void *elem2 );
627 return VAL32(m_Offset);
629 void SetOffset(DWORD Offset)
631 m_Offset = VAL32(Offset);
635 return VAL32(m_StartLine);
637 void SetStartLine(DWORD StartLine)
639 m_StartLine = VAL32(StartLine);
644 return VAL32(m_StartColumn);
646 void SetStartColumn(DWORD StartColumn)
648 m_StartColumn = VAL32(StartColumn);
653 return VAL32(m_EndLine);
655 void SetEndLine(DWORD EndLine)
657 m_EndLine = VAL32(EndLine);
661 return VAL32(m_EndColumn);
663 void SetEndColumn(DWORD EndColumn)
665 m_EndColumn = VAL32(EndColumn);
669 return VAL32(m_Document);
671 void SetDocument(DWORD Document)
673 m_Document = VAL32(Document);
678 /* ------------------------------------------------------------------------- *
679 * DocumentInfo struct
680 * ------------------------------------------------------------------------- */
681 typedef struct DocumentInfo {
686 GUID m_LanguageVendor;
689 DWORD m_CheckSumSize;
690 UINT32 m_CheckSumEntry;
692 UINT32 m_SourceEntry;
694 SymDocumentWriter * m_pDocumentWriter;
700 GUID TmpGuid = m_Language;
704 void SetLanguage(GUID Language)
707 m_Language = Language;
709 GUID LanguageVendor()
711 GUID TmpGuid = m_LanguageVendor;
715 void SetLanguageVendor(GUID LanguageVendor)
717 SwapGuid(&LanguageVendor);
718 m_LanguageVendor = LanguageVendor;
722 GUID TmpGuid = m_DocumentType;
726 void SetDocumentType(GUID DocumentType)
728 SwapGuid(&DocumentType);
729 m_DocumentType = DocumentType;
732 // Set the pointer to the SymDocumentWriter instance corresponding to this instance of DocumentInfo
733 // An argument of NULL will call Release
734 void SetDocumentWriter(SymDocumentWriter * pDoc);
736 // get the associated SymDocumentWriter
737 SymDocumentWriter * DocumentWriter()
739 return m_pDocumentWriter;
744 GUID TmpGuid = m_AlgorithmId;
748 void SetAlgorithmId(GUID AlgorithmId)
750 SwapGuid(&AlgorithmId);
751 m_AlgorithmId = AlgorithmId;
756 return VAL32(m_CheckSumSize);
758 void SetCheckSymSize(DWORD CheckSumSize)
760 m_CheckSumSize = VAL32(CheckSumSize);
762 UINT32 CheckSumEntry()
764 return VAL32(m_CheckSumEntry);
766 void SetCheckSumEntry(UINT32 CheckSumEntry)
768 m_CheckSumEntry = VAL32(CheckSumEntry);
772 return VAL32(m_SourceSize);
774 void SetSourceSize(UINT32 SourceSize)
776 m_SourceSize = VAL32(SourceSize);
780 return VAL32(m_SourceEntry);
782 void SetSourceEntry(UINT32 SourceEntry)
784 m_SourceEntry = VAL32(SourceEntry);
788 return VAL32(m_UrlEntry);
790 void SetUrlEntry(UINT32 UrlEntry)
792 m_UrlEntry = VAL32(UrlEntry);
802 ArrayStorage( int initialSize = 0 )
803 : m_spaceSize(0), m_instanceCount( 0 ), m_array( NULL )
811 DELETEARRAY(m_array);
818 if( !grow ( m_instanceCount ) )
820 _ASSERTE( m_instanceCount < m_spaceSize );
821 return &m_array[ m_instanceCount++ ];
823 bool grab(UINT32 n, UINT32 * pIndex)
825 S_UINT32 newSize = S_UINT32(m_instanceCount) + S_UINT32(n);
826 if (newSize.IsOverflow())
828 if (!grow(newSize.Value()))
830 _ASSERTE( m_instanceCount < m_spaceSize );
831 *pIndex = m_instanceCount;
832 m_instanceCount += n;
836 T& operator[]( UINT32 i ) {
837 _ASSERTE( i < m_instanceCount );
838 if (i >= m_instanceCount)
840 // Help mitigate the impact of buffer overflow
841 // Fail fast with a null-reference AV
842 volatile char* nullPointer = nullptr;
854 return m_instanceCount;
857 UINT32 m_spaceSize; // Total size of array in elements
858 UINT32 m_instanceCount; // total T's in the file
859 T *m_array; // array of T's
861 bool grow( UINT32 n )
863 if (n >= m_spaceSize)
865 // Make a new, bigger array.
869 newSpaceSize = DEF_LOCAL_SPACE;
871 newSpaceSize = max( m_spaceSize * 2, n);
873 // Make sure we're not asking for more than 4GB of bytes to ensure no integer-overflow attacks are possible
874 S_UINT32 newBytes = S_UINT32(newSpaceSize) * S_UINT32(sizeof(T));
875 if (newBytes.IsOverflow())
879 newTs = NEW(T[newSpaceSize]);
883 // Copy over the old Ts.
884 memcpy(newTs, m_array,
885 sizeof(T) * m_spaceSize);
887 // Delete the old Ts.
888 DELETEARRAY(m_array);
890 // Hang onto the new array.
892 m_spaceSize = newSpaceSize;
899 typedef struct MethodInfo {
901 ArrayStorage<SymMethodInfo> m_methods; // Methods information
902 ArrayStorage<SymLexicalScope> m_scopes; // Scope information for the method
903 ArrayStorage<SymVariable> m_vars; // Variables
904 ArrayStorage<SymUsingNamespace> m_usings; // using/imports
905 ArrayStorage<SymConstant> m_constants; // Constants
906 ArrayStorage<DocumentInfo> m_documents; // Document Source Format
907 ArrayStorage<SequencePoint> m_auxSequencePoints; // Sequence Points
908 // Array of various bytes (variable signature, etc)
909 ArrayStorage<BYTE> m_bytes;
915 m_bytes( DEF_MISC_SPACE )
920 /* ------------------------------------------------------------------------- *
922 * ------------------------------------------------------------------------- */
924 class SymWriter : public ISymUnmanagedWriter3
928 virtual ~SymWriter();
930 //-----------------------------------------------------------
932 //-----------------------------------------------------------
933 ULONG STDMETHODCALLTYPE AddRef()
935 return (InterlockedIncrement((LONG *) &m_refCount));
938 ULONG STDMETHODCALLTYPE Release()
940 // Note that this must be thread-safe - it may be invoked on the finalizer thread
941 LONG refCount = InterlockedDecrement((LONG *) &m_refCount);
947 COM_METHOD QueryInterface(REFIID riid, void **ppInterface);
949 //-----------------------------------------------------------
950 // ISymUnmanagedWriter
951 //-----------------------------------------------------------
952 COM_METHOD DefineDocument(const WCHAR *url,
953 const GUID *language,
954 const GUID *languageVendor,
955 const GUID *documentType,
956 ISymUnmanagedDocumentWriter **pRetVal);
957 COM_METHOD SetUserEntryPoint(mdMethodDef entryMethod);
958 COM_METHOD OpenMethod(mdMethodDef method);
959 COM_METHOD CloseMethod();
960 COM_METHOD DefineSequencePoints(ISymUnmanagedDocumentWriter *document,
966 ULONG32 encColumns[]);
967 COM_METHOD OpenScope(ULONG32 startOffset, ULONG32 *scopeID);
968 COM_METHOD CloseScope(ULONG32 endOffset);
969 COM_METHOD SetScopeRange(ULONG32 scopeID, ULONG32 startOffset, ULONG32 endOffset);
970 COM_METHOD DefineLocalVariable(const WCHAR *name,
975 ULONG32 addr1, ULONG32 addr2, ULONG32 addr3,
976 ULONG32 startOffset, ULONG32 endOffset);
977 COM_METHOD DefineParameter(const WCHAR *name,
981 ULONG32 addr1, ULONG32 addr2, ULONG32 addr3);
982 COM_METHOD DefineField(mdTypeDef parent,
988 ULONG32 addr1, ULONG32 addr2, ULONG32 addr3);
989 COM_METHOD DefineGlobalVariable(const WCHAR *name,
994 ULONG32 addr1, ULONG32 addr2, ULONG32 addr3);
996 COM_METHOD SetSymAttribute(mdToken parent,
1000 COM_METHOD OpenNamespace(const WCHAR *name);
1001 COM_METHOD CloseNamespace();
1002 COM_METHOD UsingNamespace(const WCHAR *fullName);
1003 COM_METHOD SetMethodSourceRange(ISymUnmanagedDocumentWriter *startDoc,
1005 ULONG32 startColumn,
1006 ISymUnmanagedDocumentWriter *endDoc,
1009 COM_METHOD GetDebugCVInfo(DWORD cData,
1013 COM_METHOD Initialize(IUnknown *emitter,
1014 const WCHAR *filename,
1018 COM_METHOD Initialize2(IUnknown *emitter,
1019 const WCHAR *pdbTempPath, // location to write pdb file
1022 const WCHAR *pdbFinalPath); // location exe should contain for pdb file
1024 COM_METHOD GetDebugInfo(IMAGE_DEBUG_DIRECTORY *pIDD,
1029 COM_METHOD RemapToken(mdToken oldToken,
1032 COM_METHOD DefineConstant(const WCHAR __RPC_FAR *name,
1035 unsigned char __RPC_FAR signature[ ]);
1037 COM_METHOD Abort(void);
1039 //-----------------------------------------------------------
1040 // ISymUnmanagedWriter2
1041 //-----------------------------------------------------------
1042 COM_METHOD DefineLocalVariable2(const WCHAR *name,
1044 mdSignature sigToken,
1049 ULONG32 startOffset,
1052 COM_METHOD DefineGlobalVariable2(const WCHAR *name,
1054 mdSignature sigToken,
1060 COM_METHOD DefineConstant2(const WCHAR *name,
1062 mdSignature sigToken);
1064 //-----------------------------------------------------------
1065 // ISymUnmanagedWriter3
1066 //-----------------------------------------------------------
1068 COM_METHOD OpenMethod2(mdMethodDef method,
1072 COM_METHOD Commit();
1074 //-----------------------------------------------------------
1075 // Methods not exposed via a COM interface.
1076 //-----------------------------------------------------------
1078 static HRESULT NewSymWriter(REFIID clsid, void** ppObj);
1079 HRESULT SetDocumentCheckSum(
1080 UINT32 DocumentEntry,
1084 HRESULT SetDocumentSrc(UINT32 DocumentEntry,
1088 COM_METHOD Write(void *pData, DWORD SizeOfData);
1089 COM_METHOD WriteStringPool();
1090 COM_METHOD WritePDB();
1092 COM_METHOD Initialize(const WCHAR *szFilename, IStream *pIStream);
1094 void SetFullPathName(const WCHAR *szFullPathName)
1100 // Helper API for CloserScope
1101 COM_METHOD CloseScopeInternal(ULONG32 endOffset);
1102 HRESULT GetOrCreateDocument(
1103 const WCHAR *wcsUrl, // Document name
1104 const GUID *pLanguage, // What Language we're compiling
1105 const GUID *pLanguageVendor, // What vendor
1106 const GUID *pDocumentType, // Type
1107 ISymUnmanagedDocumentWriter **ppRetVal // [out] Created DocumentWriter
1109 HRESULT CreateDocument(
1110 const WCHAR *wcsUrl, // Document name
1111 const GUID *pLanguage, // What Language we're compiling
1112 const GUID *pLanguageVendor, // What vendor
1113 const GUID *pDocumentType, // Type
1114 ISymUnmanagedDocumentWriter **ppRetVal // [out] Created DocumentWriter
1118 //-----------------------------------------------------------
1120 //-----------------------------------------------------------
1122 UINT32 m_refCount; // AddRef/Release
1124 mdMethodDef m_openMethodToken;
1125 mdMethodDef m_LargestMethodToken;
1126 SymMethodInfo * m_pmethod;
1128 // index of currently open scope
1129 UINT32 m_currentScope;
1131 // special scope "index" meaning there is no such scope
1132 static const UINT32 k_noScope = (UINT32)-1;
1134 // maximum scope end offset seen so far in this method
1135 ULONG32 m_maxScopeEnd;
1137 MethodInfo m_MethodInfo;
1138 ArrayStorage<SymMap> m_MethodMap; // Methods information
1141 WCHAR m_szPath[ _MAX_PATH ];
1144 // Stream we're storing into if asked to.
1145 IStream* m_pIStream;
1147 // StringPool we use to store the string into
1148 StgStringPool *m_pStringPool;
1150 // Project level symbol information
1151 PDBInfo ModuleLevelInfo;
1153 bool m_closed; // Have we closed the file yet?
1154 bool m_sortLines; // sort the line for current method
1155 bool m_sortMethodEntries; // Sort the method entries
1160 /* ------------------------------------------------------------------------- *
1161 * SymDocumentWriter class
1162 * ------------------------------------------------------------------------- */
1164 class SymDocumentWriter : public ISymUnmanagedDocumentWriter
1167 SymDocumentWriter(UINT32 DocumentEntry,
1168 SymWriter *pEmitter);
1170 virtual ~SymDocumentWriter();
1172 //-----------------------------------------------------------
1174 //-----------------------------------------------------------
1175 ULONG STDMETHODCALLTYPE AddRef()
1177 return (InterlockedIncrement((LONG *) &m_refCount));
1180 ULONG STDMETHODCALLTYPE Release()
1182 // Note that this must be thread-safe - it may be invoked on the finalizer thread
1183 LONG refCount = InterlockedDecrement((LONG *) &m_refCount);
1189 COM_METHOD QueryInterface(REFIID riid, void **ppInterface);
1191 //-----------------------------------------------------------
1192 // ISymUnmanagedDocumentWriter
1193 //-----------------------------------------------------------
1194 COM_METHOD SetSource(ULONG32 sourceSize, BYTE source[]);
1195 COM_METHOD SetCheckSum(GUID algorithmId,
1196 ULONG32 checkSumSize, BYTE checkSum[]);
1198 //-----------------------------------------------------------
1199 // Methods not exposed via a COM interface.
1200 //-----------------------------------------------------------
1202 // Commit the doc to the pdb
1204 UINT32 GetDocumentEntry()
1206 return m_DocumentEntry;
1209 //-----------------------------------------------------------
1211 //-----------------------------------------------------------
1213 UINT32 m_refCount; // AddRef/Release
1214 UINT32 m_DocumentEntry; // Entry into the documents array
1215 SymWriter *m_pEmitter; // Associated SymWriter
1219 struct RSDSI // RSDS debug info
1221 DWORD dwSig; // RSDS
1224 char szPDB[0]; // followed by a zero-terminated UTF8 file name
1227 #endif /* SYMWRITE_H_ */