summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
8673030)
A field can be prefixed by an underscore internally by the tracer.
This provides the abilility for the user to specify the underscore or
not (depending if he read the metadata or the tracepoint event
definition).
This is a fallback mechanism, so if the request fails, we prefix an
underscore to the field name and request it again.
Also, the bt_ctf_field_name function now removes the optional
underscore.
A quick benchmark shows that calling the bt_ctf_get_field without the
underscore on a field that requires an underscore adds around 151
nanoseconds to the call on a core 2 duo (tested in a loop of
1000000
iterations).
Signed-off-by: Julien Desfossez <julien.desfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
const char *field)
{
struct definition *def;
const char *field)
{
struct definition *def;
+ char *field_underscore;
if (scope) {
def = lookup_definition(scope, field);
if (scope) {
def = lookup_definition(scope, field);
+ /*
+ * optionally a field can have an underscore prefix, try
+ * to lookup the field with this prefix if it failed
+ */
+ if (!def) {
+ field_underscore = g_new(char, strlen(field) + 2);
+ field_underscore[0] = '_';
+ strcpy(&field_underscore[1], field);
+ def = lookup_definition(scope, field_underscore);
+ g_free(field_underscore);
+ }
if (bt_ctf_field_type(def) == CTF_TYPE_VARIANT) {
struct definition_variant *variant_definition;
variant_definition = container_of(def,
if (bt_ctf_field_type(def) == CTF_TYPE_VARIANT) {
struct definition_variant *variant_definition;
variant_definition = container_of(def,
const char *bt_ctf_field_name(const struct definition *def)
{
if (def)
const char *bt_ctf_field_name(const struct definition *def)
{
if (def)
- return g_quark_to_string(def->name);
+ return rem_(g_quark_to_string(def->name));
*/
int print_field(struct definition *definition);
*/
int print_field(struct definition *definition);
-static inline
-const char *rem_(const char *str)
-{
- if (str[0] == '_')
- return &str[1];
- else
- return str;
-}
-
#endif /* _BABELTRACE_CTF_TEXT_TYPES_H */
#endif /* _BABELTRACE_CTF_TEXT_TYPES_H */
struct definition *lookup_variant(struct definition *definition,
const char *field_name);
struct definition *lookup_variant(struct definition *definition,
const char *field_name);
+static inline
+const char *rem_(const char *str)
+{
+ if (str[0] == '_')
+ return &str[1];
+ else
+ return str;
+}
+
#endif /* _BABELTRACE_TYPES_H */
#endif /* _BABELTRACE_TYPES_H */