Fix method tracing and allow alloc counting during tracing.

Forcing alignment on art_trace_exit_from_code was preventing the LR of
profiled frames from matching. Also, the merge of the different types of
stalk walks introduced a small bug.

The metrod tracer now also supports the TRACE_COUNT_ALLOCS flag to count
allocations during method tracing.

Change-Id: Ief9e4612471a134a90eabf15432135162b633b92
diff --git a/src/trace.h b/src/trace.h
index b0366d9..8dbf924 100644
--- a/src/trace.h
+++ b/src/trace.h
@@ -52,6 +52,10 @@
     kMethodTraceUnwind = 2,
   };
 
+  enum TraceFlag {
+    kTraceCountAllocs = 1,
+  };
+
   static void Start(const char* trace_filename, int trace_fd, int buffer_size, int flags, bool direct_to_ddms);
   static void Stop();
   static void Shutdown();
@@ -66,9 +70,9 @@
   void ResetSavedCode(Method* method);
 
  private:
-  explicit Trace(File* trace_file, int buffer_size)
-      : trace_file_(trace_file), buf_(new uint8_t[buffer_size]()), overflow_(false), buffer_size_(buffer_size),
-        start_time_(0), trace_version_(0), record_size_(0), cur_offset_(0) {
+  explicit Trace(File* trace_file, int buffer_size, int flags)
+      : trace_file_(trace_file), buf_(new uint8_t[buffer_size]()), flags_(flags), overflow_(false),
+        buffer_size_(buffer_size), start_time_(0), trace_version_(0), record_size_(0), cur_offset_(0) {
   }
 
   void BeginTracing();
@@ -100,6 +104,9 @@
   // Buffer to store trace data.
   UniquePtr<uint8_t> buf_;
 
+  // Flags enabling extra tracing of things such as alloc counts.
+  int flags_;
+
   bool overflow_;
   int buffer_size_;
   uint64_t start_time_;