[lttng-dev] [RFC PATCH babeltrace] ctf-writer: Add support for the cpu_id field

Sebastian Andrzej Siewior bigeasy at linutronix.de
Tue Jun 3 03:39:56 EDT 2014


On 06/02/2014 07:08 PM, Jérémie Galarneau wrote:
> Hi Sebastian,

Hi Jérémie,

> I'd prefer we provide a generic way of adding fields to the packet
> context. Something akin to what's provided for structures which would
> let users define arbitrary packet context fields.
> 
> I propose adding
> 
> int bt_ctf_stream_class_add_packet_context_field(const char
> *field_name, struct bt_ctf_field_type *field_type);
> 
> and
> 
> struct bt_ctf_field *bt_ctf_stream_get_packet_context_field(const char
> *field_name);
> 
> I'm open to better naming suggestions, but hopefully I'm getting the
> functionality across.
> 
> Thoughts?
Looks like a few lines more than what I hoped for. Let me try your way.
So what you suggest is something like that:

---
struct bt_ctf_field_type *cpu_num;

cpu_num = bt_ctf_field_type_integer_create(31);

bt_ctf_field_signed_integer_set_value(cpu_num, 2);
bt_ctf_stream_class_add_packet_context_field("cpu", cpu_num);

---

and then I try to change the CPU number I have to
bt_ctf_field_signed_integer_set_value() + flush like I did before,
right?
For that to work I would have to keep an array of everything that came
via bt_ctf_stream_class_add_packet_context_field() and attach to struct
bt_ctf_stream  so I have those fields in init_packet_context().

Is this what you had in mind?

> 
> Jérémie

Sebastian



More information about the lttng-dev mailing list