summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_symbolizer.cc
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2012-06-01 06:11:13 +0000
committerAlexey Samsonov <samsonov@google.com>2012-06-01 06:11:13 +0000
commit2f7d82687c99d468aa845ed68d88910710cc51ec (patch)
treefc735d0802e4893990e0083b90ad117da9896899 /lib/sanitizer_common/sanitizer_symbolizer.cc
parentf037f565b2e02878ceb6e7b49647e814e2990ef5 (diff)
downloadcompiler-rt-2f7d82687c99d468aa845ed68d88910710cc51ec.tar.gz
compiler-rt-2f7d82687c99d468aa845ed68d88910710cc51ec.tar.bz2
compiler-rt-2f7d82687c99d468aa845ed68d88910710cc51ec.tar.xz
Stub files for common symbolizer for AddressSanitizer and ThreadSanitizer tools.
It is an analogue of addr2line utility and should allow to map instruction address to a location in source code at run-time. It should use debug information (in DWARF) in a binary, and hopefully it would be possible to re-use code from llvm/DebugInfo/DIContext.h git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@157806 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_symbolizer.cc')
-rw-r--r--lib/sanitizer_common/sanitizer_symbolizer.cc56
1 files changed, 56 insertions, 0 deletions
diff --git a/lib/sanitizer_common/sanitizer_symbolizer.cc b/lib/sanitizer_common/sanitizer_symbolizer.cc
new file mode 100644
index 00000000..0b23418c
--- /dev/null
+++ b/lib/sanitizer_common/sanitizer_symbolizer.cc
@@ -0,0 +1,56 @@
+//===-- symbolizer.cc -------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This is a stub for LLVM-based symbolizer.
+// This file is shared between AddressSanitizer and ThreadSanitizer
+// run-time libraries. See sanitizer.h for details.
+//===----------------------------------------------------------------------===//
+
+// WARNING: Avoid using library functions - see comments in symbolizer.h.
+#include "sanitizer_symbolizer.h"
+// FIXME: replace library malloc/free with internal_malloc/internal_free
+// that would be provided by ASan/TSan run-time libraries.
+#if defined(__linux__)
+# include <malloc.h>
+#elif defined(__APPLE__)
+# include <malloc/malloc.h>
+#endif
+
+namespace __sanitizer {
+
+void AddressInfo::Clear() {
+ free(module);
+ free(function);
+ free(file);
+}
+
+void AddressInfoList::Clear() {
+ AddressInfoList *cur = this;
+ while (cur) {
+ cur->info.Clear();
+ AddressInfoList *nxt = cur->next;
+ free(cur);
+ cur = nxt;
+ }
+}
+
+AddressInfoList* SymbolizeCode(uptr address) {
+ AddressInfoList *list = (AddressInfoList*)malloc(sizeof(AddressInfoList));
+ list->next = 0;
+ list->info.address = address;
+ list->info.module = 0;
+ list->info.module_offset = 0;
+ list->info.function = 0;
+ list->info.file = 0;
+ list->info.line = 0;
+ list->info.column = 0;
+ return list;
+}
+
+} // namespace __sanitizer