aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2/read.h
AgeCommit message (Collapse)AuthorFilesLines
2020-04-07gdb: small cleanups in dwarf2_psymtab constructorsSimon Marchi1-7/+3
I noticed that only one of the two dwarf2_psymtab constructors are actually used. The one that is used accepts an `addr` parameter (the base text offset), but its sole caller passes a constant, 0. We want to keep calling the three-arguments standard_psymtab constructor form, however, since it differs from the two-arguments form in subtle ways. Also, I believe the dwarf2_per_cu_data associated to the created dwarf2_psymtab should be passed as a constructor argument. That will help me in a future patchset, to convince myself that the `per_cu_data` field can't be NULL. So this patch: - Removes the two-parameters constructor of dwarf2_psymtab, as it is unused. - Removes the `addr` parameter of the remaining constructor, passing 0 directly to the base class' constructor. - Adds a `per_cu` parameter, to assign the `per_cu_data` field at construction. gdb/ChangeLog: * dwarf2/read.h (struct dwarf2_psymtab): Remove two-parameters constructor. Remove `addr` parameter from other constructor and add `per_cu` parameter. * dwarf2/read.c (create_partial_symtab): Update.
2020-03-26Convert read_indirect_line_string to a methodTom Tromey1-0/+8
This changes read_indirect_line_string to be a method on dwarf2_per_objfile. This makes it a bit simpler to share between files. gdb/ChangeLog 2020-03-26 Tom Tromey <tom@tromey.com> * dwarf2/read.h (struct dwarf2_per_objfile) <read_line_string>: Declare method. * dwarf2/read.c (read_attribute_value): Update. (dwarf2_per_objfile::read_line_string): Rename from read_indirect_line_string. (read_formatted_entries): Update.
2020-03-26Introduce dwarf2/dwz.hTom Tromey1-31/+0
This moves "struct dwz_file" to a new header file, dwarf2/dwz.h. gdb/ChangeLog 2020-03-26 Tom Tromey <tom@tromey.com> * dwarf2/read.h (struct dwz_file): Move to dwz.h. * dwarf2/read.c: Add include. * dwarf2/index-write.c: Add include. * dwarf2/index-cache.c: Add include. * dwarf2/dwz.h: New file.
2020-03-17[gdb] Skip imports of c++ CUsTom de Vries1-0/+6
The DWARF standard appendix E.1 describes techniques that can be used for compression and deduplication: DIEs can be factored out into a new compilation unit, and referenced using DW_FORM_ref_addr. Such a new compilation unit can either use a DW_TAG_compile_unit or DW_TAG_partial_unit. If a DW_TAG_compile_unit is used, its contents is evaluated by consumers as though it were an ordinary compilation unit. If a DW_TAG_partial_unit is used, it's only considered by consumers in the context of a DW_TAG_imported_unit. An example of when DW_TAG_partial_unit is required is when the factored out DIEs are not top-level, f.i. because they were children of a namespace. In such a case the corresponding DW_TAG_imported_unit will occur as child of the namespace. In the case of factoring out DIEs from c++ compilation units, we can factor out into a new DW_TAG_compile_unit, and no DW_TAG_imported_unit is required. This begs the question how to interpret a top-level DW_TAG_imported_unit of a c++ DW_TAG_compile_unit compilation unit. The semantics of DW_TAG_imported_unit describe that the imported unit logically appears at the point of the DW_TAG_imported_unit entry. But it's not clear what the effect should be in this case, since all the imported DIEs are already globally visible anyway, due to the use of DW_TAG_compile_unit. So, skip top-level imports of c++ DW_TAG_compile_unit compilation units in process_imported_unit_die. Using the cc1 binary from PR23710 comment 1 and setting a breakpoint on do_rpo_vn: ... $ gdb \ -batch \ -iex "maint set dwarf max-cache-age 316" \ -iex "set language c++" \ -ex "b do_rpo_vn" \ cc1 ... we get a 8.1% reduction in execution time, due to reducing the number of partial symtabs expanded into full symtabs from 212 to 175. Build and reg-tested on x86_64-linux. gdb/ChangeLog: 2020-03-17 Tom de Vries <tdevries@suse.de> PR gdb/23710 * dwarf2/read.h (struct dwarf2_per_cu_data): Add unit_type and lang fields. * dwarf2/read.c (process_psymtab_comp_unit): Initialize unit_type and lang fields. (process_imported_unit_die): Skip import of c++ CUs.
2020-02-26Move more declarations from dwarf2/loc.h to dwarf2/read.hSimon Marchi1-0/+33
All these functions have their implementations in dwarf2/read.c, so move their declarations to dwarf2/read.h. Move the doc to the header, at the same time. gdb/ChangeLog: * dwarf2/loc.h (dwarf2_fetch_die_loc_sect_off, dwarf2_fetch_die_loc_cu_off, dwarf2_fetch_constant_bytes, dwarf2_fetch_die_type_sect_off): Move to... * dwarf2/read.h (dwarf2_fetch_die_loc_sect_off, dwarf2_fetch_die_loc_cu_off, dwarf2_fetch_constant_bytes, dwarf2_fetch_die_type_sect_off): ... here. * dwarf2/read.c (dwarf2_fetch_die_loc_sect_off, dwarf2_fetch_die_loc_cu_off, dwarf2_fetch_constant_bytes, dwarf2_fetch_die_type_sect_off): Move doc to header file.
2020-02-25Move dwarf2_read_addr_index declaration to dwarf2/read.hSimon Marchi1-0/+8
The implementation is in dwarf2/read.c, so the declaration belongs in dwarf2/read.h. Also, move the documentation there. gdb/ChangeLog: * dwarf2/loc.h (dwarf2_read_addr_index): Move... * dwarf2/read.h (dwarf2_read_addr_index): ... here. * dwarf2/read.c (dwarf2_read_addr_index): Move doc to header.
2020-02-25Move dwarf2_get_die_type declaration to dwarf2/read.hSimon Marchi1-0/+6
Since its implementation is in dwarf2/read.c, its declaration belongs in dwarf2/read.h. Move the documentation to the .h at the same time. gdb/ChangeLog: * loc.h (dwarf2_get_die_type): Move to... * read.h (dwarf2_get_die_type): ... here. * read.c (dwarf2_get_die_type): Move doc to header.
2020-02-24Convert IS_TYPE_UNIT_GROUP to methodTom Tromey1-0/+7
This converts the IS_TYPE_UNIT_GROUP to a method on dwarf2_per_cu_data. gdb/ChangeLog 2020-02-24 Tom Tromey <tom@tromey.com> * dwarf2/read.h (struct dwarf2_per_cu_data) <type_unit_group_p>: New method. * dwarf2/read.c (IS_TYPE_UNIT_GROUP): Remove. (dw2_do_instantiate_symtab, dw2_get_file_names) (build_type_psymtab_dependencies, load_full_type_unit): Update.
2020-02-08Add some methods to dwarf2_per_cu_dataTom Tromey1-0/+43
This changes a few helper functions to be methods on dwarf2_per_cu_data. 2020-02-08 Tom Tromey <tom@tromey.com> * dwarf2/loc.c (dwarf2_find_location_expression) (dwarf_evaluate_loc_desc::get_tls_address) (dwarf_evaluate_loc_desc::push_dwarf_reg_entry_value) (rw_pieced_value, dwarf2_evaluate_loc_desc_full) (dwarf2_locexpr_baton_eval, dwarf2_evaluate_property) (dwarf2_compile_property_to_c) (dwarf2_loc_desc_get_symbol_read_needs) (dwarf2_compile_expr_to_ax, locexpr_describe_location) (locexpr_tracepoint_var_ref, locexpr_generate_c_location) (loclist_describe_location, loclist_tracepoint_var_ref) (loclist_generate_c_location): Update. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update. * dwarf2/loc.h (dwarf2_per_cu_objfile, dwarf2_per_cu_addr_size) (dwarf2_per_cu_ref_addr_size, dwarf2_per_cu_offset_size) (dwarf2_per_cu_text_offset, dwarf2_version): Don't declare. * dwarf2/read.c (dwarf2_per_cu_data::objfile) (dwarf2_per_cu_data::addr_size) (dwarf2_per_cu_data::ref_addr_size) (dwarf2_per_cu_data::text_offset) (dwarf2_per_cu_data::addr_type): Now methods. (per_cu_header_read_in): Make per_cu "const". (dwarf2_version): Remove. (dwarf2_per_cu_data::int_type): Now a method. (dwarf2_per_cu_data::_addr_sized_int_type): Likewise. (set_die_type, read_array_type, read_subrange_index_type) (read_tag_string_type, read_subrange_type): Update. * dwarf2/read.h (struct dwarf2_per_cu_data) <addr_size, offset_size, ref_addr_size, text_offset, addr_type, version, objfile, int_type, addr_sized_int_type>: Declare methods. Change-Id: I07a42fa26e00795352389fa7a0cc1c12997d26f7
2020-02-08Move dwarf2_per_cu_data::imported_symtabs earlierTom Tromey1-26/+26
This moves dwarf2_per_cu_data::imported_symtabs earlier, near where the other data members are located. 2020-02-08 Tom Tromey <tom@tromey.com> * dwarf2/read.h (struct dwarf2_per_cu_data) <imported_symtabs>: Move earlier. Change-Id: I314ddaa6f67c53a848e513b3f6d42913bd957833
2020-02-08Move DWARF line_header to new fileTom Tromey1-0/+3
This moves the line_header class to a pair of new files, making dwarf2/read.c somewhat smaller. 2020-02-08 Tom Tromey <tom@tromey.com> * dwarf2/read.h (dwarf_line_debug): Declare. * Makefile.in (COMMON_SFILES): Add dwarf2/line-header.c. * dwarf2/read.c: Move line_header code to new files. (dwarf_line_debug): No longer static. * dwarf2/line-header.c: New file. * dwarf2/line-header.h: New file. Change-Id: I8d9d8a2398b4e888e20cc5dd68d041c28b5a06e3
2020-02-08Move dwarf_always_disassemble to dwarf2/loc.cTom Tromey1-2/+0
dwarf_always_disassemble is only used in dwarf2/loc.c, so move the definition and the command infrastructure to that file. 2020-02-08 Tom Tromey <tom@tromey.com> * dwarf2/read.c (dwarf_always_disassemble) (show_dwarf_always_disassemble): Move to loc.c. (_initialize_dwarf2_read): Move "always-disassemble" registration to loc.c. * dwarf2/read.h (dwarf_always_disassemble): Don't declare. * dwarf2/loc.c (dwarf_always_disassemble): Move from read.c. Now static. (show_dwarf_always_disassemble): Move from read.c. (_initialize_dwarf2loc): Move always-disassemble from read.c. Change-Id: I33fb88112e98e583c3f4919d20e4d100f2ea0124
2020-02-08Change dwarf2_per_objfile::quick_file_names_table to htab_upTom Tromey1-1/+1
This changes dwarf2_per_objfile::quick_file_names_table to be an htab_up. This just removes a bit of manual management. 2020-02-08 Tom Tromey <tom@tromey.com> * dwarf2/read.c (~dwarf2_per_objfile): Update. (create_quick_file_names_table): Return htab_up. (dw2_get_file_names_reader, dw2_forget_cached_source_info): Update. * dwarf2/read.h (struct dwarf2_per_objfile) <quick_file_names_table>: Now htab_up. Change-Id: I4ff2fce8b8af27f4bfe01a11b97a889edfd23151
2020-02-08Change dwarf2_per_objfile::die_type_hash to htab_upTom Tromey1-1/+1
This changes dwarf2_per_objfile::die_type_hash to be an htab_up, moving its contents off the objfile obstack. 2020-02-08 Tom Tromey <tom@tromey.com> * dwarf2/read.c (set_die_type, get_die_type_at_offset): Update. * dwarf2/read.h (struct dwarf2_per_objfile) <die_type_hash>: Now htab_up. Change-Id: Ic651f99ebf71bf7ad2dc2880192adacf7b60964a
2020-02-08Change dwarf2_per_objfile::line_header_hash to htab_upTom Tromey1-1/+1
This changes dwarf2_per_objfile::line_header_hash to be an htab_up, and changes it to use heap allocation. 2020-02-08 Tom Tromey <tom@tromey.com> * dwarf2/read.c (~dwarf2_per_objfile): Don't delete line_header_hash. (handle_DW_AT_stmt_list): Update. Don't allocate on obstack. * dwarf2/read.h (struct dwarf2_per_objfile) <line_header_hash>: Change type to htab_up. Change-Id: Icb148a270838c0f96f38fc4a28b5b77d067927b6
2020-02-08Change dwarf2_per_objfile::type_unit_groups to htab_upTom Tromey1-1/+1
This changes dwarf2_per_objfile::type_unit_groups to be an htab_up, again allowing us to move the memory used by the hash table from the objfile obstack to the heap. 2020-02-08 Tom Tromey <tom@tromey.com> * dwarf2/read.c (allocate_type_unit_groups_table): Return htab_up. Don't allocate on obstack. (get_type_unit_group, dwarf2_build_psymtabs_hard): Update. * dwarf2/read.h (struct dwarf2_per_objfile) <type_unit_groups>: Change type to htab_up. Change-Id: Ia045df0ff3ec30aac813da5a9a2314a607ef7ec8
2020-02-08Change dwarf2_per_objfile::signatured_types to be htab_upTom Tromey1-1/+1
This changes dwarf2_per_objfile::signatured_types to be an htab_up. This in turn lets us change it not to use the objfile obstack for allocation; obstack allocation for hash tables is a bad practice because it leads to excess memory use if the table is ever resized. gdb/ChangeLog 2020-02-08 Tom Tromey <tom@tromey.com> * dwarf2/read.h (struct dwarf2_per_objfile) <signatured_types>: Change type to htab_up. * dwarf2/read.c (create_signatured_type_table_from_index) (create_signatured_type_table_from_debug_names) (create_all_type_units, add_type_unit) (lookup_dwo_signatured_type, lookup_signatured_type) (process_skeletonless_type_unit): Update. (create_debug_type_hash_table, create_debug_types_hash_table): Change type of types_htab. (allocate_signatured_type_table, allocate_dwo_unit_table): Return htab_up. Don't allocate on obstack. (create_cus_hash_table): Change type of cus_htab parameter. (struct dwo_file) <cus, tus>: Now htab_up. (lookup_dwo_signatured_type, lookup_dwo_cutu) (process_dwo_file_for_skeletonless_type_units, lookup_dwo_cutu) (queue_and_load_all_dwo_tus): Update. * dwarf2/index-write.c (write_gdbindex): Update. (write_debug_names): Update. Change-Id: I290a209b96945fb5f415c82723b62830e9c4b467
2020-02-08Remove DWARF queue-related globalsTom Tromey1-0/+23
This removes some queue-related globals from the DWARF reader, in favor of a new member on dwarf2_per_objfile. Globals must be avoided in this code, because they prevent multi-threading the reader. gdb/ChangeLog 2020-02-08 Tom Tromey <tom@tromey.com> * dwarf2/read.h (struct dwarf2_queue_item): Move from dwarf2/read.c. Remove "next" member. Add constructor ntad destructor. (struct dwarf2_per_objfile) <queue>: New member. * dwarf2/read.c (struct dwarf2_queue_item): Move to dwarf2/read.h. (dwarf2_queue, dwarf2_queue_tail): Remove. (class dwarf2_queue_guard): Add parameter to constructor. Use DISABLE_COPY_AND_ASSIGN. <m_per_objfile>: New member. <~dwarf2_queue_guard>: Rewrite. (dw2_do_instantiate_symtab, queue_comp_unit, process_queue): Update. (~dwarf2_queue_item): New. Change-Id: Ied1f6ff3691352a66c4709b0b2cba0588f49f79a
2020-02-08Move DWARF code to dwarf2/ subdirectoryTom Tromey1-0/+455
This moves all the remaining DWARF code to the new dwarf2 subdirectory. This is just a simple renaming, with updates to includes as needed. gdb/ChangeLog 2020-02-08 Tom Tromey <tom@tromey.com> * dwarf2/expr.c: Rename from dwarf2expr.c. * dwarf2/expr.h: Rename from dwarf2expr.h. * dwarf2/frame-tailcall.c: Rename from dwarf2-frame-tailcall.c. * dwarf2/frame-tailcall.h: Rename from dwarf2-frame-tailcall.h. * dwarf2/frame.c: Rename from dwarf2-frame.c. * dwarf2/frame.h: Rename from dwarf2-frame.h. * dwarf2/index-cache.c: Rename from dwarf-index-cache.c. * dwarf2/index-cache.h: Rename from dwarf-index-cache.h. * dwarf2/index-common.c: Rename from dwarf-index-common.c. * dwarf2/index-common.h: Rename from dwarf-index-common.h. * dwarf2/index-write.c: Rename from dwarf-index-write.c. * dwarf2/index-write.h: Rename from dwarf-index-write.h. * dwarf2/loc.c: Rename from dwarf2loc.c. * dwarf2/loc.h: Rename from dwarf2loc.h. * dwarf2/read.c: Rename from dwarf2read.c. * dwarf2/read.h: Rename from dwarf2read.h. * dwarf2/abbrev.c, aarch64-tdep.c, alpha-tdep.c, amd64-darwin-tdep.c, arc-tdep.c, arm-tdep.c, bfin-tdep.c, compile/compile-c-symbols.c, compile/compile-cplus-symbols.c, compile/compile-loc2c.c, cris-tdep.c, csky-tdep.c, findvar.c, gdbtypes.c, guile/scm-type.c, h8300-tdep.c, hppa-bsd-tdep.c, hppa-linux-tdep.c, i386-darwin-tdep.c, i386-linux-tdep.c, i386-tdep.c, iq2000-tdep.c, m32c-tdep.c, m68hc11-tdep.c, m68k-tdep.c, microblaze-tdep.c, mips-tdep.c, mn10300-tdep.c, msp430-tdep.c, nds32-tdep.c, nios2-tdep.c, or1k-tdep.c, riscv-tdep.c, rl78-tdep.c, rs6000-tdep.c, rx-tdep.c, s12z-tdep.c, s390-tdep.c, score-tdep.c, sh-tdep.c, sparc-linux-tdep.c, sparc-tdep.c, sparc64-linux-tdep.c, sparc64-tdep.c, tic6x-tdep.c, tilegx-tdep.c, v850-tdep.c, xstormy16-tdep.c, xtensa-tdep.c: Update. * Makefile.in (COMMON_SFILES): Update. (HFILES_NO_SRCDIR): Update. Change-Id: Ied9ce1436cd27ac4a4cffef10ec92e396f181928