From c4d202099ea5dea5c115fe834d425c8c7acac4bd Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Wed, 16 Apr 2014 17:14:48 +0200 Subject: [PATCH] Really detect static-ness of data members. Oops. * src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir): Let's consider that a data member being not laid out (i.e, not having a data_member_location) is is a static data member. Otherwise, we were not detecting static data members at all. Well we were only inferring their presence from seeing the static variable definition later on. That means we were missing most of the static variables. Woops. * src/abg-comparison.cc (corpus_diff::priv::ensure_lookup_tables_populated): Now that we are really seeing static data members, let's be prepare to the fact that we can the same static data member being declared several times in a corpus. * tests/data/test-diff-dwarf/test7-report.txt: New test input file. * tests/data/test-diff-dwarf/test7-v0.cc: Likewise. * tests/data/test-diff-dwarf/test7-v0.o: Likewise. * tests/data/test-diff-dwarf/test7-v1.cc: Likewise. * tests/data/test-diff-dwarf/test7-v1.o: Likewise. * tests/test-diff-dwarf.cc: Update this to consume the new test input files. * tests/Makefile.am: Update this to add the missing test files to the source distribution. Signed-off-by: Dodji Seketeli --- src/abg-comparison.cc | 10 +++++- src/abg-dwarf-reader.cc | 7 +++- tests/Makefile.am | 37 +++++++++++++++++++- tests/data/test-diff-dwarf/test7-report.txt | 15 ++++++++ tests/data/test-diff-dwarf/test7-v0.cc | 10 ++++++ tests/data/test-diff-dwarf/test7-v0.o | Bin 0 -> 2896 bytes tests/data/test-diff-dwarf/test7-v1.cc | 12 +++++++ tests/data/test-diff-dwarf/test7-v1.o | Bin 0 -> 3064 bytes tests/test-diff-dwarf.cc | 6 ++++ 9 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 tests/data/test-diff-dwarf/test7-report.txt create mode 100644 tests/data/test-diff-dwarf/test7-v0.cc create mode 100644 tests/data/test-diff-dwarf/test7-v0.o create mode 100644 tests/data/test-diff-dwarf/test7-v1.cc create mode 100644 tests/data/test-diff-dwarf/test7-v1.o diff --git a/src/abg-comparison.cc b/src/abg-comparison.cc index e83afa72..98cf9675 100644 --- a/src/abg-comparison.cc +++ b/src/abg-comparison.cc @@ -5765,7 +5765,15 @@ corpus_diff::priv::ensure_lookup_tables_populated() if (n.empty()) n = added_var->get_name(); assert(!n.empty()); - assert(added_vars_.find(n) == added_vars_.end()); + { + string_var_ptr_map::const_iterator k = added_vars_.find(n); + if ( k != added_vars_.end()) + { + assert(is_member_decl(k->second) + && get_member_is_static(k->second)); + continue; + } + } string_var_ptr_map::const_iterator j = deleted_vars_.find(n); if (j != deleted_vars_.end()) diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index bc1d1967..ecee6425 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -2362,7 +2362,12 @@ build_class_type_and_add_to_ir(read_context& ctxt, var_decl_sptr dm(new var_decl(n, t, loc, m)); result->add_data_member(dm, access, is_laid_out, - /*is_static=*/false, + // For now, is_static == + // !is_laid_out. When we have + // templates, we'll try to be + // more specific. For now, this + // approximation should do OK. + /*is_static=*/!is_laid_out, offset_in_bits); assert(has_scope(dm)); ctxt.die_decl_map()[dwarf_dieoffset(&child)] = dm; diff --git a/tests/Makefile.am b/tests/Makefile.am index 41de71f4..36873927 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -137,6 +137,21 @@ data/test-diff-dwarf/test4-v0.o \ data/test-diff-dwarf/test4-v1.cc \ data/test-diff-dwarf/test4-v1.o \ data/test-diff-dwarf/test4-report.txt \ +data/test-diff-dwarf/test5-v0.cc \ +data/test-diff-dwarf/test5-v0.o \ +data/test-diff-dwarf/test5-v1.cc \ +data/test-diff-dwarf/test5-v1.o \ +data/test-diff-dwarf/test5-report.txt \ +data/test-diff-dwarf/test6-v0.cc \ +data/test-diff-dwarf/test6-v0.o \ +data/test-diff-dwarf/test6-v1.cc \ +data/test-diff-dwarf/test6-v1.o \ +data/test-diff-dwarf/test6-report.txt \ +data/test-diff-dwarf/test7-v0.cc \ +data/test-diff-dwarf/test7-v0.o \ +data/test-diff-dwarf/test7-v1.cc \ +data/test-diff-dwarf/test7-v1.o \ +data/test-diff-dwarf/test7-report.txt \ \ data/test-read-dwarf/test0 \ data/test-read-dwarf/test0.abi \ @@ -184,7 +199,27 @@ data/test-diff-filter/test7-v0.cc \ data/test-diff-filter/test7-v1.cc \ data/test-diff-filter/test7-v0.o \ data/test-diff-filter/test7-v1.o \ -data/test-diff-filter/test7-report.txt +data/test-diff-filter/test7-report.txt \ +data/test-diff-filter/test8-v0.cc \ +data/test-diff-filter/test8-v1.cc \ +data/test-diff-filter/test8-v0.o \ +data/test-diff-filter/test8-v1.o \ +data/test-diff-filter/test8-report.txt \ +data/test-diff-filter/test9-v0.cc \ +data/test-diff-filter/test9-v1.cc \ +data/test-diff-filter/test9-v0.o \ +data/test-diff-filter/test9-v1.o \ +data/test-diff-filter/test9-report.txt \ +data/test-diff-filter/test10-v0.cc \ +data/test-diff-filter/test10-v1.cc \ +data/test-diff-filter/test10-v0.o \ +data/test-diff-filter/test10-v1.o \ +data/test-diff-filter/test10-report.txt \ +data/test-diff-filter/test11-v0.cc \ +data/test-diff-filter/test11-v1.cc \ +data/test-diff-filter/test11-v0.o \ +data/test-diff-filter/test11-v1.o \ +data/test-diff-filter/test11-report.txt clean-local: clean-local-check .PHONY: clean-local-check diff --git a/tests/data/test-diff-dwarf/test7-report.txt b/tests/data/test-diff-dwarf/test7-report.txt new file mode 100644 index 00000000..7cc2dfd6 --- /dev/null +++ b/tests/data/test-diff-dwarf/test7-report.txt @@ -0,0 +1,15 @@ +Functions changes summary: 0 Removed, 1 Changed, 0 Added function +Variables changes summary: 0 Removed, 0 Changed, 1 Added variable + +1 function with some indirect sub-type change: + + [C]'function void foo(const S&)' has some indirect sub-type changes: + parameter 0 of type 'const S&' has sub-type changes: + in unqualified underlying type 'S&': + in referenced type 'struct S': + 1 data member insertion: + 'static char S::m0' + +1 Added variable: + 'static char S::m0 + diff --git a/tests/data/test-diff-dwarf/test7-v0.cc b/tests/data/test-diff-dwarf/test7-v0.cc new file mode 100644 index 00000000..ee328955 --- /dev/null +++ b/tests/data/test-diff-dwarf/test7-v0.cc @@ -0,0 +1,10 @@ +struct S +{ + static int m1; +}; + +int S::m1; + +void +foo(S&) +{} diff --git a/tests/data/test-diff-dwarf/test7-v0.o b/tests/data/test-diff-dwarf/test7-v0.o new file mode 100644 index 0000000000000000000000000000000000000000..610726bab444293066c0f2e72c65970153242566 GIT binary patch literal 2896 zcmbtW&2Jl35TCajCpOzyPF&PR;jl$5G%CA})2K;5(watT5>ZuELN686TH9-TOLmRy zZ5u$S2mw+#02N3G!J$%BssBgss7G#`xWf&J1I+Bcv0t9I;?R-azM0>AzIh+^{f(NObumM9L??_{Z13ESmMa~I~YhT~va7cDankaNYQxl|h^{T($p0!Wz z_$_K@&x<-|VjKuby$vEZa^8D&1b_S6aQ+?V!>L;>upo z@ESqK3-*u=5uj=Ym6jKK3G1|icH3#)^ZM-rh1PGL#=YFB?n3?Mwd(FtSls~FTwgzD zpTt@h{`~I-No6H9wGn{BFJ7_d=hFe0iG35OhS6gRg|ENnSr``kg$6cH}?0 zGO6QL>90?^|C?w){eF?ZZm-K#^riedasKZ$g>FkXOpi$}&*kf3ONSY0$M=wKC(#-X zJtpD5(+BB(It{+ zlJ(ljye1QMrNb;@(>V0}w5M75pUV4l4D~AM`Bk0DlidXT^{#t#&*-UN_S23E+A$bg*9q>~zmq6xIa<7C32F_89RMp+lH1plDG ztkR$1`>p=`kA6!>zppX_ubljtClyyfxZGNTv4)fw|5D1YYWTL4@efi$w7=?Z@i}3f z>t2xdB=gxL=(>VaJrAY)uADiJ6yZG$=lFF0iMalsQxU$FGsU4^GjUJIKF1)=CCTe~ OD=)xpiBk{MKKuv&vcJ{< literal 0 HcmV?d00001 diff --git a/tests/data/test-diff-dwarf/test7-v1.cc b/tests/data/test-diff-dwarf/test7-v1.cc new file mode 100644 index 00000000..01b97da6 --- /dev/null +++ b/tests/data/test-diff-dwarf/test7-v1.cc @@ -0,0 +1,12 @@ +struct S +{ + static char m0; + static int m1; +}; + +char S::m0; +int S::m1; + +void +foo(S&) +{} diff --git a/tests/data/test-diff-dwarf/test7-v1.o b/tests/data/test-diff-dwarf/test7-v1.o new file mode 100644 index 0000000000000000000000000000000000000000..71d8bff919f5602be7ac1a5e7da595d3088e4796 GIT binary patch literal 3064 zcmbtW&2QX96n|rHl1<#KHdzpf!ofv+Gz#{vL)3(}X}3fnsi;bosFzA8^6q+f4e>7W zx+Q=R6{?WJ0f7Vp1UF8ckPrt>2&otT3wq%X;D&?*yl2mIW+$#V@FaVF^LwB3#$)^a z?dvZaLI8_^%WyJd7T_221UFOIgc?-g*6#7|yT|YS`Pu`3ACWJmx^fyK!zpq4X6%Cy z;yNnKr~$&vkO!i)PsSxNNy9{GA{-Ro78zl0!q23=xLA^8VydKtjVNyQ~TYf9-`QahL2nh;2s(1XvPodKZyIrUA zmLGR9$_uztd)_|m+_+_Lt*qE zK@f*+oceLQzj?HA-Z{T!JH4@GwEKPxu(P#w!9Irxmj5$4z+>6kLA$O8gd%Nt}&+MoDm#fJ+Skw>27p8wZEJ+X-5C zdI#a4J49WI{Z=au?vAPb*dO$QahJnz5U>lT0JlAiq5z+IcQ8x>7Z>V`62JY13>5Sa zy0ISxROJ7cB@982OnTasa7~HzCr>}qXVH%Q^Ajfh=r|XN?*AMbQNJJMpYDYcNcZ

7f2yC}g?jy+f|y9b&oWVyCW`3!4^UT>|5urx`$YMt@zV3Zi5$h` zIuWMww@gIe6jeAskME+g$o~iVvZD`yD(uJOeN-}5?S9K&mMVMN_ABYHn?IDq#<+XF zex^S|P}IMN1^vU1P42JuRX;lvdqI-l(nJw`tu)tbC-Zx9qwYzEdE{pC()W+{v?xD+ zvQ|*9ik@H9shI3a@W($Y$Ji{~F{-0zCBzq2h-^{k$zFdOW|__GZ-UFnM>Bo0^JxxD zkeiq@88FjMY9vlgpdCIfCY(7%(q7Cd>*BuRze~#V%6L4B{Jhe){JpOJCKUY+oP5&L z8n`p$&zKZkA@TG~+$Iu*&OHh9{5(FM(K*lGY5ccJh1R3)Ce=^EJlDUR(P#w z;i;bQ<=of!n{v*dQ;sibh$LX1^M0 literal 0 HcmV?d00001 diff --git a/tests/test-diff-dwarf.cc b/tests/test-diff-dwarf.cc index 8c41d307..51dc3120 100644 --- a/tests/test-diff-dwarf.cc +++ b/tests/test-diff-dwarf.cc @@ -104,6 +104,12 @@ InOutSpec in_out_specs[] = "data/test-diff-dwarf/test6-report.txt", "output/test-diff-dwarf/test6-report.txt" }, + { + "data/test-diff-dwarf/test7-v0.o", + "data/test-diff-dwarf/test7-v1.o", + "data/test-diff-dwarf/test7-report.txt", + "output/test-diff-dwarf/test6-report.txt" + }, // This should be the last entry {NULL, NULL, NULL, NULL} };