Merge pull request #12422 from CarolEidt/lvaSetClassDiffable
[platform/upstream/coreclr.git] / src / gcdump / gcdump.cpp
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  *                                  GCDump.cpp
6  *
7  * Defines functions to display the GCInfo as defined by the GC-encoding 
8  * spec. The GC information may be either dynamically created by a 
9  * Just-In-Time compiler conforming to the standard code-manager spec,
10  * or may be persisted by a managed native code compiler conforming
11  * to the standard code-manager spec.
12  */
13
14 #ifndef FEATURE_PAL
15 #include "utilcode.h"           // For _ASSERTE()
16 #endif //!FEATURE_PAL
17 #include "gcdump.h"
18
19 /*****************************************************************************/
20
21
22
23 GCDump::GCDump(UINT32 gcInfoVer, bool encBytes, unsigned maxEncBytes, bool dumpCodeOffs)
24   : gcInfoVersion   (gcInfoVer),
25     fDumpEncBytes   (encBytes    ), 
26     cMaxEncBytes    (maxEncBytes ), 
27     fDumpCodeOffsets(dumpCodeOffs)
28 {
29     // By default, use the standard printf function to dump 
30     GCDump::gcPrintf = (printfFtn) ::printf;
31 }
32
33 /*****************************************************************************
34  *
35  *  Display the byte encodings for the given range of the GC tables.
36  */
37
38 PTR_CBYTE GCDump::DumpEncoding(PTR_CBYTE gcInfoBlock, int cDumpBytes)
39 {
40     _ASSERTE((cDumpBytes >= 0) && (cMaxEncBytes < 256));
41
42     if  (fDumpEncBytes)
43     {
44         PTR_CBYTE       pCurPos;
45         unsigned        count;
46         int             cBytesLeft;
47
48         for (count = cMaxEncBytes, cBytesLeft = cDumpBytes, pCurPos = gcInfoBlock;
49              count > 0; 
50              count--, pCurPos++, cBytesLeft--)
51         {
52             if  (cBytesLeft > 0)
53             {
54                 if  (cBytesLeft > 1 && count == 1)
55                     gcPrintf("...");
56                 else
57                     gcPrintf("%02X ", *pCurPos);
58             }
59             else
60                 gcPrintf("   ");
61         }
62
63         gcPrintf("| ");
64     }
65
66     return  gcInfoBlock + cDumpBytes;
67 }
68
69 /*****************************************************************************/
70
71 void                GCDump::DumpOffset(unsigned o)
72 {
73     gcPrintf("%04X", o);
74 }
75
76 void                GCDump::DumpOffsetEx(unsigned o)
77 {
78     if (fDumpCodeOffsets) 
79         DumpOffset(o);
80 }
81
82 /*****************************************************************************/