diff options
author | Alexander Potapenko <glider@google.com> | 2012-08-15 13:58:24 +0000 |
---|---|---|
committer | Alexander Potapenko <glider@google.com> | 2012-08-15 13:58:24 +0000 |
commit | 5cfa30e23c092df3265b1ff9e205f36874a2e194 (patch) | |
tree | 6f9970a5fe9f8a13ddee1412e808ec12dc3a1f9e | |
parent | 71d47fff39a675607933e84071b2e342cc989a0a (diff) | |
download | compiler-rt-5cfa30e23c092df3265b1ff9e205f36874a2e194.tar.gz |
Pass offset of the frame address within the binary to addr2line instead of the absolute address.
Fixes the problem with -PIE binaries.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@161947 91177308-0d34-0410-b5e6-96231b3b80d8
-rwxr-xr-x | lib/asan/scripts/asan_symbolize.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/asan/scripts/asan_symbolize.py b/lib/asan/scripts/asan_symbolize.py index e89fcd4fb..5fe87e049 100755 --- a/lib/asan/scripts/asan_symbolize.py +++ b/lib/asan/scripts/asan_symbolize.py @@ -38,11 +38,14 @@ class LinuxSymbolizer(Symbolizer): self.binary = binary self.pipe = self.open_addr2line() def open_addr2line(self): - return subprocess.Popen(["addr2line", "-f", "-e", self.binary], + cmd = ["addr2line", "-f", "-e", self.binary] + if DEBUG: + print ' '.join(cmd) + return subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE) - def symbolize(self, prefix, addr, _): + def symbolize(self, prefix, addr, offset): try: - print >> self.pipe.stdin, addr + print >> self.pipe.stdin, offset function_name = self.pipe.stdout.readline().rstrip() file_name = self.pipe.stdout.readline().rstrip() except Exception: @@ -140,7 +143,7 @@ def BreakpadSymbolizerFactory(addr, binary): if suffix: filename = binary + suffix if os.access(filename, os.F_OK): - return BreakpadSymbolizer(addr, filename) + return BreakpadSymbolizer(filename) return None @@ -175,10 +178,12 @@ class BreakpadSymbolizer(Symbolizer): self.files.append(' '.join(fragments[2:])) elif fragments[0] == 'PUBLIC': self.symbols[int(fragments[1], 16)] = ' '.join(fragments[3:]) - elif fragments[0] == 'CFI': + elif fragments[0] in ['CFI', 'STACK']: pass elif fragments[0] == 'FUNC': cur_function_addr = int(fragments[1], 16) + if not cur_function_addr in self.symbols.keys(): + self.symbols[cur_function_addr] = ' '.join(fragments[4:]) else: # Line starting with an address. addr = int(fragments[0], 16) @@ -210,8 +215,10 @@ class BreakpadSymbolizer(Symbolizer): res = self.get_sym_file_line(int(offset, 16)) if res: function_name, file_name, line_no = res - return "%s%s in %s %s:%d" % ( + result = "%s%s in %s %s:%d" % ( prefix, addr, function_name, file_name, line_no) + print result + return result else: return None |