Add method_idx output to dexdump and dexlayout

Includes method_idx when dumping methods. To keeep the default output
the same, this field is only displayed when the -h option is given,
which is the option that also controls when the class_idx field is
displayed.

Test: m test-art-host-gtest
Change-Id: I6a71d2ecd29e50df506e97bb4c08c94a0b4c5a6a
diff --git a/dexdump/dexdump.cc b/dexdump/dexdump.cc
index a412938..e694c5f 100644
--- a/dexdump/dexdump.cc
+++ b/dexdump/dexdump.cc
@@ -1236,6 +1236,9 @@
     fprintf(gOutFile, "      name          : '%s'\n", name);
     fprintf(gOutFile, "      type          : '%s'\n", typeDescriptor);
     fprintf(gOutFile, "      access        : 0x%04x (%s)\n", flags, accessStr);
+    if (gOptions.showSectionHeaders) {
+      fprintf(gOutFile, "      method_idx    : %d\n", method.GetIndex());
+    }
     if (hiddenapiFlags != 0u) {
       fprintf(gOutFile,
               "      hiddenapi     : 0x%04x (%s)\n",
diff --git a/dexlayout/dexlayout.cc b/dexlayout/dexlayout.cc
index f5eeeb7..75afc78 100644
--- a/dexlayout/dexlayout.cc
+++ b/dexlayout/dexlayout.cc
@@ -1178,6 +1178,9 @@
     fprintf(out_file_, "      name          : '%s'\n", name);
     fprintf(out_file_, "      type          : '%s'\n", type_descriptor);
     fprintf(out_file_, "      access        : 0x%04x (%s)\n", flags, access_str);
+    if (options_.show_section_headers_) {
+      fprintf(out_file_, "      method_idx    : %d\n", method_id->GetIndex());
+    }
     if (hiddenapi_flags != 0u) {
       fprintf(out_file_,
               "      hiddenapi     : 0x%04x (%s)\n",