From 6a57f614973535a2e1e83e5276c2a56a79f1421a Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Fri, 4 Apr 2014 11:39:41 +0200 Subject: [PATCH] Fix off-by one comparison bug in comparing function parameters * src/abg-comparison.cc (function_decl_diff::ensure_lookup_tables_populated): Function parameters that are diff'ed start at the first non-implicit parameter, not at the first parameter. Oops. * tests/data/test-diff-dwarf/test3-v0.o: New test input binary. * tests/data/test-diff-dwarf/test3-v0.cc: Source code for the binary above. * tests/data/test-diff-dwarf/test3-v1.o: New test input binary. * tests/data/test-diff-dwarf/test3-v1.cc: Source code for the binary above. * tests/data/test-diff-dwarf/test3-report.txt: Reference report for the diff of the new test inputs. * tests/test-diff-dwarf.cc: Use the test inputs above to run new tests. Signed-off-by: Dodji Seketeli --- src/abg-comparison.cc | 5 +++-- tests/data/test-diff-dwarf/test3-report.txt | 13 ++++++++++++ tests/data/test-diff-dwarf/test3-v0.cc | 19 ++++++++++++++++++ tests/data/test-diff-dwarf/test3-v0.o | Bin 0 -> 3008 bytes tests/data/test-diff-dwarf/test3-v1.cc | 21 ++++++++++++++++++++ tests/data/test-diff-dwarf/test3-v1.o | Bin 0 -> 3064 bytes tests/test-diff-dwarf.cc | 6 ++++++ 7 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 tests/data/test-diff-dwarf/test3-report.txt create mode 100644 tests/data/test-diff-dwarf/test3-v0.cc create mode 100644 tests/data/test-diff-dwarf/test3-v0.o create mode 100644 tests/data/test-diff-dwarf/test3-v1.cc create mode 100644 tests/data/test-diff-dwarf/test3-v1.o diff --git a/src/abg-comparison.cc b/src/abg-comparison.cc index 403c27c2..7aed0b9d 100644 --- a/src/abg-comparison.cc +++ b/src/abg-comparison.cc @@ -4353,7 +4353,8 @@ function_decl_diff::ensure_lookup_tables_populated() i != priv_->parm_changes_.deletions().end(); ++i) { - parm = deleted_parameter_at(i->index()); + parm = *(first_function_decl()->get_first_non_implicit_parm() + + i->index()); parm_name = parm->get_name_id(); // If for a reason the type name is empty we want to know and // fix that. @@ -4372,7 +4373,7 @@ function_decl_diff::ensure_lookup_tables_populated() j != i->inserted_indexes().end(); ++j) { - parm = inserted_parameter_at(*j); + parm = *(second_function_decl()->get_first_non_implicit_parm() + *j); parm_name = parm->get_name_id(); // If for a reason the type name is empty we want to know and // fix that. diff --git a/tests/data/test-diff-dwarf/test3-report.txt b/tests/data/test-diff-dwarf/test3-report.txt new file mode 100644 index 00000000..d1c8be4f --- /dev/null +++ b/tests/data/test-diff-dwarf/test3-report.txt @@ -0,0 +1,13 @@ +Functions changes summary: 0 Removed, 1 Changed, 0 Added function +Variables changes summary: 0 Removed, 0 Changed, 0 Added variable + +1 function with some indirect sub-type change: + + [C]'method void C1::foo(C0&)' has some indirect sub-type changes: + parameter 1 of type 'C0&' has sub-type changes: + in referenced type 'struct C0': + size changed from 32 to 64 bits + 1 data member insertion: + 'char C0::m1', at offset 32 (in bits) + + diff --git a/tests/data/test-diff-dwarf/test3-v0.cc b/tests/data/test-diff-dwarf/test3-v0.cc new file mode 100644 index 00000000..440e34d7 --- /dev/null +++ b/tests/data/test-diff-dwarf/test3-v0.cc @@ -0,0 +1,19 @@ +struct C0 +{ + typedef int Int; + Int m0; + + C0() + :m0(0) + {} + }; + +struct C1 +{ + void + foo(C0&); +}; + +void +C1::foo(C0&) +{} diff --git a/tests/data/test-diff-dwarf/test3-v0.o b/tests/data/test-diff-dwarf/test3-v0.o new file mode 100644 index 0000000000000000000000000000000000000000..94a477d39d7521b3940274d8bbb84723175902cb GIT binary patch literal 3008 zcmbtWOK%%h6h3#xcAQK+abhTq0+NGxBq}q0G%BWTioq&z1gfe?l`15Zjy>1*fFIG! zqzxb*3sfn)f{*}-1ri{!V9SODEcgj*sxH_ev7|dB7I4nYz47>V5E2||=A84L=Y7t+ zclni@%i9pc-FA{K9*ylf>`ZGQSf=SRm9GG__egl>$*;15@Ewd-h zlA)Vx<}zDh#YfPy#PqyjoHs5Qtc2q@1$v&8T~soK6QyC`Xl(ZU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!NvpoJj^t RV0B%Uf8cGwQ!nX${swI`-7^3H literal 0 HcmV?d00001 diff --git a/tests/test-diff-dwarf.cc b/tests/test-diff-dwarf.cc index 0f7fd709..9073bf0a 100644 --- a/tests/test-diff-dwarf.cc +++ b/tests/test-diff-dwarf.cc @@ -74,6 +74,12 @@ InOutSpec in_out_specs[] = "data/test-diff-dwarf/test2-report.txt", "output/test-diff-dwarf/test2-report.txt" }, + { + "data/test-diff-dwarf/test3-v0.o", + "data/test-diff-dwarf/test3-v1.o", + "data/test-diff-dwarf/test3-report.txt", + "output/test-diff-dwarf/test3-report.txt" + }, // This should be the last entry {NULL, NULL, NULL, NULL} };