1 | // |
2 | // Copyright (c) Microsoft. All rights reserved. |
3 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. |
4 | // |
5 | |
6 | //---------------------------------------------------------- |
7 | // SpmiDumpHelper.cpp - a helper to dump structs that are used in JitEEInterface calls and spmi collections. |
8 | //---------------------------------------------------------- |
9 | |
10 | #include "standardpch.h" |
11 | #include "spmidumphelper.h" |
12 | #include "spmirecordhelper.h" |
13 | #include <assert.h> |
14 | |
15 | std::string SpmiDumpHelper::DumpAgnostic_CORINFO_RESOLVED_TOKENin( |
16 | const MethodContext::Agnostic_CORINFO_RESOLVED_TOKENin& tokenIn) |
17 | { |
18 | char buffer[MAX_BUFFER_SIZE]; |
19 | sprintf_s(buffer, MAX_BUFFER_SIZE, "tc-%016llX ts-%016llX tok-%08X tt-%u" , tokenIn.tokenContext, tokenIn.tokenScope, |
20 | tokenIn.token, tokenIn.tokenType); |
21 | return std::string(buffer); |
22 | } |
23 | |
24 | std::string SpmiDumpHelper::DumpAgnostic_CORINFO_RESOLVED_TOKENout( |
25 | const MethodContext::Agnostic_CORINFO_RESOLVED_TOKENout& tokenOut) |
26 | { |
27 | char buffer[MAX_BUFFER_SIZE]; |
28 | sprintf_s(buffer, MAX_BUFFER_SIZE, "cls-%016llX meth-%016llX fld-%016llX ti-%u ts-%u mi-%u ms-%u" , tokenOut.hClass, |
29 | tokenOut.hMethod, tokenOut.hField, tokenOut.pTypeSpec_Index, tokenOut.cbTypeSpec, |
30 | tokenOut.pMethodSpec_Index, tokenOut.cbMethodSpec); |
31 | return std::string(buffer); |
32 | } |
33 | |
34 | std::string SpmiDumpHelper::DumpAgnostic_CORINFO_RESOLVED_TOKEN( |
35 | const MethodContext::Agnostic_CORINFO_RESOLVED_TOKEN& token) |
36 | { |
37 | return DumpAgnostic_CORINFO_RESOLVED_TOKENin(token.inValue) + std::string(" " ) + |
38 | DumpAgnostic_CORINFO_RESOLVED_TOKENout(token.outValue); |
39 | } |
40 | |
41 | std::string SpmiDumpHelper::DumpAgnostic_CORINFO_LOOKUP_KIND( |
42 | const MethodContext::Agnostic_CORINFO_LOOKUP_KIND& lookupKind) |
43 | { |
44 | char buffer[MAX_BUFFER_SIZE]; |
45 | sprintf_s(buffer, MAX_BUFFER_SIZE, "nrl-%u rlk-%u" , lookupKind.needsRuntimeLookup, lookupKind.runtimeLookupKind); |
46 | return std::string(buffer); |
47 | } |
48 | |
49 | std::string SpmiDumpHelper::DumpAgnostic_CORINFO_CONST_LOOKUP( |
50 | const MethodContext::Agnostic_CORINFO_CONST_LOOKUP& constLookup) |
51 | { |
52 | char buffer[MAX_BUFFER_SIZE]; |
53 | sprintf_s(buffer, MAX_BUFFER_SIZE, "at - %u handle/address-%016llX" , constLookup.accessType, constLookup.handle); |
54 | return std::string(buffer); |
55 | } |
56 | |
57 | std::string SpmiDumpHelper::DumpAgnostic_CORINFO_RUNTIME_LOOKUP( |
58 | const MethodContext::Agnostic_CORINFO_RUNTIME_LOOKUP& lookup) |
59 | { |
60 | char buffer[MAX_BUFFER_SIZE]; |
61 | sprintf_s(buffer, MAX_BUFFER_SIZE, " sig-%016llX hlp-%u ind-%u tfn-%u tff-%u { " , lookup.signature, lookup.helper, |
62 | lookup.indirections, lookup.testForNull, lookup.testForFixup); |
63 | std::string resultDump(buffer); |
64 | for (int i = 0; i < CORINFO_MAXINDIRECTIONS; i++) |
65 | { |
66 | sprintf_s(buffer, MAX_BUFFER_SIZE, "%016llX " , lookup.offsets[i]); |
67 | resultDump += std::string(buffer); |
68 | } |
69 | resultDump += std::string("}" ); |
70 | return resultDump; |
71 | } |
72 | |
73 | std::string SpmiDumpHelper::DumpAgnostic_CORINFO_LOOKUP(const MethodContext::Agnostic_CORINFO_LOOKUP& lookup) |
74 | { |
75 | std::string kind = DumpAgnostic_CORINFO_LOOKUP_KIND(lookup.lookupKind); |
76 | std::string lookupDescription; |
77 | if (lookup.lookupKind.needsRuntimeLookup) |
78 | { |
79 | lookupDescription = DumpAgnostic_CORINFO_RUNTIME_LOOKUP(lookup.runtimeLookup); |
80 | } |
81 | else |
82 | { |
83 | lookupDescription = DumpAgnostic_CORINFO_CONST_LOOKUP(lookup.constLookup); |
84 | } |
85 | return kind + std::string(" " ) + lookupDescription; |
86 | } |
87 | |
88 | std::string SpmiDumpHelper::DumpAgnostic_CORINFO_SIG_INFO(const MethodContext::Agnostic_CORINFO_SIG_INFO& sigInfo) |
89 | { |
90 | char buffer[MAX_BUFFER_SIZE]; |
91 | sprintf_s(buffer, MAX_BUFFER_SIZE, "{flg-%08X na-%u cc-%u ci-%u mc-%u mi-%u args-%016llX scp-%016llX tok-%08X}" , |
92 | sigInfo.flags, sigInfo.numArgs, sigInfo.sigInst_classInstCount, sigInfo.sigInst_classInst_Index, |
93 | sigInfo.sigInst_methInstCount, sigInfo.sigInst_methInst_Index, sigInfo.args, sigInfo.scope, |
94 | sigInfo.token); |
95 | return std::string(buffer); |
96 | } |
97 | |