From e4c1617e17ebf2d4e20ba59041de1536ec193be3 Mon Sep 17 00:00:00 2001 From: John Pittman Date: Mon, 18 Jan 2021 09:43:27 -0500 Subject: [PATCH 08/13] set: add ability to un-set scope Currently there is no way to un-set the scope without having to exit and re-enter crash. The ability to un-set can come in very useful when running automated pykdump scripts and needing scope to be cleared between script runs. Add the ability by allowing vaddr 0 to be passed through gdb_set_crash_scope() and gdb_command_funnel(), taking advantage of the !req->addr check in gdb_set_crash_block(), enabling 'set scope 0' as a viable command. Signed-off-by: John Pittman Signed-off-by: Lianbo Jiang --- gdb_interface.c | 30 ++++++++++++++++-------------- help.c | 2 +- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/gdb_interface.c b/gdb_interface.c index 562d2ace59da..f4f4dd3993db 100644 --- a/gdb_interface.c +++ b/gdb_interface.c @@ -1012,23 +1012,25 @@ gdb_set_crash_scope(ulong vaddr, char *arg) char name[BUFSIZE]; struct load_module *lm; - if (!is_kernel_text(vaddr)) { - error(INFO, "invalid text address: %s\n", arg); - return FALSE; - } + if (vaddr) { + if (!is_kernel_text(vaddr)) { + error(INFO, "invalid text address: %s\n", arg); + return FALSE; + } - if (module_symbol(vaddr, NULL, &lm, name, 0)) { - if (!(lm->mod_flags & MOD_LOAD_SYMS)) { - error(INFO, "attempting to find/load \"%s\" module debuginfo\n", - lm->mod_name); - if (!load_module_symbols_helper(lm->mod_name)) { - error(INFO, "cannot find/load \"%s\" module debuginfo\n", + if (module_symbol(vaddr, NULL, &lm, name, 0)) { + if (!(lm->mod_flags & MOD_LOAD_SYMS)) { + error(INFO, "attempting to find/load \"%s\" module debuginfo\n", lm->mod_name); - return FALSE; + if (!load_module_symbols_helper(lm->mod_name)) { + error(INFO, "cannot find/load \"%s\" module debuginfo\n", + lm->mod_name); + return FALSE; + } } - } - } else if (kt->flags2 & KASLR) - vaddr -= (kt->relocate * -1); + } else if (kt->flags2 & KASLR) + vaddr -= (kt->relocate * -1); + } req->command = GNU_SET_CRASH_BLOCK; req->addr = vaddr; diff --git a/help.c b/help.c index d3427a36829f..7c9455f87758 100644 --- a/help.c +++ b/help.c @@ -1088,7 +1088,7 @@ char *help_set[] = { " of data structures; the \"text-addr\" argument", " must be a kernel or module text address, which", " may be expressed symbolically or as a hexadecimal", -" value.", +" value; set scope 0 to un-set.", " offline show | hide show or hide command output that is associated", " with offline cpus.", " redzone on | off if on, CONFIG_SLUB object addresses displayed by", -- 2.17.1