summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_symbolizer.h
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2013-10-31 21:44:07 +0000
committerAlexey Samsonov <samsonov@google.com>2013-10-31 21:44:07 +0000
commit66d91e3356a0c4d7aff3beaaaff3e87bbaec805c (patch)
treef8c46cf4e4982459fff87bc1d2e3f3e4b3c5c0ce /lib/sanitizer_common/sanitizer_symbolizer.h
parentb8a141f3783d796eabf45fabff82f3e08244e338 (diff)
downloadcompiler-rt-66d91e3356a0c4d7aff3beaaaff3e87bbaec805c.tar.gz
compiler-rt-66d91e3356a0c4d7aff3beaaaff3e87bbaec805c.tar.bz2
compiler-rt-66d91e3356a0c4d7aff3beaaaff3e87bbaec805c.tar.xz
[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.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/sanitizer_common/sanitizer_symbolizer.h b/lib/sanitizer_common/sanitizer_symbolizer.h
index f4191328..886fed20 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