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#ifndef __GCINFODUMPER_H__
6#define __GCINFODUMPER_H__
7
8#include "gcinfotypes.h"
9#include "gcinfodecoder.h"
10
11
12//
13// This class dumps the contents of the gc encodings, providing outputs
14// similar to the inputs to GcInfoEncoder. This uses the same GcInfoDecoder
15// functions that the EE uses (vs. decoding the bits directly).
16//
17class GcInfoDumper
18{
19public:
20
21 GcInfoDumper (GCInfoToken gcInfoToken);
22 ~GcInfoDumper ();
23
24 // Returns TRUE to stop decoding.
25 typedef BOOL InterruptibleStateChangeProc (
26 UINT32 CodeOffset,
27 BOOL fInterruptible,
28 PVOID pvData);
29
30 // Returns TRUE to stop decoding.
31 typedef BOOL OnSafePointProc (
32 UINT32 CodeOffset,
33 PVOID pvData);
34
35 // Returns TRUE to stop decoding.
36 typedef BOOL RegisterStateChangeProc (
37 UINT32 CodeOffset,
38 UINT32 RegisterNumber,
39 GcSlotFlags Flags,
40 GcSlotState NewState,
41 PVOID pvData);
42
43 // Returns TRUE to stop decoding.
44 typedef BOOL StackSlotStateChangeProc (
45 UINT32 CodeOffset,
46 GcSlotFlags flags,
47 GcStackSlotBase BaseRegister,
48 SSIZE_T StackOffset,
49 GcSlotState NewState,
50 PVOID pvData);
51
52 enum EnumerateStateChangesResults
53 {
54 SUCCESS = 0,
55 OUT_OF_MEMORY,
56 REPORTED_REGISTER_IN_CALLERS_FRAME,
57 REPORTED_FRAME_POINTER,
58 REPORTED_INVALID_BASE_REGISTER,
59 REPORTED_INVALID_POINTER,
60 DECODER_FAILED,
61 };
62
63 // Returns TRUE if successful. FALSE if out of memory, invalid data, etc.
64 EnumerateStateChangesResults EnumerateStateChanges (
65 InterruptibleStateChangeProc *pfnInterruptibleStateChange,
66 RegisterStateChangeProc *pfnRegisterStateChange,
67 StackSlotStateChangeProc *pfnStackSlotStateChange,
68 OnSafePointProc *pfnSafePointFunc,
69 PVOID pvData);
70
71 size_t GetGCInfoSize();
72
73private:
74
75 struct LivePointerRecord
76 {
77 OBJECTREF *ppObject;
78 DWORD flags;
79 LivePointerRecord *pNext;
80 UINT marked;
81 };
82
83 GCInfoToken m_gcTable;
84 UINT32 m_StackBaseRegister;
85 UINT32 m_SizeOfEditAndContinuePreservedArea;
86 LivePointerRecord *m_pRecords;
87 RegisterStateChangeProc *m_pfnRegisterStateChange;
88 StackSlotStateChangeProc *m_pfnStackSlotStateChange;
89 PVOID m_pvCallbackData;
90 EnumerateStateChangesResults m_Error;
91 size_t m_gcInfoSize;
92
93 static void LivePointerCallback (
94 LPVOID hCallback, // callback data
95 OBJECTREF* pObject, // address of obect-reference we are reporting
96 uint32_t flags // is this a pinned and/or interior pointer
97 DAC_ARG(DacSlotLocation loc)); // the location the pointer came from
98
99 static void FreePointerRecords (LivePointerRecord *pRecords);
100
101 // Return TRUE if callback requested to stop decoding.
102 BOOL ReportPointerRecord (
103 UINT32 CodeOffset,
104 BOOL fLive,
105 REGDISPLAY *pRD,
106 LivePointerRecord *pRecord);
107
108 // Return TRUE if callback requested to stop decoding.
109 BOOL ReportPointerDifferences (
110 UINT32 offset,
111 REGDISPLAY *pRD,
112 LivePointerRecord *pPrevState);
113};
114
115
116#endif // !__GCINFODUMPER_H__
117
118