summaryrefslogtreecommitdiff
path: root/runtime/monitor_android.cc
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2022-01-16 14:01:36 -0800
committerLinux Build Service Account <lnxbuild@localhost>2022-01-16 14:01:36 -0800
commit5806f26e603150889d7b7e044cd8fb685c832f4e (patch)
treee60b0a64a2b342e96f6b886ec3e2e453e494e567 /runtime/monitor_android.cc
parentaa20688e701376b1a4cfffc6284721819806cb90 (diff)
parentf9da627a42193f596d33d799bf323fced18214c5 (diff)
Merge f9da627a42193f596d33d799bf323fced18214c5 on remote branch
Change-Id: Iaf48868208da271af8b4536f089c44bf4412cc9e
Diffstat (limited to 'runtime/monitor_android.cc')
-rw-r--r--runtime/monitor_android.cc40
1 files changed, 27 insertions, 13 deletions
diff --git a/runtime/monitor_android.cc b/runtime/monitor_android.cc
index 19e1f3d2c4..f661631789 100644
--- a/runtime/monitor_android.cc
+++ b/runtime/monitor_android.cc
@@ -24,6 +24,8 @@
#include <log/log_event_list.h>
#include "art_method.h"
+#include "jni/jni_env_ext.h"
+#include "palette/palette.h"
#include "thread.h"
#define EVENT_LOG_TAG_dvm_lock_sample 20003
@@ -41,14 +43,13 @@ void Monitor::LogContentionEvent(Thread* self,
int32_t owner_line_number;
TranslateLocation(owner_method, owner_dex_pc, &owner_filename, &owner_line_number);
- // Emit the process name, <= 37 bytes.
+ // Emit the process name, <= 33 bytes.
+ char proc_name[33] = {};
{
int fd = open("/proc/self/cmdline", O_RDONLY | O_CLOEXEC);
- char procName[33];
- memset(procName, 0, sizeof(procName));
- read(fd, procName, sizeof(procName) - 1);
+ read(fd, proc_name, sizeof(proc_name) - 1);
close(fd);
- ctx << procName;
+ ctx << proc_name;
}
// Emit the sensitive thread ("main thread") status. We follow tradition that this corresponds
@@ -58,20 +59,19 @@ void Monitor::LogContentionEvent(Thread* self,
ctx << (Thread::IsSensitiveThread() ? kIsSensitive : kIsNotSensitive);
// Emit self thread name string.
- {
- std::string thread_name;
- self->GetThreadName(thread_name);
- ctx << thread_name;
- }
+ std::string thread_name;
+ self->GetThreadName(thread_name);
+ ctx << thread_name;
// Emit the wait time.
ctx << wait_ms;
const char* filename = nullptr;
+ int32_t line_number;
+ std::string method_name;
{
uint32_t pc;
ArtMethod* m = self->GetCurrentMethod(&pc);
- int32_t line_number;
TranslateLocation(m, pc, &filename, &line_number);
// Emit the source code file name.
@@ -81,7 +81,8 @@ void Monitor::LogContentionEvent(Thread* self,
ctx << line_number;
// Emit the method name.
- ctx << ArtMethod::PrettyMethod(m);
+ method_name = ArtMethod::PrettyMethod(m);
+ ctx << method_name;
}
// Emit the lock owner source code file name.
@@ -97,12 +98,25 @@ void Monitor::LogContentionEvent(Thread* self,
ctx << owner_line_number;
// Emit the owner method name.
- ctx << ArtMethod::PrettyMethod(owner_method);
+ std::string owner_method_name = ArtMethod::PrettyMethod(owner_method);
+ ctx << owner_method_name;
// Emit the sample percentage.
ctx << sample_percent;
ctx << LOG_ID_EVENTS;
+
+ // Now report to other interested parties.
+ PaletteReportLockContention(self->GetJniEnv(),
+ wait_ms,
+ filename,
+ line_number,
+ method_name.c_str(),
+ owner_filename,
+ owner_line_number,
+ owner_method_name.c_str(),
+ proc_name,
+ thread_name.c_str());
}
} // namespace art