From patchwork Thu Dec 20 01:24:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viktor Prutyanov X-Patchwork-Id: 10738445 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 07F8E6C2 for ; Thu, 20 Dec 2018 01:31:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB2502862D for ; Thu, 20 Dec 2018 01:31:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF9B12863C; Thu, 20 Dec 2018 01:31:24 +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 6F2A72862D for ; Thu, 20 Dec 2018 01:31:24 +0000 (UTC) Received: from localhost ([::1]:34874 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZnBL-0002CW-8y for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 20:31:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZn5b-0005qm-VI for qemu-devel@nongnu.org; Wed, 19 Dec 2018 20:25:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZn5W-0002yh-2k for qemu-devel@nongnu.org; Wed, 19 Dec 2018 20:25:27 -0500 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]:36610) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gZn5U-0002eO-4S for qemu-devel@nongnu.org; Wed, 19 Dec 2018 20:25:21 -0500 Received: by mail-lj1-x243.google.com with SMTP id g11-v6so75895ljk.3 for ; Wed, 19 Dec 2018 17:25:05 -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=IPSzqTv3Wak3m5D9CJEuMA2pjP+j4nG1GFFJptXDEQA=; b=RWc20JLZ1ChMxgTru4NeHnO0AqfZTuLAzaP4OE29Tvpvb6cP15KX1dw02zwkhxAPpi AbC9gtVvOP+Qr4JGDlAp+t/BPpNDafjqUi93EywqKMDcnWBqMw4a8NuGHOMNciiJ2xTZ GvXK9WpuNsNlHEpk9K8vroo3FBbfeLlgfsarH0AteR+Q7Ms2v5W9+UKUEvSllBBsjAZ7 t4qNvtTHXu2Ec7qPVP3B53LyrLoLUapf7vw7P6KMSV88ns8tbRUwstXBXyeMUjC0V1MO a+rS9qlRp3I5TkZpcLVaXbD+dpdDeLyYKJoGZX3AoCqAyDpNMOrGUqOZtK67a6djnxK8 0QUg== 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=IPSzqTv3Wak3m5D9CJEuMA2pjP+j4nG1GFFJptXDEQA=; b=OyWwph0OyFLD6BHODRmk9Lucp8kJTlhHBnzU3I0q9YVfxVKlD9+iS0Km/tixgAhSdw cgLbhiMHLyKAqeeBX3QWs5MTYayt8RRXtr5ShgR6rqN9KGTCgGfVb3lefG1SoG7jtEsf 9AJHBM5kAk6liwqpzNEfIJ+FoiU6xaF4DiscIVKyvD8lzPWBSmH6yMzOBBJUnTWcoq9S rbP5wctezpFQkevxgrYWpqbXs/5ulHtjMdjAv+ZWJmiQitk+pKmQYwpGg28GDneWtMxs qWp6e8tFrKCzJ0r888SgK+cz4Gi5Awyin3cOxThn5H6Pc4BEP+zFGVDgPx7zXCtSQb/u WuPw== X-Gm-Message-State: AA+aEWblTir0ZdDhzq7kB3jskVf/WdHg1pnxWeznoVktVYsrcuPN6tHY wb2H4NZ99AEhpsWLH15Kbvq1IA== X-Google-Smtp-Source: AFSGD/XpusdDfEfP77K1r7ati413BfUyW0vzVsFWJDCY6DRxWsHUQcZLzpNA9yVtUUBGqlurfb+RSg== X-Received: by 2002:a2e:9256:: with SMTP id v22-v6mr6983015ljg.178.1545269104023; Wed, 19 Dec 2018 17:25:04 -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.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Dec 2018 17:25:03 -0800 (PST) From: Viktor Prutyanov To: pbonzini@redhat.com, rkagan@virtuozzo.com Date: Thu, 20 Dec 2018 04:24:36 +0300 Message-Id: <20181220012441.13694-2-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::243 Subject: [Qemu-devel] [PATCH v2 1/6] contrib/elf2dmp: fix elf.h including 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 Before this patch QEMU elf.h was not actually included. Signed-off-by: Viktor Prutyanov --- contrib/elf2dmp/qemu_elf.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/elf2dmp/qemu_elf.h b/contrib/elf2dmp/qemu_elf.h index d85d6558fa..19d1299954 100644 --- a/contrib/elf2dmp/qemu_elf.h +++ b/contrib/elf2dmp/qemu_elf.h @@ -5,11 +5,11 @@ * */ -#ifndef QEMU_ELF_H -#define QEMU_ELF_H +#ifndef ELF2DMP_ELF_H +#define ELF2DMP_ELF_H #include -#include +#include "elf.h" typedef struct QEMUCPUSegment { uint32_t selector; @@ -48,4 +48,4 @@ void QEMU_Elf_exit(QEMU_Elf *qe); Elf64_Phdr *elf64_getphdr(void *map); Elf64_Half elf_getphdrnum(void *map); -#endif /* QEMU_ELF_H */ +#endif /* ELF2DMP_ELF_H */ From patchwork Thu Dec 20 01:24:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viktor Prutyanov X-Patchwork-Id: 10738439 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 8326A1399 for ; Thu, 20 Dec 2018 01:28:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F6EE2860B for ; Thu, 20 Dec 2018 01:28:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5ED762861D; Thu, 20 Dec 2018 01:28:59 +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 EB3152860B for ; Thu, 20 Dec 2018 01:28:58 +0000 (UTC) Received: from localhost ([::1]:34860 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZn8z-0000Ln-VV for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 20:28:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46567) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZn5U-0005mH-4C for qemu-devel@nongnu.org; Wed, 19 Dec 2018 20:25:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZn5T-0002wG-6S for qemu-devel@nongnu.org; Wed, 19 Dec 2018 20:25:19 -0500 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]:33526) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gZn5Q-0002fI-EH for qemu-devel@nongnu.org; Wed, 19 Dec 2018 20:25:17 -0500 Received: by mail-lf1-x144.google.com with SMTP id i26so77351lfc.0 for ; Wed, 19 Dec 2018 17:25:06 -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=JAyA7BqK1HhsNSgFJs4dpakarkygPGi9jp2igGrUPWU=; b=xUtc2BoxZaPesH6MXHWpQzPzcFtLsi8JQngBR9d2tMlAlLRmjwFpu+A/yhnWEVD82Y cxOZexYtQDkjb/nYnhV5OwGQCEdOwu+pDEgvNfZ2ROYmL2y/xinyeCvO60gs3VBUDPrr /yzEOHG0iD8zjcPwOsNIKiuAiodDNETLlte7zEZC8Ag1/r1JZeN6lADvJWEO9w85SI1n XVeDwbvb6r+kxcdVqSyNTvNI3/KMqKH22fuyNaqGVr10+Gp1UU+EA4a5OcjUDdJSevD7 Ov+MBJHa65NOuI26N6RszJQIwDE1bVi/Q3Xyu4r82JDPyO4HBWZGuNkssbffqiZRQjCi 3ZxA== 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=JAyA7BqK1HhsNSgFJs4dpakarkygPGi9jp2igGrUPWU=; b=IQu7XpJ7cm3d7OeKX9ib5TLu8nLa2puDVNPyUIz15RoPZ4/yJuwmZeivAGrMZkJYrY w7Vw46adC+NoUveS0tatwHK1keu8FBSlr/4rzQiQYIHVIuFqvChXI/2Fx4McqpXoV+u5 i8YUWkWikn8xD6rsTwzorLq55uzq4L9Yk5V+yKbPzN2h/jtI/TfwSWJvdTfigOLvpVTc W6g16kdd7P/f+kCzng9RIW9WGIX1QM+dYvmhh9rgIEpo62r5c5b/Zm2jPjq65xsr5L32 k8JdeAHGz0KrlqRTSmpfhr8lC5lIX6WVtwr+S3p67jkoT6ZrOsAxtD7/kDnwZdaIEDxi 6gYw== X-Gm-Message-State: AA+aEWYNZKDcF9nRbWP1HT3MjOfhWyX8+5NThR33ascrCbFwcuI6VYFl 5mPSTpsNtL4A8gd5ZJmkGnIoTQ== X-Google-Smtp-Source: AFSGD/VszncSqyae53o4xwsme3d9qRx8znjhi7T9SX5bwSMVzo9+HLMc59spgHXbGNHKU/gMISxucg== X-Received: by 2002:a19:9904:: with SMTP id b4mr13266364lfe.95.1545269105243; Wed, 19 Dec 2018 17:25:05 -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.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Dec 2018 17:25:04 -0800 (PST) From: Viktor Prutyanov To: pbonzini@redhat.com, rkagan@virtuozzo.com Date: Thu, 20 Dec 2018 04:24:37 +0300 Message-Id: <20181220012441.13694-3-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::144 Subject: [Qemu-devel] [PATCH v2 2/6] contrib/elf2dmp: use GLib in ELF processing 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 Replace POSIX mmap with GLib g_mapped_file_new in ELF processing module to make elf2dmp cross-platform. Signed-off-by: Viktor Prutyanov --- contrib/elf2dmp/qemu_elf.c | 27 ++++++++------------------- contrib/elf2dmp/qemu_elf.h | 2 +- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/contrib/elf2dmp/qemu_elf.c b/contrib/elf2dmp/qemu_elf.c index e9c0d2534a..0db7816586 100644 --- a/contrib/elf2dmp/qemu_elf.c +++ b/contrib/elf2dmp/qemu_elf.c @@ -120,25 +120,17 @@ static void exit_states(QEMU_Elf *qe) int QEMU_Elf_init(QEMU_Elf *qe, const char *filename) { + GError *gerr = NULL; int err = 0; - struct stat st; - qe->fd = open(filename, O_RDONLY, 0); - if (qe->fd == -1) { - eprintf("Failed to open ELF dump file \'%s\'\n", filename); + qe->gmf = g_mapped_file_new(filename, TRUE, &gerr); + if (gerr) { + eprintf("Failed to map ELF dump file \'%s\'\n", filename); return 1; } - fstat(qe->fd, &st); - qe->size = st.st_size; - - qe->map = mmap(NULL, qe->size, PROT_READ | PROT_WRITE, - MAP_PRIVATE, qe->fd, 0); - if (qe->map == MAP_FAILED) { - eprintf("Failed to map ELF file\n"); - err = 1; - goto out_fd; - } + qe->map = g_mapped_file_get_contents(qe->gmf); + qe->size = g_mapped_file_get_length(qe->gmf); if (init_states(qe)) { eprintf("Failed to extract QEMU CPU states\n"); @@ -149,9 +141,7 @@ int QEMU_Elf_init(QEMU_Elf *qe, const char *filename) return 0; out_unmap: - munmap(qe->map, qe->size); -out_fd: - close(qe->fd); + g_mapped_file_unref(qe->gmf); return err; } @@ -159,6 +149,5 @@ out_fd: void QEMU_Elf_exit(QEMU_Elf *qe) { exit_states(qe); - munmap(qe->map, qe->size); - close(qe->fd); + g_mapped_file_unref(qe->gmf); } diff --git a/contrib/elf2dmp/qemu_elf.h b/contrib/elf2dmp/qemu_elf.h index 19d1299954..fc69606d00 100644 --- a/contrib/elf2dmp/qemu_elf.h +++ b/contrib/elf2dmp/qemu_elf.h @@ -34,7 +34,7 @@ typedef struct QEMUCPUState { int is_system(QEMUCPUState *s); typedef struct QEMU_Elf { - int fd; + GMappedFile *gmf; size_t size; void *map; QEMUCPUState **state; From patchwork Thu Dec 20 01:24:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viktor Prutyanov X-Patchwork-Id: 10738443 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 EC1B56C5 for ; Thu, 20 Dec 2018 01:30:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA89B2863D for ; Thu, 20 Dec 2018 01:30:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE5E32863E; Thu, 20 Dec 2018 01:30:23 +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 690982863C for ; Thu, 20 Dec 2018 01:30:23 +0000 (UTC) Received: from localhost ([::1]:34871 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZnAM-0001Tl-Hi for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 20:30:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZn5b-0005ql-VF for qemu-devel@nongnu.org; Wed, 19 Dec 2018 20:25:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZn5X-00030N-Vs for qemu-devel@nongnu.org; Wed, 19 Dec 2018 20:25:27 -0500 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]:33234) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gZn5W-0002gK-1f for qemu-devel@nongnu.org; Wed, 19 Dec 2018 20:25:23 -0500 Received: by mail-lj1-x244.google.com with SMTP id v1-v6so85893ljd.0 for ; Wed, 19 Dec 2018 17:25:07 -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=50bkBNnopCIabFq0KYD4Rn26wGbOyf+b3JGsbOd950A=; b=L6KImHxU80Knpa+BdpZDfeDGTdWOb+L2UGFnB1ntXTeCrcCs2omFGThoutLkVyZHXP jJC+Qh0Mjp+q9AZWfW7mBnfbnzyYRQVl9SpvKjKJxtXKz0wn6xE0cCiWre8thtZo7qsT 29HFxqQy/CpRJZxwuy7fK6njp9hT5G0zBI3N9gMjmRoJVaTl4omG6HgmcIekGUSAxHfZ tSDqhbUX1wF5cIKp0bm1IJcJA5qM5ezgNf+9OgwU0I5tS13ovYRluzbw0PJPphd5ZdaW ssmse5jpqoEmdIaUlmC39cdnaj/sYd5xPGUPuHINFBNbKk9eFNrp4Tnh8Tx1HgCAAHjj MMqA== 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=50bkBNnopCIabFq0KYD4Rn26wGbOyf+b3JGsbOd950A=; b=VkLnk05LFXmFZdLU6VnofG1g+1MIg/o7FG37rP0EhkxX0g/y79T+1uNvQAvmc6pP/7 PyBkTWXpvoYzQiqlNx3MhMHhy+YYdwxbjRQHw0QneR7MnM7F6eTZsKfXkpISofQHMELq dwbZe0nQ/H8MbYKoXHLI/8l0ppJrghY2zs7PHbeC+6Se9m9dGgo/o9L0vf51fpBpNDiU uihGP5WHRm7S+lukdRgZHgQYEimOIOrS67pIU+L0PFnHh1rWqB3QDv93b350mmwpF2oW +2+ne98JoktOVd7vu8D32xauo4BuHo0V6/yOT+8fOKYlYURx/0oH5GK5v04SBEaC5JSE Vfdw== X-Gm-Message-State: AA+aEWabDfBpIe2TBGfoKX0AktzIVYvyQfMtMcfwx7zGJeV/G1n3NSLy K4txgYZt8uKNuxNKNUBEzcNaAMmsJKAufA== X-Google-Smtp-Source: AFSGD/WtHFKoT8ZUNNsbNwIKEvzbbNuCTtC726bPFrW/AdjnkulR2L5YtlDLCg0Cupdly4Odba74sA== X-Received: by 2002:a05:651c:14e:: with SMTP id c14mr13279011ljd.20.1545269106308; Wed, 19 Dec 2018 17:25:06 -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.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Dec 2018 17:25:05 -0800 (PST) From: Viktor Prutyanov To: pbonzini@redhat.com, rkagan@virtuozzo.com Date: Thu, 20 Dec 2018 04:24:38 +0300 Message-Id: <20181220012441.13694-4-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::244 Subject: [Qemu-devel] [PATCH v2 3/6] contrib/elf2dmp: use GLib in PDB processing 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 Replace POSIX mmap with GLib g_mapped_file_new in PDB processing stage to make elf2dmp cross-platform. There are no direct POSIX in elf2dmp after this patch. Signed-off-by: Viktor Prutyanov --- contrib/elf2dmp/pdb.c | 29 ++++++++--------------------- contrib/elf2dmp/pdb.h | 2 +- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/contrib/elf2dmp/pdb.c b/contrib/elf2dmp/pdb.c index bcb01b414f..52e352df79 100644 --- a/contrib/elf2dmp/pdb.c +++ b/contrib/elf2dmp/pdb.c @@ -277,28 +277,18 @@ static void pdb_reader_exit(struct pdb_reader *r) int pdb_init_from_file(const char *name, struct pdb_reader *reader) { + GError *gerr = NULL; int err = 0; - int fd; void *map; - struct stat st; - fd = open(name, O_RDONLY, 0); - if (fd == -1) { - eprintf("Failed to open PDB file \'%s\'\n", name); + reader->gmf = g_mapped_file_new(name, TRUE, &gerr); + if (gerr) { + eprintf("Failed to map PDB file \'%s\'\n", name); return 1; } - reader->fd = fd; - - fstat(fd, &st); - reader->file_size = st.st_size; - - map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); - if (map == MAP_FAILED) { - eprintf("Failed to map PDB file\n"); - err = 1; - goto out_fd; - } + reader->file_size = g_mapped_file_get_length(reader->gmf); + map = g_mapped_file_get_contents(reader->gmf); if (pdb_reader_init(reader, map)) { err = 1; goto out_unmap; @@ -307,16 +297,13 @@ int pdb_init_from_file(const char *name, struct pdb_reader *reader) return 0; out_unmap: - munmap(map, st.st_size); -out_fd: - close(fd); + g_mapped_file_unref(reader->gmf); return err; } void pdb_exit(struct pdb_reader *reader) { - munmap(reader->ds.header, reader->file_size); - close(reader->fd); + g_mapped_file_unref(reader->gmf); pdb_reader_exit(reader); } diff --git a/contrib/elf2dmp/pdb.h b/contrib/elf2dmp/pdb.h index 4351a2dd61..8e395119d1 100644 --- a/contrib/elf2dmp/pdb.h +++ b/contrib/elf2dmp/pdb.h @@ -218,7 +218,7 @@ typedef struct pdb_seg { #define IMAGE_FILE_MACHINE_AMD64 0x8664 struct pdb_reader { - int fd; + GMappedFile *gmf; size_t file_size; struct { PDB_DS_HEADER *header; From patchwork Thu Dec 20 01:24:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viktor Prutyanov X-Patchwork-Id: 10738435 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 7F9196C2 for ; Thu, 20 Dec 2018 01:26:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EBB6285D3 for ; Thu, 20 Dec 2018 01:26:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6175A2862D; Thu, 20 Dec 2018 01:26:37 +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 E86BD285D3 for ; Thu, 20 Dec 2018 01:26:36 +0000 (UTC) Received: from localhost ([::1]:34851 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZn6i-0006hF-2c for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 20:26:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46547) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZn5S-0005lh-7u for qemu-devel@nongnu.org; Wed, 19 Dec 2018 20:25:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZn5O-0002rO-HR for qemu-devel@nongnu.org; Wed, 19 Dec 2018 20:25:17 -0500 Received: from mail-lj1-x242.google.com ([2a00:1450:4864:20::242]:44101) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gZn5M-0002hn-G9 for qemu-devel@nongnu.org; Wed, 19 Dec 2018 20:25:14 -0500 Received: by mail-lj1-x242.google.com with SMTP id k19-v6so53687lji.11 for ; Wed, 19 Dec 2018 17:25:09 -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=Umqhn6Kkplin6YC4y1bAqCXn4bmOnF6f82wm8iUV7Ek=; b=pfNUgzq/SDBeTTAFCuFl+aCxTXUnGlPqpYt98TfqFW66gWl8XGftDKaWr55YTdhEQp sQ6zkFUx1qr7JZa7oS0q1GpfncyhquR600bRhmJP/DVnYWIBsw4lg5GiO8RNRm/ftzuu iRvwkxXDN2KK78nFaUkLxAVV6Q4jbco5J3vu9eNATd9ShDmCAEDRi+Q+JaCRsESt738c 2FAzRkoXcLW6Vv+M9/HaFVg9qNiVXRO79VBDdNaNn0gop/I/vNWN1Dpxm68XH0GS2Kra 0gFlzZKfWlqBhYqxIdyZjvhdT0X+b4clWbWXLa88u3x+Fq5MdMPtZIqIgk30GR/i1hQR mF9w== 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=Umqhn6Kkplin6YC4y1bAqCXn4bmOnF6f82wm8iUV7Ek=; b=QhwVuP30+u1y+CaU8yEI3vb85Y5uKqk583sTtql/PWtrJWiF44CV+Bo8PvETziuivA skVt+0Wf2W6qD3vQz+SAmR8wRDf6q8p5D5tpPSWlhlnAHpC/u70U+i/eRt3zDQ/KRC3R RWH3Mm6Stgwjh5tCPmggHO1M5rbvYfEoxaG4DJWB8ClfmlETtQOonx674yEL4ui4ZPOz j+v2kX+M7CgyPDvCThdTQbFTE3gkcFhu+TCx8q7AG5dRECv+CfJv20N6WxNG2obc5lii FP+Ew57JvvaKYJnQIDQYIrtgox6MIrUDwkITdbX9Q4y6Mne5KHh2tswa8AV3IhlHOgUA uR+w== X-Gm-Message-State: AA+aEWb0WsGsdOfZSnpO87KNPn0HBOeFCnA3ka6OQ9hSToQUMYf4TqCl Zw3niv/kiqTraA9evHpju7gZeQ== X-Google-Smtp-Source: AFSGD/W8WjyDw8EKgOoRTCHBB0QQBVAoNXuMkv0U4VVt3KdaUsg/Pognl+mwIsaJFqpECMqNDdXMEA== X-Received: by 2002:a2e:89d7:: with SMTP id c23-v6mr15407796ljk.0.1545269107863; Wed, 19 Dec 2018 17:25:07 -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.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Dec 2018 17:25:07 -0800 (PST) From: Viktor Prutyanov To: pbonzini@redhat.com, rkagan@virtuozzo.com Date: Thu, 20 Dec 2018 04:24:39 +0300 Message-Id: <20181220012441.13694-5-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::242 Subject: [Qemu-devel] [PATCH v2 4/6] contrib/elf2dmp: fix structures definitions 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 Remove duplicate structures definitions in case of build for Windows hosts. Signed-off-by: Viktor Prutyanov --- contrib/elf2dmp/kdbg.h | 12 ++++++++---- contrib/elf2dmp/pdb.h | 2 ++ contrib/elf2dmp/pe.h | 6 ++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/contrib/elf2dmp/kdbg.h b/contrib/elf2dmp/kdbg.h index 851b57c321..002e3d0cd5 100644 --- a/contrib/elf2dmp/kdbg.h +++ b/contrib/elf2dmp/kdbg.h @@ -25,11 +25,15 @@ typedef struct DBGKD_GET_VERSION64 { uint64_t DebuggerDataList; } DBGKD_GET_VERSION64; +#ifndef _WIN32 +typedef struct LIST_ENTRY64 { + struct LIST_ENTRY64 *Flink; + struct LIST_ENTRY64 *Blink; +} LIST_ENTRY64; +#endif + typedef struct DBGKD_DEBUG_DATA_HEADER64 { - struct LIST_ENTRY64 { - struct LIST_ENTRY64 *Flink; - struct LIST_ENTRY64 *Blink; - } List; + LIST_ENTRY64 List; uint32_t OwnerTag; uint32_t Size; } DBGKD_DEBUG_DATA_HEADER64; diff --git a/contrib/elf2dmp/pdb.h b/contrib/elf2dmp/pdb.h index 8e395119d1..9a848f75e2 100644 --- a/contrib/elf2dmp/pdb.h +++ b/contrib/elf2dmp/pdb.h @@ -11,12 +11,14 @@ #include #include +#ifndef _WIN32 typedef struct GUID { unsigned int Data1; unsigned short Data2; unsigned short Data3; unsigned char Data4[8]; } GUID; +#endif struct PDB_FILE { uint32_t size; diff --git a/contrib/elf2dmp/pe.h b/contrib/elf2dmp/pe.h index 374e06a9c5..0fd5c23c7f 100644 --- a/contrib/elf2dmp/pe.h +++ b/contrib/elf2dmp/pe.h @@ -10,6 +10,7 @@ #include +#ifndef _WIN32 typedef struct IMAGE_DOS_HEADER { uint16_t e_magic; /* 0x00: MZ Header signature */ uint16_t e_cblp; /* 0x02: Bytes on last page of file */ @@ -88,8 +89,6 @@ typedef struct IMAGE_NT_HEADERS64 { IMAGE_OPTIONAL_HEADER64 OptionalHeader; } __attribute__ ((packed)) IMAGE_NT_HEADERS64; -#define IMAGE_FILE_DEBUG_DIRECTORY 6 - typedef struct IMAGE_DEBUG_DIRECTORY { uint32_t Characteristics; uint32_t TimeDateStamp; @@ -102,6 +101,9 @@ typedef struct IMAGE_DEBUG_DIRECTORY { } __attribute__ ((packed)) IMAGE_DEBUG_DIRECTORY; #define IMAGE_DEBUG_TYPE_CODEVIEW 2 +#endif + +#define IMAGE_FILE_DEBUG_DIRECTORY 6 typedef struct guid_t { uint32_t a; 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; From patchwork Thu Dec 20 01:24:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viktor Prutyanov X-Patchwork-Id: 10738437 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 A8B571399 for ; Thu, 20 Dec 2018 01:28:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97F092862A for ; Thu, 20 Dec 2018 01:28:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C46528639; Thu, 20 Dec 2018 01:28:05 +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 3D0062862A for ; Thu, 20 Dec 2018 01:28:05 +0000 (UTC) Received: from localhost ([::1]:34858 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZn88-0007oP-Cm for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 20:28:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46542) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZn5S-0005le-1G for qemu-devel@nongnu.org; Wed, 19 Dec 2018 20:25:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZn5O-0002rU-IL for qemu-devel@nongnu.org; Wed, 19 Dec 2018 20:25:16 -0500 Received: from mail-lf1-x141.google.com ([2a00:1450:4864:20::141]:36928) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gZn5M-0002nK-JV for qemu-devel@nongnu.org; Wed, 19 Dec 2018 20:25:14 -0500 Received: by mail-lf1-x141.google.com with SMTP id y11so65832lfj.4 for ; Wed, 19 Dec 2018 17:25:12 -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=tk6MyYP6tMJEmhporjWAYmI02qatXT9B3UUzmIFGqk8=; b=EaJdqn0gtTSSF0IObO/qucealn9Eu3es/+OeLD8CsqW+0anf7bUqHLfOyXuR7RAyvZ 2OSsyx0f/ttjUdIsLB+DIgWEoyfQM/bD7P2lWQ+vW/9pXcIjlhsv9c4/GvPQF22+YgD4 TmFZVoRMyltaRRu0GcQ8tc2db7Xqs4NUEPOx96buB7FCmHWSW7RremI6y9kUwN6LIMX6 x4frEvqqHzSt7jak4ArrmJFe4I+h+9WYbui/zdgQx9P7Wu90LEE+Sl8ZcrkWu7TMjyom rCJWJK3ZZfX2/7WZ8UpMaNnHWLwHbFUSfwpTg3gBh22hlAL0ge8U+ZhOUhhRQqAuBMQf BfCA== 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=tk6MyYP6tMJEmhporjWAYmI02qatXT9B3UUzmIFGqk8=; b=cDOZWHRtldWlZLcbBoADnR3b/RHr9ybEWpQsEV2g1uCwcDqZrBix/S1agfrJGgAMyW eeW6JPdtumPPnLvXEeOI0shHjO+m+mASlvzWLddqUw6qN9lfkMkGPt7IipE0GNldTcn9 IFbR3xtU8d9LtoWmbxv78Mi7xeZr7EmuOkkPNtqynCsyggHnfalj8Ep4rF/dPzA00ax4 nSSHKi9/cf37d487ScvTmqmO2dpxQtzKlPUTceTMVj8RRlu6zdtXBgo7Jqh7lveSjhvR UIIXjfnJ72IPjAeWdYG0gXl5wwm8hz56zAVxfi8PI3ript3XP293oYscweCvITqc8Hli Hz9w== X-Gm-Message-State: AA+aEWZ5Ytc/unJdfli6KVLEFG4vEIMUWi/P2GZNp3dpBmFuPAeMjC9W iw+ohUW2QmDe5hOpSiFnl0uaqzjz+6yazg== X-Google-Smtp-Source: AFSGD/VKFHMzPLcKKe+iiaQYA4q9PeF+xsD1jv3/0zsCjGtPdgTdj2tZoUl82kbBkR/PXLFurVV+7Q== X-Received: by 2002:a19:3809:: with SMTP id f9mr3186148lfa.148.1545269110950; Wed, 19 Dec 2018 17:25:10 -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.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Dec 2018 17:25:10 -0800 (PST) From: Viktor Prutyanov To: pbonzini@redhat.com, rkagan@virtuozzo.com Date: Thu, 20 Dec 2018 04:24:41 +0300 Message-Id: <20181220012441.13694-7-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::141 Subject: [Qemu-devel] [PATCH v2 6/6] configure: enable elf2dmp build for Windows hosts 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 After this patch contrib/elf2dmp can be built for Windows x86 and x86_64 hosts by mingw. Signed-off-by: Viktor Prutyanov --- Makefile | 4 ++-- configure | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index c8b9efdad4..25acb94aa6 100644 --- a/Makefile +++ b/Makefile @@ -565,8 +565,8 @@ ifneq ($(EXESUF),) qemu-ga: qemu-ga$(EXESUF) $(QGA_VSS_PROVIDER) $(QEMU_GA_MSI) endif -elf2dmp: LIBS = $(CURL_LIBS) -elf2dmp: $(elf2dmp-obj-y) +elf2dmp$(EXESUF): LIBS += $(CURL_LIBS) +elf2dmp$(EXESUF): $(elf2dmp-obj-y) $(call LINK, $^) ifdef CONFIG_IVSHMEM diff --git a/configure b/configure index 224d3071ac..686ae2e093 100755 --- a/configure +++ b/configure @@ -5753,8 +5753,8 @@ if test "$want_tools" = "yes" ; then if [ "$ivshmem" = "yes" ]; then tools="ivshmem-client\$(EXESUF) ivshmem-server\$(EXESUF) $tools" fi - if [ "$posix" = "yes" ] && [ "$curl" = "yes" ]; then - tools="elf2dmp $tools" + if [ "$curl" = "yes" ]; then + tools="elf2dmp\$(EXESUF) $tools" fi fi if test "$softmmu" = yes ; then