From patchwork Fri Apr 3 21:53:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 39076 From: gprocida@google.com (Giuliano Procida) Date: Fri, 3 Apr 2020 22:53:54 +0100 Subject: [PATCH 1/2] abidiff: More compact references to prior diffs. Message-ID: <20200403215356.186742-1-gprocida@google.com> In both the default and leaf reporting modes, when there is a repeated or circular reference to a type difference of a member variable, some placeholder text is emitted instead. In the leaf reporter: type 'struct S' of 'foo::bar' changed as reported earlier In the default reporter, this spans two lines: type of 'S foo::bar' changed: details were reported earlier This patch changes the latter to the more compact: type of 'S foo::bar' changed, as reported earlier More generally, this patch makes the punctuation of such placeholder text more consistent with a comma separating the phrases in all cases. It doesn't attempt to reconcile the different formatting of member variable declarations between the two modes. * src/abg-reporter-priv.cc (represent): In the var_diff_sptr overload, use consistent punctuation and keep to a single line of output when referring back to an existing type diff report. * src/abg-reporter-priv.h: In the macro RETURN_IF_BEING_REPORTED_OR_WAS_REPORTED_EARLIER, use consistent punctuation when referring back to an existing type diff report. * tests/data/test-abidiff/test-PR18791-report0.txt: Adjust formatting of back references to existing type diff reports. * tests/data/test-diff-dwarf/PR25058-liblttng-ctl-report-1.txt: Ditto. * tests/data/test-diff-filter/test16-report-2.txt: Ditto. * tests/data/test-diff-filter/test17-1-report.txt: Ditto. * tests/data/test-diff-filter/test25-cyclic-type-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. * tests/data/test-diff-suppr/test36-leaf-report-0.txt: Ditto. Signed-off-by: Giuliano Procida Reviewed-by: Matthias Maennich --- src/abg-reporter-priv.cc | 19 ++++++++----- src/abg-reporter-priv.h | 8 +++--- .../test-abidiff/test-PR18791-report0.txt | 3 +-- .../PR25058-liblttng-ctl-report-1.txt | 22 +++++++-------- .../data/test-diff-filter/test16-report-2.txt | 2 +- .../data/test-diff-filter/test17-1-report.txt | 2 +- .../test25-cyclic-type-report-1.txt | 2 +- ...l7.x86_64-0.12.8-1.el7.x86_64-report-2.txt | 27 +++++++++---------- .../test-diff-suppr/test36-leaf-report-0.txt | 2 +- 9 files changed, 45 insertions(+), 42 deletions(-) diff --git a/src/abg-reporter-priv.cc b/src/abg-reporter-priv.cc index 883c815e..323de503 100644 --- a/src/abg-reporter-priv.cc +++ b/src/abg-reporter-priv.cc @@ -507,11 +507,11 @@ represent(const var_diff_sptr &diff, if (d->currently_reporting()) { - out << " as being reported\n"; + out << ", as being reported\n"; } else if (d->reported_once()) { - out << " as reported earlier\n"; + out << ", as reported earlier\n"; } else { @@ -527,13 +527,20 @@ represent(const var_diff_sptr &diff, if (ctxt->get_reporter()->diff_to_be_reported(d.get())) { out << indent - << "type of '" << pretty_representation << "' changed:\n"; + << "type of '" << pretty_representation << "' changed"; if (d->currently_reporting()) - out << indent << " details are being reported\n"; + { + out << ", as being reported\n"; + } else if (d->reported_once()) - out << indent << " details were reported earlier\n"; + { + out << ", as reported earlier\n"; + } else - d->report(out, indent + " "); + { + out << ":\n"; + d->report(out, indent + " "); + } begin_with_and = true; emitted = true; diff --git a/src/abg-reporter-priv.h b/src/abg-reporter-priv.h index b6c56fdb..b221fdc3 100644 --- a/src/abg-reporter-priv.h +++ b/src/abg-reporter-priv.h @@ -68,14 +68,14 @@ { \ string _name_ = _diff_->first_subject()->get_pretty_representation(); \ if (_diff_->currently_reporting()) \ - out << indent << INTRO_TEXT << " '" << _name_ << "' changed; " \ - "details are being reported\n"; \ + out << indent << INTRO_TEXT << " '" << _name_ \ + << "' changed, as being reported\n"; \ else \ { \ out << indent << INTRO_TEXT << " '" \ - << _name_ << "' changed"; \ + << _name_ << "' changed"; \ report_loc_info(D->first_subject(), *d.context(), out); \ - out << ", as reported earlier\n"; \ + out << ", as reported earlier\n"; \ } \ return ; \ } \ diff --git a/tests/data/test-abidiff/test-PR18791-report0.txt b/tests/data/test-abidiff/test-PR18791-report0.txt index 93faf599..5bc2d08b 100644 --- a/tests/data/test-abidiff/test-PR18791-report0.txt +++ b/tests/data/test-abidiff/test-PR18791-report0.txt @@ -123,8 +123,7 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable type name changed from 'std::_List_base >::_List_impl' to 'std::__cxx11::_List_base >::_List_impl' type size changed from 128 to 192 (in bits) 1 data member change: - type of 'std::__detail::_List_node_base std::_List_base >::_List_impl::_M_node' changed: - details were reported earlier + type of 'std::__detail::_List_node_base std::_List_base >::_List_impl::_M_node' changed, as reported earlier and name of 'std::_List_base >::_List_impl::_M_node' changed to 'std::__cxx11::_List_base >::_List_impl::_M_node' and name of 'std::_List_base >::_M_impl' changed to 'std::__cxx11::_List_base >::_M_impl' diff --git a/tests/data/test-diff-dwarf/PR25058-liblttng-ctl-report-1.txt b/tests/data/test-diff-dwarf/PR25058-liblttng-ctl-report-1.txt index dfb63684..44ddc6d6 100644 --- a/tests/data/test-diff-dwarf/PR25058-liblttng-ctl-report-1.txt +++ b/tests/data/test-diff-dwarf/PR25058-liblttng-ctl-report-1.txt @@ -179,8 +179,7 @@ Variables changes summary: 0 Removed, 0 Changed, 3 Added variables in pointed to type 'struct lttng_event_field': type size hasn't changed 1 data member change: - type of 'lttng_event lttng_event_field::event' changed: - details were reported earlier + type of 'lttng_event lttng_event_field::event' changed, as reported earlier [C] 'function int lttng_list_tracepoints(lttng_handle*, lttng_event**)' has some indirect sub-type changes: parameter 2 of type 'lttng_event**' has sub-type changes: @@ -232,7 +231,7 @@ Variables changes summary: 0 Removed, 0 Changed, 3 Added variables type size changed from 576 to 640 (in bits) 2 data member changes: type of 'filter_node* filter_node::parent' changed: - pointed to type 'struct filter_node' changed; details are being reported + pointed to type 'struct filter_node' changed, as being reported type of 'union {struct {} unknown; struct {filter_node* child;} root; struct {__anonymous_enum__ type; ast_link_type post_op; ast_link_type pre_op; union {char* string; uint64_t constant; double float_constant; char* identifier; filter_node* child;} u; filter_node* prev; filter_node* next;} expression; struct {op_type type; filter_node* lchild; filter_node* rchild;} op; struct {unary_op_type type; filter_node* child;} unary_op;} filter_node::u' changed: type size changed from 320 to 384 (in bits) 4 data member changes: @@ -245,21 +244,20 @@ Variables changes summary: 0 Removed, 0 Changed, 3 Added variables type size hasn't changed 1 enumerator insertion: 'ast_link_type::AST_LINK_BRACKET' value '3' - type of 'ast_link_type pre_op' changed: - details were reported earlier + type of 'ast_link_type pre_op' changed, as reported earlier type of 'union {char* string; uint64_t constant; double float_constant; char* identifier; filter_node* child;} u' changed: type size hasn't changed 1 data member change: type of 'filter_node* child' changed: - pointed to type 'struct filter_node' changed; details are being reported + pointed to type 'struct filter_node' changed, as being reported type changed from: union {char* string; uint64_t constant; double float_constant; char* identifier; filter_node* child;} to: union {char* string; uint64_t constant; double float_constant; char* identifier; filter_node* child;} type of 'filter_node* prev' changed: - pointed to type 'struct filter_node' changed; details are being reported + pointed to type 'struct filter_node' changed, as being reported type of 'filter_node* next' changed: - pointed to type 'struct filter_node' changed; details are being reported + pointed to type 'struct filter_node' changed, as being reported type of 'struct {op_type type; filter_node* lchild; filter_node* rchild;} op' changed: type size hasn't changed 3 data member changes: @@ -278,14 +276,14 @@ Variables changes summary: 0 Removed, 0 Changed, 3 Added variables 'op_type::AST_OP_BIT_OR' value '11' 'op_type::AST_OP_BIT_XOR' value '12' type of 'filter_node* lchild' changed: - pointed to type 'struct filter_node' changed; details are being reported + pointed to type 'struct filter_node' changed, as being reported type of 'filter_node* rchild' changed: - pointed to type 'struct filter_node' changed; details are being reported + pointed to type 'struct filter_node' changed, as being reported type of 'struct {filter_node* child;} root' changed: type size hasn't changed 1 data member change: type of 'filter_node* child' changed: - pointed to type 'struct filter_node' changed; details are being reported + pointed to type 'struct filter_node' changed, as being reported type of 'struct {unary_op_type type; filter_node* child;} unary_op' changed: type size hasn't changed 2 data member changes: @@ -296,7 +294,7 @@ Variables changes summary: 0 Removed, 0 Changed, 3 Added variables 1 enumerator insertion: 'unary_op_type::AST_UNARY_BIT_NOT' value '4' type of 'filter_node* child' changed: - pointed to type 'struct filter_node' changed; details are being reported + pointed to type 'struct filter_node' changed, as being reported 'cds_list_head filter_ast::allocated_nodes' offset changed from 576 to 640 (in bits) (by +64 bits) [C] 'function YYSTYPE* lttng_yyget_lval(yyscan_t)' has some indirect sub-type changes: diff --git a/tests/data/test-diff-filter/test16-report-2.txt b/tests/data/test-diff-filter/test16-report-2.txt index a90e85ad..f69eabdc 100644 --- a/tests/data/test-diff-filter/test16-report-2.txt +++ b/tests/data/test-diff-filter/test16-report-2.txt @@ -11,6 +11,6 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable 'int S::m0', at offset 0 (in bits) 1 data member change: type of 'S* S::m2' changed: - pointed to type 'struct S' changed; details are being reported + pointed to type 'struct S' changed, as being reported and offset changed from 0 to 64 (in bits) (by +64 bits) diff --git a/tests/data/test-diff-filter/test17-1-report.txt b/tests/data/test-diff-filter/test17-1-report.txt index 7c51152a..0b39c5d4 100644 --- a/tests/data/test-diff-filter/test17-1-report.txt +++ b/tests/data/test-diff-filter/test17-1-report.txt @@ -11,7 +11,7 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable 'int S::m0', at offset 0 (in bits) 1 data member change: type of 'S* S::m2' changed: - pointed to type 'struct S' changed; details are being reported + pointed to type 'struct S' changed, as being reported and offset changed from 0 to 64 (in bits) (by +64 bits) [C] 'function void foo(S&)' has some indirect sub-type changes: diff --git a/tests/data/test-diff-filter/test25-cyclic-type-report-1.txt b/tests/data/test-diff-filter/test25-cyclic-type-report-1.txt index 6a6beeef..0215d892 100644 --- a/tests/data/test-diff-filter/test25-cyclic-type-report-1.txt +++ b/tests/data/test-diff-filter/test25-cyclic-type-report-1.txt @@ -11,5 +11,5 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable 'char S::m1', at offset 32 (in bits) 1 data member change: type of 'S* S::m2' changed: - pointed to type 'struct S' changed; details are being reported + pointed to type 'struct S' changed, as being reported diff --git a/tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt b/tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt index 6d9beb85..58c94b7a 100644 --- a/tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt +++ b/tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-2.txt @@ -37,7 +37,7 @@ 13 data member changes: type of 'QXLInstance* RedDispatcher::qxl' changed: in pointed to type 'typedef QXLInstance' at spice-qxl.h:34:1: - underlying type 'struct QXLInstance' changed; details are being reported + underlying type 'struct QXLInstance' changed, as being reported type of 'Dispatcher RedDispatcher::dispatcher' changed: underlying type 'struct Dispatcher' at dispatcher.h:22:1 changed: type size changed from 960 to 1024 (in bits) @@ -51,7 +51,7 @@ 'int RedDispatcher::use_hardware_cursor' offset changed from 2240 to 2304 (in bits) (by +64 bits) type of 'RedDispatcher* RedDispatcher::next' changed: in pointed to type 'typedef RedDispatcher' at red_worker.h:87:1: - underlying type 'struct RedDispatcher' changed; details are being reported + underlying type 'struct RedDispatcher' changed, as being reported and offset changed from 2304 to 2368 (in bits) (by +64 bits) 'Ring RedDispatcher::async_commands' offset changed from 2368 to 2432 (in bits) (by +64 bits) 'pthread_mutex_t RedDispatcher::async_lock' offset changed from 2496 to 2560 (in bits) (by +64 bits) @@ -185,7 +185,7 @@ 1 data member change: type of 'SpiceCharDeviceState* SpiceCharDeviceInstance::st' changed: in pointed to type 'typedef SpiceCharDeviceState' at spice-char.h:34:1: - underlying type 'struct SpiceCharDeviceState' changed; details are being reported + underlying type 'struct SpiceCharDeviceState' changed, as being reported and offset changed from 896 to 960 (in bits) (by +64 bits) 'int SpiceCharDeviceState::during_read_from_device' offset changed from 960 to 1024 (in bits) (by +64 bits) 'int SpiceCharDeviceState::during_write_to_device' offset changed from 992 to 1056 (in bits) (by +64 bits) @@ -223,7 +223,7 @@ 2 data member changes (2 filtered): type of 'RedChannel* RedChannelClient::channel' changed: in pointed to type 'typedef RedChannel' at red_channel.h:130:1: - underlying type 'struct RedChannel' changed; details are being reported + underlying type 'struct RedChannel' changed, as being reported type of 'RedsStream* RedChannelClient::stream' changed: in pointed to type 'typedef RedsStream' at reds_stream.h:31:1: underlying type 'struct RedsStream' at reds.h:68:1 changed: @@ -391,7 +391,7 @@ in pointed to type 'function type void (RedChannel*, RedClient*, RedsStream*, int, int, uint32_t*, int, uint32_t*)': parameter 1 of type 'RedChannel*' has sub-type changes: in pointed to type 'typedef RedChannel' at red_channel.h:130:1: - underlying type 'struct RedChannel' changed; details are being reported + underlying type 'struct RedChannel' changed, as being reported parameter 3 of type 'RedsStream*' has sub-type changes: pointed to type 'typedef RedsStream' changed at red_channel.h:134:1, as reported earlier type of 'channel_client_disconnect_proc disconnect' changed: @@ -524,7 +524,7 @@ pointed to type 'typedef RedsStream' changed at red_channel.h:134:1, as reported earlier type of 'SndWorker* SndChannel::worker' changed: in pointed to type 'typedef SndWorker' at snd_worker.c:80:1: - underlying type 'struct SndWorker' changed; details are being reported + underlying type 'struct SndWorker' changed, as being reported type of 'RedChannelClient* SndChannel::channel_client' changed: pointed to type 'typedef RedChannelClient' changed at red_channel.h:136:1, as reported earlier type of 'snd_channel_handle_message_proc SndChannel::handle_message' changed: @@ -532,26 +532,26 @@ in pointed to type 'function type int (SndChannel*, typedef size_t, typedef uint32_t, void*)': parameter 1 of type 'SndChannel*' has sub-type changes: in pointed to type 'typedef SndChannel' at snd_worker.c:74:1: - underlying type 'struct SndChannel' changed; details are being reported + underlying type 'struct SndChannel' changed, as being reported type of 'snd_channel_on_message_done_proc SndChannel::on_message_done' changed: underlying type 'void (SndChannel*)*' changed: in pointed to type 'function type void (SndChannel*)': parameter 1 of type 'SndChannel*' has sub-type changes: in pointed to type 'typedef SndChannel' at snd_worker.c:74:1: - underlying type 'struct SndChannel' changed; details are being reported + underlying type 'struct SndChannel' changed, as being reported type of 'snd_channel_cleanup_channel_proc SndChannel::cleanup' changed: underlying type 'void (SndChannel*)*' changed: in pointed to type 'function type void (SndChannel*)': parameter 1 of type 'SndChannel*' has sub-type changes: in pointed to type 'typedef SndChannel' at snd_worker.c:74:1: - underlying type 'struct SndChannel' changed; details are being reported + underlying type 'struct SndChannel' changed, as being reported no data member change (1 filtered); type of 'SndWorker* SndWorker::next' changed: in pointed to type 'typedef SndWorker' at snd_worker.c:80:1: - underlying type 'struct SndWorker' changed; details are being reported + underlying type 'struct SndWorker' changed, as being reported type of 'SpicePlaybackInstance* SpicePlaybackState::sin' changed: in pointed to type 'typedef SpicePlaybackInstance' at spice-audio.h:33:1: - underlying type 'struct SpicePlaybackInstance' changed; details are being reported + underlying type 'struct SpicePlaybackInstance' changed, as being reported [C] 'function void spice_server_playback_put_samples(SpicePlaybackInstance*, uint32_t*)' at snd_worker.c:1100:1 has some indirect sub-type changes: parameter 1 of type 'SpicePlaybackInstance*' has sub-type changes: @@ -590,11 +590,10 @@ 1 data member insertion: 'uint32_t SpiceRecordState::frequency', at offset 512 (in bits) at snd_worker.c:166:1 2 data member changes: - type of 'SndWorker SpiceRecordState::worker' changed: - details were reported earlier + type of 'SndWorker SpiceRecordState::worker' changed, as reported earlier type of 'SpiceRecordInstance* SpiceRecordState::sin' changed: in pointed to type 'typedef SpiceRecordInstance' at spice-audio.h:67:1: - underlying type 'struct SpiceRecordInstance' changed; details are being reported + underlying type 'struct SpiceRecordInstance' changed, as being reported [C] 'function void spice_server_record_set_mute(SpiceRecordInstance*, uint8_t)' at snd_worker.c:1279:1 has some indirect sub-type changes: parameter 1 of type 'SpiceRecordInstance*' has sub-type changes: diff --git a/tests/data/test-diff-suppr/test36-leaf-report-0.txt b/tests/data/test-diff-suppr/test36-leaf-report-0.txt index d270740d..9caa9428 100644 --- a/tests/data/test-diff-suppr/test36-leaf-report-0.txt +++ b/tests/data/test-diff-suppr/test36-leaf-report-0.txt @@ -15,7 +15,7 @@ Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable 'struct leaf2 at test36-leaf-v0.cc:9:1' changed: type size changed from 64 to 96 (in bits) there are data member changes: - type 'struct leaf1' of 'leaf2::member0' changed as reported earlier + type 'struct leaf1' of 'leaf2::member0' changed, as reported earlier and size changed from 32 to 64 (in bits) (by +32 bits) 'char leaf2::member1' offset changed from 32 to 64 (in bits) (by +32 bits) 3 impacted interfaces: From patchwork Fri Apr 3 21:53:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 39077 From: gprocida@google.com (Giuliano Procida) Date: Fri, 3 Apr 2020 22:53:55 +0100 Subject: [PATCH 2/2] abidiff: Fix anonymous member size change reports. In-Reply-To: <20200403215356.186742-1-gprocida@google.com> References: <20200403215356.186742-1-gprocida@google.com> Message-ID: <20200403215356.186742-2-gprocida@google.com> Data members have names (unless anonymous), types, sizes and offsets (if a member of a class or struct). It is the responsibility of the represent function to detail all differences of a changed member. The size of a member is the same as the size of its type. A recent change to the function focused on cleaning up the formatting logic and added a catch-all case to the end of it in case no diff information had been emitted by then. This catch-all triggered for anonymous structs and union diffs under certain circumstances when these anonymous members had changed in size. This patch ensures size change information for a member is emitted exactly once (unless the type change has been or is being reported already). It also ensures anonymous members are identified appropriately and includes a test case would otherwise reach the catch-all case in both default and --leaf-changes-only modes. * src/abg-reporter-priv.cc (represent): In the var_diff_sptr overload, factor out some expressions as local variables, rely on diff_to_be_reported to decide whether to emit a change, fold together local/non-local change reporting using local_changes to preserve current name formatting differences, keep track explicitly of whether size information has been emitted and ensure it happens if needed, make offset and size change reporting for anonymous data members more meaningful. * tests/test-abidiff-exit.cc: Run new test cases. * tests/data/Makefile.am: Add new test files. * tests/data/test-abidiff-exit/test-member-size-v0.cc: New test. * tests/data/test-abidiff-exit/test-member-size-v0.o: Ditto. * tests/data/test-abidiff-exit/test-member-size-v1.cc: Ditto. * tests/data/test-abidiff-exit/test-member-size-v1.o: Ditto. * tests/data/test-abidiff-exit/test-member-size-report0.txt: New test, default mode. * tests/data/test-abidiff-exit/test-member-size-report1.txt: New test, --leaf-changes-only mode. * tests/data/test-abidiff-exit/test-leaf-cxx-members-report.txt: Eliminate duplicate reporting of member sizes. * tests/data/test-abidiff-exit/test-leaf-peeling-report.txt: Ditto. * tests/data/test-abidiff-exit/test-leaf1-report.txt: Ditto. * tests/data/test-abidiff-exit/test-no-stray-comma-report.txt: Ditto. * tests/data/test-diff-dwarf/test45-anon-dm-change-report-0.txt: Add size report for anonymous data member. * tests/data/test-diff-filter/test44-anonymous-data-member-report-0.txt: Ditto. * tests/data/test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt: Add missing size change report. * tests/data/test-diff-suppr/test36-leaf-report-0.txt: Remove size change report for previously reported type. * tests/data/test-diff-suppr/test46-PR25128-report-1.txt: Eliminate duplicate reporting of member size change. * tests/data/test-diff-suppr/test46-PR25128-report-2.txt: Ditto. Signed-off-by: Giuliano Procida Reviewed-by: Matthias Maennich Tested-by: Matthias Maennich --- src/abg-reporter-priv.cc | 98 +++++++----------- tests/data/Makefile.am | 6 ++ .../test-leaf-cxx-members-report.txt | 4 +- .../test-leaf-peeling-report.txt | 1 - .../test-abidiff-exit/test-leaf1-report.txt | 1 - .../test-member-size-report0.txt | 27 +++++ .../test-member-size-report1.txt | 21 ++++ .../test-abidiff-exit/test-member-size-v0.cc | 26 +++++ .../test-abidiff-exit/test-member-size-v0.o | Bin 0 -> 3184 bytes .../test-abidiff-exit/test-member-size-v1.cc | 27 +++++ .../test-abidiff-exit/test-member-size-v1.o | Bin 0 -> 3192 bytes .../test-no-stray-comma-report.txt | 1 - .../test45-anon-dm-change-report-0.txt | 1 + .../test44-anonymous-data-member-report-0.txt | 1 + ...-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt | 2 +- .../test-diff-suppr/test36-leaf-report-0.txt | 1 - .../test46-PR25128-report-1.txt | 1 - .../test46-PR25128-report-2.txt | 1 - tests/test-abidiff-exit.cc | 18 ++++ 19 files changed, 167 insertions(+), 70 deletions(-) create mode 100644 tests/data/test-abidiff-exit/test-member-size-report0.txt create mode 100644 tests/data/test-abidiff-exit/test-member-size-report1.txt create mode 100644 tests/data/test-abidiff-exit/test-member-size-v0.cc create mode 100644 tests/data/test-abidiff-exit/test-member-size-v0.o create mode 100644 tests/data/test-abidiff-exit/test-member-size-v1.cc create mode 100644 tests/data/test-abidiff-exit/test-member-size-v1.o diff --git a/src/abg-reporter-priv.cc b/src/abg-reporter-priv.cc index 323de503..72181367 100644 --- a/src/abg-reporter-priv.cc +++ b/src/abg-reporter-priv.cc @@ -411,16 +411,26 @@ represent(const var_diff_sptr &diff, var_decl_sptr o = diff->first_var(); var_decl_sptr n = diff->second_var(); + string name1 = o->get_qualified_name(); + string name2 = n->get_qualified_name(); + uint64_t size1 = get_var_size_in_bits(o); + uint64_t size2 = get_var_size_in_bits(n); + uint64_t offset1 = get_data_member_offset(o); + uint64_t offset2 = get_data_member_offset(n); // Has the main diff text been output? bool emitted = false; // Are we continuing on a new line? (implies emitted) bool begin_with_and = false; - string name1 = o->get_qualified_name(); - string name2 = n->get_qualified_name(); - string pretty_representation = o->get_pretty_representation(); + // Have we reported a size change already? + bool size_reported = false; + // Are we reporting a change to an anonymous member? bool is_strict_anonymous_data_member_change = false; + string pretty_representation = o->get_pretty_representation(); + bool show_size_offset_changes = ctxt->get_allowed_category() + & SIZE_OR_OFFSET_CHANGE_CATEGORY; + if (is_anonymous_data_member(o) && is_anonymous_data_member(n)) { is_strict_anonymous_data_member_change = true; @@ -430,8 +440,7 @@ represent(const var_diff_sptr &diff, if (tr1 != tr2) { show_offset_or_size(indent + "anonymous data member at offset", - get_data_member_offset(o), - *ctxt, out); + offset1, *ctxt, out); out << " changed from:\n" << indent << " " << tr1 << "\n" @@ -460,7 +469,6 @@ represent(const var_diff_sptr &diff, begin_with_and = true; emitted = true; } - // TODO: else ...? } else if (filtering::has_anonymous_data_member_change(diff)) { @@ -472,9 +480,7 @@ represent(const var_diff_sptr &diff, + o->get_pretty_representation() + " at offset"; - show_offset_or_size(indent + repr, - get_data_member_offset(o), - *ctxt, out); + show_offset_or_size(indent + repr, offset1, *ctxt, out); out << " became data member '" << n->get_pretty_representation() << "'\n"; @@ -486,9 +492,7 @@ represent(const var_diff_sptr &diff, + o->get_pretty_representation() + " at offset"; - show_offset_or_size(indent + repr, - get_data_member_offset(o), - *ctxt, out); + show_offset_or_size(indent + repr, offset1, *ctxt, out); out << " became anonymous data member '" << n->get_pretty_representation() << "'\n"; @@ -499,11 +503,15 @@ represent(const var_diff_sptr &diff, } else if (diff_sptr d = diff->type_diff()) { - if (local_only && d->has_local_changes()) + if (ctxt->get_reporter()->diff_to_be_reported(d.get())) { - out << indent << "type '" << get_pretty_representation(o->get_type()) - << "' of '" << o->get_qualified_name() - << "' changed"; + if (local_only) + out << indent << "type '" << get_pretty_representation(o->get_type()) + << "' of '" << o->get_qualified_name() + << "' changed"; + else + out << indent + << "type of '" << pretty_representation << "' changed"; if (d->currently_reporting()) { @@ -521,30 +529,7 @@ represent(const var_diff_sptr &diff, begin_with_and = true; emitted = true; - } - else - { - if (ctxt->get_reporter()->diff_to_be_reported(d.get())) - { - out << indent - << "type of '" << pretty_representation << "' changed"; - if (d->currently_reporting()) - { - out << ", as being reported\n"; - } - else if (d->reported_once()) - { - out << ", as reported earlier\n"; - } - else - { - out << ":\n"; - d->report(out, indent + " "); - } - - begin_with_and = true; - emitted = true; - } + size_reported = true; } } @@ -589,9 +574,9 @@ represent(const var_diff_sptr &diff, out << "now becomes laid out"; emitted = true; } - if ((ctxt->get_allowed_category() & SIZE_OR_OFFSET_CHANGE_CATEGORY)) + if (show_size_offset_changes) { - if (get_data_member_offset(o) != get_data_member_offset(n)) + if (offset1 != offset2) { if (begin_with_and) { @@ -600,26 +585,20 @@ represent(const var_diff_sptr &diff, } else if (!emitted) { + out << indent; if (is_strict_anonymous_data_member_change) - out << indent; - else - out << indent << "'" << pretty_representation << "' "; + out << "anonymous data member "; + out << "'" << pretty_representation << "' "; } else out << ", "; - show_numerical_change("offset", - get_data_member_offset(o), - get_data_member_offset(n), - *ctxt, out); + show_numerical_change("offset", offset1, offset2, *ctxt, out); maybe_show_relative_offset_change(diff, *ctxt, out); - emitted = true; } - if (// If we are not displaying only local changes, we must - // have indicated the type size change already. - local_only - && (get_var_size_in_bits(o) != get_var_size_in_bits(n))) + + if (!size_reported && size1 != size2) { if (begin_with_and) { @@ -628,18 +607,15 @@ represent(const var_diff_sptr &diff, } else if (!emitted) { + out << indent; if (is_strict_anonymous_data_member_change) - out << indent; - else - out << indent << "'" << pretty_representation << "' "; + out << "anonymous data member "; + out << "'" << pretty_representation << "' "; } else out << ", "; - show_numerical_change("size", - get_var_size_in_bits(o), - get_var_size_in_bits(n), - *ctxt, out); + show_numerical_change("size", size1, size2, *ctxt, out); maybe_show_relative_size_change(diff, *ctxt, out); emitted = true; } diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index bb0fd83b..64e36b1a 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -140,6 +140,12 @@ test-abidiff-exit/test-leaf-cxx-members-v0.o \ test-abidiff-exit/test-leaf-cxx-members-v1.cc \ test-abidiff-exit/test-leaf-cxx-members-v1.o \ test-abidiff-exit/test-leaf-cxx-members-report.txt \ +test-abidiff-exit/test-member-size-v0.cc \ +test-abidiff-exit/test-member-size-v0.o \ +test-abidiff-exit/test-member-size-v1.cc \ +test-abidiff-exit/test-member-size-v1.o \ +test-abidiff-exit/test-member-size-report0.txt \ +test-abidiff-exit/test-member-size-report1.txt \ \ test-diff-dwarf/test0-v0.cc \ test-diff-dwarf/test0-v0.o \ diff --git a/tests/data/test-abidiff-exit/test-leaf-cxx-members-report.txt b/tests/data/test-abidiff-exit/test-leaf-cxx-members-report.txt index 082db83e..eae74a3b 100644 --- a/tests/data/test-abidiff-exit/test-leaf-cxx-members-report.txt +++ b/tests/data/test-abidiff-exit/test-leaf-cxx-members-report.txt @@ -35,8 +35,8 @@ Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable type 'int' of 'ops::deleted_var' changed: type name changed from 'int' to 'long int' type size changed from 32 to 64 (in bits) - and name of 'ops::deleted_var' changed to 'ops::added_var' at test-leaf-cxx-members-v1.cc:2:1, size changed from 32 to 64 (in bits) (by +32 bits) + and name of 'ops::deleted_var' changed to 'ops::added_var' at test-leaf-cxx-members-v1.cc:2:1 type 'int' of 'ops::changed_var' changed: type name changed from 'int' to 'long int' type size changed from 32 to 64 (in bits) - and offset changed from 96 to 128 (in bits) (by +32 bits), size changed from 32 to 64 (in bits) (by +32 bits) + and offset changed from 96 to 128 (in bits) (by +32 bits) diff --git a/tests/data/test-abidiff-exit/test-leaf-peeling-report.txt b/tests/data/test-abidiff-exit/test-leaf-peeling-report.txt index bd5f36f8..7ab4dd6e 100644 --- a/tests/data/test-abidiff-exit/test-leaf-peeling-report.txt +++ b/tests/data/test-abidiff-exit/test-leaf-peeling-report.txt @@ -9,7 +9,6 @@ Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable type 'int' of 'foo::z' changed: type name changed from 'int' to 'long int' type size changed from 32 to 64 (in bits) - and size changed from 32 to 64 (in bits) (by +32 bits) 'struct ops1 at test-leaf-peeling-v0.cc:5:1' changed: type size hasn't changed diff --git a/tests/data/test-abidiff-exit/test-leaf1-report.txt b/tests/data/test-abidiff-exit/test-leaf1-report.txt index 9af6ccaa..aea08b81 100644 --- a/tests/data/test-abidiff-exit/test-leaf1-report.txt +++ b/tests/data/test-abidiff-exit/test-leaf1-report.txt @@ -40,4 +40,3 @@ Removed/Changed/Added variables summary: 1 Removed, 1 Changed, 1 Added variable type 'int' of 'changed::foo' changed: type name changed from 'int' to 'long int' type size changed from 32 to 64 (in bits) - and size changed from 32 to 64 (in bits) (by +32 bits) diff --git a/tests/data/test-abidiff-exit/test-member-size-report0.txt b/tests/data/test-abidiff-exit/test-member-size-report0.txt new file mode 100644 index 00000000..ff93dd50 --- /dev/null +++ b/tests/data/test-abidiff-exit/test-member-size-report0.txt @@ -0,0 +1,27 @@ +Functions changes summary: 0 Removed, 2 Changed, 0 Added functions +Variables changes summary: 0 Removed, 0 Changed, 0 Added variable + +2 functions with some indirect sub-type change: + + [C] 'function void reg1(S*, T*, T*)' at test-member-size-v1.cc:26:1 has some indirect sub-type changes: + parameter 1 of type 'S*' has sub-type changes: + in pointed to type 'struct S' at test-member-size-v1.cc:3:1: + type size changed from 128 to 192 (in bits) + 1 data member insertion: + 'int S::y', at offset 128 (in bits) at test-member-size-v1.cc:6:1 + no data member change (1 filtered); + parameter 2 of type 'T*' has sub-type changes: + in pointed to type 'struct T' at test-member-size-v1.cc:14:1: + type size changed from 192 to 256 (in bits) + 2 data member changes: + 'S T::s' size changed from 128 to 192 (in bits) (by +64 bits) + 'int T::a' offset changed from 128 to 192 (in bits) (by +64 bits) + + [C] 'function void reg2(U*)' at test-member-size-v1.cc:27:1 has some indirect sub-type changes: + parameter 1 of type 'U*' has sub-type changes: + in pointed to type 'struct U' at test-member-size-v1.cc:19:1: + type size changed from 192 to 256 (in bits) + 2 data member changes: + anonymous data member 'struct {S s;}' size changed from 128 to 192 (in bits) (by +64 bits) + 'int U::r' offset changed from 128 to 192 (in bits) (by +64 bits) + diff --git a/tests/data/test-abidiff-exit/test-member-size-report1.txt b/tests/data/test-abidiff-exit/test-member-size-report1.txt new file mode 100644 index 00000000..dbad76be --- /dev/null +++ b/tests/data/test-abidiff-exit/test-member-size-report1.txt @@ -0,0 +1,21 @@ +Leaf changes summary: 3 artifacts changed +Changed leaf types summary: 3 leaf types changed +Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 0 Added function +Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable + +'struct S at test-member-size-v0.cc:3:1' changed: + type size changed from 128 to 192 (in bits) + 1 data member insertion: + 'int S::y', at offset 128 (in bits) at test-member-size-v1.cc:6:1 + +'struct T at test-member-size-v0.cc:13:1' changed: + type size changed from 192 to 256 (in bits) + there are data member changes: + type 'struct S' of 'T::s' changed, as reported earlier + 'int T::a' offset changed from 128 to 192 (in bits) (by +64 bits) + +'struct U at test-member-size-v0.cc:18:1' changed: + type size changed from 192 to 256 (in bits) + there are data member changes: + anonymous data member 'struct {S s;}' size changed from 128 to 192 (in bits) (by +64 bits) + 'int U::r' offset changed from 128 to 192 (in bits) (by +64 bits) diff --git a/tests/data/test-abidiff-exit/test-member-size-v0.cc b/tests/data/test-abidiff-exit/test-member-size-v0.cc new file mode 100644 index 00000000..f974a37f --- /dev/null +++ b/tests/data/test-abidiff-exit/test-member-size-v0.cc @@ -0,0 +1,26 @@ +struct M; + +struct S { + int x; + M * m; +}; + +struct M { + int a; + S * s; +}; + +struct T { + S s; + int a; +}; + +struct U { + struct { + S s; + }; + int r; +}; + +void reg1(S*, T*, T*) { } +void reg2(U*) { } diff --git a/tests/data/test-abidiff-exit/test-member-size-v0.o b/tests/data/test-abidiff-exit/test-member-size-v0.o new file mode 100644 index 0000000000000000000000000000000000000000..e020bef77d57d601420f969061707bbf1486ac99 GIT binary patch literal 3184 zcmbtWL2MgU5S{P!#_PCtoVcY4LC91fsLC!`E2`o`ifKxds058xj(?a^Q}H#JR_E;{Xyz;Dp2hX8!(hHs8(#M)J=5H}hux|2zM$ zKYaO>ODQ3MMZkGD7%>WPKXYK$q*;R!OhJ8R@7I;R_y1bi+x>lIum0QqTR$*_<}#*A z%V@OZ*btwB*3)~g5^eGuskSzvTPn3+CW7NpZ=JBT246$34cFvA0pRe?Pa zyR0wr-m5{r5;nE!bwo&m@spQP#O>}5`kupge(nG_iieE0~6e( zKrtzvDwJ|YVYV2N_3Nby9MQYQZU6`T7Srda&(>RT1X_hpfcuCTtNAg7uKr~*% zp8>RwLi}CG<5M;pu2Deb_aeLFcN%_Z_u6-S`_`P(Y)ZCy60&g_;!g{6=1+5C(VYA! zWnhXUi0g08hyGS&)vW_+mmU>(F6!(+>~UA!wN>}}T4f!Uuhq*-XU@3u<*HM0+;U~k zt-9`9wQP5y-N0Ym@&i9?H*x5N&DLUn;jDdjzHD!m?M<(DJ7~7TZqVKB*}K8J?O?-> zyvDZQ16W>KI#+(?qTgtHL7drktEaUZa)HO?6L;ax>md3?F?%dy?c=UIhB*C5aN_}9 zDil9XE#=3qVE_)v_X6Q4vg6o)DfY*n;U}iXllaF!!ybA+a6QN z0}l25z->U{QW>B$pKM}uU>fm?4*+EukRQSbFraV*eryP*-kwVAgWP+>PAiMArQo~(^pHMjGQShPtF&RW%RJI<^XF@?^m^cg{JAI^>(n?MW3|2 zMkDlZ9ddi27i{6pkfdz41D`2a0-R>I)A8}U<^1xW*?{SJv$`d#sOuqr%P6j1xolpHm{r6w_)IWMoD#!J&XijY?zhCq( zq(-EK?5JidD+2W!#qn98`+;N;e|k>Bzfs^PG)RaZyNW&?qwqP^q;m-_nR@IM#7513 zU%gP~)BNdn)#tx4A}2y{Q`N82AR&7Fb@Yv@|Glcu`$YBW9@FdZAVxWPo@h$>PSyXM z0j0S<>-P{J#lNZ=itjH@!#vh^6`%dABfTM&gLxeH1sa5@=`sv`#lJB?VuRPu@TX{u z+P{Y*-XDFvn9utQ$` HPo4iS_W$I+ literal 0 HcmV?d00001 diff --git a/tests/data/test-abidiff-exit/test-member-size-v1.cc b/tests/data/test-abidiff-exit/test-member-size-v1.cc new file mode 100644 index 00000000..b3bd5988 --- /dev/null +++ b/tests/data/test-abidiff-exit/test-member-size-v1.cc @@ -0,0 +1,27 @@ +struct M; + +struct S { + int x; + M * m; + int y; +}; + +struct M { + int a; + S * s; +}; + +struct T { + S s; + int a; +}; + +struct U { + struct { + S s; + }; + int r; +}; + +void reg1(S*, T*, T*) { } +void reg2(U*) { } diff --git a/tests/data/test-abidiff-exit/test-member-size-v1.o b/tests/data/test-abidiff-exit/test-member-size-v1.o new file mode 100644 index 0000000000000000000000000000000000000000..eaec9ebead662bc23c00130c537133a5be5c2019 GIT binary patch literal 3192 zcmbtW&u<%55T57F#_Me3IB}ySq(VjlK~;9iMp4zYq?iWUR6q$$jiO2r*3QPZ8gHug zx;RCs2oT68S_z3FapNyQ;?M&JBraUJaYOB!4(zft%TRG~SDLb%w`xv<|QbI zoJDTK2Qj8NZ4h?0M;tIMAGK*Y_{>~`lE_bM(mEYv3fPazc3M0HN3?yi5d|ITCU- z$lQBF=}k=V5e14#@mRiS8~OSCq?pPUW-zLVJ7?Qx?Q{0BEij!i4u+KsFBi|?ghn0( z+dgj_Sl*mK^D+jF7Dbwq9fu^=a>X-qMn0j3vPgOMlM8c{IA>x|W)`RMB+ZiMlPpPE z^hm$cK8VIE_%nd^QHa0uE9T_883R)sL5zaB2V2*dP%o}~6(9{y#jTqP^wzzNb?@57;uc)GQYo#TI^`{u zmfc0yD=jW~%bvHeTyk1*Ck$5VK^R2M8V>!a)>!GDIqjTYDmnF%v*Wk-!&)QS3->y0 zrxU)}47Z)wukHqIfJ>{ZXG>2!7gU>mm}GXm<&#tpT>2=@Czl!xOe0zG08o|zmZ>#@+OiafS;7+{Ew^guNuxh`J2M2V<F})9E4d?lT+um>C8AcsPiEgkJ2i+LlZ9n$Gt+w0XM!~M{ZU@y) zeXAMn?4eKEezh6}w+^`d$PepyEu<;C%`jjJmH@Z5*J=g$QFFt+IB@Y^a@w(9yP-%y zV{0e!TY;MR|5WqHr@i7nHYx*teZ@Tcb_{7VIXNQ0E zB~y=m0kL88zpq{>^J)HcyXy1b9+DFwxS{G-Xpj=U{ucU%)&Ex2=Y693bdTxvZz4uH zd7fxW`C8S#&w$cgpY>aa594pDhT{8+(=d{S1GM#<2bSVaWTVuNU)qUx(GE+~2GE4K-o >::_List_impl' to 'std::__cxx11::_List_base >::_List_impl' type size changed from 128 to 192 (in bits) 1 data member change: - name of 'std::_List_base >::_List_impl::_M_node' changed to 'std::__cxx11::_List_base >::_List_impl::_M_node' + name of 'std::_List_base >::_List_impl::_M_node' changed to 'std::__cxx11::_List_base >::_List_impl::_M_node', size changed from 128 to 192 (in bits) (by +64 bits) and name of 'std::_List_base >::_M_impl' changed to 'std::__cxx11::_List_base >::_M_impl' ================ end of changes of 'libsigc-2.0.so.0.0.0'=============== diff --git a/tests/data/test-diff-suppr/test36-leaf-report-0.txt b/tests/data/test-diff-suppr/test36-leaf-report-0.txt index 9caa9428..fcbb9232 100644 --- a/tests/data/test-diff-suppr/test36-leaf-report-0.txt +++ b/tests/data/test-diff-suppr/test36-leaf-report-0.txt @@ -16,7 +16,6 @@ Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable type size changed from 64 to 96 (in bits) there are data member changes: type 'struct leaf1' of 'leaf2::member0' changed, as reported earlier - and size changed from 32 to 64 (in bits) (by +32 bits) 'char leaf2::member1' offset changed from 32 to 64 (in bits) (by +32 bits) 3 impacted interfaces: function void interface1(struct_type*) diff --git a/tests/data/test-diff-suppr/test46-PR25128-report-1.txt b/tests/data/test-diff-suppr/test46-PR25128-report-1.txt index 36439ce7..acff860c 100644 --- a/tests/data/test-diff-suppr/test46-PR25128-report-1.txt +++ b/tests/data/test-diff-suppr/test46-PR25128-report-1.txt @@ -13,5 +13,4 @@ Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable type 'unsigned long int' of 'root_domain::max_cpu_capacity' changed: entity changed from 'unsigned long int' to 'struct max_cpu_capacity' at sched.h:722:1 type size changed from 64 to 192 (in bits) - and size changed from 64 to 192 (in bits) (by +128 bits) 'perf_domain* root_domain::pd' offset changed from 14528 to 14656 (in bits) (by +128 bits) diff --git a/tests/data/test-diff-suppr/test46-PR25128-report-2.txt b/tests/data/test-diff-suppr/test46-PR25128-report-2.txt index 67dbf58f..79827103 100644 --- a/tests/data/test-diff-suppr/test46-PR25128-report-2.txt +++ b/tests/data/test-diff-suppr/test46-PR25128-report-2.txt @@ -9,5 +9,4 @@ Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable type 'unsigned long int' of 'root_domain::max_cpu_capacity' changed: entity changed from 'unsigned long int' to 'struct max_cpu_capacity' at sched.h:722:1 type size changed from 64 to 192 (in bits) - and size changed from 64 to 192 (in bits) (by +128 bits) 'perf_domain* root_domain::pd' offset changed from 14528 to 14656 (in bits) (by +128 bits) diff --git a/tests/test-abidiff-exit.cc b/tests/test-abidiff-exit.cc index 17523afa..97981a69 100644 --- a/tests/test-abidiff-exit.cc +++ b/tests/test-abidiff-exit.cc @@ -177,6 +177,24 @@ InOutSpec in_out_specs[] = "data/test-abidiff-exit/test-leaf-cxx-members-report.txt", "output/test-abidiff-exit/test-leaf-cxx-members-report.txt" }, + { + "data/test-abidiff-exit/test-member-size-v0.o", + "data/test-abidiff-exit/test-member-size-v1.o", + "", + "", + abigail::tools_utils::ABIDIFF_ABI_CHANGE, + "data/test-abidiff-exit/test-member-size-report0.txt", + "output/test-abidiff-exit/test-member-size-report0.txt" + }, + { + "data/test-abidiff-exit/test-member-size-v0.o", + "data/test-abidiff-exit/test-member-size-v1.o", + "", + "--leaf-changes-only", + abigail::tools_utils::ABIDIFF_ABI_CHANGE, + "data/test-abidiff-exit/test-member-size-report1.txt", + "output/test-abidiff-exit/test-member-size-report1.txt" + }, {0, 0, 0 ,0, abigail::tools_utils::ABIDIFF_OK, 0, 0} };