Updates to tracer to log events.
The tracer can now generates traces for ddms or output to a logfile.
Also includes bugfixes to allow stack walking to work properly when
tracing.
Change-Id: I8894272d9a678eeb1d376734f7822daf2ab298e4
diff --git a/src/trace.h b/src/trace.h
index 4c0edda..9637163 100644
--- a/src/trace.h
+++ b/src/trace.h
@@ -4,13 +4,18 @@
#define ART_SRC_TRACE_H_
#include <map>
+#include <ostream>
+#include <set>
+#include <string>
+#include "file.h"
#include "globals.h"
#include "macros.h"
namespace art {
class Method;
+class Thread;
struct TraceStackFrame {
TraceStackFrame(Method* method, uintptr_t return_pc)
@@ -23,9 +28,18 @@
class Trace {
public:
+
+ enum TraceEvent {
+ kMethodTraceEnter = 0,
+ kMethodTraceExit = 1,
+ kMethodTraceUnwind = 2,
+ };
+
static void Start(const char* trace_filename, int trace_fd, int buffer_size, int flags, bool direct_to_ddms);
static void Stop();
+ static void LogMethodTraceEvent(Thread* self, const Method* method, TraceEvent event);
+
static bool IsMethodTracingActive();
static void SetMethodTracingActive(bool value);
@@ -43,11 +57,32 @@
// Restores original code for each method and fixes the return values of each thread's stack.
static void UninstallStubs();
+ // Methods to output traced methods and threads.
+ static void GetVisitedMethods(size_t end_offset);
+ static void DumpMethodList(std::ostream& os);
+ static void DumpThreadList(std::ostream& os);
+
static bool method_tracing_active_;
// Maps a method to its original code pointer
static std::map<const Method*, const void*> saved_code_map_;
+ // Set of methods visited by the profiler
+ static std::set<const Method*> visited_methods_;
+
+ // Maps a thread to its clock base
+ static std::map<Thread*, uint64_t> thread_clock_base_map_;
+
+ static uint8_t* buf_;
+ static File* trace_file_;
+ static bool direct_to_ddms_;
+ static int buffer_size_;
+ static uint64_t start_time_;
+ static bool overflow_;
+ static uint16_t trace_version_;
+ static uint16_t record_size_;
+ static volatile int32_t cur_offset_;
+
DISALLOW_COPY_AND_ASSIGN(Trace);
};