@@ -206,9 +206,13 @@ static int process_fqn(struct state *state, struct die *cache, Dwarf_Die *die)
206
206
return 0; \
207
207
}
208
208
209
+ DEFINE_PROCESS_UDATA_ATTRIBUTE (accessibility )
209
210
DEFINE_PROCESS_UDATA_ATTRIBUTE (alignment )
211
+ DEFINE_PROCESS_UDATA_ATTRIBUTE (bit_size )
210
212
DEFINE_PROCESS_UDATA_ATTRIBUTE (byte_size )
211
213
DEFINE_PROCESS_UDATA_ATTRIBUTE (encoding )
214
+ DEFINE_PROCESS_UDATA_ATTRIBUTE (data_bit_offset )
215
+ DEFINE_PROCESS_UDATA_ATTRIBUTE (data_member_location )
212
216
213
217
/* Match functions -- die_match_callback_t */
214
218
#define DEFINE_MATCH (type ) \
@@ -217,8 +221,11 @@ DEFINE_PROCESS_UDATA_ATTRIBUTE(encoding)
217
221
return dwarf_tag(die) == DW_TAG_##type##_type; \
218
222
}
219
223
224
+ DEFINE_MATCH (enumerator )
220
225
DEFINE_MATCH (formal_parameter )
226
+ DEFINE_MATCH (member )
221
227
DEFINE_MATCH (subrange )
228
+ DEFINE_MATCH (variant )
222
229
223
230
bool match_all (Dwarf_Die * die )
224
231
{
@@ -263,6 +270,10 @@ static int __process_list_type(struct state *state, struct die *cache,
263
270
{
264
271
check (process (state , cache , type ));
265
272
check (process_type_attr (state , cache , die ));
273
+ check (process_accessibility_attr (state , cache , die ));
274
+ check (process_bit_size_attr (state , cache , die ));
275
+ check (process_data_bit_offset_attr (state , cache , die ));
276
+ check (process_data_member_location_attr (state , cache , die ));
266
277
check (process (state , cache , "," ));
267
278
return check (process_linebreak (cache , 0 ));
268
279
}
@@ -275,6 +286,7 @@ static int __process_list_type(struct state *state, struct die *cache,
275
286
}
276
287
277
288
DEFINE_PROCESS_LIST_TYPE (formal_parameter )
289
+ DEFINE_PROCESS_LIST_TYPE (member )
278
290
279
291
/* Container types with DW_AT_type */
280
292
static int __process_type (struct state * state , struct die * cache ,
@@ -307,6 +319,7 @@ DEFINE_PROCESS_TYPE(reference)
307
319
DEFINE_PROCESS_TYPE (restrict )
308
320
DEFINE_PROCESS_TYPE (rvalue_reference )
309
321
DEFINE_PROCESS_TYPE (shared )
322
+ DEFINE_PROCESS_TYPE (template_type_parameter )
310
323
DEFINE_PROCESS_TYPE (volatile )
311
324
DEFINE_PROCESS_TYPE (typedef )
312
325
@@ -361,6 +374,108 @@ static int process_subroutine_type(struct state *state, struct die *cache,
361
374
return check (__process_subroutine_type (state , cache , die ,
362
375
"subroutine_type" ));
363
376
}
377
+ static int process_variant_type (struct state * state , struct die * cache ,
378
+ Dwarf_Die * die )
379
+ {
380
+ return check (process_die_container (state , cache , die , process_type ,
381
+ match_member_type ));
382
+ }
383
+
384
+ static int process_variant_part_type (struct state * state , struct die * cache ,
385
+ Dwarf_Die * die )
386
+ {
387
+ check (process (state , cache , "variant_part {" ));
388
+ check (process_linebreak (cache , 1 ));
389
+ check (process_die_container (state , cache , die , process_type ,
390
+ match_variant_type ));
391
+ check (process_linebreak (cache , -1 ));
392
+ check (process (state , cache , "}," ));
393
+ return check (process_linebreak (cache , 0 ));
394
+ }
395
+
396
+ static int ___process_structure_type (struct state * state , struct die * cache ,
397
+ Dwarf_Die * die )
398
+ {
399
+ switch (dwarf_tag (die )) {
400
+ case DW_TAG_member :
401
+ case DW_TAG_variant_part :
402
+ return check (process_type (state , cache , die ));
403
+ case DW_TAG_class_type :
404
+ case DW_TAG_enumeration_type :
405
+ case DW_TAG_structure_type :
406
+ case DW_TAG_template_type_parameter :
407
+ case DW_TAG_union_type :
408
+ check (process_type (state , cache , die ));
409
+ check (process (state , cache , "," ));
410
+ return check (process_linebreak (cache , 0 ));
411
+ case DW_TAG_subprogram :
412
+ return 0 ; /* Skip member functions */
413
+ default :
414
+ error ("unexpected structure_type child: %x" , dwarf_tag (die ));
415
+ return -1 ;
416
+ }
417
+ }
418
+
419
+ static int __process_structure_type (struct state * state , struct die * cache ,
420
+ Dwarf_Die * die , const char * type ,
421
+ die_callback_t process_func ,
422
+ die_match_callback_t match_func )
423
+ {
424
+ check (process (state , cache , type ));
425
+ check (process_fqn (state , cache , die ));
426
+ check (process (state , cache , " {" ));
427
+ check (process_linebreak (cache , 1 ));
428
+
429
+ check (process_die_container (state , cache , die , process_func ,
430
+ match_func ));
431
+
432
+ check (process_linebreak (cache , -1 ));
433
+ check (process (state , cache , "}" ));
434
+
435
+ check (process_byte_size_attr (state , cache , die ));
436
+ check (process_alignment_attr (state , cache , die ));
437
+
438
+ return 0 ;
439
+ }
440
+
441
+ #define DEFINE_PROCESS_STRUCTURE_TYPE (structure ) \
442
+ static int process_##structure##_type( \
443
+ struct state *state, struct die *cache, Dwarf_Die *die) \
444
+ { \
445
+ return check(__process_structure_type( \
446
+ state, cache, die, #structure "_type ", \
447
+ ___process_structure_type, match_all)); \
448
+ }
449
+
450
+ DEFINE_PROCESS_STRUCTURE_TYPE (class )
451
+ DEFINE_PROCESS_STRUCTURE_TYPE (structure )
452
+ DEFINE_PROCESS_STRUCTURE_TYPE (union )
453
+
454
+ static int process_enumerator_type (struct state * state , struct die * cache ,
455
+ Dwarf_Die * die )
456
+ {
457
+ Dwarf_Word value ;
458
+
459
+ check (process (state , cache , "enumerator " ));
460
+ check (process_fqn (state , cache , die ));
461
+
462
+ if (get_udata_attr (die , DW_AT_const_value , & value )) {
463
+ check (process (state , cache , " = " ));
464
+ check (process_fmt (state , cache , "%" PRIu64 , value ));
465
+ }
466
+
467
+ check (process (state , cache , "," ));
468
+ return check (process_linebreak (cache , 0 ));
469
+ }
470
+
471
+ static int process_enumeration_type (struct state * state , struct die * cache ,
472
+ Dwarf_Die * die )
473
+ {
474
+ return check (__process_structure_type (state , cache , die ,
475
+ "enumeration_type " , process_type ,
476
+ match_enumerator_type ));
477
+ }
478
+
364
479
static int process_base_type (struct state * state , struct die * cache ,
365
480
Dwarf_Die * die )
366
481
{
@@ -438,17 +553,27 @@ static int process_type(struct state *state, struct die *parent, Dwarf_Die *die)
438
553
PROCESS_TYPE (rvalue_reference )
439
554
PROCESS_TYPE (shared )
440
555
PROCESS_TYPE (volatile )
556
+ /* Container types */
557
+ PROCESS_TYPE (class )
558
+ PROCESS_TYPE (structure )
559
+ PROCESS_TYPE (union )
560
+ PROCESS_TYPE (enumeration )
441
561
/* Subtypes */
562
+ PROCESS_TYPE (enumerator )
442
563
PROCESS_TYPE (formal_parameter )
564
+ PROCESS_TYPE (member )
443
565
PROCESS_TYPE (subrange )
566
+ PROCESS_TYPE (template_type_parameter )
567
+ PROCESS_TYPE (variant )
568
+ PROCESS_TYPE (variant_part )
444
569
/* Other types */
445
570
PROCESS_TYPE (array )
446
571
PROCESS_TYPE (base )
447
572
PROCESS_TYPE (subroutine )
448
573
PROCESS_TYPE (typedef )
449
574
default :
450
- debug (" unimplemented type : %x ", tag );
451
- break ;
575
+ error (" unexpected type : %x ", tag );
576
+ return -1 ;
452
577
}
453
578
454
579
/* Update cache state and append to the parent (if any) */
0 commit comments