Add new_array type info to dex dump output.
Also cleaned up a bit of the field printing.
Change-Id: Ia731d58b16f554fde9a9ac733f4d4f0148e55ac9
diff --git a/src/dex_instruction.cc b/src/dex_instruction.cc
index d06a346..80a7d9d 100644
--- a/src/dex_instruction.cc
+++ b/src/dex_instruction.cc
@@ -309,28 +309,17 @@
break;
case k21c: {
switch (insn.opcode) {
- case CHECK_CAST:
- if (file != NULL) {
- os << StringPrintf("check-cast v%d, %s // type@%d", insn.vA,
- file->StringByTypeIdx(insn.vB), insn.vB);
- break;
- } // else fall-through
- case CONST_CLASS:
- if (file != NULL) {
- os << StringPrintf("const-class v%d, %s // type@%d", insn.vA,
- file->StringByTypeIdx(insn.vB), insn.vB);
- break;
- } // else fall-through
case CONST_STRING:
if (file != NULL) {
os << StringPrintf("const-string v%d, \"%s\" // string@%d", insn.vA,
file->StringDataByIdx(insn.vB), insn.vB);
break;
} // else fall-through
+ case CHECK_CAST:
+ case CONST_CLASS:
case NEW_INSTANCE:
if (file != NULL) {
- os << StringPrintf("new-instance v%d, %s // type@%d", insn.vA,
- file->StringByTypeIdx(insn.vB), insn.vB);
+ os << opcode << " " << PrettyType(insn.vB, *file) << " // type@" << insn.vB;
break;
} // else fall-through
case SGET:
@@ -341,11 +330,7 @@
case SGET_CHAR:
case SGET_SHORT:
if (file != NULL) {
- const DexFile::FieldId& field_id = file->GetFieldId(insn.vB);
- os << StringPrintf("%s v%d, (%s) %s.%s // field@%d", opcode, insn.vA,
- file->GetFieldTypeDescriptor(field_id),
- file->GetFieldDeclaringClassDescriptor(field_id),
- file->GetFieldName(field_id), insn.vB);
+ os << opcode << " " << PrettyField(insn.vB, *file, true) << " // field@" << insn.vB;
break;
} // else fall-through
case SPUT:
@@ -356,11 +341,7 @@
case SPUT_CHAR:
case SPUT_SHORT:
if (file != NULL) {
- const DexFile::FieldId& field_id = file->GetFieldId(insn.vB);
- os << StringPrintf("%s (%s) %s.%s, v%d // field@%d", opcode,
- file->GetFieldTypeDescriptor(field_id),
- file->GetFieldDeclaringClassDescriptor(field_id),
- file->GetFieldName(field_id), insn.vA, insn.vB);
+ os << opcode << " " << PrettyField(insn.vB, *file, true) << " // field@" << insn.vB;
break;
} // else fall-through
default:
@@ -383,11 +364,7 @@
case IGET_CHAR:
case IGET_SHORT:
if (file != NULL) {
- const DexFile::FieldId& field_id = file->GetFieldId(insn.vC);
- os << StringPrintf("%s v%d, v%d, (%s) %s.%s // field@%d", opcode, insn.vA, insn.vB,
- file->GetFieldTypeDescriptor(field_id),
- file->GetFieldDeclaringClassDescriptor(field_id),
- file->GetFieldName(field_id), insn.vC);
+ os << PrettyField(insn.vC, *file, true) << " // field@" << insn.vC;
break;
} // else fall-through
case IPUT:
@@ -398,17 +375,17 @@
case IPUT_CHAR:
case IPUT_SHORT:
if (file != NULL) {
- const DexFile::FieldId& field_id = file->GetFieldId(insn.vC);
- os << StringPrintf("%s v%d, (%s) %s.%s, v%d // field@%d", opcode, insn.vA,
- file->GetFieldTypeDescriptor(field_id),
- file->GetFieldDeclaringClassDescriptor(field_id),
- file->GetFieldName(field_id), insn.vB, insn.vC);
+ os << opcode << " " << PrettyField(insn.vC, *file, true) << " // field@" << insn.vB;
break;
} // else fall-through
case INSTANCE_OF:
if (file != NULL) {
- os << StringPrintf("instance-of v%d, v%d, %s // type@%d", insn.vA, insn.vB,
- file->StringByTypeIdx(insn.vC), insn.vC);
+ os << opcode << " " << PrettyType(insn.vC, *file) << " // type@" << insn.vC;
+ break;
+ }
+ case NEW_ARRAY:
+ if (file != NULL) {
+ os << opcode << " " << PrettyType(insn.vC, *file) << " // type@" << insn.vC;
break;
} // else fall-through
default:
diff --git a/src/utils.cc b/src/utils.cc
index 71a7ebf..d038f6d 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -277,6 +277,14 @@
return result;
}
+std::string PrettyType(uint32_t type_idx, const DexFile& dex_file) {
+ const DexFile::TypeId& type_id = dex_file.GetTypeId(type_idx);
+ std::string result;
+ result += PrettyDescriptor(dex_file.GetTypeDescriptor(type_id));
+ result += ' ';
+ return result;
+}
+
std::string PrettyArguments(const char* signature) {
std::string result;
result += '(';
diff --git a/src/utils.h b/src/utils.h
index 72303f0..8412377 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -195,6 +195,7 @@
// Given String.class, the output would be "java.lang.Class<java.lang.String>".
std::string PrettyTypeOf(const Object* obj)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
+std::string PrettyType(uint32_t type_idx, const DexFile& dex_file);
// Returns a human-readable form of the name of the given class.
// Given String.class, the output would be "java.lang.Class<java.lang.String>".