From 0192dc985b00e9451738da6ecd4aa5fceaaa9892 Mon Sep 17 00:00:00 2001 From: Qiao Nuohan Date: Sat, 23 Aug 2014 10:47:09 +0800 Subject: [PATCH 06/23] x86_64: modify help -r only to display online cpu's registers 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. Signed-off-by: Qiao Nuohan --- diskdump.c | 3 +++ netdump.c | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/diskdump.c b/diskdump.c index e230c1f..d462492 100644 --- a/diskdump.c +++ b/diskdump.c @@ -2057,6 +2057,9 @@ dump_registers_for_compressed_kdump(void) error(FATAL, "-r option not supported for this dumpfile\n"); for (c = 0; c < kt->cpus; c++) { + if (check_offline_cpu(c)) + continue; + fprintf(fp, "%sCPU %d:\n", c ? "\n" : "", c); diskdump_display_regs(c, fp); } diff --git a/netdump.c b/netdump.c index c86a992..644807b 100644 --- a/netdump.c +++ b/netdump.c @@ -2354,8 +2354,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; } @@ -2462,6 +2473,9 @@ dump_registers_for_elf_dumpfiles(void) } for (c = 0; c < kt->cpus; c++) { + if (check_offline_cpu(c)) + continue; + fprintf(fp, "%sCPU %d:\n", c ? "\n" : "", c); display_regs_from_elf_notes(c); } @@ -3756,6 +3770,9 @@ dump_registers_for_qemu_mem_dump(void) nd->ofp = fp; for (i=0; inum_qemu_notes; i++) { + if (check_offline_cpu(i)) + continue; + ptr = (QEMUCPUState *)nd->nt_qemu_percpu[i]; if (i) -- 1.8.5.3