public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Eliminate some duplicate types in XML
@ 2021-06-11 17:04 Giuliano Procida
  2021-06-11 17:04 ` [PATCH 1/2] XML writer: don't emit already emitted types Giuliano Procida
  2021-06-11 17:04 ` [PATCH 2/2] XML writer: emit enclosing types of scoped declarations Giuliano Procida
  0 siblings, 2 replies; 3+ messages in thread
From: Giuliano Procida @ 2021-06-11 17:04 UTC (permalink / raw)
  To: libabigail; +Cc: dodji, kernel-team, gprocida, maennich

Hi.

There were more changes in this series and they had a greater effect,
until the commit 1cfbff1b3037d1049bdff7e86de27c3a86af23b3 "rhbz1951526
- SELF CHECK FAILED for 'gimp-2.10'" landed.

See https://sourceware.org/pipermail/libabigail/2021q2/003404.html for
the original series.

The first change is very simple and still eliminates some duplicates
from ABI XML.

The second change appears to do nothing with regard to the current
test suite but eliminated one source of duplicate types through a
certain code path.

Giuliano.

Giuliano Procida (2):
  XML writer: don't emit already emitted types
  XML writer: emit enclosing types of scoped declarations

 src/abg-writer.cc                             | 37 +++------
 .../data/test-annotate/test14-pr18893.so.abi  |  2 -
 .../data/test-annotate/test15-pr18892.so.abi  |  8 --
 ...19-pr19023-libtcmalloc_and_profiler.so.abi |  4 -
 .../data/test-annotate/test21-pr19092.so.abi  | 79 -------------------
 .../test-read-dwarf/test14-pr18893.so.abi     |  1 -
 .../test-read-dwarf/test15-pr18892.so.abi     |  4 -
 .../test-read-dwarf/test16-pr18904.so.abi     |  2 -
 ...19-pr19023-libtcmalloc_and_profiler.so.abi |  2 -
 .../test-read-dwarf/test21-pr19092.so.abi     | 59 --------------
 .../test22-pr19097-libstdc++.so.6.0.17.so.abi |  1 -
 .../test9-pr18818-clang.so.abi                | 18 -----
 12 files changed, 13 insertions(+), 204 deletions(-)

-- 
2.32.0.272.g935e593368-goog


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] XML writer: don't emit already emitted types
  2021-06-11 17:04 [PATCH 0/2] Eliminate some duplicate types in XML Giuliano Procida
@ 2021-06-11 17:04 ` Giuliano Procida
  2021-06-11 17:04 ` [PATCH 2/2] XML writer: emit enclosing types of scoped declarations Giuliano Procida
  1 sibling, 0 replies; 3+ messages in thread
From: Giuliano Procida @ 2021-06-11 17:04 UTC (permalink / raw)
  To: libabigail; +Cc: dodji, kernel-team, gprocida, maennich

The XML writer sometimes emits type definitions entirely duplicated.
This happens if for some reason a type is emitted early but is later
emitted as one of the canonical types associated with a translation
unit.

Bug 26591 - detect pathologically redundant types in abixml

	* src/abg-writer.cc:
	(writer_context::write_canonical_types_of_scope): Do not emit
	already emitted types.
	* tests/data/test-annotate/test14-pr18893.so.abi: Refresh.
	* tests/data/test-annotate/test15-pr18892.so.abi: Refresh.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Refresh.
	* tests/data/test-annotate/test21-pr19092.so.abi: Refresh.
	* tests/data/test-read-dwarf/test14-pr18893.so.abi: Refresh.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Refresh.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Refresh.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Refresh.
	* tests/data/test-read-dwarf/test21-pr19092.so.abi: Refresh.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Refresh.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Refresh.

Signed-off-by: Giuliano Procida <gprocida@google.com>
---
 src/abg-writer.cc                             |  2 +-
 .../data/test-annotate/test14-pr18893.so.abi  |  2 -
 .../data/test-annotate/test15-pr18892.so.abi  |  8 --
 ...19-pr19023-libtcmalloc_and_profiler.so.abi |  4 -
 .../data/test-annotate/test21-pr19092.so.abi  | 79 -------------------
 .../test-read-dwarf/test14-pr18893.so.abi     |  1 -
 .../test-read-dwarf/test15-pr18892.so.abi     |  4 -
 .../test-read-dwarf/test16-pr18904.so.abi     |  2 -
 ...19-pr19023-libtcmalloc_and_profiler.so.abi |  2 -
 .../test-read-dwarf/test21-pr19092.so.abi     | 59 --------------
 .../test22-pr19097-libstdc++.so.6.0.17.so.abi |  1 -
 .../test9-pr18818-clang.so.abi                | 18 -----
 12 files changed, 1 insertion(+), 181 deletions(-)

diff --git a/src/abg-writer.cc b/src/abg-writer.cc
index 03959bdc..8aa95948 100644
--- a/src/abg-writer.cc
+++ b/src/abg-writer.cc
@@ -2211,7 +2211,7 @@ write_canonical_types_of_scope(const scope_decl	&scope,
     {
       if (is_member_type)
 	write_member_type(*i, ctxt, indent);
-      else
+      else if (!ctxt.type_is_emitted(*i))
 	write_type(*i, ctxt, indent);
     }
 
diff --git a/tests/data/test-annotate/test14-pr18893.so.abi b/tests/data/test-annotate/test14-pr18893.so.abi
index 19be6587..fa106219 100644
--- a/tests/data/test-annotate/test14-pr18893.so.abi
+++ b/tests/data/test-annotate/test14-pr18893.so.abi
@@ -6327,8 +6327,6 @@
     </array-type-def>
     <!-- unnamed&#45;enum&#45;underlying&#45;type&#45;32 -->
     <type-decl name='unnamed-enum-underlying-type-32' is-anonymous='yes' size-in-bits='32' alignment-in-bits='32' id='type-id-12'/>
-    <!-- unsigned long int -->
-    <type-decl name='unsigned long int' size-in-bits='64' id='type-id-3'/>
     <!-- unsigned long int[16] -->
     <array-type-def dimensions='1' type-id='type-id-3' size-in-bits='1024' id='type-id-388'>
       <!-- <anonymous range>[16] -->
diff --git a/tests/data/test-annotate/test15-pr18892.so.abi b/tests/data/test-annotate/test15-pr18892.so.abi
index e64f0ff7..a4c34ee5 100644
--- a/tests/data/test-annotate/test15-pr18892.so.abi
+++ b/tests/data/test-annotate/test15-pr18892.so.abi
@@ -7067,8 +7067,6 @@
     <typedef-decl name='uintptr_t' type-id='type-id-117' filepath='/usr/include/stdint.h' line='123' column='1' id='type-id-23'/>
     <!-- __sanitizer::LibbacktraceSymbolizer* const -->
     <qualified-type-def type-id='type-id-308' const='yes' id='type-id-309'/>
-    <!-- backtrace_state* -->
-    <pointer-type-def type-id='type-id-10' size-in-bits='64' id='type-id-22'/>
     <!-- int (void*, typedef uintptr_t, const char*, int, const char*)* -->
     <pointer-type-def type-id='type-id-30' size-in-bits='64' id='type-id-306'/>
     <!-- void (const char*, typedef size_t, void*)* -->
@@ -7439,8 +7437,6 @@
     <type-decl name='unnamed-enum-underlying-type-32' is-anonymous='yes' size-in-bits='32' alignment-in-bits='32' id='type-id-54'/>
     <!-- unsigned int -->
     <type-decl name='unsigned int' size-in-bits='32' id='type-id-147'/>
-    <!-- unsigned long int -->
-    <type-decl name='unsigned long int' size-in-bits='64' id='type-id-117'/>
     <!-- void -->
     <type-decl name='void' id='type-id-25'/>
     <!-- __tsan::SyncClock* -->
@@ -9213,8 +9209,6 @@
     <pointer-type-def type-id='type-id-1187' size-in-bits='64' id='type-id-808'/>
     <!-- int (void*, void ()*)* -->
     <pointer-type-def type-id='type-id-1188' size-in-bits='64' id='type-id-846'/>
-    <!-- int (void*, void*)* -->
-    <pointer-type-def type-id='type-id-29' size-in-bits='64' id='type-id-13'/>
     <!-- int (void*, void**)* -->
     <pointer-type-def type-id='type-id-1189' size-in-bits='64' id='type-id-817'/>
     <!-- int (void*, void**, SIZE_T*)* -->
@@ -23305,8 +23299,6 @@
     </function-type>
   </abi-instr>
   <abi-instr address-size='64' path='../../.././libsanitizer/tsan/tsan_interface.cc' comp-dir-path='/tmp/legendre/spack-stage/spack-stage-ImG4Cf/gcc-4.9.2/x86_64-unknown-linux-gnu/libsanitizer/tsan' language='LANG_C_plus_plus'>
-    <!-- unsigned short int -->
-    <type-decl name='unsigned short int' size-in-bits='16' id='type-id-195'/>
     <!-- typedef __sanitizer::u16 uu16 -->
     <typedef-decl name='uu16' type-id='type-id-1271' filepath='../../.././libsanitizer/sanitizer_common/sanitizer_internal_defs.h' line='171' column='1' id='type-id-1274'/>
     <!-- typedef __sanitizer::u32 uu32 -->
diff --git a/tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi b/tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi
index 131b8078..a494418e 100644
--- a/tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi
+++ b/tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi
@@ -15691,15 +15691,11 @@
     </array-type-def>
     <!-- unsigned int -->
     <type-decl name='unsigned int' size-in-bits='32' id='type-id-1310'/>
-    <!-- unsigned long int -->
-    <type-decl name='unsigned long int' size-in-bits='64' id='type-id-5'/>
     <!-- unsigned long int[65536] -->
     <array-type-def dimensions='1' type-id='type-id-5' size-in-bits='4194304' id='type-id-1502'>
       <!-- <anonymous range>[65536] -->
       <subrange length='65536' type-id='type-id-5' id='type-id-1503'/>
     </array-type-def>
-    <!-- unsigned short int -->
-    <type-decl name='unsigned short int' size-in-bits='16' id='type-id-22'/>
     <!-- variadic parameter type -->
     <type-decl name='variadic parameter type' id='type-id-1504'/>
     <!-- void -->
diff --git a/tests/data/test-annotate/test21-pr19092.so.abi b/tests/data/test-annotate/test21-pr19092.so.abi
index c742d7e4..6f769379 100644
--- a/tests/data/test-annotate/test21-pr19092.so.abi
+++ b/tests/data/test-annotate/test21-pr19092.so.abi
@@ -10448,85 +10448,6 @@
         <var-decl name='system_microseconds' type-id='type-id-28' visibility='default' filepath='../.././libiberty/../include/libiberty.h' line='564' column='1'/>
       </data-member>
     </class-decl>
-    <!-- struct pex_obj -->
-    <class-decl name='pex_obj' size-in-bits='1152' is-struct='yes' visibility='default' filepath='../.././libiberty/pex-common.h' line='54' column='1' id='type-id-130'>
-      <data-member access='public' layout-offset-in-bits='0'>
-        <!-- int pex_obj::flags -->
-        <var-decl name='flags' type-id='type-id-18' visibility='default' filepath='../.././libiberty/pex-common.h' line='57' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='64'>
-        <!-- const char* pex_obj::pname -->
-        <var-decl name='pname' type-id='type-id-15' visibility='default' filepath='../.././libiberty/pex-common.h' line='59' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='128'>
-        <!-- const char* pex_obj::tempbase -->
-        <var-decl name='tempbase' type-id='type-id-15' visibility='default' filepath='../.././libiberty/pex-common.h' line='61' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='192'>
-        <!-- int pex_obj::next_input -->
-        <var-decl name='next_input' type-id='type-id-18' visibility='default' filepath='../.././libiberty/pex-common.h' line='63' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='256'>
-        <!-- char* pex_obj::next_input_name -->
-        <var-decl name='next_input_name' type-id='type-id-33' visibility='default' filepath='../.././libiberty/pex-common.h' line='65' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='320'>
-        <!-- int pex_obj::next_input_name_allocated -->
-        <var-decl name='next_input_name_allocated' type-id='type-id-18' visibility='default' filepath='../.././libiberty/pex-common.h' line='67' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='352'>
-        <!-- int pex_obj::stderr_pipe -->
-        <var-decl name='stderr_pipe' type-id='type-id-18' visibility='default' filepath='../.././libiberty/pex-common.h' line='69' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='384'>
-        <!-- int pex_obj::count -->
-        <var-decl name='count' type-id='type-id-18' visibility='default' filepath='../.././libiberty/pex-common.h' line='71' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='448'>
-        <!-- pid_t* pex_obj::children -->
-        <var-decl name='children' type-id='type-id-145' visibility='default' filepath='../.././libiberty/pex-common.h' line='73' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='512'>
-        <!-- int* pex_obj::status -->
-        <var-decl name='status' type-id='type-id-58' visibility='default' filepath='../.././libiberty/pex-common.h' line='75' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='576'>
-        <!-- pex_time* pex_obj::time -->
-        <var-decl name='time' type-id='type-id-146' visibility='default' filepath='../.././libiberty/pex-common.h' line='77' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='640'>
-        <!-- int pex_obj::number_waited -->
-        <var-decl name='number_waited' type-id='type-id-18' visibility='default' filepath='../.././libiberty/pex-common.h' line='79' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='704'>
-        <!-- FILE* pex_obj::input_file -->
-        <var-decl name='input_file' type-id='type-id-75' visibility='default' filepath='../.././libiberty/pex-common.h' line='81' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='768'>
-        <!-- FILE* pex_obj::read_output -->
-        <var-decl name='read_output' type-id='type-id-75' visibility='default' filepath='../.././libiberty/pex-common.h' line='83' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='832'>
-        <!-- FILE* pex_obj::read_err -->
-        <var-decl name='read_err' type-id='type-id-75' visibility='default' filepath='../.././libiberty/pex-common.h' line='85' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='896'>
-        <!-- int pex_obj::remove_count -->
-        <var-decl name='remove_count' type-id='type-id-18' visibility='default' filepath='../.././libiberty/pex-common.h' line='87' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='960'>
-        <!-- char** pex_obj::remove -->
-        <var-decl name='remove' type-id='type-id-123' visibility='default' filepath='../.././libiberty/pex-common.h' line='90' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='1024'>
-        <!-- const pex_funcs* pex_obj::funcs -->
-        <var-decl name='funcs' type-id='type-id-147' visibility='default' filepath='../.././libiberty/pex-common.h' line='92' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='1088'>
-        <!-- void* pex_obj::sysdep -->
-        <var-decl name='sysdep' type-id='type-id-14' visibility='default' filepath='../.././libiberty/pex-common.h' line='94' column='1'/>
-      </data-member>
-    </class-decl>
     <!-- struct pex_funcs -->
     <class-decl name='pex_funcs' size-in-bits='576' is-struct='yes' visibility='default' filepath='../.././libiberty/pex-common.h' line='99' column='1' id='type-id-479'>
       <data-member access='public' layout-offset-in-bits='0'>
diff --git a/tests/data/test-read-dwarf/test14-pr18893.so.abi b/tests/data/test-read-dwarf/test14-pr18893.so.abi
index cbfc0e19..03ef4898 100644
--- a/tests/data/test-read-dwarf/test14-pr18893.so.abi
+++ b/tests/data/test-read-dwarf/test14-pr18893.so.abi
@@ -4182,7 +4182,6 @@
       <subrange length='8' type-id='type-id-3' id='type-id-387'/>
     </array-type-def>
     <type-decl name='unnamed-enum-underlying-type-32' is-anonymous='yes' size-in-bits='32' alignment-in-bits='32' id='type-id-12'/>
-    <type-decl name='unsigned long int' size-in-bits='64' id='type-id-3'/>
     <array-type-def dimensions='1' type-id='type-id-3' size-in-bits='1024' id='type-id-388'>
       <subrange length='16' type-id='type-id-3' id='type-id-389'/>
     </array-type-def>
diff --git a/tests/data/test-read-dwarf/test15-pr18892.so.abi b/tests/data/test-read-dwarf/test15-pr18892.so.abi
index 358000f0..6edc2e0e 100644
--- a/tests/data/test-read-dwarf/test15-pr18892.so.abi
+++ b/tests/data/test-read-dwarf/test15-pr18892.so.abi
@@ -3938,7 +3938,6 @@
     <typedef-decl name='backtrace_syminfo_callback' type-id='type-id-307' filepath='../../.././libsanitizer/../libbacktrace/backtrace.h' line='175' column='1' id='type-id-28'/>
     <typedef-decl name='uintptr_t' type-id='type-id-117' filepath='/usr/include/stdint.h' line='123' column='1' id='type-id-23'/>
     <qualified-type-def type-id='type-id-308' const='yes' id='type-id-309'/>
-    <pointer-type-def type-id='type-id-10' size-in-bits='64' id='type-id-22'/>
     <pointer-type-def type-id='type-id-30' size-in-bits='64' id='type-id-306'/>
     <pointer-type-def type-id='type-id-83' size-in-bits='64' id='type-id-304'/>
     <pointer-type-def type-id='type-id-31' size-in-bits='64' id='type-id-305'/>
@@ -4173,7 +4172,6 @@
     <type-decl name='sizetype' size-in-bits='64' id='type-id-44'/>
     <type-decl name='unnamed-enum-underlying-type-32' is-anonymous='yes' size-in-bits='32' alignment-in-bits='32' id='type-id-54'/>
     <type-decl name='unsigned int' size-in-bits='32' id='type-id-147'/>
-    <type-decl name='unsigned long int' size-in-bits='64' id='type-id-117'/>
     <type-decl name='void' id='type-id-25'/>
     <pointer-type-def type-id='type-id-340' size-in-bits='64' id='type-id-341'/>
     <pointer-type-def type-id='type-id-342' size-in-bits='64' id='type-id-343'/>
@@ -5177,7 +5175,6 @@
     <pointer-type-def type-id='type-id-1186' size-in-bits='64' id='type-id-941'/>
     <pointer-type-def type-id='type-id-1187' size-in-bits='64' id='type-id-808'/>
     <pointer-type-def type-id='type-id-1188' size-in-bits='64' id='type-id-846'/>
-    <pointer-type-def type-id='type-id-29' size-in-bits='64' id='type-id-13'/>
     <pointer-type-def type-id='type-id-1189' size-in-bits='64' id='type-id-817'/>
     <pointer-type-def type-id='type-id-1190' size-in-bits='64' id='type-id-674'/>
     <pointer-type-def type-id='type-id-1191' size-in-bits='64' id='type-id-787'/>
@@ -12961,7 +12958,6 @@
     </function-type>
   </abi-instr>
   <abi-instr address-size='64' path='../../.././libsanitizer/tsan/tsan_interface.cc' comp-dir-path='/tmp/legendre/spack-stage/spack-stage-ImG4Cf/gcc-4.9.2/x86_64-unknown-linux-gnu/libsanitizer/tsan' language='LANG_C_plus_plus'>
-    <type-decl name='unsigned short int' size-in-bits='16' id='type-id-195'/>
     <typedef-decl name='uu16' type-id='type-id-1271' filepath='../../.././libsanitizer/sanitizer_common/sanitizer_internal_defs.h' line='171' column='1' id='type-id-1274'/>
     <typedef-decl name='uu32' type-id='type-id-204' filepath='../../.././libsanitizer/sanitizer_common/sanitizer_internal_defs.h' line='172' column='1' id='type-id-1275'/>
     <typedef-decl name='uu64' type-id='type-id-131' filepath='../../.././libsanitizer/sanitizer_common/sanitizer_internal_defs.h' line='173' column='1' id='type-id-1276'/>
diff --git a/tests/data/test-read-dwarf/test16-pr18904.so.abi b/tests/data/test-read-dwarf/test16-pr18904.so.abi
index 8ee54646..efca4645 100644
--- a/tests/data/test-read-dwarf/test16-pr18904.so.abi
+++ b/tests/data/test-read-dwarf/test16-pr18904.so.abi
@@ -11234,7 +11234,6 @@
     <type-decl name='char' size-in-bits='8' id='type-id-166'/>
     <type-decl name='long int' size-in-bits='64' id='type-id-222'/>
     <type-decl name='long long int' size-in-bits='64' id='type-id-212'/>
-    <type-decl name='unsigned long int' size-in-bits='64' id='type-id-6'/>
     <type-decl name='void' id='type-id-154'/>
     <class-decl name='Marshaller' size-in-bits='256' visibility='default' filepath='../../../gcc/liboffloadmic/runtime/offload_common.h' line='388' column='1' id='type-id-285'>
       <data-member access='private' layout-offset-in-bits='0'>
@@ -18092,7 +18091,6 @@
     <type-decl name='long long unsigned int' size-in-bits='64' id='type-id-3500'/>
     <type-decl name='signed char' size-in-bits='8' id='type-id-52'/>
     <type-decl name='unnamed-enum-underlying-type-32' is-anonymous='yes' size-in-bits='32' alignment-in-bits='32' id='type-id-29'/>
-    <type-decl name='unsigned short int' size-in-bits='16' id='type-id-57'/>
     <type-decl name='variadic parameter type' id='type-id-3501'/>
     <type-decl name='wchar_t' size-in-bits='32' id='type-id-9'/>
     <typedef-decl name='wint_t' type-id='type-id-2' filepath='/export/users/iverbin/gcc_build_host/gcc/include/stddef.h' line='357' column='1' id='type-id-3502'/>
diff --git a/tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi b/tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi
index 38fd82e3..781d63e8 100644
--- a/tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi
+++ b/tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi
@@ -9542,11 +9542,9 @@
       <subrange length='2169' type-id='type-id-5' id='type-id-1501'/>
     </array-type-def>
     <type-decl name='unsigned int' size-in-bits='32' id='type-id-1310'/>
-    <type-decl name='unsigned long int' size-in-bits='64' id='type-id-5'/>
     <array-type-def dimensions='1' type-id='type-id-5' size-in-bits='4194304' id='type-id-1502'>
       <subrange length='65536' type-id='type-id-5' id='type-id-1503'/>
     </array-type-def>
-    <type-decl name='unsigned short int' size-in-bits='16' id='type-id-22'/>
     <type-decl name='variadic parameter type' id='type-id-1504'/>
     <type-decl name='void' id='type-id-60'/>
     <array-type-def dimensions='1' type-id='type-id-58' size-in-bits='1984' id='type-id-1505'>
diff --git a/tests/data/test-read-dwarf/test21-pr19092.so.abi b/tests/data/test-read-dwarf/test21-pr19092.so.abi
index b4a20a04..77245cd0 100644
--- a/tests/data/test-read-dwarf/test21-pr19092.so.abi
+++ b/tests/data/test-read-dwarf/test21-pr19092.so.abi
@@ -6744,65 +6744,6 @@
         <var-decl name='system_microseconds' type-id='type-id-28' visibility='default' filepath='../.././libiberty/../include/libiberty.h' line='564' column='1'/>
       </data-member>
     </class-decl>
-    <class-decl name='pex_obj' size-in-bits='1152' is-struct='yes' visibility='default' filepath='../.././libiberty/pex-common.h' line='54' column='1' id='type-id-130'>
-      <data-member access='public' layout-offset-in-bits='0'>
-        <var-decl name='flags' type-id='type-id-18' visibility='default' filepath='../.././libiberty/pex-common.h' line='57' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='64'>
-        <var-decl name='pname' type-id='type-id-15' visibility='default' filepath='../.././libiberty/pex-common.h' line='59' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='128'>
-        <var-decl name='tempbase' type-id='type-id-15' visibility='default' filepath='../.././libiberty/pex-common.h' line='61' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='192'>
-        <var-decl name='next_input' type-id='type-id-18' visibility='default' filepath='../.././libiberty/pex-common.h' line='63' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='256'>
-        <var-decl name='next_input_name' type-id='type-id-33' visibility='default' filepath='../.././libiberty/pex-common.h' line='65' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='320'>
-        <var-decl name='next_input_name_allocated' type-id='type-id-18' visibility='default' filepath='../.././libiberty/pex-common.h' line='67' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='352'>
-        <var-decl name='stderr_pipe' type-id='type-id-18' visibility='default' filepath='../.././libiberty/pex-common.h' line='69' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='384'>
-        <var-decl name='count' type-id='type-id-18' visibility='default' filepath='../.././libiberty/pex-common.h' line='71' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='448'>
-        <var-decl name='children' type-id='type-id-145' visibility='default' filepath='../.././libiberty/pex-common.h' line='73' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='512'>
-        <var-decl name='status' type-id='type-id-58' visibility='default' filepath='../.././libiberty/pex-common.h' line='75' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='576'>
-        <var-decl name='time' type-id='type-id-146' visibility='default' filepath='../.././libiberty/pex-common.h' line='77' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='640'>
-        <var-decl name='number_waited' type-id='type-id-18' visibility='default' filepath='../.././libiberty/pex-common.h' line='79' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='704'>
-        <var-decl name='input_file' type-id='type-id-75' visibility='default' filepath='../.././libiberty/pex-common.h' line='81' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='768'>
-        <var-decl name='read_output' type-id='type-id-75' visibility='default' filepath='../.././libiberty/pex-common.h' line='83' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='832'>
-        <var-decl name='read_err' type-id='type-id-75' visibility='default' filepath='../.././libiberty/pex-common.h' line='85' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='896'>
-        <var-decl name='remove_count' type-id='type-id-18' visibility='default' filepath='../.././libiberty/pex-common.h' line='87' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='960'>
-        <var-decl name='remove' type-id='type-id-123' visibility='default' filepath='../.././libiberty/pex-common.h' line='90' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='1024'>
-        <var-decl name='funcs' type-id='type-id-147' visibility='default' filepath='../.././libiberty/pex-common.h' line='92' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='1088'>
-        <var-decl name='sysdep' type-id='type-id-14' visibility='default' filepath='../.././libiberty/pex-common.h' line='94' column='1'/>
-      </data-member>
-    </class-decl>
     <class-decl name='pex_funcs' size-in-bits='576' is-struct='yes' visibility='default' filepath='../.././libiberty/pex-common.h' line='99' column='1' id='type-id-479'>
       <data-member access='public' layout-offset-in-bits='0'>
         <var-decl name='open_read' type-id='type-id-480' visibility='default' filepath='../.././libiberty/pex-common.h' line='103' column='1'/>
diff --git a/tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi b/tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi
index 1739af09..31342d1c 100644
--- a/tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi
+++ b/tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi
@@ -8244,7 +8244,6 @@
     <type-decl name='sizetype' size-in-bits='64' id='type-id-178'/>
     <type-decl name='unnamed-enum-underlying-type-32' is-anonymous='yes' size-in-bits='32' alignment-in-bits='32' id='type-id-37'/>
     <type-decl name='unsigned int' size-in-bits='32' id='type-id-39'/>
-    <type-decl name='unsigned long int' size-in-bits='64' id='type-id-45'/>
     <array-type-def dimensions='1' type-id='type-id-45' size-in-bits='infinite' id='type-id-662'>
       <subrange length='infinite' id='type-id-663'/>
     </array-type-def>
diff --git a/tests/data/test-read-dwarf/test9-pr18818-clang.so.abi b/tests/data/test-read-dwarf/test9-pr18818-clang.so.abi
index 7db018e4..cc3f6554 100644
--- a/tests/data/test-read-dwarf/test9-pr18818-clang.so.abi
+++ b/tests/data/test-read-dwarf/test9-pr18818-clang.so.abi
@@ -4949,24 +4949,6 @@
     </namespace-decl>
   </abi-instr>
   <abi-instr address-size='64' path='src/third_party/boost-1.56.0/libs/filesystem/src/path_traits.cpp' comp-dir-path='/home/andrew/Documents/10gen/dev/src/mongodb' language='LANG_C_plus_plus'>
-    <class-decl name='__anonymous_struct__' size-in-bits='64' is-struct='yes' is-anonymous='yes' naming-typedef-id='type-id-119' visibility='default' filepath='/usr/include/wchar.h' line='82' column='1' id='type-id-27'>
-      <member-type access='public'>
-        <union-decl name='__anonymous_union__' size-in-bits='32' is-anonymous='yes' visibility='default' filepath='/usr/include/wchar.h' line='85' column='1' id='type-id-120'>
-          <data-member access='public'>
-            <var-decl name='__wch' type-id='type-id-7' visibility='default' filepath='/usr/include/wchar.h' line='88' column='1'/>
-          </data-member>
-          <data-member access='public'>
-            <var-decl name='__wchb' type-id='type-id-3' visibility='default' filepath='/usr/include/wchar.h' line='92' column='1'/>
-          </data-member>
-        </union-decl>
-      </member-type>
-      <data-member access='public' layout-offset-in-bits='0'>
-        <var-decl name='__count' type-id='type-id-11' visibility='default' filepath='/usr/include/wchar.h' line='84' column='1'/>
-      </data-member>
-      <data-member access='public' layout-offset-in-bits='32'>
-        <var-decl name='__value' type-id='type-id-120' visibility='default' filepath='/usr/include/wchar.h' line='93' column='1'/>
-      </data-member>
-    </class-decl>
     <reference-type-def kind='lvalue' type-id='type-id-452' size-in-bits='64' id='type-id-453'/>
     <pointer-type-def type-id='type-id-452' size-in-bits='64' id='type-id-454'/>
     <qualified-type-def type-id='type-id-452' const='yes' id='type-id-455'/>
-- 
2.32.0.272.g935e593368-goog


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] XML writer: emit enclosing types of scoped declarations
  2021-06-11 17:04 [PATCH 0/2] Eliminate some duplicate types in XML Giuliano Procida
  2021-06-11 17:04 ` [PATCH 1/2] XML writer: don't emit already emitted types Giuliano Procida
@ 2021-06-11 17:04 ` Giuliano Procida
  1 sibling, 0 replies; 3+ messages in thread
From: Giuliano Procida @ 2021-06-11 17:04 UTC (permalink / raw)
  To: libabigail; +Cc: dodji, kernel-team, gprocida, maennich

Bug 26591 - detect pathologically redundant types in abixml

One source of duplicated type ids in ABI XML was the writer emitting
scoped (nested) typed declarations before a later TU causes the
emission of the complete enclosing type declaration.

This no longer seems to occur within the current test suite. The code
paths responsible are still active though, but don't ever appear to be
asked to emit nested member types.

This commit was my fix for the issue. It causes the outermost
enclosing type declaration to be emitted immediately, rather than a
nested member type. This prevents the later duplicate emission of the
enclosing type and all its nested member types.

This commit still does simplify the code paths and avoids the
potential emission of partial types (which were sometimes accompanied
by incorrect member-type access attributes).

	* src/abg-writer.cc: (write_decl_in_scope): Emit the enclosing
	types of any nested type declaration.

Signed-off-by: Giuliano Procida <gprocida@google.com>
---
 src/abg-writer.cc | 35 ++++++++++++-----------------------
 1 file changed, 12 insertions(+), 23 deletions(-)

diff --git a/src/abg-writer.cc b/src/abg-writer.cc
index 8aa95948..cf2693bf 100644
--- a/src/abg-writer.cc
+++ b/src/abg-writer.cc
@@ -1941,6 +1941,8 @@ write_decl(const decl_base_sptr& decl, write_context& ctxt, unsigned indent)
 
 /// Emit a declaration, along with its scope.
 ///
+/// If the scope includes another type declaration, emit that instead.
+///
 /// This function is called at the end of emitting a translation unit,
 /// to emit type declarations that were referenced by types that were
 /// emitted in the TU already, but that were not emitted themselves.
@@ -1972,6 +1974,7 @@ write_decl_in_scope(const decl_base_sptr&	decl,
   stack<string> closing_tags;
   stack<unsigned> closing_indents;
   unsigned indent = initial_indent;
+  bool done = false;
   for (list<scope_decl*>::const_iterator i = scopes.begin();
        i != scopes.end();
        ++i)
@@ -1987,43 +1990,29 @@ write_decl_in_scope(const decl_base_sptr&	decl,
 	    << "'>\n";
 	  closing_tags.push("</namespace-decl>");
 	  closing_indents.push(indent);
+	  indent += c.get_xml_element_indent();
 	}
-      // ... or a class.
+      // ... or a class ...
       else if (class_decl* c = is_class_type(*i))
 	{
 	  class_decl_sptr class_type(c, noop_deleter());
-	  write_class_decl_opening_tag(class_type, "", ctxt, indent,
-				       /*prepare_to_handle_members=*/false);
-	  closing_tags.push("</class-decl>");
-	  closing_indents.push(indent);
-
-	  unsigned nb_ws = get_indent_to_level(ctxt, indent, 1);
-	  write_member_type_opening_tag(type, ctxt, nb_ws);
-	  indent = nb_ws;
-	  closing_tags.push("</member-type>");
-	  closing_indents.push(nb_ws);
+	  write_class_decl(class_type, ctxt, indent);
+	  done = true;
 	}
+      // ... or a union.
       else if (union_decl *u = is_union_type(*i))
 	{
 	  union_decl_sptr union_type(u, noop_deleter());
-	  write_union_decl_opening_tag(union_type, "", ctxt, indent,
-				       /*prepare_to_handle_members=*/false);
-	  closing_tags.push("</union-decl>");
-	  closing_indents.push(indent);
-
-	  unsigned nb_ws = get_indent_to_level(ctxt, indent, 1);
-	  write_member_type_opening_tag(type, ctxt, nb_ws);
-	  indent = nb_ws;
-	  closing_tags.push("</member-type>");
-	  closing_indents.push(nb_ws);
+	  write_union_decl(union_type, ctxt, indent);
+	  done = true;
 	}
       else
 	// We should never reach this point.
 	abort();
-      indent += c.get_xml_element_indent();
     }
 
-  write_decl(decl, ctxt, indent);
+  if (!done)
+    write_decl(decl, ctxt, indent);
 
   while (!closing_tags.empty())
     {
-- 
2.32.0.272.g935e593368-goog


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-11 17:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-11 17:04 [PATCH 0/2] Eliminate some duplicate types in XML Giuliano Procida
2021-06-11 17:04 ` [PATCH 1/2] XML writer: don't emit already emitted types Giuliano Procida
2021-06-11 17:04 ` [PATCH 2/2] XML writer: emit enclosing types of scoped declarations Giuliano Procida

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).