From 79750125e3ef4107de7aa01829270517954e81e0 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Mon, 14 Mar 2016 21:14:27 -0400 Subject: [PATCH] Add a few provided includable config files Signed-off-by: Philippe Proulx --- barectf/cli.py | 4 + barectf/config.py | 1 - barectf/include/lttng-ust-log-levels.yaml | 23 ++++ barectf/include/stdfloat.yaml | 19 ++++ barectf/include/stdint.yaml | 126 ++++++++++++++++++++++ barectf/include/stdmisc.yaml | 21 ++++ barectf/include/trace-basic.yaml | 24 +++++ setup.py | 5 + 8 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 barectf/include/lttng-ust-log-levels.yaml create mode 100644 barectf/include/stdfloat.yaml create mode 100644 barectf/include/stdint.yaml create mode 100644 barectf/include/stdmisc.yaml create mode 100644 barectf/include/trace-basic.yaml diff --git a/barectf/cli.py b/barectf/cli.py index cd84fbe..00a1ce9 100644 --- a/barectf/cli.py +++ b/barectf/cli.py @@ -20,6 +20,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. +from pkg_resources import resource_filename from termcolor import cprint, colored import barectf.tsdl182gen import barectf.config @@ -106,6 +107,9 @@ def _parse_args(): if not os.path.isfile(args.config): _perror('"{}" is not an existing file'.format(args.config)) + # append current working directory and provided include directory + args.include_dir += [os.getcwd(), resource_filename(__name__, 'include')] + return args diff --git a/barectf/config.py b/barectf/config.py index 2bca56d..2e3fee5 100644 --- a/barectf/config.py +++ b/barectf/config.py @@ -1170,7 +1170,6 @@ class _YamlConfigParser: metadata.Variant: self._create_variant, } self._include_dirs = include_dirs - self._include_dirs.append(os.getcwd()) self._ignore_include_not_found = ignore_include_not_found self._dump_config = dump_config diff --git a/barectf/include/lttng-ust-log-levels.yaml b/barectf/include/lttng-ust-log-levels.yaml new file mode 100644 index 0000000..76d2544 --- /dev/null +++ b/barectf/include/lttng-ust-log-levels.yaml @@ -0,0 +1,23 @@ +# Include this in the metadata object to have access to the LTTng-UST +# log level values by name. +# +# Note that the values from 0 to 7 are compatible with syslog log +# levels, although the debug severity in syslog is named DEBUG_SYSTEM +# here. + +$log-levels: + EMERG: 0 + ALERT: 1 + CRIT: 2 + ERR: 3 + WARNING: 4 + NOTICE: 5 + INFO: 6 + DEBUG_SYSTEM: 7 + DEBUG_PROGRAM: 8 + DEBUG_PROCESS: 9 + DEBUG_MODULE: 10 + DEBUG_UNIT: 11 + DEBUG_FUNCTION: 12 + DEBUG_LINE: 13 + DEBUG: 14 diff --git a/barectf/include/stdfloat.yaml b/barectf/include/stdfloat.yaml new file mode 100644 index 0000000..dfd2180 --- /dev/null +++ b/barectf/include/stdfloat.yaml @@ -0,0 +1,19 @@ +# Include this in the metadata object of your configuration to have +# access to basic floating point number type aliases. + +type-aliases: + # IEEE 754-2008 binary32 (single-precision) + float: + class: floating-point + size: + exp: 8 + mant: 24 + align: 32 + + # IEEE 754-2008 binary64 (double-precision) + double: + class: floating-point + size: + exp: 11 + mant: 53 + align: 64 diff --git a/barectf/include/stdint.yaml b/barectf/include/stdint.yaml new file mode 100644 index 0000000..2e94bcf --- /dev/null +++ b/barectf/include/stdint.yaml @@ -0,0 +1,126 @@ +# Include this in the metadata object of your configuratio +# access to basic integer type aliases. + +type-aliases: + # 8-bit unsigned integer, 8-bit aligned + uint8: + class: int + size: 8 + align: 8 + byte: uint8 + + # 8-bit signed integer, 8-bit aligned + int8: + $inherit: uint8 + signed: true + + # 16-bit unsigned integer, 16-bit aligned + uint16: + class: int + size: 16 + align: 16 + word: uint16 + + # 16-bit signed integer, 16-bit aligned + int16: + $inherit: uint8 + signed: true + + # 32-bit unsigned integer, 32-bit aligned + uint32: + class: int + size: 32 + align: 32 + dword: uint32 + + # 32-bit signed integer, 32-bit aligned + int32: + $inherit: uint8 + signed: true + + # 64-bit unsigned integer, 64-bit aligned + uint64: + class: int + size: 64 + align: 64 + + # 64-bit signed integer, 64-bit aligned + int64: + $inherit: uint8 + signed: true + + # byte-packed 8-bit unsigned integer + byte-packed-uint8: uint8 + + # byte-packed 8-bit signed integer + byte-packed-int8: int8 + + # byte-packed 16-bit unsigned integer + byte-packed-uint16: + $inherit: uint16 + align: 8 + + # byte-packed 16-bit signed integer + byte-packed-int16: + $inherit: int16 + align: 8 + + # byte-packed 32-bit unsigned integer + byte-packed-uint32: + $inherit: uint32 + align: 8 + + # byte-packed 32-bit signed integer + byte-packed-int32: + $inherit: int32 + align: 8 + + # byte-packed 64-bit unsigned integer + byte-packed-uint64: + $inherit: uint64 + align: 8 + + # byte-packed 64-bit signed integer + byte-packed-int64: + $inherit: int64 + align: 8 + + # byte-packed 8-bit unsigned integer + bit-packed-uint8: + $inherit: uint8 + align: 1 + + # bit-packed 8-bit signed integer + bit-packed-int8: + $inherit: int8 + align: 1 + + # bit-packed 16-bit unsigned integer + bit-packed-uint16: + $inherit: uint16 + align: 1 + + # bit-packed 16-bit signed integer + bit-packed-int16: + $inherit: int16 + align: 1 + + # bit-packed 32-bit unsigned integer + bit-packed-uint32: + $inherit: uint32 + align: 1 + + # bit-packed 32-bit signed integer + bit-packed-int32: + $inherit: int32 + align: 1 + + # bit-packed 64-bit unsigned integer + bit-packed-uint64: + $inherit: uint64 + align: 1 + + # bit-packed 64-bit signed integer + bit-packed-int64: + $inherit: int64 + align: 1 diff --git a/barectf/include/stdmisc.yaml b/barectf/include/stdmisc.yaml new file mode 100644 index 0000000..4177aa1 --- /dev/null +++ b/barectf/include/stdmisc.yaml @@ -0,0 +1,21 @@ +# Include this in the metadata object of your configuration to have +# access to various useful type aliases. + +type-aliases: + # UUID array + uuid: + class: array + length: 16 + element-type: + class: int + size: 8 + + # CTF magic number type + ctf-magic: + class: int + size: 32 + align: 32 + + # a simple string + string: + class: string diff --git a/barectf/include/trace-basic.yaml b/barectf/include/trace-basic.yaml new file mode 100644 index 0000000..20c2a2e --- /dev/null +++ b/barectf/include/trace-basic.yaml @@ -0,0 +1,24 @@ +# Include this in the trace object of your configuration to get a +# default, basic trace object with a little-endian byte order. The +# packet header type contains the 32-bit magic number, followed by the +# UUID, followed by an 8-bit stream ID. The trace's UUID is +# automatically generated by barectf. + +byte-order: le +uuid: auto +packet-header-type: + class: struct + fields: + magic: + class: int + size: 32 + align: 32 + uuid: + class: array + length: 16 + element-type: + class: int + size: 8 + stream_id: + class: int + size: 8 diff --git a/setup.py b/setup.py index 086793c..6fa7894 100755 --- a/setup.py +++ b/setup.py @@ -52,6 +52,11 @@ setup(name='barectf', packages=[ 'barectf', ], + package_data={ + 'barectf': [ + 'include/*.yaml', + ], + }, install_requires=[ 'termcolor', 'pyyaml', -- 2.34.1