|
|
765b01 |
From bd67c1d5e2633f302b4c0ad50cc830ff7da20b2a Mon Sep 17 00:00:00 2001
|
|
|
765b01 |
From: Baoquan He <bhe@redhat.com>
|
|
|
765b01 |
Date: Tue, 2 Jul 2013 11:09:20 +0900
|
|
|
765b01 |
Subject: [PATCH 1/2] [PATCH 1/2] Assign non-printable value as short options.
|
|
|
765b01 |
|
|
|
765b01 |
Characters for short options is limited, and now makedumpfile has
|
|
|
765b01 |
considerably many options. As times go on, no enough reasonable
|
|
|
765b01 |
letters can be assigned to each functionality with short options.
|
|
|
765b01 |
|
|
|
765b01 |
E.g non-cyclic vs Y, cyclic-buffer vs Z, eppic vs S.
|
|
|
765b01 |
|
|
|
765b01 |
Now assign non-printable value to these kind of short optins, meanwhile
|
|
|
765b01 |
define them as indicative MACRO which can make code more readable.
|
|
|
765b01 |
|
|
|
765b01 |
Signed-off-by: Baoquan He <bhe@redhat.com>
|
|
|
765b01 |
---
|
|
|
765b01 |
makedumpfile.c | 88 +++++++++++++++++++++++++++++-----------------------------
|
|
|
765b01 |
makedumpfile.h | 35 +++++++++++++++++++++++
|
|
|
765b01 |
2 files changed, 79 insertions(+), 44 deletions(-)
|
|
|
765b01 |
|
|
|
765b01 |
diff --git a/makedumpfile-1.5.4/makedumpfile.c b/makedumpfile-1.5.4/makedumpfile.c
|
|
|
765b01 |
index b42565c..bb72c66 100644
|
|
|
765b01 |
--- a/makedumpfile-1.5.4/makedumpfile.c
|
|
|
765b01 |
+++ b/makedumpfile-1.5.4/makedumpfile.c
|
|
|
765b01 |
@@ -8555,20 +8555,20 @@ calculate_cyclic_buffer_size(void) {
|
|
|
765b01 |
}
|
|
|
765b01 |
|
|
|
765b01 |
static struct option longopts[] = {
|
|
|
765b01 |
- {"split", no_argument, NULL, 's'},
|
|
|
765b01 |
- {"reassemble", no_argument, NULL, 'r'},
|
|
|
765b01 |
- {"xen-syms", required_argument, NULL, 'y'},
|
|
|
765b01 |
- {"xen-vmcoreinfo", required_argument, NULL, 'z'},
|
|
|
765b01 |
- {"xen_phys_start", required_argument, NULL, 'P'},
|
|
|
765b01 |
- {"message-level", required_argument, NULL, 'm'},
|
|
|
765b01 |
- {"vtop", required_argument, NULL, 'V'},
|
|
|
765b01 |
- {"dump-dmesg", no_argument, NULL, 'M'},
|
|
|
765b01 |
- {"config", required_argument, NULL, 'C'},
|
|
|
765b01 |
- {"help", no_argument, NULL, 'h'},
|
|
|
765b01 |
- {"diskset", required_argument, NULL, 'k'},
|
|
|
765b01 |
- {"non-cyclic", no_argument, NULL, 'Y'},
|
|
|
765b01 |
- {"cyclic-buffer", required_argument, NULL, 'Z'},
|
|
|
765b01 |
- {"eppic", required_argument, NULL, 'S'},
|
|
|
765b01 |
+ {"split", no_argument, NULL, OPT_SPLIT},
|
|
|
765b01 |
+ {"reassemble", no_argument, NULL, OPT_REASSEMBLE},
|
|
|
765b01 |
+ {"xen-syms", required_argument, NULL, OPT_XEN_SYMS},
|
|
|
765b01 |
+ {"xen-vmcoreinfo", required_argument, NULL, OPT_XEN_VMCOREINFO},
|
|
|
765b01 |
+ {"xen_phys_start", required_argument, NULL, OPT_XEN_PHYS_START},
|
|
|
765b01 |
+ {"message-level", required_argument, NULL, OPT_MESSAGE_LEVEL},
|
|
|
765b01 |
+ {"vtop", required_argument, NULL, OPT_VTOP},
|
|
|
765b01 |
+ {"dump-dmesg", no_argument, NULL, OPT_DUMP_DMESG},
|
|
|
765b01 |
+ {"config", required_argument, NULL, OPT_CONFIG},
|
|
|
765b01 |
+ {"help", no_argument, NULL, OPT_HELP},
|
|
|
765b01 |
+ {"diskset", required_argument, NULL, OPT_DISKSET},
|
|
|
765b01 |
+ {"non-cyclic", no_argument, NULL, OPT_NON_CYCLIC},
|
|
|
765b01 |
+ {"cyclic-buffer", required_argument, NULL, OPT_CYCLIC_BUFFER},
|
|
|
765b01 |
+ {"eppic", required_argument, NULL, OPT_EPPIC},
|
|
|
765b01 |
{0, 0, 0, 0}
|
|
|
765b01 |
};
|
|
|
765b01 |
|
|
|
765b01 |
@@ -8597,29 +8597,29 @@ main(int argc, char *argv[])
|
|
|
765b01 |
|
|
|
765b01 |
info->block_order = DEFAULT_ORDER;
|
|
|
765b01 |
message_level = DEFAULT_MSG_LEVEL;
|
|
|
765b01 |
- while ((opt = getopt_long(argc, argv, "b:cDd:EFfg:hi:lMpRrsvXx:", longopts,
|
|
|
765b01 |
+ while ((opt = getopt_long(argc, argv, "b:cDd:EFfg:hi:lpRvXx:", longopts,
|
|
|
765b01 |
NULL)) != -1) {
|
|
|
765b01 |
switch (opt) {
|
|
|
765b01 |
- case 'b':
|
|
|
765b01 |
+ case OPT_BLOCK_ORDER:
|
|
|
765b01 |
info->block_order = atoi(optarg);
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'C':
|
|
|
765b01 |
+ case OPT_CONFIG:
|
|
|
765b01 |
info->name_filterconfig = optarg;
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'c':
|
|
|
765b01 |
+ case OPT_COMPRESS_ZLIB:
|
|
|
765b01 |
info->flag_compress = DUMP_DH_COMPRESSED_ZLIB;
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'D':
|
|
|
765b01 |
+ case OPT_DEBUG:
|
|
|
765b01 |
flag_debug = TRUE;
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'd':
|
|
|
765b01 |
+ case OPT_DUMP_LEVEL:
|
|
|
765b01 |
if (!parse_dump_level(optarg))
|
|
|
765b01 |
goto out;
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'E':
|
|
|
765b01 |
+ case OPT_ELF_DUMPFILE:
|
|
|
765b01 |
info->flag_elf_dumpfile = 1;
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'F':
|
|
|
765b01 |
+ case OPT_FLATTEN:
|
|
|
765b01 |
info->flag_flatten = 1;
|
|
|
765b01 |
/*
|
|
|
765b01 |
* All messages are output to STDERR because STDOUT is
|
|
|
765b01 |
@@ -8627,75 +8627,75 @@ main(int argc, char *argv[])
|
|
|
765b01 |
*/
|
|
|
765b01 |
flag_strerr_message = TRUE;
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'f':
|
|
|
765b01 |
+ case OPT_FORCE:
|
|
|
765b01 |
info->flag_force = 1;
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'g':
|
|
|
765b01 |
+ case OPT_GENERATE_VMCOREINFO:
|
|
|
765b01 |
info->flag_generate_vmcoreinfo = 1;
|
|
|
765b01 |
info->name_vmcoreinfo = optarg;
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'h':
|
|
|
765b01 |
+ case OPT_HELP:
|
|
|
765b01 |
info->flag_show_usage = 1;
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'i':
|
|
|
765b01 |
+ case OPT_READ_VMCOREINFO:
|
|
|
765b01 |
info->flag_read_vmcoreinfo = 1;
|
|
|
765b01 |
info->name_vmcoreinfo = optarg;
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'k':
|
|
|
765b01 |
+ case OPT_DISKSET:
|
|
|
765b01 |
if (!sadump_add_diskset_info(optarg))
|
|
|
765b01 |
goto out;
|
|
|
765b01 |
info->flag_sadump_diskset = 1;
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'l':
|
|
|
765b01 |
+ case OPT_COMPRESS_LZO:
|
|
|
765b01 |
info->flag_compress = DUMP_DH_COMPRESSED_LZO;
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'm':
|
|
|
765b01 |
+ case OPT_MESSAGE_LEVEL:
|
|
|
765b01 |
message_level = atoi(optarg);
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'M':
|
|
|
765b01 |
+ case OPT_DUMP_DMESG:
|
|
|
765b01 |
info->flag_dmesg = 1;
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'p':
|
|
|
765b01 |
+ case OPT_COMPRESS_SNAPPY:
|
|
|
765b01 |
info->flag_compress = DUMP_DH_COMPRESSED_SNAPPY;
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'P':
|
|
|
765b01 |
+ case OPT_XEN_PHYS_START:
|
|
|
765b01 |
info->xen_phys_start = strtoul(optarg, NULL, 0);
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'R':
|
|
|
765b01 |
+ case OPT_REARRANGE:
|
|
|
765b01 |
info->flag_rearrange = 1;
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 's':
|
|
|
765b01 |
+ case OPT_SPLIT:
|
|
|
765b01 |
info->flag_split = 1;
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'S':
|
|
|
765b01 |
+ case OPT_EPPIC:
|
|
|
765b01 |
info->name_eppic_config = optarg;
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'r':
|
|
|
765b01 |
+ case OPT_REASSEMBLE:
|
|
|
765b01 |
info->flag_reassemble = 1;
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'V':
|
|
|
765b01 |
+ case OPT_VTOP:
|
|
|
765b01 |
info->vaddr_for_vtop = strtoul(optarg, NULL, 0);
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'v':
|
|
|
765b01 |
+ case OPT_VERSION:
|
|
|
765b01 |
info->flag_show_version = 1;
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'X':
|
|
|
765b01 |
+ case OPT_EXCLUDE_XEN_DOM:
|
|
|
765b01 |
info->flag_exclude_xen_dom = 1;
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'x':
|
|
|
765b01 |
+ case OPT_VMLINUX:
|
|
|
765b01 |
info->name_vmlinux = optarg;
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'y':
|
|
|
765b01 |
+ case OPT_XEN_SYMS:
|
|
|
765b01 |
info->name_xen_syms = optarg;
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'Y':
|
|
|
765b01 |
+ case OPT_NON_CYCLIC:
|
|
|
765b01 |
info->flag_cyclic = FALSE;
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'z':
|
|
|
765b01 |
+ case OPT_XEN_VMCOREINFO:
|
|
|
765b01 |
info->flag_read_vmcoreinfo = 1;
|
|
|
765b01 |
info->name_vmcoreinfo = optarg;
|
|
|
765b01 |
break;
|
|
|
765b01 |
- case 'Z':
|
|
|
765b01 |
+ case OPT_CYCLIC_BUFFER:
|
|
|
765b01 |
info->bufsize_cyclic = atoi(optarg);
|
|
|
765b01 |
break;
|
|
|
765b01 |
case '?':
|
|
|
765b01 |
diff --git a/makedumpfile-1.5.4/makedumpfile.h b/makedumpfile-1.5.4/makedumpfile.h
|
|
|
765b01 |
index a5826e0..79d4702 100644
|
|
|
765b01 |
--- a/makedumpfile-1.5.4/makedumpfile.h
|
|
|
765b01 |
+++ b/makedumpfile-1.5.4/makedumpfile.h
|
|
|
765b01 |
@@ -1671,6 +1671,41 @@ struct elf_prstatus {
|
|
|
765b01 |
#endif
|
|
|
765b01 |
|
|
|
765b01 |
/*
|
|
|
765b01 |
+ * Below are options which getopt_long can recognize. From OPT_START options are
|
|
|
765b01 |
+ * non-printable, just used for implementation.
|
|
|
765b01 |
+ */
|
|
|
765b01 |
+#define OPT_BLOCK_ORDER 'b'
|
|
|
765b01 |
+#define OPT_COMPRESS_ZLIB 'c'
|
|
|
765b01 |
+#define OPT_DEBUG 'D'
|
|
|
765b01 |
+#define OPT_DUMP_LEVEL 'd'
|
|
|
765b01 |
+#define OPT_ELF_DUMPFILE 'E'
|
|
|
765b01 |
+#define OPT_FLATTEN 'F'
|
|
|
765b01 |
+#define OPT_FORCE 'f'
|
|
|
765b01 |
+#define OPT_GENERATE_VMCOREINFO 'g'
|
|
|
765b01 |
+#define OPT_HELP 'h'
|
|
|
765b01 |
+#define OPT_READ_VMCOREINFO 'i'
|
|
|
765b01 |
+#define OPT_COMPRESS_LZO 'l'
|
|
|
765b01 |
+#define OPT_COMPRESS_SNAPPY 'p'
|
|
|
765b01 |
+#define OPT_REARRANGE 'R'
|
|
|
765b01 |
+#define OPT_VERSION 'v'
|
|
|
765b01 |
+#define OPT_EXCLUDE_XEN_DOM 'X'
|
|
|
765b01 |
+#define OPT_VMLINUX 'x'
|
|
|
765b01 |
+#define OPT_START 256
|
|
|
765b01 |
+#define OPT_SPLIT OPT_START+0
|
|
|
765b01 |
+#define OPT_REASSEMBLE OPT_START+1
|
|
|
765b01 |
+#define OPT_XEN_SYMS OPT_START+2
|
|
|
765b01 |
+#define OPT_XEN_VMCOREINFO OPT_START+3
|
|
|
765b01 |
+#define OPT_XEN_PHYS_START OPT_START+4
|
|
|
765b01 |
+#define OPT_MESSAGE_LEVEL OPT_START+5
|
|
|
765b01 |
+#define OPT_VTOP OPT_START+6
|
|
|
765b01 |
+#define OPT_DUMP_DMESG OPT_START+7
|
|
|
765b01 |
+#define OPT_CONFIG OPT_START+8
|
|
|
765b01 |
+#define OPT_DISKSET OPT_START+9
|
|
|
765b01 |
+#define OPT_NON_CYCLIC OPT_START+10
|
|
|
765b01 |
+#define OPT_CYCLIC_BUFFER OPT_START+11
|
|
|
765b01 |
+#define OPT_EPPIC OPT_START+12
|
|
|
765b01 |
+
|
|
|
765b01 |
+/*
|
|
|
765b01 |
* Function Prototype.
|
|
|
765b01 |
*/
|
|
|
765b01 |
unsigned long long get_num_dumpable_cyclic(void);
|
|
|
765b01 |
--
|
|
|
765b01 |
1.8.4.2
|
|
|
765b01 |
|