Finish dexlayout dumping of dex files and added test.
The test runs dexdump and dexlayout over the first core library jar file
and diffs the output, checking that they're the same. More dex files
will be added later for better coverage.
Bug: 29921113
Test: mm test-art-host-gtest-dexlayout_test
(cherry-picked from commit a378e88db648cf19e771714dd1059cf3d41d4753)
Change-Id: Idfd8ac9f069885b675a4a2f0c70aef2cbef5a9b8
diff --git a/dexlayout/dex_ir.h b/dexlayout/dex_ir.h
index bef5c0d..fcd3ab0 100644
--- a/dexlayout/dex_ir.h
+++ b/dexlayout/dex_ir.h
@@ -167,6 +167,14 @@
uint32_t MethodIdsSize() const { return method_ids_.Size(); }
uint32_t ClassDefsSize() const { return class_defs_.Size(); }
+ TypeId* GetTypeIdOrNullPtr(uint16_t index) {
+ return index == DexFile::kDexNoIndex16 ? nullptr : TypeIds()[index].get();
+ }
+
+ StringId* GetStringIdOrNullPtr(uint32_t index) {
+ return index == DexFile::kDexNoIndex ? nullptr : StringIds()[index].get();
+ }
+
void Accept(AbstractDispatcher* dispatch) { dispatch->Dispatch(this); }
private:
@@ -432,6 +440,8 @@
std::vector<std::unique_ptr<ArrayItem>>* StaticValues() { return static_values_; }
ClassData* GetClassData() { return &class_data_; }
+ MethodItem* GenerateMethodItem(Header& header, ClassDataItemIterator& cdii);
+
void Accept(AbstractDispatcher* dispatch) { dispatch->Dispatch(this); }
private:
@@ -497,8 +507,7 @@
insn_count_ = disk_try_item.insn_count_;
for (CatchHandlerIterator it(disk_code_item, disk_try_item); it.HasNext(); it.Next()) {
const uint16_t type_index = it.GetHandlerTypeIndex();
- const TypeId* type_id = type_index != DexFile::kDexNoIndex16 ?
- header.TypeIds()[type_index].get() : nullptr;
+ const TypeId* type_id = header.GetTypeIdOrNullPtr(type_index);
handlers_.push_back(std::unique_ptr<const CatchHandler>(
new CatchHandler(type_id, it.GetHandlerAddress())));
}