#!/usr/bin/env python3 # # Copyright (c) 2020 Intel Corporation # # SPDX-License-Identifier: Apache-2.0 import logging import struct # Note: keep sync with C code COREDUMP_HDR_ID = b'ZE' COREDUMP_HDR_VER = 2 LOG_HDR_STRUCT = " COREDUMP_HDR_VER: logger.error(f"Log version: {hdr_ver}, expected: {COREDUMP_HDR_VER}!") return False ptr_size = 2 ** ptr_size self.log_hdr = { "hdr_version": hdr_ver, "tgt_code": tgt_code, "ptr_size": ptr_size, "flags": flags, "reason": reason, } logger.info("Reason: {0}".format(reason_string(reason))) logger.info(f"Pointer size {ptr_size}") del id1, id2, hdr_ver, tgt_code, ptr_size, flags, reason while True: section_id = self.fd.read(1) if not section_id: # no more data to read break self.fd.seek(-1, 1) # go back 1 byte if section_id == COREDUMP_ARCH_HDR_ID: if not self.parse_arch_section(): logger.error("Cannot parse architecture section") return False elif section_id == COREDUMP_THREADS_META_HDR_ID: if not self.parse_threads_metadata_section(): logger.error("Cannot parse threads metadata section") return False elif section_id == COREDUMP_MEM_HDR_ID: if not self.parse_memory_section(): logger.error("Cannot parse memory section") return False else: # Unknown section in log file logger.error(f"Unknown section in log file with ID {section_id}") return False return True