All of lore.kernel.org
 help / color / mirror / Atom feed
* decoding tracef msg string via babeltrace API
@ 2019-04-02 19:03 Milian Wolff via lttng-dev
  0 siblings, 0 replies; 9+ messages in thread
From: Milian Wolff via lttng-dev @ 2019-04-02 19:03 UTC (permalink / raw)
  To: lttng-dev


[-- Attachment #1.1: Type: text/plain, Size: 2838 bytes --]

Hey all

I added a tracef tracepoint and want to decode it's `msg` field in the 
BT_EVENT_FIELDS scope. Babeltrace on the command line seems to handle this 
nicely, but whatever I try, it doesn't work with the API.

I'm using babeltrace from the stable-1.5 branch.

First, the output from babeltrace on the command line:

```
event {
        name = "lttng_ust_tracef:event";
        id = 9;
        stream_id = 0;
        loglevel = 14;
        fields := struct {
                integer { size = 32; align = 8; signed = 0; encoding = none; 
base = 10; } __msg_length;
                integer { size = 8; align = 8; signed = 1; encoding = UTF8; 
base = 10; } _msg[ __msg_length ];
        };
};
...
timestamp = 15:56:15.404973865, delta = +0.000023594, trace = 1000/64-bit, 
trace:hostname = agathebauer, trace:domain = ust, loglevel = TRACE_DEBUG (14), 
name = lttng_ust_tracef:event, stream.packet.context = { timestamp_begin = 
4382372875047, timestamp_end = 4462741641629, content_size = 47177888, 
packet_size = 47185920, packet_seq_num = 0, events_discarded = 0, cpu_id = 3 
}, stream.event.header = { id = ( "compact" : container = 9 ), v = { compact = 
{ timestamp = 70385656 } } }, event.fields = { _msg_length = 33, msg = 
"run_event_entry: ImageCache, 1000" }
...
```

Now, in my code I find the event and then I've tried:

```
            auto definition = bt_ctf_get_field(event, scope, "msg");
            auto declaration = bt_ctf_get_decl_from_def(definition);
            auto type = bt_ctf_field_type(declaration);
            auto encoding = bt_ctf_get_encoding(declaration);
            auto string = bt_ctf_get_string(definition);
            auto char_array = bt_ctf_get_char_array(definition);
            const bt_definition* const* list = nullptr;
            unsigned num_list = 0;
            auto field_list_ret = bt_ctf_get_field_list(ctf_event, definition, 
&list, &num_list);
            fprintf(stderr, "tracef dbg: %p %p | %d %d | %s | %s | %p %u 
%d\n", definition, declaration, type, encoding, string, char_array, list, 
num_list, field_list_ret);
```

the output is:

```
tracef dbg: 0x55e4c5b084f0 0x55e4c5b3f220 | 9 1 | (null) | (null) | (nil) 0 -1

```

So, it's a sequence (type 9), but I can't get the sequence... Actually, when I 
tried this the firs ttime without patching babeltrace, then it crashed in 
events.c:256 [1]. The def_sequence is non-null, but def_sequence->elems is 
null and that's not checked...

[1]: https://github.com/efficios/babeltrace/blob/stable-1.5/formats/ctf/
events.c#L256

I'm quite stumped - what am I doing wrong? How does babeltrace handle the 
string-decoding of tracef's msg arg?

Thanks
-- 
Milian Wolff | milian.wolff@kdab.com | Senior Software Engineer
KDAB (Deutschland) GmbH, a KDAB Group company
Tel: +49-30-521325470
IKDAB - The Qt, C++ and OpenGL Experts

[-- Attachment #1.2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 3826 bytes --]

[-- Attachment #2: Type: text/plain, Size: 156 bytes --]

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-04-30 15:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <33072915.QNGMzHgIAz@agathebauer>
2019-04-02 19:40 ` decoding tracef msg string via babeltrace API Milian Wolff via lttng-dev
     [not found] ` <5382125.x1mbapOiNS@agathebauer>
2019-04-02 19:54   ` Milian Wolff via lttng-dev
2019-04-04 18:25 ` Jérémie Galarneau
     [not found] ` <CA+jJMxs4UAiWSanNqTigrGSLBdm+4WfcFxM5HOhvubDtXemjEA@mail.gmail.com>
2019-04-09  8:36   ` Milian Wolff via lttng-dev
     [not found]   ` <2088473.4UkR9GzeEB@milian-kdab2>
2019-04-09 17:02     ` Jérémie Galarneau
     [not found]     ` <CA+jJMxvD4HOVaDpKM2-gAQ3WLiPC7odsdXLyEzxvDzVH2p3t9Q@mail.gmail.com>
2019-04-10  7:56       ` Milian Wolff via lttng-dev
     [not found]       ` <2430999.6Ms1xt7J43@milian-kdab2>
2019-04-10  8:57         ` Milian Wolff via lttng-dev
     [not found]         ` <13178500.jIEOPmTTT8@milian-kdab2>
2019-04-30 15:14           ` Milian Wolff via lttng-dev
2019-04-02 19:03 Milian Wolff via lttng-dev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.