From e7fbad94afda8ebbcca452273f64dabda7c8abd4 Mon Sep 17 00:00:00 2001 From: Aurelio Vivas Date: Wed, 1 Nov 2023 20:48:46 +0000 Subject: [PATCH] Update to generate btx interval and model from THAPI model old format --- hip/Makefile.am | 9 ++++++--- hip/gen_babeltrace_hip_model.rb | 8 ++++++++ utils/babeltrace_to_metababel_model.rb | 25 ++++++++++++++++++------- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/hip/Makefile.am b/hip/Makefile.am index 3fa2b9c1..bf9108df 100644 --- a/hip/Makefile.am +++ b/hip/Makefile.am @@ -161,7 +161,7 @@ BTX_HIP_GENERATED = \ EXTRA_DIST = \ $(top_srcdir)/utils/babeltrace_to_metababel_model.rb \ - $(top_srcdir)/utils/btx_interval_model.yaml \ + $(top_srcdir)/xprof/interval_model.yaml \ btx_hipmatching_model.yaml CLEANFILES = \ @@ -170,8 +170,11 @@ CLEANFILES = \ btx_model.yaml: $(top_srcdir)/utils/babeltrace_to_metababel_model.rb hip_babeltrace_model.yaml SRC_DIR=$(srcdir) $(RUBY) $^ > $@ -$(BTX_HIP_GENERATED) &: $(top_srcdir)/utils/btx_interval_model.yaml btx_hipmatching_model.yaml btx_model.yaml - $(METABABEL) -u btx_model.yaml -d $(top_srcdir)/utils/btx_interval_model.yaml -t FILTER -o btx_filter_hip -p hipinterval -c interval --matching $(srcdir)/btx_hipmatching_model.yaml -i hip.h.include +btx_interval_model.yaml: $(top_srcdir)/utils/babeltrace_to_metababel_model.rb $(top_srcdir)/xprof/interval_model.yaml + SRC_DIR=$(srcdir) $(RUBY) $^ > $@ + +$(BTX_HIP_GENERATED) &: btx_interval_model.yaml btx_hipmatching_model.yaml btx_model.yaml + $(METABABEL) -u btx_model.yaml -d btx_interval_model.yaml -t FILTER -o btx_filter_hip -p hipinterval -c interval --matching $(srcdir)/btx_hipmatching_model.yaml -i hip.h.include $(MODIFIED_HIP_HDR) &: $(HIP_HDR) $(srcdir)/headers.patch $(RM) -r modified_include/ diff --git a/hip/gen_babeltrace_hip_model.rb b/hip/gen_babeltrace_hip_model.rb index 6f5b046f..c54a7a8f 100644 --- a/hip/gen_babeltrace_hip_model.rb +++ b/hip/gen_babeltrace_hip_model.rb @@ -99,6 +99,13 @@ def get_fields_types_name(c, dir) } }.flatten +environment = [ + { + name: 'hostname', + class: 'string', + } +] + packet_context = [ { name: 'cpu_id', @@ -131,6 +138,7 @@ def get_fields_types_name(c, dir) puts YAML.dump({ name: "thapi_hip", + environment: environment, clock_snapshot_value: true, packet_context: packet_context, common_context: common_context, diff --git a/utils/babeltrace_to_metababel_model.rb b/utils/babeltrace_to_metababel_model.rb index 0c19f34b..288c0377 100644 --- a/utils/babeltrace_to_metababel_model.rb +++ b/utils/babeltrace_to_metababel_model.rb @@ -113,15 +113,26 @@ def get_stream_class(sc) stream_class end +def get_environment_entry(entry) + { :name => entry[:name], :type => entry[:class] } +end + raise "Not input model provided" unless ARGV.length > 0 input_model_path = ARGV[0] model = YAML.load_file(input_model_path) -trace = { - :environment => { - :entries => [{ :name => 'hostname', :type => 'string' }] - }, - :stream_classes => [get_stream_class(model)], -}.to_yaml +# THAPI interval and HIP model differ. +if model.key?(:stream_classes) + stream_class = model.delete(:stream_classes).pop + event_classes = model.delete(:event_classes) + stream_class[:event_classes] = event_classes +else + stream_class = model +end + +trace = {} +environment = model.delete(:environment) +trace[:environment] = { :entries => environment.map(&method(:get_environment_entry)) } if environment +trace[:stream_classes] = [get_stream_class(stream_class)] -puts trace +puts trace.to_yaml