forked from OSchip/llvm-project
parent
1d4145380e
commit
5f7048b396
|
@ -173,7 +173,6 @@ RTL_HDR=asan_allocator.h \
|
|||
asan_interceptors.h \
|
||||
asan_interface.h \
|
||||
asan_lock.h \
|
||||
asan_mac.h \
|
||||
asan_mapping.h \
|
||||
asan_procmaps.h \
|
||||
asan_stack.h \
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include "asan_allocator.h"
|
||||
#include "asan_interface.h"
|
||||
#include "asan_internal.h"
|
||||
#include "asan_mac.h"
|
||||
#include "asan_mapping.h"
|
||||
#include "asan_stack.h"
|
||||
#include "asan_stats.h"
|
||||
|
@ -697,14 +696,6 @@ void InitializeAsanInterceptors() {
|
|||
// Intercept threading-related functions
|
||||
#if !defined(_WIN32)
|
||||
CHECK(INTERCEPT_FUNCTION(pthread_create));
|
||||
# if defined(__APPLE__)
|
||||
// We don't need to intercept pthread_workqueue_additem_np() to support the
|
||||
// libdispatch API, but it helps us to debug the unsupported functions. Let's
|
||||
// intercept it only during verbose runs.
|
||||
if (FLAG_v >= 2) {
|
||||
CHECK(INTERCEPT_FUNCTION(pthread_workqueue_additem_np));
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// Some Windows-specific interceptors.
|
||||
|
@ -714,12 +705,7 @@ void InitializeAsanInterceptors() {
|
|||
|
||||
// Some Mac-specific interceptors.
|
||||
#if defined(__APPLE__)
|
||||
CHECK(INTERCEPT_FUNCTION(dispatch_async_f));
|
||||
CHECK(INTERCEPT_FUNCTION(dispatch_sync_f));
|
||||
CHECK(INTERCEPT_FUNCTION(dispatch_after_f));
|
||||
CHECK(INTERCEPT_FUNCTION(dispatch_barrier_async_f));
|
||||
CHECK(INTERCEPT_FUNCTION(dispatch_group_async_f));
|
||||
|
||||
InitializeMacGCDInterceptors();
|
||||
// http://code.google.com/p/address-sanitizer/issues/detail?id=10
|
||||
PatchCFStringCreateCopy();
|
||||
#endif
|
||||
|
|
|
@ -46,6 +46,11 @@ int64_t internal_simple_strtoll(const char *nptr, char **endptr, int base);
|
|||
|
||||
void InitializeAsanInterceptors();
|
||||
|
||||
#if defined(__APPLE__)
|
||||
void InitializeMacGCDInterceptors();
|
||||
void PatchCFStringCreateCopy();
|
||||
#endif // __APPLE__
|
||||
|
||||
} // namespace __asan
|
||||
|
||||
#endif // ASAN_INTERCEPTORS_H
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
|
||||
#ifdef __APPLE__
|
||||
|
||||
#include "asan_mac.h"
|
||||
|
||||
#include "asan_interceptors.h"
|
||||
#include "asan_internal.h"
|
||||
#include "asan_mapping.h"
|
||||
|
@ -429,6 +427,38 @@ mach_error_t __interception_deallocate_island(void *ptr) {
|
|||
// The implementation details are at
|
||||
// http://libdispatch.macosforge.org/trac/browser/trunk/src/queue.c
|
||||
|
||||
typedef void* pthread_workqueue_t;
|
||||
typedef void* pthread_workitem_handle_t;
|
||||
|
||||
typedef void* dispatch_group_t;
|
||||
typedef void* dispatch_queue_t;
|
||||
typedef uint64_t dispatch_time_t;
|
||||
typedef void (*dispatch_function_t)(void *block);
|
||||
typedef void* (*worker_t)(void *block);
|
||||
|
||||
// A wrapper for the ObjC blocks used to support libdispatch.
|
||||
typedef struct {
|
||||
void *block;
|
||||
dispatch_function_t func;
|
||||
int parent_tid;
|
||||
} asan_block_context_t;
|
||||
|
||||
extern "C" {
|
||||
void dispatch_async_f(dispatch_queue_t dq, void *ctxt,
|
||||
dispatch_function_t func);
|
||||
void dispatch_sync_f(dispatch_queue_t dq, void *ctxt,
|
||||
dispatch_function_t func);
|
||||
void dispatch_after_f(dispatch_time_t when, dispatch_queue_t dq, void *ctxt,
|
||||
dispatch_function_t func);
|
||||
void dispatch_barrier_async_f(dispatch_queue_t dq, void *ctxt,
|
||||
dispatch_function_t func);
|
||||
void dispatch_group_async_f(dispatch_group_t group, dispatch_queue_t dq,
|
||||
void *ctxt, dispatch_function_t func);
|
||||
int pthread_workqueue_additem_np(pthread_workqueue_t workq,
|
||||
void *(*workitem_func)(void *), void * workitem_arg,
|
||||
pthread_workitem_handle_t * itemhandlep, unsigned int *gencountp);
|
||||
} // extern "C"
|
||||
|
||||
extern "C"
|
||||
void asan_dispatch_call_block_and_release(void *block) {
|
||||
GET_STACK_TRACE_HERE(kStackTraceMax);
|
||||
|
@ -613,6 +643,19 @@ INTERCEPTOR(CFStringRef, CFStringCreateCopy, CFAllocatorRef alloc,
|
|||
}
|
||||
|
||||
namespace __asan {
|
||||
void InitializeMacGCDInterceptors() {
|
||||
CHECK(INTERCEPT_FUNCTION(dispatch_async_f));
|
||||
CHECK(INTERCEPT_FUNCTION(dispatch_sync_f));
|
||||
CHECK(INTERCEPT_FUNCTION(dispatch_after_f));
|
||||
CHECK(INTERCEPT_FUNCTION(dispatch_barrier_async_f));
|
||||
CHECK(INTERCEPT_FUNCTION(dispatch_group_async_f));
|
||||
// We don't need to intercept pthread_workqueue_additem_np() to support the
|
||||
// libdispatch API, but it helps us to debug the unsupported functions. Let's
|
||||
// intercept it only during verbose runs.
|
||||
if (FLAG_v >= 2) {
|
||||
CHECK(INTERCEPT_FUNCTION(pthread_workqueue_additem_np));
|
||||
}
|
||||
}
|
||||
void PatchCFStringCreateCopy() {
|
||||
// Normally CFStringCreateCopy should not copy constant CF strings.
|
||||
// Replacing the default CFAllocator causes constant strings to be copied
|
||||
|
|
|
@ -1,86 +0,0 @@
|
|||
//===-- asan_mac.h ----------------------------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file is a part of AddressSanitizer, an address sanity checker.
|
||||
//
|
||||
// ASan-private header for asan_mac.cc
|
||||
//===----------------------------------------------------------------------===//
|
||||
#ifdef __APPLE__
|
||||
|
||||
#ifndef ASAN_MAC_H
|
||||
#define ASAN_MAC_H
|
||||
|
||||
#include "asan_interceptors.h"
|
||||
|
||||
typedef void* pthread_workqueue_t;
|
||||
typedef void* pthread_workitem_handle_t;
|
||||
|
||||
typedef void* dispatch_group_t;
|
||||
typedef void* dispatch_queue_t;
|
||||
typedef uint64_t dispatch_time_t;
|
||||
typedef void (*dispatch_function_t)(void *block);
|
||||
typedef void* (*worker_t)(void *block);
|
||||
|
||||
namespace __asan {
|
||||
void PatchCFStringCreateCopy();
|
||||
} // namespace __asan
|
||||
|
||||
DECLARE_REAL_AND_INTERCEPTOR(void, dispatch_async_f, dispatch_queue_t dq,
|
||||
void *ctxt,
|
||||
dispatch_function_t func);
|
||||
DECLARE_REAL_AND_INTERCEPTOR(void, dispatch_sync_f, dispatch_queue_t dq,
|
||||
void *ctxt,
|
||||
dispatch_function_t func);
|
||||
DECLARE_REAL_AND_INTERCEPTOR(void, dispatch_after_f, dispatch_time_t when,
|
||||
dispatch_queue_t dq,
|
||||
void *ctxt,
|
||||
dispatch_function_t func);
|
||||
DECLARE_REAL_AND_INTERCEPTOR(void, dispatch_barrier_async_f,
|
||||
dispatch_queue_t dq,
|
||||
void *ctxt,
|
||||
dispatch_function_t func);
|
||||
DECLARE_REAL_AND_INTERCEPTOR(void, dispatch_group_async_f,
|
||||
dispatch_group_t group,
|
||||
dispatch_queue_t dq,
|
||||
void *ctxt,
|
||||
dispatch_function_t func);
|
||||
DECLARE_REAL_AND_INTERCEPTOR(int, pthread_workqueue_additem_np,
|
||||
pthread_workqueue_t workq,
|
||||
void *(*workitem_func)(void *),
|
||||
void * workitem_arg,
|
||||
pthread_workitem_handle_t * itemhandlep,
|
||||
unsigned int *gencountp);
|
||||
|
||||
// A wrapper for the ObjC blocks used to support libdispatch.
|
||||
typedef struct {
|
||||
void *block;
|
||||
dispatch_function_t func;
|
||||
int parent_tid;
|
||||
} asan_block_context_t;
|
||||
|
||||
|
||||
extern "C" {
|
||||
void dispatch_async_f(dispatch_queue_t dq, void *ctxt,
|
||||
dispatch_function_t func);
|
||||
void dispatch_sync_f(dispatch_queue_t dq, void *ctxt,
|
||||
dispatch_function_t func);
|
||||
void dispatch_after_f(dispatch_time_t when, dispatch_queue_t dq, void *ctxt,
|
||||
dispatch_function_t func);
|
||||
void dispatch_barrier_async_f(dispatch_queue_t dq, void *ctxt,
|
||||
dispatch_function_t func);
|
||||
void dispatch_group_async_f(dispatch_group_t group, dispatch_queue_t dq,
|
||||
void *ctxt, dispatch_function_t func);
|
||||
int pthread_workqueue_additem_np(pthread_workqueue_t workq,
|
||||
void *(*workitem_func)(void *), void * workitem_arg,
|
||||
pthread_workitem_handle_t * itemhandlep, unsigned int *gencountp);
|
||||
}
|
||||
|
||||
#endif // ASAN_MAC_H
|
||||
|
||||
#endif // __APPLE__
|
Loading…
Reference in New Issue