----- Original Message ----- > Aaron and Buland, > > I was just about to check this in when I thought that maybe it could > be a bit more informative than just "dmi_ident[#]: <string>", given > that the output could also incorporate the enum name/index, as is done > with a few other crash commands: > > crash> dmi_field > enum dmi_field { > DMI_NONE = 0 > DMI_BIOS_VENDOR = 1 > DMI_BIOS_VERSION = 2 > DMI_BIOS_DATE = 3 > DMI_SYS_VENDOR = 4 > DMI_PRODUCT_NAME = 5 > DMI_PRODUCT_VERSION = 6 > DMI_PRODUCT_SERIAL = 7 > DMI_PRODUCT_UUID = 8 > DMI_BOARD_VENDOR = 9 > DMI_BOARD_NAME = 10 > DMI_BOARD_VERSION = 11 > DMI_BOARD_SERIAL = 12 > DMI_BOARD_ASSET_TAG = 13 > DMI_CHASSIS_VENDOR = 14 > DMI_CHASSIS_TYPE = 15 > DMI_CHASSIS_VERSION = 16 > DMI_CHASSIS_SERIAL = 17 > DMI_CHASSIS_ASSET_TAG = 18 > DMI_STRING_MAX = 19 > }; > > Although, gdb doesn't have the dmi_field enum data available like the > above in really old kernels, so in those rare cases it could only be > done as you have. Maybe there could be an index_to_DMI_field() function > that returns the string above, or just a number string if it can't do > the translation? > > Dave The attached patch is what I'm thinking. On a Lenovo laptop it looks like: crash> sys -i DMI_BIOS_VENDOR: LENOVO DMI_BIOS_VERSION: G4ET37WW (1.12 ) DMI_BIOS_DATE: 05/29/2012 DMI_SYS_VENDOR: LENOVO DMI_PRODUCT_NAME: 2429BQ1 DMI_PRODUCT_VERSION: ThinkPad T530 DMI_PRODUCT_SERIAL: R9R91HZ DMI_PRODUCT_UUID: 568DFA01-5180-11CB-B851-BD06085ADDB0 DMI_BOARD_VENDOR: LENOVO DMI_BOARD_NAME: 2429BQ1 DMI_BOARD_VERSION: Not Available DMI_BOARD_SERIAL: 1ZLV127F17M DMI_BOARD_ASSET_TAG: Not Available DMI_CHASSIS_VENDOR: LENOVO DMI_CHASSIS_TYPE: 10 DMI_CHASSIS_VERSION: Not Available DMI_CHASSIS_SERIAL: R9R91HZ DMI_CHASSIS_ASSET_TAG: RH0004111 crash> A recent HP kernel looks like this though: crash> sys -i DMI_BIOS_VENDOR: Hewlett-Packard DMI_BIOS_VERSION: 786F7 v01.05 DMI_BIOS_DATE: 04/25/2008 DMI_SYS_VENDOR: Hewlett-Packard DMI_PRODUCT_NAME: HP xw4550 Workstation DMI_PRODUCT_VERSION: DMI_PRODUCT_SERIAL: BAL1010051 DMI_PRODUCT_UUID: 308A59FA-9B77-DE11-BBDA-C486CC82001C DMI_BOARD_VENDOR: Hewlett-Packard DMI_BOARD_NAME: 0AC8h DMI_BOARD_VERSION: DMI_BOARD_SERIAL: BAL1010051 DMI_BOARD_ASSET_TAG: DMI_CHASSIS_VENDOR: Hewlett-Packard DMI_CHASSIS_TYPE: 6 DMI_CHASSIS_VERSION: DMI_CHASSIS_SERIAL: BAL1010051 DMI_CHASSIS_ASSET_TAG: crash> when the "empty" entries are not NULL pointers, but rather pointers to NULL strings or strings with spaces in them: crash> p dmi_ident dmi_ident = $1 = {0x0, 0xffffffff8203b000 "Hewlett-Packard", 0xffffffff8203b010 "786F7 v01.05", 0xffffffff8203b020 "04/25/2008", 0xffffffff8203b02c "Hewlett-Packard", 0xffffffff8203b03c "HP xw4550 Workstation", 0xffffffff8203b054 " ", 0xffffffff8203b058 "BAL1010051", 0xffffffff8203b064 "308A59FA-9B77-DE11-BBDA-C486CC82001C", 0xffffffff8203b08c "Hewlett-Packard", 0xffffffff8203b09c "0AC8h", 0xffffffff8203b0a4 "", 0xffffffff8203b0a8 "BAL1010051", 0xffffffff8203b0b4 "", 0xffffffff8203b0b8 "Hewlett-Packard", 0xffffffff8203b0c8 "6", 0xffffffff8203b0cc "", 0xffffffff8203b0d0 "BAL1010051", 0xffffffff8203b0dc " "} crash> Do you think those should should be just dropped, or shown as above? Dave
--- crash-7.1.3/help.c.orig +++ crash-7.1.3/help.c @@ -3231,7 +3231,7 @@ NULL char *help_sys[] = { "sys", "system data", -"[-c [name|number]] [-t] config", +"[-c [name|number]] [-t] [-i] config", " This command displays system-specific data. If no arguments are entered,\n" " the same system data shown during %s invocation is shown.\n", " -c [name|number] If no name or number argument is entered, dump all", @@ -3254,6 +3254,7 @@ char *help_sys[] = { " /dev/mem. Results in the %s context causing an", " \"Attempted to kill the idle task!\" panic. (The dump", " will indicate that the %s context has a PID of 0).", +" -i Dump the DMI string data if available in the kernel.", "\nEXAMPLES", " Display essential system information:\n", @@ -3318,6 +3319,26 @@ char *help_sys[] = { " ", " If the current output radix has been set to 16, the system call numbers", " will be displayed in hexadecimal.", +"\n Dump the DMI string data:\n", +" %s> sys -i", +" DMI_BIOS_VENDOR: LENOVO", +" DMI_BIOS_VERSION: G4ET37WW (1.12 )", +" DMI_BIOS_DATE: 05/29/2012", +" DMI_SYS_VENDOR: LENOVO", +" DMI_PRODUCT_NAME: 2429BQ1", +" DMI_PRODUCT_VERSION: ThinkPad T530", +" DMI_PRODUCT_SERIAL: R9R91HZ", +" DMI_PRODUCT_UUID: 568DFA01-5180-11CB-B851-BD06085ADDB0", +" DMI_BOARD_VENDOR: LENOVO", +" DMI_BOARD_NAME: 2429BQ1", +" DMI_BOARD_VERSION: Not Available", +" DMI_BOARD_SERIAL: 1ZLV127F17M", +" DMI_BOARD_ASSET_TAG: Not Available", +" DMI_CHASSIS_VENDOR: LENOVO", +" DMI_CHASSIS_TYPE: 10", +" DMI_CHASSIS_VERSION: Not Available", +" DMI_CHASSIS_SERIAL: R9R91HZ", +" DMI_CHASSIS_ASSET_TAG: RH0004111", NULL }; --- crash-7.1.3/kernel.c.orig +++ crash-7.1.3/kernel.c @@ -77,6 +77,7 @@ static void dump_log_legacy(void); static void dump_variable_length_record(void); static int is_livepatch(void); static void show_kernel_taints(char *, int); +static void dump_dmi_info(void); static void list_source_code(struct gnu_request *, int); static void source_tree_init(void); @@ -4924,7 +4925,7 @@ cmd_sys(void) sflag = FALSE; - while ((c = getopt(argcnt, args, "ctp:")) != EOF) { + while ((c = getopt(argcnt, args, "ctip:")) != EOF) { switch(c) { case 'p': @@ -4942,6 +4943,10 @@ cmd_sys(void) show_kernel_taints(buf, VERBOSE); return; + case 'i': + dump_dmi_info(); + return; + default: argerrs++; break; @@ -10112,3 +10117,67 @@ show_kernel_taints(char *buf, int verbos fprintf(fp, "TAINTED_MASK: %lx %s\n", tainted_mask, buf); } +static void +dump_dmi_info(void) +{ + int i, array_len, len, maxlen; + ulong dmi_ident_p, vaddr; + char buf1[BUFSIZE]; + char buf2[BUFSIZE]; + char *arglist[MAXARGS]; + + if (!kernel_symbol_exists("dmi_ident")) + error(FATAL, "dmi_ident does not exist in this kernel\n"); + + dmi_ident_p = symbol_value("dmi_ident"); + array_len = get_array_length("dmi_ident", NULL, 0); + maxlen = 0; + + open_tmpfile(); + + if (dump_enumerator_list("dmi_field") && (pc->debug == 0)) { + rewind(pc->tmpfile); + while (fgets(buf1, BUFSIZE, pc->tmpfile)) { + if (!strstr(buf1, " = ")) + continue; + if ((parse_line(buf1, arglist) != 3) || + (atoi(arglist[2]) >= array_len)) + break; + len = strlen(arglist[0]); + if (len > maxlen) + maxlen = len; + } + + rewind(pc->tmpfile); + while (fgets(buf1, BUFSIZE, pc->tmpfile)) { + if (!strstr(buf1, " = ")) + continue; + + if ((parse_line(buf1, arglist) != 3) || + ((i = atoi(arglist[2])) >= array_len)) + break; + + readmem(dmi_ident_p + (sizeof(void *) * i), + KVADDR, &vaddr, sizeof(void *), + "dmi_ident", FAULT_ON_ERROR); + if (!vaddr) + continue; + + read_string(vaddr, buf2, BUFSIZE-1); + fprintf(pc->saved_fp, " %s%s: %s\n", + space(maxlen - strlen(arglist[0])), arglist[0], buf2); + } + } else { + for (i = 0; i < array_len; i++) { + readmem(dmi_ident_p + (sizeof(void *) * i), + KVADDR, &vaddr, sizeof(void *), + "dmi_ident", FAULT_ON_ERROR); + if (!vaddr) + continue; + read_string(vaddr, buf1, BUFSIZE-1); + fprintf(pc->saved_fp, " dmi_ident[%d]: %s\n", i, buf1); + } + } + + close_tmpfile(); +}
-- Crash-utility mailing list Crash-utility@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/crash-utility