From patchwork Thu Dec 5 12:25:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 11274849 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D9F1D138C for ; Thu, 5 Dec 2019 14:19:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AD68521823 for ; Thu, 5 Dec 2019 14:19:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="GITKPgtu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD68521823 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:55076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icryL-0003pC-LI for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Dec 2019 09:19:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56383) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icret-0002Sg-HN for qemu-devel@nongnu.org; Thu, 05 Dec 2019 08:59:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icres-0000Gv-77 for qemu-devel@nongnu.org; Thu, 05 Dec 2019 08:59:07 -0500 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]:33008) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1icrer-0000A8-Re for qemu-devel@nongnu.org; Thu, 05 Dec 2019 08:59:06 -0500 Received: by mail-lf1-x12a.google.com with SMTP id n25so2606890lfl.0 for ; Thu, 05 Dec 2019 05:59:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AwS6rtyEJKyLkwzf8eig7lEH4N3AqTO23sBKCr3rUB4=; b=GITKPgtuLZtNwgUUIhehuyF0ahpDGuPSz0cQmbKFCVOXRMdjSlFOyyAfSX4/UzDFob NpoQRzy86EHaeywxWcKxQYH24mHynOyXcm7VF3Y/B6JvANnxFSo3x5Mu21yKW7uEpygH VYsaWvR7+WjV+QBel0CUGZ3ozbBAeUpKpBdWLe1/SQXCBZ7tO6DUS5ZU+EFeVRXze8oh 41CQeNvxCScQaMznoPHB9YMVY6oukYaKIfNZnCYJ2eUcN5/P4uzCn8LThp/I9a0WwIU3 K7P/PVgr0qcwbJRfuPWohIHAowL4cR6dvryjFIbEK47XOqd1MoDz6h0e/hL5FipJ9K8l F3/Q== 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:mime-version:content-transfer-encoding; bh=AwS6rtyEJKyLkwzf8eig7lEH4N3AqTO23sBKCr3rUB4=; b=r9DA9WL6W+iJVFvMSh+r0auIYdsPPjvHh03rSpS1Y5sftjasoKE5qK9mINyv6cXbvt EAHRv7PGNVbwvryhc/lqJVWh8hPnYeqNqcVMXV3zaxNBDh2S8VnJTZd/WxoJNRZ+VI8D WmVBQKcVmveHzRdziZm+VEciG3tUxzEMcUCd05SVfOUXVqRbo40RqSKOyGd/FPIBPmBr EC3ptcVtQPIDUuIzkdwS5r1J7Xo33tFbCLT1oRzriWnKs+KfNN8qiuVKqUBjFT+i/BTk ZKdEACmyabWMMdBxBHVewvGQtEAJLZy1NvlhTSjUKpUjREPHbADRtS6PqO8yz9fhiJjL pFuA== X-Gm-Message-State: APjAAAXKM30mxpb8redoTJiUt3kJUdIovNGdaPe1JFsGhYmSJfLb5a1m wAagjhSbmeX8ve/x9HIlVR3vFucNpyY= X-Google-Smtp-Source: APXvYqxdZQiBR/wTXpkxm7aGqIElK/gMI6of//oXsbN9ZEzJh3oZ9pqYMfwlwJFuNI4BsWc8BTYk1g== X-Received: by 2002:adf:afc2:: with SMTP id y2mr9867264wrd.254.1575548722558; Thu, 05 Dec 2019 04:25:22 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id m7sm5054986wma.39.2019.12.05.04.25.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2019 04:25:18 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 255881FF8C; Thu, 5 Dec 2019 12:25:18 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 1/6] linux-user: convert target_mprotect debug to tracepoint Date: Thu, 5 Dec 2019 12:25:12 +0000 Message-Id: <20191205122518.10010-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191205122518.10010-1-alex.bennee@linaro.org> References: <20191205122518.10010-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::12a X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , =?utf-8?q?Alex_Benn=C3=A9e?= , Laurent Vivier Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" It is a pain to re-compile when you need to debug and tracepoints are a fairly low impact way to instrument QEMU. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Laurent Vivier --- v2 - don't both with ascii conversion --- linux-user/mmap.c | 10 ++-------- linux-user/trace-events | 3 +++ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 46a6e3a761a..26a83e74069 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -17,7 +17,7 @@ * along with this program; if not, see . */ #include "qemu/osdep.h" - +#include "trace.h" #include "qemu.h" //#define DEBUG_MMAP @@ -66,13 +66,7 @@ int target_mprotect(abi_ulong start, abi_ulong len, int prot) abi_ulong end, host_start, host_end, addr; int prot1, ret; -#ifdef DEBUG_MMAP - printf("mprotect: start=0x" TARGET_ABI_FMT_lx - "len=0x" TARGET_ABI_FMT_lx " prot=%c%c%c\n", start, len, - prot & PROT_READ ? 'r' : '-', - prot & PROT_WRITE ? 'w' : '-', - prot & PROT_EXEC ? 'x' : '-'); -#endif + trace_target_mprotect(start, len, prot); if ((start & ~TARGET_PAGE_MASK) != 0) return -TARGET_EINVAL; diff --git a/linux-user/trace-events b/linux-user/trace-events index 6df234bbb67..8419243de4e 100644 --- a/linux-user/trace-events +++ b/linux-user/trace-events @@ -11,3 +11,6 @@ user_handle_signal(void *env, int target_sig) "env=%p signal %d" user_host_signal(void *env, int host_sig, int target_sig) "env=%p signal %d (target %d(" user_queue_signal(void *env, int target_sig) "env=%p signal %d" user_s390x_restore_sigregs(void *env, uint64_t sc_psw_addr, uint64_t env_psw_addr) "env=%p frame psw.addr 0x%"PRIx64 " current psw.addr 0x%"PRIx64 + +# mmap.c +target_mprotect(uint64_t start, uint64_t len, int flags) "start=0x%"PRIx64 " len=0x%"PRIx64 " prot=0x%x" From patchwork Thu Dec 5 12:25:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 11274731 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E3D17138C for ; Thu, 5 Dec 2019 13:39:50 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B99B622525 for ; Thu, 5 Dec 2019 13:39:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="rKOCD9L3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B99B622525 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:54192 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icrMD-0007qC-Cz for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Dec 2019 08:39:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41947) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icrIL-0005b5-8P for qemu-devel@nongnu.org; Thu, 05 Dec 2019 08:35:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icrII-0000Qn-Nx for qemu-devel@nongnu.org; Thu, 05 Dec 2019 08:35:48 -0500 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]:39550) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1icrII-0000Kj-DJ for qemu-devel@nongnu.org; Thu, 05 Dec 2019 08:35:46 -0500 Received: by mail-wr1-x42f.google.com with SMTP id y11so3616883wrt.6 for ; Thu, 05 Dec 2019 05:35:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ojk/DQPD5yxe3f3qJM/gjK8YaBYa+zXsUEip1if0FLM=; b=rKOCD9L3meiIyOgEQNRLS3TDw2OoMphNKnf6kkU2Y3EZ7bMVe/ddDkJW4MdUnZJjuA vd03D6eYzVN52MtTcHt85x44EcpFZO+gLT6WhewyraJdPxlSWFg+0BIjG5j6pJ3gs0DK Ym08+PcuoVv7PMtIVezLIhGVC2fuxU00Ylo24zNv1hfFSaUiIsYPpd4KLhC0ck/gQ+sm gLafAmwXObk00LLFAPMvk6QwszyaMjJmx5aUnXJVOae4wNxRXLMjTAoYEYmQ35veHOh/ AlcUBWlZmAhjHWklvS9X0MTJaAatl4V6dQTUxnOLyhrMOcGRQ9PUbb2yDU/guaU/e0h8 lASA== 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:mime-version:content-transfer-encoding; bh=ojk/DQPD5yxe3f3qJM/gjK8YaBYa+zXsUEip1if0FLM=; b=BxPTWiQe1QunBIeqOiAqJudsn6pJo5HKV0DdOj+b4r6DO0xVQxFIsGMf8uBxQRzbmD EVGYVG/O5M807pjUtS+8fuW8650oB7KTElM59HNdMDkn2U4G47vOX0pz2nAjAHlgbKNC rIJBqyXG/XDlWMewu5JCJ25eRuIb8nLfOteRtjcxW/XrgsmSwTXegt1+d3dr7YpKMnIC /wm65G5cba+EuVPS7KWqbiUUpAWzeMK+VxGaLyeX/ixAMolV1+l4tCBPJEV9KJq7jyWL UJ0ZgTtK2EUFTpzhfr4kxe3WigexahuaoSC5N/CAwhoHufmtmkKXDR0S4+WNGc9osiZH onLw== X-Gm-Message-State: APjAAAWnSla6qV6mWWkSmUl5ZQ/vZdl8IuN7IP5G/pXK1ZsgLnMQpRhC XRo7DKK/aklxHNByYIIL79jO9RykDQE= X-Google-Smtp-Source: APXvYqz5Oa+2PH4m3D2Y8zwvkXvSzhC3OpGgHSFi8aBXOY+4aGKvlEahkfU8Exfpyt1jHa5uIXH7iw== X-Received: by 2002:adf:fd91:: with SMTP id d17mr10394205wrr.340.1575548721417; Thu, 05 Dec 2019 04:25:21 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id v20sm10471139wmj.32.2019.12.05.04.25.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2019 04:25:18 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 3BF631FF8F; Thu, 5 Dec 2019 12:25:18 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 2/6] linux-user: convert target_mmap debug to tracepoint Date: Thu, 5 Dec 2019 12:25:13 +0000 Message-Id: <20191205122518.10010-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191205122518.10010-1-alex.bennee@linaro.org> References: <20191205122518.10010-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42f X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , =?utf-8?q?Alex_Benn=C3=A9e?= , Laurent Vivier Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" It is a pain to re-compile when you need to debug and tracepoints are a fairly low impact way to instrument QEMU. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Laurent Vivier --- linux-user/mmap.c | 27 +-------------------------- linux-user/trace-events | 1 + 2 files changed, 2 insertions(+), 26 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 26a83e74069..f4f10deaeac 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -363,32 +363,7 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, abi_ulong ret, end, real_start, real_end, retaddr, host_offset, host_len; mmap_lock(); -#ifdef DEBUG_MMAP - { - printf("mmap: start=0x" TARGET_ABI_FMT_lx - " len=0x" TARGET_ABI_FMT_lx " prot=%c%c%c flags=", - start, len, - prot & PROT_READ ? 'r' : '-', - prot & PROT_WRITE ? 'w' : '-', - prot & PROT_EXEC ? 'x' : '-'); - if (flags & MAP_FIXED) - printf("MAP_FIXED "); - if (flags & MAP_ANONYMOUS) - printf("MAP_ANON "); - switch(flags & MAP_TYPE) { - case MAP_PRIVATE: - printf("MAP_PRIVATE "); - break; - case MAP_SHARED: - printf("MAP_SHARED "); - break; - default: - printf("[MAP_TYPE=0x%x] ", flags & MAP_TYPE); - break; - } - printf("fd=%d offset=" TARGET_ABI_FMT_lx "\n", fd, offset); - } -#endif + trace_target_mmap(start, len, prot, flags, fd, offset); if (!len) { errno = EINVAL; diff --git a/linux-user/trace-events b/linux-user/trace-events index 8419243de4e..8d8d4c3c68c 100644 --- a/linux-user/trace-events +++ b/linux-user/trace-events @@ -14,3 +14,4 @@ user_s390x_restore_sigregs(void *env, uint64_t sc_psw_addr, uint64_t env_psw_add # mmap.c target_mprotect(uint64_t start, uint64_t len, int flags) "start=0x%"PRIx64 " len=0x%"PRIx64 " prot=0x%x" +target_mmap(uint64_t start, uint64_t len, int pflags, int mflags, int fd, uint64_t offset) "start=0x%"PRIx64 " len=0x%"PRIx64 " prot=0x%x flags=0x%x fd=%d offset=0x%"PRIx64 From patchwork Thu Dec 5 12:25:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 11274853 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2423E138C for ; Thu, 5 Dec 2019 14:23:37 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EE00D206DB for ; Thu, 5 Dec 2019 14:23:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="H9d2840q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EE00D206DB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:55212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ics2Z-0000Jk-TN for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Dec 2019 09:23:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45874) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icrwD-0002c0-Qs for qemu-devel@nongnu.org; Thu, 05 Dec 2019 09:17:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icrwC-0003tT-CI for qemu-devel@nongnu.org; Thu, 05 Dec 2019 09:17:01 -0500 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:34183) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1icrwC-0003oN-26 for qemu-devel@nongnu.org; Thu, 05 Dec 2019 09:17:00 -0500 Received: by mail-wr1-x441.google.com with SMTP id t2so3847049wrr.1 for ; Thu, 05 Dec 2019 06:16:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j8BHLefjvES9SOUgRcfX4ySy651Dqcu3C9AOxEtMINE=; b=H9d2840qQHkWnEUhW/yRLuN9XbkJ2AtviP8lUc4S+3SvC/u3qn30KkX2ynW/dZwws6 zkN3DLP2z983CcHPnDhwOXKwaQPjRbrb8BZ0L2Cezw2jGMmWpcKM2zXwhQEhlz1R3cII ROP0sz9Bf5oa8LMBWqXRrcTv4faM/KDoITZ3ntc5gh1gTrv99MHqd9g9rcfwDjIA4Avi 496oyNAP8pZrxwjmMeooiCOX6usOZSK2uueloRDSm6appx2Qgz8nvOFZr6hhlMZSxExj nlMhC0NlKxfcyzLS1KpPcKIfdbNKs7OmIdAM1aBiUP1fixn8ZM2N5hiHAWki6e9euXrT leBw== 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:mime-version:content-transfer-encoding; bh=j8BHLefjvES9SOUgRcfX4ySy651Dqcu3C9AOxEtMINE=; b=mDnz0TlgDjouTJP6vUuJ/XNPlCzJ8FVcgBT7IianKrEWI6NRybi3XV7H0gUWkXseap 4miYtbWrbrxIm1sYGwOUzMwjHQXW2UQMoFNOnWsUuwUMGH3dE03xt3s7XQCiva0U9w4O OdBPoQTUt0n7Xdl+BeOlJCaIpgGx+YH3jgeIBpDnYguIjEn435BQ8f00JFZll9Zl6Qfd ted3Ce042xfxB5dFUbTC6MJjprqZ2e506LRAVRR6CLFkTbr+2TSqI44T0UneV93Kimk5 VKKaj3i7Un2NNftCuzZSXpOrCvTbIYC7cjuC4XuPRDKmtoVR6gu+TaURRwz3MVld23Bb uulA== X-Gm-Message-State: APjAAAURnyZ3ktPIOMqQrlatwKw3jGddm4NuqjCOMQIeF9Qv/T/3294x v8xZLRhEXfXvnZ+XTaPQacBzPnaQvDw= X-Google-Smtp-Source: APXvYqxydtaMiRT0SEobaIhuXxFW9PNVF4Dvltqac99Cpx361b4ZTkA+usCgXtBBEasv5LBJRNCKGw== X-Received: by 2002:adf:fa50:: with SMTP id y16mr9908354wrr.183.1575548723861; Thu, 05 Dec 2019 04:25:23 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id a64sm11379882wmc.18.2019.12.05.04.25.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2019 04:25:20 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 5225C1FF90; Thu, 5 Dec 2019 12:25:18 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 3/6] linux-user: add target_mmap_complete tracepoint Date: Thu, 5 Dec 2019 12:25:14 +0000 Message-Id: <20191205122518.10010-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191205122518.10010-1-alex.bennee@linaro.org> References: <20191205122518.10010-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Riku Voipio , =?utf-8?q?Alex_Benn=C3=A9e?= , Laurent Vivier Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" For full details we also want to see where the mmaps end up. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Laurent Vivier --- linux-user/mmap.c | 2 +- linux-user/trace-events | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index f4f10deaeac..0b1b43ac3c0 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -538,8 +538,8 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, the_end1: page_set_flags(start, start + len, prot | PAGE_VALID); the_end: + trace_target_mmap_complete(start); #ifdef DEBUG_MMAP - printf("ret=0x" TARGET_ABI_FMT_lx "\n", start); page_dump(stdout); printf("\n"); #endif diff --git a/linux-user/trace-events b/linux-user/trace-events index 8d8d4c3c68c..6d6aeef7b52 100644 --- a/linux-user/trace-events +++ b/linux-user/trace-events @@ -15,3 +15,4 @@ user_s390x_restore_sigregs(void *env, uint64_t sc_psw_addr, uint64_t env_psw_add # mmap.c target_mprotect(uint64_t start, uint64_t len, int flags) "start=0x%"PRIx64 " len=0x%"PRIx64 " prot=0x%x" target_mmap(uint64_t start, uint64_t len, int pflags, int mflags, int fd, uint64_t offset) "start=0x%"PRIx64 " len=0x%"PRIx64 " prot=0x%x flags=0x%x fd=%d offset=0x%"PRIx64 +target_mmap_complete(uint64_t retaddr) "retaddr=0x%"PRIx64 From patchwork Thu Dec 5 12:25:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 11274833 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 63D596C1 for ; Thu, 5 Dec 2019 14:07:01 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3881C2245C for ; Thu, 5 Dec 2019 14:07:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="M38C/sxQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3881C2245C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:54862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icrmV-0000bL-SO for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Dec 2019 09:06:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42644) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icrbn-0007jf-Ll for qemu-devel@nongnu.org; Thu, 05 Dec 2019 08:55:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icrbm-0000Rt-1h for qemu-devel@nongnu.org; Thu, 05 Dec 2019 08:55:55 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:39556) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1icrbl-0000MS-NG for qemu-devel@nongnu.org; Thu, 05 Dec 2019 08:55:53 -0500 Received: by mail-wr1-x444.google.com with SMTP id y11so3708103wrt.6 for ; Thu, 05 Dec 2019 05:55:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+aAcg7zfu3h11WqWsNjIj4w0+SSQrzO+SPiMdumxwPs=; b=M38C/sxQAU0NtdioFNZF9aZmTzys4b+YebJd6E6ryGA5szJQ/nxOY0gESlUJqu3pUY 2WknaPFSyQYiaPkhe9NGpp6VPqCo4+mwI2mlrDojQO2QUvnqVG0CxhEwk1ApmpwpS2uX qmRqwB8i2zbCKprwTTBpHoUVJd+EBr3c9R1wEOvPzFZLvijJeN/HWt82TiioU2Hhxylx c9h4mfDBpyH7JOQAuWWsghvhHNzXL+mHqGEFTh0mHFH1P2exmzh7uf3C3tMqDPZ0RIQK QL38hjsnIkIf4qkMsGh1ucv4qKqpXlUgME4+s7K7Zec38ft+Vg9lHkKylpLEyZrqL0E5 3l+A== 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:mime-version:content-transfer-encoding; bh=+aAcg7zfu3h11WqWsNjIj4w0+SSQrzO+SPiMdumxwPs=; b=FyeS22JEpO5V8J05Ogzp4OtCQntqN2lFpfKSdcEAQfI9z6mUDrG/pUX3PSmZeNB2mC G4fV/XuYz4OcdAp1fwGda9/ERX/aatYGSeaZaJhGj0JSDbDjv4JWdwH38eAs7u9ugv1g wmACOP+cTLzoXCkMt2r9/eDliljQDChqATItAMHvXwW6KaocEhMYt4M+BFi52cyITMkY Jsil9mdQaidl1oCakqb0T8ZNJUj1/uJb7WND2GVdmUL+UHALlpffKj+a+9sFuytlnm5J 4VvVcvkesrokxiDYfV/RNnytzPUy2fQMQVs/29wFLNODcyxmLrqW5O2h5n4cswrP5w22 8nNg== X-Gm-Message-State: APjAAAWd0vrPq5NOMMSXObL+DeFVCcDPqualrNlkB+7eVVsAzZkg4GuE 4rH5sK/Z67hBEZoJ2OOi28pNaXr02Ds= X-Google-Smtp-Source: APXvYqwy2+El1zorGSaAjV9lh9JnG3fvQrzwpUbWk9vOW/x19vOf2ZEg54rhbs+KB4t73Yjnwsb27Q== X-Received: by 2002:adf:f382:: with SMTP id m2mr9800560wro.163.1575548725921; Thu, 05 Dec 2019 04:25:25 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id v3sm9639813wml.47.2019.12.05.04.25.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2019 04:25:22 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 6A1A31FF91; Thu, 5 Dec 2019 12:25:18 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 4/6] linux-user: log page table changes under -d page Date: Thu, 5 Dec 2019 12:25:15 +0000 Message-Id: <20191205122518.10010-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191205122518.10010-1-alex.bennee@linaro.org> References: <20191205122518.10010-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , =?utf-8?q?Alex_Benn=C3=A9e?= , Laurent Vivier Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" The CPU_LOG_PAGE flag is woefully underused and could stand to do extra duty tracking page changes. If the user doesn't want to see the details as things change they still have the tracepoints available. We push the locking into log_page_dump and pass a reason for the banner text. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Laurent Vivier --- v2 - reworded banner text - moved locking into helper - converted stray calls of page_dump --- include/exec/log.h | 5 ++++- bsd-user/main.c | 2 +- linux-user/main.c | 2 +- linux-user/mmap.c | 8 ++++---- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/include/exec/log.h b/include/exec/log.h index e2cfd436e61..012af09f9b3 100644 --- a/include/exec/log.h +++ b/include/exec/log.h @@ -50,9 +50,12 @@ static inline void log_disas(void *code, unsigned long size) #if defined(CONFIG_USER_ONLY) /* page_dump() output to the log file: */ -static inline void log_page_dump(void) +static inline void log_page_dump(const char *operation) { + qemu_log_lock(); + qemu_log("page layout changed following %s\n", operation); page_dump(qemu_logfile); + qemu_log_unlock(); } #endif #endif diff --git a/bsd-user/main.c b/bsd-user/main.c index 470a8bf79ed..7f4e3cd6271 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -963,7 +963,7 @@ int main(int argc, char **argv) if (qemu_loglevel_mask(CPU_LOG_PAGE)) { qemu_log("guest_base 0x%lx\n", guest_base); - log_page_dump(); + log_page_dump("binary load"); qemu_log("start_brk 0x" TARGET_ABI_FMT_lx "\n", info->start_brk); qemu_log("end_code 0x" TARGET_ABI_FMT_lx "\n", info->end_code); diff --git a/linux-user/main.c b/linux-user/main.c index 6ff7851e86f..8718d03ee21 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -826,7 +826,7 @@ int main(int argc, char **argv, char **envp) if (qemu_loglevel_mask(CPU_LOG_PAGE)) { qemu_log("guest_base 0x%lx\n", guest_base); - log_page_dump(); + log_page_dump("binary load"); qemu_log("start_brk 0x" TARGET_ABI_FMT_lx "\n", info->start_brk); qemu_log("end_code 0x" TARGET_ABI_FMT_lx "\n", info->end_code); diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 0b1b43ac3c0..3d90fa459ca 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -18,6 +18,7 @@ */ #include "qemu/osdep.h" #include "trace.h" +#include "exec/log.h" #include "qemu.h" //#define DEBUG_MMAP @@ -539,10 +540,9 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, page_set_flags(start, start + len, prot | PAGE_VALID); the_end: trace_target_mmap_complete(start); -#ifdef DEBUG_MMAP - page_dump(stdout); - printf("\n"); -#endif + if (qemu_loglevel_mask(CPU_LOG_PAGE)) { + log_page_dump(__func__); + } tb_invalidate_phys_range(start, start + len); mmap_unlock(); return start; From patchwork Thu Dec 5 12:25:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 11274839 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9EF466C1 for ; Thu, 5 Dec 2019 14:09:25 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 74E0A2245C for ; Thu, 5 Dec 2019 14:09:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="PnkFp6iw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74E0A2245C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:54918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icroq-0003hM-Fq for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Dec 2019 09:09:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36642) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icrnW-0001z4-AA for qemu-devel@nongnu.org; Thu, 05 Dec 2019 09:08:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icrnU-0006Mr-Uh for qemu-devel@nongnu.org; Thu, 05 Dec 2019 09:08:01 -0500 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:46823) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1icrnU-0006Es-L3 for qemu-devel@nongnu.org; Thu, 05 Dec 2019 09:08:00 -0500 Received: by mail-wr1-x442.google.com with SMTP id z7so3696269wrl.13 for ; Thu, 05 Dec 2019 06:08:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LlKAQUU8BKqjO5SGyRq373lXLOzaiq/UNvhXOUrnIRc=; b=PnkFp6iwJHjJz5h4WFjkI0alqjBMd1+8kTpKE8H0jcyRQIY8Xu9PxjqlShj/GfZxOJ AR1UgiQfnS+hSiz3S98XmqRggV5a1ht7JN7ZrJJ2lu4zLshalRb9WTNIatbQM+GL10y6 miuyiQLVClhZWSZz6AeiWN3udkVhLFC46yTuCeFgDTz/IXPgpUQgp49X920SJ4ac2+o7 HYYqeYCOkzw3DiIeIuCDEOlT9Xk2lj2NvwBHaiU4Vkg2/ElUjfbc5fVbepyjZJ63fZvI gUxTgW0uhov6oOxlxlD/QswX3eBzeqK8R/LXhdok4rr/4a0pePK+mp6TfVUJdu+YL+wS z5rA== 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:mime-version:content-transfer-encoding; bh=LlKAQUU8BKqjO5SGyRq373lXLOzaiq/UNvhXOUrnIRc=; b=iI/RonqgHwVdnEn1dOGrTQfb2+q6laKxeK6Rrjqb3OtJ8c87D6JdkfSv7St6a2qxXt qnY+vFAI8pM4IPy1pwSz5OZqXFUfsDGv7kPQaAFyVcxpEjfG1MWdB7l5OZ3vnaLQiwts bFO4lpjJZSds4KYzYaQBN7aB9oV8k5B1Fw1ASxpu7I7KTQC75xf/LKhcJbwGTC5EAoDr SPgSR/Zg01texl4WeQI2TzB72m+7XtGm61e0Bi+l9KpJi37kOYtMQZiEt9ESLMrbcDiV CU1Q9tMFS8iFV/10hmt78YcA5LOaITva82yhoo9eT0WbQMU/TO4t16wRLP8GzL/kfKPj mx2A== X-Gm-Message-State: APjAAAXxjuMCxgoxyK/nVw3f8QHqrWJHgq8Rvs3Dfe/vjGB1MjBwPMPl oVSFg5Ls5Au01ayzHImU8R/lOfZPuXg= X-Google-Smtp-Source: APXvYqz9TOS7bca2SwKFuCPe0c/tREBtWUGY/+v4q6e4uxDXLkqfSO+ISmTHFY8LOm9MaeHm96nHrw== X-Received: by 2002:adf:f581:: with SMTP id f1mr10237571wro.264.1575548727599; Thu, 05 Dec 2019 04:25:27 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id u10sm10125668wmd.1.2019.12.05.04.25.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2019 04:25:23 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7EB841FF92; Thu, 5 Dec 2019 12:25:18 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 5/6] linux-user: convert target_munmap debug to a tracepoint Date: Thu, 5 Dec 2019 12:25:16 +0000 Message-Id: <20191205122518.10010-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191205122518.10010-1-alex.bennee@linaro.org> References: <20191205122518.10010-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Riku Voipio , =?utf-8?q?Alex_Benn=C3=A9e?= , Laurent Vivier Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Convert the final bit of DEBUG_MMAP to a tracepoint and remove the last remanents of the #ifdef hackery. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Laurent Vivier --- linux-user/mmap.c | 9 ++------- linux-user/trace-events | 1 + 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 3d90fa459ca..8685f02e7e9 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -21,8 +21,6 @@ #include "exec/log.h" #include "qemu.h" -//#define DEBUG_MMAP - static pthread_mutex_t mmap_mutex = PTHREAD_MUTEX_INITIALIZER; static __thread int mmap_lock_count; @@ -597,11 +595,8 @@ int target_munmap(abi_ulong start, abi_ulong len) abi_ulong end, real_start, real_end, addr; int prot, ret; -#ifdef DEBUG_MMAP - printf("munmap: start=0x" TARGET_ABI_FMT_lx " len=0x" - TARGET_ABI_FMT_lx "\n", - start, len); -#endif + trace_target_munmap(start, len); + if (start & ~TARGET_PAGE_MASK) return -TARGET_EINVAL; len = TARGET_PAGE_ALIGN(len); diff --git a/linux-user/trace-events b/linux-user/trace-events index 6d6aeef7b52..f6de1b8befc 100644 --- a/linux-user/trace-events +++ b/linux-user/trace-events @@ -16,3 +16,4 @@ user_s390x_restore_sigregs(void *env, uint64_t sc_psw_addr, uint64_t env_psw_add target_mprotect(uint64_t start, uint64_t len, int flags) "start=0x%"PRIx64 " len=0x%"PRIx64 " prot=0x%x" target_mmap(uint64_t start, uint64_t len, int pflags, int mflags, int fd, uint64_t offset) "start=0x%"PRIx64 " len=0x%"PRIx64 " prot=0x%x flags=0x%x fd=%d offset=0x%"PRIx64 target_mmap_complete(uint64_t retaddr) "retaddr=0x%"PRIx64 +target_munmap(uint64_t start, uint64_t len) "start=0x%"PRIx64" len=0x%"PRIx64 From patchwork Thu Dec 5 12:25:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 11274841 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6668A6C1 for ; Thu, 5 Dec 2019 14:10:28 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3B3602245C for ; Thu, 5 Dec 2019 14:10:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="HloIVpv2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B3602245C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:54928 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icrpq-0004vD-SR for patchwork-qemu-devel@patchwork.kernel.org; Thu, 05 Dec 2019 09:10:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56768) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1icrex-0002Xw-4s for qemu-devel@nongnu.org; Thu, 05 Dec 2019 08:59:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1icrew-0000Yl-0H for qemu-devel@nongnu.org; Thu, 05 Dec 2019 08:59:11 -0500 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:38127) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1icrev-0000VF-PO for qemu-devel@nongnu.org; Thu, 05 Dec 2019 08:59:09 -0500 Received: by mail-wr1-x444.google.com with SMTP id y17so3731489wrh.5 for ; Thu, 05 Dec 2019 05:59:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=et7ltZY7DPRXGygmqJQSM9s82vIGOWea1S/OwancEF4=; b=HloIVpv2ZsUpCeB42Jm/DQW8F9xJlGHdlqPleFxK8RcIiHbRu8uIVNQs89iJZ5/fxA 7XzBsbwZ5KPNkEtR2ApMkLaQYRFE+Mmdmya408z6SxkDKa+/vW1zjbbObGBq142BF2Oh W2ZCn9g/aqbtRNB7jvCxeRJs4Gb7ZWMDfDXZlSP9sK6S4uoGkICBhrHiy2g5BLFD1KRF pUEcggkqBm/3Xxtr+wJnX86SZ/KiZUzYBexdhh66dfKm8bTWGfLxK1LASWIlgaR6zCJb BL7POBLO9y0hffJYFCkiSYj+G/fEp1nAKU2HoyNx/5gd358sPM387nWpzZHxMsfaQ/cX R+ww== 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:mime-version:content-transfer-encoding; bh=et7ltZY7DPRXGygmqJQSM9s82vIGOWea1S/OwancEF4=; b=IwZesQVCPJLz961VtIPQ+WPHscbXUsi0lBYzSXdakNadPFXgJe/cr1eUwd0K+Ggw5P sX2tKclMLubjczE1dQ6XZxZk6kc8Ssli8Ln+6FzYztNPhTxmWyssa3z2P0d7iF7CDXXT Wtcy4YcCiIBZGkyRRC48UcogpORsTNS93Zl80sWKJWvWB8C1uDa8Tdlemrp/UUPXJJlt Mz2kdcm8d3VHWO7HgpyGatDtcSOviXdXPJs+bT/GX1PvL2dyj3U86RSHKjdN8z1h9eU0 ACeub89ozPeQJlf4PbnzIfTFdIMgvN8NNlPD2PObgHqw3434L91cnTjU+GKkf1n2/5+k 8Dbg== X-Gm-Message-State: APjAAAVXstFaO6ItJM/wH6nZODRjYgWWdg93Qb3ZyXeY2rRjxx+HCrt8 dtJCUvaTdp2AdK2IO30rTP9Pr9AFygs= X-Google-Smtp-Source: APXvYqxvuHZ2tnnTGJfH/sNA0j6Lp6f1S8UalXH8PjWZADaUT4CiODLGGQR7QjXc65KJ0SFRf3RHkA== X-Received: by 2002:a5d:4a84:: with SMTP id o4mr9712985wrq.396.1575548728753; Thu, 05 Dec 2019 04:25:28 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id i127sm10954997wma.35.2019.12.05.04.25.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Dec 2019 04:25:23 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 947E11FF93; Thu, 5 Dec 2019 12:25:18 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v2 6/6] trace: replace hand-crafted pattern_glob with g_pattern_match_simple Date: Thu, 5 Dec 2019 12:25:17 +0000 Message-Id: <20191205122518.10010-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191205122518.10010-1-alex.bennee@linaro.org> References: <20191205122518.10010-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Stefan Hajnoczi Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" We already use g_pattern_match elsewhere so remove the duplication. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Stefan Hajnoczi --- trace/control.c | 35 +---------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/trace/control.c b/trace/control.c index d9cafc161bb..0fb81241607 100644 --- a/trace/control.c +++ b/trace/control.c @@ -98,38 +98,6 @@ TraceEvent *trace_event_name(const char *name) return NULL; } -static bool pattern_glob(const char *pat, const char *ev) -{ - while (*pat != '\0' && *ev != '\0') { - if (*pat == *ev) { - pat++; - ev++; - } - else if (*pat == '*') { - if (pattern_glob(pat, ev+1)) { - return true; - } else if (pattern_glob(pat+1, ev)) { - return true; - } else { - return false; - } - } else { - return false; - } - } - - while (*pat == '*') { - pat++; - } - - if (*pat == '\0' && *ev == '\0') { - return true; - } else { - return false; - } -} - - void trace_event_iter_init(TraceEventIter *iter, const char *pattern) { iter->event = 0; @@ -148,8 +116,7 @@ TraceEvent *trace_event_iter_next(TraceEventIter *iter) iter->group++; } if (!iter->pattern || - pattern_glob(iter->pattern, - trace_event_get_name(ev))) { + g_pattern_match_simple(iter->pattern, trace_event_get_name(ev))) { return ev; } }