Пример #1
0
    def _hash_backtrace(self, backtrace):
        result = []

        for key in ["function_name", "fingerprint", "build_id_offset"]:
            hashbase = []

            threads_sane = []
            for thread in backtrace:
                threads_sane.append(all(key in f for f in thread["frames"]))

            if not all(threads_sane):
                continue

            for thread in backtrace:
                if "crash_thread" in thread and thread["crash_thread"]:
                    hashbase.append("Crash Thread")
                else:
                    hashbase.append("Thread")

                for frame in thread["frames"]:
                    if "build_id" in frame:
                        build_id = frame["build_id"]
                    else:
                        build_id = None

                    hashbase.append("  {0} @ {1} ({2})".format(
                        frame[key],
                        frame["file_name"].encode("ascii",
                                                  "ignore"), build_id))

            result.append(hash_list(hashbase))

        return result
Пример #2
0
    def _hash_koops(self, koops, taintflags=None, skip_unreliable=False):
        if taintflags is None:
            taintflags = []

        if skip_unreliable:
            frames = [f for f in koops if f["reliable"]]
        else:
            frames = koops

        if not frames:
            return None

        hashbase = list(taintflags)
        for frame in frames:
            if not "module_name" in frame:
                module = "vmlinux"
            else:
                module = frame["module_name"]

            if "address" not in frame:
                address = 0
            else:
                address = frame["address"]


            hashbase.append("{0} {1}+{2}/{3} @ {4}"
                            .format(address, frame["function_name"],
                                    frame["function_offset"],
                                    frame["function_length"], module))

        return hash_list(hashbase)
Пример #3
0
    def _hash_koops(self, koops, taintflags=None, skip_unreliable=False):
        if taintflags is None:
            taintflags = []

        if skip_unreliable:
            frames = [f for f in koops if f["reliable"]]
        else:
            frames = koops

        if not frames:
            return None

        hashbase = list(taintflags)
        for frame in frames:
            if not "module_name" in frame:
                module = "vmlinux"
            else:
                module = frame["module_name"]

            if "address" not in frame:
                address = 0
            else:
                address = frame["address"]


            hashbase.append("{0} {1}+{2}/{3} @ {4}"
                            .format(address, frame["function_name"],
                                    frame["function_offset"],
                                    frame["function_length"], module))

        return hash_list(hashbase)
Пример #4
0
    def _hash_backtrace(self, backtrace):
        result = []

        for key in ["function_name", "fingerprint", "build_id_offset"]:
            hashbase = []

            threads_sane = []
            for thread in backtrace:
                threads_sane.append(all(key in f for f in thread["frames"]))

            if not all(threads_sane):
                continue

            for thread in backtrace:
                if "crash_thread" in thread and thread["crash_thread"]:
                    hashbase.append("Crash Thread")
                else:
                    hashbase.append("Thread")

                for frame in thread["frames"]:
                    if "build_id" in frame:
                        build_id = frame["build_id"]
                    else:
                        build_id = None

                    hashbase.append("  {0} @ {1} ({2})"
                                    .format(frame[key],
                                            frame["file_name"].encode("ascii",
                                                                      "ignore"),
                                            build_id))

            result.append(hash_list(hashbase))

        return result
Пример #5
0
    def test_hash_list_encoding(self):
        """
        hash_list and hashlib.sha1 respectively shouldn't fail if
        passed unicode literals
        """

        self.assertEqual(hash_list([u"♥", u"Bl\xe9"]),
                         'b4661b6dd570d2aeb4c90477f2c0cc4e3582fa10')
Пример #6
0
    def test_hash_list_encoding(self):
        """
        hash_list and hashlib.sha1 respectively shouldn't fail if
        passed unicode literals
        """

        self.assertEqual(hash_list([u"♥", u"Bl\xe9"]),
                         'b4661b6dd570d2aeb4c90477f2c0cc4e3582fa10')
Пример #7
0
    def _hash_traceback(self, traceback):
        hashbase = []
        for frame in traceback:
            if "special_function" in frame:
                funcname = "<{0}>".format(frame["special_function"])
            else:
                funcname = frame["function_name"]

            hashbase.append("{0} @ {1} + {2}".format(funcname,
                                                     frame["file_name"],
                                                     frame["file_line"]))

        return hash_list(hashbase)
Пример #8
0
    def _hash_traceback(self, traceback):
        hashbase = []
        for frame in traceback:
            if "special_function" in frame:
                funcname = "<{0}>".format(frame["special_function"])
            else:
                funcname = frame["function_name"]

            hashbase.append("{0} @ {1} + {2}".format(funcname,
                                                     frame["file_name"],
                                                     frame["file_line"]))

        return hash_list(hashbase)
Пример #9
0
    def _hash_backtrace(self,
                        db_backtrace,
                        hashbase=None,
                        offset=False) -> str:
        if hashbase is None:
            hashbase = []

        crashthreads = [t for t in db_backtrace.threads if t.crashthread]
        if not crashthreads:
            raise FafError("No crash thread found")

        if len(crashthreads) > 1:
            raise FafError("Multiple crash threads found")

        frames = [f for f in crashthreads[0].frames if not f.inlined][:16]

        hasnames = all([
            f.symbolsource.symbol is not None
            and f.symbolsource.symbol.name is not None
            and f.symbolsource.symbol.name != "??" for f in frames
        ])
        hashashes = all([f.symbolsource.hash is not None for f in frames])

        # use function names if available
        if hasnames:
            # also hash offset for reports that use it as line numbers
            # these reports always have function names
            if offset:
                hashbase.extend([
                    "{0} @ {1} + {2}".format(f.symbolsource.symbol.name,
                                             f.symbolsource.path,
                                             f.symbolsource.offset)
                    for f in frames
                ])
            else:
                hashbase.extend([
                    "{0} @ {1}".format(f.symbolsource.symbol.name,
                                       f.symbolsource.path) for f in frames
                ])
        # fallback to hashes
        elif hashashes:
            hashbase.extend([
                "{0} @ {1}".format(f.symbolsource.hash, f.symbolsource.path)
                for f in frames
            ])
        else:
            raise FafError("either function names or hashes are required")

        return hash_list(hashbase)
Пример #10
0
Файл: python.py Проект: abrt/faf
    def hash_ureport(self, ureport):
        hashbase = [ureport["component"]]

        for i, frame in enumerate(ureport["stacktrace"]):
            # Instance of 'PythonProblem' has no 'hashframes' member
            # pylint: disable-msg=E1101
            if i >= self.hashframes:
                break

            if "special_function" in frame:
                funcname = "<{0}>".format(frame["special_function"])
            else:
                funcname = frame["function_name"]

            hashbase.append("{0} @ {1} + {2}".format(funcname,
                                                     frame["file_name"],
                                                     frame["file_line"]))
        return hash_list(hashbase)
Пример #11
0
    def hash_ureport(self, ureport):
        hashbase = [ureport["component"]]
        hashbase.extend(ureport["taint_flags"])

        for i, frame in enumerate(ureport["frames"]):
            # Instance of 'KerneloopsProblem' has no 'hashframes' member
            # pylint: disable-msg=E1101
            if i >= self.hashframes:
                break

            if not "module_name" in frame:
                module = "vmlinux"
            else:
                module = frame["module_name"]

            hashbase.append("{0} @ {1}".format(frame["function_name"], module))

        return hash_list(hashbase)
Пример #12
0
    def hash_ureport(self, ureport):
        hashbase = [ureport["component"]]

        for i, frame in enumerate(ureport["stacktrace"]):
            # Instance of 'PythonProblem' has no 'hashframes' member
            # pylint: disable-msg=E1101
            if i >= self.hashframes:
                break

            if "special_function" in frame:
                funcname = "<{0}>".format(frame["special_function"])
            else:
                funcname = frame["function_name"]

            hashbase.append("{0} @ {1} + {2}".format(funcname,
                                                     frame["file_name"],
                                                     frame["file_line"]))
        return hash_list(hashbase)
Пример #13
0
    def _hash_backtrace(self, threads):
        hashbase = []

        for thread in threads:
            hashbase.append("Thread")

            for frame in thread["frames"]:
                # Instance of 'JavaProblem' has no 'hashframes' member
                # pylint: disable-msg=E1101

                if "class_path" in frame:
                    hashbase.append("{0} @ {1}".format(frame["name"],
                                                       frame["class_path"]))
                    continue

                hashbase.append(frame["name"])

        return hash_list(hashbase)
Пример #14
0
    def _hash_backtrace(self, threads):
        hashbase = []

        for thread in threads:
            hashbase.append("Thread")

            for frame in thread["frames"]:
                # Instance of 'JavaProblem' has no 'hashframes' member
                # pylint: disable-msg=E1101

                if "class_path" in frame:
                    hashbase.append("{0} @ {1}".format(frame["name"],
                                                       frame["class_path"]))
                    continue

                hashbase.append(frame["name"])

        return hash_list(hashbase)
Пример #15
0
    def hash_ureport(self, ureport):
        hashbase = [ureport["component"]]
        hashbase.extend(ureport["taint_flags"])

        for i, frame in enumerate(ureport["frames"]):
            # Instance of 'KerneloopsProblem' has no 'hashframes' member
            # pylint: disable-msg=E1101
            if i >= self.hashframes:
                break

            if not "module_name" in frame:
                module = "vmlinux"
            else:
                module = frame["module_name"]

            hashbase.append("{0} @ {1}".format(frame["function_name"], module))

        return hash_list(hashbase)
Пример #16
0
    def hash_ureport(self, ureport):
        hashbase = [ureport["component"]]

        # at the moment we only send crash thread
        # we may need to identify the crash thread in the future
        for i, frame in enumerate(ureport["threads"][0]["frames"]):
            # Instance of 'JavaProblem' has no 'hashframes' member
            # pylint: disable-msg=E1101
            if i >= self.hashframes:
                break

            if "class_path" in frame:
                hashbase.append("{0} @ {1}".format(frame["name"],
                                                   frame["class_path"]))
                continue

            hashbase.append(frame["name"])

        return hash_list(hashbase)
Пример #17
0
    def hash_ureport(self, ureport):
        hashbase = [ureport["component"]]

        # at the moment we only send crash thread
        # we may need to identify the crash thread in the future
        for i, frame in enumerate(ureport["threads"][0]["frames"]):
            # Instance of 'JavaProblem' has no 'hashframes' member
            # pylint: disable-msg=E1101
            if i >= self.hashframes:
                break

            if "class_path" in frame:
                hashbase.append("{0} @ {1}".format(frame["name"],
                                                   frame["class_path"]))
                continue

            hashbase.append(frame["name"])

        return hash_list(hashbase)
Пример #18
0
    def hash_ureport(self, ureport):
        crashthread = self._get_crash_thread(ureport["stacktrace"])
        hashbase = [ureport["component"]]

        if all("function_name" in f for f in crashthread):
            key = "function_name"
        elif all("fingerprint" in f for f in crashthread):
            key = "fingerprint"
        else:
            key = "build_id_offset"

        for i, frame in enumerate(crashthread):
            # Instance of 'CoredumpProblem' has no 'hashframes' member
            # pylint: disable-msg=E1101
            if i >= self.hashframes:
                break

            hashbase.append("{0} @ {1}".format(frame[key], frame["file_name"]))

        return hash_list(hashbase)
Пример #19
0
    def hash_ureport(self, ureport):
        crashthread = self._get_crash_thread(ureport["stacktrace"])
        hashbase = [ureport["component"]]

        if all("function_name" in f for f in crashthread):
            key = "function_name"
        elif all("fingerprint" in f for f in crashthread):
            key = "fingerprint"
        else:
            key = "build_id_offset"

        for i, frame in enumerate(crashthread):
            # Instance of 'CoredumpProblem' has no 'hashframes' member
            # pylint: disable-msg=E1101
            if i >= self.hashframes:
                break

            hashbase.append("{0} @ {1}".format(
                frame[key],
                frame["file_name"].encode("ascii", "ignore")))

        return hash_list(hashbase)
Пример #20
0
 def test_hash_list(self):
     self.assertEqual(hash_list(["aa", "bb"]),
                      'f67229713c9dcb92b3388cc8d254c866221404f3')
Пример #21
0
 def test_hash_list(self):
     self.assertEqual(hash_list(["aa", "bb"]),
                      'f67229713c9dcb92b3388cc8d254c866221404f3')