sink.text.pretty: add optional `print-enum-flags` parameter
authorGeneviève Bastien <gbastien@versatic.net>
Tue, 25 Feb 2020 20:33:49 +0000 (15:33 -0500)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 6 Aug 2020 18:24:48 +0000 (14:24 -0400)
commit5288c8aef93013b72a48cec6851a00b0c91f09dc
tree04a2d52009bbe5fbc25246af4fb591fba431ca9b
parented30eb8d59e3bc1d26808d3414a1fbc5f8bb23d8
sink.text.pretty: add optional `print-enum-flags` parameter

`print-enum-flags` parameter
============================
This new parameter tells the component to try to print enum values as
ORed bit flags if it applies.

When printing the value of an enum field that has no corresponding mapping,
the value is divided into its bit values and if each bit has a corresponding
mapping, consider that those mappings are ORed bit flags.

If any of the bits has no mapping, then the value is printed as <unknown>.

Example Babeltrace output of such a field (block_rq* kernel events):

  [13:15:49.024354958] (+0.000003868) wilbrod block_rq_complete: { cpu_id = 4 },
      { dev = 8388624, sector = 375490176, nr_sector = 360, error = 0,
       rwbs = ( "RWBS_FLAG_READ" | "RWBS_FLAG_RAHEAD" : container = 12 ) }

This parameter defaults to `false` as it may trigger unexpected behavior
if a trace contains a bit flag that is not described in the metadata as
is, but can be expressed as a binary OR of two existing values.
This can happen if an application changes the possible values of an
enumeration but forgets to update the metadata associated with
that recorded field. Such value must be printed as <unknown>.

Print all labels matching value
===============================
With this commit, a `sink.text.pretty` component will print all matching
labels inside curly brackets separated by commas. See
`print_enum_value_label_array()`.

So if an enum value matches two labels it will be printed as:
  enum_field = ( { "bit0", "range1to3" } : container = 1 )

Change-Id: I26a17307243d5612c70c0e5b04e6b9567b0720d3
Signed-off-by: Geneviève Bastien <gbastien@versatic.net>
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3045
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/plugins/text/pretty/pretty.c
src/plugins/text/pretty/pretty.h
src/plugins/text/pretty/print.c
tests/plugins/sink.text.pretty/test_enum
This page took 0.024898 seconds and 4 git commands to generate.