@@ -579,7 +579,7 @@ int class_member__dwarf_recode_bitfield(struct class_member *self,
579
579
return 0 ;
580
580
}
581
581
582
- static struct class_member * class_member__new (Dwarf_Die * die , struct cu * cu )
582
+ static struct class_member * class_member__new (Dwarf_Die * die )
583
583
{
584
584
struct class_member * self = tag__alloc (sizeof (* self ));
585
585
@@ -594,16 +594,6 @@ static struct class_member *class_member__new(Dwarf_Die *die, struct cu *cu)
594
594
self -> bitfield_offset = attr_numeric (die , DW_AT_bit_offset );
595
595
self -> bitfield_size = attr_numeric (die , DW_AT_bit_size );
596
596
self -> bit_offset = self -> byte_offset * 8 + self -> bitfield_offset ;
597
- /*
598
- * We may need to recode the type, possibly creating a suitably
599
- * sized new base_type
600
- */
601
- if (self -> bitfield_size != 0 &&
602
- class_member__dwarf_recode_bitfield (self , cu )) {
603
- free (self -> tag .priv );
604
- free (self );
605
- return NULL ;
606
- }
607
597
self -> bit_hole = 0 ;
608
598
self -> bitfield_end = 0 ;
609
599
self -> visited = 0 ;
@@ -1108,7 +1098,7 @@ static int die__process_class(Dwarf_Die *die, struct type *class,
1108
1098
switch (dwarf_tag (die )) {
1109
1099
case DW_TAG_inheritance :
1110
1100
case DW_TAG_member : {
1111
- struct class_member * member = class_member__new (die , cu );
1101
+ struct class_member * member = class_member__new (die );
1112
1102
1113
1103
if (member == NULL )
1114
1104
return - ENOMEM ;
@@ -1365,7 +1355,7 @@ static void __tag__print_type_not_found(struct tag *self, const char *func)
1365
1355
1366
1356
static void ftype__recode_dwarf_types (struct tag * self , struct cu * cu );
1367
1357
1368
- static void namespace__recode_dwarf_types (struct tag * self , struct cu * cu )
1358
+ static int namespace__recode_dwarf_types (struct tag * self , struct cu * cu )
1369
1359
{
1370
1360
struct tag * pos ;
1371
1361
struct dwarf_cu * dcu = cu -> priv ;
@@ -1376,15 +1366,24 @@ static void namespace__recode_dwarf_types(struct tag *self, struct cu *cu)
1376
1366
struct dwarf_tag * dpos = pos -> priv ;
1377
1367
1378
1368
if (tag__has_namespace (pos )) {
1379
- namespace__recode_dwarf_types (pos , cu );
1369
+ if (namespace__recode_dwarf_types (pos , cu ))
1370
+ return -1 ;
1380
1371
continue ;
1381
1372
}
1382
1373
1383
1374
switch (pos -> tag ) {
1384
- case DW_TAG_member :
1385
- /* Check if this is an already recoded bitfield */
1386
- if (pos -> type != 0 )
1375
+ case DW_TAG_member : {
1376
+ struct class_member * member = tag__class_member (pos );
1377
+ /*
1378
+ * We may need to recode the type, possibly creating a
1379
+ * suitably sized new base_type
1380
+ */
1381
+ if (member -> bitfield_size != 0 ) {
1382
+ if (class_member__dwarf_recode_bitfield (member , cu ))
1383
+ return -1 ;
1387
1384
continue ;
1385
+ }
1386
+ }
1388
1387
break ;
1389
1388
case DW_TAG_subroutine_type :
1390
1389
case DW_TAG_subprogram :
@@ -1413,6 +1412,7 @@ static void namespace__recode_dwarf_types(struct tag *self, struct cu *cu)
1413
1412
next :
1414
1413
pos -> type = dtype -> small_id ;
1415
1414
}
1415
+ return 0 ;
1416
1416
}
1417
1417
1418
1418
static void type__recode_dwarf_specification (struct tag * self , struct cu * cu )
@@ -1572,22 +1572,20 @@ static void lexblock__recode_dwarf_types(struct lexblock *self, struct cu *cu)
1572
1572
}
1573
1573
}
1574
1574
1575
- static void tag__recode_dwarf_type (struct tag * self , struct cu * cu )
1575
+ static int tag__recode_dwarf_type (struct tag * self , struct cu * cu )
1576
1576
{
1577
1577
struct dwarf_tag * dtag = self -> priv ;
1578
1578
struct dwarf_tag * dtype ;
1579
1579
1580
1580
/* Check if this is an already recoded bitfield */
1581
1581
if (dtag == NULL )
1582
- return ;
1582
+ return 0 ;
1583
1583
1584
1584
if (tag__is_type (self ))
1585
1585
type__recode_dwarf_specification (self , cu );
1586
1586
1587
- if (tag__has_namespace (self )) {
1588
- namespace__recode_dwarf_types (self , cu );
1589
- return ;
1590
- }
1587
+ if (tag__has_namespace (self ))
1588
+ return namespace__recode_dwarf_types (self , cu );
1591
1589
1592
1590
switch (self -> tag ) {
1593
1591
case DW_TAG_subprogram : {
@@ -1601,7 +1599,7 @@ static void tag__recode_dwarf_type(struct tag *self, struct cu *cu)
1601
1599
* <3><1423de>: Abbrev Number: 209 (DW_TAG_subprogram)
1602
1600
* <1423e0> DW_AT_declaration : 1
1603
1601
*/
1604
- return ;
1602
+ return 0 ;
1605
1603
}
1606
1604
dtype = dwarf_cu__find_tag_by_id (cu -> priv , dtag -> abstract_origin );
1607
1605
if (dtype == NULL )
@@ -1629,7 +1627,7 @@ static void tag__recode_dwarf_type(struct tag *self, struct cu *cu)
1629
1627
1630
1628
case DW_TAG_lexical_block :
1631
1629
lexblock__recode_dwarf_types (tag__lexblock (self ), cu );
1632
- return ;
1630
+ return 0 ;
1633
1631
1634
1632
case DW_TAG_ptr_to_member_type : {
1635
1633
struct ptr_to_member_type * pt = tag__ptr_to_member_type (self );
@@ -1649,8 +1647,7 @@ static void tag__recode_dwarf_type(struct tag *self, struct cu *cu)
1649
1647
break ;
1650
1648
1651
1649
case DW_TAG_namespace :
1652
- namespace__recode_dwarf_types (self , cu );
1653
- return ;
1650
+ return namespace__recode_dwarf_types (self , cu );
1654
1651
/* Damn, DW_TAG_inlined_subroutine is an special case
1655
1652
as dwarf_tag->id is in fact an abtract origin, i.e. must be
1656
1653
looked up in the tags_table, not in the types_table.
@@ -1669,37 +1666,42 @@ static void tag__recode_dwarf_type(struct tag *self, struct cu *cu)
1669
1666
1670
1667
if (dtag -> type == 0 ) {
1671
1668
self -> type = 0 ; /* void */
1672
- return ;
1669
+ return 0 ;
1673
1670
}
1674
1671
1675
1672
find_type :
1676
1673
dtype = dwarf_cu__find_type_by_id (cu -> priv , dtag -> type );
1677
1674
check_type :
1678
1675
if (dtype == NULL ) {
1679
1676
tag__print_type_not_found (self );
1680
- return ;
1677
+ return 0 ;
1681
1678
}
1682
1679
out :
1683
1680
self -> type = dtype -> small_id ;
1681
+ return 0 ;
1684
1682
}
1685
1683
1686
- static void cu__recode_dwarf_types_table (struct cu * self ,
1687
- struct ptr_table * pt ,
1688
- uint32_t i )
1684
+ static int cu__recode_dwarf_types_table (struct cu * self ,
1685
+ struct ptr_table * pt ,
1686
+ uint32_t i )
1689
1687
{
1690
1688
for (; i < pt -> nr_entries ; ++ i ) {
1691
1689
struct tag * tag = pt -> entries [i ];
1692
1690
1693
1691
if (tag != NULL ) /* void, see cu__new */
1694
- tag__recode_dwarf_type (tag , self );
1692
+ if (tag__recode_dwarf_type (tag , self ))
1693
+ return -1 ;
1695
1694
}
1695
+ return 0 ;
1696
1696
}
1697
1697
1698
- static void cu__recode_dwarf_types (struct cu * self )
1698
+ static int cu__recode_dwarf_types (struct cu * self )
1699
1699
{
1700
- cu__recode_dwarf_types_table (self , & self -> types_table , 1 );
1701
- cu__recode_dwarf_types_table (self , & self -> tags_table , 0 );
1702
- cu__recode_dwarf_types_table (self , & self -> functions_table , 0 );
1700
+ if (cu__recode_dwarf_types_table (self , & self -> types_table , 1 ) ||
1701
+ cu__recode_dwarf_types_table (self , & self -> tags_table , 0 ) ||
1702
+ cu__recode_dwarf_types_table (self , & self -> functions_table , 0 ))
1703
+ return -1 ;
1704
+ return 0 ;
1703
1705
}
1704
1706
1705
1707
static const char * dwarf_tag__decl_file (const struct tag * self ,
@@ -1783,8 +1785,7 @@ static int die__process(Dwarf_Die *die, struct cu *cu)
1783
1785
"DW_TAG_compile_unit!\n" ,
1784
1786
__FUNCTION__ , dwarf_tag_name (tag ));
1785
1787
1786
- cu__recode_dwarf_types (cu );
1787
- return 0 ;
1788
+ return cu__recode_dwarf_types (cu );
1788
1789
}
1789
1790
1790
1791
static int class_member__cache_byte_size (struct tag * self , struct cu * cu ,
0 commit comments