From patchwork Tue May 17 20:09:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 68012 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp2268895qge; Tue, 17 May 2016 13:10:10 -0700 (PDT) X-Received: by 10.66.237.35 with SMTP id uz3mr4805370pac.145.1463515810796; Tue, 17 May 2016 13:10:10 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zu17si6553451pab.174.2016.05.17.13.10.10; Tue, 17 May 2016 13:10:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751411AbcEQUKH (ORCPT + 29 others); Tue, 17 May 2016 16:10:07 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:34001 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750711AbcEQUKF (ORCPT ); Tue, 17 May 2016 16:10:05 -0400 Received: by mail-pf0-f194.google.com with SMTP id 145so2846431pfz.1 for ; Tue, 17 May 2016 13:10:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=2Br+qccVlShg1r2nk+eT4s1tO/STuH6C0W5Ql72TNw0=; b=BbZ6kgGyn5TO6eWgAu6J1cYp/kAQc8hcLzsU1bQ4OlJFJRySIRgtonJEyi5d0Hh4eq 34rR5sBMbVhT8sp1isP1StbCQKFeAV3xza7fgI06GasXRngNE8LuA1II8Toae4geUtPi D0aNpybkGTAU8Coy3tYzXmwIXT/MD0riOipS8kR5qbkWtZ3u3QaoBossA9/mUUl8X4LL qWyf3V0kVsGfUuOo2lWeRFYlnfr3n9DJ4B9IcjqxypEaeB6eVRtvDHC5zsJA8/V9HA3F v9PUN98GK06LfRcAqckMmYZ/xDNbia4dlYGeBtCwpp+8DolTRfqe73YVVki0kmQkhwjA iDEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=2Br+qccVlShg1r2nk+eT4s1tO/STuH6C0W5Ql72TNw0=; b=TpyBsmxkMkAoBWizl5zQ9okm3KaPtrqxCvgaZ26W6t4PtVW7a7isIN9/8dzQxcejxu hFkBh16RZPfLkQfGt1EmN5syqZbhX0pnWcqUVCSt/RZZFBotIZXfRTaEwKyFOC8xXYAn sAX24FR/JJgLbphpev3sM54P3LZALbGNuMIVYWrOPTwsqFD51Gb94PlL2SzOVDco7RqI muwFDWGAuEWyCxjTPsaViITo0MayBNmVNf6eG8QmaCXvHsRor8mMGEyNfUEHRr3wXWdA 3kJmSeXjhV7ZSIHTCuwoUkPbA+/hX0JWF5SDZGiwIlXXvBjXvPkSQYodaSYqxo5zVqII KI2g== X-Gm-Message-State: AOPr4FWSzr1GENlfKZCZai+Nj8LPvUXlVcpSkDPFakgdKauAOjSYh/vhdyNQsZc9rJdT5g== X-Received: by 10.98.94.71 with SMTP id s68mr4869520pfb.43.1463515803900; Tue, 17 May 2016 13:10:03 -0700 (PDT) Received: from serve.minyard.net ([108.19.215.157]) by smtp.gmail.com with ESMTPSA id lq10sm6714550pab.36.2016.05.17.13.10.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 May 2016 13:10:02 -0700 (PDT) Received: from t430.minyard.net (unknown [IPv6:2001:470:b8f6:1b:118:a7b5:8fb4:e42a]) by serve.minyard.net (Postfix) with ESMTPA id 8DD17129C; Tue, 17 May 2016 15:10:01 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id C41C6300551; Tue, 17 May 2016 15:10:00 -0500 (CDT) From: minyard@acm.org To: kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Vivek Goyal , Haren Myneni , Baoquan He Cc: Corey Minyard Subject: [PATCH] kdump: Fix dmesg gdbmacro to work with record based printk Date: Tue, 17 May 2016 15:09:54 -0500 Message-Id: <1463515794-1599-1-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Corey Minyard Change 7ff9554bb578ba02166071d2d487b7fc7d860d62 introduced a record based printk buffer. Modify gdbmacros.txt to parse this new structure so dmesg will work properly. Signed-off-by: Corey Minyard --- Documentation/kdump/gdbmacros.txt | 93 ++++++++++++++++++++++++++++++++++----- 1 file changed, 82 insertions(+), 11 deletions(-) -- 2.7.4 diff --git a/Documentation/kdump/gdbmacros.txt b/Documentation/kdump/gdbmacros.txt index 9b9b454..7c590fb 100644 --- a/Documentation/kdump/gdbmacros.txt +++ b/Documentation/kdump/gdbmacros.txt @@ -178,21 +178,92 @@ document trapinfo address the kernel panicked. end +define dump_log_idx + set $idx = $arg0 + if ($argc > 1) + set $prev_flags = $arg1 + else + set $prev_flags = 0 + end + set $msg = ((struct printk_log *) (log_buf + $idx)) + set $prefix = 1 + set $newline = 1 + set $log = log_buf + $idx + sizeof(*$msg) -define dmesg - set $i = 0 - set $end_idx = (log_end - 1) & (log_buf_len - 1) + # prev & LOG_CONT && !(msg->flags & LOG_PREIX) + if (($prev_flags & 8) && !($msg->flags & 4)) + set $prefix = 0 + end + + # msg->flags & LOG_CONT + if ($msg->flags & 8) + # (prev & LOG_CONT && !(prev & LOG_NEWLINE)) + if (($prev_flags & 8) && !($prev_flags & 2)) + set $prefix = 0 + end + # (!(msg->flags & LOG_NEWLINE)) + if (!($msg->flags & 2)) + set $newline = 0 + end + end + + if ($prefix) + printf "[%5lu.%06lu] ", $msg->ts_nsec / 1000000000, $msg->ts_nsec % 1000000000 + end + if ($msg->text_len != 0) + eval "printf \"%%%d.%ds\", $log", $msg->text_len, $msg->text_len + end + if ($newline) + printf "\n" + end + if ($msg->dict_len > 0) + set $dict = $log + $msg->text_len + set $idx = 0 + set $line = 1 + while ($idx < $msg->dict_len) + if ($line) + printf " " + set $line = 0 + end + set $c = $dict[$idx] + if ($c == '\0') + printf "\n" + set $line = 1 + else + if ($c < ' ' || $c >= 127 || $c == '\\') + printf "\\x%02x", $c + else + printf "%c", $c + end + end + set $idx = $idx + 1 + end + printf "\n" + end +end +document dump_log_idx + Dump a single log given its index in the log buffer. The first + parameter is the index into log_buf, the second is optional and + specified the previous log buffer's flags, used for properly + formatting continued lines. +end - while ($i < logged_chars) - set $idx = (log_end - 1 - logged_chars + $i) & (log_buf_len - 1) +define dmesg + set $i = log_first_idx + set $end_idx = log_first_idx + set $prev_flags = 0 - if ($idx + 100 <= $end_idx) || \ - ($end_idx <= $idx && $idx + 100 < log_buf_len) - printf "%.100s", &log_buf[$idx] - set $i = $i + 100 + while (1) + set $msg = ((struct printk_log *) (log_buf + $i)) + if ($msg->len == 0) + set $i = 0 else - printf "%c", log_buf[$idx] - set $i = $i + 1 + dump_log_idx $i $prev_flags + set $i = $i + $msg->len + set $prev_flags = $msg->flags + end + if ($i == $end_idx) + loop_break end end end