diff options
author | Stephen Boyd <swboyd@chromium.org> | 2019-04-26 10:28:16 +1000 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2019-04-28 01:04:32 +1000 |
commit | fcffdd642c29754438885bf84129eab103730e7f (patch) | |
tree | 985841ced9531c2fc2966b6decd861104c0bbd50 /scripts/gdb/linux/config.py | |
parent | f954a3369c7e41b81f72463e2e7b87989d278258 (diff) | |
download | linux-next-fcffdd642c29754438885bf84129eab103730e7f.tar.gz |
scripts-gdb-add-kernel-config-dumping-command-v2
* Fixed config dumping script off-by-one error on builtin config size
* Silenced pep8 style warnings and errors
Link: http://lkml.kernel.org/r/20190329220844.38234-3-swboyd@chromium.org
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Cc: Douglas Anderson <dianders@chromium.org>
Cc: Nikolay Borisov <n.borisov.lkml@gmail.com>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Jackie Liu <liuyun01@kylinos.cn>
Cc: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Diffstat (limited to 'scripts/gdb/linux/config.py')
-rw-r--r-- | scripts/gdb/linux/config.py | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/scripts/gdb/linux/config.py b/scripts/gdb/linux/config.py index 400f09bb2665..90e1565b1967 100644 --- a/scripts/gdb/linux/config.py +++ b/scripts/gdb/linux/config.py @@ -7,6 +7,7 @@ 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 @@ -14,7 +15,7 @@ class LxConfigDump(gdb.Command): def __init__(self): super(LxConfigDump, self).__init__("lx-configdump", gdb.COMMAND_DATA, - gdb.COMPLETE_FILENAME) + gdb.COMPLETE_FILENAME) def invoke(self, arg, from_tty): if len(arg) == 0: @@ -23,26 +24,21 @@ class LxConfigDump(gdb.Command): filename = arg try: - py_config_ptr = gdb.parse_and_eval( - "kernel_config_data + 8") + 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: + "sizeof(kernel_config_data) - 1 - 8 * 2") + except gdb.error as e: 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() + 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() + with open(filename, 'wb') as f: + f.write(config_buf) gdb.write("Dumped config to " + filename + "\n") + LxConfigDump() |