コード例 #1
0
    def _get_hisi_log(self: any, info: any, err_i_folder: str) -> None:
        hisi_log_devid_path = os.path.join(self.collection.collect_bbox_path,
                                           Constant.DIR_BBOX,
                                           "device-" + info.dev_id)
        if not os.path.exists(hisi_log_devid_path):
            utils.print_warn_log(
                'There is no hisi log for device_id(%s), the path=%s.' %
                (info.dev_id, hisi_log_devid_path))
            return

        key_word = "device_id=%s, stream_id=%s, task_id=%s" % (
            info.dev_id, info.stream_id, info.task_id)
        cmd = ['grep', key_word, '-nr', self.collection.collect_bbox_path]
        _, data = utils.execute_command(cmd)
        regexp = r"(%s.+?(\d+)-(\d+).+%s)" % (
            self.collection.collect_bbox_path, 'ts.txt')
        ret = re.findall(regexp, data, re.M)
        if len(ret) == 0:
            utils.print_warn_log(
                "Failed to get hisi log for device_id(%s) stream_id(%s) "
                "task_id(%s), you may reboot and try again." %
                (info.dev_id, info.stream_id, info.task_id))
            return

        # find the last time(max time)
        max_hisi_file_path = self._get_max_hisi_file_path(ret)
        utils.copy_file(max_hisi_file_path,
                        os.path.join(err_i_folder, "ts.log"))
コード例 #2
0
    def copy_kernel_meta(self, report_path: str, collect_compile_path: str, kernel_name: str) -> bool:
        """
        collect local dump file:
        :param report_path: the local compile path
        :param collect_compile_path: the collect compile path
        :param kernel_name: the kernel name
        """
        match = False
        kernel_meta_path = os.path.join(self.report_path, "extra-info", "ops")
        if os.path.exists(kernel_meta_path):
            for root, _, names in os.walk(kernel_meta_path):
                for name in names:
                    if name.startswith(kernel_name):
                        src = os.path.join(root, name)
                        collect_kernel_meta_path = os.path.join(
                            collect_compile_path, "kernel_meta")
                        utils.check_path_valid(collect_kernel_meta_path, isdir=True,
                                        output=True)
                        dest = os.path.join(collect_kernel_meta_path, name)
                        utils.copy_file(src, dest)
                        match = True

        if not match:
            utils.print_warn_log('There is no kernel_meta file for "%s" in %s.'
                        % (kernel_name, report_path))
        return match
コード例 #3
0
def copy_file_to_dest(log_path: str, target: str, collect_target_path: str, report_path: str) -> None:
    """
    copy file to dest:
    :param log_path: the local log path
    :param target: the target in log
    :param collect_target_path: the collect path
    :param report_path: the local report path
    """
    match = False
    for top, _, files in os.walk(log_path):
        for name in files:
            src = os.path.join(top, name)
            dest = os.path.join(collect_target_path,
                                top[len(report_path) + 1:], name)
            utils.copy_file(src, dest)
            match = True
    if not match:
        utils.print_warn_log(
            'There is no %s file in %s.' % (target, report_path))
コード例 #4
0
    def copy_proto_file(self, report_path: str, collect_compile_path: str) -> bool:
        """
        copy proto file:
        :param report_path: the local compile path
        :param collect_compile_path: the collect compile path
        """
        match = False
        proto_path = os.path.join(self.report_path, "extra-info", "graph")
        for root, _, names in os.walk(report_path):
            for name in names:
                file_name_pattern = re.compile(Constant.BUILD_PROTO_FILE_PATTERN)
                pattern_match = file_name_pattern.match(name)
                if pattern_match:
                    src = os.path.join(root, name)
                    dest = os.path.join(collect_compile_path, name)
                    utils.copy_file(src, dest)
                    match = True

        if not match:
            utils.print_warn_log('There is no graph file in %s.' % report_path)

        return match
コード例 #5
0
    def _decompile(self: any, kernel_info: list, dir_path: str,
                   info: any) -> bool:
        kernel_name = kernel_info[0]
        kernel_meta_path = kernel_info[1]
        diff_str, err_pc = self._get_info_for_decompile(info)

        # decompile .o file
        cce_file = os.path.join(kernel_meta_path, kernel_name + ".cce")
        if os.path.exists(cce_file) is False:
            utils.print_warn_log(".cce file %s not exist" % cce_file)
        else:
            utils.copy_file(cce_file,
                            os.path.join(dir_path, kernel_name + ".cce"))

        # decompile .o file
        o_file = os.path.join(kernel_meta_path, kernel_name + ".o")
        if os.path.exists(o_file) is False:
            utils.print_warn_log(".o file %s not exist" % o_file)
            return False

        utils.copy_file(o_file, os.path.join(dir_path, kernel_name + ".o"))

        utils.copy_file(o_file, os.path.join(dir_path, kernel_name + ".json"))

        decompile_file_name = kernel_name + ".o.txt"
        decompile_file = os.path.join(dir_path, decompile_file_name)

        status = self._get_decompile_status(o_file, decompile_file)
        if status != 0:
            utils.print_error_log(
                "Failed to decompile %s, you can fix problem according to the "
                "message above, or copy %s and %s to another host and execute : "
                "%s -d -mcpu=%s %s > %s" %
                (o_file, Constant.OBJ_DUMP_FILE, o_file,
                 Constant.OBJ_DUMP_FILE, "dav-m100", kernel_name + ".o",
                 decompile_file_name))
            return False

        loc_json_file = os.path.join(kernel_meta_path,
                                     kernel_name + "_loc.json")
        self._get_cce_tbe_code_number(decompile_file, loc_json_file, err_pc,
                                      info)
        self._get_occur_before_mark(decompile_file, diff_str, info)

        return True