2 * Copyright (C) 2017 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 * Header file of dex ir verifier.
18 * Compares two dex files at the IR level, allowing differences in layout, but not in data.
21 #ifndef ART_DEXLAYOUT_DEX_VERIFY_H_
22 #define ART_DEXLAYOUT_DEX_VERIFY_H_
27 // Check that the output dex file contains the same data as the original.
28 // Compares the dex IR of both dex files. Allows the dex files to have different layouts.
29 bool VerifyOutputDexFile(dex_ir::Header* orig_header,
30 dex_ir::Header* output_header,
31 std::string* error_msg);
33 template<class T> bool VerifyIds(std::vector<std::unique_ptr<T>>& orig,
34 std::vector<std::unique_ptr<T>>& output,
35 const char* section_name,
36 std::string* error_msg);
37 bool VerifyId(dex_ir::StringId* orig, dex_ir::StringId* output, std::string* error_msg);
38 bool VerifyId(dex_ir::TypeId* orig, dex_ir::TypeId* output, std::string* error_msg);
39 bool VerifyId(dex_ir::ProtoId* orig, dex_ir::ProtoId* output, std::string* error_msg);
40 bool VerifyId(dex_ir::FieldId* orig, dex_ir::FieldId* output, std::string* error_msg);
41 bool VerifyId(dex_ir::MethodId* orig, dex_ir::MethodId* output, std::string* error_msg);
43 bool VerifyClassDefs(std::vector<std::unique_ptr<dex_ir::ClassDef>>& orig,
44 std::vector<std::unique_ptr<dex_ir::ClassDef>>& output,
45 std::string* error_msg);
46 bool VerifyClassDef(dex_ir::ClassDef* orig, dex_ir::ClassDef* output, std::string* error_msg);
48 bool VerifyTypeList(const dex_ir::TypeList* orig, const dex_ir::TypeList* output);
50 bool VerifyAnnotationsDirectory(dex_ir::AnnotationsDirectoryItem* orig,
51 dex_ir::AnnotationsDirectoryItem* output,
52 std::string* error_msg);
53 bool VerifyFieldAnnotations(dex_ir::FieldAnnotationVector* orig,
54 dex_ir::FieldAnnotationVector* output,
56 std::string* error_msg);
57 bool VerifyMethodAnnotations(dex_ir::MethodAnnotationVector* orig,
58 dex_ir::MethodAnnotationVector* output,
60 std::string* error_msg);
61 bool VerifyParameterAnnotations(dex_ir::ParameterAnnotationVector* orig,
62 dex_ir::ParameterAnnotationVector* output,
64 std::string* error_msg);
65 bool VerifyAnnotationSetRefList(dex_ir::AnnotationSetRefList* orig,
66 dex_ir::AnnotationSetRefList* output,
67 std::string* error_msg);
68 bool VerifyAnnotationSet(dex_ir::AnnotationSetItem* orig,
69 dex_ir::AnnotationSetItem* output,
70 std::string* error_msg);
71 bool VerifyAnnotation(dex_ir::AnnotationItem* orig,
72 dex_ir::AnnotationItem* output,
73 std::string* error_msg);
74 bool VerifyEncodedAnnotation(dex_ir::EncodedAnnotation* orig,
75 dex_ir::EncodedAnnotation* output,
77 std::string* error_msg);
78 bool VerifyAnnotationElement(dex_ir::AnnotationElement* orig,
79 dex_ir::AnnotationElement* output,
81 std::string* error_msg);
82 bool VerifyEncodedValue(dex_ir::EncodedValue* orig,
83 dex_ir::EncodedValue* output,
85 std::string* error_msg);
86 bool VerifyEncodedArray(dex_ir::EncodedArrayItem* orig,
87 dex_ir::EncodedArrayItem* output,
88 std::string* error_msg);
90 bool VerifyClassData(dex_ir::ClassData* orig, dex_ir::ClassData* output, std::string* error_msg);
91 bool VerifyFields(dex_ir::FieldItemVector* orig,
92 dex_ir::FieldItemVector* output,
94 std::string* error_msg);
95 bool VerifyMethods(dex_ir::MethodItemVector* orig,
96 dex_ir::MethodItemVector* output,
98 std::string* error_msg);
99 bool VerifyCode(dex_ir::CodeItem* orig, dex_ir::CodeItem* output, std::string* error_msg);
100 bool VerifyDebugInfo(dex_ir::DebugInfoItem* orig,
101 dex_ir::DebugInfoItem* output,
102 std::string* error_msg);
103 bool VerifyPositionInfo(dex_ir::PositionInfoVector& orig,
104 dex_ir::PositionInfoVector& output,
105 uint32_t orig_offset,
106 std::string* error_msg);
107 bool VerifyLocalInfo(dex_ir::LocalInfoVector& orig,
108 dex_ir::LocalInfoVector& output,
109 uint32_t orig_offset,
110 std::string* error_msg);
111 bool VerifyTries(dex_ir::TryItemVector* orig,
112 dex_ir::TryItemVector* output,
113 uint32_t orig_offset,
114 std::string* error_msg);
115 bool VerifyHandlers(dex_ir::CatchHandlerVector* orig,
116 dex_ir::CatchHandlerVector* output,
117 uint32_t orig_offset,
118 std::string* error_msg);
119 bool VerifyHandler(const dex_ir::CatchHandler* orig,
120 const dex_ir::CatchHandler* output,
121 uint32_t orig_offset,
122 std::string* error_msg);
125 #endif // ART_DEXLAYOUT_DEX_VERIFY_H_