Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3511687img; Mon, 25 Mar 2019 11:47:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqz5+7OFS2Q6mPn80Eime560gRxbr+aj6Z8gy0vQlb0ankafO48QVjqgknyf74nMCk/L9Yqe X-Received: by 2002:a63:b52:: with SMTP id a18mr24854270pgl.393.1553539625635; Mon, 25 Mar 2019 11:47:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553539625; cv=none; d=google.com; s=arc-20160816; b=waWjl0gTS4JoZ8m3HE+WA/xPZMZ38EGcWT/Oojh5tyjlWiIFRVQ7jaOhS1gapmyxpP lKgVKeiyHOdT+qs41VO+n25a1zUAzUqOgSGvs73k5rPPpx6n1Wsana57dy3T8g/EkHZe F5hFhYZ4UyEcZx+wGHRDE8CDa5AOZ3c2tQuY4KO4phcER4Yi4TTvCFwnGcaJ7q5ot/Lc Xz0NqbcNQCC/l7DDYjnKahhCBvH3b2URjoVUcyZn6Lu8i6f6cE+Tq6BV3cgVh4m25SSm DkYmXAqT45hiCxOBJrXlJ5KyX8UxJblGqtCgA4+lgJ0R0qIV4Z1CMgE7QRVRliHZRQCM BwYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HU7yuDm8Y1RRdsoUGwsej4fqxozu4cJsDeGBIryMkHY=; b=O6n2BYPUL7LAlrdCsSxmIqNuNjnYi+RuQIYjdpLG8q2RHvQfR7Kwe0tHxVt/oYhkLp cJB8xbWwpEuGgA0gR9s3qRATsAk5gehlKk/2sGEkr9iox2g+R7yvhRvj3pOU/X0jJdf6 k7XT0lCWVYcyVAdNrLJip0LHiG2W2S3ylyE2wXQlyWKOPzJ/Snmct5bT9H7LWAX8Z2wE D2WUXzYHxCzcQhAXm2vGjx/ICq8jkYAAUrtUyNRqvQ+UCUU5eermUM4IWULE32GQxRmg 47SOQmkLtVaz4VScxmbhN1NoYLNcwOyK+aPhho84zwzqR3SJNlHmZpOtQHYWVGqiXc/C tY7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="b/qmNqaY"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v9si13838943pgs.438.2019.03.25.11.46.50; Mon, 25 Mar 2019 11:47:05 -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=pass header.i=@chromium.org header.s=google header.b="b/qmNqaY"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730412AbfCYSpw (ORCPT + 99 others); Mon, 25 Mar 2019 14:45:52 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:35598 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730261AbfCYSp0 (ORCPT ); Mon, 25 Mar 2019 14:45:26 -0400 Received: by mail-pl1-f193.google.com with SMTP id p19so365020plo.2 for ; Mon, 25 Mar 2019 11:45:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HU7yuDm8Y1RRdsoUGwsej4fqxozu4cJsDeGBIryMkHY=; b=b/qmNqaY1Sneu02VrFzYXfLnTX4W3+n6LQE8UZvUtWTr9Uai7zgvAqY9rLCSWmYiKi TQKQGC8V9iXNg4siXEdtNjkFKe7apc7pDoDheRFh0CsbmWyAZyo66AbKCouv8vQ576R2 1eZUJjS8LFlQrbH9oMmMLIsuhx5K1ZVKzJnaA= 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=HU7yuDm8Y1RRdsoUGwsej4fqxozu4cJsDeGBIryMkHY=; b=ge3JzXyjZjTCjIrJhV+DxT+oXCWxmynWJPmKCbK8sO6uPNVNAZKk3pMOovUajSIJfu 9ccY/Tb5NiODXcRYIKiWRyQlGczIQ1s20ePvA3VLXMuamTJqr6EXC9hgeG0ZhxLoXJro LqY3Z+yuJp4+eQcTGmktJG8vNGQjfDeUAOtltlMO35gb0nhhOw7aClK9aHjPvP3DmYST LL25T9hTZVNvjyAvJngHHzlsO6JTv/XYNZ/1HMU3EtuHDGCTVSNKS1UKV/b6cX35eZwi RCnEs7LZD0EJDHFTg8SG+VEREFx1gM3Gi4rHMNw0MPrag8WsL2KA4IcN29glQ33wEA1y CA3A== X-Gm-Message-State: APjAAAV3w/4Lvy5pojy3ePKBgO9XwLHcM5sNOvov5CO+qHmC49nXc1Kx 9G0XrOZkPFV5T3b53Lzo5Tpk7g== X-Received: by 2002:a17:902:7896:: with SMTP id q22mr27385924pll.66.1553539526223; Mon, 25 Mar 2019 11:45:26 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id h3sm27505108pfb.31.2019.03.25.11.45.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Mar 2019 11:45:25 -0700 (PDT) From: Stephen Boyd To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Douglas Anderson , Nikolay Borisov , Kieran Bingham , Jan Kiszka , Jackie Liu Subject: [PATCH 2/4] scripts/gdb: Add kernel config dumping command Date: Mon, 25 Mar 2019 11:45:20 -0700 Message-Id: <20190325184522.260535-3-swboyd@chromium.org> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog In-Reply-To: <20190325184522.260535-1-swboyd@chromium.org> References: <20190325184522.260535-1-swboyd@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org lx-configdump dumps the contents of the gzipped .config to a text file when the config is included in the kernel with CONFIG_IKCONFIG. By default, the file written is called config.txt, but it can be any user supplied filename as well. If the kernel config is in a module (configs.ko), then it can be loaded along with symbols for the module loaded with 'lx-symbols' and then this command will still work. Obviously if you have the whole vmlinux then this can also be achieved with scripts/extract-ikconfig, but this gdb script can be useful to confirm that the memory contents of the config in memory and the vmlinux contents on disk match what is expected. Cc: Douglas Anderson Cc: Nikolay Borisov Cc: Kieran Bingham Cc: Jan Kiszka Cc: Jackie Liu Signed-off-by: Stephen Boyd --- scripts/gdb/linux/config.py | 48 +++++++++++++++++++++++++++++++++++++ scripts/gdb/vmlinux-gdb.py | 1 + 2 files changed, 49 insertions(+) create mode 100644 scripts/gdb/linux/config.py diff --git a/scripts/gdb/linux/config.py b/scripts/gdb/linux/config.py new file mode 100644 index 000000000000..400f09bb2665 --- /dev/null +++ b/scripts/gdb/linux/config.py @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright 2019 Google LLC. + +import gdb +import zlib + +from linux import utils + +class LxConfigDump(gdb.Command): + """Output kernel config to the filename specified as the command + argument. Equivalent to 'zcat /proc/config.gz > config.txt' on + a running target""" + + def __init__(self): + super(LxConfigDump, self).__init__("lx-configdump", gdb.COMMAND_DATA, + gdb.COMPLETE_FILENAME) + + def invoke(self, arg, from_tty): + if len(arg) == 0: + filename = "config.txt" + else: + filename = arg + + try: + py_config_ptr = gdb.parse_and_eval( + "kernel_config_data + 8") + py_config_size = gdb.parse_and_eval( + "sizeof(kernel_config_data) - 2 - 8 * 2") + except: + raise gdb.GdbError("Can't find config, enable CONFIG_IKCONFIG?") + + inf = gdb.inferiors()[0] + zconfig_buf = utils.read_memoryview(inf, py_config_ptr, + py_config_size).tobytes() + + config_buf = zlib.decompress(zconfig_buf, 16) + try: + f = open(filename, 'wb') + except: + raise gdb.GdbError("Could not open file to dump config") + + f.write(config_buf) + f.close() + + gdb.write("Dumped config to " + filename + "\n") + +LxConfigDump() diff --git a/scripts/gdb/vmlinux-gdb.py b/scripts/gdb/vmlinux-gdb.py index 6e0b0afd888a..be0efb5dda5b 100644 --- a/scripts/gdb/vmlinux-gdb.py +++ b/scripts/gdb/vmlinux-gdb.py @@ -27,6 +27,7 @@ else: import linux.modules import linux.dmesg import linux.tasks + import linux.config import linux.cpus import linux.lists import linux.proc -- Sent by a computer through tubes