From patchwork Fri Mar 28 16:43:25 2014 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: 27362 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f200.google.com (mail-ve0-f200.google.com [209.85.128.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0F16920545 for ; Fri, 28 Mar 2014 16:50:11 +0000 (UTC) Received: by mail-ve0-f200.google.com with SMTP id oy12sf11748563veb.3 for ; Fri, 28 Mar 2014 09:50:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=Ap8jhpraax1QsjcHgy9twyp4I7NzzspSpaNuUCV6oiU=; b=b+yXTzhSBE+WtIwX6PiSUwLKY1J2+oUMDxeKKC1jg4ED463+l+9/dWNXjiZWPMxXyU ssyYq49HmKKGtNb/DBpuy/iHHMse/hC+9zOMhLDHtHL9Nu06fEguulpJZmyv8PfqMk8I P59VMjTDn9r5ABDqyJ3YBw6epv6jdqaC1n5eQ8ErypaC4Fuowxwfis8+wcjo2X1uynuk /nQx3FdwRcZGKNoHI26UCpwosb7i4bAl42CBxROYmoF+6KwQdNQ+uYToO/E+oFx9Y5lO /uTMKpUHQiGRx/d1857ttjZ011H5M9+5lJWjIxN+q0/ponbJNdvswjeVv3cEGLJeUgJw 8Z1Q== X-Gm-Message-State: ALoCoQniwaa3HNennhj9a8JU3FounvGKcq6zAX+Mg83J8vv1YmOJTBKsR9VAgq8DGCuMIv6iEGJS X-Received: by 10.236.130.101 with SMTP id j65mr2844791yhi.29.1396025411801; Fri, 28 Mar 2014 09:50:11 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.16.73 with SMTP id 67ls1595054qga.18.gmail; Fri, 28 Mar 2014 09:50:11 -0700 (PDT) X-Received: by 10.58.187.78 with SMTP id fq14mr7902523vec.9.1396025411633; Fri, 28 Mar 2014 09:50:11 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id fx7si1237147vcb.153.2014.03.28.09.50.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Mar 2014 09:50:11 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id im17so6005670vcb.23 for ; Fri, 28 Mar 2014 09:50:11 -0700 (PDT) X-Received: by 10.52.119.197 with SMTP id kw5mr6670519vdb.5.1396025411542; Fri, 28 Mar 2014 09:50:11 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.12.8 with SMTP id v8csp23513vcv; Fri, 28 Mar 2014 09:50:11 -0700 (PDT) X-Received: by 10.224.132.6 with SMTP id z6mr10589793qas.66.1396025410842; Fri, 28 Mar 2014 09:50:10 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m17si2801033qga.165.2014.03.28.09.50.10 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 28 Mar 2014 09:50:10 -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; Received: from localhost ([::1]:35003 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTZys-0006nE-Eq for patch@linaro.org; Fri, 28 Mar 2014 12:50:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52957) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTZsV-00077G-3t for qemu-devel@nongnu.org; Fri, 28 Mar 2014 12:43:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WTZsP-0002js-R8 for qemu-devel@nongnu.org; Fri, 28 Mar 2014 12:43:35 -0400 Received: from static.88-198-71-155.clients.your-server.de ([88.198.71.155]:56335 helo=socrates.bennee.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTZsP-0002jU-HU for qemu-devel@nongnu.org; Fri, 28 Mar 2014 12:43:29 -0400 Received: from localhost ([127.0.0.1] helo=zen.linaro.local) by socrates.bennee.com with esmtp (Exim 4.80) (envelope-from ) id 1WTZso-0004ll-FO; Fri, 28 Mar 2014 17:43:54 +0100 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 28 Mar 2014 16:43:25 +0000 Message-Id: <1396025007-27592-6-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1396025007-27592-1-git-send-email-alex.bennee@linaro.org> References: <1396025007-27592-1-git-send-email-alex.bennee@linaro.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: alex.bennee@linaro.org X-SA-Exim-Scanned: No (on socrates.bennee.com); SAEximRunCond expanded to false X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 88.198.71.155 Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Anthony Liguori Subject: [Qemu-devel] [PATCH v2 5/7] qemu-log: new option -dfilter to limit output X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: alex.bennee@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 When debugging big programs or system emulation sometimes you want both the verbosity of cpu,exec et all but don't want to generate lots of logs for unneeded stuff. This patch adds a new option -dfilter which allows you to specify interesting address ranges in the form: -dfilter 0x8000-0x9000,0xffffffc000080000+0x200,... Then logging code can use the new qemu_log_in_addr_range() function to decide if it will output logging information for the given range. Signed-off-by: Alex Bennée ---- v2 - More clean-ups to the documentation diff --git a/include/qemu/log.h b/include/qemu/log.h index da22e13..8cfe57f 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -181,6 +181,8 @@ static inline void qemu_set_log(int log_flags) } void qemu_set_log_filename(const char *filename); +void qemu_set_dfilter_ranges(const char *ranges); +bool qemu_log_in_addr_range(uint64_t addr); int qemu_str_to_log_mask(const char *str); /* Print a usage message listing all the valid logging categories diff --git a/qemu-log.c b/qemu-log.c index 4dd530c..a54b332 100644 --- a/qemu-log.c +++ b/qemu-log.c @@ -19,11 +19,13 @@ #include "qemu-common.h" #include "qemu/log.h" +#include "qemu/range.h" static char *logfilename; FILE *qemu_logfile; int qemu_loglevel; static int log_append = 0; +static GSList *debug_regions = NULL; void qemu_log(const char *fmt, ...) { @@ -92,6 +94,60 @@ void qemu_set_log_filename(const char *filename) qemu_set_log(qemu_loglevel); } +/* Returns true if addr is in our debug filter or no filter defined + */ +bool qemu_log_in_addr_range(uint64_t addr) +{ + if (debug_regions) { + GSList *region = debug_regions; + do { + struct Range *range = region->data; + if (addr >= range->begin && addr <= range->end) { + return true; + } + region = g_slist_next(region); + } while (region); + return false; + } else { + return true; + } +} + + +void qemu_set_dfilter_ranges(const char *filter_spec) +{ + gchar **ranges = g_strsplit(filter_spec, ",", 0); + if (ranges) { + gchar **next = ranges; + gchar *r = *next++; + while (r) { + gchar *delim = g_strrstr(r, "-"); + if (!delim) { + delim = g_strrstr(r, "+"); + } + if (delim) { + struct Range *range = g_malloc(sizeof(Range)); + range->begin = strtoul(r, NULL, 0); + switch (*delim) { + case '+': + range->end = range->begin + strtoul(delim+1, NULL, 0); + break; + case '-': + range->end = strtoul(delim+1, NULL, 0); + break; + default: + g_assert_not_reached(); + } + debug_regions = g_slist_append(debug_regions, range); + } else { + g_error("Bad range specifier in: %s", r); + } + r = *next++; + } + g_strfreev(ranges); + } +} + const QEMULogItem qemu_log_items[] = { { CPU_LOG_TB_OUT_ASM, "out_asm", "show generated host assembly code for each compiled TB" }, diff --git a/qemu-options.hx b/qemu-options.hx index 2d33815..ae0b5c0 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2675,6 +2675,22 @@ STEXI Output log in @var{logfile} instead of to stderr ETEXI +DEF("dfilter", HAS_ARG, QEMU_OPTION_DFILTER, \ + "-dfilter range,.. filter debug output to range of addresses (useful for -d cpu,exec,etc..)\n", + QEMU_ARCH_ALL) +STEXI +@item -dfilter @var{range1}[,...] +@findex -dfilter +Filter debug output to that relevant to a range of target addresses. The filter +spec can be either @var{start}-@var{end} or @var{start}+@var{size} where @var{start} +@var{end} and @var{size} are the addresses and sizes required. For example: +@example + -dfilter 0x8000-0x9000,0xffffffc000080000+0x200 +@end example +Will dump output for any code in the 0x1000 sized block starting at 0x8000 and +the 0x200 sized block starting at 0xffffffc000080000. +ETEXI + DEF("L", HAS_ARG, QEMU_OPTION_L, \ "-L path set the directory for the BIOS, VGA BIOS and keymaps\n", QEMU_ARCH_ALL) diff --git a/vl.c b/vl.c index 9975e5a..c130c00 100644 --- a/vl.c +++ b/vl.c @@ -3334,6 +3334,9 @@ int main(int argc, char **argv, char **envp) case QEMU_OPTION_D: log_file = optarg; break; + case QEMU_OPTION_DFILTER: + qemu_set_dfilter_ranges(optarg); + break; case QEMU_OPTION_s: add_device_config(DEV_GDB, "tcp::" DEFAULT_GDBSTUB_PORT); break;