summaryrefslogtreecommitdiff
path: root/gdb/dwarf2read.c
AgeCommit message (Collapse)Author
2018-01-10language_get_symbol_name_matcher -> get_symbol_name_matcherPedro Alves
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 Alves
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-01Add support for dynamic DW_AT_byte_stride.Joel Brobecker
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 Brobecker
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 Brobecker
gdb/ChangeLog: Update copyright year range in all GDB files
2017-12-30dwarf2read: Silence -Wenum-compare-switch warningSimon Marchi
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 Marchi
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 Kratochvil
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 Alves
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 Alves
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 Alves
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 Alves
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 Kratochvil
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 Kratochvil
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 Kratochvil
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 Kratochvil
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 Seitz
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 Marchi
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.
2017-12-01Add support for the readnever conceptSergio Durigan Junior
The purpose of this concept is to turn the load of debugging information off, either globally (via the '--readnever' option), or objfile-specific. The implementation proposed here is an extension of the patch distributed with Fedora GDB; looking at the Fedora patch itself and the history, one can see some reasons why it was never resubmitted: - The patch appears to have been introduced as a workaround, at least initially; - The patch is far from perfect, as it simply shunts the load of DWARF debugging information, without really worrying about the other debug format. - Who really does non-symbolic debugging anyways? One use of this feature is when a user simply wants to do the following sequence: attach, dump core, detach. Loading the debugging information in this case is an unnecessary cause of delay. This patch expands the version shipped with Fedora GDB in order to make the feature available for all the debuginfo backends, not only for DWARF. It also implements a per-objfile flag which can be activated by using the "-readnever" command when using the 'add-symbol-file' or 'symbol-file' commands. It's also worth mentioning that this patch tests whether GDB correctly fails to initialize if both '--readnow' and '--readnever' options are passed. Tested on the BuildBot. gdb/ChangeLog: 2017-12-01 Andrew Cagney <cagney@redhat.com> Joel Brobecker <brobecker@adacore.com> Sergio Durigan Junior <sergiodj@redhat.com> * NEWS (Changes since GDB 8.0: Mention new '--readnever' feature. * coffread.c (coff_symfile_read): Do not map over sections with 'coff_locate_sections' if readnever is on. * dwarf2read.c (dwarf2_has_info): Return 0 if readnever is on. * elfread.c (elf_symfile_read): Do not map over sections with 'elf_locate_sections' if readnever is on. * main.c (validate_readnow_readnever): New function. (captured_main_1): Add support for --readnever. (print_gdb_help): Document --readnever. * objfile-flags.h (enum objfile_flag) <OBJF_READNEVER>: New flag. * symfile.c (readnever_symbol_files): New global. (symbol_file_add_with_addrs): Set 'OBJF_READNEVER' when 'READNEVER_SYMBOL_FILES' is set. (validate_readnow_readnever): New function. (symbol_file_command): Handle '-readnever' option. Call 'validate_readnow_readnever'. (add_symbol_file_command): Handle '-readnever' option. Call 'validate_readnow_readnever'. (_initialize_symfile): Document new '-readnever' option for both 'symbol-file' and 'add-symbol-file' commands. * top.h (readnever_symbol_files): New extern global. * xcoffread.c (xcoff_initial_scan): Do not read debug information if readnever is on. gdb/doc/ChangeLog: 2017-12-01 Andrew Cagney <cagney@redhat.com> Joel Brobecker <brobecker@adacore.com> Sergio Durigan Junior <sergiodj@redhat.com> * gdb.texinfo (File Options): Document --readnever. (Commands to Specify Files): Likewise, for 'symbol-file' and 'add-symbol-file'. gdb/testsuite/ChangeLog: 2017-12-01 Joel Brobecker <brobecker@adacore.com> Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * gdb.base/readnever.c, gdb.base/readnever.exp: New files.
2017-12-01Revert "Add support for the readnever concept"Sergio Durigan Junior
This reverts commit e2e321740ce2e36a97be2a410cd56eebaa2304aa. It was mistakenly pushed.
2017-12-01Add support for the readnever conceptSergio Durigan Junior
The purpose of this concept is to turn the load of debugging information off, either globally (via the '--readnever' option), or objfile-specific. The implementation proposed here is an extension of the patch distributed with Fedora GDB; looking at the Fedora patch itself and the history, one can see some reasons why it was never resubmitted: - The patch appears to have been introduced as a workaround, at least initially; - The patch is far from perfect, as it simply shunts the load of DWARF debugging information, without really worrying about the other debug format. - Who really does non-symbolic debugging anyways? One use of this feature is when a user simply wants to do the following sequence: attach, dump core, detach. Loading the debugging information in this case is an unnecessary cause of delay. This patch expands the version shipped with Fedora GDB in order to make the feature available for all the debuginfo backends, not only for DWARF. It also implements a per-objfile flag which can be activated by using the "-readnever" command when using the 'add-symbol-file' or 'symbol-file' commands. It's also worth mentioning that this patch tests whether GDB correctly fails to initialize if both '--readnow' and '--readnever' options are passed. Tested on the BuildBot. gdb/ChangeLog: 2017-12-01 Andrew Cagney <cagney@redhat.com> Joel Brobecker <brobecker@adacore.com> Sergio Durigan Junior <sergiodj@redhat.com> * NEWS (Changes since GDB 8.0: Mention new '--readnever' feature. * coffread.c (coff_symfile_read): Do not map over sections with 'coff_locate_sections' if readnever is on. * dwarf2read.c (dwarf2_has_info): Return 0 if readnever is on. * elfread.c (elf_symfile_read): Do not map over sections with 'elf_locate_sections' if readnever is on. * main.c (validate_readnow_readnever): New function. (captured_main_1): Add support for --readnever. (print_gdb_help): Document --readnever. * objfile-flags.h (enum objfile_flag) <OBJF_READNEVER>: New flag. * symfile.c (readnever_symbol_files): New global. (symbol_file_add_with_addrs): Set 'OBJF_READNEVER' when 'READNEVER_SYMBOL_FILES' is set. (validate_readnow_readnever): New function. (symbol_file_command): Handle '-readnever' option. Call 'validate_readnow_readnever'. (add_symbol_file_command): Handle '-readnever' option. Call 'validate_readnow_readnever'. (_initialize_symfile): Document new '-readnever' option for both 'symbol-file' and 'add-symbol-file' commands. * top.h (readnever_symbol_files): New extern global. * xcoffread.c (xcoff_initial_scan): Do not read debug information if readnever is on. gdb/doc/ChangeLog: 2017-12-01 Andrew Cagney <cagney@redhat.com> Joel Brobecker <brobecker@adacore.com> Sergio Durigan Junior <sergiodj@redhat.com> * gdb.texinfo (File Options): Document --readnever. (Commands to Specify Files): Likewise, for 'symbol-file' and 'add-symbol-file'. gdb/testsuite/ChangeLog: 2017-12-01 Joel Brobecker <brobecker@adacore.com> Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * gdb.base/readnever.c, gdb.base/readnever.exp: New files.
2017-11-29Make "break foo" find "A::foo", A::B::foo", etc. [C++ and wild matching]Pedro Alves
This patch teaches GDB about setting breakpoints in all scopes (namespaces and classes) by default. Here's a contrived example: (gdb) b func<tab> (anonymous namespace)::A::function() Bn::(anonymous namespace)::B::function() function(int, int) (anonymous namespace)::B::function() Bn::(anonymous namespace)::function() gdb::(anonymous namespace)::A::function() (anonymous namespace)::B::function() const Bn::(anonymous namespace)::function(int, int) gdb::(anonymous namespace)::function() (anonymous namespace)::function() Bn::B::func() gdb::(anonymous namespace)::function(int, int) (anonymous namespace)::function(int, int) Bn::B::function() gdb::A::func() A::func() Bn::func() gdb::A::function() A::function() Bn::function() gdb::func() B::func() Bn::function(int, int) gdb::function() B::function() Bn::function(long) gdb::function(int, int) B::function() const func() gdb::function(long) B::function_const() const function() (gdb) b function Breakpoint 1 at 0x4005ce: function. (26 locations) (gdb) b B::function<tab> (anonymous namespace)::B::function() B::function() const Bn::B::function() (anonymous namespace)::B::function() const B::function_const() const B::function() Bn::(anonymous namespace)::B::function() (gdb) b B::function Breakpoint 1 at 0x40072c: B::function. (6 locations) To get back the original behavior of interpreting the function name as a fully-qualified name, you can use the new "-qualified" (or "-q") option/flag (added by this commit). For example: (gdb) b B::function (anonymous namespace)::B::function() B::function() const Bn::B::function() (anonymous namespace)::B::function() const B::function_const() const B::function() Bn::(anonymous namespace)::B::function() vs: (gdb) b -qualified B::function B::function() B::function() const B::function_const() const I've chosen "-qualified" / "-q" because "-f" (for "full" or "fully-qualified") is already taken for "-function". Note: the "-qualified" option works with both linespecs and explicit locations. I.e., these are equivalent: (gdb) b -q func (gdb) b -q -f func and so are these: (gdb) b -q filename.cc:func (gdb) b -q -s filename.cc -f func (gdb) b -s filename.cc -q -f func (gdb) b -s filename.cc -f func -q To better understand why I consider wild matching the better default, consider what happens when we get to the point when _all_ of GDB is wrapped under "namespace gdb {}". I have a patch series that does that, and when I started debugging that GDB, I immediately became frustrated. You'd have to write "b gdb::internal_error", "b gdb::foo", "b gdb::bar", etc. etc., which gets annoying pretty quickly. OTOH, consider how this makes it very easy to set breakpoints in classes wrapped in anonymous namespaces. You just don't think of them, GDB finds the symbols for you automatically. (At the Cauldron a couple months ago, several people told me that they run into a similar issue when debugging other C++ projects. One example was when debugging LLVM, which puts all its code under the "llvm" namespace.) Implementation-wise, what the patch does is: - makes C++ symbol name hashing only consider the last component of a symbol name. (so that we can look up symbol names by last-component name only). - adds a C++ symbol name matcher for symbol_name_match_type::WILD, which ignores missing leading specifiers / components. - adjusts a few preexisting testsuite tests to use "-qualified" when they mean it. - adds new testsuite tests. - adds unit tests. Grows the gdb.linespec/ tests like this: -# of expected passes 7823 +# of expected passes 8977 gdb/ChangeLog: 2017-11-29 Pedro Alves <palves@redhat.com> * NEWS: Mention that breakpoints on C++ functions are now set on on all namespaces/classes by default, and mention "break -qualified". * ax-gdb.c (agent_command_1): Adjust to pass a symbol_name_match_type to new_linespec_location. * breakpoint.c (parse_breakpoint_sals): Adjust to get_linespec_location's return type change. (strace_marker_create_sals_from_location): Adjust to pass a symbol_name_match_type to new_linespec_location. (strace_marker_decode_location): Adjust to get_linespec_location's return type change. (strace_command): Adjust to pass a symbol_name_match_type to new_linespec_location. (LOCATION_HELP_STRING): Add paragraph about wildmatching, and mention "-qualified". * c-lang.c (cplus_language_defn): Install cp_search_name_hash. * completer.c (explicit_location_match_type::MATCH_QUALIFIED): New enumerator. (complete_address_and_linespec_locations): New parameter 'match_type'. Pass it down. (explicit_options): Add "-qualified". (collect_explicit_location_matches): Pass the requested match type to the linespec completers. Handle MATCH_QUALIFIED. (location_completer): Handle "-qualified" combined with linespecs. * cp-support.c (cp_search_name_hash): New. (cp_symbol_name_matches_1): Implement wild matching for C++. (cp_fq_symbol_name_matches): Reimplement. (cp_get_symbol_name_matcher): Return different matchers depending on the lookup name's match type. (selftests::test_cp_symbol_name_matches): Add wild matching tests. * cp-support.h (cp_search_name_hash): New declaration. * dwarf2read.c (selftests::dw2_expand_symtabs_matching::test_symbols): Add symbols. (test_dw2_expand_symtabs_matching_symbol): Add wild matching tests. * guile/scm-breakpoint.c (gdbscm_register_breakpoint_x): Adjust to pass a symbol_name_match_type to new_linespec_location. * linespec.c (linespec_parse_basic): Lookup function symbols using the parser's symbol name match type. (convert_explicit_location_to_linespec): New symbol_name_match_type parameter. Pass it down to find_linespec_symbols. (convert_explicit_location_to_sals): Pass the location's name match type to convert_explicit_location_to_linespec. (parse_linespec): New match_type parameter. Save it in the parser. (linespec_parser_new): Default to symbol_name_match_type::WILD. (linespec_complete_function): New symbol_name_match_type parameter. Use it. (complete_linespec_component): Pass down the parser's recorded name match type. (linespec_complete_label): New symbol_name_match_type parameter. Use it. (linespec_complete): New symbol_name_match_type parameter. Save it in the parser and pass it down. Adjust to get_linespec_location's prototype change. (find_function_symbols, find_linespec_symbols): New symbol_name_match_type parameter. Pass it down instead of assuming symbol_name_match_type::WILD. * linespec.h (linespec_complete, linespec_complete_function) (linespec_complete_label): New symbol_name_match_type parameter. * location.c (event_location::linespec_location): Now a struct linespec_location. (EL_LINESPEC): Adjust. (initialize_explicit_location): Default to symbol_name_match_type::WILD. (new_linespec_location): New symbol_name_match_type parameter. Record it in the location. (get_linespec_location): Now returns a struct linespec_location. (new_explicit_location): Also copy func_name_match_type. (explicit_to_string_internal) (string_to_explicit_location): Handle "-qualified". (copy_event_location): Adjust to LINESPEC_LOCATION type change. Copy symbol_name_match_type fields. (event_location_deleter::operator()): Adjust to LINESPEC_LOCATION type change. (event_location_to_string): Adjust to LINESPEC_LOCATION type change. Handle "-qualfied". (string_to_explicit_location): Handle "-qualified". (string_to_event_location_basic): New symbol_name_match_type parameter. Pass it down. (string_to_event_location): Handle "-qualified". * location.h (struct linespec_location): New. (explicit_location::func_name_match_type): New field. (new_linespec_location): Now returns a const linespec_location *. (string_to_event_location_basic): New symbol_name_match_type parameter. (explicit_completion_info::saw_explicit_location_option): New field. * mi/mi-cmd-break.c (mi_cmd_break_insert_1): Adjust to pass a symbol_name_match_type to new_linespec_location. * python/py-breakpoint.c (bppy_init): Likewise. * python/python.c (gdbpy_decode_line): Likewise. gdb/testsuite/ChangeLog: 2017-11-29 Pedro Alves <palves@redhat.com> * gdb.base/langs.exp: Use -qualified. * gdb.cp/meth-typedefs.exp: Use -qualified, and add tests without it. * gdb.cp/namespace.exp: Use -qualified. * gdb.linespec/cpcompletion.exp (overload-2, fqn, fqn-2) (overload-3, template-overload, template-ret-type, const-overload) (const-overload-quoted, anon-ns, ambiguous-prefix): New procedures. (test_driver): Call them. * gdb.cp/save-bp-qualified.cc: New. * gdb.cp/save-bp-qualified.exp: New. * gdb.linespec/explicit.exp: Test -qualified. * lib/completion-support.exp (completion::explicit_opts_list): Add "-qualified". * lib/gdb.exp (gdb_breakpoint): Handle "qualified". gdb/doc/ChangeLog: 2017-11-29 Pedro Alves <palves@redhat.com> * gdb.texinfo (Linespec Locations): Document how "function" is interpreted in C++ and Ada. Document "-qualified". (Explicit Locations): Document how "-function" is interpreted in C++ and Ada. Document "-qualified".
2017-11-21Fix mapped_index::find_name_components_bounds upper bound computationPedro Alves
Here we want to find where we'd insert "after", so we want std::lower_bound, not std::upper_bound. gdb/ChangeLog: 2017-11-21 Pedro Alves <palves@redhat.com> * dwarf2read.c (mapped_index::find_name_components_bounds) <completion mode, upper bound>: Use std::lower_bound instead of std::upper_bound. (test_mapped_index_find_name_component_bounds): Remove incorrect "t1_fund" from expected symbols.
2017-11-21Unit test name-component bounds searching directlyPedro Alves
This commit factors out the name-components-vector building and bounds searching out of dw2_expand_symtabs_matching_symbol into separate functions, and adds unit tests that: - expose both the latent bug mentioned in the previous commit, and also, - for completeness exercise the 0xff character handling fixed in the previous commit more directly. The actual fix for the now-exposed bug is left for the following patch. gdb/ChangeLog: 2017-11-21 Pedro Alves <palves@redhat.com> * dwarf2read.c (mapped_index::name_components_casing): New field. (mapped_index) <build_name_components, find_name_components_bounds): Declare new methods. (mapped_index::find_name_components_bounds) (mapped_index::build_name_components): New methods, factored out from dw2_expand_symtabs_matching_symbol. (check_find_bounds_finds) (test_mapped_index_find_name_component_bounds): New. (run_test): Rename to ... (test_dw2_expand_symtabs_matching_symbol): ... this. (run_test): Reimplement.
2017-11-210xff chars in name components table; cp-name-parser lex UTF-8 identifiersPedro Alves
The find-upper-bound-for-completion algorithm in the name components accelerator table in dwarf2read.c increments a char in a string, and asserts that it's not incrementing a 0xff char, but that's incorrect. First, we shouldn't be calling gdb_assert on input. Then, if "char" is signed, comparing a caracther with "0xff" will never yield true, which is caught by Clang with: error: comparison of constant 255 with expression of type '....' (aka 'char') is always true [-Werror,-Wtautological-constant-out-of-range-compare] gdb_assert (after.back () != 0xff); ~~~~~~~~~~~~~ ^ ~~~~ And then, 0xff is a valid character on non-UTF-8/ASCII character sets. E.g., it's 'ΓΏ' in Latin1. While GCC nor Clang support !ASCII && !UTF-8 characters in identifiers (GCC supports UTF-8 characters only via UCNs, see https://gcc.gnu.org/onlinedocs/cpp/Character-sets.html), but other compilers might (Visual Studio?), so it doesn't hurt to handle it correctly. Testing is covered by extending the dw2_expand_symtabs_matching unit tests with relevant cases. However, without further changes, the unit tests still fail... The problem is that cp-name-parser.y assumes that identifiers are ASCII (via ISALPHA/ISALNUM). This commit fixes that too, so that we can unit test the dwarf2read.c changes. (The regular C/C++ lexer in c-lang.y needs a similar treatment, but I'm leaving that for another patch.) While doing this, I noticed a thinko in the computation of the upper bound for completion in dw2_expand_symtabs_matching_symbol. We're using std::upper_bound but we should use std::lower_bound. I extended the unit test with a case that I thought would expose it, this one: + /* These are used to check that the increment-last-char in the + matching algorithm for completion doesn't match "t1_fund" when + completing "t1_func". */ + "t1_func", + "t1_func1", + "t1_fund", + "t1_fund1", The algorithm actually returns "t1_fund1" as lower bound, so "t1_fund" matches incorrectly. But turns out the problem is masked because later here: for (;lower != upper; ++lower) { const char *qualified = index.symbol_name_at (lower->idx); if (!lookup_name_matcher.matches (qualified) the lookup_name_matcher.matches check above filters out "t1_fund" because that doesn't start with "t1_func". I'll fix the latent bug in follow up patches, after factoring things out a bit in a way that allows unit testing the relevant code more directly. gdb/ChangeLog: 2017-11-21 Pedro Alves <palves@redhat.com> * cp-name-parser.y (cp_ident_is_alpha, cp_ident_is_alnum): New. (symbol_end): Use cp_ident_is_alnum. (yylex): Use cp_ident_is_alpha and cp_ident_is_alnum. * dwarf2read.c (make_sort_after_prefix_name): New function. (dw2_expand_symtabs_matching_symbol): Use it. (test_symbols): Add more symbols. (run_test): Add tests.
2017-11-17Use an enum to represent subclasses of symbolTom Tromey
This changes struct symbol to use an enum to encode the concrete subclass of a particular symbol. Note that "enum class" doesn't work properly with bitfields, so a plain enum is used. 2017-11-17 Tom Tromey <tom@tromey.com> * symtab.h (enum symbol_subclass_kind): New. (struct symbol) <is_cplus_template_function, is_rust_vtable>: Remove. <subclass>: New member. (SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION): Update. * rust-lang.c (rust_get_trait_object_pointer): Update. * dwarf2read.c (read_func_scope): Update. (read_variable): Update.
2017-11-17Make template_symbol derive from symbolTom Tromey
This changes template_symbol to derive from symbol, which seems a bit cleaner; and also more consistent with rust_vtable_symbol. 2017-11-17 Tom Tromey <tom@tromey.com> * dwarf2read.c (read_func_scope): Update. * symtab.h (struct template_symbol): Derive from symbol. <base>: Remove.
2017-11-17Handle dereferencing Rust trait objectsTom Tromey
In Rust, virtual tables work a bit differently than they do in C++. In C++, as you know, they are connected to a particular class hierarchy. Rust, instead, can generate a virtual table for potentially any type -- in fact, one such virtual table for each trait (a trait is similar to an abstract class or to a Java interface) that a type implements. Objects that are referenced via a trait can't currently be inspected by gdb. This patch implements the Rust equivalent of "set print object". gdb relies heavily on the C++ ABI to decode virtual tables; primarily to make "set print object" work; but also "info vtbl". However, Rust does not currently have a specified ABI, so this approach seems unwise to emulate. Instead, I've changed the Rust compiler to emit some DWARF that describes trait objects (previously their internal structure was opaque), vtables (currently just a size -- but I hope to expand this in the future), and the concrete type for which a vtable was emitted. The concrete type is expressed as a DW_AT_containing_type on the vtable's type. This is a small extension to DWARF. This patch adds a new entry to quick_symbol_functions to return the symtab that holds a data address. Previously there was no way in gdb to look up a full (only minimal) non-text symbol by address. The psymbol implementation of this method works by lazily filling in a map that is added to the objfile. This avoids slowing down psymbol reading for a feature that is likely to not be used too frequently. I did not update .gdb_index. My thinking here is that the DWARF 5 indices will obsolete .gdb_index soon-ish, meaning that adding a new feature to them is probably wasted work. If necessary I can update the DWARF 5 index code when it lands in gdb. Regression tested on x86-64 Fedora 25. 2017-11-17 Tom Tromey <tom@tromey.com> * symtab.h (struct symbol) <is_rust_vtable>: New member. (struct rust_vtable_symbol): New. (find_symbol_at_address): Declare. * symtab.c (find_symbol_at_address): New function. * symfile.h (struct quick_symbol_functions) <find_compunit_symtab_by_address>: New member. * symfile-debug.c (debug_qf_find_compunit_symtab_by_address): New function. (debug_sym_quick_functions): Link to debug_qf_find_compunit_symtab_by_address. * rust-lang.c (rust_get_trait_object_pointer): New function. (rust_evaluate_subexp) <case UNOP_IND>: New case. Call rust_get_trait_object_pointer. * psymtab.c (psym_relocate): Clear psymbol_map. (psym_fill_psymbol_map, psym_find_compunit_symtab_by_address): New functions. (psym_functions): Link to psym_find_compunit_symtab_by_address. * objfiles.h (struct objfile) <psymbol_map>: New member. * dwarf2read.c (dwarf2_gdb_index_functions): Update. (process_die) <DW_TAG_variable>: New case. Call read_variable. (rust_containing_type, read_variable): New functions. 2017-11-17 Tom Tromey <tom@tromey.com> * gdb.rust/traits.rs: New file. * gdb.rust/traits.exp: New file.
2017-11-08Remove symbolp vectorTom Tromey
This removes the symbolp typedef from dwarf2read.c and converts the associated VEC uses to std::vector. This fixes a latent possible memory leak if an exception were thrown, because there were no cleanups installed for these VECs. Regression tested on the buildbot. gdb/ChangeLog 2017-11-08 Tom Tromey <tom@tromey.com> * dwarf2read.c (symbolp): Remove typedef. (read_func_scope): Use std::vector. (process_structure_scope): Use std::vector.
2017-11-08lookup_name_info::make_ignore_paramsPedro Alves
A few places in the completion code look for a "(" to find a function's parameter list, in order to strip it, because psymtabs (and gdb index) don't include parameter info in the symbol names. See compare_symbol_name and default_collect_symbol_completion_matches_break_on. This is too naive. Consider: ns_overload2_test::([TAB] We'd want to complete that to: ns_overload2_test::(anonymous namespace)::struct_overload2_test Or: b (anonymous namespace)::[TAB] That currently completes to: b (anonymous namespace) Which is obviously broken. This patch makes that work. Also, the current compare_symbol_name hack means that while this works: "b function([TAB]" -> "b function()" This does not: "b function ([TAB]" This patch fixes that. Whitespace "ignoring" now Just Works, i.e., assuming a symbol named "function(int, long)", this: b function ( int , lon[TAB] completes to: b function ( int , long) To address all of this, this patch builds on top of the rest of the series, and pushes the responsibility of stripping parameters from a lookup name to the new lookup_name_info object, where we can apply per-language rules. Also note that we now only make a version of the lookup name with parameters stripped out where it's actually required to do that, in the psymtab and GDB index code. For C++, the right way to strip parameters is with "cp_remove_params", which uses a real parser (cp-name-parser.y) to split the name into a component tree and then discards parameters. The trouble for completion is that in that case we have an incomplete name, like "foo::func(int" and thus cp_remove_params throws an error. This patch sorts that by adding a cp_remove_params_if_any variant of cp_remove_params that tries removing characters from the end of the string until cp_remove_params works. So cp_remove_params_if_any behaves like this: With a complete name: "foo::func(int)" => foo::func(int) # cp_remove_params_1 succeeds the first time. With an incomplete name: "foo::func(int" => NULL # cp_remove_params fails the first time. "foo::func(in" => NULL # and again... "foo::func(i" => NULL # and again... "foo::func(" => NULL # and again... "foo::func" => "foo::func" # success! Note that even if this approach removes significant rightmost characters, it's still OK, because this parameter stripping is only necessary for psymtabs and gdb index, where we're determining whether to expand a symbol table. Say cp_remove_params_if_any returned "foo::" above for "foo::func(int". That'd cause us to expand more symtabs than ideal (because we'd expand all symtabs with symbols that start with "foo::", not just "foo::func"), but then when we actually look for completion matches, we'd still use the original lookup name, with parameter information ["foo::func(int"], and thus we'll return no false positive to the user. Whether the stripping works as intended and doesn't strip too much is thus covered by a unit test instead of a testsuite test. The "if_any" part of the name refers to the fact that while cp_remove_params returns NULL if the input name has no parameters in the first place, like: "foo::func" => NULL # cp_remove_params cp_remove_params_if_any still returns the function name: "foo::func" => "foo::func" # cp_remove_params_if_any gdb/ChangeLog: 2017-11-08 Pedro Alves <palves@redhat.com> * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add unittests/lookup_name_info-selftests.c. (SUBDIR_UNITTESTS_OBS): Add lookup_name_info-selftests.o. * cp-support.c: Include "selftest.h". (cp_remove_params_1): Rename from cp_remove_params. Add 'require_param' parameter, and handle it. (cp_remove_params): Reimplement. (cp_remove_params_if_any): New. (selftests::quote): New. (selftests::check_remove_params): New. (selftests::test_cp_remove_params): New. (_initialize_cp_support): Install selftests::test_cp_remove_params. * cp-support.h (cp_remove_params_if_any): Declare. * dwarf2read.c :Include "selftest.h". (dw2_expand_symtabs_matching_symbol): Use lookup_name_info::make_ignore_params. (selftests::dw2_expand_symtabs_matching::mock_mapped_index) (selftests::dw2_expand_symtabs_matching::string_or_null) (selftests::dw2_expand_symtabs_matching::check_match) (selftests::dw2_expand_symtabs_matching::test_symbols) (selftests::dw2_expand_symtabs_matching::run_test): New. (_initialize_dwarf2_read): Register selftests::dw2_expand_symtabs_matching::run_test. * psymtab.c (psym_expand_symtabs_matching): Use lookup_name_info::make_ignore_params. * symtab.c (demangle_for_lookup_info::demangle_for_lookup_info): If the lookup name wants to ignore parameters, strip them. (compare_symbol_name): Remove sym_text/sym_text_len parameters and code handling '('. (completion_list_add_name): Don't pass down sym_text/sym_text_len. (default_collect_symbol_completion_matches_break_on): Don't try to strip parameters. * symtab.h (lookup_name_info::lookup_name_info): Add 'ignore_parameters' parameter. (lookup_name_info::ignore_parameters) (lookup_name_info::make_ignore_params): New methods. (lookup_name_info::m_ignore_parameters): New field. * unittests/lookup_name_info-selftests.c: New file.
2017-11-08Reorder/reindent dw2_expand_symtabs_matching & friendsPedro Alves
The previous patch had added dw2_expand_symtabs_matching_symbol and dw2_expand_marked_cus forward declarations and did not reindent dw2_expand_marked_cus to avoid moving the code around while changing it at the same time. gdb/ChangeLog: 2017-11-08 Pedro Alves <palves@redhat.com> * dwarf2read.c (dw2_expand_marked_cus) (dw2_expand_symtabs_matching_symbol): Remove forward declarations. (dw2_expand_symtabs_matching): Move further below. (dw2_expand_marked_cus): Reindent.
2017-11-08Optimize .gdb_index symbol name searchingPedro Alves
As mentioned in the previous patch, .gdb_index name lookup got significantly slower with the previous patch. This patch addresses that, and in the process makes .gdb_index name searching faster than what we had before the previous patch, even. Using the same test: $ cat script.cmd set pagination off set $count = 0 while $count < 400 complete b string_prin printf "count = %d\n", $count set $count = $count + 1 end $ time gdb --batch -q ./gdb-with-index -ex "source script.cmd" I got, before the previous patch (-O2, x86-64): real 0m1.773s user 0m1.737s sys 0m0.040s and after this patch: real 0m1.361s user 0m1.315s sys 0m0.040s The basic idea here is simple: instead of always iterating over all the symbol names in the index, we build an accelerator/sorted name table and binary search names in it. Later in the series, we'll want to support wild matching for C++ too, so this mechanism already considers that. For example, say that you're looking up functions/methods named "func", no matter the containing namespace/class. If we sorted the table by qualified name, then we obviously wouldn't be able to find those symbols with a binary search: func ns1::a::b::func ns1::b::func ns2::func (function symbol names in .gdb_index have no parameter info, like psymbols) To address that out, we put an entry for each name component in the sorted table. something like this: Table Entry Actual symbol --------------------------------- func func func ns1::a::b::func b::func ns1::a::b::func a::b::func ns1::a::b::func ns1::a::b::func ns1::a::b::func func ns1::b::func b::func ns1::b::func ns1::b::func ns1::b::func func ns2::func ns2::func ns2::func Which sorted results in this: Table Entry Actual symbol --------------------------------- a::b::func ns1::a::b::func b::func ns1::a::b::func b::func ns1::b::func func func func ns1::a::b::func func ns1::b::func func ns2::func ns1::a::b::func ns1::a::b::func ns1::b::func ns1::b::func ns2::func ns2::func And we can binary search this. Note that a binary search approach works for both completion and regular lookup, while a name hashing approach only works for normal symbol looking, since obviously "fun" and "func" have different hashes. At first I was a bit wary of these tables potentially growing GDB's memory significantly. But I did an experiment that convinced it's not a worry at all. I hacked gdb to count the total number of entries in all the tables, attached that gdb to my system/Fedora's Firefox (Fedora's debug packages uses .gdb_index), did "set max-completions unlimited", and then hit "b [TAB]" to cause everything to expand. That resulted in 1351355 name_components. Each entry takes 8 bytes, so that's 10810840 bytes (ignoring std::vector overhead), or ~10.3 MB. That's IMO too small to worry about, given GDB was using over 7400MB total at that point. I.e., we're talking about 0.1% increase. dw2_expand_symtabs_matching unit tests covering this will be added in a follow up patch. If the size of this table turns out to be a concern, I have an idea to reduce the size of the table further at the expense of a bit more code -- the vast majority of the name offsets are either 0 or fit in 8-bits: total name_component = 1351355, of which, name_component::name_offset instances need 0 bits = 679531 name_component::name_offset instances need 8 bits = 669526 name_component::name_offset instances need 16 bits = 2298 name_component::name_offset instances need 32 bits = 0 name_component::idx instances need 0 bits = 51 name_component::idx instances need 8 bits = 8361 name_component::idx instances need 16 bits = 280329 name_component::idx instances need 32 bits = 1062614 so we could have separate tables for 0 name_offset, 8-bit name_offset and 32-bit name_offset. That'd give us roughly: 679531 * 0 + 669526 * 1 + 2298 * 4 + 1062614 * 4 = 4929174, or ~4.7MB with only 8-bit and 32-bit tables, that'd be: 1349057 * 1 + 2298 * 4 + 4 * 1351355 = 6763669 bytes, or ~6.5MB. I don't think we need to bother though. I also timed: $ time gdb --batch -q -p `pidof firefox` $ time gdb --batch -q -p `pidof firefox` -ex "b main" $ time gdb --batch -q -p `pidof firefox` -ex "set max-completion unlimited" -ex "complete b " and compared before previous patch vs this patch, and I didn't see a significant difference, seemingly because time to read debug info dominates. The "complete b " variant of the test takes ~2min currently... (I have a follow up series that speeds that up somewhat.) gdb/ChangeLog: 2017-11-08 Pedro Alves <palves@redhat.com> * dwarf2read.c (byte_swap, MAYBE_SWAP): Move higher up in file. (struct name_component): New. (mapped_index::name_components): New field. (mapped_index::symbol_name_at): New method. (dwarf2_read_index): Call mapped_index ctor. (dw2_map_matching_symbols): Add comment about name_components table. (dw2_expand_symtabs_matching): Factor part to... (dw2_expand_symtabs_matching_symbol): ... this new function. Build name components table, and lookup symbols in it before calling the name matcher. (dw2_expand_marked_cus): New, factored out from dw2_expand_symtabs_matching. (dwarf2_per_objfile_free): Call the mapped_index's dtor.
2017-11-08Introduce lookup_name_info and generalize Ada's FULL/WILD name matchingPedro Alves
Summary: - This is preparation for supporting wild name matching on C++ too. - This is also preparation for TAB-completion fixes. - Makes symbol name matching (think strcmp_iw) be based on a per-language method. - Merges completion and non-completion name comparison (think language_ops::la_get_symbol_name_cmp generalized). - Avoid re-hashing lookup name multiple times - Centralizes preparing a name for lookup (Ada name encoding / C++ Demangling), both completion and non-completion. - Fixes Ada latent bug with verbatim name matches in expressions - Makes ada-lang.c use common|symtab.c completion code a bit more. Ada's wild matching basically means that "(gdb) break foo" will find all methods named "foo" in all packages. Translating to C++, it's roughly the same as saying that "break klass::method" sets breakpoints on all "klass::method" methods of all classes, no matter the namespace. A following patch will teach GDB about fullname vs wild matching for C++ too. This patch is preparatory work to get there. Another idea here is to do symbol name matching based on the symbol language's algorithm. I.e., avoid dependency on current language set. This allows for example doing (gdb) b foo::bar< int > (<tab> and having gdb name match the C++ symbols correctly even if the current language is C or Assembly (or Rust, or Ada, or ...), which can easily happen if you step into an Assembly/C runtime library frame. By encapsulating all the information related to a lookup name in a class, we can also cache hash computation for a given language in the lookup name object, to avoid recomputing it over and over. Similarly, because we don't really know upfront which languages the lookup name will be matched against, for each language we store the lookup name transformed into a search name. E.g., for C++, that means demangling the name. But for Ada, it means encoding the name. This actually forces us to centralize all the different lookup name encoding in a central place, resulting in clearer code, IMO. See e.g., the new ada_lookup_name_info class. The lookup name -> symbol search name computation is also done only once per language. The old language->la_get_symbol_name_cmp / symbol_name_cmp_ftype are generalized to work with both completion, and normal symbol look up. At some point early on, I had separate completion vs non-completion language vector entry points, but a single method ends up being better IMO for simplifying things -- the more we merge the completion / non-completion name lookup code paths, the less changes for bugs causing completion vs normal lookup finding different symbols. The ada-lex.l change is necessary because when doing (gdb) p <UpperCase> then the name that is passed to write_ write_var_or_type -> ada_lookup_symbol_list misses the "<>", i.e., it's just "UpperCase", and we end up doing a wild match against "UpperCase" lowercased by ada_lookup_name_info's constructor. I.e., "uppercase" wouldn't ever match "UpperCase", and the symbol lookup fails. This wouldn't cause any regression in the testsuite, but I added a new test that would pass before the patch and fail after, if it weren't for that fix. This is latent bug that happens to go unnoticed because that particular path was inconsistent with the rest of Ada symbol lookup by not lowercasing the lookup name. Ada's symbol_completion_add is deleted, replaced by using common code's completion_list_add_name. To make the latter work for Ada, we needed to add a new output parameter, because Ada wants to return back a custom completion candidates that are not the symbol name. With this patch, minimal symbol demangled name hashing is made consistent with regular symbol hashing. I.e., it now goes via the language vector's search_name_hash method too, as I had suggested in a previous patch. dw2_expand_symtabs_matching / .gdb_index symbol names were a challenge. The problem is that we have no way to telling what is the language of each symbol name found in the index, until we expand the corresponding full symbol, which is off course what we're trying to avoid. Language information is simply not considered in the index format... Since the symbol name hashing and comparison routines are per-language, we now have a problem. The patch sorts this out by matching each name against all languages. This is inneficient, and indeed slows down completion several times. E.g., with: $ cat script.cmd set pagination off set $count = 0 while $count < 400 complete b string_prin printf "count = %d\n", $count set $count = $count + 1 end $ time gdb --batch -q ./gdb-with-index -ex "source script-string_printf.cmd" I get, before patch (-O2, x86-64): real 0m1.773s user 0m1.737s sys 0m0.040s While after patch (-O2, x86-64): real 0m9.843s user 0m9.482s sys 0m0.034s However, the following patch will optimize this, and will actually make this use case faster compared to the "before patch" above: real 0m1.321s user 0m1.285s sys 0m0.039s gdb/ChangeLog: 2017-11-08 Pedro Alves <palves@redhat.com> * ada-lang.c (ada_encode): Rename to .. (ada_encode_1): ... this. Add throw_errors parameter and handle it. (ada_encode): Reimplement. (match_name): Delete, folded into full_name. (resolve_subexp): No longer pass the encoded name to ada_lookup_symbol_list. (should_use_wild_match): Delete. (name_match_type_from_name): New. (ada_lookup_simple_minsym): Use lookup_name_info and the language's symbol_name_matcher_ftype. (add_symbols_from_enclosing_procs, ada_add_local_symbols) (ada_add_block_renamings): Adjust to use lookup_name_info. (ada_lookup_name): New. (add_nonlocal_symbols, ada_add_all_symbols) (ada_lookup_symbol_list_worker, ada_lookup_symbol_list) (ada_iterate_over_symbols): Adjust to use lookup_name_info. (ada_name_for_lookup): Delete. (ada_lookup_encoded_symbol): Construct a verbatim name. (wild_match): Reverse sense of return type. Use bool. (full_match): Reverse sense of return type. Inline bits of old match_name here. (ada_add_block_symbols): Adjust to use lookup_name_info. (symbol_completion_match): Delete, folded into... (ada_lookup_name_info::matches): ... .this new method. (symbol_completion_add): Delete. (ada_collect_symbol_completion_matches): Add name_match_type parameter. Adjust to use lookup_name_info and completion_list_add_name. (get_var_value, ada_add_global_exceptions): Adjust to use lookup_name_info. (ada_get_symbol_name_cmp): Delete. (do_wild_match, do_full_match): New functions. (ada_lookup_name_info::ada_lookup_name_info): New method. (ada_symbol_name_matches, ada_get_symbol_name_matcher): New functions. (ada_language_defn): Install ada_get_symbol_name_matcher. * ada-lex.l (processId): If name starts with '<', copy it verbatim. * block.c (block_iter_match_step, block_iter_match_first) (block_iter_match_next, block_lookup_symbol) (block_lookup_symbol_primary, block_find_symbol): Adjust to use lookup_name_info. * block.h (block_iter_match_first, block_iter_match_next) (ALL_BLOCK_SYMBOLS_WITH_NAME): Adjust to use lookup_name_info. * c-lang.c (c_language_defn, cplus_language_defn) (asm_language_defn, minimal_language_defn): Adjust comments to refer to la_get_symbol_name_matcher. * completer.c (complete_files_symbols) (collect_explicit_location_matches, symbol_completer): Pass a symbol_name_match_type down. * completer.h (class completion_match, completion_match_result): New classes. (completion_tracker::reset_completion_match_result): New method. (completion_tracker::m_completion_match_result): New field. * cp-support.c (make_symbol_overload_list_block): Adjust to use lookup_name_info. (cp_fq_symbol_name_matches, cp_get_symbol_name_matcher): New functions. * cp-support.h (cp_get_symbol_name_matcher): New declaration. * d-lang.c: Adjust comments to refer to la_get_symbol_name_matcher. * dictionary.c (dict_vector) <iter_match_first, iter_match_next>: Adjust to use lookup_name_info. (dict_iter_match_first, dict_iter_match_next) (iter_match_first_hashed, iter_match_next_hashed) (iter_match_first_linear, iter_match_next_linear): Adjust to work with a lookup_name_info. * dictionary.h (dict_iter_match_first, dict_iter_match_next): Likewise. * dwarf2read.c (dw2_lookup_symbol): Adjust to use lookup_name_info. (dw2_map_matching_symbols): Adjust to use symbol_name_match_type. (gdb_index_symbol_name_matcher): New class. (dw2_expand_symtabs_matching) Adjust to use lookup_name_info and gdb_index_symbol_name_matcher. Accept a NULL symbol_matcher. * f-lang.c (f_collect_symbol_completion_matches): Adjust to work with a symbol_name_match_type. (f_language_defn): Adjust comments to refer to la_get_symbol_name_matcher. * go-lang.c (go_language_defn): Adjust comments to refer to la_get_symbol_name_matcher. * language.c (default_symbol_name_matcher) (language_get_symbol_name_matcher): New functions. (unknown_language_defn, auto_language_defn): Adjust comments to refer to la_get_symbol_name_matcher. * language.h (symbol_name_cmp_ftype): Delete. (language_defn) <la_collect_symbol_completion_matches>: Add match type parameter. <la_get_symbol_name_cmp>: Delete field. <la_get_symbol_name_matcher>: New field. <la_iterate_over_symbols>: Adjust to use lookup_name_info. (default_symbol_name_matcher, language_get_symbol_name_matcher): Declare. * linespec.c (iterate_over_all_matching_symtabs) (iterate_over_file_blocks): Adjust to use lookup_name_info. (find_methods): Add language parameter, and use lookup_name_info and the language's symbol_name_matcher_ftype. (linespec_complete_function): Adjust. (lookup_prefix_sym): Use lookup_name_info. (add_all_symbol_names_from_pspace): Adjust. (find_superclass_methods): Add language parameter and pass it down. (find_method): Pass symbol language down. (find_linespec_symbols): Don't demangle or Ada encode here. (search_minsyms_for_name): Add lookup_name_info parameter. (add_matching_symbols_to_info): Add name_match_type parameter. Use lookup_name_info. * m2-lang.c (m2_language_defn): Adjust comments to refer to la_get_symbol_name_matcher. * minsyms.c: Include <algorithm>. (add_minsym_to_demangled_hash_table): Remove table parameter and add objfile parameter. Use search_name_hash, and add language to demangled languages vector. (struct found_minimal_symbols): New struct. (lookup_minimal_symbol_mangled, lookup_minimal_symbol_demangled): New functions. (lookup_minimal_symbol): Adjust to use them. Don't canonicalize input names here. Use lookup_name_info instead. Lookup up demangled names once for each language in the demangled names vector. (iterate_over_minimal_symbols): Use lookup_name_info. Lookup up demangled names once for each language in the demangled names vector. (build_minimal_symbol_hash_tables): Adjust. * minsyms.h (iterate_over_minimal_symbols): Adjust to pass down a lookup_name_info. * objc-lang.c (objc_language_defn): Adjust comment to refer to la_get_symbol_name_matcher. * objfiles.h: Include <vector>. (objfile_per_bfd_storage) <demangled_hash_languages>: New field. * opencl-lang.c (opencl_language_defn): Adjust comment to refer to la_get_symbol_name_matcher. * p-lang.c (pascal_language_defn): Adjust comment to refer to la_get_symbol_name_matcher. * psymtab.c (psym_lookup_symbol): Use lookup_name_info. (match_partial_symbol): Use symbol_name_match_type, lookup_name_info and psymbol_name_matches. (lookup_partial_symbol): Use lookup_name_info. (map_block): Use symbol_name_match_type and lookup_name_info. (psym_map_matching_symbols): Use symbol_name_match_type. (psymbol_name_matches): New. (recursively_search_psymtabs): Use lookup_name_info and psymbol_name_matches. Rename 'kind' parameter to 'domain'. (psym_expand_symtabs_matching): Use lookup_name_info. Rename 'kind' parameter to 'domain'. * rust-lang.c (rust_language_defn): Adjust comment to refer to la_get_symbol_name_matcher. * symfile-debug.c (debug_qf_map_matching_symbols) (debug_qf_map_matching_symbols): Use symbol_name_match_type. (debug_qf_expand_symtabs_matching): Use lookup_name_info. * symfile.c (expand_symtabs_matching): Use lookup_name_info. * symfile.h (quick_symbol_functions) <map_matching_symbols>: Adjust to use symbol_name_match_type. <expand_symtabs_matching>: Adjust to use lookup_name_info. (expand_symtabs_matching): Adjust to use lookup_name_info. * symmisc.c (maintenance_expand_symtabs): Use lookup_name_info::match_any (). * symtab.c (symbol_matches_search_name): New. (eq_symbol_entry): Adjust to use lookup_name_info and the language's matcher. (demangle_for_lookup_info::demangle_for_lookup_info): New. (lookup_name_info::match_any): New. (iterate_over_symbols, search_symbols): Use lookup_name_info. (compare_symbol_name): Add language, lookup_name_info and completion_match_result parameters, and use them. (completion_list_add_name): Make extern. Add language and lookup_name_info parameters. Use them. (completion_list_add_symbol, completion_list_add_msymbol) (completion_list_objc_symbol): Add lookup_name_info parameters and adjust. Pass down language. (completion_list_add_fields): Add lookup_name_info parameters and adjust. Pass down language. (add_symtab_completions): Add lookup_name_info parameters and adjust. (default_collect_symbol_completion_matches_break_on): Add name_match_type parameter, and use it. Use lookup_name_info. (default_collect_symbol_completion_matches) (collect_symbol_completion_matches): Add name_match_type parameter, and pass it down. (collect_symbol_completion_matches_type): Adjust. (collect_file_symbol_completion_matches): Add name_match_type parameter, and use lookup_name_info. * symtab.h: Include <string> and "common/gdb_optional.h". (enum class symbol_name_match_type): New. (class ada_lookup_name_info): New. (struct demangle_for_lookup_info): New. (class lookup_name_info): New. (symbol_name_matcher_ftype): New. (SYMBOL_MATCHES_SEARCH_NAME): Use symbol_matches_search_name. (symbol_matches_search_name): Declare. (MSYMBOL_MATCHES_SEARCH_NAME): Delete. (default_collect_symbol_completion_matches) (collect_symbol_completion_matches) (collect_file_symbol_completion_matches): Add name_match_type parameter. (iterate_over_symbols): Use lookup_name_info. (completion_list_add_name): Declare. * utils.c (enum class strncmp_iw_mode): Moved to utils.h. (strncmp_iw_with_mode): Now extern. * utils.h (enum class strncmp_iw_mode): Moved from utils.c. (strncmp_iw_with_mode): Declare. gdb/testsuite/ChangeLog: 2017-11-08 Pedro Alves <palves@redhat.com> * gdb.ada/complete.exp (p <Exported_Capitalized>): New test. (p Exported_Capitalized): New test. (p exported_capitalized): New test.
2017-11-08Per-language symbol name hashing algorithmPedro Alves
Currently, we have a mess of symbol name hashing/comparison routines. There's msymbol_hash for mangled names, and dict_hash and msymbol_hash_iw for demangled names. Then there's strcmp_iw, strcmp_iw_ordered and Ada's full_match/wild_match, which all have to agree with the hashing routines. That's why dict_hash is really about Ada names. From the inconsistency department, minimal symbol hashing doesn't go via dict_hash, so Ada's wild matching can't ever work with minimal symbols. This patch starts fixing this, by doing two things: #1 - adds a language vector method to let each language decide how to compute a symbol name hash. #2 - makes dictionaries know the language of the symbols they hold, and then use the dictionaries language to decide which hashing method to use. For now, this is just scaffolding, since all languages install the default method. The series will make C++ install its own hashing method later on, and will add per-language symbol name comparison routines too. This patch was originally based on a patch that Keith wrote for the libcc1/C++ WIP support. gdb/ChangeLog: 2017-11-08 Keith Seitz <keiths@redhat.com> Pedro Alves <palves@redhat.com> * ada-lang.c (ada_language_defn): Install default_search_name_hash. * buildsym.c (struct buildsym_compunit): <language>: New field. (finish_block_internal): Pass language when creating dictionaries. (start_buildsym_compunit, start_symtab): New language parameters. Use them. (restart_symtab): Pass down compilation unit's language. * buildsym.h (enum language): Forward declare. (start_symtab): New 'language' parameter. * c-lang.c (c_language_defn, cplus_language_defn) (asm_language_defn, minimal_language_defn): Install default_search_name_hash. * coffread.c (coff_start_symtab): Adjust. * d-lang.c (d_language_defn): Install default_search_name_hash. * dbxread.c (struct symloc): Add 'pst_language' field. (PST_LANGUAGE): Define. (start_psymtab, read_ofile_symtab): Use it. (process_one_symbol): New 'language' parameter. Pass it down. * dictionary.c (struct dictionary) <language>: New field. (DICT_LANGUAGE): Define. (dict_create_hashed, dict_create_hashed_expandable) (dict_create_linear, dict_create_linear_expandable): New parameter 'language'. Set the dictionary's language. (iter_match_first_hashed): Adjust to rename. (insert_symbol_hashed): Assert we don't see mismatching languages. Adjust to rename. (dict_hash): Rename to ... (default_search_name_hash): ... this and make extern. * dictionary.h (struct language_defn): Forward declare. (dict_create_hashed): New parameter 'language'. * dwarf2read.c (dwarf2_start_symtab): Pass down language. * f-lang.c (f_language_defn): Install default_search_name_hash. * go-lang.c (go_language_defn): Install default_search_name_hash. * jit.c (finalize_symtab): Pass compunit's language to dictionary creation. * language.c (unknown_language_defn, auto_language_defn): * language.h (language_defn::la_search_name_hash): New field. (default_search_name_hash): Declare. * m2-lang.c (m2_language_defn): Install default_search_name_hash. * mdebugread.c (new_block): New parameter 'language'. * mdebugread.c (parse_symbol): Pass symbol language to block allocation. (psymtab_to_symtab_1): Pass down language. (new_symtab): Pass compunit's language to block allocation. * objc-lang.c (objc_language_defn): Install default_search_name_hash. * opencl-lang.c (opencl_language_defn): * p-lang.c (pascal_language_defn): Install default_search_name_hash. * rust-lang.c (rust_language_defn): Install default_search_name_hash. * stabsread.h (enum language): Forward declare. (process_one_symbol): Add 'language' parameter. * symtab.c (search_name_hash): New function. * symtab.h (search_name_hash): Declare. * xcoffread.c (read_xcoff_symtab): Pass language to start_symtab.
2017-11-04Replace really_free_pendings with a scoped_ classTom Tromey
This introduces scoped_free_pendings, and changes users of really_free_pendings to use it instead, removing some clenaups. I tried to examine the affected code to ensure there aren't dangling cleanups in the vicinity. gdb/ChangeLog 2017-11-04 Tom Tromey <tom@tromey.com> * dwarf2read.c (process_full_comp_unit, process_full_type_unit): Use scoped_free_pendings. * dbxread.c (dbx_symfile_read, dbx_psymtab_to_symtab_1): Use scoped_free_pendings. * xcoffread.c (xcoff_psymtab_to_symtab_1): Use scoped_free_pendings. (xcoff_initial_scan): Likewise. * buildsym.c (reset_symtab_globals): Update comment. (scoped_free_pendings): Rename from really_free_pendings. (prepare_for_building): Update comment. (buildsym_init): Likewise. * buildsym.h (class scoped_free_pendings): New class. (really_free_pendings): Don't declare.
2017-10-18Issue complaint instead of assert for invalid/unhandled DW_AT_accessibilityKeith Seitz
A previous patch called gdb_assert_not_reached whenever reading the accessibility of a nested typedef definition. Wisely, Pedro has asked me not do this. This patch changes the previous one so that it issues a complaint instead. gdb/ChangeLog: * dwarf2read.c (dwarf2_add_typedef): Issue a complaint on unhandled DW_AT_accessibility.
2017-10-16Record and output access specifiers for nested typedefsKeith Seitz
We currently do not record access information for typedefs defined inside classes. Consider: struct foo { typedef int PUBLIC; private: typedef int PRIVATE; PRIVATE b; }; (gdb) ptype foo type = struct foo { private: PRIVATE b; typedef int PRIVATE; typedef int PUBLIC; } This patch fixes this: (gdb) ptype foo type = struct foo { private: PRIVATE b; typedef int PRIVATE; public: typedef int PUBLIC; } gdb/ChangeLog: * c-typeprint.c (enum access_specifier): Moved here from c_type_print_base. (output_access_specifier): New function. (c_type_print_base): Consider typedefs when assessing whether access labels are needed. Use output_access_specifier as needed. Output access specifier for typedefs, if needed. * dwarf2read.c (dwarf2_add_typedef): Record DW_AT_accessibility. * gdbtypes.h (struct typedef_field) <is_protected, is_private>: New fields. (TYPE_TYPEDEF_FIELD_PROTECTED, TYPE_TYPEDEF_FIELD_PRIVATE): New accessor macros. gdb/testsuite/ChangeLog: * gdb.cp/classes.cc (class_with_typedefs, class_with_public_typedef) (class_with_protected_typedef, class_with_private_typedef) (struct_with_public_typedef, struct_with_protected_typedef) (struct_with_private_typedef): New classes/structs. * gdb.cp/classes.exp (test_ptype_class_objects): Add tests for typedefs and access specifiers.
2017-10-14Replace psymbol_allocation_list with std::vectorSimon Marchi
psymbol_allocation_list is basically a vector implementation. We can replace it with an std::vector, now that objfile has been C++-ified. I sent this to the buildbot, there are a few suspicious failures, but I don't think they are related to this patch. For example on powerpc: new FAIL: gdb.base/catch-syscall.exp: execve: syscall execve has returned new FAIL: gdb.base/catch-syscall.exp: execve: continue to main new FAIL: gdb.base/catch-syscall.exp: execve: continue until exit I get the same failures when testing manually on gcc112, without this patch. gdb/ChangeLog: * objfiles.h: Don't include symfile.h. (struct partial_symbol): Remove forward-declaration. (struct objfile) <global_psymbols, static_psymbols>: Change type to std::vector<partial_symbol *>. * objfiles.c (objfile::objfile): Don't memset those fields. (objfile::~objfile): Don't free those fields. * psympriv.h (struct psymbol_allocation_list): Remove forward-declaration. (add_psymbol_to_list): Change psymbol_allocation_list parameter to std::vector. (start_psymtab_common): Change parameters to std::vector. * psymtab.c: Include algorithm. (require_partial_symbols): Call shrink_to_fit. (find_pc_sect_psymbol): Adjust to vector change. (match_partial_symbol): Likewise. (lookup_partial_symbol): Likewise. (psym_relocate): Likewise. (dump_psymtab): Likewise. (recursively_search_psymtabs): Likewise. (compare_psymbols): Remove. (sort_pst_symbols): Adjust to vector change. (start_psymtab_common): Likewise. (end_psymtab_common): Likewise. (psymbol_bcache_full): De-constify return value. (add_psymbol_to_bcache): Likewise. (extend_psymbol_list): Remove. (append_psymbol_to_list): Adjust to vector change. (add_psymbol_to_list): Likewise. (init_psymbol_list): Likewise. (maintenance_info_psymtabs): Likewise. (maintenance_check_psymtabs): Likewise. * symfile.h (struct psymbol_allocation_list): Remove. * symfile.c (reread_symbols): Adjust to vector change. * dbxread.c (start_psymtab): Change type of parameters. (dbx_symfile_read): Adjust to vector change. (read_dbx_symtab): Likewise. (start_psymtab): Change type of parameters. * dwarf2read.c (dwarf2_build_psymtabs): Adjust to vector change. (create_partial_symtab): Likewise. (add_partial_symbol): Likewise. (write_one_signatured_type): Likewise. (recursively_write_psymbols): Likewise. * mdebugread.c (parse_partial_symbols): Likewise. * xcoffread.c (xcoff_start_psymtab): Change type of parameters. (scan_xcoff_symtab): Adjust to vector change. (xcoff_initial_scan): Likewise.
2017-10-11Constify add_prefix_cmdTom Tromey
This changes add_prefix_cmd to accept a const-taking function as an argument; then fixes up all the callers. In a couple of spots I had to add a non-const overload of a function, because the function is passed to two different command-adding "constructors". These overloads are temporary; once constification is complete they can be removed. This patch also fixes a typo I happened to notice while constifying. Note that this touches a couple of files (gnu-nat.c and go32-nat.c) that I can't build. So, while I made a best-effort there, I am not certain they will still compile. Tested by rebuilding. gdb/ChangeLog 2017-10-11 Tom Tromey <tom@tromey.com> * gdbthread.h (thread_command): Constify. * inferior.h (detach_command): Constify. * top.h (set_history, show_history): Constify. * arm-tdep.c (set_arm_command, show_arm_command): Constify. * serial.c (serial_set_cmd, serial_show_cmd): Constify. * bsd-kvm.c (bsd_kvm_cmd): Constify. * printcmd.c (set_command): Constify. (non_const_set_command): New function. * dcache.c (set_dcache_command, show_dcache_command): Constify. * breakpoint.c (enable_command, disable_command, delete_command) (catch_command, tcatch_command, set_breakpoint_cmd) (show_breakpoint_cmd): Constify. * macrocmd.c (macro_command): Constify. * infcmd.c (unset_command, kill_command, detach_command) (info_proc_cmd): Constify. * i386-tdep.c (set_mpx_cmd, show_mpx_cmd): Constify. * auto-load.c (show_auto_load_cmd, set_auto_load_cmd) (info_auto_load_cmd): Constify. * target-descriptions.c (set_tdesc_cmd, show_tdesc_cmd) (unset_tdesc_cmd): Constify. * ada-lang.c (set_ada_command, show_ada_command) (maint_set_ada_cmd, maint_show_ada_cmd): Constify. * guile/guile.c (set_guile_command, show_guile_command) (info_guile_command): Constify. * tui/tui-win.c (tui_command, set_tui_cmd, show_tui_cmd): Constify. * skip.c (skip_command): Constify. * compile/compile.c (_initialize_compile): Constify. * dwarf2read.c (set_dwarf_cmd, show_dwarf_cmd): Constify. * btrace.c (maint_btrace_cmd, maint_btrace_set_cmd) (maint_btrace_show_cmd, maint_btrace_pt_set_cmd) (maint_btrace_pt_show_cmd): Constify. * remote.c (set_remote_cmd, show_remote_cmd, remote_command): Constify. * python/python.c (user_show_python, user_set_python): Constify. * mips-tdep.c (set_mips_command, show_mips_command) (set_mipsfpu_command): Constify. * record-btrace.c (cmd_record_btrace_start) (cmd_set_record_btrace, cmd_show_record_btrace) (cmd_set_record_btrace_bts, cmd_show_record_btrace_bts) (cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): Constify. * rs6000-tdep.c (set_powerpc_command, show_powerpc_command): Constify. * symfile.c (overlay_command): Constify. * spu-tdep.c (set_spu_command, show_spu_command): Constify. * cli/cli-logging.c (set_logging_command, show_logging_command): Constify. * cli/cli-dump.c (dump_command, append_command) (srec_dump_command, ihex_dump_command, verilog_dump_command) (tekhex_dump_command, binary_dump_command) (binary_append_command): Constify. * cli/cli-decode.c (struct cmd_list_element): Change type of "fun". * cli/cli-cmds.c (info_command, show_command, set_debug) (show_debug): Constify. (show_command): Add non-const overload. * top.c (set_history, show_history): Constify. * sh-tdep.c (set_sh_command, show_sh_command): Constify. * command.h (add_prefix_cmd): Accept a cmd_const_cfunc_ftype. * target.c (target_command): Constify. * sparc64-tdep.c (info_adi_command): Constify. * record-full.c (cmd_record_full_start): Constify. (set_record_full_command): Constify. Fix typo. (show_record_full_command): Constify. * thread.c (thread_command, thread_apply_command): Constify. * memattr.c (dummy_cmd): Constify. * value.c (function_command): Constify. * frame.c (set_backtrace_cmd, show_backtrace_cmd): Constify. * probe.c (info_probes_command): Constify. * ser-tcp.c (set_tcp_cmd, show_tcp_cmd): Constify. * gnu-nat.c (set_task_cmd, show_task_cmd, set_thread_cmd) (show_thread_cmd, set_thread_default_cmd) (show_thread_default_cmd): Constify. (check_empty): Constify. * tracepoint.c (tfind_command): Constify. * cp-support.c (maint_cplus_command): Constify. * windows-tdep.c (info_w32_command): Constify. * record.c (cmd_record_start, set_record_command) (show_record_command, info_record_command, cmd_record_goto): Constify. * ravenscar-thread.c (set_ravenscar_command) (show_ravenscar_command): Constify. * utils.c (set_internal_problem_cmd, show_internal_problem_cmd): Constify. (add_internal_problem_command): Remove casts. * arc-tdep.c (maintenance_print_arc_command): Constify. * valprint.c (set_print, show_print, set_print_raw) (show_print_raw): Constify. * maint.c (maintenance_command, maintenance_info_command) (maintenance_print_command, maintenance_set_cmd) (maintenance_show_cmd, set_per_command_cmd) (show_per_command_cmd, maintenance_check_command): Constify. * language.c (set_check, show_check): Constify. * typeprint.c (show_print_type, set_print_type): Constify. * go32-nat.c (go32_info_dos_command): Constify.
2017-10-09Make cp_remove_params return a gdb::unique_xmalloc_ptrPedro Alves
Use the type system instead of callers needing to know how the returned string's memory is supposed to be managed. gdb/ChangeLog: 2017-10-09 Pedro Alves <palves@redhat.com> * cp-support.c (cp_remove_params): Return a gdb::unique_xmalloc_ptr. Use bool. (overload_list_add_symbol): Adjust to use gdb::unique_xmalloc_ptr. * cp-support.h (cp_remove_params): Now returns a gdb::unique_xmalloc_ptr. * dwarf2read.c (find_slot_in_mapped_hash): Now returns bool. Adjust to cp_remove_params returning a gdb::unique_xmalloc_ptr. * psymtab.c (psymtab_search_name): Adjust to cp_remove_params returning a gdb::unique_xmalloc_ptr. (lookup_partial_symbol): Adjust to use gdb::unique_xmalloc_ptr. * stack.c (find_frame_funname): Adjust to cp_remove_params returning a gdb::unique_xmalloc_ptr.
2017-10-08Remove some cleanups from dwarf2read.cTom Tromey
This removes a number of cleanups from dwarf2read.c in a straightforward way. Note that some places in dwarf2read create dangling cleanups. I don't believe any of the changes in this patch interact with those spots. Regression tested by the buildbot. gdb/ChangeLog 2017-10-08 Tom Tromey <tom@tromey.com> * dwarf2read.c (dwarf2_get_dwz_file): Use gdb::unique_xmalloc_ptr. (find_slot_in_mapped_hash): Likewise. (dwarf2_physname): Likewise. (create_dwo_unit_in_dwp_v1): Use std::string. (create_dwo_unit_in_dwp_v2): Likewise. (lookup_dwo_cutu): Likewise. (inherit_abstract_dies): Use std::vector. (read_array_type): Likewise. (dwarf_decode_macros): Remove unused declaration. (unsigned_int_compar): Remove. (dwarf2_build_psymtabs_hard): Use scoped_restore. (psymtabs_addrmap_cleanup): Remove.
2017-09-28(open_and_init_dwp_file): Protect against some segvsDoug Evans
This is a "tiny patch", no assignment required. 2017-09-28 Alexander Shaposhnikov <alexander.v.shaposhnikov@gmail.com> * dwarf2read.c (open_and_init_dwp_file): Protect against dwp_file having NULL cus or tus.
2017-09-27Make init_type/arch_type take a size in bitsUlrich Weigand
This changes the interfaces to init_type and arch_type to take the type length in bits as input (instead of as bytes). The routines assert that the length is a multiple of TARGET_CHAR_BIT. For consistency, arch_flags_type is changed likewise, so that now all type creation interfaces always use length in bits. All callers are updated in the straightforward manner. The assert actually found a bug in read_range_type, where the init_integer_type routine was called with a wrong argument (probably a bug introduced with the conversion to use init_integer_type). gdb/ChangeLog 2017-09-27 Ulrich Weigand <uweigand@de.ibm.com> * gdbtypes.c (init_type): Change incoming argument from length-in-bytes to length-in-bits. Assert length is a multiple of TARGET_CHAR_BITS. (arch_type, arch_flags_type): Likewise. (init_integer_type): Update call to init_type. (init_character_type): Likewise. (init_boolean_type): Likewise. (init_float_type): Likewise. (init_decfloat_type): Likewise. (init_complex_type): Likewise. (init_pointer_type): Likewise. (objfile_type): Likewise. (arch_integer_type): Update call to arch_type. (arch_character_type): Likewise. (arch_boolean_type): Likewise. (arch_float_type): Likewise. (arch_decfloat_type): Likewise. (arch_complex_type): Likewise. (arch_pointer_type): Likewise. (gdbtypes_post_init): Likewise. * dwarf2read.c (dwarf2_init_float_type): Update call to init_type. (read_base_type): Likewise. * mdebugread.c (basic_type): Likewise. * stabsread.c (dbx_init_float_type): Likewise. (rs6000_builtin_type): Likewise. (read_range_type): Likewise. Also, fix call to init_integer_type with erroneous length argument. * ada-lang.c (ada_language_arch_info): Update call to arch_type. * d-lang.c (build_d_types): Likewise. * f-lang.c (build_fortran_types): Likewise. * go-lang.c (build_go_types): Likewise. * opencl-lang.c (build_opencl_types): Likewise. * jit.c (finalize_symtab): Likewise. * gnu-v3-abi.c (build_gdb_vtable_type): Likewise. (build_std_type_info_type): Likewise. * target-descriptions.c (tdesc_gdb_type): Likewise. Also, update call to arch_flags_type. * linux-tdep.c (linux_get_siginfo_type_with_fields): Update call to arch_type. * fbsd-tdep.c (fbsd_get_siginfo_type): Likewise. * windows-tdep.c (windows_get_tlb_type): Likewise. * avr-tdep.c (avr_gdbarch_init): Update call to arch_type. * ft32-tdep.c (ft32_gdbarch_init): Likewise. * m32c-tdep.c (make_types): Likewise. * rl78-tdep.c (rl78_gdbarch_init): Likewise. (rl78_psw_type): Update call to arch_flags_type. * m68k-tdep.c (m68k_ps_type): Update call to arch_flags_type. * rx-tdep.c (rx_psw_type): Likewise. (rx_fpsw_type): Likewise. * sparc-tdep.c (sparc_psr_type): Likewise. (sparc_fsr_type): Likewise. * sparc64-tdep.c (sparc64_pstate_type): Likewise. (sparc64_ccr_type): Likewise. (sparc64_fsr_type): Likewise. (sparc64_fprs_type): Likewise.
2017-09-27Constify save_gdb_index_commandTom Tromey
gdb/ChangeLog 2017-09-27 Tom Tromey <tom@tromey.com> * dwarf2read.c (save_gdb_index_command): Constify.
2017-09-26dwarf2read: Restrict ICC workaround to ICC<14Walfred Tedeschi
GDB has a workaround for DWARF output by ICC, related to missing DW_AT_declaration on incomplete types. The bug was fixed in ICC 14, so this commit adjusts GDB accordingly. For the version check, this adds a new parser function for the ICC producer string. While at it, it also adds unit tests for the producer parsing covering the new function and preexisting parsers. gdb/ChangeLog: 2017-09-26 Walfred Tedeschi <walfred.tedeschi@intel.com> Pedro Alves <palves@redhat.com> * dwarf2read.c (dwarf2_cu): Remove field producer_is_icc and add producer_is_icc_lt_14. (producer_is_icc_lt_14): New function. (check_producer): Add code for checking version of ICC. (producer_is_icc): Move to producer.c. (read_structure_type): Restrict ICC workaround to ICC<14. * producer.c: Include selftest.h. (producer_is_icc, producer_parsing_tests, _initialize_producer): New functions. * producer.h (producer_is_icc): New declaration.
2017-09-26Move GDB producer parsing routines to a separate fileWalfred Tedeschi
gdb/ChangeLog: 2017-09-26 Walfred Tedeschi <walfred.tedeschi@intel.com> * Makefile.in (SFILES): Add producer.c. (COMMON_OBS): Add producer.o * amd64-tdep.c (producer.h): Add new include. * dwarf2read.c (producer.h): Add new include. * producer.c: New file. * producer.h: New file. * utils.c (producer_is_gcc, producer_is_gcc_ge_4): Move to producer.c. * utils.h (producer_is_gcc, producer_is_gcc_ge_4): Move to producer.h.
2017-09-19Use DISABLE_COPY_AND_ASSIGNYao Qi
We have many classes that copy cotr and assignment operator are deleted, so this patch replaces these existing mechanical code with macro DISABLE_COPY_AND_ASSIGN. gdb: 2017-09-19 Yao Qi <yao.qi@linaro.org> * annotate.h (struct annotate_arg_emitter): Use DISABLE_COPY_AND_ASSIGN. * common/refcounted-object.h (refcounted_object): Likewise. * completer.h (struct completion_result): Likewise. * dwarf2read.c (struct dwarf2_per_objfile): Likewise. * filename-seen-cache.h (filename_seen_cache): Likewise. * gdbcore.h (thread_section_name): Likewise. * gdb_regex.h (compiled_regex): Likewise. * gdbthread.h (scoped_restore_current_thread): Likewise. * inferior.h (scoped_restore_current_inferior): Likewise. * jit.c (jit_reader): Likewise. * linespec.h (struct linespec_result): Likewise. * mi/mi-parse.h (struct mi_parse): Likewise. * nat/fork-inferior.c (execv_argv): Likewise. * progspace.h (scoped_restore_current_program_space): Likewise. * python/python-internal.h (class gdbpy_enter): Likewise. * regcache.h (regcache): Likewise. * target-descriptions.c (struct tdesc_reg): Likewise. (struct tdesc_type): Likewise. (struct tdesc_feature): Likewise. * ui-out.h (ui_out_emit_type): Likewise.
2017-09-15dwarf2read: Replace copy_string usages with savestringSimon Marchi
copy_string does the exact same thing as savestring, so replace the usages of the former with the latter. gdb/ChangeLog: * dwarf2read.c (copy_string): Remove. (parse_macro_definition): Replace copy_string with savestring.
2017-09-09Use std::vector in add_using_directiveTom Tromey
This changes add_using_directive to accept a std::vector and then changes the callers. This allows removing a cleanup. ChangeLog 2017-09-09 Tom Tromey <tom@tromey.com> * namespace.h (add_using_directive): Update. * namespace.c (add_using_directive): Change type of excludes to std::vector. * dwarf2read.c (read_import_statement): Use std::vector. (read_namespace): Update. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Update.
2017-09-09Remove unnecessary function prototypes.John Baldwin
These prototypes were required when compiling GDB as C but are not required for C++. gdb/ChangeLog: * aarch64-linux-nat.c: Remove _initialize_aarch64_linux_nat prototype. * aarch64-linux-tdep.c: Remove _initialize_aarch64_linux_tdep prototype. * aarch64-newlib-tdep.c: Remove _initialize_aarch64_newlib_tdep prototype. * aarch64-tdep.c: Remove _initialize_aarch64_tdep prototype. * ada-exp.y: Remove _initialize_ada_exp prototype. * ada-lang.c: Remove _initialize_ada_language prototype. * ada-tasks.c: Remove _initialize_tasks prototype. * addrmap.c: Remove _initialize_addrmap prototype. * agent.c: Remove _initialize_agent prototype. * aix-thread.c: Remove _initialize_aix_thread prototype. * alpha-bsd-nat.c: Remove _initialize_alphabsd_nat prototype. * alpha-linux-nat.c: Remove _initialize_alpha_linux_nat prototype. * alpha-linux-tdep.c: Remove _initialize_alpha_linux_tdep prototype. * alpha-nbsd-tdep.c: Remove _initialize_alphanbsd_tdep prototype. * alpha-obsd-tdep.c: Remove _initialize_alphaobsd_tdep prototype. * alpha-tdep.c: Remove _initialize_alpha_tdep prototype. * amd64-darwin-tdep.c: Remove _initialize_amd64_darwin_tdep prototype. * amd64-dicos-tdep.c: Remove _initialize_amd64_dicos_tdep prototype. * amd64-fbsd-nat.c: Remove _initialize_amd64fbsd_nat prototype. * amd64-fbsd-tdep.c: Remove _initialize_amd64fbsd_tdep prototype. * amd64-linux-nat.c: Remove _initialize_amd64_linux_nat prototype. * amd64-linux-tdep.c: Remove _initialize_amd64_linux_tdep prototype. * amd64-nbsd-nat.c: Remove _initialize_amd64nbsd_nat prototype. * amd64-nbsd-tdep.c: Remove _initialize_amd64nbsd_tdep prototype. * amd64-obsd-nat.c: Remove _initialize_amd64obsd_nat prototype. * amd64-obsd-tdep.c: Remove _initialize_amd64obsd_tdep prototype. * amd64-sol2-tdep.c: Remove _initialize_amd64_sol2_tdep prototype. * amd64-tdep.c: Remove _initialize_amd64_tdep prototype. * amd64-windows-nat.c: Remove _initialize_amd64_windows_nat prototype. * amd64-windows-tdep.c: Remove _initialize_amd64_windows_tdep prototype. * annotate.c: Remove _initialize_annotate prototype. * arc-newlib-tdep.c: Remove _initialize_arc_newlib_tdep prototype. * arc-tdep.c: Remove _initialize_arc_tdep prototype. * arch-utils.c: Remove _initialize_gdbarch_utils prototype. * arm-linux-nat.c: Remove _initialize_arm_linux_nat prototype. * arm-linux-tdep.c: Remove _initialize_arm_linux_tdep prototype. * arm-nbsd-tdep.c: Remove _initialize_arm_netbsd_tdep prototype. * arm-obsd-tdep.c: Remove _initialize_armobsd_tdep prototype. * arm-symbian-tdep.c: Remove _initialize_arm_symbian_tdep prototype. * arm-tdep.c: Remove _initialize_arm_tdep prototype. * arm-wince-tdep.c: Remove _initialize_arm_wince_tdep prototype. * auto-load.c: Remove _initialize_auto_load prototype. * auxv.c: Remove _initialize_auxv prototype. * avr-tdep.c: Remove _initialize_avr_tdep prototype. * ax-gdb.c: Remove _initialize_ax_gdb prototype. * bfin-linux-tdep.c: Remove _initialize_bfin_linux_tdep prototype. * bfin-tdep.c: Remove _initialize_bfin_tdep prototype. * break-catch-sig.c: Remove _initialize_break_catch_sig prototype. * break-catch-syscall.c: Remove _initialize_break_catch_syscall prototype. * break-catch-throw.c: Remove _initialize_break_catch_throw prototype. * breakpoint.c: Remove _initialize_breakpoint prototype. * bsd-uthread.c: Remove _initialize_bsd_uthread prototype. * btrace.c: Remove _initialize_btrace prototype. * charset.c: Remove _initialize_charset prototype. * cli/cli-cmds.c: Remove _initialize_cli_cmds prototype. * cli/cli-dump.c: Remove _initialize_cli_dump prototype. * cli/cli-interp.c: Remove _initialize_cli_interp prototype. * cli/cli-logging.c: Remove _initialize_cli_logging prototype. * cli/cli-script.c: Remove _initialize_cli_script prototype. * coff-pe-read.c: Remove _initialize_coff_pe_read prototype. * coffread.c: Remove _initialize_coffread prototype. * compile/compile.c: Remove _initialize_compile prototype. * complaints.c: Remove _initialize_complaints prototype. * completer.c: Remove _initialize_completer prototype. * copying.awk: Remove _initialize_copying prototype. * copying.c: Regenerate. * core-regset.c: Remove _initialize_core_regset prototype. * corefile.c: Remove _initialize_core prototype. * corelow.c: Remove _initialize_corelow prototype. * cp-abi.c: Remove _initialize_cp_abi prototype. * cp-namespace.c: Remove _initialize_cp_namespace prototype. * cp-support.c: Remove _initialize_cp_support prototype. * cp-valprint.c: Remove _initialize_cp_valprint prototype. * cris-linux-tdep.c: Remove _initialize_cris_linux_tdep prototype. * cris-tdep.c: Remove _initialize_cris_tdep prototype. * ctf.c: Remove _initialize_ctf prototype. * d-lang.c: Remove _initialize_d_language prototype. * darwin-nat-info.c: Remove _initialize_darwin_info_commands prototype. * darwin-nat.c: Remove _initialize_darwin_inferior prototype. * dbxread.c: Remove _initialize_dbxread prototype. * dcache.c: Remove _initialize_dcache prototype. * demangle.c: Remove _initialize_demangler prototype. * disasm-selftests.c: Remove _initialize_disasm_selftests prototype. * disasm.c: Remove _initialize_disasm prototype. * dtrace-probe.c: Remove _initialize_dtrace_probe prototype. * dummy-frame.c: Remove _initialize_dummy_frame prototype. * dwarf2-frame-tailcall.c: Remove _initialize_tailcall_frame prototype. * dwarf2-frame.c: Remove _initialize_dwarf2_frame prototype. * dwarf2expr.c: Remove _initialize_dwarf2expr prototype. * dwarf2loc.c: Remove _initialize_dwarf2loc prototype. * dwarf2read.c: Remove _initialize_dwarf2_read prototype. * elfread.c: Remove _initialize_elfread prototype. * exec.c: Remove _initialize_exec prototype. * extension.c: Remove _initialize_extension prototype. * f-lang.c: Remove _initialize_f_language prototype. * f-valprint.c: Remove _initialize_f_valprint prototype. * fbsd-nat.c: Remove _initialize_fbsd_nat prototype. * fbsd-tdep.c: Remove _initialize_fbsd_tdep prototype. * filesystem.c: Remove _initialize_filesystem prototype. * findcmd.c: Remove _initialize_mem_search prototype. * fork-child.c: Remove _initialize_fork_child prototype. * frame-base.c: Remove _initialize_frame_base prototype. * frame-unwind.c: Remove _initialize_frame_unwind prototype. * frame.c: Remove _initialize_frame prototype. * frv-linux-tdep.c: Remove _initialize_frv_linux_tdep prototype. * frv-tdep.c: Remove _initialize_frv_tdep prototype. * ft32-tdep.c: Remove _initialize_ft32_tdep prototype. * gcore.c: Remove _initialize_gcore prototype. * gdb_bfd.c: Remove _initialize_gdb_bfd prototype. * gdbarch.c: Regenerate. * gdbarch.sh: Remove _initialize_gdbarch prototype. * gdbtypes.c: Remove _initialize_gdbtypes prototype. * gnu-nat.c: Remove _initialize_gnu_nat prototype. * gnu-v2-abi.c: Remove _initialize_gnu_v2_abi prototype. * gnu-v3-abi.c: Remove _initialize_gnu_v3_abi prototype. * go-lang.c: Remove _initialize_go_language prototype. * go32-nat.c: Remove _initialize_go32_nat prototype. * guile/guile.c: Remove _initialize_guile prototype. * h8300-tdep.c: Remove _initialize_h8300_tdep prototype. * hppa-linux-nat.c: Remove _initialize_hppa_linux_nat prototype. * hppa-linux-tdep.c: Remove _initialize_hppa_linux_tdep prototype. * hppa-nbsd-nat.c: Remove _initialize_hppanbsd_nat prototype. * hppa-nbsd-tdep.c: Remove _initialize_hppanbsd_tdep prototype. * hppa-obsd-nat.c: Remove _initialize_hppaobsd_nat prototype. * hppa-obsd-tdep.c: Remove _initialize_hppaobsd_tdep prototype. * hppa-tdep.c: Remove _initialize_hppa_tdep prototype. * i386-bsd-nat.c: Remove _initialize_i386bsd_nat prototype. * i386-cygwin-tdep.c: Remove _initialize_i386_cygwin_tdep prototype. * i386-darwin-tdep.c: Remove _initialize_i386_darwin_tdep prototype. * i386-dicos-tdep.c: Remove _initialize_i386_dicos_tdep prototype. * i386-fbsd-nat.c: Remove _initialize_i386fbsd_nat prototype. * i386-fbsd-tdep.c: Remove _initialize_i386fbsd_tdep prototype. * i386-gnu-nat.c: Remove _initialize_i386gnu_nat prototype. * i386-gnu-tdep.c: Remove _initialize_i386gnu_tdep prototype. * i386-linux-nat.c: Remove _initialize_i386_linux_nat prototype. * i386-linux-tdep.c: Remove _initialize_i386_linux_tdep prototype. * i386-nbsd-nat.c: Remove _initialize_i386nbsd_nat prototype. * i386-nbsd-tdep.c: Remove _initialize_i386nbsd_tdep prototype. * i386-nto-tdep.c: Remove _initialize_i386nto_tdep prototype. * i386-obsd-nat.c: Remove _initialize_i386obsd_nat prototype. * i386-obsd-tdep.c: Remove _initialize_i386obsd_tdep prototype. * i386-sol2-nat.c: Remove _initialize_amd64_sol2_nat prototype. * i386-sol2-tdep.c: Remove _initialize_amd64_sol2_tdep prototype. * i386-tdep.c: Remove _initialize_i386_tdep prototype. * i386-windows-nat.c: Remove _initialize_i386_windows_nat prototype. * ia64-libunwind-tdep.c: Remove _initialize_libunwind_frame prototype. * ia64-linux-nat.c: Remove _initialize_ia64_linux_nat prototype. * ia64-linux-tdep.c: Remove _initialize_ia64_linux_tdep prototype. * ia64-tdep.c: Remove _initialize_ia64_tdep prototype. * ia64-vms-tdep.c: Remove _initialize_ia64_vms_tdep prototype. * infcall.c: Remove _initialize_infcall prototype. * infcmd.c: Remove _initialize_infcmd prototype. * inferior.c: Remove _initialize_inferiors prototype. * inflow.c: Remove _initialize_inflow prototype. * infrun.c: Remove _initialize_infrun prototype. * interps.c: Remove _initialize_interpreter prototype. * iq2000-tdep.c: Remove _initialize_iq2000_tdep prototype. * jit.c: Remove _initialize_jit prototype. * language.c: Remove _initialize_language prototype. * linux-fork.c: Remove _initialize_linux_fork prototype. * linux-nat.c: Remove _initialize_linux_nat prototype. * linux-tdep.c: Remove _initialize_linux_tdep prototype. * linux-thread-db.c: Remove _initialize_thread_db prototype. * lm32-tdep.c: Remove _initialize_lm32_tdep prototype. * m2-lang.c: Remove _initialize_m2_language prototype. * m32c-tdep.c: Remove _initialize_m32c_tdep prototype. * m32r-linux-nat.c: Remove _initialize_m32r_linux_nat prototype. * m32r-linux-tdep.c: Remove _initialize_m32r_linux_tdep prototype. * m32r-tdep.c: Remove _initialize_m32r_tdep prototype. * m68hc11-tdep.c: Remove _initialize_m68hc11_tdep prototype. * m68k-bsd-nat.c: Remove _initialize_m68kbsd_nat prototype. * m68k-bsd-tdep.c: Remove _initialize_m68kbsd_tdep prototype. * m68k-linux-nat.c: Remove _initialize_m68k_linux_tdep prototype. * m68k-linux-tdep.c: Remove _initialize_m68k_linux_tdep prototype. * m68k-tdep.c: Remove _initialize_m68k_tdep prototype. * m88k-bsd-nat.c: Remove _initialize_m68kbsd_nat prototype. * m88k-tdep.c: Remove _initialize_m68kbsd_tdep prototype. * machoread.c: Remove _initialize_machoread prototype. * macrocmd.c: Remove _initialize_macrocmd prototype. * macroscope.c: Remove _initialize_macroscope prototype. * maint.c: Remove _initialize_maint_cmds prototype. * mdebugread.c: Remove _initialize_mdebugread prototype. * memattr.c: Remove _initialize_mem prototype. * mep-tdep.c: Remove _initialize_mep_tdep prototype. * mi/mi-cmd-env.c: Remove _initialize_mi_cmd_env prototype. * mi/mi-cmds.c: Remove _initialize_mi_cmds prototype. * mi/mi-interp.c: Remove _initialize_mi_interp prototype. * mi/mi-main.c: Remove _initialize_mi_main prototype. * microblaze-linux-tdep.c: Remove _initialize_microblaze_linux_tdep prototype. * microblaze-tdep.c: Remove _initialize_microblaze_tdep prototype. * mips-fbsd-nat.c: Remove _initialize_mips_fbsd_nat prototype. * mips-fbsd-tdep.c: Remove _initialize_mips_fbsd_tdep prototype. * mips-linux-nat.c: Remove _initialize_mips_linux_nat prototype. * mips-linux-tdep.c: Remove _initialize_mips_linux_tdep prototype. * mips-nbsd-nat.c: Remove _initialize_mipsnbsd_nat prototype. * mips-nbsd-tdep.c: Remove _initialize_mipsnbsd_tdep prototype. * mips-sde-tdep.c: Remove _initialize_mips_sde_tdep prototype. * mips-tdep.c: Remove _initialize_mips_tdep prototype. * mips64-obsd-nat.c: Remove _initialize_mips64obsd_nat prototype. * mips64-obsd-tdep.c: Remove _initialize_mips64obsd_tdep prototype. * mipsread.c: Remove _initialize_mipsread prototype. * mn10300-linux-tdep.c: Remove _initialize_mn10300_linux_tdep prototype. * mn10300-tdep.c: Remove _initialize_mn10300_tdep prototype. * moxie-tdep.c: Remove _initialize_moxie_tdep prototype. * msp430-tdep.c: Remove _initialize_msp430_tdep prototype. * mt-tdep.c: Remove _initialize_mt_tdep prototype. * nds32-tdep.c: Remove _initialize_nds32_tdep prototype. * nios2-linux-tdep.c: Remove _initialize_nios2_linux_tdep prototype. * nios2-tdep.c: Remove _initialize_nios2_tdep prototype. * nto-procfs.c: Remove _initialize_procfs prototype. * nto-tdep.c: Remove _initialize_nto_tdep prototype. * objc-lang.c: Remove _initialize_objc_language prototype. * objfiles.c: Remove _initialize_objfiles prototype. * observer.c: Remove observer_test_first_notification_function, observer_test_second_notification_function, observer_test_third_notification_function, and _initialize_observer prototypes. * opencl-lang.c: Remove _initialize_opencl_language prototypes. * osabi.c: Remove _initialize_gdb_osabi prototype. * osdata.c: Remove _initialize_osdata prototype. * p-valprint.c: Remove _initialize_pascal_valprint prototype. * parse.c: Remove _initialize_parse prototype. * ppc-fbsd-nat.c: Remove _initialize_ppcfbsd_nat prototype. * ppc-fbsd-tdep.c: Remove _initialize_ppcfbsd_tdep prototype. * ppc-linux-nat.c: Remove _initialize_ppc_linux_nat prototype. * ppc-linux-tdep.c: Remove _initialize_ppc_linux_tdep prototype. * ppc-nbsd-nat.c: Remove _initialize_ppcnbsd_nat prototype. * ppc-nbsd-tdep.c: Remove _initialize_ppcnbsd_tdep prototype. * ppc-obsd-nat.c: Remove _initialize_ppcobsd_nat prototype. * ppc-obsd-tdep.c: Remove _initialize_ppcobsd_tdep prototype. * printcmd.c: Remove _initialize_printcmd prototype. * probe.c: Remove _initialize_probe prototype. * proc-api.c: Remove _initialize_proc_api prototype. * proc-events.c: Remove _initialize_proc_events prototype. * proc-service.c: Remove _initialize_proc_service prototype. * procfs.c: Remove _initialize_procfs prototype. * psymtab.c: Remove _initialize_psymtab prototype. * python/python.c: Remove _initialize_python prototype. * ravenscar-thread.c: Remove _initialize_ravenscar prototype. * record-btrace.c: Remove _initialize_record_btrace prototype. * record-full.c: Remove _initialize_record_full prototype. * record.c: Remove _initialize_record prototype. * regcache.c: Remove _initialize_regcache prototype. * reggroups.c: Remove _initialize_reggroup prototype. * remote-notif.c: Remove _initialize_notif prototype. * remote-sim.c: Remove _initialize_remote_sim prototype. * remote.c: Remove _initialize_remote prototype. * reverse.c: Remove _initialize_reverse prototype. * rl78-tdep.c: Remove _initialize_rl78_tdep prototype. * rs6000-aix-tdep.c: Remove _initialize_rs6000_aix_tdep prototype. * rs6000-lynx178-tdep.c: Remove _initialize_rs6000_lynx178_tdep prototype. * rs6000-nat.c: Remove _initialize_rs6000_nat prototype. * rs6000-tdep.c: Remove _initialize_rs6000_tdep prototype. * rust-exp.y: Remove _initialize_rust_exp prototype. * rx-tdep.c: Remove _initialize_rx_tdep prototype. * s390-linux-nat.c: Remove _initialize_s390_nat prototype. * s390-linux-tdep.c: Remove _initialize_s390_tdep prototype. * score-tdep.c: Remove _initialize_score_tdep prototype. * selftest-arch.c: Remove _initialize_selftests_foreach_arch prototype. * ser-go32.c: Remove _initialize_ser_dos prototype. * ser-mingw.c: Remove _initialize_ser_windows prototype. * ser-pipe.c: Remove _initialize_ser_pipe prototype. * ser-tcp.c: Remove _initialize_ser_tcp prototype. * ser-unix.c: Remove _initialize_ser_hardwire prototype. * serial.c: Remove _initialize_serial prototype. * sh-linux-tdep.c: Remove _initialize_sh_linux_tdep prototype. * sh-nbsd-nat.c: Remove _initialize_shnbsd_nat prototype. * sh-nbsd-tdep.c: Remove _initialize_shnbsd_tdep prototype. * sh-tdep.c: Remove _initialize_sh_tdep prototype. * skip.c: Remove _initialize_step_skip prototype. * sol-thread.c: Remove _initialize_sol_thread prototype. * solib-aix.c: Remove _initialize_solib_aix prototype. * solib-darwin.c: Remove _initialize_darwin_solib prototype. * solib-dsbt.c: Remove _initialize_dsbt_solib prototype. * solib-frv.c: Remove _initialize_frv_solib prototype. * solib-spu.c: Remove _initialize_spu_solib prototype. * solib-svr4.c: Remove _initialize_svr4_solib prototype. * solib-target.c: Remove _initialize_solib_target prototype. * solib.c: Remove _initialize_solib prototype. * source.c: Remove _initialize_source prototype. * sparc-linux-nat.c: Remove _initialize_sparc_linux_nat prototype. * sparc-linux-tdep.c: Remove _initialize_sparc_linux_tdep prototype. * sparc-nat.c: Remove _initialize_sparc_nat prototype. * sparc-nbsd-nat.c: Remove _initialize_sparcnbsd_nat prototype. * sparc-nbsd-tdep.c: Remove _initialize_sparcnbsd_tdep prototype. * sparc-obsd-tdep.c: Remove _initialize_sparc32obsd_tdep prototype. * sparc-sol2-nat.c: Remove _initialize_sparc_sol2_nat prototype. * sparc-sol2-tdep.c: Remove _initialize_sparc_sol2_tdep prototype. * sparc-tdep.c: Remove _initialize_sparc_tdep prototype. * sparc64-fbsd-nat.c: Remove _initialize_sparc64fbsd_nat prototype. * sparc64-fbsd-tdep.c: Remove _initialize_sparc64fbsd_tdep prototype. * sparc64-linux-nat.c: Remove _initialize_sparc64_linux_nat prototype. * sparc64-linux-tdep.c: Remove _initialize_sparc64_linux_tdep prototype. * sparc64-nat.c: Remove _initialize_sparc64_nat prototype. * sparc64-nbsd-nat.c: Remove _initialize_sparc64nbsd_nat prototype. * sparc64-nbsd-tdep.c: Remove _initialize_sparc64nbsd_tdep prototype. * sparc64-obsd-nat.c: Remove _initialize_sparc64obsd_nat prototype. * sparc64-obsd-tdep.c: Remove _initialize_sparc64obsd_tdep prototype. * sparc64-sol2-tdep.c: Remove _initialize_sparc64_sol2_tdep prototype. * spu-linux-nat.c: Remove _initialize_spu_nat prototype. * spu-multiarch.c: Remove _initialize_spu_multiarch prototype. * spu-tdep.c: Remove _initialize_spu_tdep prototype. * stabsread.c: Remove _initialize_stabsread prototype. * stack.c: Remove _initialize_stack prototype. * stap-probe.c: Remove _initialize_stap_probe prototype. * std-regs.c: Remove _initialize_frame_reg prototype. * symfile-debug.c: Remove _initialize_symfile_debug prototype. * symfile-mem.c: Remove _initialize_symfile_mem prototype. * symfile.c: Remove _initialize_symfile prototype. * symmisc.c: Remove _initialize_symmisc prototype. * symtab.c: Remove _initialize_symtab prototype. * target-dcache.c: Remove _initialize_target_dcache prototype. * target-descriptions.c: Remove _initialize_target_descriptions prototype. * thread.c: Remove _initialize_thread prototype. * tic6x-linux-tdep.c: Remove _initialize_tic6x_linux_tdep prototype. * tic6x-tdep.c: Remove _initialize_tic6x_tdep prototype. * tilegx-linux-nat.c: Remove _initialize_tile_linux_nat prototype. * tilegx-linux-tdep.c: Remove _initialize_tilegx_linux_tdep prototype. * tilegx-tdep.c: Remove _initialize_tilegx_tdep prototype. * tracefile-tfile.c: Remove _initialize_tracefile_tfile prototype. * tracefile.c: Remove _initialize_tracefile prototype. * tracepoint.c: Remove _initialize_tracepoint prototype. * tui/tui-hooks.c: Remove _initialize_tui_hooks prototype. * tui/tui-interp.c: Remove _initialize_tui_interp prototype. * tui/tui-layout.c: Remove _initialize_tui_layout prototype. * tui/tui-regs.c: Remove _initialize_tui_regs prototype. * tui/tui-stack.c: Remove _initialize_tui_stack prototype. * tui/tui-win.c: Remove _initialize_tui_win prototype. * tui/tui.c: Remove _initialize_tui prototype. * typeprint.c: Remove _initialize_typeprint prototype. * user-regs.c: Remove _initialize_user_regs prototype. * utils.c: Remove _initialize_utils prototype. * v850-tdep.c: Remove _initialize_v850_tdep prototype. * valarith.c: Remove _initialize_valarith prototype. * valops.c: Remove _initialize_valops prototype. * valprint.c: Remove _initialize_valprint prototype. * value.c: Remove _initialize_values prototype. * varobj.c: Remove _initialize_varobj prototype. * vax-bsd-nat.c: Remove _initialize_vaxbsd_nat prototype. * vax-nbsd-tdep.c: Remove _initialize_vaxnbsd_tdep prototype. * vax-tdep.c: Remove _initialize_vax_tdep prototype. * windows-nat.c: Remove _initialize_windows_nat, _initialize_check_for_gdb_ini, and _initialize_loadable prototypes. * windows-tdep.c: Remove _initialize_windows_tdep prototype. * xcoffread.c: Remove _initialize_xcoffread prototype. * xml-support.c: Remove _initialize_xml_support prototype. * xstormy16-tdep.c: Remove _initialize_xstormy16_tdep prototype. * xtensa-linux-nat.c: Remove _initialize_xtensa_linux_nat prototype. * xtensa-linux-tdep.c: Remove _initialize_xtensa_linux_tdep prototype. * xtensa-tdep.c: Remove _initialize_xtensa_tdep prototype.