OSDN Git Service

ART: Allow oatdump to print vr stack locations
authorRazvan A Lupusoru <razvan.a.lupusoru@intel.com>
Sat, 30 Aug 2014 00:56:46 +0000 (17:56 -0700)
committerIan Rogers <irogers@google.com>
Thu, 4 Sep 2014 15:35:11 +0000 (08:35 -0700)
For both debugging and performance analysis, it is necessary to understand
stack layout. This patch adds capability to oatdump to print out the offsets
of the locals, ins, method*, and out VRs.

Change-Id: I73512f59e4fd2d2b12725a6c76d602182c46ff78
Signed-off-by: Razvan A Lupusoru <razvan.a.lupusoru@intel.com>
oatdump/oatdump.cc

index 1feb27d..931ee56 100644 (file)
@@ -396,6 +396,7 @@ class OatDumper {
       *indent2_os << StringPrintf("\nvmap_table: %p (offset=0x%08x)\n",
                                   oat_method.GetVmapTable(), oat_method.GetVmapTableOffset());
       DumpVmap(*indent2_os, oat_method);
+      DumpVregLocations(*indent2_os, oat_method, code_item);
       *indent2_os << StringPrintf("mapping_table: %p (offset=0x%08x)\n",
                                   oat_method.GetMappingTable(), oat_method.GetMappingTableOffset());
       if (dump_raw_mapping_table_) {
@@ -492,6 +493,45 @@ class OatDumper {
     }
   }
 
+  void DumpVregLocations(std::ostream& os, const OatFile::OatMethod& oat_method,
+                         const DexFile::CodeItem* code_item) {
+    if (code_item != nullptr) {
+      size_t num_locals_ins = code_item->registers_size_;
+      size_t num_ins = code_item->ins_size_;
+      size_t num_locals = num_locals_ins - num_ins;
+      size_t num_outs = code_item->outs_size_;
+
+      os << "vr_stack_locations:";
+      for (size_t reg = 0; reg <= num_locals_ins; reg++) {
+        // For readability, delimit the different kinds of VRs.
+        if (reg == num_locals_ins) {
+          os << "\n\tmethod*:";
+        } else if (reg == num_locals && num_ins > 0) {
+          os << "\n\tins:";
+        } else if (reg == 0 && num_locals > 0) {
+          os << "\n\tlocals:";
+        }
+
+        uint32_t offset = StackVisitor::GetVRegOffset(code_item, oat_method.GetCoreSpillMask(),
+                                                      oat_method.GetFpSpillMask(),
+                                                      oat_method.GetFrameSizeInBytes(), reg,
+                                                      GetInstructionSet());
+        os << " v" << reg << "[sp + #" << offset << "]";
+      }
+
+      for (size_t out_reg = 0; out_reg < num_outs; out_reg++) {
+        if (out_reg == 0) {
+          os << "\n\touts:";
+        }
+
+        uint32_t offset = StackVisitor::GetOutVROffset(out_reg, GetInstructionSet());
+        os << " v" << out_reg << "[sp + #" << offset << "]";
+      }
+
+      os << "\n";
+    }
+  }
+
   void DescribeVReg(std::ostream& os, const OatFile::OatMethod& oat_method,
                     const DexFile::CodeItem* code_item, size_t reg, VRegKind kind) {
     const uint8_t* raw_table = oat_method.GetVmapTable();