[Crash-utility] Re: [RFC] Provide minimal debugging to crash
Dave Anderson
anderson at redhat.com
Mon Aug 18 20:16:31 UTC 2008
Sharyathi Nagesh wrote:
> Dave
> I have done the suggested modifications, have a look
This one looks pretty good. I made a couple minor tweaks for the unhandled
command entry error-handling, the minimal commands message, and for a clean
compile. Other than that, it's queued for the next release.
Thanks,
Dave
>>
>> I haven't walked through all the restricted command list code paths to
>> verify that they can work properly for all architectures without, say,
>> kernel_init(), the 3 machdep_init() calls, vm_init() etc. having run.
>> Certainly trying to rd or dis vmalloc addresses would display garbage
>> data or just fail, but that's to be expected.
>>
>> I quickly tried this on a x86 and x86_64 -- but have you tried this on
>> an ia64 or ppc64?
> I tested on ppc64 and on corrupted dump and it worked fine
>>
>> The only thing I'm not excited about is all the re-tinkering with the
>> help screen output. Why bother? I'd prefer to keep things simple.
>> During initialization, display a WARNING message that lists the supported
>> commands just prior to the first prompt. And then just leave the help
>> screen alone, and let your command-restriction mechanism display the
>> per-command message:
>>
>> error(INFO, "command: %s not available in minimal mode\n", args[0]);
>> ...and then perhaps followed up immediately with the acceptable command
>> list again.
> I have done this code change
>>
>> Another minor suggestion -- I think you can put the "eval" command in
>> the supported list. I use it all the time, and in this minimal
>> environment
>> it may come in very handy. (There may be others, but they're probably
>> not
>> worth having...)
> allowed eval to be executed in minimal mode
>
> Thanks
> Yeehaw
>
>
>
>
> ------------------------------------------------------------------------
>
> Signed-off-by: Sharyathi Nagesh <sharyath at in.ibm.com>
> Signed-off-by: Sachin P Sant <sachinp at in.ibm.com>
> ---
>
> diff -Naurp crash-old/cmdline.c crash-new/cmdline.c
> --- crash-old/cmdline.c 2008-03-31 22:58:31.000000000 +0530
> +++ crash-new/cmdline.c 2008-08-18 09:25:21.000000000 +0530
> @@ -2137,3 +2137,11 @@ wait_for_children(ulong waitflag)
> stall(1000);
> }
> }
> +
> +int minimal_functions(char *name)
> +{
> + return STREQ("log", name) || STREQ("help",name) || \
> + STREQ("dis", name) || STREQ("q", name) || \
> + STREQ("sym", name) || STREQ("exit", name)|| \
> + STREQ("rd", name) || STREQ("eval", name) ;
> +}
> diff -Naurp crash-old/defs.h crash-new/defs.h
> --- crash-old/defs.h 2008-03-31 22:58:31.000000000 +0530
> +++ crash-new/defs.h 2008-08-04 13:36:23.000000000 +0530
> @@ -183,6 +183,7 @@ struct number_option {
> #define PLEASE_WAIT (0x200000000000000ULL)
> #define IFILE_ERROR (0x400000000000000ULL)
> #define KERNTYPES (0x800000000000000ULL)
> +#define MINIMAL_MODE (0x1000000000000000ULL)
>
> #define ACTIVE() (pc->flags & LIVE_SYSTEM)
> #define DUMPFILE() (!(pc->flags & LIVE_SYSTEM))
> @@ -3129,6 +3130,7 @@ int received_SIGINT(void);
> void debug_redirect(char *);
> int CRASHPAGER_valid(void);
> char *setup_scroll_command(void);
> +int minimal_functions(char *);
>
> /*
> * tools.c
> diff -Naurp crash-old/main.c crash-new/main.c
> --- crash-old/main.c 2008-08-18 11:50:38.000000000 +0530
> +++ crash-new/main.c 2008-08-18 11:54:31.000000000 +0530
> @@ -56,6 +56,7 @@ static struct option long_options[] = {
> {"no_scroll", 0, 0, 0},
> {"reloc", required_argument, 0, 0},
> {"active", 0, 0, 0},
> + {"minimal", 0, 0, 0},
> {0, 0, 0, 0}
> };
>
> @@ -197,6 +198,9 @@ main(int argc, char **argv)
> kt->flags |= RELOC_SET;
> }
>
> + else if (STREQ(long_options[option_index].name, "minimal"))
> + pc->flags |= MINIMAL_MODE;
> +
> else {
> error(INFO, "internal error: option %s unhandled\n",
> long_options[option_index].name);
> @@ -492,7 +496,7 @@ main_loop(void)
> #else
> error(FATAL, XEN_HYPERVISOR_NOT_SUPPORTED);
> #endif
> - } else {
> + } else if(!(pc->flags & MINIMAL_MODE)){
> read_in_kernel_config(IKCFG_INIT);
> kernel_init();
> machdep_init(POST_GDB);
> @@ -520,7 +524,7 @@ main_loop(void)
> #else
> error(FATAL, XEN_HYPERVISOR_NOT_SUPPORTED);
> #endif
> - } else {
> + } else if(!(pc->flags & MINIMAL_MODE)){
> display_sys_stats();
> show_context(CURRENT_CONTEXT());
> }
> @@ -528,6 +532,11 @@ main_loop(void)
> }
>
> pc->flags |= RUNTIME;
> +
> + if(pc->flags & MINIMAL_MODE){
> + error(WARNING, "In minimal mode you have access to only these \n \
> + commands: 'log', 'dis', 'rd','sym', 'eval' and 'exit' \n");
> + }
>
> /*
> * Return here if a non-recoverable error occurs
> @@ -610,7 +619,14 @@ reattempt:
> return;
>
> pc->curcmd = pc->program_name;
> - error(INFO, "command not found: %s\n", args[0]);
> + if (!(pc->flags & MINIMAL_MODE))
> + error(INFO, "command not found: %s\n", args[0]);
> + else{
> + error(INFO,
> + "command: %s not available in minimal mode\n", args[0]);
> + error(INFO,
> + "supported commands:'log', 'dis', 'rd', 'sym', 'eval', 'exit' \n");
> + }
>
> if (pc->curcmd_flags & REPEAT)
> pc->curcmd_flags &= ~REPEAT;
> @@ -625,6 +641,9 @@ get_command_table_entry(char *name)
> {
> struct command_table_entry *cp;
> struct extension_table *ext;
> +
> + if ((pc->flags & MINIMAL_MODE) && !minimal_functions(name))
> + return NULL;
>
> for (cp = pc->cmd_table; cp->name; cp++) {
> if (STREQ(cp->name, name))
More information about the Crash-utility
mailing list