ART: Support per PID stack trace files.

Introduce an -Xstacktracedir argument that supplies a directory
under which stack traces are written, with a unique file created
per trace. The location of the actual directory in a production
system is still not decided, and follow up changes might be
introduced to supply a per process override.

Bug: 32064548
Test: test-art-host, test-art-target

Change-Id: If377ce6a2abe8b325f6441d8de222b1ea3f40ec9
diff --git a/runtime/signal_catcher.h b/runtime/signal_catcher.h
index de6a212..4cd7a98 100644
--- a/runtime/signal_catcher.h
+++ b/runtime/signal_catcher.h
@@ -32,7 +32,15 @@
  */
 class SignalCatcher {
  public:
-  explicit SignalCatcher(const std::string& stack_trace_file);
+  // If |stack_trace_dir| is non empty, traces will be written to a
+  // unique file under that directory.
+  //
+  // If |stack_trace_dir| is empty, and |stack_frace_file| is non-empty,
+  // traces will be appended to |stack_trace_file|.
+  //
+  // If both are empty, all traces will be written to the log buffer.
+  explicit SignalCatcher(const std::string& stack_trace_dir,
+                         const std::string& stack_trace_file);
   ~SignalCatcher();
 
   void HandleSigQuit() REQUIRES(!Locks::mutator_lock_, !Locks::thread_list_lock_,
@@ -43,12 +51,14 @@
   // NO_THREAD_SAFETY_ANALYSIS for static function calling into member function with excludes lock.
   static void* Run(void* arg) NO_THREAD_SAFETY_ANALYSIS;
 
+  std::string GetStackTraceFileName();
   void HandleSigUsr1();
   void Output(const std::string& s);
   void SetHaltFlag(bool new_value) REQUIRES(!lock_);
   bool ShouldHalt() REQUIRES(!lock_);
   int WaitForSignal(Thread* self, SignalSet& signals) REQUIRES(!lock_);
 
+  std::string stack_trace_dir_;
   std::string stack_trace_file_;
 
   mutable Mutex lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;