1 //===-- sanitizer_libignore.h -----------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // LibIgnore allows to ignore all interceptors called from a particular set
11 // of dynamic libraries. LibIgnore can be initialized with several templates
12 // of names of libraries to be ignored. It finds code ranges for the libraries;
13 // and checks whether the provided PC value belongs to the code ranges.
15 //===----------------------------------------------------------------------===//
17 #ifndef SANITIZER_LIBIGNORE_H
18 #define SANITIZER_LIBIGNORE_H
20 #include "sanitizer_internal_defs.h"
21 #include "sanitizer_common.h"
22 #include "sanitizer_atomic.h"
23 #include "sanitizer_mutex.h"
25 namespace __sanitizer {
29 explicit LibIgnore(LinkerInitialized);
31 // Must be called during initialization.
32 void AddIgnoredLibrary(const char *name_templ);
34 // Must be called after a new dynamic library is loaded.
35 void OnLibraryLoaded(const char *name);
37 // Must be called after a dynamic library is unloaded.
38 void OnLibraryUnloaded();
40 // Checks whether the provided PC belongs to one of the ignored libraries.
41 bool IsIgnored(uptr pc) const;
47 char *real_name; // target of symlink
56 static const uptr kMaxLibs = 128;
59 atomic_uintptr_t loaded_count_;
60 LibCodeRange code_ranges_[kMaxLibs];
67 // Disallow copying of LibIgnore objects.
68 LibIgnore(const LibIgnore&); // not implemented
69 void operator = (const LibIgnore&); // not implemented
72 inline bool LibIgnore::IsIgnored(uptr pc) const {
73 const uptr n = atomic_load(&loaded_count_, memory_order_acquire);
74 for (uptr i = 0; i < n; i++) {
75 if (pc >= code_ranges_[i].begin && pc < code_ranges_[i].end)
81 } // namespace __sanitizer
83 #endif // SANITIZER_LIBIGNORE_H