mirror of
git://sourceware.org/git/libabigail.git
synced 2024-12-18 07:54:36 +00:00
Read enum values in the size_t and write them in ssize_t
Make sure to read enum values in the widest possible integer (size_t) but write them (in abixml writer) using a signed type to ease comparison. This makes the runtestreaddwarf pass on 32 bit x86, because we were losing some precision reading enum values using a signed integer. * include/abg-ir.h (enum_type_def::enumerator::get_value): Return a size_t. * src/abg-ir.cc (enum_type_decl::enumerator::get_value): Likewise. * src/abg-dwarf-reader.cc (die_signed_constant_attribute): #if-out this static function that is not used anymore. (build_enum_type): Read the value of the enumerator using a size_t value. * src/abg-reader.cc (build_enum_type_decl): Read the enum value using a long long int. * src/abg-writer.cc (write_enum_type_decl): Write using a ssize_t. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
parent
f8187a93ea
commit
86ec69a86d
@ -1832,7 +1832,7 @@ public:
|
||||
void
|
||||
set_name(const string& n);
|
||||
|
||||
ssize_t
|
||||
size_t
|
||||
get_value() const;
|
||||
|
||||
void
|
||||
|
@ -3956,6 +3956,7 @@ die_unsigned_constant_attribute(Dwarf_Die* die,
|
||||
return true;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/// Get the value of an attribute that is supposed to be a signed
|
||||
/// constant.
|
||||
///
|
||||
@ -3988,6 +3989,7 @@ die_signed_constant_attribute(Dwarf_Die* die,
|
||||
cst = result;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// Get the value of a DIE attribute; that value is meant to be a
|
||||
/// flag.
|
||||
@ -6476,8 +6478,8 @@ build_enum_type(read_context& ctxt,
|
||||
string n, m;
|
||||
location l;
|
||||
die_loc_and_name(ctxt, &child, loc, n, m);
|
||||
ssize_t val = 0;
|
||||
die_signed_constant_attribute(&child, DW_AT_const_value, val);
|
||||
size_t val = 0;
|
||||
die_unsigned_constant_attribute(&child, DW_AT_const_value, val);
|
||||
enms.push_back(enum_type_decl::enumerator(n, val));
|
||||
}
|
||||
while (dwarf_siblingof(&child, &child) == 0);
|
||||
|
@ -8200,7 +8200,7 @@ enum_type_decl::enumerator::set_name(const string& n)
|
||||
///
|
||||
/// @return the value of the current instance of
|
||||
/// enum_type_decl::enumerator.
|
||||
ssize_t
|
||||
size_t
|
||||
enum_type_decl::enumerator::get_value() const
|
||||
{return priv_->value_;}
|
||||
|
||||
|
@ -3176,7 +3176,7 @@ build_enum_type_decl(read_context& ctxt,
|
||||
if (xmlStrEqual(n->name, BAD_CAST("enumerator")))
|
||||
{
|
||||
string name;
|
||||
ssize_t value = 0;
|
||||
size_t value = 0;
|
||||
|
||||
xml_char_sptr a = xml::build_sptr(xmlGetProp(n, BAD_CAST("name")));
|
||||
if (a)
|
||||
@ -3185,7 +3185,7 @@ build_enum_type_decl(read_context& ctxt,
|
||||
a = xml::build_sptr(xmlGetProp(n, BAD_CAST("value")));
|
||||
if (a)
|
||||
{
|
||||
value = strtol(CHAR_STR(a), NULL, 0);
|
||||
value = strtoll(CHAR_STR(a), NULL, 0);
|
||||
if (errno == ERANGE)
|
||||
return nil;
|
||||
}
|
||||
|
@ -1861,7 +1861,7 @@ write_enum_type_decl(const enum_type_decl_sptr decl,
|
||||
o << "<enumerator name='"
|
||||
<< i->get_name()
|
||||
<< "' value='"
|
||||
<< i->get_value()
|
||||
<< (ssize_t)i->get_value()
|
||||
<< "'/>\n";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user