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 * GCDump.h
7 *
8 * Defines functions to display the GCInfo as defined by the GC-encoding
9 * spec. The GC information may be either dynamically created by a
10 * Just-In-Time compiler conforming to the standard code-manager spec,
11 * or may be persisted by a managed native code compiler conforming
12 * to the standard code-manager spec.
13 */
14
15/*****************************************************************************/
16#ifndef __GCDUMP_H__
17#define __GCDUMP_H__
18/*****************************************************************************/
19
20#include "gcinfotypes.h" // For InfoHdr
21
22#ifndef FASTCALL
23#ifndef FEATURE_PAL
24#define FASTCALL __fastcall
25#else
26#define FASTCALL
27#endif
28#endif
29
30
31class GCDump
32{
33public:
34
35 GCDump (UINT32 gcInfoVersion,
36 bool encBytes = true,
37 unsigned maxEncBytes = 5,
38 bool dumpCodeOffs = true);
39
40#ifdef _TARGET_X86_
41 /*-------------------------------------------------------------------------
42 * Dumps the InfoHdr to 'stdout'
43 * table : Start of the GC info block
44 * verifyGCTables : If the JIT has been compiled with VERIFY_GC_TABLES
45 * Return value : Size in bytes of the header encoding
46 */
47
48 unsigned FASTCALL DumpInfoHdr (PTR_CBYTE gcInfoBlock,
49 InfoHdr * header, /* OUT */
50 unsigned * methodSize, /* OUT */
51 bool verifyGCTables = false);
52#endif
53
54 /*-------------------------------------------------------------------------
55 * Dumps the GC tables to 'stdout'
56 * gcInfoBlock : Start of the GC info block
57 * verifyGCTables : If the JIT has been compiled with VERIFY_GC_TABLES
58 * Return value : Size in bytes of the GC table encodings
59 */
60
61 size_t FASTCALL DumpGCTable (PTR_CBYTE gcInfoBlock,
62#ifdef _TARGET_X86_
63 const InfoHdr& header,
64#endif
65 unsigned methodSize,
66 bool verifyGCTables = false);
67
68 /*-------------------------------------------------------------------------
69 * Dumps the location of ptrs for the given code offset
70 * verifyGCTables : If the JIT has been compiled with VERIFY_GC_TABLES
71 */
72
73 void FASTCALL DumpPtrsInFrame(PTR_CBYTE gcInfoBlock,
74 PTR_CBYTE codeBlock,
75 unsigned offs,
76 bool verifyGCTables = false);
77
78
79public:
80 typedef void (*printfFtn)(const char* fmt, ...);
81 printfFtn gcPrintf;
82 UINT32 gcInfoVersion;
83 //-------------------------------------------------------------------------
84protected:
85
86 bool fDumpEncBytes;
87 unsigned cMaxEncBytes;
88
89 bool fDumpCodeOffsets;
90
91 /* Helper methods */
92
93 PTR_CBYTE DumpEncoding(PTR_CBYTE gcInfoBlock,
94 int cDumpBytes);
95 void DumpOffset (unsigned o);
96 void DumpOffsetEx(unsigned o);
97
98};
99
100/*****************************************************************************/
101#endif // __GC_DUMP_H__
102/*****************************************************************************/
103