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
|
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
//----------------------------------------------------------
// nearDiffer.h - differ that handles code that is very similar
//----------------------------------------------------------
#ifndef _nearDiffer
#define _nearDiffer
#include "methodcontext.h"
#include "compileresult.h"
class NearDiffer
{
public:
NearDiffer(const char *targetArch, bool useCorDisTools)
: TargetArchitecture(targetArch)
, UseCoreDisTools(useCorDisTools)
#ifdef USE_COREDISTOOLS
, corAsmDiff(nullptr)
#endif // USE_COREDISTOOLS
{
}
~NearDiffer();
void InitAsmDiff();
bool compare(MethodContext *mc, CompileResult *cr1,CompileResult *cr2);
const char* TargetArchitecture;
const bool UseCoreDisTools;
private:
void DumpCodeBlock(unsigned char *block, ULONG blocksize, void *originalAddr);
bool compareCodeSection(
MethodContext *mc,
CompileResult *cr1,
CompileResult *cr2,
unsigned char *block1,
ULONG blocksize1,
unsigned char *datablock1,
ULONG datablockSize1,
void *originalBlock1,
void *originalDataBlock1,
void *otherCodeBlock1,
ULONG otherCodeBlockSize1,
unsigned char *block2,
ULONG blocksize2,
unsigned char *datablock2,
ULONG datablockSize2,
void *originalBlock2,
void *originalDataBlock2,
void *otherCodeBlock2,
ULONG otherCodeBlockSize2);
bool compareReadOnlyDataBlock(MethodContext *mc, CompileResult *cr1, CompileResult *cr2,
unsigned char *block1, ULONG blocksize1, void *originalDataBlock1,
unsigned char *block2, ULONG blocksize2, void *originalDataBlock2);
bool compareEHInfo(MethodContext *mc, CompileResult *cr1, CompileResult *cr2);
bool compareGCInfo(MethodContext *mc, CompileResult *cr1, CompileResult *cr2);
bool compareVars(MethodContext *mc, CompileResult *cr1, CompileResult *cr2);
bool compareBoundaries(MethodContext *mc, CompileResult *cr1, CompileResult *cr2);
static bool compareOffsets(const void *payload,
size_t blockOffset,
size_t instrLen,
uint64_t offset1,
uint64_t offset2);
#ifdef USE_COREDISTOOLS
CorAsmDiff *corAsmDiff;
#endif // USE_COREDISTOOLS
#ifdef USE_MSVCDIS
DIS* GetMsVcDis();
#endif // USE_MSVCDIS
};
#endif // _nearDiffer
|