barectf.git
3 years agobarectf v3.0.0 v3.0.0
Philippe Proulx [Thu, 24 Sep 2020 14:36:26 +0000 (10:36 -0400)] 
barectf v3.0.0

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agodocs: how-barectf-works: update CTF trace structure images
Philippe Proulx [Fri, 25 Sep 2020 18:48:31 +0000 (14:48 -0400)] 
docs: how-barectf-works: update CTF trace structure images

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agotest_pass_everything.py: check two new symbols
Philippe Proulx [Fri, 25 Sep 2020 14:15:57 +0000 (10:15 -0400)] 
test_pass_everything.py: check two new symbols

ed4a69c ("barectf.h.j2: add barectf_discarded_event_records_count()")
and 3bf37cb ("barectf.h.j2: add barectf_packet_buf_addr()") introduced
new API symbols to check here.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agotest_pass_everything.py: use `cc` by default (like Make), not `gcc`
Philippe Proulx [Fri, 25 Sep 2020 14:15:39 +0000 (10:15 -0400)] 
test_pass_everything.py: use `cc` by default (like Make), not `gcc`

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agotest_pass_everything.py: reformat
Philippe Proulx [Fri, 25 Sep 2020 14:15:25 +0000 (10:15 -0400)] 
test_pass_everything.py: reformat

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agodocs: whats-new.adoc: use headings for main topics
Philippe Proulx [Fri, 25 Sep 2020 14:03:52 +0000 (10:03 -0400)] 
docs: whats-new.adoc: use headings for main topics

This is more readable than a single long list.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agodocs: cli: usage.adoc: improve page
Philippe Proulx [Fri, 25 Sep 2020 14:02:02 +0000 (10:02 -0400)] 
docs: cli: usage.adoc: improve page

Changes:

* Add link to <https://git-scm.com/>.

* Use the third person for the command descriptions in the
  General description section.

* Add and fix many internal links.

* Specify that `PREFIX` must be a valid C identifier.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agotests/tracing/conftest.py: add valid `basic-extra-pc-ft-members` cat.
Philippe Proulx [Fri, 25 Sep 2020 02:02:45 +0000 (22:02 -0400)] 
tests/tracing/conftest.py: add valid `basic-extra-pc-ft-members` cat.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agotests/tracing: add DST extra packet context FT members test
Philippe Proulx [Fri, 25 Sep 2020 00:12:17 +0000 (20:12 -0400)] 
tests/tracing: add DST extra packet context FT members test

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agotests/tracing: add event record type tests
Philippe Proulx [Fri, 25 Sep 2020 00:00:25 +0000 (20:00 -0400)] 
tests/tracing: add event record type tests

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agotests/tracing: add data stream type tests
Philippe Proulx [Thu, 24 Sep 2020 23:54:07 +0000 (19:54 -0400)] 
tests/tracing: add data stream type tests

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agotests/tracing/support/basic/test-platform.h: `ctx` -> `platform_ctx`
Philippe Proulx [Thu, 24 Sep 2020 23:36:22 +0000 (19:36 -0400)] 
tests/tracing/support/basic/test-platform.h: `ctx` -> `platform_ctx`

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agotests/tracing: add data stream type event record feature tests
Philippe Proulx [Thu, 24 Sep 2020 23:35:55 +0000 (19:35 -0400)] 
tests/tracing: add data stream type event record feature tests

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agotests/tracing: add data stream type packet feature tests
Philippe Proulx [Thu, 24 Sep 2020 23:31:42 +0000 (19:31 -0400)] 
tests/tracing: add data stream type packet feature tests

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agotests/tracing: `int main()` -> `int main(void)`
Philippe Proulx [Thu, 24 Sep 2020 23:28:43 +0000 (19:28 -0400)] 
tests/tracing: `int main()` -> `int main(void)`

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agotests/tracing: add trace type feature tests
Philippe Proulx [Thu, 24 Sep 2020 23:15:59 +0000 (19:15 -0400)] 
tests/tracing: add trace type feature tests

This patch adds a new tracing test category named `counter-clock`.

This is because the `counter-clock` platform (in
`tests/tracing/support/counter-clock`) has a data stream clock which is
a simpler counter starting at 0.

The platform's base YAML trace type object,
`tests/tracing/support/counter-clock/base.yaml`, specifies a single
event record type `dummy` so that test-specific configurations which do
not need event record types are lighter.

The C files in `tests/tracing/src/counter-clock/trace-type-features`
do not call any tracing function: they only initialize and finalize
the test platform, which effectively opens and closes a single packet.

In the new `test-platform.c` file, test_platform_fini() closes the
current packet whether or not it's empty.

`tests/tracing/support/counter-clock/base-no-features.yaml` is a YAML
trace type object file which disables all the trace type and data stream
type features except the data stream type ID and event record type ID
features.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agotests: reflow licence headers for 72 columns
Philippe Proulx [Thu, 24 Sep 2020 23:13:43 +0000 (19:13 -0400)] 
tests: reflow licence headers for 72 columns

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoFix: schemas/config/3/config.yaml: allow `uuid-field-type` to be `true`
Philippe Proulx [Thu, 24 Sep 2020 21:45:21 +0000 (17:45 -0400)] 
Fix: schemas/config/3/config.yaml: allow `uuid-field-type` to be `true`

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agobarectf/schemas/config/3/config.yaml: `True` -> `true`
Philippe Proulx [Thu, 24 Sep 2020 21:44:41 +0000 (17:44 -0400)] 
barectf/schemas/config/3/config.yaml: `True` -> `true`

It works, but this is not Python.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agobarectf.c.j2: only declare `ts` variable when needed
Philippe Proulx [Thu, 24 Sep 2020 21:28:15 +0000 (17:28 -0400)] 
barectf.c.j2: only declare `ts` variable when needed

This patch changes the `barectf.c.j2` template so that, for the
packet opening, packet closing, and event record header serialization
functions, the `ts` variable is only declared when it's used.

Without this patch, the C compiler can report such a warning:

    warning: unused variable ‘ts’ [-Wunused-variable]

In `barectf.c-macros.j2`, the open_close_func_preamble() macro is
changed to accept the timestamp packet feature in order to check either
the packet beginning or end timestamp field type feature.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agotests/tracing: use test categories
Philippe Proulx [Thu, 24 Sep 2020 20:35:48 +0000 (16:35 -0400)] 
tests/tracing: use test categories

This patch renames all `succeed` directories under `tests/tracing`
to `basic`. All tracing tests must succeed anyway.

In `basic/dynamic-array/of-double.yaml`:

* `basic` is the category.
* `dynamic-array` is the subcategory.
* `of-double.yaml` is the test file.

Support files are now per category: `tests/tracing/support` is moved
to `tests/tracing/support/basic`.

This makes it possible to add tracing test categories which have their
own platform and base YAML trace type object.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agobarectf: add pre-release version information (`barectf.__pre_version__`)
Philippe Proulx [Thu, 24 Sep 2020 20:01:25 +0000 (16:01 -0400)] 
barectf: add pre-release version information (`barectf.__pre_version__`)

This makes it possible to make a `-dev` or `-pre` version for example.

`barectf.__version__` contains the pre-release information.

The generated metadata stream gets a new `tracer_pre` environment entry
set to this value (empty string as of this patch).

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agotests/tracing: add basic structure data field tests
Philippe Proulx [Thu, 24 Sep 2020 18:13:08 +0000 (14:13 -0400)] 
tests/tracing: add basic structure data field tests

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agotests/tracing: add data stream test (two packets)
Philippe Proulx [Thu, 24 Sep 2020 17:55:58 +0000 (13:55 -0400)] 
tests/tracing: add data stream test (two packets)

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agotests/tracing: add basic int., enum., real, and string data field tests
Philippe Proulx [Thu, 24 Sep 2020 17:47:51 +0000 (13:47 -0400)] 
tests/tracing: add basic int., enum., real, and string data field tests

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoconfigs/succeed/**/*.yaml: remove useless YAML document end
Philippe Proulx [Thu, 24 Sep 2020 17:46:47 +0000 (13:46 -0400)] 
configs/succeed/**/*.yaml: remove useless YAML document end

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agodocs: yaml: put static/dynamic array FT obj. C types example in partial
Philippe Proulx [Thu, 24 Sep 2020 17:33:51 +0000 (13:33 -0400)] 
docs: yaml: put static/dynamic array FT obj. C types example in partial

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agodocs: {static,dyn}-array-ft-obj.adoc: use example block
Philippe Proulx [Thu, 24 Sep 2020 17:31:33 +0000 (13:31 -0400)] 
docs: {static,dyn}-array-ft-obj.adoc: use example block

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoFix: YAML: force enumeration FT objects to have at least one mapping
Philippe Proulx [Thu, 24 Sep 2020 17:23:34 +0000 (13:23 -0400)] 
Fix: YAML: force enumeration FT objects to have at least one mapping

As per CTF 1.8.3:

> Enumerations need to contain at least one entry.

Before this patch, ythose were legal:

    class: uenum
    size: 8

    class: uenum
    size: 8
    mappings: {}

    class: uenum
    size: 8
    mappings:
      A: []

CTF consumers would not like the resulting metadata stream. For
example, Babeltrace 2.1.0-rc1 [v1.2.0-3520-g73f74ae1f]:

    09-24 13:26:41.740 80492 80492 E PLUGIN/CTF/META/PARSER yyerror@parser.y:925 At line 109 in metadata stream: syntax error, unexpected CTF_RBRAC: token="}"
    09-24 13:26:41.740 80492 80492 E PLUGIN/CTF/META/DECODER ctf_metadata_decoder_append_content@decoder.c:280 [N/A] Cannot create the metadata AST out of the metadata text: mdec-addr=0x559dd9546a10
    09-24 13:26:41.740 80492 80492 W PLUGIN/SRC.CTF.FS/QUERY support_info_query@query.c:459 cannot append metadata content: metadata-decoder-status=-2
    09-24 13:26:41.741 80492 80492 W LIB/QUERY-EXECUTOR bt_query_executor_query@query-executor.c:231 Component class's "query" method failed: query-exec-addr=0x559dd9548070, cc-addr=0x559dd95233e0, cc-type=SOURCE, cc-name="fs", cc-partial-descr="Read CTF traces from the file sy", cc-is-frozen=0, cc-so-handle-addr=0x559dd9522770, cc-so-handle-path="lib/babeltrace2/plugins/babeltrace-plugin-ctf.so", object="babeltrace.support-info", params-addr=0x559dd9545f10, params-type=MAP, params-element-count=2, log-level=WARNING
    09-24 13:26:41.741 80492 80492 E CLI-CFG-SRC-AUTO-DISC support_info_query_all_sources@autodisc.c:493 babeltrace.support-info query failed.
    09-24 13:26:41.741 80492 80492 E CLI main@babeltrace2.c:2644 Command-line error: retcode=1

    ERROR:    [Babeltrace CLI] (babeltrace2.c:2644)
      Command-line error: retcode=1
    CAUSED BY [Source auto-discovery] (autodisc.c:493)
      babeltrace.support-info query failed.
    CAUSED BY [libbabeltrace2] (query-executor.c:231)
      Component class's "query" method failed: query-exec-addr=0x559dd9548070, cc-addr=0x559dd95233e0, cc-type=SOURCE, cc-name="fs", cc-partial-descr="Read CTF traces from
      the file sy", cc-is-frozen=0, cc-so-handle-addr=0x559dd9522770, cc-so-handle-path="babeltrace2/plugins/babeltrace-plugin-ctf.so",
      object="babeltrace.support-info", params-addr=0x559dd9545f10, params-type=MAP, params-element-count=2, log-level=WARNING

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agobarectf/templates: use `loop.last` instead of hack in `barectf/cgen.py`
Philippe Proulx [Thu, 24 Sep 2020 16:11:08 +0000 (12:11 -0400)] 
barectf/templates: use `loop.last` instead of hack in `barectf/cgen.py`

This patch removes the raw text replacement at the end of
_CodeGen.gen_src() (`barectf/cgen.py`).

Instead, to avoid empty lines before `}`, Jinja 2 templates only
output an empty line it's not the loop's last iteration:

    {% if not loop.last %}{{ '\n' }}{% endif %}

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agotest-platform.h: do not include `barectf.h`: forward-declare context
Philippe Proulx [Thu, 24 Sep 2020 16:09:28 +0000 (12:09 -0400)] 
test-platform.h: do not include `barectf.h`: forward-declare context

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoYAML files: remove empty line after `%YAML 1.2` directive
Philippe Proulx [Thu, 24 Sep 2020 15:41:40 +0000 (11:41 -0400)] 
YAML files: remove empty line after `%YAML 1.2` directive

It's more common not to have one. At least the specification's
examples [1] do not have any.

[1]: https://yaml.org/spec/1.2/spec.html

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agotests/tracing: use a base trace type YAML file
Philippe Proulx [Thu, 24 Sep 2020 15:33:07 +0000 (11:33 -0400)] 
tests/tracing: use a base trace type YAML file

This patch adds `tests/tracing/support/base.yaml` as a base YAML trace
type object for test configuration files to include.

`tests/tracing/conftest.py` is changed to add `tests/tracing/support` to
the barectf inclusion search directories and to only consider YAML files
in `tests/tracing/configs/succeed` (`tests/tracing/support/base.yaml` is
not a test).

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agodocs: example.adoc: use file names as heading titles
Philippe Proulx [Thu, 24 Sep 2020 14:14:35 +0000 (10:14 -0400)] 
docs: example.adoc: use file names as heading titles

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agomodules/platform/pages/example.adoc: add a list of other examples
Philippe Proulx [Thu, 24 Sep 2020 13:59:23 +0000 (09:59 -0400)] 
modules/platform/pages/example.adoc: add a list of other examples

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agodocs: add missing `build` module
Philippe Proulx [Thu, 24 Sep 2020 14:02:20 +0000 (10:02 -0400)] 
docs: add missing `build` module

This was not added because the root `.gitignore` file contained `build/`
(fixed by 4dd70d0 (".gitignore: simplify")).

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years ago.gitignore: simplify
Philippe Proulx [Thu, 24 Sep 2020 14:08:37 +0000 (10:08 -0400)] 
.gitignore: simplify

This patch removes lines from the root `.gitignore` file which were
useless for the barectf project.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agotest-platform.c: write_packet(): use `const size_t`
Philippe Proulx [Thu, 24 Sep 2020 11:32:13 +0000 (07:32 -0400)] 
test-platform.c: write_packet(): use `const size_t`

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agodocs/modules/ROOT/pages/index.adoc: add internal links
Philippe Proulx [Thu, 24 Sep 2020 11:19:04 +0000 (07:19 -0400)] 
docs/modules/ROOT/pages/index.adoc: add internal links

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoDocument barectf 3
Philippe Proulx [Thu, 24 Sep 2020 00:01:30 +0000 (20:01 -0400)] 
Document barectf 3

This patch adds the complete documentation of barectf 3 (upcoming major
release of the project).

The new `docs` directory is an Antora [1] documentation component
version. You can include it in an Antora site.

All the pages are written in AsciiDoc (Asciidoctor version).

Some contents were copied (and adapted) from the barectf wiki [2], but
most of the pages feature brand new text. The logo and diagrams are also
refreshed.

I'm removing the `barectf` CLI tool's manual page (`doc/man`) as it's
now documented in `docs/modules/cli/pages/usage.adoc`. Having the CLI
documented within the whole project's documentation makes it possible to
have critical links to and from other parts of it. This is to the
advantage of the reader.

[1]: https://antora.org/
[2]: https://github.com/efficios/barectf/wiki

3 years agobarectf_platform_linux_fs_init(): accept DS file path, not trace dir.
Philippe Proulx [Thu, 24 Sep 2020 02:45:24 +0000 (22:45 -0400)] 
barectf_platform_linux_fs_init(): accept DS file path, not trace dir.

This patch changes the Linux FS platform's
barectf_platform_linux_fs_init() function so that it accepts the data
stream file path instead of its trace directory.

This makes it possible to initialize many Linux FS platform contexts for
the same trace, each one targeting a distinct data stream file.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agobarectf-platform-linux-fs.c: write_packet(): use `const size_t`
Philippe Proulx [Thu, 24 Sep 2020 02:37:13 +0000 (22:37 -0400)] 
barectf-platform-linux-fs.c: write_packet(): use `const size_t`

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agobarectf-platform-linux-fs.c: rename missing `ctx` -> `platform_ctx`
Philippe Proulx [Thu, 24 Sep 2020 02:36:38 +0000 (22:36 -0400)] 
barectf-platform-linux-fs.c: rename missing `ctx` -> `platform_ctx`

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agopoetry.lock: update
Philippe Proulx [Thu, 24 Sep 2020 02:25:23 +0000 (22:25 -0400)] 
poetry.lock: update

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agopyproject.toml: update description
Philippe Proulx [Thu, 24 Sep 2020 02:24:21 +0000 (22:24 -0400)] 
pyproject.toml: update description

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agobarectf/templates/c: name `void *` context parameters `vctx`
Philippe Proulx [Wed, 23 Sep 2020 23:59:49 +0000 (19:59 -0400)] 
barectf/templates/c: name `void *` context parameters `vctx`

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agobarectf.h.j2: add barectf_packet_buf_addr()
Philippe Proulx [Wed, 23 Sep 2020 22:20:07 +0000 (18:20 -0400)] 
barectf.h.j2: add barectf_packet_buf_addr()

barectf_packet_buf_addr() is an alias of barectf_packet_buf().

This is more in line with the barectf_packet_set_buf() function which
sets both the buffer's address and size.

This change helps document the platform API.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agobarectf.h.j2: add barectf_discarded_event_records_count()
Philippe Proulx [Wed, 23 Sep 2020 22:18:08 +0000 (18:18 -0400)] 
barectf.h.j2: add barectf_discarded_event_records_count()

barectf_discarded_event_records_count() is an alias of
barectf_packet_events_discarded().

The count of discarded event records is not related to the current
packet; it's a data stream variable.

This change helps document the platform API.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agobarectf.h.j2: rename "clock callbacks" -> "clock source callbacks"
Philippe Proulx [Wed, 23 Sep 2020 22:17:28 +0000 (18:17 -0400)] 
barectf.h.j2: rename "clock callbacks" -> "clock source callbacks"

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agobarectf/templates/c: rename "back-end" -> "back end"
Philippe Proulx [Wed, 23 Sep 2020 22:17:07 +0000 (18:17 -0400)] 
barectf/templates/c: rename "back-end" -> "back end"

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoStandardize root field type prefixes
Philippe Proulx [Wed, 23 Sep 2020 14:51:05 +0000 (10:51 -0400)] 
Standardize root field type prefixes

This patch changes `cgen.py` and what depends on it so that:

* `_RootFtPrefixes` attribute names always begin with `P` (packet) or
  `ER` (event record).

* `_RootFtPrefixes` attribute values for event record prefixes do not
  begin with `er`.

  The C source context where this is used indicates that it's an event
  record field, so `er` is redundant.

  This also makes the documentation easier to understand.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoAdd missing `serialize-write-timestamp-statements.j2` file
Philippe Proulx [Mon, 21 Sep 2020 23:29:14 +0000 (19:29 -0400)] 
Add missing `serialize-write-timestamp-statements.j2` file

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoEnable discarded event records snapshot FT DST feature by default
Philippe Proulx [Mon, 21 Sep 2020 23:26:49 +0000 (19:26 -0400)] 
Enable discarded event records snapshot FT DST feature by default

This patch changes `config.py` (API) and the v3 YAML parser to make
the discarded event records snapshot field type (data stream type)
feature enabled by default.

This feature is nice to have, only adds an integer field to each packet,
and doesn't require anything from the user.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoRename "time" -> "timestamp" (terminology)
Philippe Proulx [Mon, 21 Sep 2020 21:04:36 +0000 (17:04 -0400)] 
Rename "time" -> "timestamp" (terminology)

This patch renames the "time" concept to "timestamp" throughout.

The term "timestamp" is better to describe what used to be named "time",
for example a packet's beginning and end timestamps, and an event
record's timestamp.

"Time" has many definitions, one of which is duration, whereas the
only definition of "timestamp" in Antidote 10 is:

> a printed or stamped mark indicating a time or date of an event

which is pretty accurate.

Which is also why the timestamp members are named `timestamp_begin`,
`timestamp_end`, and `timestamp` in CTF 1.8.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoRename "target byte order" -> "native byte order"
Philippe Proulx [Fri, 18 Sep 2020 19:32:20 +0000 (15:32 -0400)] 
Rename "target byte order" -> "native byte order"

Going back to the CTF terminology.

From the trace type's perspective, I believe this term is better. I
think it's also easier to understand when reading the documentation.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoconfig.py: move target byte order property from config. to trace type
Philippe Proulx [Fri, 18 Sep 2020 19:27:12 +0000 (15:27 -0400)] 
config.py: move target byte order property from config. to trace type

This property is part of the trace type, as it's related to the byte
order of bit array field types which are all part of the trace type.

Also it's a CTF concept, not a barectf concept.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agopoetry.lock: update
Philippe Proulx [Fri, 18 Sep 2020 17:01:11 +0000 (13:01 -0400)] 
poetry.lock: update

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years ago.gitignore: ignore generated HTML READMEs
Philippe Proulx [Fri, 18 Sep 2020 17:00:44 +0000 (13:00 -0400)] 
.gitignore: ignore generated HTML READMEs

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoUse YAML 1.2 throughout
Philippe Proulx [Fri, 18 Sep 2020 16:56:41 +0000 (12:56 -0400)] 
Use YAML 1.2 throughout

The `yes` and `no` boolean values do not exist in YAML 1.2 [1].

Change all of them for `true` and `false`.

Also, in `tests/tracing/configs` and in
`examples/linux-fs-simple/config.yaml`, add the explicit `%YAML 1.2`
directive to indicate that it's a YAML 1.2 document.

[1]: https://yaml.org/spec/1.2/spec.html#id2805071

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoRemove `CHANGELOG.md`
Philippe Proulx [Thu, 17 Sep 2020 14:42:10 +0000 (10:42 -0400)] 
Remove `CHANGELOG.md`

This is the change log of barectf 2.

For barectf 3, the change log will be part of the documentation.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agobarectf-tracepoint.h: improve quality
Philippe Proulx [Thu, 17 Sep 2020 13:13:18 +0000 (09:13 -0400)] 
barectf-tracepoint.h: improve quality

Changes:

* Reflow header comment to fit 72 columns.

* Capitalize comments.

* Use updated `barectf.h` definition names (`_BARECTF_IDENTIFIER_PREFIX`
  and `_BARECTF_DEFAULT_DATA_STREAM_TYPE_NAME`).

* Check for `BARECTF_TRACEPOINT_DATA_STREAM_TYPE_NAME` as an alternative
  to `BARECTF_TRACEPOINT_STREAM` (for consistency).

* Rework error messages.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agobarectf.h.j2: use more accurate definition names
Philippe Proulx [Thu, 17 Sep 2020 13:12:06 +0000 (09:12 -0400)] 
barectf.h.j2: use more accurate definition names

Leaving the old definitions to avoid breaking anything.

The updated names are:

`_BARECTF_PREFIX`:
    `_BARECTF_IDENTIFIER_PREFIX`

`_BARECTF_DEFAULT_STREAM`:
    `_BARECTF_DEFAULT_DATA_STREAM_TYPE_NAME`

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoexamples/linux-fs-simple: use `trace` as trace directory, not `ctf`
Philippe Proulx [Thu, 17 Sep 2020 04:09:02 +0000 (00:09 -0400)] 
examples/linux-fs-simple: use `trace` as trace directory, not `ctf`

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoexamples/linux-fs-simple: convert README to Asciidoctor and improve it
Philippe Proulx [Thu, 17 Sep 2020 04:05:44 +0000 (00:05 -0400)] 
examples/linux-fs-simple: convert README to Asciidoctor and improve it

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agolinux-fs-simple/config.yaml: convert to v3 format
Philippe Proulx [Thu, 17 Sep 2020 03:59:58 +0000 (23:59 -0400)] 
linux-fs-simple/config.yaml: convert to v3 format

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agolinux-fs-simple.c: improve quality
Philippe Proulx [Thu, 17 Sep 2020 03:58:27 +0000 (23:58 -0400)] 
linux-fs-simple.c: improve quality

Changes:

* Remove unneeded included headers.
* Remove unneeded TO_VOID_PTR() macro.
* Use `const` where possible.
* Use single return points.
* Capitalize comments.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agolinux-fs-simple/Makefile: remove nonexistent `view` from `.PHONY`
Philippe Proulx [Thu, 17 Sep 2020 03:57:22 +0000 (23:57 -0400)] 
linux-fs-simple/Makefile: remove nonexistent `view` from `.PHONY`

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agobarectf-platform-linux-fs.c: improve quality
Philippe Proulx [Thu, 17 Sep 2020 01:19:39 +0000 (21:19 -0400)] 
barectf-platform-linux-fs.c: improve quality

Changes:

* Remove unneeded included headers.
* Remove unneeded TO_VOID_PTR() macro.
* Use `const` where possible.
* Use single return points.
* Rename platform context variables to `platform_ctx`.
* Capitalize comments.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agobarectf-platform-linux-fs.*: remove header titles
Philippe Proulx [Thu, 17 Sep 2020 01:08:36 +0000 (21:08 -0400)] 
barectf-platform-linux-fs.*: remove header titles

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoexamples/linux-fs-simple, platforms/linux-fs: use double quotes to include
Philippe Proulx [Thu, 17 Sep 2020 01:05:32 +0000 (21:05 -0400)] 
examples/linux-fs-simple, platforms/linux-fs: use double quotes to include

    #include "barectf.h"

is more permissive than

    #include <barectf.h>

You don't need to add `-I.` to search the same directory.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agobarectf-platform-linux-fs.*: update copyright years
Philippe Proulx [Thu, 17 Sep 2020 01:00:44 +0000 (21:00 -0400)] 
barectf-platform-linux-fs.*: update copyright years

Also reflow the license headers to fit 72 columns.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agobarectf-platform-linux-fs.h: remove function documentation
Philippe Proulx [Thu, 17 Sep 2020 01:00:12 +0000 (21:00 -0400)] 
barectf-platform-linux-fs.h: remove function documentation

This is now in the local `README.adoc` file.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agobarectf-platform-linux-fs.c: use `CLOCK_REALTIME`
Philippe Proulx [Thu, 17 Sep 2020 00:57:52 +0000 (20:57 -0400)] 
barectf-platform-linux-fs.c: use `CLOCK_REALTIME`

Although this clock source can go back, the result is more friendly than
using `CLOCK_MONOTONIC` and having to set the clock type's offset
manually or getting invalid event record times.

I believe this is acceptable considering the demonstration purpose of
this platform.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoplatforms/linux-fs: remove `README.md`, write a better `README.adoc`
Philippe Proulx [Thu, 17 Sep 2020 00:57:16 +0000 (20:57 -0400)] 
platforms/linux-fs: remove `README.md`, write a better `README.adoc`

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoMove `doc/examples` to `examples`
Philippe Proulx [Thu, 17 Sep 2020 00:09:49 +0000 (20:09 -0400)] 
Move `doc/examples` to `examples`

I'm planning to remove the `doc` directory, writing the documentation
within the `docs` directory.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoRemove Parallella platform and examples
Philippe Proulx [Thu, 17 Sep 2020 00:05:49 +0000 (20:05 -0400)] 
Remove Parallella platform and examples

It's very hard to test and to integrate in a CI.

Also, the Epiphany repositories are not updated since 3-4 years [1].

[1]: https://github.com/adapteva

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoRename "event type" -> "event record type", "stream type" -> "data stream type"
Philippe Proulx [Wed, 16 Sep 2020 23:36:59 +0000 (19:36 -0400)] 
Rename "event type" -> "event record type", "stream type" -> "data stream type"

This matches an eventual CTF 2 terminology and makes writing the barectf
documentation easier, as a data stream type describes data streams and
an event record type describes event records. An event record is what
the tracer records for an occurring event.

Throughout the code, for names, variables, and file names:

* `dst` means "data stream type".
* `ds` means "data stream".
* `ert` means "event record type".
* `er` means "event record".

The v3 YAML schemas are modified accordingly.

This patch also renames "discarded events counter" to "discarded event
records counter snapshot", as this field is a snapshot of the per-data
stream counter.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoAdd dynamic array tracing tests
Philippe Proulx [Thu, 10 Sep 2020 21:32:50 +0000 (17:32 -0400)] 
Add dynamic array tracing tests

The new tests are modified copies of static array tracing tests as a
dynamic array field can contain the same fields as a static array field.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoRemoved unused `tests/conftest.py`
Philippe Proulx [Thu, 10 Sep 2020 20:54:58 +0000 (16:54 -0400)] 
Removed unused `tests/conftest.py`

Used to contain the yaml_cfg_path() fixture; not needed anymore since
b1c5cbc ("tests/config/yaml: use pytest_collect_file() hook for YAML
files") and 816fefd ("tests/tracing: use pytest_collect_file() hook for
YAML files").

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agotests/tracing/support/test-platform.c: clear buffer at every packet opening
Philippe Proulx [Thu, 10 Sep 2020 19:01:56 +0000 (15:01 -0400)] 
tests/tracing/support/test-platform.c: clear buffer at every packet opening

This ensures that there's no garbage data left in the buffer between
packets.

It's not triggering any failure currently because all the tests in
`tests/tracing` produce a single packet.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agotracing/src/succeed/static-array: update copyright notice's year
Philippe Proulx [Thu, 10 Sep 2020 19:01:36 +0000 (15:01 -0400)] 
tracing/src/succeed/static-array: update copyright notice's year

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agosrc/succeed/static-array: add missing `const` qualifiers
Philippe Proulx [Thu, 10 Sep 2020 18:58:14 +0000 (14:58 -0400)] 
src/succeed/static-array: add missing `const` qualifiers

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agotests/tracing: use pytest_collect_file() hook for YAML files
Philippe Proulx [Thu, 10 Sep 2020 18:41:12 +0000 (14:41 -0400)] 
tests/tracing: use pytest_collect_file() hook for YAML files

This patch applies the same strategy as b1c5cbc ("tests/config/yaml: use
pytest_collect_file() hook for YAML files") to `tests/tracing`.

This patch changes `tests/tracing/conftest.py` so that it implements a
pytest_collect_file() Pytest hook to create Pytest file and item objects
for each barectf YAML configuration file found in the `configs`
directory. Thanks to the base name of this YAML file,
pytest_collect_file() automatically finds the corresponding
test-specific C source and expectation files.

This makes is possible to remove `test_succeed_static_array.py` and
avoid duplication and mismatches between existing YAML files and
available test functions.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agotests/config/yaml: use pytest_collect_file() hook for YAML files
Philippe Proulx [Thu, 10 Sep 2020 04:06:41 +0000 (00:06 -0400)] 
tests/config/yaml: use pytest_collect_file() hook for YAML files

This patch changes `tests/config/yaml/conftest.py` so that it implements
a pytest_collect_file() Pytest hook to create Pytest file and item
objects for each failing barectf YAML configuration file found.

This makes is possible to remove all `test_fail_*.py` files and avoid
duplication and mismatches between existing YAML files and available
test functions.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoconfig.py, tsdl182gen.py: fix Mypy/Pylint errors
Philippe Proulx [Thu, 10 Sep 2020 01:36:54 +0000 (21:36 -0400)] 
config.py, tsdl182gen.py: fix Mypy/Pylint errors

3 years agoAdd static array tracing tests
Philippe Proulx [Wed, 9 Sep 2020 23:35:11 +0000 (19:35 -0400)] 
Add static array tracing tests

This patch adds static array tracing tests, also adding the testing
infrastructure for other such tests.

In `tests/tracing`, the test functions of `test_succeed_static_array.py`
use the tracing_succeed_test() fixture as found in
`tests/tracing/conftest.py`.

tracing_succeed_test() does the following:

 1. Creates a temporary directory with the tmpdir() fixture.

 2. Automatically finds the paths, based on the test's module and
    function names, of:

    * A YAML configuration file.

    * A test-specific C source file.

    * Two expectation files (one for the metadata stream and one for the
      data stream).

 3. Creates a barectf configuration from the YAML file found in 2.

 4. Generates the C code files using the barectf configuration of 3.,
    writing the files to the temporary directory of 1.

 5. Generates the metadata stream using the barectf configuration of 3.,
    stripping some variable version and generation date lines.

    This step does not write any file to the file system.

 6. Copies the files in the `tests/tracing/support` directory to the
    temporary directory of 1.

    `test-platform.c` and `test-platform.h` form the barectf platform
    for all the tracing tests.

 7. Copies the test-specific C source file found in 2. as `test.c` to
    the temporary directory of 1.

 8. Executes `make` in the temporary directory of 1.

 9. Executes `./test` in the temporary directory of 1.

10. Reads the produced data stream file (`stream` in the temporary
    directory of 1.) and compares it with the data stream expectation
    file found in 2.

11. Compares the metadata stream contents of 5. with the metadata stream
    expectation file found in 2.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoSimplify current tests
Philippe Proulx [Wed, 9 Sep 2020 22:02:17 +0000 (18:02 -0400)] 
Simplify current tests

This patch:

* Adds the global yaml_cfg_path() fixture which returns the path to an
  hypothetical barectf YAML configuration file based on the test's
  module file and function names.

* Updates the config_fail_test() fixture to only use yaml_cfg_path()

* Updates all the test functions to only use config_fail_test() and call
  it without parameters.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoFix: include/3/stdreal.yaml: `align` -> `alignment`
Philippe Proulx [Thu, 10 Sep 2020 01:14:22 +0000 (21:14 -0400)] 
Fix: include/3/stdreal.yaml: `align` -> `alignment`

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoAdd user dynamic array field support
Philippe Proulx [Wed, 9 Sep 2020 20:50:51 +0000 (16:50 -0400)] 
Add user dynamic array field support

This patch adds support for user dynamic array fields.

The element field type of a user dynamic array field type can be any of
the following:

* Bit array field type.
* String field type.
* Static array field type.

Note that it _cannot_ be another dynamic array field type.

The new `barectf.DynamicArrayFieldType` represents a dynamic array field
type. Its constructor accepts a length field type. As of this version,
this length field type must be within the same immediate structure field
type and before it.

The YAML ways to specify a dynamic array field type are:

barectf 2 configuration:
    class: array
    length: dynamic
    element-type:
      ...

barectf 3 configuration:
    class: dynamic-array
    element-field-type:
      ...

Note that in YAML, you don't specify the length field type: the parser
automatically creates a 32-bit, byte-aligned unsigned integer field type
before which, for a dynamic array field type named `a`, has the name
`__a_len`. This also becomes part of the corresponding tracing function
parameter's name.

In the future, I can add a `length-field-type` property to a barectf 3
YAML dynamic array field type to point to an anterior unsigned integer
field type using some kind of reference, for example:

    class: structure
    members:
      - my_length: uint16
      - my_array:
          field-type:
            class: dynamic-array
            length-field-type-name: my_length
            element-field-type:
              ...

This would make it possible for more than one dynamic array fields
to use the same length field, for example:

    class: structure
    members:
      - my_length: uint16
      - my_uint_array:
          field-type:
            class: dynamic-array
            length-field-type-name: my_length
            element-field-type: uint8
      - my_string_array:
          field-type:
            class: dynamic-array
            length-field-type-name: my_length
            element-field-type: string

The constructor of `barectf.StructureFieldType` calls
_set_dyn_array_ft_length_ft_member_names() which, for each member having
a dynamic array field type:

* Sets its `_length_ft_member_name` attribute to the name of the
  structure field type member having its length field type.

* Sets its length field type's `_is_len` attribute to `True`.

I consider those as hacks, but considering the current constraints, it
makes parts of the (barectf) code easier to implement and maintain.

The C code generation approach is similar to the static array field
case. The `*-write-static-array-statements.j2` templates are renamed to
`*-write-array-statements.j2` and use the `length_src` variable as the
loop's length's value. `*-write-static-array-statements.j2` and the new
`*-write-dynamic-array-statements.j2` set `length_src` before including
`*-write-array-statements.j2`.

To make things easier, barectf now systematically generates alignment
statements if the alignment is greater than one. This could be optimized
again in the future, considering arrays this time. The
`_WriteOp.offset_in_byte` optimization still exists, although as soon as
it's not statically known, it's now `None` and
`serialize-write-bit-array-statements.j2` uses the safe, dynamic
`ctx->at % 8` expression. try_create_align_op() does this, more or less:

    If `self._offset_in_byte` is not currently known and the requested
    alignment is 8:
      Set `self._offset_in_byte` to 0.
    Else:
      If we're currently within an array operation:
        Reset `self._offset_in_byte`.
      Else:
        If `self._offset_in_byte` is currently known:
          Align `self._offset_in_byte` with the requested alignment.

This ensures that each array field's element is aligned before being
written.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoconfig.py: UnsignedIntegerFieldType.__init__(): forward `**kwargs` too
Philippe Proulx [Wed, 9 Sep 2020 20:43:41 +0000 (16:43 -0400)] 
config.py: UnsignedIntegerFieldType.__init__(): forward `**kwargs` too

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoAdd user static array field support (with recursion)
Philippe Proulx [Wed, 9 Sep 2020 15:00:12 +0000 (11:00 -0400)] 
Add user static array field support (with recursion)

This patch adds support for user static array fields.

The element field type of a user static array field type can be any of
the following:

* Bit array field type.
* String field type.
* Static array field type.

The generated serializing C code does not assume anything about the
memory layout of a user array: it iterates each item to serialize them
individually.

For example, consider the following TSDL field type:

    class: static-array
    length: 3
    element-field-type:
      class: unsigned-integer
      size: 16

The tracing function's parameter's C type for the corresponding field is
`const uint16_t *`. Assuming the parameter's name is `a`, the
serialization function accesses `a[0]`, `a[1]`, and `a[2]`; it doesn't
copy large blocks of memory as is. This is because we don't know the
target architecture's alignment constraints and general memory layout.

For:

    class: static-array
    length: 3
    element-field-type:
      class: string

the parameter's C type is `const char * const *`.

Note that a pointed C type is always `const`, so the `barectf.h` user
might need to cast accordingly if her own C types miss such `const`
qualifiers. Here's another example:

    class: static-array
    length: 2
    element-field-type:
      class: static-array
      length: 3
      element-field-type:
        class: unsigned-integer
        size: 8

This becomes `const uint8_t * const *`.

As of this patch, a tracing function uses `uint32_t` as the loop index
type. I believe this will be enough for barectf's use cases. It could
(should) also be based on the static array field type's length.

Each loop is isolated within its own C scope. The loop index variable
names are `i`, then `j`, then `k`, then `k1`, then `k2`, and so on.

Notable changes
===============
`cgen.py`:
    * Add a level property to operation objects.

      This is the static array nesting level.

    * _OpBuilder._build_for_ft(): handle user static array field types.

      A user static array field type leads to an "align" operation
      (possibly) and its element field type's operation, all within a
      compound operation.

      The name of the element field type's operation is the C array
      subscript with the right index variable name, for example `[i]`.

      The packet header's UUID field type still has its special case.

    * Add _loop_var_name() function which returns the name of a loop
      index variable name based on a level (0 is `i`, 1 is `j`, and so
      on).

    * Add general template filter `loop_var_name` which is
      _loop_var_name().

    * Add general template filter `op_src_var_name` which returns an
      operation's source variable name.

      This used to be the op_src() macro in `c/common.j2`, but with
      array subscript names, it's too ugly for the Jinja 2 language.

    * _CodeGen._ft_c_type(): handle static array field types (return a
      `_PointerCType` object).

`config_parse_v3.py`:
    Accept user static array field types.

Existing templates:
    Remove op_src(); use the `op_src_var_name` filter instead.

`serialize-write-static-array-statements.j2`,
`size-write-static-array-statements.j2`:
    New templates to serialize and compute the size of static array
    fields.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoFix: config.py: implement _ArrayFieldType.size_is_dynamic()
Philippe Proulx [Wed, 9 Sep 2020 14:15:25 +0000 (10:15 -0400)] 
Fix: config.py: implement _ArrayFieldType.size_is_dynamic()

An array field type's size is dynamic if its element field type is.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoserialize-write-bit-array-statements.j2: increment position within scope
Philippe Proulx [Wed, 9 Sep 2020 01:52:42 +0000 (21:52 -0400)] 
serialize-write-bit-array-statements.j2: increment position within scope

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agocgen.py: use C type classes for _CodeGen._ft_c_type()
Philippe Proulx [Wed, 9 Sep 2020 01:21:33 +0000 (21:21 -0400)] 
cgen.py: use C type classes for _CodeGen._ft_c_type()

This patch introduces new classes to represent C types in `cgen.py`.

The C type class hierarchy is:

    _CType
      _ArithCType
      _PointerCType

A `_PointerCType` object contains another `_CType` object.

You can get the string representation of a C type object with its
__str__() method.

A C type constructor's `is_const` parameter controls whether or not the
_value_ is const. For example:

`const char *`:
    `_PointerCType` containing a const `_ArithCType`.

`const char * const`:
    Const `_PointerCType` containing a const `_ArithCType`.

_CodeGen._ft_c_type() now returns a `_CType` object instead of a string.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoFix: barectf/include/3: remove `byte-order` properties
Philippe Proulx [Tue, 8 Sep 2020 23:52:51 +0000 (19:52 -0400)] 
Fix: barectf/include/3: remove `byte-order` properties

Removed in 4c91e76 ("config.py: remove bit array field type's byte order
property"), so this should not be here.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agoFix: size-write-struct-statements.j2: use `ev_type`, not `event_type`
Philippe Proulx [Tue, 8 Sep 2020 20:21:39 +0000 (16:21 -0400)] 
Fix: size-write-struct-statements.j2: use `ev_type`, not `event_type`

3 years agoconfig_parse_v2.py: fix typing issue
Philippe Proulx [Tue, 8 Sep 2020 20:19:02 +0000 (16:19 -0400)] 
config_parse_v2.py: fix typing issue

Reported by mypy 0.782.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agostruct-ft.j2: use a single line for array indices
Philippe Proulx [Tue, 8 Sep 2020 20:15:31 +0000 (16:15 -0400)] 
struct-ft.j2: use a single line for array indices

Still readable and less weird in my opinion.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agocgen.py, templates: use new `_CompoundOp` for structure fields
Philippe Proulx [Tue, 8 Sep 2020 20:05:42 +0000 (16:05 -0400)] 
cgen.py, templates: use new `_CompoundOp` for structure fields

This patch adds the `_CompoundOp` class which inherits `_Op`. It also
makes `_AlignOp` and `_WriteOp` inherit a new `_LeadOf` class. The final
operation class hierarchy is:

    _Op
      _CompoundOp
      _LeafOp
        _AlignOp
        _WriteOp

A compound operation is a simple container of suboperations (compound or
leaf). It is expected that a compound field type leads to a compound
operation.

As of this version, the only "real" compound field type is the structure
field type.

`_OpsBuilder` becomes `_OpBuilder` and does not accumulate operations
anymore: it still has a state, but its build_for_root_ft() method
returns a `_CompoundOp` object for a given root structure field type.

The returned compound operation can contain an "align" operation for the
structure field itself as its first suboperation.

Because an `_OpBuilder` doesn't accumulate operations anymore, there's
no need to copy operations anymore.

For a structure field type, _OpBuilder._build_for_ft() returns a single
compound operation having the new serialization and size templates
`serialize-write-struct-statements.j2` and
`size-write-struct-statements.j2`. Those templates contain a C comment
and a simple loop to render the appropriate template for each
suboperation, forwarding the `stream_type` and `ev_type` context
variables.

`barectf.c.j2` is changed to render a single template for any compound
operation. This removes many loops.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
3 years agopoetry.lock: update
Philippe Proulx [Tue, 8 Sep 2020 17:05:48 +0000 (13:05 -0400)] 
poetry.lock: update

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
This page took 0.044198 seconds and 4 git commands to generate.