From patchwork Mon Aug 15 09:21:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen (ThunderTown)" X-Patchwork-Id: 12943379 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AE3C5C00140 for ; Mon, 15 Aug 2022 09:46:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=J47WvcXGPF/DxQfKXaeTP7AKB+tLlEStllmzB+Ss12M=; b=G3JykaYHZ7caAl wbCMeR33OsRJouN9egmlt6Gr6AVe7kw1KLCkn1/5zBOKPAmaM1RcmKYuTul4mlGBJTOdfHNCVVrR6 fMEFaB/kkeMxpPKcb+/J250WTkgsvrk7Ze4mWVC7vtrsdKxhV97xfjNSEqcrEh1XTD0WmjRzw6YUL L39lQAVBPf1xyIbW2X2OpsuQYd5N2pAffOHZlVftXRmbOvaPnaH7u8mBGAuoIhKWTce2JtIXH77kA H559Y3S20dJkmiITsGLkwkALtjI4FcxFZL3yGhBTJtHGqe49zmGj1+9Sl0DKzSOI47Jh+lWkqcq6F s4Y5EVcKCWopuMoem5QA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oNWf2-00E4Yu-VI; Mon, 15 Aug 2022 09:45:29 +0000 Received: from szxga02-in.huawei.com ([45.249.212.188]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oNWKF-00Dn92-Fy for linux-arm-kernel@lists.infradead.org; Mon, 15 Aug 2022 09:24:08 +0000 Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4M5pdR0rHVzXdh2; Mon, 15 Aug 2022 17:19:39 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 15 Aug 2022 17:23:49 +0800 Received: from thunder-town.china.huawei.com (10.174.178.55) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 15 Aug 2022 17:23:48 +0800 From: Zhen Lei To: Russell King , , , CC: Zhen Lei Subject: [PATCH v2] ARM: Remove the special printing format of pc and lr in __show_regs() Date: Mon, 15 Aug 2022 17:21:37 +0800 Message-ID: <20220815092137.1819-1-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220815_022405_595168_8696A40E X-CRM114-Status: UNSURE ( 9.42 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When CONFIG_KALLSYMS is set, the parsed symbols of 'pc' and 'lr' are printed. Otherwise, the raw content of 'pc' and 'lr' are printed in the lines: "PC is at" and "LR is at". If at this point they are printed in format [<%08lx>], the subsequent printing of 'pc' and 'lr' does not need to follow this format again. This allows the register list to be printed neatly. For example: CONFIG_KALLSYMS=y before: PC is at test+0x58/0x74 LR is at test+0x28/0x74 pc : [<802f3868>] lr : [<802f3838>] psr: 60000013 sp : cabc5da8 ip : 00002ff4 fp : 00000001 r10: 81951018 r9 : 00400cc0 r8 : 7ffff000 CONFIG_KALLSYMS=n after: PC is at [<802f369c>] LR is at [<802f366c>] pc : 802f369c lr : 802f366c psr: 60000013 sp : cabd9da8 ip : 00002ff4 fp : 00000001 r10: 827e6018 r9 : 00400cc0 r8 : 7ffff000 Signed-off-by: Zhen Lei --- KernelVersion: v6.0-rc1 arch/arm/kernel/process.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) v1 --> v2: On the basis of v1, print the instruction pointers in the lines of "PC is at" and "LR is at" in format [<%08lx>] if CONFIG_KALLSYMS=n, as is done in dump_backtrace_entry(). To make sure that tools like scripts/decode_stacktrace.sh can output the symbols of 'pc' and 'lr'. v1: Change the format of "pc:" and "lr:" from [<%08lx>] to %08lx. diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c index 96f3fbd51764292..f9f4e31393a6f56 100644 --- a/arch/arm/kernel/process.c +++ b/arch/arm/kernel/process.c @@ -134,9 +134,15 @@ void __show_regs(struct pt_regs *regs) show_regs_print_info(KERN_DEFAULT); +#ifdef CONFIG_KALLSYMS printk("PC is at %pS\n", (void *)instruction_pointer(regs)); printk("LR is at %pS\n", (void *)regs->ARM_lr); - printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n", +#else + printk("PC is at [<%08lx>]\n", instruction_pointer(regs)); + printk("LR is at [<%08lx>]\n", regs->ARM_lr); +#endif + + printk("pc : %08lx lr : %08lx psr: %08lx\n", regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr); printk("sp : %08lx ip : %08lx fp : %08lx\n", regs->ARM_sp, regs->ARM_ip, regs->ARM_fp);