From patchwork Thu Jan 7 22:52:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 358838 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_INVALID, DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7593CC432C3 for ; Thu, 7 Jan 2021 22:53:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44B3F23602 for ; Thu, 7 Jan 2021 22:53:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728324AbhAGWx1 (ORCPT ); Thu, 7 Jan 2021 17:53:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728568AbhAGWxW (ORCPT ); Thu, 7 Jan 2021 17:53:22 -0500 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB96CC0612F5; Thu, 7 Jan 2021 14:52:41 -0800 (PST) Received: by mail-pg1-x52d.google.com with SMTP id p18so6303792pgm.11; Thu, 07 Jan 2021 14:52:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=q4EKfM/UykAzpJGwavvmFKVMSq591R3UWoZHA7HF3eo=; b=Z3DwANhR/EydQ/pT8/9aBcSh6GI0g0LS9rE/IkN+7em5cd7vpgcEklo0g4tfV0n7Jw fVBfxxQgkeGzIwb4RUDt6MjtVaAftHMa61yIySRheNYNQ+ZDrp91QgDqZ+bk2T00mFwE WWVTeZopWwGJhjwvIqjEwXK1dewIG8rnXEG9wdSwEpeDxpFpC6SF3BoABj70eqT2UDem tqkhPwBsmA2V7+WzW1jit9Wmmx6ImpR3oRAhzO7s5FsyfwmixO1qJmo1srnwHIPDo5ke NEMTnXN5pTPUEpzrqHoBouj8O9AnX93Z/m+1cAc1HzO2mOJfXxDI9uJZXmYfaoYqLZ58 pufA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q4EKfM/UykAzpJGwavvmFKVMSq591R3UWoZHA7HF3eo=; b=Els76OejHSwol3IAJrVWWfOPyzhu60VOM6Se38uBcoxY7e5TW6TX8smjHcrqezK1mV VanGhXChvMczmSRWOvxBOrZXzZlatdmFGxOa5qo6k5XlVMebO65JL7pfgRk2cRsCounB VdgPk8dUsi0pRuySsAIUQQI+5yBrZZ3fro434zt/R1R9hxNbuUpUK7KMFoO+4tM3XhJ4 UKde095duqO4G8O0vXu8zbjhW7e1Ep7kMriDGYjAzZ737HPZmoUlKPppyTGF5T0zATuQ AK8+YQ61n4ny2+uXdA8YwyapL7hdcC7SzMBdwHhNy1erQ/nvJ19unN9c2Wca6IrQ9A+D CkSA== X-Gm-Message-State: AOAM530I+nunZeeB61sR+asQeY5d4WTuQHIjOqy+Uawi4CquVmNqdBPy qGF/dwBjY6ju69W0MMnCQB/o9shoyr4= X-Google-Smtp-Source: ABdhPJz8qjQLbY+x7sWjO9oB3B7vCcgf8+Ul70rcroTlofsq9c7bQOdUhjbzC9Pk3eL2yO5PBqKKtA== X-Received: by 2002:a62:19cb:0:b029:19e:75c2:61ec with SMTP id 194-20020a6219cb0000b029019e75c261ecmr712266pfz.19.1610059960956; Thu, 07 Jan 2021 14:52:40 -0800 (PST) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id a10sm6510603pfi.168.2021.01.07.14.52.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jan 2021 14:52:40 -0800 (PST) From: Florian Fainelli To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Andr=C3=A9_Draszik?= , Kieran Bingham , Jan Kiszka , Andrew Morton , Linus Torvalds , Florian Fainelli , Leonard Crestez , Du Changbin Subject: [stable 4.9.y 1/4] scripts/gdb: make lx-dmesg command work (reliably) Date: Thu, 7 Jan 2021 14:52:26 -0800 Message-Id: <20210107225229.1502459-2-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210107225229.1502459-1-f.fainelli@gmail.com> References: <20210107225229.1502459-1-f.fainelli@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: André Draszik commit d6c9708737c2107c38bd75f133d14d5801b8d6d5 upstream lx-dmesg needs access to the log_buf symbol from printk.c. Unfortunately, the symbol log_buf also exists in BPF's verifier.c and hence gdb can pick one or the other. If it happens to pick BPF's log_buf, lx-dmesg doesn't work: (gdb) lx-dmesg Python Exception Cannot access memory at address 0x0: Error occurred in Python command: Cannot access memory at address 0x0 (gdb) p log_buf $15 = 0x0 Luckily, GDB has a way to deal with this, see https://sourceware.org/gdb/onlinedocs/gdb/Symbols.html (gdb) info variables ^log_buf$ All variables matching regular expression "^log_buf$": File /kernel/bpf/verifier.c: static char *log_buf; File /kernel/printk/printk.c: static char *log_buf; (gdb) p 'verifier.c'::log_buf $1 = 0x0 (gdb) p 'printk.c'::log_buf $2 = 0x811a6aa0 <__log_buf> "" (gdb) p &log_buf $3 = (char **) 0x8120fe40 (gdb) p &'verifier.c'::log_buf $4 = (char **) 0x8120fe40 (gdb) p &'printk.c'::log_buf $5 = (char **) 0x8048b7d0 By being explicit about the location of the symbol, we can make lx-dmesg work again. While at it, do the same for the other symbols we need from printk.c Link: http://lkml.kernel.org/r/20170526112222.3414-1-git@andred.net Signed-off-by: André Draszik Tested-by: Kieran Bingham Acked-by: Jan Kiszka Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Florian Fainelli --- scripts/gdb/linux/dmesg.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/gdb/linux/dmesg.py b/scripts/gdb/linux/dmesg.py index f9b92ece7834..5afd1098e33a 100644 --- a/scripts/gdb/linux/dmesg.py +++ b/scripts/gdb/linux/dmesg.py @@ -23,10 +23,11 @@ class LxDmesg(gdb.Command): super(LxDmesg, self).__init__("lx-dmesg", gdb.COMMAND_DATA) def invoke(self, arg, from_tty): - log_buf_addr = int(str(gdb.parse_and_eval("log_buf")).split()[0], 16) - log_first_idx = int(gdb.parse_and_eval("log_first_idx")) - log_next_idx = int(gdb.parse_and_eval("log_next_idx")) - log_buf_len = int(gdb.parse_and_eval("log_buf_len")) + log_buf_addr = int(str(gdb.parse_and_eval( + "'printk.c'::log_buf")).split()[0], 16) + log_first_idx = int(gdb.parse_and_eval("'printk.c'::log_first_idx")) + log_next_idx = int(gdb.parse_and_eval("'printk.c'::log_next_idx")) + log_buf_len = int(gdb.parse_and_eval("'printk.c'::log_buf_len")) inf = gdb.inferiors()[0] start = log_buf_addr + log_first_idx