From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id 4CAB7385842B; Tue, 12 Jul 2022 15:12:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4CAB7385842B Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/symtab] Add dwarf2_cu::lang () X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 98f49277b5d9c8bf16717b898f79cef11b2e47a6 X-Git-Newrev: 3da5576c911a0f3fc608471f1486dc6db11052ef Message-Id: <20220712151221.4CAB7385842B@sourceware.org> Date: Tue, 12 Jul 2022 15:12:21 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jul 2022 15:12:21 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D3da5576c911a= 0f3fc608471f1486dc6db11052ef commit 3da5576c911a0f3fc608471f1486dc6db11052ef Author: Tom de Vries Date: Tue Jul 12 17:12:17 2022 +0200 [gdb/symtab] Add dwarf2_cu::lang () =20 The cu->per_cu->lang field was added to carry information from the init= ial partial symtabs phase to the symtab expansion phase, for the benefit of= a particular optimization in process_imported_unit_die. =20 Other uses have been added, but since the first phase now has been parallelized, those have become problematic and sources of race conditi= ons. =20 Fix this by adding dwarf2_cu::lang () and using it where we can to repl= ace cu->per_cu->lang () with cu->lang (). =20 Also assert in dwarf2_cu::lang () that we're not returning language_unk= nown. =20 Tested on x86_64-linux. Diff: --- gdb/dwarf2/cu.c | 2 +- gdb/dwarf2/cu.h | 7 ++ gdb/dwarf2/read.c | 198 +++++++++++++++++++++++++++-----------------------= ---- 3 files changed, 107 insertions(+), 100 deletions(-) diff --git a/gdb/dwarf2/cu.c b/gdb/dwarf2/cu.c index 8cbd97661a5..d40dd094b09 100644 --- a/gdb/dwarf2/cu.c +++ b/gdb/dwarf2/cu.c @@ -62,7 +62,7 @@ dwarf2_cu::start_compunit_symtab (const char *name, const= char *comp_dir, =20 m_builder.reset (new struct buildsym_compunit (this->per_objfile->objfile, - name, comp_dir, per_cu->lang (), low_pc)); + name, comp_dir, lang (), low_pc)); =20 list_in_scope =3D get_builder ()->get_file_symbols (); =20 diff --git a/gdb/dwarf2/cu.h b/gdb/dwarf2/cu.h index 6b72ec234bf..23cb3d21b2e 100644 --- a/gdb/dwarf2/cu.h +++ b/gdb/dwarf2/cu.h @@ -23,6 +23,7 @@ #include "buildsym.h" #include "dwarf2/comp-unit-head.h" #include "gdbsupport/gdb_optional.h" +#include "language.h" =20 /* Type used for delaying computation of method physnames. See comments for compute_delayed_physnames. */ @@ -105,6 +106,12 @@ struct dwarf2_cu /* The language we are debugging. */ const struct language_defn *language_defn =3D nullptr; =20 + enum language lang () const + { + gdb_assert (language_defn !=3D language_def (language_unknown)); + return language_defn->la_language; + } + const char *producer =3D nullptr; =20 private: diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 31000877f42..2aac9912ef1 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -6809,7 +6809,7 @@ process_psymtab_comp_unit (dwarf2_per_cu_data *this_c= u, prepare_one_comp_unit (reader.cu, reader.comp_unit_die, language_minimal); gdb_assert (storage !=3D nullptr); - cooked_indexer indexer (storage, this_cu, reader.cu->per_cu->lang ()); + cooked_indexer indexer (storage, this_cu, reader.cu->lang ()); indexer.make_index (&reader); } } @@ -6833,7 +6833,7 @@ build_type_psymtabs_reader (cutu_reader *reader, prepare_one_comp_unit (cu, type_unit_die, language_minimal); =20 gdb_assert (storage !=3D nullptr); - cooked_indexer indexer (storage, per_cu, cu->per_cu->lang ()); + cooked_indexer indexer (storage, per_cu, cu->lang ()); indexer.make_index (reader); } =20 @@ -7746,7 +7746,7 @@ compute_delayed_physnames (struct dwarf2_cu *cu) /* Only C++ delays computing physnames. */ if (cu->method_list.empty ()) return; - gdb_assert (cu->per_cu->lang () =3D=3D language_cplus); + gdb_assert (cu->lang () =3D=3D language_cplus); =20 for (const delayed_method_info &mi : cu->method_list) { @@ -8175,7 +8175,7 @@ quirk_rust_enum (struct type *type, struct objfile *o= bjfile) static void rust_union_quirks (struct dwarf2_cu *cu) { - gdb_assert (cu->per_cu->lang () =3D=3D language_rust); + gdb_assert (cu->lang () =3D=3D language_rust); for (type *type_ : cu->rust_unions) quirk_rust_enum (type_, cu->per_objfile->objfile); /* We don't need this any more. */ @@ -8369,7 +8369,7 @@ process_full_comp_unit (dwarf2_cu *cu, enum language = pretend_language) process_die (cu->dies, cu); =20 /* For now fudge the Go package. */ - if (cu->per_cu->lang () =3D=3D language_go) + if (cu->lang () =3D=3D language_go) fixup_go_packaging (cu); =20 /* Now that we have processed all the DIEs in the CU, all the types @@ -8377,7 +8377,7 @@ process_full_comp_unit (dwarf2_cu *cu, enum language = pretend_language) physnames. */ compute_delayed_physnames (cu); =20 - if (cu->per_cu->lang () =3D=3D language_rust) + if (cu->lang () =3D=3D language_rust) rust_union_quirks (cu); =20 /* Some compilers don't define a DW_AT_high_pc attribute for the @@ -8406,9 +8406,9 @@ process_full_comp_unit (dwarf2_cu *cu, enum language = pretend_language) /* Set symtab language to language from DW_AT_language. If the compilation is from a C file generated by language preprocessors, do not set the language if it was already deduced by start_subfile. */ - if (!(cu->per_cu->lang () =3D=3D language_c + if (!(cu->lang () =3D=3D language_c && cust->primary_filetab ()->language () !=3D language_unknown)) - cust->primary_filetab ()->set_language (cu->per_cu->lang ()); + cust->primary_filetab ()->set_language (cu->lang ()); =20 /* GCC-4.0 has started to support -fvar-tracking. GCC-3.x still can produce DW_AT_location with location lists but it can be possibly @@ -8462,7 +8462,7 @@ process_full_type_unit (dwarf2_cu *cu, process_die (cu->dies, cu); =20 /* For now fudge the Go package. */ - if (cu->per_cu->lang () =3D=3D language_go) + if (cu->lang () =3D=3D language_go) fixup_go_packaging (cu); =20 /* Now that we have processed all the DIEs in the CU, all the types @@ -8470,7 +8470,7 @@ process_full_type_unit (dwarf2_cu *cu, physnames. */ compute_delayed_physnames (cu); =20 - if (cu->per_cu->lang () =3D=3D language_rust) + if (cu->lang () =3D=3D language_rust) rust_union_quirks (cu); =20 /* TUs share symbol tables. @@ -8491,9 +8491,9 @@ process_full_type_unit (dwarf2_cu *cu, compilation is from a C file generated by language preprocessors, do not set the language if it was already deduced by start_subfile. */ - if (!(cu->per_cu->lang () =3D=3D language_c + if (!(cu->lang () =3D=3D language_c && cust->primary_filetab ()->language () !=3D language_c)) - cust->primary_filetab ()->set_language (cu->per_cu->lang ()); + cust->primary_filetab ()->set_language (cu->lang ()); } } else @@ -8544,9 +8544,9 @@ process_imported_unit_die (struct die_info *die, stru= ct dwarf2_cu *cu) =20 /* If necessary, add it to the queue and load its DIEs. */ if (maybe_queue_comp_unit (cu, per_cu, per_objfile, - cu->per_cu->lang ())) + cu->lang ())) load_full_comp_unit (per_cu, per_objfile, per_objfile->get_cu (per_cu), - false, cu->per_cu->lang ()); + false, cu->lang ()); =20 cu->per_cu->imported_symtabs_push (per_cu); } @@ -8604,7 +8604,7 @@ process_die (struct die_info *die, struct dwarf2_cu *= cu) break; case DW_TAG_subprogram: /* Nested subprograms in Fortran get a prefix. */ - if (cu->per_cu->lang () =3D=3D language_fortran + if (cu->lang () =3D=3D language_fortran && die->parent !=3D NULL && die->parent->tag =3D=3D DW_TAG_subprogram) cu->processing_has_namespace_info =3D true; @@ -8648,7 +8648,7 @@ process_die (struct die_info *die, struct dwarf2_cu *= cu) /* We only need to handle this case for Ada -- in other languages, it's normal for the compiler to emit a typedef instead. */ - if (cu->per_cu->lang () !=3D language_ada) + if (cu->lang () !=3D language_ada) break; /* FALLTHROUGH */ case DW_TAG_base_type: @@ -8682,7 +8682,7 @@ process_die (struct die_info *die, struct dwarf2_cu *= cu) case DW_TAG_imported_module: cu->processing_has_namespace_info =3D true; if (die->child !=3D NULL && (die->tag =3D=3D DW_TAG_imported_declara= tion - || cu->per_cu->lang () !=3D language_fortran)) + || cu->lang () !=3D language_fortran)) complaint (_("Tag '%s' has unexpected children"), dwarf_tag_name (die->tag)); read_import_statement (die, cu); @@ -8794,7 +8794,7 @@ dw2_linkage_name (struct die_info *die, struct dwarf2= _cu *cu) =20 /* rustc emits invalid values for DW_AT_linkage_name. Ignore these. See https://github.com/rust-lang/rust/issues/32925. */ - if (cu->per_cu->lang () =3D=3D language_rust && linkage_name !=3D NULL + if (cu->lang () =3D=3D language_rust && linkage_name !=3D NULL && strchr (linkage_name, '{') !=3D NULL) linkage_name =3D NULL; =20 @@ -8826,7 +8826,7 @@ dwarf2_compute_name (const char *name, if (name =3D=3D NULL) name =3D dwarf2_name (die, cu); =20 - enum language lang =3D cu->per_cu->lang (); + enum language lang =3D cu->lang (); =20 /* For Fortran GDB prefers DW_AT_*linkage_name for the physname if prese= nt but otherwise compute it by typename_concat inside GDB. @@ -9075,7 +9075,7 @@ dwarf2_physname (const char *name, struct die_info *d= ie, struct dwarf2_cu *cu) if (!die_needs_namespace (die, cu)) return dwarf2_compute_name (name, die, cu, 1); =20 - if (cu->per_cu->lang () !=3D language_rust) + if (cu->lang () !=3D language_rust) mangled =3D dw2_linkage_name (die, cu); =20 /* DW_AT_linkage_name is missing in some cases - depend on what GDB @@ -9232,7 +9232,7 @@ read_alias (struct die_info *die, struct dwarf2_cu *c= u) static struct using_direct ** using_directives (struct dwarf2_cu *cu) { - if (cu->per_cu->lang () =3D=3D language_ada + if (cu->lang () =3D=3D language_ada && cu->get_builder ()->outermost_context_p ()) return cu->get_builder ()->get_global_using_directives (); else @@ -9323,7 +9323,7 @@ read_import_statement (struct die_info *die, struct d= warf2_cu *cu) else if (strlen (imported_name_prefix) > 0) canonical_name =3D obconcat (&objfile->objfile_obstack, imported_name_prefix, - (cu->per_cu->lang () =3D=3D language_d + (cu->lang () =3D=3D language_d ? "." : "::"), imported_name, (char *) NULL); @@ -9331,7 +9331,7 @@ read_import_statement (struct die_info *die, struct d= warf2_cu *cu) canonical_name =3D imported_name; =20 if (die->tag =3D=3D DW_TAG_imported_module - && cu->per_cu->lang () =3D=3D language_fortran) + && cu->lang () =3D=3D language_fortran) for (child_die =3D die->child; child_die && child_die->tag; child_die =3D child_die->sibling) { @@ -9557,7 +9557,7 @@ read_file_scope (struct die_info *die, struct dwarf2_= cu *cu) struct die_info *child_die; CORE_ADDR baseaddr; =20 - prepare_one_comp_unit (cu, die, cu->per_cu->lang ()); + prepare_one_comp_unit (cu, die, cu->lang ()); baseaddr =3D objfile->text_section_offset (); =20 get_scope_pc_bounds (die, &lowpc, &highpc, cu); @@ -11719,7 +11719,7 @@ queue_and_load_dwo_tu (void **slot, void *info) a real dependency of PER_CU on SIG_TYPE. That is detected later while processing PER_CU. */ if (maybe_queue_comp_unit (NULL, sig_type, cu->per_objfile, - cu->per_cu->lang ())) + cu->lang ())) load_full_type_unit (sig_type, cu->per_objfile); cu->per_cu->imported_symtabs_push (sig_type); } @@ -12009,7 +12009,7 @@ read_func_scope (struct die_info *die, struct dwarf= 2_cu *cu) =20 if (dwarf2_flag_true_p (die, DW_AT_main_subprogram, cu)) set_objfile_main_name (objfile, newobj->name->linkage_name (), - cu->per_cu->lang ()); + cu->lang ()); =20 /* If there is a location expression for DW_AT_frame_base, record it. */ @@ -12054,7 +12054,7 @@ read_func_scope (struct die_info *die, struct dwarf= 2_cu *cu) /* If we have a DW_AT_specification, we might need to import using directives from the context of the specification DIE. See the comment in determine_prefix. */ - if (cu->per_cu->lang () =3D=3D language_cplus + if (cu->lang () =3D=3D language_cplus && dwarf2_attr (die, DW_AT_specification, cu)) { struct dwarf2_cu *spec_cu =3D cu; @@ -12082,10 +12082,10 @@ read_func_scope (struct die_info *die, struct dwa= rf2_cu *cu) cstk.static_link, lowpc, highpc); =20 /* For C++, set the block's scope. */ - if ((cu->per_cu->lang () =3D=3D language_cplus - || cu->per_cu->lang () =3D=3D language_fortran - || cu->per_cu->lang () =3D=3D language_d - || cu->per_cu->lang () =3D=3D language_rust) + if ((cu->lang () =3D=3D language_cplus + || cu->lang () =3D=3D language_fortran + || cu->lang () =3D=3D language_d + || cu->lang () =3D=3D language_rust) && cu->processing_has_namespace_info) block_set_scope (block, determine_prefix (die, cu), &objfile->objfile_obstack); @@ -12585,7 +12585,7 @@ read_variable (struct die_info *die, struct dwarf2_= cu *cu) { struct rust_vtable_symbol *storage =3D NULL; =20 - if (cu->per_cu->lang () =3D=3D language_rust) + if (cu->lang () =3D=3D language_rust) { struct type *containing_type =3D rust_containing_type (die, cu); =20 @@ -13099,7 +13099,7 @@ dwarf2_get_subprogram_pc_bounds (struct die_info *d= ie, =20 /* If the language does not allow nested subprograms (either inside subprograms or lexical blocks), we're done. */ - if (cu->per_cu->lang () !=3D language_ada) + if (cu->lang () !=3D language_ada) return; =20 /* Check all the children of the given DIE. If it contains nested @@ -13904,7 +13904,7 @@ dwarf2_attach_fields_to_type (struct field_info *fi= p, struct type *type, type->set_fields ((struct field *) TYPE_ZALLOC (type, sizeof (struct field) * nfields)); =20 - if (fip->non_public_fields && cu->per_cu->lang () !=3D language_ada) + if (fip->non_public_fields && cu->lang () !=3D language_ada) { ALLOCATE_CPLUS_STRUCT_TYPE (type); =20 @@ -13923,7 +13923,7 @@ dwarf2_attach_fields_to_type (struct field_info *fi= p, struct type *type, =20 /* If the type has baseclasses, allocate and clear a bit vector for TYPE_FIELD_VIRTUAL_BITS. */ - if (!fip->baseclasses.empty () && cu->per_cu->lang () !=3D language_ada) + if (!fip->baseclasses.empty () && cu->lang () !=3D language_ada) { int num_bytes =3D B_BYTES (fip->baseclasses.size ()); unsigned char *pointer; @@ -13949,12 +13949,12 @@ dwarf2_attach_fields_to_type (struct field_info *= fip, struct type *type, switch (field.accessibility) { case DW_ACCESS_private: - if (cu->per_cu->lang () !=3D language_ada) + if (cu->lang () !=3D language_ada) SET_TYPE_FIELD_PRIVATE (type, i); break; =20 case DW_ACCESS_protected: - if (cu->per_cu->lang () !=3D language_ada) + if (cu->lang () !=3D language_ada) SET_TYPE_FIELD_PROTECTED (type, i); break; =20 @@ -13975,7 +13975,7 @@ dwarf2_attach_fields_to_type (struct field_info *fi= p, struct type *type, { case DW_VIRTUALITY_virtual: case DW_VIRTUALITY_pure_virtual: - if (cu->per_cu->lang () =3D=3D language_ada) + if (cu->lang () =3D=3D language_ada) error (_("unexpected virtuality in component of Ada type")); SET_TYPE_FIELD_VIRTUAL (type, i); break; @@ -14026,7 +14026,7 @@ dwarf2_add_member_fn (struct field_info *fip, struc= t die_info *die, const char *fieldname; struct type *this_type; =20 - if (cu->per_cu->lang () =3D=3D language_ada) + if (cu->lang () =3D=3D language_ada) error (_("unexpected member function in Ada type")); =20 /* Get name of member function. */ @@ -14059,7 +14059,7 @@ dwarf2_add_member_fn (struct field_info *fip, struc= t die_info *die, fnp =3D &flp->fnfields.back (); =20 /* Delay processing of the physname until later. */ - if (cu->per_cu->lang () =3D=3D language_cplus) + if (cu->lang () =3D=3D language_cplus) add_to_method_list (type, i, flp->fnfields.size () - 1, fieldname, die, cu); else @@ -14214,7 +14214,7 @@ static void dwarf2_attach_fn_fields_to_type (struct field_info *fip, struct type *type, struct dwarf2_cu *cu) { - if (cu->per_cu->lang () =3D=3D language_ada) + if (cu->lang () =3D=3D language_ada) error (_("unexpected member functions in Ada type")); =20 ALLOCATE_CPLUS_STRUCT_TYPE (type); @@ -14357,7 +14357,7 @@ static void quirk_ada_thick_pointer_struct (struct die_info *die, struct dwarf2_cu *cu, struct type *type) { - gdb_assert (cu->per_cu->lang () =3D=3D language_ada); + gdb_assert (cu->lang () =3D=3D language_ada); =20 /* Check for a structure with two children. */ if (type->code () !=3D TYPE_CODE_STRUCT || type->num_fields () !=3D 2) @@ -14536,9 +14536,9 @@ read_structure_type (struct die_info *die, struct d= warf2_cu *cu) name =3D dwarf2_name (die, cu); if (name !=3D NULL) { - if (cu->per_cu->lang () =3D=3D language_cplus - || cu->per_cu->lang () =3D=3D language_d - || cu->per_cu->lang () =3D=3D language_rust) + if (cu->lang () =3D=3D language_cplus + || cu->lang () =3D=3D language_d + || cu->lang () =3D=3D language_rust) { const char *full_name =3D dwarf2_full_name (name, die, cu); =20 @@ -14574,7 +14574,7 @@ read_structure_type (struct die_info *die, struct d= warf2_cu *cu) type->set_code (TYPE_CODE_STRUCT); } =20 - if (cu->per_cu->lang () =3D=3D language_cplus && die->tag =3D=3D DW_TAG_= class_type) + if (cu->lang () =3D=3D language_cplus && die->tag =3D=3D DW_TAG_class_ty= pe) type->set_is_declared_class (true); =20 /* Store the calling convention in the type if it's available in @@ -14786,7 +14786,7 @@ handle_struct_member_die (struct die_info *child_di= e, struct type *type, /* Rust doesn't have member functions in the C++ sense. However, it does emit ordinary functions as children of a struct DIE. */ - if (cu->per_cu->lang () =3D=3D language_rust) + if (cu->lang () =3D=3D language_rust) read_func_scope (child_die, cu); else { @@ -14950,7 +14950,7 @@ process_structure_scope (struct die_info *die, stru= ct dwarf2_cu *cu) /* Copy fi.nested_types_list linked list elements content into the allocated array TYPE_NESTED_TYPES_ARRAY (type). */ if (!fi.nested_types_list.empty () - && cu->per_cu->lang () !=3D language_ada) + && cu->lang () !=3D language_ada) { int count =3D fi.nested_types_list.size (); =20 @@ -14966,9 +14966,9 @@ process_structure_scope (struct die_info *die, stru= ct dwarf2_cu *cu) } =20 quirk_gcc_member_function_pointer (type, objfile); - if (cu->per_cu->lang () =3D=3D language_rust && die->tag =3D=3D DW_TAG_u= nion_type) + if (cu->lang () =3D=3D language_rust && die->tag =3D=3D DW_TAG_union_typ= e) cu->rust_unions.push_back (type); - else if (cu->per_cu->lang () =3D=3D language_ada) + else if (cu->lang () =3D=3D language_ada) quirk_ada_thick_pointer_struct (die, cu, type); =20 /* NOTE: carlton/2004-03-16: GCC 3.4 (or at least one of its @@ -15672,7 +15672,7 @@ read_array_type (struct die_info *die, struct dwarf= 2_cu *cu) maybe_set_alignment (cu, die, type); =20 struct type *replacement_type =3D nullptr; - if (cu->per_cu->lang () =3D=3D language_ada) + if (cu->lang () =3D=3D language_ada) { replacement_type =3D quirk_ada_thick_pointer (die, cu, type); if (replacement_type !=3D nullptr) @@ -15709,7 +15709,7 @@ read_array_order (struct die_info *die, struct dwar= f2_cu *cu) FIXME: dsl/2004-8-20: If G77 is ever fixed, this will also need version checking. */ =20 - if (cu->per_cu->lang () =3D=3D language_fortran + if (cu->lang () =3D=3D language_fortran && cu->producer && strstr (cu->producer, "GNU F77")) { return DW_ORD_row_major; @@ -16448,9 +16448,9 @@ prototyped_function_p (struct die_info *die, struct= dwarf2_cu *cu) languages that allow unprototyped functions (Eg: Objective C). For all other languages, assume that functions are always prototyped. */ - if (cu->per_cu->lang () !=3D language_c - && cu->per_cu->lang () !=3D language_objc - && cu->per_cu->lang () !=3D language_opencl) + if (cu->lang () !=3D language_c + && cu->lang () !=3D language_objc + && cu->lang () !=3D language_opencl) return 1; =20 /* RealView does not emit DW_AT_prototyped. We can not distinguish @@ -16575,7 +16575,7 @@ read_subroutine_type (struct die_info *die, struct = dwarf2_cu *cu) /* RealView does not mark THIS as const, which the testsuite expects. GCC marks THIS as const in method definitions, but not in the class specifications (GCC PR 43053). */ - if (cu->per_cu->lang () =3D=3D language_cplus + if (cu->lang () =3D=3D language_cplus && !TYPE_CONST (arg_type) && TYPE_FIELD_ARTIFICIAL (ftype, iparams)) { @@ -17011,7 +17011,7 @@ dwarf2_init_complex_target_type (struct dwarf2_cu *= cu, /* Try to find a suitable floating point builtin type of size BITS. We're going to use the name of this type as the name for the complex target type that we are about to create. */ - switch (cu->per_cu->lang ()) + switch (cu->lang ()) { case language_fortran: switch (bits) @@ -17101,7 +17101,7 @@ read_base_type (struct die_info *die, struct dwarf2= _cu *cu) } =20 if ((encoding =3D=3D DW_ATE_signed_fixed || encoding =3D=3D DW_ATE_unsig= ned_fixed) - && cu->per_cu->lang () =3D=3D language_ada + && cu->lang () =3D=3D language_ada && has_zero_over_zero_small_attribute (die, cu)) { /* brobecker/2018-02-24: This is a fixed point type for which @@ -17123,7 +17123,7 @@ read_base_type (struct die_info *die, struct dwarf2= _cu *cu) than an "else if". */ const char *gnat_encoding_suffix =3D nullptr; if ((encoding =3D=3D DW_ATE_signed || encoding =3D=3D DW_ATE_unsigned) - && cu->per_cu->lang () =3D=3D language_ada + && cu->lang () =3D=3D language_ada && name !=3D nullptr) { gnat_encoding_suffix =3D gnat_encoded_fixed_point_type_info (name); @@ -17180,7 +17180,7 @@ read_base_type (struct die_info *die, struct dwarf2= _cu *cu) type =3D dwarf2_init_integer_type (cu, objfile, bits, 0, name); break; case DW_ATE_unsigned: - if (cu->per_cu->lang () =3D=3D language_fortran + if (cu->lang () =3D=3D language_fortran && name && startswith (name, "character(")) type =3D init_character_type (objfile, bits, 1, name); @@ -17188,20 +17188,20 @@ read_base_type (struct die_info *die, struct dwar= f2_cu *cu) type =3D dwarf2_init_integer_type (cu, objfile, bits, 1, name); break; case DW_ATE_signed_char: - if (cu->per_cu->lang () =3D=3D language_ada - || cu->per_cu->lang () =3D=3D language_m2 - || cu->per_cu->lang () =3D=3D language_pascal - || cu->per_cu->lang () =3D=3D language_fortran) + if (cu->lang () =3D=3D language_ada + || cu->lang () =3D=3D language_m2 + || cu->lang () =3D=3D language_pascal + || cu->lang () =3D=3D language_fortran) type =3D init_character_type (objfile, bits, 0, name); else type =3D dwarf2_init_integer_type (cu, objfile, bits, 0, name); break; case DW_ATE_unsigned_char: - if (cu->per_cu->lang () =3D=3D language_ada - || cu->per_cu->lang () =3D=3D language_m2 - || cu->per_cu->lang () =3D=3D language_pascal - || cu->per_cu->lang () =3D=3D language_fortran - || cu->per_cu->lang () =3D=3D language_rust) + if (cu->lang () =3D=3D language_ada + || cu->lang () =3D=3D language_m2 + || cu->lang () =3D=3D language_pascal + || cu->lang () =3D=3D language_fortran + || cu->lang () =3D=3D language_rust) type =3D init_character_type (objfile, bits, 1, name); else type =3D dwarf2_init_integer_type (cu, objfile, bits, 1, name); @@ -17499,7 +17499,7 @@ read_subrange_type (struct die_info *die, struct dw= arf2_cu *cu) =20 /* Set LOW_DEFAULT_IS_VALID if current language and DWARF version allow omitting DW_AT_lower_bound. */ - switch (cu->per_cu->lang ()) + switch (cu->lang ()) { case language_c: case language_cplus: @@ -17635,7 +17635,7 @@ read_subrange_type (struct die_info *die, struct dw= arf2_cu *cu) range_type->bounds ()->flag_upper_bound_is_count =3D 1; =20 /* Ada expects an empty array on no boundary attributes. */ - if (attr =3D=3D NULL && cu->per_cu->lang () !=3D language_ada) + if (attr =3D=3D NULL && cu->lang () !=3D language_ada) range_type->bounds ()->high.set_undefined (); =20 name =3D dwarf2_name (die, cu); @@ -17668,7 +17668,7 @@ read_unspecified_type (struct die_info *die, struct= dwarf2_cu *cu) of the type is deferred to a different unit. When encountering such a type, we treat it as a stub, and try to resolve it later on, when needed. */ - if (cu->per_cu->lang () =3D=3D language_ada) + if (cu->lang () =3D=3D language_ada) type->set_is_stub (true); =20 return set_die_type (die, type, cu); @@ -20687,16 +20687,16 @@ new_symbol (struct die_info *die, struct type *ty= pe, struct dwarf2_cu *cu, OBJSTAT (objfile, n_syms++); =20 /* Cache this symbol's name and the name's demangled form (if any). = */ - sym->set_language (cu->per_cu->lang (), &objfile->objfile_obstack); + sym->set_language (cu->lang (), &objfile->objfile_obstack); /* Fortran does not have mangling standard and the mangling does dif= fer between gfortran, iFort etc. */ const char *physname - =3D (cu->per_cu->lang () =3D=3D language_fortran + =3D (cu->lang () =3D=3D language_fortran ? dwarf2_full_name (name, die, cu) : dwarf2_physname (name, die, cu)); const char *linkagename =3D dw2_linkage_name (die, cu); =20 - if (linkagename =3D=3D nullptr || cu->per_cu->lang () =3D=3D languag= e_ada) + if (linkagename =3D=3D nullptr || cu->lang () =3D=3D language_ada) sym->set_linkage_name (physname); else { @@ -20768,8 +20768,8 @@ new_symbol (struct die_info *die, struct type *type= , struct dwarf2_cu *cu, sym->set_aclass_index (LOC_BLOCK); attr2 =3D dwarf2_attr (die, DW_AT_external, cu); if ((attr2 !=3D nullptr && attr2->as_boolean ()) - || cu->per_cu->lang () =3D=3D language_ada - || cu->per_cu->lang () =3D=3D language_fortran) + || cu->lang () =3D=3D language_ada + || cu->lang () =3D=3D language_fortran) { /* Subprograms marked external are stored as a global symbol. Ada and Fortran subprograms, whether marked external or @@ -20834,7 +20834,7 @@ new_symbol (struct die_info *die, struct type *type= , struct dwarf2_cu *cu, =20 /* Fortran explicitly imports any global symbols to the local scope by DW_TAG_common_block. */ - if (cu->per_cu->lang () =3D=3D language_fortran && die->parent + if (cu->lang () =3D=3D language_fortran && die->parent && die->parent->tag =3D=3D DW_TAG_common_block) attr2 =3D NULL; =20 @@ -20888,7 +20888,7 @@ new_symbol (struct die_info *die, struct type *type= , struct dwarf2_cu *cu, =20 /* Fortran explicitly imports any global symbols to the local scope by DW_TAG_common_block. */ - if (cu->per_cu->lang () =3D=3D language_fortran && die->parent + if (cu->lang () =3D=3D language_fortran && die->parent && die->parent->tag =3D=3D DW_TAG_common_block) { /* SYMBOL_CLASS doesn't matter here because @@ -20982,16 +20982,16 @@ new_symbol (struct die_info *die, struct type *ty= pe, struct dwarf2_cu *cu, buildsym_compunit *builder =3D cu->get_builder (); list_to_add =3D (cu->list_in_scope =3D=3D builder->get_file_symbols () - && cu->per_cu->lang () =3D=3D language_cplus + && cu->lang () =3D=3D language_cplus ? builder->get_global_symbols () : cu->list_in_scope); =20 /* The semantics of C++ state that "struct foo { ... }" also defines a typedef for "foo". */ - if (cu->per_cu->lang () =3D=3D language_cplus - || cu->per_cu->lang () =3D=3D language_ada - || cu->per_cu->lang () =3D=3D language_d - || cu->per_cu->lang () =3D=3D language_rust) + if (cu->lang () =3D=3D language_cplus + || cu->lang () =3D=3D language_ada + || cu->lang () =3D=3D language_d + || cu->lang () =3D=3D language_rust) { /* The symbol's name is already allocated along with this objfile, so we don't need to @@ -21027,7 +21027,7 @@ new_symbol (struct die_info *die, struct type *type= , struct dwarf2_cu *cu, =20 list_to_add =3D (cu->list_in_scope =3D=3D cu->get_builder ()->get_file_symbols = () - && cu->per_cu->lang () =3D=3D language_cplus + && cu->lang () =3D=3D language_cplus ? cu->get_builder ()->get_global_symbols () : cu->list_in_scope); } @@ -21070,7 +21070,7 @@ new_symbol (struct die_info *die, struct type *type= , struct dwarf2_cu *cu, /* For the benefit of old versions of GCC, check for anonymous namespaces based on the demangled name. */ if (!cu->processing_has_namespace_info - && cu->per_cu->lang () =3D=3D language_cplus) + && cu->lang () =3D=3D language_cplus) cp_scan_for_anonymous_namespaces (cu->get_builder (), sym, objfile); } return (sym); @@ -21282,7 +21282,7 @@ need_gnat_info (struct dwarf2_cu *cu) { /* Assume that the Ada compiler was GNAT, which always produces the auxiliary information. */ - return (cu->per_cu->lang () =3D=3D language_ada); + return (cu->lang () =3D=3D language_ada); } =20 /* Return the auxiliary type of the die in question using its @@ -21659,10 +21659,10 @@ determine_prefix (struct die_info *die, struct dw= arf2_cu *cu) struct type *parent_type; const char *retval; =20 - if (cu->per_cu->lang () !=3D language_cplus - && cu->per_cu->lang () !=3D language_fortran - && cu->per_cu->lang () !=3D language_d - && cu->per_cu->lang () !=3D language_rust) + if (cu->lang () !=3D language_cplus + && cu->lang () !=3D language_fortran + && cu->lang () !=3D language_d + && cu->lang () !=3D language_rust) return ""; =20 retval =3D anonymous_struct_prefix (die, cu); @@ -21750,7 +21750,7 @@ determine_prefix (struct die_info *die, struct dwar= f2_cu *cu) /* GCC 4.0 and 4.1 had a bug (PR c++/28460) where they generated bogus DW_TAG_namespace DIEs with a name of "::" for the global namespace. Work around this problem here. */ - if (cu->per_cu->lang () =3D=3D language_cplus + if (cu->lang () =3D=3D language_cplus && strcmp (parent_type->name (), "::") =3D=3D 0) return ""; /* We give a name to even anonymous namespaces. */ @@ -21771,7 +21771,7 @@ determine_prefix (struct die_info *die, struct dwar= f2_cu *cu) case DW_TAG_compile_unit: case DW_TAG_partial_unit: /* gcc-4.5 -gdwarf-4 can drop the enclosing namespace. Cope. */ - if (cu->per_cu->lang () =3D=3D language_cplus + if (cu->lang () =3D=3D language_cplus && !per_objfile->per_bfd->types.empty () && die->child !=3D NULL && (die->tag =3D=3D DW_TAG_class_type @@ -21786,7 +21786,7 @@ determine_prefix (struct die_info *die, struct dwar= f2_cu *cu) case DW_TAG_subprogram: /* Nested subroutines in Fortran get a prefix with the name of the parent's subroutine. */ - if (cu->per_cu->lang () =3D=3D language_fortran) + if (cu->lang () =3D=3D language_fortran) { if ((die->tag =3D=3D DW_TAG_subprogram) && (dwarf2_name (parent, cu) !=3D NULL)) @@ -21825,7 +21825,7 @@ typename_concat (struct obstack *obs, const char *p= refix, const char *suffix, if (suffix =3D=3D NULL || suffix[0] =3D=3D '\0' || prefix =3D=3D NULL || prefix[0] =3D=3D '\0') sep =3D ""; - else if (cu->per_cu->lang () =3D=3D language_d) + else if (cu->lang () =3D=3D language_d) { /* For D, the 'main' function could be defined in any module, but it should never be prefixed. */ @@ -21837,7 +21837,7 @@ typename_concat (struct obstack *obs, const char *p= refix, const char *suffix, else sep =3D "."; } - else if (cu->per_cu->lang () =3D=3D language_fortran && physname) + else if (cu->lang () =3D=3D language_fortran && physname) { /* This is gfortran specific mangling. Normally DW_AT_linkage_name = or DW_AT_MIPS_linkage_name is preferred and used instead. */ @@ -21878,7 +21878,7 @@ static const char * dwarf2_canonicalize_name (const char *name, struct dwarf2_cu *cu, struct objfile *objfile) { - if (name && cu->per_cu->lang () =3D=3D language_cplus) + if (name && cu->lang () =3D=3D language_cplus) { gdb::unique_xmalloc_ptr canon_name =3D cp_canonicalize_string (name); @@ -22255,10 +22255,10 @@ follow_die_offset (sect_offset sect_off, int offs= et_in_dwz, Even if maybe_queue_comp_unit doesn't require us to load the CU's DIEs, it doesn't mean they are currently loaded. Since we require them to be loaded, we must check for ourselves. */ - if (maybe_queue_comp_unit (cu, per_cu, per_objfile, cu->per_cu->lang= ()) + if (maybe_queue_comp_unit (cu, per_cu, per_objfile, cu->lang ()) || per_objfile->get_cu (per_cu) =3D=3D nullptr) load_full_comp_unit (per_cu, per_objfile, per_objfile->get_cu (per_cu), - false, cu->per_cu->lang ()); + false, cu->lang ()); =20 target_cu =3D per_objfile->get_cu (per_cu); gdb_assert (target_cu !=3D nullptr);