From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-fw-2101.amazon.com (smtp-fw-2101.amazon.com [72.21.196.25]) by mx.groups.io with SMTP id smtpd.web10.3205.1653619431365736140 for ; Thu, 26 May 2022 19:43:52 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=QAwnrHcS; spf=pass (domain: amazon.de, ip: 72.21.196.25, mailfrom: prvs=139655964=graf@amazon.de) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1653619432; x=1685155432; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MCJEs8pYM9WDetF8ckYFMttxbYNKDYYMWVwhNQhmdMg=; b=QAwnrHcSiFfpawLqifMmiF8AV+Tgl6ZsskpF98EzEbkJu8m1A5k0Q0bb TJbO33sGnFsmOhSUGJP+qAj9x8YqBhz4YZHH+SCP1C6RrPCIc3OIc6+ao emvAcrHoR2SkZu2/1AG8qkZ7CEyugTNOTy0D5jDF0Y4d+Fl81vqaJHbsd g=; X-IronPort-AV: E=Sophos;i="5.91,254,1647302400"; d="scan'208";a="202322444" Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-iad-1a-a31e1d63.us-east-1.amazon.com) ([10.43.8.2]) by smtp-border-fw-2101.iad2.amazon.com with ESMTP; 27 May 2022 02:43:52 +0000 Received: from EX13MTAUWC001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1a-a31e1d63.us-east-1.amazon.com (Postfix) with ESMTPS id 738D79169D; Fri, 27 May 2022 02:43:50 +0000 (UTC) Received: from EX13D20UWC001.ant.amazon.com (10.43.162.244) by EX13MTAUWC001.ant.amazon.com (10.43.162.135) with Microsoft SMTP Server (TLS) id 15.0.1497.36; Fri, 27 May 2022 02:43:49 +0000 Received: from u79c5a0a55de558.ant.amazon.com (10.43.161.125) by EX13D20UWC001.ant.amazon.com (10.43.162.244) with Microsoft SMTP Server (TLS) id 15.0.1497.36; Fri, 27 May 2022 02:43:47 +0000 From: "Alexander Graf" To: CC: Ard Biesheuvel , Leif Lindholm , Dandan Bi , Zhichao Gao , Liming Gao Subject: [PATCH 09/12] Scripts: Add bootlog decyphering script Date: Fri, 27 May 2022 04:43:14 +0200 Message-ID: <20220527024317.13476-10-graf@amazon.com> X-Mailer: git-send-email 2.28.0.394.ge197136389 In-Reply-To: <20220527024317.13476-1-graf@amazon.com> References: <20220527024317.13476-1-graf@amazon.com> MIME-Version: 1.0 X-Originating-IP: [10.43.161.125] X-ClientProxiedBy: EX13D06UWC001.ant.amazon.com (10.43.162.91) To EX13D20UWC001.ant.amazon.com (10.43.162.244) Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit The bootlog itself is a binary data structure that is not immediately human readable. This commit adds a python script to generate a human readable form of it with Linux dmesg like time stamp information. The script can take multiple log sources and collate them into a single output, making it easier to correlate messages. Signed-off-by: Alexander Graf --- BaseTools/Scripts/ShowDebugLog.py | 88 +++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100755 BaseTools/Scripts/ShowDebugLog.py diff --git a/BaseTools/Scripts/ShowDebugLog.py b/BaseTools/Scripts/ShowDebugLog.py new file mode 100755 index 0000000000..f99b4b02f7 --- /dev/null +++ b/BaseTools/Scripts/ShowDebugLog.py @@ -0,0 +1,88 @@ +#!/usr/bin/python3 +## @file +# Dump Bootlog files +# +# Copyright (c) 2022, Amazon Development Center Germany GmbH. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# + +from __future__ import print_function + +VersionNumber = '0.1' +__copyright__ = "Copyright (c) 2022, Amazon Development Center Germany GmbH. All rights reserved.." + +import argparse +import os +import sys +import struct + +class DebugLog: + """Parses a Bootlog blob and provides a string representation + """ + + def __init__(self, log): + self.entries = [] + off = 0 + + signature, self.producer, extraheadertype, extraheadersize, msgextraheadersize, lastbyte, self.tickspersecond = struct.unpack_from('<4s4sHBBLQ', log) + if signature != b'BTLH': + raise Exception("File has incorrect signature. Expected b'BTLH'. Found %s." % signature) + if len(log) < lastbyte: + raise Exception("File smaller than total log contents (%d < %d). It was probably truncated." % (len(log), lastbyte)) + off = 4 + 4 + 2 + 1 + 1 + 4 + 8 + extraheadersize + + while off < lastbyte: + off = off + msgextraheadersize + time, = struct.unpack_from('