mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 23:36:40 +00:00
[asan] Android logging.
This change duplicates all ASan output to system log on Android. llvm-svn: 199887
This commit is contained in:
parent
a515896343
commit
350fe4b1af
@ -104,7 +104,7 @@ elseif(ANDROID)
|
||||
${ASAN_CFLAGS})
|
||||
set_property(TARGET clang_rt.asan-arm-android APPEND PROPERTY
|
||||
COMPILE_DEFINITIONS ${ASAN_COMMON_DEFINITIONS})
|
||||
target_link_libraries(clang_rt.asan-arm-android dl)
|
||||
target_link_libraries(clang_rt.asan-arm-android dl log)
|
||||
list(APPEND ASAN_RUNTIME_LIBRARIES clang_rt.asan-arm-android)
|
||||
else()
|
||||
# Build separate libraries for each target.
|
||||
|
@ -223,6 +223,7 @@ if(ANDROID)
|
||||
${ASAN_NOINST_TEST_SOURCES})
|
||||
set_target_compile_flags(AsanNoinstTest ${ASAN_UNITTEST_COMMON_CFLAGS})
|
||||
set_target_link_flags(AsanNoinstTest ${ASAN_UNITTEST_NOINST_LINKFLAGS})
|
||||
target_link_libraries(AsanNoinstTest log)
|
||||
|
||||
# Test with ASan instrumentation. Link with ASan dynamic runtime.
|
||||
add_executable(AsanTest
|
||||
|
@ -495,6 +495,12 @@ F IndirectExternCall(F f) {
|
||||
return f;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if SANITIZER_ANDROID
|
||||
void AndroidLogWrite(const char *buffer);
|
||||
#else
|
||||
INLINE void AndroidLogWrite(const char *buffer_unused) {}
|
||||
#endif
|
||||
} // namespace __sanitizer
|
||||
|
||||
inline void *operator new(__sanitizer::operator_new_size_type size,
|
||||
|
@ -48,6 +48,10 @@
|
||||
#include <sys/signal.h>
|
||||
#endif
|
||||
|
||||
#if SANITIZER_ANDROID
|
||||
#include <android/log.h>
|
||||
#endif
|
||||
|
||||
// <linux/time.h>
|
||||
struct kernel_timeval {
|
||||
long tv_sec;
|
||||
@ -646,6 +650,17 @@ uptr internal_clone(int (*fn)(void *), void *child_stack, int flags, void *arg,
|
||||
return res;
|
||||
}
|
||||
#endif // defined(__x86_64__)
|
||||
|
||||
#if SANITIZER_ANDROID
|
||||
// This thing is not, strictly speaking, async signal safe, but it does not seem
|
||||
// to cause any issues. Alternative is writing to log devices directly, but
|
||||
// their location and message format might change in the future, so we'd really
|
||||
// like to avoid that.
|
||||
void AndroidLogWrite(const char *buffer) {
|
||||
__android_log_write(ANDROID_LOG_INFO, NULL, buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace __sanitizer
|
||||
|
||||
#endif // SANITIZER_LINUX
|
||||
|
@ -272,6 +272,7 @@ static void SharedPrintfCode(bool append_pid, const char *format,
|
||||
break;
|
||||
}
|
||||
RawWrite(buffer);
|
||||
AndroidLogWrite(buffer);
|
||||
CallPrintfAndReportCallback(buffer);
|
||||
// If we had mapped any memory, clean up.
|
||||
if (buffer != local_buffer)
|
||||
|
@ -165,6 +165,7 @@ if(ANDROID)
|
||||
set_target_properties(SanitizerTest PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set_target_link_flags(SanitizerTest ${SANITIZER_TEST_LINK_FLAGS_COMMON})
|
||||
target_link_libraries(SanitizerTest log)
|
||||
# Add unit test to test suite.
|
||||
add_dependencies(SanitizerUnitTests SanitizerTest)
|
||||
endif()
|
||||
|
@ -111,7 +111,7 @@ ANDROID_COMMON_FLAGS := -target arm-linux-androideabi \
|
||||
-B$(LLVM_ANDROID_TOOLCHAIN_DIR)
|
||||
CFLAGS.asan-arm-android := $(CFLAGS) -fPIC -fno-builtin \
|
||||
$(ANDROID_COMMON_FLAGS) -mllvm -arm-enable-ehabi -fno-rtti
|
||||
LDFLAGS.asan-arm-android := $(LDFLAGS) $(ANDROID_COMMON_FLAGS) -ldl -lm \
|
||||
LDFLAGS.asan-arm-android := $(LDFLAGS) $(ANDROID_COMMON_FLAGS) -ldl -lm -llog \
|
||||
-Wl,-soname=libclang_rt.asan-arm-android.so -Wl,-z,defs
|
||||
|
||||
# Use our stub SDK as the sysroot to support more portable building. For now we
|
||||
|
Loading…
x
Reference in New Issue
Block a user