From 2362310b546b157eeee352e72b1585363002d662 Mon Sep 17 00:00:00 2001 From: Yabin Cui Date: Wed, 13 Apr 2016 21:28:54 -0700 Subject: simpleperf: use libbacktrace_offline static library. Device may not have libbacktrace_offline shared library, so always using libbacktrace_offline static library. Use simpleperf namespace to avoid conflicts with ThreadEntry in libbacktrace. Bug: 28152982 Change-Id: Ia2cdbee3b28556c790ccd7b061a801ed96f9b97c (cherry picked from commit 040f7b4c62ce49f0af0746640e94d415764262cd) --- simpleperf/Android.mk | 46 +++++++++++++++++++++++++--------------------- simpleperf/dwarf_unwind.h | 4 ++++ simpleperf/thread_tree.cpp | 4 ++++ simpleperf/thread_tree.h | 8 ++++++++ 4 files changed, 41 insertions(+), 21 deletions(-) diff --git a/simpleperf/Android.mk b/simpleperf/Android.mk index add39abf..9eb4be8a 100644 --- a/simpleperf/Android.mk +++ b/simpleperf/Android.mk @@ -32,22 +32,17 @@ include $(LLVM_ROOT_PATH)/llvm.mk simpleperf_shared_libraries_target := \ libbacktrace \ - libbacktrace_offline \ + libunwind \ libbase \ liblog \ libutils \ libLLVM \ simpleperf_static_libraries_target := \ - libziparchive \ - -simpleperf_shared_libraries_host_linux := \ - libbacktrace \ libbacktrace_offline \ - -simpleperf_shared_libraries_host_darwin := libLLVM - -simpleperf_shared_libraries_host_windows := libLLVM + liblzma \ + libziparchive \ + libz \ simpleperf_static_libraries_host := \ libziparchive-host \ @@ -55,6 +50,19 @@ simpleperf_static_libraries_host := \ liblog \ libz \ libutils \ + libLLVMObject \ + libLLVMBitReader \ + libLLVMMC \ + libLLVMMCParser \ + libLLVMCore \ + libLLVMSupport \ + +simpleperf_static_libraries_host_linux := \ + libbacktrace_offline \ + libbacktrace \ + libunwind \ + libcutils \ + liblzma \ simpleperf_ldlibs_host_linux := -lrt @@ -126,10 +134,7 @@ LOCAL_SRC_FILES_darwin := $(libsimpleperf_src_files_darwin) LOCAL_SRC_FILES_linux := $(libsimpleperf_src_files_linux) LOCAL_SRC_FILES_windows := $(libsimpleperf_src_files_windows) LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_host) -LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_host) -LOCAL_SHARED_LIBRARIES_darwin := $(simpleperf_shared_libraries_host_darwin) -LOCAL_SHARED_LIBRARIES_linux := $(simpleperf_shared_libraries_host_linux) -LOCAL_SHARED_LIBRARIES_windows := $(simpleperf_shared_libraries_host_windows) +LOCAL_STATIC_LIBRARIES_linux := $(simpleperf_static_libraries_host_linux) LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux) LOCAL_MULTILIB := first include $(LLVM_HOST_BUILD_MK) @@ -162,11 +167,10 @@ LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux) LOCAL_CPPFLAGS_windows := $(simpleperf_cppflags_host_windows) LOCAL_SRC_FILES := main.cpp LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_host) -LOCAL_SHARED_LIBRARIES_darwin := $(simpleperf_shared_libraries_host_darwin) -LOCAL_SHARED_LIBRARIES_linux := $(simpleperf_shared_libraries_host_linux) -LOCAL_SHARED_LIBRARIES_windows := $(simpleperf_shared_libraries_host_windows) +LOCAL_STATIC_LIBRARIES_linux := $(simpleperf_static_libraries_host_linux) LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux) LOCAL_MULTILIB := first +include $(LLVM_HOST_BUILD_MK) include $(BUILD_HOST_EXECUTABLE) @@ -215,11 +219,10 @@ LOCAL_CPPFLAGS_windows := $(simpleperf_cppflags_host_windows) LOCAL_SRC_FILES := $(simpleperf_unit_test_src_files) LOCAL_SRC_FILES_linux := $(simpleperf_unit_test_src_files_linux) LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_host) -LOCAL_SHARED_LIBRARIES_darwin := $(simpleperf_shared_libraries_host_darwin) -LOCAL_SHARED_LIBRARIES_linux := $(simpleperf_shared_libraries_host_linux) -LOCAL_SHARED_LIBRARIES_windows := $(simpleperf_shared_libraries_host_windows) +LOCAL_STATIC_LIBRARIES_linux := $(simpleperf_static_libraries_host_linux) LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux) LOCAL_MULTILIB := first +include $(LLVM_HOST_BUILD_MK) include $(BUILD_HOST_NATIVE_TEST) @@ -248,9 +251,10 @@ LOCAL_CPPFLAGS := $(simpleperf_cppflags_host) LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux) LOCAL_SRC_FILES := $(simpleperf_cpu_hotplug_test_src_files) LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_host) -LOCAL_SHARED_LIBRARIES_linux := $(simpleperf_shared_libraries_host_linux) +LOCAL_STATIC_LIBRARIES_linux := $(simpleperf_static_libraries_host_linux) LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux) LOCAL_MULTILIB := first +include $(LLVM_HOST_BUILD_MK) include $(BUILD_HOST_NATIVE_TEST) @@ -283,7 +287,7 @@ LOCAL_CPPFLAGS := $(simpleperf_cppflags_host) -DIN_CTS_TEST LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux) LOCAL_SRC_FILES := $(libsimpleperf_cts_test_src_files) LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_host) -LOCAL_SHARED_LIBRARIES_linux := $(simpleperf_shared_libraries_host_linux) +LOCAL_STATIC_LIBRARIES_linux := $(simpleperf_static_libraries_host_linux) LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux) LOCAL_MULTILIB := both include $(LLVM_HOST_BUILD_MK) diff --git a/simpleperf/dwarf_unwind.h b/simpleperf/dwarf_unwind.h index 4e3ffd1b..6982b05d 100644 --- a/simpleperf/dwarf_unwind.h +++ b/simpleperf/dwarf_unwind.h @@ -21,7 +21,11 @@ #include "perf_regs.h" +namespace simpleperf { struct ThreadEntry; +} + +using ThreadEntry = simpleperf::ThreadEntry; std::vector UnwindCallChain(ArchType arch, const ThreadEntry& thread, const RegSet& regs, const std::vector& stack); diff --git a/simpleperf/thread_tree.cpp b/simpleperf/thread_tree.cpp index 31348749..daf3ff52 100644 --- a/simpleperf/thread_tree.cpp +++ b/simpleperf/thread_tree.cpp @@ -24,6 +24,8 @@ #include "perf_event.h" #include "record.h" +namespace simpleperf { + bool MapComparator::operator()(const MapEntry* map1, const MapEntry* map2) const { if (map1->start_addr != map2->start_addr) { return map1->start_addr < map2->start_addr; @@ -207,6 +209,8 @@ void ThreadTree::Clear() { user_dso_tree_.clear(); } +} // namespace simpleperf + void BuildThreadTree(const Record& record, ThreadTree* thread_tree) { if (record.header.type == PERF_RECORD_MMAP) { const MmapRecord& r = *static_cast(&record); diff --git a/simpleperf/thread_tree.h b/simpleperf/thread_tree.h index 3652bbcc..de10138a 100644 --- a/simpleperf/thread_tree.h +++ b/simpleperf/thread_tree.h @@ -25,6 +25,8 @@ #include "dso.h" +namespace simpleperf { + struct MapEntry { uint64_t start_addr; uint64_t len; @@ -97,6 +99,12 @@ class ThreadTree { Symbol unknown_symbol_; }; +} // namespace simpleperf + +using MapEntry = simpleperf::MapEntry; +using ThreadEntry = simpleperf::ThreadEntry; +using ThreadTree = simpleperf::ThreadTree; + struct Record; void BuildThreadTree(const Record& record, ThreadTree* thread_tree); -- cgit v1.2.3