dwarf2out.c (245023) | dwarf2out.c (259269) |
---|---|
1/* Output Dwarf2 format symbol table information from GCC. 2 Copyright (C) 1992, 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 3 2003, 2004, 2005, 2006 Free Software Foundation, Inc. 4 Contributed by Gary Funck (gary@intrepid.com). 5 Derived from DWARF 1 implementation of Ron Guilmette (rfg@monkeys.com). 6 Extensively modified by Jason Merrill (jason@cygnus.com). 7 8This file is part of GCC. --- 4201 unchanged lines hidden (view full) --- 4210static void gen_label_die (tree, dw_die_ref); 4211static void gen_lexical_block_die (tree, dw_die_ref, int); 4212static void gen_inlined_subroutine_die (tree, dw_die_ref, int); 4213static void gen_field_die (tree, dw_die_ref); 4214static void gen_ptr_to_mbr_type_die (tree, dw_die_ref); 4215static dw_die_ref gen_compile_unit_die (const char *); 4216static void gen_inheritance_die (tree, tree, dw_die_ref); 4217static void gen_member_die (tree, dw_die_ref); | 1/* Output Dwarf2 format symbol table information from GCC. 2 Copyright (C) 1992, 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 3 2003, 2004, 2005, 2006 Free Software Foundation, Inc. 4 Contributed by Gary Funck (gary@intrepid.com). 5 Derived from DWARF 1 implementation of Ron Guilmette (rfg@monkeys.com). 6 Extensively modified by Jason Merrill (jason@cygnus.com). 7 8This file is part of GCC. --- 4201 unchanged lines hidden (view full) --- 4210static void gen_label_die (tree, dw_die_ref); 4211static void gen_lexical_block_die (tree, dw_die_ref, int); 4212static void gen_inlined_subroutine_die (tree, dw_die_ref, int); 4213static void gen_field_die (tree, dw_die_ref); 4214static void gen_ptr_to_mbr_type_die (tree, dw_die_ref); 4215static dw_die_ref gen_compile_unit_die (const char *); 4216static void gen_inheritance_die (tree, tree, dw_die_ref); 4217static void gen_member_die (tree, dw_die_ref); |
4218static void gen_struct_or_union_type_die (tree, dw_die_ref); | 4218static void gen_struct_or_union_type_die (tree, dw_die_ref, 4219 enum debug_info_usage); |
4219static void gen_subroutine_type_die (tree, dw_die_ref); 4220static void gen_typedef_die (tree, dw_die_ref); 4221static void gen_type_die (tree, dw_die_ref); 4222static void gen_tagged_type_instantiation_die (tree, dw_die_ref); 4223static void gen_block_die (tree, dw_die_ref, int); 4224static void decls_for_scope (tree, dw_die_ref, int); 4225static int is_redundant_typedef (tree); 4226static void gen_namespace_die (tree); --- 8241 unchanged lines hidden (view full) --- 12468 } 12469} 12470 12471/* Generate a DIE for a structure or union type. If TYPE_DECL_SUPPRESS_DEBUG 12472 is set, we pretend that the type was never defined, so we only get the 12473 member DIEs needed by later specification DIEs. */ 12474 12475static void | 4220static void gen_subroutine_type_die (tree, dw_die_ref); 4221static void gen_typedef_die (tree, dw_die_ref); 4222static void gen_type_die (tree, dw_die_ref); 4223static void gen_tagged_type_instantiation_die (tree, dw_die_ref); 4224static void gen_block_die (tree, dw_die_ref, int); 4225static void decls_for_scope (tree, dw_die_ref, int); 4226static int is_redundant_typedef (tree); 4227static void gen_namespace_die (tree); --- 8241 unchanged lines hidden (view full) --- 12469 } 12470} 12471 12472/* Generate a DIE for a structure or union type. If TYPE_DECL_SUPPRESS_DEBUG 12473 is set, we pretend that the type was never defined, so we only get the 12474 member DIEs needed by later specification DIEs. */ 12475 12476static void |
12476gen_struct_or_union_type_die (tree type, dw_die_ref context_die) | 12477gen_struct_or_union_type_die (tree type, dw_die_ref context_die, 12478 enum debug_info_usage usage) |
12477{ 12478 dw_die_ref type_die = lookup_type_die (type); 12479 dw_die_ref scope_die = 0; 12480 int nested = 0; 12481 int complete = (TYPE_SIZE (type) 12482 && (! TYPE_STUB_DECL (type) 12483 || ! TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (type)))); 12484 int ns_decl = (context_die && context_die->die_tag == DW_TAG_namespace); | 12479{ 12480 dw_die_ref type_die = lookup_type_die (type); 12481 dw_die_ref scope_die = 0; 12482 int nested = 0; 12483 int complete = (TYPE_SIZE (type) 12484 && (! TYPE_STUB_DECL (type) 12485 || ! TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (type)))); 12486 int ns_decl = (context_die && context_die->die_tag == DW_TAG_namespace); |
12487 complete = complete && should_emit_struct_debug (type, usage); |
|
12485 12486 if (type_die && ! complete) 12487 return; 12488 12489 if (TYPE_CONTEXT (type) != NULL_TREE 12490 && (AGGREGATE_TYPE_P (TYPE_CONTEXT (type)) 12491 || TREE_CODE (TYPE_CONTEXT (type)) == NAMESPACE_DECL)) 12492 nested = 1; --- 111 unchanged lines hidden (view full) --- 12604 12605 if (DECL_ABSTRACT (decl)) 12606 equate_decl_number_to_die (decl, type_die); 12607} 12608 12609/* Generate a type description DIE. */ 12610 12611static void | 12488 12489 if (type_die && ! complete) 12490 return; 12491 12492 if (TYPE_CONTEXT (type) != NULL_TREE 12493 && (AGGREGATE_TYPE_P (TYPE_CONTEXT (type)) 12494 || TREE_CODE (TYPE_CONTEXT (type)) == NAMESPACE_DECL)) 12495 nested = 1; --- 111 unchanged lines hidden (view full) --- 12607 12608 if (DECL_ABSTRACT (decl)) 12609 equate_decl_number_to_die (decl, type_die); 12610} 12611 12612/* Generate a type description DIE. */ 12613 12614static void |
12612gen_type_die (tree type, dw_die_ref context_die) | 12615gen_type_die_with_usage (tree type, dw_die_ref context_die, 12616 enum debug_info_usage usage) |
12613{ 12614 int need_pop; 12615 12616 if (type == NULL_TREE || type == error_mark_node) 12617 return; 12618 12619 if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL 12620 && DECL_ORIGINAL_TYPE (TYPE_NAME (type))) --- 31 unchanged lines hidden (view full) --- 12652 ensures that the gen_type_die recursion will terminate even if the 12653 type is recursive. Recursive types are possible in Ada. */ 12654 /* ??? We could perhaps do this for all types before the switch 12655 statement. */ 12656 TREE_ASM_WRITTEN (type) = 1; 12657 12658 /* For these types, all that is required is that we output a DIE (or a 12659 set of DIEs) to represent the "basis" type. */ | 12617{ 12618 int need_pop; 12619 12620 if (type == NULL_TREE || type == error_mark_node) 12621 return; 12622 12623 if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL 12624 && DECL_ORIGINAL_TYPE (TYPE_NAME (type))) --- 31 unchanged lines hidden (view full) --- 12656 ensures that the gen_type_die recursion will terminate even if the 12657 type is recursive. Recursive types are possible in Ada. */ 12658 /* ??? We could perhaps do this for all types before the switch 12659 statement. */ 12660 TREE_ASM_WRITTEN (type) = 1; 12661 12662 /* For these types, all that is required is that we output a DIE (or a 12663 set of DIEs) to represent the "basis" type. */ |
12660 gen_type_die (TREE_TYPE (type), context_die); | 12664 gen_type_die_with_usage (TREE_TYPE (type), context_die, 12665 DINFO_USAGE_IND_USE); |
12661 break; 12662 12663 case OFFSET_TYPE: 12664 /* This code is used for C++ pointer-to-data-member types. 12665 Output a description of the relevant class type. */ | 12666 break; 12667 12668 case OFFSET_TYPE: 12669 /* This code is used for C++ pointer-to-data-member types. 12670 Output a description of the relevant class type. */ |
12666 gen_type_die (TYPE_OFFSET_BASETYPE (type), context_die); | 12671 gen_type_die_with_usage (TYPE_OFFSET_BASETYPE (type), context_die, 12672 DINFO_USAGE_IND_USE); |
12667 12668 /* Output a description of the type of the object pointed to. */ | 12673 12674 /* Output a description of the type of the object pointed to. */ |
12669 gen_type_die (TREE_TYPE (type), context_die); | 12675 gen_type_die_with_usage (TREE_TYPE (type), context_die, 12676 DINFO_USAGE_IND_USE); |
12670 12671 /* Now output a DIE to represent this pointer-to-data-member type 12672 itself. */ 12673 gen_ptr_to_mbr_type_die (type, context_die); 12674 break; 12675 12676 case FUNCTION_TYPE: 12677 /* Force out return type (in case it wasn't forced out already). */ | 12677 12678 /* Now output a DIE to represent this pointer-to-data-member type 12679 itself. */ 12680 gen_ptr_to_mbr_type_die (type, context_die); 12681 break; 12682 12683 case FUNCTION_TYPE: 12684 /* Force out return type (in case it wasn't forced out already). */ |
12678 gen_type_die (TREE_TYPE (type), context_die); | 12685 gen_type_die_with_usage (TREE_TYPE (type), context_die, 12686 DINFO_USAGE_DIR_USE); |
12679 gen_subroutine_type_die (type, context_die); 12680 break; 12681 12682 case METHOD_TYPE: 12683 /* Force out return type (in case it wasn't forced out already). */ | 12687 gen_subroutine_type_die (type, context_die); 12688 break; 12689 12690 case METHOD_TYPE: 12691 /* Force out return type (in case it wasn't forced out already). */ |
12684 gen_type_die (TREE_TYPE (type), context_die); | 12692 gen_type_die_with_usage (TREE_TYPE (type), context_die, 12693 DINFO_USAGE_DIR_USE); |
12685 gen_subroutine_type_die (type, context_die); 12686 break; 12687 12688 case ARRAY_TYPE: 12689 gen_array_type_die (type, context_die); 12690 break; 12691 12692 case VECTOR_TYPE: --- 9 unchanged lines hidden (view full) --- 12702 to instantiations of member class templates; they need to be added to 12703 the containing class as they are generated. FIXME: This hurts the 12704 idea of combining type decls from multiple TUs, since we can't predict 12705 what set of template instantiations we'll get. */ 12706 if (TYPE_CONTEXT (type) 12707 && AGGREGATE_TYPE_P (TYPE_CONTEXT (type)) 12708 && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type))) 12709 { | 12694 gen_subroutine_type_die (type, context_die); 12695 break; 12696 12697 case ARRAY_TYPE: 12698 gen_array_type_die (type, context_die); 12699 break; 12700 12701 case VECTOR_TYPE: --- 9 unchanged lines hidden (view full) --- 12711 to instantiations of member class templates; they need to be added to 12712 the containing class as they are generated. FIXME: This hurts the 12713 idea of combining type decls from multiple TUs, since we can't predict 12714 what set of template instantiations we'll get. */ 12715 if (TYPE_CONTEXT (type) 12716 && AGGREGATE_TYPE_P (TYPE_CONTEXT (type)) 12717 && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type))) 12718 { |
12710 gen_type_die (TYPE_CONTEXT (type), context_die); | 12719 gen_type_die_with_usage (TYPE_CONTEXT (type), context_die, usage); |
12711 12712 if (TREE_ASM_WRITTEN (type)) 12713 return; 12714 12715 /* If that failed, attach ourselves to the stub. */ 12716 push_decl_scope (TYPE_CONTEXT (type)); 12717 context_die = lookup_type_die (TYPE_CONTEXT (type)); 12718 need_pop = 1; --- 7 unchanged lines hidden (view full) --- 12726 if (TREE_CODE (type) == ENUMERAL_TYPE) 12727 { 12728 /* This might have been written out by the call to 12729 declare_in_namespace. */ 12730 if (!TREE_ASM_WRITTEN (type)) 12731 gen_enumeration_type_die (type, context_die); 12732 } 12733 else | 12720 12721 if (TREE_ASM_WRITTEN (type)) 12722 return; 12723 12724 /* If that failed, attach ourselves to the stub. */ 12725 push_decl_scope (TYPE_CONTEXT (type)); 12726 context_die = lookup_type_die (TYPE_CONTEXT (type)); 12727 need_pop = 1; --- 7 unchanged lines hidden (view full) --- 12735 if (TREE_CODE (type) == ENUMERAL_TYPE) 12736 { 12737 /* This might have been written out by the call to 12738 declare_in_namespace. */ 12739 if (!TREE_ASM_WRITTEN (type)) 12740 gen_enumeration_type_die (type, context_die); 12741 } 12742 else |
12734 gen_struct_or_union_type_die (type, context_die); | 12743 gen_struct_or_union_type_die (type, context_die, usage); |
12735 12736 if (need_pop) 12737 pop_decl_scope (); 12738 12739 /* Don't set TREE_ASM_WRITTEN on an incomplete struct; we want to fix 12740 it up if it is ever completed. gen_*_type_die will set it for us 12741 when appropriate. */ 12742 return; --- 12 unchanged lines hidden (view full) --- 12755 12756 default: 12757 gcc_unreachable (); 12758 } 12759 12760 TREE_ASM_WRITTEN (type) = 1; 12761} 12762 | 12744 12745 if (need_pop) 12746 pop_decl_scope (); 12747 12748 /* Don't set TREE_ASM_WRITTEN on an incomplete struct; we want to fix 12749 it up if it is ever completed. gen_*_type_die will set it for us 12750 when appropriate. */ 12751 return; --- 12 unchanged lines hidden (view full) --- 12764 12765 default: 12766 gcc_unreachable (); 12767 } 12768 12769 TREE_ASM_WRITTEN (type) = 1; 12770} 12771 |
12772static void 12773gen_type_die (tree type, dw_die_ref context_die) 12774{ 12775 gen_type_die_with_usage (type, context_die, DINFO_USAGE_DIR_USE); 12776} 12777 |
|
12763/* Generate a DIE for a tagged type instantiation. */ 12764 12765static void 12766gen_tagged_type_instantiation_die (tree type, dw_die_ref context_die) 12767{ 12768 if (type == NULL_TREE || type == error_mark_node) 12769 return; 12770 --- 581 unchanged lines hidden (view full) --- 13352 We need decl DIE for reference and scope die. First, get DIE for the decl 13353 itself. */ 13354 13355 /* Get the scope die for decl context. Use comp_unit_die for global module 13356 or decl. If die is not found for non globals, force new die. */ 13357 if (!context) 13358 scope_die = comp_unit_die; 13359 else if (TYPE_P (context)) | 12778/* Generate a DIE for a tagged type instantiation. */ 12779 12780static void 12781gen_tagged_type_instantiation_die (tree type, dw_die_ref context_die) 12782{ 12783 if (type == NULL_TREE || type == error_mark_node) 12784 return; 12785 --- 581 unchanged lines hidden (view full) --- 13367 We need decl DIE for reference and scope die. First, get DIE for the decl 13368 itself. */ 13369 13370 /* Get the scope die for decl context. Use comp_unit_die for global module 13371 or decl. If die is not found for non globals, force new die. */ 13372 if (!context) 13373 scope_die = comp_unit_die; 13374 else if (TYPE_P (context)) |
13375 { 13376 if (!should_emit_struct_debug (context, DINFO_USAGE_DIR_USE)) 13377 return; |
|
13360 scope_die = force_type_die (context); | 13378 scope_die = force_type_die (context); |
13379 } |
|
13361 else 13362 scope_die = force_decl_die (context); 13363 13364 /* For TYPE_DECL or CONST_DECL, lookup TREE_TYPE. */ 13365 if (TREE_CODE (decl) == TYPE_DECL || TREE_CODE (decl) == CONST_DECL) 13366 { 13367 if (is_base_type (TREE_TYPE (decl))) 13368 at_import_die = base_type_die (TREE_TYPE (decl)); --- 9 unchanged lines hidden (view full) --- 13378 emitted the member decl for this field. Emit it now. */ 13379 if (TREE_CODE (decl) == FIELD_DECL) 13380 { 13381 tree type = DECL_CONTEXT (decl); 13382 dw_die_ref type_context_die; 13383 13384 if (TYPE_CONTEXT (type)) 13385 if (TYPE_P (TYPE_CONTEXT (type))) | 13380 else 13381 scope_die = force_decl_die (context); 13382 13383 /* For TYPE_DECL or CONST_DECL, lookup TREE_TYPE. */ 13384 if (TREE_CODE (decl) == TYPE_DECL || TREE_CODE (decl) == CONST_DECL) 13385 { 13386 if (is_base_type (TREE_TYPE (decl))) 13387 at_import_die = base_type_die (TREE_TYPE (decl)); --- 9 unchanged lines hidden (view full) --- 13397 emitted the member decl for this field. Emit it now. */ 13398 if (TREE_CODE (decl) == FIELD_DECL) 13399 { 13400 tree type = DECL_CONTEXT (decl); 13401 dw_die_ref type_context_die; 13402 13403 if (TYPE_CONTEXT (type)) 13404 if (TYPE_P (TYPE_CONTEXT (type))) |
13405 { 13406 if (!should_emit_struct_debug (TYPE_CONTEXT (type), 13407 DINFO_USAGE_DIR_USE)) 13408 return; |
|
13386 type_context_die = force_type_die (TYPE_CONTEXT (type)); | 13409 type_context_die = force_type_die (TYPE_CONTEXT (type)); |
13410 } |
|
13387 else 13388 type_context_die = force_decl_die (TYPE_CONTEXT (type)); 13389 else 13390 type_context_die = comp_unit_die; 13391 gen_type_die_for_member (type, decl, type_context_die); 13392 } 13393 at_import_die = force_decl_die (decl); 13394 } --- 1074 unchanged lines hidden --- | 13411 else 13412 type_context_die = force_decl_die (TYPE_CONTEXT (type)); 13413 else 13414 type_context_die = comp_unit_die; 13415 gen_type_die_for_member (type, decl, type_context_die); 13416 } 13417 at_import_die = force_decl_die (decl); 13418 } --- 1074 unchanged lines hidden --- |