summaryrefslogtreecommitdiff
path: root/src/vm/ilinstrumentation.cpp
blob: a2bdbf1a60835dc4a500ba8c99a4eb7dc82dd00d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ===========================================================================
// File: ILInstrumentation.cpp
//
// ===========================================================================


#include "common.h"
#include "ilinstrumentation.h"


//---------------------------------------------------------------------------------------
InstrumentedILOffsetMapping::InstrumentedILOffsetMapping()
{
    LIMITED_METHOD_DAC_CONTRACT;

    m_cMap = 0;
    m_rgMap = NULL;
    _ASSERTE(IsNull());
}

//---------------------------------------------------------------------------------------
//
// Check whether there is any mapping information stored in this object.
//
// Notes:
//    The memory should be alive throughout the process lifetime until 
//    the Module containing the instrumented method is destructed.
//

BOOL InstrumentedILOffsetMapping::IsNull() const
{
    LIMITED_METHOD_DAC_CONTRACT;

    _ASSERTE((m_cMap == 0) == (m_rgMap == NULL));
    return (m_cMap == 0);
}

#if !defined(DACCESS_COMPILE)
//---------------------------------------------------------------------------------------
//
// Release the memory used by the array of COR_IL_MAPs.
//
// Notes:
//    * The memory should be alive throughout the process lifetime until the Module containing 
//      the instrumented method is destructed.
//    * This struct should be read-only in DAC builds.
//

void InstrumentedILOffsetMapping::Clear()
{
    LIMITED_METHOD_CONTRACT;

    if (m_rgMap != NULL)
    {
        delete[] m_rgMap;
    }

    m_cMap = 0;
    m_rgMap = NULL;
}
#endif // !DACCESS_COMPILE

#if !defined(DACCESS_COMPILE)
void InstrumentedILOffsetMapping::SetMappingInfo(SIZE_T cMap, COR_IL_MAP * rgMap)
{
    WRAPPER_NO_CONTRACT;
    _ASSERTE((cMap == 0) == (rgMap == NULL));
    m_cMap = cMap;
    m_rgMap = ARRAY_PTR_COR_IL_MAP(rgMap);
}
#endif // !DACCESS_COMPILE

SIZE_T InstrumentedILOffsetMapping::GetCount() const
{
    LIMITED_METHOD_DAC_CONTRACT;

    _ASSERTE((m_cMap == 0) == (m_rgMap == NULL));
    return m_cMap;
}

ARRAY_PTR_COR_IL_MAP InstrumentedILOffsetMapping::GetOffsets() const
{
    LIMITED_METHOD_DAC_CONTRACT;

    _ASSERTE((m_cMap == 0) == (m_rgMap == NULL));
    return m_rgMap;
}