diff mbox

compile failure if I enable guest_mem_before trace event

Message ID 20170324023943.GA21650@flamenco
State New
Headers show

Commit Message

Emilio Cota March 24, 2017, 2:39 a.m. UTC
On Thu, Mar 23, 2017 at 19:08:11 +0000, Peter Maydell wrote:
> Hi; I thought I'd have a look at the guest_mem_before trace event,
> but if I enable it (by deleting "disable" from the line in trace-events)
> QEMU doesn't compile:
> 
>   CC      arm-softmmu/tcg/tcg-op.o
> In file included from
> /home/petmay01/linaro/qemu-from-laptop/qemu/include/trace-tcg.h:4:0,
>                  from
> /home/petmay01/linaro/qemu-from-laptop/qemu/tcg/tcg-op.c:31:
> ../trace/generated-tcg-tracers.h: In function ‘trace_guest_mem_before_tcg’:
> ../trace/generated-tcg-tracers.h:11:5: error: implicit declaration of
> function ‘trace_guest_mem_before_trans’
> [-Werror=implicit-function-declaration]
>      trace_guest_mem_before_trans(__cpu, info);
>      ^
> ../trace/generated-tcg-tracers.h:11:5: error: nested extern
> declaration of ‘trace_guest_mem_before_trans’ [-Werror=nested-externs]
> 
> Am I doing something wrong, or is this a bug?

It doesn't work for me either. I bisected it to:

0ab8ed18 "trace: switch to modular code generation for sub-directories"

It seems that after that commit no appropriate include is added
to the generated tcg tracing .h files. The 'header' variable isn't used
in the generation scripts for TCG, which is suspicious, e.g.:

Comments

Stefan Hajnoczi March 27, 2017, 1:17 p.m. UTC | #1
On Thu, Mar 23, 2017 at 10:39:43PM -0400, Emilio G. Cota wrote:
> On Thu, Mar 23, 2017 at 19:08:11 +0000, Peter Maydell wrote:
> > Hi; I thought I'd have a look at the guest_mem_before trace event,
> > but if I enable it (by deleting "disable" from the line in trace-events)
> > QEMU doesn't compile:
> > 
> >   CC      arm-softmmu/tcg/tcg-op.o
> > In file included from
> > /home/petmay01/linaro/qemu-from-laptop/qemu/include/trace-tcg.h:4:0,
> >                  from
> > /home/petmay01/linaro/qemu-from-laptop/qemu/tcg/tcg-op.c:31:
> > ../trace/generated-tcg-tracers.h: In function ‘trace_guest_mem_before_tcg’:
> > ../trace/generated-tcg-tracers.h:11:5: error: implicit declaration of
> > function ‘trace_guest_mem_before_trans’
> > [-Werror=implicit-function-declaration]
> >      trace_guest_mem_before_trans(__cpu, info);
> >      ^
> > ../trace/generated-tcg-tracers.h:11:5: error: nested extern
> > declaration of ‘trace_guest_mem_before_trans’ [-Werror=nested-externs]
> > 
> > Am I doing something wrong, or is this a bug?
> 
> It doesn't work for me either. I bisected it to:
> 
> 0ab8ed18 "trace: switch to modular code generation for sub-directories"
> 
> It seems that after that commit no appropriate include is added
> to the generated tcg tracing .h files. The 'header' variable isn't used
> in the generation scripts for TCG, which is suspicious, e.g.:
> 
> --- a/scripts/tracetool/format/tcg_h.py
> +++ b/scripts/tracetool/format/tcg_h.py
> @@ -28,13 +28,17 @@ def vcpu_transform_args(args):
> 
> 
>  def generate(events, backend, group):
> +    if group == "root":
> +        header = "trace-root.h"
> +    else:
> +        header = "trace.h"
> +
>      out('/* This file is autogenerated by tracetool, do not edit. */',
>          '/* You must include this file after the inclusion of helper.h */',
>          '',
>          '#ifndef TRACE_%s_GENERATED_TCG_TRACERS_H' % group.upper(),
>          '#define TRACE_%s_GENERATED_TCG_TRACERS_H' % group.upper(),
>          '',
> -        '#include "trace.h"',
>          '#include "exec/helper-proto.h"',
>          '',
>          )
> 
> 
> The appended fixes it for me; I hope it's enough for the tracing
> people to come quickly to a proper fix (sorry, I didn't even know
> what the tracing features were only a few minutes ago!).

Thanks for looking into this.  I have sent a patch.

Stefan
diff mbox

Patch

--- a/scripts/tracetool/format/tcg_h.py
+++ b/scripts/tracetool/format/tcg_h.py
@@ -28,13 +28,17 @@  def vcpu_transform_args(args):


 def generate(events, backend, group):
+    if group == "root":
+        header = "trace-root.h"
+    else:
+        header = "trace.h"
+
     out('/* This file is autogenerated by tracetool, do not edit. */',
         '/* You must include this file after the inclusion of helper.h */',
         '',
         '#ifndef TRACE_%s_GENERATED_TCG_TRACERS_H' % group.upper(),
         '#define TRACE_%s_GENERATED_TCG_TRACERS_H' % group.upper(),
         '',
-        '#include "trace.h"',
         '#include "exec/helper-proto.h"',
         '',
         )


The appended fixes it for me; I hope it's enough for the tracing
people to come quickly to a proper fix (sorry, I didn't even know
what the tracing features were only a few minutes ago!).

Thanks,

		Emilio

diff --git a/scripts/tracetool/format/tcg_h.py b/scripts/tracetool/format/tcg_h.py
index 7ddc4a5..d020e9d 100644
--- a/scripts/tracetool/format/tcg_h.py
+++ b/scripts/tracetool/format/tcg_h.py
@@ -28,10 +28,7 @@  def vcpu_transform_args(args):
 
 
 def generate(events, backend, group):
-    if group == "root":
-        header = "trace-root.h"
-    else:
-        header = "trace.h"
+    header = "trace-root.h"
 
     out('/* This file is autogenerated by tracetool, do not edit. */',
         '/* You must include this file after the inclusion of helper.h */',
@@ -40,6 +37,7 @@  def generate(events, backend, group):
         '#define TRACE_%s_GENERATED_TCG_TRACERS_H' % group.upper(),
         '',
         '#include "exec/helper-proto.h"',
+        '#include "%s"' % header,
         '',
         )
 
diff --git a/scripts/tracetool/format/tcg_helper_c.py b/scripts/tracetool/format/tcg_helper_c.py
index 7dccd8c..be7c71b 100644
--- a/scripts/tracetool/format/tcg_helper_c.py
+++ b/scripts/tracetool/format/tcg_helper_c.py
@@ -41,10 +41,7 @@  def vcpu_transform_args(args, mode):
 
 
 def generate(events, backend, group):
-    if group == "root":
-        header = "trace-root.h"
-    else:
-        header = "trace.h"
+    header = "trace-root.h"
 
     events = [e for e in events
               if "disable" not in e.properties]
@@ -55,6 +52,7 @@  def generate(events, backend, group):
         '#include "qemu-common.h"',
         '#include "cpu.h"',
         '#include "exec/helper-proto.h"',
+        '#include "%s"' % header,
         '',
         )