lewisje / address-sanitizer

Automatically exported from code.google.com/p/address-sanitizer
0 stars 0 forks source link

asan_symbolize.py should try to demangle C++ names #145

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Currently, the asan_symbolize.py script doesn't demangle C++ filenames by 
itself. I quickly rewrote the print_symbolized_lines function to do this in 
case the c++filt command is available:

  def print_symbolized_lines(self, symbolized_lines):
    if not symbolized_lines:
      print self.current_line
    else:
      cppfilt = None
      try:
        cppfilt = subprocess.Popen(["c++filt"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
      except OSError:
        # c++filt not available, ignore error
        pass

      for symbolized_frame in symbolized_lines:
        frame = symbolized_frame.rstrip()
        if cppfilt != None:
          stdout, stderr = cppfilt.communicate(frame)
          frame = stdout
        print '    #' + str(self.frame_no) + ' ' + frame
        self.frame_no += 1

Not sure if you want to add something similar, but it works well for me and 
makes automation a little easier :)

Original issue reported on code.google.com by decoder...@googlemail.com on 25 Jan 2013 at 2:01

GoogleCodeExporter commented 9 years ago
we usually simply run 
  ./a.out 2>&1 | asan_symbolize.py| c++filt 
Isn't that enough? 

The new symbolizer is coming, so asan_symbolize.py will eventually get 
deprecated. 
https://code.google.com/p/address-sanitizer/wiki/CallStack

Original comment by konstant...@gmail.com on 25 Jan 2013 at 2:04

GoogleCodeExporter commented 9 years ago
People often don't know that they should run it like that and I got this 
question more than once already. I think in most, if not all cases, there is no 
benefit in showing the mangled trace, because it is at most useful for 
debugging problems in the symbolizer, but not for reading the actual trace. If 
that is the case, then the symbolizer should demangle on its own by default.

But if the new symbolizer is coming soon anyway, then I hope it'll be able to 
do this and we don't need to change the python script right now :)

Original comment by decoder...@googlemail.com on 25 Jan 2013 at 2:06

GoogleCodeExporter commented 9 years ago
Note filtering the whole ASan logs through c++filt sometimes produces silly 
results. We must demangle only function names with c++filt in asan_symbolize.py 
or llvm-symbolizer.

Original comment by gli...@chromium.org on 25 Jan 2013 at 2:23

GoogleCodeExporter commented 9 years ago
FTR: Using a pipe for c++filt is unnecessary on Linux - you can additionally 
pass "-C" to addr2line process or "--demangle" to llvm-symbolizer.

Original comment by samso...@google.com on 25 Jan 2013 at 3:28

GoogleCodeExporter commented 9 years ago
http://llvm.org/viewvc/llvm-project?rev=175429&view=rev adds flag -d to do what
samsonov@ suggested in comment #4

This does not seem applicable to atos on MacOS

Original comment by konstant...@gmail.com on 18 Feb 2013 at 8:04

GoogleCodeExporter commented 9 years ago
Adding Project:AddressSanitizer as part of GitHub migration.

Original comment by ramosian.glider@gmail.com on 30 Jul 2015 at 9:13