From patchwork Thu Aug 9 17:55:51 2018 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: 143876 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2388689ljj; Thu, 9 Aug 2018 10:58:22 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzxWnwupfLqoWDNjxZ80raTZCTTcor5z9mHFzbVOjUnYQDoYm7b9iYQR2C0ddgoBvK1azEH X-Received: by 2002:ac8:365b:: with SMTP id n27-v6mr3139067qtb.141.1533837502425; Thu, 09 Aug 2018 10:58:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533837502; cv=none; d=google.com; s=arc-20160816; b=rRkSy6ivexUaGCbYx7YIpR8sNn4WgHac6+7ta8INRKeE8KjtAO3A6nupXEN1WE+8lH 8vcJGXU/ctsghRuiTD9n/0FB2h1APHGLnEcwWCnqO5mkG6+55qo6mz9Vrmi0jIiyI8kG DT4HATF/9Qsj8cPiBrJnxBAavRWv8Q0QworOJ+Y5K3UoiPsbuWJmCeRhOF0iMfC+nXSa Dwde9jy5W2nFZMG3eBH27MV0+KQhJqK/zXeAGRc1Jp773wVT/4u8NL6T9+jy2wMzJF3w P+LILBtz3TK6NnhbL4eBW+Hru8Tg+6I5LtUNPBiIN2U2ybMhG7TYOchG12k/ME486o6x LCwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=m9XHKczBCfZKJnBKtgcKHhJOx0keN4+gJldX0UXceRM=; b=m3aj/tEmKiRj7nL36U4MsDE/HyS08HRfvqCONPFPpKnfGHkkdc/vDQ2esdDc64zR7B YppZ29x/xVSFup2x+9RkWqxRlGaeOhp9KaAZTqKzRGbOvaQNurqBOocdWPuzHMSywoHT KBvwlKfofphPAr+0CI+MOLjS5ccztlE34Hqgwx2ywEZim7QvvFjo8guIrsPs0+D5m5Qg oHdJBzifNteIaLnlGX6dmsA9OeZU/7OX+6FPiJNazW7LQdfiBiZIq4C5gzPDKwh7QR0h vUoMcycfs9rGOZBGqKOvTr581bvhgDmJX1yuhsC3Vc66cJ4WPaH1q0z+TcLhrxPW71EH YFYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="FYmsII/I"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y5-v6si5476639qkb.239.2018.08.09.10.58.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 09 Aug 2018 10:58:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="FYmsII/I"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52236 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnpCX-0000rM-Tb for patch@linaro.org; Thu, 09 Aug 2018 13:58:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49724) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnpAG-0008Lm-Ql for qemu-devel@nongnu.org; Thu, 09 Aug 2018 13:56:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnpAD-0004hl-D4 for qemu-devel@nongnu.org; Thu, 09 Aug 2018 13:56:00 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:46893) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fnpAD-0004gs-3B for qemu-devel@nongnu.org; Thu, 09 Aug 2018 13:55:57 -0400 Received: by mail-wr1-x434.google.com with SMTP id h14-v6so5870792wrw.13 for ; Thu, 09 Aug 2018 10:55:56 -0700 (PDT) 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=m9XHKczBCfZKJnBKtgcKHhJOx0keN4+gJldX0UXceRM=; b=FYmsII/IGOYs4nNdfRPN4pkiFTRl1akZeRRHLmQHlVvH9kKvBZJL/pdMPLgOYUDj40 YyLG5EcqeKxJiPYIuUKm0veHVrv0PGVl2ESI0ladZwDQ867hFFWfdB/HCVphh4kdBkXt GwmD2VSYXP+FmIJjjmi3jbDr5MERAFappabl0= 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=m9XHKczBCfZKJnBKtgcKHhJOx0keN4+gJldX0UXceRM=; b=roXJhGX6uvLQVzsaskavBbXNiOfRCvgavA6HlX9WCJv3L659oiO375IfQ0RIucvyXL ay/ftaQ1J0fX0rYban+SqxLxNAs4SGJfD00s/ge2TXKGeKk7J9510GTu8XWlsYcdRQ43 df3te+1moRilynJ8VQkYhoVyzgZkXpnYMUQ6MxJaf8ZONNyNM2/MJzHIrrl0/NdnBXMO MiQgzLL9gcMGs0Vdz9fLcshCgFki7+MCaW2TkB0MDmQleP8gtaBiYGNrdee2GC5Igl4R rkGLtFx1GQy9NTcLt96h9vdczk7K9aSRhRFQUYXgP+vAUSOxTHjJyG763+GQS881DBuH 79oQ== X-Gm-Message-State: AOUpUlFC5HJj/+NZy5lCl6QA51M49dZtFLHSw2WZxZrG70MlZ7xzlv9X 677iWXTkp5WsLu0EyAZ9iqZG2w== X-Received: by 2002:adf:e887:: with SMTP id d7-v6mr2175717wrm.43.1533837355849; Thu, 09 Aug 2018 10:55:55 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 198-v6sm14848982wmm.0.2018.08.09.10.55.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Aug 2018 10:55:55 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id E2D473E0619; Thu, 9 Aug 2018 18:55:53 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Thu, 9 Aug 2018 18:55:51 +0100 Message-Id: <20180809175553.18479-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180809175553.18479-1-alex.bennee@linaro.org> References: <20180809175553.18479-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::434 Subject: [Qemu-devel] [RFC PATCH 1/3] util/log: allow -dfilter to stack 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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The original dfilter was patched to avoid a leak in the case of multiple -dfilter ranges. There is no reason not to allow the user to stack several dfilter options rather than push them all into one mega line. We avoid the leak by simply only allocating the first time around. As we are using a g_array it will automatically re-size as needed. The allocation is pushed to a helper as future patches will offer additional ways to add to the dfilter. We also add a helper qemu_reset_dfilter_ranges() so we can be explicit in our unit tests. Signed-off-by: Alex Bennée --- include/qemu/log.h | 1 + tests/test-logging.c | 14 ++++++++++++++ util/log.c | 23 +++++++++++++++++------ 3 files changed, 32 insertions(+), 6 deletions(-) -- 2.17.1 diff --git a/include/qemu/log.h b/include/qemu/log.h index b097a6cae1..8ed932ec24 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -116,6 +116,7 @@ void qemu_set_log(int log_flags); void qemu_log_needs_buffers(void); void qemu_set_log_filename(const char *filename, Error **errp); void qemu_set_dfilter_ranges(const char *ranges, Error **errp); +void qemu_reset_dfilter_ranges(void); bool qemu_log_in_addr_range(uint64_t addr); int qemu_str_to_log_mask(const char *str); diff --git a/tests/test-logging.c b/tests/test-logging.c index a12585f70a..fbddd70ebc 100644 --- a/tests/test-logging.c +++ b/tests/test-logging.c @@ -43,6 +43,8 @@ static void test_parse_range(void) g_assert(qemu_log_in_addr_range(0x10ff)); g_assert_false(qemu_log_in_addr_range(0x1100)); + qemu_reset_dfilter_ranges(); + qemu_set_dfilter_ranges("0x1000-0x100", &error_abort); g_assert_false(qemu_log_in_addr_range(0x1001)); @@ -50,6 +52,8 @@ static void test_parse_range(void) g_assert(qemu_log_in_addr_range(0x0f01)); g_assert_false(qemu_log_in_addr_range(0x0f00)); + qemu_reset_dfilter_ranges(); + qemu_set_dfilter_ranges("0x1000..0x1100", &error_abort); g_assert_false(qemu_log_in_addr_range(0xfff)); @@ -57,26 +61,36 @@ static void test_parse_range(void) g_assert(qemu_log_in_addr_range(0x1100)); g_assert_false(qemu_log_in_addr_range(0x1101)); + qemu_reset_dfilter_ranges(); + qemu_set_dfilter_ranges("0x1000..0x1000", &error_abort); g_assert_false(qemu_log_in_addr_range(0xfff)); g_assert(qemu_log_in_addr_range(0x1000)); g_assert_false(qemu_log_in_addr_range(0x1001)); + qemu_reset_dfilter_ranges(); + qemu_set_dfilter_ranges("0x1000+0x100,0x2100-0x100,0x3000..0x3100", &error_abort); g_assert(qemu_log_in_addr_range(0x1050)); g_assert(qemu_log_in_addr_range(0x2050)); g_assert(qemu_log_in_addr_range(0x3050)); + qemu_reset_dfilter_ranges(); + qemu_set_dfilter_ranges("0xffffffffffffffff-1", &error_abort); g_assert(qemu_log_in_addr_range(UINT64_MAX)); g_assert_false(qemu_log_in_addr_range(UINT64_MAX - 1)); + qemu_reset_dfilter_ranges(); + qemu_set_dfilter_ranges("0..0xffffffffffffffff", &err); g_assert(qemu_log_in_addr_range(0)); g_assert(qemu_log_in_addr_range(UINT64_MAX)); + qemu_reset_dfilter_ranges(); + qemu_set_dfilter_ranges("2..1", &err); error_free_or_abort(&err); diff --git a/util/log.c b/util/log.c index c0dbbd4700..c6c197cbb3 100644 --- a/util/log.c +++ b/util/log.c @@ -149,19 +149,30 @@ bool qemu_log_in_addr_range(uint64_t addr) } } +static void maybe_allocate_dfilter(int size_hint) +{ + if (!debug_regions) { + debug_regions = g_array_sized_new(FALSE, FALSE, + sizeof(Range), + size_hint ? size_hint : 1); + } +} + +/* This is only really used for testing, usually dfilter stacks */ +void qemu_reset_dfilter_ranges(void) +{ + GArray *old = debug_regions; + debug_regions = NULL; + g_array_free(old, TRUE); +} void qemu_set_dfilter_ranges(const char *filter_spec, Error **errp) { gchar **ranges = g_strsplit(filter_spec, ",", 0); int i; - if (debug_regions) { - g_array_unref(debug_regions); - debug_regions = NULL; - } + maybe_allocate_dfilter(g_strv_length(ranges)); - debug_regions = g_array_sized_new(FALSE, FALSE, - sizeof(Range), g_strv_length(ranges)); for (i = 0; ranges[i]; i++) { const char *r = ranges[i]; const char *range_op, *r2, *e; From patchwork Thu Aug 9 17:55:52 2018 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: 143877 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2390186ljj; Thu, 9 Aug 2018 10:59:53 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzpIsrOw7eqaqrsxCurw5k2ljQ1ofjcsK6o7/9ba67SGIflBT63QgVTcnwYPoGec9aZcbx/ X-Received: by 2002:ac8:2c39:: with SMTP id d54-v6mr3134580qta.239.1533837593548; Thu, 09 Aug 2018 10:59:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533837593; cv=none; d=google.com; s=arc-20160816; b=nlZMJht31D7BQxadiOpNb4cOTTB3fbEll0p9kHk5pIOh/nLOMftvK/eArmTQXae/Q+ uxDBIlYYHz/zLPYzYgjBgWvR4ofcLMQyl/QR12OP/eH62bBNwF/6YSwQTwdO3vBnUcpN Cl9ucsYWenpd/4/6x/ZREf5qz31pCjlFyeCJFp95+5NheMUjF2v5X3ZeYpWR/Q+3HriQ cxA+s/9J0Wn4kaz4FlCNwM/YpSRf4iEReKvxo2AwtWrvyvweJ85X3AcVMlQPVqMIq0hJ tEEHrQT506OF1B3j6sSGrIRgKjt518lWUQMnmpic0/XEk6TE6RJdGILaL43rJLFsh9I0 4j6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=3dtEqPV9HNNeCR5sykAVm1UXvMIxxZcWMmX2Ma4sNig=; b=bFSFg02o6X6KGrgd3Lp+3+vnyD3AuQ6fB5HuxHUL18kzK1tG0M0D7PerEAlK9PqE2H STa0WV2qzN7C6rqlD74CkX2UzD2hYsvMOvldiwE8CcKvsen76MKfIqJtU2jAQLOvPmKq z6FCP0q4ZGhV/2C5X90UBDUjbLMB/W4R3sCZnYW/QK9npNuhfCnhI5DkL1EeW7btP2Hz ExWdyBUl0BEdp5UFb8/Azu6nb9bL2ZBfTfnRNMo/y5iQQn9GCGcV3SV5AxYU3BzMJ8k8 UVKa4xMeORcEAhbc023lJm8g3T6H9jwr0K1yly3QEh4Fl8G6p3p0JFiMjnEphIoLNGI1 2Sjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BUT8gU2E; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d19-v6si157544qte.348.2018.08.09.10.59.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 09 Aug 2018 10:59:53 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BUT8gU2E; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52247 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnpE1-0002Lr-42 for patch@linaro.org; Thu, 09 Aug 2018 13:59:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49725) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnpAG-0008Ln-Qr for qemu-devel@nongnu.org; Thu, 09 Aug 2018 13:56:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnpAE-0004iH-0S for qemu-devel@nongnu.org; Thu, 09 Aug 2018 13:56:00 -0400 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]:55481) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fnpAD-0004hZ-QO for qemu-devel@nongnu.org; Thu, 09 Aug 2018 13:55:57 -0400 Received: by mail-wm0-x229.google.com with SMTP id f21-v6so1035517wmc.5 for ; Thu, 09 Aug 2018 10:55:57 -0700 (PDT) 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=3dtEqPV9HNNeCR5sykAVm1UXvMIxxZcWMmX2Ma4sNig=; b=BUT8gU2E9nFB923ATTS9IHDiJFf5/bi1HPbZ0H5RfW3WQ+TlqhPIKgkEdOAGOGKeTw xIwusUBDIz8BSbpmKu8tlzwooekN743/yUtq7Avm3TdpbaV8DUd1jkz3U8nfCsOflV9t Xt4NhkQY00BzLzOrYjyYAG3gWhI5qwXIlm/RM= 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=3dtEqPV9HNNeCR5sykAVm1UXvMIxxZcWMmX2Ma4sNig=; b=YaNFHQAtfUjbTyJA36v8EmlajW5k05b6nfLZ7tK/2ZidRWWGRA7ZMuiwuKIq+S0d0A l+48WmlgvkuGOJjGyAqFo/VKzrjjlucWGQzXStg/HzDvS4GwbPoMeT8EQ3MsNh1bLIe4 UJxy5UMIMKH/sC6nUufWFkLRjEMOHl1kGc1l7uD+xnlzWrIOPfc5ux85364DIwM8uF0t tc/ow989EiRt9w8sRdMiApeczpXuqUfISHkAiNjmHikGg7P/LXXvHTT85lGbBgpyVan3 gJCHqZqxj0M7G3d6a9pBqD3Ech2zJq6h0ctR0jen5MMIjdVfLYXwMqrkI3Sfd1ZVZJSh b1GA== X-Gm-Message-State: AOUpUlH5IVwcIoXiRKlFlxex3w/kMCl7KsFC7HM2t+0OtK9VE0EnYztc 7YVt0zGmyeMtp+04stRVOlb5ng== X-Received: by 2002:a1c:5bc7:: with SMTP id p190-v6mr2227735wmb.101.1533837356606; Thu, 09 Aug 2018 10:55:56 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id j16-v6sm4764953wme.8.2018.08.09.10.55.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Aug 2018 10:55:55 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 01FC13E061C; Thu, 9 Aug 2018 18:55:54 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Thu, 9 Aug 2018 18:55:52 +0100 Message-Id: <20180809175553.18479-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180809175553.18479-1-alex.bennee@linaro.org> References: <20180809175553.18479-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:400c:c09::229 Subject: [Qemu-devel] [RFC PATCH 2/3] util/log: add qemu_dfilter_append_range() 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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This allows us to add to the dfilter range as we go. Signed-off-by: Alex Bennée --- include/qemu/log.h | 1 + util/log.c | 6 ++++++ 2 files changed, 7 insertions(+) -- 2.17.1 diff --git a/include/qemu/log.h b/include/qemu/log.h index 8ed932ec24..f915b5bd91 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -117,6 +117,7 @@ void qemu_log_needs_buffers(void); void qemu_set_log_filename(const char *filename, Error **errp); void qemu_set_dfilter_ranges(const char *ranges, Error **errp); void qemu_reset_dfilter_ranges(void); +void qemu_append_dfilter_range(Range r, Error **errp); bool qemu_log_in_addr_range(uint64_t addr); int qemu_str_to_log_mask(const char *str); diff --git a/util/log.c b/util/log.c index c6c197cbb3..cc79a146d1 100644 --- a/util/log.c +++ b/util/log.c @@ -233,6 +233,12 @@ out: g_strfreev(ranges); } +void qemu_append_dfilter_range(Range r, Error **errp) +{ + maybe_allocate_dfilter(1); + g_array_append_val(debug_regions, r); +} + /* fflush() the log file */ void qemu_log_flush(void) { From patchwork Thu Aug 9 17:55:53 2018 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: 143875 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2387485ljj; Thu, 9 Aug 2018 10:56:55 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxFb7hDrBdw5n9TwRmHec8+lDJtDk0NjvVt7kxnBno0U9iz8KsIl7URvKB6lRxtrXTX9L+7 X-Received: by 2002:ac8:13c3:: with SMTP id i3-v6mr3171780qtj.54.1533837415484; Thu, 09 Aug 2018 10:56:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533837415; cv=none; d=google.com; s=arc-20160816; b=iwr45OgG21GXwzS5sJy4N4qa3Q0J0GV8RhEni70lxjLiaY4gId/i9F5g7RORVwsLlB o2B2sRGTCUqSjHZDbxuA/z+2t3oSZ/FfxIsHuTmSPv59QPbypd1xdi/Hfn5/rCcmB/AG qaXQpBbOdpHDDFcAmSDPqmZi2PIdQnFB6HIg1M9cScIyJEVfvzL4stNzYkSBuH5BKsj0 57pnJidUWvZWSoWPrY/No0gSvdB5+n8h2UncRNfZg+q0Q/+RAZqcYDU5TlqKnW5dbqag yd/CQ2CitwdJxppc2WASQwd6Iy1hc8qYY/61NhwODtSkuDJDu9J36/RQFxzGenjiRThh MP9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=RKewQxtxItzFSUaEhi8cjiLKk+zd6n6oRJFO+Q8/etQ=; b=cr0Y4gETrepvJjbm/YfbodZdVTU8mDm3OwHxq9PJ+jbJTBU9j1ZSxoImkBoIOXJ7QP i43pU3sHKKWOiz0XK4nYUjJ9Z7nsUGYI1IOeXlvqYdxFudhYx50AJTXlv6+rWXYjg1/i OiDjhYvWyiCw0TvKnXDlDRKu4OZQzkmImckTpltph8HXkvLdP2wjUpdTsL6lA1kWkvph k71qcVO5rKH69bVYyrAZCqc084Uq5nO9CdzCOBIBmHOcjUvZ5IsYWgphreQuOX0saydd Pdo97XcPdCDd2ompGeuMgJfKpt7ohKDoEa7Tf9rvF/by/9kg1xZzrQA0pUtumNfpkNQF eWDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BIKUp0vB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j16-v6si2020630qvc.65.2018.08.09.10.56.55 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 09 Aug 2018 10:56:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BIKUp0vB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52234 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnpB8-0000Lm-Ue for patch@linaro.org; Thu, 09 Aug 2018 13:56:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnpAG-0008Ll-Pu for qemu-devel@nongnu.org; Thu, 09 Aug 2018 13:56:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnpAF-0004j7-7H for qemu-devel@nongnu.org; Thu, 09 Aug 2018 13:56:00 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:37789) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fnpAE-0004iQ-Vg for qemu-devel@nongnu.org; Thu, 09 Aug 2018 13:55:59 -0400 Received: by mail-wr1-x441.google.com with SMTP id u12-v6so5892058wrr.4 for ; Thu, 09 Aug 2018 10:55:58 -0700 (PDT) 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=RKewQxtxItzFSUaEhi8cjiLKk+zd6n6oRJFO+Q8/etQ=; b=BIKUp0vBxN50bVHCh+vOVwwgklUIzm3ink/n+SEgBzYomSgHecCur1eoLSnwhdxJHb 9eEvH4B673VK4JQYW465Rt/blfjW1DaCjs5JtZCL/JOlsil8YCd4gteFvuafwSorG2iS v/0eU3mFTBTN/NJq9WCOVcayd6f49k7zdMN0U= 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=RKewQxtxItzFSUaEhi8cjiLKk+zd6n6oRJFO+Q8/etQ=; b=sTgWHy1heytlRBzJCxaJ4j36c4WK575z2HmKV8zjyHhSqsjEXdKUAyOJmq5RhlS44l /Ge6KVQhQEJ9TltnbtXKwQGL1XIykNYY15AqPKBO8Z02nAWc8kspHBjx+Acp2/HFpWX1 t0GiBuba/Xd3/5oHzj0Uh3t+eWdSeyT2C6fqe6N71NGDYkSSNtrzJ6+9wLOeniE4EaQJ U52oaA2uFaIofZLmLAfbFsREy1WBl1vaVW14VeuxEydjNFBBiB8x/q8AEfNv0HoUXHqn 2wVcm36pCtTqGEcyYcwR4J9XmDiOoUzMLrKmKxw360GFhoTG86/abKh+1rgzn1hoo3ci UUxg== X-Gm-Message-State: AOUpUlE2JDABng7k+Ie+19sjZjIoDqcU8SK85/R4qN7Y6sOhKKO17vMV 6oTMaeQGJcInJdGlDKYK6mCOtA== X-Received: by 2002:adf:afd3:: with SMTP id y19-v6mr2323367wrd.176.1533837357590; Thu, 09 Aug 2018 10:55:57 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id b13-v6sm9699724wrs.43.2018.08.09.10.55.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Aug 2018 10:55:55 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 13EB73E0625; Thu, 9 Aug 2018 18:55:54 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Thu, 9 Aug 2018 18:55:53 +0100 Message-Id: <20180809175553.18479-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180809175553.18479-1-alex.bennee@linaro.org> References: <20180809175553.18479-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 Subject: [Qemu-devel] [RFC PATCH 3/3] linux-user: add -dfilter progtext shortcut 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: Riku Voipio , =?utf-8?q?Alex_Benn=C3=A9e?= , Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When debugging you often don't care about the libraries but just the code in the testcase. Rather than make the user build this by hand offer a shortcut. Signed-off-by: Alex Bennée --- linux-user/main.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) -- 2.17.1 Reviewed-by: Laurent Vivier diff --git a/linux-user/main.c b/linux-user/main.c index ea00dd9057..8d4427727e 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -28,6 +28,7 @@ #include "qemu/config-file.h" #include "qemu/cutils.h" #include "qemu/help_option.h" +#include "qemu/range.h" #include "cpu.h" #include "exec/exec-all.h" #include "tcg.h" @@ -51,6 +52,8 @@ unsigned long mmap_min_addr; unsigned long guest_base; int have_guest_base; +static bool dfilter_progtext; + /* * When running 32-on-64 we should make sure we can fit all of the possible * guest address space into a contiguous chunk of virtual host memory. @@ -222,6 +225,11 @@ static void handle_arg_log(const char *arg) static void handle_arg_dfilter(const char *arg) { + if (strcmp(arg, "progtext") == 0) { + dfilter_progtext = true; + return; + } + qemu_set_dfilter_ranges(arg, NULL); } @@ -423,7 +431,7 @@ static const struct qemu_argument arg_table[] = { "item[,...]", "enable logging of specified items " "(use '-d help' for a list of items)"}, {"dfilter", "QEMU_DFILTER", true, handle_arg_dfilter, - "range[,...]","filter logging based on address range"}, + "range|progtext[,...]", "filter logging based on address range"}, {"D", "QEMU_LOG_FILENAME", true, handle_arg_log_filename, "logfile", "write logs to 'logfile' (default stderr)"}, {"p", "QEMU_PAGESIZE", true, handle_arg_pagesize, @@ -796,6 +804,12 @@ int main(int argc, char **argv, char **envp) qemu_log("auxv_start 0x" TARGET_ABI_FMT_lx "\n", info->saved_auxv); } + if (dfilter_progtext) { + Range r; + range_set_bounds(&r, info->start_code, info->end_code); + qemu_append_dfilter_range(r, NULL); + } + target_set_brk(info->brk); syscall_init(); signal_init();