[Crash-utility] - [PATCH v2 2/3] vmware: vmss beautify and extend debug log

HAGIO KAZUHITO(萩尾 一仁) k-hagio-ab at nec.com
Wed Aug 12 04:53:26 UTC 2020


Hi Mathias,

-----Original Message-----
> The parser's debug log is missing a few line breaks as well as some
> crucial information, like control register dumps.
> 
> Add them for read- and debugability.
> 
> Signed-off-by: Mathias Krause <minipli at grsecurity.net>
> ---
>  vmware_vmss.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/vmware_vmss.c b/vmware_vmss.c
> index 11b7b72bf503..2eee36c3daec 100644
> --- a/vmware_vmss.c
> +++ b/vmware_vmss.c
> @@ -175,8 +175,10 @@ vmware_vmss_init(char *filename, FILE *ofp)
>  				}
>  				DEBUG_PARSE_PRINT((ofp, "[%d]", idx[j]));
>  			}
> -		       if (nextgroup)
> +			if (nextgroup) {
> +				DEBUG_PARSE_PRINT((ofp, "\n"));
>  				break;
> +			}
> 
>  			if (IS_BLOCK_TAG(tag)) {
>  				uint64_t nbytes;
> @@ -232,16 +234,21 @@ vmware_vmss_init(char *filename, FILE *ofp)
>  						      filename, errno, strerror(errno));
>  						break;
>  					}
> +					DEBUG_PARSE_PRINT((ofp, "\n"));
>  					vmss.vcpu_regs[cpu] |= REGS_PRESENT_GPREGS;
>  				} else if (strcmp(name, "CR64") == 0 &&
>  					   nbytes == VMW_CR64_SIZE &&
>  					   idx[0] < vmss.num_vcpus) {
>  					int cpu = idx[0];
> +					DEBUG_PARSE_PRINT((ofp, "\t=> "));
>  					if (fread(&vmss.regs64[cpu]->cr[0], VMW_CR64_SIZE, 1, fp) != 1) {
>  						error(INFO, LOGPRX"Failed to read '%s': [Error %d] %s\n",
>  						      filename, errno, strerror(errno));
>  						break;
>  					}
> +					for (j = 0; j < VMW_CR64_SIZE / 8; j++)
> +						DEBUG_PARSE_PRINT((ofp, "%s%016llX", j ? " " : "",
> vmss.regs64[cpu]->cr[j]));

This warning is emitted.

$ make warn
...
cc -c -g -DX86_64 -DSNAPPY -DLZO -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:250:7: warning: format ‘%llX’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘uint64_t’ [-Wformat=]
       DEBUG_PARSE_PRINT((ofp, "%s%016llX", j ? " " : "", vmss.regs64[cpu]->cr[j]));
       ^

I'll fix when merging.

-                                               DEBUG_PARSE_PRINT((ofp, "%s%016llX", j ? " " : "", vmss.regs64[cpu]->cr[j]));
+                                               DEBUG_PARSE_PRINT((ofp, "%s%016llX", j ? " " : "",
+                                                               (ulonglong)vmss.regs64[cpu]->cr[j]));

Thanks,
Kazu

> +					DEBUG_PARSE_PRINT((ofp, "\n"));
>  					vmss.vcpu_regs[cpu] |= REGS_PRESENT_CRS;
>  				} else if (strcmp(name, "IDTR") == 0 &&
>  					   nbytes == VMW_IDTR_SIZE &&
> @@ -258,6 +265,7 @@ vmware_vmss_init(char *filename, FILE *ofp)
>  						      filename, errno, strerror(errno));
>  						break;
>  					}
> +					DEBUG_PARSE_PRINT((ofp, "\n"));
>  					vmss.regs64[cpu]->idtr = idtr;
>  					vmss.vcpu_regs[cpu] |= REGS_PRESENT_IDTR;
>  				} else {
> @@ -266,6 +274,7 @@ vmware_vmss_init(char *filename, FILE *ofp)
>  						      (ulonglong)(blockpos + nbytes));
>  						break;
>  					}
> +					DEBUG_PARSE_PRINT((ofp, "\n"));
>  				}
>  			} else {
>  				union {
> --
> 2.20.1
> 
> 
> --
> Crash-utility mailing list
> Crash-utility at redhat.com
> https://www.redhat.com/mailman/listinfo/crash-utility





More information about the Crash-utility mailing list