ART: Fix things for valgrind

Wire up valgrind gtests. Add valgrind-test-art-host, currently
only depending on valgrind-test-art-host-gtest32.

Fix an Alloc setting to allow running valgrind.

Refactor the fault handler to manage (and correctly release) the
handlers.

Fix minor failure-case leaks exposed by tests.

Failing tests:

The optimizing compiler is leaking non-arena-ed structures
(e.g., assembler buffers), as code generators are not destroyed.
The solution has been moved to a follow-up CL.

Note: All 64b tests are failing as we cannot allocate a heap.

Change-Id: I7f854cfd098d9f68107ce492363e7dba9a82b9fa
diff --git a/runtime/fault_handler.cc b/runtime/fault_handler.cc
index 47696f9..fede2f8 100644
--- a/runtime/fault_handler.cc
+++ b/runtime/fault_handler.cc
@@ -19,6 +19,7 @@
 #include <setjmp.h>
 #include <sys/mman.h>
 #include <sys/ucontext.h>
+#include "base/stl_util.h"
 #include "mirror/art_method.h"
 #include "mirror/class.h"
 #include "sigchain.h"
@@ -115,13 +116,23 @@
   initialized_ = true;
 }
 
-void FaultManager::Shutdown() {
+void FaultManager::Release() {
   if (initialized_) {
     UnclaimSignalChain(SIGSEGV);
     initialized_ = false;
   }
 }
 
+void FaultManager::Shutdown() {
+  if (initialized_) {
+    Release();
+
+    // Free all handlers.
+    STLDeleteElements(&generated_code_handlers_);
+    STLDeleteElements(&other_handlers_);
+  }
+}
+
 void FaultManager::HandleFault(int sig, siginfo_t* info, void* context) {
   // BE CAREFUL ALLOCATING HERE INCLUDING USING LOG(...)
   //
@@ -156,9 +167,9 @@
 
   // Now set up the nested signal handler.
 
-  // Shutdown the fault manager so that it will remove the signal chain for
+  // Release the fault manager so that it will remove the signal chain for
   // SIGSEGV and we call the real sigaction.
-  fault_manager.Shutdown();
+  fault_manager.Release();
 
   // The action for SIGSEGV should be the default handler now.
 
@@ -226,6 +237,7 @@
 }
 
 void FaultManager::AddHandler(FaultHandler* handler, bool generated_code) {
+  DCHECK(initialized_);
   if (generated_code) {
     generated_code_handlers_.push_back(handler);
   } else {