Add systrace output for dlopen calls
Bug: http://b/27195126
Test: manual: adb shell atrace -t 5 bionic
and run bionic-unit-tests --gtest_filter=dl*:Dl*
Change-Id: Ib2bad794e571b89bd1f52c9e0de642c2092e5c21
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 7b16cc3..a05cd3b 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -1861,6 +1861,9 @@
void* do_dlopen(const char* name, int flags,
const android_dlextinfo* extinfo,
const void* caller_addr) {
+ std::string trace_prefix = std::string("dlopen: ") + (name == nullptr ? "(nullptr)" : name);
+ ScopedTrace trace(trace_prefix.c_str());
+ ScopedTrace loading_trace((trace_prefix + " - loading and linking").c_str());
soinfo* const caller = find_containing_library(caller_addr);
android_namespace_t* ns = get_caller_namespace(caller);
@@ -1937,6 +1940,8 @@
ProtectedDataGuard guard;
soinfo* si = find_library(ns, translated_name, flags, extinfo, caller);
+ loading_trace.End();
+
if (si != nullptr) {
void* handle = si->to_handle();
LD_LOG(kLogDlopen,