Project

General

Profile

Actions

Feature #508

open
SB

arrays of floats are stored and/or displayed as arrays of ints

Feature #508: arrays of floats are stored and/or displayed as arrays of ints

Added by Sébastien Barthélémy over 12 years ago. Updated over 3 years ago.

Status:
Feedback
Priority:
Normal
Assignee:
-
Target version:
Start date:
04/19/2013
Due date:
% Done:

0%

Estimated time:

Description

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:

$ 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 ] }

as a workaround, the floating point value can be retrieved in python using:

In [1]: import struct

In [2]: struct.unpack('f', struct.pack('i', 1066192077))
Out[2]: (1.100000023841858,)


Files

0001-test-array-of-floats-in-hello.cxx.patch (1.91 KB) 0001-test-array-of-floats-in-hello.cxx.patch Sébastien Barthélémy, 04/19/2013 04:33 PM
metadata (4 KB) metadata Sébastien Barthélémy, 04/19/2013 05:01 PM

MD Updated by Mathieu Desnoyers over 12 years ago Actions #1

  • Description updated (diff)
  • Status changed from New to Feedback

please upload your metadata file.

Thanks,

Mathieu

SB Updated by Sébastien Barthélémy over 12 years ago Actions #2

Mathieu Desnoyers wrote:

please upload your metadata file.

here it is.

MD Updated by Mathieu Desnoyers over 12 years ago Actions #3

integer { size = 32; align = 8; signed = 1; encoding = none; base = 10; } _floatarrfield[3];

wrong type declared by UST.

MD Updated by Mathieu Desnoyers over 12 years ago Actions #4

I don't really see how we could distinguish between float and integer at the macro level.

So we might end up having to implement a ctf_array_float() in include/lttng/ust-tracepoint-event.h.

Thoughts ?

SB Updated by Sébastien Barthélémy over 12 years ago Actions #5

Mathieu Desnoyers wrote:

I don't really see how we could distinguish between float and integer at the macro level.

So we might end up having to implement a ctf_array_float() in include/lttng/ust-tracepoint-event.h.

Thoughts ?

maybe something like

#define ctf_array(type, field, var, size) ctf_array_##type(field, var, size)

MD Updated by Mathieu Desnoyers over 12 years ago Actions #6

#define ctf_array(type, field, var, size) ctf_array_##type(field, var, size)

won't work, because "type" can be "unsigned long" (with space), which cannot be used in an identifier.

MD Updated by Mathieu Desnoyers over 12 years ago Actions #7

would a new "ctf_array_float" be a sensible solution then ? I'm tempted to flag this bug as a feature request though.

SB Updated by Sébastien Barthélémy over 12 years ago Actions #8

Mathieu Desnoyers wrote:

would a new "ctf_array_float" be a sensible solution then ?

yes adding ctf_array_float & ctf_array_double sounds sensible (and I have not better solution)

MD Updated by Mathieu Desnoyers over 12 years ago Actions #9

  • Tracker changed from Bug to Feature

MJ Updated by Michael Jeanson over 3 years ago Actions #10

  • Target version set to Wishlist
Actions

Also available in: PDF Atom