freebsd-nq/cddl/contrib/opensolaris
Mark Johnston 105fd928b0 libctf: Improve check for duplicate SOU definitions in ctf_add_type()
When copying a struct or union from one CTF container to another,
ctf_add_type() checks whether it matches an existing type in the
destination container.  It does so by looking for a type with the same
name and kind as the new type, and if one exists, it iterates over all
members of the source type and checks whether a member with matching
name and offset exists in the matched destination type.  This can
produce false positives, for example because member types are not
compared, but this is not expected to arise in practice.  If the match
fails, ctf_add_type() returns an error.

The procedure used for member comparison breaks down in the face of
anonymous struct and union members.  ctf_member_iter() visits each
member in the source definition and looks up the corresponding member in
the desination definition by name using ctf_member_info(), but this
function will descend into anonymous members and thus fail to match.
Fix the problem by introducing a custom comparison routine which does
not assume member names are unique.  This should also be faster for
types with many members; in the previous scheme, membcmp() would perform
a linear scan of the desination type's members to perform a lookup by
name.  The new routine steps through the members of both types in a
single loop.

PR:		258763
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2021-10-04 12:28:22 -04:00
..
cmd dtrace.1: Document a couple of preprocessor-related options 2021-09-07 14:04:50 -04:00
common libctf: Improve check for duplicate SOU definitions in ctf_add_type() 2021-10-04 12:28:22 -04:00
head
lib dtrace: fix an out of bound read and a NULL pointer increment 2021-06-17 13:52:32 -04:00
tools/ctf Merge OpenZFS support in to HEAD. 2020-08-25 02:21:27 +00:00
OPENSOLARIS.LICENSE