diff options
author | Jeff Brown <jeffbrown@google.com> | 2014-09-10 18:41:18 -0700 |
---|---|---|
committer | Brian Carlstrom <bdc@google.com> | 2014-09-11 16:13:00 -0700 |
commit | b4fffc702abc8aebac2c34eaf852aec52be87eb3 (patch) | |
tree | 4f9e8ddba864ccb6b6bda8925405c45cb00d0bce | |
parent | 77f46bbe03cde911bc4b36ff8e7807e8ceaa9f90 (diff) | |
download | art-b4fffc702abc8aebac2c34eaf852aec52be87eb3.zip art-b4fffc702abc8aebac2c34eaf852aec52be87eb3.tar.gz art-b4fffc702abc8aebac2c34eaf852aec52be87eb3.tar.bz2 |
Print the command line and ABI in stack dumps like debuggerd.
Ensure the heading is "Cmd line:" just like debuggerd and
as it used to be in Dalvik.
Fix a missing newline.
Trim all training nulls from the command line.
Don't bother printing the original command line if unset.
Add the ABI to the dump to help the native stack symbol tool.
Bug: 17474152
(cherry picked from commit 09865b8aa2d85f2824fbdac8034cab01629e8adc)
Change-Id: I52d55660276092ed73b61d5e0708460ec39f1a4a
-rw-r--r-- | runtime/signal_catcher.cc | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/runtime/signal_catcher.cc b/runtime/signal_catcher.cc index c13776d..11e06fe 100644 --- a/runtime/signal_catcher.cc +++ b/runtime/signal_catcher.cc @@ -28,6 +28,7 @@ #include "base/unix_file/fd_file.h" #include "class_linker.h" #include "gc/heap.h" +#include "instruction_set.h" #include "os.h" #include "runtime.h" #include "scoped_thread_state_change.h" @@ -42,20 +43,21 @@ static void DumpCmdLine(std::ostream& os) { #if defined(__linux__) // Show the original command line, and the current command line too if it's changed. // On Android, /proc/self/cmdline will have been rewritten to something like "system_server". + // Note: The string "Cmd line:" is chosen to match the format used by debuggerd. std::string current_cmd_line; if (ReadFileToString("/proc/self/cmdline", ¤t_cmd_line)) { - current_cmd_line.resize(current_cmd_line.size() - 1); // Lose the trailing '\0'. + current_cmd_line.resize(current_cmd_line.find_last_not_of('\0') + 1); // trim trailing '\0's std::replace(current_cmd_line.begin(), current_cmd_line.end(), '\0', ' '); - os << "Cmdline: " << current_cmd_line; + os << "Cmd line: " << current_cmd_line << "\n"; const char* stashed_cmd_line = GetCmdLine(); - if (stashed_cmd_line != NULL && current_cmd_line != stashed_cmd_line) { - os << "Original command line: " << stashed_cmd_line; + if (stashed_cmd_line != NULL && current_cmd_line != stashed_cmd_line + && strcmp(stashed_cmd_line, "<unset>") != 0) { + os << "Original command line: " << stashed_cmd_line << "\n"; } } - os << "\n"; #else - os << "Cmdline: " << GetCmdLine() << "\n"; + os << "Cmd line: " << GetCmdLine() << "\n"; #endif } @@ -133,6 +135,9 @@ void SignalCatcher::HandleSigQuit() { DumpCmdLine(os); + // Note: The string "ABI:" is chosen to match the format used by debuggerd. + os << "ABI: " << GetInstructionSetString(runtime->GetInstructionSet()) << "\n"; + os << "Build type: " << (kIsDebugBuild ? "debug" : "optimized") << "\n"; runtime->DumpForSigQuit(os); |