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 remembers all "called_from_lib" suppressions
10 // from the provided SuppressionContext; 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_suppressions.h"
21 #include "sanitizer_atomic.h"
22 #include "sanitizer_mutex.h"
24 namespace __sanitizer
{
28 explicit LibIgnore(LinkerInitialized
);
30 // Fetches all "called_from_lib" suppressions from the SuppressionContext.
31 void Init(const SuppressionContext
&supp
);
33 // Must be called after a new dynamic library is loaded.
34 void OnLibraryLoaded(const char *name
);
36 // Must be called after a dynamic library is unloaded.
37 void OnLibraryUnloaded();
39 // Checks whether the provided PC belongs to one of the ignored libraries.
40 bool IsIgnored(uptr pc
) const;
46 char *real_name
; // target of symlink
55 static const uptr kMaxLibs
= 128;
58 atomic_uintptr_t loaded_count_
;
59 LibCodeRange code_ranges_
[kMaxLibs
];
66 // Disallow copying of LibIgnore objects.
67 LibIgnore(const LibIgnore
&); // not implemented
68 void operator = (const LibIgnore
&); // not implemented
71 inline bool LibIgnore::IsIgnored(uptr pc
) const {
72 const uptr n
= atomic_load(&loaded_count_
, memory_order_acquire
);
73 for (uptr i
= 0; i
< n
; i
++) {
74 if (pc
>= code_ranges_
[i
].begin
&& pc
< code_ranges_
[i
].end
)
80 } // namespace __sanitizer
82 #endif // SANITIZER_LIBIGNORE_H