Skip to content

Commit 163abcb

Browse files
Alexey Makhalovlian-bo
authored andcommitted
crash_get_nr_cpus: get nr_cpus from the dumps
Most of the dumps have information about real number of CPUS. Use that to instantiate GDB's target inferior threads. Signed-off-by: Alexey Makhalov <[email protected]>
1 parent 9fab193 commit 163abcb

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

diskdump.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2593,13 +2593,22 @@ diskdump_kaslr_check()
25932593
return FALSE;
25942594
}
25952595

2596-
#ifdef X86_64
25972596
int
25982597
diskdump_get_nr_cpus(void)
25992598
{
2600-
return dd->num_qemu_notes;
2599+
if (dd->num_prstatus_notes)
2600+
return dd->num_prstatus_notes;
2601+
else if (dd->num_qemu_notes)
2602+
return dd->num_qemu_notes;
2603+
else if (dd->num_vmcoredd_notes)
2604+
return dd->num_vmcoredd_notes;
2605+
else if (dd->header->nr_cpus)
2606+
return dd->header->nr_cpus;
2607+
2608+
return 1;
26012609
}
26022610

2611+
#ifdef X86_64
26032612
QEMUCPUState *
26042613
diskdump_get_qemucpustate(int cpu)
26052614
{

gdb_interface.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,15 @@ int crash_get_nr_cpus(void);
10701070

10711071
int crash_get_nr_cpus(void)
10721072
{
1073+
if (SADUMP_DUMPFILE())
1074+
return sadump_get_nr_cpus();
1075+
else if (DISKDUMP_DUMPFILE())
1076+
return diskdump_get_nr_cpus();
1077+
else if (KDUMP_DUMPFILE())
1078+
return kdump_get_nr_cpus();
1079+
else if (VMSS_DUMPFILE())
1080+
return vmware_vmss_get_nr_cpus();
1081+
10731082
/* Just CPU #0 */
10741083
return 1;
10751084
}

netdump.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5206,11 +5206,17 @@ kdump_kaslr_check(void)
52065206
return FALSE;
52075207
}
52085208

5209-
#ifdef X86_64
52105209
int
52115210
kdump_get_nr_cpus(void)
52125211
{
5213-
return nd->num_qemu_notes;
5212+
if (nd->num_prstatus_notes)
5213+
return nd->num_prstatus_notes;
5214+
else if (nd->num_qemu_notes)
5215+
return nd->num_qemu_notes;
5216+
else if (nd->num_vmcoredd_notes)
5217+
return nd->num_vmcoredd_notes;
5218+
5219+
return 1;
52145220
}
52155221

52165222
QEMUCPUState *
@@ -5232,7 +5238,6 @@ kdump_get_qemucpustate(int cpu)
52325238

52335239
return (QEMUCPUState *)nd->nt_qemu_percpu[cpu];
52345240
}
5235-
#endif
52365241

52375242
static void *
52385243
get_kdump_device_dump_offset(void)

sadump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1670,14 +1670,14 @@ get_sadump_data(void)
16701670
return sd;
16711671
}
16721672

1673-
#ifdef X86_64
16741673
int
16751674
sadump_get_nr_cpus(void)
16761675
{
16771676
/* apicids */
16781677
return sd->dump_header->nr_cpus;
16791678
}
16801679

1680+
#ifdef X86_64
16811681
int
16821682
sadump_get_cr3_cr4_idtr(int cpu, ulong *cr3, ulong *cr4, ulong *idtr)
16831683
{

0 commit comments

Comments
 (0)