diff options
author | Alexey Samsonov <samsonov@google.com> | 2012-07-31 11:51:26 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2012-07-31 11:51:26 +0000 |
commit | 41df5652a12b45998111ca2aca09fc0c63674684 (patch) | |
tree | aac785fb2681e0aa0b889bd8c1034a846bd36131 /lib/sanitizer_common/sanitizer_symbolizer.cc | |
parent | b0bb7fb31301ee9ac9cf41f21d3a19987dc30609 (diff) |
[Sanitizer] Wrapper around llvm::DIContext from LLVM DebugInfo library. If a macro SANITIZER_USES_LLVM_LIBS is defined (by default it is not), then sanitizer runtime includes llvm headers and tries to use LLVM libs for in-process symbolization. To make it functional, we have to link with these LLVM libs - either pass them to linker from Clang driver, or link them into static ASan runtime when we build it.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@161045 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_symbolizer.cc')
-rw-r--r-- | lib/sanitizer_common/sanitizer_symbolizer.cc | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/lib/sanitizer_common/sanitizer_symbolizer.cc b/lib/sanitizer_common/sanitizer_symbolizer.cc index 85eb0764f..5bfc957af 100644 --- a/lib/sanitizer_common/sanitizer_symbolizer.cc +++ b/lib/sanitizer_common/sanitizer_symbolizer.cc @@ -7,13 +7,11 @@ // //===----------------------------------------------------------------------===// // -// This is a stub for LLVM-based symbolizer. // This file is shared between AddressSanitizer and ThreadSanitizer -// run-time libraries. See sanitizer.h for details. +// run-time libraries. See sanitizer_symbolizer.h for details. //===----------------------------------------------------------------------===// #include "sanitizer_common.h" -#include "sanitizer_placement_new.h" #include "sanitizer_procmaps.h" #include "sanitizer_symbolizer.h" @@ -50,6 +48,7 @@ ModuleDIContext::ModuleDIContext(const char *module_name, uptr base_address) { n_ranges_ = 0; mapped_addr_ = 0; mapped_size_ = 0; + dwarf_context_ = 0; } void ModuleDIContext::addAddressRange(uptr beg, uptr end) { @@ -71,29 +70,25 @@ void ModuleDIContext::getAddressInfo(AddressInfo *info) { info->module = internal_strdup(full_name_); info->module_offset = info->address - base_address_; if (mapped_addr_ == 0) - CreateDIContext(); - // FIXME: Use the actual debug info context here. - info->function = 0; - info->file = 0; - info->line = 0; - info->column = 0; + CreateDWARFContext(); + getLineInfoFromContext(dwarf_context_, info); } -void ModuleDIContext::CreateDIContext() { +void ModuleDIContext::CreateDWARFContext() { mapped_addr_ = (uptr)MapFileToMemory(full_name_, &mapped_size_); CHECK(mapped_addr_); DWARFSection debug_info; DWARFSection debug_abbrev; - DWARFSection debug_line; DWARFSection debug_aranges; + DWARFSection debug_line; DWARFSection debug_str; FindDWARFSection(mapped_addr_, "debug_info", &debug_info); FindDWARFSection(mapped_addr_, "debug_abbrev", &debug_abbrev); - FindDWARFSection(mapped_addr_, "debug_line", &debug_line); FindDWARFSection(mapped_addr_, "debug_aranges", &debug_aranges); + FindDWARFSection(mapped_addr_, "debug_line", &debug_line); FindDWARFSection(mapped_addr_, "debug_str", &debug_str); - // FIXME: Construct actual debug info context using mapped_addr, - // mapped_size and pointers to DWARF sections in memory. + dwarf_context_ = getDWARFContext(debug_info, debug_abbrev, debug_aranges, + debug_line, debug_str); } class Symbolizer { |