Since the recent sourceware infrastructure refresh the management of
the mailing list moved to mailman. So the form we use to register to
the mailing list changed as well. I have updated the information on
the web page to reflect that.
* doc/website/mainpage.txt: Use the form at
https://sourceware.org/mailman/listinfo/libabigail to register to
the mailing list.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
The DWARF reader could divide by zero when emitting statistics about
late canonicalisation of types. This is undefined behaviour but
typically results in process termination.
* src/abg-dwarf-reader.cc (perform_late_type_canonicalizing):
If total is zero, don't try to output percentages using it as
a divisor.
Signed-off-by: Giuliano Procida <gprocida@google.com>
The file tests/data/test-diff-pkg/dirpkg-2-report-1.txt looks like it
was committed in error. It's not used, its contents don't match the
implied directories being compared and there are other tests that
cover the same functionality, with or without --no-abignore, anyway.
* tests/data/Makefile.am: Removed
tests/data/test-diff-pkg/dirpkg-2-report-1.txt.
* tests/data/test-diff-pkg/dirpkg-2-report-1.txt: Removed.
Signed-off-by: Giuliano Procida <gprocida@google.com>
Commit 79383f937c added many tests but
didn't actually execute three of them.
Commit fe9fa7a05f added many tests but
didn't actually execute one of them.
This patch corrects these issues.
* tests/test-diff-suppr.cc: Add stanzas for
test6-fn-suppr-report-4, test16-suppr-removed-fn-report-5 and
test22-suppr-removed-var-sym-report-5 and
test23-alias-filter-report-4 tests.
* tests/data/test-diff-suppr/test6-fn-suppr-report-4.txt:
Number parameters from 1 and update expected output to current
formatting.
* tests/data/test-diff-suppr/test16-suppr-removed-fn-report-5.txt:
Update expected output to current formatting.
* tests/data/test-diff-suppr/test22-suppr-removed-var-sym-report-5.txt:
Update expected output to current formatting.
Signed-off-by: Giuliano Procida <gprocida@google.com>
This patch removes perhaps the last remaining cause of double blank
lines in output.
The state variable emit_nl was being set to true just after emitting a
new line which resulted in a blank line after every local typedef
change report.
* include/abg-reporter.h
(default_reporter::report_local_typedef_changes): Change
return type to void.
* src/abg-default-reporter.cc:
(default_reporter::report_local_typedef_changes): Change
return type to void, remove emit_nl state variable and logic.
* tests/data/test-abidiff/test-PR18791-report0.txt: Remove
blank lines.
* tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.txt:
Ditto.
* tests/data/test-diff-suppr/test39-opaque-type-report-0.txt:
Ditto.
Signed-off-by: Giuliano Procida <gprocida@google.com>
The code in abg-ir.cc that calculated the memory size of an array
summed, rather than multiplied, the dimensions. It also did duplicate
work for each dimension after the first.
Existing code in abg-reader.cc asserted that array size information
read from XML match freshly calculated values.
This patch corrects the calculation, eliminates the duplicate work and
updates the XML reader validation to just emit a warning if old bad
array size information is found.
* include/abg-ir.h (array_type_def::append_subrange): Remove
this function.
* src/abg-ir.cc (array_type_def::set_element_type): Add a note
about safe usage.
(array_type_def::append_subrange): Inline this function into
its only caller append_subranges and remove it.
(array_type_def::append_subranges): Do correct multiplicative
calculation of multidimensional array sizes.
* src/abg-reader.cc (build_array_type_def): When checking
calculated against read array sizes, warn once if value
matches old behaviour rather than raising an assertion.
Otherwise, before raising an assertion, emit an informative
error message.
* tests/data/test-annotate/test14-pr18893.so.abi: Correct
array sizes.
* tests/data/test-annotate/test17-pr19027.so.abi: Ditto.
* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
Ditto.
* tests/data/test-annotate/test7.so.abi: Ditto.
* tests/data/test-diff-dwarf/test10-report.txt: Ditto.
* tests/data/test-diff-dwarf/test11-report.txt: Ditto.
* tests/data/test-read-write/test25.xml: Ditto.
Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
These blank lines break up the output unexpectedly and often cause
double blank lines after reporting of function changes.
* src/abg-default-reporter.cc: (report_local_function_type_changes):
Remove unnecessary blank lines after lists of parameter changes.
* tests/data/test-*/test*report*.txt: Remove blank lines after
parameter change lists in 12 files.
Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
In --leaf-changes-only mode, the report currently has 2 blank lines
after each type-diff section. This patches changes this to 1.
* src/abg-leaf-reporter.cc: (report_diffs) Emit 1 instead of 2
new lines between sections.
* tests/data/test-abidiff-exit/test-leaf-peeling-report.txt:
Replace double blank lines with single ones.
* tests/data/test-diff-filter/libtest45-basic-type-change-report-1.txt:
Ditto.
* tests/data/test-diff-suppr/test36-leaf-report-0.txt: Ditto.
* tests/data/test-*/test*report*.txt:: Ditto.
Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
The represent(var_diff_sptr) function tracks vertical "\n" and
horizontal ", " spacing using two state variables:
- emitted - the main diff text has been emitted
- begin_with_and - main text emitted && new line started, so
any further description must be indented and prefixed "and ".
- if emitted is true and begin_with_and is false, then further
description is prefixed with ", " instead.
There was some inconsistent emission of new lines and maintenance of
the state variables. This patch documents the variables and makes sure
new lines and state variables are kept in sync.
Finally, it is theoretically possible to reach the end of the function
without emitted becoming true. This patch adds a TODO and makes sure
at least something is output should that ever happen.
* src/abg-reporter-priv.cc: (represent) In the var_diff_sptr
overload, make sure the state variables begin_with_and and
emitted are updated consistently; add a TODO for one case
which may result in the end of the function being reached
without having emitted a report; add missing new lines
following reporting of anonymous member changes; only emit a
final new line if begin_with_and hasn't tracked one already;
document state variables.
* tests/data/test-diff-dwarf/test45-anon-dm-change-report-0.txt:
Add missing blank line after anonymous member change text.
* tests/data/test-diff-filter/test44-anonymous-data-member-report-1.txt:
Add missing "and " continuation.
Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Currently, lists of member function deletions, additions and changes
are each followed by a blank line in abidiff output.
While this formatting works reasonably well in leaf-changes-only mode
for top-level changes to types, it is inconsistent with everthing
else. In particular, when reporting member function diffs in default
mode, or more deeply nested in leaf mode, the blank lines are
jarring.
There was also no test coverage for leaf-changes-only mode.
This change removes these blank lines and associated state variables
and logic. It adds a test case for leaf-changes-only mode.
Note that the patch also modifies default mode reporting of member
types, template member functions and template member classes
analogously, but I wasn't able to exercise those code paths.
* src/abg-default-reporter.cc (report): In the
class_or_union_diff overload, don't emit a new line after each
list of member function, member type, template member
function and template member class changes.
* src/abg-leaf-reporter.cc (report): : In the
class_or_union_diff overload, don't emit a new line after each
list of member function changes.
* tests/data/Makefile.am: Add new test case files.
* tests/data/test-abidiff-exit/test-leaf-cxx-members-v0.cc:
New test case for --leaf-changes-only member function diffs.
* tests/data/test-abidiff-exit/test-leaf-cxx-members-v0.o:
Ditto.
* tests/data/test-abidiff-exit/test-leaf-cxx-members-v1.cc:
Ditto. Also add a TODO regarding a potentially bad diff.
* tests/data/test-abidiff-exit/test-leaf-cxx-members-v1.o:
Ditto.
* tests/data/test-abidiff/test-struct1-report.txt: Remove
blank lines after member function changes lists.
* tests/data/test-diff-dwarf/test41-PR20476-hidden-report-0.txt:
Ditto.
* tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt:
Ditto.
* tests/test-abidiff-exit.cc: Add new test case.
Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
There was a spurious new line at the end of reporting enum diffs,
before reporting impacted interfaces, if requested.
* src/abg-default-reporter.cc (report): In the enum_diff
overload, don't emit a blank line before a possible "impacted
interfaces" stanza. In the class_or_union overload, change a
stray conditional to use the emitted state variable for
consistency.
* tests/data/test*report*.txt: Remove blank lines after enum
diffs in 17 files.
Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
This patch removes the blank line emitted after base class diffs.
These are jarring, particularly when the diffs are nested.
* src/abg-default-reporter.cc (report): In the class_diff
overload, eliminate the extra blank line after base class
changes and remove unneeded new line logic.
* tests/data/test*report*.txt: Remove blank lines after base
class diffs in 9 files.
Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Some blank lines were unintentionally removed with a recent patch. The
new line to remove should have been the one after all changed
functions not the one after each one. Changed functions (and
variables) tend to be reported as paragraphs, rather than single
lines, so the extra spacing is useful.
This patch removes the blank line emitted after all changed
functions, variables and unreachable types, and adds back the
missing blank lines between changed functions.
* src/abg-default-reporter.cc (report): In the corpus_diff
override, add back the extra blank line per changed function
but remove the extra one after all changed changed functions
and variables; comment these.
* src/abg-leaf-reporter.cc (report): In the corpus_diff
override, add back the extra blank line per changed function
but remove the extra one after all changed changed functions
and variables; comment these.
* src/abg-reporter-priv.cc
(maybe_report_unreachable_type_changes): Remove extra blank
line emitted after all unreachable type changes; comment
this.
* tests/data/test*report*.txt: Remove/add blank lines.
Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
This is a follow-up to a recent commit. This patch adds more tests, as
suggested by a reviewer.
* src/abg-ir.cc (types_have_similar_structure): Update TODO
regarding structure of arrays - multidimensional arrays are
the issue.
* tests/data/test-abidiff-exit/test-leaf-peeling-report.txt:
Updated following changes.
* tests/data/test-abidiff-exit/test-leaf-peeling-v0.cc: Add
more cases (see below).
* tests/data/test-abidiff-exit/test-leaf-peeling-v0.o:
Updated.
* tests/data/test-abidiff-exit/test-leaf-peeling-v1.cc: Add
comment about a potential change to local-change semantics;
add test cases to demonstrate that * and & and * and *** are
structurally different; add a TODO regarding multidimensional
arrays where changes are sometimes missed in leaf mode.
* tests/data/test-abidiff-exit/test-leaf-peeling-v1.o
Signed-off-by: Giuliano Procida <gprocida@google.com>
Following commit 474ad38f, we need to update the test reference output
tests/data/test-abidiff-exit/test-leaf-peeling-report.txt.
* tests/data/test-abidiff-exit/test-leaf-peeling-report.txt:
Update output.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This is another round of moving responsibility for generation of new
lines into functions and getting rid of redundant new lines.
* src/abg-default-reporter.cc (report) In the
class_or_union_diff overload, don't emit a new line after
calls to represent. In the union_diff overload, emit a new
line after a from/to change; fix indentation. In the
corpus_diff overload, don't emit an extra new line after
reporting a diff.
* src/abg-leaf-reporter.cc (report_diffs) Don't emit a new
line after reporting a canonical diff. In the
class_or_union_diff overload, don't emit a new line after
calls to represent. In the corpus_diff overload, don't emit an
extra new line after reporting a diff.
* src/abg-reporter-priv.cc (represent): Emit a final new line,
but only if needed.
(maybe_report_interfaces_impacted_by_diff): Emit a new line
after the last impacted interface.
* tests/data/test-*/*report*.txt: Remove blank lines (and add
a missing one) to 77 test cases.
This function is used to determine whether or not type differences are
"local" and is primarily used in --leaf-changes-only mode. The logic
has some issues which are addressed by this patch:
- Any number of points-to (*) and refers-to (& and &&) components
are peeled off the types being compared, rather than checking
these match in number and kind.
- This peeling is done with peel_typedef_pointer_or_reference_type
which also peels any number of CV qualifiers (OK) and
array-of ([N]) type components (not OK).
- The function sets a state variable (was_indirect_type) to modify
the behaviour of downstream comparisons, but this cannot be
passed through recursive calls.
The effect of the indirect_type flag is to switch to comparisons by
name: identically named structs don't get introspected. Arguably, a
more useful behaviour for --leaf-changes-only mode would be to treat
any change to a named type as non-local, except in the context of the
definition of that type itself. This would be a more significant
change in behaviour.
* include/abg-fwd.h (types_have_similar_structure): In both
overloads, add an indirect_type argument, defaulting to
false.
* src/abg-ir.cc (reference_type_def constructor): Tabify.
(types_have_similar_structure): In both overloads, add an
indirect_type argument and update documentation text. In the
type_base_sptr overload, pass indirect_type in the tail
call. In the type_base* overload, replace was_indirect_type
with indirect_type; peel CV qualifiers and typedefs without
testing as the peel function does this; replace the
indiscriminate peeling of qualifier/pointer/reference/array
type components with code that checks the same
pointer/reference/array type component is used on each side
and makes recursive calls with indirect_type set to true; pass
the indirect_type argument recursively when comparing other
subtypes; move the typeid check earlier, document its purpose
and remove unneccessary checks after later dynamic casts;
remove an always-true conditional; add a TODO for comparing
array types more accurately.
* tests/data/Makefile.am: Add new test case files.
* tests/data/test-abidiff-exit/test-leaf-peeling-v0.cc: New
test case.
* tests/data/test-abidiff-exit/test-leaf-peeling-v1.cc: Ditto.
* tests/data/test-abidiff-exit/test-leaf-peeling-report.txt:
Ditto.
* tests/test-abidiff-exit.cc: Run new test case.
Signed-off-by: Giuliano Procida <gprocida@google.com>
There is an instance of a if-statement testing the same variable as
its containing if-statement. The inner test always evaluates to true,
if it is reached.
* src/abg-ir.cc (types_have_similar_structure): Remove
identical nested conditional.
(reference_type_def::reference_type_def): Tabify.
Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
The various peel_*_type functions are supposed to return either an
underlying type (when something can be "peeled") or the original
type (when not).
This overload of peel_typedef_type currently returns null if the type
isn't a typedef. This patch corrects this.
The bug hasn't bitten as all existing calls are protected by an
is_typedef check. Note that the recursive calls within the function
are to the other (const type_base_sptr&) overload.
* src/abg-ir.cc (peel_typedef_type): In the const type_base*
overload, return the original argument rather than null if the
type isn't actually a typedef.
Signed-off-by: Giuliano Procida <gprocida@google.com>
The bloom filter of the GNU_HASH section of binaries is made of words
(bitmasks) that are either 32-bits for ELFCLASS32 binaries or 64-bits
for ELFCLASS64 binaries.
By using the GElf_Word type to hold the content of each bitmask we
assume the bitmask to be of a size of at most 'sizeof(Elf64_Word)'.
Unfortunately, the name Elf64_Word is a bit misleading because it's a
32-bits wide type (uint32_t). That type is thus too short to hold an
entire bitmask for 64-bits binaries.
I won't give too many details here about how the bloom filter works as
it's described in details in the documentation for the GNU_HASH
section at http://www.linker-aliens.org/blogs/ali/entry/gnu_hash_elf_sections/.
Suffice it to say that in practise, we were comparing the least
significant bytes of a 64-bits bloom bitmask to a 32-bits value.
Depending on if we read those least significant bytes on a big or
little endian, we obviously don't get the same result. Hence the
recent buid breakage at
https://builder.wildebeest.org/buildbot/#builders/14/builds/352 where
the runtestlookupsyms test fails.
This patch thus changes the code of lookup_symbol_from_gnu_hash_tab to
use a 64-bits type to hold the value of the bloom bitmask. That way,
we never have any information loss. The function bloom_word_at is
also changed to read the bloom bitmask as a 64-bits value when looking
at an ELFCLASS64 binary and to always return a 64-bits value.
It also adds a test to access the bloom filter of an ELFCLASS32
binary.
* src/abg-dwarf-reader.cc (bloom_word_at): Properly read an
element from the bloom bitmasks array of 32-bits values as a
64-bits value in a portable way. Always return a 64 bits value.
(lookup_symbol_from_gnu_hash_tab): Use a 64-bits value to store
the bloom bitmask.
* tests/data/test-lookup-syms/test1-32bits.so: New test input,
compiled as a 32bits binary to test for ELFCLASS32 binaries.
* tests/data/test-lookup-syms/test1.c.compiling.txt: Documentation
about how to compile the test1[-21bits].so files.
* tests/data/Makefile.am: Add the new test material above to
source distribution.
* tests/test-lookup-syms.cc (in_out_specs): Add the
test1-32bits.so test case to this test harness.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
The change_kind enumeration (bitset) values are used to track what
kinds of a changes are present at a diff node.
Local type and non-type changes may be present. These are tracked
using 3 bits, with the invariant that LOCAL_TYPE_CHANGE_KIND or
LOCAL_NON_TYPE_CHANGE_KIND both imply LOCAL_CHANGE_KIND. This
invariant has to be maintained in code which doesn't always happen.
This patch fixes a couple of cases where LOCAL_CHANGE_KIND or
LOCAL_TYPE_CHANGE_KIND was missing and changes a few other bits of
code so that it is clear that two bits are being paired together.
A follow-up patch will drop LOCAL_CHANGE_KIND as it is now completely
redundant.
* src/abg-comparison.cc (distinct_diff::has_local_changes):
Remove unnecessary parentheses around return expression.
* src/abg-default-reporter.cc (report): In the reference_diff
overload, replace test against LOCAL_CHANGE_KIND with test
against ALL_LOCAL_CHANGES_MASK.
* src/abg-ir.cc (equals): In the array_type_def and class_decl
overloads, add missing LOCAL_TYPE_CHANGE_KIND. In the
class_decl overload, also add missing LOCAL_CHANGE_KIND. In
the enum_type_decl and function_decl::parameter overloads
clarify pairing of LOCAL*CHANGE_KIND bits.
(enum_has_non_name_change): Clarify pairing of
LOCAL*CHANGE_KIND bits.
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Most of the bit values used for GNU hash ELF section Bloom filtering
were being ignored due to integer narrowing, reducing missing symbol
filtering efficiency considerably.
This patch fixes this.
Note on testing.
The .gnu.hash section seems to be present in all the .so but none of
the .o test files. abisym doesn't appear to find dynamic symbols (nm
-D), only normal ones, so it was a little tricky to test this.
I found a Debian .so (libpthread) with both the .gnu.hash section and
normal symbols. abisym behaves identically with my change, looking up
lots of present and non-present (as far as it's concerned) symbols. I
just extracted a full list with nm/sed and looked up each one.
389 symbols looked up, 241 present, 148 absent
8-bit filter: 336 maybe, 53 no (53/148 filtering efficiency)
64-bit filter: 255 maybe, 134 no (134/148 filtering efficiency)
* src/abg-dwarf-reader.cc (lookup_symbol_from_gnu_hash_tab):
Don't narrow calculated Bloom word to 8 bits before using it
to mask the fetched Bloom word.
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
maybe_adjust_et_rel_sym_addr_to_abs_addr contained an ABG_ASSERT to
ensure symbol_section is not used on an invalid value. Since
maybe_adjust_et_rel_sym_addr_to_abs_addr handles this case, this assert
can be removed.
* src/abg-dwarf-reader.cc
(maybe_adjust_et_rel_sym_addr_to_abs_addr): improve NULL check,
remove superfluous ABG_ASSERT
* tests/data/Makefile.am: Add new test case to the distribution.
* tests/test-read-dwarf.cc: Likewise.
* tests/data/test-read-dwarf/test27-bogus-binary.elf: New test case.
Signed-off-by: Matthias Maennich <maennich@google.com>
test-read-dwarf silently succeeded even if the input elf file was not
existing. Hence, make distcheck succeeded even though the testfiles were
not distributed. Assert on the existence of the input file and add the
missing test case files.
* tests/data/Makefile.am: add missing test case files
* tests/test-read-dwarf.cc (test_task::perform): assert the
input elf file exists.
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>
Update the help string of the --impacted-interface option to make it
match the one from the abidiff tool.
* tools/abipkgdiff.cc (display_usage): Use the same help string
for the --impacted-interface option as abidiff does.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
abidiff --impacted-interfaces is supposed to show the impacted
interfaces. Hence fix the documentation to reflect that.
* tools/abidiff.cc(display_usage): Fix doc string for
--impacted-interfaces.
Reported-by: Saravana Kannan <saravanak@google.com>
Signed-off-by: Matthias Maennich <maennich@google.com>
These tags were previously only emitted by the default reporter if the
there were more than 100 (hard-coded constant) items in a a list. The
leaf reporter emitted them unconditionally. This change simplifies the
code, makes output more consistent and makes it easier to interpret
diffs of diff output.
Additionally, in the reporting of changed unreachable types, the
indentation and quoting for the deleted and added cases was missing.
This patch corrects these issues.
Finally, when doing package differences, there were no tags for
deleted/added binaries. This patch adds them.
* src/abg-default-reporter.cc (report): In the corpus_diff
override, remove calculations of number of changes (total) and
comparisons against arbitrary threshold (large_num); emit [A],
[D], [C] tags unconditionally.
* src/abg-reporter-priv.cc
(maybe_report_unreachable_type_changes): Remove comparisons of
number of changes against arbitrary threshold (large_num);
emit [A], [D], [C] tags unconditionally; fix quoting of
deleted unreachable types; fix indentation of changed
unreachable types.
* tools/abipkgdiff.cc (compare_prepared_userspace_packages):
Emit [D] and [A] tags for removed and added binaries.
* tests/data/test-*/*report*.txt: In 109 report files, add
tags [A], [D], [C] tags and correct some indentation and
quoting.
Signed-off-by: Giuliano Procida <gprocida@google.com>
Since bring_workers_down is not atomic, a worker thread can make a racy
read on it while do_bring_workers_down() writes it. That can lead to a
deadlock between the worker thread waiting for more work and
do_bring_workers_down() waiting for the worker to finish.
Address this by guarding all access to bring_workers_down with locking
tasks_todo_mutex. This is likely to be dropped after migrating to newer
C++ standards supporting std::atomic.
* src/abg-workers.cc(do_bring_workers_down): keep
task_todo_mutex locked while writing bring_workers_down,
(wait_to_execute_a_task): rewrite the loop condition to ensure
safe access to bring_workers_down.
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>
For valid values of h1/h2 and c, the signed integer left shift
expression (1 << (h1 % c)) might overflow, exposing undefined behaviour.
Fix that by using a data type that can hold the value.
That issue had been reported by ASAN when running test-lookup-syms:
src/abg-dwarf-reader.cc:2028:50: runtime error:
shift exponent 53 is too large for 32-bit type 'int'
* src/abg-dwarf-reader.cc(lookup_symbol_from_gnu_hash_tab): Fix
signed integer overflow.
Signed-off-by: Matthias Maennich <maennich@google.com>
In leaf-changes-only mode, if the type of a struct's function pointer
member changes it currently gets categorised as a non-local change and
so is not reported. The change to any function passing such a struct
is considered non-local and also not reported.
This patch broadens the definition of local changes to include these
cases and so have them be reported in leaf-changes-only mode. It may
be the first of a sequence of such patches,
* src/abg-ir.cc (types_have_similar_structure): Always compare
function types (instead of just returning true) regardless of
whether they are components of pointer-to-function or
reference-to-function types.
* tests/data/Makefile.am: Add new test case files.
* tests/data/test-abidiff-exit/test-leaf2-report.txt: New test
case.
* tests/data/test-abidiff-exit/test-leaf2-v0.cc: Ditto.
* tests/data/test-abidiff-exit/test-leaf2-v0.o: Ditto.
* tests/data/test-abidiff-exit/test-leaf2-v1.cc: Ditto.
* tests/data/test-abidiff-exit/test-leaf2-v1.o: Ditto.
* tests/test-abidiff-exit.cc: Run new test case.
Signed-off-by: Giuliano Procida <gprocida@google.com>
abidiff emits hierarchical difference information using 2-space
indentation, almost everywhere.
In a few places, long lines are split up and 1-space is used for
clarity. Otherwise 1-space indentation appears to be only used when
reporting:
- data member changes (not additions or removals)
- the change of the type of a variable
This patch resolves these inconsistencies in favour of 2-space
indentation.
* src/abg-default-reporter.cc (report): In the
class_or_union_diff override, use 2-space indentation when
listing changed members. In the var_diff override, do the same
for variable type changes.
* src/abg-leaf-reporter.cc: Ditto.
* tests/data/test-*/*report*.txt: Update many test cases.
Signed-off-by: Giuliano Procida <gprocida@google.com>
v2: More code simplification. Tests unchanged.
There is distributed responsibility for horizontal and vertical
whitespace in the reporting code with indent and new line control
information being manipulated by and passed in and out of functions.
Occasionally, this information is ignored or incorrect and the code
tends to err on the side of more rather than fewer new lines.
The outcome is that abidiff output sometimes contains extra blank
lines which can be confusing.
This patch eliminates some of the more obvious cases:
- after data member deletions
- in enumerator change lists
- after "type size hasn't changed"
- before listing impacted interfaces
A lot of passing of "new line needed" booleans between functions has
been eliminated in the process.
The patch cleans up the reporting of data members. The code will
either emit indentation, a short description and a new line or do
nothing at all.
The patch also removes some stray location reporting code for array
diffs which would have produced some oddly placed output. I could not
get this code to trigger as loc = decl->get_location() was never
present on the array decls in question.
* src/abg-default-reporter.cc (report): In the type_decl_diff,
enum_diff, array_diff, class_diff, union_diff and var_diff
overrides, simplify new line logic which no longer needs to be
threaded through report_name_size_and_alignment_changes. In
the distinct_diff override, simplify new line logic which no
longer needs to be threaded through
report_size_and_alignment_changes. In the enum_diff override,
emit just one blank line after each enum. In the array_diff
override, remove stray location reporting which doesn't appear
to ever trigger; fix new line logic. In the
class_or_union_diff override, simplify new line logic for
deleted members; pass indentation to represent_data_member.
* src/abg-leaf-reporter.cc (report): In the array_diff,
class_diff, union_diff and var_diff overrides, simplify new
line logic which no longer needs to be threaded through
report_name_size_and_alignment_changes. In the distinct_diff
override, simplify new line logic which no longer needs to be
threaded through report_size_and_alignment_changes. In the
array_diff override, remove stray location reporting which
doesn't appear to ever trigger; fix new line handling. In the
class_or_union_diff override, simplify new line logic for
deleted members; pass indentation to represent_data_member.
In the corpus_diff override, tabify source indentation.
* src/abg-reporter-priv.cc (represent_data_member): Handle
indentation; fix new line logic.
(report_size_and_alignment_changes): Fix new line logic
for "type size hasn't changed" message; simplify new line
logic and replace local bool n with argument bool nl for
clarity.
(report_size_and_alignment_changes): Remove bool nl argument
and associated code as it had become always false; take
responsibility for emitting terminating new lines and change
return type to void.
(report_name_size_and_alignment_changes): Fix new line logic;
remove bool nl argument and associated code as it had become
always false; take responsibility for emitting terminating new
lines and change return type to void.
(maybe_report_interfaces_impacted_by_diff) In both overrides,
remove new line prefix code and new_line_prefix argument.
* src/abg-reporter-priv.h (represent_data_member): Add indent
argument.
(report_size_and_alignment_changes) Remove bool nl argument;
change return type to void.
(report_name_size_and_alignment_changes) Remove bool nl
argument; change return type to void.
(maybe_report_interfaces_impacted_by_diff) In both overrides,
remove new_line_prefix argument.
* tests/data/test-*/*report*.txt: Remove some blank lines.
Signed-off-by: Giuliano Procida <gprocida@google.com>
When reporting the details of changes to function parameter
differences in leaf-changes-only mode, the details are output at the
same level of indentation as the introductory text. In default mode
the usual 2-space indentation is used.
This patch fixes this discrepancy, making the output more readable.
* src/abg-leaf-reporter.cc (report): In the fn_parm_diff
override, indent the lines of detail by 2 spaces.
* tests/data/test-abidiff-exit/test-leaf3-report.txt: Update
report with correct indentation.
Signed-off-by: Giuliano Procida <gprocida@google.com>
The --redundant (meaning show-redundant-changes) option is supposed to
be implied by --leaf-changes-only and this is currently implemented by
making diff_context's --leaf-changes-only setter also duplicate the
behaviour of its --redundant setter.
In both abidiff and abipkgdiff, the diff_context setters are called
unconditionally, but the relative order of the calls for these two
options is different in each case, resulting in two different issues.
In abidiff, the --redundant setter is called second, undoing the
intended side-effect of any --leaf-changes-only flag. So --redundant
is not actually turned on in --leaf-changes-only mode unless requested
explicitly.
In abipkgdiff, the leaf-changes-only setter is called second, undoing
(in non-leaf mode) the effect of any --redundant flag. So --redundant
has no effect in default reporting mode.
The fix is move to move the "--leaf-changes-only implies --redundant"
logic from the setter to the set_diff_context_from_opts functions.
This patch also documents the implied behaviour in the usage strings.
* src/abg-comparison.cc (diff_context::show_leaf_changes_only):
Remove "--leaf-changes-only implies --redundant" logic.
* tools/abidiff.cc (display_usage): Mention that
--leaf-changes-only implies --redundant.
(set_diff_context_from_opts): Make --leaf-changes-only imply
--redundant; document this behaviour in a comment.
* tools/abipkgdiff.cc: Ditto.
* tests/data/Makefile.am: Add new test case files.
* tests/data/test-abidiff-exit/test-leaf3-report.txt: Add new
test case, to show --leaf-changes-only implies --redundant.
* tests/data/test-abidiff-exit/test-leaf3-v0.c: Ditto.
* tests/data/test-abidiff-exit/test-leaf3-v0.o: Ditto.
* tests/data/test-abidiff-exit/test-leaf3-v1.c: Ditto.
* tests/data/test-abidiff-exit/test-leaf3-v1.o: Ditto.
* tests/test-abidiff-exit.cc: Run new test case.
* tests/data/test-diff-pkg/libcdio-0.94-1.fc26.x86_64--libcdio-0.94-2.fc26.x86_64-report.1.txt:
Update abipkgdiff report with --redundant output.
* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-1.txt:
Ditto.
* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt:
Ditto.
Signed-off-by: Giuliano Procida <gprocida@google.com>
The leaf-changes-only reporting path does not report on all the same
kinds of differences as the default reporting path does, such as
reporting about changes to variables, even though they can be
considered leaf changs.
- The addition or removal of any symbol affects the ABI and is
clearly a leaf change.
- A change to a variable's declaration may be local rather than
caused by a type change elsewhere.
This patch adds these missing pieces and reorders some of the existing
leaf reporting, bringing the default and leaf corpus_diff functions
closer to the point where they can be trivially merged or refactored.
This patch also corrects an error in reporting the total number of
leaf changes.
* doc/manuals/abidiff.rst: Update the documentation for
--leaf-changes-only.
* doc/manuals/abipkgdiff.rst: Likewise.
* src/abg-comparison.cc (emit_diff_stats): Exclude non-leaf
changes to variables from the reported total of leaf changes.
* src/abg-default-reporter.cc (report): In the corpus_diff
override, move some code and comments for clarity.
* src/abg-leaf-reporter.cc (report): In the corpus_diff
override, additionally report removed/added/changed variables
and removed/added symbols absent from debug info.
* tests/data/Makefile.am: Add new test case files.
* tests/data/test-abidiff-exit/test-leaf0-report.txt: Update
to include reporting of variable diff (change of type).
* tests/data/test-abidiff-exit/test-leaf1-report.txt: New test
case with added/removed variables/functions and changed
variables (both local and non-local type changes).
* tests/data/test-abidiff-exit/test-leaf1-v0.cc: Ditto.
* tests/data/test-abidiff-exit/test-leaf1-v0.o: Ditto.
* tests/data/test-abidiff-exit/test-leaf1-v1.cc: Ditto.
* tests/data/test-abidiff-exit/test-leaf1-v1.o: Ditto.
* tests/test-abidiff-exit.cc: Run new test case. Supply
--redundant otherwise the test isn't meaningful.
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This patch is a follow-up to this commit:
b602f46c Fix spurious new lines after diff sections.
The intent is to update the tests that relate to the fedpkgdiff tool.
I didn't notice that those tests reference output were not updated by
commit b602f46c because I didn't have 'koji' installed on the system
I ran the regression test suite on; and without koji installed, the
fedpkgdiff test is automatically disabled.
The patch just mechanically adjusts the reference output that needed
it to comply with the newer better output of fedpkgdiff.
* tests/data/test-fedabipkgdiff/test0-from-fc20-to-fc23-dbus-glib-report-0.txt:
Adjust for useless whitespace removal.
* tests/data/test-fedabipkgdiff/test1-from-fc20-to-dbus-glib-0.106-1.fc23.x86_64-report-0.txt: Likewise.
* tests/data/test-fedabipkgdiff/test2-dbus-glib-0.100.2-2.fc20--dbus-glib-0.106-1.fc23-report-0.txt: Likewise.
* tests/data/test-fedabipkgdiff/test3-dbus-glib-0.100.2-2.fc20.i686--dbus-glib-0.106-1.fc23.i686-report-0.txt: Likewise.
* tests/data/test-fedabipkgdiff/test4-glib-0.100.2-2.fc20.x86_64.rpm-glib-0.106-1.fc23.x86_64.rpm-report-0.txt: Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
The top-level corpus diff routines in abidiff have varied ways of
tracking whether or not to emit a new line after each section. Reuse
of state variables (which aren't always cleared) between sections
means that spurious new lines are sometimes output.
This patch replaces this new line logic in the functions with the same
simple pattern of using a local boolean state variable.
* src/abg-default-reporter.cc (report): In the corpus_diff
overload, just use a local boolean emitted state variable
within each section to determine whether or not to follow the
section with an extra new line.
* src/abg-leaf-reporter.cc: Ditto.
* tests/data/test-*/*report*.txt: Remove unwanted new lines
from 27 files.
Signed-off-by: Giuliano Procida <gprocida@google.com>
There was a stray file-scoped declaration of show_relative_offset_changes. This
function is now a member of diff_context.
* src/abg-comparison.cc (show_relative_offset_changes): Remove
this stray function declaration.
Signed-off-by: Giuliano Procida <gprocida@google.com>
When abisym reports a symbol as found, it currently emits a leading
space. It does not do this when reporting a symbol as not found.
This patch removes the leading space.
* tools/abisym.cc (main): Remove leading space from output.
* tests/data/test-lookup-syms/test0-report.txt: Remove leading
space from expected output.
* tests/data/test-lookup-syms/test01-report.txt: Ditto.
* tests/data/test-lookup-syms/test02-report.txt: Ditto.
* tests/data/test-lookup-syms/test1-1-report.txt: Ditto.
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Leaf changes (as reported with --leaf-changes-only) to variables were
miscounted as changes to functions.
* src/abg-comparison.cc
(apply_filters_and_compute_diff_stats): Increment the correct
counter for leaf variable changes.
* tests/data/Makefile.am: Add new test case files.
* tests/data/test-abidiff-exit/test-leaf0-report.txt: New test
case.
* tests/data/test-abidiff-exit/test-leaf0-v0.cc: Ditto.
* tests/data/test-abidiff-exit/test-leaf0-v0.o: Ditto.
* tests/data/test-abidiff-exit/test-leaf0-v1.cc: Ditto.
* tests/data/test-abidiff-exit/test-leaf0-v1.o: Ditto.
* tests/test-abidiff-exit.cc: Run new test case.
Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
All such tags are now followed by a space and are more readable.
* src/abg-default-reporter.cc (report): In the overload for
corpus_diff, output space after "[C]".
* src/abg-leaf-reporter.cc (report): Likewise.
* tests/data/test-*/*report*.txt: Update all the test
reports.
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
In the leaf reporter member subtype changes are labelled as plain
changes and vice versa. This was probably due to the different
ordering of the code sections in the default and leaf reporters.
Output is unchanged as these tags currently map to the same strings.
When generating diff reports there were some rare cases where a
pretty representation might have been emitted twice or the trailing
whitespace might have been missing.
* src/abg-leaf-reporter.cc (report): In the class_or_union_diff
overoad, swap calls to report_mem_header to match the rest of the
code.
* src/abg-reporter-priv.cc (represent): In the var_diff_sptr
overload, add some missing whitespace; remember we've emitted the
pretty representation in 2 cases where this was omitted (though 1
of these is the last case where it makes no difference).
maybe_report_diff_for_symbol Add some missing whitespace; remember
we've reported a diff (and need a trailing newline) in 1 case
where this was omitted, also affecting the return value of the
function (but no caller cares).
Signed-off-by: Giuliano Procida <gprocida@google.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>