diff -r 5c068b86064f dwarf2read.c --- a/dwarf2read.c Tue Sep 30 15:08:26 2008 -0700 +++ b/dwarf2read.c Tue Sep 30 18:09:41 2008 -0700 @@ -1217,6 +1217,19 @@ dwarf2_resize_section (asection *sectp, sectp->name); } +/* Return non-zero if the given CU may contains some nested subprograms + (in other words, subprograms defined inside another subprogram or + inside a lexical block). + + The result is currently purely based on the compilation unit language, + and thus the content of the compilation unit itself is not checked. */ + +static int +dwarf2_handle_nested_subprograms_p (struct dwarf2_cu *cu) +{ + return (cu->language == language_ada || cu->language == language_pascal); +} + /* Build a partial symbol table. */ void @@ -2163,7 +2176,7 @@ add_partial_subprogram (struct partial_d if (! pdi->has_children) return; - if (cu->language == language_ada) + if (dwarf2_handle_nested_subprograms_p (cu)) { pdi = pdi->die_child; while (pdi != NULL) @@ -3345,7 +3358,7 @@ dwarf2_get_subprogram_pc_bounds (struct /* If the language does not allow nested subprograms (either inside subprograms or lexical blocks), we're done. */ - if (cu->language != language_ada) + if (!dwarf2_handle_nested_subprograms_p (cu)) return; /* Check all the children of the given DIE. If it contains nested @@ -5770,7 +5783,7 @@ load_partial_dies (bfd *abfd, gdb_byte * || last_die->tag == DW_TAG_interface_type || last_die->tag == DW_TAG_structure_type || last_die->tag == DW_TAG_union_type)) - || (cu->language == language_ada + || (dwarf2_handle_nested_subprograms_p (cu) && (last_die->tag == DW_TAG_subprogram || last_die->tag == DW_TAG_lexical_block)))) {