diff options
author | Alexey Samsonov <samsonov@google.com> | 2013-10-31 21:44:07 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2013-10-31 21:44:07 +0000 |
commit | 66d91e3356a0c4d7aff3beaaaff3e87bbaec805c (patch) | |
tree | f8c46cf4e4982459fff87bc1d2e3f3e4b3c5c0ce /lib/sanitizer_common/sanitizer_symbolizer.h | |
parent | b8a141f3783d796eabf45fabff82f3e08244e338 (diff) | |
download | compiler-rt-66d91e3356a0c4d7aff3beaaaff3e87bbaec805c.tar.gz |
[Sanitizer] Add Symbolizer::AddHooks() and use it in TSan and MSan.
Summary:
TSan and MSan need to know if interceptor was called by the
user code or by the symbolizer and use pre- and post-symbolization hooks
for that. Make Symbolizer class responsible for calling these hooks instead.
This would ensure the hooks are only called when necessary (during
in-process symbolization, they are not needed for out-of-process) and
save specific sanitizers from tracing all places in the code where symbolization
will be performed.
Reviewers: eugenis, dvyukov
Reviewed By: eugenis
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D2067
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@193807 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_symbolizer.h')
-rw-r--r-- | lib/sanitizer_common/sanitizer_symbolizer.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/sanitizer_common/sanitizer_symbolizer.h b/lib/sanitizer_common/sanitizer_symbolizer.h index f41913281..886fed20d 100644 --- a/lib/sanitizer_common/sanitizer_symbolizer.h +++ b/lib/sanitizer_common/sanitizer_symbolizer.h @@ -105,6 +105,16 @@ class Symbolizer { } virtual void PrepareForSandboxing() {} + // Allow user to install hooks that would be called before/after Symbolizer + // does the actual file/line info fetching. Specific sanitizers may need this + // to distinguish system library calls made in user code from calls made + // during in-process symbolization. + typedef void (*StartSymbolizationHook)(); + typedef void (*EndSymbolizationHook)(); + // May be called at most once. + void AddHooks(StartSymbolizationHook start_hook, + EndSymbolizationHook end_hook); + private: /// Platform-specific function for creating a Symbolizer object. static Symbolizer *PlatformInit(const char *path_to_external); @@ -116,7 +126,19 @@ class Symbolizer { static StaticSpinMutex init_mu_; protected: + Symbolizer(); + static LowLevelAllocator symbolizer_allocator_; + + StartSymbolizationHook start_hook_; + EndSymbolizationHook end_hook_; + class SymbolizerScope { + public: + explicit SymbolizerScope(const Symbolizer *sym); + ~SymbolizerScope(); + private: + const Symbolizer *sym_; + }; }; } // namespace __sanitizer |