diff --git a/hip/Makefile.am b/hip/Makefile.am index bf9108df..7042ed3b 100644 --- a/hip/Makefile.am +++ b/hip/Makefile.am @@ -161,20 +161,18 @@ BTX_HIP_GENERATED = \ EXTRA_DIST = \ $(top_srcdir)/utils/babeltrace_to_metababel_model.rb \ - $(top_srcdir)/xprof/interval_model.yaml \ + $(top_srcdir)/utils/btx_interval_model.yaml \ btx_hipmatching_model.yaml CLEANFILES = \ - btx_model.yaml + btx_hip_model.yaml \ + btx_interval_model.yaml -btx_model.yaml: $(top_srcdir)/utils/babeltrace_to_metababel_model.rb hip_babeltrace_model.yaml +btx_hip_model.yaml: $(top_srcdir)/utils/babeltrace_to_metababel_model.rb hip_babeltrace_model.yaml SRC_DIR=$(srcdir) $(RUBY) $^ > $@ -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 +$(BTX_HIP_GENERATED) &: $(top_srcdir)/utils/btx_interval_model.yaml btx_hipmatching_model.yaml btx_hip_model.yaml + $(METABABEL) -u btx_hip_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 $(MODIFIED_HIP_HDR) &: $(HIP_HDR) $(srcdir)/headers.patch $(RM) -r modified_include/ @@ -226,7 +224,6 @@ HIP_MODEL = \ $(srcdir)/../utils/LTTng.rb \ hip.h.include -# TODO: Take this file and use the script to generate the new model version. hip_babeltrace_model.yaml: $(srcdir)/gen_babeltrace_hip_model.rb $(HIP_MODEL) SRC_DIR=$(srcdir) $(RUBY) $< > $@ diff --git a/hip/btx_hipinterval_callbacks.cpp b/hip/btx_hipinterval_callbacks.cpp index ab7ac59d..6553a505 100644 --- a/hip/btx_hipinterval_callbacks.cpp +++ b/hip/btx_hipinterval_callbacks.cpp @@ -12,11 +12,19 @@ struct data_s { - std::unordered_map dispatch; + std::unordered_map entry_ts; }; typedef struct data_s data_t; +void set_entry_ts(data_t *data, hpt_t hpt, int64_t ts) { + data->entry_ts[hpt] = ts; +} + +int64_t get_entry_ts(data_t *data, hpt_t hpt) { + return data->entry_ts.at(hpt); +} + std::string strip_event_class_name(const char *str) { std::string temp(str); std::smatch match; @@ -34,7 +42,7 @@ static void send_host_message(void *btx_handle, void *usr_data, int64_t ts, uint64_t vtid, bool err) { std::string event_class_name_striped = strip_event_class_name(event_class_name); - const int64_t _start = (static_cast(usr_data))->dispatch.at({hostname, vpid, vtid, event_class_name_striped}); + const int64_t _start = get_entry_ts(static_cast(usr_data), {hostname, vpid, vtid}); btx_push_message_lttng_host(btx_handle, hostname, vpid, vtid, _start, BACKEND_HIP, event_class_name_striped.c_str(), (ts - _start), err); @@ -49,8 +57,7 @@ void btx_finalize_component(void *usr_data) { static void entries_callback(void *btx_handle, void *usr_data, int64_t ts, const char *event_class_name, const char *hostname, int64_t vpid, uint64_t vtid) { - - ((data_t *)usr_data)->dispatch[{hostname, vpid, vtid, strip_event_class_name(event_class_name)}] = ts; + set_entry_ts(((data_t *)usr_data), {hostname, vpid, vtid}, ts); } static void exits_callback_hipError_absent(void *btx_handle, void *usr_data, int64_t ts, diff --git a/hip/btx_hipmatching_model.yaml b/hip/btx_hipmatching_model.yaml index 774a85f4..6ad52847 100644 --- a/hip/btx_hipmatching_model.yaml +++ b/hip/btx_hipmatching_model.yaml @@ -28,7 +28,7 @@ :members: - :name: ^hipResult$ :field_class: - :type: ^integer_signed$ + :type: integer_signed :cast_type: ^hipError_t$ - :set_id: exits_hipError_absent diff --git a/utils/babeltrace_to_metababel_model.rb b/utils/babeltrace_to_metababel_model.rb index 288c0377..23c8d6f2 100644 --- a/utils/babeltrace_to_metababel_model.rb +++ b/utils/babeltrace_to_metababel_model.rb @@ -5,18 +5,11 @@ HIP_STRUCT_TYPES = [ 'struct hipChannelFormatDesc', + 'struct hipExtent', 'hipIpcMemHandle_t', 'hipIpcEventHandle_t', 'hipPitchedPtr', 'hipExtent', - 'hipPitchedPtr', - 'hipExtent', - 'struct hipExtent', - 'dim3', - 'hipPitchedPtr', - 'hipExtent', - 'hipPitchedPtr', - 'hipExtent', 'dim3', ] @@ -52,7 +45,9 @@ def translate_key_value(k,v) def get_element_field_class(element_field, parent_field) class_properties = element_field.delete(:class_properties) field_properties = (element_field.to_a + class_properties.to_a).filter_map {|k,v| translate_key_value(k,v) unless INGONRE_PROPERTIES.include?(k) }.to_h + if parent_field[:class] == 'array_dynamic' + # get array elements' cast_type match = parent_field[:cast_type].match(/(.*) \*/) raise ":cast_type for element_field in array_dynamic can not be determined for #{parent_field}." unless match field_properties[:cast_type] = match[1] @@ -65,9 +60,11 @@ def get_field_class_properties(field, member_name) class_properties = field.delete(:class_properties) field_element_field_class = field.key?(:field) ? get_element_field_class(field.delete(:field), field) : {} field_properties = (field.to_a + class_properties.to_a + field_element_field_class.to_a ).filter_map {|k,v| translate_key_value(k,v) unless INGONRE_PROPERTIES.include?(k) }.to_h - field_properties[:cast_type_is_struct] = true if HIP_STRUCT_TYPES.include?(field[:cast_type]) field_properties[:length_field_path] = "EVENT_PAYLOAD[\"_#{member_name}_length\"]" if field_properties[:type] == 'array_dynamic' - + + # Special casting case for struct <-> string. + field_properties[:cast_type_is_struct] = true if HIP_STRUCT_TYPES.include?(field[:cast_type]) + field_properties end