"abilint --show-type-use <type-id> <abixml-file>" is a facility that
shows how a type defined in an abixml file is used. That is, it emits
a textual representation of how the use a type is used up until the
function or global variable that constitutes an entry point in the API
corpus. Here is an example of its use:
test-read-write$ abilint --noout --show-type-use type-id-5 test17.xml
Type ID 'type-id-5' is for type 'enum E'
The usage graph for that type is:
| -> enum E -> E S::m2 -> class S -> S* -> method void S::S()
| -> enum E -> E S::m2 -> class S -> S* -> method void S::__base_ctor ()
| -> enum E -> E S::m2 -> class S -> S* -> method void S::__comp_ctor ()
| -> enum E -> E S::m2 -> class S -> S* -> method void S::S(S&)
| -> enum E -> E S::m2 -> class S -> S* -> S& -> method void S::S(S&)
| -> enum E -> E S::m2 -> class S -> S* -> S& -> S var
| -> enum E -> E S::m2 -> class S -> S* -> S& -> E S::m2 -> class S -> S* -> method void S::S()
| -> enum E -> E S::m2 -> class S -> S* -> S& -> E S::m2 -> class S -> S* -> method void S::__base_ctor ()
| -> enum E -> E S::m2 -> class S -> S* -> S& -> E S::m2 -> class S -> S* -> method void S::__comp_ctor ()
| -> enum E -> E S::m2 -> class S -> S* -> S& -> E S::m2 -> class S -> S* -> method void S::S(S&)
| -> enum E -> E S::m2 -> class S -> S* -> S& -> E S::m2 -> class S -> S* -> S& -> method void S::S(S&)
| -> enum E -> E S::m2 -> class S -> S* -> S& -> E S::m2 -> class S -> S* -> S& -> S var
$
The screenshot above should be self explanatory.
This facility is useful to analyse type usage and find potential
issues in how libabigail represents some types.
To activate this feature, one needs to configure the package with the
configure option "--enable-show-type-use-in-abilint".
* configure.ac: Define the --enable-show-type-use-in-abilint
configure option. It defines the WITH_SHOW_TYPE_USE_IN_ABILINT
macro.
* include/abg-reader.h (read_translation_unit): Add an overload
that takes the read context.
(get_types_from_type_id, get_artifact_used_by_relation_map):
Declare new functions.
* src/abg-reader.cc (get_types_from_type_id)
(get_artifact_used_by_relation_map): Declare these functions as
friend of the read_context type.
(read_context::m_artifact_used_by_map):
(read_context::key_type_decl): Replace the shared_ptr<type_base>
type of the first parm by the equivalent type_base_sptr type.
(read_context::{record_artifact_as_used_by,
record_artifacts_as_used_in_fn_decl,
record_artifacts_as_used_in_fn_type}): Add new methods guarded by
the WITH_SHOW_TYPE_USE_IN_ABILINT macro.
(get_types_from_type_id, get_artifact_used_by_relation_map): Define
new functions guarded by the WITH_SHOW_TYPE_USE_IN_ABILINT macro.
(read_translation_unit): Define new overload.
(RECORD_ARTIFACT_AS_USED_BY, RECORD_ARTIFACTS_AS_USED_IN_FN_DECL)
(RECORD_ARTIFACTS_AS_USED_IN_FN_TYPE): Define new macros.
(build_function_decl, build_var_decl, build_qualified_type_decl)
(build_pointer_type_def, build_reference_type_def)
(build_function_type, build_array_type_def, build_enum_type_decl)
(build_typedef_decl, build_class_decl, build_union_decl): Use the
macros above to mark the relevant sub-types as used by the
artifact being built.
* tools/abilint.cc (struct artifact_use_relation_tree): Define new
type, guarded by the WITH_SHOW_TYPE_USE_IN_ABILINT macro.
(fill_artifact_use_tree, build_type_use_tree, emit_trace)
(emit_artifact_use_trace, emit_artifact_use_trace)
(show_how_type_is_used): Define static functions guarded by the
WITH_SHOW_TYPE_USE_IN_ABILINT macro.
(display_usage): Add doc string for the --show-type-use option,
guarded by the WITH_SHOW_TYPE_USE_IN_ABILINT macro.
(parse_command_line): Parse the --show-type-use option, guarded by
the WITH_SHOW_TYPE_USE_IN_ABILINT macro.
(main): Slight re-organisation to make the abixml file reading use
a read_context. That read context is then used to analyze how a
given type is used whenever the --show-type-use option is used.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When using the musl C library fts is optional. So we need to detect
its presence by looking at the fts-standalone pkgconfig module.
This patch does that.
This comes from Gentoo bug https://bugs.gentoo.org/831571
* configure.ac: Invoke AC_CANONICAL_HOST to compute the host_cpu,
host_vendor, host_os parts of the 'host" variable. Then if the
host_os ends up with "musl" then, check for the fts-standalone
pkgconfig module and record the fts library into
FTS_{LIBS,CFLAGS}.
* src/Makefile.am: Link to $FTS_LIBS and use $FTS_CFLAGS for
compilation.
* tools/Makefile.am: Likewise.
* tools/abisym.cc: Include libgen.h
* tools/kmidiff.cc: Remove useless fts.h header file.
Signed-off-by: David Seifert <soap@gentoo.org>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
... as is now documented in 'CONTRIBUTING'.
* tools/fedabipkgdiff: Handle 'koji.ConfigurationError'.
* configure.ac: Likewise.
* CONTRIBUTING: Document "fedabipkgdiff testing".
Documenting/providing a way to enable such testing, this commit can be
considered a sequel to commit 90d236a033
"Bug 22076 - Disable fedabipkgdiff for old koji clients", for Mark Wielaard's
PR22076 "runtestfedabipkgdiff.py fails on debian-amd64".
Signed-off-by: Thomas Schwinge <thomas@codesourcery.com>
If no 'rpm' is available, we currently get:
[...]
checking for rpm... no
../git/configure: line 13119: rpm: command not found
configure: detected rpm version:
configure: rpm support in abipkgdiff is disabled
[...]
Here is the configuration of the package:
[...]
Enable rpm support in abipkgdiff : no
Enable rpm 4.15 support in abipkgdiff tests : no
[...]
Notice intermixed error output: 'rpm: command not found'.
If Ubuntu focal 'rpm' 4.14.2.1+dfsg1-1build2 is available, we currently get:
[...]
checking for rpm... yes
configure: detected rpm version: 4.14.2.1
configure: rpm support in abipkgdiff is enabled
configure: rpm 4.15 support in abipkgdiff tests is enabled
[...]
Here is the configuration of the package:
[...]
Enable rpm support in abipkgdiff : yes
Enable rpm 4.15 support in abipkgdiff tests : yes
[...]
Notice wrong 4.15+ version detection (due to '[[ "$rpmversion" > "4.14.0" ]]'),
which is satisfied by '4.14.2.1'. (Comparing versions with shell '[['
generally is fragile; instead use 'autoconf-archive/ax_compare_version.m4'
or similar?)
Also, 'configure'ing with '--disable-rpm415' doesn't work; same output as
before. That's due to commit 26c41c060b
"Fix thinko in configure.ac", where either there was no thinko in fact (the
original idea, I suppose, was only if 'test x$ENABLE_RPM = xyes' to do the
4.15+ 'auto' checking?), and/or a typo: instead of 'test x$ENABLE_RPM = xyes',
the first conditional should 'test x$ENABLE_RPM415 = xyes'?
And, 'configure'ing with '--enable-rpm415' doesn't raise a hard error if 'rpm'
actually isn't 4.15+.
But all that said, we don't actually need to check for rpm 4.15+ version, but
instead may simply check for the rpm/zstd support that we need: 'rpm2cpio'.
* configure.ac: Instead of for rpm 4.15+ version, test actual
rpm/zstd support.
* tests/test-diff-pkg.cc: Adjust.
Signed-off-by: Thomas Schwinge <thomas@codesourcery.com>
If 'configure' finds some Python koji module, but it's "insufficient" per
the testing once added in commit 90d236a033
"Bug 22076 - Disable fedabipkgdiff for old koji clients", we currently get,
for example:
[...]
checking python3 module: koji... yes
[...]
checking checking if koji client is recent enough ...... Traceback (most recent call last):
File "<string>", line 3, in <module>
File "[...]/koji/__init__.py", line 2016, in read_config
raise ConfigurationError("no configuration for profile name: %s"
koji.ConfigurationError: no configuration for profile name: koji
no, disabling fedpkgdiff
[...]
Here is the configuration of the package:
[...]
Enable fedabipkgdiff : auto
[...]
Note repeated 'checking' and '...', intermixed error output, 'fedpkgdiff'
typo, final 'auto' result.
Changing that to:
[...]
checking if koji client is recent enough... no
configure: WARNING: disabling fedabipkgdiff
[...]
Here is the configuration of the package:
[...]
Enable fedabipkgdiff : no
[...]
... with 'config.log':
[...]
configure:13774: checking if koji client is recent enough
configure:13784: result: no
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "[...]/koji/__init__.py", line 2016, in read_config
raise ConfigurationError("no configuration for profile name: %s"
koji.ConfigurationError: no configuration for profile name: koji
configure:13792: WARNING: disabling fedabipkgdiff
[...]
Similarly, with explicit '--enable-fedabipkgdiff', we currently get:
[...]
checking checking if koji client is recent enough ...... Traceback (most recent call last):
File "<string>", line 3, in <module>
File "[...]/koji/__init__.py", line 2016, in read_config
raise ConfigurationError("no configuration for profile name: %s"
koji.ConfigurationError: no configuration for profile name: koji
no, disabling fedpkgdiff
[...]
Here is the configuration of the package:
[...]
Enable fedabipkgdiff : yes
[...]
... instead of a fatal error.
Changing that to:
[...]
checking if koji client is recent enough... no
configure: error: unsuitable koji client
* configure.ac: Tune fedabipkgdiff dependencies detection.
Signed-off-by: Thomas Schwinge <thomas@codesourcery.com>
Add a command line option to display the version number of the ABIXML
output format.
* doc/manuals/abidw.rst: Document the --abixml-version command
line option.
* configure.ac (ABIXML_VERSION_MAJOR, ABIXML_VERSION_MINOR):
Define these two new autoconf variables.
* include/abg-config.h (abigail_get_abixml_version): Declare new
function.
* include/abg-tools-utils.h (get_abixml_version_string): Declare
new function.
* include/abg-version.h.in (ABIGAIL_ABIXML_VERSION_MAJOR)
(ABIGAIL_ABIXML_VERSION_MINOR): Define new preprocessor macros.
* src/abg-config.cc (config::config): Initialize
config::m_format_{minor,major} using the newly defined
preprocessor macros ABIGAIL_ABIXML_VERSION_M{IN,AJ}OR.
* src/abg-tools-utils.cc (get_abixml_version_string): Define new
function.
* tools/abidw.cc (options::display_abixml_version): Define new
data member.
(options::options): Initialize it.
(display_usage): Emit a help string for the new --abixml-version
option.
(parse_command_line): Parse the --abixml-version string.
(main): Emit the abixml version when asked.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
CTF (C Type Format) is a lightweight debugging format that provides
information about C types and the association between functions and
data symbols and types. It is designed to be very compact and
simple. More can be learned about it at https://ctfstd.org.
This patch introduces support in libabigail to extract ABI information
from CTF stored in ELF files.
A few notes on this implementation:
- The implementation is complete in terms of CTF support. Every CTF
feature is processed and handled to generate libabigail IR. This
includes basic types, typedefs, pointer, array and struct types.
The CTF record of data objects (variables) and functions are also
used in order to generate the corresponding libabigail IR artifacts.
- The decoding of CTF data is done using the libctf library which is
part of binutils. In order to link with it, binutils shall be built
with --enable-shared for libctf.so to become available.
- This initial implementation is aimed to simplicity. We have not
tried to resolve any and every corner case that may require special
handling. We have observed that the DWARF front-end (which is
naturally way more complex as the scope is way bigger) is plagued
with hacks to handle such situations. However, for the CTF support
we prefer to proceed in a simpler and more modest way: we will
handle these problems if/when we find them. The fact that CTF only
supports C (currently) certainly helps there.
- Likewise, in this basic support we are not handling symbol
suppressions or other goodies that libabigail provides. We are new
to libabigail and ABI analysis, and at this point we simply don't
have a clear picture about what is most useful/relevant to support
or not. With the maintainer's blesssing, we will tackle that
functionaly after this basic support is applied upstream.
- The implementation in abg-ctf-reader.{cc,h} is pretty much
self-contained. As a result there is some duplication in terms of
ELF handling with the DWARF reader, but since that logic is very
simple and can be easily implemented, we don't consider this to be a
big deal (for now.) Hopefully the maintainers agree.
- The libabigail tools assume that ELF means to always use DWARF to
generate the ABI IR. We added a new command-line option --ctf to
the tools in order to make them to use the CTF debug info instead.
We are definitely not sure whether this is the best user interface.
In fact I would be suprised if it was ;)
- We added support for --ctf to both abilint and abidiff. We are not
sure whether it would make sense to add support for CTF to the other
tools. Feedback welcome.
- We are pondering about what to do in terms of testing. We have
cursory tested this implementation using abilint and abidiff. We
know we are generating IR corpus that seem to be ok. It would be
good however to be able to run the libabigail testsuites using CTF.
However the testsuites may need some non-trivial changes in order to
make this possible. Let's talk about that :)
* configure.ac: Check for libctf.
* src/abg-ctf-reader.cc: New file.
* include/abg-ctf-reader.h: Likewise.
* src/Makefile.am (libabigail_la_SOURCES): Add abg-ctf-reader.cc
conditionally.
* include/Makefile.am (pkginclude_HEADERS): Add abg-ctf-reader.h
conditionally.
* tools/abilint.cc (struct options): New option `use_ctf'.
(display_usage): Documentation for --ctf.
(parse_command_line): Handle --ctf.
(main): Honour --ctf.
* tools/abidiff.cc (struct options): New option `use_ctf'.
(display_usage): Documentation for --ctf.
(parse_command_line): Handle --ctf.
(main): Honour --ctf.
* doc/manuals/abidiff.rst: Document --ctf.
* doc/manuals/abilint.rst: Likewise.
Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This configure option adds the possibility to debug the type
canonicalization process specifically.
When this new configure option is turned on, in
ir::get_canonical_type_for, when the type T, candidate for
canonicalization is compared to a given canonical type C, the
comparison is done twice; once using structural equality and once
using canonical equality whenever it's possible. For all the
sub-types of T and C, structural equality and canonical equality must
yield the same result. Otherwise, an error message is emitted and the
process aborts.
This all happens when using the abidw program with the --enable-tc or
--enable-type-canonicalization option.
This has proven to be very helpful to detect type canonicalization issues.
For instance, here is a trace of canonicalization issue that was
detected thanks to this patch:
$ build/tools/abidw --debug-tc /usr/lib64/libwiretap.so.11.0.8
structural & canonical equality different for type: function type void (wtap*)
in compare_types_during_canonicalization at: /home/dodji/git/libabigail/PR28364/src/abg-ir.cc:13575: execution should not have reached this point!
Abandon (core dumped)
This means that right after canonicalizing the type "void (wtap*)",
structural and canonical equality yield different results. So it
means there is a problem with that type specifically that makes its
canonicalization "go wrong". This requires further debugging to
understand, but at least, we are super close to the root cause of the
canonicalization problem.
* configure.ac: Support the new
--enable-debug-type-canonicalization option. Define macro
WITH_DEBUG_TYPE_CANONICALIZATION accordingly.
* doc/manuals/abidw.rst: Update documentation.
* include/abg-ir.h
(environment::debug_type_canonicalization_is_on): Declare new
member function if WITH_DEBUG_TYPE_CANONICALIZATION is defined.
* src/abg-ir-priv.h
(environment::priv::{use_canonical_type_comparison_,
debug_type_canonicalization_}): Define new data members if
WITH_DEBUG_TYPE_CANONICALIZATION is defined.
(environment::priv::priv): Initialize them.
* src/abg-ir.cc (try_canonical_compare): When
WITH_DEBUG_TYPE_CANONICALIZATION is defined, perform comparison
using either structural or canonical equality depending on the
environment::priv::use_canonical_type_comparison_ flag.
(environment::debug_type_canonicalization_is_on): Define member
function when WITH_DEBUG_TYPE_CANONICALIZATION is defined.
(compare_types_during_canonicalization): Define new function.
(type_base::get_canonical_type_for): Use the new function
compare_types_during_canonicalization.
* tools/abidw.cc (options::debug_type_canonicalization): Define
new data member.
(option::option): Initialize it.
(display_usage): Add help string for --debug-tc.
(parse_command_line): Support new option --debug-tc or
--debug-type-canonicalization.
(load_corpus_and_write_abixml): Turn type canonicalization
debugging on if --enable-tc is provided.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
During the self comparison triggered by "abidw --abidiff <binary>",
some comparison errors can happen when canonicalizing types that are
"de-serialized" from the abixml that was serialized from the input
binary.
This patch adds some debugging checks and messaging to emit a message
when a type from the abixml appears to not "match" the original type
from the initial corpus it originated from.
This is the more detailed description:
Let's consider a type T coming from the corpus of the input binary.
That input corpus is serialized into abixml and de-serialized again
into a second corpus that we shall name the abixml corpus. From that
second corpus, let's consider the type T' that is the result of
serializing T into abixml and de-serializing it again. T is said to
be the original type of T'. If T is a canonical type, then T' should
equal T. Otherwise, if T is not a canonical type, its canonical type
should equal the canonical type of T'.
For the sake of simplicity, let's consider that T is a canonical
type. During the canonicalization of T', T' should equal T. Each and
every canonical type coming from the abixml corpus should be equal to its
original type from the binary corpus.
If a T' is different from its original type T, then there is an
"equality problem" between T and T'. In other words, there is a
mismatch between T and T'. We want to be notified of that problem so
that we can debug it further and fix it.
So this patch introduces the option "abidw --debug-abidiff <binary>"
to trigger the "debug self comparison mode". At canonicalization
time, we detect that we are in that debug self comparison mode and
during canonicalization of types from the abixml corpus, it detects
when they compare different from their counterpart from the original
corpus.
This debugging capability can be enabled at configure time with a new
--enable-debug-self-comparison configure option. That option defines
a new WITH_DEBUG_SELF_COMPARISON compile time macro that is used to
conditionally compile the implementation of this debugging feature.
So, one example of this might look like this:
abidw --debug-abidiff bin:
error: problem detected with type 'typedef Vmalloc_t' from second corpus
error: problem detected with type 'Vmalloc_t*' from second corpus
[...]
So that means the "typedef Vmalloc_t" read from the abixml compares
different from its original type where it should not.
So armed with this new insight, I know I need to debug that comparison
in particular to see why it wrongly results in two different types.
* doc/manuals/abidw.rst: Add documentation for the --debug-abidiff
option.
* include/abg-ir.h (environment::{set_self_comparison_debug_input,
get_self_comparison_debug_inputs, self_comparison_debug_is_on}):
Declare new methods.
* configure.ac: Define a new --enable-debug-self-comparison option
that is disabled by default. That option defines a new
WITH_DEBUG_SELF_COMPARISON preprocessor macro.
* src/abg-ir.cc
(environment::priv::{first_self_comparison_corpus_,
second_self_comparison_corpus_, self_comparison_debug_on_}): New
data members. Also, re-indent the data members.
(environment::{set_self_comparison_debug_input,
get_self_comparison_debug_inputs, self_comparison_debug_is_on}):
Define new method.
(type_base::get_canonical_type_for): In the "debug self comparison
mode", if a type coming from the second corpus compares different
from its counterpart coming from the first corpus then log a debug
message.
* src/abg-dwarf-reader.cc (read_debug_info_into_corpus): When
loading the first corpus, if the debug self comparison mode is on,
then save that corpus on the side in the environment.
* src/abg-reader.cc (read_corpus_from_input): When loading the
second corpus, if the debug self comparison mode is on, then save
that corpus on the side in the environment.
* tools/abidw.cc: Include the config.h file for preprocessor
macros defined at configure
(options::debug_abidiff): New data member.
(parse_command_line): Parse the --debug-abidiff option.
(load_corpus_and_write_abixml): Switch the self debug mode on when
the --debug-abidiff option is provided. Use a read_context for
the abixml loading. That is going to be useful for subsequent
patches.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
The optional zip archive feature was broken when the concept of
environment was introduced by commit b2e5366d3 back in 2015. Since it
wouldn't even compile and nobody noticed, we are fairly sure nobody
uses that feature. Therefore, we decided to remove it rather than fix
it.
* configure.ac: remove --enable-zip-archive option and logic
associated with it.
* include/abg-libzip-utils.h: Remove.
* src/abg-libzip-utils.cc: Likewise.
* include/Makefile.am: remove reference to include/abg-libzip-utils.h
that no longer exists.
* src/Makefile.am: remove reference to src/abg-libzip-utils.cc that no
longer exists.
* relicensing-scripts/file-licenses.orig.txt: remove references to
files that no longer exist.
* relicensing-scripts/files-with-lgplv3.txt: remove references to
files that no longer exist.
* tests/test-write-read-archive.cc: Remove because it tests code
that no longer exists.
* tests/Makefile.am: remove reference to tests that no longer exist.
* include/abg-reader.h: remove conditionally compiled code for zip
archives.
* include/abg-tools-utils.h: remove conditionally compiled code for
zip archives.
* src/abg-corpus.cc: remove conditionally compiled code for zip
archives.
* src/abg-reader.cc: remove conditionally compiled code for zip
archives.
* src/abg-tools-utils.cc: remove conditionally compiled code for zip
archives.
* src/abg-writer.cc: remove conditionally compiled code for zip
archives.
* tools/abidiff.cc: remove conditionally compiled code for zip
archives.
* tools/abilint.cc: remove conditionally compiled code for zip
archives.
* tools/abiar.c: Remove.
* tools/Makefile.am: remove references to abiar a utility that no
longer has a reason for existing.
Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* configure.ac: Define if HAS_DW_FORM_line_strp if the
DW_FORM_line_strp enumerator is present.
* src/abg-dwarf-reader.cc (form_is_DW_FORM_line_strp): Define new
static function.
(compare_dies_string_attribute_value): Use it.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
As the Enterprise Linux 6 platform has now essentially reached it's
end of life for what it's worth (the Fedora EPEL6 distribution is not
maintained anymore) nothing ties us to using C++03 only anymore.
So, I think it makes sense to move the code base to the C++11
standard.
Why C++11 and not, say, C++14 or more? Well, the more direct reason I
see is that we need to support long life cycle platforms, the older
one being Enterprise Linux 7 currently. This is the Fedora EPEL7
distribution, in concrete terms. And in that distribution, the
compiler is GCC 4.8.x. And it supports C++11.
In practise, nothing changes in the code that is already there.
The new code however can use C++11 constructs just fine.
I have updated the CONTRIBUTING file to write down some of the
unwritten cultural biases of the current code base. Hopefully these
few lines will help to shed some light on the choices made so far.
The update to that file also enacts the use of C++11 and sets some
limits to what we expects in terms of what the code base would look
like.
configure.ac is modified to unconditionally pass -std=c++11 to the
compiler and express that in the configuration text displayed at the
end of the configuration stage.
Some Makefile.am files are updated accordingly.
* CONTRIBUTING: Enact use of c++11. Also, we favor those who
read/debug/maintain the code as opposed to those who write it ;-)
* configure.ac: Switch to c++11 unconditionally.
* src/Makefile.am: Adjust.
* tests/Makefile.am: Adjust.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
It's useful to be able to force the build system into avoiding the use
of rpm 4.15 version or higher. That version of RPM is the one that
supports RPMs from Fedora 31 or higher. Those RPMs use the zstd
compression scheme. Prior to Fedora 31, RPM were not using the zstd
compression scheme. So, systems with rpm version lower than 4.15
cannot deal with RPMs coming from Fedora 31 or higher. So on those
systems, some regression tests of libabigail who use RPMs from Fedora
33 will fail.
With this patch, one can use the --disable-rpm415 option of the
configure script to prevent those tests from running on those pre 4.15
rpm systems.
* configure: Introduce the --{en, dis}able-rpm415 option.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When GCC 10 artificially generates a translation unit, the path/name
of the translation unit as given by the DW_AT_name attribute of the
translation unit DIE is the string "<artificial>".
Libabigail expects that translation units have unique file paths so
having several artificially generated translation units like this one
with the same name makes hell break loose down the road.
This patch suffixes the name of artificial DIE with their die offset
number to have a unique path name for artificially generated
translation units.
* configure.ac: Detect if we are running on RPM >= 4.15. If yes,
then define the preprocessor macro RPM_4_15. If that macro is
defined then test-diff-pkg.cc can support RPMs from Fedora >= 31
as those are compressed with zstd. Earlier RPM versions don't
support that compression scheme.
* src/abg-dwarf-reader.cc (build_translation_unit_and_add_to_ir):
Suffix the offset of the translation unit to its name when that
name is "<artificial>".
* tests/data/test-diff-pkg/mesa-libGLU-9.0.1-3.fc33.x86_64.rpm:
New binary test input.
* tests/data/test-diff-pkg/mesa-libGLU-debuginfo-9.0.1-3.fc33.x86_64.rpm: Likewise.
* tests/data/test-diff-pkg/mesa-libGLU-9.0.1-3.fc33.x86_64.self-check-report-0.txt:
New reference output for the binary test input above.
* tests/data/Makefile.am: Add the new test inputs above to source
distribution.
* tests/test-diff-pkg.cc (in_out_specs): Add the binary test
inputs above to source distribution if we are running on an RPM
version >= 4.15.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
The symptom of the issue at hand is that sometimes there can be types
missing from the abixml output. This happens when analysing some C++
code bases.
The core of the issue is the following. Support we have a type
"struct S" defined somewhere as:
struct S // #0
{
int dm1;
char dm2;
};
S s;
Suppose that in another translation unit, we have the class 'S' being
extended to add a member type to it:
struct S // #1
{
typedef int dm1_type;
};
typedef S::dm1_type Integer;
Integer something;
When emitting the abixml for the codebase, the definition of the
typedef S::dm1_type can be missing.
Note that in location #1, struct S is considered declaration-only.
It's definition is in another translation unit, in location #0.
So the abixml writer emits the 'struct S' defined in location #0, but
forgets to emit the 'struct S' in #1, which is indirectly used for the
sole purpose of using its member type S::dm1_type.
This patch emits the S::dm1_type type that is mistakenly forgotten
today.
Now that the "struct S" of #1 is also emitted, a tangent problem is
uncovered: S in #0 can be wrongly thought to be equivalent to S in #1,
for ABI purposes
This is because of an ODR-based optimization that is used for C++.
That is, the two struct S can be wrongly considered equivalent just
because they have the same name. Note that ODR means "One Definition Rule[1]"
This patch removes the ODR-based optimization and thus fixes many of
the issues uncovered by the previous changes.
The patch also uncovered that some non-static variables were sometimes wrongly
being added to the set of exported variables, while libabigail reads
corpora from abixml. The patch fixes this as well.
[1]: One Definition Rule: https://en.wikipedia.org/wiki/One_Definition_Rule
* include/abg-corpus.h (corpus::{record_canonical_type,
lookup_canonical_type}): Remove function declarations.
* src/abg-corpus-priv.h (corpus::priv::canonical_types_): Remove
data member.
* src/abg-corpus.cc (corpus::{record_canonical_type,
lookup_canonical_type}): Remove functions.
* src/abg-ir.cc (type_eligible_for_odr_based_comparison): Remove
static function.
(type_base::get_canonical_type_for): Don't perform the ODR-based
optimization for C++ anymore.
* src/abg-reader.cc
(read_context&::maybe_add_var_to_exported_decls): Don't add a
variable that hasn't been added to its scope. Otherwise, it means
we added a variable that wasn't yet properly constructed. Also
add a new overload for var_decl_sptr&.
(build_var_decl): Do not add the var to its the set of exported
declaration before we are sure it has been fully constructed and
added to the scope it belongs.
(build_class_decl): Only add *static* data members to the list of
exported declarations.
(handle_var_decl): A var decl seen here is a global variable
declaration. Add it to the list of exported declarations.
* src/abg-writer.cc (write_context::decl_only_type_is_emitted):
Constify parameter.
(write_translation_unit): Do not forget to emit referenced types
that were maybe not canonicalized. Also, avoid using noop_deleter
when it's not necessary.
(write_namespace_decl): Do not forget to emit canonicalized types
that are present in namespaces other than the global namespace.
* tests/runtestslowselfcompare.sh.in: New test that compares
libabigail.so against its own ABIXML representation.
* tests/Makefile.am: Add the new test runtestslowselfcompare.sh to
source distribution. This test is too slow to be run during the
course of 'make check'. It takes more than 5 minutes on my slow
box here. Rather, it can be run using 'make check-self-compare'.
I plan to run this before releases now.
* tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Adjust.
* tests/data/test-annotate/libtest24-drop-fns.so.abi: Likewise.
* tests/data/test-annotate/test0.abi: Likewise.
* tests/data/test-annotate/test13-pr18894.so.abi: Likewise.
* tests/data/test-annotate/test14-pr18893.so.abi: Likewise.
* tests/data/test-annotate/test15-pr18892.so.abi: Likewise.
* tests/data/test-annotate/test17-pr19027.so.abi: Likewise.
* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
Likewise.
* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
Likewise.
* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
Likewise.
* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.
* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi:
Likewise.
* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
* tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi:
Likewise.
* tests/data/test-read-dwarf/PR26261/PR26261-exe.abi: Likewise.
* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi:
Likewise.
* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise.
* tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise.
* tests/data/test-read-dwarf/test0.abi: Likewise.
* tests/data/test-read-dwarf/test0.hash.abi: Likewise.
* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
* tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise.
* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
Likewise.
* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
Likewise.
* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi:
Likewise.
* tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise.
* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
Likewise.
* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.
* tests/data/test-read-write/test28-without-std-fns-ref.xml:
Likewise.
* tests/data/test-read-write/test28-without-std-vars-ref.xml:
Likewise.
* tests/data/test-read-write/test6.xml: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When working in development environments with compiler versions that
might be very bleeding edge (like the Fedora Rawhide distribution) it
might be worthwhile to disable all compiler optimization to have a
better debugging experience. In practice, I bumped into this need
again and again.
So I am adding this ABIGAIL_NO_OPTIMIZATION_DEBUG environment variable
to basically allow the "-g -O0" combination, if need be.
This patch obviously doesn't change any existing behaviour if the user
doesn't set this newly introduced environment variable.
* configure.ac: Set the CXXFLAGS and CFLAGS to "-g -O0 -Wall
-Wextra -Werror" if the ABIGAIL_NO_OPTIMIZATION_DEBUG is set.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Ths warning is no longer triggered and can be reenabled.
* configure.ac: Remove the special clause that disabled
-Werror-overloaded-virtual for Clang builds.
Signed-off-by: Giuliano Procida <gprocida@google.com>
When exporting ABIGAIL_DEVEL=1, add more flags to ABIGAIL_DEVEL that are
suitable for development to find issues during edit/compile/test time.
The subsequent changes to source and test code are needed to make the
code compile with ABIGAIL_DEVEL=yes.
Note, unless bug #25989 is addressed, runtestannotate is failing.
See https://sourceware.org/bugzilla/show_bug.cgi?id=25989 for details.
* configure.ac: add -D_FORTIFY_SOURCE=2 and -D_GLIBCXX_DEBUG
compilation defines if ABIGAIL_DEVEL is set. Note that with GCC 4.8.5,
-D_FORTIFY_SOURCE=2 requires options to be set. So I am setting
the optimization level to -Og.
* src/abg-dwarf-reader.cc (read_context::{compute_canonical_die,
get_or_compute_canonical_die, associate_die_to_decl,
set_canonical_die_offset, schedule_type_for_late_canonicalization,
compare_dies}, get_scope_for_die, add_or_update_union_type)
(read_debug_info_into_corpus, build_ir_node_from_die): Initialize
the 'source' variable.
* tests/test-diff-filter.cc (main): Check the return value of the
system function.
* tests/test-diff-pkg.cc (main): Likewise.
* tests/test-read-write.cc (main): Likewise.
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When exporting ABIGAIL_DEBUG=1, the binaries compiled are especially
suitable for debugging. The CFLAGS and CXXFLAGS that are added reduce
optimization to a reasonable amount and increase debug information levels.
* configure.ac: add ABIGAIL_DEBUG environment variable for
improved debugging capabilities
Signed-off-by: Matthias Maennich <maennich@google.com>
When compiling with clang, several locations in the code emit the
warning -Woverloaded-virtual. That warning is not trivial to fix. In order
to allow CXX=clang++ ABIGAIL_DEVEL=1 development, demote the warning to
not be an error when compiling with clang.
* configure.ac: set -Wno-error-overloaded-virtual for clang++
Signed-off-by: Matthias Maennich <maennich@google.com>
Similarly to asan, tsan and ubsan, add support for msan conditionally at
configure time. This allows us to track down issues caused by using
uninitialized values.
* configure.ac: Add configure options for -fsanitize=memory
Signed-off-by: Matthias Maennich <maennich@google.com>
Similarly to asan and ubsan, add support for tsan conditionally at
configure time. This allows us to track down race conditions etc.
* configure.ac: Add configure options for -fsanitize=thread
Signed-off-by: Matthias Maennich <maennich@google.com>
Allow appending arbitrary text to the libabigail version string
representation. That is useful to identify custom versions of the
library (e.g. development versions or versions of a particular origin).
The feature can be enabled by passing VERSION_SUFFIX to `configure`,
e.g.
$ configure VERSION_SUFFIX="-dev"
That will extend the version string to (currently) 1.7.0-dev.
The behaviour before this patch remains the default behaviour of not
appending any additional text.
The feature stays intentionally undocumented as the main release of
libabigail will usually not carry a version suffix.
* configure.ac: add substitution for VERSION_SUFFIX
* include/abg-version.h.in: add define for ABIGAIL_VERSION_SUFFIX
* include/abg-config.h(abigail_get_library_version): add support
for a version suffix
* src/abg-config.cc(abigail_get_library_version): Likewise.
* src/abg-tools-utils.cc(get_library_version_string): Likewise.
Reviewed-by: Dodji Seketeli <dodji@seketeli.org>
Signed-off-by: Matthias Maennich <maennich@google.com>
My patch "568dee1 PR25042 - Support string form DW_FORM_strx{1,4} from
DWARF 5" introduced a thinko in configure.ac. The thinko triggers a
regression test issue on old systems where we don't support
DW_FORM_strx from DWARF 5. Fixed thus.
* configure.ac: Fix thinko when setting the HAVE_DW_FORM_strx
macro.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* configure.ac: Detect the presence of the DW_FORM_strx{1,4}
enumerators.
* src/abg-dwarf-reader.cc (form_is_DW_FORM_strx): Define new
function.
(compare_dies_string_attribute_value): Use the new
form_is_DW_FORM_strx here.
* tests/data/Makefile.am: Add the new test input files below to
source distribution.
* tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0:
New binary test input file.
* tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi:
Reference output of the new binary test input file.
* tests/test-read-dwarf.cc (in_out_specs): Add the input test
files above to the test harness, for platforms that support the
DW_FORM_strx form.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
The patch:
"e687032 Support pre and post v4.19 ksymtabs for Linux kernel modules"
introduces the use of the R_AARCH64_{ABS64, PREL32} macros. However,
some older "elf.h" don't define these. When compiling on these older
platforms, we thus need to avoid using these new macros.
With this patch, the configure system detects the presence of these
macros and defines the HAVE_R_AARCH64_{ABS64, PREL32}_MACRO macros
accordingly.
Note that just to comply with what's in there in the code already, we
don't directly do "#ifdef R_AARCH64_ABS64", but rather "#ifdef
HAVE_R_AARCH64_ABS64_MACRO", to allow cases where we want to
artificially disable the "feature" at configure time, in the future.
* configure.ac: Define macros HAVE_R_AARCH64_{ABS64, PREL32}_MACRO
if the macros R_AARCH64_{ABS64, PREL32} are present.
* src/abg-dwarf-reader.cc
(read_context::get_ksymtab_format_module): Conditionalize the use
of R_AARCH64_{ABS64, PREL32} using HAVE_R_AARCH64_{ABS64, PREL32}_MACRO.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
On older compilers (such as g++ 4.8), the default C++ standard is set to
gnu++98. When compiling libabigail with --enable-cxx11=yes, src/ and
tests/ where compiled with the correct flag, while tools/ was compiled
without specifying a standard. With a compiler falling back to gnu++98
that leads to unresolved references when linking the tools against the
libabigail library. Fix that by consistently using the std= flag across
the code base.
* configure.ac: add -std=c++11 flag to CXXFLAGS when compiling
for C++11
* src/Makefile.am: drop now obsolete setting of the -std flag
* tests/Makefile.am: likewise
Reported-by: Chun-Hung Wu <Chun-hung.Wu@mediatek.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Add options to enable building with -fsanitize=address or
-fsanitize=undefined.
* configure.ac: Add configure options for -fsanitize=address and
-fsanitize=undefined.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
With this patch, configuring the project with the environment variables
ABIGAIL_DEVEL=on and ABIGAIL_DEVEL_ASAN=on will turn on
AddressSanitizer.
* configure.ac: If ABIGAIL_DEVEL_ASAN=on (in addition to
ABIGAIL_DEVEL=on), then turn on AddressSanitizer in the build.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* configure.ac: Fix the typo HAS_LANG_Rust into HAS_DW_LANG_Rust.
* tests/data/test-diff-dwarf/test46-readme.txt: Add new file to
the test suite.
* tests/data/test-diff-dwarf/test46-rust-libone.so: Likewise.
* tests/data/test-diff-dwarf/test46-rust-libtwo.so: Likewise.
* tests/data/test-diff-dwarf/test46-rust-report-0.txt: Likewise.
* tests/test-diff-dwarf.cc (in_out_specs): Update the tests array
to compare the two new binaries included above.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
elfutils regularly adds new members to the anonymous DWARF language
encodings enum which contains the DW_LANG_* enumerators, from the
dwarf.h header file.
If we want libabigail to keep compiling with older versions of
elfutils, we need to detect the absence of a given DW_LANG_*
enumerator and avoid using it in that case.
Until now, we were doing #ifdef DW_LANG_* for that purpose. But then
the DW_LANG_* are *enumerators*, not preprocessor macros. So that
preprocessor macro.
This patch detects the presence of each of the "newer" DW_LANG_*
enumerator using autoconf. And for each DW_LANG_xxx enumerator that
is present, autoconf defines the HAVE_DW_LANG_xxx_enumerator macro.
Libabigail source code can thus do #ifdef HAVE_DW_LANG_xxx_enumerator
to guard the use of DW_LANG_xxx.
Tested with the Rust binaries from
https://gitlab.gnome.org/federico/abi-rust.
* configure.ac: Detect the presence of DW_LANG_{UPC, D, Python,
Go, C11, C_plus_plus_03, C_plus_plus_11, C_plus_plus_14,
Mips_Assembler, Rust} and define the corresponding
HAVE_DW_LANG_*_enumerator macro accordingly.
* include/abg-ir.h (LANG_C_plus_plus_03): Define this new
enumerator in the translation_unit::language enum.
* src/abg-dwarf-reader.cc (dwarf_language_to_tu_language): Use the
new HAVE_DW_LANG_*_enumerator macros.
(get_default_array_lower_bound): Support the
translation_unit::LANG_C_plus_plus_03 enumerator.
* src/abg-ir.cc (is_cplus_plus_language): Support the
translation_unit::LANG_C_plus_plus_03 enumerator.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
There are lots of spots in libabigail's source code where the argument
of the assert() call does have side effects. This is a problem
because when the code is compiled with the NDEBUG macro defined, the
assert call does nothing, so the side effects of its argument are then
suppressed, changing the behaviour of the program.
To handle this issue, this patch introduces the ABG_ASSERT macro which
is a wrapper around the assert call that enable the use of side
effects in its argument. The patch now uses that ABG_ASSERT macro
instead of using the assert call directly.
The patch also makes it so that the configure option accepts the
--disable-assert option so that the user can build libabigail with the
NDEBUG macro defined.
Tested by running the testsuite with and without the --disable-assert
option to configure.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
It turns out that when we disable fedabipkgdiff, we also disable
detection of python and the setting of the proper environment
variables that are expected by some makefiles down the road. The
leads to the runtestdefaultsupprs.py test to be blocked at runtime
because the environement variable PYTHON is not defined. This patch
fixes that.
* configure.ac: Detect the presence and version of python even
when fedabipkgdiff is disabled.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
If no python2 interpreter is found and only a python3 one is found,
then use that one rather than just bailing.
* configure.ac: When no python2 is found and only python3 is
found, then use python3.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
* configure.ac: Make the PYTHON environemnt variable usable in
auto-generated files.
* tests/runtestdefaultsupprs.py.in: Use the python interpreter
detected by configure.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
When doing the Koji version tests at configure time, use the version
of the python interpreter that was selected by configure, not the one
first (randomly) found in the current PATH.
* configure.ac: Use the python interpreter that was selected by
the configure script for the Koji version test.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This patch makes fedabipkgdiff Python 3 compatible. All tests written
in Python are updated and compatible with Python 3 as well.
The patch looks for a Python 3 interperter. If it finds one then it
runs the tests using that interpreter. Otherwise it just tries to use
the Python 2 interpreter.
This behaviour can be disabled by the new --disable-python3 option.
* configure.ac: Add new option --enable-python3. Add new
test runner file tests/runtestdefaultsupprs-py3 and
tests/runtestfedabipkgdiffpy3.sh. Add required six Python module.
* tests/Makefile.am: Add new test files
tests/runtestdefaultsupprspy3.sh and
tests/runtestfedabipkgdiffpy3.sh accordingly.
* tests/mockfedabipkgdiff.in: Convert print statement to
six.print_. Replace call to function filter with list
comprehension. Replace basestring with six.string_types.
* tests/runtestdefaultsupprspy3.sh.in: New shell script to run
test runtestdefaultsupprs with Python 3.
* tests/runtestdefaultsupprs.py.in: Repalce a few tabs with
proper number of spaces which is detected by Python 3
interpreter.
* tests/runtestfedabipkgdiffpy3.sh.in: New shell script to run
test runtestfedabipkgdiff with Python 3.
* tests/runtestfedabipkgdiff.py.in: Use python from env in
shebang instead of a fixed path to a Python interpreter.
* tools/fedabipkgdiff: Globally replace print statement with a
function call to print which is available by importing
print_function from __future__ module. Use six.print_ to output
string to stderr instead. Convert function call to map to
for-loop. (cmp_nvr): Change argument to handle a Koji build
mapping instead of only the nvr. (Brew.listBuilds): use the new
cmp_nvr to sort builds.
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
If the rpm program is not installed, then we disable tests that
require it.
* configure.ac: Detect that the 'rpm' is present. Otherwise,
disable rpm support.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>