aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2019-12-05Remove gdbarch parameter of lookup_typenameSimon Marchi13-69/+51
I noticed that the gdbarch parameter of lookup_typename was unused, so I removed it (as well as from lookup_signed_typename and lookup_unsigned_typename) and updated all callers. Tested by rebuilding. gdb/ChangeLog: * c-exp.y: Update calls to lookup_typename, lookup_signed_typename and lookup_unsigned_typename. * c-lang.c (evaluate_subexp_c): Likewise. * cp-namespace.c (cp_lookup_symbol_imports_or_template): Likewise. * eval.c (binop_promote): Likewise. * gdbtypes.c (lookup_typename): Remove gdbarch parameter. (lookup_unsigned_typename): Likewise. (lookup_signed_typename): Likewise. * gdbtypes.h (lookup_unsigned_typename): Likewise. (lookup_signed_typename): Likewise. (lookup_typename): Likewise. * guile/scm-type.c (tyscm_lookup_typename): Update calls to lookup_typename, lookup_signed_typename, lookup_unsigned_typename. * m2-exp.y: Likewise. * printcmd.c (printf_wide_c_string): Likewise. (ui_printf): Likewise. * python/py-type.c (typy_lookup_typename): Likewise. * python/py-xmethods.c (python_xmethod_worker::invoke): Likewise. * rust-exp.y: Likewise.
2019-12-05Fix a problem computing the size fields in the PE format header.Nick Clifton2-0/+9
PR 25029 * peXXigen.c (_bfd_XXi_swap_aouthdr_out): Ignore empty sections when computing the sizes stored in the headers.
2019-12-05Re: PR25244, --print-memory-usage, division by zero if MEMORY length is zeroAlan Modra2-1/+7
Do print the linefeed when length is zero. PR 25244 * ldlang.c (lang_print_memory_usage): Correct last patch.
2019-12-05Arm64: simplify Crypto arch extension handlingJan Beulich6-16/+20
This, at the assembler level, is just a "brace" feature covering both AES and SHA2. Hence there's no need for it to have a separate feature flag, freeing up a bit for future re-use. Along these lines there are also a number of dead definitions/variables in the opcode table file.
2019-12-05Arm64: correct "sha3" arch-extension directive handlingJan Beulich7-45/+49
SHA2 is a prereq to SHA3, not part of it aiui. Hence disabling the latter should not also disable the former. In the course of adding respective tests also do away with the duplication of crypto.d's contents in crypto-directive.d.
2019-12-05PR25243, static linking with exceptions and iostream is broken on ARMAlan Modra7-52/+42
PR 25243 * emulparams/armelf.sh (OTHER_READONLY_SECTIONS): Move definition of __exidx_start and __exidx_end into ARM.exidx. * emulparams/armelf_linux_eabi.sh (OTHER_READONLY_SECTIONS): Likewise. * emulparams/armsymbian.sh (OTHER_READONLY_SECTIONS): Similarly. * emulparams/elf32_tic6x_le.sh (OTHER_READONLY_SECTIONS): Similarly. * emulparams/armelf_fuchsia.sh: Source armelf_linux_eabi.sh, just redefining TEXT_START_ADDR. * emulparams/armelf_linux_fdpiceabi.sh: Source armelf_linux_eabi.sh, adding to OTHER_READONLY_SECTIONS.
2019-12-05PR25244, --print-memory-usage, division by zero if MEMORY length is zeroAlan Modra2-4/+11
PR 25244 * ldlang.c (lang_print_memory_usage): Don't print percent used when length is zero.
2019-12-05PR25249, Memory leak in microblaze-dis.cAlan Modra2-138/+182
PR 25249 * microblaze-dis.c (NUM_STRBUFS, STRBUF_SIZE): Define. (struct string_buf): New. (strbuf): New function. (get_field): Use strbuf rather than strdup of local temp. (get_field_imm, get_field_imm5, get_field_imm5_mbar): Likewise. (get_field_rfsl, get_field_imm15): Likewise. (get_field_rd, get_field_r1, get_field_r2): Update macros. (get_field_special): Likewise. Don't strcpy spr. Formatting. (print_insn_microblaze): Formatting. Init and pass string_buf to get_field functions.
2019-12-05Automatic date update in version.inGDB Administrator1-1/+1
2019-12-04Fix (most) OpenBSD link errorsChristian Biesinger2-2/+8
This fixes these errors: ld: error: undefined symbol: x86_stopped_by_hw_breakpoint() >>> referenced by x86-nat.h:109 (../../gdb/x86-nat.h:109) >>> amd64-obsd-nat.o:(x86_nat_target<obsd_nat_target>::stopped_by_hw_breakpoint()) ld: error: undefined symbol: x86_can_use_hw_breakpoint(bptype, int, int) >>> referenced by x86-nat.h:76 (../../gdb/x86-nat.h:76) >>> amd64-obsd-nat.o:(x86_nat_target<obsd_nat_target>::can_use_hw_breakpoint(bptype, int, int)) ld: error: undefined symbol: x86_insert_hw_breakpoint(gdbarch*, bp_target_info*) >>> referenced by x86-nat.h:93 (../../gdb/x86-nat.h:93) >>> amd64-obsd-nat.o:(x86_nat_target<obsd_nat_target>::insert_hw_breakpoint(gdbarch*, bp_target_info*)) ld: error: undefined symbol: x86_remove_hw_breakpoint(gdbarch*, bp_target_info*) >>> referenced by x86-nat.h:97 (../../gdb/x86-nat.h:97) >>> amd64-obsd-nat.o:(x86_nat_target<obsd_nat_target>::remove_hw_breakpoint(gdbarch*, bp_target_info*)) ld: error: undefined symbol: x86_remove_watchpoint(unsigned long, int, target_hw_bp_type, expression*) >>> referenced by x86-nat.h:89 (../../gdb/x86-nat.h:89) >>> amd64-obsd-nat.o:(x86_nat_target<obsd_nat_target>::remove_watchpoint(unsigned long, int, target_hw_bp_type, expression*)) ld: error: undefined symbol: x86_insert_watchpoint(unsigned long, int, target_hw_bp_type, expression*) >>> referenced by x86-nat.h:84 (../../gdb/x86-nat.h:84) >>> amd64-obsd-nat.o:(x86_nat_target<obsd_nat_target>::insert_watchpoint(unsigned long, int, target_hw_bp_type, expression*)) ld: error: undefined symbol: x86_stopped_by_watchpoint() >>> referenced by x86-nat.h:100 (../../gdb/x86-nat.h:100) >>> amd64-obsd-nat.o:(x86_nat_target<obsd_nat_target>::stopped_by_watchpoint()) ld: error: undefined symbol: x86_stopped_data_address(unsigned long*) >>> referenced by x86-nat.h:103 (../../gdb/x86-nat.h:103) >>> amd64-obsd-nat.o:(x86_nat_target<obsd_nat_target>::stopped_data_address(unsigned long*)) ld: error: undefined symbol: x86_region_ok_for_hw_watchpoint(unsigned long, int) >>> referenced by x86-nat.h:79 (../../gdb/x86-nat.h:79) >>> amd64-obsd-nat.o:(x86_nat_target<obsd_nat_target>::region_ok_for_hw_watchpoint(unsigned long, int)) and ld: error: undefined symbol: x86_dr_insert_watchpoint(x86_debug_reg_state*, target_hw_bp_type, unsigned long, int) >>> referenced by x86-nat.c:156 (../../gdb/x86-nat.c:156) >>> x86-nat.o:(x86_insert_watchpoint(unsigned long, int, target_hw_bp_type, expression*)) ld: error: undefined symbol: x86_dr_remove_watchpoint(x86_debug_reg_state*, target_hw_bp_type, unsigned long, int) >>> referenced by x86-nat.c:169 (../../gdb/x86-nat.c:169) >>> x86-nat.o:(x86_remove_watchpoint(unsigned long, int, target_hw_bp_type, expression*)) ld: error: undefined symbol: x86_dr_region_ok_for_watchpoint(x86_debug_reg_state*, unsigned long, int) >>> referenced by x86-nat.c:181 (../../gdb/x86-nat.c:181) >>> x86-nat.o:(x86_region_ok_for_hw_watchpoint(unsigned long, int)) ld: error: undefined symbol: x86_dr_stopped_data_address(x86_debug_reg_state*, unsigned long*) >>> referenced by x86-nat.c:194 (../../gdb/x86-nat.c:194) >>> x86-nat.o:(x86_stopped_data_address(unsigned long*)) ld: error: undefined symbol: x86_dr_stopped_by_watchpoint(x86_debug_reg_state*) >>> referenced by x86-nat.c:206 (../../gdb/x86-nat.c:206) >>> x86-nat.o:(x86_stopped_by_watchpoint()) ld: error: undefined symbol: x86_dr_insert_watchpoint(x86_debug_reg_state*, target_hw_bp_type, unsigned long, int) >>> referenced by x86-nat.c:219 (../../gdb/x86-nat.c:219) >>> x86-nat.o:(x86_insert_hw_breakpoint(gdbarch*, bp_target_info*)) ld: error: undefined symbol: x86_dr_remove_watchpoint(x86_debug_reg_state*, target_hw_bp_type, unsigned long, int) >>> referenced by x86-nat.c:233 (../../gdb/x86-nat.c:233) >>> x86-nat.o:(x86_remove_hw_breakpoint(gdbarch*, bp_target_info*)) ld: error: undefined symbol: x86_dr_stopped_by_hw_breakpoint(x86_debug_reg_state*) >>> referenced by x86-nat.c:269 (../../gdb/x86-nat.c:269) >>> x86-nat.o:(x86_stopped_by_hw_breakpoint()) It does not fix: ld: error: can't create dynamic relocation R_X86_64_64 against symbol: __gmp_binvert_limb_table in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output >>> defined in /usr/local/lib/libgmp.a(mp_minv_tab.o) >>> referenced by tmp-dive_1.s >>> dive_1.o:(__gmpn_divexact_1) in archive /usr/local/lib/libgmp.a ld: error: can't create dynamic relocation R_X86_64_64 against symbol: __gmp_binvert_limb_table in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output >>> defined in /usr/local/lib/libgmp.a(mp_minv_tab.o) >>> referenced by tmp-bdiv_q_1.s >>> bdiv_q_1.o:(__gmpn_bdiv_q_1) in archive /usr/local/lib/libgmp.a ld: error: can't create dynamic relocation R_X86_64_64 against symbol: __gmpn_invert_limb_table in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output >>> defined in /usr/local/lib/libgmp.a(invert_limb_table.o) >>> referenced by tmp-invert_limb.s >>> invert_limb.o:(__gmpn_invert_limb) in archive /usr/local/lib/libgmp.a gdb/ChangeLog: 2019-12-04 Christian Biesinger <cbiesinger@google.com> * configure.nat (obsd64): Add missing files x86-nat.o and nat/x86-dregs.o. Change-Id: I4a443c0cf805efd7b45feaabd729a01b07772724
2019-12-04Use metadata style in a few more placesTom Tromey5-15/+24
I happened to find a few more spots that should use metadata style, but do not. I missed these in my earlier search somehow. This patch also adds gettext markup in a couple of spots where it was missing. gdb/ChangeLog 2019-12-04 Tom Tromey <tom@tromey.com> * valprint.c (val_print_string): Use metadata_style. * go-valprint.c (print_go_string): Use metadata style. * p-valprint.c (pascal_object_print_static_field): Use metadata style. * cp-valprint.c (cp_print_static_field): Use metadata style. Change-Id: Id82ca2aa306c6694b111d5c92dfa6f0cce919ebf
2019-12-04gdb/testsuite: Use -J option when compiling Fortran testsAndrew Burgess3-1/+18
When compiling Fortran tests (e.g. gdb.fortran/info-modules.exp), the Fotran compile produces .mod files. These files contain details of compiled modules that are then consumed by the compiler when compiling other files that USE a module. Currently the compiler writes the .mod files into its current directory, so for us this turns out to be 'build/gdb/testsuite/'. This means that .mod files can be shared between tests, which seems against the spirit of the GDB testsuite; source files should be compiled fresh for each test. This commit adds the -J option to the compiler flags whenever we compile a Fortran file, this option tells the compiler where to write, and look for, .mod files. After this commit there was one Fortran test that needed fixing, with that fix in place all of the Fortran tests pass again, but now the .mod files are now produced in the per-test output directories. gdb/testsuite/ChangeLog: * lib/gdb.exp (gdb_compile): Add -J compiler option when building Fortran tests. * gdb.mi/mi-fortran-modules.exp: Compile source files in correct order. Change-Id: I99444cf22d80e320093d3f3ed9abb8825f378e0b
2019-12-04gdb/fortran: Support for single/double type modifiersAndrew Burgess4-3/+52
Extend the Fortran parser to support 'single precision' and 'double precision' types as well 'single complex' and 'double complex' types. gdb/ChangeLog: * f-exp.y (COMPLEX_KEYWORD, SINGLE, DOUBLE, PRECISION): New tokens. (typebase): New patterns for complex, single/double precision, and single/double complex. (f77_keywords): Change token for complex keyword, and add single, double, and precision keywords. gdb/testsuite/ChangeLog: * gdb.fortran/type-kinds.exp (test_cast_1_to_type_kind): Handle casting to type with no kind specified. (test_basic_parsing_of_type_kinds): Additional tests for types with no kind specified, and add tests for single/double precision/complex types. Change-Id: I9c82f4d392c58607747bd08862c1ee330723a1ba
2019-12-04Fix doc of AVR-specific command "info io_registers"Simon Marchi2-1/+6
Running the selftests on an all-targets build, I get: Running selftest help_doc_invariants. help doc broken invariant: command 'info io_registers' help doc first line is not terminated with a '.' character Self test failed: self-test failed at /home/simark/src/binutils-gdb/gdb/unittests/help-doc-selftests.c:95 Add a period at the end of the doc of that command, and make it a bit nicer in general. gdb/ChangeLog: * avr-tdep.c (_initialize_avr_tdep): Improve help of command "info io_registers".
2019-12-04Fix regcache::cooked_read_test selftest for mepSimon Marchi2-0/+6
When running the regcache::cooked_read_test selftest in an all targets build, I get the following internal error: /home/simark/src/binutils-gdb/gdb/thread.c:95: internal-error: thread_info* inferior_thread(): Assertion `tp' failed. The stack trace is the followiing: #9 0x000055fe25584a52 in internal_error (file=0x55fe27a25fe0 "/home/simark/src/binutils-gdb/gdb/thread.c", line=95, fmt=0x55fe27a25c80 "%s: Assertion `%s' failed.") at /home/simark/src/binutils-gdb/gdb/gdbsupport/errors.c:55 #10 0x000055fe260674bc in inferior_thread () at /home/simark/src/binutils-gdb/gdb/thread.c:95 #11 0x000055fe25c62f0f in get_current_regcache () at /home/simark/src/binutils-gdb/gdb/regcache.c:372 #12 0x000055fe2594fcf1 in current_options () at /home/simark/src/binutils-gdb/gdb/mep-tdep.c:873 #13 0x000055fe2594ff08 in mep_register_name (gdbarch=0x62100056f510, regnr=152) at /home/simark/src/binutils-gdb/gdb/mep-tdep.c:958 #14 0x000055fe25950112 in mep_register_reggroup_p (gdbarch=0x62100056f510, regnum=152, group=0x55fe2924d540 <save_group>) at /home/simark/src/binutils-gdb/gdb/mep-tdep.c:1029 #15 0x000055fe2555ad87 in gdbarch_register_reggroup_p (gdbarch=0x62100056f510, regnum=152, reggroup=0x55fe2924d540 <save_group>) at /home/simark/src/binutils-gdb/gdb/gdbarch.c:3622 #16 0x000055fe25c61d45 in reg_buffer::save(gdb::function_view<register_status (int, unsigned char*)>) (this=0x7ffc61a0ed90, cooked_read=...) at /home/simark/src/binutils-gdb/gdb/regcache.c:247 #17 0x000055fe2552ac60 in readonly_detached_regcache::readonly_detached_regcache(gdbarch*, gdb::function_view<register_status (int, unsigned char*)>) (this=0x7ffc61a0ed90, gdbarch=0x62100056f510, cooked_read=...) at /home/simark/src/binutils-gdb/gdb/regcache.h:444 #18 0x000055fe25c61867 in readonly_detached_regcache::readonly_detached_regcache (this=0x7ffc61a0ed90, src=...) at /home/simark/src/binutils-gdb/gdb/regcache.c:212 #19 0x000055fe25c6a5ca in selftests::cooked_read_test (gdbarch=0x62100056f510) at /home/simark/src/binutils-gdb/gdb/regcache.c:1613 The problems is that mep's code ends up calling inferior_thread, which calls find_thread_ptid. find_thread_ptid searches for a thread by ptid in the thread list of the inferior that is expected to contain that thread. However, the thread list of the mock inferior set up in cooked_read_test is never initialized. So find_thread_ptid doesn't find the thread, which is an unexpected situation for inferior_thread. This is failing since this commit: 080363310650c93ad8e93018bcb6760ba5d32d1c Per-inferior thread list, thread ranges/iterators, down with ALL_THREADS, etc. Fix it by putting the mock thread in the thread list of the mock inferior in cooked_read_test. gdb/ChangeLog: * regcache.c (cooked_read_test): Initialize thread list of mock_inferior.
2019-12-04Remove unused includes in aarch64-linux-tdep.cSimon Marchi2-5/+5
include-what-you-use reports: ../../../src/binutils-gdb/gdb/aarch64-linux-tdep.c should remove these lines: - #include "arch-utils.h" // lines 24-24 - #include "auxv.h" // lines 48-48 - #include "cli/cli-utils.h" // lines 39-39 - #include "elf/common.h" // lines 49-49 - #include "inferior.h" // lines 35-35 Add an include for "target/target.h", otherwise target_read_memory isn't found. gdb/ChangeLog: * aarch64-linux-tdep.c: Remove includes.
2019-12-04Remove unused includes in aarch64-tdep.cSimon Marchi2-7/+4
include-what-you-use reports: ../../../src/binutils-gdb/gdb/aarch64-tdep.c should remove these lines: - #include "ax.h" // lines 45-45 - #include "elf-bfd.h" // lines 52-52 - #include "elf/aarch64.h" // lines 53-53 - #include "infcall.h" // lines 44-44 - #include "inferior.h" // lines 24-24 - #include "language.h" // lines 43-43 gdb/ChangeLog: * aarch64-tdep.c: Remove includes.
2019-12-04Compare iterators, not values, in filtered_iterator::operator{==,!=}Simon Marchi4-2/+176
The == and != operators on filtered_iterator are not doing the right thing, they compare values pointed by the wrapped iterators instead of comparing the iterators themselves. As a result, operator== will return true if the two iterators point to two equal values at different positions. operator!= will fail similarly. Also, this causes it to deference past-the-end iterators when doing. For example, in for (iter = ...; iter != end_iter; ++iter) the != comparison dereferences end_iter. I don't think this should happen. I don't think it's a problem today, given that we only use filtered_iterator to wrap linked lists of threads and inferiors. Dereferencing past-the-end iterators of these types is not fatal, it just returns NULL, which is not a value we otherwise find in the lists. But in other contexts, it could become problematic. I have added a simple self test that fails without the fix applied. gdb/ChangeLog: * filtered-iterator.h (filtered_iterator) <operator==, operator!=>: Compare wrapped iterators, not wrapped pointers. * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add unittests/filtered_iterator-selftests.c. * unittests/filtered_iterator-selftests.c: New file.
2019-12-04sim-utils.c: prevent buffer overflow.Pavel I. Kryukov2-4/+8
Representation of max 32-bit integer is 10 chars. The potential issue is observed by GCC 7 targeted to AArch64. sim/common/ChangeLog: 2019-12-01 Pavel I. Kryukov <kryukov@frtk.ru> * sim-utils.c: Prevent buffer overflow.
2019-12-04Add bit-field test for scalar_storage_orderTom Tromey3-3/+11
This adds a bit-field test for scalar_storage_order. gdb/testsuite/ChangeLog 2019-12-04 Tom Tromey <tromey@adacore.com> * gdb.base/endianity.c (struct other) <x>: New field. (main): Initialize it. * gdb.base/endianity.exp: Update. Change-Id: I9e07d1b3e08e7c3384832b68ef286afe1d11479a
2019-12-04Propagate endianity to subrange typesTom Tromey7-0/+138
A subrange type should inherit its endianity from its base type. gdb/ChangeLog 2019-12-04 Tom Tromey <tromey@adacore.com> * gdbtypes.c (create_range_type): Inherit endianity from base type. gdb/testsuite/ChangeLog 2019-12-04 Tom Tromey <tromey@adacore.com> * gdb.ada/scalar_storage/storage.adb: New file. * gdb.ada/scalar_storage/pck.adb: New file. * gdb.ada/scalar_storage/pck.ads: New file. * gdb.ada/scalar_storage.exp: New file. Change-Id: I2998ab919dc28aeff097763c4242f9bfb90823a3
2019-12-04Remove gdbarch_bits_big_endianTom Tromey13-55/+37
From what I can tell, set_gdbarch_bits_big_endian has never been used. That is, all architectures since its introduction have simply used the default, which is simply check the architecture's byte-endianness. Because this interferes with the scalar_storage_order code, this patch removes this gdbarch setting entirely. In some places, type_byte_order is used rather than the plain gdbarch. gdb/ChangeLog 2019-12-04 Tom Tromey <tromey@adacore.com> * ada-lang.c (decode_constrained_packed_array) (ada_value_assign, value_assign_to_component): Update. * dwarf2loc.c (rw_pieced_value, access_memory) (dwarf2_compile_expr_to_ax): Update. * dwarf2read.c (dwarf2_add_field): Update. * eval.c (evaluate_subexp_standard): Update. * gdbarch.c, gdbarch.h: Rebuild. * gdbarch.sh (bits_big_endian): Remove. * gdbtypes.h (union field_location): Update comment. * target-descriptions.c (make_gdb_type): Update. * valarith.c (value_bit_index): Update. * value.c (struct value) <bitpos>: Update comment. (unpack_bits_as_long, modify_field): Update. * value.h (value_bitpos): Update comment. Change-Id: I379b5e0c408ec8742f7a6c6b721108e73ed1b018
2019-12-04Move type_byte_order earlierTom Tromey2-18/+25
I failed to notice that the scalar_storage_order patch put type_byte_order at the end of gdbtypes.c. The end of the file is normally where the file's _initialize function goes. This moves type_byte_order earlier, into a more relevant section. gdb/ChangeLog 2019-12-04 Tom Tromey <tromey@adacore.com> * gdbtypes.c (type_byte_order): Move earlier. Assert for unknown endian-ness. Change-Id: I4666431ecbb32ec98918f39f72d22c86b2bc8dde
2019-12-04Add scalar_storage_order support for floating pointTom Tromey7-28/+66
Testing the scalar_storage_order patch pointed out that it does not handle floating point properly. This patch fixes this problem. gdb/ChangeLog 2019-12-04 Tom Tromey <tromey@adacore.com> * dwarf2read.c (dwarf2_init_float_type) (dwarf2_init_complex_target_type): Add byte_order parameter. (read_base_type): Compute byte order earlier. * gdbtypes.c (init_float_type): Add byte_order parameter. * gdbtypes.h (init_float_type): Add byte_order parameter. gdb/testsuite/ChangeLog 2019-12-04 Tom Tromey <tromey@adacore.com> * gdb.base/endianity.c (struct otherendian) <f>: New field. (main): Initialize it. * gdb.base/endianity.exp: Update. Change-Id: Ic02eb711d80ce678ef0ecf8c506a626e441b8440
2019-12-04Fix another build failure in tui-selftests.cTom Tromey2-1/+6
Christian had emailed me to say that the TUI unit test broke the mingw build, but I erroneously thought this was fixed by the earlier patch that made the test body conditional on the TUI being built. However, I was wrong about this -- tui-selftests.c unconditionally includes tui-winsource.h, which fails if curses is not available. This patch fixes the build problem by moving this include into the "#ifdef TUI" section. Tested by rebuilding a mingw-hosted gdb. gdb/ChangeLog 2019-12-04 Tom Tromey <tromey@adacore.com> * unittests/tui-selftests.c: Conditionally include tui-winsource.h. Change-Id: If608649ef5cbef8ea92192e11c53379742967ee7
2019-12-04Silence maybe-uninitialized warning in dwarf2read.cTom Tromey2-1/+6
I upgraded to Fedora 30 recently. It includes GCC 9, which gives a warning for dwarf2read.c: ../../binutils-gdb/gdb/dwarf2read.c:16103:24: warning: ‘discr_offset’ may be used uninitialized in this function [-Wmaybe-uninitialized] This patch fixes the problem by initializing discr_offset. Tested by rebuilding. gdb/ChangeLog 2019-12-04 Tom Tromey <tromey@adacore.com> * dwarf2read.c (process_structure_scope): Initialize "discr_offset". Change-Id: I76a6157921c9beacb641b8a41e10026006621b95
2019-12-04gdb/mi: Add -max-results parameter to some -symbol-info-* commandsAndrew Burgess8-36/+180
Adds a new parameter -max-results to -symbol-info-functions, -symbol-info-variables, -symbol-info-types, and -symbol-info-modules. This parameter limits the number of results returned. This change still leaves -symbol-info-module-functions and -symbol-info-module-variables always returning all results, fixing these commands is slightly harder. There's currently no mechanism for the user of these commands to know if the result list has been truncated if you get back the maximum number of results, so if there are exactly 10 functions and you call '-symbol-info-functions --max-results 10' the reply would appear no different than if you had 20 functions and called with a max of 10. Right now, if you get back the maximum then you should assume that there might be more results available. One other thing to note is that the global_symbol_searcher::search by default returns SIZE_MAX results, there's no longer a mechanism to return an unlimited number of results, though hopefully this will not be a huge issue. gdb/ChangeLog: * mi/mi-symbol-cmds.c (mi_symbol_info): Take extra parameter, and add it into the search spec. (parse_max_results_option): New function. (mi_info_functions_or_variables): Parse -max-results flag and pass it to mi_symbol_info. (mi_cmd_symbol_info_modules): Likewise. (mi_cmd_symbol_info_types): Likewise. * symtab.c (global_symbol_searcher::add_matching_symbols): Change return type to bool, change result container into a set, and don't add new results if we have enough already. (global_symbol_searcher::add_matching_msymbols): Change return type to bool, and don't add new results if we have enough already. (sort_search_symbols_remove_dups): Delete. (global_symbol_searcher::search): Early exit from search loop when we have enough results. Use a std::set to collect the results from calling add_matching_symbols. * symtab.h (global_symbol_searcher) <set_max_seach_results>: New member function. (global_symbol_searcher) <m_max_search_results>: New member variable. (global_symbol_searcher) <add_matching_symbols>: Update header comment and change return type to bool. (global_symbol_searcher) <add_matching_msymbols>: Update header comment and change return type to bool. gdb/doc/ChangeLog: * doc/gdb.texinfo (GDB/MI Symbol Query): Add documentation of -max-results to some -symbol-info-* commands. gdb/testsuite/ChangeLog: * gdb.mi/mi-sym-info.exp: Add tests for -max-results parameter. Change-Id: I90a28feb55b388fb46461a096c5db08b6b0bd427
2019-12-04gdb: Split global symbol search into separate functionsAndrew Burgess3-195/+273
In preparation for the next commit, this commit restructures the code by splitting global_symbol_searcher::search into separate functions. There should be no functional changes after this commit. gdb/ChangeLog: * symtab.c (symbol_search::compare_search_syms): Update header comment. (global_symbol_searcher::is_suitable_msymbol): New function. (global_symbol_searcher::expand_symtabs): New function. (global_symbol_searcher::add_matching_symbols): New function. (global_symbol_searcher::add_matching_msymbols): New function. (global_symbol_searcher::search): Move most of the content into the new functions above, and call them as needed. * symtab.h (global_symbol_searcher) <expand_symtabs>: New member function. (global_symbol_searcher) <add_matching_symbols>: New member function. (global_symbol_searcher) <add_matching_msymbols>: New member function. (global_symbol_searcher) <is_suitable_msymbol>: New member function. Change-Id: I06b26920f35c268f7a38d8203dc2c2813aa501c6
2019-12-04gdb/mi: Add -symbol-info-module-{variables,functions}Andrew Burgess9-1/+356
Two new MI command -symbol-info-module-variables and -symbol-info-module-functions, which are the equivalent of the CLI command 'info module variables' and 'info module functions'. These return information about functions and variables within Fortran modules. gdb/ChangeLog: * mi/mi-cmds.c (mi_cmds): Add -symbol-info-module-functions and -symbol-info-module-variables entries. * mi/mi-cmds.h (mi_cmd_symbol_info_module_functions): Declare. (mi_cmd_symbol_info_module_variables): Declare. * mi/mi-symbol-cmds.c (module_symbol_search_iterator): New typedef. (output_module_symbols_in_single_module_and_file): New function. (output_module_symbols_in_single_module): New function. (mi_info_module_functions_or_variables): New function. (mi_cmd_symbol_info_module_functions): New function. (mi_cmd_symbol_info_module_variables): New function. * NEWS: Mention new MI command. gdb/doc/ChangeLog: * doc/gdb.texinfo (GDB/MI Symbol Query): Document new MI command -symbol-info-module-functions and -symbol-info-module-variables. gdb/testsuite/ChangeLog: * gdb.mi/mi-fortran-modules.exp: Add additional tests for -symbol-info-module-functions and -symbol-info-module-variables. Change-Id: Ic96f12dd14bd7e34774c3cde008fec30a4055bfe
2019-12-04x86-64: accept 64-bit LFS/LGS/LSS forms with suffix or operand size specifierJan Beulich12-14/+101
Since we accept these without suffix / operand size specifier, we should also do so with one. (The fact that we unilaterally accept these, other than far branches, rather than limiting them to Intel64 mode, will be taken care of later on.) Also take the opportunity and make sure "lfs <reg>, tbyte ptr <mem>" et al get rejected outside of 64-bit mode. This became broken by dc2be329b950 ("i386: Only check suffix in instruction mnemonic"). Furthermore cover lgdt et al in the Intel syntax handling as well, which continued to work after said commit just by coincidence.
2019-12-04x86-64/Intel: fix CALL/JMP with dword operandJan Beulich4-6/+31
While dc2be329b950 ("i386: Only check suffix in instruction mnemonic") has made the assembler accept these in the first place (they were wrongly rejected before), the generated code was still wrong in that it lacked an operand size override. (In 64-bit code, other than in 16- and 32-bit ones, CALL and JMP with memory operands are all entirely unambiguous: No operand size can have two meanings.)
2019-12-04x86: consolidate tracking of MMX register useJan Beulich2-9/+8
Just like for XMM/YMM/ZMM don't key this to any Cpu* flags. Instead include the two special insns (not having register operands) explicitly.
2019-12-04x86/Intel: extend MOVDIRI testingJan Beulich9-1/+28
Test also memory operands with operand size specifier, which was broken prior to dc2be329b950 ("i386: Only check suffix in instruction mnemonic"), due to the template not permitting any suffixes. Note that this uncovered a disassembler issue, which is being fixed here as well.
2019-12-04x86: make sure all PUSH/POP honor DefaultSizeJan Beulich4-8/+40
While segment registers are registers, their use doesn't allow sizing of insns without suffix / explicit operand size specifier. Prevent PUSH and POP of segment registers from entering that path, instead allowing them to observe the stackop_size setting just like other PUSH/POP and alike do.
2019-12-04x86: drop some stray/bogus DefaultSizeJan Beulich7-19/+111
Insns permitting only GPR operands (and hence implicit sizing when there's no suffix) don't ever have their DefaultSize attribute inspected, so it shouldn't be there in the first place. Additionally XBEGIN is like JMP, not CALL, and hence shouldn't be converted to 32-bit operand size in .code16gcc mode. While the same is true for SYSRET, it permitting more than one suffix makes it FLDENV- like, and hence rather than dropping the attribute, for now add it to the exclusion list to avoid it getting an operand size prefix emitted in .code16gcc mode. (This will be dealt with later, perhaps together with FLDENV and friends.)
2019-12-04Automatic date update in version.inGDB Administrator1-1/+1
2019-12-03Replace hash function from bcache with fast_hashChristian Biesinger6-44/+32
This function is not just slower than xxhash, it is slower than even libiberty's iterative_hash, so there does not seem to be a reason for it to exist. ------------------------------------------------------------ Benchmark Time CPU Iterations ------------------------------------------------------------ BM_xxh3 11 ns 11 ns 66127192 BM_xxh32 19 ns 19 ns 36792609 BM_xxh64 16 ns 16 ns 42941328 BM_city32 26 ns 26 ns 27028370 BM_city64 17 ns 17 ns 40472793 BM_iterative_hash 77 ns 77 ns 9088854 BM_bcache_hash 125 ns 125 ns 5599232 gdb/ChangeLog: 2019-12-03 Christian Biesinger <cbiesinger@google.com> * bcache.c (hash): Remove. (hash_continue): Remove. * bcache.h (hash): Remove. (hash_continue): Remove. (struct bcache) <ctor>: Update. * psymtab.c (psymbol_hash): Update. * stabsread.c (hashname): Update. * utils.h (fast_hash): Add an argument for a start value, defaulting to zero. Change-Id: I107f013eda5fdd3293326b5a206be43155dae0f8
2019-12-03Fix leak of symbol name in block_symbol_cachePhilippe Waroquiers2-14/+33
A symbol not found inserted in the cache has a xstrdup-ed name that must be freed, but only the struct block_symbol_cache is freed. Add a function destroy_block_symbol_cache that clears all slots before releasing the cache. 2019-12-03 Philippe Waroquiers <philippe.waroquiers@skynet.be> * symtab.c (symbol_cache_clear_slot): Move close to cleared type. (destroy_block_symbol_cache): New function. (symbol_cache:~symbol_cache) Call destroy_block_symbol_cache. (resize_symbol_cache): Likewise.
2019-12-03PR25230, addr2line fails on dwz outputAlan Modra2-60/+172
This patch remedies the following DW_FORM_GNU_ref_alt related problem: /* FIXME: Do we need to locate the correct CU, in a similar fashion to the code in the DW_FORM_ref_addr case above ? */ Without the correct CU the wrong abbrevs are used, resulting in errors and/or wrong file names. There is scope for further work here. Parsing of CUs should be a two step process, with the first stage just finding the bounds of the CU. This would allow find_abstract_instance to quickly find the CU referenced by DW_FORM_ref_addr or DW_FORM_GNU_ref_alt, then take the second stage of CU parsing where abbrevs, ranges and suchlike consume time and memory. As it is, we just process CUs from the start of .debug_info until we find the one of interest. The testcase in the PR takes 98G of virtual memory. PR 25230 * dwarf2.c (struct dwarf2_debug_file): Add line_table and abbrev_offsets. (struct abbrev_offset_entry): New. (hash_abbrev, eq_abbrev, del_abbrev): New functions. (read_abbrevs): Check whether we have already read abbrevs at given offset, and add new offset/abbrev to hash table. (decode_line_info): Keep line table at offset zero in file struct. Return this for a cu reusing the same dir/file list. (find_abstract_instance): Find cu for DW_FORM_GNU_ref_alt. (_bfd_dwarf2_slurp_debug_info): Create offset/abbrev hash tables. (_bfd_dwarf2_cleanup_debug_info): Adjust deletion of lines and abbrevs.
2019-12-03PR25230, dwarf2.c per file stashAlan Modra2-246/+261
This is just moving things around, in preparation for parsing alt file debug_info. PR 25230 * dwarf2.c (struct dwarf2_debug_file): New struct. (struct dwarf2_debug): Delete fields now in dwarf2_debug_file. Add f, alt fields. (struct comp_unit): Add file field. (read_indirect_string, read_indirect_line_string): Adjust to suit. (read_alt_indirect_string, read_alt_indirect_ref): Likewise. (read_debug_ranges, find_abstract_instance, read_rangelist): Likewise. (_bfd_dwarf2_stash_syms, place_sections): Likewise. (stash_maybe_update_info_hash_tablse): Likewise. (stash_verify_info_hash_table): Likewise. (_bfd_dwarf2_slurp_debug_info): Likewise. (_bfd_dwarf2_find_symbol_bias): Likewise. (_bfd_dwarf2_find_nearest_line): Likewise. (_bfd_dwarf2_cleanup_debug_info): Likewise. (read_abbrevs): Add file param and adjust. Update calls. (stash_comp_unit): Likewise. (decode_line_info): Delete stash param and adjust. Update calls. (comp_unit_find_nearest_line): Likewise. (comp_unit_maybe_decode_line_info): Likewise. (comp_unit_find_line): Likewise. (parse_comp_unit): Add file and info_ptr param and adjust. Update calls.
2019-12-03dwarf2.c: read_abbrevs fail cleanup, and offset checkingAlan Modra2-29/+32
read_section does offset checking, reporting an error on out of bounds. There's no need to duplicate the check in functions calling read_section. Also, I spotted a place where a pointer difference expression was being cast to unsigned int, possibly truncating relevant bits on a 64-bit host. * dwarf2.c (read_indirect_string): Don't duplicate offset check done in read_section. (read_indirect_line_string): Likewise. (read_alt_indirect_string): Likewise. (read_alt_indirect_ref): Likewise. (read_abbrevs): Likewise. Free memory on all failure paths. Use correct unsigned type for pointer difference comparison.
2019-12-03dwarf2.c stash->sec_info_ptr and stash->secAlan Modra2-20/+12
These are unused. Remove them. Also fix the wrong sort of 0 being returned from read_alt_indirect_ref. * dwarf2.c (struct dwarf2_debug): Update comments. Remove sec and sec_info_ptr. (_bfd_dwarf2_slurp_debug_info): Don't set sec or sec_info_ptr. (stash_comp_unit): Likewise. (read_alt_indirect_ref): Return NULL not FALSE.
2019-12-03_bfd_dwarf2_find_nearest_line comment fixAlan Modra2-3/+5
These lines should have been removed along with the addr_size parameter. * dwarf2.c (_bfd_dwarf2_find_nearest_line): Correct function comment.
2019-12-03Automatic date update in version.inGDB Administrator1-1/+1
2019-12-02Fix build breakage with --disable-tuiTom Tromey2-0/+11
An earlier patch introduced a unit test for tui_copy_source_line. However if the TUI is not built (as is apparently the case on some of the buildbot builders), then this will fail to link. This patch fixes the problem. Tested by rebuilding with the TUI disabled. gdb/ChangeLog 2019-12-02 Tom Tromey <tom@tromey.com> * unittests/tui-selftests.c (run_tests): Make conditional. (_initialize_tui_selftest): Make conditional. Change-Id: I964811c7635be24cf6c53920e74e920914503674
2019-12-02Change type of debug_aix_thread to boolChristian Biesinger2-1/+5
This fixes AIX build breakage from commit 491144b5e21bbfd41969c175aebb663976f59058 Thanks to Sangamesh Mallayya for pointing this out to me. gdb/ChangeLog: 2019-12-02 Christian Biesinger <cbiesinger@google.com> * aix-thread.c (debug_aix_thread): Change type to bool. Change-Id: Ie7b2eab97b75b48067ef77e414e7510d1f79a525
2019-12-02Remove stale FIXME commentLuis Machado2-1/+4
While debugging something, i noticed this odd FIXME comment. It seems stale and therefore here's a patch removing it. gdb/ChangeLog: 2019-12-02 Luis Machado <luis.machado@linaro.org> * infrun.c (follow_fork_inferior): Remove outdated FIXME comment. Change-Id: I2436ca4ae4a6741012cafe8123325f738b692c9c
2019-12-02Automatic date update in version.inGDB Administrator1-1/+1
2019-12-01gdb: Dynamic string length supportAndrew Burgess5-24/+128
Add support for strings with dynamic length using the DWARF attribute DW_AT_string_length. Currently gFortran generates DWARF for some strings that make use of DW_AT_string_length like this: <1><2cc>: Abbrev Number: 20 (DW_TAG_string_type) <2cd> DW_AT_string_length: 5 byte block: 99 bd 1 0 0 (DW_OP_call4: <0x1bd>) <2d3> DW_AT_byte_size : 4 <2d4> DW_AT_sibling : <0x2e2> In this type entry the DW_AT_string_length attribute references a second DW_TAG_formal_parameter that contains the string length. The DW_AT_byte_size indicates that the length is a 4-byte value. This commit extends GDB's DWARF parsing for strings so that we can create dynamic types as well as static types, based on the attribute the DWARF contains. I then extend the dynamic type resolution code in gdbtypes.c to add support for resolving dynamic strings. gdb/ChangeLog: * dwarf2read.c (read_tag_string_type): Read the fields required to make a dynamic string, and possibly create a dynamic range for the string. (attr_to_dynamic_prop): Setup is_reference based on the type of attribute being processed. * gdbtypes.c (is_dynamic_type_internal): Handle TYPE_CODE_STRING. (resolve_dynamic_array): Rename to... (resolve_dynamic_array_or_string): ...this, update header comment, and accept TYPE_CODE_STRING. (resolve_dynamic_type_internal): Handle TYPE_CODE_STRING. gdb/testsuite/ChangeLog: * gdb.fortran/array-slices.exp: Add test for dynamic strings. Change-Id: I03f2d181b26156f48f27a03c8a59f9bd4d71ac17
2019-12-01gdb/dwarf: Introduce dwarf2_per_cu_int_type functionAndrew Burgess2-11/+31
This is a minor refactor in preparation for the next commit. Splits the core of dwarf2_per_cu_addr_sized_int_type out into a separate function. There should be no user visible changes after this commit. gdb/ChangeLog: * dwarf2read.c (dwarf2_per_cu_int_type): New function, takes most of its implementation from... (dwarf2_per_cu_addr_sized_int_type): ...here, which now just calls the new function. Change-Id: I8b849dd338012ec033b3f0a57d65cec0d7a3bd97