Skip to content

Commit 7ffe1bd

Browse files
TApplencourtclaude
andauthored
xprof: name the type of each integer component parameter (#547)
A component parameter's type is declared in its `*_params.yaml`, but Ruby has a single Integer type, so `BTValue.from_value()` has to guess which `bt_value` to build: it picks unsigned above 2**63 and signed below it, whatever the component actually expects. That guess is wrong for the timeline's `offset`, declared `integer_unsigned` and read into a `uint64_t`: every realistic value is below 2**63, so it was sent as a signed value. metababel 1.1.4 generated no type check, so it went unnoticed; 2.0.0 validates the type and rejects it: Bad value for command line argument 'offset' the value must be 'integer_unsigned'. Both of THAPI's integer parameters now name the type their model declares, through the `BTValue` passthrough `from_value()` already offers. The tally's `display_name_max_size` is unchanged in behaviour -- signed is what the guess happened to pick -- but it no longer depends on the guess being right. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 26a92c8 commit 7ffe1bd

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎utils/babeltrace_thapi.in‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,19 +236,25 @@ def get_and_add_components(graph, names, l_inputs)
236236

237237
params['ctf-version'] = '1.8' if Gem::Version.new(semantic_version_str) >= Gem::Version.new('2.1.0')
238238
graph.add(comp, 'ctf_sink', params: params)
239+
# We cast integers, because babeltrace2 infers the type from the value
240+
# passed rather than from the one the *_params.yaml declares.
239241
when 'sink.btx_tally.tally'
240242
graph.add(comp, 'tally',
241243
params: { 'display' => $options[:display],
242244
'name' => $options[:name],
243245
'display_mode' => $options[:'display-mode'],
244246
'display_metadata' => $options[:'display-metadata'],
245-
'display_name_max_size' => $options[:'display-name-max-size'],
247+
'display_name_max_size' => BT2::BTValueIntegerSigned.new(
248+
value: $options[:'display-name-max-size']
249+
),
246250
'display_kernel_verbose' => $options[:'display-kernel-verbose'],
247251
'backend_levels' => $options[:backends].join(',') })
248252
when 'sink.btx_timeline.timeline'
249253
graph.add(comp, 'timeline',
250254
params: { 'output_path' => $options[:'output-path'],
251-
'offset' => $options[:'output-offset'] })
255+
'offset' => BT2::BTValueIntegerUnsigned.new(
256+
value: $options[:'output-offset']
257+
) })
252258
when 'filter.utils.muxer'
253259
graph.add(comp, name)
254260
when 'filter.btx_aggreg.aggreg'

0 commit comments

Comments
 (0)