22
22
import argparse
23
23
import bisect
24
24
import errno
25
- import getopt
26
25
import logging
27
26
import os
28
27
import re
38
37
allow_system_symbolizer = True
39
38
force_system_symbolizer = False
40
39
40
+
41
41
# FIXME: merge the code that calls fix_filename().
42
42
def fix_filename (file_name ):
43
43
if fix_filename_patterns :
@@ -507,20 +507,29 @@ def symbolize_address(self, addr, binary, offset, arch):
507
507
assert result
508
508
return result
509
509
510
- def get_symbolized_lines (self , symbolized_lines , inc_frame_counter = True ):
510
+ def get_symbolized_lines (self , symbolized_lines ):
511
511
if not symbolized_lines :
512
- if inc_frame_counter :
513
- self . frame_no += 1
514
- return [ self . current_line ]
515
- else :
516
- assert inc_frame_counter
517
- result = []
518
- for symbolized_frame in symbolized_lines :
519
- result . append (
520
- " #%s %s" % ( str ( self .frame_no ), symbolized_frame . rstrip ())
512
+ # If it is an unparsable frame, but contains a frame counter and address
513
+ # replace the frame counter so the stack is still consistent.
514
+ unknown_stack_frame_format = r"^( *#([0-9]+) +)(0x[0-9a-f]+) +.*"
515
+ match = re . match ( unknown_stack_frame_format , self . current_line )
516
+ if match :
517
+ rewritten_line = (
518
+ self . current_line [: match . start ( 2 )]
519
+ + str ( self . frame_no )
520
+ + self .current_line [ match . end ( 2 ) :]
521
521
)
522
522
self .frame_no += 1
523
- return result
523
+ return [rewritten_line ]
524
+ # Not a frame line so don't increment the frame counter.
525
+ return [self .current_line ]
526
+ result = []
527
+ for symbolized_frame in symbolized_lines :
528
+ result .append (
529
+ " #%s %s" % (str (self .frame_no ), symbolized_frame .rstrip ())
530
+ )
531
+ self .frame_no += 1
532
+ return result
524
533
525
534
def process_logfile (self ):
526
535
self .frame_no = 0
@@ -546,8 +555,7 @@ def process_line_posix(self, line):
546
555
match = re .match (stack_trace_line_format , line )
547
556
if not match :
548
557
logging .debug ('Line "{}" does not match regex' .format (line ))
549
- # Not a frame line so don't increment the frame counter.
550
- return self .get_symbolized_lines (None , inc_frame_counter = False )
558
+ return self .get_symbolized_lines (None )
551
559
logging .debug (line )
552
560
_ , frameno_str , addr , binary , offset = match .groups ()
553
561
@@ -603,6 +611,7 @@ def _load_plugin_from_file_impl_py_gt_2(self, file_path, globals_space):
603
611
def load_plugin_from_file (self , file_path ):
604
612
logging .info ('Loading plugins from "{}"' .format (file_path ))
605
613
globals_space = dict (globals ())
614
+
606
615
# Provide function to register plugins
607
616
def register_plugin (plugin ):
608
617
logging .info ("Registering plugin %s" , plugin .get_name ())
@@ -779,9 +788,13 @@ def __str__(self):
779
788
arch = self .arch ,
780
789
start_addr = self .start_addr ,
781
790
end_addr = self .end_addr ,
782
- module_path = self .module_path
783
- if self .module_path == self .module_path_for_symbolization
784
- else "{} ({})" .format (self .module_path_for_symbolization , self .module_path ),
791
+ module_path = (
792
+ self .module_path
793
+ if self .module_path == self .module_path_for_symbolization
794
+ else "{} ({})" .format (
795
+ self .module_path_for_symbolization , self .module_path
796
+ )
797
+ ),
785
798
uuid = self .uuid ,
786
799
)
787
800
0 commit comments