Include non-attached native threads in the SIGQUIT output.

These threads look something like this:

  "droid.phasebeam' prio=5 tid=? (not attached)
    | sysTid=5369 nice=-4 sched=0/0 cgrp=default
    | schedstat=( 0 0 0 ) utm=1 stm=8 core=0 HZ=100
    native: __futex_syscall3+8 [0x40074678] (libc.so)
    native: __pthread_cond_timedwait_relative+48 [0x40079474] (libc.so)
    native: __pthread_cond_timedwait+72 [0x40079528] (libc.so)
    native: android::renderscript::Signal::wait(unsigned long long)+58 [0x418bf117] (libRS.so)
    native: android::renderscript::LocklessCommandFifo::wait(unsigned long long)+38 [0x418bab97] (libRS.so)
    native: android::renderscript::LocklessCommandFifo::get(unsigned int*, unsigned int*, unsigned long long)+22 [0x418babbb] (libRS.so)
    native: android::renderscript::ThreadIO::playCoreCommands(android::renderscript::Context*, bool, unsigned long long)+126 [0x418bf84b] (libRS.so)
    native: android::renderscript::Context::threadProc(void*)+382 [0x418b7347] (libRS.so)
    native: __thread_entry+48 [0x40079d30] (libc.so)
    native: pthread_create+180 [0x40079884] (libc.so)

Also fix running tests on Mac OS, which has no /proc/self/cmdline.

Change-Id: Ib5e6f7e23dd45aecdf814e84f573361a5d91bac6
diff --git a/src/signal_catcher.cc b/src/signal_catcher.cc
index 0703b61..33600ba 100644
--- a/src/signal_catcher.cc
+++ b/src/signal_catcher.cc
@@ -36,8 +36,13 @@
 #include "thread_list.h"
 #include "utils.h"
 
+#if !defined(__APPLE__)
+#define HAVE_PROC_CMDLINE
+#endif
+
 namespace art {
 
+#if defined(HAVE_PROC_CMDLINE)
 static bool ReadCmdLine(std::string& result) {
   if (!ReadFileToString("/proc/self/cmdline", &result)) {
     return false;
@@ -45,6 +50,7 @@
   std::replace(result.begin(), result.end(), '\0', ' ');
   return true;
 }
+#endif
 
 SignalCatcher::SignalCatcher(const std::string& stack_trace_file)
     : stack_trace_file_(stack_trace_file),
@@ -53,9 +59,11 @@
       thread_(NULL) {
   SetHaltFlag(false);
 
+#if defined(HAVE_PROC_CMDLINE)
   // Stash the original command line for SIGQUIT reporting.
   // By then, /proc/self/cmdline will have been rewritten to something like "system_server".
   CHECK(ReadCmdLine(cmd_line_));
+#endif
 
   // Create a raw pthread; its start routine will attach to the runtime.
   CHECK_PTHREAD_CALL(pthread_create, (&pthread_, NULL, &Run, this), "signal catcher thread");
@@ -121,6 +129,7 @@
   os << "\n"
      << "----- pid " << getpid() << " at " << GetIsoDate() << " -----\n";
 
+#if defined(HAVE_PROC_CMDLINE)
   std::string current_cmd_line;
   if (ReadCmdLine(current_cmd_line) && current_cmd_line != cmd_line_) {
     os << "Cmdline: " << current_cmd_line;
@@ -130,6 +139,7 @@
   if (current_cmd_line != cmd_line_) {
     os << "Original command line: " << cmd_line_ << "\n";
   }
+#endif
 
   os << "Build type: " << (kIsDebugBuild ? "debug" : "optimized") << "\n";