try fix tracing for modules
PATCH 4/4 meson: try link tracepoints to module
In reply to Gerd HoffmannAdd source set to trace_events_config, use it in trace/meson.build so the trace objects are linked to the module not core qemu.
Not working as intended.
/me looks puzzled.
--- hw/display/meson.build | 1 + trace/meson.build | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-)
hw/display/meson.build +1 -0
@@ -46,6 +46,7 @@ if config_all_devices.has_key('CONFIG_QXL') trace_events_config += { 'file' : meson.source_root() / 'hw' / 'display' / 'trace-events-qxl', 'group' : 'hw_display_qxl', + 'ss' : qxl_ss, } hw_display_modules += {'qxl': qxl_ss} endif
trace/meson.build +5 -4
@@ -18,6 +18,7 @@ foreach c : trace_events_config trace_events_files += [ trace_events_file ] group = '--group=' + c.get('group') fmt = '@0@-' + c.get('group') + '.@1@' + module_ss = c.get('ss', trace_ss) trace_h = custom_target(fmt.format('trace', 'h'), output: fmt.format('trace', 'h'),
@@ -36,10 +37,10 @@ foreach c : trace_events_config input: trace_events_file, command: [ tracetool, group, '--format=ust-events-h', '@INPUT@' ], capture: true) - trace_ss.add(trace_ust_h, lttng, urcubp) + module_ss.add(trace_ust_h, lttng, urcubp) genh += trace_ust_h endif - trace_ss.add(trace_h, trace_c) + module_ss.add(trace_h, trace_c) if 'CONFIG_TRACE_DTRACE' in config_host trace_dtrace = custom_target(fmt.format('trace-dtrace', 'dtrace'), output: fmt.format('trace-dtrace', 'dtrace'),
@@ -50,13 +51,13 @@ foreach c : trace_events_config output: fmt.format('trace-dtrace', 'h'), input: trace_dtrace, command: [ 'dtrace', '-o', '@OUTPUT@', '-h', '-s', '@INPUT@' ]) - trace_ss.add(trace_dtrace_h) + module_ss.add(trace_dtrace_h) if host_machine.system() != 'darwin' trace_dtrace_o = custom_target(fmt.format('trace-dtrace', 'o'), output: fmt.format('trace-dtrace', 'o'), input: trace_dtrace, command: [ 'dtrace', '-o', '@OUTPUT@', '-G', '-s', '@INPUT@' ]) - trace_ss.add(trace_dtrace_o) + module_ss.add(trace_dtrace_o) endif genh += trace_dtrace_h
Signature · 1 line
2.27.0
cover try fix tracing for modules
Problem only partly solved so far.
Building separate object files for modules works. Actually linking those to the module not yet. See last patch of the series for my not working approach.
More context:
https://bugzilla.redhat.com/show_bug.cgi?id=1898700
https://bugzilla.redhat.com/show_bug.cgi?id=1869642
take care,
Gerd
Gerd Hoffmann (4):
meson: add trace_events_config[]
meson: move up hw subdir (specifically before trace subdir)
meson: move qxl trace events to separate file [broken] meson: try link tracepoints to module
hw/display/qxl-render.c | 1 + hw/display/qxl.c | 1 + hw/display/meson.build | 5 +++ hw/display/trace-events | 67 ------------------------------------- hw/display/trace-events-qxl | 66 ++++++++++++++++++++++++++++++++++++ meson.build | 4 ++- trace/meson.build | 30 ++++++++++++----- 7 files changed, 97 insertions(+), 77 deletions(-) create mode 100644 hw/display/trace-events-qxl
Signature · 1 line
2.27.0
PATCH 1/4 meson: add trace_events_config[]
It's an array of dicts, where each dict holds the configuration for one trace-events file. For now just fill it from trace_events_subdirs.
--- meson.build | 1 + trace/meson.build | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-)
meson.build +1 -0
@@ -1365,6 +1365,7 @@ target_softmmu_arch = {} # TODO: add each directory to the subdirs from its own meson.build, once # we have those +trace_events_config = [] trace_events_subdirs = [ 'accel/kvm', 'accel/tcg',
trace/meson.build +16 -5
@@ -1,12 +1,23 @@ specific_ss.add(files('control-target.c')) trace_events_files = [] -foreach dir : [ '.' ] + trace_events_subdirs - trace_events_file = meson.source_root() / dir / 'trace-events' + +trace_events_config += { + 'file' : meson.source_root() / 'trace-events', + 'group' : 'root', +} +foreach dir : trace_events_subdirs + trace_events_config += { + 'file' : meson.source_root() / dir / 'trace-events', + 'group' : dir.underscorify(), + } +endforeach + +foreach c : trace_events_config + trace_events_file = c.get('file') trace_events_files += [ trace_events_file ] - group_name = dir == '.' ? 'root' : dir.underscorify() - group = '--group=' + group_name - fmt = '@0@-' + group_name + '.@1@' + group = '--group=' + c.get('group') + fmt = '@0@-' + c.get('group') + '.@1@' trace_h = custom_target(fmt.format('trace', 'h'), output: fmt.format('trace', 'h'),
Signature · 1 line
2.27.0
PATCH 3/4 meson: move qxl trace events to separate file
In reply to Gerd HoffmannMove qxl trace events to separate trace-events-qxl file.
--- hw/display/qxl-render.c | 1 + hw/display/qxl.c | 1 + hw/display/meson.build | 4 +++ hw/display/trace-events | 67 ------------------------------------- hw/display/trace-events-qxl | 66 ++++++++++++++++++++++++++++++++++++ 5 files changed, 72 insertions(+), 67 deletions(-) create mode 100644 hw/display/trace-events-qxl
hw/display/qxl-render.c +1 -0
@@ -23,6 +23,7 @@#include "qxl.h" #include "sysemu/runstate.h" #include "trace.h" +#include "trace/trace-hw_display_qxl.h" static void qxl_blit (PCIQXLDevice *qxl,QXLRect *rect) {
hw/display/qxl.c +1 -0
@@ -33,6 +33,7 @@#include "migration/blocker.h" #include "migration/vmstate.h" #include "trace.h" +#include "trace/trace-hw_display_qxl.h" #include "qxl.h"
hw/display/meson.build +4 -0
@@ -43,6 +43,10 @@ if config_all_devices.has_key('CONFIG_QXL') qxl_ss = ss.source_set() qxl_ss.add(when: 'CONFIG_QXL', if_true: [files('qxl.c', 'qxl-logger.c', 'qxl-render.c'), pixman, spice]) + trace_events_config += { + 'file' : meson.source_root() / 'hw' / 'display' / 'trace-events-qxl', + 'group' : 'hw_display_qxl', + } hw_display_modules += {'qxl': qxl_ss} endif
hw/display/trace-events +0 -67
73 lines not on this page · raw message
hw/display/trace-events-qxl new file +66 -0
66 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 2/4 meson: move up hw subdir (specifically before trace subdir)
In reply to Gerd HoffmannNeeded so trace/meson.build can see
stuff done in hw/*/meson.build.
--- meson.build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
meson.build +2 -1
@@ -1456,6 +1456,8 @@ trace_events_subdirs += [ 'util', ] +subdir('hw') + subdir('contrib/libvhost-user') subdir('qapi') subdir('qobject')
@@ -1543,7 +1545,6 @@ subdir('migration') subdir('monitor') subdir('net') subdir('replay') -subdir('hw') subdir('accel') subdir('plugins') subdir('bsd-user')
Signature · 1 line
2.27.0
Re: [PATCH 3/4] meson: move qxl trace events to separate file
In reply to Gerd HoffmannQuoted 9 lines · Gerd Hoffmann
Move qxl trace events to separate trace-events-qxl file.
Signed-off-by Gerd Hoffmann <[email protected]>--- hw/display/qxl-render.c | 1 + hw/display/qxl.c | 1 + hw/display/meson.build | 4 +++ hw/display/trace-events | 67 ------------------------------------- hw/display/trace-events-qxl | 66 ++++++++++++++++++++++++++++++++++++
FWIW, I think we should name the files to match the source prefix, such as 'qxl.trace-events', so that a simple glob hw/display/qxl* will match everything for the MAINTAINERS file assignments.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [PATCH 1/4] meson: add trace_events_config[]
In reply to Gerd HoffmannQuoted 8 lines · Gerd Hoffmann
It's an array of dicts, where each dict holds the configuration for one trace-events file. For now just fill it from
trace_events_subdirs.Signed-off-by Gerd Hoffmann <[email protected]>--- meson.build | 1 + trace/meson.build | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-)
Re: [PATCH 2/4] meson: move up hw subdir (specifically before trace subdir)
In reply to Gerd HoffmannQuoted 22 lines · Gerd Hoffmann
Needed so trace/meson.build can see
stuff done in hw/*/meson.build.Signed-off-by Gerd Hoffmann <[email protected]>--- meson.build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)meson.build +2
-0@@ -1456,6 +1456,8 @@ trace_events_subdirs += [ 'util', ] +subdir('hw') + subdir('contrib/libvhost-user') subdir('qapi') subdir('qobject')
meson.build subdir('migration') · line 1550
Quoted 7 lines
meson.build +0
-1@@ -1543,7 +1545,6 @@ subdir('migration') subdir('monitor') subdir('net') subdir('replay') -subdir('hw') subdir('accel') subdir('plugins') subdir('bsd-user')
This is unmaintainable because someone reading the code won't be aware of the ordering constraint. A comment is needed.
I wonder if anyone has suggestions for meson best practices? Relying on ordering of subdirs is awkward, but so is moving the code into the top-level meson.build file.
Stefan
Re: [PATCH 3/4] meson: move qxl trace events to separate file
In reply to Gerd HoffmannQuoted 3 lines · Gerd Hoffmann
Move qxl trace events to separate trace-events-qxl file.
Signed-off-by Gerd Hoffmann <[email protected]>
Can we put modules into their own subdirs so that the existing meson and tracing infrastructure (e.g. scripts/cleanup-trace-events.pl) can handle them without modifications?
Re: [PATCH 3/4] meson: move qxl trace events to separate file
Quoted 8 lines · Stefan Hajnoczi
Quoted 3 lines · Gerd Hoffmann
Move qxl trace events to separate trace-events-qxl file.
Signed-off-by Gerd Hoffmann <[email protected]>Can we put modules into their own subdirs so that the existing meson and tracing infrastructure (e.g.
scripts/cleanup-trace-events.pl) can handle them without modifications?
Would probably work too.
But before bikeshedding on those details we need a workable overall approach. I have no idea why 4/4 is not working. Possibly the approach I'm trying to take is completely wrong ...
take care,
Gerd
Re: [PATCH 4/4] [broken] meson: try link tracepoints to module
In reply to Gerd HoffmannQuoted 29 lines · Gerd Hoffmann
Add source set to
trace_events_config, use it in trace/meson.build so the trace objects are linked to the module not core qemu.Not working as intended.
/me looks puzzled.Signed-off-by Gerd Hoffmann <[email protected]>--- hw/display/meson.build | 1 + trace/meson.build | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-)hw/display/meson.build +1
-0@@ -46,6 +46,7 @@ if config_all_devices.has_key('CONFIG_QXL') trace_events_config += { 'file' : meson.source_root() / 'hw' / 'display' / 'trace-events-qxl', 'group' : 'hw_display_qxl', + 'ss' : qxl_ss, } hw_display_modules += {'qxl': qxl_ss} endiftrace/meson.build +0
-0
trace/meson.build foreach c : trace_events_config · line 21
Quoted 4 lines
trace/meson.build +1
-0@@ -18,6 +18,7 @@ foreach c : trace_events_config trace_events_files += [ trace_events_file ] group = '--group=' + c.get('group') fmt = '@0@-' + c.get('group') + '.@1@' + module_ss = c.get('ss', trace_ss)
One idea: module_ss is already used in other files. Are you sure there isn't an identifier naming conflict?
Re: [PATCH 4/4] [broken] meson: try link tracepoints to module
Hi,
Quoted 4 lines
Quoted 4 lines
trace/meson.build +0
-0
Quoted 8 lines
trace/meson.build foreach c : trace_events_config · line 21
Quoted 5 lines
trace/meson.build +1
-0@@ -18,6 +18,7 @@ foreach c : trace_events_config trace_events_files += [ trace_events_file ] group = '--group=' + c.get('group') fmt = '@0@-' + c.get('group') + '.@1@' + module_ss = c.get('ss', trace_ss)One idea:
module_ssis already used in other files. Are you sure there isn't an identifier naming conflict?
Nope. Tried s/module_ss/kraxel_ss/, still not working.
I get tons of "undefined reference to `_TRACE_something'" errors (*not* qxl). Seems trace_ss is not updated as intended.
take care,
Gerd
Re: [PATCH 4/4] [broken] meson: try link tracepoints to module
Quoted 15 lines · Gerd Hoffmann
Hi,
Quoted 4 lines
Quoted 4 lines
trace/meson.build +0
-0Quoted 8 lines
trace/meson.build foreach c : trace_events_config · line 21
Quoted 5 lines
trace/meson.build +1
-0@@ -18,6 +18,7 @@ foreach c : trace_events_config trace_events_files += [ trace_events_file ] group = '--group=' + c.get('group') fmt = '@0@-' + c.get('group') + '.@1@' + module_ss = c.get('ss', trace_ss)One idea:
module_ssis already used in other files. Are you sure there isn't an identifier naming conflict?
Quoted 4 lines
Nope. Tried s/module_ss/kraxel_ss/, still not working.
I get tons of "undefined reference to `_TRACE_something'" errors (*not* qxl). Seems
trace_ssis not updated as intended.
Okay. There is a workaround available:
[PATCH v2] trace: use STAP_SDT_V2 to work around symbol visibility
We can take time to figure out how to extend the build system to handle modules.
Would you like me to try to debug this?
I'm also on #qemu IRC if you want to discuss.
Stefan
Re: [PATCH 4/4] [broken] meson: try link tracepoints to module
Hi,
Quoted 10 lines
Quoted 4 lines
Nope. Tried s/module_ss/kraxel_ss/, still not working.
I get tons of "undefined reference to `_TRACE_something'" errors (*not* qxl). Seems
trace_ssis not updated as intended.Okay. There is a workaround available:
[PATCH v2] trace: useSTAP_SDT_V2to work around symbol visibilityWe can take time to figure out how to extend the build system to handle modules.
IMHO it isn't 5.2 material anyway.
Quoted 1 line
Would you like me to try to debug this?
Guess I'll go dig into the meson documentation, this looks more like a build system than a tracing problem to me.
Nevertheless any ideas/hints are welcome of course.
take care,
Gerd
Re: [PATCH 4/4] [broken] meson: try link tracepoints to module
Hi,
Quoted 2 lines
Guess I'll go dig into the meson documentation, this looks more like a build system than a tracing problem to me.
Looking at https://mesonbuild.com/Syntax.html ...
"all objects are immutable".
So "var2 = var1" creates a copy not a reference I guess?
Which implies that ...
foo_ss.add(something)
... is different from ...
bar_ss = foo_ss
bar_ss.add(something)
... which in turn explains why the patch doesn't work at all.
Now I'm wondering how I can make trace/meson.build add the trace objects to the module source sets if I can't pass around references to the module source sets?
Paolo? Any hints how to tackle this the meson way?
thanks,
Gerd
Re: [PATCH 4/4] [broken] meson: try link tracepoints to module
Quoted 20 lines · Gerd Hoffmann
Hi,
Quoted 2 lines
Guess I'll go dig into the meson documentation, this looks more like a build system than a tracing problem to me.
Looking at https://mesonbuild.com/Syntax.html ...
"all objects are immutable".
So "var2 = var1" creates a copy not a reference I guess?
Which implies that ...
foo_ss.add(something)... is different from ...
bar_ss=foo_ss
bar_ss.add(something)
Quoted 7 lines
... which in turn explains why the patch doesn't work at all.
Now I'm wondering how I can make trace/meson.build add the trace objects to the module source sets if I can't pass around references to the module source sets?
Paolo? Any hints how to tackle this the meson way?
Maybe managing it all in the main meson.build, like the e28ab096bf8..da33fc09873 cleanup?
("Move the creation of the library to the main meson.build")
Quoted 5 lines
thanks,
Gerd
Re: [PATCH 4/4] [broken] meson: try link tracepoints to module
In reply to Gerd HoffmannQuoted 20 lines · Gerd Hoffmann
Hi,Quoted 2 lines
Guess I'll go dig into the meson documentation, this looks more like a build system than a tracing problem to me.
Looking at https://mesonbuild.com/Syntax.html ...
"all objects are immutable".
So "var2 = var1" creates a copy not a reference I guess?
Which implies that ...
foo_ss.add(something)... is different from ...
bar_ss=foo_ss
bar_ss.add(something)
Quoted 7 lines
... which in turn explains why the patch doesn't work at all.
Now I'm wondering how I can make trace/meson.build add the trace objects to the module source sets if I can't pass around references to the module source sets?
Paolo? Any hints how to tackle this the meson way?
You could build a separate dictionary in trace/meson.build. Instead of using the 'hw_display_qxl' group, you use the module name i.e. 'hw-display-qxl'. trace/meson.build does:
module_trace = {}
and in trace/meson.build
module_trace_src = []
foreach c : ...
...
group = '--group=' + c['name'].underscorify()
module_trace_src += [trace_h, trace_c]
...
module_trace += { c['name']: module_trace_src }endforeach
Then when building the shared_module you add the trace files to the sources, like
module_trace_src = module_trace.get(d + '-' + m, [])
sl = static_library(d + '-' + m,
[genh, module_ss.sources(), module_trace_src],
dependencies: ...)
Paolo
Re: [PATCH 4/4] [broken] meson: try link tracepoints to module
In reply to Philippe Mathieu-DaudéQuoted 3 lines · Philippe Mathieu-Daudé
Maybe managing it all in the main meson.build, like the
e28ab096bf8..da33fc09873cleanup?
("Move the creation of the library to the main meson.build")
That was a different issue due to variables being defined in many different meson.build files. But I think in this case the ordering is not an issue, and that's actually because of your patch. :)
Paolo
Re: [PATCH 4/4] [broken] meson: try link tracepoints to module
In reply to Philippe Mathieu-DaudéQuoted 17 lines
Quoted 17 lines
So "var2 = var1" creates a copy not a reference I guess?
Which implies that ...
foo_ss.add(something)... is different from ...
bar_ss=foo_ss
bar_ss.add(something)... which in turn explains why the patch doesn't work at all.
Now I'm wondering how I can make trace/meson.build add the trace objects to the module source sets if I can't pass around references to the module source sets?
Quoted 5 lines
Quoted 1 line
Paolo? Any hints how to tackle this the meson way?
Maybe managing it all in the main meson.build, like the
e28ab096bf8..da33fc09873cleanup?
("Move the creation of the library to the main meson.build")
I don't see how that'll help.
The fundamental idea is hw/*/meson.build stores the source set in the new trace_events_config, then trace/meson.build can pick it up there when it loops over the trace_events_config array, adding the generated trace source files to the correct source set.
Whenever that loop is in trace/meson.build or the toplevel meson.build doesn't make much of a difference I think.
I think the problem is meson stores a copy not a reference so the trace_events_config loop doesn't update the original source set. When meson loops over the module source sets it doesn't see the updates because those changes where done on a throw-away copy.
I don't see an easy way out :(
take care,
Gerd
Re: [PATCH 4/4] [broken] meson: try link tracepoints to module
In reply to Paolo BonziniQuoted 17 lines
You could build a separate dictionary in trace/meson.build. Instead of using the '
hw_display_qxl' group, you use the module name i.e. 'hw-display-qxl'. trace/meson.build does:
module_trace= {}and in trace/meson.build
module_trace_src= []
foreach c : ...... group = '--group=' + c['name'].underscorify() module_trace_src += [trace_h, trace_c] ... module_trace += { c['name']: module_trace_src }endforeach
Quoted 7 lines
Then when building the
shared_moduleyou add the trace files to the sources, likemodule_trace_src = module_trace.get(d + '-' + m, []) sl = static_library(d + '-' + m, [genh, module_ss.sources(), module_trace_src], dependencies: ...)
So basically keep track of the objects separately. Got that working for the modular builds. Progress!!!
Non-modular builds fail due to missing qxl tracepoints. Tried to fix that with a simple 'softmmu_ss.add(module_trace_src)'. Now I get:
../../meson.build:1802:2: ERROR: Object extraction arguments must be strings or Files.
/me looks surprised. Doing trace_ss.add(module_trace_src) in trace/meson.buikd works just fine ...
Branch available at git://git.kraxel.org/qemu sirius/trace-modules
Running "qemu -device qxl" segfaults. Not investigated yet, but I guess this is just modular tracepoint not being properly initialized. Will check later, have to run pick up my daughter now.
take care,
Gerd
Re: [PATCH 4/4] [broken] meson: try link tracepoints to module
Quoted 5 lines · Gerd Hoffmann
So basically keep track of the objects separately. Got that working for the modular builds. Progress!!!
Non-modular builds fail due to missing qxl tracepoints. Tried to fix that with a simple '
softmmu_ss.add(module_trace_src)'.
Mentioned in https://wiki.qemu.org/Features/Meson#Pending_Meson_changes as "extract_objects does not support generated file (not needed yet but could be surprising)".
Just use util_ss instead, confirming both points in the parentheses.
Paolo