From patchwork Thu Dec 20 01:24:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viktor Prutyanov X-Patchwork-Id: 10738441 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 53C3F6C2 for ; Thu, 20 Dec 2018 01:29:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40B6E28628 for ; Thu, 20 Dec 2018 01:29:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34D4C2862D; Thu, 20 Dec 2018 01:29:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9D93D28628 for ; Thu, 20 Dec 2018 01:29:48 +0000 (UTC) Received: from localhost ([::1]:34863 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZn9n-0000xS-PZ for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 20:29:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46605) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZn5b-0005qk-VJ for qemu-devel@nongnu.org; Wed, 19 Dec 2018 20:25:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZn5X-00030A-Nz for qemu-devel@nongnu.org; Wed, 19 Dec 2018 20:25:27 -0500 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]:37340) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gZn5V-0002le-Qf for qemu-devel@nongnu.org; Wed, 19 Dec 2018 20:25:22 -0500 Received: by mail-lj1-x22c.google.com with SMTP id t18-v6so74708ljd.4 for ; Wed, 19 Dec 2018 17:25:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=phystech-edu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Esf22o4ogI3Xl5N2sUXDNWQ2NEP9WHH/uuQQJ7XfxAg=; b=EHGK6hEns76uXqZIp1bFwSdHrAET8MOUx47ndbkSdwuYqjhIqLzwGohrcz5GQQ5S/7 Jd9HjGxeE99n1cIbKV2ar/NbA5lyR5ennmkzNb86rLy+5LULk1j9MjFkG0tMx+weLSmO 8YNpDIz8gKsUaFpt0Q1H5m5mk8Q6nA92qmSEiyQB8XG/6YKkJ4WmY981Pp7LU0zJFYzG j9LzTd28MKK4LtpM5ngLuU0uHwAQDki1Sinu35VLCL0a+d+RGfafr4DpoeZxhAEu7WoQ vs862T25pSnGznJLXumcun6D/ejZ+S3A6ywBVFAHiyGu5R00GxPXrACK6qzGitmzFk5N rwpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Esf22o4ogI3Xl5N2sUXDNWQ2NEP9WHH/uuQQJ7XfxAg=; b=f3zOK8vWtYHcWMNblHMt6Mzjpi4zEHjXxeyOsMr+6R4m4ZJU7AEDSBGVRaR+yOqvxx 4dln/TdEKyf+G69szJA/gYfgRfdVdRGJ/+mkSo+p7TIJDKRtHxDj6/4gK9ikE5txQz32 CijfewK9Lmur2UtcGTvRmZgxjDPmBeXCJ3i36jhpqLRKp/Ws7fx2YKnJQk0GkR/vHFi2 MNLXK6Nao8uBWEkZxM3X3hgKM+w/qtGKpzCTHno++nHB9gQFxK3nREyByPaTtDgXlxD6 pfjZXPQ2VxW9V+VSbVN7fvUmbElXMXAfZK3pov7Mr0N3XIaw6YOiF2ceM8e1AR+AcEbb IVOQ== X-Gm-Message-State: AA+aEWaulqD5RWnpMBARsoEwMrKxM4T86VrXBQh5uxgSHrQB4Uut8khc QkyYcMfGIHLk7kPbl0B4Z2CtUA== X-Google-Smtp-Source: AFSGD/ULJVdZueaa5syR5GA1+0f3PklHoMbtRWigxn2XqVuqm0UaRFy9eJt4J8uYyWKsGP90CsX7Gw== X-Received: by 2002:a2e:9e16:: with SMTP id e22-v6mr2533985ljk.4.1545269109550; Wed, 19 Dec 2018 17:25:09 -0800 (PST) Received: from localhost.localdomain ([93.175.11.132]) by smtp.gmail.com with ESMTPSA id z7-v6sm3737540lji.42.2018.12.19.17.25.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Dec 2018 17:25:08 -0800 (PST) From: Viktor Prutyanov To: pbonzini@redhat.com, rkagan@virtuozzo.com Date: Thu, 20 Dec 2018 04:24:40 +0300 Message-Id: <20181220012441.13694-6-viktor.prutyanov@phystech.edu> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181220012441.13694-1-viktor.prutyanov@phystech.edu> References: <20181220012441.13694-1-viktor.prutyanov@phystech.edu> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::22c Subject: [Qemu-devel] [PATCH v2 5/6] contrib/elf2dmp: fix printf format X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Viktor Prutyanov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Format strings for printf are changed for successful build for Windows hosts. Signed-off-by: Viktor Prutyanov --- contrib/elf2dmp/main.c | 27 +++++++++++++++------------ contrib/elf2dmp/pdb.c | 4 +++- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c index 9b93dab662..fdafb54900 100644 --- a/contrib/elf2dmp/main.c +++ b/contrib/elf2dmp/main.c @@ -5,6 +5,8 @@ * */ +#include + #include "qemu/osdep.h" #include "err.h" #include "addrspace.h" @@ -41,7 +43,8 @@ static const uint64_t SharedUserData = 0xfffff78000000000; #define KUSD_OFFSET_PRODUCT_TYPE 0x264 #define SYM_RESOLVE(base, r, s) ((s = pdb_resolve(base, r, #s)),\ - s ? printf(#s" = 0x%016lx\n", s) : eprintf("Failed to resolve "#s"\n"), s) + s ? printf(#s" = 0x%016"PRIx64"\n", s) :\ + eprintf("Failed to resolve "#s"\n"), s) static uint64_t rol(uint64_t x, uint64_t y) { @@ -98,8 +101,8 @@ static KDDEBUGGER_DATA64 *get_kdbg(uint64_t KernBase, struct pdb_reader *pdb, return NULL; } - printf("[KiWaitNever] = 0x%016lx\n", kwn); - printf("[KiWaitAlways] = 0x%016lx\n", kwa); + printf("[KiWaitNever] = 0x%016"PRIx64"\n", kwn); + printf("[KiWaitAlways] = 0x%016"PRIx64"\n", kwa); /* * If KDBG header can be decoded, KDBG size is available @@ -202,7 +205,7 @@ static int fix_dtb(struct va_space *vs, QEMU_Elf *qe) if (is_system(s)) { va_space_set_dtb(vs, s->cr[3]); - printf("DTB 0x%016lx has been found from CPU #%zu" + printf("DTB 0x%016"PRIx64" has been found from CPU #%zu" " as system task CR3\n", vs->dtb, i); return !(va_space_resolve(vs, SharedUserData)); } @@ -222,7 +225,7 @@ static int fix_dtb(struct va_space *vs, QEMU_Elf *qe) } va_space_set_dtb(vs, *cr3); - printf("DirectoryTableBase = 0x%016lx has been found from CPU #0" + printf("DirectoryTableBase = 0x%016"PRIx64" has been found from CPU #0" " as interrupt handling CR3\n", vs->dtb); return !(va_space_resolve(vs, SharedUserData)); } @@ -393,8 +396,8 @@ static int pe_get_pdb_symstore_hash(uint64_t base, void *start_addr, return 1; } - printf("Debug Directory RVA = 0x%016x\n", - data_dir[IMAGE_FILE_DEBUG_DIRECTORY].VirtualAddress); + printf("Debug Directory RVA = 0x%08"PRIx32"\n", + (uint32_t)data_dir[IMAGE_FILE_DEBUG_DIRECTORY].VirtualAddress); if (va_space_rw(vs, base + data_dir[IMAGE_FILE_DEBUG_DIRECTORY].VirtualAddress, @@ -488,7 +491,7 @@ int main(int argc, char *argv[]) } state = qemu_elf.state[0]; - printf("CPU #0 CR3 is 0x%016lx\n", state->cr[3]); + printf("CPU #0 CR3 is 0x%016"PRIx64"\n", state->cr[3]); va_space_create(&vs, &ps, state->cr[3]); if (fix_dtb(&vs, &qemu_elf)) { @@ -497,7 +500,7 @@ int main(int argc, char *argv[]) goto out_elf; } - printf("CPU #0 IDT is at 0x%016lx\n", state->idt.base); + printf("CPU #0 IDT is at 0x%016"PRIx64"\n", state->idt.base); if (va_space_rw(&vs, state->idt.base, &first_idt_desc, sizeof(first_idt_desc), 0)) { @@ -505,10 +508,10 @@ int main(int argc, char *argv[]) err = 1; goto out_ps; } - printf("CPU #0 IDT[0] -> 0x%016lx\n", idt_desc_addr(first_idt_desc)); + printf("CPU #0 IDT[0] -> 0x%016"PRIx64"\n", idt_desc_addr(first_idt_desc)); KernBase = idt_desc_addr(first_idt_desc) & ~(PAGE_SIZE - 1); - printf("Searching kernel downwards from 0x%16lx...\n", KernBase); + printf("Searching kernel downwards from 0x%016"PRIx64"...\n", KernBase); for (; KernBase >= 0xfffff78000000000; KernBase -= PAGE_SIZE) { nt_start_addr = va_space_resolve(&vs, KernBase); @@ -521,7 +524,7 @@ int main(int argc, char *argv[]) } } - printf("KernBase = 0x%16lx, signature is \'%.2s\'\n", KernBase, + printf("KernBase = 0x%016"PRIx64", signature is \'%.2s\'\n", KernBase, (char *)nt_start_addr); if (pe_get_pdb_symstore_hash(KernBase, nt_start_addr, pdb_hash, &vs)) { diff --git a/contrib/elf2dmp/pdb.c b/contrib/elf2dmp/pdb.c index 52e352df79..64af20f584 100644 --- a/contrib/elf2dmp/pdb.c +++ b/contrib/elf2dmp/pdb.c @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include + #include "qemu/osdep.h" #include "pdb.h" #include "err.h" @@ -66,7 +68,7 @@ uint64_t pdb_find_public_v3_symbol(struct pdb_reader *r, const char *name) uint32_t sect_rva = segment->dword[1]; uint64_t rva = sect_rva + sym->public_v3.offset; - printf("%s: 0x%016x(%d:\'%.8s\') + 0x%08x = 0x%09lx\n", name, + printf("%s: 0x%016x(%d:\'%.8s\') + 0x%08x = 0x%09"PRIx64"\n", name, sect_rva, sym->public_v3.segment, ((char *)segment - 8), sym->public_v3.offset, rva); return rva;