`ctf` plugin: add `ctf::src::MsgIter` class
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 7 Jun 2022 19:15:47 +0000 (15:15 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Tue, 23 Aug 2022 16:06:16 +0000 (12:06 -0400)
commit73c5947855d5ff001f2eb7f8867171e7b60b57bf
treea07a50be0ca21f91c282b5371efb120c3161be8c
parentf0e85e6f3c46b4769cd7e81b42ab5faed722dcf5
`ctf` plugin: add `ctf::src::MsgIter` class

Original patch by Simon.

Philippe's changes over original patch (no functional change intended):

* Conform to the Babeltrace 2 coding style for new C++11 code and to
  some naming conventions of the common part of the `ctf` plugin.

* Add many public and internal comments.

* Rename `Quirks` class to `MsgIterQuirks`.

  Also, rename the quirks to the generic `pktEndDefClkValZero`,
  `eventRecordDefClkValGtNextPktBeginDefClkVal`, and
  `eventRecordDefClkValLtPktBeginDefClkVal` names to decouple this API
  from specific tracers.

* Remove `MsgIterItemVisitor`.

  Instead, MsgIter::_handleItem() dispatches the item to a specific
  handling method based on its numeric type.

  Move the relevant members of `MsgIterItemVisitor` into `MsgIter`
  itself.

* In `_StackFrame`, rename everything named "field" to "sub-field" so as
  to remove some ambiguity.

* Add MsgIter::_stackTop*() helper methods which defer to the
  corresponding method on the top stack frame.

* Add MsgIter::_stackPush() and MsgIter::_stackPop() helper methods.

* Add MsgIter::_addMsgToQueue() helper method.

* Only log item details when the `TRACE` level is enabled.

* Handle `PktMagicNumberItem`: validate the magic number value.

* Handle `MetadataStreamUuidItem`: validate the UUID.

  The `MsgIter` constructor now accepts an `expectedMetadataStreamUuid`
  parameter (optional UUID) which is the expected metadata stream UUID
  to compare to.

* Handle variable-length integer field items, adding the
  MsgIter::_handleUIntFieldItem() and MsgIter::_handleSIntFieldItem()
  helper method templates to do so.

* Handle BLOB field items.

  A new data member, `_mCurBlobFieldDataOffset`, tracks the current BLOB
  field data offset to write to when handling the next
  `BlobFieldSectionItem` (we can't append to a BLOB field like when
  handling `StrFieldSubstrItem`).

* Handle optional field items, adding a member to
  `MsgIter::_StackFrame::_Field`.

* In MsgIter::_StackFrame::goToNextSubField(), unconditionally increment
  `_mSubFieldIndex`: curSubField() doesn't care about `_mSubFieldIndex`
  for the variant/option field cases anyway.

  Therefore, make curSubFieldAndGoToNextSubField() reuse curSubField()
  and goToNextSubField() to remove some almost duplicate code.

Change-Id: If2dd82b43f4d19a16ec4420c13c9a3686034766d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8227
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/cpp-common/bt2/message.hpp
src/plugins/ctf/common/src/Makefile.am
src/plugins/ctf/common/src/msg-iter.cpp [new file with mode: 0644]
src/plugins/ctf/common/src/msg-iter.hpp [new file with mode: 0644]
This page took 0.026677 seconds and 5 git commands to generate.