OSDN Git Service

ART: Change the stack dump format to be in line with debuggerd
authorAndreas Gampe <agampe@google.com>
Thu, 23 Jul 2015 21:37:18 +0000 (14:37 -0700)
committerAndreas Gampe <agampe@google.com>
Fri, 24 Jul 2015 22:10:22 +0000 (15:10 -0700)
Make offsets 16 digits on 64-bit platforms.

Add the ability to provide the build fingerprint, and print it in
the traces output.

Bug: 22693991

(cherry picked from commit 242ae94dc39be53e519a6163ea1db494ceb75954)

Change-Id: Ibd3d3b3bd65dce84acfb97a487807d6f280a9508

runtime/parsed_options.cc
runtime/runtime.cc
runtime/runtime.h
runtime/runtime_options.def
runtime/signal_catcher.cc
runtime/utils.cc

index 7772354..25b5e49 100644 (file)
@@ -263,6 +263,9 @@ std::unique_ptr<RuntimeParser> ParsedOptions::MakeParser(bool ignore_unrecognize
       .Define("--cpu-abilist=_")
           .WithType<std::string>()
           .IntoKey(M::CpuAbiList)
+      .Define("-Xfingerprint:_")
+          .WithType<std::string>()
+          .IntoKey(M::Fingerprint)
       .Define({"-Xexperimental-lambdas", "-Xnoexperimental-lambdas"})
           .WithType<bool>()
           .WithValues({true, false})
index c92f08f..a297510 100644 (file)
@@ -852,6 +852,8 @@ bool Runtime::Init(const RuntimeOptions& raw_options, bool ignore_unrecognized)
 
   Split(runtime_options.GetOrDefault(Opt::CpuAbiList), ',', &cpu_abilist_);
 
+  fingerprint_ = runtime_options.ReleaseOrDefault(Opt::Fingerprint);
+
   if (runtime_options.GetOrDefault(Opt::Interpret)) {
     GetInstrumentation()->ForceInterpretOnly();
   }
index 8aed768..4577b75 100644 (file)
@@ -563,6 +563,11 @@ class Runtime {
 
   bool IsDebuggable() const;
 
+  // Returns the build fingerprint, if set. Otherwise an empty string is returned.
+  std::string GetFingerprint() {
+    return fingerprint_;
+  }
+
  private:
   static void InitPlatformSignalHandlers();
 
@@ -757,6 +762,9 @@ class Runtime {
 
   MethodRefToStringInitRegMap method_ref_string_init_reg_map_;
 
+  // Contains the build fingerprint, if given as a parameter.
+  std::string fingerprint_;
+
   DISALLOW_COPY_AND_ASSIGN(Runtime);
 };
 std::ostream& operator<<(std::ostream& os, const Runtime::CalleeSaveType& rhs);
index 9922c5f..02ed3a2 100644 (file)
@@ -112,6 +112,7 @@ RUNTIME_OPTIONS_KEY (std::string,         NativeBridge)
 RUNTIME_OPTIONS_KEY (unsigned int,        ZygoteMaxFailedBoots,           10)
 RUNTIME_OPTIONS_KEY (Unit,                NoDexFileFallback)
 RUNTIME_OPTIONS_KEY (std::string,         CpuAbiList)
+RUNTIME_OPTIONS_KEY (std::string,         Fingerprint)
 RUNTIME_OPTIONS_KEY (bool,                ExperimentalLambdas,            false) // -X[no]experimental-lambdas
 
 // Not parse-able from command line, but can be provided explicitly.
index 9f8c55c..6cb7950 100644 (file)
@@ -133,8 +133,11 @@ void SignalCatcher::HandleSigQuit() {
 
   DumpCmdLine(os);
 
-  // Note: The string "ABI:" is chosen to match the format used by debuggerd.
-  os << "ABI: " << GetInstructionSetString(runtime->GetInstructionSet()) << "\n";
+  // Note: The strings "Build fingerprint:" and "ABI:" are chosen to match the format used by
+  // debuggerd. This allows, for example, the stack tool to work.
+  std::string fingerprint = runtime->GetFingerprint();
+  os << "Build fingerprint: '" << (fingerprint.empty() ? "unknown" : fingerprint) << "'\n";
+  os << "ABI: '" << GetInstructionSetString(runtime->GetInstructionSet()) << "'\n";
 
   os << "Build type: " << (kIsDebugBuild ? "debug" : "optimized") << "\n";
 
index 194d9fe..20512f9 100644 (file)
@@ -1130,9 +1130,13 @@ void DumpNativeStack(std::ostream& os, pid_t tid, const char* prefix,
     os << prefix << StringPrintf("#%02zu pc ", it->num);
     bool try_addr2line = false;
     if (!BacktraceMap::IsValid(it->map)) {
-      os << StringPrintf("%08" PRIxPTR "  ???", it->pc);
+      os << StringPrintf(Is64BitInstructionSet(kRuntimeISA) ? "%016" PRIxPTR "  ???"
+                                                            : "%08" PRIxPTR "  ???",
+                         it->pc);
     } else {
-      os << StringPrintf("%08" PRIxPTR "  ", BacktraceMap::GetRelativePc(it->map, it->pc));
+      os << StringPrintf(Is64BitInstructionSet(kRuntimeISA) ? "%016" PRIxPTR "  "
+                                                            : "%08" PRIxPTR "  ",
+                         BacktraceMap::GetRelativePc(it->map, it->pc));
       os << it->map.name;
       os << " (";
       if (!it->func_name.empty()) {