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 | |
5 | |
6 | #ifndef _NIDUMP_H_ |
7 | #define _NIDUMP_H_ |
8 | |
9 | |
10 | #ifdef FEATURE_PREJIT |
11 | #include <daccess.h> |
12 | |
13 | //some DPTR definitions that aren't elsewhere in the source |
14 | typedef DPTR(const COR_SIGNATURE) PTR_CCOR_SIGNATURE; |
15 | typedef DPTR(IMAGE_SECTION_HEADER) ; |
16 | typedef DPTR(CerNgenRootTable) PTR_CerNgenRootTable; |
17 | typedef DPTR(struct CerRoot) PTR_CerRoot; |
18 | typedef DPTR(MethodContextElement) PTR_MethodContextElement; |
19 | typedef DPTR(DictionaryEntry) PTR_DictionaryEntry; |
20 | typedef DPTR(GuidInfo) PTR_GuidInfo; |
21 | #if defined(FEATURE_COMINTEROP) |
22 | typedef DPTR(SparseVTableMap) PTR_SparseVTableMap; |
23 | #endif |
24 | #if defined(FEATURE_COMINTEROP) |
25 | typedef DPTR(ClassFactoryBase) PTR_ClassFactoryBase; |
26 | #endif |
27 | typedef DPTR(LayoutEEClass) PTR_LayoutEEClass; |
28 | typedef DPTR(ArrayClass) PTR_ArrayClass; |
29 | typedef DPTR(DelegateEEClass) PTR_DelegateEEClass; |
30 | typedef DPTR(UMThunkMarshInfo) PTR_UMThunkMarshInfo; |
31 | typedef DPTR(CORCOMPILE_DEPENDENCY) PTR_CORCOMPILE_DEPENDENCY; |
32 | typedef DPTR(struct ModuleCtorInfo) PTR_ModuleCtorInfo; |
33 | typedef DPTR(class EEImplMethodDesc) PTR_EEImplMethodDesc; |
34 | typedef DPTR(class EEClassLayoutInfo) PTR_EEClassLayoutInfo; |
35 | typedef DPTR(class FieldMarshaler) PTR_FieldMarshaler; |
36 | typedef DPTR(LPCUTF8) PTR_LPCUTF8; |
37 | typedef DPTR(struct STORAGESIGNATURE UNALIGNED) PTR_STORAGESIGNATURE; |
38 | typedef DPTR(struct STORAGEHEADER UNALIGNED) ; |
39 | typedef DPTR(struct STORAGESTREAM UNALIGNED) PTR_STORAGESTREAM; |
40 | typedef DPTR(ArrayMethodDesc) PTR_ArrayMethodDesc; |
41 | |
42 | |
43 | #if 0 |
44 | template<typename PtrType> |
45 | class TokenHashMap : CClosedHash< Pair<DPTR(PtrType), mdToken> > |
46 | { |
47 | public: |
48 | typedef DPTR(PtrType) Key; |
49 | typedef mdTypeRef Data; |
50 | typedef Pair<Key, Data> Entry; |
51 | typedef CClosedHash< Entry > Parent; |
52 | TokenHashMap(int buckets = 23) : Parent(buckets) |
53 | { |
54 | |
55 | } |
56 | ~TokenHashMap() { } |
57 | |
58 | void Add(const Key key, const Data data) |
59 | { |
60 | Entry * newEntry = Parent::Add((void*)PTR_HOST_TO_TADDR(key)); |
61 | newEntry->First() = key; |
62 | newEntry->Second() = data; |
63 | } |
64 | |
65 | Data Find(const Key key) |
66 | { |
67 | Entry * found = Parent::Find((void*)PTR_HOST_TO_TADDR(key)); |
68 | if( !found ) |
69 | return mdTokenNil; |
70 | else |
71 | return found->Second(); |
72 | } |
73 | inline Key GetKey(Entry * entry) { return entry->First(); } |
74 | Parent::ELEMENTSTATUS Status(Entry * entry) |
75 | { |
76 | if( entry->First() == 0xffffffff && entry->Second() == 0xffffffff ) |
77 | return Parent::DELETED; |
78 | else if( entry->First() == 0x00000000 && entry->Second() == 0x00000000 ) |
79 | return Parent::FREE; |
80 | else |
81 | return Parent::USED; |
82 | } |
83 | void SetStatus(Entry * entry, Parent::ELEMENTSTATUS status) |
84 | { |
85 | switch(status) |
86 | { |
87 | case Parent::FREE: |
88 | entry->First() = Key((TADDR)0x00000000); |
89 | entry->Second() = 0x00000000; |
90 | break; |
91 | case Parent::DELETED: |
92 | entry->First() = Key((TADDR)0xffffffff); |
93 | entry->Second() = 0xffffffff; |
94 | break; |
95 | } |
96 | } |
97 | |
98 | unsigned int Compare(const Entry * lhs, Entry * rhs) |
99 | { |
100 | return lhs->First() == rhs->First() && lhs->Second() == rhs->Second(); |
101 | } |
102 | |
103 | //parent methods |
104 | unsigned int Hash(const void *pData) |
105 | { |
106 | return (int)(INT_PTR)pData; |
107 | } |
108 | unsigned int Compare(const void * p1, BYTE * p2) |
109 | { |
110 | return Compare((const Entry *) p1, (Entry*) p2); |
111 | } |
112 | Parent::ELEMENTSTATUS Status(BYTE * p){ |
113 | return Status((Entry*)p); |
114 | } |
115 | void SetStatus(BYTE * p, Parent::ELEMENTSTATUS status) { |
116 | SetStatus((Entry*)p, status); |
117 | } |
118 | void * GetKey(BYTE *p) { return (void*)GetKey((Entry*)p); } |
119 | }; |
120 | typedef TokenHashMap<EEClass> EEClassToTypeRefMap; |
121 | typedef TokenHashMap<MethodTable> MTToTypeRefMap; |
122 | #endif |
123 | |
124 | class NativeImageDumper |
125 | { |
126 | public: |
127 | //DPTR to private field needs to be a member of NativeImageDumper |
128 | #if defined(FEATURE_COMINTEROP) |
129 | typedef DPTR(SparseVTableMap::Entry) PTR_SparseVTableMap_Entry; |
130 | #endif |
131 | |
132 | NativeImageDumper(PTR_VOID loadedBase, const WCHAR * const name, |
133 | IXCLRDataDisplay * display, IXCLRLibrarySupport *support, |
134 | IXCLRDisassemblySupport * dis); |
135 | ~NativeImageDumper(); |
136 | |
137 | //type dumping methods |
138 | void DumpNativeImage(); |
139 | |
140 | void ComputeMethodFixupHistogram( PTR_Module module ); |
141 | void DumpFixupTables( PTR_Module module); |
142 | |
143 | void WriteElementTypeHandle( const char * name, TypeHandle th ); |
144 | void DoWriteFieldFieldDesc( const char * name, unsigned offset, |
145 | unsigned fieldSize, PTR_FieldDesc fd ); |
146 | void DoWriteFieldMethodDesc( const char * name, unsigned offset, |
147 | unsigned fieldSize, PTR_MethodDesc md ); |
148 | void DoWriteFieldTypeHandle( const char * name, unsigned offset, |
149 | unsigned fieldSize, TypeHandle th ); |
150 | void DoWriteFieldMDToken( const char * name, unsigned offset, |
151 | unsigned fieldsize, mdToken token, |
152 | IMetaDataImport2 *pAssemblyImport = NULL); |
153 | void DoWriteFieldMethodTable( const char * name, unsigned offset, |
154 | unsigned fieldSize, PTR_MethodTable mt ); |
155 | //if fixup is a fixup, it writes the field as if it were a fixup (including |
156 | //subelements) and returns true. Otherwise, it returns false. |
157 | BOOL DoWriteFieldAsFixup( const char * name, unsigned offset, |
158 | unsigned fieldSize, TADDR fixup ); |
159 | |
160 | void WriteElementMethodTable( const char * name, PTR_MethodTable mt ); |
161 | void WriteElementMethodDesc( const char * name, PTR_MethodDesc md ); |
162 | |
163 | void DoWriteFieldCorElementType( const char * name, unsigned offset, |
164 | unsigned fieldSize, CorElementType type ); |
165 | void WriteElementMDToken( const char * name, mdToken token ); |
166 | |
167 | void DoWriteFieldAsHex( const char * name, unsigned offset, |
168 | unsigned fieldSize, PTR_BYTE data, |
169 | unsigned dataLen ); |
170 | |
171 | void DumpMethods(PTR_Module module); |
172 | |
173 | void DumpCompleteMethod(PTR_Module module, MethodIterator& mi); |
174 | |
175 | void DisassembleMethod(BYTE *method, SIZE_T size); |
176 | |
177 | void DumpModule( PTR_Module module ); |
178 | void DumpNative(); |
179 | void (); |
180 | |
181 | void DumpBaseRelocs(); |
182 | void DumpHelperTable(); |
183 | |
184 | void DumpMethodFixups(PTR_Module module, |
185 | TADDR fixupList); |
186 | |
187 | void DumpTypes( PTR_Module module ); |
188 | |
189 | void DumpNgenRootTable( PTR_CerNgenRootTable table, const char * name, |
190 | unsigned offset, unsigned fieldSize ); |
191 | |
192 | void DumpMethodTable( PTR_MethodTable mt, const char * name, |
193 | PTR_Module module ); |
194 | |
195 | #ifndef STUB_DISPATCH_ALL |
196 | void DumpMethodTableSlotChunk( TADDR slotChunk, COUNT_T size, bool ); |
197 | #endif |
198 | |
199 | void DumpSlot( unsigned index, PCODE tgt ); |
200 | void DumpFieldDesc( PTR_FieldDesc fd, const char * name ); |
201 | void DumpEEClassForMethodTable( PTR_MethodTable mt ); |
202 | void DumpTypeDesc( PTR_TypeDesc td ); |
203 | |
204 | void DumpMethodDesc( PTR_MethodDesc md, PTR_Module module ); |
205 | void DumpPrecode( PTR_Precode precode, PTR_Module module ); |
206 | |
207 | |
208 | |
209 | |
210 | |
211 | |
212 | |
213 | //utility routines |
214 | void AppendTokenName(mdToken token, SString& str); |
215 | void AppendTokenName(mdToken token, SString& str, IMetaDataImport2 *pImport, |
216 | bool force = false); |
217 | void PrintManifestTokenName(mdToken token, SString& str); |
218 | void PrintManifestTokenName(mdToken token, SString& str, |
219 | IMetaDataAssemblyImport *pAssemblyImport, |
220 | bool force = false); |
221 | void WriteElementsFixupBlob(PTR_CORCOMPILE_IMPORT_SECTION pSection, SIZE_T fixup); |
222 | void WriteElementsFixupTargetAndName(RVA rva); |
223 | void FixupBlobToString(RVA rva, SString& buf); |
224 | |
225 | void AppendToken(mdToken token, SString& buf); |
226 | void AppendToken(mdToken token, SString& buf, IMetaDataImport2 *pImport); |
227 | IMetaDataImport2* TypeToString(PTR_CCOR_SIGNATURE &sig, SString& buf); // assumes pImport is m_import |
228 | IMetaDataImport2* TypeToString(PTR_CCOR_SIGNATURE &sig, SString& buf, |
229 | IMetaDataImport2 *pImport, |
230 | IMetaDataImport2 *pOrigImport =NULL); |
231 | void MethodTableToString( PTR_MethodTable mt, SString& buf ); |
232 | void TypeHandleToString( TypeHandle td, SString& buf ); |
233 | void TypeDescToString( PTR_TypeDesc td, SString& buf ); |
234 | void DictionaryToArgString( PTR_Dictionary dictionary, unsigned numArgs, SString& buf ); |
235 | |
236 | void EntryPointToString( PCODE pEntryPoint, SString& buf ); |
237 | void MethodDescToString( PTR_MethodDesc md, SString& buf ); |
238 | void FieldDescToString( PTR_FieldDesc fd, SString& buf ); |
239 | //uses tok to generate a name if fd == NULL |
240 | void FieldDescToString( PTR_FieldDesc fd, mdFieldDef tok, SString& buf ); |
241 | |
242 | #ifdef FEATURE_READYTORUN |
243 | private: |
244 | READYTORUN_HEADER * ; |
245 | |
246 | PTR_RUNTIME_FUNCTION m_pRuntimeFunctions; |
247 | DWORD m_nRuntimeFunctions; |
248 | |
249 | NativeFormat::NativeReader m_nativeReader; |
250 | NativeFormat::NativeArray m_methodDefEntryPoints; |
251 | |
252 | IMAGE_DATA_DIRECTORY * FindReadyToRunSection(DWORD type); |
253 | |
254 | public: |
255 | void DumpReadyToRun(); |
256 | void (); |
257 | void DumpReadyToRunMethods(); |
258 | void DumpReadyToRunMethod(PCODE pEntryPoint, PTR_RUNTIME_FUNCTION pRuntimeFunction, SString& name); |
259 | #endif // FEATURE_READYTORUN |
260 | |
261 | private: |
262 | PEDecoder m_decoder; |
263 | const WCHAR * const m_name; |
264 | PTR_VOID m_baseAddress; |
265 | SIZE_T m_imageSize; |
266 | IXCLRDataDisplay * m_display; |
267 | IXCLRLibrarySupport * m_librarySupport; |
268 | |
269 | bool isInRange(TADDR ptr) |
270 | { |
271 | return dac_cast<TADDR>(m_baseAddress) <= ptr |
272 | && ptr < (dac_cast<TADDR>(m_baseAddress) + m_imageSize); |
273 | } |
274 | |
275 | |
276 | COUNT_T ** m_fixupHistogram; |
277 | |
278 | #define COUNT_HISTOGRAM_SIZE 16 |
279 | COUNT_T m_fixupCountHistogram[COUNT_HISTOGRAM_SIZE]; |
280 | COUNT_T m_fixupCount; //used to track above counts |
281 | |
282 | // Primary image metadata |
283 | IMetaDataImport2 *m_import; |
284 | IMetaDataAssemblyImport *m_assemblyImport; |
285 | |
286 | // Installation manifest metadata. For native images this is metadata |
287 | // copied from the IL image. |
288 | IMetaDataImport2 *m_manifestImport; |
289 | IMetaDataAssemblyImport *m_manifestAssemblyImport; |
290 | |
291 | //helper for ComputeMethodFixupHistogram |
292 | BOOL HandleFixupForHistogram(PTR_CORCOMPILE_IMPORT_SECTION pSection, SIZE_T fixupIndex, SIZE_T *fixupCell); |
293 | |
294 | //helper for DumpMethodFixups |
295 | BOOL HandleFixupForMethodDump(PTR_CORCOMPILE_IMPORT_SECTION pSection, SIZE_T fixupIndex, SIZE_T *fixupCell); |
296 | |
297 | // Dependencies |
298 | |
299 | public: |
300 | struct Dependency |
301 | { |
302 | CORCOMPILE_DEPENDENCY * entry; |
303 | //CORINFO_ASSEMBLY_HANDLE assembly; |
304 | |
305 | TADDR pPreferredBase; |
306 | TADDR pLoadedAddress; |
307 | SIZE_T size; |
308 | |
309 | PTR_Module pModule; |
310 | IMetaDataImport2 *pImport; |
311 | TADDR pMetadataStartTarget; |
312 | TADDR pMetadataStartHost; |
313 | SIZE_T MetadataSize; |
314 | bool fIsMscorlib; |
315 | bool fIsHardbound; |
316 | WCHAR name[128]; |
317 | }; |
318 | |
319 | /* REVISIT_TODO Fri 12/09/2005 |
320 | * Perhaps the module and import should be in the dependency. In order to |
321 | * properly name tokens in modules w/o import entries. |
322 | */ |
323 | struct Import |
324 | { |
325 | DWORD index; |
326 | Dependency *dependency; |
327 | }; |
328 | private: |
329 | |
330 | Dependency *m_dependencies; |
331 | COUNT_T m_numDependencies; |
332 | Import *m_imports; |
333 | COUNT_T m_numImports; |
334 | CORCOMPILE_DEPENDENCY m_self; |
335 | |
336 | bool inline isSelf(const Dependency* dep) { |
337 | return &m_dependencies[0] == dep; |
338 | } |
339 | |
340 | |
341 | void OpenMetadata(); |
342 | void WriteElementsMetadata( const char * elementName, |
343 | TADDR data, SIZE_T size ); |
344 | NativeImageDumper::Dependency* |
345 | GetDependency(mdAssemblyRef token, IMetaDataAssemblyImport *pImport = NULL); |
346 | NativeImageDumper::Import *OpenImport(int i); |
347 | NativeImageDumper::Dependency * OpenDependency(int index); |
348 | void TraceDumpImport(int idx, NativeImageDumper::Import * import); |
349 | void TraceDumpDependency(int idx, NativeImageDumper::Dependency * dependency); |
350 | mdAssemblyRef MapAssemblyRefToManifest(mdAssemblyRef token, IMetaDataAssemblyImport *pAssemblyImport); |
351 | |
352 | const Dependency * GetDependencyForFixup(RVA rva); |
353 | const Dependency * GetDependencyForModule( PTR_Module module ); |
354 | #if 0 |
355 | const Import * GetImportForPointer( TADDR ptr ); |
356 | #endif |
357 | const Dependency * GetDependencyForPointer( TADDR ptr ); |
358 | #ifdef MANUAL_RELOCS |
359 | template< typename T > |
360 | inline T RemapPointerForReloc( T ptr ); |
361 | |
362 | inline TADDR RemapTAddrForReloc( TADDR ptr ); |
363 | |
364 | inline TADDR RemapTAddrForReloc( const NativeImageDumper::Dependency * d, |
365 | TADDR ptr ); |
366 | |
367 | template< typename T > |
368 | inline T RemapPointerForReloc( const NativeImageDumper::Dependency * d, |
369 | T ptr ); |
370 | #endif |
371 | |
372 | |
373 | // msdis support |
374 | |
375 | #if 0 |
376 | static size_t TranslateFixupCallback(const DIS *, DIS::ADDR, size_t, WCHAR *, size_t, DWORDLONG *); |
377 | static size_t TranslateRegrelCallback(const DIS *, DIS::REGA, DWORD, WCHAR *, size_t, DWORD *); |
378 | static size_t TranslateConstCallback(const DIS *, DWORD, WCHAR *, size_t); |
379 | #endif |
380 | IXCLRDisassemblySupport * m_dis; |
381 | static SIZE_T __stdcall TranslateFixupCallback(IXCLRDisassemblySupport *dis, |
382 | CLRDATA_ADDRESS addr, |
383 | SIZE_T size, __out_ecount(nameSize) WCHAR *name, |
384 | SIZE_T nameSize, |
385 | DWORDLONG *offset); |
386 | static SIZE_T __stdcall TranslateAddressCallback(IXCLRDisassemblySupport *dis, |
387 | CLRDATA_ADDRESS addr, |
388 | __out_ecount(nameSize) WCHAR *name, SIZE_T nameSize, |
389 | DWORDLONG *offset); |
390 | size_t TranslateSymbol(IXCLRDisassemblySupport *dis, |
391 | CLRDATA_ADDRESS addr, __out_ecount(nameSize) WCHAR *name, |
392 | SIZE_T nameSize, DWORDLONG *offset); |
393 | |
394 | CLRDATA_ADDRESS m_currentAddress; |
395 | bool m_currentIsAddress; |
396 | |
397 | //mscorwks sizes |
398 | TADDR m_mscorwksBase; |
399 | TADDR m_mscorwksPreferred; |
400 | SIZE_T m_mscorwksSize; |
401 | |
402 | |
403 | //internal type dumpers |
404 | void DumpDictionaryEntry( const char * name, DictionaryEntryKind kind, |
405 | PTR_DictionaryEntry entry ); |
406 | void WriteFieldDictionaryLayout( const char * name, unsigned offset, |
407 | unsigned fieldSize, |
408 | PTR_DictionaryLayout layout, |
409 | IMetaDataImport2 * import ); |
410 | |
411 | |
412 | IMAGE_SECTION_HEADER * FindSection( char const * name ); |
413 | |
414 | |
415 | //map traversal methods and helpers |
416 | void IterateTypeDefToMTCallback(TADDR taddrTarget, TADDR flags, PTR_LookupMapBase map, DWORD rid); |
417 | void IterateTypeRefToMTCallback(TADDR taddrTarget, TADDR flags, PTR_LookupMapBase map, DWORD rid); |
418 | void IterateMethodDefToMDCallback(TADDR taddrTarget, TADDR flags, PTR_LookupMapBase map, DWORD rid); |
419 | void IterateFieldDefToFDCallback(TADDR taddrTarget, TADDR flags, PTR_LookupMapBase map, DWORD rid); |
420 | void IterateMemberRefToDescCallback(TADDR taddrTarget, TADDR flags, PTR_LookupMapBase map, DWORD rid); |
421 | void IterateGenericParamToDescCallback(TADDR fdTarget, TADDR flags, PTR_LookupMapBase map, DWORD rid); |
422 | void IterateFileReferencesCallback(TADDR moduleTarget, TADDR flags, PTR_LookupMapBase map, DWORD rid); |
423 | void IterateManifestModules(TADDR moduleTarget, TADDR flags, PTR_LookupMapBase map, DWORD rid); |
424 | |
425 | void TraverseMap(PTR_LookupMapBase map, const char * name, unsigned offset, |
426 | unsigned fieldSize, |
427 | void(NativeImageDumper::*cb)(TADDR, TADDR, PTR_LookupMapBase, DWORD)); |
428 | |
429 | template<typename HASH_CLASS, typename HASH_ENTRY_CLASS> |
430 | void TraverseNgenHash(DPTR(HASH_CLASS) pTable, const char * name, |
431 | unsigned offset, unsigned fieldSize, |
432 | bool saveClasses, |
433 | void (NativeImageDumper::*DisplayEntryFunction)(void *, DPTR(HASH_ENTRY_CLASS), bool), |
434 | void *pContext); |
435 | template<typename HASH_CLASS, typename HASH_ENTRY_CLASS> |
436 | void TraverseNgenPersistedEntries(DPTR(HASH_CLASS) pTable, |
437 | DPTR(typename HASH_CLASS::PersistedEntries) pEntries, |
438 | bool saveClasses, |
439 | void (NativeImageDumper::*DisplayEntryFunction)(void *, DPTR(HASH_ENTRY_CLASS), bool), |
440 | void *pContext); |
441 | |
442 | void TraverseClassHashEntry(void *pContext, PTR_EEClassHashEntry pEntry, bool saveClasses); |
443 | void TraverseClassHash(PTR_EEClassHashTable pTable, const char * name, |
444 | unsigned offset, unsigned fieldSize, |
445 | bool saveClasses); |
446 | |
447 | #ifdef FEATURE_COMINTEROP |
448 | void TraverseGuidToMethodTableEntry(void *pContext, PTR_GuidToMethodTableEntry pEntry, bool saveClasses); |
449 | void TraverseGuidToMethodTableHash(PTR_GuidToMethodTableHashTable pTable, const char * name, |
450 | unsigned offset, unsigned fieldSize, bool saveClasses); |
451 | #endif // FEATURE_COMINTEROP |
452 | |
453 | void TraverseMemberRefToDescHashEntry(void *pContext, PTR_MemberRefToDescHashEntry pEntry, bool saveClasses); |
454 | |
455 | void TraverseMemberRefToDescHash(PTR_MemberRefToDescHashTable pTable, const char * name, |
456 | unsigned offset, unsigned fieldSize, bool saveClasses); |
457 | |
458 | |
459 | void TraverseTypeHashEntry(void *pContext, PTR_EETypeHashEntry pEntry, bool saveClasses); |
460 | void TraverseTypeHash(PTR_EETypeHashTable pTable, const char * name, |
461 | unsigned offset, unsigned fieldSize ); |
462 | |
463 | void TraverseInstMethodHashEntry(void *pContext, PTR_InstMethodHashEntry pEntry, bool saveClasses); |
464 | void TraverseInstMethodHash(PTR_InstMethodHashTable pTable, |
465 | const char * name, unsigned offset, |
466 | unsigned fieldSize, PTR_Module module); |
467 | |
468 | void TraverseStubMethodHashEntry(void *pContext, PTR_StubMethodHashEntry pEntry, bool saveClasses); |
469 | void TraverseStubMethodHash(PTR_StubMethodHashTable pTable, |
470 | const char * name, unsigned offset, |
471 | unsigned fieldSize, PTR_Module module); |
472 | |
473 | void DoWriteFieldStr( PTR_BYTE ptr, const char * name, unsigned offset, |
474 | unsigned fieldSize ); |
475 | |
476 | |
477 | template<typename T> |
478 | TADDR DPtrToPreferredAddr( T ptr ); |
479 | |
480 | TADDR DPtrToPreferredAddr( TADDR tptr ); |
481 | |
482 | void DumpAssemblySignature(CORCOMPILE_ASSEMBLY_SIGNATURE & assemblySignature); |
483 | |
484 | SIZE_T CountFields( PTR_MethodTable mt ); |
485 | mdToken ConvertToTypeDef( mdToken typeSpecOrRef, IMetaDataImport2* (&pImport) ); |
486 | SIZE_T CountDictionariesInClass( mdToken typeDefOrRef, IMetaDataImport2 * pImport ); |
487 | PTR_EEClass GetClassFromMT( PTR_MethodTable mt ); |
488 | PTR_MethodTable GetParent( PTR_MethodTable mt ); |
489 | |
490 | const Dependency* GetDependencyFromFD( PTR_FieldDesc fd ); |
491 | const Dependency* GetDependencyFromMD( PTR_MethodDesc md ); |
492 | const Dependency* GetDependencyFromMT( PTR_MethodTable mt ); |
493 | |
494 | CLRNativeImageDumpOptions m_dumpOptions; |
495 | inline TADDR RvaToDisplay( SIZE_T rva ); |
496 | inline TADDR DataPtrToDisplay(TADDR ptr); |
497 | inline int CheckOptions( CLRNativeImageDumpOptions opt ); |
498 | |
499 | //support various LookupMap Iterators |
500 | SArray<PTR_MethodTable> m_discoveredMTs; |
501 | |
502 | struct SlotChunk |
503 | { |
504 | TADDR addr; |
505 | WORD nSlots; |
506 | bool isRelative; |
507 | |
508 | inline bool operator==(const SlotChunk& sc) const |
509 | { |
510 | return (addr == sc.addr) && (nSlots == sc.nSlots) && (isRelative == sc.isRelative); |
511 | } |
512 | |
513 | inline bool operator<(const SlotChunk& sc) const |
514 | { |
515 | if (addr < sc.addr) |
516 | { |
517 | return TRUE; |
518 | } |
519 | else if (addr > sc.addr) |
520 | { |
521 | return FALSE; |
522 | } |
523 | else |
524 | { |
525 | return nSlots < sc.nSlots; |
526 | } |
527 | } |
528 | }; |
529 | |
530 | SArray<SlotChunk> m_discoveredSlotChunks; |
531 | //SArray<PTR_MethodDesc> m_discoveredMDs; |
532 | //SArray<PTR_FieldDesc> m_discoveredFDs; |
533 | SArray<PTR_MethodTable> m_discoveredClasses; |
534 | SArray<PTR_TypeDesc> m_discoveredTypeDescs; |
535 | |
536 | typedef InlineSString<128> TempBuffer; |
537 | |
538 | /* XXX Mon 10/03/2005 |
539 | * When we encounter pointers from metadata they are already in the host |
540 | * process because we read all of metadata in as one big block (since the |
541 | * metadata api isn't dac-ized. Map the metadata pointers back to good DAC |
542 | * pointers for compatibility with certain sig parsing code. |
543 | */ |
544 | TADDR m_MetadataStartHost; |
545 | TADDR m_MetadataStartTarget; |
546 | COUNT_T m_MetadataSize; |
547 | |
548 | //Support dumping IL. The COR_ILMETHOD_DECODER is not DACized, so read the |
549 | //whole IL section in, and translate RVAs into host pointers into the IL |
550 | //section copy |
551 | RVA m_ILSectionStart; |
552 | BYTE * m_ILHostCopy; |
553 | #ifdef _DEBUG |
554 | COUNT_T m_ILSectionSize; |
555 | #endif |
556 | |
557 | //This is true if we are hard bound to mscorlib. This enables various forms of generics dumping and MT |
558 | //dumping that require g_pObjectClass to be set. |
559 | bool m_isMscorlibHardBound; |
560 | |
561 | #if 0 |
562 | PTR_CCOR_SIGNATURE metadataToHostDAC( PCCOR_SIGNATURE pSig, |
563 | IMetaDataImport2 * import ); |
564 | #endif |
565 | template<typename T> |
566 | DPTR(T) metadataToHostDAC( T * pSig, IMetaDataImport2 * import); |
567 | |
568 | void DoDumpFieldStub( PTR_Stub stub, unsigned offset, unsigned fieldSize, |
569 | const char * name ); |
570 | #ifdef FEATURE_COMINTEROP |
571 | void DoDumpComPlusCallInfo( PTR_ComPlusCallInfo compluscall ); |
572 | #endif // FEATURE_COMINTEROP |
573 | |
574 | SIZE_T m_sectionAlignment; |
575 | inline SIZE_T GetSectionAlignment() const; |
576 | |
577 | public: |
578 | //this is the list of valid precode addresses for the current module. |
579 | struct PrecodeRange |
580 | { |
581 | PrecodeRange( CorCompileSection section, TADDR start, SIZE_T size ) |
582 | : m_sectionType(section), m_rangeStart(start), |
583 | m_rangeSize(size) { } |
584 | CorCompileSection m_sectionType; |
585 | TADDR m_rangeStart; |
586 | SIZE_T m_rangeSize; |
587 | }; |
588 | private: |
589 | bool isPrecode(TADDR maybePrecode); |
590 | void FixupThunkToString(PTR_CORCOMPILE_IMPORT_SECTION pImportSection, TADDR thunkAddr, SString& buf); |
591 | |
592 | #if 0 |
593 | MTToTypeRefMap m_mtToTypeRefMap; |
594 | EEClassToTypeRefMap m_eeClassToTypeRefMap; |
595 | void RecordTypeRef( mdTypeRef token, PTR_MethodTable mt ); |
596 | void RecordTypeRef( mdTypeRef token, PTR_EEClass clazz ); |
597 | mdTypeRef FindTypeRefForMT( PTR_MethodTable mt ); |
598 | mdTypeRef FindTypeRefForEEClass( PTR_EEClass clazz ); |
599 | #endif |
600 | |
601 | |
602 | public: |
603 | struct EnumMnemonics |
604 | { |
605 | EnumMnemonics( DWORD val, const WCHAR * m ) |
606 | : value(val), mask(val), mnemonic(m){ } |
607 | EnumMnemonics( DWORD val, DWORD msk, const WCHAR * m ) |
608 | : value(val), mask(msk), mnemonic(m) { } |
609 | DWORD value; |
610 | DWORD mask; |
611 | const WCHAR * mnemonic; |
612 | }; |
613 | |
614 | static EnumMnemonics s_ModulePersistedFlags[]; |
615 | static EnumMnemonics s_MDC[]; |
616 | static EnumMnemonics s_MDFlag2[]; |
617 | static EnumMnemonics s_TDFlags[]; |
618 | static EnumMnemonics s_SSMDExtendedFlags[]; |
619 | static EnumMnemonics s_IMDFlags[]; |
620 | static EnumMnemonics s_EECLIFlags[]; |
621 | }; |
622 | #include "nidump.inl" |
623 | |
624 | #endif //FEATURE_PREJIT |
625 | #endif |
626 | |