mirror of
git://sourceware.org/git/libabigail.git
synced 2025-01-18 23:30:45 +00:00
Bug 18894 - Fix representation of enumerators in abixml format
It turns out that using a size_t to serialize an enumerator is not enough to represent things like enum foo {value = -3}; We need to represent it using ssize_t. Also, the patch avoids early canonicalization (when reading DWARF) of types that refer to themselves. This was leading to type degradation (serializing the type from IR to abixml and de-serializing it back to IR leads to a different type). * include/abg-ir.h (enum_type_decl::enumerator::get_value()): Change the type of this from size_t to ssize_t. * src/abg-ir.cc (enum_type_decl::enumerator::get_value): Do the same on the definition side. (non_canonicalized_subtype_detector::visit_begin): If a type refers to itself, late canonicalize it to have a similar hashing result as what the abixml reader does. * src/abg-reader.cc (build_enum_type_decl): Use ssize_t to read the value of enumerators. * tests/data/test-read-dwarf/test13-pr18894.so.abi: New test input. * tests/data/Makefile.am: Add the new test inputs above to source distribution. * tests/test-read-dwarf.cc (in_out_specs): Add new test inputs. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Adjust. * tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise. * tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise. * tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
parent
425f8a4ec4
commit
5822798dd1
@ -26,6 +26,7 @@
|
||||
#define __ABG_IR_H__
|
||||
|
||||
#include <assert.h>
|
||||
#include <cstdlib>
|
||||
#include <tr1/unordered_map>
|
||||
#include "abg-fwd.h"
|
||||
#include "abg-hash.h"
|
||||
@ -1672,7 +1673,7 @@ public:
|
||||
void
|
||||
set_name(const string& n);
|
||||
|
||||
size_t
|
||||
ssize_t
|
||||
get_value() const;
|
||||
|
||||
void
|
||||
|
@ -7219,7 +7219,7 @@ enum_type_decl::enumerator::set_name(const string& n)
|
||||
///
|
||||
/// @return the value of the current instance of
|
||||
/// enum_type_decl::enumerator.
|
||||
size_t
|
||||
ssize_t
|
||||
enum_type_decl::enumerator::get_value() const
|
||||
{return priv_->value_;}
|
||||
|
||||
@ -11629,14 +11629,6 @@ public:
|
||||
{
|
||||
if (t != type_)
|
||||
{
|
||||
// If 'type_' references a type which is a combination of
|
||||
// pointer to, reference to, or typedef of himself, then do
|
||||
// not look in there for a sub-type which doesn't have a
|
||||
// canonical type.
|
||||
type_base* type = peel_typedef_pointer_or_reference_type(t);
|
||||
if (get_type_name(type, true) == get_type_name(type_, true))
|
||||
return true;
|
||||
|
||||
if (!t->get_canonical_type())
|
||||
// We are looking a sub-type of 'type_' which has no
|
||||
// canonical type. So tada! we found one! Get out right
|
||||
|
@ -2954,7 +2954,7 @@ build_enum_type_decl(read_context& ctxt,
|
||||
if (xmlStrEqual(n->name, BAD_CAST("enumerator")))
|
||||
{
|
||||
string name;
|
||||
size_t value = 0;
|
||||
ssize_t value = 0;
|
||||
|
||||
xml_char_sptr a = xml::build_sptr(xmlGetProp(n, BAD_CAST("name")));
|
||||
if (a)
|
||||
|
@ -273,6 +273,8 @@ test-read-dwarf/test11-pr18828.so \
|
||||
test-read-dwarf/test11-pr18828.so.abi \
|
||||
test-read-dwarf/test12-pr18844.so \
|
||||
test-read-dwarf/test12-pr18844.so.abi \
|
||||
test-read-dwarf/test13-pr18894.so \
|
||||
test-read-dwarf/test13-pr18894.so.abi \
|
||||
\
|
||||
test-diff-filter/test0-v0.cc \
|
||||
test-diff-filter/test0-v1.cc \
|
||||
|
@ -34462,13 +34462,13 @@
|
||||
</class-decl>
|
||||
<enum-decl name='float_denorm_style' id='type-id-618'>
|
||||
<underlying-type type-id='type-id-619'/>
|
||||
<enumerator name='denorm_indeterminate' value='18446744073709551615'/>
|
||||
<enumerator name='denorm_indeterminate' value='-1'/>
|
||||
<enumerator name='denorm_absent' value='0'/>
|
||||
<enumerator name='denorm_present' value='1'/>
|
||||
</enum-decl>
|
||||
<enum-decl name='float_round_style' id='type-id-620'>
|
||||
<underlying-type type-id='type-id-621'/>
|
||||
<enumerator name='round_indeterminate' value='18446744073709551615'/>
|
||||
<enumerator name='round_indeterminate' value='-1'/>
|
||||
<enumerator name='round_toward_zero' value='0'/>
|
||||
<enumerator name='round_to_nearest' value='1'/>
|
||||
<enumerator name='round_toward_infinity' value='2'/>
|
||||
|
@ -29354,7 +29354,7 @@
|
||||
</class-decl>
|
||||
<enum-decl name='BSONType' id='type-id-2236'>
|
||||
<underlying-type type-id='type-id-2336'/>
|
||||
<enumerator name='MinKey' value='18446744073709551615'/>
|
||||
<enumerator name='MinKey' value='-1'/>
|
||||
<enumerator name='EOO' value='0'/>
|
||||
<enumerator name='NumberDouble' value='1'/>
|
||||
<enumerator name='String' value='2'/>
|
||||
|
@ -27042,7 +27042,7 @@
|
||||
</class-decl>
|
||||
<enum-decl name='BSONType' id='type-id-2581'>
|
||||
<underlying-type type-id='type-id-2621'/>
|
||||
<enumerator name='MinKey' value='18446744073709551615'/>
|
||||
<enumerator name='MinKey' value='-1'/>
|
||||
<enumerator name='EOO' value='0'/>
|
||||
<enumerator name='NumberDouble' value='1'/>
|
||||
<enumerator name='String' value='2'/>
|
||||
@ -40472,7 +40472,7 @@
|
||||
</class-decl>
|
||||
<enum-decl name='BSONType' id='type-id-2581'>
|
||||
<underlying-type type-id='type-id-2621'/>
|
||||
<enumerator name='MinKey' value='18446744073709551615'/>
|
||||
<enumerator name='MinKey' value='-1'/>
|
||||
<enumerator name='EOO' value='0'/>
|
||||
<enumerator name='NumberDouble' value='1'/>
|
||||
<enumerator name='String' value='2'/>
|
||||
@ -53962,7 +53962,7 @@
|
||||
</class-decl>
|
||||
<enum-decl name='BSONType' id='type-id-2581'>
|
||||
<underlying-type type-id='type-id-2621'/>
|
||||
<enumerator name='MinKey' value='18446744073709551615'/>
|
||||
<enumerator name='MinKey' value='-1'/>
|
||||
<enumerator name='EOO' value='0'/>
|
||||
<enumerator name='NumberDouble' value='1'/>
|
||||
<enumerator name='String' value='2'/>
|
||||
|
BIN
tests/data/test-read-dwarf/test13-pr18894.so
Normal file
BIN
tests/data/test-read-dwarf/test13-pr18894.so
Normal file
Binary file not shown.
11388
tests/data/test-read-dwarf/test13-pr18894.so.abi
Normal file
11388
tests/data/test-read-dwarf/test13-pr18894.so.abi
Normal file
File diff suppressed because it is too large
Load Diff
@ -18472,13 +18472,13 @@
|
||||
</class-decl>
|
||||
<enum-decl name='float_denorm_style' id='type-id-498'>
|
||||
<underlying-type type-id='type-id-499'/>
|
||||
<enumerator name='denorm_indeterminate' value='18446744073709551615'/>
|
||||
<enumerator name='denorm_indeterminate' value='-1'/>
|
||||
<enumerator name='denorm_absent' value='0'/>
|
||||
<enumerator name='denorm_present' value='1'/>
|
||||
</enum-decl>
|
||||
<enum-decl name='float_round_style' id='type-id-500'>
|
||||
<underlying-type type-id='type-id-501'/>
|
||||
<enumerator name='round_indeterminate' value='18446744073709551615'/>
|
||||
<enumerator name='round_indeterminate' value='-1'/>
|
||||
<enumerator name='round_toward_zero' value='0'/>
|
||||
<enumerator name='round_to_nearest' value='1'/>
|
||||
<enumerator name='round_toward_infinity' value='2'/>
|
||||
@ -19920,41 +19920,41 @@
|
||||
<var-decl name='reg_save_area' type-id='type-id-35' visibility='default'/>
|
||||
</data-member>
|
||||
</class-decl>
|
||||
<typedef-decl name='__va_list_tag' type-id='type-id-73' id='type-id-509'/>
|
||||
<pointer-type-def type-id='type-id-509' size-in-bits='64' id='type-id-510'/>
|
||||
<typedef-decl name='__va_list_tag' type-id='type-id-73' id='type-id-74'/>
|
||||
<pointer-type-def type-id='type-id-74' size-in-bits='64' id='type-id-75'/>
|
||||
<function-decl name='vfwprintf' filepath='/usr/include/wchar.h' line='612' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
<parameter type-id='type-id-63'/>
|
||||
<parameter type-id='type-id-52'/>
|
||||
<parameter type-id='type-id-510'/>
|
||||
<parameter type-id='type-id-75'/>
|
||||
<return type-id='type-id-3'/>
|
||||
</function-decl>
|
||||
<function-decl name='vfwscanf' filepath='/usr/include/wchar.h' line='689' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
<parameter type-id='type-id-63'/>
|
||||
<parameter type-id='type-id-52'/>
|
||||
<parameter type-id='type-id-510'/>
|
||||
<parameter type-id='type-id-75'/>
|
||||
<return type-id='type-id-3'/>
|
||||
</function-decl>
|
||||
<function-decl name='vswprintf' filepath='/usr/include/wchar.h' line='625' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
<parameter type-id='type-id-44'/>
|
||||
<parameter type-id='type-id-37'/>
|
||||
<parameter type-id='type-id-52'/>
|
||||
<parameter type-id='type-id-510'/>
|
||||
<parameter type-id='type-id-75'/>
|
||||
<return type-id='type-id-3'/>
|
||||
</function-decl>
|
||||
<function-decl name='vswscanf' filepath='/usr/include/wchar.h' line='701' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
<parameter type-id='type-id-52'/>
|
||||
<parameter type-id='type-id-52'/>
|
||||
<parameter type-id='type-id-510'/>
|
||||
<parameter type-id='type-id-75'/>
|
||||
<return type-id='type-id-3'/>
|
||||
</function-decl>
|
||||
<function-decl name='vwprintf' filepath='/usr/include/wchar.h' line='620' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
<parameter type-id='type-id-52'/>
|
||||
<parameter type-id='type-id-510'/>
|
||||
<parameter type-id='type-id-75'/>
|
||||
<return type-id='type-id-3'/>
|
||||
</function-decl>
|
||||
<function-decl name='vwscanf' filepath='/usr/include/wchar.h' line='697' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
<parameter type-id='type-id-52'/>
|
||||
<parameter type-id='type-id-510'/>
|
||||
<parameter type-id='type-id-75'/>
|
||||
<return type-id='type-id-3'/>
|
||||
</function-decl>
|
||||
<function-decl name='wcrtomb' filepath='/usr/include/wchar.h' line='370' column='1' visibility='default' binding='global' size-in-bits='64'>
|
||||
|
@ -116,6 +116,11 @@ InOutSpec in_out_specs[] =
|
||||
"data/test-read-dwarf/test12-pr18844.so.abi",
|
||||
"output/test-read-dwarf/test12-pr18844.so.abi",
|
||||
},
|
||||
{
|
||||
"data/test-read-dwarf/test13-pr18894.so",
|
||||
"data/test-read-dwarf/test13-pr18894.so.abi",
|
||||
"output/test-read-dwarf/test13-pr18894.so.abi",
|
||||
},
|
||||
// This should be the last entry.
|
||||
{NULL, NULL, NULL}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user