Skip to content

Commit 2098c56

Browse files
berrangestefanhaRH
authored andcommitted
trace: move setting of group name into Makefiles
Having tracetool.py figure out the right group name from just the input filename is not practical when considering the different build vs src path combinations. Instead simply take the group name as a command line arg from the Makefile, which can trivially provide the right name. Reviewed-by: Stefan Hajnoczi <[email protected]> Signed-off-by: Daniel P. Berrange <[email protected]> Message-id: [email protected] Signed-off-by: Stefan Hajnoczi <[email protected]>
1 parent 9c58263 commit 2098c56

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

Makefile.target

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ endif
5050

5151
$(QEMU_PROG).stp-installed: $(BUILD_DIR)/trace-events-all
5252
$(call quiet-command,$(TRACETOOL) \
53+
--group=all \
5354
--format=stap \
5455
--backends=$(TRACE_BACKENDS) \
5556
--binary=$(bindir)/$(QEMU_PROG) \
@@ -59,6 +60,7 @@ $(QEMU_PROG).stp-installed: $(BUILD_DIR)/trace-events-all
5960

6061
$(QEMU_PROG).stp: $(BUILD_DIR)/trace-events-all
6162
$(call quiet-command,$(TRACETOOL) \
63+
--group=all \
6264
--format=stap \
6365
--backends=$(TRACE_BACKENDS) \
6466
--binary=$(realpath .)/$(QEMU_PROG) \
@@ -68,6 +70,7 @@ $(QEMU_PROG).stp: $(BUILD_DIR)/trace-events-all
6870

6971
$(QEMU_PROG)-simpletrace.stp: $(BUILD_DIR)/trace-events-all
7072
$(call quiet-command,$(TRACETOOL) \
73+
--group=all \
7174
--format=simpletrace-stap \
7275
--backends=$(TRACE_BACKENDS) \
7376
--probe-prefix=qemu.$(TARGET_TYPE).$(TARGET_NAME) \

scripts/tracetool.py

+9-14
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def error_opt(msg = None):
4949
--binary <path> Full path to QEMU binary.
5050
--target-type <type> QEMU emulator target type ('system' or 'user').
5151
--target-name <name> QEMU emulator target name.
52+
--group <name> Name of the event group
5253
--probe-prefix <prefix> Prefix for dtrace probe names
5354
(default: qemu-<target-type>-<target-name>).\
5455
""" % {
@@ -62,22 +63,12 @@ def error_opt(msg = None):
6263
else:
6364
sys.exit(1)
6465

65-
def make_group_name(filename):
66-
dirname = os.path.realpath(os.path.dirname(filename))
67-
basedir = os.path.join(os.path.dirname(__file__), os.pardir)
68-
basedir = os.path.realpath(os.path.abspath(basedir))
69-
dirname = dirname[len(basedir) + 1:]
70-
71-
if dirname == "":
72-
return "common"
73-
return "_" + re.sub(r"[^A-Za-z0-9]", "_", dirname)
74-
7566
def main(args):
7667
global _SCRIPT
7768
_SCRIPT = args[0]
7869

7970
long_opts = ["backends=", "format=", "help", "list-backends",
80-
"check-backends"]
71+
"check-backends", "group="]
8172
long_opts += ["binary=", "target-type=", "target-name=", "probe-prefix="]
8273

8374
try:
@@ -88,6 +79,7 @@ def main(args):
8879
check_backends = False
8980
arg_backends = []
9081
arg_format = ""
82+
arg_group = None
9183
binary = None
9284
target_type = None
9385
target_name = None
@@ -98,6 +90,8 @@ def main(args):
9890

9991
elif opt == "--backends":
10092
arg_backends = arg.split(",")
93+
elif opt == "--group":
94+
arg_group = arg
10195
elif opt == "--format":
10296
arg_format = arg
10397

@@ -129,6 +123,9 @@ def main(args):
129123
sys.exit(1)
130124
sys.exit(0)
131125

126+
if arg_group is None:
127+
error_opt("group name is required")
128+
132129
if arg_format == "stap":
133130
if binary is None:
134131
error_opt("--binary is required for SystemTAP tapset generator")
@@ -145,10 +142,8 @@ def main(args):
145142
with open(args[0], "r") as fh:
146143
events = tracetool.read_events(fh)
147144

148-
group = make_group_name(args[0])
149-
150145
try:
151-
tracetool.generate(events, group, arg_format, arg_backends,
146+
tracetool.generate(events, arg_group, arg_format, arg_backends,
152147
binary=binary, probe_prefix=probe_prefix)
153148
except tracetool.TracetoolError as e:
154149
error_opt(str(e))

trace/Makefile.objs

+9
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ $(obj)/generated-ust-provider.h: $(obj)/generated-ust-provider.h-timestamp
2020
@cmp $< $@ >/dev/null 2>&1 || cp $< $@
2121
$(obj)/generated-ust-provider.h-timestamp: $(BUILD_DIR)/trace-events-all $(tracetool-y)
2222
$(call quiet-command,$(TRACETOOL) \
23+
--group=all \
2324
--format=ust-events-h \
2425
--backends=$(TRACE_BACKENDS) \
2526
$< > $@,"GEN","$(patsubst %-timestamp,%,$@)")
@@ -28,6 +29,7 @@ $(obj)/generated-ust.c: $(obj)/generated-ust.c-timestamp $(BUILD_DIR)/config-hos
2829
@cmp $< $@ >/dev/null 2>&1 || cp $< $@
2930
$(obj)/generated-ust.c-timestamp: $(BUILD_DIR)/trace-events-all $(tracetool-y)
3031
$(call quiet-command,$(TRACETOOL) \
32+
--group=all \
3133
--format=ust-events-c \
3234
--backends=$(TRACE_BACKENDS) \
3335
$< > $@,"GEN","$(patsubst %-timestamp,%,$@)")
@@ -48,6 +50,7 @@ $(obj)/generated-tracers.h: $(obj)/generated-tracers.h-timestamp
4850
@cmp -s $< $@ || cp $< $@
4951
$(obj)/generated-tracers.h-timestamp: $(BUILD_DIR)/trace-events-all $(BUILD_DIR)/config-host.mak $(tracetool-y)
5052
$(call quiet-command,$(TRACETOOL) \
53+
--group=all \
5154
--format=h \
5255
--backends=$(TRACE_BACKENDS) \
5356
$< > $@,"GEN","$(patsubst %-timestamp,%,$@)")
@@ -59,6 +62,7 @@ $(obj)/generated-tracers.c: $(obj)/generated-tracers.c-timestamp
5962
@cmp -s $< $@ || cp $< $@
6063
$(obj)/generated-tracers.c-timestamp: $(BUILD_DIR)/trace-events-all $(BUILD_DIR)/config-host.mak $(tracetool-y)
6164
$(call quiet-command,$(TRACETOOL) \
65+
--group=all \
6266
--format=c \
6367
--backends=$(TRACE_BACKENDS) \
6468
$< > $@,"GEN","$(patsubst %-timestamp,%,$@)")
@@ -77,6 +81,7 @@ $(obj)/generated-tracers-dtrace.dtrace: $(obj)/generated-tracers-dtrace.dtrace-t
7781
@cmp $< $@ >/dev/null 2>&1 || cp $< $@
7882
$(obj)/generated-tracers-dtrace.dtrace-timestamp: $(BUILD_DIR)/trace-events-all $(BUILD_DIR)/config-host.mak $(tracetool-y)
7983
$(call quiet-command,$(TRACETOOL) \
84+
--group=all \
8085
--format=d \
8186
--backends=$(TRACE_BACKENDS) \
8287
$< > $@,"GEN","$(patsubst %-timestamp,%,$@)")
@@ -96,6 +101,7 @@ $(obj)/generated-helpers-wrappers.h: $(obj)/generated-helpers-wrappers.h-timesta
96101
@cmp $< $@ >/dev/null 2>&1 || cp $< $@
97102
$(obj)/generated-helpers-wrappers.h-timestamp: $(BUILD_DIR)/trace-events-all $(BUILD_DIR)/config-host.mak $(tracetool-y)
98103
$(call quiet-command,$(TRACETOOL) \
104+
--group=all \
99105
--format=tcg-helper-wrapper-h \
100106
--backend=$(TRACE_BACKENDS) \
101107
$< > $@,"GEN","$(patsubst %-timestamp,%,$@)")
@@ -104,6 +110,7 @@ $(obj)/generated-helpers.h: $(obj)/generated-helpers.h-timestamp
104110
@cmp $< $@ >/dev/null 2>&1 || cp $< $@
105111
$(obj)/generated-helpers.h-timestamp: $(BUILD_DIR)/trace-events-all $(BUILD_DIR)/config-host.mak $(tracetool-y)
106112
$(call quiet-command,$(TRACETOOL) \
113+
--group=all \
107114
--format=tcg-helper-h \
108115
--backend=$(TRACE_BACKENDS) \
109116
$< > $@,"GEN","$(patsubst %-timestamp,%,$@)")
@@ -112,6 +119,7 @@ $(obj)/generated-helpers.c: $(obj)/generated-helpers.c-timestamp
112119
@cmp $< $@ >/dev/null 2>&1 || cp $< $@
113120
$(obj)/generated-helpers.c-timestamp: $(BUILD_DIR)/trace-events-all $(BUILD_DIR)/config-host.mak $(tracetool-y)
114121
$(call quiet-command,$(TRACETOOL) \
122+
--group=all \
115123
--format=tcg-helper-c \
116124
--backend=$(TRACE_BACKENDS) \
117125
$< > $@,"GEN","$(patsubst %-timestamp,%,$@)")
@@ -125,6 +133,7 @@ $(obj)/generated-tcg-tracers.h: $(obj)/generated-tcg-tracers.h-timestamp
125133
@cmp $< $@ >/dev/null 2>&1 || cp $< $@
126134
$(obj)/generated-tcg-tracers.h-timestamp: $(BUILD_DIR)/trace-events-all $(BUILD_DIR)/config-host.mak $(tracetool-y)
127135
$(call quiet-command,$(TRACETOOL) \
136+
--group=all \
128137
--format=tcg-h \
129138
--backend=$(TRACE_BACKENDS) \
130139
$< > $@,"GEN","$(patsubst %-timestamp,%,$@)")

0 commit comments

Comments
 (0)