[Crash-utility] [PATCH] sys: Introduce -i option to dump dmi_ident data
Aaron Tomlin
atomlin at redhat.com
Wed Dec 9 12:37:57 UTC 2015
On Tue 2015-12-08 12:15 -0500, Dave Anderson wrote:
Hi Dave,
Sorry for the delay. Please find a v2 patch attached with a similar
approach to your attempt to add support for 'dmi_field' when available.
> 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?
What does 'dmidecode' show? If dmidecode shows the same, I'd suggest that
perhaps we should follow suit.
--
Aaron Tomlin
-------------- next part --------------
>From df03f6d79760d974fbec78421f988c86e2a46cfb Mon Sep 17 00:00:00 2001
From: Aaron Tomlin <atomlin at redhat.com>
Date: Sun, 6 Dec 2015 09:58:45 +0000
Subject: [PATCH v2] sys: Introduce -i option to dump dmi_ident data
This patch introduces a '-i' option to the 'sys' command to allow the user
to conveniently display the DMI (Desktop Management Interface) table,
if available in the kernel. For example:
crash> sys -i
DMI_BIOS_VENDOR: LENOVO
DMI_BIOS_VERSION: GIET75WW (2.25 )
DMI_BIOS_DATE: 06/24/2014
DMI_SYS_VENDOR: LENOVO
DMI_PRODUCT_NAME: 20AMS22U0C
DMI_PRODUCT_VERSION: ThinkPad X240
DMI_PRODUCT_SERIAL: PC00CDZE
DMI_PRODUCT_UUID: 01338439-0853-CB11-8EBB-CE1D1FC1CBC0
DMI_BOARD_VENDOR: LENOVO
DMI_BOARD_NAME: 20AMS22U0C
DMI_BOARD_VERSION: Not Defined
DMI_BOARD_SERIAL: L1HF47E00T3
DMI_BOARD_ASSET_TAG: Not Available
DMI_CHASSIS_VENDOR: LENOVO
DMI_CHASSIS_TYPE: 10
DMI_CHASSIS_VERSION: Not Available
DMI_CHASSIS_SERIAL: PC00CDZE
DMI_CHASSIS_ASSET_TAG: No Asset Information
crash>
For older kernels that do not have 'dmi_field' enum data available, the
output is as follows:
crash> sys -i
dmi_ident[1]: LENOVO
dmi_ident[2]: GIET75WW (2.25 )
dmi_ident[3]: 06/24/2014
dmi_ident[4]: LENOVO
dmi_ident[5]: 20AMS22U0C
dmi_ident[6]: ThinkPad X240
dmi_ident[7]: PC00CDZE
dmi_ident[8]: 01338439-0853-CB11-8EBB-CE1D1FC1CBC0
dmi_ident[9]: LENOVO
dmi_ident[10]: 20AMS22U0C
dmi_ident[11]: Not Defined
dmi_ident[12]: L1HF47E00T3
dmi_ident[13]: Not Available
dmi_ident[14]: LENOVO
dmi_ident[15]: 10
dmi_ident[16]: Not Available
dmi_ident[17]: PC00CDZE
dmi_ident[18]: No Asset Information
crash>
Suggested-by: Buland Singh <bsingh at redhat.com>
Signed-off-by: Aaron Tomlin <atomlin at redhat.com>
---
help.c | 23 ++++++++++++++++++++++-
kernel.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 80 insertions(+), 2 deletions(-)
diff --git a/help.c b/help.c
index 4834f4b..f9d654e 100644
--- a/help.c
+++ b/help.c
@@ -3231,7 +3231,7 @@ NULL
char *help_sys[] = {
"sys",
"system data",
-"[-c [name|number]] [-t] config",
+"[-c [name|number]] [-t] config [-i]",
" 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 dmi_ident 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 dmi_ident data:\n",
+" %s> sys -i",
+" DMI_BIOS_VENDOR: LENOVO",
+" DMI_BIOS_VERSION: GIET75WW (2.25 )",
+" DMI_BIOS_DATE: 06/24/2014",
+" DMI_SYS_VENDOR: LENOVO",
+" DMI_PRODUCT_NAME: 20AMS22U0C",
+" DMI_PRODUCT_VERSION: ThinkPad X240",
+" DMI_PRODUCT_SERIAL: PC00CDZE",
+" DMI_PRODUCT_UUID: 01338439-0853-CB11-8EBB-CE1D1FC1CBC0",
+" DMI_BOARD_VENDOR: LENOVO",
+" DMI_BOARD_NAME: 20AMS22U0C",
+" DMI_BOARD_VERSION: Not Defined",
+" DMI_BOARD_SERIAL: L1HF47E00T3",
+" DMI_BOARD_ASSET_TAG: Not Available",
+" DMI_CHASSIS_VENDOR: LENOVO",
+" DMI_CHASSIS_TYPE: 10",
+" DMI_CHASSIS_VERSION: Not Available",
+" DMI_CHASSIS_SERIAL: PC00CDZE",
+" DMI_CHASSIS_ASSET_TAG: No Asset Information",
NULL
};
diff --git a/kernel.c b/kernel.c
index dbba05a..096cfa2 100644
--- a/kernel.c
+++ b/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':
@@ -4941,6 +4942,9 @@ cmd_sys(void)
case 't':
show_kernel_taints(buf, VERBOSE);
return;
+ case 'i':
+ dump_dmi_info();
+ return;
default:
argerrs++;
@@ -10112,3 +10116,56 @@ show_kernel_taints(char *buf, int verbose)
fprintf(fp, "TAINTED_MASK: %lx %s\n", tainted_mask, buf);
}
+static void
+dump_dmi_info(void)
+{
+ int i, len;
+ ulong dmi_ident_p, vaddr;
+ char buf[BUFSIZE];
+ char dmi_str[BUFSIZE];
+ char *arglist[MAXARGS];
+
+ if (!kernel_symbol_exists("dmi_ident")) {
+ error(INFO, "dmi_ident does not exist in this kernel\n");
+ }
+
+ dmi_ident_p = symbol_value("dmi_ident");
+ len = get_array_length("dmi_ident", NULL, 0);
+
+ open_tmpfile();
+ if (dump_enumerator_list("dmi_field")) {
+ rewind(pc->tmpfile);
+ while (fgets(buf, BUFSIZE, pc->tmpfile)) {
+ if (!strstr(buf, " = "))
+ continue;
+
+ parse_line(buf, arglist);
+
+ i = atoi(arglist[2]);
+ if (i >= len)
+ break;
+
+ readmem(dmi_ident_p + (sizeof(void *) * i),
+ KVADDR, &vaddr, sizeof(void *),
+ "dmi_ident", FAULT_ON_ERROR);
+
+ if (!vaddr)
+ continue;
+ read_string(vaddr, dmi_str, BUFSIZE-1);
+ fprintf(pc->saved_fp, " %25s: %s\n", arglist[0],
+ dmi_str);
+ }
+ } else {
+ for (i = 0; i < len; i++) {
+ readmem(dmi_ident_p + (sizeof(void *) * i),
+ KVADDR, &vaddr, sizeof(void *),
+ "dmi_ident", FAULT_ON_ERROR);
+
+ if (!vaddr)
+ continue;
+ read_string(vaddr, buf, BUFSIZE-1);
+ fprintf(pc->saved_fp, " dmi_ident[%d]: %s\n", i, buf);
+ }
+ }
+ close_tmpfile();
+}
--
2.4.3
More information about the Crash-utility
mailing list