Put BacktraceOffline code into a separate library.

BacktraceOffline is the only code that uses libLLVM. Create
a new shared library, backtrace_offline.so, that references this
so that including libbacktrace.so doesn't wind up pulling in libLLVM.

Change-Id: I90c502d833f6c464c3810dffde52a0c6da241cce
This commit is contained in:
Christopher Ferris 2016-01-25 16:17:48 -08:00
parent 506d233e7a
commit 8540216028
3 changed files with 40 additions and 26 deletions

View File

@ -48,7 +48,6 @@ libbacktrace_src_files := \
Backtrace.cpp \
BacktraceCurrent.cpp \
BacktraceMap.cpp \
BacktraceOffline.cpp \
BacktracePtrace.cpp \
thread_utils.c \
ThreadEntry.cpp \
@ -61,25 +60,6 @@ libbacktrace_shared_libraries := \
liblog \
libunwind \
# Use shared llvm library on device to save space.
libbacktrace_shared_libraries_target := \
libLLVM \
# Use static llvm libraries on host to remove dependency on 32-bit llvm shared library
# which is not included in the prebuilt.
libbacktrace_static_libraries_host := \
libcutils \
libLLVMObject \
libLLVMBitReader \
libLLVMMC \
libLLVMMCParser \
libLLVMCore \
libLLVMSupport \
libbacktrace_ldlibs_host := \
-lpthread \
-lrt \
module := libbacktrace
module_tag := optional
build_type := target
@ -97,6 +77,40 @@ build_target := STATIC_LIBRARY
include $(LOCAL_PATH)/Android.build.mk
libbacktrace_static_libraries :=
#-------------------------------------------------------------------------
# The libbacktrace_offline shared library.
#-------------------------------------------------------------------------
libbacktrace_offline_src_files := \
BacktraceOffline.cpp \
libbacktrace_offline_shared_libraries := \
libbacktrace \
liblog \
libunwind \
# Use shared llvm library on device to save space.
libbacktrace_offline_shared_libraries_target := \
libLLVM \
# Use static llvm libraries on host to remove dependency on 32-bit llvm shared library
# which is not included in the prebuilt.
libbacktrace_offline_static_libraries_host := \
libLLVMObject \
libLLVMBitReader \
libLLVMMC \
libLLVMMCParser \
libLLVMCore \
libLLVMSupport \
module := libbacktrace_offline
module_tag := optional
build_type := target
build_target := SHARED_LIBRARY
include $(LOCAL_PATH)/Android.build.mk
build_type := host
libbacktrace_multilib := both
include $(LOCAL_PATH)/Android.build.mk
#-------------------------------------------------------------------------
# The libbacktrace_test library needed by backtrace_test.
#-------------------------------------------------------------------------
@ -141,6 +155,7 @@ backtrace_test_ldlibs_host := \
backtrace_test_shared_libraries := \
libbacktrace_test \
libbacktrace \
libbacktrace_offline \
libbase \
libcutils \
libunwind \

View File

@ -28,7 +28,6 @@
#include <backtrace/BacktraceMap.h>
#include "BacktraceLog.h"
#include "BacktraceOffline.h"
#include "thread_utils.h"
#include "UnwindCurrent.h"
#include "UnwindPtrace.h"
@ -149,8 +148,3 @@ Backtrace* Backtrace::Create(pid_t pid, pid_t tid, BacktraceMap* map) {
return new UnwindPtrace(pid, tid, map);
}
}
Backtrace* Backtrace::CreateOffline(pid_t pid, pid_t tid, BacktraceMap* map,
const backtrace_stackinfo_t& stack, bool cache_file) {
return new BacktraceOffline(pid, tid, map, stack, cache_file);
}

View File

@ -659,3 +659,8 @@ static DebugFrameInfo* ReadDebugFrameFromFile(const std::string& filename) {
}
return nullptr;
}
Backtrace* Backtrace::CreateOffline(pid_t pid, pid_t tid, BacktraceMap* map,
const backtrace_stackinfo_t& stack, bool cache_file) {
return new BacktraceOffline(pid, tid, map, stack, cache_file);
}