class POSIXSymbolizer : public Symbolizer {
public:
- explicit POSIXSymbolizer(SymbolizerTool *symbolizer_tool)
- : Symbolizer(), symbolizer_tool_(symbolizer_tool) {}
+ explicit POSIXSymbolizer(IntrusiveList<SymbolizerTool> tools)
+ : Symbolizer(), tools_(tools) {}
SymbolizedStack *SymbolizePC(uptr addr) override {
BlockingMutexLock l(&mu_);
return res;
// Always fill data about module name and offset.
res->info.FillModuleInfo(module_name, module_offset);
- if (symbolizer_tool_) {
+ for (auto iter = Iterator(&tools_); iter.hasNext();) {
+ auto *tool = iter.next();
SymbolizerScope sym_scope(this);
- symbolizer_tool_->SymbolizePC(addr, res);
+ if (tool->SymbolizePC(addr, res)) {
+ return res;
+ }
}
return res;
}
info->Clear();
info->module = internal_strdup(module_name);
info->module_offset = module_offset;
- if (symbolizer_tool_) {
+ for (auto iter = Iterator(&tools_); iter.hasNext();) {
+ auto *tool = iter.next();
SymbolizerScope sym_scope(this);
- symbolizer_tool_->SymbolizeData(addr, info);
+ if (tool->SymbolizeData(addr, info)) {
+ return true;
+ }
}
return true;
}
}
bool CanReturnFileLineInfo() override {
- return symbolizer_tool_ != nullptr;
+ return !tools_.empty();
}
void Flush() override {
BlockingMutexLock l(&mu_);
- if (symbolizer_tool_) {
+ for (auto iter = Iterator(&tools_); iter.hasNext();) {
+ auto *tool = iter.next();
SymbolizerScope sym_scope(this);
- symbolizer_tool_->Flush();
+ tool->Flush();
}
}
const char *Demangle(const char *name) override {
BlockingMutexLock l(&mu_);
- if (symbolizer_tool_) {
+ for (auto iter = Iterator(&tools_); iter.hasNext();) {
+ auto *tool = iter.next();
SymbolizerScope sym_scope(this);
- if (const char *demangled = symbolizer_tool_->Demangle(name))
+ if (const char *demangled = tool->Demangle(name))
return demangled;
}
return DemangleCXXABI(name);
bool modules_fresh_;
BlockingMutex mu_;
- SymbolizerTool *const symbolizer_tool_; // Leaked.
+ typedef IntrusiveList<SymbolizerTool>::Iterator Iterator;
+ IntrusiveList<SymbolizerTool> tools_;
};
static SymbolizerTool *ChooseSymbolizer(LowLevelAllocator *allocator) {
}
Symbolizer *Symbolizer::PlatformInit() {
- return new(symbolizer_allocator_)
- POSIXSymbolizer(ChooseSymbolizer(&symbolizer_allocator_));
+ IntrusiveList<SymbolizerTool> list;
+ list.clear();
+ if (SymbolizerTool *tool = ChooseSymbolizer(&symbolizer_allocator_)) {
+ list.push_back(tool);
+ }
+ return new(symbolizer_allocator_) POSIXSymbolizer(list);
}
} // namespace __sanitizer