qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Christopher Covington <cov@codeaurora.org>
To: "Alex Bennée" <alex.bennee@linaro.org>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, pbonzini@redhat.com,
	crosthwaitepeter@gmail.com, aurelien@aurel32.net,
	rth@twiddle.net
Subject: Re: [Qemu-devel] [PATCH v4 07/11] qemu-log: new option -dfilter to limit output
Date: Mon, 10 Aug 2015 12:59:01 -0400	[thread overview]
Message-ID: <55C8D855.9060205@codeaurora.org> (raw)
In-Reply-To: <1438593291-27109-8-git-send-email-alex.bennee@linaro.org>

Hi Alex,

On 08/03/2015 05:14 AM, Alex Bennée wrote:
> 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 <alex.bennee@linaro.org>

My usual flow is to filter based on mode (CurrentEL on AArch64) and PID
(CONTEXTIDR on AArch64). Do you foresee any problems with adding such filters?

Thanks,
Christopher Covington

> v2
>   - More clean-ups to the documentation
> 
> v3
>   - re-base
>   - use GArray instead of GList to avoid cache bouncing
>   - checkpatch fixes
> ---
>  include/qemu/log.h |  2 ++
>  qemu-log.c         | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  qemu-options.hx    | 16 +++++++++++++++
>  vl.c               |  3 +++
>  4 files changed, 78 insertions(+)
> 
> diff --git a/include/qemu/log.h b/include/qemu/log.h
> index b80f8f5..ade1f76 100644
> --- a/include/qemu/log.h
> +++ b/include/qemu/log.h
> @@ -182,6 +182,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 77ed7bc..b3ebd3c 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 GArray *debug_regions;
>  
>  void qemu_log(const char *fmt, ...)
>  {
> @@ -92,6 +94,61 @@ 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) {
> +        int i = 0;
> +        for (i = 0; i < debug_regions->len; i++) {
> +            struct Range *range = &g_array_index(debug_regions, Range, i);
> +            if (addr >= range->begin && addr <= range->end) {
> +                return true;
> +            }
> +        }
> +        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++;
> +        debug_regions = g_array_sized_new(FALSE, FALSE,
> +                                          sizeof(Range), g_strv_length(ranges));
> +        while (r) {
> +            gchar *delim = g_strrstr(r, "-");
> +            if (!delim) {
> +                delim = g_strrstr(r, "+");
> +            }
> +            if (delim) {
> +                struct Range 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();
> +                }
> +                g_array_append_val(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 ae53346..90f0df9 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -2987,6 +2987,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 1d2de4f..05211cf 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -3349,6 +3349,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_PERFMAP:
>                  tb_enable_perfmap();
>                  break;
> 


-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

  parent reply	other threads:[~2015-08-10 16:59 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-03  9:14 [Qemu-devel] [PATCH v4 00/11] qemu-log, perfmap and other logging tweaks Alex Bennée
2015-08-03  9:14 ` [Qemu-devel] [PATCH v4 01/11] tcg: add ability to dump /tmp/perf-<pid>.map files Alex Bennée
2015-08-03 13:40   ` Paolo Bonzini
2015-08-04  7:39     ` Alex Bennée
2015-08-04 10:02       ` Paolo Bonzini
2015-08-04 11:59       ` Aurelien Jarno
2015-08-04 12:55         ` Alex Bennée
2015-08-04 19:01           ` Aurelien Jarno
2015-08-04 12:15   ` Aurelien Jarno
2015-08-03  9:14 ` [Qemu-devel] [PATCH v4 02/11] tcg: light re-factor and pass down TranslationBlock Alex Bennée
2015-08-04 12:36   ` Aurelien Jarno
2016-02-03 18:38     ` Alex Bennée
2015-08-03  9:14 ` [Qemu-devel] [PATCH v4 03/11] qemu-log: correct help text for -d cpu Alex Bennée
2015-08-04 12:16   ` Aurelien Jarno
2015-08-04 15:11     ` Alex Bennée
2015-08-04 15:15       ` Peter Maydell
2015-08-04 15:21         ` Richard Henderson
2015-08-04 17:22           ` Alex Bennée
2015-08-04 18:09             ` Richard Henderson
2015-08-04 19:08               ` Alex Bennée
2015-08-04 19:16                 ` Richard Henderson
2015-09-15 19:28                   ` Peter Maydell
2015-09-15 19:41                     ` Richard Henderson
2015-08-03  9:14 ` [Qemu-devel] [PATCH v4 04/11] qemu-log: Avoid function call for disabled qemu_log_mask logging Alex Bennée
2015-08-04 12:17   ` Aurelien Jarno
2015-08-03  9:14 ` [Qemu-devel] [PATCH v4 05/11] qemu-log: Improve the "exec" TB execution logging Alex Bennée
2015-08-04 12:17   ` Aurelien Jarno
2015-08-10 19:40   ` Christopher Covington
2016-02-03 18:45     ` Alex Bennée
2015-08-03  9:14 ` [Qemu-devel] [PATCH v4 06/11] qemu-log: support simple pid substitution in logfile Alex Bennée
2015-08-04 12:17   ` Aurelien Jarno
2015-08-03  9:14 ` [Qemu-devel] [PATCH v4 07/11] qemu-log: new option -dfilter to limit output Alex Bennée
2015-08-04 12:21   ` Aurelien Jarno
2015-08-10 16:59   ` Christopher Covington [this message]
2015-08-10 18:30     ` Alex Bennée
2015-08-03  9:14 ` [Qemu-devel] [PATCH v4 08/11] qemu-log: dfilter-ise exec, out_asm, and op_opt Alex Bennée
2015-08-04 12:22   ` Aurelien Jarno
2015-08-03  9:14 ` [Qemu-devel] [PATCH v4 09/11] target-arm: dfilter support for in_asm, op, opt_op Alex Bennée
2015-08-04 12:23   ` Aurelien Jarno
2015-08-04 14:44   ` Richard Henderson
2015-08-04 17:26     ` Alex Bennée
2015-08-04 18:11       ` Richard Henderson
2015-08-03  9:14 ` [Qemu-devel] [PATCH v4 10/11] vl.c: log system invocation when enabled Alex Bennée
2015-08-04 12:30   ` Aurelien Jarno
2015-08-04 12:40   ` Peter Maydell
2015-08-04 12:46     ` Aurelien Jarno
2015-08-04 13:14       ` Peter Maydell
2015-08-04 15:12         ` Alex Bennée
2015-08-03  9:14 ` [Qemu-devel] [PATCH v4 11/11] cputlb: modernise the debug support Alex Bennée
2015-08-04 12:33   ` Aurelien Jarno
2016-02-03 18:54     ` Alex Bennée
2016-02-03 19:05       ` Peter Maydell
2016-02-04  7:03         ` Alex Bennée
2015-09-11  7:54 ` [Qemu-devel] [PATCH v4 00/11] qemu-log, perfmap and other logging tweaks Michael Tokarev
2015-09-11 14:07   ` Alex Bennée

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55C8D855.9060205@codeaurora.org \
    --to=cov@codeaurora.org \
    --cc=alex.bennee@linaro.org \
    --cc=aurelien@aurel32.net \
    --cc=crosthwaitepeter@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).