Stub to capture method entry/exit.
Added stubs to allow traceview to do method tracing. Currently only
outputs to logcat, and a later change will generate the proper log file.
Change-Id: Icaafc50e2eaf042ddc4d882011f7e8121bdd8b1c
diff --git a/src/runtime_support.cc b/src/runtime_support.cc
index 1d05527..3a3eaf1 100644
--- a/src/runtime_support.cc
+++ b/src/runtime_support.cc
@@ -22,6 +22,7 @@
#include "object.h"
#include "object_utils.h"
#include "reflection.h"
+#include "trace.h"
#include "ScopedLocalRef.h"
namespace art {
@@ -139,6 +140,10 @@
extern "C" void artThrowStackOverflowFromCode(Method* method, Thread* thread, Method** sp) {
FinishCalleeSaveFrameSetup(thread, sp, Runtime::kSaveAll);
+ // Remove extra entry pushed onto second stack during method tracing
+ if (Trace::IsMethodTracingActive()) {
+ artTraceMethodUnwindFromCode(thread);
+ }
thread->SetStackEndForStackOverflow(); // Allow space on the stack for constructor to execute
thread->ThrowNewExceptionF("Ljava/lang/StackOverflowError;",
"stack size %zdkb; default stack size: %zdkb",
@@ -1163,6 +1168,32 @@
}
}
+extern "C" const void* artTraceMethodEntryFromCode(Method* method, Thread* self, uintptr_t lr) {
+ LOG(INFO) << "Tracer - entering: " << PrettyMethod(method);
+ TraceStackFrame trace_frame = TraceStackFrame(method, lr);
+ self->PushTraceStackFrame(trace_frame);
+
+ return Trace::GetSavedCodeFromMap(method);
+}
+
+extern "C" uintptr_t artTraceMethodExitFromCode() {
+ TraceStackFrame trace_frame = Thread::Current()->PopTraceStackFrame();
+ Method* method = trace_frame.method_;
+ uintptr_t lr = trace_frame.return_pc_;
+ LOG(INFO) << "Tracer - exiting: " << PrettyMethod(method);
+
+ return lr;
+}
+
+uintptr_t artTraceMethodUnwindFromCode(Thread* self) {
+ TraceStackFrame trace_frame = self->PopTraceStackFrame();
+ Method* method = trace_frame.method_;
+ uintptr_t lr = trace_frame.return_pc_;
+ LOG(INFO) << "Tracer - unwinding: " << PrettyMethod(method);
+
+ return lr;
+}
+
/*
* Float/double conversion requires clamping to min and max of integer form. If
* target doesn't support this normally, use these.