Francis Deslauriers [Fri, 22 Apr 2022 20:47:55 +0000 (16:47 -0400)]
src/cpp-common: add `LogCfg` class
`LogCfg` is a class to carry around the logging information used by
`BT_LOG*()` macros in the in-tree plugins.
Philippe added:
* Class comment.
* Setting other members when possible (for example, `_mSelfComp` when
using the self message iterator constructor).
* Use references instead of pointers in constructors because they can't
be `nullptr`, making it possible to remove some assertions.
* Component class member (because the libbabeltrace2 API has nothing
to get a self component class from a self component) and
compClsName() method.
compClsName() is always available when using the self message
iterator, component, or component class constructor.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ic6980a2bcf74f8b270b0a108efc79f25f0e65d8d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7936
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10808
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Thu, 17 Feb 2022 04:10:29 +0000 (23:10 -0500)]
lib: adjust son dev/non-dev precondition assertions in field-class.c
I found some functions using BT_ASSERT_PRE_DEV_FC_NON_NULL followed by
either BT_ASSERT_PRE_FC_HAS_TYPE or BT_ASSERT_PRE_FC_IS_STRUCT (i.e. a
dev followed by a non-dev). This seems illogical to me. Either the
function is considered "fast path" and we use the dev versions, either
it's not "fast path" and we use the non-dev versions.
Change a few assertions to be dev. If some of these functions aren't
actually considered fast path, then I think we should switch the
BT_ASSERT_PRE_DEV_FC_NON_NULLs to be non-dev.
Change-Id: I4f0c1cb0ef1006beddcc688d4e71f37fdb561e15
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7326
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10807
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Fri, 26 Aug 2022 17:50:53 +0000 (13:50 -0400)]
tests: only preload libasan for gcc compilers
Clang appears to not use an external library for ASan, so we should not
try to preload it when building with clang.
Change-Id: I5cd88007fefcd7b8ad7caaee9155d3d9ea7f463e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10806
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Thu, 30 Mar 2023 16:11:19 +0000 (12:11 -0400)]
cpp-common/uuid-view: use string::operator[] instead of string::data to access internal buffer
Using UuidView::string fails with:
CXX ctf-ir.lo
In file included from /home/smarchi/src/babeltrace/src/cpp-common/bt2/clock-class.hpp:20,
from /home/smarchi/src/babeltrace/src/cpp-common/bt2/trace-ir.hpp:19,
from /home/smarchi/src/babeltrace/src/plugins/ctf/common/src/metadata/ctf-ir.hpp:18,
from /home/smarchi/src/babeltrace/src/plugins/ctf/common/src/metadata/ctf-ir.cpp:8:
/home/smarchi/src/babeltrace/src/cpp-common/uuid-view.hpp: In member function 'std::string bt2_common::UuidView::str() const':
/home/smarchi/src/babeltrace/src/cpp-common/uuid-view.hpp:57:38: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
57 | bt_uuid_to_str(_mUuid, s.data());
| ~~~~~~^~
| |
| const char*
In file included from /home/smarchi/src/babeltrace/src/plugins/ctf/common/src/metadata/ctf-ir.hpp:15:
/home/smarchi/src/babeltrace/src/common/uuid.h:40:62: note: initializing argument 2 of 'void bt_uuid_to_str(const uint8_t*, char*)'
40 | BT_HIDDEN void bt_uuid_to_str(const bt_uuid_t uuid_in, char *str_out);
| ~~~~~~^~~~~~~
This is because the data method only has a const version in C++11:
https://en.cppreference.com/w/cpp/string/basic_string/data
It therefore can't be used to modify the content of the string. Use
operator[] instead.
Change-Id: I3bd9c9756c4e79856a5f0f0c7d8fa14e19c1eadd
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10805
Tested-by: jenkins <jenkins@lttng.org>
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Philippe Proulx [Fri, 20 May 2022 13:11:40 +0000 (09:11 -0400)]
field-class.hpp: add missing support for user attributes
This patch adds the missing
bt2::CommonStructureFieldClassMember::userAttributes() and
bt2::CommonVariantFieldClassOption::userAttributes() methods to set and
borrow user attributes of structure field member classes and variant
field class options.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I023e835531753eb928ea5db41b5f429750139af7
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8100
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10804
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Fri, 20 May 2022 01:50:36 +0000 (21:50 -0400)]
Add bt2::Common{Field,FieldClass,Value,Message}<>::as<>()
Those new as() method templates conceptually cast their object to the
first template parameter. Those are shorthands to use specific types
within a template function, for example:
template <typename FieldT, typename ValT>
void g(bt2::Field field, const ValT val)
{
// ...
field.as<FieldT>() = val;
// ...
}
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ifc1f49487ac6ef9c143bf4c2faa3373f4eaccd9e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8099
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10803
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Thu, 19 May 2022 16:22:29 +0000 (12:22 -0400)]
bt2::internal::BorrowedObj: add static assertions for generic copy ops.
This patch adds static assertions to `borrowed-obj.hpp` so as to make
compiler errors more readable when assigning a const wrapper to a
non-const wrapper, for example:
bt2::Value v = bt2::ConstMapValue {somePtr};
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ib23d91c6660a478e0ad663abbd141b0a90eaa92d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8091
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10802
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Thu, 19 May 2022 16:11:40 +0000 (12:11 -0400)]
bt2::internal::BorrowedObj: use default copy operations explicitly
What was called the generic copy constructor and assignment operator
are in fact constructor templates, not true copy operations.
This is because C++ requires that a copy constructor/assignment operator
be a "non-template non-static member function".
This patch is not a fix because the generated default copy operations
were fine (just copy the underlying libbabeltrace2 pointer). Just use
the default ones explicitly and fix the comments so that we know what's
going on.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I4b4f19416a78ca05eaf3fa92f85f9637b2be2c0a
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8090
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10801
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Thu, 19 May 2022 16:06:59 +0000 (12:06 -0400)]
src/cpp-common/bt2/internal/*-obj.hpp: template param. names not needed
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I40d093d773fc07f6972e7b86262c01dac4540575
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8088
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10800
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Tue, 17 May 2022 18:09:05 +0000 (14:09 -0400)]
field-class.hpp: support optional variant FC option name
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I4b2df4343a0f773b82e472b1138536440279e940
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8056
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10799
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Sat, 14 May 2022 16:28:52 +0000 (12:28 -0400)]
Fix: bt2::internal::SharedObj: add real copy/move ctor./operator=()
Observed issue
==============
Given the type S, some `bt2::internal::SharedObj` class template
instantiation:
* Constructing an S object A from another S object doesn't increment the
internal reference count of the libbabeltrace2 object which A wraps.
* Assigning an S object A from an S object B:
* Doesn't increment the internal reference count of the libbabeltrace2
object which B wraps.
* Doesn't decrement the internal reference count of the libbabeltrace2
object which A wraps.
* Constructing an S object from another moved S object B doesn't
reset B.
* Assigning an S object A from a moved S object B:
* Doesn't reset B.
* Doesn't decrement the internal reference count of the libbabeltrace2
object which A wraps.
Cause
=====
What I thought were copy/move constructor and assignment operators in
`bt2::internal::SharedObj` are in fact simple constructor and assignment
operator templates. In other words, they don't qualify as copy/move
constructor and assignment operators, so the compiler uses default ones.
From [1]:
> A copy constructor of class `T` is a non-template constructor whose
> first parameter is `T&`, `const T&`, `volatile T&`, or `const
> volatile T&`, and either there are no other parameters, or the rest
> of the parameters all have default values.
The same condition (non-template) holds for a move constructor, a copy
assignment operator, and a move assignment operator.
Solution
========
Add copy/move constructors and assignment operators to
`bt2::internal::SharedObj`.
Although you may call an operator=() method template like this:
this->operator=<ObjT, LibObjT>(other)
you can't specify the template parameters when you call a constructor
template: the types of all its parameters need to be deduced.
This is why, to avoid redundant code, I added two common "copy" and
"move" (not real copy/move constructors) private constructor templates
to which the true copy/move constructors and the generic "copy"/"move"
constructors delegate. Those common ones accept a second, unused `int`
parameter to differentiate them from the public, generic "copy"/"move"
constructors.
Known drawbacks
===============
None.
References
==========
[1]: https://en.cppreference.com/w/cpp/language/copy_constructor
Change-Id: I6d8cb7c16da0a79296a482f8d130ab40468cc1a5
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8041
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10798
Tested-by: jenkins <jenkins@lttng.org>
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Philippe Proulx [Fri, 13 May 2022 17:29:36 +0000 (13:29 -0400)]
Add bt2::internal::SharedObj::create{With,Without}Ref() methods
It seems like there were some confusion regarding the reference
acquisition of the `bt2::internal::SharedObj` constructor vs. its
createWithInitialRef() static method.
Make it clear with a private constructor and two public static methods:
* createWithoutRef() creates a shared object without getting a
reference.
* createWithRef() creates a shared object, immediately getting a new
reference.
Both methods have two versions: one which accepts a wrapper and one
which accepts a raw libbabeltrace2 pointer.
Update all the `src/cpp-common/bt2` code to use those methods.
The pattern for a non-static shared() method is:
Shared shared() const noexcept
{
return Shared::createWithRef(*this);
}
This means if you have a borrowed wrapper `obj`, then `obj.shared()`
returns a shared object, incrementing the reference count.
The pattern for a creation method is:
return Shared::createWithoutRef(libObjPtr);
where `libObjPtr` is a raw libbabeltrace2 pointer to an object of which
the reference count is one.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ifeef4af74a0078c1b7e9e5dfec8ebd5be381da8f
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8039
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10797
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Thu, 12 May 2022 17:23:48 +0000 (13:23 -0400)]
Fix: bt2::CommonStreamClass: use correct memory error status
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I325d41eeaa4f81df5ad6177fc935bffe49416b34
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8025
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10796
Tested-by: jenkins <jenkins@lttng.org>
Francis Deslauriers [Fri, 11 Mar 2022 17:30:06 +0000 (12:30 -0500)]
integer-range-set.hpp: add `begin()` and `end()` to bt2::CommonIntegerRangeSet
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I85d92d27f90f25b2f86780180b248bde3c394b20
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7568
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10795
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Francis Deslauriers [Thu, 17 Mar 2022 01:12:49 +0000 (21:12 -0400)]
cpp-common: add `begin()` and `end()` to VariantWithIntegerSelector FC
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ice31d346102258a6af593bd38fc3f123179482f4
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7619
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10794
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Francis Deslauriers [Wed, 16 Mar 2022 19:24:03 +0000 (15:24 -0400)]
cpp-common: add `begin()` and `end()` to bt2::CommonEnumerationFieldClass
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Id8b001611288121dd1adc1c3ae5bb698722b5bca
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7618
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10793
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Francis Deslauriers [Wed, 9 Mar 2022 22:42:44 +0000 (17:42 -0500)]
cpp-common: add `begin()` and `end()` to bt2::ConstFieldPath
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ie442f80bf1d5b055f6707ff516a8094417ff6c1d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7553
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10792
Tested-by: jenkins <jenkins@lttng.org>
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Philippe Proulx [Mon, 9 May 2022 20:08:23 +0000 (16:08 -0400)]
src/cpp-common/bt2: add `bt2::AddConst` and `bt2::RemoveConst`
This patch adds the `bt2::AddConst` and `bt2::RemoveConst` structure
templates in `src/cpp-common/bt2/type-traits.hpp` which both provide the
`Type` type alias to transform a const object type into a non-const
object type and vice versa.
For example, `bt2::AddConst<bt2::ClockClass>::Type` is
`bt2::ConstClockClass` and `bt2::RemoveConst<bt2::ConstMapValue>::Type`
is `bt2::MapValue`.
I needed this to call something like
bt2::RemoveConst<typename LibFcT::Mapping::RangeSet>::Type::create()
where `LibFcT` is some non-const enumeration field class, but I decided
to implement it for all the types right now.
Internally, we add something like this for all type pairs:
namespace internal {
struct XyzTypeDescr
{
using Const = ConstXyz;
using NonConst = Xyz;
};
template <>
struct TypeDescr<Xyz> : public XyzTypeDescr
{
};
template <>
struct TypeDescr<ConstXyz> : public XyzTypeDescr
{
};
} /* namespace internal */
The type trait structure templates in `type-traits.hpp` just use
`internal::TypeDescr`, for example:
template <typename ObjT>
struct RemoveConst
{
using Type = typename internal::TypeDescr<ObjT>::NonConst;
};
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ia4d44a286fd836dcdb2a0f37c5a08a43bad5508e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8008
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10791
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Mon, 9 May 2022 19:34:33 +0000 (15:34 -0400)]
Add bt2::CommonEnumerationFieldClass::addMapping() methods
They make it possible to add mappings to an enumeration field class.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I9683e14e57f3b3167693d18ff16316fec12d7611
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8007
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10790
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Mon, 9 May 2022 19:33:39 +0000 (15:33 -0400)]
Fix: bt2::CommonIntegerFieldClass::fieldValueRange(): use correct func.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I38f60c9888e04b367806d54db9d7dc6f9bbb6579
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8006
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10789
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Mon, 9 May 2022 18:12:28 +0000 (14:12 -0400)]
Fix: src/cpp-common/bt2/trace-ir.hpp: use correct variable name
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ic6fec0fbe90b5528a37ef34e67c4789c61fb7ad6
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8004
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10788
Tested-by: jenkins <jenkins@lttng.org>
Francis Deslauriers [Tue, 26 Apr 2022 15:39:11 +0000 (11:39 -0400)]
cpp-common: Expose BorrowedObj::libObjPtr() as public method
This will be useful for component class queries that may use bt2::Value
C++ wrappers but must return a `bt_value` at the moment.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Iea93caa6b47ce1afeb7977fee26dffdd3f97013e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7948
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10787
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Francis Deslauriers [Wed, 16 Mar 2022 15:30:54 +0000 (11:30 -0400)]
Fix: field-path.hpp: add missing `shared-obj.hpp` include
gcc 9.3 emits the following warning when including the `field-path.hpp`
file by itself:
../../../../src/cpp-common/bt2/field-path.hpp:180:5: error: return type ‘using Shared = class bt2::internal::SharedObj<bt2::ConstFieldPath, const bt_field_path, bt2::internal::FieldPathRefFuncs>’ {aka ‘class bt2::internal::SharedObj<bt2::ConstFieldPath, const bt_field_path, bt2::internal::FieldPathRefFuncs>’} is incomplete
180 | {
| ^
../../../../src/cpp-common/bt2/field-path.hpp: In member function ‘void bt2::ConstFieldPath::shared() const’:
../../../../src/cpp-common/bt2/field-path.hpp:181:29: error: too many initializers for ‘bt2::ConstFieldPath::Shared’ {aka ‘bt2::internal::SharedObj<bt2::ConstFieldPath, const bt_field_path, bt2::internal::FieldPathRefFuncs>’}
181 | return Shared {*this};
| ^
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: If18d48f16eb6ecb5b14e12a9c8314392c3f3698e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7604
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10786
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Thu, 17 Mar 2022 19:10:09 +0000 (15:10 -0400)]
Fix: cpp-common: add missing argument to bt_field_class_variant_create call
Change-Id: I582fb40180e2d34b5890e13ae517566945ec3a15
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7641
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10765
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Thu, 17 Mar 2022 18:54:03 +0000 (14:54 -0400)]
Fix: cpp-common: remove unexpected parameter to createStructureFieldClass
Change-Id: Ib9e050b109df596f7c7198a80fed6c1cd9c20cea
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7640
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10764
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Francis Deslauriers [Thu, 17 Mar 2022 02:09:34 +0000 (22:09 -0400)]
Cleanup: cpp-common: typo: clkSnapshot -> fieldPath
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Idf62a2a8d1eb52799c71dee37f08e44af277b15a
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7621
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10763
Tested-by: jenkins <jenkins@lttng.org>
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Francis Deslauriers [Tue, 8 Mar 2022 21:41:24 +0000 (16:41 -0500)]
field-class.hpp: remove redundant template parameters
C++ Standard excerpt:
14.6.1 Locally declared names [temp.local]
Like normal (non-template) classes, class templates have an
injected-class-name (Clause 9). The injected-class-name can be used
with or without a template-argument-list. When it is used without a
template-argument-list, it is equivalent to the injected-class-name
followed by the template-parameters of the class template enclosed in
<>. When it is used with a template-argument-list, it refers to the
specified class template specialization, which could be the current
specialization or another specialization.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I1c0c104431f7cf57806a66ed1bce964c007f2c47
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7527
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10762
Tested-by: jenkins <jenkins@lttng.org>
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Francis Deslauriers [Mon, 7 Mar 2022 22:17:46 +0000 (17:17 -0500)]
field-class.hpp: Add CommonVariantWithSelectorFieldClass
This is useful to call the `selectorFieldPath()` method without knowing
if the variant field class has a signed or unsigned selector.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ib54bfa31d8f818430ec378c7c0e0c9258e20e450
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7511
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10761
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Francis Deslauriers [Mon, 7 Mar 2022 21:54:34 +0000 (16:54 -0500)]
field-class.hpp: Add CommonBaseEnumerationFieldClass
This is useful to call the `size()` method without knowing if the
enumeration field class is of the signed or unsigned type.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I952fc54c015f8548489aab74e85cded23f9841f7
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7510
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10760
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Francis Deslauriers [Thu, 10 Feb 2022 22:06:27 +0000 (17:06 -0500)]
cpp-common: add `begin()` and `end()` to Variant and Struct FC
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ic78e9a06ec86b3a1749c1763698408964f34ec27
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7323
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7290
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Francis Deslauriers [Tue, 8 Mar 2022 17:16:27 +0000 (12:16 -0500)]
cpp-common: template ArrayValueIterator for reuse with other containers
This pattern will be reused for Structure and Variant field class.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I8b6521e41dcc2ebdb81b6348de916544176dbf20
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7518
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10759
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Francis Deslauriers [Fri, 4 Mar 2022 19:52:08 +0000 (14:52 -0500)]
Fix: field-class.cpp: calling _option_fc lib function on VariantFieldClass
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ie3bbc05a20368b8b1388b484ef02da4fb4b68a2d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7497
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10758
Tested-by: jenkins <jenkins@lttng.org>
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Francis Deslauriers [Fri, 4 Mar 2022 15:08:18 +0000 (10:08 -0500)]
field-class.hpp: add missing #include
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I5dedb44d393fe318253f5912c032ad313fd1c455
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7495
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10757
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Francis Deslauriers [Thu, 24 Feb 2022 19:37:29 +0000 (14:37 -0500)]
cpp-common: Add `CommonFieldClass::isReal()` method
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I420462ccfd78c06d7b496f4650af77cd2d2e57b7
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7385
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10756
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Francis Deslauriers [Tue, 22 Feb 2022 20:43:46 +0000 (15:43 -0500)]
cpp-common: Add hash() and isSame() methods to BorrowedObj
This will allow us to use the C++ wrapper objects in
`std::unordered_map` by using these methods in custom hasher and isEqual
objects.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I4e018ece9ea4ca755f6612cd9adec408667b202d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7356
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10755
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Tue, 1 Mar 2022 16:25:05 +0000 (11:25 -0500)]
src/cpp-common: use C-style comments in C++ files
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I63b73d110e59f39afc59e83fcf7b59e61db78dbc
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7434
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10754
Tested-by: jenkins <jenkins@lttng.org>
Francis Deslauriers [Tue, 1 Feb 2022 14:05:18 +0000 (09:05 -0500)]
Add `bt2::CommonArrayValueIterator` to iterate on `bt2::CommonArrayValue` container
This commit implements an array value input iterator and adds `begin()` and
`end()` methods to the `CommonArrayValue` container class.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I2e3c502bd5b11a507fc4643cee27b48b06a6c4a8
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7322
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7193
Tested-by: jenkins <jenkins@lttng.org>
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Mon, 11 Sep 2023 13:48:14 +0000 (09:48 -0400)]
ctf: fix -Wformat-overflow warning in ctf-meta-resolve.cpp
Compiling with gcc 13.2.1 (Arch's gcc version as of today) and -O2, I
get:
libtool: compile: ccache g++ -std=c++11 -DHAVE_CONFIG_H -I/home/smarchi/src/babeltrace/include -I../../../../../src -I/home/smarchi/src/babeltrace/src -include common/config.h -I. -I/home/smarchi/src/babeltrace/src/plugins/ctf/common/metadata -fvisibility=hidden -fvisibility-inlines-hidden -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/sysprof-4 -pthread -Wall -Wextra -Wmissing-prototypes -Wmissing-declarations -Wnull-dereference -Wundef -Wredundant-decls -Wshadow -Wjump-misses-init -Wsuggest-attribute=format -Wnested-externs -Wwrite-strings -Wformat=2 -Wstrict-aliasing -Wmissing-noreturn -Winit-self -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wsuggest-override -Wno-unused-parameter -Wno-sign-compare -Wno-cast-function-type -Wno-missing-field-initializers -Wno-maybe-uninitialized -Werror -g3 -O2 -fmax-errors=1 -fdiagnostics-color=always -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_28 -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_28 -D_GLIBCXX_DEBUG=1 -MT ctf-meta-resolve.lo -MD -MP -MF .deps/ctf-meta-resolve.Tpo -c /home/smarchi/src/babeltrace/src/plugins/ctf/common/metadata/ctf-meta-resolve.cpp -fPIC -DPIC -o .libs/ctf-meta-resolve.o
In file included from /home/smarchi/src/babeltrace/src/logging/comp-logging.h:16,
from /home/smarchi/src/babeltrace/src/plugins/ctf/common/metadata/ctf-meta-resolve.cpp:12:
/home/smarchi/src/babeltrace/src/plugins/ctf/common/metadata/ctf-meta-resolve.cpp: In function 'int64_t get_field_paths_lca_index(ctf_field_path*, ctf_field_path*, resolve_context*)':
/home/smarchi/src/babeltrace/src/logging/comp-logging.h:18:41: error: '%s' directive argument is null [-Werror=format-overflow=]
18 | #define _BT_COMP_LOG_COMP_PREFIX "[%s] "
/home/smarchi/src/babeltrace/src/logging/log.h:807:67: note: in definition of macro 'BT_LOG_WRITE'
807 | lvl, tag, __VA_ARGS__); \
| ^~~~~~~~~~~
/home/smarchi/src/babeltrace/src/logging/comp-logging.h:23:42: note: in expansion of macro '_BT_COMP_LOG_COMP_PREFIX'
23 | BT_LOG_WRITE((_lvl), BT_LOG_TAG, _BT_COMP_LOG_COMP_PREFIX _fmt, \
| ^~~~~~~~~~~~~~~~~~~~~~~~
/home/smarchi/src/babeltrace/src/logging/comp-logging.h:83:9: note: in expansion of macro 'BT_COMP_LOG'
83 | BT_COMP_LOG(BT_LOG_DEBUG, (BT_COMP_LOG_SELF_COMP), _fmt, ##__VA_ARGS__)
| ^~~~~~~~~~~
/home/smarchi/src/babeltrace/src/plugins/ctf/common/metadata/ctf-meta-resolve.cpp:734:9: note: in expansion of macro 'BT_COMP_LOGD'
734 | BT_COMP_LOGD("Finding lowest common ancestor (LCA) between two field paths: "
| ^~~~~~~~~~~~
It is undefined what happens when %s receives NULL. Use the literal
string "(null)" instead of NULL.
Change-Id: I4f53165ff9fc08fb373f7c1cdf87a63f2b792532
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10856
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Philippe Proulx [Fri, 1 Sep 2023 18:17:28 +0000 (14:17 -0400)]
doc/man: make default values of boolean init. params. clearer
This patch answers to <https://bugs.lttng.org/issues/1387>, removing the
"=`yes`" and "=`no`" in the component class manual pages to replace them
with "='VAL'" and indicate the behaviour depending on "'VAL'", as well
as the default value.
Fixes: https://bugs.lttng.org/issues/1387
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ie7439fa397e2a9a5818152a68073f7bf87385675
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10709
Simon Marchi [Fri, 26 May 2023 16:17:19 +0000 (12:17 -0400)]
build: gen-version-i.sh: make it an error if git describe fails
When doing `make` as a regular user, building from the git repo, the
src/common/version.i file may contain:
#define BT_VERSION_GIT "
v1.2.0-3717-ga7074326ba9a"
Then, doing `make` as root, when logged in with `su -`, generates a new
version.i with an empty version string:
#define BT_VERSION_GIT ""
This is because the `git describe --tags --dirty --abbrev=12` command
fails with:
make[1]: Entering directory '/home/smarchi/build/babeltrace/src/common'
GEN version.i
fatal: detected dubious ownership in repository at '/home/smarchi/src/babeltrace'
To add an exception for this directory, call:
git config --global --add safe.directory /home/smarchi/src/babeltrace
By default, git refuses to work on a git repository owned by a different
user. Note that running a command under sudo doesn't hit this problem,
because git honors the SUDO_UID & co variables.
I think that the current state is buggy, because it results in the
installed library having an empty version string, and it happens almost
silently. I suggest making it an error if that `git describe` command
fails, since the script can't work correctly in those conditions. The
user would then need to adjust their setup: either add the directory to
git's safe.directory variable (as the git command suggested) or run the
command under sudo.
Doing "make install" as root not under sudo is one use case, but another
one would be to do the complete build as a regular user from a source
git repository that is owned by another reguar user. In that case, the
script wouldn't be able to generate a version string in the first
place. I think that the right thing to do is to error out. And in that
case, the only solution I see if or the user to use the git
safe.directory variable.
Note that the second git describe command is expected to fail in normal
situations, when it doesn't find an exact tag match, so the `|| true`
there is fine.
Change-Id: I879ddc2184223266829afceca252fe971795f395
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Fixes: https://bugs.lttng.org/issues/1376
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10104
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Fri, 26 May 2023 16:17:01 +0000 (12:17 -0400)]
build: gen-version-i.sh: use a fixed abbrev length
When doing:
- make
- sudo make install
... it is possible for the `sudo make install` command to generate a new
src/common/version.i file, if the regular user has a custom value for
the `core.abbrev` git configuration variable.
The version.i file generated by `make` contains a version number with a
hash of a certain length. Then `sudo make install` generates an
equivalent version number, but with a hash of a different length. This
then causes some object files that depended on it to be rebuilt, which
is not expected for the install target.
To avoid this, add --abbrev=12 to the git describe command that
genenerates the version string, so that the same hash representation is
generated during both "make" and "sudo make install".
Change-Id: I979d6a9d627f133909dc026e0d2820b52f409d98
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Fixes: https://bugs.lttng.org/issues/1376
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10098
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Simon Marchi [Tue, 20 Jun 2023 01:28:12 +0000 (21:28 -0400)]
build: gen-version-i.sh: use errexit option
Use `set -o errexit` in gen-version-i.sh, so that any unexpected
command failures stops the script.
The first `git describe` command can unexpectedly fail when the script
is ran by a user other than the owner of the git repository (and sudo
wasn't used, so SUDO_UID & co are not set):
# git describe --tags --dirty
fatal: detected dubious ownership in repository at '/home/smarchi/src/babeltrace'
To add an exception for this directory, call:
git config --global --add safe.directory /home/smarchi/src/babeltrace
For instance, this happens if the git repository is owned by a regular
user, and `make install` is ran in a root shell started with `su`. Add
`|| true` to that command, to keep the existing behavior (even if
it's not ideal).
Change-Id: Idfbcb3a86158bcddff11a34a18a5d004def37742
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10103
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Simon Marchi [Fri, 26 May 2023 12:50:55 +0000 (08:50 -0400)]
build: gen-version-i.sh: use `mv -f`
When file src/common/version.i happens to be owned by root (there are
known bugs that causes version.i to be rebuilt when doing `make install`
as root), doing `make` as a regular user gives an interactive prompt:
make[3]: Entering directory '/home/smarchi/build/babeltrace/src/common'
GEN version.i
mv: replace 'version.i', overriding mode 0644 (rw-r--r--)?
Pass -f to mv to avoid this.
Change-Id: I3ac19cff615fd52db1c025b08c046d34814fb50a
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10102
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Simon Marchi [Fri, 26 May 2023 16:14:04 +0000 (12:14 -0400)]
build: gen-version-i.sh: use `command` to check if git exists
Use the shell builtin `command` to check if git is a valid command,
instead of `which`.
Change-Id: I2e3b4cc178383be1e34dfddbff0794e6fc7ddf86
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10105
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Simon Marchi [Fri, 26 May 2023 12:35:37 +0000 (08:35 -0400)]
build: gen-version-i.sh: make shellcheck-clean
Fix all the warnings below.
In src/common/gen-version-i.sh line 27:
if (test ! -f version.i && test -f "$TOP_SRCDIR/include/version.i"); then
^-- SC2233 (style): Remove superfluous (..) around condition to avoid subshell overhead.
In src/common/gen-version-i.sh line 39:
if (test -r "$TOP_SRCDIR/bootstrap" && test -r "$TOP_SRCDIR/.git") &&
^-- SC2235 (style): Use { ..; } instead of (..) to avoid subshell overhead.
In src/common/gen-version-i.sh line 40:
test -x "`which git 2>&1;true`"; then
^-------------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
Did you mean:
test -x "$(which git 2>&1;true)"; then
In src/common/gen-version-i.sh line 41:
GIT_VERSION_STR="`cd "$TOP_SRCDIR" && git describe --tags --dirty`"
^-- SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
Did you mean:
GIT_VERSION_STR="$(cd "$TOP_SRCDIR" && git describe --tags --dirty)"
In src/common/gen-version-i.sh line 42:
GIT_CURRENT_TAG="`cd "$TOP_SRCDIR" && git describe --tags --exact-match --match="v[0-9]*" HEAD || true 2> /dev/null`"
^-- SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
^-- SC2015 (info): Note that A && B || C is not if-then-else. C may run when A is true.
Did you mean:
GIT_CURRENT_TAG="$(cd "$TOP_SRCDIR" && git describe --tags --exact-match --match="v[0-9]*" HEAD || true 2> /dev/null)"
In src/common/gen-version-i.sh line 64:
echo "#define BT_VERSION_EXTRA_NAME \"`$SED -n '1p' "$TOP_SRCDIR/version/extra_version_name" 2> /dev/null`\"" >> version.i.tmp
^-- SC2129 (style): Consider using { cmd1; cmd2; } >> file instead of individual redirects.
^-- SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
Did you mean:
echo "#define BT_VERSION_EXTRA_NAME \"$($SED -n '1p' "$TOP_SRCDIR/version/extra_version_name" 2> /dev/null)\"" >> version.i.tmp
In src/common/gen-version-i.sh line 70:
echo "#define BT_VERSION_EXTRA_DESCRIPTION \"`$SED -E ':a ; N ; $!ba ; s/[^a-zA-Z0-9 \n\t\.,]/-/g ; s/\r{0,1}\n/\\\n/g' "$TOP_SRCDIR/version/extra_version_description" 2> /dev/null`\"" >> version.i.tmp
^-- SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
Did you mean:
echo "#define BT_VERSION_EXTRA_DESCRIPTION \"$($SED -E ':a ; N ; $!ba ; s/[^a-zA-Z0-9 \n\t\.,]/-/g ; s/\r{0,1}\n/\\\n/g' "$TOP_SRCDIR/version/extra_version_description" 2> /dev/null)\"" >> version.i.tmp
In src/common/gen-version-i.sh line 80:
echo "#define BT_VERSION_EXTRA_PATCHES \"`ls -1 "$TOP_SRCDIR/version/extra_patches" | $GREP -v '^README.adoc' | $SED -E ':a ; N ; $!ba ; s/[^a-zA-Z0-9 \n\t\.]/-/g ; s/\r{0,1}\n/\\\n/g' 2> /dev/null`\"" >> version.i.tmp
^-- SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
^-- SC2012 (info): Use find instead of ls to better handle non-alphanumeric filenames.
Did you mean:
echo "#define BT_VERSION_EXTRA_PATCHES \"$(ls -1 "$TOP_SRCDIR/version/extra_patches" | $GREP -v '^README.adoc' | $SED -E ':a ; N ; $!ba ; s/[^a-zA-Z0-9 \n\t\.]/-/g ; s/\r{0,1}\n/\\\n/g' 2> /dev/null)\"" >> version.i.tmp
In src/common/gen-version-i.sh line 87:
test x"`cat version.i.tmp`" != x"`cat version.i`"; then
^-----------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
^-------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.
Did you mean:
test x"$(cat version.i.tmp)" != x"$(cat version.i)"; then
For more information:
https://www.shellcheck.net/wiki/SC2012 -- Use find instead of ls to better ...
https://www.shellcheck.net/wiki/SC2015 -- Note that A && B || C is not if-t...
https://www.shellcheck.net/wiki/SC2006 -- Use $(...) notation instead of le...
Change-Id: I519fd427b248bc8f460aa1e5b592aed0ea6858c2
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10096
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Simon Marchi [Thu, 25 May 2023 18:36:49 +0000 (14:36 -0400)]
build: move script to generate version.i to its own file
Move the script from src/common/Makefile.am to its own file. This will
make it easier to read, modify and lint.
I inlined the big comment from Makefile.am in the new script. I tried
to keep the code as-is as much as possible, but I needed to tweak a few
things.
- Replace $(FOO) with $FOO
- The script expects to get the top srcdir and the grep and sed
binaries through the TOP_SRCDIR, GREP and SED env var. GREP and SED
are optional, to make it easier to run the script by hand
Change-Id: Iaa8948018785e0de4250285110b78ccea1abaedb
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10095
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Erica Bugden [Thu, 10 Aug 2023 20:32:12 +0000 (16:32 -0400)]
Bump minimum supported automake version to 1.13
since 1.13.4 is the earliest version of automake that we currently build
with regularly in the CI. Build tests are not currently run with 1.12 so
it is risky to claim supporting it.
Change-Id: I353a60f39c9ac8e1d279745b3225d64e40eab4cc
Signed-off-by: Erica Bugden <ebugden@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10586
CI-Build: Michael Jeanson <mjeanson@efficios.com>
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Michael Jeanson [Tue, 15 Aug 2023 20:43:03 +0000 (16:43 -0400)]
fix: make flake8 6.x happy
./src/bindings/python/bt2/bt2/trace_collection_message_iterator.py:143:12: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`
./src/bindings/python/bt2/bt2/trace_collection_message_iterator.py:151:12: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`
./src/bindings/python/bt2/bt2/trace_collection_message_iterator.py:156:16: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`
./src/bindings/python/bt2/bt2/trace_collection_message_iterator.py:160:16: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`
./src/bindings/python/bt2/bt2/trace_collection_message_iterator.py:164:16: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`
./src/bindings/python/bt2/bt2/trace_collection_message_iterator.py:168:16: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`
./tests/data/auto-source-discovery/params-log-level/bt_plugin_test.py:33:20: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`
Change-Id: I388dfe9b1c8fa7030a805e6c6e0e487e56947616
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10612
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Michael Jeanson [Tue, 15 Aug 2023 18:29:22 +0000 (14:29 -0400)]
fix: running black on python 3.11
Black 22.0 is incompatible with click >= 8.1 [1], pin it to a working
version.
Traceback (most recent call last):
File ".pyenv/bin/black", line 8, in <module>
sys.exit(patched_main())
^^^^^^^^^^^^^^
File ".pyenv/lib/python3.11/site-packages/black/__init__.py", line 6606, in patched_main
patch_click()
File ".pyenv/lib/python3.11/site-packages/black/__init__.py", line 6595, in patch_click
from click import _unicodefun # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: cannot import name '_unicodefun' from 'click' (.pyenv/lib/python3.11/site-packages/click/__init__.py)
[1] https://github.com/psf/black/issues/2964
Change-Id: I502f10e4cdedae4c431a243fc621fa10ab8bc5cf
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10604
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Philippe Proulx [Wed, 9 Aug 2023 08:01:01 +0000 (04:01 -0400)]
bt_query_executor_create_with_method_data(): fix docs note
The bt_graph_add_*_component*() functions accept a `params` parameter,
not the bt_graph_add_*_component_*_port_added_listener() ones.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ib2b8fa0177a8915d344ccaf3e55c05d3c939d2ca
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10559
Simon Marchi [Thu, 25 May 2023 18:37:55 +0000 (14:37 -0400)]
build: correct alignment of "GEN version.i"
Before:
make[1]: Entering directory '/home/smarchi/build/babeltrace/src/common'
CC assert.lo
CC common.lo
CC uuid.lo
CCLD libbabeltrace2-common.la
GEN version.i
After:
make[1]: Entering directory '/home/smarchi/build/babeltrace/src/common'
CC assert.lo
CC common.lo
CC uuid.lo
CCLD libbabeltrace2-common.la
GEN version.i
Change-Id: Ia4968e5209ef1afc83c287797f4d88756fe30b2f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10094
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Michael Jeanson [Thu, 15 Jun 2023 19:59:52 +0000 (15:59 -0400)]
.gitignore: add missing '/tests/lib/test_fields_bin'
Change-Id: Ia77516852a3d4aeca443a7d42b7c2ea4922d0195
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10375
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Simon Marchi [Thu, 8 Jun 2023 14:57:48 +0000 (10:57 -0400)]
python: make all _get_ref/_put_ref proper static methods
The pyright static type checker doesn't like for these methods in
_SharedObject:
@staticmethod
def _get_ref(ptr):
raise NotImplementedError
@staticmethod
def _put_ref(ptr):
raise NotImplementedError
... to be overriden by assignment like this:
_get_ref = staticmethod(native_bt.field_class_get_ref)
_put_ref = staticmethod(native_bt.field_class_put_ref)
The warnings it gives are:
/home/smarchi/src/babeltrace/src/bindings/python/bt2/bt2/field_class.py
/home/smarchi/src/babeltrace/src/bindings/python/bt2/bt2/field_class.py:48:16 - error: Expression of type "staticmethod[(field_class: Unknown), Unknown]" cannot be assigned to declared type "(ptr: Unknown) -> Unknown"
Type "staticmethod[(field_class: Unknown), Unknown]" cannot be assigned to type "(ptr: Unknown) -> Unknown"
Parameter name mismatch: "ptr" versus "field_class" (reportGeneralTypeIssues)
/home/smarchi/src/babeltrace/src/bindings/python/bt2/bt2/field_class.py:49:16 - error: Expression of type "staticmethod[(field_class: Unknown), Unknown]" cannot be assigned to declared type "(ptr: Unknown) -> Unknown"
Type "staticmethod[(field_class: Unknown), Unknown]" cannot be assigned to type "(ptr: Unknown) -> Unknown"
Parameter name mismatch: "ptr" versus "field_class" (reportGeneralTypeIssues)
So, it's just the parameter name that it doesn't like. The obvious
solution would be to rename the `ptr` parameters of
_SharedObject._{get,put}_ref to `field_class`, in _SharedObject, to
match the names in native_bt.py. However, I don't want us to be tied to
the names in native_bt.py (which originally come from the C header
files), as in Python we often want to use `ptr` in the name to
differentiate the SWIG wrapper around the pointer and the higher-level.
Another solution might be to use SWIG code to rename function parameters
in the SWIG-generated code, but I'm not so well-versed in SWIG, I
couldn't find how to do that.
So, I propose to just use the standard syntax for methods instead, the
type checker seems to be happy with that.
Change-Id: Ife5ad007aea4fb315d3ff4f8da67c48f4bf3e96d
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10240
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Thu, 8 Jun 2023 15:21:31 +0000 (11:21 -0400)]
python: mark _SharedObject._{get,put}_ref as abstract methods
_get_ref and _put_ref must be implemented by any sub-class of
_SharedObject, marking them as abstract methods could help find
mistakes.
Change-Id: I0e161a0bbc1c432d9ed59279d3e4b1b6f6a26215
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10239
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Philippe Proulx [Mon, 5 Jun 2023 18:11:41 +0000 (14:11 -0400)]
tests/lib/utils/run-in.cpp: apply BT 2 C++ coding style
• Separate declarative and other statements.
• Use an anonymous namespace.
• Fix a comment.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ic755d5a05b31e8408a69a4443caf0e0823e9fa21
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10201
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Thu, 1 Jun 2023 00:59:54 +0000 (20:59 -0400)]
tests: fix formatting of run-in.cpp
Done by running `tools/format-cpp`.
Change-Id: I6b07f4bc24176e5bd7f4a9f164b0ba3ee4c00fac
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10189
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Wed, 24 May 2023 16:43:49 +0000 (12:43 -0400)]
tests: add bt_field_string_clear test
Add a test for bt_field_string_clear, exercising the fix done in commit
0022a87819b0 ("Fix: clear_string_field(): set first character to 0").
The test sets the field to a non-empty value, clears it with
bt_field_string_clear, and verifies that the value returned by
bt_field_string_get_value is an empty string, and that the length
returned by bt_field_string_get_length is 0.
When reverting
0022a87819b0, the test gives:
1..2
not ok 1 - string field is empty
# Failed test (/home/smarchi/src/babeltrace/tests/lib/test_fields.cpp:operator()() at line 36)
ok 2 - string field length is 0
# Looks like you failed 1 test of 2.
Change-Id: I46800a93a7290fe72618081efdc5cdcd944c8567
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10068
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Tue, 23 May 2023 21:45:45 +0000 (17:45 -0400)]
tests: make pre/post-condition assertions test use the run-in framework
Change this test to use the new "run-in" framework, instead of
implementing its own "run in component class" util.
Change-Id: If6c84cef632c11fabdbf386a6adabf95e5aac658
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10061
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Wed, 24 May 2023 16:40:15 +0000 (12:40 -0400)]
tests: add extern "C" to tap.h
This makes it possible to use it from C++ programs.
Change-Id: Ic111f493b0b048b8e491b824af293f0742bda35a
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10067
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Tue, 23 May 2023 18:19:42 +0000 (14:19 -0400)]
tests: add framework to run code in comp cls / comp / msg iter context
Add a little framework to make it easier to write tests that need a
bt_self_component_class, bt_self_component or bt_self_message_iterator.
This is inspired from what we have already in
tests/lib/conds/utils.{hpp,cpp}, but decoupled from the
pre/post-condition assertion tests. A subsequent commit will change
this test to use the new framework.
The framework exposes the run_in function, which accepts three callbacks
that are executed at three different points in the graph's lifecycle,
providing access to all three contexts. Each callback may be nullptr.
For convenience, there are also three functions to run code in each
individual context:
- runInCompClsQuery
- runInCompClsInitFunc
- runInMsgIterClsInitFunc
If needed, some additional hook points can be added later, to access
other points of the graph's lifecycle.
The run_in function makes an end-to-end run:
- creates a graph
- creates a source component class
- makes a query on that component class
- adds a source component
- adds a dummy sink component, connects the ports of the two components
- runs the graph
Even for a test that only needs to run code in component class context,
for instance, we still run the whole enchilada. This is a bit
inefficient, but given that this is just for testing, we don't really
care, as it still runs quick.
Change-Id: Ie532b316dc330758b60fd5f6fe9499f0555f8a8a
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10060
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Tue, 23 May 2023 19:47:30 +0000 (15:47 -0400)]
tests: use nlohmann's json lib to generate conds list
Change lib/conds/utils.cpp to use nlohmann to dump the test list in
JSON, rather than dumping it by hand.
Change-Id: I7641a3fcdf118b3787abd76c395c098e1f991717
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10059
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Francis Deslauriers [Thu, 20 Jan 2022 15:31:33 +0000 (10:31 -0500)]
cpp-common: add nlohmann/json header-only dependency
This commit adds the C++ nlohmann JSON library which comes from the
MIT-licensed <https://github.com/nlohmann/json/> project [1].
Babeltrace 2 will be using this library to encode JSON strings during
the generation of CTF 2 traces.
In any Babeltrace 2 C++ file, include it like this:
#include "cpp-common/nlohmann/json.hpp"
[1] https://raw.githubusercontent.com/nlohmann/json/
a0c1318830519eac027a31edec1a99ce1ae5670e/single_include/nlohmann/json.hpp
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I139ea0c0763a129a8d4db351f8ece2edb1c112dd
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7321
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7138
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Tue, 23 May 2023 14:50:54 +0000 (10:50 -0400)]
tests: include babeltrace.h in conds/utils.hpp
This file uses bt_self_component, so it should include
babeltrace2/babeltrace.h. In practice, this removes errors when editing
this file in a woke editor.
Change-Id: I72b24b603e878d0773ecc827f73192123e596f05
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10055
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Tue, 23 May 2023 14:49:37 +0000 (10:49 -0400)]
tests: re-format conds C++ files
Run tools/format-cpp to format the new C++ files.
Change-Id: Ia919658ed83e8ade0ade02709774caf57b1ee455
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10054
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Tue, 23 May 2023 14:40:41 +0000 (10:40 -0400)]
tests: convert lib conds test to C++
Rename the files from .c/.h to .cpp/.hpp. Do some minor adjustments so
that it builds.
Change-Id: I4ab79151428ecaf37396e0da891ecd5fa10e19e9
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10053
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Tue, 23 May 2023 15:44:36 +0000 (11:44 -0400)]
tests: add a basic pre-condition assertion test
There is currently no "basic" pre-condition assertion test, even though
we have the support for it. Add one, so that the support code is
exercised. The new test checks that passing a wrong MIP version to
bt_grbt_graph_create triggers an assertion.
Change-Id: Iddaa7905684e1bda3a731ab215a0e42b5eb62633
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10056
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Tue, 23 May 2023 14:30:19 +0000 (10:30 -0400)]
tests: remove unused forward declaration
Change-Id: I4f5a3496e67f0db6f4c850deec58c34ba0df7c77
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10052
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Wed, 17 May 2023 19:38:27 +0000 (15:38 -0400)]
lib: remove TODO in add_port
I think that the {input,output}-port-name-is-unique assertions basically
check that this TODO is about.
Change-Id: Ib5029697114f46fd5485d902068ca912b658ebc9
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10038
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Fri, 19 May 2023 21:24:39 +0000 (17:24 -0400)]
lib: de-duplicate assertions in bt_component_add_{input,output}_port
Move assertions from bt_component_add_input_port and
bt_component_add_output_port to add_port. Add a parameter to indicate
to add_port if it's adding an input or output port. This is only used
to select the correct strings for the "no duplicate name" pre-condition
check. I think this de-duplication helps ensure both the input and
output paths are equivalent.
Change-Id: I217794719231251bf73d0347d6208af9fcaf6a0d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10037
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Wed, 17 May 2023 19:29:38 +0000 (15:29 -0400)]
lib: de-duplicate "no error" assertion in add port functions
Add BT_ASSERT_PRE_NO_ERROR_FROM_FUNC calls in
bt_component_add_output_port and bt_component_add_input_port, and remove
the equivalent calls in their callers. This moves the assertion check
next to the other existing assertions.
Change-Id: Ia251510ce2b6ba369cfc1f4afae50e8e46060957
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10036
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Wed, 17 May 2023 19:25:41 +0000 (15:25 -0400)]
lib: remove duplicated assertion in bt_self_component_source_add_output_port
The use of BT_ASSERT_PRE_OUTPUT_PORT_NAME_UNIQUE in
bt_self_component_source_add_output_port is not necessary, as
bt_component_add_output_port checks the same thing:
BT_ASSERT_PRE_FROM_FUNC(api_func, "output-port-name-is-unique",
bt_component_port_name_is_unique(component->output_ports, name),
"Output port name is not unique: name=\"%s\", %![comp-]c",
name, component);
Remove this use of BT_ASSERT_PRE_OUTPUT_PORT_NAME_UNIQUE, and then
remove BT_ASSERT_PRE_OUTPUT_PORT_NAME_UNIQUE itself. Then, make
bt_component_port_name_is_unique static to component.c, since it's only
used in that file now.
Change-Id: Ia341be570596d798179d1937b40726f829cbebfe
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10035
Tested-by: jenkins <jenkins@lttng.org>
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Wed, 17 May 2023 19:41:04 +0000 (15:41 -0400)]
Revert "Fix: lib: add missing BT_ASSERT_PRE_NO_ERROR in trace-ir/clock-class.c"
This reverts commit
bbc5046d02a09977fb1743ad26b7fcedeb888850.
After further discussion, we concluded that the existing behavior
(before the reverted patch) is desirable. It should only be forbidden
to call an API function while there is a current error for API functions
that can fail and set a current error themselves.
The documentation currently says:
You cannot call any libbabeltrace2 function when the current thread
has an error, except the reference counting functions (ending with
_get_ref() or _put_ref()).
It will later be updated to reflect the fact that it's allowed to call
API functions that can't fail while there is a current error.
Change-Id: Id7d1419862066e0e3d9fd537198b7e630a9c2dc8
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10034
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Tue, 15 Feb 2022 15:47:53 +0000 (10:47 -0500)]
lib: remove unneeded forward declarations in trace-ir/field-class.h
`struct bt_field` is not used in this file. `struct bt_field_class` is
not needed, as the struct is defined right there below.
Change-Id: I4f4da1b32fd80eefecc6205febf51e3e0dd5a365
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7318
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7297
Simon Marchi [Mon, 15 May 2023 17:51:08 +0000 (13:51 -0400)]
Fix: lib: add missing BT_ASSERT_PRE_NO_ERROR in trace-ir/clock-class.c
I spotted some API functions missing BT_ASSERT_PRE_NO_ERROR calls, fix
that.
Change-Id: I3ad30b0d2865afae1ce554ad7e93d03bf8cb3dc8
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9995
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Sat, 6 May 2023 02:59:47 +0000 (22:59 -0400)]
debug-info: fix -Wenum-int-mismatch problem in copy_field_class_content_internal
GCC 13 points out that the return value differs between the declaration
and definition of copy_field_class_content_internal, fix that.
CC trace-ir-metadata-field-class-copy.lo
cc1: warning: command-line option '-Wsuggest-override' is valid for C++/ObjC++ but not for C
/home/smarchi/src/babeltrace/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c:885:41: error: conflicting types for 'copy_field_class_content_internal' due to enum/integer mismatch; have 'enum debug_info_trace_ir_mapping_status(struct trace_ir_metadata_maps *, const bt_field_class *, bt_field_class *)' [-Werror=enum-int-mismatch]
885 | enum debug_info_trace_ir_mapping_status copy_field_class_content_internal(
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/smarchi/src/babeltrace/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c:22:
/home/smarchi/src/babeltrace/src/plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.h:17:5: note: previous declaration of 'copy_field_class_content_internal' with type 'int(struct trace_ir_metadata_maps *, const bt_field_class *, bt_field_class *)'
17 | int copy_field_class_content_internal(struct trace_ir_metadata_maps *trace_ir_metadata_maps,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Change-Id: I9c0dd3ffc3ba1a2e9fbbca948a391357ae28a483
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9986
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Fri, 5 May 2023 17:44:09 +0000 (13:44 -0400)]
Add .editorconfig entry for .h and .c files
Change-Id: Ie892477b6d1d42dab969bfb75a5900a71634a50a
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9971
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Wed, 3 May 2023 19:28:41 +0000 (15:28 -0400)]
tools/format-cpp: run `xargs` with `-P$(nproc)` (format in parallel)
This saves many seconds per run.
Note that some implementations of xargs might not accept the `-P`
option, therefore `tools/format-cpp` now requires something like
GNU xargs.
`nproc` is also a GNU (Coreutils) thing.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ie7113dae32cff506b716c3b590bbe58eac5f1586
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9950
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Philippe Proulx [Tue, 2 May 2023 18:35:26 +0000 (14:35 -0400)]
Change required clang-format version to 15
No changes between clang-format 14 and 15 when running
`tools/format-cpp`.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Iae32e88a60f8104535f0a9163dfd1d7dc59d23be
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9945
Simon Marchi [Mon, 3 Apr 2023 00:44:57 +0000 (20:44 -0400)]
configure: add --enable-ubsan configure flag
Just like we have --enable-asan.
Change-Id: I9fb5a625ba366e41d7055fa06c0b2870f5dbdbee
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9729
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Michael Jeanson [Wed, 5 Apr 2023 14:40:31 +0000 (10:40 -0400)]
fix: document proper Bison version requirement
The minimum version of Bison was bumped to 2.5 a while ago, update the
documentation and help messages that still refer to 2.4.
Change-Id: I3daef3eb51f24ff0194c43e3e13575eaa6de4f56
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9734
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Michael Jeanson [Wed, 22 Mar 2023 21:57:09 +0000 (17:57 -0400)]
fix: pass exec-prefix to python bindings install
Some systems will split the arch independent files from the arch
specific using a different value for 'prefix' and 'exec-prefix'. Pass
this information from the Makefile to the python build system.
Change-Id: I2f26ba1d8c8252e5a1c49fb54733e02ae336f157
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9695
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Jérémie Galarneau [Tue, 25 Apr 2023 19:14:59 +0000 (15:14 -0400)]
babeltrace2-query(1): erroneous parameter used in example
The src.ctf.fs component class expects the `inputs` parameter (an array
of strings) rather than `path` (a string).
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id716d68cbb289fe7b52f10c22ed6bc5c9914e2e4
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9867
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Mon, 3 Apr 2023 01:09:56 +0000 (21:09 -0400)]
cli: use return value of g_string_free
When building against glib 2.76, I see:
CC babeltrace2-cfg-cli-args.o
In file included from /usr/include/glib-2.0/glib/giochannel.h:36,
from /usr/include/glib-2.0/glib.h:56,
from /home/simark/src/babeltrace/src/common/assert.h:12,
from /home/simark/src/babeltrace/src/logging/log.h:27,
from /home/simark/src/babeltrace/src/cli/logging.h:11,
from /home/simark/src/babeltrace/src/cli/babeltrace2-cfg-cli-args.c:10:
/home/simark/src/babeltrace/src/cli/babeltrace2-cfg-cli-args.c: In function ‘plugin_comp_cls_names’:
/usr/include/glib-2.0/glib/gstring.h:72:5: error: ignoring return value of ‘g_string_free_and_steal’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
68 | (__builtin_constant_p (free_segment) ? \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
69 | ((free_segment) ? \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70 | (g_string_free) ((str), (free_segment)) : \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
71 | g_string_free_and_steal (str)) \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
72 | : \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
73 | (g_string_free) ((str), (free_segment)))
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/simark/src/babeltrace/src/cli/babeltrace2-cfg-cli-args.c:136:25: note: in expansion of macro ‘g_string_free’
136 | g_string_free(gs_name, FALSE);
| ^~~~~~~~~~~~~
glib made g_string_free warn about unused results in this commit:
https://gitlab.gnome.org/GNOME/glib/-/commit/
c3d07a625a407b56432f4b8c60295fd32ee1ee2b
Fix that by changing our code to get the released value from the return
value of g_string_free, rather than doing it in two steps.. No
functional changes intended.
Change-Id: I62f4002d0487165b7c9d33f471937185f3bc0f82
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9728
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Fri, 31 Mar 2023 15:47:33 +0000 (11:47 -0400)]
Fix: mark (again) section start/end symbols as hidden
Commit
1353b066072e ("Visibility hidden by default") broke the plugin
loading on RHEL 7 (and probably other Linux systems with an older
linker). The ld version on RHEL 7 is 2.27-44.base.el7_9.1.
The symptom is that plugins aren't loaded:
$ ./src/cli/babeltrace2 list-plugins
From the following plugin paths:
- /home/mjeanson/Git/babeltrace/src/plugins/ctf
- /home/mjeanson/Git/babeltrace/src/plugins/text
- /home/mjeanson/Git/babeltrace/src/plugins/utils
- /home/mjeanson/Git/babeltrace/src/plugins/lttng-utils
No plugins found.
While debugging, I found this strange behavior that I am unable to
explain:
(gdb) frame
#0 __bt_get_begin_section_plugin_descriptors () at /home/mjeanson/Git/babeltrace/src/plugins/ctf/plugin.cpp:16
16 BT_PLUGIN_MODULE();
(gdb) disassemble
Dump of assembler code for function __bt_get_begin_section_plugin_descriptors():
0x00007ffff57b0045 <+0>: push %rbp
0x00007ffff57b0046 <+1>: mov %rsp,%rbp
=> 0x00007ffff57b0049 <+4>: mov 0x2b8f68(%rip),%rax # 0x7ffff5a68fb8
0x00007ffff57b0050 <+11>: pop %rbp
0x00007ffff57b0051 <+12>: retq
End of assembler dump.
(gdb) si
0x00007ffff57b0050 16 BT_PLUGIN_MODULE();
(gdb) p/x $rax
$2 = 0x7ffff7bc6dd0
We are in the function that is supposed to return the beginning of the
__bt_plugin_descriptor section for the babeltrace-plugin-ctf.so shared
object (the address of the __start___bt_plugin_descriptor symbol). The
address displayed by the disassembler (0x7ffff5a68fb8) appears correct.
It is the sum of 0x2b8f68 and the (next instruction's) PC,
0x7ffff57b0050. However, after stepping, we see that rax contains a
different value, 0x7ffff7bc6dd0. I do not understand how it's possible
for this instruction to give that result. But this address
(0x7ffff7bc6dd0) is the beginning of the __bt_plugin_descriptor section
of libbabeltrace2.so. So, the symbol from libbabeltrace2.so seems to
hide the symbol of the same name in babeltrace-plugin-ctf.so. The
function that is supposed to return the start of the plugin descriptor
section in babeltrace-plugin-ctf.so actually returns the start of that
section but in libbabeltrace2.so.
I checked the properties of the special section start/end symbols, both
on RHEL7 and on a more recent system (Arch), for both before and after
1353b066072e. Here are the results:
RHEL7 before:
00000000002c9768 0 NOTYPE LOCAL DEFAULT 26 __start___bt_plugin_descriptors
RHEL7 after :
00000000002c86c8 0 NOTYPE GLOBAL DEFAULT 26 __start___bt_plugin_descriptors
Arch before:
0000000000236a00 0 NOTYPE GLOBAL HIDDEN 27 __start___bt_plugin_descriptors
Arch after :
00000000002326c0 0 NOTYPE GLOBAL PROTECTED 27 __start___bt_plugin_descriptors
On RHEL7 the symbols originally had LOCAL binding, meaning they weren't
used for relocation outside their object. The
__start___bt_plugin_descriptor symbol from libbabeltrace2.so therefore
didn't override the one in babeltrace-plugin-ctf.so. Similarly, on
Arch, the symbols had HIDDEN visibility, so they also didn't cross
shared object boundary.
After
1353b066072e, the symbols on RHEL7 were "GLOBAL DEFAULT", meaning
the symbols from libbabeltrace2.so would override the symbols with the
same names in plugin (which are necessarily loaded after the main
library). On Arch, things kept working because the symbols use the
PROTECTED visibility. ld started to use PROTECTED visibility at some
point for these special section start/end symbols, because it makes no
sense to make them overridable (which they are with the DEFAULT
visibility). The code in a given file always wants to refer to the
section start/end symbols of its own file.
Note that starting with ld 2.35, we can use the "-z
start-stop-visibility" option to control the visibility of those
symbols. In some way, it is the linker equivalent of
-fvisibility=hidden for the compiler (just for these start/stop
symbols). But it doesn't help us for these older systems.
Here are the relevant changes I found in the ld history:
* This commit (included in binutils 2.29) made the symbols hidden:
Always define referenced __start_SECNAME/__stop_SECNAME
https://inbox.sourceware.org/binutils/
20170610224649.GA12339@gmail.com/
https://gitlab.com/gnutools/binutils-gdb/-/commit/
cbd0eecf261c2447781f8c89b0d955ee66fae7e9
* This commit (included in binutils 2.29.1 and binutils 2.30) made the
symbols protected, after people complained they couldn't look them
up:
Make __start/__stop symbols protected visibility
https://inbox.sourceware.org/binutils/CAMe9rOq5vJzAw0-Quy-J_-UZH9tpoxa4jXWdks255nuFoph7zA@mail.gmail.com/
https://gitlab.com/gnutools/binutils-gdb/-/commit/
487b6440dad57440939fab7afdd84a218b612796
* This commit (included in binutils 2.35) added the option to control
the visibility:
gold, ld: Implement -z start-stop-visibility=... option.
https://inbox.sourceware.org/binutils/CAB=4xhqb63g_b8K_BJiKne8N+X9zRO_0sYZw+0UNTTFTbdV3OA@mail.gmail.com/
https://gitlab.com/gnutools/binutils-gdb/-/commit/
cae64165f47b64898c4f1982d294862cfae89a47
Fix all this by making these symbols explicitly hidden again, as they
were before
1353b066072e.
Change-Id: Iad6c07691bbfdcbd56948cdc7ccd241d3d8311e3
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9726
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Michael Jeanson [Thu, 30 Mar 2023 18:07:05 +0000 (14:07 -0400)]
fix: visibility of bt_plugin_python_create_all_from_file
With glib2 < 2.52, G_MODULE_EXPORT is defined to nothing on platforms
other than Windows instead of __attribute__((visibility("default")))
which results in an hidden symbol and the failure to load the python
plugin provider.
Use our own macro to export this symbol.
Change-Id: I83ac515c573d92e22021759bf23a1a9615bd3e07
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9724
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Michael Jeanson [Wed, 22 Mar 2023 21:34:51 +0000 (17:34 -0400)]
Show python bindings install output in verbose builds
When running 'make V=1' print the output of the python bindings install
command to help with debugging.
Change-Id: I33ffa5de1ce4d1957877630662615965a6c78b6f
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9694
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Mon, 4 Jul 2022 13:43:27 +0000 (09:43 -0400)]
Visibility hidden by default
Change the default visibility of functions to be hidden. Tag the
functions we want exported as "BT_EXPORT", rather than tagging the ones
we want hidden as "BT_HIDDEN".
The benefits of this method are explained here:
https://gcc.gnu.org/wiki/Visibility
This is the only practical way to avoid some C++ symbols to be
externally visible (for example, the
bt_param_validation_map_value_entry_descr symbol below).
Change configure.ac to add -fvisibility=hidden to CFLAGS and CXXFLAGS,
and -fvisibility-inlines-hidden to CXXFLAGS. Remove all mentions of
BT_HIDDEN and its definition. Add BT_EXPORT, and tag all functions
meant to be exported with it.
Using the abidiff tool, I confirmed that there is not change in exported
symbols for these two libraries:
- ./src/lib/.libs/libbabeltrace2.so
- ./src/ctf-writer/.libs/libbabeltrace2-ctf-writer.so
In the CTF plugin, some symbols that used to be exported are now hidden.
There are some C++ symbols like:
[D] 'method bt_param_validation_map_value_entry_descr::bt_param_validation_map_value_entry_descr()' {_ZN41bt_param_validation_map_value_entry_descrC2Ev, aliases _ZN41bt_param_validation_map_value_entry_descrC1Ev}
And some bison/flex symbols like:
[D] 'function void bt_yyset_out(FILE*, yyscan_t)' {_Z12bt_yyset_outP8_IO_FILEPv}
I think this is OK, it is extremely unlikely that anybody is relying on
this, and the plugins do not claim to offer a stable ABI anyway.
In plugins "with id", the following symbol becomes not visible:
[D] '__bt_plugin_descriptor __bt_plugin_descriptor_lttng_utils' {__bt_plugin_descriptor_lttng_utils}
I think this is OK, this symbol is only referenced internally, its
address is put in the plugin descriptors table. But its address is
never looked up by an external party. The equivalent symbol for plugins
without an explicit id (__bt_plugin_descriptor_auto) was already local,
I'm not sure why.
Change-Id: I2dcb41af9bf9ff6aec4f1f950da4bad52707ada9
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8543
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Wed, 15 Mar 2023 19:44:02 +0000 (15:44 -0400)]
Fix: tests: print real values in a fixed format
The cli_params_to_string.to_string function converts float values
(bt2._RealValueConst) to string using the str function. The format of
that seems to differ across platform. On a 32-bit powerpcspe platform,
we see this failure in the cli/params/test_params test:
-{a=
10500000.0, b=
10500000.0, c=1.05e-05, d=1.05e-05}
+{a=
10500000.0, b=
10500000.0, c=1.
0499999999999999e-05, d=1.
0499999999999999e-05}
Fix that by doing an explicit string conversion for _RealValueConst objects,
with a constant 7 decimal places after the decimal point. The 7 is chosen so
that the numbers in tests in cli/params/test_params are not truncated.
Change-Id: Ie4fcb8eb422c3d44eeec1201169dc8a995536d4a
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9651
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Mon, 20 Feb 2023 20:40:35 +0000 (15:40 -0500)]
Fix: ctf: verify that field class is int before calling ctf_field_class_as_int
Some code paths call ctf_field_class_as_int functions before confirming
that the field class is indeed an int (or enum, which is a sub-type of
int). This causes assertion failures, because these functions assert
that the field class they receive have the right type.
One case can be hit using the invalid-sequence-length-field-class trace,
included with this patch:
$ /home/smarchi/build/babeltrace/tests/../src/cli/babeltrace2 -c sink.text.details -p with-trace-name=no,with-stream-name=no /home/smarchi/src/babeltrace/tests/data/ctf-traces/fail/invalid-sequence-length-field-class
(╯°□°)╯︵ ┻━┻ /home/smarchi/src/babeltrace/src/plugins/ctf/common/metadata/ctf-meta.hpp:355: ctf_field_class_as_int(): Assertion `!fc || (fc->type == CTF_FIELD_CLASS_TYPE_INT || fc->type == CTF_FIELD_CLASS_TYPE_ENUM)` failed.
This particular crash happens here:
#4 0x00007ffff535de9d in bt_common_assert_failed (file=0x7ffff5374a60 "/home/smarchi/src/babeltrace/src/plugins/ctf/common/metadata/ctf-meta.hpp",
line=355, func=0x7ffff5374a20 "ctf_field_class_as_int",
assertion=0x7ffff53749a0 "!fc || (fc->type == CTF_FIELD_CLASS_TYPE_INT || fc->type == CTF_FIELD_CLASS_TYPE_ENUM)")
at /home/smarchi/src/babeltrace/src/common/assert.c:40
#5 0x00007ffff5271cca in ctf_field_class_as_int (fc=0x603000002b60) at /home/smarchi/src/babeltrace/src/plugins/ctf/common/metadata/ctf-meta.hpp:355
#6 0x00007ffff527a54b in validate_target_field_path (target_field_path=0x7fffffffce60, target_fc=0x603000002b60, ctx=0x7fffffffd050)
at /home/smarchi/src/babeltrace/src/plugins/ctf/common/metadata/ctf-meta-resolve.cpp:877
#7 0x00007ffff527bb7f in resolve_sequence_or_variant_field_class (fc=0x607000000950, ctx=0x7fffffffd050)
at /home/smarchi/src/babeltrace/src/plugins/ctf/common/metadata/ctf-meta-resolve.cpp:969
In validate_target_field_path, when handing a sequence, we call
ctf_field_class_as_int on target_fc (the length field class) before
confirming it is really an int. Fix that by moving the call to
ctf_field_class_as_int below that check.
I went around and looked at all the uses of ctf_field_class_as_int, and
fixed some more instances of the same problem.
In some cases, I moved calls to ctf_field_class_as_int after
BT_COMP_LOGT calls. While not necessary, my thinking is that should the
assert in ctf_field_class_as_int ever fail for these calls, it could be
able to see the output of the BT_COMP_LOGT, before crashing.
Add a test with a sequence whose length specifier is not an integer.
I also wrote an equivalent test for a variant whose selector is not an
enumeration. It doesn't cause a crash, but I thought it would be a good
test to have anyway, I don't think we exercise that.
Change-Id: I0d375e9727572d97f129cdefdaad7bfa1a6102dc
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9528
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Simon Marchi [Wed, 24 Aug 2022 15:41:31 +0000 (11:41 -0400)]
doc: fix uptream -> upstream typos
Change-Id: Ic52f47c1b3fbbeb2db6da260c1d75570ec6542d5
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8742
CI-Build: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Michael Jeanson [Wed, 8 Mar 2023 16:06:37 +0000 (11:06 -0500)]
fix: python: monkey patch the proper sysconfig implementation
Since we monkey patch sysconfig, use the distutils implementation when
building with distutils and the upstream one when building with
setuptools.
This ensures the properly patched version is used to build the
extension.
Change-Id: I66eb2d02519d585a15721b2bd77007672e895d7a
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9621
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Simon Marchi [Wed, 8 Mar 2023 21:54:25 +0000 (16:54 -0500)]
Fix: tests: free message iterator class in test_graph_topo.c
In a build with --enable-asan and optimizations (-O2), I see:
Direct leak of 112 byte(s) in 1 object(s) allocated from:
#0 0x7fc88d6bf411 in __interceptor_calloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:77
#1 0x7fc88d3b4631 in g_malloc0 (/usr/lib/libglib-2.0.so.0+0x53631)
#2 0x563fdbbb98c7 in init_test /home/smarchi/src/babeltrace/tests/lib/test_graph_topo.c:330
#3 0x563fdbbb98c7 in main /home/smarchi/src/babeltrace/tests/lib/test_graph_topo.c:711
#4 0x7fc88d19d78f (/usr/lib/libc.so.6+0x2378f)
For some reason, that leak does not show up on a -O0 build. Anyhow,
call BT_MESSAGE_ITERATOR_CLASS_PUT_REF_AND_RESET, it's the right thing
to do to clean things up.
Change-Id: I875d8961c2eb4915fbc13706b9148151e82e26d8
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9626
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Michael Jeanson [Mon, 27 Feb 2023 18:40:08 +0000 (13:40 -0500)]
python: replace distutils with setuptools
Since 'distutils' will be removed in Python 3.12, use setuptools instead
to build the bindings. Thanks to the python devs that removed the only
facility to build native extensions from the core distribution.
See https://peps.python.org/pep-0632/
Change-Id: Ib515931d2352416bcc92e18be6b5a3981fb3f067
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8846
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Michael Jeanson [Mon, 27 Feb 2023 18:38:42 +0000 (13:38 -0500)]
python: Use standalone 'sysconfig' module
Since 'distutils' will be removed in Python 3.12, use the standalone
'sysconfig' module that was introduced in Python 3.2.
See https://peps.python.org/pep-0632/
Change-Id: I7a89516b03af01cb7ca5178c210bef8248c55c26
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9591
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Michael Jeanson [Mon, 27 Feb 2023 22:35:30 +0000 (17:35 -0500)]
fix: 1 byte overflow in UuidView
The string() method of UuidView allocates a buffer of BT_UUID_STR_LEN
bytes and then calls bt_uuid_to_str() that prints a C string of
BT_UUID_STR_LEN + 1 bytes (including the terminating null byte ('\0'))
which results in a 1 byte overflow.
Directly use an std::string instead of a char array, resize it to
BT_UUID_STR_LEN which implicitly adds the terminating null byte and then
use the data method to write to the underlying C string.
Change-Id: Ifa6f0322c219e28dec78b8680763b3126a1e513a
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9594
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Tue, 7 Mar 2023 18:59:39 +0000 (13:59 -0500)]
error.c: clean-up: remove dead error cause clean-up code
Coverity warns of logically dead code in error.c:
1506395 Logically dead code
The indicated dead code may have performed some action; that action will never occur.
In bt_error_append_cause_from_component_class: Code can never be reached because of a logical contradiction (CWE-561)
`cause` is indeed always NULL at the `end` label since it either failed
to be allocated or its ownership was transferred to the `causes` array.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie1c746b9fe6d6202cd6c3baaef39516a5e902471
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9614
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Sat, 18 Feb 2023 03:44:26 +0000 (22:44 -0500)]
ctf-writer: avoid using NULL pointer in BT_CTF_TO_COMMON
When running the test tests/ctf-writer/test_ctf_writer in a build with
-fsanitize=undefined, I see:
/home/simark/src/babeltrace/src/ctf-writer/trace.c:1457:9: runtime error: member access within null pointer of type 'struct bt_ctf_trace'
#0 0x7f8f57e34ab4 in bt_ctf_trace_set_environment_field_integer /home/simark/src/babeltrace/src/ctf-writer/trace.c:1457
#1 0x563de0f9234a in main /home/simark/src/babeltrace/tests/ctf-writer/ctf_writer.c:1659
#2 0x7f8f5723c78f (/usr/lib/libc.so.6+0x2378f)
#3 0x7f8f5723c849 in __libc_start_main (/usr/lib/libc.so.6+0x23849)
#4 0x563de0f87834 in _start (/home/simark/build/babeltrace/tests/ctf-writer/.libs/ctf_writer+0x44834)
This happens within the BT_CTF_TO_COMMON macro. My first attempt was
something like this:
#define BT_CTF_TO_COMMON(_obj) \
({ typeof(_obj) _obj_local = _obj; _obj_local ? &_obj_local->common : NULL; })
However, it gives this warning, which I did not find a way to work
around:
/home/simark/src/babeltrace/src/ctf-writer/fields.c: In function 'bt_ctf_field_variant_create':
/home/simark/src/babeltrace/src/ctf-writer/utils.h:17:57: error: declaration of '_obj_local' shadows a previous local [-Werror=shadow]
17 | #define BT_CTF_TO_COMMON(_obj) ({ typeof(_obj) _obj_local = _obj; _obj_local ? &_obj_local->common : NULL; })
| ^~~~~~~~~~
Since the BT_CTF_FROM_COMMON macro already appears to assume that the
common field is at offset 0, I think we can do the same for
BT_CTF_TO_COMMON, and just cast the pointer directly the other way
around.
Although `_obj` is mentioned twice in the macro definition, one of them
is in the typeof expression. So, should there be any side-effects in
`_obj`, they will be executed only once. At least, that's my
understanding from this SO answer:
https://stackoverflow.com/questions/
11504629/side-effects-within-a-typeof-expression
Change-Id: I595fe888ef99daa0f0a4d657aa227c2b52457941
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9587
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Sat, 18 Feb 2023 03:13:16 +0000 (22:13 -0500)]
ctf-writer: avoid undefined behavior left shift
Running the plugins/src.ctf.fs/succeed/test_succeed test in a build with
-fsanitize=undefined, I get a failure:
# Generating trace 'simple'
ERROR: "/home/simark/build/babeltrace/tests/plugins/src.ctf.fs/succeed/gen-trace-simple" "/tmp/tmp.QvrLAHYWXw" failed
not ok 3 - Generated trace 'simple' gives the expected output
This is because of this undefined behavior error:
$ /home/simark/build/babeltrace/tests/plugins/src.ctf.fs/succeed/gen-trace-simple /tmp/yo
/home/simark/src/babeltrace/src/ctf-writer/stream.c:483:29: runtime error: shift exponent 64 is too large for 64-bit type 'long long unsigned int'
#0 0x7feddba0c21d in update_clock_value /home/simark/src/babeltrace/src/ctf-writer/stream.c:483
#1 0x7feddba0c918 in visit_field_update_clock_value /home/simark/src/babeltrace/src/ctf-writer/stream.c:555
#2 0x7feddba0cd74 in visit_field_update_clock_value /home/simark/src/babeltrace/src/ctf-writer/stream.c:626
#3 0x7feddba0ced2 in visit_event_update_clock_value /home/simark/src/babeltrace/src/ctf-writer/stream.c:663
#4 0x7feddba0e129 in set_packet_context_timestamps /home/simark/src/babeltrace/src/ctf-writer/stream.c:818
#5 0x7feddba0ebca in auto_populate_packet_context /home/simark/src/babeltrace/src/ctf-writer/stream.c:908
#6 0x7feddba146aa in bt_ctf_stream_flush /home/simark/src/babeltrace/src/ctf-writer/stream.c:1650
#7 0x55940807b535 in write_stream /home/simark/src/babeltrace/tests/plugins/src.ctf.fs/succeed/gen-trace-simple.c:109
#8 0x55940807b75b in main /home/simark/src/babeltrace/tests/plugins/src.ctf.fs/succeed/gen-trace-simple.c:119
#9 0x7feddae3c78f (/usr/lib/libc.so.6+0x2378f)
#10 0x7feddae3c849 in __libc_start_main (/usr/lib/libc.so.6+0x23849)
#11 0x559408079f74 in _start (/home/simark/build/babeltrace/tests/plugins/src.ctf.fs/succeed/.libs/gen-trace-simple+0x2af74)
Fix that by avoiding the left shift if new_val_size is 64. If
new_val_size is 64, leave pow2 at 0, which is what I suppose is the
behavior we are relying on.
Change-Id: I8814773e24c53094be5af613664e6ed4b9ef2d82
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9586
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Sat, 18 Feb 2023 02:17:15 +0000 (21:17 -0500)]
ctf: avoid using computing offset from nullptr pointer
When running the test_trace_collection_message_iterator.py test in a
build with -fsanitize=undefined, I see:
/home/simark/src/babeltrace/src/plugins/ctf/common/metadata/visitor-generate-ir.cpp:1143:30: runtime error: member access within null pointer of type 'struct ctf_node'
This happens when `node_field_class_declarator` is nullptr. Avoid this
by using `node_field_class_declarator` once we know it's non-nullptr.
Change-Id: I585e5b17af7e1a16a217ef46c0a49fae901dcae8
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9513
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Simon Marchi [Sun, 22 Jan 2023 19:49:27 +0000 (14:49 -0500)]
lib: remove one BT_LIB_LOGD from init_error_cause
This BT_LIB_LOGD is problematic when debug logging is enabled. It
prints a half-constructed bt_error_cause object, which may cause an
assertion failure, as seen here:
#3 0x00007f6defd91105 in bt_common_abort () at common.c:2111
#4 0x00007f6defd995c6 in bt_common_field_class_type_string (class_type=<optimized out>) at ../../src/common/common.h:547
#5 format_field (field=<optimized out>, prefix=<optimized out>, extended=<optimized out>, buf_ch=<optimized out>) at lib-logging.c:366
#6 handle_conversion_specifier_bt (priv_data=priv_data@entry=0x0, buf_ch=buf_ch@entry=0x7fff0bf60d80, avail_size=<optimized out>, out_fmt_ch=out_fmt_ch@entry=0x7fff0bf60d78, args=args@entry=0x7fff0bf60e40) at lib-logging.c:1401
#7 0x00007f6defdcddd4 in bt_common_custom_vsnprintf (buf=0x7f6def96a740 "Initialized error cause: addr=0x55c0f6232340, actor-type=COMPONENT, module-name=\"\", partial-msg=\"\", comp-name=\"(null)\"", buf_size=16384, intro=33 '!', handle_specifier=0x7f6defd99320 <handle_conversion_specifier_bt>, priv_data=0x0,
fmt=<optimized out>, args=0x7fff0bf60e40) at common.c:1728
#8 0x00007f6defd9c275 in bt_lib_log_v (func=0x7f6defdd0190 <__func__.28> "init_error_cause", file=0x7f6defdcf6b0 "error.c", line=158, lvl=2, tag=0x7f6defdcf6b8 "LIB/ERROR", fmt=0x7f6defdcf6c2 "Initialized error cause: %!+r", args=0x7fff0bf60e40) at lib-logging.c:1491
#9 0x00007f6defd9c35c in bt_lib_log (func=func@entry=0x7f6defdd0190 <__func__.28> "init_error_cause", file=file@entry=0x7f6defdcf6b0 "error.c", line=line@entry=158, lvl=lvl@entry=2, tag=tag@entry=0x7f6defdcf6b8 "LIB/ERROR", fmt=fmt@entry=0x7f6defdcf6c2 "Initialized error cause: %!+r") at lib-logging.c:1503
#10 0x00007f6defd928d2 in init_error_cause (cause=cause@entry=0x55c0f6232340, actor_type=actor_type@entry=BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT) at error.c:158
#11 0x00007f6defd93296 in create_error_cause_component_actor (line_no=102, file_name=0x7f6dedfb7638 "bt2/native_bt_log_and_append_error.h", comp=0x55c0f66f18d0) at error.c:277
#12 bt_error_append_cause_from_component (error=0x55c0f66f1d10, self_comp=self_comp@entry=0x55c0f66f18d0, file_name=file_name@entry=0x7f6dedfb7638 "bt2/native_bt_log_and_append_error.h", line_no=line_no@entry=102, msg_fmt=msg_fmt@entry=0x7f6dedfb70da "%s", args=args@entry=0x7fff0bf60fa0) at error.c:512
In this specific case, the component class type value passed to
bt_common_component_class_type_string is uninitialized and invalid.
Remove that logging statement. Each caller already calls BT_LIB_LOGD
again with the fully constructed object, so this BT_LIB_LOGD in
init_error_cause would not bring anything useful anyway.
Change-Id: I8a56142e6a1d70017f1a50f6c93dff623a08f3bf
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/9585
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
This page took 0.053658 seconds and 4 git commands to generate.