diff --git a/lldb/examples/python/crashlog.py b/lldb/examples/python/crashlog.py --- a/lldb/examples/python/crashlog.py +++ b/lldb/examples/python/crashlog.py @@ -549,8 +549,6 @@ def __init__(self, debugger, path, options): self.path = os.path.expanduser(path) self.options = options - # List of DarwinImages sorted by their index. - self.images = list() self.crashlog = CrashLog(debugger, self.path, self.options.verbose) @abc.abstractmethod @@ -645,7 +643,6 @@ darwin_image.arch = json_image["arch"] if path == self.crashlog.process_path: self.crashlog.process_arch = darwin_image.arch - self.images.append(darwin_image) self.crashlog.images.append(darwin_image) def parse_main_image(self, json_data): @@ -672,7 +669,7 @@ location = 0 if "symbolLocation" in json_frame and json_frame["symbolLocation"]: location = int(json_frame["symbolLocation"]) - image = self.images[image_id] + image = self.crashlog.images[image_id] image.symbols[symbol] = { "name": symbol, "type": "code", @@ -780,7 +777,7 @@ if frame_offset: description += " + " + frame_offset frame_offset_value = int(frame_offset, 0) - for image in self.images: + for image in self.crashlog.images: if image.identifier == frame_img_name: image.symbols[frame_symbol] = { "name": frame_symbol, @@ -829,6 +826,7 @@ if "reportNotes" in json_data: self.crashlog.errors = json_data["reportNotes"] + class TextCrashLogParser(CrashLogParser): parent_process_regex = re.compile(r"^Parent Process:\s*(.*)\[(\d+)\]") thread_state_regex = re.compile(r"^Thread \d+ crashed with") @@ -888,7 +886,6 @@ ) exception_extra_regex = re.compile(r"^Exception\s+.*:\s+(.*)") - class CrashLogParseMode: NORMAL = 0 THREAD = 1 @@ -1209,7 +1206,6 @@ "address": symbol["address"] - int(img_lo, 0), } - self.images.append(image) self.crashlog.images.append(image) return True else: diff --git a/lldb/examples/python/symbolication.py b/lldb/examples/python/symbolication.py --- a/lldb/examples/python/symbolication.py +++ b/lldb/examples/python/symbolication.py @@ -501,7 +501,7 @@ class Symbolicator: - def __init__(self, debugger=None, target=None, images=list()): + def __init__(self, debugger=None, target=None, images=None): """A class the represents the information needed to symbolicate addresses in a program. @@ -510,7 +510,8 @@ """ self.debugger = debugger self.target = target - self.images = images # a list of images to be used when symbolicating + # a list of images to be used when symbolicating + self.images = images if images else list() self.addr_mask = 0xFFFFFFFFFFFFFFFF @classmethod