All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Lluís Vilanova" <vilanova@ac.upc.edu>,
	qemu-devel <qemu-devel@nongnu.org>,
	"Stefan Hajnoczi" <stefanha@gmail.com>
Subject: Re: [Qemu-devel] [PATCH v3 05/24] trace: Minimize inclusions of "qemu-common.h" to avoid inclusion loops
Date: Fri, 26 Apr 2013 17:23:39 +0200	[thread overview]
Message-ID: <517A9BFB.6050103@redhat.com> (raw)
In-Reply-To: <20130421191157.8947.82654.stgit@fimbulvetr.bsc.es>

Il 21/04/2013 21:11, Lluís Vilanova ha scritto:
> This problem arises in the following patches.

Removing inclusions of qemu-common.h from .h files is definitely useful.

However, the TRACE__CONTROL__USE__TRACE_PRINT_EVENTS is really hideous.
:)  Just make inclusion of qemu-common.h mandatory before inclusion of
trace/control.h.

Paolo

> Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
> ---
>  hw/virtio/virtio.c            |    1 +
>  monitor.c                     |    4 +++-
>  scripts/tracetool/format/h.py |    9 ++++++++-
>  trace/control-internal.h      |    4 +++-
>  trace/control.c               |    4 +++-
>  trace/control.h               |    9 +++++++--
>  trace/default.c               |    4 +++-
>  trace/simple.c                |    4 +++-
>  trace/simple.h                |    1 +
>  trace/stderr.c                |    4 +++-
>  10 files changed, 35 insertions(+), 9 deletions(-)
> 
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index 1c2282c..a3dda2c 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -14,6 +14,7 @@
>  #include <inttypes.h>
>  
>  #include "trace.h"
> +#include "qemu-common.h"
>  #include "qemu/error-report.h"
>  #include "hw/virtio/virtio.h"
>  #include "qemu/atomic.h"
> diff --git a/monitor.c b/monitor.c
> index c897e80..a8f49d9 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -22,6 +22,9 @@
>   * THE SOFTWARE.
>   */
>  #include <dirent.h>
> +#define TRACE__CONTROL__USE__TRACE_PRINT_EVENTS
> +#include "trace/control.h"
> +#undef TRACE__CONTROL__USE__TRACE_PRINT_EVENTS
>  #include "hw/hw.h"
>  #include "monitor/qdev.h"
>  #include "hw/usb.h"
> @@ -59,7 +62,6 @@
>  #include "qemu/osdep.h"
>  #include "cpu.h"
>  #include "trace.h"
> -#include "trace/control.h"
>  #ifdef CONFIG_TRACE_SIMPLE
>  #include "trace/simple.h"
>  #endif
> diff --git a/scripts/tracetool/format/h.py b/scripts/tracetool/format/h.py
> index ed7c8a5..c98aebd 100644
> --- a/scripts/tracetool/format/h.py
> +++ b/scripts/tracetool/format/h.py
> @@ -22,7 +22,14 @@ def begin(events):
>          '#ifndef TRACE__GENERATED_TRACERS_H',
>          '#define TRACE__GENERATED_TRACERS_H',
>          '',
> -        '#include "qemu-common.h"')
> +        '/* Do not directly include "qemu-common.h" to avoid circular dependencies */',
> +        '#include <stdint.h>',
> +        '#include <inttypes.h>',
> +        '#include <stdbool.h>',
> +        '#include <stddef.h>',
> +        '#include <unistd.h>',
> +        '',
> +        )
>  
>  def end(events):
>      out('#endif /* TRACE__GENERATED_TRACERS_H */')
> diff --git a/trace/control-internal.h b/trace/control-internal.h
> index cce2da4..a15a994 100644
> --- a/trace/control-internal.h
> +++ b/trace/control-internal.h
> @@ -1,7 +1,7 @@
>  /*
>   * Interface for configuring and controlling the state of tracing events.
>   *
> - * Copyright (C) 2011-2012 Lluís Vilanova <vilanova@ac.upc.edu>
> + * Copyright (C) 2011-2013 Lluís Vilanova <vilanova@ac.upc.edu>
>   *
>   * This work is licensed under the terms of the GNU GPL, version 2 or later.
>   * See the COPYING file in the top-level directory.
> @@ -11,6 +11,8 @@
>  #define TRACE__CONTROL_INTERNAL_H
>  
>  #include <string.h>
> +#include <assert.h>
> +#include <stddef.h>
>  
>  
>  extern TraceEvent trace_events[];
> diff --git a/trace/control.c b/trace/control.c
> index 49f61e1..dd7b260 100644
> --- a/trace/control.c
> +++ b/trace/control.c
> @@ -1,7 +1,7 @@
>  /*
>   * Interface for configuring and controlling the state of tracing events.
>   *
> - * Copyright (C) 2011-2012 Lluís Vilanova <vilanova@ac.upc.edu>
> + * Copyright (C) 2011-2013 Lluís Vilanova <vilanova@ac.upc.edu>
>   *
>   * This work is licensed under the terms of the GNU GPL, version 2 or later.
>   * See the COPYING file in the top-level directory.
> @@ -9,6 +9,8 @@
>  
>  #include "trace/control.h"
>  
> +#include "qemu-common.h"
> +
>  
>  TraceEvent *trace_event_name(const char *name)
>  {
> diff --git a/trace/control.h b/trace/control.h
> index cde8260..29ff9c1 100644
> --- a/trace/control.h
> +++ b/trace/control.h
> @@ -1,7 +1,7 @@
>  /*
>   * Interface for configuring and controlling the state of tracing events.
>   *
> - * Copyright (C) 2011-2012 Lluís Vilanova <vilanova@ac.upc.edu>
> + * Copyright (C) 2011-2013 Lluís Vilanova <vilanova@ac.upc.edu>
>   *
>   * This work is licensed under the terms of the GNU GPL, version 2 or later.
>   * See the COPYING file in the top-level directory.
> @@ -10,7 +10,6 @@
>  #ifndef TRACE__CONTROL_H
>  #define TRACE__CONTROL_H
>  
> -#include "qemu-common.h"
>  #include "trace/generated-events.h"
>  
>  
> @@ -155,6 +154,10 @@ void trace_event_set_state_dynamic_backend(TraceEvent *ev, bool state);
>  
>  
>  
> +#if defined(TRACE__CONTROL__USE__TRACE_PRINT_EVENTS)
> +/* Minimize inclusions of "qemu-common.h" to avoid circular dependencies */
> +#include "qemu-common.h"

Can you just include this from the C files instead?

>  /**
>   * trace_print_events:
>   *
> @@ -164,6 +167,8 @@ void trace_event_set_state_dynamic_backend(TraceEvent *ev, bool state);
>   */
>  void trace_print_events(FILE *stream, fprintf_function stream_printf);
>  
> +#endif  /* defined(TRACE__CONTROL__USE__TRACE_PRINT_EVENTS) */
> +
>  /**
>   * trace_backend_init:
>   * @events: Name of file with events to be enabled at startup; may be NULL.
> diff --git a/trace/default.c b/trace/default.c
> index 6e07a47..4dbaf11 100644
> --- a/trace/default.c
> +++ b/trace/default.c
> @@ -1,13 +1,15 @@
>  /*
>   * Default implementation for backend initialization from commandline.
>   *
> - * Copyright (C) 2011-2012 Lluís Vilanova <vilanova@ac.upc.edu>
> + * Copyright (C) 2011-2013 Lluís Vilanova <vilanova@ac.upc.edu>
>   *
>   * This work is licensed under the terms of the GNU GPL, version 2.  See
>   * the COPYING file in the top-level directory.
>   */
>  
> +#define TRACE__CONTROL__USE__TRACE_PRINT_EVENTS
>  #include "trace/control.h"
> +#undef TRACE__CONTROL__USE__TRACE_PRINT_EVENTS
>  
>  
>  void trace_print_events(FILE *stream, fprintf_function stream_printf)
> diff --git a/trace/simple.c b/trace/simple.c
> index 8b59760..cb4361f 100644
> --- a/trace/simple.c
> +++ b/trace/simple.c
> @@ -19,8 +19,10 @@
>  #include <pthread.h>
>  #endif
>  #include "qemu/timer.h"
> -#include "trace.h"
> +#define TRACE__CONTROL__USE__TRACE_PRINT_EVENTS
>  #include "trace/control.h"
> +#undef TRACE__CONTROL__USE__TRACE_PRINT_EVENTS
> +#include "trace.h"
>  
>  /** Trace file header event ID */
>  #define HEADER_EVENT_ID (~(uint64_t)0) /* avoids conflicting with TraceEventIDs */
> diff --git a/trace/simple.h b/trace/simple.h
> index 5260d9a..1541ea0 100644
> --- a/trace/simple.h
> +++ b/trace/simple.h
> @@ -16,6 +16,7 @@
>  #include <stdio.h>
>  
>  #include "trace/generated-events.h"
> +#include "qemu-common.h"
>  
>  
>  void st_print_trace_file_status(FILE *stream, fprintf_function stream_printf);
> diff --git a/trace/stderr.c b/trace/stderr.c
> index e212efd..3a6f4bd 100644
> --- a/trace/stderr.c
> +++ b/trace/stderr.c
> @@ -1,5 +1,7 @@
> -#include "trace.h"
> +#define TRACE__CONTROL__USE__TRACE_PRINT_EVENTS
>  #include "trace/control.h"
> +#undef TRACE__CONTROL__USE__TRACE_PRINT_EVENTS
> +#include "trace.h"
>  
>  
>  void trace_print_events(FILE *stream, fprintf_function stream_printf)
> 
> 
> 

  reply	other threads:[~2013-04-26 15:23 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-21 19:11 [Qemu-devel] [RFC][PATCH v3 00/24] instrument: Let the user wrap/override specific event tracing routines Lluís Vilanova
2013-04-21 19:11 ` [Qemu-devel] [PATCH v3 01/24] instrument: Add documentation Lluís Vilanova
2013-04-21 19:11 ` [Qemu-devel] [PATCH v3 02/24] trace: [simple] Do not include "trace/simple.h" in generated tracer headers Lluís Vilanova
2013-04-21 19:11 ` [Qemu-devel] [PATCH v3 03/24] trace: Let the user specify her own trace-events file Lluís Vilanova
2013-04-26 15:21   ` Paolo Bonzini
2013-04-26 18:28     ` Lluís Vilanova
2013-04-21 19:11 ` [Qemu-devel] [PATCH v3 04/24] tracetool: Use method 'Event.api' to get the name of public routines Lluís Vilanova
2013-04-21 19:11 ` [Qemu-devel] [PATCH v3 05/24] trace: Minimize inclusions of "qemu-common.h" to avoid inclusion loops Lluís Vilanova
2013-04-26 15:23   ` Paolo Bonzini [this message]
2013-04-21 19:12 ` [Qemu-devel] [PATCH v3 06/24] instrument: [none] Add null instrumentation Lluís Vilanova
2013-04-21 19:12 ` [Qemu-devel] [PATCH v3 07/24] system: [linux] Use absolute include path for linux-headers Lluís Vilanova
2013-04-26 15:17   ` Paolo Bonzini
2013-04-21 19:12 ` [Qemu-devel] [PATCH v3 08/24] instrument: [static] Call statically linked user-provided routines Lluís Vilanova
2013-04-21 19:12 ` [Qemu-devel] [PATCH v3 09/24] build: Add variable 'tools-obj-y' for tool-only files Lluís Vilanova
2013-04-21 19:12 ` [Qemu-devel] [PATCH v3 10/24] instrument: [dynamic] Call dynamically linked user-provided routines Lluís Vilanova
2013-04-21 19:12 ` [Qemu-devel] [PATCH v3 11/24] qapi: Add a primitive to include other files from a QAPI schema file Lluís Vilanova
2013-04-21 19:12 ` [Qemu-devel] [PATCH v3 12/24] qapi: [trivial] Set the input root directory when parsing QAPI files Lluís Vilanova
2013-04-21 19:12 ` [Qemu-devel] [PATCH v3 13/24] qapi: [trivial] Allow user to use 'args' as an argument name Lluís Vilanova
2013-04-21 19:12 ` [Qemu-devel] [PATCH v3 14/24] instrument: Add internal control interface Lluís Vilanova
2013-04-26 14:08   ` Eric Blake
2013-04-26 15:11   ` Paolo Bonzini
2013-04-26 15:25     ` Lluís Vilanova
2013-04-26 15:27       ` Paolo Bonzini
2013-04-21 19:12 ` [Qemu-devel] [PATCH v3 15/24] instrument: [qmp, qapi] Add " Lluís Vilanova
2013-04-21 19:12 ` [Qemu-devel] [PATCH v3 16/24] instrument: [hmp] " Lluís Vilanova
2013-04-21 19:13 ` [Qemu-devel] [PATCH v3 17/24] Let makefiles add entries to the set of target architecture objects Lluís Vilanova
2013-04-21 19:13 ` [Qemu-devel] [PATCH v3 18/24] instrument: Add commandline options to start with an instrumentation library Lluís Vilanova
2013-04-21 19:13 ` [Qemu-devel] [PATCH v3 19/24] instrument: Add client-side API to enumerate events Lluís Vilanova
2013-04-21 19:13 ` [Qemu-devel] [PATCH v3 20/24] instrument: Add client-side API to control tracing state of events Lluís Vilanova
2013-04-21 19:13 ` [Qemu-devel] [PATCH v3 21/24] instrument: Add client-side API to control event instrumentation Lluís Vilanova
2013-04-21 19:13 ` [Qemu-devel] [PATCH v3 22/24] build: Fix installation of target-dependant files Lluís Vilanova
2013-04-26 15:24   ` Paolo Bonzini
2013-04-26 15:27     ` Peter Maydell
2013-04-21 19:13 ` [Qemu-devel] [PATCH v3 23/24] instrument: Install headers for dynamic instrumentation clients Lluís Vilanova
2013-04-21 19:13 ` [Qemu-devel] [PATCH v3 24/24] trace: Do not use the word 'new' in event arguments Lluís Vilanova
2013-04-24 11:17 ` [Qemu-devel] [RFC][PATCH v3 00/24] instrument: Let the user wrap/override specific event tracing routines Stefan Hajnoczi
2013-04-24 12:17   ` Lluís Vilanova
2013-04-25 12:39     ` Stefan Hajnoczi
2013-04-26 12:15       ` Lluís Vilanova
2013-04-26 15:10         ` Stefan Hajnoczi
2013-04-28 19:25           ` Lluís Vilanova
2013-05-01 11:54             ` Stefan Hajnoczi
2013-05-01 14:34               ` Lluís Vilanova

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=517A9BFB.6050103@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=vilanova@ac.upc.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.