@@ -300,6 +300,21 @@ static char *type_id_internal(Dwarf_Die *die,
300
300
void * data ,
301
301
int flags );
302
302
303
+ /*
304
+ * Internal: generate the type ID for a type DIE.
305
+ *
306
+ * If there are no overrides, look for a bit_size and bit_offset and pass them
307
+ * down as well.
308
+ */
309
+ static char * type_id_type_die (Dwarf_Die * die ,
310
+ Dwarf_Die * type_die ,
311
+ struct die_override * overrides ,
312
+ void (* fun )(Dwarf_Die * die ,
313
+ const char * id ,
314
+ struct die_override * overrides ,
315
+ void * data ),
316
+ void * data );
317
+
303
318
/*
304
319
* Convert 'long unsigned int' to 'sizetype'. Internal use within type_id().
305
320
*/
@@ -1474,6 +1489,51 @@ static char *type_id(Dwarf_Die *die,
1474
1489
return type_id_internal (die , overrides , fun , data , 0 );
1475
1490
}
1476
1491
1492
+ /*
1493
+ * Internal: generate the type ID for a type DIE.
1494
+ *
1495
+ * If there are no overrides, look for a bit_size and bit_offset and pass them
1496
+ * down as well.
1497
+ */
1498
+ static char * type_id_type_die (Dwarf_Die * die ,
1499
+ Dwarf_Die * type_die ,
1500
+ struct die_override * overrides ,
1501
+ void (* fun )(Dwarf_Die * die ,
1502
+ const char * id ,
1503
+ struct die_override * overrides ,
1504
+ void * data ),
1505
+ void * data )
1506
+ {
1507
+ char * id ;
1508
+
1509
+ /*
1510
+ * bit_size and bit_offset go together: we can assume that if a member
1511
+ * has the one, it has the other.
1512
+ */
1513
+
1514
+ if (private_dwarf_hasattr (die , DW_AT_bit_size )) {
1515
+ Dwarf_Word size ;
1516
+ Dwarf_Word offset ;
1517
+
1518
+ size = private_dwarf_udata (die , DW_AT_bit_size , NULL );
1519
+ offset = private_dwarf_udata (die , DW_AT_bit_offset , NULL );
1520
+ struct die_override o [] = {
1521
+ { DW_TAG_base_type ,
1522
+ DW_AT_bit_size ,
1523
+ DIE_OVERRIDE_REPLACE ,
1524
+ size , NULL },
1525
+ { DW_TAG_base_type ,
1526
+ DW_AT_bit_offset ,
1527
+ DIE_OVERRIDE_REPLACE ,
1528
+ offset , overrides },
1529
+ {0 }
1530
+ };
1531
+ id = type_id (type_die , o , fun , data );
1532
+ } else
1533
+ id = type_id (type_die , overrides , fun , data );
1534
+ return id ;
1535
+ }
1536
+
1477
1537
/*
1478
1538
* Internal: allows flags to be passed to affect one (and only one) type ID
1479
1539
* recursion, without affecting other type_id()s launched from the 'fun'.
@@ -1490,7 +1550,6 @@ static char *type_id_internal(Dwarf_Die *die,
1490
1550
char * id = NULL ;
1491
1551
int no_type_id = 0 ;
1492
1552
int decorated = 1 ;
1493
- Dwarf_Die type_die ;
1494
1553
1495
1554
/*
1496
1555
* The ID of a null pointer is NULL.
@@ -1511,8 +1570,8 @@ static char *type_id_internal(Dwarf_Die *die,
1511
1570
1512
1571
/*
1513
1572
* If we have a type DIE, generate it first, passing any overrides down.
1514
- * If there are no overrides, look for a bit_size and bit_offset and pass
1515
- * them down as well.
1573
+ * (Base types and enumerations don't have a type DIE that CTF can
1574
+ * encode the type of in any useful fashion.)
1516
1575
*
1517
1576
* Otherwise, note the location of this DIE, providing scoping
1518
1577
* information for all types based upon this one. Location elements are
@@ -1528,40 +1587,12 @@ static char *type_id_internal(Dwarf_Die *die,
1528
1587
if (dwarf_tag (die ) != DW_TAG_subrange_type ) {
1529
1588
if ((dwarf_tag (die ) != DW_TAG_base_type ) &&
1530
1589
(dwarf_tag (die ) != DW_TAG_enumeration_type )) {
1590
+ Dwarf_Die type_die ;
1531
1591
Dwarf_Die * diep = private_dwarf_type (die , & type_die );
1532
1592
1533
- /*
1534
- * bit_size and bit_offset go together: we can assume
1535
- * that if a member has the one, it has the other.
1536
- */
1537
- if (diep ) {
1538
- if (private_dwarf_hasattr (die , DW_AT_bit_size )) {
1539
- Dwarf_Word size ;
1540
- Dwarf_Word offset ;
1541
-
1542
- size = private_dwarf_udata (die ,
1543
- DW_AT_bit_size ,
1544
- NULL );
1545
- offset = private_dwarf_udata (die ,
1546
- DW_AT_bit_offset ,
1547
- NULL );
1548
- struct die_override o [] = {
1549
- { DW_TAG_base_type ,
1550
- DW_AT_bit_size ,
1551
- DIE_OVERRIDE_REPLACE ,
1552
- size ,
1553
- NULL },
1554
- { DW_TAG_base_type ,
1555
- DW_AT_bit_offset ,
1556
- DIE_OVERRIDE_REPLACE ,
1557
- offset ,
1558
- overrides },
1559
- {0 }
1560
- };
1561
- id = type_id (diep , o , fun , data );
1562
- } else
1563
- id = type_id (diep , overrides , fun , data );
1564
- }
1593
+ if (diep )
1594
+ id = type_id_type_die (die , diep , overrides ,
1595
+ fun , data );
1565
1596
}
1566
1597
1567
1598
/*
@@ -1768,6 +1799,7 @@ static char *type_id_internal(Dwarf_Die *die,
1768
1799
id = str_append (id , "[" );
1769
1800
1770
1801
if (nelems > 0 ) {
1802
+ Dwarf_Die type_die ;
1771
1803
char elems [22 ]; /* bigger than 2^64's digit count */
1772
1804
char * sub_id = type_id_internal (private_dwarf_type (die , & type_die ),
1773
1805
overrides , fun , data ,
0 commit comments