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 <amakhalov@vmware.com>
This commit is contained in:
Alexey Makhalov 2021-03-19 21:07:26 -07:00 committed by Lianbo Jiang
parent 9fab193edb
commit 163abcbbab
4 changed files with 29 additions and 6 deletions

View File

@ -2593,13 +2593,22 @@ diskdump_kaslr_check()
return FALSE;
}
#ifdef X86_64
int
diskdump_get_nr_cpus(void)
{
return dd->num_qemu_notes;
if (dd->num_prstatus_notes)
return dd->num_prstatus_notes;
else if (dd->num_qemu_notes)
return dd->num_qemu_notes;
else if (dd->num_vmcoredd_notes)
return dd->num_vmcoredd_notes;
else if (dd->header->nr_cpus)
return dd->header->nr_cpus;
return 1;
}
#ifdef X86_64
QEMUCPUState *
diskdump_get_qemucpustate(int cpu)
{

View File

@ -1070,6 +1070,15 @@ int crash_get_nr_cpus(void);
int crash_get_nr_cpus(void)
{
if (SADUMP_DUMPFILE())
return sadump_get_nr_cpus();
else if (DISKDUMP_DUMPFILE())
return diskdump_get_nr_cpus();
else if (KDUMP_DUMPFILE())
return kdump_get_nr_cpus();
else if (VMSS_DUMPFILE())
return vmware_vmss_get_nr_cpus();
/* Just CPU #0 */
return 1;
}

View File

@ -5206,11 +5206,17 @@ kdump_kaslr_check(void)
return FALSE;
}
#ifdef X86_64
int
kdump_get_nr_cpus(void)
{
return nd->num_qemu_notes;
if (nd->num_prstatus_notes)
return nd->num_prstatus_notes;
else if (nd->num_qemu_notes)
return nd->num_qemu_notes;
else if (nd->num_vmcoredd_notes)
return nd->num_vmcoredd_notes;
return 1;
}
QEMUCPUState *
@ -5232,7 +5238,6 @@ kdump_get_qemucpustate(int cpu)
return (QEMUCPUState *)nd->nt_qemu_percpu[cpu];
}
#endif
static void *
get_kdump_device_dump_offset(void)

View File

@ -1670,7 +1670,6 @@ get_sadump_data(void)
return sd;
}
#ifdef X86_64
int
sadump_get_nr_cpus(void)
{
@ -1678,6 +1677,7 @@ sadump_get_nr_cpus(void)
return sd->dump_header->nr_cpus;
}
#ifdef X86_64
int
sadump_get_cr3_cr4_idtr(int cpu, ulong *cr3, ulong *cr4, ulong *idtr)
{