Commit d6da884c authored by Jan Kiene's avatar Jan Kiene
Browse files

unify classes more

parent e5511cf2
Loading
Loading
Loading
Loading
Loading
+20 −16
Original line number Diff line number Diff line
@@ -2,16 +2,17 @@ import pandas as pd
from xml.etree import ElementTree
import argparse
from enum import Enum
from typing import List
from typing import List, Tuple
import re


class SanitizerError:
    SUMMARY_ID = ""

    def __init__(self, traceback: str, commandlines: dict) -> None:
        self.traceback = traceback
        self.commandlines = commandlines
        self.location = ""
        self.type = ""
        self.type, self.location = self.parse_type_and_location(traceback)

    def __hash__(self):
        return hash(self.location)
@@ -33,28 +34,31 @@ class SanitizerError:
            **self.commandlines,
        }

    def parse_type_and_location(self, traceback) -> Tuple[str, str]:
        last_line = traceback.split("\n")[-1].strip()
        assert last_line.startswith(f"SUMMARY: {self.SUMMARY_ID}")
        m = re.match(
            r"SUMMARY: " + self.SUMMARY_ID + r": ([a-z-]*) (.*\/.*\.[ch]:\d+:\d+) in",
            last_line,
        )
        assert m is not None

        type, location = m.groups()
        return type, location


class UsanError(SanitizerError):
    SUMMARY_ID = "UndefinedBehaviorSanitizer"

    def __init__(self, traceback: str, commandlines: dict):
        super().__init__(traceback, commandlines)
        err_lines = traceback.split("\n")
        self.location = err_lines[0].strip().split(": runtime error:")[0]
        self.type = "undefined-behaviour"


class MsanError(SanitizerError):
    SUMMARY_ID = "MemorySanitizer"

    def __init__(self, traceback: str, commandlines: dict) -> None:
        super().__init__(traceback, commandlines)
        err_lines = traceback.split("\n")
        last_line = err_lines[-1].strip()
        assert last_line.startswith("SUMMARY: MemorySanitizer: ")
        m = re.search(
            r"^SUMMARY: MemorySanitizer: ([a-z-]*) .*\/(.*\.[ch]:\d+:\d+) in .+$",
            traceback,
        )
        assert m is not None

        self.type, self.location = m.groups()


def parse_commandlines_from_sysout(sysout: str) -> dict: