[Crash-utility] [PATCH v2] vmware_vmss: read vCPUs regs and show them in 'bt'

Dave Anderson anderson at redhat.com
Thu Mar 22 14:22:10 UTC 2018



----- Original Message -----
> VMSS dump files contain the state of each vCPU at the time of suspending
> the VM. This change enables 'crash' to read some relevant registers from
> each vCPU state to display them in 'bt' and adds additional output for
> commands 'help -D', 'help -r' and 'help -p'.
> 
> This is also the first step towards implementing kaslr offset
> calculation for VMSS dump files.
> ---
>  defs.h        |   5 +
>  help.c        |   3 +
>  kernel.c      |   2 +
>  main.c        |   3 +
>  memory.c      |   2 +
>  vmware_vmss.c | 375
>  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
>  vmware_vmss.h |  31 +++++
>  x86_64.c      |  13 +-
>  8 files changed, 424 insertions(+), 10 deletions(-)
> 

Hi Sergio,

I should have mentioned this before, but there is a build option 
for compiling with several warning ptions, which should result in
clean compiles.  Here on an x86_64:

$ make warn
... [ cut ] ...
cc -c -g -DX86_64 -DLZO -DSNAPPY -DGDB_7_6  vmware_vmss.c -Wall -O2 -Wstrict-prototypes -Wmissing-prototypes -fstack-protector -Wformat-security 
vmware_vmss.c: In function ‘vmware_vmss_init’:
vmware_vmss.c:242:6: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
      vmss.regs64[cpu]->idtr = *((uint64_t *)(&buf[0] + 2));
      ^
vmware_vmss.c: In function ‘vmware_vmss_display_regs’:
vmware_vmss.c:439:3: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘uint64_t’ [-Wformat=]
   );
   ^
vmware_vmss.c:439:3: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:439:3: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 5 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:439:3: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 6 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:439:3: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 7 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:439:3: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 8 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:439:3: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 9 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:439:3: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 10 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:439:3: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 11 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:439:3: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 12 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:439:3: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 13 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:439:3: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 14 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:439:3: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 15 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:439:3: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 16 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:439:3: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 17 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:439:3: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 18 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:439:3: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 19 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:439:3: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 20 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c: In function ‘get_vmware_vmss_regs’:
vmware_vmss.c:447:23: warning: unused variable ‘rp’ [-Wunused-variable]
  struct register_set *rp;
                       ^
vmware_vmss.c: In function ‘vmware_vmss_memory_dump’:
vmware_vmss.c:501:4: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat=]
    errno, strerror(errno));
    ^
vmware_vmss.c:501:4: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘char *’ [-Wformat=]
vmware_vmss.c:501:4: warning: format ‘%s’ expects a matching ‘char *’ argument [-Wformat=]
vmware_vmss.c: In function ‘dump_registers_for_vmss_dump’:
vmware_vmss.c:695:4: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘uint64_t’ [-Wformat=]
    regs->rax, regs->rbx, regs->rcx);
    ^
vmware_vmss.c:695:4: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:695:4: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 5 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:697:4: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘uint64_t’ [-Wformat=]
    regs->rdx, regs->rsi, regs->rdi);
    ^
vmware_vmss.c:697:4: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:697:4: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 5 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:699:4: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘uint64_t’ [-Wformat=]
    regs->rsp, regs->rbp, regs->r8);
    ^
vmware_vmss.c:699:4: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:699:4: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 5 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:701:4: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘uint64_t’ [-Wformat=]
    regs->r9, regs->r10, regs->r11);
    ^
vmware_vmss.c:701:4: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:701:4: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 5 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:703:4: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘uint64_t’ [-Wformat=]
    regs->r12, regs->r13, regs->r14);
    ^
vmware_vmss.c:703:4: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:703:4: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 5 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:705:4: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘uint64_t’ [-Wformat=]
    regs->r15, regs->rip, regs->rflags);
    ^
vmware_vmss.c:705:4: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:705:4: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 5 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:707:25: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘uint64_t’ [-Wformat=]
                         regs->idtr);
                         ^
vmware_vmss.c:709:4: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘uint64_t’ [-Wformat=]
    regs->cr[0], regs->cr[1], regs->cr[2]);
    ^
vmware_vmss.c:709:4: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:709:4: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 5 has type ‘uint64_t’ [-Wformat=]
vmware_vmss.c:711:4: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘uint64_t’ [-Wformat=]
    regs->cr[3], regs->cr[4]);
    ^
vmware_vmss.c:711:4: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘uint64_t’ [-Wformat=]
cc -c -g -DX86_64 -DLZO -DSNAPPY -DGDB_7_6  xen_dom0.c -Wall -O2 -Wstrict-prototypes -Wmissing-prototypes -fstack-protector -Wformat-security 
...

And here on 32-bit x86:

$ make warn
... [ cut ] ...
cc -c -g -DX86 -m32 -D_FILE_OFFSET_BITS=64 -DLZO -DSNAPPY -DGDB_7_6  vmware_vmss.c -Wall -O2 -Wstrict-prototypes -Wmissing-prototypes -fstack-protector -Wformat-security 
vmware_vmss.c: In function ‘vmware_vmss_init’:
vmware_vmss.c:242:6: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
      vmss.regs64[cpu]->idtr = *((uint64_t *)(&buf[0] + 2));
      ^
vmware_vmss.c: In function ‘get_vmware_vmss_regs’:
vmware_vmss.c:447:23: warning: unused variable ‘rp’ [-Wunused-variable]
  struct register_set *rp;
                       ^
vmware_vmss.c: In function ‘vmware_vmss_memory_dump’:
vmware_vmss.c:501:4: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat=]
    errno, strerror(errno));
    ^
vmware_vmss.c:501:4: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘char *’ [-Wformat=]
vmware_vmss.c:501:4: warning: format ‘%s’ expects a matching ‘char *’ argument [-Wformat=]
...

Can you clean these up?

Thanks,
  Dave




More information about the Crash-utility mailing list