blob: d48067baa95b23b790e84dfb77906a57e929a171 [file] [log] [blame]
Carl Shapiro1fb86202011-06-27 17:43:13 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2
3#ifndef ART_SRC_DEX_FILE_H_
4#define ART_SRC_DEX_FILE_H_
5
Brian Carlstrom7e49dca2011-07-22 18:07:34 -07006#include <map>
Elliott Hughes0c424cb2011-08-26 10:16:25 -07007#include <string>
Brian Carlstrom74eb46a2011-08-02 20:10:14 -07008#include <vector>
Brian Carlstrom7e49dca2011-07-22 18:07:34 -07009
Elliott Hughes90a33692011-08-30 13:27:07 -070010#include "UniquePtr.h"
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070011#include "globals.h"
Jesse Wilson6bf19152011-09-29 13:12:33 -040012#include "jni.h"
Brian Carlstrom7e49dca2011-07-22 18:07:34 -070013#include "logging.h"
Brian Carlstrom33f741e2011-10-03 11:24:05 -070014#include "mem_map.h"
Jesse Wilson6bf19152011-09-29 13:12:33 -040015#include "mutex.h"
Brian Carlstrom7e49dca2011-07-22 18:07:34 -070016#include "stringpiece.h"
Shih-wei Liao2fb97532011-08-11 16:17:23 -070017#include "utils.h"
Carl Shapiro1fb86202011-06-27 17:43:13 -070018
19namespace art {
20
Brian Carlstrom7e49dca2011-07-22 18:07:34 -070021// TODO: move all of the macro functionality into the DexCache class.
Brian Carlstromf615a612011-07-23 12:50:34 -070022class DexFile {
Carl Shapiro1fb86202011-06-27 17:43:13 -070023 public:
Brian Carlstrom7e49dca2011-07-22 18:07:34 -070024 static const byte kDexMagic[];
25 static const byte kDexMagicVersion[];
26 static const size_t kSha1DigestSize = 20;
Carl Shapiro80d4dde2011-06-28 16:24:07 -070027
Brian Carlstromb7bbba42011-10-13 14:58:47 -070028 // name of the DexFile entry within a zip archive
29 static const char* kClassesDex;
30
Brian Carlstrom7e49dca2011-07-22 18:07:34 -070031 // The value of an invalid index.
32 static const uint32_t kDexNoIndex = 0xFFFFFFFF;
33
Ian Rogers0571d352011-11-03 19:51:38 -070034 // The value of an invalid index.
35 static const uint16_t kDexNoIndex16 = 0xFFFF;
Carl Shapiro1fb86202011-06-27 17:43:13 -070036
Brian Carlstrom7e49dca2011-07-22 18:07:34 -070037 // Raw header_item.
38 struct Header {
39 uint8_t magic_[8];
40 uint32_t checksum_;
41 uint8_t signature_[kSha1DigestSize];
42 uint32_t file_size_; // length of entire file
43 uint32_t header_size_; // offset to start of next section
44 uint32_t endian_tag_;
Ian Rogers0571d352011-11-03 19:51:38 -070045 uint32_t link_size_; // unused
46 uint32_t link_off_; // unused
47 uint32_t map_off_; // unused
48 uint32_t string_ids_size_; // number of StringIds
49 uint32_t string_ids_off_; // file offset of StringIds array
50 uint32_t type_ids_size_; // number of TypeIds, we don't support more than 65535
51 uint32_t type_ids_off_; // file offset of TypeIds array
52 uint32_t proto_ids_size_; // number of ProtoIds, we don't support more than 65535
53 uint32_t proto_ids_off_; // file offset of ProtoIds array
54 uint32_t field_ids_size_; // number of FieldIds
55 uint32_t field_ids_off_; // file offset of FieldIds array
56 uint32_t method_ids_size_; // number of MethodIds
57 uint32_t method_ids_off_; // file offset of MethodIds array
58 uint32_t class_defs_size_; // number of ClassDefs
59 uint32_t class_defs_off_; // file offset of ClassDef array
60 uint32_t data_size_; // unused
61 uint32_t data_off_; // unused
Brian Carlstromd2fbb2b2011-08-23 11:57:08 -070062 private:
63 DISALLOW_COPY_AND_ASSIGN(Header);
Brian Carlstrom7e49dca2011-07-22 18:07:34 -070064 };
Carl Shapiro1fb86202011-06-27 17:43:13 -070065
Brian Carlstrom7e49dca2011-07-22 18:07:34 -070066 // Raw string_id_item.
67 struct StringId {
68 uint32_t string_data_off_; // offset in bytes from the base address
Brian Carlstromd2fbb2b2011-08-23 11:57:08 -070069 private:
70 DISALLOW_COPY_AND_ASSIGN(StringId);
Brian Carlstrom7e49dca2011-07-22 18:07:34 -070071 };
72
73 // Raw type_id_item.
74 struct TypeId {
75 uint32_t descriptor_idx_; // index into string_ids
Brian Carlstromd2fbb2b2011-08-23 11:57:08 -070076 private:
77 DISALLOW_COPY_AND_ASSIGN(TypeId);
Brian Carlstrom7e49dca2011-07-22 18:07:34 -070078 };
79
80 // Raw field_id_item.
81 struct FieldId {
Ian Rogers0571d352011-11-03 19:51:38 -070082 uint16_t class_idx_; // index into type_ids_ array for defining class
83 uint16_t type_idx_; // index into type_ids_ array for field type
84 uint32_t name_idx_; // index into string_ids_ array for field name
Brian Carlstromd2fbb2b2011-08-23 11:57:08 -070085 private:
86 DISALLOW_COPY_AND_ASSIGN(FieldId);
Brian Carlstrom7e49dca2011-07-22 18:07:34 -070087 };
88
89 // Raw method_id_item.
90 struct MethodId {
Ian Rogers0571d352011-11-03 19:51:38 -070091 uint16_t class_idx_; // index into type_ids_ array for defining class
92 uint16_t proto_idx_; // index into proto_ids_ array for method prototype
93 uint32_t name_idx_; // index into string_ids_ array for method name
Brian Carlstromd2fbb2b2011-08-23 11:57:08 -070094 private:
95 DISALLOW_COPY_AND_ASSIGN(MethodId);
Brian Carlstrom7e49dca2011-07-22 18:07:34 -070096 };
97
98 // Raw proto_id_item.
99 struct ProtoId {
Ian Rogers0571d352011-11-03 19:51:38 -0700100 uint32_t shorty_idx_; // index into string_ids array for shorty descriptor
101 uint16_t return_type_idx_; // index into type_ids array for return type
102 uint16_t pad_; // padding = 0
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700103 uint32_t parameters_off_; // file offset to type_list for parameter types
Brian Carlstromd2fbb2b2011-08-23 11:57:08 -0700104 private:
105 DISALLOW_COPY_AND_ASSIGN(ProtoId);
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700106 };
107
108 // Raw class_def_item.
109 struct ClassDef {
Ian Rogers0571d352011-11-03 19:51:38 -0700110 uint16_t class_idx_; // index into type_ids_ array for this class
111 uint16_t pad1_; // padding = 0
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700112 uint32_t access_flags_;
Ian Rogers0571d352011-11-03 19:51:38 -0700113 uint16_t superclass_idx_; // index into type_ids_ array for superclass
114 uint16_t pad2_; // padding = 0
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700115 uint32_t interfaces_off_; // file offset to TypeList
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700116 uint32_t source_file_idx_; // index into string_ids_ for source file name
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700117 uint32_t annotations_off_; // file offset to annotations_directory_item
118 uint32_t class_data_off_; // file offset to class_data_item
119 uint32_t static_values_off_; // file offset to EncodedArray
Brian Carlstromd2fbb2b2011-08-23 11:57:08 -0700120 private:
121 DISALLOW_COPY_AND_ASSIGN(ClassDef);
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700122 };
123
124 // Raw type_item.
125 struct TypeItem {
126 uint16_t type_idx_; // index into type_ids section
Brian Carlstromd2fbb2b2011-08-23 11:57:08 -0700127 private:
128 DISALLOW_COPY_AND_ASSIGN(TypeItem);
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700129 };
130
131 // Raw type_list.
132 class TypeList {
133 public:
134 uint32_t Size() const {
135 return size_;
136 }
137
138 const TypeItem& GetTypeItem(uint32_t idx) const {
139 CHECK_LT(idx, this->size_);
140 return this->list_[idx];
141 }
142
143 private:
144 uint32_t size_; // size of the list, in entries
145 TypeItem list_[1]; // elements of the list
Brian Carlstromd2fbb2b2011-08-23 11:57:08 -0700146 DISALLOW_COPY_AND_ASSIGN(TypeList);
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700147 };
148
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700149 // Raw code_item.
150 struct CodeItem {
151 uint16_t registers_size_;
152 uint16_t ins_size_;
153 uint16_t outs_size_;
154 uint16_t tries_size_;
155 uint32_t debug_info_off_; // file offset to debug info stream
Ian Rogersd81871c2011-10-03 13:57:23 -0700156 uint32_t insns_size_in_code_units_; // size of the insns array, in 2 byte code units
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700157 uint16_t insns_[1];
Brian Carlstromd2fbb2b2011-08-23 11:57:08 -0700158 private:
159 DISALLOW_COPY_AND_ASSIGN(CodeItem);
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700160 };
161
Carl Shapiro2eaa9682011-08-04 19:26:11 -0700162 // Raw try_item.
163 struct TryItem {
164 uint32_t start_addr_;
165 uint16_t insn_count_;
166 uint16_t handler_off_;
Brian Carlstromd2fbb2b2011-08-23 11:57:08 -0700167 private:
168 DISALLOW_COPY_AND_ASSIGN(TryItem);
Carl Shapiro2eaa9682011-08-04 19:26:11 -0700169 };
170
Brian Carlstrom74eb46a2011-08-02 20:10:14 -0700171 typedef std::pair<const DexFile*, const DexFile::ClassDef*> ClassPathEntry;
172 typedef std::vector<const DexFile*> ClassPath;
173
174 // Search a collection of DexFiles for a descriptor
175 static ClassPathEntry FindInClassPath(const StringPiece& descriptor,
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -0700176 const ClassPath& class_path);
Brian Carlstrom74eb46a2011-08-02 20:10:14 -0700177
Brian Carlstrom78128a62011-09-15 17:21:19 -0700178 // Opens a collection of .dex files
179 static void OpenDexFiles(std::vector<const char*>& dex_filenames,
180 std::vector<const DexFile*>& dex_files,
181 const std::string& strip_location_prefix);
182
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700183 // Opens .dex file, guessing the container format based on file extension
Brian Carlstrom16192862011-09-12 17:50:06 -0700184 static const DexFile* Open(const std::string& filename,
185 const std::string& strip_location_prefix);
jeffhao262bf462011-10-20 18:36:32 -0700186
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700187 // Closes a .dex file.
Brian Carlstromf615a612011-07-23 12:50:34 -0700188 virtual ~DexFile();
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700189
Brian Carlstroma663ea52011-08-19 23:33:41 -0700190 const std::string& GetLocation() const {
191 return location_;
192 }
193
Jesse Wilson6bf19152011-09-29 13:12:33 -0400194 // Returns a com.android.dex.Dex object corresponding to the mapped-in dex file.
195 // Used by managed code to implement annotations.
196 jobject GetDexObject(JNIEnv* env) const;
197
Brian Carlstroma663ea52011-08-19 23:33:41 -0700198 const Header& GetHeader() const {
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700199 CHECK(header_ != NULL);
200 return *header_;
Carl Shapiro1fb86202011-06-27 17:43:13 -0700201 }
202
Ian Rogers0571d352011-11-03 19:51:38 -0700203 // Decode the dex magic version
Ian Rogersd81871c2011-10-03 13:57:23 -0700204 uint32_t GetVersion() const;
205
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700206 // Returns the number of string identifiers in the .dex file.
207 size_t NumStringIds() const {
208 CHECK(header_ != NULL);
209 return header_->string_ids_size_;
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700210 }
211
Ian Rogers0571d352011-11-03 19:51:38 -0700212 // Returns the StringId at the specified index.
213 const StringId& GetStringId(uint32_t idx) const {
214 CHECK_LT(idx, NumStringIds());
215 return string_ids_[idx];
216 }
217
218 uint32_t GetIndexForStringId(const StringId& string_id) const {
219 CHECK_GE(&string_id, string_ids_);
220 CHECK_LT(&string_id, string_ids_ + header_->string_ids_size_);
221 return &string_id - string_ids_;
222 }
223
224 int32_t GetStringLength(const StringId& string_id) const;
225
226 // Returns a pointer to the UTF-8 string data referred to by the given string_id.
227 const char* GetStringDataAndLength(const StringId& string_id, int32_t* length) const;
228
229 const char* GetStringData(const StringId& string_id) const {
230 int32_t length;
231 return GetStringDataAndLength(string_id, &length);
232 }
233
234 // return the UTF-8 encoded string with the specified string_id index
235 const char* StringDataAndLengthByIdx(uint32_t idx, int32_t* unicode_length) const {
236 if (idx == kDexNoIndex) {
237 *unicode_length = 0;
238 return NULL;
239 }
240 const StringId& string_id = GetStringId(idx);
241 return GetStringDataAndLength(string_id, unicode_length);
242 }
243
244 const char* StringDataByIdx(uint32_t idx) const {
245 int32_t unicode_length;
246 return StringDataAndLengthByIdx(idx, &unicode_length);
247 }
248
249 // Looks up a string id for a given string
250 const StringId* FindStringId(const std::string& string) const;
251
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700252 // Returns the number of type identifiers in the .dex file.
253 size_t NumTypeIds() const {
254 CHECK(header_ != NULL);
255 return header_->type_ids_size_;
Carl Shapiro5fafe2b2011-07-09 15:34:41 -0700256 }
257
Ian Rogers0571d352011-11-03 19:51:38 -0700258 // Returns the TypeId at the specified index.
259 const TypeId& GetTypeId(uint32_t idx) const {
260 CHECK_LT(idx, NumTypeIds());
261 return type_ids_[idx];
Carl Shapiro5fafe2b2011-07-09 15:34:41 -0700262 }
263
Ian Rogers0571d352011-11-03 19:51:38 -0700264 uint16_t GetIndexForTypeId(const TypeId& type_id) const {
265 CHECK_GE(&type_id, type_ids_);
266 CHECK_LT(&type_id, type_ids_ + header_->type_ids_size_);
267 size_t result = &type_id - type_ids_;
268 DCHECK(result < 65536);
269 return static_cast<uint16_t>(result);
270 }
271
272 // Get the descriptor string associated with a given type index.
273 const char* StringByTypeIdx(uint32_t idx, int32_t* unicode_length) const {
274 const TypeId& type_id = GetTypeId(idx);
275 return StringDataAndLengthByIdx(type_id.descriptor_idx_, unicode_length);
276 }
277
278 const char* StringByTypeIdx(uint32_t idx) const {
279 const TypeId& type_id = GetTypeId(idx);
280 return StringDataByIdx(type_id.descriptor_idx_);
281 }
282
283 // Returns the type descriptor string of a type id.
284 const char* GetTypeDescriptor(const TypeId& type_id) const {
285 return StringDataByIdx(type_id.descriptor_idx_);
286 }
287
288 // Looks up a type for the given string index
289 const TypeId* FindTypeId(uint32_t string_idx) const;
290
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700291 // Returns the number of field identifiers in the .dex file.
292 size_t NumFieldIds() const {
293 CHECK(header_ != NULL);
294 return header_->field_ids_size_;
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700295 }
296
Ian Rogers0571d352011-11-03 19:51:38 -0700297 // Returns the FieldId at the specified index.
298 const FieldId& GetFieldId(uint32_t idx) const {
299 CHECK_LT(idx, NumFieldIds());
300 return field_ids_[idx];
Brian Carlstromd2fbb2b2011-08-23 11:57:08 -0700301 }
302
Ian Rogers9b1a4f42011-11-14 18:35:10 -0800303 uint32_t GetIndexForFieldId(const FieldId& field_id) const {
304 CHECK_GE(&field_id, field_ids_);
305 CHECK_LT(&field_id, field_ids_ + header_->field_ids_size_);
306 return &field_id - field_ids_;
307 }
308
309 // Looks up a field by its declaring class, name and type
310 const FieldId* FindFieldId(const DexFile::TypeId& declaring_klass,
311 const DexFile::StringId& name,
312 const DexFile::TypeId& type) const;
313
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700314 // Returns the declaring class descriptor string of a field id.
315 const char* GetFieldDeclaringClassDescriptor(const FieldId& field_id) const {
Brian Carlstromb9edb842011-08-28 16:31:06 -0700316 const DexFile::TypeId& type_id = GetTypeId(field_id.class_idx_);
317 return GetTypeDescriptor(type_id);
318 }
319
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700320 // Returns the class descriptor string of a field id.
321 const char* GetFieldTypeDescriptor(const FieldId& field_id) const {
322 const DexFile::TypeId& type_id = GetTypeId(field_id.type_idx_);
323 return GetTypeDescriptor(type_id);
324 }
325
Brian Carlstromb9edb842011-08-28 16:31:06 -0700326 // Returns the name of a field id.
327 const char* GetFieldName(const FieldId& field_id) const {
Ian Rogers0571d352011-11-03 19:51:38 -0700328 return StringDataByIdx(field_id.name_idx_);
Brian Carlstromb9edb842011-08-28 16:31:06 -0700329 }
330
Ian Rogers0571d352011-11-03 19:51:38 -0700331 // Returns the number of method identifiers in the .dex file.
332 size_t NumMethodIds() const {
333 CHECK(header_ != NULL);
334 return header_->method_ids_size_;
335 }
336
337 // Returns the MethodId at the specified index.
338 const MethodId& GetMethodId(uint32_t idx) const {
339 CHECK_LT(idx, NumMethodIds());
340 return method_ids_[idx];
341 }
342
343 uint32_t GetIndexForMethodId(const MethodId& method_id) const {
344 CHECK_GE(&method_id, method_ids_);
345 CHECK_LT(&method_id, method_ids_ + header_->method_ids_size_);
346 return &method_id - method_ids_;
347 }
348
Ian Rogers9b1a4f42011-11-14 18:35:10 -0800349 // Looks up a method by its declaring class, name and proto_id
350 const MethodId* FindMethodId(const DexFile::TypeId& declaring_klass,
351 const DexFile::StringId& name,
Ian Rogers0571d352011-11-03 19:51:38 -0700352 const DexFile::ProtoId& signature) const;
353
Brian Carlstrom6b4ef022011-10-23 14:59:04 -0700354 // Returns the declaring class descriptor string of a method id.
355 const char* GetMethodDeclaringClassDescriptor(const MethodId& method_id) const {
Brian Carlstrom7540ff42011-09-04 16:38:46 -0700356 const DexFile::TypeId& type_id = GetTypeId(method_id.class_idx_);
357 return GetTypeDescriptor(type_id);
358 }
359
jeffhao98eacac2011-09-14 16:11:53 -0700360 // Returns the prototype of a method id.
Brian Carlstromaded5f72011-10-07 17:15:04 -0700361 const ProtoId& GetMethodPrototype(const MethodId& method_id) const {
362 return GetProtoId(method_id.proto_idx_);
363 }
364
365 // Returns the signature of a method id.
366 const std::string GetMethodSignature(const MethodId& method_id) const {
Ian Rogers0571d352011-11-03 19:51:38 -0700367 return CreateMethodSignature(method_id.proto_idx_, NULL);
jeffhao98eacac2011-09-14 16:11:53 -0700368 }
369
Brian Carlstrom7540ff42011-09-04 16:38:46 -0700370 // Returns the name of a method id.
371 const char* GetMethodName(const MethodId& method_id) const {
Ian Rogers0571d352011-11-03 19:51:38 -0700372 return StringDataByIdx(method_id.name_idx_);
Brian Carlstrom7540ff42011-09-04 16:38:46 -0700373 }
374
Ian Rogers0571d352011-11-03 19:51:38 -0700375 // Returns the shorty of a method id.
376 const char* GetMethodShorty(const MethodId& method_id) const {
377 return StringDataByIdx(GetProtoId(method_id.proto_idx_).shorty_idx_);
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700378 }
379
Ian Rogers0571d352011-11-03 19:51:38 -0700380 // Returns the number of class definitions in the .dex file.
381 size_t NumClassDefs() const {
382 CHECK(header_ != NULL);
383 return header_->class_defs_size_;
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700384 }
385
386 // Returns the ClassDef at the specified index.
387 const ClassDef& GetClassDef(uint32_t idx) const {
388 CHECK_LT(idx, NumClassDefs());
389 return class_defs_[idx];
390 }
391
Ian Rogers0571d352011-11-03 19:51:38 -0700392 uint32_t GetIndexForClassDef(const ClassDef& class_def) const {
393 CHECK_GE(&class_def, class_defs_);
394 CHECK_LT(&class_def, class_defs_ + header_->class_defs_size_);
395 return &class_def - class_defs_;
396 }
397
398 // Returns the class descriptor string of a class definition.
399 const char* GetClassDescriptor(const ClassDef& class_def) const {
400 return StringByTypeIdx(class_def.class_idx_);
401 }
402
403 // Looks up a class definition by its class descriptor.
404 const ClassDef* FindClassDef(const StringPiece& descriptor) const;
405
406 // Looks up a class definition index by its class descriptor.
407 bool FindClassDefIndex(const StringPiece& descriptor, uint32_t& idx) const;
408
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700409 const TypeList* GetInterfacesList(const ClassDef& class_def) const {
410 if (class_def.interfaces_off_ == 0) {
411 return NULL;
412 } else {
413 const byte* addr = base_ + class_def.interfaces_off_;
414 return reinterpret_cast<const TypeList*>(addr);
415 }
416 }
417
Ian Rogers0571d352011-11-03 19:51:38 -0700418 // Returns a pointer to the raw memory mapped class_data_item
419 const byte* GetClassData(const ClassDef& class_def) const {
420 if (class_def.class_data_off_ == 0) {
421 return NULL;
422 } else {
423 return base_ + class_def.class_data_off_;
424 }
Shih-wei Liao2fb97532011-08-11 16:17:23 -0700425 }
426
Ian Rogers0571d352011-11-03 19:51:38 -0700427 //
Shih-wei Liao2fb97532011-08-11 16:17:23 -0700428 const CodeItem* GetCodeItem(const uint32_t code_off_) const {
429 if (code_off_ == 0) {
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700430 return NULL; // native or abstract method
431 } else {
Shih-wei Liao2fb97532011-08-11 16:17:23 -0700432 const byte* addr = base_ + code_off_;
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700433 return reinterpret_cast<const CodeItem*>(addr);
434 }
435 }
436
Ian Rogers0571d352011-11-03 19:51:38 -0700437 const char* GetReturnTypeDescriptor(const ProtoId& proto_id) const {
438 return StringByTypeIdx(proto_id.return_type_idx_);
439 }
440
441 // Returns the number of prototype identifiers in the .dex file.
442 size_t NumProtoIds() const {
443 CHECK(header_ != NULL);
444 return header_->proto_ids_size_;
445 }
446
447 // Returns the ProtoId at the specified index.
448 const ProtoId& GetProtoId(uint32_t idx) const {
449 CHECK_LT(idx, NumProtoIds());
450 return proto_ids_[idx];
451 }
452
453 uint16_t GetIndexForProtoId(const ProtoId& proto_id) const {
454 CHECK_GE(&proto_id, proto_ids_);
455 CHECK_LT(&proto_id, proto_ids_ + header_->proto_ids_size_);
456 return &proto_id - proto_ids_;
457 }
458
459 // Looks up a proto id for a given return type and signature type list
460 const ProtoId* FindProtoId(uint16_t return_type_id,
461 const std::vector<uint16_t>& signature_type_ids_) const;
462
463 // Given a signature place the type ids into the given vector, returns true on success
464 bool CreateTypeList(uint16_t* return_type_idx, std::vector<uint16_t>* param_type_idxs,
465 const std::string& signature) const;
466
467 // Given a proto_idx decode the type list and return type into a method signature
468 std::string CreateMethodSignature(uint32_t proto_idx, int32_t* unicode_length) const;
469
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700470 // Returns the short form method descriptor for the given prototype.
471 const char* GetShorty(uint32_t proto_idx) const {
472 const ProtoId& proto_id = GetProtoId(proto_idx);
Ian Rogers0571d352011-11-03 19:51:38 -0700473 return StringDataByIdx(proto_id.shorty_idx_);
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700474 }
475
476 const TypeList* GetProtoParameters(const ProtoId& proto_id) const {
477 if (proto_id.parameters_off_ == 0) {
478 return NULL;
479 } else {
480 const byte* addr = base_ + proto_id.parameters_off_;
481 return reinterpret_cast<const TypeList*>(addr);
482 }
483 }
484
Ian Rogers0571d352011-11-03 19:51:38 -0700485 const byte* GetEncodedStaticFieldValuesArray(const ClassDef& class_def) const {
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700486 if (class_def.static_values_off_ == 0) {
487 return 0;
488 } else {
489 return base_ + class_def.static_values_off_;
490 }
491 }
492
Ian Rogers0571d352011-11-03 19:51:38 -0700493 static const TryItem* GetTryItems(const CodeItem& code_item, uint32_t offset) {
Ian Rogersd81871c2011-10-03 13:57:23 -0700494 const uint16_t* insns_end_ = &code_item.insns_[code_item.insns_size_in_code_units_];
Shih-wei Liao2fb97532011-08-11 16:17:23 -0700495 return reinterpret_cast<const TryItem*>
496 (RoundUp(reinterpret_cast<uint32_t>(insns_end_), 4)) + offset;
497 }
498
499 // Get the base of the encoded data for the given DexCode.
Ian Rogers0571d352011-11-03 19:51:38 -0700500 static const byte* GetCatchHandlerData(const CodeItem& code_item, uint32_t offset) {
501 const byte* handler_data =
502 reinterpret_cast<const byte*>(GetTryItems(code_item, code_item.tries_size_));
Shih-wei Liao2fb97532011-08-11 16:17:23 -0700503 return handler_data + offset;
504 }
505
506 // Find the handler associated with a given address, if any.
507 // Initializes the given iterator and returns true if a match is
508 // found. Returns end if there is no applicable handler.
Ian Rogers0571d352011-11-03 19:51:38 -0700509 static int32_t FindCatchHandlerOffset(const CodeItem &code_item, int32_t tries_size,
510 uint32_t address);
Shih-wei Liao2fb97532011-08-11 16:17:23 -0700511
Shih-wei Liao195487c2011-08-20 13:29:04 -0700512 // Get the pointer to the start of the debugging data
Ian Rogers0571d352011-11-03 19:51:38 -0700513 const byte* GetDebugInfoStream(const CodeItem* code_item) const {
Shih-wei Liao195487c2011-08-20 13:29:04 -0700514 if (code_item->debug_info_off_ == 0) {
515 return NULL;
516 } else {
517 return base_ + code_item->debug_info_off_;
518 }
519 }
520
521 // Callback for "new position table entry".
522 // Returning true causes the decoder to stop early.
Brian Carlstrom78128a62011-09-15 17:21:19 -0700523 typedef bool (*DexDebugNewPositionCb)(void* cnxt, uint32_t address, uint32_t line_num);
Shih-wei Liao195487c2011-08-20 13:29:04 -0700524
525 // Callback for "new locals table entry". "signature" is an empty string
526 // if no signature is available for an entry.
Brian Carlstrom78128a62011-09-15 17:21:19 -0700527 typedef void (*DexDebugNewLocalCb)(void* cnxt, uint16_t reg,
Shih-wei Liao195487c2011-08-20 13:29:04 -0700528 uint32_t startAddress,
529 uint32_t endAddress,
Brian Carlstrom40381fb2011-10-19 14:13:40 -0700530 const char* name,
531 const char* descriptor,
532 const char* signature);
Shih-wei Liao195487c2011-08-20 13:29:04 -0700533
Ian Rogers0571d352011-11-03 19:51:38 -0700534 static bool LineNumForPcCb(void* cnxt, uint32_t address, uint32_t line_num);
Shih-wei Liao195487c2011-08-20 13:29:04 -0700535
536 // Debug info opcodes and constants
537 enum {
538 DBG_END_SEQUENCE = 0x00,
539 DBG_ADVANCE_PC = 0x01,
540 DBG_ADVANCE_LINE = 0x02,
541 DBG_START_LOCAL = 0x03,
542 DBG_START_LOCAL_EXTENDED = 0x04,
543 DBG_END_LOCAL = 0x05,
544 DBG_RESTART_LOCAL = 0x06,
545 DBG_SET_PROLOGUE_END = 0x07,
546 DBG_SET_EPILOGUE_BEGIN = 0x08,
547 DBG_SET_FILE = 0x09,
548 DBG_FIRST_SPECIAL = 0x0a,
549 DBG_LINE_BASE = -4,
550 DBG_LINE_RANGE = 15,
551 };
552
553 struct LocalInfo {
Ian Rogers0571d352011-11-03 19:51:38 -0700554 LocalInfo() : name_(NULL), descriptor_(NULL), signature_(NULL), start_address_(0),
555 is_live_(false) {}
Shih-wei Liao195487c2011-08-20 13:29:04 -0700556
Ian Rogers0571d352011-11-03 19:51:38 -0700557 const char* name_; // E.g., list
558 const char* descriptor_; // E.g., Ljava/util/LinkedList;
559 const char* signature_; // E.g., java.util.LinkedList<java.lang.Integer>
560 uint16_t start_address_; // PC location where the local is first defined.
561 bool is_live_; // Is the local defined and live.
Brian Carlstromd2fbb2b2011-08-23 11:57:08 -0700562
563 private:
564 DISALLOW_COPY_AND_ASSIGN(LocalInfo);
Shih-wei Liao195487c2011-08-20 13:29:04 -0700565 };
566
567 struct LineNumFromPcContext {
568 LineNumFromPcContext(uint32_t address, uint32_t line_num) :
569 address_(address), line_num_(line_num) {}
570 uint32_t address_;
571 uint32_t line_num_;
Brian Carlstromd2fbb2b2011-08-23 11:57:08 -0700572 private:
573 DISALLOW_COPY_AND_ASSIGN(LineNumFromPcContext);
Shih-wei Liao195487c2011-08-20 13:29:04 -0700574 };
575
Brian Carlstrom78128a62011-09-15 17:21:19 -0700576 void InvokeLocalCbIfLive(void* cnxt, int reg, uint32_t end_address,
577 LocalInfo* local_in_reg, DexDebugNewLocalCb local_cb) const {
Shih-wei Liao195487c2011-08-20 13:29:04 -0700578 if (local_cb != NULL && local_in_reg[reg].is_live_) {
579 local_cb(cnxt, reg, local_in_reg[reg].start_address_, end_address,
580 local_in_reg[reg].name_, local_in_reg[reg].descriptor_,
581 local_in_reg[reg].signature_);
582 }
583 }
584
585 // Determine the source file line number based on the program counter.
586 // "pc" is an offset, in 16-bit units, from the start of the method's code.
587 //
588 // Returns -1 if no match was found (possibly because the source files were
589 // compiled without "-g", so no line number information is present).
590 // Returns -2 for native methods (as expected in exception traces).
591 //
592 // This is used by runtime; therefore use art::Method not art::DexFile::Method.
Ian Rogers0571d352011-11-03 19:51:38 -0700593 int32_t GetLineNumFromPC(const Method* method, uint32_t rel_pc) const;
Shih-wei Liao195487c2011-08-20 13:29:04 -0700594
Ian Rogers0571d352011-11-03 19:51:38 -0700595 void DecodeDebugInfo0(const CodeItem* code_item, const Method* method,
596 DexDebugNewPositionCb posCb, DexDebugNewLocalCb local_cb,
597 void* cnxt, const byte* stream, LocalInfo* local_in_reg) const;
Shih-wei Liao195487c2011-08-20 13:29:04 -0700598
Ian Rogers0571d352011-11-03 19:51:38 -0700599 void DecodeDebugInfo(const CodeItem* code_item, const Method* method,
600 DexDebugNewPositionCb posCb, DexDebugNewLocalCb local_cb,
601 void* cnxt) const;
Shih-wei Liao195487c2011-08-20 13:29:04 -0700602
Ian Rogers0571d352011-11-03 19:51:38 -0700603 const char* GetSourceFile(const ClassDef& class_def) const {
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700604 if (class_def.source_file_idx_ == 0xffffffff) {
605 return NULL;
606 } else {
Ian Rogers0571d352011-11-03 19:51:38 -0700607 return StringDataByIdx(class_def.source_file_idx_);
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700608 }
Carl Shapiro0e5d75d2011-07-06 18:28:37 -0700609 }
610
jeffhaob4df5142011-09-19 20:25:32 -0700611 void ChangePermissions(int prot) const;
612
Carl Shapiro1fb86202011-06-27 17:43:13 -0700613 private:
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700614
615 // Opens a .dex file
616 static const DexFile* OpenFile(const std::string& filename,
617 const std::string& original_location,
618 const std::string& strip_location_prefix);
619
620 // Opens a dex file from within a .jar, .zip, or .apk file
621 static const DexFile* OpenZip(const std::string& filename,
622 const std::string& strip_location_prefix);
623
Brian Carlstrom9f30b382011-08-28 22:41:38 -0700624 // Opens a .dex file at the given address.
Brian Carlstrom58ae9412011-10-04 00:56:06 -0700625 static const DexFile* OpenMemory(const byte* dex_file,
626 size_t length,
627 const std::string& location,
628 MemMap* mem_map);
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700629
Brian Carlstrom33f741e2011-10-03 11:24:05 -0700630 DexFile(const byte* addr, size_t length, const std::string& location, MemMap* mem_map)
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700631 : base_(addr),
632 length_(length),
Brian Carlstroma663ea52011-08-19 23:33:41 -0700633 location_(location),
Brian Carlstrom33f741e2011-10-03 11:24:05 -0700634 mem_map_(mem_map),
Jesse Wilson6bf19152011-09-29 13:12:33 -0400635 dex_object_lock_("a dex_object_lock_"),
636 dex_object_(NULL),
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700637 header_(0),
638 string_ids_(0),
639 type_ids_(0),
640 field_ids_(0),
641 method_ids_(0),
642 proto_ids_(0),
Brian Carlstroma663ea52011-08-19 23:33:41 -0700643 class_defs_(0) {
644 CHECK(addr != NULL);
645 CHECK_GT(length, 0U);
Brian Carlstrom33f741e2011-10-03 11:24:05 -0700646 CHECK(mem_map != NULL);
Brian Carlstroma663ea52011-08-19 23:33:41 -0700647 }
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700648
649 // Top-level initializer that calls other Init methods.
650 bool Init();
651
652 // Caches pointers into to the various file sections.
653 void InitMembers();
654
655 // Builds the index of descriptors to class definitions.
656 void InitIndex();
657
658 // Returns true if the byte string equals the magic value.
659 bool CheckMagic(const byte* magic);
660
661 // Returns true if the header magic is of the expected value.
662 bool IsMagicValid();
663
Brian Carlstrome24fa612011-09-29 00:53:55 -0700664 // The index of descriptors to class definition indexes.
Ian Rogers0571d352011-11-03 19:51:38 -0700665 // TODO: given type_ids are sorted by string_id index, and string_ids are alphabetically, class
666 // lookup can be done with a binary search. Is the index necessary?
Brian Carlstrome24fa612011-09-29 00:53:55 -0700667 typedef std::map<const StringPiece, uint32_t> Index;
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700668 Index index_;
669
670 // The base address of the memory mapping.
671 const byte* base_;
672
673 // The size of the underlying memory allocation in bytes.
674 size_t length_;
675
Elliott Hughes64bf5a32011-09-20 14:43:12 -0700676 // Typically the dex file name when available, alternatively some identifying string.
Brian Carlstroma663ea52011-08-19 23:33:41 -0700677 //
678 // The ClassLinker will use this to match DexFiles the boot class
679 // path to DexCache::GetLocation when loading from an image.
680 const std::string location_;
681
Brian Carlstrom33f741e2011-10-03 11:24:05 -0700682 // Manages the underlying memory allocation.
683 UniquePtr<MemMap> mem_map_;
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700684
Jesse Wilson6bf19152011-09-29 13:12:33 -0400685 // A cached com.android.dex.Dex instance, possibly NULL. Use GetDexObject.
686 mutable Mutex dex_object_lock_;
687 mutable jobject dex_object_;
688
Brian Carlstrom7e49dca2011-07-22 18:07:34 -0700689 // Points to the header section.
690 const Header* header_;
691
692 // Points to the base of the string identifier list.
693 const StringId* string_ids_;
694
695 // Points to the base of the type identifier list.
696 const TypeId* type_ids_;
697
698 // Points to the base of the field identifier list.
699 const FieldId* field_ids_;
700
701 // Points to the base of the method identifier list.
702 const MethodId* method_ids_;
703
704 // Points to the base of the prototype identifier list.
705 const ProtoId* proto_ids_;
706
707 // Points to the base of the class definition list.
708 const ClassDef* class_defs_;
Carl Shapiro1fb86202011-06-27 17:43:13 -0700709};
710
Ian Rogers0571d352011-11-03 19:51:38 -0700711// Iterate over a dex file's ProtoId's paramters
712class DexFileParameterIterator {
713 public:
714 DexFileParameterIterator(const DexFile& dex_file, const DexFile::ProtoId& proto_id)
715 : dex_file_(dex_file), size_(0), pos_(0) {
716 type_list_ = dex_file_.GetProtoParameters(proto_id);
717 if (type_list_ != NULL) {
718 size_ = type_list_->Size();
719 }
720 }
721 bool HasNext() const { return pos_ < size_; }
722 void Next() { ++pos_; }
723 uint16_t GetTypeId() {
724 return type_list_->GetTypeItem(pos_).type_idx_;
725 }
726 const char* GetDescriptor() {
727 return dex_file_.StringByTypeIdx(GetTypeId());
728 }
729 private:
730 const DexFile& dex_file_;
731 const DexFile::TypeList* type_list_;
732 uint32_t size_;
733 uint32_t pos_;
734 DISALLOW_IMPLICIT_CONSTRUCTORS(DexFileParameterIterator);
735};
736
737// Iterate and decode class_data_item
738class ClassDataItemIterator {
739 public:
740 ClassDataItemIterator(const DexFile& dex_file, const byte* raw_class_data_item)
741 : dex_file_(dex_file), pos_(0), ptr_pos_(raw_class_data_item), last_idx_(0) {
742 ReadClassDataHeader();
743 if (EndOfInstanceFieldsPos() > 0) {
744 ReadClassDataField();
745 } else if (EndOfVirtualMethodsPos() > 0) {
746 ReadClassDataMethod();
747 }
748 }
749 uint32_t NumStaticFields() const {
750 return header_.static_fields_size_;
751 }
752 uint32_t NumInstanceFields() const {
753 return header_.instance_fields_size_;
754 }
755 uint32_t NumDirectMethods() const {
756 return header_.direct_methods_size_;
757 }
758 uint32_t NumVirtualMethods() const {
759 return header_.virtual_methods_size_;
760 }
761 bool HasNextStaticField() const {
762 return pos_ < EndOfStaticFieldsPos();
763 }
764 bool HasNextInstanceField() const {
765 return pos_ >= EndOfStaticFieldsPos() && pos_ < EndOfInstanceFieldsPos();
766 }
767 bool HasNextDirectMethod() const {
768 return pos_ >= EndOfInstanceFieldsPos() && pos_ < EndOfDirectMethodsPos();
769 }
770 bool HasNextVirtualMethod() const {
771 return pos_ >= EndOfDirectMethodsPos() && pos_ < EndOfVirtualMethodsPos();
772 }
773 bool HasNext() const {
774 return pos_ < EndOfVirtualMethodsPos();
775 }
776 void Next() {
777 pos_++;
778 if (pos_ < EndOfStaticFieldsPos()) {
779 last_idx_ = GetMemberIndex();
780 ReadClassDataField();
781 } else if (pos_ == EndOfStaticFieldsPos() && NumInstanceFields() > 0) {
782 last_idx_ = 0; // transition to next array, reset last index
783 ReadClassDataField();
784 } else if (pos_ < EndOfInstanceFieldsPos()) {
785 last_idx_ = GetMemberIndex();
786 ReadClassDataField();
787 } else if (pos_ == EndOfInstanceFieldsPos() && NumDirectMethods() > 0) {
788 last_idx_ = 0; // transition to next array, reset last index
789 ReadClassDataMethod();
790 } else if (pos_ < EndOfDirectMethodsPos()) {
791 last_idx_ = GetMemberIndex();
792 ReadClassDataMethod();
793 } else if (pos_ == EndOfDirectMethodsPos() && NumVirtualMethods() > 0) {
794 last_idx_ = 0; // transition to next array, reset last index
795 ReadClassDataMethod();
796 } else if (pos_ < EndOfVirtualMethodsPos()) {
797 last_idx_ = GetMemberIndex();
798 ReadClassDataMethod();
799 } else {
800 DCHECK(!HasNext());
801 }
802 }
803 uint32_t GetMemberIndex() const {
804 if (pos_ < EndOfInstanceFieldsPos()) {
805 return last_idx_ + field_.field_idx_delta_;
806 } else {
807 CHECK_LT(pos_, EndOfVirtualMethodsPos());
808 return last_idx_ + method_.method_idx_delta_;
809 }
810 }
811 uint32_t GetMemberAccessFlags() const {
812 if (pos_ < EndOfInstanceFieldsPos()) {
813 return field_.access_flags_;
814 } else {
815 CHECK_LT(pos_, EndOfVirtualMethodsPos());
816 return method_.access_flags_;
817 }
818 }
819 const DexFile::CodeItem* GetMethodCodeItem() const {
820 return dex_file_.GetCodeItem(method_.code_off_);
821 }
822 uint32_t GetMethodCodeItemOffset() const {
823 return method_.code_off_;
824 }
825 private:
826 // A dex file's class_data_item is leb128 encoded, this structure holds a decoded form of the
827 // header for a class_data_item
828 struct ClassDataHeader {
829 uint32_t static_fields_size_; // the number of static fields
830 uint32_t instance_fields_size_; // the number of instance fields
831 uint32_t direct_methods_size_; // the number of direct methods
832 uint32_t virtual_methods_size_; // the number of virtual methods
833 } header_;
834
835 // Read and decode header from a class_data_item stream into header
836 void ReadClassDataHeader();
837
838 uint32_t EndOfStaticFieldsPos() const {
839 return header_.static_fields_size_;
840 }
841 uint32_t EndOfInstanceFieldsPos() const {
842 return EndOfStaticFieldsPos() + header_.instance_fields_size_;
843 }
844 uint32_t EndOfDirectMethodsPos() const {
845 return EndOfInstanceFieldsPos() + header_.direct_methods_size_;
846 }
847 uint32_t EndOfVirtualMethodsPos() const {
848 return EndOfDirectMethodsPos() + header_.virtual_methods_size_;
849 }
850
851 // A decoded version of the field of a class_data_item
852 struct ClassDataField {
853 uint32_t field_idx_delta_; // delta of index into the field_ids array for FieldId
854 uint32_t access_flags_; // access flags for the field
855 ClassDataField() : field_idx_delta_(0), access_flags_(0) {}
856 private:
857 DISALLOW_COPY_AND_ASSIGN(ClassDataField);
858 } field_;
859
860 // Read and decode a field from a class_data_item stream into field
861 void ReadClassDataField();
862
863 // A decoded version of the method of a class_data_item
864 struct ClassDataMethod {
865 uint32_t method_idx_delta_; // delta of index into the method_ids array for MethodId
866 uint32_t access_flags_;
867 uint32_t code_off_;
868 ClassDataMethod() : method_idx_delta_(0), access_flags_(0), code_off_(0) {}
869 private:
870 DISALLOW_COPY_AND_ASSIGN(ClassDataMethod);
871 } method_;
872
873 // Read and decode a method from a class_data_item stream into method
874 void ReadClassDataMethod();
875
876 const DexFile& dex_file_;
877 size_t pos_; // integral number of items passed
878 const byte* ptr_pos_; // pointer into stream of class_data_item
879 uint32_t last_idx_; // last read field or method index to apply delta to
880 DISALLOW_IMPLICIT_CONSTRUCTORS(ClassDataItemIterator);
881};
882
883class ClassLinker;
884class DexCache;
885class Field;
886
887class EncodedStaticFieldValueIterator {
888 public:
889 EncodedStaticFieldValueIterator(const DexFile& dex_file, DexCache* dex_cache,
890 ClassLinker* linker, const DexFile::ClassDef& class_def);
891
892 void ReadValueToField(Field* field) const;
893
894 bool HasNext() { return pos_ < array_size_; }
895
896 void Next();
897 private:
898 enum ValueType {
899 kByte = 0x00,
900 kShort = 0x02,
901 kChar = 0x03,
902 kInt = 0x04,
903 kLong = 0x06,
904 kFloat = 0x10,
905 kDouble = 0x11,
906 kString = 0x17,
907 kType = 0x18,
908 kField = 0x19,
909 kMethod = 0x1a,
910 kEnum = 0x1b,
911 kArray = 0x1c,
912 kAnnotation = 0x1d,
913 kNull = 0x1e,
914 kBoolean = 0x1f
915 };
916
917 static const byte kEncodedValueTypeMask = 0x1f; // 0b11111
918 static const byte kEncodedValueArgShift = 5;
919
920 const DexFile& dex_file_;
921 DexCache* dex_cache_; // dex cache to resolve literal objects
922 ClassLinker* linker_; // linker to resolve literal objects
923 size_t array_size_; // size of array
924 size_t pos_; // current position
925 const byte* ptr_; // pointer into encoded data array
926 byte type_; // type of current encoded value
927 jvalue jval_; // value of current encoded value
928 DISALLOW_IMPLICIT_CONSTRUCTORS(EncodedStaticFieldValueIterator);
929};
930
931class CatchHandlerIterator {
932 public:
933 CatchHandlerIterator(const DexFile::CodeItem& code_item, uint32_t address);
934 explicit CatchHandlerIterator(const byte* handler_data) {
935 Init(handler_data);
936 }
937
938 uint16_t GetHandlerTypeIndex() const {
939 return handler_.type_idx_;
940 }
941 uint32_t GetHandlerAddress() const {
942 return handler_.address_;
943 }
944 void Next();
945 bool HasNext() const {
946 return remaining_count_ != -1 || catch_all_;
947 }
948 // End of this set of catch blocks, convenience method to locate next set of catch blocks
949 const byte* EndDataPointer() const {
950 CHECK(!HasNext());
951 return current_data_;
952 }
953 private:
954 void Init(const byte* handler_data);
955
956 struct CatchHandlerItem {
957 uint16_t type_idx_; // type index of the caught exception type
958 uint32_t address_; // handler address
959 } handler_;
960 const byte *current_data_; // the current handler in dex file.
961 int32_t remaining_count_; // number of handlers not read.
962 bool catch_all_; // is there a handler that will catch all exceptions in case
963 // that all typed handler does not match.
964};
965
Carl Shapiro1fb86202011-06-27 17:43:13 -0700966} // namespace art
967
968#endif // ART_SRC_DEX_FILE_H_