Merge pull request #2898 from adityamandaleeka/remove_sigprocmask
[platform/upstream/coreclr.git] / src / debug / inc / dacdbistructures.h
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 // File: DacDbiStructures.h
6 // 
7
8 //
9 // Declarations and inline functions for data structures shared between by the 
10 // DAC/DBI interface functions and the right side.
11 //
12 // Note that for MAC these structures are marshalled between Windows and Mac
13 // and so their layout and size must be identical in both builds.  Use the
14 // MSLAYOUT macro on every structure to avoid compiler packing differences.
15 //
16 //*****************************************************************************
17
18 #ifndef DACDBISTRUCTURES_H_
19 #define DACDBISTRUCTURES_H_
20
21 #include "./common.h"
22
23 //-------------------------------------------------------------------------------
24 // classes shared by the DAC/DBI interface functions and the right side
25 //-------------------------------------------------------------------------------
26
27 // DacDbiArrayList encapsulates an array and the number of elements in the array. 
28 // Notes:
29 // - storage is always on the DacDbi heap
30 // - this class owns the memory. Its dtor will free.
31 // - Operations that initialize list elements use the assignment
32 //   operator defined for type T.  If T is a pointer type or has pointer
33 //   type components and no assignment operator override, this will make a shallow copy of 
34 //   the element. If T has an assignment operator override that makes a deep copy of pointer
35 //   types, T must also have a destructor that will deallocate any memory allocated.  
36 // - this is NOT thread safe!!!
37 // - the array elements are always mutable, but the number of elements is fixed between allocations
38 // - you can gain access to the array using &(list[0]) but this is NOT safe if the array is empty. You 
39 //   can call IsEmpty to determine if it is safe to access the array portion
40 //   This list is not designed to have unused elements at the end of the array (extra space) nor to be growable
41     
42 // usage examples:
43 // typedef DacDbiArrayList<Bar> BarList;       // handy typedef
44 // void GetAListOfBars(BarList * pBarList)
45 // { 
46 //     DacDbiArrayList<Foo> fooList;   // fooList is an empty array of objects of type Foo
47 //     int elementCount = GetNumberOfFoos();
48 //     Bar * pBars = new Bar[elementCount];     
49 // 
50 //     fooList.Alloc(elementCount);            // get space for the list of Foo instances
51 //     for (int i = 0; i < fooList.Count(); ++i)
52 //     {
53 //        fooList[i] = GetNextFoo();           // copy elements into the list
54 //     }
55 //     ConvertFoosToBars(pBars, &fooList);     // always pass by reference
56 //     pBarList->Init(pBars, fooList.Count()); // initialize  a list
57 // }
58 // 
59 // void ConvertFoosToBars(Bar * pBars, DacDbiArrayList<Foo> * pFooList)
60 // {
61 //    for (int i = 0; i < pFooList->Count(); ++i)
62 //    {
63 //        if ((*pFooList)[i].IsBaz())
64 //            pBars [i] = ConvertBazToBar(&(*pFooList)[i]);
65 //        else pBars [i] = (*pFooList)[i].barPart;
66 //    } 
67 // }
68 //    
69 template<class T> 
70 class MSLAYOUT DacDbiArrayList
71 {
72 public:
73     // construct an empty list
74     DacDbiArrayList();
75  
76     // deep copy constructor
77     DacDbiArrayList(const T * list, int count);
78
79     // destructor--sets list to empty state
80     ~DacDbiArrayList();
81
82     // explicitly deallocate the list and set it back to the empty state
83     void Dealloc();
84     
85     // allocate a list with space for nElements items
86     void Alloc(int nElements);
87
88     // allocate and initialize a DacDbiArrayList from an array of type T and a count
89     void Init(const T * list, int count);
90
91     // predicate to indicate if the list is empty
92     bool IsEmpty() { return m_nEntries == 0; }
93
94     // read-only element accessor
95     const T & operator [](int index) const;
96     
97     // writeable element accessor
98     T & operator [](int index);
99
100
101     // returns the number of elements in the list
102     int Count() const;
103
104     // @dbgtodo  Mac - cleaner way to expose this for serialization?
105     void PrepareForDeserialize()
106     {
107         m_pList = NULL; 
108     }
109 private:
110     // because these are private (and unimplemented), calls will generate a compiler (or linker) error. 
111     // This prevents accidentally invoking the default (shallow) copy ctor or assignment operator.
112     // This prevents having multiple instances point to the same list memory (eg. due to passing by value), 
113     // which would result in memory corruption when the first copy is destroyed and the list memory is deallocated.
114     DacDbiArrayList(const DacDbiArrayList<T> & sourceList);
115     T & operator = (const DacDbiArrayList<T> & rhs);
116  
117 // data members
118 protected:
119     T *  m_pList;           // the list 
120     
121     // - the count is managed by the member functions and is not settable, so (m_pList == NULL) == (m_nEntries == 0) 
122     //   is always true. 
123     int  m_nEntries;        // the number of items in the list
124
125 };
126
127
128 // Describes a buffer in the target
129 struct MSLAYOUT TargetBuffer
130 {
131     TargetBuffer();
132     TargetBuffer(CORDB_ADDRESS pBuffer, ULONG cbSizeInput);
133
134     // @dbgtodo : This ctor form confuses target and host address spaces.  This should probably be PTR_VOID instead of void*
135     TargetBuffer(void * pBuffer, ULONG cbSizeInput);
136
137     //
138     // Helper methods
139     //
140     
141     // Return a sub-buffer that's starts at byteOffset within this buffer and runs to the end.
142     TargetBuffer SubBuffer(ULONG byteOffset) const;
143
144     // Return a sub-buffer that starts at byteOffset within this buffer and is byteLength long.
145     TargetBuffer SubBuffer(ULONG byteOffset, ULONG byteLength) const;
146
147     // Returns true if the buffer length is 0. 
148     bool IsEmpty() const;
149
150     // Sets address to NULL and size to 0
151     // IsEmpty() will be true after this.
152     void Clear();
153
154     // Initialize fields
155     void Init(CORDB_ADDRESS address, ULONG size);
156
157     // Target address of buffer
158     CORDB_ADDRESS pAddress;
159
160     // Size of buffer in bytes
161     ULONG         cbSize;
162 };
163
164 //===================================================================================
165 // Module properties, retrieved by DAC.
166 // Describes a VMPTR_DomainFile representing a module. 
167 // In the VM, a raw Module may be domain neutral and shared by many appdomains.
168 // Whereas a DomainFile is like a { AppDomain, Module} pair. DomainFile corresponds
169 // much more to ICorDebugModule (which also has appdomain affinity).
170 //===================================================================================
171 struct MSLAYOUT DomainFileInfo
172 {
173     // The appdomain that the DomainFile is associated with.
174     // Although VMPTR_Module may be shared across multiple domains, a DomainFile has appdomain affinity.
175     VMPTR_AppDomain vmAppDomain; 
176
177     // The assembly this module belongs to. All modules live in an assembly.
178     VMPTR_DomainAssembly vmDomainAssembly;
179 };
180
181 struct MSLAYOUT ModuleInfo
182 {
183     // The non-domain specific assembly which this module resides in.
184     VMPTR_Assembly vmAssembly;
185     
186     // The PE Base address and size of the module. These may be 0 if there is no image
187     // (such as for a dynamic module that's not persisted to disk).
188     CORDB_ADDRESS pPEBaseAddress;
189
190     // The PEFile associated with the module. Every module (even non-file-based ones) has a PEFile. 
191     // This is critical because DAC may ask for a metadata importer via PE-file.
192     // a PEFile may have 1 or more PEImage child objects (1 for IL, 1 for native image, etc)
193     VMPTR_PEFile vmPEFile; 
194   
195     // The PE Base address and size of the module. These may be 0 if there is no image
196     // (such as for a dynamic module that's not persisted to disk).
197     ULONG nPESize;
198     
199     // Is this a dynamic (reflection.emit) module?
200     // This means that new classes can be added to the module; and so
201     // the module's metadata and symbols can be updated. Debugger will have to do extra work
202     // to keep up with the updates.
203     // Dynamic modules may be transient (entirely in-memory) or persisted to disk (have a file associated with them).
204     BOOL  fIsDynamic;
205
206     // Is this an inmemory module? 
207     // Assemblies can be instantiated purely in-memory from just a Byte[]. 
208     // This means the module (and pdb) are not in files, and thus the debugger
209     // needs to do extra work to retrieve them from the Target's memory.
210     BOOL  fInMemory;
211 };
212
213 // the following two classes track native offsets for local variables and sequence 
214 // points. This information is initialized on demand. 
215
216
217 //===================================================================================
218 // NativeVarData holds a list of structs that provide the following information for
219 // each local variable and fixed argument in a function: the offsets between which the 
220 // variable or argument lives in a particular location, the location itself, and the 
221 // variable number (ID). This allows us to determine where a value is at any given IP.
222
223 // Lifetime management of the list is the responsibility of the NativeVarData class. 
224 // Callers that allocate memory for a new list should NOT maintain a separate pointer
225 // to the list. 
226
227 // The arguments we track are the "fixed" arguments, specifically, the explicit arguments
228 // that appear in the source code and the "this" pointer for non-static methods. 
229 // Varargs and other implicit arguments, such as the generic handle are counted in 
230 // CordbJITILFrame::m_allArgsCount. 
231
232 // Although logically, we really don't differentiate between arguments and locals when 
233 // all we want to know is where to find a value, we need to have two 
234 // separate counts. The full explanation is in the comment in rsthread.cpp in 
235 // CordbJITILFrame::ILVariableToNative, but the short version is that it allows us to  
236 // compute the correct ID for a value. 
237
238 // m_fixedArgsCount, accessed through GetFixedArgCount, is the actual number of fixed 
239 // arguments. 
240 // m_allArgsCount, accessed through GetAllArgsCount, is the number of fixed args plus the
241 // number of varargs.
242
243 // The number of entries in m_offsetInfo, accessed through Count(), is NOT the 
244 // number of locals, nor the number of locals plus the number of arguments. It is the 
245 // number of entries in the list. Any particular value may have an arbitrary number of 
246 // entries, depending on how many different places it is stored during the execution of 
247 // the method. The list is not sorted, so searches for data within it must be linear. 
248 //===================================================================================
249 class MSLAYOUT NativeVarData 
250 {
251 public:
252     // constructor
253     NativeVarData();
254     // destructor
255     ~NativeVarData();
256
257
258     // initialize the list of native var information structures, including the starting address of the list
259     // (m_pOffsetInfo, the number of entries (m_count) and the number of fixed args (m_fixedArgsCount).
260     // NativeVarData will manage the lifetime of the allocated memory for the list, so the caller should not
261     // hold on to its address. 
262     void InitVarDataList(ICorDebugInfo::NativeVarInfo * plistStart, int fixedArgCount, int entryCount);
263     
264 private:
265     // non-existent copy constructor to disable the (shallow) compiler-generated
266     // one. If you attempt to use this, you will get a compiler or linker error.
267     NativeVarData(const NativeVarData & rhs) {};
268
269     // non-existent assignment operator to disable the (shallow) compiler-generated
270     // one. If you attempt to use this, you will get a compiler or linker error.
271     NativeVarData & operator=(const NativeVarData & rhs);
272
273 //----------------------------------------------------------------------------------
274 // Accessor Functions
275 //----------------------------------------------------------------------------------
276 public:
277
278     // get the list of native offset info
279     const DacDbiArrayList<ICorDebugInfo::NativeVarInfo> * GetOffsetInfoList() const
280     {
281         _ASSERTE(m_fInitialized);
282         return &m_offsetInfo;
283     }
284
285     // get the number of explicit arguments for this function--this
286     // includes the fixed arguments for vararg methods, but not the variable ones
287     ULONG32 GetFixedArgCount()
288     {
289         _ASSERTE(IsInitialized());
290         // this count includes explicit arguments plus one for the "this" pointer
291         // but doesn't count varargs
292         return m_fixedArgsCount;
293     }
294
295     // get the number of all arguments, including varargs
296     ULONG32 GetAllArgsCount()
297     {
298         _ASSERTE(IsInitialized());
299         return m_allArgsCount;
300     }
301
302     // set the number of all arguments, including varargs
303     void SetAllArgsCount(ULONG32 count)
304     {
305         m_allArgsCount = count;
306     }
307
308     // determine whether we have successfully initialized this
309     BOOL IsInitialized()
310     {
311         return m_fInitialized == true;
312     }
313
314
315 //----------------------------------------------------------------------------------
316 // Data Members
317 //----------------------------------------------------------------------------------
318
319 // @dbgtodo  Mac - making this public for serializing for remote DAC on mac. Need to make this private again.
320 public: 
321     // contains a list of structs providing information about the location of a local 
322     // variable or argument between a pair of offsets and the number of entries in the list
323     DacDbiArrayList<ICorDebugInfo::NativeVarInfo> m_offsetInfo;   
324
325     // number of fixed arguments to the function i.e., the explicit arguments and "this" pointer
326     ULONG32                                     m_fixedArgsCount;     
327
328     // number of fixed arguments plus number of varargs
329     ULONG32                                     m_allArgsCount;   
330
331     // indicates whether an attempt has been made toinitialize the var data already
332     bool                                        m_fInitialized;   
333 }; // class NativeVarData
334
335 //===================================================================================
336 // SequencePoints holds a list of sequence points that map IL offsets to native offsets. In addition,  
337 // it keeps track of the number of entries in the list and whether the list is sorted. 
338 //===================================================================================
339 class MSLAYOUT SequencePoints
340 {
341 public:
342     SequencePoints();
343
344     ~SequencePoints();
345
346     // Initialize the m_pMap data member to the address of an allocated chunk 
347     // of memory (or to NULL if the count is zero). Set m_count as the 
348     // number of entries in the map.
349     void InitSequencePoints(ULONG32 count);
350
351 private:
352     // non-existent copy constructor to disable the (shallow) compiler-generated
353     // one. If you attempt to use this, you will get a compiler or linker error.
354     SequencePoints(const SequencePoints & rhs) {};
355
356     // non-existent assignment operator to disable the (shallow) compiler-generated
357     // one. If you attempt to use this, you will get a compiler or linker error.
358     SequencePoints & operator=(const SequencePoints & rhs);
359
360     //----------------------------------------------------------------------------------
361     // class MapSortILMap:  A template class that will sort an array of DebuggerILToNativeMap.
362     // This class is intended to be instantiated on the stack / in temporary storage, and used 
363     // to reorder the sequence map.
364     //----------------------------------------------------------------------------------
365     class MapSortILMap : public CQuickSort<DebuggerILToNativeMap>
366     {
367       public:
368         //Constructor
369         MapSortILMap(DebuggerILToNativeMap * map,
370                   int count)
371           : CQuickSort<DebuggerILToNativeMap>(map, count) {}
372
373         // secondary key comparison--if two IL offsets are the same, 
374         // we determine order based on native offset
375         int CompareInternal(DebuggerILToNativeMap * first,
376                             DebuggerILToNativeMap * second);
377
378         //Comparison operator
379         int Compare(DebuggerILToNativeMap * first,
380                     DebuggerILToNativeMap * second);
381     };
382
383 //----------------------------------------------------------------------------------
384 // Accessor Functions
385 //----------------------------------------------------------------------------------
386 public:
387     // @dbgtodo Microsoft inspection: It would be very nice not to need this at all. Ideally,
388     // it would be better to make ExportILToNativeMap expect a DacDbiArrayList instead of the
389     // array and size. At present, there's a call to ExportILToNativeMap in debugger.cpp where
390     // DacDbiArrayLists aren't available, so at present, we need to pass the array and size.
391     // We should be able to eliminate the debugger.cpp call when we get rid of in-proc 
392     // inspection. At that point, we can delete this function too, as well as GetEntryCount. 
393     // In the meantime, it would be great if no one else took a dependency on this. 
394
395     // get value of m_pMap
396     DebuggerILToNativeMap * GetMapAddr()
397     {
398         // Please don't call this function
399        _ASSERTE(m_fInitialized); 
400        return &(m_map[0]);
401     }
402
403     // get value of m_count
404     ULONG32 GetEntryCount()
405     {
406         _ASSERTE(m_fInitialized); 
407         return m_mapCount;
408     }
409     
410     ULONG32 GetCallsiteEntryCount()
411     {
412         _ASSERTE(m_fInitialized); 
413         return m_map.Count() - m_mapCount; //m_map.Count();
414     }
415     
416     DebuggerILToNativeMap * GetCallsiteMapAddr()
417     {
418         // Please don't call this function
419        _ASSERTE(m_fInitialized);
420        
421        if (m_map.Count() == m_mapCount)
422           return NULL;
423        
424        return &(m_map[m_mapCount]);
425     }
426     
427     
428
429     // determine whether we have initialized this
430     BOOL IsInitialized()
431     {
432         return m_fInitialized == true;
433     }
434
435     // Copy data from the VM map data to our own map structure and sort. The 
436     // information comes to us in a data structure that differs slightly from the 
437     // one we use out of process, so we have to copy it to the right-side struct.
438     void CopyAndSortSequencePoints(const ICorDebugInfo::OffsetMapping  mapCopy[]);
439
440
441     // Set the IL offset of the last sequence point before the epilog.  
442     // If a native offset maps to the epilog, we will return the this IL offset.
443     void SetLastILOffset(ULONG32 lastILOffset)
444     {
445         _ASSERTE(m_fInitialized);
446         m_lastILOffset = lastILOffset;
447     }
448
449     // Map the given native offset to IL offset.  Also return the mapping type.
450     DWORD MapNativeOffsetToIL(DWORD dwNativeOffset,
451                               CorDebugMappingResult *pMapType);
452
453 //----------------------------------------------------------------------------------
454 // Data Members
455 //----------------------------------------------------------------------------------
456
457     // @dbgtodo  Mac - making this public for serializing for remote DAC on mac. Need to make this private again.
458 public:
459
460     // map of IL to native offsets for sequence points
461     DacDbiArrayList<DebuggerILToNativeMap> m_map;
462     
463     //
464     ULONG32 m_mapCount;
465          
466     // the IL offset of the last sequence point before the epilog
467     ULONG32                                m_lastILOffset; 
468     // indicates whether an attempt has been made to initialize the sequence points already
469     bool                                   m_fInitialized; 
470 }; // class SequencePoints
471
472 //----------------------------------------------------------------------------------
473 // declarations needed for getting native code regions
474 //----------------------------------------------------------------------------------
475
476 // Code may be split into Hot & Cold regions, so we need an extra address & size.
477 // The jitter doesn't do this optimization w/ debuggable code, so we'll
478 // rarely see the cold region information as non-null values.
479
480 // This enumeration provides symbolic indices into m_rgCodeRegions. 
481 typedef enum {kHot = 0, kCold, MAX_REGIONS} CodeBlobRegion;
482
483 // This contains the information we need to initialize a CordbNativeCode object
484 class MSLAYOUT NativeCodeFunctionData
485 {
486 public:
487     // set all fields to default values (NULL, FALSE, or zero as appropriate)
488     NativeCodeFunctionData();
489     
490     // conversion constructor to convert from an instance of DebuggerIPCE_JITFUncData to an instance of 
491     // NativeCodeFunctionData.
492     NativeCodeFunctionData(DebuggerIPCE_JITFuncData * source);
493
494     // The hot region start address could be NULL in the following circumstances:
495     // 1. We haven't yet tried to get the information
496     // 2. We tried to get the information, but the function hasn't been jitted yet 
497     // 3. We tried to get the information, but the MethodDesc wasn't available yet (very early in 
498     //    module initialization), which implies that the code isn't available either.
499     // 4. We tried to get the information, but a method edit has reset the MethodDesc, but the
500     //    method hasn't been jitted yet. 
501     // In all cases, we can check the hot region start address to determine whether the rest of the
502     // the information is valid.
503     BOOL IsValid() { return (m_rgCodeRegions[kHot].pAddress != NULL); }
504     void Clear();
505        
506     // data members
507     // start addresses and sizes of hot & cold regions
508     TargetBuffer     m_rgCodeRegions[MAX_REGIONS]; 
509
510     // indicates whether the function is a generic function, or a method inside a generic class (or both).
511     BOOL             isInstantiatedGeneric;     
512
513     // MethodDesc for the function
514     VMPTR_MethodDesc vmNativeCodeMethodDescToken;  
515
516     // EnC version number of the function
517     SIZE_T           encVersion;                    
518 };
519
520 //----------------------------------------------------------------------------------
521 // declarations needed for getting type information
522 //----------------------------------------------------------------------------------
523
524 // FieldData holds data for each field within a class or type. This data
525 // is passed from the DAC to the DI in response to a request for class info.
526 // This type is also used by CordbClass and CordbType to hold the list of fields for the
527 // class.
528 class MSLAYOUT FieldData
529 {
530 public:
531 #ifndef RIGHT_SIDE_COMPILE
532     // initialize various fields of an instance of FieldData from information in a FieldDesc
533     void Initialize(BOOL fIsStatic, BOOL fIsPrimitive, mdFieldDef mdToken);
534 #else
535     HRESULT GetFieldSignature(class CordbModule * pModule, /*OUT*/ SigParser * pSigParser);
536 #endif
537
538     // clear various fields for a new instance of FieldData
539     void ClearFields();
540
541     // Make sure it's okay to get or set an instance field offset. 
542     BOOL OkToGetOrSetInstanceOffset();
543
544     // Make sure it's okay to get or set a static field address. 
545     BOOL OkToGetOrSetStaticAddress();
546
547     // If this is an instance field, store its offset
548     void SetInstanceOffset( SIZE_T offset );
549
550     // If this is a "normal" static, store its absolute address
551     void SetStaticAddress( TADDR addr );
552
553     // If this is an instance field, return its offset
554     // Note that this offset is allways a real offset (possibly larger than 22 bits), which isn't
555     // necessarily the same as the overloaded FieldDesc.dwOffset field which can have
556     // some special FIELD_OFFSET tokens.
557     SIZE_T  GetInstanceOffset();
558
559     // If this is a "normal" static, get its absolute address
560     // TLS and context-specific statics are "special".
561     TADDR GetStaticAddress();
562
563 //
564 // Data members
565 // 
566     mdFieldDef      m_fldMetadataToken;
567     // m_fFldStorageAvailable is true whenever the storage for this field is available.
568     // If this is a field that is newly added with EnC and hasn't had any storage
569     // allocated yet, then fldEnCAvailable will be false.
570     BOOL            m_fFldStorageAvailable;
571
572     // Bits that specify what type of field this is
573     bool            m_fFldIsStatic;           // true if static field, false if instance field
574     bool            m_fFldIsRVA;              // true if static relative to module address
575     bool            m_fFldIsTLS;              // true if thread-specific static
576     bool            m_fFldIsContextStatic;    // true if context-specific static
577     bool            m_fFldIsPrimitive;        // Only true if this is a value type masquerading as a primitive.
578     bool            m_fFldIsCollectibleStatic; // true if this is a static field on a collectible type
579
580 private:
581     // The m_fldInstanceOffset and m_pFldStaticAddress are mutually exclusive. Only one is ever set at a time.
582     SIZE_T          m_fldInstanceOffset;      // The offset of a field within an object instance
583                                               // For EnC fields, this isn't actually within the object instance,
584                                               // but has been cooked to still be relative to the beginning of 
585                                               // the object.
586     TADDR           m_pFldStaticAddress;      // The absolute target address of a static field
587
588     PCCOR_SIGNATURE m_fldSignatureCache;      // This is passed across as null. It is a RS-only cache, and SHOULD 
589                                               // NEVER BE ACCESSED DIRECTLY!
590     ULONG           m_fldSignatureCacheSize;  // This is passed across as 0. It is a RS-only cache, and SHOULD 
591                                               // NEVER BE ACCESSED DIRECTLY!
592 public:
593     VMPTR_FieldDesc m_vmFieldDesc;
594
595 }; // class FieldData
596
597
598 // ClassInfo holds information about a type (class or other structured type), including a list of its fields
599 class MSLAYOUT ClassInfo
600 {
601 public:
602     ClassInfo();
603
604     ~ClassInfo();
605
606     void Clear(); 
607
608     // Size of object in bytes, for non-generic types. Note: this is NOT valid for constructed value types,
609     // e.g. value type Pair<DateTime,int>.  Use CordbType::m_objectSize instead.
610     SIZE_T                     m_objectSize;        
611
612     // list of structs containing information about all the fields in this Class, along with the number of entries
613     // in the list. Does not include inherited fields. DON'T KEEP POINTERS TO ELEMENTS OF m_fieldList AROUND!!
614                                                 // This may be deleted if the class gets EnC'd.
615     DacDbiArrayList<FieldData> m_fieldList;         
616 }; // class ClassInfo
617
618 // EnCHangingFieldInfo holds information describing a field added with Edit And Continue. This data
619 // is passed from the DAC to the DI in response to a request for EnC field info.
620 class MSLAYOUT EnCHangingFieldInfo
621 {
622 public:
623     // Init will initialize fields, taking into account whether the field is static or not. 
624     void Init(VMPTR_Object     pObject, 
625               SIZE_T           offset, 
626               mdFieldDef       fieldToken, 
627               CorElementType   elementType, 
628               mdTypeDef        metadataToken,
629               VMPTR_DomainFile vmDomainFile); 
630
631     DebuggerIPCE_BasicTypeData GetObjectTypeData() const { return m_objectTypeData; };
632     mdFieldDef GetFieldToken() const { return m_fldToken; };
633     VMPTR_Object GetVmObject() const { return m_vmObject; };
634     SIZE_T GetOffsetToVars() const { return m_offsetToVars; };
635
636 private:
637     DebuggerIPCE_BasicTypeData m_objectTypeData; // type data for the EnC field
638     VMPTR_Object               m_vmObject;        // object instance to which the field has been added--if the field is 
639                                                  // static, this will be NULL instead of pointing to an instance
640     SIZE_T                     m_offsetToVars;   // offset to the beginning of variable storage in the object
641     mdFieldDef                 m_fldToken;       // metadata token for the added field
642
643 }; // EnCHangingFieldInfo
644
645 // TypeHandleToExpandedTypeInfo returns different DebuggerIPCE_ExpandedTypeData objects
646 // depending on whether the object value that the TypeData corresponds to is
647 // boxed or not.  Different parts of the API transfer objects in slightly different ways.
648 // AllBoxed:
649 //    For GetAndSendObjectData all values are boxed,
650 //
651 // OnlyPrimitivesUnboxed:
652 //     When returning results from FuncEval only "true" structs
653 //     get boxed, i.e. primitives are unboxed.
654 //
655 // NoValueTypeBoxing:
656 //     TypeHandleToExpandedTypeInfo is also used to report type parameters,
657 //      and in this case none of the types are considered boxed (
658 enum AreValueTypesBoxed { NoValueTypeBoxing, OnlyPrimitivesUnboxed, AllBoxed };
659
660 // TypeRefData is used for resolving a type reference (see code:CordbModule::ResolveTypeRef and 
661 // code:DacDbiInterfaceImpl::ResolveTypeReference) to store relevant information about the type
662 typedef struct MSLAYOUT 
663 {
664     // domain file for the type
665     VMPTR_DomainFile vmDomainFile;
666     // metadata token for the type. This may be a typeRef (for requests) or a typeDef (for responses).
667     mdToken          typeToken;
668 } TypeRefData;
669
670 // @dbgtodo Microsoft inspection: get rid of IPCE type.
671 // TypeInfoList encapsulates a list of type data instances and the length of the list.
672 typedef DacDbiArrayList<DebuggerIPCE_TypeArgData> TypeInfoList;
673
674 // ArgInfoList encapsulates a list of type data instances for arguments for a top-level
675 // type and the length of the list.
676 typedef DacDbiArrayList<DebuggerIPCE_BasicTypeData> ArgInfoList;
677
678 // TypeParamsList encapsulate a list of type parameters and the length of the list
679 typedef DacDbiArrayList<DebuggerIPCE_ExpandedTypeData> TypeParamsList;
680     
681 // A struct for passing version information from DBI to DAC.
682 // See code:CordbProcess::CordbProcess#DBIVersionChecking for more information.
683 const DWORD kCurrentDacDbiProtocolBreakingChangeCounter = 1;
684
685 struct DbiVersion
686 {
687     DWORD m_dwFormat;               // the format of this DbiVersion instance
688     DWORD m_dwDbiVersionMS;         // version of the DBI DLL, in the convention used by VS_FIXEDFILEINFO
689     DWORD m_dwDbiVersionLS;
690     DWORD m_dwProtocolBreakingChangeCounter;  // initially this was reserved and always set to 0
691                                                   // Now we use it as a counter to explicitly introduce breaking changes
692                                                   // between DBI and DAC when we have our IPC transport in the middle
693                                                   // If DBI and DAC don't agree on the same value CheckDbiVersion will return CORDBG_E_INCOMPATIBLE_PROTOCOL
694                                                   // Please document every time this value changes
695                                                   // 0 - initial value
696                                                   // 1 - Indicates that the protocol now supports the GetRemoteInterfaceHashAndTimestamp message
697                                                   //     The message must have ID 2, with signature:
698                                                   //     OUT DWORD & hash1, OUT DWORD & hash2, OUT DWORD & hash3, OUT DWORD & hash4, OUT DWORD & timestamp1, OUT DWORD & timestamp2
699                                                   //     The hash can be used as an indicator of many other breaking changes providing
700                                                   //     easier automated enforcement during development. It is NOT recommended to use
701                                                   //     the hash as a release versioning mechanism however.
702     DWORD m_dwReservedMustBeZero1;  // reserved for future use
703 };
704
705 // The way in which a thread is blocking on an object
706 enum DacBlockingReason
707 {
708     DacBlockReason_MonitorCriticalSection,
709     DacBlockReason_MonitorEvent
710 };
711
712 // Information about an object which is blocking a managed thread
713 struct DacBlockingObject
714 {
715     VMPTR_Object      vmBlockingObject;
716     VMPTR_AppDomain   vmAppDomain;
717     DWORD             dwTimeout;
718     DacBlockingReason blockingReason;
719 };
720
721 // Opaque user defined data used in callbacks
722 typedef void* CALLBACK_DATA;
723
724 struct MonitorLockInfo
725 {
726     VMPTR_Thread lockOwner;
727     DWORD acquisitionCount;
728 };
729
730 struct MSLAYOUT DacGcReference
731 {
732     VMPTR_AppDomain vmDomain;   // The AppDomain of the handle/object, may be null.
733     union
734     {
735         CORDB_ADDRESS pObject;     // A managed object, with the low bit set.
736         VMPTR_OBJECTHANDLE objHnd;  // A reference to the object, valid if (pAddress & 1) == 0
737     };
738     DWORD dwType;           // Where the root came from.
739     
740     /*
741         DependentSource - for HandleDependent
742         RefCount - for HandleStrongRefCount
743         Size - for HandleSizedByref
744     */
745     UINT64 i64ExtraData;
746 }; // struct DacGcReference
747
748 struct MSLAYOUT DacExceptionCallStackData
749 {
750     VMPTR_AppDomain vmAppDomain;
751     VMPTR_DomainFile vmDomainFile;
752     CORDB_ADDRESS ip;
753     mdMethodDef methodDef;
754     BOOL isLastForeignExceptionFrame;
755 };
756
757 // These represent the various states a SharedReJitInfo can be in.
758 enum DacSharedReJitInfoState
759 {
760     // The profiler has requested a ReJit, so we've allocated stuff, but we haven't
761     // called back to the profiler to get any info or indicate that the ReJit has
762     // started. (This Info can be 'reused' for a new ReJit if the
763     // profiler calls RequestReJit again before we transition to the next state.)
764     kStateRequested = 0x00000000,
765
766     // We have asked the profiler about this method via ICorProfilerFunctionControl,
767     // and have thus stored the IL and codegen flags the profiler specified. Can only
768     // transition to kStateReverted from this state.
769     kStateActive = 0x00000001,
770
771     // The methoddef has been reverted, but not freed yet. It (or its instantiations
772     // for generics) *MAY* still be active on the stack someplace or have outstanding
773     // memory references.
774     kStateReverted = 0x00000002,
775
776
777     kStateMask = 0x0000000F,
778 };
779
780 struct MSLAYOUT DacSharedReJitInfo
781 {
782     DWORD          m_state;
783     CORDB_ADDRESS  m_pbIL;
784     DWORD          m_dwCodegenFlags;
785     ULONG          m_cInstrumentedMapEntries;
786     CORDB_ADDRESS  m_rgInstrumentedMapEntries;
787 };
788
789 #include "dacdbistructures.inl"
790 #endif // DACDBISTRUCTURES_H_