1 //===-- sanitizer_libignore.h -----------------------------------*- C++ -*-===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // LibIgnore allows to ignore all interceptors called from a particular set
9 // of dynamic libraries. LibIgnore can be initialized with several templates
10 // of names of libraries to be ignored. It finds code ranges for the libraries;
11 // and checks whether the provided PC value belongs to the code ranges.
13 //===----------------------------------------------------------------------===//
15 #ifndef SANITIZER_LIBIGNORE_H
16 #define SANITIZER_LIBIGNORE_H
18 #include "sanitizer_internal_defs.h"
19 #include "sanitizer_common.h"
20 #include "sanitizer_atomic.h"
21 #include "sanitizer_mutex.h"
23 namespace __sanitizer
{
27 explicit LibIgnore(LinkerInitialized
);
29 // Must be called during initialization.
30 void AddIgnoredLibrary(const char *name_templ
);
32 // Must be called after a new dynamic library is loaded.
33 void OnLibraryLoaded(const char *name
);
35 // Must be called after a dynamic library is unloaded.
36 void OnLibraryUnloaded();
38 // Checks whether the provided PC belongs to one of the ignored libraries.
39 bool IsIgnored(uptr pc
) const;
45 char *real_name
; // target of symlink
54 static const uptr kMaxLibs
= 128;
57 atomic_uintptr_t loaded_count_
;
58 LibCodeRange code_ranges_
[kMaxLibs
];
65 // Disallow copying of LibIgnore objects.
66 LibIgnore(const LibIgnore
&); // not implemented
67 void operator = (const LibIgnore
&); // not implemented
70 inline bool LibIgnore::IsIgnored(uptr pc
) const {
71 const uptr n
= atomic_load(&loaded_count_
, memory_order_acquire
);
72 for (uptr i
= 0; i
< n
; i
++) {
73 if (pc
>= code_ranges_
[i
].begin
&& pc
< code_ranges_
[i
].end
)
79 } // namespace __sanitizer
81 #endif // SANITIZER_LIBIGNORE_H