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: ILInstrumentation.cpp
6//
7// ===========================================================================
8
9
10#include "common.h"
11#include "ilinstrumentation.h"
12
13
14//---------------------------------------------------------------------------------------
15InstrumentedILOffsetMapping::InstrumentedILOffsetMapping()
16{
17 LIMITED_METHOD_DAC_CONTRACT;
18
19 m_cMap = 0;
20 m_rgMap = NULL;
21 _ASSERTE(IsNull());
22}
23
24//---------------------------------------------------------------------------------------
25//
26// Check whether there is any mapping information stored in this object.
27//
28// Notes:
29// The memory should be alive throughout the process lifetime until
30// the Module containing the instrumented method is destructed.
31//
32
33BOOL InstrumentedILOffsetMapping::IsNull() const
34{
35 LIMITED_METHOD_DAC_CONTRACT;
36
37 _ASSERTE((m_cMap == 0) == (m_rgMap == NULL));
38 return (m_cMap == 0);
39}
40
41#if !defined(DACCESS_COMPILE)
42//---------------------------------------------------------------------------------------
43//
44// Release the memory used by the array of COR_IL_MAPs.
45//
46// Notes:
47// * The memory should be alive throughout the process lifetime until the Module containing
48// the instrumented method is destructed.
49// * This struct should be read-only in DAC builds.
50//
51
52void InstrumentedILOffsetMapping::Clear()
53{
54 LIMITED_METHOD_CONTRACT;
55
56 if (m_rgMap != NULL)
57 {
58 delete[] m_rgMap;
59 }
60
61 m_cMap = 0;
62 m_rgMap = NULL;
63}
64#endif // !DACCESS_COMPILE
65
66#if !defined(DACCESS_COMPILE)
67void InstrumentedILOffsetMapping::SetMappingInfo(SIZE_T cMap, COR_IL_MAP * rgMap)
68{
69 WRAPPER_NO_CONTRACT;
70 _ASSERTE((cMap == 0) == (rgMap == NULL));
71 m_cMap = cMap;
72 m_rgMap = ARRAY_PTR_COR_IL_MAP(rgMap);
73}
74#endif // !DACCESS_COMPILE
75
76SIZE_T InstrumentedILOffsetMapping::GetCount() const
77{
78 LIMITED_METHOD_DAC_CONTRACT;
79
80 _ASSERTE((m_cMap == 0) == (m_rgMap == NULL));
81 return m_cMap;
82}
83
84ARRAY_PTR_COR_IL_MAP InstrumentedILOffsetMapping::GetOffsets() const
85{
86 LIMITED_METHOD_DAC_CONTRACT;
87
88 _ASSERTE((m_cMap == 0) == (m_rgMap == NULL));
89 return m_rgMap;
90}
91