* [lttng-dev] Add support of CTF structure global type
@ 2014-03-26 14:55 Geneviève Bastien
2014-03-26 14:55 ` [lttng-dev] [RFC Patch Tools 1/3] Update data structures to support CTF global structures Geneviève Bastien
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Geneviève Bastien @ 2014-03-26 14:55 UTC (permalink / raw)
The following patch series in LTTng-Tools add support of the named CTF
structure global type. It goes along with a patch series in LTTng-ust.
It is built above the CTF enumerations patches proposed earlier adn being
staged in Mathieu Desnoyers's development branch here:
https://github.com/compudj/lttng-tools-dev/tree/ust-enum
^ permalink raw reply [flat|nested] 4+ messages in thread
* [lttng-dev] [RFC Patch Tools 1/3] Update data structures to support CTF global structures
2014-03-26 14:55 [lttng-dev] Add support of CTF structure global type Geneviève Bastien
@ 2014-03-26 14:55 ` Geneviève Bastien
2014-03-26 14:55 ` [lttng-dev] [RFC Patch Tools 2/3] Statedump the metadata for the " Geneviève Bastien
2014-03-26 14:55 ` [lttng-dev] [RFC Patch Tools 3/3] Update regression tests for UST global structure declarations Geneviève Bastien
2 siblings, 0 replies; 4+ messages in thread
From: Geneviève Bastien @ 2014-03-26 14:55 UTC (permalink / raw)
It also adds appropriate data structures to describe a structure field in
tracepoints.
Signed-off-by: Genevi?ve Bastien <gbastien+lttng at versatic.net>
---
src/bin/lttng-sessiond/lttng-ust-ctl.h | 14 ++++++++++++++
src/bin/lttng-sessiond/ust-registry.c | 1 +
2 files changed, 15 insertions(+)
diff --git a/src/bin/lttng-sessiond/lttng-ust-ctl.h b/src/bin/lttng-sessiond/lttng-ust-ctl.h
index 379260d..9a13fd9 100644
--- a/src/bin/lttng-sessiond/lttng-ust-ctl.h
+++ b/src/bin/lttng-sessiond/lttng-ust-ctl.h
@@ -244,6 +244,7 @@ enum ustctl_abstract_types {
ustctl_atype_sequence,
ustctl_atype_string,
ustctl_atype_float,
+ ustctl_atype_structure,
NR_USTCTL_ABSTRACT_TYPES,
};
@@ -314,6 +315,9 @@ struct ustctl_type {
struct ustctl_basic_type length_type;
struct ustctl_basic_type elem_type;
} sequence;
+ struct {
+ char name[LTTNG_UST_SYM_NAME_LEN];
+ } structure;
char padding[USTCTL_UST_TYPE_PADDING];
} u;
} LTTNG_PACKED;
@@ -327,9 +331,18 @@ struct ustctl_enum {
char padding[USTCTL_UST_ENUM_TYPE_PADDING];
} LTTNG_PACKED;
+#define USTCTL_UST_STRUCT_TYPE_PADDING 368
+struct ustctl_structure {
+ char name[LTTNG_UST_SYM_NAME_LEN];
+ size_t nr_fields;
+ struct ustctl_field *fields;
+ char padding[USTCTL_UST_STRUCT_TYPE_PADDING];
+} LTTNG_PACKED;
+
/* CTF categories for global types declared outside event descriptions */
enum ustctl_global_type_categories {
ustctl_mtype_enum,
+ ustctl_mtype_structure,
NR_USTCTL_GLOBAL_TYPES,
};
@@ -338,6 +351,7 @@ struct ustctl_global_type_decl {
uint32_t mtype;
union {
struct ustctl_enum ctf_enum;
+ struct ustctl_structure ctf_structure;
char padding[USTCTL_UST_GLOBAL_TYPE_DECL_PADDING];
} u;
} LTTNG_PACKED;
diff --git a/src/bin/lttng-sessiond/ust-registry.c b/src/bin/lttng-sessiond/ust-registry.c
index 8b58b25..6fd2f3b 100644
--- a/src/bin/lttng-sessiond/ust-registry.c
+++ b/src/bin/lttng-sessiond/ust-registry.c
@@ -135,6 +135,7 @@ int validate_event_field(struct ustctl_field *field,
case ustctl_atype_array:
case ustctl_atype_sequence:
case ustctl_atype_string:
+ case ustctl_atype_structure:
break;
case ustctl_atype_float:
--
1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [lttng-dev] [RFC Patch Tools 2/3] Statedump the metadata for the CTF global structures
2014-03-26 14:55 [lttng-dev] Add support of CTF structure global type Geneviève Bastien
2014-03-26 14:55 ` [lttng-dev] [RFC Patch Tools 1/3] Update data structures to support CTF global structures Geneviève Bastien
@ 2014-03-26 14:55 ` Geneviève Bastien
2014-03-26 14:55 ` [lttng-dev] [RFC Patch Tools 3/3] Update regression tests for UST global structure declarations Geneviève Bastien
2 siblings, 0 replies; 4+ messages in thread
From: Geneviève Bastien @ 2014-03-26 14:55 UTC (permalink / raw)
It reuses the event field's statedump functions to statedump the fields of
the structure.
Signed-off-by: Genevi?ve Bastien <gbastien+lttng at versatic.net>
---
src/bin/lttng-sessiond/ust-metadata.c | 41 ++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/src/bin/lttng-sessiond/ust-metadata.c b/src/bin/lttng-sessiond/ust-metadata.c
index 1a482f2..3eb131c 100644
--- a/src/bin/lttng-sessiond/ust-metadata.c
+++ b/src/bin/lttng-sessiond/ust-metadata.c
@@ -270,6 +270,14 @@ int _lttng_field_statedump(struct ust_registry_session *session,
" { encoding = ASCII; }" : "",
field->name);
break;
+ case ustctl_atype_structure:
+ {
+ ret = lttng_metadata_printf(session,
+ " struct __ust_struct__%s _%s;\n",
+ field->type.u.structure.name,
+ field->name);
+ break;
+ }
default:
return -EINVAL;
}
@@ -339,6 +347,12 @@ int _lttng_one_global_type_statedump(struct ust_registry_session *session,
strncpy(global_type->name, global_type_decl->u.ctf_enum.name, LTTNG_UST_SYM_NAME_LEN);
global_type->name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0';
break;
+ case ustctl_mtype_structure:
+ strncpy(global_type->name,
+ global_type_decl->u.ctf_structure.name,
+ LTTNG_UST_SYM_NAME_LEN);
+ global_type->name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0';
+ break;
default:
return -EINVAL;
}
@@ -356,7 +370,8 @@ int _lttng_one_global_type_statedump(struct ust_registry_session *session,
cds_lfht_node_init(&global_type->node.node);
rcu_read_unlock();
-
+ DBG("adding global type %s of type %d to metadata",
+ global_type->name, global_type_decl->mtype);
switch (global_type_decl->mtype) {
case ustctl_mtype_enum:
{
@@ -440,6 +455,30 @@ int _lttng_one_global_type_statedump(struct ust_registry_session *session,
return ret;
break;
}
+ case ustctl_mtype_structure:
+ {
+ const struct ustctl_structure *ustruct;
+
+ ustruct = &global_type_decl->u.ctf_structure;
+ ret = lttng_metadata_printf(session,
+ "struct __ust_struct__%s {\n",
+ ustruct->name);
+ if (ret)
+ return ret;
+ /* Dump the fields */
+ for (i = 0; i < ustruct->nr_fields; i++) {
+ struct ustctl_field field;
+
+ field = ustruct->fields[i];
+ ret = _lttng_field_statedump(session, &field);
+ if (ret)
+ return ret;
+ }
+ ret = lttng_metadata_printf(session, "};\n\n");
+ if (ret)
+ return ret;
+ break;
+ }
default:
return -EINVAL;
}
--
1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [lttng-dev] [RFC Patch Tools 3/3] Update regression tests for UST global structure declarations
2014-03-26 14:55 [lttng-dev] Add support of CTF structure global type Geneviève Bastien
2014-03-26 14:55 ` [lttng-dev] [RFC Patch Tools 1/3] Update data structures to support CTF global structures Geneviève Bastien
2014-03-26 14:55 ` [lttng-dev] [RFC Patch Tools 2/3] Statedump the metadata for the " Geneviève Bastien
@ 2014-03-26 14:55 ` Geneviève Bastien
2 siblings, 0 replies; 4+ messages in thread
From: Geneviève Bastien @ 2014-03-26 14:55 UTC (permalink / raw)
And fix enumeration tests that didn't work anymore.
Signed-off-by: Genevi?ve Bastien <gbastien+lttng at versatic.net>
---
.../global-type-declarations.c | 9 ++++++
.../test_global_type_declarations.py | 31 ++++++++++++++++----
.../ust/global-type-declarations/ust_tests_gtd.h | 33 ++++++++++++++++++++++
3 files changed, 67 insertions(+), 6 deletions(-)
diff --git a/tests/regression/ust/global-type-declarations/global-type-declarations.c b/tests/regression/ust/global-type-declarations/global-type-declarations.c
index edd6fc7..b20a9e9 100644
--- a/tests/regression/ust/global-type-declarations/global-type-declarations.c
+++ b/tests/regression/ust/global-type-declarations/global-type-declarations.c
@@ -27,11 +27,20 @@
int main(int argc, char *argv[])
{
int i;
+ char text[10] = "test";
for (i = 0; i < 2; i++) {
tracepoint(ust_tests_gtd, tptest, i%2, (i+1)%2);
tracepoint(ust_tests_gtd, tptest_bis, i%2);
}
+ tracepoint(ust_tests_gtd, tptest_struct, 0, text, strlen(text));
+
+ /*
+ * Add a normal tracepoint after, just to be sure the previous dynamic
+ * fields didn't wrongly offset the next event.
+ */
+ tracepoint(ust_tests_gtd, tptest_bis, 1);
+
return 0;
}
diff --git a/tests/regression/ust/global-type-declarations/test_global_type_declarations.py b/tests/regression/ust/global-type-declarations/test_global_type_declarations.py
index 5661b35..da1b476 100644
--- a/tests/regression/ust/global-type-declarations/test_global_type_declarations.py
+++ b/tests/regression/ust/global-type-declarations/test_global_type_declarations.py
@@ -29,7 +29,7 @@ test_utils_path = test_utils_path + "/utils"
sys.path.append(test_utils_path)
from test_utils import *
-NR_TESTS = 9
+NR_TESTS = 12
current_test = 1
print("1..{0}".format(NR_TESTS))
@@ -78,13 +78,14 @@ current_test += 1
if babeltrace_process.returncode != 0:
bail("Unreadable trace; can't proceed with analysis.")
-print_test_result(len(event_lines) == 4, current_test, "Correct number of events found in resulting trace")
+print_test_result(len(event_lines) == 6, current_test, "Correct number of events found in resulting trace")
current_test += 1
-if len(event_lines) != 4:
+if len(event_lines) != 6:
bail("Unexpected number of events found in resulting trace (" + session_info.trace_path + ")." )
-match = re.search(r".*ust_tests_gtd:(.*):.*enumfield = \( \"(.*)\" :.*enumfield_bis = \( \"(.*)\" :.*", event_lines[0])
+# Test enumeration fields in tracepoints
+match = re.search(r".*ust_tests_gtd:(.*):.*enumfield = \( (.*) :.*enumfield_bis = \( (.*) :.*", event_lines[0])
print_test_result(match is not None and match.group(1) == "tptest", current_test,\
"First tracepoint is present")
current_test += 1
@@ -97,7 +98,7 @@ print_test_result(match is not None and match.group(3) == "one", current_test,\
"First tracepoint's second enum value maps to one")
current_test += 1
-match = re.search(r".*ust_tests_gtd:(.*):.*enumfield = \( \"(.*)\" :.*", event_lines[1])
+match = re.search(r".*ust_tests_gtd:(.*):.*enumfield = \( (.*) :.*", event_lines[1])
print_test_result(match is not None and match.group(1) == "tptest_bis", current_test,\
"Second tracepoint is present")
current_test += 1
@@ -106,9 +107,27 @@ print_test_result(match is not None and match.group(2) == "zero", current_test,\
"Second tracepoint's enum value maps to zero")
current_test += 1
-match = re.search(r".*ust_tests_gtd:(.*):.*enumfield = \( \"(.*)\" :.*enumfield_bis = \( \"(.*)\" .*", event_lines[2])
+match = re.search(r".*ust_tests_gtd:(.*):.*enumfield = \( (.*) :.*enumfield_bis = \( (.*) .*", event_lines[2])
print_test_result(match is not None and match.group(2) == "one", current_test,\
"Third tracepoint's enum value maps to one")
+current_test += 1
+
+# Test structure fields in tracepoint
+match = re.search(r".*ust_tests_gtd:(.*):.*structfield = { _outer_seqfield_length = 4, outer_seqfield = \[ \[0\] = 116, \[1\] = 101, \[2\] = 115, \[3\] = 116 \].*", event_lines[4])
+print_test_result(match is not None and match.group(1) == "tptest_struct", current_test,\
+ "Struct field in tracepoint is present with field dynamic sequence")
+current_test += 1
+
+# Test inner structure fields in tracepoint
+match = re.search(r".*ust_tests_gtd:(.*):.*innerfield = { arrfield = \[ \[0\] = 116, \[1\] = 101, \[2\] = 115, \[3\] = 116, \[4\] = 0, \[5\] = 0, \[6\] = 0, \[7\] = 0, \[8\] = 0, \[9\] = 0 \], _inner_seqfield_length = 4, inner_seqfield = \[ \[0\] = 116, \[1\] = 101, \[2\] = 115, \[3\] = 116 \], enumfield = \( zero : container = 0 \) } }.*", event_lines[4])
+print_test_result(match is not None and match.group(1) == "tptest_struct", current_test,\
+ "Inner struct field inside another struct is present with fields dynamic sequence, array and enumeration")
+current_test += 1
+
+match = re.search(r".*ust_tests_gtd:(.*):.*enumfield = \( one : container = 1 \) }", event_lines[5])
+print_test_result(match is not None and match.group(1) == "tptest_bis", current_test,\
+ "Tracepoint after struct and dynamic field is correct")
+current_test += 1
shutil.rmtree(session_info.tmp_directory)
diff --git a/tests/regression/ust/global-type-declarations/ust_tests_gtd.h b/tests/regression/ust/global-type-declarations/ust_tests_gtd.h
index ad3df0c..41b1c43 100644
--- a/tests/regression/ust/global-type-declarations/ust_tests_gtd.h
+++ b/tests/regression/ust/global-type-declarations/ust_tests_gtd.h
@@ -36,6 +36,27 @@ TRACEPOINT_ENUM(ust_tests_gtd, testenum,
)
)
+/* Structure contains dynamic field and enumeration */
+TRACEPOINT_STRUCT(ust_tests_gtd, inner_struct,
+ TP_ARGS(char *, text, size_t, textlen,
+ int, enumvalue),
+ TP_FIELDS(
+ ctf_array(char, arrfield, text, 10)
+ ctf_sequence(char, inner_seqfield, text, size_t, textlen)
+ ctf_enum(ust_tests_gtd, testenum, enumfield, enumvalue)
+ )
+)
+
+/* Structure contains dynamic field and another structure */
+TRACEPOINT_STRUCT(ust_tests_gtd, outer_struct,
+ TP_ARGS(char *, text, size_t, textlen,
+ int, enumvalue),
+ TP_FIELDS(
+ ctf_sequence(char, outer_seqfield, text, size_t, textlen)
+ ctf_struct(ust_tests_gtd, inner_struct, innerfield, text, textlen, enumvalue)
+ )
+)
+
/*
* Enumeration field is used twice to make sure the global type declaration
* is entered only once in the metadata file.
@@ -59,6 +80,18 @@ TRACEPOINT_EVENT(ust_tests_gtd, tptest_bis,
)
)
+/*
+ * This structure uses a structure fields that contains both dynamic fields
+ * and another structure, who itself contains dynamic fields and an
+ * enumeration.
+ */
+TRACEPOINT_EVENT(ust_tests_gtd, tptest_struct,
+ TP_ARGS(int, enumval, char *, text, size_t, textlen),
+ TP_FIELDS(
+ ctf_struct(ust_tests_gtd, outer_struct, structfield, text, textlen, enumval)
+ )
+)
+
#endif /* _TRACEPOINT_UST_TESTS_GLOBAL_TYPE_DECLARATIONS_H */
#undef TRACEPOINT_INCLUDE
--
1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-03-26 14:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-26 14:55 [lttng-dev] Add support of CTF structure global type Geneviève Bastien
2014-03-26 14:55 ` [lttng-dev] [RFC Patch Tools 1/3] Update data structures to support CTF global structures Geneviève Bastien
2014-03-26 14:55 ` [lttng-dev] [RFC Patch Tools 2/3] Statedump the metadata for the " Geneviève Bastien
2014-03-26 14:55 ` [lttng-dev] [RFC Patch Tools 3/3] Update regression tests for UST global structure declarations Geneviève Bastien
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox