aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2read.c
AgeCommit message (Collapse)AuthorFilesLines
2018-03-11Use std::vector for field lists in dwarf2read.cTom Tromey1-193/+96
This changes dwarf2read.c to use std::vector rather than a linked list when managing the fields and base classes to be added to a type. This removes some bookkeeping types and also allows the removal of some cleanups. gdb/ChangeLog 2018-03-11 Tom Tromey <tom@tromey.com> * dwarf2read.c (struct nextfield): Add initializers. (struct nextfnfield): Remove. (struct fnfieldlist): Add initializers. Remove "length" and "head", use std::vector. (struct decl_field_list): Remove. (struct field_info): Add initializers. <fields, baseclasses>: Now std::vector. <nbaseclasses, nfnfields, typedef_field_list_count, nested_types_list_count>: Remove. (dwarf2_add_field, dwarf2_add_type_defn) (dwarf2_attach_fields_to_type, dwarf2_add_member_fn) (dwarf2_attach_fn_fields_to_type, handle_struct_member_die) (process_structure_scope): Update.
2018-03-11Remove cleanup from build_type_psymtabs_1Tom Tromey1-20/+9
This removes a cleanup from build_type_psymtabs_1, by using std::vector rather than manual memory management. gdb/ChangeLog 2018-03-11 Tom Tromey <tom@tromey.com> * dwarf2read.c (sort_tu_by_abbrev_offset): Change to be suitable for use by std::sort. (build_type_psymtabs_1): Use std::vector.
2018-03-01Fix Rust enum test failuresTom Tromey1-2/+5
Pedro pointed out that some Rust tests were failing after the recent enum change. I was able to reproduce this even with the most current Rust compiler -- no test was failing, but rather the gdb internal error was causing an "untested" result, which I didn't notice. The internal error is caused by a bad assertion in alloc_discriminant_info. This happened because, in an earlier version of the patch, the discriminant could only appear at index 0. However, it can now appear anywhere. This patch fixes the assertion in the obvious way, and adds a second assertion to ensure that the discriminant is also correct. Fixing this revealed a real failure, which was caused by using the wrong base name when computing the name of a univariant enum's sole member. This is also fixed here. Tested by running the gdb.rust tests with rustc 1.23 and double-checking the summary: # of expected passes 276 Note that if you try this yourself, it is still possible to get an "untested" result from traits.exp if your Rust compiler is old enough. 2018-03-01 Tom Tromey <tom@tromey.com> * dwarf2read.c (alloc_discriminant_info): Fix default_index assertion. Add assertion for discriminant_index. (quirk_rust_enum): Use correct base type name in univariant case.
2018-02-28Create new common/pathstuff.[ch]Sergio Durigan Junior1-0/+1
This commit moves the path manipulation routines found on utils.c to a new common/pathstuff.c, and updates the Makefile.in's accordingly. The routines moved are "gdb_realpath", "gdb_realpath_keepfile" and "gdb_abspath". This will be needed because gdbserver will have to call "gdb_abspath" on my next patch, which implements a way to expand the path of the inferior provided by the user in order to allow specifying just the binary name when starting gdbserver, like: $ gdbserver :1234 a.out With the recent addition of the startup-with-shell feature on gdbserver, this scenario doesn't work anymore if the user doesn't have the current directory listed in the PATH variable. I had to do a minor adjustment on "gdb_abspath" because we don't have access to "tilde_expand" on gdbserver, so now the function is using "gdb_tilde_expand" instead. Otherwise, the code is the same. Regression tested on the BuildBot, without regressions. gdb/ChangeLog: 2018-02-28 Sergio Durigan Junior <sergiodj@redhat.com> * Makefile.in (COMMON_SFILES): Add "common/pathstuff.c". (HFILES_NO_SRCDIR): Add "common/pathstuff.h". * auto-load.c: Include "common/pathstuff.h". * common/common-def.h (current_directory): Move here. * common/gdb_tilde_expand.c (gdb_tilde_expand_up): New function. * common/gdb_tilde_expand.h (gdb_tilde_expand_up): New prototype. * common/pathstuff.c: New file. * common/pathstuff.h: New file. * compile/compile.c: Include "common/pathstuff.h". * defs.h (current_directory): Move to "common/common-defs.h". * dwarf2read.c: Include "common/pathstuff.h". * exec.c: Likewise. * guile/scm-safe-call.c: Likewise. * linux-thread-db.c: Likewise. * main.c: Likewise. * nto-tdep.c: Likewise. * objfiles.c: Likewise. * source.c: Likewise. * symtab.c: Likewise. * utils.c: Include "common/pathstuff.h". (gdb_realpath): Move to "common/pathstuff.c". (gdb_realpath_keepfile): Likewise. (gdb_abspath): Likewise. * utils.h (gdb_realpath): Move to "common/pathstuff.h". (gdb_realpath_keepfile): Likewise. (gdb_abspath): Likewise. gdb/gdbserver/ChangeLog: 2018-02-28 Sergio Durigan Junior <sergiodj@redhat.com> * Makefile.in (SFILES): Add "$(srcdir)/common/pathstuff.c". (OBJS): Add "pathstuff.o". * server.c (current_directory): New global variable. (captured_main): Initialize "current_directory".
2018-02-26Handle DW_TAG_variant_part and DW_TAG_variantTom Tromey1-37/+181
This changes dwarf2read to understand DW_TAG_variant_part and DW_TAG_variant. Note that DW_AT_discr_list is not handled. I did not need this for Rust. I imagine this should not be too hard to add later, should someone need it. Meanwhile I have gdb emit a complaint if it is seen. There is a lurking issue concerning the placement of the discriminant in the DWARF. For Rust, I ended up following the letter of the standard and having the discriminant be a child of the DW_TAG_variant_part. However, GCC's Ada support does not do this. Pierre-Marie filed this with the DWARF committee: http://dwarfstd.org/ShowIssue.php?issue=180123.1 However as that is read-only, if you have comments you might consider adding them to the GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83935 Finally, there is a DWARF extension lurking in here. In Rust, a univariant enum will not have a discriminant. However, in order to unify the representation of all data-carrying enums, I've made LLVM (and my forthcoming rustc patch) emit a univariant enum using a DW_TAG_variant with a single variant part and without DW_AT_discr. The lack of this DW_AT_discr is the extension. I will submit an issue on dwarfstd.org about this. 2018-02-26 Tom Tromey <tom@tromey.com> * dwarf2read.c (struct variant_field): New. (struct nextfield) <variant>: New field. (dwarf2_add_field): Handle DW_TAG_variant_part. (dwarf2_attach_fields_to_type): Attach a discriminant_info to a discriminated union. (read_structure_type): Handle DW_TAG_variant_part. (handle_struct_member_die): New function, extracted from process_structure_scope. Handle DW_TAG_variant. (process_structure_scope): Handle discriminated unions. Call handle_struct_member_die. 2018-02-26 Tom Tromey <tom@tromey.com> * gdb.dwarf2/variant.c: New file. * gdb.dwarf2/variant.exp: New file.
2018-02-26Convert Rust to use discriminated unionsTom Tromey1-0/+313
A Rust enum is, essentially, a discriminated union. Currently the Rust language support handles Rust enums locally, in rust-lang.c. However, because I am changing the Rust compiler to use DW_TAG_variant* to represent enums, it seemed better to have a single internal representation for Rust enums in gdb. This patch implements this idea by moving the current Rust enum handling code to dwarf2read. This allows the simplification of some parts of rust-lang.c as well. 2018-02-26 Tom Tromey <tom@tromey.com> * rust-lang.h (rust_last_path_segment): Declare. * rust-lang.c (rust_last_path_segment): Now public. Change contract. (struct disr_info): Remove. (RUST_ENUM_PREFIX, RUST_ENCODED_ENUM_REAL) (RUST_ENCODED_ENUM_HIDDEN, rust_union_is_untagged) (rust_get_disr_info, rust_tuple_variant_type_p): Remove. (rust_enum_p, rust_enum_variant): New function. (rust_underscore_fields): Remove "offset" parameter. (rust_print_enum): New function. (rust_val_print) <TYPE_CODE_UNION>: Remove enum code. <TYPE_CODE_STRUCT>: Call rust_print_enum when appropriate. (rust_print_struct_def): Add "for_rust_enum" parameter. Handle enums. (rust_internal_print_type): New function, from rust_print_type. Remove enum code. (rust_print_type): Call rust_internal_print_type. (rust_evaluate_subexp) <STRUCTOP_ANONYMOUS, STRUCTOP_STRUCT>: Update enum handling. * dwarf2read.c (struct dwarf2_cu) <rust_unions>: New field. (rust_fully_qualify, alloc_discriminant_info, quirk_rust_enum) (rust_union_quirks): New functions. (process_full_comp_unit, process_full_type_unit): Call rust_union_quirks. (process_structure_scope): Update rust_unions if necessary. 2018-02-26 Tom Tromey <tom@tromey.com> * gdb.rust/simple.exp: Accept more possible results in enum test.
2018-02-26Move read_partial_die to partial_die_info::readYao Qi1-52/+56
gdb: 2018-02-26 Yao Qi <yao.qi@linaro.org> * dwarf2read.c (struct partial_die_info) <read>: New method. (read_partial_die): Remove the declaration. (load_partial_dies): Update. (partial_die_info::partial_die_info): (read_partial_die): Change it to partial_die_info::read.
2018-02-26Move fixup_partial_die to partial_die_info::fixupYao Qi1-38/+35
fixup_partial_die can be a partial_die_info method fixup. gdb: 2018-02-26 Yao Qi <yao.qi@linaro.org> * dwarf2read.c (struct partial_die_info) <fixup>: New method. (fixup_partial_die): Remove declaration. (scan_partial_symbols): Update. (partial_die_parent_scope): Likewise. (partial_die_full_name): Likewise. (fixup_partial_die): Change it to partial_die_info::fixup.
2018-02-26Remove one argument abbrev_len in read_partial_dieYao Qi1-7/+5
gdb: 2018-02-26 Yao Qi <yao.qi@linaro.org> * dwarf2read.c (read_partial_die): Update the declaration. (load_partial_dies): Caller update. (read_partial_die): Remove one argument abbrev_len.
2018-02-26Class-fy partial_die_infoYao Qi1-26/+62
This patch is to class-fy partial_die_info. Two things special here, - disable assignment operator, but keep copy ctor, which is used in load_partial_dies, - have a private ctor which is only used by dwarf2_cu::find_partial_die, I don't want other code use it, so make it private, gdb: 2018-02-26 Yao Qi <yao.qi@linaro.org> * dwarf2read.c (struct partial_die_info): Add ctor, delete assignment operator. (load_partial_dies): Use ctor and copy ctor. (read_partial_die): Update. (dwarf2_cu::find_partial_die): Use ctor.
2018-02-26Change find_partial_die_in_comp_unit to dwarf2_cu::find_partial_dieYao Qi1-6/+8
This patch changes find_partial_die_in_comp_unit to a dwarf2_cu method find_partial_die. gdb: 2018-02-26 Yao Qi <yao.qi@linaro.org> * dwarf2read.c (struct dwarf2_cu) <find_partial_die>: New method. (find_partial_die_in_comp_unit): Change it to dwarf2_cu::find_partial_die. (find_partial_die): Update.
2018-02-26Don't check abbrev is NULL in read_partial_dieYao Qi1-10/+7
'abbrev' won't be NULL, so don't check it. gdb: 2018-02-26 Yao Qi <yao.qi@linaro.org> * dwarf2read.c (read_partial_die): Remove the code checking abbrev is NULL.
2018-02-26Re-write partial_die_info allocation in load_partial_diesYao Qi1-30/+25
load_partial_dies has a "while (1)" loop to visit each die, and create partial_die_info if needed in each iteration, like this, part_die = XOBNEW (&cu->comp_unit_obstack, struct partial_die_info); while (1) { if (foo1) continue; if (foo2) continue; read_partial_die (, , part_die, ,); .... part_die = XOBNEW (&cu->comp_unit_obstack, struct partial_die_info); }; the code was written in a way that spaces are allocated on necessary on cu->comp_unit_obstack. I want to class-fy partial_die_info, but partial_die_info ctor can't follow XOBNEW immediately, so this patch rewrite this loop to: while (1) { if (foo1) continue; if (foo2) continue; struct partial_die_info pdi; read_partial_die (, , &pdi, ,); part_die = XOBNEW (&cu->comp_unit_obstack, struct partial_die_info); memcpy (part_die, &pdi, sizeof (pdi)); }; we create a local variable pdi, if we need it, call XOBNEW, and copy. This also reduce one XOBNEW call. I measured the number of XOBNEW call in load_partial_dies when gdb reads dwarf2read.o, without this patch, it is 18827, and with this patch, it is 18826. gdb: 2018-026-26 Yao Qi <yao.qi@linaro.org> * dwarf2read.c (load_partial_dies): Move the location of XOBNEW.
2018-02-23dwarf: Make sect_offset 64-bitsSimon Marchi1-167/+170
Does anybody have an opinion about this? It would be nice to unbreak the "default" build with clang (i.e. without passing special -Wno-error= flags). Here's a version rebased on today's master. From 47d28075117fa2ddb93584ec50881e33777a85e5 Mon Sep 17 00:00:00 2001 From: Simon Marchi <simon.marchi@ericsson.com> Date: Sat, 30 Dec 2017 22:48:18 -0500 Subject: [PATCH] dwarf: Make sect_offset 64-bits Compiling with Clang 6 shows these errors: /home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:26610:43: error: result of comparison of constant 4294967296 with expression of type 'typename std::underlying_type<sect_offset>::type' (a ka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare] if (to_underlying (per_cu.sect_off) >= (static_cast<uint64_t> (1) << 32)) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:26618:43: error: result of comparison of constant 4294967296 with expression of type 'typename std::underlying_type<sect_offset>::type' (a ka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare] if (to_underlying (per_cu.sect_off) >= (static_cast<uint64_t> (1) << 32)) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The code in question checks if there is any offset exceeding 32 bits, and therefore if we need to use the 64-bit DWARF format when writing the .debug_names section. The type we use currently to represent section offsets is an unsigned int (32-bits), which means a value of this type will never exceed 32 bits, hence the errors above. There are many signs that we want to support 64-bits DWARF (although I haven't tested), such as: - We correctly read initial length fields (read_initial_length) - We take that into account when reading offsets (read_offset_1) - The check_dwarf64_offsets function However, I don't see how it can work if sect_offset is a 32-bits type. Every time we record a section offset, we risk truncating the value. And if a file uses the 64-bit DWARF format, it's most likely because there are such offset values that overflow 32 bits. Because of this, I think the way forward is to change sect_offset to be a uint64_t. It will be able to represent any offset, regardless of the bitness of the DWARF info. This patch was regtested on the buildbot. gdb/ChangeLog: * gdbtypes.h (sect_offset): Change type to uint64_t. (sect_offset_str): New function. * dwarf2read.c (create_addrmap_from_aranges): Use sect_offset_str. (error_check_comp_unit_head): Likewise. (create_debug_type_hash_table): Likewise. (read_cutu_die_from_dwo): Likewise. (init_cutu_and_read_dies): Likewise. (init_cutu_and_read_dies_no_follow): Likewise. (process_psymtab_comp_unit_reader): Likewise. (partial_die_parent_scope): Likewise. (peek_die_abbrev): Likewise. (process_queue): Likewise. (dwarf2_physname): Likewise. (read_namespace_alias): Likewise. (read_import_statement): Likewise. (create_dwo_cu_reader): Likewise. (create_cus_hash_table): Likewise. (lookup_dwo_cutu): Likewise. (inherit_abstract_dies): Likewise. (read_func_scope): Likewise. (read_call_site_scope): Likewise. (dwarf2_add_member_fn): Likewise. (read_common_block): Likewise. (read_module_type): Likewise. (read_typedef): Likewise. (read_subrange_type): Likewise. (load_partial_dies): Likewise. (read_partial_die): Likewise. (find_partial_die): Likewise. (read_str_index): Likewise. (dwarf2_string_attr): Likewise. (build_error_marker_type): Likewise. (lookup_die_type): Likewise. (dump_die_shallow): Likewise. (follow_die_ref): Likewise. (dwarf2_fetch_die_loc_sect_off): Likewise. (dwarf2_fetch_constant_bytes): Likewise. (follow_die_sig): Likewise. (get_signatured_type): Likewise. (get_DW_AT_signature_type): Likewise. (dwarf2_find_containing_comp_unit): Likewise. (set_die_type): Likewise.
2018-02-16New class allocate_on_obstackYao Qi1-9/+5
This patch adds a new class allocate_on_obstack, and let dwarf2_per_objfile inherit it, so that dwarf2_per_objfile is automatically allocated on obstack, and "delete dwarf2_per_objfile" doesn't de-allocate any space. gdb: 2018-02-16 Yao Qi <yao.qi@linaro.org> * block.c (block_namespace_info): Inherit allocate_on_obstack. (block_initialize_namespace): Use new. * dwarf2read.c (dwarf2_per_objfile): Inherit allocate_on_obstack. (dwarf2_free_objfile): Use delete. * gdbtypes.c (type_pair): Inherit allocate_on_obstack. (copy_type_recursive): Use new. * gdb_obstack.h (allocate_on_obstack): New.
2018-02-14Change openp et al to use a unique_xmalloc_ptrTom Tromey1-9/+14
This changes openp, source_full_path_of, and find_and_open_source to take a unique_xmalloc_ptr, rather than a char*, as an outgoing argument type. This simplifies the API, ownership-wise, and allows for the removal of some cleanups. gdb/ChangeLog 2018-02-14 Tom Tromey <tom@tromey.com> * symfile.c (symfile_bfd_open): Update. * source.h (openp, source_full_path_of, find_and_open_source): Change argument type to unique_xmalloc_ptr. * source.c (openp): Take a unique_xmalloc_ptr. (source_full_path_of, find_and_open_source): Likewise. (open_source_file, symtab_to_fullname): Update. * solist.h (struct target_so_ops) <find_and_open_solib>: Take a unique_xmalloc_ptr. * solib.c (solib_find_1): Use unique_xmalloc_ptr. (exec_file_find): Update. * psymtab.c (psymtab_to_fullname): Update. * nto-tdep.h (nto_find_and_open_solib): Update. * nto-tdep.c (nto_find_and_open_solib): Change temp_path to a unique_xmalloc_ptr. * exec.c (exec_file_attach): Update. * dwarf2read.c (try_open_dwop_file): Use unique_xmalloc_ptr. * cli/cli-cmds.c (find_and_open_script): Use unique_xmalloc_ptr.
2018-02-13Use enum flags for flags passed to openpSimon Marchi1-2/+2
gdb/ChangeLog: * defs.h (enum openp_flags): New enum. (OPF_TRY_CWD_FIRST, OPF_SEARCH_IN_PATH, OPF_RETURN_REALPATH): Move to enum openp_flags. (openp_flags): New enum flags. (openp): Change parameter type to openp_flags. * source.c (openp): Change parameter type to openp_flags. * cli/cli-cmds.c (find_and_open_script): Use openp_flags. * dwarf2read.c (try_open_dwop_file): Use openp_flags.
2018-02-12gdb: Remove cleanup from dw2_do_instantiate_symtabAndrew Burgess1-35/+41
When running the test gdb.dwarf2/dw2-bad-parameter-type.exp under valgrind, I see the following issue reported (on x86-64 Fedora): (gdb) ptype f ==5203== Invalid read of size 1 ==5203== at 0x6931FE: process_die_scope::~process_die_scope() (dwarf2read.c:10642) ==5203== by 0x66818F: process_die(die_info*, dwarf2_cu*) (dwarf2read.c:10664) ==5203== by 0x66A01F: read_file_scope(die_info*, dwarf2_cu*) (dwarf2read.c:11650) ==5203== by 0x667F2D: process_die(die_info*, dwarf2_cu*) (dwarf2read.c:10672) ==5203== by 0x6677B6: process_full_comp_unit(dwarf2_per_cu_data*, language) (dwarf2read.c:10445) ==5203== by 0x66657A: process_queue(dwarf2_per_objfile*) (dwarf2read.c:9945) ==5203== by 0x6559B4: dw2_do_instantiate_symtab(dwarf2_per_cu_data*) (dwarf2read.c:3163) ==5203== by 0x66683D: psymtab_to_symtab_1(partial_symtab*) (dwarf2read.c:10034) ==5203== by 0x66622A: dwarf2_read_symtab(partial_symtab*, objfile*) (dwarf2read.c:9811) ==5203== by 0x787984: psymtab_to_symtab(objfile*, partial_symtab*) (psymtab.c:792) ==5203== by 0x786E3E: psym_lookup_symbol(objfile*, int, char const*, domain_enum_tag) (psymtab.c:522) ==5203== by 0x804BD0: lookup_symbol_via_quick_fns(objfile*, int, char const*, domain_enum_tag) (symtab.c:2383) ==5203== Address 0x147ed063 is 291 bytes inside a block of size 4,064 free'd ==5203== at 0x4C2CD5A: free (vg_replace_malloc.c:530) ==5203== by 0x444415: void xfree<void>(void*) (common-utils.h:60) ==5203== by 0x9DA8C2: call_freefun (obstack.c:103) ==5203== by 0x9DAD35: _obstack_free (obstack.c:280) ==5203== by 0x44464C: auto_obstack::~auto_obstack() (gdb_obstack.h:73) ==5203== by 0x68AFB0: dwarf2_cu::~dwarf2_cu() (dwarf2read.c:25080) ==5203== by 0x68B204: free_one_cached_comp_unit(dwarf2_per_cu_data*) (dwarf2read.c:25174) ==5203== by 0x66668C: dwarf2_release_queue(void*) (dwarf2read.c:9982) ==5203== by 0x563A4C: do_my_cleanups(cleanup**, cleanup*) (cleanups.c:154) ==5203== by 0x563AA7: do_cleanups(cleanup*) (cleanups.c:176) ==5203== by 0x5646CE: throw_exception_cxx(gdb_exception) (common-exceptions.c:289) ==5203== by 0x5647B7: throw_exception(gdb_exception) (common-exceptions.c:317) ==5203== Block was alloc'd at ==5203== at 0x4C2BBAD: malloc (vg_replace_malloc.c:299) ==5203== by 0x564BE8: xmalloc (common-utils.c:44) ==5203== by 0x9DA872: call_chunkfun (obstack.c:94) ==5203== by 0x9DA935: _obstack_begin_worker (obstack.c:141) ==5203== by 0x9DAA3C: _obstack_begin (obstack.c:164) ==5203== by 0x4445E0: auto_obstack::auto_obstack() (gdb_obstack.h:70) ==5203== by 0x68AE07: dwarf2_cu::dwarf2_cu(dwarf2_per_cu_data*) (dwarf2read.c:25073) ==5203== by 0x661A8A: init_cutu_and_read_dies(dwarf2_per_cu_data*, abbrev_table*, int, int, void (*)(die_reader_specs const*, unsigned char const*, die_info*, int, void*), void*) (dwarf2read.c:7869) ==5203== by 0x666A29: load_full_comp_unit(dwarf2_per_cu_data*, language) (dwarf2read.c:10108) ==5203== by 0x655847: load_cu(dwarf2_per_cu_data*) (dwarf2read.c:3120) ==5203== by 0x655928: dw2_do_instantiate_symtab(dwarf2_per_cu_data*) (dwarf2read.c:3148) ==5203== by 0x66683D: psymtab_to_symtab_1(partial_symtab*) (dwarf2read.c:10034) There's actually a series of three issues reported, but it turns out they're all related, so we can consider on the first one. The invalid read is triggered from a destructor which is being invoked as part of a stack unwind after throwing an error. At the time the error is thrown, the stack looks like this: #0 0x00000000009f4ecd in __cxa_throw () #1 0x0000000000564761 in throw_exception_cxx (exception=...) at ../../src/gdb/common/common-exceptions.c:303 #2 0x00000000005647b8 in throw_exception (exception=...) at ../../src/gdb/common/common-exceptions.c:317 #3 0x00000000005648ff in throw_it(return_reason, errors, const char *, typedef __va_list_tag __va_list_tag *) (reason=RETURN_ERROR, error=GENERIC_ERROR, fmt=0xb33020 "Dwarf Error: Cannot find DIE at 0x%x referenced from DIE at 0x%x [in module %s]", ap=0x7fff387f2d68) at ../../src/gdb/common/common-exceptions.c:373 #4 0x0000000000564929 in throw_verror (error=GENERIC_ERROR, fmt=0xb33020 "Dwarf Error: Cannot find DIE at 0x%x referenced from DIE at 0x%x [in module %s]", ap=0x7fff387f2d68) at ../../src/gdb/common/common-exceptions.c:379 #5 0x0000000000867be4 in verror (string=0xb33020 "Dwarf Error: Cannot find DIE at 0x%x referenced from DIE at 0x%x [in module %s]", args=0x7fff387f2d68) at ../../src/gdb/utils.c:251 #6 0x000000000056879d in error (fmt=0xb33020 "Dwarf Error: Cannot find DIE at 0x%x referenced from DIE at 0x%x [in module %s]") at ../../src/gdb/common/errors.c:43 #7 0x0000000000686875 in follow_die_ref (src_die=0x30bc8a0, attr=0x30bc8c8, ref_cu=0x7fff387f2ed0) at ../../src/gdb/dwarf2read.c:22969 #8 0x00000000006844cd in lookup_die_type (die=0x30bc8a0, attr=0x30bc8c8, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:21976 #9 0x0000000000683f27 in die_type (die=0x30bc8a0, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:21832 #10 0x0000000000679b39 in read_subroutine_type (die=0x30bc830, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:17343 #11 0x00000000006845fb in read_type_die_1 (die=0x30bc830, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:22035 #12 0x0000000000684576 in read_type_die (die=0x30bc830, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:22010 #13 0x000000000067003f in read_func_scope (die=0x30bc830, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:13822 #14 0x0000000000667f5e in process_die (die=0x30bc830, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:10679 #15 0x000000000066a020 in read_file_scope (die=0x30bc720, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:11650 #16 0x0000000000667f2e in process_die (die=0x30bc720, cu=0x30bc5d0) at ../../src/gdb/dwarf2read.c:10672 #17 0x00000000006677b7 in process_full_comp_unit (per_cu=0x3089b80, pretend_language=language_minimal) at ../../src/gdb/dwarf2read.c:10445 #18 0x000000000066657b in process_queue (dwarf2_per_objfile=0x30897d0) at ../../src/gdb/dwarf2read.c:9945 #19 0x00000000006559b5 in dw2_do_instantiate_symtab (per_cu=0x3089b80) at ../../src/gdb/dwarf2read.c:3163 #20 0x000000000066683e in psymtab_to_symtab_1 (pst=0x3089bd0) at ../../src/gdb/dwarf2read.c:10034 #21 0x000000000066622b in dwarf2_read_symtab (self=0x3089bd0, objfile=0x3073f40) at ../../src/gdb/dwarf2read.c:9811 #22 0x0000000000787985 in psymtab_to_symtab (objfile=0x3073f40, pst=0x3089bd0) at ../../src/gdb/psymtab.c:792 #23 0x0000000000786e3f in psym_lookup_symbol (objfile=0x3073f40, block_index=1, name=0x30b2e30 "f", domain=VAR_DOMAIN) at ../../src/gdb/psymtab.c:522 #24 0x0000000000804bd1 in lookup_symbol_via_quick_fns (objfile=0x3073f40, block_index=1, name=0x30b2e30 "f", domain=VAR_DOMAIN) at ../../src/gdb/symtab.c:2383 #25 0x0000000000804fe4 in lookup_symbol_in_objfile (objfile=0x3073f40, block_index=1, name=0x30b2e30 "f", domain=VAR_DOMAIN) at ../../src/gdb/symtab.c:2558 #26 0x0000000000805125 in lookup_static_symbol (name=0x30b2e30 "f", domain=VAR_DOMAIN) at ../../src/gdb/symtab.c:2595 #27 0x0000000000804357 in lookup_symbol_aux (name=0x30b2e30 "f", match_type=symbol_name_match_type::FULL, block=0x0, domain=VAR_DOMAIN, language=language_c, is_a_field_of_this=0x0) at ../../src/gdb/symtab.c:2105 #28 0x0000000000803ad9 in lookup_symbol_in_language (name=0x30b2e30 "f", block=0x0, domain=VAR_DOMAIN, lang=language_c, is_a_field_of_this=0x0) at ../../src/gdb/symtab.c:1887 #29 0x0000000000803b53 in lookup_symbol (name=0x30b2e30 "f", block=0x0, domain=VAR_DOMAIN, is_a_field_of_this=0x0) at ../../src/gdb/symtab.c:1899 #30 0x000000000053b246 in classify_name (par_state=0x7fff387f6090, block=0x0, is_quoted_name=false, is_after_structop=false) at ../../src/gdb/c-exp.y:2879 #31 0x000000000053b7e9 in c_yylex () at ../../src/gdb/c-exp.y:3083 #32 0x000000000053414a in c_yyparse () at c-exp.c:1903 #33 0x000000000053c2e7 in c_parse (par_state=0x7fff387f6090) at ../../src/gdb/c-exp.y:3255 #34 0x0000000000774a02 in parse_exp_in_context_1 (stringptr=0x7fff387f61c0, pc=0, block=0x0, comma=0, void_context_p=0, out_subexp=0x0) at ../../src/gdb/parse.c:1213 #35 0x000000000077476a in parse_exp_in_context (stringptr=0x7fff387f61c0, pc=0, block=0x0, comma=0, void_context_p=0, out_subexp=0x0) at ../../src/gdb/parse.c:1115 #36 0x0000000000774714 in parse_exp_1 (stringptr=0x7fff387f61c0, pc=0, block=0x0, comma=0) at ../../src/gdb/parse.c:1106 #37 0x0000000000774c53 in parse_expression (string=0x27ff996 "f") at ../../src/gdb/parse.c:1253 #38 0x0000000000861dc4 in whatis_exp (exp=0x27ff996 "f", show=1) at ../../src/gdb/typeprint.c:472 #39 0x00000000008620d8 in ptype_command (type_name=0x27ff996 "f", from_tty=1) at ../../src/gdb/typeprint.c:561 #40 0x000000000047430b in do_const_cfunc (c=0x3012010, args=0x27ff996 "f", from_tty=1) at ../../src/gdb/cli/cli-decode.c:106 #41 0x000000000047715e in cmd_func (cmd=0x3012010, args=0x27ff996 "f", from_tty=1) at ../../src/gdb/cli/cli-decode.c:1886 #42 0x00000000008431bb in execute_command (p=0x27ff996 "f", from_tty=1) at ../../src/gdb/top.c:630 #43 0x00000000006bf946 in command_handler (command=0x27ff990 "ptype f") at ../../src/gdb/event-top.c:583 #44 0x00000000006bfd12 in command_line_handler (rl=0x30bb3a0 "\240\305\v\003") at ../../src/gdb/event-top.c:774 The problem is that in `process_die` (frames 14 and 16) we create a `process_die_scope` object, that takes a copy of the `struct dwarf2_cu *` passed into the frame. The destructor of the `process_die_scope` dereferences the stored pointer. This wouldn't be an issue, except... ... in dw2_do_instantiate_symtab (frame 19) a clean up was registered that clears the dwarf2_queue in case of an error. Part of this clean up involves deleting the `struct dwarf2_cu`s referenced from the queue.. The problem then, is that cleanups are processed at the site of the throw, while, class destructors are invoked as we unwind their frame. The result is that we process the frame 19 cleanup (and delete the struct dwarf2_cu) before we process the destructors in frames 14 and 16. When we do get back to frames 14 and 16 the objects being references have already been deleted. The solution is to remove the cleanup from dw2_do_instantiate_symtab, and instead use a destructor to release the dwarf2_queue instead. With this patch in place, the valgrind errors are now resolved. gdb/ChangeLog: * dwarf2read.c (dwarf2_release_queue): Delete function, move body into... (class dwarf2_queue_guard): ...the destructor of this new class. (dw2_do_instantiate_symtab): Create instance of the new class dwarf2_queue_guard, remove cleanup.
2018-02-04Move comment in gdb/dwarf2read.c::dwarf2_physnameJoel Brobecker1-8/+8
This commit just moves a comment right next to where it is actually relevant. No actual code change. gdb/ChangeLog: * dwarf2read.c (dwarf2_physname): Move commment. Tested by rebuilding GDB.
2018-01-28Remove dwarf2_per_objfile_free and use after free of dwarf2_per_objfileSimon Marchi1-33/+24
I got some crashes while doing some work with dwarf2_per_objfile. It turns out that dwarf2_per_objfile_free is using the dwarf2_per_objfile objects after their destructor has ran. The easiest way to reproduce this is to run the inferior twice (do "start" twice). Currently, it goes unnoticed, but when I tried to change all_comp_units and all_type_units to std::vectors, things started crashing. The dwarf2_per_objfile objects get destroyed here: #0 dwarf2_per_objfile::~dwarf2_per_objfile (this=0x35afe70, __in_chrg=<optimized out>) at /home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:2422 #1 0x0000000000833282 in dwarf2_free_objfile (objfile=0x356cff0) at /home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:25363 #2 0x0000000000699255 in elf_symfile_finish (objfile=0x356cff0) at /home/emaisin/src/binutils-gdb/gdb/elfread.c:1309 #3 0x0000000000911ed3 in objfile::~objfile (this=0x356cff0, __in_chrg=<optimized out>) at /home/emaisin/src/binutils-gdb/gdb/objfiles.c:674 and just after that the dwarf2read per-objfile registry cleanup function gets called: #0 dwarf2_per_objfile_free (objfile=0x356cff0, d=0x35afe70) at /home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:25667 ... registry boilerplate ... #4 0x00000000009103ea in objfile_free_data (container=0x356cff0) at /home/emaisin/src/binutils-gdb/gdb/objfiles.c:61 #5 0x0000000000911ee2 in objfile::~objfile (this=0x356cff0, __in_chrg=<optimized out>) at /home/emaisin/src/binutils-gdb/gdb/objfiles.c:678 In dwarf2_per_objfile_free, we access fields of the dwarf2_per_objfile object, which is invalid since its destructor has been executed. This patch moves the content of dwarf2_per_objfile_free to the destructor of dwarf2_per_objfile. The call to register_objfile_data_with_cleanup in _initialize_dwarf2_read can be changed to the simpler register_objfile_data. gdb/ChangeLog: * dwarf2read.c (free_dwo_files): Add forward-declaration. (dwarf2_per_objfile::~dwarf2_per_objfile): Move content from dwarf2_per_objfile_free here. (dwarf2_per_objfile_free): Remove. (_initialize_dwarf2_read): Don't register dwarf2_per_objfile_free as a registry cleanup.
2018-01-21Ada/DWARF: Assume the Ada compiler produces descriptive type attributesJoel Brobecker1-9/+3
GCC was enhanced in 2011 to generate this attribute, so I think we can now assume that it is available when using that compiler. Doing so allows us to speed up what we call "parallel type" lookups when processing certain types encoded using the GNAT encoding. This patch changes need_gnat_info to always expect those attributes to be generated when the language is Ada. This is an assumption that on the surfcace looks like it might be a bit on the edge; but in practice, it should be OK because this is only useful in the context of handling GNAT-specific encodings. Other Ada compilers would presumably produce debugging information using pure DWARF constructs, so would not be impacted by this. gdb/ChangeLog: * dwarf2read.c (need_gnat_info): Return nonzero if the cu's language is Ada. Tested on x86_64-linux.
2018-01-18Make abbrev_table::abbrevs privateYao Qi1-6/+8
abbrev_table::abbrevs is only access within abbrev_table's methods, so it can be private. Add "m_" prefix. gdb: 2018-01-18 Yao Qi <yao.qi@linaro.org> * dwarf2read.c (abbrev_table) <abbrevs>: Rename it to m_abbrevs. (abbrev_table::add_abbrev): Update. (abbrev_table::lookup_abbrev): Update.
2018-01-17Remove symbolp typedefTom Tromey1-3/+0
This removes the symbolp typedef from dwarf2read.c. It is no longer used. 2018-01-17 Tom Tromey <tom@tromey.com> * dwarf2read.c (symbolp): Remove typedef. Don't instantiate VEC.
2018-01-17Remove objfile argument from add_dyn_propTom Tromey1-3/+3
The objfile argument to add_dyn_prop is redundant, so this patch removes it. 2018-01-17 Tom Tromey <tom@tromey.com> * gdbtypes.h (add_dyn_prop): Remove objfile parameter. * gdbtypes.c (add_dyn_prop): Remove objfile parameter. (create_array_type_with_stride): Update. * dwarf2read.c (set_die_type): Update.
2018-01-17Change dwarf2_cu::method_info to be a std::vectorTom Tromey1-57/+36
This changes the type of dwarf2_cu::method_info and fixes up the uses. In order to remove cleanups from process_full_comp_unit and process_full_type_unit, psymtab_include_file_name also had to be changed to avoid leaving dangling cleanups. 2018-01-17 Tom Tromey <tom@tromey.com> * dwarf2read.c (delayed_method_info): Remove typedef. (dwarf2_cu::method_info): Now a std::vector. (add_to_method_list): Update. (free_delayed_list): Remove. (compute_delayed_physnames): Update. (process_full_comp_unit, process_full_type_unit): Clear the method list. Remove cleanups. (psymtab_include_file_name): Add name_holder parameter. Use unique_xmalloc_ptr. (dwarf_decode_lines): Update.
2018-01-17Allocate dwarf2_cu with newSimon Marchi1-143/+67
This changes dwarf2_cu to be allocated with new, and fixes up the users. 2018-01-17 Tom Tromey <tom@tromey.com> Simon Marchi <simon.marchi@ericsson.com> * dwarf2read.c (struct dwarf2_cu): Add constructor, destructor. (dwarf2_per_objfile::free_cached_comp_units) (init_tu_and_read_dwo_dies, init_cutu_and_read_dies) (init_cutu_and_read_dies_no_follow): Update. (dwarf2_cu::dwarf2_cu): Rename from init_one_comp_unit. (dwarf2_cu::~dwarf2_cu): New. (free_heap_comp_unit, free_stack_comp_unit): Remove. (age_cached_comp_units, free_one_cached_comp_unit): Update.
2018-01-17Allocate abbrev_table with newTom Tromey1-180/+106
This changes dwarf2read.c to allocate abbrev tables using "new", and then updates the users. This version of the patch incorporates the changes that Simon implemented. These changes simplify the ownership rules for abbrev tables. 2018-01-17 Tom Tromey <tom@tromey.com> Simon Marchi <simon.marchi@ericsson.com> * dwarf2read.c (struct dwarf2_cu) <abbrev_table>: Remove. (struct die_reader_specs) <abbrev_table>: New member. (struct abbrev_table): Add constructor. <alloc_abbrev, add_abbrev, lookup_abbrev>: Declare. <abbrev_obstack>: Now an auto_obstack. (abbrev_table_up): New typedef. (init_cu_die_reader): Add abbrev_table parameter. (read_cutu_die_from_dwo): Remove abbrev_table_provided parameter. Add result_dwo_abbrev_table. (init_tu_and_read_dwo_dies, init_cutu_and_read_dies) (init_cutu_and_read_dies_no_follow, build_type_psymtabs_1): Update. (peek_die_abbrev): Take die_reader_specs, not dwarf_cu as parameter. (skip_children): Update. (abbrev_table::alloc_abbrev): Rename from abbrev_table_alloc_abbrev. (abbrev_table::add_abbrev): Rename from abbrev_table_add_abbrev. (abbrev_table::lookup_abbrev): Rename from abbrev_table_lookup_abbrev. (abbrev_table_read_table): Return abbrev_table_up. (abbrev_table_free, abbrev_table_free_cleanup) (dwarf2_read_abbrevs, dwarf2_free_abbrev_table): Remove. (load_partial_dies): Update.
2018-01-17Unify new_symbol and new_symbol_fullTom Tromey1-20/+9
This patch unifies new_symbol with new_symbol_full, replacing a wrapper function with a default parameter. 2018-01-17 Tom Tromey <tom@tromey.com> * dwarf2read.c (dwarf2_compute_name): Update comment. (read_func_scope, read_variable): Update. (new_symbol): Remove. (new_symbol_full): Rename to new_symbol.
2018-01-10language_get_symbol_name_matcher -> get_symbol_name_matcherPedro Alves1-1/+1
Rename language_get_symbol_name_matcher -> get_symbol_name_matcher, since the function is no longer a straight "language method". gdb/ChangeLog: 2018-01-10 Pedro Alves <palves@redhat.com> * language.h (language_get_symbol_name_matcher): Rename ... (get_symbol_name_matcher): ... this. * language.c (language_get_symbol_name_matcher): Ditto. * dictionary.c, linespec.c, minsyms.c, psymtab.c, symtab.c: All callers adjusted.
2018-01-10Ada: make verbatim matcher override other language matchers (PR gdb/22670)Pedro Alves1-17/+15
A previous patch fixed verbatim matching in the lookup at the minimal symbol level, but we should also be finding that same symbol through the partial/full symtab search. For example, this is what happens if we use "print" instead of "break": (gdb) p <MixedCaseFunc> $1 = {<text variable, no debug info>} 0x4024dc <MixedCaseFunc> Before the C++ wildmatching series, GDB knows that MixedCaseFunc is a function without parameters, and the expression above means calling it. If you try it before having started the inferior, you'd get the following (expected) error: (gdb) print <MixedCaseFunc> You can't do that without a process to debug. The main idea behind making the name matcher be determined by the symbol's language is so that C++ (etc.) wildmatching in linespecs works even if the current language is not C++, as e.g., when you step through C or assembly code. Ada's verbatim matching syntax however ("<...>") isn't quite the same. It is more a property of the current language than of a particular symbol's language. We want to support this syntax when debugging an Ada program, but it's reason of existence is to find non-Ada symbols. This suggests going back to enabling it depending on current language instead of language of the symbol being matched. I'm not entirely happy with the "current_language" reference (though I think that it's harmless). I think we could try storing the current language in the lookup_name_info object, and then convert a bunch of functions more to pass around lookup_name_info objects instead of "const char *" names. I.e., build the lookup_name_info higher up. I'm not sure about that, I'll have to think more about it. Maybe something different will be better. Meanwhile, this gets us going. I've extended the testcase to also exercise a no-debug-info function, for extra coverage of the minsyms-only paths. gdb/ChangeLog: 2018-01-10 Pedro Alves <palves@redhat.com> PR gdb/22670 * dwarf2read.c (gdb_index_symbol_name_matcher::gdb_index_symbol_name_matcher): Adjust to use language_get_symbol_name_matcher instead of language_defn::la_get_symbol_name_matcher. * language.c (language_get_symbol_name_matcher): If in Ada mode and the lookup name is a verbatim match, return Ada's matcher. * language.h (language_get_symbol_name_matcher): Adjust comment. (ada_lookup_name_info::verbatim_p):: New method. gdb/testsuite/ChangeLog: 2018-01-10 Pedro Alves <palves@redhat.com> PR gdb/22670 * gdb.ada/bp_c_mixed_case.exp: Add intro comment. Test printing C functions too. Test setting breakpoints and printing C functions with no debug info too. * gdb.ada/bp_c_mixed_case/qux.c: New file.
2018-01-09Fix breakpoint add on inlined function using function name.Xavier Roirand1-8/+13
Using this Ada example: package B is procedure Read_Small with Inline_Always; end B; package body B is Total : Natural := 0; procedure Read_Small is begin Total := Total + 1; end Read_Small; end B; and with B; procedure M is begin B.Read_Small; end M; % gnatmake -g -O0 -m m.adb -cargs -gnatn % gdb m Inserting a breakpoint on Read_Small inlined function does not work: (gdb) b read_small Breakpoint 1 at 0x40250e: file b.adb, line 5. (gdb) info b Num Type Disp Enb Address What 1 breakpoint keep y 0x000000000040250e in b.doit at b.adb:5 (gdb) In this exemple we should have two breakpoints set, one in package B and the other one in the inlined instance inside procedure M), like below: (gdb) b read_small Breakpoint 1 at 0x40250e: b.adb:5. (2 locations) (gdb) info b Num Type Disp Enb Address What 1 breakpoint keep y <MULTIPLE> 1.1 y 0x000000000040250e in b.doit at b.adb:5 1.2 y 0x0000000000402540 in m at b.adb:5 (gdb) Looking at the DWARF info for inlined instance of Read_Small: <1><1526>: Abbrev Number: 2 (DW_TAG_subprogram) <1527> DW_AT_name : ([...], offset: 0x1e82): b__read_small <152b> DW_AT_decl_file : 2 <152c> DW_AT_decl_line : 3 <152d> DW_AT_inline : 3 (declared as inline and inlined) [...] <2><1547>: Abbrev Number: 4 (DW_TAG_inlined_subroutine) <1548> DW_AT_abstract_origin: <0x1526> <154c> DW_AT_low_pc : 0x402552 <1554> DW_AT_high_pc : 0x2b <155c> DW_AT_call_file : 1 <155d> DW_AT_call_line : 5 <2><155e>: Abbrev Number: 0 During the parsing of DWARF info in order to produce partial DIE linked list, the DW_TAG_inlined_subroutine were skipped thus not present in the final partial dies. Taking DW_TAG_inlined_subroutine in account during the parsing process fixes the problem. gdb/ChangeLog: * dwarf2read.c (scan_partial_symbols, add_partial_symbol) (add_partial_subprogram, load_partial_dies): Add DW_TAG_inlined_subroutine handling. gdb/testsuite/ChangeLog: * gdb.ada/bp_inlined_func: New testcase.
2018-01-07Remove dwarf2_cu::dwarf2_per_objfileSimon Marchi1-107/+140
This patch removes the dwarf2_per_objfile field of dwarf2_cu. It is redundant, since we can access dwarf2_per_objfile through dwarf2_per_objfile, which is guaranteed to be set. gdb/ChangeLog: * dwarf2read.c (struct dwarf2_cu) <dwarf2_per_objfile>: Remove. (dw2_get_file_names_reader): Adjust. (lookup_dwo_signatured_type): Adjust. (lookup_dwp_signatured_type): Adjust. (lookup_signatured_type): Adjust. (create_type_unit_group): Adjust. (get_type_unit_group): Adjust. (process_psymtab_comp_unit_reader): Adjust. (build_type_psymtabs_reader): Adjust. (scan_partial_symbols): Adjust. (add_partial_symbol): Adjust. (add_partial_subprogram): Adjust. (peek_die_abbrev): Adjust. (fixup_go_packaging): Adjust. (process_imported_unit_die): Adjust. (dwarf2_compute_name): Adjust. (dwarf2_physname): Adjust. (read_import_statement): Adjust. (handle_DW_AT_stmt_list): Adjust. (read_file_scope): Adjust. (read_func_scope): Adjust. (read_lexical_block_scope): Adjust. (read_call_site_scope): Adjust. (read_variable): Adjust. (dwarf2_rnglists_process): Adjust. (dwarf2_ranges_process): Adjust. (dwarf2_ranges_read): Adjust. (dwarf2_get_pc_bounds): Adjust. (dwarf2_record_block_ranges): Adjust. (dwarf2_add_field): Adjust. (dwarf2_add_member_fn): Adjust. (read_structure_type): Adjust. (process_structure_scope): Adjust. (read_enumeration_type): Adjust. (read_array_type): Adjust. (mark_common_block_symbol_computed): Adjust. (read_common_block): Adjust. (read_namespace_type): Adjust. (read_namespace): Adjust. (read_module_type): Adjust. (read_tag_pointer_type): Adjust. (read_tag_ptr_to_member_type): Adjust. (read_tag_string_type): Adjust. (read_subroutine_type): Adjust. (read_typedef): Adjust. (read_base_type): Adjust. (attr_to_dynamic_prop): Adjust. (read_subrange_type): Adjust. (read_unspecified_type): Adjust. (dwarf2_read_abbrevs): Adjust. (load_partial_dies): Adjust. (read_partial_die): Adjust. (find_partial_die): Adjust. (guess_partial_die_structure_name): Adjust. (fixup_partial_die): Adjust. (read_attribute_value): Adjust. (read_addr_index): Adjust. (read_addr_index_from_leb128): Adjust. (read_str_index): Adjust. (dwarf2_string_attr): Adjust. (get_debug_line_section): Adjust. (dwarf_decode_line_header): Adjust. (lnp_state_machine::check_line_address): Adjust. (dwarf_decode_lines_1): Adjust. (dwarf_decode_lines): Adjust. (dwarf2_start_symtab): Adjust. (var_decode_location): Adjust. (new_symbol_full): Adjust. (dwarf2_const_value_data): Adjust. (dwarf2_const_value_attr): Adjust. (dwarf2_const_value): Adjust. (die_type): Adjust. (die_containing_type): Adjust. (build_error_marker_type): Adjust. (lookup_die_type): Adjust. (guess_full_die_structure_name): Adjust. (anonymous_struct_prefix): Adjust. (determine_prefix): Adjust. (dwarf2_name): Adjust. (follow_die_ref_or_sig): Adjust. (follow_die_offset): Adjust. (follow_die_ref): Adjust. (follow_die_sig_1): Adjust. (follow_die_sig): Adjust. (get_signatured_type): Adjust. (get_DW_AT_signature_type): Adjust. (decode_locdesc): Adjust. (dwarf_decode_macros): Adjust. (cu_debug_loc_section): Adjust. (fill_in_loclist_baton): Adjust. (dwarf2_symbol_mark_computed): Adjust. (init_one_comp_unit): Don't assign dwarf2_cu::dwarf2_per_objfile. (set_die_type): Adjust.
2018-01-07Remove dwarf2_per_objfile globalSimon Marchi1-410/+614
This patch removes the global variable dwarf2_per_objfile. This global variable is set at the various entry points of dwarf2read.c (using dw2_setup), and is referred to throughout the file. Instead of passing data between functions in global variables like this one, it would be better if the functions that depend on it either received it as argument or got it from the existing arguments they receive. For example, a function receiving a reference to a dwarf2_per_cu_data can access it from dwarf2_per_cu_data::dwarf2_per_objfile. This patch has been tested on the buildbot. gdb/ChangeLog: * dwarf2read.c (struct mapped_debug_names): Add constructor. <dwarf2_per_objfile>: New field. (dwarf2_per_objfile): Remove global. (get_dwarf2_per_objfile): New function. (set_dwarf2_per_objfile): New function. (dwarf2_build_psymtabs_hard): Change objfile parameter to dwarf2_per_objfile. (abbrev_table_read_table): Add dwarf2_per_objfile parameter. (read_abbrev_offset): Likewise. (read_indirect_string): Likewise. (read_indirect_line_string): Likewise. (read_indirect_string_at_offset): Likewise. (read_indirect_string_from_dwz): Likewise. (dwarf2_find_containing_comp_unit): Change objfile parameter to dwarf2_per_objfile. (age_cached_comp_units): Add dwarf2_per_objfile parameter. (create_all_comp_units): Change objfile parameter to dwarf2_per_objfile. (create_all_type_units): Likewise. (process_queue): Add dwarf2_per_objfile parameter. (read_and_check_comp_unit_head): Likewise. (lookup_dwo_unit_in_dwp): Likewise. (get_dwp_file): Likewise. (process_cu_includes): Likewise. (struct free_dwo_file_cleanup_data): New struct. (dwarf2_has_info): Use get_dwarf2_per_objfile and set_dwarf2_per_objfile. (dwarf2_get_dwz_file): Add dwarf2_per_objfile parameter. (dw2_do_instantiate_symtab): Get dwarf2_per_objfile from context, adjust calls. (dw2_instantiate_symtab): Likewise. (dw2_get_cutu): Add dwarf2_per_objfile parameter. (dw2_get_cu): Likewise. (create_cu_from_index_list): Change objfile parameter to dwarf2_per_objfile. (create_cus_from_index_list): Get dwarf2_per_objfile from context, adjust calls. (create_cus_from_index): Likewise. (create_signatured_type_table_from_index): Change objfile parameter to dwarf2_per_objfile. (create_signatured_type_table_from_debug_names): Change objfile parameter to dwarf2_per_objfile. (create_addrmap_from_index): Likewise. (create_addrmap_from_aranges): Likewise. (dwarf2_read_index): Use get_dwarf2_per_objfile, adjust calls. (dw2_setup): Remove. (dw2_get_file_names_reader): Get dwarf2_per_objfile from context. (dw2_find_last_source_symtab): Get dwarf2_per_objfile using get_dwarf2_per_objfile. (dw2_forget_cached_source_info): Likewise. (dw2_map_symtabs_matching_filename): Likewise. (struct dw2_symtab_iterator) <index>: Remove. <dwarf2_per_objfile>: New field. (dw2_symtab_iter_init): Replace index parameter with dwarf2_per_objfile. (dw2_symtab_iter_next): Use dwarf2_per_objfile from iter. (dw2_lookup_symbol): Use get_dwarf2_per_objfile and adjust. (dw2_print_stats): Likewise. (dw2_dump): Likewise. (dw2_expand_symtabs_for_function): Likewise. (dw2_expand_all_symtabs): Likewise. (dw2_expand_symtabs_with_fullname): Likewise. (dw2_expand_marked_cus): Replace index and objfile parameters with dwarf2_per_objfile. (dw_expand_symtabs_matching_file_matcher): Add dwarf2_per_objfile parameter and adjust calls. (dw2_expand_symtabs_matching): Use get_dwarf2_per_objfile and adjust calls. (dw2_find_pc_sect_compunit_symtab): Don't call dw2_setup. (dw2_map_symbol_filenames): Use get_dwarf2_per_objfile and adjust calls. (create_cus_from_debug_names_list): Replace objfile parameter with dwarf2_per_objfile and adjust calls. (create_cus_from_debug_names): Likewise. (dwarf2_read_debug_names): Likewise. (mapped_debug_names::namei_to_name): Adjust call. (dw2_debug_names_iterator::next): Likewise. (dw2_debug_names_iterator::find_vec_in_debug_names): Likewise. (dw2_debug_names_lookup_symbol): Use get_dwarf2_per_objfile. (dw2_debug_names_dump): Likewise. (dw2_debug_names_expand_symtabs_for_function): Likewise. (dw2_debug_names_expand_symtabs_matching): Likewise. (dwarf2_initialize_objfile): Likewise. (dwarf2_build_psymtabs): Likewise. (get_abbrev_section_for_cu): Get dwarf2_per_objfile from this_cu. (error_check_comp_unit_head): Add dwarf2_per_objfile parameter. (read_and_check_comp_unit_head): Likewise. (read_abbrev_offset): Likewise. (create_debug_type_hash_table): Likewise. (create_debug_types_hash_table): Likewise. (create_all_type_units): Replace objfile parameter with dwarf2_per_objfile. (add_type_unit): Add dwarf2_per_objfile parameter. (fill_in_sig_entry_from_dwo_entry): Replace objfile parameter with dwarf2_per_objfile. (lookup_dwo_signatured_type): Get dwarf2_per_objfile from cu. (lookup_dwp_signatured_type): Likewise. (lookup_signatured_type): Likewise. (read_cutu_die_from_dwo): Likewise. (init_tu_and_read_dwo_dies): Likewise. (init_cutu_and_read_dies): Likewise. (init_cutu_and_read_dies_no_follow): Likewise. (allocate_type_unit_groups_table): Add objfile parameter. (create_type_unit_group): Use dwarf2_per_objfile from cu. (get_type_unit_group): Likewise. (process_psymtab_comp_unit): Update call. (build_type_psymtabs_reader): Use dwarf2_per_objfile from cu. (build_type_psymtabs_1): Add dwarf2_per_objfile parameter. (print_tu_stats): Likewise. (build_type_psymtab_dependencies): Use dwarf2_per_objfile passed in void* parameter. (build_type_psymtabs): Change objfile parameter to dwarf2_per_objfile. (process_skeletonless_type_unit): Use dwarf2_per_objfile passed in void* parameter. (process_skeletonless_type_units): Change objfile parameter to dwarf2_per_objfile. (set_partial_user): Likewise. (dwarf2_build_psymtabs_hard): Likewise. (read_comp_units_from_section): Likewise. (create_all_comp_units): Likewise. (scan_partial_symbols): Update calls. (add_partial_symbol): Likewise. (dwarf2_read_symtab): Use get_dwarf2_per_objfile. (maybe_queue_comp_unit): Use dwarf2_read_symtab from cu. (process_queue): Add dwarf2_per_objfile parameter. (get_compunit_symtab): Use dwarf2_per_objfile from cu. (compute_compunit_symtab_includes): Likewise. (process_cu_includes): Add dwarf2_per_objfile parameter. (process_full_comp_unit): Use dwarf2_per_objfile from cu. (process_full_type_unit): Likewise. (process_imported_unit_die): Update call. (handle_DW_AT_stmt_list): Use dwarf2_per_objfile from cu. (read_file_scope): Likewise. (allocate_dwo_file_hash_table): Add objfile parameter. (lookup_dwo_file_slot): Add dwarf2_per_objfile parameter. (create_cus_hash_table): Likewise. (create_dwp_hash_table): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwp_v2_section): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (lookup_dwo_unit_in_dwp): Likewise. (try_open_dwop_file): Likewise. (open_dwo_file): Likewise. Use dwarf2_per_objfile from cu. (open_and_init_dwo_file): Use dwarf2_per_objfile from cu, update cleanup to include a reference to dwarf2_per_objfile. (open_dwp_file): Add dwarf2_per_objfile parameter. (open_and_init_dwp_file): Likewise. (get_dwp_file): Likewise. (lookup_dwo_cutu): Use dwarf2_per_objfile from cu. (queue_and_load_all_dwo_tus): Update call. (free_dwo_file_cleanup): Use dwarf2_per_objfile from cleanup data. (dwarf2_rnglists_process): Use dwarf2_per_objfile from cu. (dwarf2_ranges_process): Likewise. (dwarf2_get_pc_bounds): Likewise. (mark_common_block_symbol_computed): Likewise. (abbrev_table_read_table): Add dwarf2_per_objfile parameter. (dwarf2_read_abbrevs): Update call. (read_partial_die): Use dwarf2_per_objfile from cu. (find_partial_die): Likewise. (fixup_partial_die): Likewise. (read_attribute_value): Likewise. (read_indirect_string_at_offset_from): Add objfile parameter. (read_indirect_string_at_offset): Add dwarf2_per_objfile parameter. (read_indirect_string_from_dwz): Add objfile parameter. (read_indirect_string): Add objfile parameter. (read_addr_index_1): Add dwarf2_per_objfile parameter. (read_addr_index): Use dwarf2_per_objfile from cu. (dwarf2_read_addr_index): Use dwarf2_per_objfile from cu, don't call dw2_setup. (read_str_index): Use dwarf2_per_objfile from cu. (get_debug_line_section): Likewise. (read_formatted_entries): Add dwarf2_per_objfile parameter. (dwarf_decode_line_header): Use dwarf2_per_objfile from cu. (new_symbol_full): Use dwarf2_per_objfile from cu. (build_error_marker_type): Likewise. (lookup_die_type): Likewise. (determine_prefix): Likewise. (follow_die_offset): Likewise. (dwarf2_fetch_die_loc_sect_off): Use get_dwarf2_per_objfile. (dwarf2_fetch_constant_bytes): Don't call dw2_setup. (dwarf2_fetch_die_type_sect_off): Likewise. (dwarf2_get_die_type): Likewise. (follow_die_sig_1): Use dwarf2_per_objfile from cu. (get_signatured_type): Likewise. (get_DW_AT_signature_type): Likewise. (dwarf_decode_macro_bytes): Add dwarf2_per_objfile parameter. (dwarf_decode_macros): Use dwarf2_per_objfile from cu. (cu_debug_loc_section): Likewise. (fill_in_loclist_baton): Likewise. (dwarf2_symbol_mark_computed): Likewise. (dwarf2_find_containing_comp_unit): Change objfile parameter to dwarf2_per_objfile. (free_cached_comp_units): Use dwarf2_per_objfile passed in void* parameter. (age_cached_comp_units): Add dwarf2_per_objfile parameter. (free_one_cached_comp_unit): Use dwarf2_per_objfile from cu. (dwarf2_free_objfile): Use get_dwarf2_per_objfile. (set_die_type): Use dwarf2_free_objfile from cu. (get_die_type_at_offset): Likewise. (dwarf2_per_objfile_free): Don't assign global variable. (debug_names) <constructor>: Add dwarf2_per_objfile parameter, update m_debugstrlookup construction. (debug_names::debug_str_lookup): Add dwarf2_per_objfile parameter. <m_dwarf2_per_objfile>: New field. <lookup>: Use m_dwarf2_per_objfile. (check_dwarf64_offsets): Add dwarf2_per_objfile parameter. (psyms_seen_size): Likewise. (write_gdbindex): Replace objfile parameter with dwarf2_per_objfile. (write_debug_names): Likewise. (write_psymtabs_to_index): Likewise. (save_gdb_index_command): Use get_dwarf2_per_objfile, update calls.
2018-01-07Replace objfile field in dwarf2_cu and dwarf2_per_cu_data with ↵Simon Marchi1-111/+122
dwarf2_per_objfile The next patch aims to remove the dwarf2_per_objfile global. In many functions, we need to find a way to get a reference to the current dwarf2_per_objfile through the objects passed in parameters. Often, we have access to a dwarf2_cu or a dwarf2_per_cu_data. These objects have a reference to the objfile, through which we can get the dwarf2_per_objfile: dwarf2_per_objfile = ((struct dwarf2_per_objfile *) objfile_data (objfile, dwarf2_objfile_data_key)); However, this is a bit cumbersome to do all over the place. It would be more logical if the dwarf2_cu and dwarf2_per_cu_data had a reference to their dwarf2_per_objfile, which would then have a reference to the objfile. It would be more in line with the object hierarchy, where dwarf2_per_objfile owns the dwarf2_per_cu_data instances. We could even remove the reference dwarf2_cu has to dwarf2_per_objfile, since we can access dwarf2_per_objfile through dwarf2_cu::per_cu. In a graphical way, references would look like this after the current patch: objfile <--- dwarf2_per_objfile <--- dwarf2_per_cu_data | ^ | | `- dwarf2_cu This patch has been tested on the buildbot. gdb/ChangeLog: * dwarf2read.c (struct dwarf2_cu) <objfile>: Remove. <dwarf2_per_objfile>: New field. (struct dwarf2_per_cu_data) <objfile>: Remove. <dwarf2_per_objfile>: New field. (create_cu_from_index_list): Assign dwarf2_per_objfile instead of objfile. (create_signatured_type_table_from_index): Likewise. (create_debug_type_hash_table): Likewise. (fill_in_sig_entry_from_dwo_entry): Likewise. (lookup_dwo_unit): Access objfile through dwarf2_per_objfile. (create_type_unit_group): Assign dwarf2_per_objfile instead of objfile. (create_partial_symtab): Access objfile through dwarf2_per_objfile. (process_psymtab_comp_unit_reader): Likewise. (read_comp_units_from_section): Likewise. (scan_partial_symbols): Likewise. (add_partial_symbol): Likewise. (add_partial_subprogram): Likewise. (peek_die_abbrev): Likewise. (fixup_go_packaging): Likewise. (process_full_comp_unit): Likewise. (process_full_type_unit): Likewise. (process_imported_unit_die): Likewise. (dwarf2_compute_name): Likewise. (dwarf2_physname): Likewise. (read_import_statement): Likewise. (create_cus_hash_table): Assign dwarf2_physname instead of objfile. (read_func_scope): Access objfile through dwarf2_per_objfile. (read_lexical_block_scope): Likewise. (read_call_site_scope): Likewise. (read_variable): Likewise. (dwarf2_rnglists_process): Likewise. (dwarf2_ranges_process): Likewise. (dwarf2_ranges_read): Likewise. (dwarf2_record_block_ranges): Likewise. (dwarf2_add_field): Likewise. (dwarf2_add_member_fn): Likewise. (read_structure_type): Likewise. (process_structure_scope): Likewise. (read_enumeration_type): Likewise. (read_array_type): Likewise. (read_common_block): Likewise. (read_namespace_type): Likewise. (read_namespace): Likewise. (read_module_type): Likewise. (read_tag_pointer_type): Likewise. (read_tag_ptr_to_member_type): Likewise. (read_tag_string_type): Likewise. (read_subroutine_type): Likewise. (read_typedef): Likewise. (read_base_type): Likewise. (attr_to_dynamic_prop): Likewise. (read_subrange_type): Likewise. (read_unspecified_type): Likewise. (load_partial_dies): Likewise. (read_partial_die): Likewise. (find_partial_die): Likewise. (guess_partial_die_structure_name): Likewise. (fixup_partial_die): Likewise. (read_attribute_value): Likewise. (read_addr_index_from_leb128): Likewise. (dwarf2_read_addr_index): Likewise. (dwarf2_string_attr): Likewise. (lnp_state_machine::check_line_address): Likewise. (dwarf_decode_lines_1): Likewise. (dwarf_decode_lines): Likewise. (dwarf2_start_symtab): Likewise. (var_decode_location): Likewise. (new_symbol_full): Likewise. (dwarf2_const_value_data): Likewise. (dwarf2_const_value_attr): Likewise. (dwarf2_const_value): Likewise. (die_type): Likewise. (die_containing_type): Likewise. (lookup_die_type): Likewise. (guess_full_die_structure_name): Likewise. (anonymous_struct_prefix): Likewise. (dwarf2_name): Likewise. (follow_die_ref_or_sig): Likewise. (follow_die_offset): Likewise. (follow_die_ref): Likewise. (dwarf2_fetch_die_loc_sect_off): Likewise. (dwarf2_fetch_constant_bytes): Likewise. (dwarf2_fetch_die_type_sect_off): Likewise. (dwarf2_get_die_type): Likewise. (follow_die_sig): Likewise. (decode_locdesc): Likewise. (dwarf2_per_cu_objfile): Likewise. (dwarf2_per_cu_text_offset): Likewise. (init_one_comp_unit): Assign dwarf2_per_objfile instead of objfile. (set_die_type): Access objfile through dwarf2_per_objfile.
2018-01-01Add support for dynamic DW_AT_byte_stride.Joel Brobecker1-4/+23
This patch adds support for DW_AT_byte_stride, using Ada as one example of where this would be useful. However, the implementation is language-agnostic. Consider the following Ada code: procedure Nested (L, U : Integer) is subtype Small_Type is Integer range L .. U; type Record_Type (I : Small_Type := L) is record S : String (1 .. I); end record; type Array_Type is array (Integer range <>) of Record_Type; A1 : Array_Type := (1 => (I => 0, S => <>), 2 => (I => 1, S => "A"), 3 => (I => 2, S => "AB")); procedure Discard (R : Record_Type) is begin null; end Discard; begin Discard (A1 (1)); -- STOP end; It defines an array A1 of Record_Type, which is a variant record type whose maximum size actually depends on the value of the parameters passed when calling Nested. As a result, the stride of the array A1 cannot be known statically, which leads the compiler to generate a dynamic DW_AT_byte_stride attribute for our type. Here is what the debugging info looks like with GNAT: .uleb128 0x10 # (DIE (0x14e) DW_TAG_array_type) .long .LASF17 # DW_AT_name: "foo__nested__T18b" .long 0x141 # DW_AT_byte_stride .long 0xdc # DW_AT_type .uleb128 0x11 # (DIE (0x15f) DW_TAG_subrange_type) .long 0x166 # DW_AT_type .byte 0x3 # DW_AT_upper_bound .byte 0 # end of children of DIE 0x14e There DW_AT_byte_stride is a reference to a local (internal) variable: .uleb128 0x9 # (DIE (0x141) DW_TAG_variable) .long .LASF6 # DW_AT_name: "foo__nested__T18b___PAD___XVZ" This patch enhances GDB to handle this dynamic byte stride attribute by first adding a new dynamic_prop_node_kind (DYN_PROP_BYTE_STRIDE) to store the array dynamic stride info (when dynamic). It then enhances the dynamic type resolver to handle this dynamic property. Before applying this patch, trying to print the value of some of A1's elements after having stopped at the "STOP" comment does not work. For instance: (gdb) p a1(2) Cannot access memory at address 0x80000268dec0 With this patch applied, GDB now prints the value of all 3 elements correctly: (gdb) print A1(1) $1 = (i => 0, s => "") (gdb) print A1(2) $2 = (i => 1, s => "A") (gdb) print A1(3) $3 = (i => 2, s => "AB") gdb/ChangeLog: * gdbtypes.h (enum dynamic_prop_node_kind) <DYN_PROP_BYTE_STRIDE>: New enum value. (create_array_type_with_stride): Add byte_stride_prop parameter. * gdbtypes.c (create_array_type_with_stride) <byte_stride_prop>: New parameter. Update all callers in this file. (array_type_has_dynamic_stride): New function. (is_dynamic_type_internal, resolve_dynamic_array): Add handling of arrays with dynamic byte strides. * dwarf2read.c (read_array_type): Add support for dynamic DW_AT_byte_stride attributes. gdb/testsuite/ChangeLog: * gdb.ada/dyn_stride: New testcase. Tested on x86_64-linux.
2018-01-01treat Ada DW_TAG_unspecified_type DIEs as stub typesJoel Brobecker1-2/+7
Consider the gdb.ada/taft_type.exp testcase, which exercises the situation where a variable is defined using a type which is a pointer to an incomplete type, with the actual type definition being provided by another unit. Up to now, the strategy used by GNAT when generating the DWARF debugging info was to produce a incomplete DW_TAG_enumeration_type DIE with a DW_AT_declaration flag attached to it: .uleb128 0x4 # (DIE (0x3e) DW_TAG_enumeration_type) .long .LASF4 # DW_AT_name: "pck__empty" # DW_AT_declaration However, a more standard way for the compiler to describe this kind of type is to use the DW_TAG_unspecified_type tag. When the compiler is enhanced to do so, we'll need to treat such types as stubs -- we only do so with types from Ada units, however, as the meaning of this TAG is intentionally left permissive and language-specific by the DWARF standard. Without this patch, running the testcase above with an enhanced compiler now yields: (gdb) print w.e.all Attempt to dereference a generic pointer. FAIL: gdb.ada/taft_type.exp: print w.e.all gdb/ChangeLog: * dwarf2read.c (read_unspecified_type): Treat DW_TAG_enumeration_type DIEs from Ada units as stubs. Tested on x86_64-linux, fixes the FAIL in gdb.ada/taft_type.exp above.
2018-01-02Update copyright year range in all GDB filesJoel Brobecker1-1/+1
gdb/ChangeLog: Update copyright year range in all GDB files
2017-12-30dwarf2read: Silence -Wenum-compare-switch warningSimon Marchi1-0/+6
Compiling with Clang 6 gives: /home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:24385:14: error: comparison of two values with different enumeration types in switch statement ('enum dwarf_macro_record_type' and 'dwarf_macinfo_record_type') [-Werror,-Wenum-compare-switch] case DW_MACINFO_vendor_ext: ^~~~~~~~~~~~~~~~~~~~~ /home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:24561:7: error: comparison of two values with different enumeration types in switch statement ('enum dwarf_macro_record_type' and 'dwarf_macinfo_record_type') [-Werror,-Wenum-compare-switch] case DW_MACINFO_vendor_ext: ^~~~~~~~~~~~~~~~~~~~~ This code uses the two enum types on purpose, because it handles both .debug_macro and .debug_macinfo sections. Add some pragmas to disable the warning in these specific cases. gdb/ChangeLog: * dwarf2read.c (dwarf_decode_macro_bytes): Ignore -Wenum-compare-switch warning. (dwarf_decode_macros): Likewise.
2017-12-30Make mapped_debug_names and mapped_index finalSimon Marchi1-2/+2
When compiling with Clang 6, I see these warnings: /home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:25421:5: error: destructor called on non-final 'mapped_index' that has virtual functions but non-virtual destructor [-Werror,-Wdelete-non-virtual-dtor] data->index_table->~mapped_index (); ^ In file included from /home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:31: In file included from /home/emaisin/src/binutils-gdb/gdb/defs.h:28: In file included from /home/emaisin/src/binutils-gdb/gdb/common/common-defs.h:92: In file included from /home/emaisin/src/binutils-gdb/gdb/common/gdb_unique_ptr.h:23: In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/memory:81: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/bits/unique_ptr.h:76:2: error: delete called on non-final 'mapped_debug_names' that has virtual functions but non-virtual destructor [-Werror,-Wdelete-non-virtual-dtor] delete __ptr; ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/bits/unique_ptr.h:236:4: note: in instantiation of member function 'std::default_delete<mapped_debug_names>::operator()' requested here get_deleter()(__ptr); ^ /home/emaisin/src/binutils-gdb/gdb/dwarf2read.c:2374:21: note: in instantiation of member function 'std::unique_ptr<mapped_debug_names, std::default_delete<mapped_debug_names> >::~unique_ptr' requested here dwarf2_per_objfile::dwarf2_per_objfile (struct objfile *objfile_, ^ This patch silences these warnings by making the classes final. gdb/ChangeLog: * dwarf2read.c (struct mapped_debug_names): Make final. (struct mapped_index): Make final.
2017-12-14DWARF-5 .debug_names DW_IDX_type_unit fixJan Kratochvil1-25/+111
The .debug_names completely misses its support as it did not even produce DW_IDX_type_unit. gdb/ChangeLog 2017-12-14 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf2read.c (dw2_debug_names_iterator::next): Support DW_IDX_type_unit. (debug_names::dwarf5_offset_size, unit_kind): New. (debug_names::insert): Add parameter kind. (debug_names::build): Support DW_IDX_type_unit. (debug_names::recursively_write_psymbols): Update (debug_names::write_psymbols caller. (debug_names::write_one_signatured_type_data) (debug_names::write_one_signatured_type): New. (debug_names::index_key, debug_names::symbol_value) (debug_names::write_psymbols): Add kind. (debug_names::write_one_signatured_type): New. (write_debug_names): Move dwarf5_offset_size to debug_names. Use debug_names::write_one_signatured_type for type units.
2017-12-11Unbreak build for non-ELF portsPedro Alves1-18/+14
As reported at <https://sourceware.org/ml/gdb-patches/2017-12/msg00229.html>, this commit: ~~~~ commit abccd1e7b7a37385159610ca4e0bc2632a547e9a Author: Jan Kratochvil <jan.kratochvil@redhat.com> AuthorDate: Fri Dec 8 22:44:11 2017 +0000 Change dwarf2_initialize_objfile's return value dwarf2_initialize_objfile was returning boolean whether it is psymtabs or .gdb_index while now it needs to return also whether it is .debug_names. ~~~~ breaks non-ELF-target builds: dwarf2read.o: In function `dwarf2_initialize_objfile(objfile*)': /home/yao.qi/SourceCode/gnu/binutils-gdb/gdb/dwarf2read.c:6486: undefined reference to `elf_sym_fns_gdb_index' /home/yao.qi/SourceCode/gnu/binutils-gdb/gdb/dwarf2read.c:6490: undefined reference to `elf_sym_fns_debug_names' /home/yao.qi/SourceCode/gnu/binutils-gdb/gdb/dwarf2read.c:6495: undefined reference to `elf_sym_fns_lazy_psyms' collect2: error: ld returned 1 exit status Makefile:1920: recipe for target 'gdb' failed because gdb/elfread.c is not included in the gdb build unless bfd also includes elf support. Fix this by reverting the patch mentioned above and at the same time re-adding .debug_names support by adding a new output parameter to dwarf2_initialize_objfile to indicate the index variant in use. We can reuse the new dw_index_kind enum in dwarf2read.c for that. gdb/ChangeLog: 2017-12-11 Pedro Alves <palves@redhat.com> * defs.h (elf_sym_fns_lazy_psyms, elf_sym_fns_gdb_index) (elf_sym_fns_debug_names): Move to elfread.c. * dwarf2read.c (dwarf2_initialize_objfile): Return a boolean instead of a sym_fns and add 'index_kind' output parameter. Fill the latter in with the index variant kind if using an index. (enum dw_index_kind): Moved to symfile.h. * elfread.c (elf_sym_fns_gdb_index, elf_sym_fns_debug_names) (elf_sym_fns_lazy_psyms): Move from defs.h. (elf_symfile_read): Adjust to new dwarf2_initialize_objfile interface. * symfile.h (enum class dw_index_kind): New, moved from dwarf2read.c. (dwarf2_initialize_objfile): Change prototype.
2017-12-08dwarf2read.c: Rewrite/simplify mock_mapped_indexPedro Alves1-45/+28
Now that dw2_expand_symtabs_matching_symbol works with the abstract mapped_index_base, we can make mock_mapped_index inherit mapped_index_base too instead of having it pretend to be a real .gdb_index table. gdb/ChangeLog: 2017-12-08 Pedro Alves <palves@redhat.com> * dwarf2read.c (mock_mapped_index): Reimplement as an extension of mapped_index_base. (check_match): Adjust to use mock_index directly. (check_find_bounds_finds) (test_mapped_index_find_name_component_bounds): Adjust to work with a mapped_index_base.
2017-12-08Support wildmatching in .debug_names too.Pedro Alves1-41/+75
dw2_debug_names_expand_symtabs_matching currently doesn't support symbol_name_match_type::WILD, it always matches symbol names fully. The .gdb_index code supports via dw2_expand_symtabs_matching_symbol, which builds the mapped_index::name_components table on demand, and then binary searches that table. The .debug_names names index is pretty much the same as the .gdb_index names index, i.e., a list of fully-qualified names with no parameter/overload info. (There's no what-is-the-language-of-symbol-name info in .debug_names either, unfortunately.) So this fixes .debug_names by factoring out the related .gdb_index code out of the mapped_index class to a base class that is inherited by both the .gdb_index (mapped_index) and .debug_names (mapped_debug_names) map classes. gdb/ChangeLog: 2017-12-08 Pedro Alves <palves@redhat.com> * dwarf2read.c (struct mapped_index_base): New, partially factored out from ... (struct mapped_index): ... this. Inherit mapped_index_base. (mapped_index::symbol_name_slot_invalid): (mapped_index::symbol_name_at): Add override marker. (mapped_index::symbol_name_count): New. (struct mapped_debug_names): Inherit mapped_index_base. (mapped_debug_names::symbol_name_at): New. (mapped_debug_names::symbol_name_count): New. (mapped_index::find_name_components_bounds): Rename to ... (mapped_index_base::find_name_components_bounds): ... this. (mapped_index::build_name_components): Rename to ... (mapped_index_base::build_name_components): ... this. Adjust to use mapped_index_base::symbol_name_count and mapped_index_base::symbol_name_slot_invalid. (dw2_expand_symtabs_matching_symbol): Take a mapped_index_base instead of a mapped_index. Use dw2_expand_symtabs_matching_symbol.
2017-12-08dwarf2read.c:mapped_index, use gdb::array_view, simplify symbol tablePedro Alves1-39/+40
This replaces a couple ptr+size pairs with gdb::array_view in the .gdb_index code, and simplifies things by using an aggregate for the type of the symbol table hash bucket instead of having to consider the distinction between size of table vs number of slots and access name vs vec by index. gdb/ChangeLog: 2017-12-08 Pedro Alves <palves@redhat.com> * dwarf2read.c (mapped_index::symbol_table_slot): New. (mapped_index::address_table): Now a gdb::array_view of const gdb_byte. (mapped_index::symbol_table): Now a gdb::array_view of symbol_table_slot. (mapped_index::address_table_size) (mapped_index::symbol_table_slots): Delete. (create_addrmap_from_index): Adjust. (find_slot_in_mapped_hash): Adjust. (read_index_from_section): Adjust. (dwarf2_read_index): Adjust.
2017-12-08DWARF-5: .debug_names index consumerJan Kratochvil1-18/+1108
Some testcases needed to be updated as they were missing .debug_aranges. While that does not matter for no-index (as GDB builds the mapping internally during dwarf2_build_psymtabs_hard) and neither for .gdb_index (as GDB uses that internally built mapping which it stores into .gdb_index) it does matter for .debug_names as that simply assumes existing .debug_aranges from GCC. gdb/ChangeLog: 2017-12-08 Jan Kratochvil <jan.kratochvil@redhat.com> Pedro Alves <palves@redhat.com> * defs.h (elf_sym_fns_debug_names): New declaration. * dwarf2read.c: Include "hash_enum.h". (mapped_debug_names): New. (struct dwarf2_per_objfile): Add debug_names, debug_aranges and debug_names_table. (dwarf2_elf_names): Add ".debug_names" and ".debug_aranges". (struct dwz_file): Add debug_names. (dwarf2_per_objfile::locate_sections): Handle debug_names and debug_aranges. (locate_dwz_sections): Handle debug_names. (create_signatured_type_table_from_debug_names) (create_addrmap_from_aranges): New. (dwarf2_read_index): Update function comment. (dwarf5_augmentation): Moved up. (read_debug_names_from_section, create_cus_from_debug_names_list) (create_cus_from_debug_names, dwarf2_read_debug_names): New. (dwarf5_djb_hash): Moved up. (dw2_debug_names_iterator): New. (read_indirect_string_at_offset): New declaration. (mapped_debug_names::namei_to_name) (dw2_debug_names_iterator::find_vec_in_debug_names) (dw2_debug_names_iterator::next, dw2_debug_names_lookup_symbol) (dw2_debug_names_dump, dw2_debug_names_expand_symtabs_for_function) (dw2_debug_names_expand_symtabs_matching, dwarf2_debug_names_functions): New. (dwarf2_initialize_objfile): Return also elf_sym_fns_debug_names. (debug_names::djb_hash): Rename it to dwarf5_djb_hash. (debug_names::build): Update djb_hash caller. (write_debug_names): Move out and rename augmentation to dwarf5_augmentation. * elfread.c (elf_sym_fns_debug_names): New. * psymtab.h (dwarf2_debug_names_functions): New declaration. * symfile.h (struct dwarf2_debug_sections): Add debug_names and debug_aranges. * xcoffread.c (dwarf2_xcoff_names): Add debug_names and debug_aranges. gdb/testsuite/ChangeLog: 2017-12-08 Jan Kratochvil <jan.kratochvil@redhat.com> Pedro Alves <palves@redhat.com> * gdb.base/maint.exp (check for .gdb_index): Check also for .debug_names. * gdb.dlang/watch-loc.c (.debug_aranges): New. * gdb.dwarf2/dw2-case-insensitive-debug.S: Likewise. * gdb.dwarf2/gdb-index.exp (check if index present, .gdb_index used) (.gdb_index used after symbol reloading): Support also .debug_names. * gdb.mi/dw2-ref-missing-frame-func.c (.debug_aranges): New.
2017-12-08Refactor: Move some generic code out of .gdb_index codeJan Kratochvil1-89/+131
Preparation for the next patch. gdb/ChangeLog 2017-12-08 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf2read.c (create_cu_from_index_list): New from ... (create_cus_from_index_list): ... this function, use it. (dw_expand_symtabs_matching_file_matcher) (dw2_expand_symtabs_matching_one): New from ... (dw2_expand_symtabs_matching): ... this function, use them.
2017-12-08Change dwarf2_initialize_objfile's return valueJan Kratochvil1-4/+4
dwarf2_initialize_objfile was returning boolean whether it is psymtabs or .gdb_index while now it needs to return also whether it is .debug_names. gdb/ChangeLog 2017-12-08 Jan Kratochvil <jan.kratochvil@redhat.com> * defs.h (elf_sym_fns_lazy_psyms, elf_sym_fns_gdb_index): Move here declarations from elfread.c. (dwarf2_initialize_objfile): Change return value. * elfread.c (elf_sym_fns_lazy_psyms, elf_sym_fns_gdb_index): Move these declarations to defs.h. (elf_symfile_read): Adjust dwarf2_initialize_objfile caller. * symfile.h (dwarf2_initialize_objfile): Change return type.
2017-12-08DWARF-5: .debug_names index producerJan Kratochvil1-49/+867
This adds a new "-dwarf-5" switch to "save gdb-index" that makes it generate index files with DWARF-5 .debug_names/.debug_str sections instead of GDB's own .gdb_index. We should probably add a command line option to contrib/gdb-add-index.sh (incl. cc-with-tweaks.sh) for the new -dwarf-5 GDB option, and a new target board to make it more convenient to exercise this. To be done later. gdb/ChangeLog 2017-12-08 Jan Kratochvil <jan.kratochvil@redhat.com> Pedro Alves <palves@redhat.com> * contrib/gdb-add-index.sh (index): Rename to ... (index4): ... here. (index5, debugstr, debugstrmerge, debugstrerr): New variables. Support also .debug_names and .debug_str. * dwarf2read.c: Include cmath, set, list. (INDEX_SUFFIX): Rename to ... (INDEX4_SUFFIX): ... here. (INDEX5_SUFFIX, DEBUG_STR_SUFFIX): New. (file_write(FILE *, const void *, size_t)): New. (file_write(FILE *, const std::vector<Elem, Alloc> &)): New. (data_buf::append_unsigned_leb128, data_buf::empty): New. (data_buf::file_write): Use ::file_write. (data_buf::c_str, dwarf5_djb_hash, debug_names) (check_dwarf64_offsets): New. (psyms_seen_size, write_gdbindex): New from write_psymtabs_to_index code. (dwarf5_gdb_augmentation, write_debug_names, assert_file_size) (enum dw_index_kind): New. (write_psymtabs_to_index): New parameter index_kind. Support filename_str and out_file_str. Move code to write_gdbindex, possibly call write_debug_names. (save_gdb_index_command): New parameter -dwarf-5. (_initialize_dwarf2_read): Document the new parameter -dwarf-5. gdb/doc/ChangeLog 2017-12-08 Jan Kratochvil <jan.kratochvil@redhat.com> * gdb.texinfo (Index Files): Document .debug_names and -dwarf-5. -- gdb/contrib/gdb-add-index.sh | 53 ++ gdb/doc/gdb.texinfo | 24 + gdb/dwarf2read.c | 919 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 935 insertions(+), 61 deletions(-)
2017-12-07Record nested typesKeith Seitz1-22/+76
GDB currently does not track types defined in classes. Consider: class A { public: class B { public: class C { }; }; }; (gdb) ptype A type = class A { <no data fields> } This patch changes this behavior so that GDB records these nested types and displays them to the user when he has set the (new) "print type" option "nested-type-limit." Example: (gdb) set print type nested-type-limit 1 (gdb) ptype A type = class A { <no data fields> class A::B { <no data fields> }; } (gdb) set print type nested-type-limit 2 type = class A { <no data fields> class A::B { <no data fields> class A::B::C { <no data fields> }; }; } By default, the code maintains the status quo, that is, it will not print any nested type definitions at all. Testing is carried out via cp_ptype_class which required quite a bit of modification to permit recursive calling (for the nested types). This was most easily facilitated by turning the ptype command output into a queue. Upshot: the test suite now has stack and queue data structures that may be used by test writers. gdb/ChangeLog * NEWS (New commands): Mention set/show print type nested-type-limit. * c-typeprint.c (c_type_print_base): Print out nested types. * dwarf2read.c (struct typedef_field_list): Rename to ... (struct decl_field_list): ... this. Change all uses. (struct field_info) <nested_types_list, nested_types_list_count>: New fields. (add_partial_symbol): Look for nested type definitions in C++, too. (dwarf2_add_typedef): Rename to ... (dwarf2_add_type_defn): ... this. (type_can_define_types): New function. Update assertion to use type_can_define_types. Permit NULL for a field's name. (process_structure_scope): Handle child DIEs of types that can define types. Copy the list of nested types into the type struct. * gdbtypes.h (struct typedef_field): Rename to ... (struct decl_field): ... this. Change all uses. [is_protected, is_private]: New fields. (struct cplus_struct_type) <nested_types, nested_types_count>: New fields. (TYPE_NESTED_TYPES_ARRAY, TYPE_NESTED_TYPES_FIELD) (TYPE_NESTED_TYPES_FIELD_NAME, TYPE_NESTED_TYPES_FIELD_TYPE) (TYPE_NESTED_TYPES_COUNT, TYPE_NESTED_TYPES_FIELD_PROTECTED) (TYPE_NESTED_TYPES_FIELD_PRIVATE): New macros. * typeprint.c (type_print_raw_options, default_ptype_flags): Add default value for print_nested_type_limit. (print_nested_type_limit): New static variable. (set_print_type_nested_types, show_print_type_nested_types): New functions. (_initialize_typeprint): Register new commands for set/show `print-nested-type-limit'. * typeprint.h (struct type_print_options) [print_nested_type_limit]: New field. gdb/testsuite/ChangeLog * gdb.cp/nested-types.cc: New file. * gdb.cp/nested-types.exp: New file. * lib/cp-support.exp: Load data-structures.exp library. (debug_cp_test_ptype_class): New global. (cp_ptype_class_verbose, next_line): New procedures. (cp_test_ptype_class): Add and document new parameter `recursive_qid'. Add and document new return value. Switch the list of lines to a queue. Add support for new `type' key for nested type definitions. Add debugging/troubleshooting messages. * lib/data-structures.exp: New file. gdb/doc/ChangeLog * gdb.texinfo (Symbols): Document "set print type nested-type-limit" and "show print type nested-type-limit".
2017-12-05Remove some unused variablesSimon Marchi1-24/+0
This patch removes some unused variables, found with -Wunused. I have not removed everything reported by -Wunused, because some expressions such as struct type *arg_type = check_typedef (value_type); in bfin-tdep.c could have an unexpected but important side-effect. I removed others that I considered more low-risk, such as: struct gdbarch *gdbarch = get_objfile_arch (objfile); I tested building with Python 2/Python 3/no Python, with/without expat, with/without libipt and with/without babeltrace. gdb/ChangeLog: * ada-lang.c (ada_collect_symbol_completion_matches): Remove unused variables. (ada_is_redundant_range_encoding): Likewise. * ada-varobj.c (ada_varobj_get_value_of_array_variable): Likewise. * alpha-tdep.c (alpha_software_single_step): Likewise. * arm-tdep.c (_initialize_arm_tdep): Likewise. * auto-load.c (info_auto_load_cmd): Likewise. * break-catch-syscall.c (insert_catch_syscall): Likewise. (remove_catch_syscall): Likewise. * breakpoint.c (condition_completer): Likewise. (clear_command): Likewise. (update_breakpoint_locations): Likewise. * btrace.c (btrace_disable): Likewise. (btrace_teardown): Likewise. (btrace_maint_update_pt_packets): Likewise. (maint_btrace_clear_cmd): Likewise. * cli/cli-decode.c (lookup_cmd_1): Likewise. (lookup_cmd_composition): Likewise. * cli/cli-dump.c (scan_filename): Likewise. (restore_command): Likewise. * compile/compile-loc2c.c (compute_stack_depth): Likewise. * compile/compile-object-load.c (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * compile/compile.c (compile_to_object): Likewise. * completer.c (filename_completer): Likewise. (complete_files_symbols): Likewise. (complete_expression): Likewise. * corelow.c (core_open): Likewise. * ctf.c (ctf_start): Likewise. (ctf_write_status): Likewise. (ctf_write_uploaded_tsv): Likewise. (ctf_write_definition_end): Likewise. (ctf_open_dir): Likewise. (ctf_xfer_partial): Likewise. (ctf_trace_find): Likewise. * disasm.c (gdb_pretty_print_disassembler::pretty_print_insn): Likewise. * dwarf2loc.c (allocate_piece_closure): Likewise. (indirect_pieced_value): Likewise. (dwarf2_evaluate_loc_desc_full): Likewise. * dwarf2read.c (dw2_expand_marked_cus): Likewise. (dw2_expand_symtabs_matching): Likewise. (dw2_map_symbol_filenames): Likewise. (read_and_check_comp_unit_head): Likewise. (read_cutu_die_from_dwo): Likewise. (lookup_dwo_unit): Likewise. (read_comp_units_from_section): Likewise. (dwarf2_compute_name): Likewise. (handle_DW_AT_stmt_list): Likewise. (create_cus_hash_table): Likewise. (create_dwp_v2_section): Likewise. (dwarf2_rnglists_process): Likewise. (dwarf2_ranges_process): Likewise. (dwarf2_record_block_ranges): Likewise. (is_vtable_name): Likewise. (read_formatted_entries): Likewise. (skip_form_bytes): Likewise. * elfread.c (elf_symtab_read): Likewise. * exec.c (exec_file_command): Likewise. * f-valprint.c (f_val_print): Likewise. (info_common_command_for_block): Likewise. * guile/guile.c (initialize_scheme_side): Likewise. * guile/scm-breakpoint.c (gdbscm_breakpoint_commands): Likewise. * guile/scm-cmd.c (cmdscm_completer): Likewise. (gdbscm_register_command_x): Likewise. * guile/scm-frame.c (gdbscm_frame_read_var): Likewise. * guile/scm-param.c (gdbscm_parameter_value): Likewise. * guile/scm-ports.c (file_port_magic): Likewise. * guile/scm-pretty-print.c (ppscm_search_pp_list): Likewise. (ppscm_pretty_print_one_value): Likewise. (ppscm_print_children): Likewise. * guile/scm-string.c (gdbscm_string_to_argv): Likewise. * guile/scm-symtab.c (gdbscm_sal_symtab): Likewise. * guile/scm-type.c (gdbscm_type_next_field_x): Likewise. * guile/scm-utils.c (gdbscm_parse_function_args): Likewise. * i386-tdep.c (i386_register_reggroup_p): Likewise. * infcmd.c (run_command_1): Likewise. (until_next_fsm_clean_up): Likewise. * linespec.c (linespec_complete): Likewise. (find_label_symbols): Likewise. * m2-valprint.c (m2_val_print): Likewise. * memattr.c (require_user_regions): Likewise. (lookup_mem_region): Likewise. (disable_mem_command): Likewise. (mem_delete): Likewise. * mep-tdep.c (mep_register_name): Likewise. (mep_analyze_prologue): Likewise. * mi/mi-cmd-file.c (mi_cmd_file_list_shared_libraries): Likewise. * mi/mi-interp.c (mi_on_sync_execution_done): Likewise. * mi/mi-main.c (mi_cmd_trace_frame_collected): Likewise. * microblaze-linux-tdep.c (microblaze_linux_init_abi): Likewise. * minidebug.c (lzma_open): Likewise. * minsyms.c (lookup_minimal_symbol): Likewise. * mips-linux-tdep.c (mips64_fill_fpregset): Likewise. * mips-tdep.c (mips_stub_frame_sniffer): Likewise. (mips_o64_return_value): Likewise. (mips_single_step_through_delay): Likewise. (_initialize_mips_tdep): Likewise. * nios2-tdep.c (nios2_push_dummy_call): Likewise. (nios2_software_single_step): Likewise. * parse.c (find_minsym_type_and_address): Likewise. * psymtab.c (psym_relocate): Likewise. * python/py-breakpoint.c (bppy_get_commands): Likewise. (gdbpy_breakpoint_modified): Likewise. * python/py-infevents.c (create_inferior_call_event_object): Likewise. * python/py-record-btrace.c (btpy_list_item): Likewise. * python/py-type.c (typy_str): Likewise. * python/py-value.c (valpy_call): Likewise. * python/python.c (do_start_initialization): Likewise. * record-btrace.c (record_btrace_insn_history_range): Likewise. (record_btrace_call_history_range): Likewise. (record_btrace_record_method): Likewise. (record_btrace_xfer_partial): Likewise. (btrace_get_frame_function): Likewise. * record-full.c (record_full_open): Likewise. * record.c (get_context_size): Likewise. * registry.h (DEFINE_REGISTRY): Likewise. * remote-fileio.c (remote_fileio_request): Likewise. * remote.c (remote_update_thread_list): Likewise. (remote_check_symbols): Likewise. (remote_commit_resume): Likewise. (remote_interrupt): Likewise. (remote_insert_breakpoint): Likewise. (compare_sections_command): Likewise. * rust-exp.y (super_name): Likewise. (lex_string): Likewise. (convert_ast_to_type): Likewise. (convert_ast_to_expression): Likewise. * rust-lang.c (rust_print_struct_def): Likewise. (rust_print_type): Likewise. (rust_evaluate_subexp): Likewise. * rx-tdep.c (rx_register_type): Likewise. * ser-event.c (serial_event_clear): Likewise. * serial.c (serial_open): Likewise. * spu-tdep.c (spu_overlay_new_objfile): Likewise. * symfile.c (section_is_overlay): Likewise. (overlay_unmapped_address): Likewise. (overlay_mapped_address): Likewise. (simple_overlay_update_1): Likewise. (simple_overlay_update): Likewise. * symtab.c (symbol_find_demangled_name): Likewise. (search_symbols): Likewise. * target-descriptions.c (tdesc_predefined_type): Likewise. * target.c (target_commit_resume): Likewise. * thread.c (print_selected_thread_frame): Likewise. * top.c (new_ui_command): Likewise. (gdb_readline_no_editing): Likewise. * tracefile-tfile.c (tfile_open): Likewise. * tracepoint.c (create_tsv_from_upload): Likewise. * utils.c (quit): Likewise. (defaulted_query): Likewise. * valarith.c (value_concat): Likewise. * xml-syscall.c (xml_list_syscalls_by_group): Likewise. * xml-tdesc.c (target_fetch_description_xml): Likewise. * xtensa-tdep.c (xtensa_pseudo_register_read): Likewise. (xtensa_pseudo_register_write): Likewise. gdb/gdbserver/ChangeLog: * regcache.c (registers_to_string): Remove unused variable.