@@ -333,37 +333,11 @@ static void calculate_version(struct version *version,
333333 cache_free (& expansion_cache );
334334}
335335
336- static void __type_expand (struct die * cache , struct type_expansion * type ,
337- bool recursive );
338-
339- static void type_expand_child (struct die * cache , struct type_expansion * type ,
340- bool recursive )
341- {
342- struct type_expansion child ;
343- char * name ;
344-
345- name = get_type_name (cache );
346- if (!name ) {
347- __type_expand (cache , type , recursive );
348- return ;
349- }
350-
351- if (recursive && !__cache_was_expanded (& expansion_cache , cache -> addr )) {
352- __cache_mark_expanded (& expansion_cache , cache -> addr );
353- type_expansion_init (& child );
354- __type_expand (cache , & child , true);
355- type_map_add (name , & child );
356- type_expansion_free (& child );
357- }
358-
359- type_expansion_append (type , name , name );
360- }
361-
362- static void __type_expand (struct die * cache , struct type_expansion * type ,
363- bool recursive )
336+ static void __type_expand (struct die * cache , struct type_expansion * type )
364337{
365338 struct die_fragment * df ;
366339 struct die * child ;
340+ char * name ;
367341
368342 list_for_each_entry (df , & cache -> fragments , list ) {
369343 switch (df -> type ) {
@@ -379,7 +353,12 @@ static void __type_expand(struct die *cache, struct type_expansion *type,
379353 error ("unknown child: %" PRIxPTR ,
380354 df -> data .addr );
381355
382- type_expand_child (child , type , recursive );
356+ name = get_type_name (child );
357+ if (name )
358+ type_expansion_append (type , name , name );
359+ else
360+ __type_expand (child , type );
361+
383362 break ;
384363 case FRAGMENT_LINEBREAK :
385364 /*
@@ -397,12 +376,17 @@ static void __type_expand(struct die *cache, struct type_expansion *type,
397376 }
398377}
399378
400- static void type_expand (struct die * cache , struct type_expansion * type ,
401- bool recursive )
379+ static void type_expand (const char * name , struct die * cache ,
380+ struct type_expansion * type )
402381{
382+ const char * override ;
383+
403384 type_expansion_init (type );
404- __type_expand (cache , type , recursive );
405- cache_free (& expansion_cache );
385+
386+ if (stable && kabi_get_type_string (name , & override ))
387+ type_parse (name , override , type );
388+ else
389+ __type_expand (cache , type );
406390}
407391
408392static void type_parse (const char * name , const char * str ,
@@ -416,8 +400,6 @@ static void type_parse(const char *name, const char *str,
416400 if (!* str )
417401 error ("empty type string override for '%s'" , name );
418402
419- type_expansion_init (type );
420-
421403 for (pos = 0 ; str [pos ]; ++ pos ) {
422404 bool empty ;
423405 char marker = ' ' ;
@@ -478,7 +460,6 @@ static void type_parse(const char *name, const char *str,
478460static void expand_type (struct die * cache , void * arg )
479461{
480462 struct type_expansion type ;
481- const char * override ;
482463 char * name ;
483464
484465 if (cache -> mapped )
@@ -504,11 +485,7 @@ static void expand_type(struct die *cache, void *arg)
504485
505486 debug ("%s" , name );
506487
507- if (stable && kabi_get_type_string (name , & override ))
508- type_parse (name , override , & type );
509- else
510- type_expand (cache , & type , true);
511-
488+ type_expand (name , cache , & type );
512489 type_map_add (name , & type );
513490 type_expansion_free (& type );
514491 free (name );
@@ -518,7 +495,6 @@ static void expand_symbol(struct symbol *sym, void *arg)
518495{
519496 struct type_expansion type ;
520497 struct version version ;
521- const char * override ;
522498 struct die * cache ;
523499
524500 /*
@@ -532,10 +508,7 @@ static void expand_symbol(struct symbol *sym, void *arg)
532508 if (__die_map_get (sym -> die_addr , DIE_SYMBOL , & cache ))
533509 return ; /* We'll warn about missing CRCs later. */
534510
535- if (stable && kabi_get_type_string (sym -> name , & override ))
536- type_parse (sym -> name , override , & type );
537- else
538- type_expand (cache , & type , false);
511+ type_expand (sym -> name , cache , & type );
539512
540513 /* If the symbol already has a version, don't calculate it again. */
541514 if (sym -> state != SYMBOL_PROCESSED ) {
0 commit comments