Feature #508
Updated by Mathieu Desnoyers over 11 years ago
The attached patch modifies the hello.cxx test (from lttng-ust 2.1.1) to add an array of floats argument.
as you see in the following output (babeltrace v1.0.3 with the python bindings patchs), the field floatarrfield shows ints instead of the expected floats:
<pre>
$ rm -rf ~/lttng-traces/ ; lttng create && lttng enable-event -a -u && lttng start && ./run && lttng stop && lttng destroy && babeltrace ~/lttng-traces | head -n 2
Session auto-20130419-222314 created.
Traces will be written in /home/sbarthelemy/lttng-traces/auto-20130419-222314
All UST events are enabled in channel channel0
Tracing started for session auto-20130419-222314
Hello, World!
Tracing... done.
Waiting for data availability
Tracing stopped for session auto-20130419-222314
Session auto-20130419-222314 destroyed
[22:23:14.605465399] (+?.?????????) ald-0987-de:hello:30232 ust_tests_hello:tptest: { cpu_id = 5 }, { intfield = 0, intfield2 = 0x0, longfield = 0, netintfield = 0, netintfieldhex = 0x0, arrfield1 = [ [0] = 1, [1] = 2, [2] = 3 ], arrfield2 = "test", _seqfield1_length = 4, seqfield1 = [ [0] = 116, [1] = 101, [2] = 115, [3] = 116 ], _seqfield2_length = 4, seqfield2 = "test", stringfield = "test", floatfield = 2222.1, doublefield = 2.1, floatarrfield = [ [0] = 1066192077, [1] = 1074580685, [2] = 1079194419 ] }
[22:23:14.605470207] (+0.000004808) ald-0987-de:hello:30232 ust_tests_hello:tptest: { cpu_id = 5 }, { intfield = 1, intfield2 = 0x1, longfield = 1, netintfield = 1, netintfieldhex = 0x1, arrfield1 = [ [0] = 1, [1] = 2, [2] = 3 ], arrfield2 = "test", _seqfield1_length = 4, seqfield1 = [ [0] = 116, [1] = 101, [2] = 115, [3] = 116 ], _seqfield2_length = 4, seqfield2 = "test", stringfield = "test", floatfield = 2222.1, doublefield = 2.1, floatarrfield = [ [0] = 1066192077, [1] = 1074580685, [2] = 1079194419 ] }
</pre>
as a workaround, the floating point value can be retrieved in python using:
<pre>
In [1]: import struct
In [2]: struct.unpack('f', struct.pack('i', 1066192077))
Out[2]: (1.100000023841858,)
</pre>