Commit f65f5610 authored by Brice Videau's avatar Brice Videau
Browse files

Merge branch 'modularize_merge' into 'master'

Modularize merge

See merge request !14
parents e1a2cd9f 71be6239
Pipeline #12999 failed with stage
......@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([thapi], [0.0.6], [bvideau@anl.gov])
AC_INIT([thapi], [0.0.7], [bvideau@anl.gov])
AC_CONFIG_SRCDIR([opencl/tracer_opencl_helpers.include.c])
AC_CONFIG_HEADERS([utils/config.h])
......@@ -18,6 +18,8 @@ AM_PROG_AR
LT_INIT([disable-static])
# Checks for programs.
AC_PROG_LN_S
AC_PROG_MKDIR_P
AC_PROG_CXX
AC_PROG_CC
if test -z "$RUBY"; then
......@@ -83,8 +85,11 @@ AC_CONFIG_FILES([Makefile
AC_CONFIG_FILES([opencl/tracer_opencl.sh], [chmod +x opencl/tracer_opencl.sh])
AC_CONFIG_FILES([opencl/babeltrace_opencl], [chmod +x opencl/babeltrace_opencl])
AC_CONFIG_FILES([opencl/extract_enqueues], [chmod +x opencl/extract_enqueues])
AC_CONFIG_FILES([opencl/test_wrapper.sh], [chmod +x opencl/test_wrapper.sh])
AC_CONFIG_FILES([ze/tracer_ze.sh], [chmod +x ze/tracer_ze.sh])
AC_CONFIG_FILES([ze/babeltrace_ze], [chmod +x ze/babeltrace_ze])
AC_CONFIG_FILES([ze/test_wrapper.sh], [chmod +x ze/test_wrapper.sh])
AC_CONFIG_FILES([cuda/babeltrace_cuda], [chmod +x cuda/babeltrace_cuda])
AC_CONFIG_FILES([cuda/tracer_cuda.sh], [chmod +x cuda/tracer_cuda.sh])
AC_CONFIG_FILES([cuda/test_wrapper.sh], [chmod +x cuda/test_wrapper.sh])
AC_OUTPUT
.DELETE_ON_ERROR:
LTTNG_FLAGS=-fPIC -Wall -Wextra -Wno-unused-parameter -Wno-type-limits -Wno-sign-compare -Werror -I$(top_srcdir)/utils -I$(srcdir)/include -I../utils -I./
LTTNG_FLAGS=-fPIC -Wall -Wextra -Wno-unused-parameter -Wno-type-limits -Wno-sign-compare -Werror -I$(top_srcdir)/utils -I$(top_srcdir)/utils/include -I$(srcdir)/include -I../utils -I./
CUDA_PROBES_TP = \
cuda_tracepoints.tp
......@@ -118,6 +118,7 @@ MODIFIED_CUDA_HDR = \
modified_include/cuda.h: $(CUDA_HDR) $(srcdir)/headers.patch
$(RM) -r modified_include/
cp -r $(srcdir)/include/ modified_include/
chmod -R u+w modified_include/
cat $(srcdir)/headers.patch | patch -i - -d modified_include/ -s -p1
$(MODIFIED_CUDA_EXTRA_HDR): modified_include/cuda.h
......@@ -139,6 +140,11 @@ cuda_api.yaml: modified_include/cuda.h $(CUDA_EXTRACT) $(srcdir)/extract_cuda.rb
cudart_api.yaml: modified_include/cuda_runtime_api.h $(CUDA_EXTRACT) $(srcdir)/extract_cudart.rb
SRC_DIR=$(srcdir) $(RUBY) $(srcdir)/extract_cudart.rb
cuda_babeltrace_model.yaml: $(srcdir)/gen_babeltrace_cuda_model.rb $(CUDA_MODEL)
SRC_DIR=$(srcdir) $(RUBY) $< > $@
CLEANFILES += cuda_babeltrace_model.yaml
EXTRA_DIST += \
extract_cuda.rb \
extract_cudart.rb
......@@ -212,7 +218,7 @@ nodist_libTracerCUDA_la_SOURCES = \
$(CUDA_PROBES_INCL) \
tracer_cuda.c
libTracerCUDA_la_CPPFLAGS = -I$(top_srcdir)/utils -I$(srcdir)/include -I../utils -I./
libTracerCUDA_la_CPPFLAGS = -I$(top_srcdir)/utils -I$(top_srcdir)/utils/include -I$(srcdir)/include -I../utils -I./
libTracerCUDA_la_CFLAGS = -Wall -Wextra -Werror $(LIBFFI_CFLAGS) $(LTTNG_UST_CFLAGS)
libTracerCUDA_la_LDFLAGS = $(LTTNG_UST_LIBS) -ldl -lpthread $(LIBFFI_LIBS)
libTracerCUDA_la_LDFLAGS += -version-info 1:0:0
......@@ -222,22 +228,30 @@ nodist_libTracerCUDART_la_SOURCES = \
$(CUDART_PROBES_INCL) \
tracer_cudart.c
libTracerCUDART_la_CPPFLAGS = -I$(top_srcdir)/utils -I$(srcdir)/include -I../utils -I./
libTracerCUDART_la_CPPFLAGS = -I$(top_srcdir)/utils -I$(top_srcdir)/utils/include -I$(srcdir)/include -I../utils -I./
libTracerCUDART_la_CFLAGS = -Wall -Wextra -Werror $(LIBFFI_CFLAGS) $(LTTNG_UST_CFLAGS)
libTracerCUDART_la_LDFLAGS = $(LTTNG_UST_LIBS) -ldl -lpthread $(LIBFFI_LIBS)
libTracerCUDART_la_LDFLAGS += -version-number 11:0:3
libTracerCUDART_la_LIBADD = libcudarttracepoints.la
install-exec-hook::
mkdir -p $(pkglibdir)
mkdir -p $(pkglibdir)/cuda
mkdir -p $(pkglibdir)/cudart
$(RM) $(pkglibdir)/cudart/libcudart.so.11.0 $(pkglibdir)/cudart/libcudart.so
$(RM) $(pkglibdir)/cuda/libcuda.so.1 $(pkglibdir)/cuda/libcuda.so
ln -s $(libdir)/libTracerCUDART.so.11.0.3 $(pkglibdir)/cudart/libcudart.so.11.0
ln -s $(pkglibdir)/cudart/libcudart.so.11.0 $(pkglibdir)/cudart/libcudart.so
ln -s $(libdir)/libTracerCUDA.so.1.0.0 $(pkglibdir)/cuda/libcuda.so.1
ln -s $(pkglibdir)/cuda/libcuda.so.1 $(pkglibdir)/cuda/libcuda.so
install-exec-hook:
$(MKDIR_P) $(DESTDIR)$(pkglibdir)/cudart
$(MKDIR_P) $(DESTDIR)$(pkglibdir)/cuda
$(LN_S) -f $(DESTDIR)$(libdir)/libTracerCUDART.so.11.0.3 $(DESTDIR)$(pkglibdir)/cudart/libcudart.so.11.0
$(LN_S) -f $(DESTDIR)$(pkglibdir)/cudart/libcudart.so.11.0 $(DESTDIR)$(pkglibdir)/cudart/libcudart.so
$(LN_S) -f $(DESTDIR)$(libdir)/libTracerCUDA.so.1.0.0 $(DESTDIR)$(pkglibdir)/cuda/libcuda.so.1
$(LN_S) -f $(DESTDIR)$(pkglibdir)/cuda/libcuda.so.1 $(DESTDIR)$(pkglibdir)/cuda/libcuda.so
uninstall-hook:
$(RM) -f $(DESTDIR)$(pkglibdir)/cudart/libcudart.so.11.0 $(DESTDIR)$(pkglibdir)/cudart/libcudart.so
$(RM) -f $(DESTDIR)$(pkglibdir)/cuda/libcuda.so.1 $(DESTDIR)$(pkglibdir)/cuda/libcuda.so
-rmdir $(DESTDIR)$(pkglibdir)/cudart
-rmdir $(DESTDIR)$(pkglibdir)/cuda
tmplibdir = $(libdir)/tmp
tmplib_LTLIBRARIES = libBabeltraceCUDA.la
install-data-hook::
$(RM) -r $(DESTDIR)$(tmplibdir)
CUDA_LIB_GEN = \
$(srcdir)/gen_cuda_library_base.rb \
......@@ -245,6 +259,32 @@ CUDA_LIB_GEN = \
EXTRA_DIST += $(CUDA_LIB_GEN)
babeltrace_cuda_callbacks.h: $(srcdir)/gen_babeltrace_cuda_callbacks.rb cuda_babeltrace_model.yaml
SRC_DIR=$(srcdir) $(RUBY) $< > $@
BUILT_SOURCES += babeltrace_cuda_callbacks.h
babeltrace_cuda_dispatchers.c: $(srcdir)/gen_babeltrace_cuda_dispatchers.rb cuda_babeltrace_model.yaml
SRC_DIR=$(srcdir) $(RUBY) $< > $@
EXTRA_DIST += \
gen_babeltrace_cuda_callbacks.rb \
gen_babeltrace_cuda_dispatchers.rb
CLEANFILES += \
babeltrace_cuda_callbacks.h \
babeltrace_cuda_dispatchers.c
nodist_libBabeltraceCUDA_la_SOURCES = \
babeltrace_cuda_callbacks.h \
babeltrace_cuda_dispatchers.c
libBabeltraceCUDA_la_SOURCES = \
babeltrace_cuda.c \
babeltrace_cuda.h
libBabeltraceCUDA_la_CPPFLAGS = -I$(top_srcdir)/utils -I$(top_srcdir)/utils/include -I$(srcdir)/include -I./
libBabeltraceCUDA_la_CFLAGS = -Wall -Wextra -Wno-unused-parameter -Werror $(BABELTRACE2_CFLAGS)
libBabeltraceCUDA_la_LDFLAGS = $(BABELTRACE2_LIBS) -avoid-version -module
cuda_library.rb: $(srcdir)/gen_cuda_library.rb $(CUDA_LIB_GEN) $(CUDA_MODEL)
SRC_DIR=$(srcdir) $(RUBY) $< > $@
......@@ -255,10 +295,28 @@ CUDA_BINDINGS = \
cuda_library.rb \
babeltrace_cuda_lib.rb
tests/cuda_dummy_trace.yaml: cuda_babeltrace_model.yaml
mkdir -p tests
$(RUBY) $(top_srcdir)/utils/gen_dummy_trace.rb cuda_babeltrace_model.yaml > $@
CLEANFILES += tests/cuda_dummy_trace.yaml
TEST_FILES = \
tests/cuda_dummy_trace.dust
TESTS = $(TEST_FILES)
TEST_EXTENSIONS = .dust
DUST_LOG_COMPILER = ./test_wrapper.sh
check_DATA = \
test_wrapper.sh \
tests/cuda_dummy_trace.yaml
data_DATA = $(CUDA_BINDINGS)
EXTRA_DIST += \
gen_cuda_library.rb \
gen_babeltrace_cuda_lib.rb
gen_babeltrace_cuda_lib.rb \
$(TEST_FILES)
CLEANFILES += $(CUDA_BINDINGS)
#include "babeltrace_cuda.h"
struct cuda_event_callbacks * cuda_create_event_callbacks(const char *name) {
intptr_t mem = (intptr_t)calloc(1, sizeof(struct cuda_event_callbacks) + strlen(name) + 1);
struct cuda_event_callbacks * callbacks = (struct cuda_event_callbacks *)mem;
callbacks->name = (const char *)(mem + sizeof(struct cuda_event_callbacks));
strcpy((char *)(callbacks->name), name);
utarray_new(callbacks->callbacks, &ut_ptr_icd);
return callbacks;
}
void cuda_register_dispatcher(struct cuda_dispatch *cuda_dispatch, const char *name, cuda_dispatcher_t *dispatcher) {
struct cuda_event_callbacks *callbacks = NULL;
HASH_FIND_STR(cuda_dispatch->event_callbacks, name, callbacks);
if (!callbacks) {
callbacks = cuda_create_event_callbacks(name);
HASH_ADD_KEYPTR(hh, cuda_dispatch->event_callbacks, callbacks->name, strlen(callbacks->name), callbacks);
}
callbacks->dispatcher = dispatcher;
}
void cuda_register_callback(struct cuda_dispatch *cuda_dispatch, const char *name, void *func) {
struct cuda_event_callbacks *callbacks;
HASH_FIND_STR(cuda_dispatch->event_callbacks, name, callbacks);
if (!callbacks) {
callbacks = cuda_create_event_callbacks(name);
HASH_ADD_STR(cuda_dispatch->event_callbacks, name, callbacks);
}
if (func)
utarray_push_back(callbacks->callbacks, &func);
}
/*
* Initializes the sink component.
*/
static
bt_component_class_initialize_method_status cuda_dispatch_initialize(
bt_self_component_sink *self_component_sink,
bt_self_component_sink_configuration *configuration,
const bt_value *params, void *initialize_method_data)
{
/* Allocate a private data structure */
struct cuda_dispatch *cuda_dispatch = calloc(1, sizeof(struct cuda_dispatch));
/* Set the component's user data to our private data structure */
bt_self_component_set_data(
bt_self_component_sink_as_self_component(self_component_sink),
cuda_dispatch);
/*
* Add an input port named `in` to the sink component.
*
* This is needed so that this sink component can be connected to a
* filter or a source component. With a connected upstream
* component, this sink component can create a message iterator
* to consume messages.
*/
bt_self_component_sink_add_input_port(self_component_sink,
"in", NULL, NULL);
init_dispatchers(cuda_dispatch);
return BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK;
}
/*
* Finalizes the sink component.
*/
static
void cuda_dispatch_finalize(bt_self_component_sink *self_component_sink)
{
/* Retrieve our private data from the component's user data */
struct cuda_dispatch *cuda_dispatch = bt_self_component_get_data(
bt_self_component_sink_as_self_component(self_component_sink));
struct cuda_callbacks *s, *tmp;
HASH_ITER(hh, cuda_dispatch->callbacks, s, tmp) {
HASH_DEL(cuda_dispatch->callbacks, s);
free(s);
}
struct cuda_event_callbacks *s2, *tmp2;
HASH_ITER(hh, cuda_dispatch->event_callbacks, s2, tmp2) {
HASH_DEL(cuda_dispatch->event_callbacks, s2);
utarray_free(s2->callbacks);
free(s2);
}
/* Free the allocated structure */
free(cuda_dispatch);
}
/*
* Called when the trace processing graph containing the sink component
* is configured.
*
* This is where we can create our upstream message iterator.
*/
static
bt_component_class_sink_graph_is_configured_method_status
cuda_dispatch_graph_is_configured(bt_self_component_sink *self_component_sink)
{
/* Retrieve our private data from the component's user data */
struct cuda_dispatch *cuda_dispatch = bt_self_component_get_data(
bt_self_component_sink_as_self_component(self_component_sink));
/* Borrow our unique port */
bt_self_component_port_input *in_port =
bt_self_component_sink_borrow_input_port_by_index(
self_component_sink, 0);
/* Create the uptream message iterator */
bt_message_iterator_create_from_sink_component(self_component_sink,
in_port, &cuda_dispatch->message_iterator);
return BT_COMPONENT_CLASS_SINK_GRAPH_IS_CONFIGURED_METHOD_STATUS_OK;
}
/*
* Consumes a batch of messages and writes the corresponding lines to
* the standard output.
*/
static
bt_component_class_sink_consume_method_status cuda_dispatch_consume(
bt_self_component_sink *self_component_sink)
{
bt_component_class_sink_consume_method_status status =
BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK;
/* Retrieve our private data from the component's user data */
struct cuda_dispatch *cuda_dispatch = bt_self_component_get_data(
bt_self_component_sink_as_self_component(self_component_sink));
/* Consume a batch of messages from the upstream message iterator */
bt_message_array_const messages;
uint64_t message_count;
bt_message_iterator_next_status next_status =
bt_message_iterator_next(cuda_dispatch->message_iterator, &messages,
&message_count);
switch (next_status) {
case BT_MESSAGE_ITERATOR_NEXT_STATUS_END:
/* End of iteration: put the message iterator's reference */
bt_message_iterator_put_ref(cuda_dispatch->message_iterator);
status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_END;
goto end;
case BT_MESSAGE_ITERATOR_NEXT_STATUS_AGAIN:
status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_AGAIN;
goto end;
case BT_MESSAGE_ITERATOR_NEXT_STATUS_MEMORY_ERROR:
status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_MEMORY_ERROR;
goto end;
case BT_MESSAGE_ITERATOR_NEXT_STATUS_ERROR:
status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR;
goto end;
default:
break;
}
/* For each consumed message */
for (uint64_t i = 0; i < message_count; i++) {
/* Current message */
const bt_message *message = messages[i];
if (bt_message_get_type(message) == BT_MESSAGE_TYPE_EVENT) {
const bt_event *event = bt_message_event_borrow_event_const(message);
const bt_event_class *event_class = bt_event_borrow_class_const(event);
struct cuda_callbacks *callbacks = NULL;
const char * class_name = bt_event_class_get_name(event_class);
HASH_FIND_STR(cuda_dispatch->callbacks, class_name, callbacks);
if (!callbacks) {
const size_t class_name_sz = strlen(class_name);
callbacks = (struct cuda_callbacks *)calloc(1, sizeof(struct cuda_callbacks) + class_name_sz + 1);
callbacks->name = (const char *)callbacks + class_name_sz;
strncpy((char *)(callbacks->name), class_name, class_name_sz + 1);
HASH_ADD_KEYPTR(hh, cuda_dispatch->callbacks, class_name, class_name_sz, callbacks);
struct cuda_event_callbacks *event_callbacks = NULL;
HASH_FIND_STR(cuda_dispatch->event_callbacks, class_name, event_callbacks);
if (event_callbacks) {
callbacks->dispatcher = event_callbacks->dispatcher;
callbacks->callbacks = event_callbacks->callbacks;
}
}
/* Print line for current message if it's an event message */
if (callbacks->dispatcher)
callbacks->dispatcher(cuda_dispatch, callbacks, event, bt_message_event_borrow_default_clock_snapshot_const(message));
/* Put this message's reference */
}
bt_message_put_ref(message);
}
end:
return status;
}
/* Mandatory */
BT_PLUGIN_MODULE();
/* Define the `cuda` plugin */
BT_PLUGIN(cuda);
/* Define the `text` sink component class */
BT_PLUGIN_SINK_COMPONENT_CLASS(dispatch, cuda_dispatch_consume);
/* Set some of the `text` sink component class's optional methods */
BT_PLUGIN_SINK_COMPONENT_CLASS_INITIALIZE_METHOD(dispatch, cuda_dispatch_initialize);
BT_PLUGIN_SINK_COMPONENT_CLASS_FINALIZE_METHOD(dispatch, cuda_dispatch_finalize);
BT_PLUGIN_SINK_COMPONENT_CLASS_GRAPH_IS_CONFIGURED_METHOD(dispatch, cuda_dispatch_graph_is_configured);
#ifndef _BABELTRACE_CUDA_H
#define _BABELTRACE_CUDA_H
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <stdbool.h>
#include <babeltrace2/babeltrace.h>
#include "uthash.h"
#include "utarray.h"
#ifdef __cplusplus
extern "C" {
#endif
struct cuda_dispatch;
struct cuda_callbacks;
extern void init_dispatchers(struct cuda_dispatch *cuda_dispatch);
typedef void (cuda_dispatcher_t)
(struct cuda_dispatch *cuda_dispatch,
struct cuda_callbacks *callbacks,
const bt_event *message,
const bt_clock_snapshot *clock);
struct cuda_callbacks {
const char* name;
cuda_dispatcher_t *dispatcher;
UT_array *callbacks;
UT_hash_handle hh;
};
struct cuda_event_callbacks {
const char *name;
cuda_dispatcher_t *dispatcher;
UT_array *callbacks;
UT_hash_handle hh;
};
/* Sink component's private data */
struct cuda_dispatch {
/* Upstream message iterator (owned by this) */
bt_message_iterator *message_iterator;
/* Hash table */
struct cuda_callbacks *callbacks;
/* Hash table by name */
struct cuda_event_callbacks *event_callbacks;
};
extern void
cuda_register_dispatcher(struct cuda_dispatch *cuda_dispatch,
const char *name,
cuda_dispatcher_t *dispatcher);
extern void
cuda_register_callback(struct cuda_dispatch *cuda_dispatch,
const char *name,
void *func);
#ifdef __cplusplus
}
#endif
#endif
require 'yaml'
cuda_babeltrace_model = YAML::load_file("cuda_babeltrace_model.yaml")
puts <<EOF
#ifndef _BABELTRACE_CUDA_CALLBACKS_H
#define _BABELTRACE_CUDA_CALLBACKS_H
#define __CUDA_API_VERSION_INTERNAL 1
#include <cuda.h>
#include <babeltrace2/babeltrace.h>
EOF
cuda_babeltrace_model[:event_classes].each { |klass|
name = klass[:name]
fields = klass[:payload]
decls = []
fields.each { |f|
decls.push ['size_t', "_#{f[:name]}_length"] if f[:class] == 'array_static'
decls.push [f[:cast_type], f[:name]]
}
puts <<EOF
typedef void (#{name.gsub(":","_")}_cb)(
#{(["const bt_event *bt_evt", "const bt_clock_snapshot *bt_clock"]+
decls.collect { |t, n| "#{t} #{n}" }).join(",\n ")}
);
EOF
}
puts <<EOF
#endif
EOF
require 'yaml'
cuda_babeltrace_model = YAML::load_file("cuda_babeltrace_model.yaml")
puts <<EOF
#include "babeltrace_cuda.h"
#include "babeltrace_cuda_callbacks.h"
EOF
print_signed = lambda { |_, name, type|
puts <<EOF
#{name} = (#{type})bt_field_integer_signed_get_value(_field);
EOF
}
print_unsigned = lambda { |_, name, type|
puts <<EOF
#{name} = (#{type})bt_field_integer_unsigned_get_value(_field);
EOF
}
print_single = lambda { |_, name, type|
puts <<EOF
#{name} = (#{type})bt_field_real_single_precision_get_value(_field);
EOF
}
print_double = lambda { |_, name, type|
puts <<EOF
#{name} = (#{type})bt_field_real_double_precision_get_value(_field);
EOF
}
print_array_access = lambda { |length, field, name, type|
scalar_type = type.gsub("const","").sub("*", "")
voidp = false
if scalar_type.strip == "void"
voidp = true
scalar_type = "uint8_t"
end
puts <<EOF
#{length} = bt_field_array_get_length(_field);
if (#{length} > 0) {
#{name} = (#{type})malloc(#{length}*sizeof(#{scalar_type}));
for (uint64_t _i = 0; _i < #{length}; _i++) {
EOF
case field[:field][:class]
when 'unsigned'
if scalar_type.match('float')
scalar_type = 'uint32_t'
puts <<EOF
((#{scalar_type} *)#{name})[_i] =
(#{scalar_type})bt_field_integer_unsigned_get_value(
bt_field_array_borrow_element_field_by_index_const(_field, _i));
EOF
else
puts <<EOF
#{voidp ? "((#{scalar_type} *)#{name})" : name}[_i] =
(#{scalar_type})bt_field_integer_unsigned_get_value(
bt_field_array_borrow_element_field_by_index_const(_field, _i));
EOF
end
when 'signed'
puts <<EOF
#{voidp ? "((#{scalar_type} *)#{name})" : name}[_i] =
(#{scalar_type})bt_field_integer_signed_get_value(
bt_field_array_borrow_element_field_by_index_const(_field, _i));
EOF
else
raise "unsupported array element #{field[:field][:class]}"
end
puts <<EOF
}
} else
#{name} = NULL;
EOF
}
print_array_static = lambda { |field, name, type|
print_array_access["_#{name}_length", field, name, type]
}
print_array_dynamic = lambda { |field, name, type|
puts <<EOF
size_t _sz;
EOF
print_array_access["_sz", field, name, type]
}
print_string = lambda { |field, name, type|
if !type.to_s.match(/\*/)
puts <<EOF
if (bt_field_string_get_value(_field))
memcpy(&#{name}, bt_field_string_get_value(_field), sizeof(#{name}));
EOF
else
puts <<EOF
#{name} = (#{type})bt_field_string_get_value(_field);
EOF
end
}
default_access = lambda { |field, name, type|
raise "unsupported babeltrace_type: #{field[:class]}"
}
$print_accessors = Hash.new { |h, k| h[k] = default_access }
$print_accessors.merge!({
'signed' => print_signed,
'enumeration_signed' => print_signed,
'unsigned' => print_unsigned,
'enumeration_unsigned' => print_unsigned,
'single' => print_single,
'double' => print_double,
'array_static' => print_array_static,
'array_dynamic' => print_array_dynamic,
'string' => print_string
})
def print_field_member_access(f, i)
klass = f[:class]
name = f[:name]
type = f[:cast_type]
puts <<EOF
{
const bt_field *_field = NULL;
_field = bt_field_structure_borrow_member_field_by_index_const(payload_field, #{i});
EOF
$print_accessors[klass][f, name, type]
puts <<EOF
}
EOF
end
def print_field_members_decl(fields)