[PATCH v2 07/25] modify help -r to hide offline cpus' registers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



help -r can display registers on three types of vmcore:
1. qemu memoly-only dump
2. kdump(kdump-compressed format)
3. kdump(elf format)

This patch will hide the offline cpus' registers.

With data of offline cpu hiden, the output is like below

1. qemu memory-only dump, cpu#1 and cpu#2 are offline
<cut>
...
  idt:
    selector:00000000  limit:00000fff  flags:00000000
    pad:00000000  base:ffffffffff529000
  cr[0]:000000008005003b  cr[1]:0000000000000000  cr[2]:00007f6885fa3000
  cr[3]:000000003b481000  cr[4]:00000000000006f0

CPU 1: <OFFLINE>

CPU 2: <OFFLINE>

CPU 3:
  rax:00000000ffffffed  rbx:ffff88003daeffd8  rcx:0100000000000000
  rdx:0000000000000000  rsi:0000000000000000  rdi:0000000000000046
  rsp:ffff88003daefe98  rbp:ffff88003daefe98   r8:0000000000000000
   r9:0000000000000000  r10:0000000000000013  r11:ffff88003db45028
  r12:0000000000000003  r13:ffff88003daeffd8  r14:0000000000000000
  r15:ffff88003daeffd8  rip:ffffffff81046346  rflags:00000286
...
<cut>

2. kdump(kdump-compressed format), cpu#2 is offline
<cut>
...
CPU 1:
    RIP: ffffffff8134b6c6  RSP: ffff88003df25e18  RFLAGS: 00010096
    RAX: 0000000000000010  RBX: 0000000000000063  RCX: 0000000000000000
    RDX: 0000000000000000  RSI: 0000000000000000  RDI: 0000000000000063
    RBP: ffff88003df25e18   R8: 0000000000000000   R9: ffffffff81645da0
    R10: 0000000000000001  R11: 0000000000000000  R12: 0000000000000000
    R13: ffffffff81b01a40  R14: 0000000000000286  R15: 0000000000000004
    CS: 0010  SS: 0018

CPU 2: <OFFLINE>

CPU 3:
    RIP: ffffffff81015670  RSP: ffff88003f3fdca0  RFLAGS: 00000097
    RAX: 0000000000000000  RBX: 000000000000001f  RCX: 0000000000000000
    RDX: 00000000000003d5  RSI: 000000000000001f  RDI: ffffffff81fdd2a8
...
<cut>

3. kdump(elf format), cpu #1 is offline
<cut>
...
    RBP: ffffffff818c3e98   R8: 0000000000000000   R9: 0000000000000000
    R10: 0000000000000000  R11: 0000000000000000  R12: 0000000000000000
    R13: ffffffff818c3fd8  R14: ffff88003ff54780  R15: ffffffff818c3fd8
    CS: 0010  SS: 0018

CPU 1: <OFFLINE>

CPU 2:
    RIP: ffffffff81046346  RSP: ffff88003daede98  RFLAGS: 00000286
    RAX: 00000000ffffffed  RBX: ffff88003daedfd8  RCX: 0100000000000000
    RDX: 0000000000000000  RSI: 0000000000000000  RDI: 0000000000000046
    RBP: ffff88003daede98   R8: 0000000000000000   R9: 0000000000000000
...
<cut>

Signed-off-by: Qiao Nuohan <qiaonuohan@xxxxxxxxxxxxxx>
---
 diskdump.c |  6 +++++-
 netdump.c  | 25 +++++++++++++++++++++++--
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/diskdump.c b/diskdump.c
index 7639e32..08216ab 100644
--- a/diskdump.c
+++ b/diskdump.c
@@ -2057,7 +2057,11 @@ dump_registers_for_compressed_kdump(void)
 		error(FATAL, "-r option not supported for this dumpfile\n");
 
 	for (c = 0; c < kt->cpus; c++) {
-		fprintf(fp, "%sCPU %d:\n", c ? "\n" : "", c);
+		if (hide_offline_cpu(c)) {
+			fprintf(fp, "%sCPU %d: <OFFLINE>\n", c ? "\n" : "", c);
+			continue;
+		} else
+			fprintf(fp, "%sCPU %d:\n", c ? "\n" : "", c);
 		diskdump_display_regs(c, fp);
 	}
 }
diff --git a/netdump.c b/netdump.c
index e946b45..9cce479 100644
--- a/netdump.c
+++ b/netdump.c
@@ -2380,8 +2380,19 @@ display_regs_from_elf_notes(int cpu)
 	Elf64_Nhdr *note64;
 	size_t len;
 	char *user_regs;
+	int c, skipped_count;
 
-	if (cpu >= nd->num_prstatus_notes) {
+	/*
+	 * NT_PRSTATUS notes are only related to online cpus, offline cpus
+	 * should be skipped.
+	 */
+	skipped_count = 0;
+	for (c = 0; c < cpu; c++) {
+		if (check_offline_cpu(c))
+			skipped_count++;
+	}
+
+	if ((cpu - skipped_count) >= nd->num_prstatus_notes) {
 		error(INFO, "registers not collected for cpu %d\n", cpu);
 		return;
 	}
@@ -2488,6 +2499,11 @@ dump_registers_for_elf_dumpfiles(void)
 	}
 
         for (c = 0; c < kt->cpus; c++) {
+		if (check_offline_cpu(c)) {
+			fprintf(fp, "%sCPU %d: <OFFLINE>\n", c ? "\n" : "", c);
+			continue;
+		}
+
                 fprintf(fp, "%sCPU %d:\n", c ? "\n" : "", c);
                 display_regs_from_elf_notes(c);
         }
@@ -3786,7 +3802,12 @@ dump_registers_for_qemu_mem_dump(void)
 
 		if (i)
 			netdump_print("\n");
-		netdump_print("CPU %d:\n", i);
+
+		if (hide_offline_cpu(i)) {
+			netdump_print("CPU %d: <OFFLINE>\n", i);
+			continue;
+		} else
+			netdump_print("CPU %d:\n", i);
 
 		if (CRASHDEBUG(1))
 			netdump_print("  version:%08lx      size:%08lx\n",
-- 
1.8.5.3

--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux