From 26bd107763037f9cd9534ccc19119bd027bf2062 Mon Sep 17 00:00:00 2001 From: Qiao Nuohan Date: Sun, 14 Sep 2014 15:00:22 +0800 Subject: [PATCH 2/3] add a flag to display/hide data related to offline cpu Add a field in pc->flags2 to display/hide data related to offline cpu. This flag can be changed by the following 2 ways: 1. start crash with "--offline_cpu [on|off]" 2. execute crash command "set offline_cpu on|off" The default set is offline_cpu off(hiding data related to offline cpu). This flag will be used by following patches to hide date related to offline cpus. And if offline_cpu is set to on, those hidden data will be shown as same as the original output. Signed-off-by: Qiao Nuohan --- defs.h | 1 + help.c | 6 ++++++ main.c | 15 ++++++++++++++- tools.c | 15 +++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/defs.h b/defs.h index 8fbbdeb..19b4b8f 100755 --- a/defs.h +++ b/defs.h @@ -505,6 +505,7 @@ struct program_context { #define REM_PAUSED_F (0x1000ULL) #define RAMDUMP (0x2000ULL) #define REMOTE_PAUSED() (pc->flags2 & REM_PAUSED_F) +#define OFFLINE_CPU (0x4000ULL) char *cleanup; char *namelist_orig; char *namelist_debug_orig; diff --git a/help.c b/help.c index 30d7759..7da0728 100755 --- a/help.c +++ b/help.c @@ -339,6 +339,10 @@ char *program_usage_info[] = { " --kvmio ", " override the automatically-calculated KVM guest I/O hole size.", "", + " --offline_cpu [on|off]", + " Display/hide data related to offline cpu. Crash command \"set offline", + " [on|off]\" can be used to override the set here", + "", "FILES:", "", " .crashrc", @@ -1054,6 +1058,8 @@ char *help_set[] = { " must be a kernel or module text address, which", " may be expressed symbolically or as a hexadecimal", " value.", +" offline_cpu on | off if on, crash will display data related to offline", +" cpu.", " ", " Internal variables may be set in four manners:\n", " 1. entering the set command in $HOME/.%src.", diff --git a/main.c b/main.c index ad66058..35305c4 100755 --- a/main.c +++ b/main.c @@ -70,6 +70,7 @@ static struct option long_options[] = { {"dec", 0, 0, 0}, {"no_strip", 0, 0, 0}, {"hash", required_argument, 0, 0}, + {"offline_cpu", required_argument, 0, 0}, {0, 0, 0, 0} }; @@ -279,7 +280,17 @@ main(int argc, char **argv) pc->flags2 |= RADIX_OVERRIDE; pc->output_radix = 10; } - + + else if (STREQ(long_options[option_index].name, "offline_cpu")) { + if (STREQ(optarg, "on")) + pc->flags2 |= OFFLINE_CPU; + else if (STREQ(optarg, "off")) + pc->flags2 &= ~OFFLINE_CPU; + else { + error(INFO, "invalid --offline_cpu argument: %s\n", optarg); + program_usage(SHORT_FORM); + } + } else { error(INFO, "internal error: option %s unhandled\n", @@ -1393,6 +1404,8 @@ dump_program_context(void) fprintf(fp, "%sALLOW_FP", others++ ? "|" : ""); if (pc->flags2 & RAMDUMP) fprintf(fp, "%sRAMDUMP", others++ ? "|" : ""); + if (pc->flags2 & OFFLINE_CPU) + fprintf(fp, "%sOFFLINE_CPU", others++ ? "|" : ""); fprintf(fp, ")\n"); fprintf(fp, " namelist: %s\n", pc->namelist); diff --git a/tools.c b/tools.c index a5f514f..2ed17aa 100755 --- a/tools.c +++ b/tools.c @@ -2365,6 +2365,20 @@ cmd_set(void) "on" : "off"); return; + } else if (STREQ(args[optind], "offline_cpu")) { + + if (args[optind+1]) { + optind++; + if (STREQ(args[optind], "on")) + pc->flags2 |= OFFLINE_CPU; + else if(STREQ(args[optind], "off")) + pc->flags2 &= ~OFFLINE_CPU; + else + goto invalid_set_command; + } + + return; + } else if (XEN_HYPER_MODE()) { error(FATAL, "invalid argument for the Xen hypervisor\n"); } else if (pc->flags & MINIMAL_MODE) { @@ -2467,6 +2481,7 @@ show_options(void) fprintf(fp, "(%s)\n", value_to_symstr(pc->scope, buf, 0)); else fprintf(fp, "(not set)\n"); + fprintf(fp, " offline_cpu: %s\n", pc->flags2 & OFFLINE_CPU ? "on" : "off"); } -- 1.8.5.3