On Tue, 7 Jun 2022 at 16:33, Vladimir Sementsov-Ogievskiy <vsement...@yandex-team.ru> wrote: > > Add a variable with QEMU_FULL_VERSION definition. Then the content of > the variable is easily searchable: > > strings /path/to/core | grep QEMU_FULL_VERSION > > 'volatile' keyword is used to avoid removing the variable by compiler as > unused. > > Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@yandex-team.ru> > --- > > Hi all! > > Probably, I just don't know the correct way to get version from core > file. If so, please teach me :)
I've never hit this issue because bug reports usually include the QEMU distro package version. Keeping the version string in the core file seems reasonable (unless there is already another way to do this). Something I'm curious about: is the coredump guaranteed to contain static const variables? I wondered if they might be located in the .rodata ELF section and excluded from the coredump because they are referenced in the NT_FILE mmap note instead. Maybe volatile prevents this? I CCed Laszlo because I think he worked on crash dumping in the past and might know the answer to my question about coredumps. Stefan > > softmmu/vl.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/softmmu/vl.c b/softmmu/vl.c > index 4c1e94b00e..1f51a713a0 100644 > --- a/softmmu/vl.c > +++ b/softmmu/vl.c > @@ -164,6 +164,19 @@ typedef struct DeviceOption { > QTAILQ_ENTRY(DeviceOption) next; > } DeviceOption; > > +/* > + * qemu_full_version_decl is for debugging. Assume you have coredump file, > but > + * don't know the version neither have original qemu binary file. You need to > + * download a package with corresponding binary (and debug package with > + * symbols), but which one? You need the version. > + * > + * This variable makes it simple to get the version by command > + * > + * strings path/to/core | grep QEMU_FULL_VERSION > + */ > +static volatile const char qemu_full_version_decl[] = > + "QEMU_FULL_VERSION: " QEMU_FULL_VERSION; > + > static const char *cpu_option; > static const char *mem_path; > static const char *incoming; > -- > 2.25.1 > >