blob: 4943defe16ccc464bb33f746da9bf759756ce150 [file] [log] [blame]
Jeff Haoec7f1a92017-03-13 16:24:24 -07001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 *
16 * Header file of dex ir verifier.
17 *
18 * Compares two dex files at the IR level, allowing differences in layout, but not in data.
19 */
20
21#ifndef ART_DEXLAYOUT_DEX_VERIFY_H_
22#define ART_DEXLAYOUT_DEX_VERIFY_H_
23
24#include "dex_ir.h"
25
26namespace art {
Jeff Haoec7f1a92017-03-13 16:24:24 -070027// 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.
29bool VerifyOutputDexFile(dex_ir::Header* orig_header,
30 dex_ir::Header* output_header,
31 std::string* error_msg);
Jeff Haocc829592017-03-14 16:13:39 -070032
David Sehr2b5a38f2018-06-14 15:13:04 -070033template<class T> bool VerifyIds(dex_ir::CollectionVector<T>& orig,
34 dex_ir::CollectionVector<T>& output,
Jeff Haoec7f1a92017-03-13 16:24:24 -070035 const char* section_name,
36 std::string* error_msg);
37bool VerifyId(dex_ir::StringId* orig, dex_ir::StringId* output, std::string* error_msg);
38bool VerifyId(dex_ir::TypeId* orig, dex_ir::TypeId* output, std::string* error_msg);
39bool VerifyId(dex_ir::ProtoId* orig, dex_ir::ProtoId* output, std::string* error_msg);
40bool VerifyId(dex_ir::FieldId* orig, dex_ir::FieldId* output, std::string* error_msg);
41bool VerifyId(dex_ir::MethodId* orig, dex_ir::MethodId* output, std::string* error_msg);
Jeff Haocc829592017-03-14 16:13:39 -070042
David Sehr2b5a38f2018-06-14 15:13:04 -070043bool VerifyClassDefs(dex_ir::CollectionVector<dex_ir::ClassDef>& orig,
44 dex_ir::CollectionVector<dex_ir::ClassDef>& output,
Jeff Haocc829592017-03-14 16:13:39 -070045 std::string* error_msg);
46bool VerifyClassDef(dex_ir::ClassDef* orig, dex_ir::ClassDef* output, std::string* error_msg);
47
Jeff Haoec7f1a92017-03-13 16:24:24 -070048bool VerifyTypeList(const dex_ir::TypeList* orig, const dex_ir::TypeList* output);
49
Jeff Haocc829592017-03-14 16:13:39 -070050bool VerifyAnnotationsDirectory(dex_ir::AnnotationsDirectoryItem* orig,
51 dex_ir::AnnotationsDirectoryItem* output,
52 std::string* error_msg);
53bool VerifyFieldAnnotations(dex_ir::FieldAnnotationVector* orig,
54 dex_ir::FieldAnnotationVector* output,
55 uint32_t orig_offset,
56 std::string* error_msg);
57bool VerifyMethodAnnotations(dex_ir::MethodAnnotationVector* orig,
58 dex_ir::MethodAnnotationVector* output,
59 uint32_t orig_offset,
60 std::string* error_msg);
61bool VerifyParameterAnnotations(dex_ir::ParameterAnnotationVector* orig,
62 dex_ir::ParameterAnnotationVector* output,
63 uint32_t orig_offset,
64 std::string* error_msg);
65bool VerifyAnnotationSetRefList(dex_ir::AnnotationSetRefList* orig,
66 dex_ir::AnnotationSetRefList* output,
67 std::string* error_msg);
68bool VerifyAnnotationSet(dex_ir::AnnotationSetItem* orig,
69 dex_ir::AnnotationSetItem* output,
70 std::string* error_msg);
71bool VerifyAnnotation(dex_ir::AnnotationItem* orig,
72 dex_ir::AnnotationItem* output,
73 std::string* error_msg);
74bool VerifyEncodedAnnotation(dex_ir::EncodedAnnotation* orig,
75 dex_ir::EncodedAnnotation* output,
76 uint32_t orig_offset,
77 std::string* error_msg);
78bool VerifyAnnotationElement(dex_ir::AnnotationElement* orig,
79 dex_ir::AnnotationElement* output,
80 uint32_t orig_offset,
81 std::string* error_msg);
82bool VerifyEncodedValue(dex_ir::EncodedValue* orig,
83 dex_ir::EncodedValue* output,
84 uint32_t orig_offset,
85 std::string* error_msg);
86bool VerifyEncodedArray(dex_ir::EncodedArrayItem* orig,
87 dex_ir::EncodedArrayItem* output,
88 std::string* error_msg);
89
90bool VerifyClassData(dex_ir::ClassData* orig, dex_ir::ClassData* output, std::string* error_msg);
91bool VerifyFields(dex_ir::FieldItemVector* orig,
92 dex_ir::FieldItemVector* output,
93 uint32_t orig_offset,
94 std::string* error_msg);
95bool VerifyMethods(dex_ir::MethodItemVector* orig,
96 dex_ir::MethodItemVector* output,
97 uint32_t orig_offset,
98 std::string* error_msg);
99bool VerifyCode(dex_ir::CodeItem* orig, dex_ir::CodeItem* output, std::string* error_msg);
100bool VerifyDebugInfo(dex_ir::DebugInfoItem* orig,
101 dex_ir::DebugInfoItem* output,
102 std::string* error_msg);
Jeff Haocc829592017-03-14 16:13:39 -0700103bool VerifyTries(dex_ir::TryItemVector* orig,
104 dex_ir::TryItemVector* output,
105 uint32_t orig_offset,
106 std::string* error_msg);
107bool VerifyHandlers(dex_ir::CatchHandlerVector* orig,
108 dex_ir::CatchHandlerVector* output,
109 uint32_t orig_offset,
110 std::string* error_msg);
111bool VerifyHandler(const dex_ir::CatchHandler* orig,
112 const dex_ir::CatchHandler* output,
113 uint32_t orig_offset,
114 std::string* error_msg);
Jeff Haoec7f1a92017-03-13 16:24:24 -0700115} // namespace art
116
117#endif // ART_DEXLAYOUT_DEX_VERIFY_H_