Change IsMethodTracingActive to GetMethodTracingMode for art.
This allows traceview to tell whether sampling or just normal
method profiling is enabled.
Change-Id: I518a1888a90bc50568fe56bf708d801027ac98d7
diff --git a/runtime/native/dalvik_system_VMDebug.cc b/runtime/native/dalvik_system_VMDebug.cc
index ae45701..96c3e78 100644
--- a/runtime/native/dalvik_system_VMDebug.cc
+++ b/runtime/native/dalvik_system_VMDebug.cc
@@ -96,8 +96,8 @@
Trace::Start(traceFilename.c_str(), -1, bufferSize, flags, false, false, 0);
}
-static jboolean VMDebug_isMethodTracingActive(JNIEnv*, jclass) {
- return Trace::IsMethodTracingActive();
+static jint VMDebug_getMethodTracingMode(JNIEnv*, jclass) {
+ return Trace::GetMethodTracingMode();
}
static void VMDebug_stopMethodTracing(JNIEnv*, jclass) {
@@ -317,7 +317,7 @@
NATIVE_METHOD(VMDebug, infopoint, "(I)V"),
NATIVE_METHOD(VMDebug, isDebuggerConnected, "()Z"),
NATIVE_METHOD(VMDebug, isDebuggingEnabled, "()Z"),
- NATIVE_METHOD(VMDebug, isMethodTracingActive, "()Z"),
+ NATIVE_METHOD(VMDebug, getMethodTracingMode, "()I"),
NATIVE_METHOD(VMDebug, lastDebuggerActivity, "()J"),
NATIVE_METHOD(VMDebug, printLoadedClasses, "(I)V"),
NATIVE_METHOD(VMDebug, resetAllocCount, "(I)V"),
diff --git a/runtime/trace.cc b/runtime/trace.cc
index 6d040e1..7b25306 100644
--- a/runtime/trace.cc
+++ b/runtime/trace.cc
@@ -427,14 +427,20 @@
}
void Trace::Shutdown() {
- if (IsMethodTracingActive()) {
+ if (GetMethodTracingMode() != kTracingInactive) {
Stop();
}
}
-bool Trace::IsMethodTracingActive() {
+TracingMode Trace::GetMethodTracingMode() {
MutexLock mu(Thread::Current(), *Locks::trace_lock_);
- return the_trace_ != NULL;
+ if (the_trace_ == NULL) {
+ return kTracingInactive;
+ } else if (the_trace_->sampling_enabled_) {
+ return kSampleProfilingActive;
+ } else {
+ return kMethodTracingActive;
+ }
}
Trace::Trace(File* trace_file, int buffer_size, int flags, bool sampling_enabled)
diff --git a/runtime/trace.h b/runtime/trace.h
index 06cb6a6..ffcb36d 100644
--- a/runtime/trace.h
+++ b/runtime/trace.h
@@ -42,6 +42,12 @@
kProfilerClockSourceDual, // Both wall and thread CPU clocks.
};
+enum TracingMode {
+ kTracingInactive,
+ kMethodTracingActive,
+ kSampleProfilingActive,
+};
+
class Trace : public instrumentation::InstrumentationListener {
public:
enum TraceFlag {
@@ -58,7 +64,7 @@
Locks::trace_lock_);
static void Stop() LOCKS_EXCLUDED(Locks::trace_lock_);
static void Shutdown() LOCKS_EXCLUDED(Locks::trace_lock_);
- static bool IsMethodTracingActive() LOCKS_EXCLUDED(Locks::trace_lock_);
+ static TracingMode GetMethodTracingMode() LOCKS_EXCLUDED(Locks::trace_lock_);
bool UseWallClock();
bool UseThreadCpuClock();