summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@redhat.com>2016-07-26 16:30:13 +0200
committerDodji Seketeli <dodji@redhat.com>2016-07-26 20:05:23 +0200
commit980d2b60659b53ec3d43b859638bdae72d43aca1 (patch)
tree4c767edde9fa9c8132e46223daf273947134e49b
parentCleanup is_class and is_compatible_with_class_type (diff)
downloadlibabigail-980d2b60659b53ec3d43b859638bdae72d43aca1.tar.gz
libabigail-980d2b60659b53ec3d43b859638bdae72d43aca1.tar.bz2
libabigail-980d2b60659b53ec3d43b859638bdae72d43aca1.tar.xz
Generalize DIE source concept in DWARF reader
There are many functions in the DWARF reader that need to know if a DIE comes from the primary or alternate debug info file. Today, this is conveyed by a boolean parameter. This patch generalizes this idea of "source of DIE" by introducing a new enum type named die_source that says where the DIE comes from. This is to help later enable the introduction of a new kind of DIE source. The patch also introduces a new member function named read_context::get_die_source to determine the source of a DIE. This helps remove the need of a die_source parameter on functions that already take a DIE. So this patch conceptually removes the die_source parameter from many functions. * src/abg-dwarf-reader.cc (enum die_source): Define new enum. (operator++): Define new prefix increment operator for the die_source enum. (imported_unit_point::imported_unit_from_alt_di): Remove this data member. (imported_unit_point::imported_unit_die_source): New data member of type die_source. (read_context::primary_die_parent_map_): Renamed die_parent_map_ data member into this. (read_context::clear_per_corpus_data): Use the new clear_die_type_maps function, not die_type_map. Also use the new clear_types_to_canonicalize overload that takes no parameter. (read_context::{get_die_source, clear_die_type_maps, clear_types_to_canonicalize}): New member functions. (build_ir_node_from_die, die_die_attribute, get_parent_die) (get_scope_for_die, build_namespace_decl_and_add_to_ir) (build_type_decl, build_enum_type) (build_class_type_and_add_to_ir, build_qualified_type) (build_pointer_type_def, build_reference_type) (build_function_type, build_array_type, build_typedef_type) (build_var_decl, build_function_decl): Remove the boolean parameter that was designating the source of the DIE. If necessary, get the source of the DIE from inside the function using the new read_context::get_die_source. (read_debug_info_into_corpus): Adjust. (maybe_canonicalize_type, find_import_unit_point_between_dies) (maybe_canonicalize_type, read_context::{associate_die_to_decl, lookup_decl_from_die_offset, die_type_map, associate_die_to_type, lookup_type_from_die_offset, die_wip_classes_map, die_wip_function_types_map, is_wip_class_die_offset, is_wip_function_type_die_offset, types_to_canonicalize, schedule_type_for_late_canonicalization, canonicalize_types_scheduled, add_late_canonicalized_types_stats, perform_late_type_canonicalizing}): Take a die_source as the source of the DIE, not a boolean. Adjust the code of the function accordingly. (read_context::{tu_die_imported_unit_points_map}): Modified this to make it take a die_source and return the appropriate map depending on the source. (read_context::build_die_parent_relations_under): Turn the non-member static function build_die_parent_relations_under into a member function. (read_context::build_die_parent_maps): Turn the non-member static function build_die_parent_maps into a member function. Make this function build a DIE -> parent map also for type DIEs that are in the .type_units section. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
-rw-r--r--src/abg-dwarf-reader.cc1315
1 files changed, 589 insertions, 726 deletions
diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
index 8e7b36fd..490ac6dc 100644
--- a/src/abg-dwarf-reader.cc
+++ b/src/abg-dwarf-reader.cc
@@ -68,6 +68,29 @@ using std::stack;
68using std::deque; 68using std::deque;
69using std::list; 69using std::list;
70 70
71/// Where a DIE comes from. For instance, a DIE can come from the main
72/// debug info section, the alternate debug info section or from the
73/// type unit section.
74enum die_source
75{
76 NO_DEBUG_INFO_DIE_SOURCE,
77 PRIMARY_DEBUG_INFO_DIE_SOURCE,
78 ALT_DEBUG_INFO_DIE_SOURCE,
79 NUMBER_OF_DIE_SOURCES, // This one must always be the latest
80 // enumerator
81};
82
83/// Prefix increment operator for @ref die_source.
84///
85/// @param source the die_source to increment.
86/// @return the incremented source.
87static die_source&
88operator++(die_source& source)
89{
90 source = static_cast<die_source>(source + 1);
91 return source;
92}
93
71/// A functor used by @ref dwfl_sptr. 94/// A functor used by @ref dwfl_sptr.
72struct dwfl_deleter 95struct dwfl_deleter
73{ 96{
@@ -139,7 +162,7 @@ struct imported_unit_point
139 Dwarf_Off offset_of_import; 162 Dwarf_Off offset_of_import;
140 // The boolean below is true iff the imported unit comes from the 163 // The boolean below is true iff the imported unit comes from the
141 // alternate debug info file. 164 // alternate debug info file.
142 bool imported_unit_from_alt_di; 165 die_source imported_unit_die_source;
143 Dwarf_Off imported_unit_die_off; 166 Dwarf_Off imported_unit_die_off;
144 Dwarf_Off imported_unit_cu_off; 167 Dwarf_Off imported_unit_cu_off;
145 Dwarf_Off imported_unit_child_off; 168 Dwarf_Off imported_unit_child_off;
@@ -147,7 +170,7 @@ struct imported_unit_point
147 /// Default constructor for @ref the type imported_unit_point. 170 /// Default constructor for @ref the type imported_unit_point.
148 imported_unit_point () 171 imported_unit_point ()
149 : offset_of_import(), 172 : offset_of_import(),
150 imported_unit_from_alt_di(), 173 imported_unit_die_source(PRIMARY_DEBUG_INFO_DIE_SOURCE),
151 imported_unit_die_off(), 174 imported_unit_die_off(),
152 imported_unit_cu_off(), 175 imported_unit_cu_off(),
153 imported_unit_child_off() 176 imported_unit_child_off()
@@ -159,7 +182,7 @@ struct imported_unit_point
159 /// been imported. 182 /// been imported.
160 imported_unit_point (Dwarf_Off import_off) 183 imported_unit_point (Dwarf_Off import_off)
161 : offset_of_import(import_off), 184 : offset_of_import(import_off),
162 imported_unit_from_alt_di(), 185 imported_unit_die_source(PRIMARY_DEBUG_INFO_DIE_SOURCE),
163 imported_unit_die_off(), 186 imported_unit_die_off(),
164 imported_unit_cu_off(), 187 imported_unit_cu_off(),
165 imported_unit_child_off() 188 imported_unit_child_off()
@@ -170,15 +193,14 @@ struct imported_unit_point
170 /// @param import_off the offset of the point at which the unit has 193 /// @param import_off the offset of the point at which the unit has
171 /// been imported. 194 /// been imported.
172 /// 195 ///
173 /// @param imported_from_alt_di true iff the imported DIE comes from 196 /// @param from where the imported DIE comes from.
174 /// the alternate debug info file.
175 /// 197 ///
176 /// @param imported_die the die of the unit that has been imported. 198 /// @param imported_die the die of the unit that has been imported.
177 imported_unit_point (Dwarf_Off import_off, 199 imported_unit_point (Dwarf_Off import_off,
178 const Dwarf_Die& imported_die, 200 const Dwarf_Die& imported_die,
179 bool imported_from_alt_di) 201 die_source from)
180 : offset_of_import(import_off), 202 : offset_of_import(import_off),
181 imported_unit_from_alt_di(imported_from_alt_di), 203 imported_unit_die_source(from),
182 imported_unit_die_off(dwarf_dieoffset 204 imported_unit_die_off(dwarf_dieoffset
183 (const_cast<Dwarf_Die*>(&imported_die))), 205 (const_cast<Dwarf_Die*>(&imported_die))),
184 imported_unit_cu_off(), 206 imported_unit_cu_off(),
@@ -241,9 +263,15 @@ die_location_address(Dwarf_Die* die,
241 Dwarf_Addr& address, 263 Dwarf_Addr& address,
242 bool& is_tls_address); 264 bool& is_tls_address);
243 265
266static bool
267die_die_attribute(Dwarf_Die* die,
268 unsigned attr_name,
269 Dwarf_Die& result,
270 bool look_thru_abstract_origin = true);
271
244static void 272static void
245maybe_canonicalize_type(Dwarf_Off die_offset, 273maybe_canonicalize_type(Dwarf_Off die_offset,
246 bool in_alt_di, 274 die_source source,
247 read_context& ctxt); 275 read_context& ctxt);
248 276
249static int 277static int
@@ -2102,7 +2130,7 @@ class read_context
2102 corpus_sptr cur_corpus_; 2130 corpus_sptr cur_corpus_;
2103 translation_unit_sptr cur_tu_; 2131 translation_unit_sptr cur_tu_;
2104 scope_stack_type scope_stack_; 2132 scope_stack_type scope_stack_;
2105 offset_offset_map die_parent_map_; 2133 offset_offset_map primary_die_parent_map_;
2106 // A map that associates each tu die to a vector of unit import 2134 // A map that associates each tu die to a vector of unit import
2107 // points, in the main debug info 2135 // points, in the main debug info
2108 tu_die_imported_unit_points_map_type tu_die_imported_unit_points_map_; 2136 tu_die_imported_unit_points_map_type tu_die_imported_unit_points_map_;
@@ -2202,10 +2230,8 @@ public:
2202 { 2230 {
2203 die_decl_map().clear(); 2231 die_decl_map().clear();
2204 alternate_die_decl_map().clear(); 2232 alternate_die_decl_map().clear();
2205 die_type_map(/*in_alt_di=*/true).clear(); 2233 clear_die_type_maps();
2206 die_type_map(/*in_alt_di=*/false).clear(); 2234 clear_types_to_canonicalize();
2207 types_to_canonicalize(/*in_alt_di=*/true).clear();
2208 types_to_canonicalize(/*in_alt_di=*/false).clear();
2209 } 2235 }
2210 2236
2211 /// Getter for the current environment. 2237 /// Getter for the current environment.
@@ -2422,6 +2448,79 @@ public:
2422 die_decl_map() const 2448 die_decl_map() const
2423 {return die_decl_map_;} 2449 {return die_decl_map_;}
2424 2450
2451 /// Get the source of the DIE.
2452 ///
2453 /// The function returns an enumerator value saying if the DIE comes
2454 /// from the .debug_info section of the primary debug info file, the
2455 /// .debug_info section of the alternate debug info file, or the
2456 /// .debug_types section.
2457 ///
2458 /// @param die the DIE to get the source of.
2459 ///
2460 /// @param source out parameter. The function sets this parameter
2461 /// to the source of the DIE @p iff it returns true.
2462 ///
2463 /// @return true iff the source of the DIE could be determined and
2464 /// returned.
2465 bool
2466 get_die_source(Dwarf_Die *die, die_source &source)
2467 {
2468 assert(die);
2469 return get_die_source(*die, source);
2470 }
2471
2472 /// Get the source of the DIE.
2473 ///
2474 /// The function returns an enumerator value saying if the DIE comes
2475 /// from the .debug_info section of the primary debug info file, the
2476 /// .debug_info section of the alternate debug info file, or the
2477 /// .debug_types section.
2478 ///
2479 /// @param die the DIE to get the source of.
2480 ///
2481 /// @param source out parameter. The function sets this parameter
2482 /// to the source of the DIE @p iff it returns true.
2483 ///
2484 /// @return true iff the source of the DIE could be determined and
2485 /// returned.
2486 bool
2487 get_die_source(Dwarf_Die &die, die_source &source)
2488 {
2489 Dwarf_Die cu_die;
2490 Dwarf_Die cu_kind;
2491 uint8_t address_size = 0, offset_size = 0;
2492 if (!dwarf_diecu(&die, &cu_die, &address_size, &offset_size))
2493 return false;
2494
2495 Dwarf_Half version = 0;
2496 Dwarf_Off abbrev_offset = 0;
2497 uint64_t type_signature = 0;
2498 Dwarf_Off type_offset = 0;
2499 if (!dwarf_cu_die(cu_die.cu, &cu_kind,
2500 &version, &abbrev_offset,
2501 &address_size, &offset_size,
2502 &type_signature, &type_offset))
2503 return false;
2504
2505 int tag = dwarf_tag(&cu_kind);
2506
2507 if (tag == DW_TAG_compile_unit
2508 || tag == DW_TAG_partial_unit)
2509 {
2510 Dwarf *die_dwarf = dwarf_cu_getdwarf(cu_die.cu);
2511 if (dwarf() == die_dwarf)
2512 source = PRIMARY_DEBUG_INFO_DIE_SOURCE;
2513 else if (alt_dwarf() == die_dwarf)
2514 source = ALT_DEBUG_INFO_DIE_SOURCE;
2515 else
2516 ABG_ASSERT_NOT_REACHED;
2517 }
2518 else
2519 return false;
2520
2521 return true;
2522 }
2523
2425 /// Return the map that associates a decl to the DIE that represents 2524 /// Return the map that associates a decl to the DIE that represents
2426 /// it. This if for DIEs that come from the main debug info file we 2525 /// it. This if for DIEs that come from the main debug info file we
2427 /// are looking at. 2526 /// are looking at.
@@ -2482,15 +2581,23 @@ private:
2482 decl_base_sptr decl) 2581 decl_base_sptr decl)
2483 {alternate_die_decl_map()[die_offset] = decl;} 2582 {alternate_die_decl_map()[die_offset] = decl;}
2484 2583
2584 /// Add an entry to the die->decl map for DIEs coming from the
2585 /// type unit section.
2586 ///
2587 /// @param die_offset the DIE offset of the DIE we are interested in.
2588 ///
2589 /// @param decl the decl we are interested in.
2590 void
2591 associate_die_to_decl_from_type_unit(size_t die_offset, decl_base_sptr decl)
2592 {type_unit_die_decl_map_[die_offset] = decl;}
2593
2485public: 2594public:
2486 2595
2487 /// Add an entry to the relevant die->decl map. 2596 /// Add an entry to the relevant die->decl map.
2488 /// 2597 ///
2489 /// @param die_offset the offset of the DIE to add the the map. 2598 /// @param die_offset the offset of the DIE to add the the map.
2490 /// 2599 ///
2491 /// @param die_is_from_alternate_debug_info true if the DIE comes 2600 /// @param source where the DIE comes from.
2492 /// from the alternate debug info file, false if it comes from the
2493 /// main debug info file.
2494 /// 2601 ///
2495 /// Note that "alternate debug info sections" is a GNU extension as 2602 /// Note that "alternate debug info sections" is a GNU extension as
2496 /// of DWARF4 and is described at 2603 /// of DWARF4 and is described at
@@ -2499,13 +2606,21 @@ public:
2499 /// @param decl the decl to consider. 2606 /// @param decl the decl to consider.
2500 void 2607 void
2501 associate_die_to_decl(size_t die_offset, 2608 associate_die_to_decl(size_t die_offset,
2502 bool die_is_from_alternate_debug_info, 2609 die_source source,
2503 decl_base_sptr decl) 2610 decl_base_sptr decl)
2504 { 2611 {
2505 if (die_is_from_alternate_debug_info) 2612 switch(source)
2506 associate_die_to_decl_alternate(die_offset, decl); 2613 {
2507 else 2614 case PRIMARY_DEBUG_INFO_DIE_SOURCE:
2508 associate_die_to_decl_primary(die_offset, decl); 2615 associate_die_to_decl_primary(die_offset, decl);
2616 break;
2617 case ALT_DEBUG_INFO_DIE_SOURCE:
2618 associate_die_to_decl_alternate(die_offset, decl);
2619 break;
2620 case NO_DEBUG_INFO_DIE_SOURCE:
2621 case NUMBER_OF_DIE_SOURCES:
2622 ABG_ASSERT_NOT_REACHED;
2623 }
2509 } 2624 }
2510 2625
2511public: 2626public:
@@ -2551,9 +2666,8 @@ public:
2551 /// 2666 ///
2552 /// @param die_offset the offset of the DIE to consider. 2667 /// @param die_offset the offset of the DIE to consider.
2553 /// 2668 ///
2554 /// @param is_from_alternate_debug_info true if the DIE represented 2669 /// @param source where the DIE represented by @p die_offset comes
2555 /// by @p die_offset comes from the alternate debug info section, 2670 /// from.
2556 /// false if it comes from the main debug info sections.
2557 /// 2671 ///
2558 /// Note that "alternate debug info sections" is a GNU extension as 2672 /// Note that "alternate debug info sections" is a GNU extension as
2559 /// of DWARF4 and is described at 2673 /// of DWARF4 and is described at
@@ -2562,58 +2676,82 @@ public:
2562 /// @return the resulting decl, or null if no decl is associated to 2676 /// @return the resulting decl, or null if no decl is associated to
2563 /// the DIE represented by @p die_offset. 2677 /// the DIE represented by @p die_offset.
2564 decl_base_sptr 2678 decl_base_sptr
2565 lookup_decl_from_die_offset(size_t die_offset, 2679 lookup_decl_from_die_offset(size_t die_offset, die_source source)
2566 bool is_from_alternate_debug_info)
2567 { 2680 {
2568 return is_from_alternate_debug_info 2681 decl_base_sptr result;
2569 ? lookup_decl_from_die_offset_alternate(die_offset) 2682
2570 : lookup_decl_from_die_offset_primary(die_offset); 2683 switch(source)
2684 {
2685 case PRIMARY_DEBUG_INFO_DIE_SOURCE:
2686 result = lookup_decl_from_die_offset_primary(die_offset);
2687 break;
2688 case ALT_DEBUG_INFO_DIE_SOURCE:
2689 result = lookup_decl_from_die_offset_alternate(die_offset);
2690 break;
2691 case NO_DEBUG_INFO_DIE_SOURCE:
2692 case NUMBER_OF_DIE_SOURCES:
2693 ABG_ASSERT_NOT_REACHED;
2694 }
2695
2696 return result;
2571 } 2697 }
2572 2698
2573 /// Return the map that associates DIEs to the type they represent. 2699 /// Return the map that associates DIEs to the type they represent.
2574 /// 2700 ///
2575 /// @param in_alt_die true iff the DIE is in the alternate debug info section. 2701 /// @param source where the DIE comes from.
2576 /// 2702 ///
2577 /// @return return the map that associated DIEs to the type they represent. 2703 /// @return return the map that associated DIEs to the type they represent.
2578 die_type_map_type& 2704 die_type_map_type&
2579 die_type_map(bool in_alt_die) 2705 die_type_map(die_source source)
2580 { 2706 {
2581 if (in_alt_die) 2707 switch(source)
2582 return alternate_die_type_map_; 2708 {
2709 case PRIMARY_DEBUG_INFO_DIE_SOURCE:
2710 break;
2711 case ALT_DEBUG_INFO_DIE_SOURCE:
2712 return alternate_die_type_map_;
2713 case NO_DEBUG_INFO_DIE_SOURCE:
2714 case NUMBER_OF_DIE_SOURCES:
2715 // We should not reach this point!
2716 ABG_ASSERT_NOT_REACHED;
2717 }
2583 return die_type_map_; 2718 return die_type_map_;
2584 } 2719 }
2585 2720
2721 /// Clear the type maps that associate a die to a type.
2722 void
2723 clear_die_type_maps()
2724 {
2725 die_type_map_.clear();
2726 alternate_die_type_map_.clear();
2727 }
2728
2586 /// Return the map that associates DIEs to the type they represent. 2729 /// Return the map that associates DIEs to the type they represent.
2587 /// 2730 ///
2588 /// @param in_alt_die true iff the DIE is in the alternate debug info section. 2731 /// @param source where the DIE comes from.
2589 /// 2732 ///
2590 /// @return the map that associated DIEs to the type they represent. 2733 /// @return the map that associated DIEs to the type they represent.
2591 const die_type_map_type& 2734 const die_type_map_type&
2592 die_type_map(bool in_alt_die) const 2735 die_type_map(die_source source) const
2593 { 2736 {return const_cast<read_context*>(this)->die_type_map(source);}
2594 if (in_alt_die)
2595 return alternate_die_type_map_;
2596 return die_type_map_;
2597 }
2598 2737
2599 /// Associated a DIE (representing a type) at a given offset to the 2738 /// Associated a DIE (representing a type) at a given offset to the
2600 /// type that it represents. 2739 /// type that it represents.
2601 /// 2740 ///
2602 /// @param die_offset the offset of the DIE to consider. 2741 /// @param die_offset the offset of the DIE to consider.
2603 /// 2742 ///
2604 /// @param in_alt_di true if the DIE comes from the alternate debug 2743 /// @param source where the DIE comes from.
2605 /// info section, false if it does not.
2606 /// 2744 ///
2607 /// @param type the type to associate the DIE to. 2745 /// @param type the type to associate the DIE to.
2608 void 2746 void
2609 associate_die_to_type(size_t die_offset, 2747 associate_die_to_type(size_t die_offset,
2610 bool in_alt_di, 2748 die_source source,
2611 type_base_sptr type) 2749 type_base_sptr type)
2612 { 2750 {
2613 if (!type) 2751 if (!type)
2614 return; 2752 return;
2615 2753
2616 die_type_map_type& m = die_type_map(in_alt_di); 2754 die_type_map_type& m = die_type_map(source);
2617 m[die_offset] = type; 2755 m[die_offset] = type;
2618 } 2756 }
2619 2757
@@ -2625,18 +2763,16 @@ public:
2625 /// 2763 ///
2626 /// @param die_offset the offset of the DIE to consider. 2764 /// @param die_offset the offset of the DIE to consider.
2627 /// 2765 ///
2628 /// @param in_alt_di true if the DIE comes from the alternate debug 2766 /// @param source where the DIE comes from.
2629 /// info section, false if it does not.
2630 /// 2767 ///
2631 /// @return the type associated to the DIE of offset @p die_offset, 2768 /// @return the type associated to the DIE of offset @p die_offset,
2632 /// or NULL if no type is associated to the DIE. 2769 /// or NULL if no type is associated to the DIE.
2633 type_base_sptr 2770 type_base_sptr
2634 lookup_type_from_die_offset(size_t die_offset, 2771 lookup_type_from_die_offset(size_t die_offset, die_source source) const
2635 bool in_alt_die) const
2636 { 2772 {
2637 type_base_sptr result; 2773 type_base_sptr result;
2638 { 2774 {
2639 const die_type_map_type& m = die_type_map(in_alt_die); 2775 const die_type_map_type& m = die_type_map(source);
2640 die_type_map_type::const_iterator i = m.find(die_offset); 2776 die_type_map_type::const_iterator i = m.find(die_offset);
2641 2777
2642 if (i != m.end()) 2778 if (i != m.end())
@@ -2646,7 +2782,7 @@ public:
2646 if (!result) 2782 if (!result)
2647 { 2783 {
2648 // Maybe we are looking for a class type being constructed? 2784 // Maybe we are looking for a class type being constructed?
2649 const die_class_map_type& m = die_wip_classes_map(in_alt_die); 2785 const die_class_map_type& m = die_wip_classes_map(source);
2650 die_class_map_type::const_iterator i = m.find(die_offset); 2786 die_class_map_type::const_iterator i = m.find(die_offset);
2651 2787
2652 if (i != m.end()) 2788 if (i != m.end())
@@ -2657,7 +2793,7 @@ public:
2657 { 2793 {
2658 // Maybe we are looking for a function type being constructed? 2794 // Maybe we are looking for a function type being constructed?
2659 const die_function_type_map_type& m = 2795 const die_function_type_map_type& m =
2660 die_wip_function_types_map(in_alt_die); 2796 die_wip_function_types_map(source);
2661 die_function_type_map_type::const_iterator i = m.find(die_offset); 2797 die_function_type_map_type::const_iterator i = m.find(die_offset);
2662 2798
2663 if (i != m.end()) 2799 if (i != m.end())
@@ -2671,33 +2807,35 @@ public:
2671 /// class/struct with the declaration of the class, while the class 2807 /// class/struct with the declaration of the class, while the class
2672 /// is being constructed. 2808 /// is being constructed.
2673 /// 2809 ///
2674 /// @param in_alt_die true iff the DIE is in the alternate debug 2810 /// @param source where the DIE is from.
2675 /// info section.
2676 /// 2811 ///
2677 /// @return the map that associates a DIE to the class that is being 2812 /// @return the map that associates a DIE to the class that is being
2678 /// built. 2813 /// built.
2679 const die_class_map_type& 2814 const die_class_map_type&
2680 die_wip_classes_map(bool in_alt_die) const 2815 die_wip_classes_map(die_source source) const
2681 { 2816 {return const_cast<read_context*>(this)->die_wip_classes_map(source);}
2682 if (in_alt_die)
2683 return alternate_die_wip_classes_map_;
2684 return die_wip_classes_map_;
2685 }
2686 2817
2687 /// Getter of a map that associates a die that represents a 2818 /// Getter of a map that associates a die that represents a
2688 /// class/struct with the declaration of the class, while the class 2819 /// class/struct with the declaration of the class, while the class
2689 /// is being constructed. 2820 /// is being constructed.
2690 /// 2821 ///
2691 /// @param in_alt_die true iff the DIE is in the alternate debug 2822 /// @param source where the DIE comes from.
2692 /// info section.
2693 /// 2823 ///
2694 /// @return the map that associates a DIE to the class that is being 2824 /// @return the map that associates a DIE to the class that is being
2695 /// built. 2825 /// built.
2696 die_class_map_type& 2826 die_class_map_type&
2697 die_wip_classes_map(bool in_alt_die) 2827 die_wip_classes_map(die_source source)
2698 { 2828 {
2699 if (in_alt_die) 2829 switch(source)
2700 return alternate_die_wip_classes_map_; 2830 {
2831 case PRIMARY_DEBUG_INFO_DIE_SOURCE:
2832 break;
2833 case ALT_DEBUG_INFO_DIE_SOURCE:
2834 return alternate_die_wip_classes_map_;
2835 case NO_DEBUG_INFO_DIE_SOURCE:
2836 case NUMBER_OF_DIE_SOURCES:
2837 ABG_ASSERT_NOT_REACHED;
2838 }
2701 return die_wip_classes_map_; 2839 return die_wip_classes_map_;
2702 } 2840 }
2703 2841
@@ -2705,28 +2843,33 @@ public:
2705 /// function type) whith a function type, while the function type is 2843 /// function type) whith a function type, while the function type is
2706 /// being constructed (WIP == work in progress). 2844 /// being constructed (WIP == work in progress).
2707 /// 2845 ///
2708 /// @param in_alt_die true iff the DIE is in the alternate debug 2846 /// @param source where the DIE comes from.n
2709 /// info section.
2710 /// 2847 ///
2711 /// @return the map of wip function types. 2848 /// @return the map of wip function types.
2712 const die_function_type_map_type& 2849 const die_function_type_map_type&
2713 die_wip_function_types_map(bool in_alt_di) const 2850 die_wip_function_types_map(die_source source) const
2714 { 2851 {return const_cast<read_context*>(this)->die_wip_function_types_map(source);}
2715 if (in_alt_di)
2716 return alternate_die_wip_function_types_map_;
2717 return die_wip_function_types_map_;
2718 }
2719 2852
2720 /// Getter for a map that associates a die (that represents a 2853 /// Getter for a map that associates a die (that represents a
2721 /// function type) whith a function type, while the function type is 2854 /// function type) whith a function type, while the function type is
2722 /// being constructed (WIP == work in progress). 2855 /// being constructed (WIP == work in progress).
2723 /// 2856 ///
2857 /// @param source where DIEs of the map come from.
2858 ///
2724 /// @return the map of wip function types. 2859 /// @return the map of wip function types.
2725 die_function_type_map_type& 2860 die_function_type_map_type&
2726 die_wip_function_types_map(bool in_alt_die) 2861 die_wip_function_types_map(die_source source)
2727 { 2862 {
2728 if (in_alt_die) 2863 switch(source)
2729 return alternate_die_wip_function_types_map_; 2864 {
2865 case PRIMARY_DEBUG_INFO_DIE_SOURCE:
2866 break;
2867 case ALT_DEBUG_INFO_DIE_SOURCE:
2868 return alternate_die_wip_function_types_map_;
2869 case NO_DEBUG_INFO_DIE_SOURCE:
2870 case NUMBER_OF_DIE_SOURCES:
2871 ABG_ASSERT_NOT_REACHED;
2872 }
2730 return die_wip_function_types_map_; 2873 return die_wip_function_types_map_;
2731 } 2874 }
2732 2875
@@ -2747,17 +2890,16 @@ public:
2747 /// 2890 ///
2748 /// @param offset the DIE offset to consider. 2891 /// @param offset the DIE offset to consider.
2749 /// 2892 ///
2750 // @param is_in_alt_di true if the DIE is in the alternate debug 2893 /// @param source where the DIE of the map come from.
2751 // info section.
2752 /// 2894 ///
2753 /// @return true iff @p offset is the offset of the DIE of a class 2895 /// @return true iff @p offset is the offset of the DIE of a class
2754 /// that is being currently built. 2896 /// that is being currently built.
2755 bool 2897 bool
2756 is_wip_class_die_offset(Dwarf_Off offset, bool is_in_alt_di) const 2898 is_wip_class_die_offset(Dwarf_Off offset, die_source source) const
2757 { 2899 {
2758 die_class_map_type::const_iterator i = 2900 die_class_map_type::const_iterator i =
2759 die_wip_classes_map(is_in_alt_di).find(offset); 2901 die_wip_classes_map(source).find(offset);
2760 return (i != die_wip_classes_map(is_in_alt_di).end()); 2902 return (i != die_wip_classes_map(source).end());
2761 } 2903 }
2762 2904
2763 /// Return true iff a given offset is for the DIE of a function type 2905 /// Return true iff a given offset is for the DIE of a function type
@@ -2766,17 +2908,16 @@ public:
2766 /// 2908 ///
2767 /// @param offset DIE offset to consider. 2909 /// @param offset DIE offset to consider.
2768 /// 2910 ///
2769 /// @param is_in_alt_di true if the DIE is in the alternate debug 2911 /// @param source where the DIE comes from.
2770 /// info section.
2771 /// 2912 ///
2772 /// @return true iff @p offset is the offset of the DIE of a 2913 /// @return true iff @p offset is the offset of the DIE of a
2773 /// function type that is being currently built. 2914 /// function type that is being currently built.
2774 bool 2915 bool
2775 is_wip_function_type_die_offset(Dwarf_Off offset, bool is_in_alt_di) const 2916 is_wip_function_type_die_offset(Dwarf_Off offset, die_source source) const
2776 { 2917 {
2777 die_function_type_map_type::const_iterator i = 2918 die_function_type_map_type::const_iterator i =
2778 die_wip_function_types_map(is_in_alt_di).find(offset); 2919 die_wip_function_types_map(source).find(offset);
2779 return (i != die_wip_function_types_map(is_in_alt_di).end()); 2920 return (i != die_wip_function_types_map(source).end());
2780 } 2921 }
2781 2922
2782 /// Getter for the map of declaration-only classes that are to be 2923 /// Getter for the map of declaration-only classes that are to be
@@ -2965,29 +3106,39 @@ public:
2965 /// Return a reference to the vector containing the offsets of the 3106 /// Return a reference to the vector containing the offsets of the
2966 /// types that need late canonicalizing. 3107 /// types that need late canonicalizing.
2967 /// 3108 ///
2968 /// @param in_alt_di true iff the vector to return is the one 3109 /// @param source whe DIEs referred to by the offsets contained in
2969 /// containining offsets of DIEs that are in the alternate debug 3110 /// the vector to return are from.
2970 /// info section.
2971 vector<Dwarf_Off>& 3111 vector<Dwarf_Off>&
2972 types_to_canonicalize(bool in_alt_di) 3112 types_to_canonicalize(die_source source)
2973 { 3113 {
2974 if (in_alt_di) 3114 switch(source)
2975 return alt_types_to_canonicalize_; 3115 {
3116 case PRIMARY_DEBUG_INFO_DIE_SOURCE:
3117 break;
3118 case ALT_DEBUG_INFO_DIE_SOURCE:
3119 return alt_types_to_canonicalize_;
3120 case NO_DEBUG_INFO_DIE_SOURCE:
3121 case NUMBER_OF_DIE_SOURCES:
3122 ABG_ASSERT_NOT_REACHED;
3123 }
2976 return types_to_canonicalize_; 3124 return types_to_canonicalize_;
2977 } 3125 }
2978 3126
2979 /// Return a reference to the vector containing the offsets of the 3127 /// Return a reference to the vector containing the offsets of the
2980 /// types that need late canonicalizing. 3128 /// types that need late canonicalizing.
2981 /// 3129 ///
2982 /// @param in_alt_di true iff the vector to return is the one 3130 /// @param source where the DIEs referred to by the offset in the
2983 /// containining offsets of DIEs that are in the alternate debug 3131 /// returned vector are from.
2984 /// info section.
2985 const vector<Dwarf_Off>& 3132 const vector<Dwarf_Off>&
2986 types_to_canonicalize(bool in_alt_di) const 3133 types_to_canonicalize(die_source source) const
3134 {return const_cast<read_context*>(this)->types_to_canonicalize(source);}
3135
3136 /// Clear the containers holding types to canonicalize.
3137 void
3138 clear_types_to_canonicalize()
2987 { 3139 {
2988 if (in_alt_di) 3140 types_to_canonicalize_.clear();
2989 return alt_types_to_canonicalize_; 3141 alt_types_to_canonicalize_.clear();
2990 return types_to_canonicalize_;
2991 } 3142 }
2992 3143
2993 /// Put the offset of a DIE representing a type on a side vector so 3144 /// Put the offset of a DIE representing a type on a side vector so
@@ -2998,28 +3149,28 @@ public:
2998 /// 3149 ///
2999 /// @param o the offset of the type DIE to schedule for late type 3150 /// @param o the offset of the type DIE to schedule for late type
3000 /// canonicalization. 3151 /// canonicalization.
3152 ///
3153 /// @param source where the DIE referred to by @p o is from.
3001 void 3154 void
3002 schedule_type_for_late_canonicalization(Dwarf_Off o, 3155 schedule_type_for_late_canonicalization(Dwarf_Off o, die_source source)
3003 bool in_alt_di)
3004 { 3156 {
3005 // First, some sanity check: ensure that the offset 'o' is for a 3157 // First, some sanity check: ensure that the offset 'o' is for a
3006 // type DIE that we know about. 3158 // type DIE that we know about.
3007 type_base_sptr t = lookup_type_from_die_offset(o, in_alt_di); 3159 type_base_sptr t = lookup_type_from_die_offset(o, source);
3008 assert(t); 3160 assert(t);
3009 3161
3010 // Then really do the scheduling. 3162 // Then really do the scheduling.
3011 types_to_canonicalize(in_alt_di).push_back(o); 3163 types_to_canonicalize(source).push_back(o);
3012 } 3164 }
3013 3165
3014 /// Canonicalize types which DIE offsets are stored in vectors on 3166 /// Canonicalize types which DIE offsets are stored in vectors on
3015 /// the side. This is a sub-routine of 3167 /// the side. This is a sub-routine of
3016 /// read_context::perform_late_type_canonicalizing(). 3168 /// read_context::perform_late_type_canonicalizing().
3017 /// 3169 ///
3018 /// @param in_alt_di true if the types to canonicalize are in the 3170 /// @param source where the DIE of the types to canonicalize are
3019 /// alternate debug info section, otherwise, the types are in the 3171 /// from.
3020 /// main debug info section.
3021 void 3172 void
3022 canonicalize_types_scheduled(bool in_alt_di) 3173 canonicalize_types_scheduled(die_source source)
3023 { 3174 {
3024 if (do_log()) 3175 if (do_log())
3025 { 3176 {
@@ -3027,19 +3178,19 @@ public:
3027 corpus_sptr c = current_corpus(); 3178 corpus_sptr c = current_corpus();
3028 if (c) 3179 if (c)
3029 cerr << " of corpus " << current_corpus()->get_path(); 3180 cerr << " of corpus " << current_corpus()->get_path();
3030 cerr << " (in alt di: " << in_alt_di << ")\n"; 3181 cerr << " (DIEs source: " << source << ")\n";
3031 } 3182 }
3032 3183
3033 if (!types_to_canonicalize(in_alt_di).empty()) 3184 if (!types_to_canonicalize(source).empty())
3034 { 3185 {
3035 size_t total = types_to_canonicalize(in_alt_di).size(); 3186 size_t total = types_to_canonicalize(source).size();
3036 if (do_log()) 3187 if (do_log())
3037 cerr << total << " types to canonicalize\n"; 3188 cerr << total << " types to canonicalize\n";
3038 for (size_t i = 0; i < total; ++i) 3189 for (size_t i = 0; i < total; ++i)
3039 { 3190 {
3040 Dwarf_Off element = types_to_canonicalize(in_alt_di)[i]; 3191 Dwarf_Off element = types_to_canonicalize(source)[i];
3041 type_base_sptr t = 3192 type_base_sptr t =
3042 lookup_type_from_die_offset(element, in_alt_di); 3193 lookup_type_from_die_offset(element, source);
3043 assert(t); 3194 assert(t);
3044 if (do_log()) 3195 if (do_log())
3045 { 3196 {
@@ -3056,16 +3207,15 @@ public:
3056 } 3207 }
3057 } 3208 }
3058 if (do_log()) 3209 if (do_log())
3059 cerr << "finished canonicalizing types. (in alt di: " 3210 cerr << "finished canonicalizing types. (source: "
3060 << in_alt_di << ")\n"; 3211 << source << ")\n";
3061 } 3212 }
3062 3213
3063 /// Compute the number of canonicalized and missed types in the late 3214 /// Compute the number of canonicalized and missed types in the late
3064 /// canonicalization phase. 3215 /// canonicalization phase.
3065 /// 3216 ///
3066 /// @param in_alt_di if set to yes, this means to look for types in 3217 /// @param source where the DIEs of the canonicalized types are
3067 /// the alternate debug info. If set to no, this means to look for 3218 /// from.
3068 /// the main debug info.
3069 /// 3219 ///
3070 /// @param canonicalized the number of types that got canonicalized 3220 /// @param canonicalized the number of types that got canonicalized
3071 /// is added to the value already present in this parameter. 3221 /// is added to the value already present in this parameter.
@@ -3074,16 +3224,16 @@ public:
3074 /// canonicalization and which couldn't be canonicalized (for a 3224 /// canonicalization and which couldn't be canonicalized (for a
3075 /// reason) is added to the value already present in this parameter. 3225 /// reason) is added to the value already present in this parameter.
3076 void 3226 void
3077 add_late_canonicalized_types_stats(bool in_alt_di, 3227 add_late_canonicalized_types_stats(die_source source,
3078 size_t& canonicalized, 3228 size_t& canonicalized,
3079 size_t& missed) const 3229 size_t& missed) const
3080 { 3230 {
3081 for (vector<Dwarf_Off>::const_iterator i = 3231 for (vector<Dwarf_Off>::const_iterator i =
3082 types_to_canonicalize(in_alt_di).begin(); 3232 types_to_canonicalize(source).begin();
3083 i != types_to_canonicalize(in_alt_di).end(); 3233 i != types_to_canonicalize(source).end();
3084 ++i) 3234 ++i)
3085 { 3235 {
3086 type_base_sptr t = lookup_type_from_die_offset(*i, in_alt_di); 3236 type_base_sptr t = lookup_type_from_die_offset(*i, source);
3087 if (t->get_canonical_type()) 3237 if (t->get_canonical_type())
3088 ++canonicalized; 3238 ++canonicalized;
3089 else 3239 else
@@ -3104,13 +3254,10 @@ public:
3104 add_late_canonicalized_types_stats(size_t& canonicalized, 3254 add_late_canonicalized_types_stats(size_t& canonicalized,
3105 size_t& missed) const 3255 size_t& missed) const
3106 { 3256 {
3107 add_late_canonicalized_types_stats(/*in_alt_di=*/true, 3257 for (die_source source = PRIMARY_DEBUG_INFO_DIE_SOURCE;
3108 canonicalized, 3258 source < NUMBER_OF_DIE_SOURCES;
3109 missed); 3259 ++source)
3110 3260 add_late_canonicalized_types_stats(source, canonicalized, missed);
3111 add_late_canonicalized_types_stats(/*in_alt_di=*/false,
3112 canonicalized,
3113 missed);
3114 } 3261 }
3115 3262
3116 // Look at the types that need to be canonicalized after the 3263 // Look at the types that need to be canonicalized after the
@@ -3118,8 +3265,10 @@ public:
3118 void 3265 void
3119 perform_late_type_canonicalizing() 3266 perform_late_type_canonicalizing()
3120 { 3267 {
3121 canonicalize_types_scheduled(/*in_alt_di=*/false); 3268 for (die_source source = PRIMARY_DEBUG_INFO_DIE_SOURCE;
3122 canonicalize_types_scheduled(/*in_alt_di=*/true); 3269 source < NUMBER_OF_DIE_SOURCES;
3270 ++source)
3271 canonicalize_types_scheduled(source);
3123 3272
3124 if (show_stats()) 3273 if (show_stats())
3125 { 3274 {
@@ -3151,36 +3300,25 @@ public:
3151 /// Getter for the map that associates a translation unit DIE to the 3300 /// Getter for the map that associates a translation unit DIE to the
3152 /// vector of imported unit points that it contains. 3301 /// vector of imported unit points that it contains.
3153 /// 3302 ///
3154 /// @return the map. 3303 /// @param source where the DIEs are from.
3155 tu_die_imported_unit_points_map_type&
3156 tu_die_imported_unit_points_map()
3157 {return tu_die_imported_unit_points_map_;}
3158
3159 /// Getter for the map that associates a translation unit DIE to the
3160 /// vector of imported unit points that it contains.
3161 ///
3162 /// @return the map.
3163 const tu_die_imported_unit_points_map_type&
3164 tu_die_imported_unit_points_map() const
3165 {return tu_die_imported_unit_points_map_;}
3166
3167 /// Getter for the map that associates a translation unit DIE to the
3168 /// vector of imported unit points that it contains. This is for
3169 /// translation units in the alternate debug info file.
3170 /// 3304 ///
3171 /// @return the map. 3305 /// @return the map.
3172 tu_die_imported_unit_points_map_type& 3306 tu_die_imported_unit_points_map_type&
3173 alt_tu_die_imported_unit_points_map() 3307 tu_die_imported_unit_points_map(die_source source)
3174 {return alt_tu_die_imported_unit_points_map_;} 3308 {
3175 3309 switch(source)
3176 /// Getter for the map that associates a translation unit DIE to the 3310 {
3177 /// vector of imported unit points that it contains. This is for 3311 case PRIMARY_DEBUG_INFO_DIE_SOURCE:
3178 /// translation units in the alternate debug info file. 3312 break;
3179 /// 3313 case ALT_DEBUG_INFO_DIE_SOURCE:
3180 /// @return the map. 3314 return alt_tu_die_imported_unit_points_map_;
3181 const tu_die_imported_unit_points_map_type& 3315 case NO_DEBUG_INFO_DIE_SOURCE:
3182 alt_tu_die_imported_unit_points_map() const 3316 case NUMBER_OF_DIE_SOURCES:
3183 {return alt_tu_die_imported_unit_points_map_;} 3317 // We cannot reach this point.
3318 ABG_ASSERT_NOT_REACHED;
3319 }
3320 return tu_die_imported_unit_points_map_;
3321 }
3184 3322
3185 const corpus_sptr 3323 const corpus_sptr
3186 current_corpus() const 3324 current_corpus() const
@@ -3204,39 +3342,39 @@ public:
3204 /// Get the map that associates each DIE to its parent DIE. This is 3342 /// Get the map that associates each DIE to its parent DIE. This is
3205 /// for DIEs coming from the main debug info sections. 3343 /// for DIEs coming from the main debug info sections.
3206 /// 3344 ///
3345 /// @param source where the DIEs in the map come from.
3346 ///
3207 /// @return the DIE -> parent map. 3347 /// @return the DIE -> parent map.
3208 const offset_offset_map& 3348 const offset_offset_map&
3209 die_parent_map() const 3349 die_parent_map(die_source source) const
3210 {return die_parent_map_;} 3350 {return const_cast<read_context*>(this)->die_parent_map(source);}
3211 3351
3212 /// Get the map that associates each DIE to its parent DIE. This is 3352 /// Get the map that associates each DIE to its parent DIE. This is
3213 /// for DIEs coming from the main debug info sections. 3353 /// for DIEs coming from the main debug info sections.
3214 /// 3354 ///
3215 /// @return the die -> parent map. 3355 /// @param source where the DIEs in the map come from.
3216 offset_offset_map&
3217 die_parent_map()
3218 {return die_parent_map_;}
3219
3220 /// Get the map that associates each DIE coming from the alternate
3221 /// debug info sections to its parent DIE.
3222 ///
3223 /// Note that "alternate debug info sections" is a GNU extension as
3224 /// of DWARF4 and is described at
3225 /// http://www.dwarfstd.org/ShowIssue.php?issue=120604.1
3226 /// 3356 ///
3227 /// @return the DIE -> parent map. 3357 /// @return the DIE -> parent map.
3358 offset_offset_map&
3359 die_parent_map(die_source source)
3360 {
3361 switch(source)
3362 {
3363 case PRIMARY_DEBUG_INFO_DIE_SOURCE:
3364 break;
3365 case ALT_DEBUG_INFO_DIE_SOURCE:
3366 return alternate_die_parent_map_;
3367 case NO_DEBUG_INFO_DIE_SOURCE:
3368 case NUMBER_OF_DIE_SOURCES:
3369 ABG_ASSERT_NOT_REACHED;
3370 }
3371 return primary_die_parent_map_;
3372 }
3373
3228 const offset_offset_map& 3374 const offset_offset_map&
3229 alternate_die_parent_map() const 3375 alternate_die_parent_map() const
3230 {return alternate_die_parent_map_;} 3376 {return alternate_die_parent_map_;}
3231 3377
3232 /// Get the map that associates each DIE coming from the alternate
3233 /// debug info sections to its parent DIE.
3234 ///
3235 /// Note that "alternate debug info sections" is a GNU extension as
3236 /// of DWARF4 and is described at
3237 /// http://www.dwarfstd.org/ShowIssue.php?issue=120604.1
3238 ///
3239 /// @return the DIE -> parent map.
3240 offset_offset_map& 3378 offset_offset_map&
3241 alternate_die_parent_map() 3379 alternate_die_parent_map()
3242 {return alternate_die_parent_map_;} 3380 {return alternate_die_parent_map_;}
@@ -4645,12 +4783,115 @@ public:
4645 if (corpus::exported_decls_builder* b = exported_decls_builder()) 4783 if (corpus::exported_decls_builder* b = exported_decls_builder())
4646 b->maybe_add_var_to_exported_vars(var); 4784 b->maybe_add_var_to_exported_vars(var);
4647 } 4785 }
4786
4787 /// Walk the DIEs under a given die and for each child, populate the
4788 /// die -> parent map to record the child -> parent relationship
4789 /// that
4790 /// exists between the child and the given die.
4791 ///
4792 /// The function also builds the vector of places where units are
4793 /// imported.
4794 ///
4795 /// This is done recursively as for each child DIE, this function
4796 /// walks its children as well.
4797 ///
4798 /// @param die the DIE whose children to walk recursively.
4799 ///
4800 /// @param source where the DIE @p die comes from.
4801 ///
4802 /// @param imported_units a vector containing all the offsets of the
4803 /// points where unit have been imported, under @p die.
4804 void
4805 build_die_parent_relations_under(Dwarf_Die* die,
4806 die_source source,
4807 imported_unit_points_type & imported_units)
4808 {
4809 if (!die)
4810 return;
4811
4812 offset_offset_map& parent_of = die_parent_map(source);
4813
4814 Dwarf_Die child;
4815 if (dwarf_child(die, &child) != 0)
4816 return;
4817
4818 do
4819 {
4820 parent_of[dwarf_dieoffset(&child)] = dwarf_dieoffset(die);
4821 if (dwarf_tag(&child) == DW_TAG_imported_unit)
4822 {
4823 Dwarf_Die imported_unit;
4824 if (die_die_attribute(&child, DW_AT_import, imported_unit))
4825 {
4826 die_source imported_unit_die_source = NO_DEBUG_INFO_DIE_SOURCE;
4827 assert(get_die_source(imported_unit, imported_unit_die_source));
4828 imported_units.push_back
4829 (imported_unit_point(dwarf_dieoffset(&child),
4830 imported_unit,
4831 imported_unit_die_source));
4832 }
4833 }
4834 build_die_parent_relations_under(&child, source, imported_units);
4835 }
4836 while (dwarf_siblingof(&child, &child) == 0);
4837
4838 }
4839
4840 /// Walk all the DIEs accessible in the debug info (and in the
4841 /// alternate debug info as well) and build maps representing the
4842 /// relationship DIE -> parent. That is, make it so that we can get
4843 /// the parent for a given DIE.
4844 void
4845 build_die_parent_maps()
4846 {
4847 // Build the DIE -> parent relation for DIEs coming from the
4848 // .debug_info section in the alternate debug info file.
4849 die_source source = ALT_DEBUG_INFO_DIE_SOURCE;
4850 uint8_t address_size = 0;
4851 size_t header_size = 0;
4852 for (Dwarf_Off offset = 0, next_offset = 0;
4853 (dwarf_next_unit(alt_dwarf(), offset, &next_offset, &header_size,
4854 NULL, NULL, &address_size, NULL, NULL, NULL) == 0);
4855 offset = next_offset)
4856 {
4857 Dwarf_Off die_offset = offset + header_size;
4858 Dwarf_Die cu;
4859 if (!dwarf_offdie(alt_dwarf(), die_offset, &cu))
4860 continue;
4861 cur_tu_die(&cu);
4862
4863 imported_unit_points_type& imported_units =
4864 tu_die_imported_unit_points_map(source)[die_offset] =
4865 imported_unit_points_type();
4866 build_die_parent_relations_under(&cu, source, imported_units);
4867 }
4868
4869 // Build the DIE -> parent relation for DIEs coming from the
4870 // .debug_info section of the main debug info file.
4871 source = PRIMARY_DEBUG_INFO_DIE_SOURCE;
4872 address_size = 0;
4873 header_size = 0;
4874 for (Dwarf_Off offset = 0, next_offset = 0;
4875 (dwarf_next_unit(dwarf(), offset, &next_offset, &header_size,
4876 NULL, NULL, &address_size, NULL, NULL, NULL) == 0);
4877 offset = next_offset)
4878 {
4879 Dwarf_Off die_offset = offset + header_size;
4880 Dwarf_Die cu;
4881 if (!dwarf_offdie(dwarf(), die_offset, &cu))
4882 continue;
4883 cur_tu_die(&cu);
4884 imported_unit_points_type& imported_units =
4885 tu_die_imported_unit_points_map(source)[die_offset] =
4886 imported_unit_points_type();
4887 build_die_parent_relations_under(&cu, source, imported_units);
4888 }
4889 }
4648};// end class read_context. 4890};// end class read_context.
4649 4891
4650static type_or_decl_base_sptr 4892static type_or_decl_base_sptr
4651build_ir_node_from_die(read_context& ctxt, 4893build_ir_node_from_die(read_context& ctxt,
4652 Dwarf_Die* die, 4894 Dwarf_Die* die,
4653 bool die_is_from_alt_di,
4654 scope_decl* scope, 4895 scope_decl* scope,
4655 bool called_from_public_decl, 4896 bool called_from_public_decl,
4656 size_t where_offset); 4897 size_t where_offset);
@@ -4658,7 +4899,6 @@ build_ir_node_from_die(read_context& ctxt,
4658static type_or_decl_base_sptr 4899static type_or_decl_base_sptr
4659build_ir_node_from_die(read_context& ctxt, 4900build_ir_node_from_die(read_context& ctxt,
4660 Dwarf_Die* die, 4901 Dwarf_Die* die,
4661 bool die_is_from_alt_di,
4662 bool called_from_public_decl, 4902 bool called_from_public_decl,
4663 size_t where_offset); 4903 size_t where_offset);
4664 4904
@@ -4668,7 +4908,6 @@ build_ir_node_for_void_type(read_context& ctxt);
4668static function_decl_sptr 4908static function_decl_sptr
4669build_function_decl(read_context& ctxt, 4909build_function_decl(read_context& ctxt,
4670 Dwarf_Die* die, 4910 Dwarf_Die* die,
4671 bool is_in_alt_di,
4672 size_t where_offset, 4911 size_t where_offset,
4673 function_decl_sptr fn); 4912 function_decl_sptr fn);
4674 4913
@@ -4894,82 +5133,6 @@ die_decl_file_attribute(Dwarf_Die* die)
4894 return str ? str : ""; 5133 return str ? str : "";
4895} 5134}
4896 5135
4897/// Tests if a given attribute that resolves to a DIE, resolves to a
4898/// DIE that is in the alternate debug info section. That is, tests
4899/// if the resolution is done through a DW_FORM_GNU_ref_alt kind of
4900/// attribute.
4901///
4902/// Note that this function works even if there is a
4903/// DW_AT_abstract_origin or DW_AT_specification between @p die and
4904/// the finally resolved DIE.
4905///
4906/// Note also that this function is a subroutine of
4907/// die_die_attribute().
4908///
4909/// @param die the DIE to consider.
4910///
4911/// @param attr_name the attribute name to consider.
4912///
4913/// @param thru_abstract_origin true if this function should follow a
4914/// DW_AT_specification or DW_AT_abstract_origin and perform the test
4915/// on the resulting target.
4916///
4917/// @return true if the test succeeds, false otherwise.
4918static bool
4919is_die_attribute_resolved_through_gnu_ref_alt(Dwarf_Die* die,
4920 unsigned attr_name,
4921 bool thru_abstract_origin = true)
4922{
4923 Dwarf_Attribute attr;
4924 if (thru_abstract_origin)
4925 {
4926 if (!dwarf_attr_integrate(die, attr_name, &attr))
4927 return false;
4928 }
4929 else
4930 {
4931 if (!dwarf_attr(die, attr_name, &attr))
4932 return false;
4933 }
4934
4935 bool is_in_alternate_debug_info = false;
4936 Dwarf_Die result;
4937 bool r = dwarf_formref_die(&attr, &result);
4938 if (r)
4939 is_in_alternate_debug_info = (attr.form == DW_FORM_GNU_ref_alt);
4940
4941 // Now let's see if we got to the attribute attr_name by looking
4942 // through either DW_AT_abstract_origin or DW_AT_specification, or
4943 // even DW_AT_abstract_origin *and then* DW_AT_specification. Would
4944 // then be looking at a function which definition is in the
4945 // alternate debug info file.
4946 if (r && !is_in_alternate_debug_info && thru_abstract_origin)
4947 {
4948 Dwarf_Die origin_die;
4949 Dwarf_Attribute mem;
4950 Dwarf_Attribute* a = dwarf_attr(die, DW_AT_abstract_origin, &mem);
4951 if (a == NULL || a->form != DW_FORM_GNU_ref_alt)
4952 {
4953 if (a == NULL)
4954 a = dwarf_attr(die, DW_AT_specification, &mem);
4955 else
4956 {
4957 // so we looked through a DW_AT_abstract_origin
4958 // attribute. So let's get that origin DIE and see if
4959 // it has an DW_AT_specification attribute ...
4960 assert(dwarf_formref_die(a, &origin_die));
4961 a = dwarf_attr(&origin_die, DW_AT_specification, &mem);
4962 }
4963 }
4964 // Now if the final function we got by jumping through hoops is
4965 // inside an alternate debug info file, we are good.
4966 if (a && a->form == DW_FORM_GNU_ref_alt)
4967 is_in_alternate_debug_info = true;
4968 }
4969
4970 return is_in_alternate_debug_info;
4971}
4972
4973/// Get the value of an attribute which value is supposed to be a 5136/// Get the value of an attribute which value is supposed to be a
4974/// reference to a DIE. 5137/// reference to a DIE.
4975/// 5138///
@@ -4983,10 +5146,6 @@ is_die_attribute_resolved_through_gnu_ref_alt(Dwarf_Die* die,
4983/// @param result the DIE resulting from reading the attribute value. 5146/// @param result the DIE resulting from reading the attribute value.
4984/// This is set iff the function returns true. 5147/// This is set iff the function returns true.
4985/// 5148///
4986/// @param result_die_is_in_alt_di out parameter. This is set to true
4987/// if the resulting DIE is in the alternate debug info section, false
4988/// otherwise.
4989///
4990/// @param look_thru_abstract_origin if yes, the function looks 5149/// @param look_thru_abstract_origin if yes, the function looks
4991/// through the possible DW_AT_abstract_origin attribute all the way 5150/// through the possible DW_AT_abstract_origin attribute all the way
4992/// down to the initial DIE that is cloned and look on that DIE to see 5151/// down to the initial DIE that is cloned and look on that DIE to see
@@ -4995,10 +5154,10 @@ is_die_attribute_resolved_through_gnu_ref_alt(Dwarf_Die* die,
4995/// @return true if the DIE @p die contains an attribute named @p 5154/// @return true if the DIE @p die contains an attribute named @p
4996/// attr_name that is a DIE reference, false otherwise. 5155/// attr_name that is a DIE reference, false otherwise.
4997static bool 5156static bool
4998die_die_attribute(Dwarf_Die* die, bool die_is_in_alt_di, 5157die_die_attribute(Dwarf_Die* die,
4999 unsigned attr_name, Dwarf_Die& result, 5158 unsigned attr_name,
5000 bool& result_die_is_in_alt_di, 5159 Dwarf_Die& result,
5001 bool look_thru_abstract_origin = true) 5160 bool look_thru_abstract_origin)
5002{ 5161{
5003 Dwarf_Attribute attr; 5162 Dwarf_Attribute attr;
5004 if (look_thru_abstract_origin) 5163 if (look_thru_abstract_origin)
@@ -5011,14 +5170,7 @@ die_die_attribute(Dwarf_Die* die, bool die_is_in_alt_di,
5011 if (!dwarf_attr(die, attr_name, &attr)) 5170 if (!dwarf_attr(die, attr_name, &attr))
5012 return false; 5171 return false;
5013 } 5172 }
5014
5015 bool r = dwarf_formref_die(&attr, &result); 5173 bool r = dwarf_formref_die(&attr, &result);
5016 if (r)
5017 result_die_is_in_alt_di =
5018 is_die_attribute_resolved_through_gnu_ref_alt(die, attr_name,
5019 look_thru_abstract_origin);
5020
5021 result_die_is_in_alt_di |= die_is_in_alt_di;
5022 return r; 5174 return r;
5023} 5175}
5024 5176
@@ -6439,116 +6591,6 @@ die_virtual_function_index(Dwarf_Die* die,
6439 return true; 6591 return true;
6440} 6592}
6441 6593
6442/// Walk the DIEs under a given die and for each child, populate the
6443/// die -> parent map to record the child -> parent relationship that
6444/// exists between the child and the given die.
6445///
6446/// The function also builds the vector of places where units are
6447/// imported.
6448///
6449/// This is done recursively as for each child DIE, this function
6450/// walks its children as well.
6451///
6452/// @param die the DIE whose children to walk recursively.
6453///
6454/// @param die_parent_map the die -> parent map to populate.
6455///
6456/// @param in_alt_di true iff the DIE under which this function is to
6457/// build the die parent relations is in the alternate debug info
6458/// file.
6459///
6460/// @param a vector containing all the offsets of the points where
6461/// unit have been imported, under @p die.
6462static void
6463build_die_parent_relations_under(Dwarf_Die* die,
6464 offset_offset_map& die_parent_map,
6465 bool in_alt_di,
6466 imported_unit_points_type & imported_units)
6467{
6468 if (!die)
6469 return;
6470
6471 Dwarf_Die child;
6472 if (dwarf_child(die, &child) != 0)
6473 return;
6474
6475 do
6476 {
6477 die_parent_map[dwarf_dieoffset(&child)] = dwarf_dieoffset(die);
6478 if (dwarf_tag(&child) == DW_TAG_imported_unit)
6479 {
6480 Dwarf_Die imported_unit;
6481 bool unit_imported_from_alt_di = in_alt_di;
6482 if (die_die_attribute(&child,
6483 /*die_is_in_alt_di=*/false,
6484 DW_AT_import, imported_unit,
6485 unit_imported_from_alt_di))
6486 imported_units.push_back
6487 (imported_unit_point(dwarf_dieoffset(&child),
6488 imported_unit,
6489 unit_imported_from_alt_di));
6490 }
6491 build_die_parent_relations_under(&child, die_parent_map,
6492 in_alt_di, imported_units);
6493 }
6494 while (dwarf_siblingof(&child, &child) == 0);
6495
6496}
6497
6498/// Walk all the DIEs accessible in the debug info (and in the
6499/// alternate debug info as well) and build maps representing the
6500/// relationship DIE -> parent. That is, make it so that we can get
6501/// the parent for a given DIE.
6502///
6503/// @param ctxt the read context from which to get the needed
6504/// information.
6505static void
6506build_die_parent_maps(read_context& ctxt)
6507{
6508 uint8_t address_size = 0;
6509 size_t header_size = 0;
6510
6511 for (Dwarf_Off offset = 0, next_offset = 0;
6512 (dwarf_next_unit(ctxt.alt_dwarf(), offset, &next_offset, &header_size,
6513 NULL, NULL, &address_size, NULL, NULL, NULL) == 0);
6514 offset = next_offset)
6515 {
6516 Dwarf_Off die_offset = offset + header_size;
6517 Dwarf_Die cu;
6518 if (!dwarf_offdie(ctxt.alt_dwarf(), die_offset, &cu))
6519 continue;
6520 ctxt.cur_tu_die(&cu);
6521 imported_unit_points_type& imported_units =
6522 ctxt.alt_tu_die_imported_unit_points_map()[die_offset] =
6523 imported_unit_points_type();
6524 build_die_parent_relations_under(&cu,
6525 ctxt.alternate_die_parent_map(),
6526 /*in_alt_di=*/true,
6527 imported_units);
6528 }
6529
6530 address_size = 0;
6531 header_size = 0;
6532 for (Dwarf_Off offset = 0, next_offset = 0;
6533 (dwarf_next_unit(ctxt.dwarf(), offset, &next_offset, &header_size,
6534 NULL, NULL, &address_size, NULL, NULL, NULL) == 0);
6535 offset = next_offset)
6536 {
6537 Dwarf_Off die_offset = offset + header_size;
6538 Dwarf_Die cu;
6539 if (!dwarf_offdie(ctxt.dwarf(), die_offset, &cu))
6540 continue;
6541 ctxt.cur_tu_die(&cu);
6542 imported_unit_points_type& imported_units =
6543 ctxt.tu_die_imported_unit_points_map()[die_offset] =
6544 imported_unit_points_type();
6545 build_die_parent_relations_under(&cu,
6546 ctxt.die_parent_map(),
6547 /*in_alt_di=*/false,
6548 imported_units);
6549 }
6550}
6551
6552/// Get the point where a DW_AT_import DIE is used to import a given 6594/// Get the point where a DW_AT_import DIE is used to import a given
6553/// (unit) DIE, between two DIEs. 6595/// (unit) DIE, between two DIEs.
6554/// 6596///
@@ -6567,9 +6609,8 @@ build_die_parent_maps(read_context& ctxt)
6567/// @param first_die_cu_offset the offset of the (compilation) unit 6609/// @param first_die_cu_offset the offset of the (compilation) unit
6568/// that @p first_die_cu_offset belongs to. 6610/// that @p first_die_cu_offset belongs to.
6569/// 6611///
6570/// @param is_from_alt_di true if the @p first_die_cu_offset is for a 6612/// @param source where the DIE of first_die_cu_offset unit comes
6571/// unit that comes from the alternate debug 6613/// from.
6572/// information file.
6573/// 6614///
6574/// @param last_die_offset the offset of the last DIE of the up to 6615/// @param last_die_offset the offset of the last DIE of the up to
6575/// which this function looks for the import point of @p 6616/// which this function looks for the import point of @p
@@ -6589,14 +6630,12 @@ find_import_unit_point_between_dies(read_context& ctxt,
6589 size_t partial_unit_offset, 6630 size_t partial_unit_offset,
6590 Dwarf_Off first_die_offset, 6631 Dwarf_Off first_die_offset,
6591 Dwarf_Off first_die_cu_offset, 6632 Dwarf_Off first_die_cu_offset,
6592 bool is_from_alt_di, 6633 die_source source,
6593 size_t last_die_offset, 6634 size_t last_die_offset,
6594 size_t& imported_point_offset) 6635 size_t& imported_point_offset)
6595{ 6636{
6596 tu_die_imported_unit_points_map_type& tu_die_imported_unit_points_map = 6637 tu_die_imported_unit_points_map_type& tu_die_imported_unit_points_map =
6597 is_from_alt_di 6638 ctxt.tu_die_imported_unit_points_map(source);
6598 ? ctxt.alt_tu_die_imported_unit_points_map()
6599 : ctxt.tu_die_imported_unit_points_map();
6600 6639
6601 tu_die_imported_unit_points_map_type::iterator iter = 6640 tu_die_imported_unit_points_map_type::iterator iter =
6602 tu_die_imported_unit_points_map.find(first_die_cu_offset); 6641 tu_die_imported_unit_points_map.find(first_die_cu_offset);
@@ -6634,7 +6673,7 @@ find_import_unit_point_between_dies(read_context& ctxt,
6634 partial_unit_offset, 6673 partial_unit_offset,
6635 i->imported_unit_child_off, 6674 i->imported_unit_child_off,
6636 i->imported_unit_cu_off, 6675 i->imported_unit_cu_off,
6637 i->imported_unit_from_alt_di, 6676 i->imported_unit_die_source,
6638 (Dwarf_Off)-1, 6677 (Dwarf_Off)-1,
6639 imported_point_offset)) 6678 imported_point_offset))
6640 return true; 6679 return true;
@@ -6655,7 +6694,7 @@ find_import_unit_point_between_dies(read_context& ctxt,
6655 partial_unit_offset, 6694 partial_unit_offset,
6656 i->imported_unit_child_off, 6695 i->imported_unit_child_off,
6657 i->imported_unit_cu_off, 6696 i->imported_unit_cu_off,
6658 i->imported_unit_from_alt_di, 6697 i->imported_unit_die_source,
6659 (Dwarf_Off)-1, 6698 (Dwarf_Off)-1,
6660 imported_point_offset)) 6699 imported_point_offset))
6661 return true; 6700 return true;
@@ -6711,7 +6750,7 @@ find_import_unit_point_before_die(read_context& ctxt,
6711 if (find_import_unit_point_between_dies(ctxt, partial_unit_offset, 6750 if (find_import_unit_point_between_dies(ctxt, partial_unit_offset,
6712 dwarf_dieoffset(&first_die_of_tu), 6751 dwarf_dieoffset(&first_die_of_tu),
6713 dwarf_dieoffset(cu_die), 6752 dwarf_dieoffset(cu_die),
6714 /*is_from_alt_die=*/false, 6753 /*source=*/PRIMARY_DEBUG_INFO_DIE_SOURCE,
6715 where_offset, 6754 where_offset,
6716 import_point_offset)) 6755 import_point_offset))
6717 { 6756 {
@@ -6738,9 +6777,6 @@ find_import_unit_point_before_die(read_context& ctxt,
6738/// 6777///
6739/// @param die the DIE for which we want the parent. 6778/// @param die the DIE for which we want the parent.
6740/// 6779///
6741/// @param die_is_from_alt_di true if @p die represent a DIE that
6742/// comes from alternate debug info, false otherwise.
6743///
6744/// @param parent_die the output parameter set to the parent die of 6780/// @param parent_die the output parameter set to the parent die of
6745/// @p die. Its memory must be allocated and handled by the caller. 6781/// @p die. Its memory must be allocated and handled by the caller.
6746/// 6782///
@@ -6754,58 +6790,31 @@ find_import_unit_point_before_die(read_context& ctxt,
6754static bool 6790static bool
6755get_parent_die(read_context& ctxt, 6791get_parent_die(read_context& ctxt,
6756 Dwarf_Die* die, 6792 Dwarf_Die* die,
6757 bool die_is_from_alt_di,
6758 Dwarf_Die& parent_die, 6793 Dwarf_Die& parent_die,
6759 size_t where_offset) 6794 size_t where_offset)
6760{ 6795{
6761 assert(ctxt.dwarf()); 6796 assert(ctxt.dwarf());
6762 6797
6763 offset_offset_map::const_iterator i = 6798 die_source source = NO_DEBUG_INFO_DIE_SOURCE;
6764 (die_is_from_alt_di) 6799 assert(ctxt.get_die_source(die, source));
6765 ? ctxt.alternate_die_parent_map().find(dwarf_dieoffset(die))
6766 : ctxt.die_parent_map().find(dwarf_dieoffset(die));
6767 6800
6768 if (die_is_from_alt_di) 6801 const offset_offset_map& m = ctxt.die_parent_map(source);
6769 { 6802 offset_offset_map::const_iterator i = m.find(dwarf_dieoffset(die));
6770 if (i == ctxt.alternate_die_parent_map().end()) 6803
6771 { 6804 if (i == m.end())
6772 // We haven't found the DIE in the alternate debug info. 6805 return false;
6773 // 6806
6774 // This could a problem in the debug info (the DIE doesn't 6807 switch(source)
6775 // exist in it).
6776 //
6777 // But first let's make sure the DIE we are looking for is
6778 // not in the main debug info either; if it is, it might
6779 // mean that we are looking for the DIE in the wrong debug
6780 // info. And that would most likely argue for a wrongdoing
6781 // on our part that ought fixing.
6782 assert(ctxt.die_parent_map().find(dwarf_dieoffset(die))
6783 == ctxt.die_parent_map().end());
6784 return false;
6785 }
6786 else
6787 assert(dwarf_offdie(ctxt.alt_dwarf(), i->second, &parent_die));
6788 }
6789 else
6790 { 6808 {
6791 if (i == ctxt.die_parent_map().end()) 6809 case PRIMARY_DEBUG_INFO_DIE_SOURCE:
6792 { 6810 assert(dwarf_offdie(ctxt.dwarf(), i->second, &parent_die));
6793 // We haven't found the DIE in the main debug info. 6811 break;
6794 // 6812 case ALT_DEBUG_INFO_DIE_SOURCE:
6795 // This could a problem in the debug info (the DIE doesn't 6813 assert(dwarf_offdie(ctxt.alt_dwarf(), i->second, &parent_die));
6796 // exist in it). 6814 break;
6797 // 6815 case NO_DEBUG_INFO_DIE_SOURCE:
6798 // But first let's make sure the DIE we are looking for is not 6816 case NUMBER_OF_DIE_SOURCES:
6799 // in the alternate debug info either; if it is, it might mean 6817 ABG_ASSERT_NOT_REACHED;
6800 // that we are looking for the DIE int the wrong debug info.
6801 // And that would most likely argue for a wrongdoing on our
6802 // part that ought fixing.
6803 assert(ctxt.alternate_die_parent_map().find(dwarf_dieoffset(die))
6804 == ctxt.alternate_die_parent_map().end());
6805 return false;
6806 }
6807 else
6808 assert(dwarf_offdie(ctxt.dwarf(), i->second, &parent_die));
6809 } 6818 }
6810 6819
6811 if (dwarf_tag(&parent_die) == DW_TAG_partial_unit) 6820 if (dwarf_tag(&parent_die) == DW_TAG_partial_unit)
@@ -6831,7 +6840,6 @@ get_parent_die(read_context& ctxt,
6831 import_point_offset, 6840 import_point_offset,
6832 &import_point_die)); 6841 &import_point_die));
6833 return get_parent_die(ctxt, &import_point_die, 6842 return get_parent_die(ctxt, &import_point_die,
6834 /*die_is_from_alt_di=*/false,
6835 parent_die, where_offset); 6843 parent_die, where_offset);
6836 } 6844 }
6837 } 6845 }
@@ -6850,9 +6858,6 @@ get_parent_die(read_context& ctxt,
6850/// 6858///
6851/// @param die the DIE to get the scope for. 6859/// @param die the DIE to get the scope for.
6852/// 6860///
6853/// @param die_is_from_alt_di true if @p comes from alternate debug
6854/// info sections, false otherwise.
6855///
6856/// @param called_from_public_decl is true if this function has been 6861/// @param called_from_public_decl is true if this function has been
6857/// initially called within the context of a public decl. 6862/// initially called within the context of a public decl.
6858/// 6863///
@@ -6863,27 +6868,22 @@ get_parent_die(read_context& ctxt,
6863static scope_decl_sptr 6868static scope_decl_sptr
6864get_scope_for_die(read_context& ctxt, 6869get_scope_for_die(read_context& ctxt,
6865 Dwarf_Die* die, 6870 Dwarf_Die* die,
6866 bool die_is_from_alt_di,
6867 bool called_for_public_decl, 6871 bool called_for_public_decl,
6868 size_t where_offset) 6872 size_t where_offset)
6869{ 6873{
6874 die_source source_of_die;
6875 assert(ctxt.get_die_source(die, source_of_die));
6876
6870 Dwarf_Die cloned_die; 6877 Dwarf_Die cloned_die;
6871 bool cloned_die_is_from_alternate_debug_info = false; 6878 if (die_die_attribute(die, DW_AT_specification, cloned_die, false)
6872 if (die_die_attribute(die, die_is_from_alt_di, 6879 || die_die_attribute(die, DW_AT_abstract_origin, cloned_die, false))
6873 DW_AT_specification, cloned_die,
6874 cloned_die_is_from_alternate_debug_info, false)
6875 || die_die_attribute(die, die_is_from_alt_di,
6876 DW_AT_abstract_origin, cloned_die,
6877 cloned_die_is_from_alternate_debug_info, false))
6878 return get_scope_for_die(ctxt, &cloned_die, 6880 return get_scope_for_die(ctxt, &cloned_die,
6879 cloned_die_is_from_alternate_debug_info,
6880 called_for_public_decl, 6881 called_for_public_decl,
6881 where_offset); 6882 where_offset);
6882 6883
6883 Dwarf_Die parent_die; 6884 Dwarf_Die parent_die;
6884 6885
6885 if (!get_parent_die(ctxt, die, die_is_from_alt_di, 6886 if (!get_parent_die(ctxt, die, parent_die, where_offset))
6886 parent_die, where_offset))
6887 return scope_decl_sptr(); 6887 return scope_decl_sptr();
6888 6888
6889 if (dwarf_tag(&parent_die) == DW_TAG_compile_unit 6889 if (dwarf_tag(&parent_die) == DW_TAG_compile_unit
@@ -6891,7 +6891,7 @@ get_scope_for_die(read_context& ctxt,
6891 { 6891 {
6892 if (dwarf_tag(&parent_die) == DW_TAG_partial_unit) 6892 if (dwarf_tag(&parent_die) == DW_TAG_partial_unit)
6893 { 6893 {
6894 assert(die_is_from_alt_di); 6894 assert(source_of_die == ALT_DEBUG_INFO_DIE_SOURCE);
6895 return ctxt.cur_tu()->get_global_scope(); 6895 return ctxt.cur_tu()->get_global_scope();
6896 } 6896 }
6897 6897
@@ -6915,11 +6915,10 @@ get_scope_for_die(read_context& ctxt,
6915 // function. Yeah, weird. So if I drop the typedef DIE, I'd drop 6915 // function. Yeah, weird. So if I drop the typedef DIE, I'd drop
6916 // the function parm too. So for that case, let's say that the 6916 // the function parm too. So for that case, let's say that the
6917 // scope is the scope of the function itself. 6917 // scope is the scope of the function itself.
6918 return get_scope_for_die(ctxt, &parent_die, die_is_from_alt_di, 6918 return get_scope_for_die(ctxt, &parent_die,
6919 called_for_public_decl, where_offset); 6919 called_for_public_decl, where_offset);
6920 else 6920 else
6921 d = build_ir_node_from_die(ctxt, &parent_die, 6921 d = build_ir_node_from_die(ctxt, &parent_die,
6922 die_is_from_alt_di,
6923 called_for_public_decl, 6922 called_for_public_decl,
6924 where_offset); 6923 where_offset);
6925 s = dynamic_pointer_cast<scope_decl>(d); 6924 s = dynamic_pointer_cast<scope_decl>(d);
@@ -7171,7 +7170,6 @@ build_translation_unit_and_add_to_ir(read_context& ctxt,
7171 7170
7172 do 7171 do
7173 build_ir_node_from_die(ctxt, &child, 7172 build_ir_node_from_die(ctxt, &child,
7174 /*die_is_from_alt_di=*/false,
7175 die_is_public_decl(&child), 7173 die_is_public_decl(&child),
7176 dwarf_dieoffset(&child)); 7174 dwarf_dieoffset(&child));
7177 while (dwarf_siblingof(&child, &child) == 0); 7175 while (dwarf_siblingof(&child, &child) == 0);
@@ -7251,9 +7249,6 @@ build_translation_unit_and_add_to_ir(read_context& ctxt,
7251/// @param die the DIE to read from. Must be either DW_TAG_namespace 7249/// @param die the DIE to read from. Must be either DW_TAG_namespace
7252/// or DW_TAG_module. 7250/// or DW_TAG_module.
7253/// 7251///
7254/// @param die_is_from_alt_di true if @p die comes from alternate
7255/// debug info sections, false otherwise.
7256///
7257/// @param where_offset the offset of the DIE where we are "logically" 7252/// @param where_offset the offset of the DIE where we are "logically"
7258/// positionned at, in the DIE tree. This is useful when @p die is 7253/// positionned at, in the DIE tree. This is useful when @p die is
7259/// e.g, DW_TAG_partial_unit that can be included in several places in 7254/// e.g, DW_TAG_partial_unit that can be included in several places in
@@ -7264,7 +7259,6 @@ build_translation_unit_and_add_to_ir(read_context& ctxt,
7264static namespace_decl_sptr 7259static namespace_decl_sptr
7265build_namespace_decl_and_add_to_ir(read_context& ctxt, 7260build_namespace_decl_and_add_to_ir(read_context& ctxt,
7266 Dwarf_Die* die, 7261 Dwarf_Die* die,
7267 bool die_is_from_alt_di,
7268 size_t where_offset) 7262 size_t where_offset)
7269{ 7263{
7270 namespace_decl_sptr result; 7264 namespace_decl_sptr result;
@@ -7272,11 +7266,14 @@ build_namespace_decl_and_add_to_ir(read_context& ctxt,
7272 if (!die) 7266 if (!die)
7273 return result; 7267 return result;
7274 7268
7269 die_source source;
7270 assert(ctxt.get_die_source(die, source));
7271
7275 unsigned tag = dwarf_tag(die); 7272 unsigned tag = dwarf_tag(die);
7276 if (tag != DW_TAG_namespace && tag != DW_TAG_module) 7273 if (tag != DW_TAG_namespace && tag != DW_TAG_module)
7277 return result; 7274 return result;
7278 7275
7279 scope_decl_sptr scope = get_scope_for_die(ctxt, die, die_is_from_alt_di, 7276 scope_decl_sptr scope = get_scope_for_die(ctxt, die,
7280 /*called_for_public_decl=*/false, 7277 /*called_for_public_decl=*/false,
7281 where_offset); 7278 where_offset);
7282 7279
@@ -7286,7 +7283,7 @@ build_namespace_decl_and_add_to_ir(read_context& ctxt,
7286 7283
7287 result.reset(new namespace_decl(ctxt.env(), name, loc)); 7284 result.reset(new namespace_decl(ctxt.env(), name, loc));
7288 add_decl_to_scope(result, scope.get()); 7285 add_decl_to_scope(result, scope.get());
7289 ctxt.associate_die_to_decl(dwarf_dieoffset(die), die_is_from_alt_di, result); 7286 ctxt.associate_die_to_decl(dwarf_dieoffset(die), source, result);
7290 7287
7291 Dwarf_Die child; 7288 Dwarf_Die child;
7292 if (dwarf_child(die, &child) != 0) 7289 if (dwarf_child(die, &child) != 0)
@@ -7295,7 +7292,6 @@ build_namespace_decl_and_add_to_ir(read_context& ctxt,
7295 ctxt.scope_stack().push(result.get()); 7292 ctxt.scope_stack().push(result.get());
7296 do 7293 do
7297 build_ir_node_from_die(ctxt, &child, 7294 build_ir_node_from_die(ctxt, &child,
7298 die_is_from_alt_di,
7299 /*called_from_public_decl=*/false, 7295 /*called_from_public_decl=*/false,
7300 where_offset); 7296 where_offset);
7301 while (dwarf_siblingof(&child, &child) == 0); 7297 while (dwarf_siblingof(&child, &child) == 0);
@@ -7312,9 +7308,7 @@ build_namespace_decl_and_add_to_ir(read_context& ctxt,
7312/// 7308///
7313/// @return the resulting decl_base_sptr. 7309/// @return the resulting decl_base_sptr.
7314static type_decl_sptr 7310static type_decl_sptr
7315build_type_decl(read_context& ctxt, 7311build_type_decl(read_context& ctxt, Dwarf_Die* die)
7316 bool die_is_from_alt_di,
7317 Dwarf_Die* die)
7318{ 7312{
7319 type_decl_sptr result; 7313 type_decl_sptr result;
7320 7314
@@ -7322,6 +7316,9 @@ build_type_decl(read_context& ctxt,
7322 return result; 7316 return result;
7323 assert(dwarf_tag(die) == DW_TAG_base_type); 7317 assert(dwarf_tag(die) == DW_TAG_base_type);
7324 7318
7319 die_source source;
7320 assert(ctxt.get_die_source(die, source));
7321
7325 uint64_t byte_size = 0, bit_size = 0; 7322 uint64_t byte_size = 0, bit_size = 0;
7326 if (!die_unsigned_constant_attribute(die, DW_AT_byte_size, byte_size)) 7323 if (!die_unsigned_constant_attribute(die, DW_AT_byte_size, byte_size))
7327 if (!die_unsigned_constant_attribute(die, DW_AT_bit_size, bit_size)) 7324 if (!die_unsigned_constant_attribute(die, DW_AT_bit_size, bit_size))
@@ -7350,9 +7347,7 @@ build_type_decl(read_context& ctxt,
7350 if (!result) 7347 if (!result)
7351 result.reset(new type_decl(ctxt.env(), type_name, bit_size, 7348 result.reset(new type_decl(ctxt.env(), type_name, bit_size,
7352 /*alignment=*/0, loc, linkage_name)); 7349 /*alignment=*/0, loc, linkage_name));
7353 ctxt.associate_die_to_type(dwarf_dieoffset(die), 7350 ctxt.associate_die_to_type(dwarf_dieoffset(die), source, result);
7354 die_is_from_alt_di,
7355 result);
7356 return result; 7351 return result;
7357} 7352}
7358 7353
@@ -7364,14 +7359,15 @@ build_type_decl(read_context& ctxt,
7364/// 7359///
7365/// @return the built enum_type_decl or NULL if it could not be built. 7360/// @return the built enum_type_decl or NULL if it could not be built.
7366static enum_type_decl_sptr 7361static enum_type_decl_sptr
7367build_enum_type(read_context& ctxt, 7362build_enum_type(read_context& ctxt, Dwarf_Die* die)
7368 bool die_is_from_alt_di,
7369 Dwarf_Die* die)
7370{ 7363{
7371 enum_type_decl_sptr result; 7364 enum_type_decl_sptr result;
7372 if (!die) 7365 if (!die)
7373 return result; 7366 return result;
7374 7367
7368 die_source source;
7369 assert(ctxt.get_die_source(die, source));
7370
7375 unsigned tag = dwarf_tag(die); 7371 unsigned tag = dwarf_tag(die);
7376 if (tag != DW_TAG_enumeration_type) 7372 if (tag != DW_TAG_enumeration_type)
7377 return result; 7373 return result;
@@ -7440,9 +7436,7 @@ build_enum_type(read_context& ctxt,
7440 assert(t); 7436 assert(t);
7441 result.reset(new enum_type_decl(name, loc, t, enms, linkage_name)); 7437 result.reset(new enum_type_decl(name, loc, t, enms, linkage_name));
7442 result->set_is_anonymous(enum_is_anonymous); 7438 result->set_is_anonymous(enum_is_anonymous);
7443 ctxt.associate_die_to_type(dwarf_dieoffset(die), 7439 ctxt.associate_die_to_type(dwarf_dieoffset(die), source, result);
7444 die_is_from_alt_di,
7445 result);
7446 return result; 7440 return result;
7447} 7441}
7448 7442
@@ -7565,9 +7559,6 @@ finish_member_function_reading(Dwarf_Die* die,
7565/// @param die the DIE to read information from. Must be either a 7559/// @param die the DIE to read information from. Must be either a
7566/// DW_TAG_structure_type or a DW_TAG_class_type. 7560/// DW_TAG_structure_type or a DW_TAG_class_type.
7567/// 7561///
7568/// @param is_in_alt_di true if @p die is in the alternate debug
7569/// sections, false otherwise.
7570///
7571/// @param is_struct wheter the class was declared as a struct. 7562/// @param is_struct wheter the class was declared as a struct.
7572/// 7563///
7573/// @param scope a pointer to the scope_decl* under which this class 7564/// @param scope a pointer to the scope_decl* under which this class
@@ -7588,7 +7579,6 @@ finish_member_function_reading(Dwarf_Die* die,
7588static class_decl_sptr 7579static class_decl_sptr
7589build_class_type_and_add_to_ir(read_context& ctxt, 7580build_class_type_and_add_to_ir(read_context& ctxt,
7590 Dwarf_Die* die, 7581 Dwarf_Die* die,
7591 bool is_in_alt_di,
7592 scope_decl* scope, 7582 scope_decl* scope,
7593 bool is_struct, 7583 bool is_struct,
7594 class_decl_sptr klass, 7584 class_decl_sptr klass,
@@ -7599,6 +7589,9 @@ build_class_type_and_add_to_ir(read_context& ctxt,
7599 if (!die) 7589 if (!die)
7600 return result; 7590 return result;
7601 7591
7592 die_source source;
7593 assert(ctxt.get_die_source(die, source));
7594
7602 unsigned tag = dwarf_tag(die); 7595 unsigned tag = dwarf_tag(die);
7603 7596
7604 if (tag != DW_TAG_class_type && tag != DW_TAG_structure_type) 7597 if (tag != DW_TAG_class_type && tag != DW_TAG_structure_type)
@@ -7606,8 +7599,8 @@ build_class_type_and_add_to_ir(read_context& ctxt,
7606 7599
7607 { 7600 {
7608 die_class_map_type::const_iterator i = 7601 die_class_map_type::const_iterator i =
7609 ctxt.die_wip_classes_map(is_in_alt_di).find(dwarf_dieoffset(die)); 7602 ctxt.die_wip_classes_map(source).find(dwarf_dieoffset(die));
7610 if (i != ctxt.die_wip_classes_map(is_in_alt_di).end()) 7603 if (i != ctxt.die_wip_classes_map(source).end())
7611 return i->second; 7604 return i->second;
7612 } 7605 }
7613 7606
@@ -7659,7 +7652,7 @@ build_class_type_and_add_to_ir(read_context& ctxt,
7659 result->set_is_declaration_only(false); 7652 result->set_is_declaration_only(false);
7660 } 7653 }
7661 7654
7662 ctxt.associate_die_to_type(dwarf_dieoffset(die), is_in_alt_di, result); 7655 ctxt.associate_die_to_type(dwarf_dieoffset(die), source, result);
7663 ctxt.maybe_schedule_declaration_only_class_for_resolution(result); 7656 ctxt.maybe_schedule_declaration_only_class_for_resolution(result);
7664 7657
7665 if (!has_child) 7658 if (!has_child)
@@ -7667,7 +7660,7 @@ build_class_type_and_add_to_ir(read_context& ctxt,
7667 // here. 7660 // here.
7668 return result; 7661 return result;
7669 7662
7670 ctxt.die_wip_classes_map(is_in_alt_di)[dwarf_dieoffset(die)] = result; 7663 ctxt.die_wip_classes_map(source)[dwarf_dieoffset(die)] = result;
7671 7664
7672 scope_decl_sptr scop = 7665 scope_decl_sptr scop =
7673 dynamic_pointer_cast<scope_decl>(res); 7666 dynamic_pointer_cast<scope_decl>(res);
@@ -7686,15 +7679,11 @@ build_class_type_and_add_to_ir(read_context& ctxt,
7686 result->set_is_declaration_only(false); 7679 result->set_is_declaration_only(false);
7687 7680
7688 Dwarf_Die type_die; 7681 Dwarf_Die type_die;
7689 bool type_die_is_in_alternate_debug_info = false; 7682 if (!die_die_attribute(&child, DW_AT_type, type_die))
7690 if (!die_die_attribute(&child, is_in_alt_di,
7691 DW_AT_type, type_die,
7692 type_die_is_in_alternate_debug_info))
7693 continue; 7683 continue;
7694 7684
7695 decl_base_sptr base_type = is_decl( 7685 decl_base_sptr base_type = is_decl(
7696 build_ir_node_from_die(ctxt, &type_die, 7686 build_ir_node_from_die(ctxt, &type_die,
7697 type_die_is_in_alternate_debug_info,
7698 called_from_public_decl, 7687 called_from_public_decl,
7699 where_offset)); 7688 where_offset));
7700 class_decl_sptr b = is_compatible_with_class_type(base_type); 7689 class_decl_sptr b = is_compatible_with_class_type(base_type);
@@ -7732,10 +7721,7 @@ build_class_type_and_add_to_ir(read_context& ctxt,
7732 || tag == DW_TAG_variable) 7721 || tag == DW_TAG_variable)
7733 { 7722 {
7734 Dwarf_Die type_die; 7723 Dwarf_Die type_die;
7735 bool type_die_is_in_alternate_debug_info = false; 7724 if (!die_die_attribute(&child, DW_AT_type, type_die))
7736 if (!die_die_attribute(&child, is_in_alt_di,
7737 DW_AT_type, type_die,
7738 type_die_is_in_alternate_debug_info))
7739 continue; 7725 continue;
7740 7726
7741 string n, m; 7727 string n, m;
@@ -7755,7 +7741,6 @@ build_class_type_and_add_to_ir(read_context& ctxt,
7755 7741
7756 decl_base_sptr ty = is_decl( 7742 decl_base_sptr ty = is_decl(
7757 build_ir_node_from_die(ctxt, &type_die, 7743 build_ir_node_from_die(ctxt, &type_die,
7758 type_die_is_in_alternate_debug_info,
7759 called_from_public_decl, 7744 called_from_public_decl,
7760 where_offset)); 7745 where_offset));
7761 type_base_sptr t = is_type(ty); 7746 type_base_sptr t = is_type(ty);
@@ -7786,16 +7771,13 @@ build_class_type_and_add_to_ir(read_context& ctxt,
7786 result->add_data_member(dm, access, is_laid_out, 7771 result->add_data_member(dm, access, is_laid_out,
7787 is_static, offset_in_bits); 7772 is_static, offset_in_bits);
7788 assert(has_scope(dm)); 7773 assert(has_scope(dm));
7789 ctxt.associate_die_to_decl(dwarf_dieoffset(&child), 7774 ctxt.associate_die_to_decl(dwarf_dieoffset(&child), source, dm);
7790 is_in_alt_di,
7791 dm);
7792 } 7775 }
7793 // Handle member functions; 7776 // Handle member functions;
7794 else if (tag == DW_TAG_subprogram) 7777 else if (tag == DW_TAG_subprogram)
7795 { 7778 {
7796 decl_base_sptr r = 7779 decl_base_sptr r =
7797 is_decl(build_ir_node_from_die(ctxt, &child, 7780 is_decl(build_ir_node_from_die(ctxt, &child,
7798 is_in_alt_di,
7799 result.get(), 7781 result.get(),
7800 called_from_public_decl, 7782 called_from_public_decl,
7801 where_offset)); 7783 where_offset));
@@ -7807,14 +7789,12 @@ build_class_type_and_add_to_ir(read_context& ctxt,
7807 7789
7808 finish_member_function_reading(&child, f, result, ctxt); 7790 finish_member_function_reading(&child, f, result, ctxt);
7809 7791
7810 ctxt.associate_die_to_decl(dwarf_dieoffset(&child), 7792 ctxt.associate_die_to_decl(dwarf_dieoffset(&child), source, f);
7811 is_in_alt_di, f);
7812 } 7793 }
7813 // Handle member types 7794 // Handle member types
7814 else if (is_type_die(&child)) 7795 else if (is_type_die(&child))
7815 decl_base_sptr td = 7796 decl_base_sptr td =
7816 is_decl(build_ir_node_from_die(ctxt, &child, is_in_alt_di, 7797 is_decl(build_ir_node_from_die(ctxt, &child, result.get(),
7817 result.get(),
7818 called_from_public_decl, 7798 called_from_public_decl,
7819 where_offset)); 7799 where_offset));
7820 } while (dwarf_siblingof(&child, &child) == 0); 7800 } while (dwarf_siblingof(&child, &child) == 0);
@@ -7824,13 +7804,13 @@ build_class_type_and_add_to_ir(read_context& ctxt,
7824 7804
7825 { 7805 {
7826 die_class_map_type::const_iterator i = 7806 die_class_map_type::const_iterator i =
7827 ctxt.die_wip_classes_map(is_in_alt_di).find(dwarf_dieoffset(die)); 7807 ctxt.die_wip_classes_map(source).find(dwarf_dieoffset(die));
7828 if (i != ctxt.die_wip_classes_map(is_in_alt_di).end()) 7808 if (i != ctxt.die_wip_classes_map(source).end())
7829 { 7809 {
7830 if (is_member_type(i->second)) 7810 if (is_member_type(i->second))
7831 set_member_access_specifier(res, 7811 set_member_access_specifier(res,
7832 get_member_access_specifier(i->second)); 7812 get_member_access_specifier(i->second));
7833 ctxt.die_wip_classes_map(is_in_alt_di).erase(i); 7813 ctxt.die_wip_classes_map(source).erase(i);
7834 } 7814 }
7835 } 7815 }
7836 7816
@@ -7845,9 +7825,6 @@ build_class_type_and_add_to_ir(read_context& ctxt,
7845/// 7825///
7846/// @param die the input DIE to read from. 7826/// @param die the input DIE to read from.
7847/// 7827///
7848/// @param die_is_in_alt_di true if @p is in alternate debug info
7849/// sections.
7850///
7851/// @param called_from_public_decl true if this function was called 7828/// @param called_from_public_decl true if this function was called
7852/// from a context where either a public function or a public variable 7829/// from a context where either a public function or a public variable
7853/// is being built. 7830/// is being built.
@@ -7861,7 +7838,6 @@ build_class_type_and_add_to_ir(read_context& ctxt,
7861static qualified_type_def_sptr 7838static qualified_type_def_sptr
7862build_qualified_type(read_context& ctxt, 7839build_qualified_type(read_context& ctxt,
7863 Dwarf_Die* die, 7840 Dwarf_Die* die,
7864 bool die_is_in_alt_di,
7865 bool called_from_public_decl, 7841 bool called_from_public_decl,
7866 size_t where_offset) 7842 size_t where_offset)
7867{ 7843{
@@ -7869,6 +7845,9 @@ build_qualified_type(read_context& ctxt,
7869 if (!die) 7845 if (!die)
7870 return result; 7846 return result;
7871 7847
7848 die_source source;
7849 assert(ctxt.get_die_source(die, source));
7850
7872 unsigned tag = dwarf_tag(die); 7851 unsigned tag = dwarf_tag(die);
7873 7852
7874 if (tag != DW_TAG_const_type 7853 if (tag != DW_TAG_const_type
@@ -7877,11 +7856,8 @@ build_qualified_type(read_context& ctxt,
7877 return result; 7856 return result;
7878 7857
7879 Dwarf_Die underlying_type_die; 7858 Dwarf_Die underlying_type_die;
7880 bool utype_is_in_alt_di = false;
7881 decl_base_sptr utype_decl; 7859 decl_base_sptr utype_decl;
7882 if (!die_die_attribute(die, die_is_in_alt_di, DW_AT_type, 7860 if (!die_die_attribute(die, DW_AT_type, underlying_type_die))
7883 underlying_type_die,
7884 utype_is_in_alt_di))
7885 // So, if no DW_AT_type is present, then this means (if we are 7861 // So, if no DW_AT_type is present, then this means (if we are
7886 // looking at a debug info emitted by GCC) that we are looking 7862 // looking at a debug info emitted by GCC) that we are looking
7887 // at a qualified void type. 7863 // at a qualified void type.
@@ -7889,7 +7865,6 @@ build_qualified_type(read_context& ctxt,
7889 7865
7890 if (!utype_decl) 7866 if (!utype_decl)
7891 utype_decl = is_decl(build_ir_node_from_die(ctxt, &underlying_type_die, 7867 utype_decl = is_decl(build_ir_node_from_die(ctxt, &underlying_type_die,
7892 utype_is_in_alt_di,
7893 called_from_public_decl, 7868 called_from_public_decl,
7894 where_offset)); 7869 where_offset));
7895 if (!utype_decl) 7870 if (!utype_decl)
@@ -7898,7 +7873,7 @@ build_qualified_type(read_context& ctxt,
7898 // The call to build_ir_node_from_die() could have triggered the 7873 // The call to build_ir_node_from_die() could have triggered the
7899 // creation of the type for this DIE. In that case, just return it. 7874 // creation of the type for this DIE. In that case, just return it.
7900 if (type_base_sptr t = ctxt.lookup_type_from_die_offset(dwarf_dieoffset(die), 7875 if (type_base_sptr t = ctxt.lookup_type_from_die_offset(dwarf_dieoffset(die),
7901 die_is_in_alt_di)) 7876 source))
7902 { 7877 {
7903 result = is_qualified_type(t); 7878 result = is_qualified_type(t);
7904 assert(result); 7879 assert(result);
@@ -7921,9 +7896,7 @@ build_qualified_type(read_context& ctxt,
7921 qualified_type_def::CV_RESTRICT, 7896 qualified_type_def::CV_RESTRICT,
7922 location())); 7897 location()));
7923 7898
7924 ctxt.associate_die_to_type(dwarf_dieoffset(die), 7899 ctxt.associate_die_to_type(dwarf_dieoffset(die), source, result);
7925 die_is_in_alt_di,
7926 result);
7927 7900
7928 return result; 7901 return result;
7929} 7902}
@@ -7975,9 +7948,6 @@ maybe_strip_qualification(const qualified_type_def_sptr t)
7975/// 7948///
7976/// @param die the DIE to read information from. 7949/// @param die the DIE to read information from.
7977/// 7950///
7978/// @param die_is_in_alt_di true if @p is in alternate debug info
7979/// sections, false otherwise.
7980///
7981/// @param called_from_public_decl true if this function was called 7951/// @param called_from_public_decl true if this function was called
7982/// from a context where either a public function or a public variable 7952/// from a context where either a public function or a public variable
7983/// is being built. 7953/// is being built.
@@ -7991,7 +7961,6 @@ maybe_strip_qualification(const qualified_type_def_sptr t)
7991static pointer_type_def_sptr 7961static pointer_type_def_sptr
7992build_pointer_type_def(read_context& ctxt, 7962build_pointer_type_def(read_context& ctxt,
7993 Dwarf_Die* die, 7963 Dwarf_Die* die,
7994 bool die_is_in_alt_di,
7995 bool called_from_public_decl, 7964 bool called_from_public_decl,
7996 size_t where_offset) 7965 size_t where_offset)
7997{ 7966{
@@ -8000,6 +7969,9 @@ build_pointer_type_def(read_context& ctxt,
8000 if (!die) 7969 if (!die)
8001 return result; 7970 return result;
8002 7971
7972 die_source source;
7973 assert(ctxt.get_die_source(die, source));
7974
8003 unsigned tag = dwarf_tag(die); 7975 unsigned tag = dwarf_tag(die);
8004 if (tag != DW_TAG_pointer_type) 7976 if (tag != DW_TAG_pointer_type)
8005 return result; 7977 return result;
@@ -8007,10 +7979,7 @@ build_pointer_type_def(read_context& ctxt,
8007 type_or_decl_base_sptr utype_decl; 7979 type_or_decl_base_sptr utype_decl;
8008 Dwarf_Die underlying_type_die; 7980 Dwarf_Die underlying_type_die;
8009 bool has_underlying_type_die = false; 7981 bool has_underlying_type_die = false;
8010 bool utype_die_is_in_alt_di = false; 7982 if (!die_die_attribute(die, DW_AT_type, underlying_type_die))
8011 if (!die_die_attribute(die, die_is_in_alt_di, DW_AT_type,
8012 underlying_type_die,
8013 utype_die_is_in_alt_di))
8014 // If the DW_AT_type attribute is missing, that means we are 7983 // If the DW_AT_type attribute is missing, that means we are
8015 // looking at a pointer to "void". 7984 // looking at a pointer to "void".
8016 utype_decl = build_ir_node_for_void_type(ctxt); 7985 utype_decl = build_ir_node_for_void_type(ctxt);
@@ -8019,7 +7988,6 @@ build_pointer_type_def(read_context& ctxt,
8019 7988
8020 if (!utype_decl && has_underlying_type_die) 7989 if (!utype_decl && has_underlying_type_die)
8021 utype_decl = build_ir_node_from_die(ctxt, &underlying_type_die, 7990 utype_decl = build_ir_node_from_die(ctxt, &underlying_type_die,
8022 utype_die_is_in_alt_di,
8023 called_from_public_decl, 7991 called_from_public_decl,
8024 where_offset); 7992 where_offset);
8025 if (!utype_decl) 7993 if (!utype_decl)
@@ -8028,7 +7996,7 @@ build_pointer_type_def(read_context& ctxt,
8028 // The call to build_ir_node_from_die() could have triggered the 7996 // The call to build_ir_node_from_die() could have triggered the
8029 // creation of the type for this DIE. In that case, just return it. 7997 // creation of the type for this DIE. In that case, just return it.
8030 if (type_base_sptr t = ctxt.lookup_type_from_die_offset(dwarf_dieoffset(die), 7998 if (type_base_sptr t = ctxt.lookup_type_from_die_offset(dwarf_dieoffset(die),
8031 die_is_in_alt_di)) 7999 source))
8032 { 8000 {
8033 result = is_pointer_type(t); 8001 result = is_pointer_type(t);
8034 assert(result); 8002 assert(result);
@@ -8051,13 +8019,9 @@ build_pointer_type_def(read_context& ctxt,
8051 // of the current translation unit. 8019 // of the current translation unit.
8052 assert((size_t) ctxt.cur_tu()->get_address_size() == size); 8020 assert((size_t) ctxt.cur_tu()->get_address_size() == size);
8053 8021
8054 result.reset(new pointer_type_def(utype, size, 8022 result.reset(new pointer_type_def(utype, size, /*alignment=*/0, location()));
8055 /*alignment=*/0,
8056 location()));
8057 assert(result->get_pointed_to_type()); 8023 assert(result->get_pointed_to_type());
8058 ctxt.associate_die_to_type(dwarf_dieoffset(die), 8024 ctxt.associate_die_to_type(dwarf_dieoffset(die), source, result);
8059 die_is_in_alt_di,
8060 result);
8061 return result; 8025 return result;
8062} 8026}
8063 8027
@@ -8068,9 +8032,6 @@ build_pointer_type_def(read_context& ctxt,
8068/// 8032///
8069/// @param die the DIE to read from. 8033/// @param die the DIE to read from.
8070/// 8034///
8071/// @param die_is_in_alt_di true if @p die is from alternate debug
8072/// info section, false otherwise.
8073///
8074/// @param called_from_public_decl true if this function was called 8035/// @param called_from_public_decl true if this function was called
8075/// from a context where either a public function or a public variable 8036/// from a context where either a public function or a public variable
8076/// is being built. 8037/// is being built.
@@ -8084,7 +8045,6 @@ build_pointer_type_def(read_context& ctxt,
8084static reference_type_def_sptr 8045static reference_type_def_sptr
8085build_reference_type(read_context& ctxt, 8046build_reference_type(read_context& ctxt,
8086 Dwarf_Die* die, 8047 Dwarf_Die* die,
8087 bool die_is_from_alt_di,
8088 bool called_from_public_decl, 8048 bool called_from_public_decl,
8089 size_t where_offset) 8049 size_t where_offset)
8090{ 8050{
@@ -8093,21 +8053,20 @@ build_reference_type(read_context& ctxt,
8093 if (!die) 8053 if (!die)
8094 return result; 8054 return result;
8095 8055
8056 die_source source;
8057 assert(ctxt.get_die_source(die, source));
8058
8096 unsigned tag = dwarf_tag(die); 8059 unsigned tag = dwarf_tag(die);
8097 if (tag != DW_TAG_reference_type 8060 if (tag != DW_TAG_reference_type
8098 && tag != DW_TAG_rvalue_reference_type) 8061 && tag != DW_TAG_rvalue_reference_type)
8099 return result; 8062 return result;
8100 8063
8101 Dwarf_Die underlying_type_die; 8064 Dwarf_Die underlying_type_die;
8102 bool utype_is_in_alt_di = false; 8065 if (!die_die_attribute(die, DW_AT_type, underlying_type_die))
8103 if (!die_die_attribute(die, die_is_from_alt_di,
8104 DW_AT_type, underlying_type_die,
8105 utype_is_in_alt_di))
8106 return result; 8066 return result;
8107 8067
8108 type_or_decl_base_sptr utype_decl = 8068 type_or_decl_base_sptr utype_decl =
8109 build_ir_node_from_die(ctxt, &underlying_type_die, 8069 build_ir_node_from_die(ctxt, &underlying_type_die,
8110 utype_is_in_alt_di,
8111 called_from_public_decl, 8070 called_from_public_decl,
8112 where_offset); 8071 where_offset);
8113 if (!utype_decl) 8072 if (!utype_decl)
@@ -8116,7 +8075,7 @@ build_reference_type(read_context& ctxt,
8116 // The call to build_ir_node_from_die() could have triggered the 8075 // The call to build_ir_node_from_die() could have triggered the
8117 // creation of the type for this DIE. In that case, just return it. 8076 // creation of the type for this DIE. In that case, just return it.
8118 if (type_base_sptr t = ctxt.lookup_type_from_die_offset(dwarf_dieoffset(die), 8077 if (type_base_sptr t = ctxt.lookup_type_from_die_offset(dwarf_dieoffset(die),
8119 die_is_from_alt_di)) 8078 source))
8120 { 8079 {
8121 result = is_reference_type(t); 8080 result = is_reference_type(t);
8122 assert(result); 8081 assert(result);
@@ -8142,9 +8101,7 @@ build_reference_type(read_context& ctxt,
8142 result.reset(new reference_type_def(utype, is_lvalue, size, 8101 result.reset(new reference_type_def(utype, is_lvalue, size,
8143 /*alignment=*/0, 8102 /*alignment=*/0,
8144 location())); 8103 location()));
8145 ctxt.associate_die_to_type(dwarf_dieoffset(die), 8104 ctxt.associate_die_to_type(dwarf_dieoffset(die), source, result);
8146 die_is_from_alt_di,
8147 result);
8148 return result; 8105 return result;
8149} 8106}
8150 8107
@@ -8154,9 +8111,6 @@ build_reference_type(read_context& ctxt,
8154/// 8111///
8155/// @param die the DIE to read from. 8112/// @param die the DIE to read from.
8156/// 8113///
8157/// @param die_is_from_alt_di true if @p is from alternate debug
8158/// info.
8159///
8160/// @param is_method points to a class declaration iff we're 8114/// @param is_method points to a class declaration iff we're
8161/// building the type for a method. 8115/// building the type for a method.
8162/// 8116///
@@ -8169,7 +8123,6 @@ build_reference_type(read_context& ctxt,
8169static function_type_sptr 8123static function_type_sptr
8170build_function_type(read_context& ctxt, 8124build_function_type(read_context& ctxt,
8171 Dwarf_Die* die, 8125 Dwarf_Die* die,
8172 bool die_is_from_alt_di,
8173 class_decl_sptr is_method, 8126 class_decl_sptr is_method,
8174 size_t where_offset) 8127 size_t where_offset)
8175{ 8128{
@@ -8181,6 +8134,9 @@ build_function_type(read_context& ctxt,
8181 assert(dwarf_tag(die) == DW_TAG_subroutine_type 8134 assert(dwarf_tag(die) == DW_TAG_subroutine_type
8182 || dwarf_tag(die) == DW_TAG_subprogram); 8135 || dwarf_tag(die) == DW_TAG_subprogram);
8183 8136
8137 die_source source;
8138 assert(ctxt.get_die_source(die, source));
8139
8184 decl_base_sptr type_decl; 8140 decl_base_sptr type_decl;
8185 8141
8186 translation_unit_sptr tu = ctxt.cur_tu(); 8142 translation_unit_sptr tu = ctxt.cur_tu();
@@ -8189,7 +8145,7 @@ build_function_type(read_context& ctxt,
8189 // The call to build_ir_node_from_die() could have triggered the 8145 // The call to build_ir_node_from_die() could have triggered the
8190 // creation of the type for this DIE. In that case, just return it. 8146 // creation of the type for this DIE. In that case, just return it.
8191 if (type_base_sptr t = ctxt.lookup_type_from_die_offset(dwarf_dieoffset(die), 8147 if (type_base_sptr t = ctxt.lookup_type_from_die_offset(dwarf_dieoffset(die),
8192 die_is_from_alt_di)) 8148 source))
8193 { 8149 {
8194 result = is_function_type(t); 8150 result = is_function_type(t);
8195 assert(result); 8151 assert(result);
@@ -8208,19 +8164,15 @@ build_function_type(read_context& ctxt,
8208 /*alignment=*/0)); 8164 /*alignment=*/0));
8209 tu->bind_function_type_life_time(result); 8165 tu->bind_function_type_life_time(result);
8210 ctxt.associate_die_to_type(dwarf_dieoffset(die), 8166 ctxt.associate_die_to_type(dwarf_dieoffset(die),
8211 die_is_from_alt_di, 8167 source, result);
8212 result); 8168 ctxt.die_wip_function_types_map(source)[dwarf_dieoffset(die)] =
8213 ctxt.die_wip_function_types_map(die_is_from_alt_di)[dwarf_dieoffset(die)] =
8214 result; 8169 result;
8215 8170
8216 decl_base_sptr return_type_decl; 8171 decl_base_sptr return_type_decl;
8217 Dwarf_Die ret_type_die; 8172 Dwarf_Die ret_type_die;
8218 bool ret_type_die_is_in_alternate_debug_info = false; 8173 if (die_die_attribute(die, DW_AT_type, ret_type_die))
8219 if (die_die_attribute(die, die_is_from_alt_di, DW_AT_type, ret_type_die,
8220 ret_type_die_is_in_alternate_debug_info))
8221 return_type_decl = 8174 return_type_decl =
8222 is_decl(build_ir_node_from_die(ctxt, &ret_type_die, 8175 is_decl(build_ir_node_from_die(ctxt, &ret_type_die,
8223 ret_type_die_is_in_alternate_debug_info,
8224 /*called_from_public_decl=*/true, 8176 /*called_from_public_decl=*/true,
8225 where_offset)); 8177 where_offset));
8226 if (!return_type_decl) 8178 if (!return_type_decl)
@@ -8247,13 +8199,9 @@ build_function_type(read_context& ctxt,
8247 bool is_artificial = die_is_artificial(&child); 8199 bool is_artificial = die_is_artificial(&child);
8248 decl_base_sptr parm_type_decl; 8200 decl_base_sptr parm_type_decl;
8249 Dwarf_Die parm_type_die; 8201 Dwarf_Die parm_type_die;
8250 bool parm_type_die_is_in_alt_di = false; 8202 if (die_die_attribute(&child, DW_AT_type, parm_type_die))
8251 if (die_die_attribute(&child, die_is_from_alt_di,
8252 DW_AT_type, parm_type_die,
8253 parm_type_die_is_in_alt_di))
8254 parm_type_decl = 8203 parm_type_decl =
8255 is_decl(build_ir_node_from_die(ctxt, &parm_type_die, 8204 is_decl(build_ir_node_from_die(ctxt, &parm_type_die,
8256 parm_type_die_is_in_alt_di,
8257 /*called_from_public_decl=*/true, 8205 /*called_from_public_decl=*/true,
8258 where_offset)); 8206 where_offset));
8259 if (!parm_type_decl) 8207 if (!parm_type_decl)
@@ -8293,10 +8241,10 @@ build_function_type(read_context& ctxt,
8293 8241
8294 { 8242 {
8295 die_function_type_map_type::const_iterator i = 8243 die_function_type_map_type::const_iterator i =
8296 ctxt.die_wip_function_types_map(die_is_from_alt_di). 8244 ctxt.die_wip_function_types_map(source).
8297 find(dwarf_dieoffset(die)); 8245 find(dwarf_dieoffset(die));
8298 if (i != ctxt.die_wip_function_types_map(die_is_from_alt_di).end()) 8246 if (i != ctxt.die_wip_function_types_map(source).end())
8299 ctxt.die_wip_function_types_map(die_is_from_alt_di).erase(i); 8247 ctxt.die_wip_function_types_map(source).erase(i);
8300 } 8248 }
8301 8249
8302 return result; 8250 return result;
@@ -8308,9 +8256,6 @@ build_function_type(read_context& ctxt,
8308/// 8256///
8309/// @param die the DIE to read from. 8257/// @param die the DIE to read from.
8310/// 8258///
8311/// @param die_is_from_alt_di true if @p is from alternate debug
8312/// info.
8313///
8314/// @param called_from_public_decl true if this function was called 8259/// @param called_from_public_decl true if this function was called
8315/// from a context where either a public function or a public variable 8260/// from a context where either a public function or a public variable
8316/// is being built. 8261/// is being built.
@@ -8324,7 +8269,6 @@ build_function_type(read_context& ctxt,
8324static array_type_def_sptr 8269static array_type_def_sptr
8325build_array_type(read_context& ctxt, 8270build_array_type(read_context& ctxt,
8326 Dwarf_Die* die, 8271 Dwarf_Die* die,
8327 bool die_is_from_alt_di,
8328 bool called_from_public_decl, 8272 bool called_from_public_decl,
8329 size_t where_offset) 8273 size_t where_offset)
8330{ 8274{
@@ -8333,6 +8277,9 @@ build_array_type(read_context& ctxt,
8333 if (!die) 8277 if (!die)
8334 return result; 8278 return result;
8335 8279
8280 die_source source;
8281 assert(ctxt.get_die_source(die, source));
8282
8336 unsigned tag = dwarf_tag(die); 8283 unsigned tag = dwarf_tag(die);
8337 if (tag != DW_TAG_array_type) 8284 if (tag != DW_TAG_array_type)
8338 return result; 8285 return result;
@@ -8340,11 +8287,8 @@ build_array_type(read_context& ctxt,
8340 decl_base_sptr type_decl; 8287 decl_base_sptr type_decl;
8341 Dwarf_Die type_die; 8288 Dwarf_Die type_die;
8342 8289
8343 bool utype_is_in_alt_di = false; 8290 if (die_die_attribute(die, DW_AT_type, type_die))
8344 if (die_die_attribute(die, die_is_from_alt_di, DW_AT_type,
8345 type_die, utype_is_in_alt_di))
8346 type_decl = is_decl(build_ir_node_from_die(ctxt, &type_die, 8291 type_decl = is_decl(build_ir_node_from_die(ctxt, &type_die,
8347 utype_is_in_alt_di,
8348 called_from_public_decl, 8292 called_from_public_decl,
8349 where_offset)); 8293 where_offset));
8350 if (!type_decl) 8294 if (!type_decl)
@@ -8353,7 +8297,7 @@ build_array_type(read_context& ctxt,
8353 // The call to build_ir_node_from_die() could have triggered the 8297 // The call to build_ir_node_from_die() could have triggered the
8354 // creation of the type for this DIE. In that case, just return it. 8298 // creation of the type for this DIE. In that case, just return it.
8355 if (type_base_sptr t = ctxt.lookup_type_from_die_offset(dwarf_dieoffset(die), 8299 if (type_base_sptr t = ctxt.lookup_type_from_die_offset(dwarf_dieoffset(die),
8356 die_is_from_alt_di)) 8300 source))
8357 { 8301 {
8358 result = is_array_type(t); 8302 result = is_array_type(t);
8359 assert(result); 8303 assert(result);
@@ -8442,9 +8386,6 @@ build_array_type(read_context& ctxt,
8442/// 8386///
8443/// @param die the DIE to read from. 8387/// @param die the DIE to read from.
8444/// 8388///
8445/// @param die_is_from_alt_di true if @p die is from alternate debug
8446/// info sections, false otherwise.
8447///
8448/// @param called_from_public_decl true if this function was called 8389/// @param called_from_public_decl true if this function was called
8449/// from a context where either a public function or a public variable 8390/// from a context where either a public function or a public variable
8450/// is being built. 8391/// is being built.
@@ -8458,7 +8399,6 @@ build_array_type(read_context& ctxt,
8458static typedef_decl_sptr 8399static typedef_decl_sptr
8459build_typedef_type(read_context& ctxt, 8400build_typedef_type(read_context& ctxt,
8460 Dwarf_Die* die, 8401 Dwarf_Die* die,
8461 bool die_is_from_alt_di,
8462 bool called_from_public_decl, 8402 bool called_from_public_decl,
8463 size_t where_offset) 8403 size_t where_offset)
8464{ 8404{
@@ -8467,20 +8407,19 @@ build_typedef_type(read_context& ctxt,
8467 if (!die) 8407 if (!die)
8468 return result; 8408 return result;
8469 8409
8410 die_source source;
8411 assert(ctxt.get_die_source(die, source));
8412
8470 unsigned tag = dwarf_tag(die); 8413 unsigned tag = dwarf_tag(die);
8471 if (tag != DW_TAG_typedef) 8414 if (tag != DW_TAG_typedef)
8472 return result; 8415 return result;
8473 8416
8474 Dwarf_Die underlying_type_die; 8417 Dwarf_Die underlying_type_die;
8475 bool utype_is_in_alternate_di = false; 8418 if (!die_die_attribute(die, DW_AT_type, underlying_type_die))
8476 if (!die_die_attribute(die, die_is_from_alt_di,
8477 DW_AT_type, underlying_type_die,
8478 utype_is_in_alternate_di))
8479 return result; 8419 return result;
8480 8420
8481 decl_base_sptr utype_decl = 8421 decl_base_sptr utype_decl =
8482 is_decl(build_ir_node_from_die(ctxt, &underlying_type_die, 8422 is_decl(build_ir_node_from_die(ctxt, &underlying_type_die,
8483 utype_is_in_alternate_di,
8484 called_from_public_decl, 8423 called_from_public_decl,
8485 where_offset)); 8424 where_offset));
8486 if (!utype_decl) 8425 if (!utype_decl)
@@ -8489,7 +8428,7 @@ build_typedef_type(read_context& ctxt,
8489 // The call to build_ir_node_from_die() could have triggered the 8428 // The call to build_ir_node_from_die() could have triggered the
8490 // creation of the type for this DIE. In that case, just return it. 8429 // creation of the type for this DIE. In that case, just return it.
8491 if (type_base_sptr t = ctxt.lookup_type_from_die_offset(dwarf_dieoffset(die), 8430 if (type_base_sptr t = ctxt.lookup_type_from_die_offset(dwarf_dieoffset(die),
8492 die_is_from_alt_di)) 8431 source))
8493 { 8432 {
8494 result = is_typedef(t); 8433 result = is_typedef(t);
8495 assert(result); 8434 assert(result);
@@ -8504,9 +8443,7 @@ build_typedef_type(read_context& ctxt,
8504 die_loc_and_name(ctxt, die, loc, name, linkage_name); 8443 die_loc_and_name(ctxt, die, loc, name, linkage_name);
8505 8444
8506 result.reset(new typedef_decl(name, utype, loc, linkage_name)); 8445 result.reset(new typedef_decl(name, utype, loc, linkage_name));
8507 ctxt.associate_die_to_type(dwarf_dieoffset(die), 8446 ctxt.associate_die_to_type(dwarf_dieoffset(die), source, result);
8508 die_is_from_alt_di,
8509 result);
8510 return result; 8447 return result;
8511} 8448}
8512 8449
@@ -8514,10 +8451,7 @@ build_typedef_type(read_context& ctxt,
8514/// 8451///
8515/// @param ctxt the read context to use. 8452/// @param ctxt the read context to use.
8516/// 8453///
8517/// @param die the DIE to read from to build the @ref var_decl. 8454/// @param die the DIE representing the variable we are looking at.
8518///
8519/// @param die_is_from_alt_di true if @p die is from alternate debug
8520/// ifo sections, false otherwise.
8521/// 8455///
8522/// @param where_offset the offset of the DIE where we are "logically" 8456/// @param where_offset the offset of the DIE where we are "logically"
8523/// positionned at, in the DIE tree. This is useful when @p die is 8457/// positionned at, in the DIE tree. This is useful when @p die is
@@ -8534,7 +8468,6 @@ build_typedef_type(read_context& ctxt,
8534static var_decl_sptr 8468static var_decl_sptr
8535build_var_decl(read_context& ctxt, 8469build_var_decl(read_context& ctxt,
8536 Dwarf_Die *die, 8470 Dwarf_Die *die,
8537 bool die_is_from_alt_di,
8538 size_t where_offset, 8471 size_t where_offset,
8539 var_decl_sptr result = var_decl_sptr()) 8472 var_decl_sptr result = var_decl_sptr())
8540{ 8473{
@@ -8545,15 +8478,15 @@ build_var_decl(read_context& ctxt,
8545 if (!die_is_public_decl(die)) 8478 if (!die_is_public_decl(die))
8546 return result; 8479 return result;
8547 8480
8481 die_source source;
8482 assert(ctxt.get_die_source(die, source));
8483
8548 type_base_sptr type; 8484 type_base_sptr type;
8549 Dwarf_Die type_die; 8485 Dwarf_Die type_die;
8550 bool utype_is_in_alt_di = false; 8486 if (die_die_attribute(die, DW_AT_type, type_die))
8551 if (die_die_attribute(die, die_is_from_alt_di,
8552 DW_AT_type, type_die, utype_is_in_alt_di))
8553 { 8487 {
8554 decl_base_sptr ty = 8488 decl_base_sptr ty =
8555 is_decl(build_ir_node_from_die(ctxt, &type_die, 8489 is_decl(build_ir_node_from_die(ctxt, &type_die,
8556 utype_is_in_alt_di,
8557 /*called_from_public_decl=*/true, 8490 /*called_from_public_decl=*/true,
8558 where_offset)); 8491 where_offset));
8559 if (!ty) 8492 if (!ty)
@@ -8612,9 +8545,6 @@ build_var_decl(read_context& ctxt,
8612/// 8545///
8613/// @param die the DW_TAG_subprogram DIE to read from. 8546/// @param die the DW_TAG_subprogram DIE to read from.
8614/// 8547///
8615/// @param is_in_alt_di true if @p die is a DIE from the alternate
8616/// debug info sections.
8617///
8618/// @param where_offset the offset of the DIE where we are "logically" 8548/// @param where_offset the offset of the DIE where we are "logically"
8619/// positionned at, in the DIE tree. This is useful when @p die is 8549/// positionned at, in the DIE tree. This is useful when @p die is
8620/// e.g, DW_TAG_partial_unit that can be included in several places in 8550/// e.g, DW_TAG_partial_unit that can be included in several places in
@@ -8625,7 +8555,6 @@ build_var_decl(read_context& ctxt,
8625static function_decl_sptr 8555static function_decl_sptr
8626build_function_decl(read_context& ctxt, 8556build_function_decl(read_context& ctxt,
8627 Dwarf_Die* die, 8557 Dwarf_Die* die,
8628 bool is_in_alt_di,
8629 size_t where_offset, 8558 size_t where_offset,
8630 function_decl_sptr fn) 8559 function_decl_sptr fn)
8631{ 8560{
@@ -8634,6 +8563,9 @@ build_function_decl(read_context& ctxt,
8634 return result; 8563 return result;
8635 assert(dwarf_tag(die) == DW_TAG_subprogram); 8564 assert(dwarf_tag(die) == DW_TAG_subprogram);
8636 8565
8566 die_source source;
8567 assert(ctxt.get_die_source(die, source));
8568
8637 if (!die_is_public_decl(die)) 8569 if (!die_is_public_decl(die))
8638 return result; 8570 return result;
8639 8571
@@ -8646,8 +8578,7 @@ build_function_decl(read_context& ctxt,
8646 8578
8647 size_t is_inline = die_is_declared_inline(die); 8579 size_t is_inline = die_is_declared_inline(die);
8648 class_decl_sptr is_method = 8580 class_decl_sptr is_method =
8649 dynamic_pointer_cast<class_decl>(get_scope_for_die(ctxt, die, is_in_alt_di, 8581 dynamic_pointer_cast<class_decl>(get_scope_for_die(ctxt, die, true, where_offset));
8650 true, where_offset));
8651 8582
8652 if (result) 8583 if (result)
8653 { 8584 {
@@ -8665,10 +8596,7 @@ build_function_decl(read_context& ctxt,
8665 } 8596 }
8666 else 8597 else
8667 { 8598 {
8668 function_type_sptr fn_type(build_function_type(ctxt, 8599 function_type_sptr fn_type(build_function_type(ctxt, die, is_method,
8669 die,
8670 is_in_alt_di,
8671 is_method,
8672 where_offset)); 8600 where_offset));
8673 8601
8674 result.reset(is_method 8602 result.reset(is_method
@@ -8701,7 +8629,7 @@ build_function_decl(read_context& ctxt,
8701 } 8629 }
8702 8630
8703 Dwarf_Off die_offset = dwarf_dieoffset(die); 8631 Dwarf_Off die_offset = dwarf_dieoffset(die);
8704 ctxt.associate_die_to_type(die_offset, is_in_alt_di, result->get_type()); 8632 ctxt.associate_die_to_type(die_offset, source, result->get_type());
8705 8633
8706 if (symbol_updated 8634 if (symbol_updated
8707 && fn 8635 && fn
@@ -8770,7 +8698,7 @@ read_debug_info_into_corpus(read_context& ctxt)
8770 if (ctxt.do_log()) 8698 if (ctxt.do_log())
8771 cerr << "building die -> parent maps ..."; 8699 cerr << "building die -> parent maps ...";
8772 8700
8773 build_die_parent_maps(ctxt); 8701 ctxt.build_die_parent_maps();
8774 8702
8775 if (ctxt.do_log()) 8703 if (ctxt.do_log())
8776 cerr << " DONE@" << ctxt.current_corpus()->get_path() << "\n"; 8704 cerr << " DONE@" << ctxt.current_corpus()->get_path() << "\n";
@@ -8864,16 +8792,16 @@ read_debug_info_into_corpus(read_context& ctxt)
8864/// read_context::associate_die_to_type() prior to calling this 8792/// read_context::associate_die_to_type() prior to calling this
8865/// function. 8793/// function.
8866/// 8794///
8867/// @param in_alt_di true if the DIE represented by @p die_offset 8795/// @param die_source where the DIE represented by @p die_offset comes
8868/// comes from the alternate debug info section. 8796/// from.
8869/// 8797///
8870/// @param ctxt the @ref read_context to use. 8798/// @param ctxt the @ref read_context to use.
8871static void 8799static void
8872maybe_canonicalize_type(Dwarf_Off die_offset, 8800maybe_canonicalize_type(Dwarf_Off die_offset,
8873 bool in_alt_di, 8801 die_source source,
8874 read_context& ctxt) 8802 read_context& ctxt)
8875{ 8803{
8876 type_base_sptr t = ctxt.lookup_type_from_die_offset(die_offset, in_alt_di); 8804 type_base_sptr t = ctxt.lookup_type_from_die_offset(die_offset, source);
8877 assert(t); 8805 assert(t);
8878 8806
8879 if (class_decl_sptr klass = 8807 if (class_decl_sptr klass =
@@ -8884,11 +8812,11 @@ maybe_canonicalize_type(Dwarf_Off die_offset,
8884 // be able to able detect it here (thinking about classes that are 8812 // be able to able detect it here (thinking about classes that are
8885 // work-in-progress, or classes that might be later amended by 8813 // work-in-progress, or classes that might be later amended by
8886 // some DWARF construct). So we err on the safe side. 8814 // some DWARF construct). So we err on the safe side.
8887 ctxt.schedule_type_for_late_canonicalization(die_offset, in_alt_di); 8815 ctxt.schedule_type_for_late_canonicalization(die_offset, source);
8888 else if ((is_function_type(t) 8816 else if ((is_function_type(t)
8889 && ctxt.is_wip_function_type_die_offset(die_offset, in_alt_di)) 8817 && ctxt.is_wip_function_type_die_offset(die_offset, source))
8890 || type_has_non_canonicalized_subtype(t)) 8818 || type_has_non_canonicalized_subtype(t))
8891 ctxt.schedule_type_for_late_canonicalization(die_offset, in_alt_di); 8819 ctxt.schedule_type_for_late_canonicalization(die_offset, source);
8892 else 8820 else
8893 canonicalize(t); 8821 canonicalize(t);
8894} 8822}
@@ -8922,9 +8850,6 @@ maybe_set_member_type_access_specifier(decl_base_sptr member_type_declaration,
8922/// 8850///
8923/// @param die the DIE to consider. 8851/// @param die the DIE to consider.
8924/// 8852///
8925/// @param die_is_from_alt_di true if @p die is a DIE coming from the
8926/// alternate debug info sections, false otherwise.
8927///
8928/// @param scope the scope under which the resulting IR node has to be 8853/// @param scope the scope under which the resulting IR node has to be
8929/// added. 8854/// added.
8930/// 8855///
@@ -8945,7 +8870,6 @@ maybe_set_member_type_access_specifier(decl_base_sptr member_type_declaration,
8945static type_or_decl_base_sptr 8870static type_or_decl_base_sptr
8946build_ir_node_from_die(read_context& ctxt, 8871build_ir_node_from_die(read_context& ctxt,
8947 Dwarf_Die* die, 8872 Dwarf_Die* die,
8948 bool die_is_from_alt_di,
8949 scope_decl* scope, 8873 scope_decl* scope,
8950 bool called_from_public_decl, 8874 bool called_from_public_decl,
8951 size_t where_offset) 8875 size_t where_offset)
@@ -8970,17 +8894,18 @@ build_ir_node_from_die(read_context& ctxt,
8970 return result; 8894 return result;
8971 } 8895 }
8972 8896
8897 die_source source_of_die;
8898 assert(ctxt.get_die_source(die, source_of_die));
8899
8973 if (result = ctxt.lookup_decl_from_die_offset(dwarf_dieoffset(die), 8900 if (result = ctxt.lookup_decl_from_die_offset(dwarf_dieoffset(die),
8974 die_is_from_alt_di)) 8901 source_of_die))
8975 return result; 8902 return result;
8976 8903
8977 switch (tag) 8904 switch (tag)
8978 { 8905 {
8979 // Type DIEs we support. 8906 // Type DIEs we support.
8980 case DW_TAG_base_type: 8907 case DW_TAG_base_type:
8981 if (type_decl_sptr t = build_type_decl(ctxt, 8908 if (type_decl_sptr t = build_type_decl(ctxt, die))
8982 die_is_from_alt_di,
8983 die))
8984 { 8909 {
8985 result = add_decl_to_scope(t, ctxt.cur_tu()->get_global_scope()); 8910 result = add_decl_to_scope(t, ctxt.cur_tu()->get_global_scope());
8986 canonicalize(t); 8911 canonicalize(t);
@@ -8989,16 +8914,14 @@ build_ir_node_from_die(read_context& ctxt,
8989 8914
8990 case DW_TAG_typedef: 8915 case DW_TAG_typedef:
8991 { 8916 {
8992 typedef_decl_sptr t = build_typedef_type(ctxt, die, die_is_from_alt_di, 8917 typedef_decl_sptr t = build_typedef_type(ctxt, die,
8993 called_from_public_decl, 8918 called_from_public_decl,
8994 where_offset); 8919 where_offset);
8995 result = add_decl_to_scope(t, scope); 8920 result = add_decl_to_scope(t, scope);
8996 if (result) 8921 if (result)
8997 { 8922 {
8998 maybe_set_member_type_access_specifier(is_decl(result), die); 8923 maybe_set_member_type_access_specifier(is_decl(result), die);
8999 maybe_canonicalize_type(dwarf_dieoffset(die), 8924 maybe_canonicalize_type(dwarf_dieoffset(die), source_of_die, ctxt);
9000 die_is_from_alt_di,
9001 ctxt);
9002 } 8925 }
9003 } 8926 }
9004 break; 8927 break;
@@ -9006,16 +8929,14 @@ build_ir_node_from_die(read_context& ctxt,
9006 case DW_TAG_pointer_type: 8929 case DW_TAG_pointer_type:
9007 { 8930 {
9008 pointer_type_def_sptr p = 8931 pointer_type_def_sptr p =
9009 build_pointer_type_def(ctxt, die, die_is_from_alt_di, 8932 build_pointer_type_def(ctxt, die,
9010 called_from_public_decl, 8933 called_from_public_decl,
9011 where_offset); 8934 where_offset);
9012 if (p) 8935 if (p)
9013 { 8936 {
9014 result = add_decl_to_scope(p, ctxt.cur_tu()->get_global_scope()); 8937 result = add_decl_to_scope(p, ctxt.cur_tu()->get_global_scope());
9015 assert(result->get_translation_unit()); 8938 assert(result->get_translation_unit());
9016 maybe_canonicalize_type(dwarf_dieoffset(die), 8939 maybe_canonicalize_type(dwarf_dieoffset(die), source_of_die, ctxt);
9017 die_is_from_alt_di,
9018 ctxt);
9019 } 8940 }
9020 } 8941 }
9021 break; 8942 break;
@@ -9024,18 +8945,14 @@ build_ir_node_from_die(read_context& ctxt,
9024 case DW_TAG_rvalue_reference_type: 8945 case DW_TAG_rvalue_reference_type:
9025 { 8946 {
9026 reference_type_def_sptr r = 8947 reference_type_def_sptr r =
9027 build_reference_type(ctxt, die, die_is_from_alt_di, 8948 build_reference_type(ctxt, die,
9028 called_from_public_decl, 8949 called_from_public_decl,
9029 where_offset); 8950 where_offset);
9030 if (r) 8951 if (r)
9031 { 8952 {
9032 result = add_decl_to_scope(r, ctxt.cur_tu()->get_global_scope()); 8953 result = add_decl_to_scope(r, ctxt.cur_tu()->get_global_scope());
9033 ctxt.associate_die_to_type(dwarf_dieoffset(die), 8954 ctxt.associate_die_to_type(dwarf_dieoffset(die), source_of_die, r);
9034 die_is_from_alt_di, 8955 maybe_canonicalize_type(dwarf_dieoffset(die), source_of_die, ctxt);
9035 r);
9036 maybe_canonicalize_type(dwarf_dieoffset(die),
9037 die_is_from_alt_di,
9038 ctxt);
9039 } 8956 }
9040 } 8957 }
9041 break; 8958 break;
@@ -9045,7 +8962,7 @@ build_ir_node_from_die(read_context& ctxt,
9045 case DW_TAG_restrict_type: 8962 case DW_TAG_restrict_type:
9046 { 8963 {
9047 qualified_type_def_sptr q = 8964 qualified_type_def_sptr q =
9048 build_qualified_type(ctxt, die, die_is_from_alt_di, 8965 build_qualified_type(ctxt, die,
9049 called_from_public_decl, 8966 called_from_public_decl,
9050 where_offset); 8967 where_offset);
9051 if (q) 8968 if (q)
@@ -9057,29 +8974,21 @@ build_ir_node_from_die(read_context& ctxt,
9057 // Associate the die to type ty again because 'ty'might be 8974 // Associate the die to type ty again because 'ty'might be
9058 // different from 'q', because 'ty' is 'q' possibly 8975 // different from 'q', because 'ty' is 'q' possibly
9059 // stripped from some redundant type qualifier. 8976 // stripped from some redundant type qualifier.
9060 ctxt.associate_die_to_type(dwarf_dieoffset(die), 8977 ctxt.associate_die_to_type(dwarf_dieoffset(die), source_of_die, ty);
9061 die_is_from_alt_di,
9062 ty);
9063 result = add_decl_to_scope(d, ctxt.cur_tu()->get_global_scope()); 8978 result = add_decl_to_scope(d, ctxt.cur_tu()->get_global_scope());
9064 maybe_canonicalize_type(dwarf_dieoffset(die), 8979 maybe_canonicalize_type(dwarf_dieoffset(die), source_of_die, ctxt);
9065 die_is_from_alt_di,
9066 ctxt);
9067 } 8980 }
9068 } 8981 }
9069 break; 8982 break;
9070 8983
9071 case DW_TAG_enumeration_type: 8984 case DW_TAG_enumeration_type:
9072 { 8985 {
9073 enum_type_decl_sptr e = build_enum_type(ctxt, 8986 enum_type_decl_sptr e = build_enum_type(ctxt, die);
9074 die_is_from_alt_di,
9075 die);
9076 result = add_decl_to_scope(e, scope); 8987 result = add_decl_to_scope(e, scope);
9077 if (result) 8988 if (result)
9078 { 8989 {
9079 maybe_set_member_type_access_specifier(is_decl(result), die); 8990 maybe_set_member_type_access_specifier(is_decl(result), die);
9080 maybe_canonicalize_type(dwarf_dieoffset(die), 8991 maybe_canonicalize_type(dwarf_dieoffset(die), source_of_die, ctxt);
9081 die_is_from_alt_di,
9082 ctxt);
9083 } 8992 }
9084 } 8993 }
9085 break; 8994 break;
@@ -9089,20 +8998,15 @@ build_ir_node_from_die(read_context& ctxt,
9089 { 8998 {
9090 Dwarf_Die spec_die; 8999 Dwarf_Die spec_die;
9091 scope_decl_sptr scop; 9000 scope_decl_sptr scop;
9092 bool spec_die_is_in_alt_di = false;
9093 class_decl_sptr klass; 9001 class_decl_sptr klass;
9094 if (die_die_attribute(die, die_is_from_alt_di, 9002 if (die_die_attribute(die, DW_AT_specification, spec_die))
9095 DW_AT_specification, spec_die,
9096 spec_die_is_in_alt_di))
9097 { 9003 {
9098 scope_decl_sptr skope = get_scope_for_die(ctxt, &spec_die, 9004 scope_decl_sptr skope = get_scope_for_die(ctxt, &spec_die,
9099 spec_die_is_in_alt_di,
9100 called_from_public_decl, 9005 called_from_public_decl,
9101 where_offset); 9006 where_offset);
9102 assert(skope); 9007 assert(skope);
9103 decl_base_sptr cl = 9008 decl_base_sptr cl =
9104 is_decl(build_ir_node_from_die(ctxt, &spec_die, 9009 is_decl(build_ir_node_from_die(ctxt, &spec_die,
9105 spec_die_is_in_alt_di,
9106 skope.get(), 9010 skope.get(),
9107 called_from_public_decl, 9011 called_from_public_decl,
9108 where_offset)); 9012 where_offset));
@@ -9112,7 +9016,6 @@ build_ir_node_from_die(read_context& ctxt,
9112 9016
9113 klass = 9017 klass =
9114 build_class_type_and_add_to_ir(ctxt, die, 9018 build_class_type_and_add_to_ir(ctxt, die,
9115 die_is_from_alt_di,
9116 skope.get(), 9019 skope.get(),
9117 tag == DW_TAG_structure_type, 9020 tag == DW_TAG_structure_type,
9118 klass, 9021 klass,
@@ -9121,7 +9024,7 @@ build_ir_node_from_die(read_context& ctxt,
9121 } 9024 }
9122 else 9025 else
9123 klass = 9026 klass =
9124 build_class_type_and_add_to_ir(ctxt, die, die_is_from_alt_di, 9027 build_class_type_and_add_to_ir(ctxt, die,
9125 scope, tag == DW_TAG_structure_type, 9028 scope, tag == DW_TAG_structure_type,
9126 class_decl_sptr(), 9029 class_decl_sptr(),
9127 called_from_public_decl, 9030 called_from_public_decl,
@@ -9130,9 +9033,7 @@ build_ir_node_from_die(read_context& ctxt,
9130 if (klass) 9033 if (klass)
9131 { 9034 {
9132 maybe_set_member_type_access_specifier(klass, die); 9035 maybe_set_member_type_access_specifier(klass, die);
9133 maybe_canonicalize_type(dwarf_dieoffset(die), 9036 maybe_canonicalize_type(dwarf_dieoffset(die), source_of_die, ctxt);
9134 die_is_from_alt_di,
9135 ctxt);
9136 } 9037 }
9137 } 9038 }
9138 break; 9039 break;
@@ -9141,16 +9042,14 @@ build_ir_node_from_die(read_context& ctxt,
9141 case DW_TAG_subroutine_type: 9042 case DW_TAG_subroutine_type:
9142 { 9043 {
9143 function_type_sptr f = 9044 function_type_sptr f =
9144 build_function_type(ctxt, die, die_is_from_alt_di, 9045 build_function_type(ctxt, die,
9145 /*called_from_public_decl,*/ 9046 /*called_from_public_decl,*/
9146 class_decl_sptr(), 9047 class_decl_sptr(),
9147 where_offset); 9048 where_offset);
9148 if (f) 9049 if (f)
9149 { 9050 {
9150 result = f; 9051 result = f;
9151 maybe_canonicalize_type(dwarf_dieoffset(die), 9052 maybe_canonicalize_type(dwarf_dieoffset(die), source_of_die, ctxt);
9152 die_is_from_alt_di,
9153 ctxt);
9154 } 9053 }
9155 } 9054 }
9156 break; 9055 break;
@@ -9160,18 +9059,13 @@ build_ir_node_from_die(read_context& ctxt,
9160 { 9059 {
9161 array_type_def_sptr a = build_array_type(ctxt, 9060 array_type_def_sptr a = build_array_type(ctxt,
9162 die, 9061 die,
9163 die_is_from_alt_di,
9164 called_from_public_decl, 9062 called_from_public_decl,
9165 where_offset); 9063 where_offset);
9166 if (a) 9064 if (a)
9167 { 9065 {
9168 result = add_decl_to_scope(a, ctxt.cur_tu()->get_global_scope()); 9066 result = add_decl_to_scope(a, ctxt.cur_tu()->get_global_scope());
9169 ctxt.associate_die_to_type(dwarf_dieoffset(die), 9067 ctxt.associate_die_to_type(dwarf_dieoffset(die), source_of_die, a);
9170 die_is_from_alt_di, 9068 maybe_canonicalize_type(dwarf_dieoffset(die), source_of_die, ctxt);
9171 a);
9172 maybe_canonicalize_type(dwarf_dieoffset(die),
9173 die_is_from_alt_di,
9174 ctxt);
9175 } 9069 }
9176 } 9070 }
9177 break; 9071 break;
@@ -9204,34 +9098,24 @@ build_ir_node_from_die(read_context& ctxt,
9204 9098
9205 case DW_TAG_namespace: 9099 case DW_TAG_namespace:
9206 case DW_TAG_module: 9100 case DW_TAG_module:
9207 result = build_namespace_decl_and_add_to_ir(ctxt, die, die_is_from_alt_di, 9101 result = build_namespace_decl_and_add_to_ir(ctxt, die, where_offset);
9208 where_offset);
9209 break; 9102 break;
9210 9103
9211 case DW_TAG_variable: 9104 case DW_TAG_variable:
9212 { 9105 {
9213 Dwarf_Die spec_die; 9106 Dwarf_Die spec_die;
9214 bool var_is_cloned = false; 9107 bool var_is_cloned = false;
9215 bool spec_die_is_in_alt_di = false; 9108 if (die_die_attribute(die, DW_AT_specification, spec_die,false)
9216 if (die_die_attribute(die, die_is_from_alt_di, 9109 || (var_is_cloned = die_die_attribute(die, DW_AT_abstract_origin,
9217 DW_AT_specification, spec_die, 9110 spec_die, false)))
9218 spec_die_is_in_alt_di,
9219 false)
9220 || (var_is_cloned = die_die_attribute(die, die_is_from_alt_di,
9221 DW_AT_abstract_origin,
9222 spec_die,
9223 spec_die_is_in_alt_di,
9224 false)))
9225 { 9111 {
9226 scope_decl_sptr scop = get_scope_for_die(ctxt, &spec_die, 9112 scope_decl_sptr scop = get_scope_for_die(ctxt, &spec_die,
9227 spec_die_is_in_alt_di,
9228 called_from_public_decl, 9113 called_from_public_decl,
9229 where_offset); 9114 where_offset);
9230 if (scop) 9115 if (scop)
9231 { 9116 {
9232 decl_base_sptr d = 9117 decl_base_sptr d =
9233 is_decl(build_ir_node_from_die(ctxt, &spec_die, 9118 is_decl(build_ir_node_from_die(ctxt, &spec_die,
9234 spec_die_is_in_alt_di,
9235 scop.get(), 9119 scop.get(),
9236 called_from_public_decl, 9120 called_from_public_decl,
9237 where_offset)); 9121 where_offset));
@@ -9241,13 +9125,12 @@ build_ir_node_from_die(read_context& ctxt,
9241 dynamic_pointer_cast<var_decl>(d); 9125 dynamic_pointer_cast<var_decl>(d);
9242 if (var_is_cloned) 9126 if (var_is_cloned)
9243 m = m->clone(); 9127 m = m->clone();
9244 m = build_var_decl(ctxt, die, die_is_from_alt_di, 9128 m = build_var_decl(ctxt, die, where_offset, m);
9245 where_offset, m);
9246 if (is_data_member(m)) 9129 if (is_data_member(m))
9247 { 9130 {
9248 set_member_is_static(m, true); 9131 set_member_is_static(m, true);
9249 ctxt.associate_die_to_decl(dwarf_dieoffset(die), 9132 ctxt.associate_die_to_decl(dwarf_dieoffset(die),
9250 die_is_from_alt_di, m); 9133 source_of_die, m);
9251 } 9134 }
9252 else 9135 else
9253 { 9136 {
@@ -9260,9 +9143,7 @@ build_ir_node_from_die(read_context& ctxt,
9260 } 9143 }
9261 } 9144 }
9262 } 9145 }
9263 else if (var_decl_sptr v = build_var_decl(ctxt, die, 9146 else if (var_decl_sptr v = build_var_decl(ctxt, die, where_offset))
9264 die_is_from_alt_di,
9265 where_offset))
9266 { 9147 {
9267 result = add_decl_to_scope(v, scope); 9148 result = add_decl_to_scope(v, scope);
9268 assert(is_decl(result)->get_scope()); 9149 assert(is_decl(result)->get_scope());
@@ -9285,18 +9166,11 @@ build_ir_node_from_die(read_context& ctxt,
9285 break; 9166 break;
9286 9167
9287 function_decl_sptr fn; 9168 function_decl_sptr fn;
9288 bool is_in_alternate_debug_info = false; 9169 bool has_spec = die_die_attribute(die, DW_AT_specification,
9289 bool has_spec = die_die_attribute(die, die_is_from_alt_di, 9170 spec_die, true);
9290 DW_AT_specification,
9291 spec_die,
9292 is_in_alternate_debug_info,
9293 true);
9294 bool has_abstract_origin = 9171 bool has_abstract_origin =
9295 die_die_attribute(die, die_is_from_alt_di, 9172 die_die_attribute(die, DW_AT_abstract_origin,
9296 DW_AT_abstract_origin, 9173 abstract_origin_die, true);
9297 abstract_origin_die,
9298 is_in_alternate_debug_info,
9299 true);
9300 if (has_spec || has_abstract_origin) 9174 if (has_spec || has_abstract_origin)
9301 { 9175 {
9302 interface_die = 9176 interface_die =
@@ -9312,7 +9186,6 @@ build_ir_node_from_die(read_context& ctxt,
9312 string spec_linkage_name = die_linkage_name(interface_die); 9186 string spec_linkage_name = die_linkage_name(interface_die);
9313 9187
9314 scop = get_scope_for_die(ctxt, interface_die, 9188 scop = get_scope_for_die(ctxt, interface_die,
9315 is_in_alternate_debug_info,
9316 called_from_public_decl, 9189 called_from_public_decl,
9317 where_offset); 9190 where_offset);
9318 if (scop) 9191 if (scop)
@@ -9320,7 +9193,6 @@ build_ir_node_from_die(read_context& ctxt,
9320 decl_base_sptr d = 9193 decl_base_sptr d =
9321 is_decl(build_ir_node_from_die(ctxt, 9194 is_decl(build_ir_node_from_die(ctxt,
9322 origin_die, 9195 origin_die,
9323 is_in_alternate_debug_info,
9324 scop.get(), 9196 scop.get(),
9325 called_from_public_decl, 9197 called_from_public_decl,
9326 where_offset)); 9198 where_offset));
@@ -9336,15 +9208,13 @@ build_ir_node_from_die(read_context& ctxt,
9336 // of 'd'. 9208 // of 'd'.
9337 fn = fn->clone(); 9209 fn = fn->clone();
9338 ctxt.associate_die_to_decl(dwarf_dieoffset(die), 9210 ctxt.associate_die_to_decl(dwarf_dieoffset(die),
9339 die_is_from_alt_di, 9211 source_of_die, fn);
9340 fn);
9341 } 9212 }
9342 } 9213 }
9343 } 9214 }
9344 ctxt.scope_stack().push(scope); 9215 ctxt.scope_stack().push(scope);
9345 9216
9346 result = build_function_decl(ctxt, die, die_is_from_alt_di, 9217 result = build_function_decl(ctxt, die, where_offset, fn);
9347 where_offset, fn);
9348 if (result && !fn) 9218 if (result && !fn)
9349 result = add_decl_to_scope(is_decl(result), scope); 9219 result = add_decl_to_scope(is_decl(result), scope);
9350 9220
@@ -9361,8 +9231,7 @@ build_ir_node_from_die(read_context& ctxt,
9361 { 9231 {
9362 ctxt.maybe_add_fn_to_exported_decls(fn.get()); 9232 ctxt.maybe_add_fn_to_exported_decls(fn.get());
9363 maybe_canonicalize_type(dwarf_dieoffset(die), 9233 maybe_canonicalize_type(dwarf_dieoffset(die),
9364 die_is_from_alt_di, 9234 source_of_die, ctxt);
9365 ctxt);
9366 } 9235 }
9367 9236
9368 ctxt.scope_stack().pop(); 9237 ctxt.scope_stack().pop();
@@ -9432,7 +9301,7 @@ build_ir_node_from_die(read_context& ctxt,
9432 9301
9433 if (result && tag != DW_TAG_subroutine_type) 9302 if (result && tag != DW_TAG_subroutine_type)
9434 ctxt.associate_die_to_decl(dwarf_dieoffset(die), 9303 ctxt.associate_die_to_decl(dwarf_dieoffset(die),
9435 die_is_from_alt_di, 9304 source_of_die,
9436 is_decl(result)); 9305 is_decl(result));
9437 9306
9438 return result; 9307 return result;
@@ -9463,9 +9332,6 @@ build_ir_node_for_void_type(read_context& ctxt)
9463/// 9332///
9464/// @param die the DIE to consider. 9333/// @param die the DIE to consider.
9465/// 9334///
9466/// @param die_is_from_alt_di true if @p die is a DIE from the
9467/// alternate debug info sections, false otherwise.
9468///
9469/// @param called_from_public_decl set to yes if this function is 9335/// @param called_from_public_decl set to yes if this function is
9470/// called from the functions used to build a public decl (functions 9336/// called from the functions used to build a public decl (functions
9471/// and variables). In that case, this function accepts building IR 9337/// and variables). In that case, this function accepts building IR
@@ -9483,19 +9349,16 @@ build_ir_node_for_void_type(read_context& ctxt)
9483static type_or_decl_base_sptr 9349static type_or_decl_base_sptr
9484build_ir_node_from_die(read_context& ctxt, 9350build_ir_node_from_die(read_context& ctxt,
9485 Dwarf_Die* die, 9351 Dwarf_Die* die,
9486 bool die_is_from_alt_di,
9487 bool called_from_public_decl, 9352 bool called_from_public_decl,
9488 size_t where_offset) 9353 size_t where_offset)
9489{ 9354{
9490 if (!die) 9355 if (!die)
9491 return decl_base_sptr(); 9356 return decl_base_sptr();
9492 9357
9493 scope_decl_sptr scope = get_scope_for_die(ctxt, die, die_is_from_alt_di, 9358 scope_decl_sptr scope = get_scope_for_die(ctxt, die,
9494 called_from_public_decl, 9359 called_from_public_decl,
9495 where_offset); 9360 where_offset);
9496 return build_ir_node_from_die(ctxt, die, 9361 return build_ir_node_from_die(ctxt, die, scope.get(),
9497 die_is_from_alt_di,
9498 scope.get(),
9499 called_from_public_decl, 9362 called_from_public_decl,
9500 where_offset); 9363 where_offset);
9501} 9364}