[TTC-3] Fix asan_symbolize.py output frame numbers. 08/139808/8
authorMikhail Kashkarov <m.kashkarov@partner.samsung.com>
Thu, 20 Jul 2017 11:19:13 +0000 (14:19 +0300)
committerDongkyun Son <dongkyun.s@samsung.com>
Thu, 3 Aug 2017 00:28:20 +0000 (00:28 +0000)
If input line already symbolized and has format
'#0 0x7f6e35cf2e45 in func foo:46' - fix internal frame number.

packaging/
    * asan_symbolized.py (have_line_to_symbolized): New function.

Change-Id: I2c52c58f9e2d6dfce709e87dee2abd62b642bcad

packaging/asan_symbolize.py [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 235a273..f37530b
@@ -626,13 +626,29 @@ class SymbolizationLoop(object):
   def process_line_echo(self, line):
     return [line.rstrip()]
 
-  def process_line_posix(self, line):
-    self.current_line = line.rstrip()
-    #0 0x7f6e35cf2e45  (/blah/foo.so+0x11fe45)
+  def have_line_to_symbolize(self, line):
+    #0 0x7f6e35cf2e45 in func (/blah/foo.so+0x11fe45)
     stack_trace_line_format = (
         '^( *#([0-9]+) *)(0x[0-9a-f]+)( *in [^/]+)? *\((.*)\+(0x[0-9a-f]+)\)')
     match = re.match(stack_trace_line_format, line)
     if not match:
+      # If already symbolized (format below) - fix given frame number
+      #0 0x7f6e35cf2e45 in func foo:46
+      stack_trace_line_format_symbolized = (
+          '^( *#([0-9]+) *)(0x[0-9a-f]+)( *in [^/]+)? *(.*)\:([0-9]+)')
+      match_symbolized = re.match(stack_trace_line_format_symbolized, line);
+      if match_symbolized:
+          # Frame number from line
+          match_frame_number = match_symbolized.group(2)
+          if (self.frame_no != int(match_frame_number)):
+              self.current_line = re.sub(match_frame_number, str(self.frame_no), line, count=1)
+          self.frame_no += 1
+    return match
+
+  def process_line_posix(self, line):
+    self.current_line = line.rstrip()
+    match = self.have_line_to_symbolize(line)
+    if not match:
       return [self.current_line]
     if DEBUG:
       print line