[Crash-utility] Make note information human readable when help -D

Dave Anderson anderson at redhat.com
Wed Dec 10 22:27:06 UTC 2014



----- Original Message -----
> Hello all,
> 
> When analysing elf format core, if "help -D" is specified, crash will
> show dumpfile contents/statistics. But the output is hardly to read.
> So the patches is to make it human readable.
> 
> When analysing kdump format core, if "help -D" is specified, crash won't
> show the note information. The patches add note information to the output.

Hello Zhou,

I haven't had the chance to fully test this patch, but I do
have a few prelinaries to get out of the way.

First, please address all of these warnings:

$ make warn
... [ cut ] ...
cc -c -g -DX86_64 -DLZO -DSNAPPY -DGDB_7_6  netdump.c -Wall -O2 -Wstrict-prototypes -Wmissing-prototypes -fstack-protector -Wformat-security 
netdump.c: In function 'dump_Elf32_Nhdr':
netdump.c:1987:4: warning: format not a string literal and no format arguments [-Wformat-security]
netdump.c: In function 'dump_Elf64_Nhdr':
netdump.c:2272:4: warning: format not a string literal and no format arguments [-Wformat-security]
netdump.c:2303:4: warning: format not a string literal and no format arguments [-Wformat-security]
netdump.c: At top level:
netdump.c:2593:1: warning: no previous prototype for 'display_prstatus_elf64' [-Wmissing-prototypes]
netdump.c: In function 'display_prstatus_elf64':
netdump.c:2643:3: warning: format '%d' expects argument of type 'int', but argument 7 has type 'long unsigned int' [-Wformat]
netdump.c:2643:3: warning: format '%d' expects argument of type 'int', but argument 8 has type 'long unsigned int' [-Wformat]
netdump.c:2643:3: warning: format '%d' expects argument of type 'int', but argument 13 has type '__time_t' [-Wformat]
netdump.c:2643:3: warning: format '%d' expects argument of type 'int', but argument 14 has type '__suseconds_t' [-Wformat]
netdump.c:2643:3: warning: format '%d' expects argument of type 'int', but argument 15 has type '__time_t' [-Wformat]
netdump.c:2643:3: warning: format '%d' expects argument of type 'int', but argument 16 has type '__suseconds_t' [-Wformat]
netdump.c:2643:3: warning: format '%d' expects argument of type 'int', but argument 17 has type '__time_t' [-Wformat]
netdump.c:2643:3: warning: format '%d' expects argument of type 'int', but argument 18 has type '__suseconds_t' [-Wformat]
netdump.c:2643:3: warning: format '%d' expects argument of type 'int', but argument 19 has type '__time_t' [-Wformat]
netdump.c:2643:3: warning: format '%d' expects argument of type 'int', but argument 20 has type '__suseconds_t' [-Wformat]
netdump.c:2643:3: warning: format '%d' expects argument of type 'int', but argument 21 has type 'long unsigned int' [-Wformat]
netdump.c:2643:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 23 has type 'long unsigned int' [-Wformat]
netdump.c:2643:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 24 has type 'long unsigned int' [-Wformat]
netdump.c:2643:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 25 has type 'long unsigned int' [-Wformat]
netdump.c:2643:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 26 has type 'long unsigned int' [-Wformat]
netdump.c:2643:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 27 has type 'long unsigned int' [-Wformat]
netdump.c:2643:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 28 has type 'long unsigned int' [-Wformat]
netdump.c:2643:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 29 has type 'long unsigned int' [-Wformat]
netdump.c:2643:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 30 has type 'long unsigned int' [-Wformat]
netdump.c:2643:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 31 has type 'long unsigned int' [-Wformat]
netdump.c:2643:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 32 has type 'long unsigned int' [-Wformat]
netdump.c:2643:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 33 has type 'long unsigned int' [-Wformat]
netdump.c:2643:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 34 has type 'long unsigned int' [-Wformat]
netdump.c:2643:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 35 has type 'long unsigned int' [-Wformat]
netdump.c:2643:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 36 has type 'long unsigned int' [-Wformat]
netdump.c:2643:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 37 has type 'long unsigned int' [-Wformat]
netdump.c:2643:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 38 has type 'long unsigned int' [-Wformat]
netdump.c:2643:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 39 has type 'long unsigned int' [-Wformat]
netdump.c:2643:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 40 has type 'long unsigned int' [-Wformat]
netdump.c:2643:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 41 has type 'long unsigned int' [-Wformat]
netdump.c:2643:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 42 has type 'long unsigned int' [-Wformat]
netdump.c: At top level:
netdump.c:2673:1: warning: no previous prototype for 'display_prstatus_elf32' [-Wmissing-prototypes]
netdump.c: In function 'display_prstatus_elf32':
netdump.c:2713:3: warning: format '%d' expects argument of type 'int', but argument 7 has type 'long unsigned int' [-Wformat]
netdump.c:2713:3: warning: format '%d' expects argument of type 'int', but argument 8 has type 'long unsigned int' [-Wformat]
netdump.c:2713:3: warning: format '%d' expects argument of type 'int', but argument 13 has type '__time_t' [-Wformat]
netdump.c:2713:3: warning: format '%d' expects argument of type 'int', but argument 14 has type '__suseconds_t' [-Wformat]
netdump.c:2713:3: warning: format '%d' expects argument of type 'int', but argument 15 has type '__time_t' [-Wformat]
netdump.c:2713:3: warning: format '%d' expects argument of type 'int', but argument 16 has type '__suseconds_t' [-Wformat]
netdump.c:2713:3: warning: format '%d' expects argument of type 'int', but argument 17 has type '__time_t' [-Wformat]
netdump.c:2713:3: warning: format '%d' expects argument of type 'int', but argument 18 has type '__suseconds_t' [-Wformat]
netdump.c:2713:3: warning: format '%d' expects argument of type 'int', but argument 19 has type '__time_t' [-Wformat]
netdump.c:2713:3: warning: format '%d' expects argument of type 'int', but argument 20 has type '__suseconds_t' [-Wformat]
netdump.c:2713:3: warning: format '%d' expects argument of type 'int', but argument 21 has type 'long unsigned int' [-Wformat]
netdump.c: At top level:
netdump.c:2717:1: warning: no previous prototype for 'display_qemu_elf' [-Wmissing-prototypes]
netdump.c: In function 'display_qemu_elf':
netdump.c:2737:4: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'uint32_t' [-Wformat]
netdump.c:2737:4: warning: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'uint32_t' [-Wformat]
netdump.c:2737:4: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 5 has type 'uint64_t' [-Wformat]
netdump.c:2737:4: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 6 has type 'uint64_t' [-Wformat]
netdump.c:2737:4: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 7 has type 'uint64_t' [-Wformat]
netdump.c:2737:4: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 8 has type 'uint64_t' [-Wformat]
netdump.c:2737:4: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 9 has type 'uint64_t' [-Wformat]
netdump.c:2737:4: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 10 has type 'uint64_t' [-Wformat]
netdump.c:2737:4: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 11 has type 'uint64_t' [-Wformat]
netdump.c:2737:4: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 12 has type 'uint64_t' [-Wformat]
netdump.c:2749:5: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 3 has type 'uint64_t' [-Wformat]
netdump.c:2749:5: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 4 has type 'uint64_t' [-Wformat]
netdump.c:2749:5: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 5 has type 'uint64_t' [-Wformat]
netdump.c:2749:5: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 6 has type 'uint64_t' [-Wformat]
netdump.c:2749:5: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 7 has type 'uint64_t' [-Wformat]
netdump.c:2749:5: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 8 has type 'uint64_t' [-Wformat]
netdump.c:2749:5: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 9 has type 'uint64_t' [-Wformat]
netdump.c:2749:5: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 10 has type 'uint64_t' [-Wformat]
netdump.c:2761:5: warning: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'uint32_t' [-Wformat]
netdump.c:2761:5: warning: format '%lx' expects argument of type 'long unsigned int', but argument 5 has type 'uint32_t' [-Wformat]
netdump.c:2761:5: warning: format '%lx' expects argument of type 'long unsigned int', but argument 6 has type 'uint32_t' [-Wformat]
netdump.c:2761:5: warning: format '%lx' expects argument of type 'long unsigned int', but argument 7 has type 'uint32_t' [-Wformat]
netdump.c:2761:5: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 8 has type 'uint64_t' [-Wformat]
netdump.c:2771:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 3 has type 'uint64_t' [-Wformat]
netdump.c:2771:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 4 has type 'uint64_t' [-Wformat]
netdump.c:2771:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 5 has type 'uint64_t' [-Wformat]
netdump.c:2771:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 6 has type 'uint64_t' [-Wformat]
netdump.c:2771:3: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 7 has type 'uint64_t' [-Wformat]
netdump.c: At top level:
netdump.c:2775:1: warning: no previous prototype for 'display_qemu_elf64' [-Wmissing-prototypes]
netdump.c:2788:1: warning: no previous prototype for 'display_qemu_elf32' [-Wmissing-prototypes]
netdump.c:2801:1: warning: no previous prototype for 'display_note' [-Wmissing-prototypes]
cc -c -g -DX86_64 -DLZO -DSNAPPY -DGDB_7_6  diskdump.c -Wall -O2 -Wstrict-prototypes -Wmissing-prototypes -fstack-protector -Wformat-security 
diskdump.c: In function '__diskdump_memory_dump':
diskdump.c:1749:41: warning: implicit declaration of function 'display_note_elf32' [-Wimplicit-function-declaration]
diskdump.c:1751:41: warning: implicit declaration of function 'display_note_elf64' [-Wimplicit-function-declaration]
diskdump.c:1752:33: warning: format not a string literal and no format arguments [-Wformat-security]
...

Secondly, for compressed kdumps in diskdump.c, you have this construct:

       if (dd->machine_type == EM_386)
               display_note_elf32(dd->nt_prstatus_percpu[i],l_buf);
       else if (dd->machine_type == EM_X86_64)
               display_note_elf64(dd->nt_prstatus_percpu[i],l_buf);

But for ELF kdumps in netdump.c, display_note_elf32() are display_note_elf64()
look to be called unconditionally.  What about the other architectures?

Also, are there any dumping facilities that actually utilize any of
the nt_prstatus fields besides the registers and maybe the pid?:

struct x86_64_prstatus {
        int si_signo;
        int si_code;
        int si_errno;
        short cursig;
        unsigned long sigpend;
        unsigned long sighold;
        int pid;
        int ppid;
        int pgrp;
        int sid;
        struct timeval utime;
        struct timeval stime;
        struct timeval cutime;
        struct timeval cstime;
        struct x86_64_user_regs_struct regs;
        int fpvalid;
};

For example, kdump just does this:

        memset(&prstatus, 0, sizeof(prstatus));
        prstatus.pr_pid = current->pid;
        elf_core_copy_kernel_regs(&prstatus.pr_reg, regs);

So I guess I wonder what is the point of displaying of all the other fields?

Also, can you explain to me the difference between the register contents
in the QEMUCPUState structure vs. the register contents in the NT_PRSTATUS
note? 

And related to that question, why doesn't your dump_qemu_elf() function
display the rip and rflags registers?

Dave




More information about the Crash-utility mailing list