aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2020-05-19Default gdb_bfd_open's fd parameter to -1Pedro Alves10-13/+19
A following patch will add one more defaulted parameter. gdb/ChangeLog: 2020-05-19 Pedro Alves <palves@redhat.com> * gdb_bfd.h: (gdb_bfd_open): Default to 'fd' parameter to -1. Adjust all callers.
2020-05-19gdb: fix -Wtautological-overlap-compare error in h8300-tdep.cYoshinori Sato2-6/+12
Compiling with clang 11 gives us: CXX h8300-tdep.o /home/smarchi/src/binutils-gdb/gdb/h8300-tdep.c:225:21: error: overlapping comparisons always evaluate to false [-Werror,-Wtautological-overlap-compare] if (disp < 0 && disp > 0xffffff) ~~~~~~~~~^~~~~~~~~~~~~~~~~~ /home/smarchi/src/binutils-gdb/gdb/h8300-tdep.c:203:17: error: overlapping comparisons always evaluate to false [-Werror,-Wtautological-overlap-compare] if (disp < 0 && disp > 0xffffff) ~~~~~~~~~^~~~~~~~~~~~~~~~~~ /home/smarchi/src/binutils-gdb/gdb/h8300-tdep.c:184:17: error: overlapping comparisons always evaluate to false [-Werror,-Wtautological-overlap-compare] if (disp < 0 && disp > 0xffffff) ~~~~~~~~~^~~~~~~~~~~~~~~~~~ Indeed, disp (of type LONGEST) can't be less than 0 and greater than 0xffffff. Fix it by changing the way we check if disp is negative. Check the sign bit of disp, which is a 24-bit number. gdb/ChangeLog: * h8300-tdep.c (h8300_is_argument_spill): Change how we check whether disp is negative.
2020-05-19Fix thinko in recent update to bfd_section_from_shdr.Gunther Nikl2-1/+7
PR 26005 * elf.c (bfd_section_from_shdr): Replace bfd_malloc + memset with bfd_zmalloc to allocate memory for the sections_being_created array.
2020-05-19gdb: make symfile_segment_data::segment_info an std::vectorSimon Marchi4-8/+15
Change the symfile_segment_data::segment_info array to be an std::vector. No functional changes are expected. gdb/ChangeLog: * symfile.h (struct symfile_segment_data) <~symfile_segment_data>: Remove. <segment_info>: Change to std::vector. * symfile.c (default_symfile_segments): Update. * elfread.c (elf_symfile_segments): Update.
2020-05-19gdb: use std::vector to store segments in symfile_segment_dataSimon Marchi6-41/+45
Instead of maintaining two vectors, I added a small `segment` class which holds both the base address and size of one segment and replaced the two `segment_bases` and `segment_sizes` arrays with a single vector. The rest of the changes are straightforward, no behavior changes are expected. gdb/ChangeLog: * symfile.h (struct symfile_segment_data) <struct segment>: New. <segments>: New. <segment_bases, segment_sizes>: Remove. * symfile.c (default_symfile_segments): Update. * elfread.c (elf_symfile_segments): Update. * remote.c (remote_target::get_offsets): Update. * solib-target.c (solib_target_relocate_section_addresses): Update.
2020-05-19gdb: allocate symfile_segment_data with newSimon Marchi7-45/+55
- Allocate this structure with new instead of XNEW, use a unique pointer to manage its lifetime. - Change a few functions to return a unique pointer instead of a plain pointer. - Change free_symfile_segment_data to be symfile_segment_data's destructor. gdb/ChangeLog: * symfile.h (struct symfile_segment_data): Initialize fields. <~symfile_segment_data>: Add. (symfile_segment_data_up): New. (struct sym_fns) <sym_segments>: Return a symfile_segment_data_up. (default_symfile_segments): Return a symfile_segment_data_up. (free_symfile_segment_data): Remove. (get_symfile_segment_data): Return a symfile_segment_data_up. * symfile.c (default_symfile_segments): Likewise. (get_symfile_segment_data): Likewise. (free_symfile_segment_data): Remove. (symfile_find_segment_sections): Update. * elfread.c (elf_symfile_segments): Return a symfile_segment_data_up. * remote.c (remote_target::get_offsets): Update. * solib-target.c (solib_target_relocate_section_addresses): Update. * symfile-debug.c (debug_sym_segments): Return a symfile_segment_data_up.
2020-05-19Allow readelf to issue warnings if checking is enabled and there are ↵H.J. Lu2-7/+47
discrepancies between the dynamic tags and the dynamic sections. PR binutils/25809 * readelf.c (process_program_headers): Warn if the PT_DYNAMIC segment doesn't match the .dynamic section and checks are enabled. (struct filedata): Add dynamic_symtab_section and dynamic_strtab_section fields. (process_section_headers): Set dynamic_symtab_section to the .dynsym section. Set dynamic_strtab_section to the .dynstr section. (process_dynamic_section): Warn if the .dynsym section doesn't match DT_SYMTAB and DT_SYMENT or the .dynstr section doesn't DT_STRTAB and DT_STRSZ. But only if checks are enabled.
2020-05-19OpenRISC BFD fixups for Glibc:Stafford Horne2-132/+264
or1k: Fix static linking when with .rela.got relocations or1k: Fix dynamic TLS symbol flag or1k: Add TLS mask to handle multiple model access or1k: Fix issue with multiple PCREL relocations or1k: TLS offset to use tcb size and section alignment or1k: refactor: Rename p to sec_relocs or1k: refactor: Rename s to sgot and splt or1k: Add dynamic flag to tpoff bfd * elf32-or1k.c (or1k_elf_finish_dynamic_symbol): Rename srela to relgot. (or1k_elf_relocate_section): Access srelgot via htab->root.srelgot. Add assertions for srelgot->contents. Introduce local variable for srelgot to not reuse global sreloc. (or1k_elf_relocate_section): Fixup dynamic symbol detection. (or1k_set_got_and_rela_sizes): New function. (or1k_initial_exec_offset): New function. (TLS_GD, TLS_IE, TLS_LD, TLS_LE): Redefine macros as masks. (or1k_elf_relocate_section): Allow for TLS to handle multiple model access. (or1k_elf_check_relocs): Use OR to set TLS access. (allocate_dynrelocs): Use or1k_set_got_and_rela_sizes to set sizes. (or1k_elf_size_dynamic_sections): Use or1k_set_got_and_rela_sizes to set sizes. (or1k_elf_relocate_section): Fixup PCREL relocation calculation. (TCB_SIZE): New macro. (tpoff): Use TCB_SIZE and alignment to calculate offset. (allocate_dynrelocs, readonly_dynrelocs, or1k_elf_check_relocs) (or1k_elf_size_dynamic_sections): Rename p to sec_relocs. (allocate_dynrelocs): Rename s to splt or sgot based on usage. (tpoff): Add dynamic boolean argument. (or1k_elf_relocate_section): Pass dynamic flag to tpoff.
2020-05-19Fix the ARM assembler to generate a Realtime profile for armv8-r.Alexander Fedotov8-11/+28
PR 25992 gas * config/tc-arm.c : Add arm_ext_v8r feature. (it_fsm_post_encode): Check arm_ext_v8r feature. (get_aeabi_cpu_arch_from_fset): Check arm_ext_v8r feature. include * opcode/arm.h (ARM_EXT2_V8R): Define. Modified ARM_AEXT2_V8R.
2020-05-19or1k: Regenerate opcodes after removing 32-bit supportStafford Horne9-1648/+1195
opcodes/ChangeLog: yyyy-mm-dd Stafford Horne <shorne@gmail.com> PR 25184 * or1k-asm.c: Regenerate. * or1k-desc.c: Regenerate. * or1k-desc.h: Regenerate. * or1k-dis.c: Regenerate. * or1k-ibld.c: Regenerate. * or1k-opc.c: Regenerate. * or1k-opc.h: Regenerate. * or1k-opinst.c: Regenerate.
2020-05-19or1k: Remove 64-bit support, it's not used and it breaks 32-bit hostsStafford Horne4-110/+16
Reported by Rich Felker when building on 32-bit hosts. Backwards jump negative offsets were not calculated correctly due to improper 32-bit to 64-bit zero-extension. The 64-bit fields are present because we are mixing 32-bit and 64-bit architectures in our cpu descriptions. Removing 64-bit fixes the issue. We don't use 64-bit, there is an architecture spec for 64-bit but no implementations or simulators. My thought is if we need them in the future we should do the proper work to support both 32-bit and 64-bit implementations co-existing then. cpu/ChangeLog: yyyy-mm-dd Stafford Horne <shorne@gmail.com> PR 25184 * or1k.cpu (arch or1k): Remove or64 and or64nd machs. (ORBIS-MACHS, ORFPX32-MACHS): Remove pmacros. (cpu or1k64bf, mach or64, mach or64nd): Remove definitions. * or1kcommon.cpu (h-fdr): Remove hardware. * or1korfpx.cpu (rDDF, rADF, rBDF): Remove operand definitions. (float-regreg-insn): Remove lf- mnemonic -d instruction pattern. (float-setflag-insn-base): Remove lf-sf mnemonic -d pattern. (float-cust-insn): Remove "lf-cust" cust-num "-d" pattern. (lf-rem-d, lf-itof-d, lf-ftoi-d, lf-madd-d): Remove.
2020-05-19[PATCH v3] aarch64: Emit jump slot for conditional branch to undefined symbolsSiddhesh Poyarekar6-4/+44
The linker silently writes out a conditional branch to 0 if the target symbol in R_AARCH64_CONDBR19 or R_AARCH64_TSTBR14 relocations is undefined. Emit a PLT instead so that behaviour is the same for these relocations as the llvm linker. The special behaviour for undefined weak symbols, where conditional branches to such symbols result in a branch unto themselves, has been retained. This is because the weak-undefined.s test explicitly checks for that, leading me to conclude that it's expected behaviour. bfd * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Club BFD_RELOC_AARCH64_BRANCH19 and BFD_RELOC_AARCH64_TSTBR14 cases with BFD_RELOC_AARCH64_JUMP26. (elfNN_aarch64_check_relocs): Likewise. ld * testsuite/ld-aarch64/aarch64-elf.exp: New test emit-relocs-560. * testsuite/ld-aarch64/emit-relocs-560.d: New file. * testsuite/ld-aarch64/emit-relocs-560.s: New file.
2020-05-19Use bfd_get_filename throughout ldAlan Modra10-55/+80
* emultempl/beos.em (sort_by_file_name): Use bfd_get_filename rather than accessing bfd->filename directly. * emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Likewise. * emultempl/pep.em (gld_${EMULATION_NAME}_after_open): Likewise. * emultempl/spuelf.em (embedded_spu_file): Likewise. * ldlang.c (input_statement_is_archive_path, wild_sort), (check_excluded_libs): Likewise. * ldmain.c (add_archive_element): Likewise. * ldmisc.c (vfinfo): Likewise. * pe-dll.c (auto_export, generate_edata, pe_create_import_fixup), (pe_dll_generate_implib, pe_process_import_defs): Likewise. * plugin.c (plugin_object_p): Likewise.
2020-05-19Use bfd_get_filename throughout gasAlan Modra2-6/+16
* write.c (write_contents): Use bfd_get_filename rather than accessing bfd->filename directly. Use bfd_section_name rather than accessing section->name directly.
2020-05-19Use bfd_get_filename throughout binutilsAlan Modra5-16/+26
* ar.c (map_over_members, get_pos_bfd, delete_members, move_members), (replace_members): Use bfd_get_filename rather than accessing bfd->filename directly. * arsup.c (map_over_list, ar_delete, ar_replace, ar_extract): Likewise. * binemul.c (do_ar_emul_append): Likewise. * coffgrok.c (coff_grok): Likewise.
2020-05-19Use bfd_get_filename throughout bfdAlan Modra28-106/+158
* aix5ppc-core.c (xcoff64_core_file_matches_executable_p): Use bfd_get_filename rather than accessing bfd->filename directly. * aout-target.h (MY (object_p)): Likewise. * aoutx.h (aout_find_nearest_line, aout_link_write_symbols): Likewise. * archive.c (find_nested_archive, _bfd_generic_read_ar_hdr_mag), (_bfd_construct_extended_name_table, _bfd_bsd44_write_ar_hdr), (_bfd_archive_bsd44_construct_extended_name_table), (_bfd_write_archive_contents, _bfd_compute_and_write_armap), (_bfd_bsd_write_armap): Likewise. * bfd.c (bfd_errmsg, _bfd_doprnt): Likewise. * cache.c (bfd_open_file): Likewise. * ecoff.c (_bfd_ecoff_write_armap): Likewise. * ecofflink.c (bfd_ecoff_debug_accumulate_other): Likewise. * elf32-bfin.c (bfinfdpic_relocate_section): Likewise. * elf32-frv.c (elf32_frv_relocate_section): Likewise. * elf32-hppa.c (elf32_hppa_final_link): Likewise. * elf32-nds32.c (nds32_elf_output_symbol_hook), (patch_tls_desc_to_ie): Likewise. * elf32-spu.c (sort_bfds, print_one_overlay_section), (spu_elf_auto_overlay): Likewise. * elf64-hppa.c (elf_hppa_final_link): Likewise. * elf64-ia64-vms.c (elf64_ia64_size_dynamic_sections): Likewise. * elfcore.h (elf_core_file_matches_executable_p): Likewise. * elflink.c (bfd_elf_size_dynamic_sections), (elf_link_input_bfd): Likewise. * linker.c (_bfd_generic_link_output_symbols): Likewise. * mach-o.c (bfd_mach_o_follow_dsym), (bfd_mach_o_close_and_cleanup): Likewise. * opncls.c (_bfd_delete_bfd, _maybe_make_executable), (find_separate_debug_file, get_build_id_name): Likewise. * pdp11.c (aout_find_nearest_line, aout_link_write_symbols): Likewise. * plugin.c (bfd_plugin_open_input): Likewise. * rs6000-core.c (rs6000coff_core_file_matches_executable_p): Likewise. * som.c (som_write_armap): Likewise. * srec.c (srec_write_record, srec_write_symbols): Likewise. * vms-lib.c (_bfd_vms_lib_get_imagelib_file), (_bfd_vms_lib_write_archive_contents): Likewise. * xcofflink.c (xcoff_link_add_dynamic_symbols): Likewise.
2020-05-19Clear all local_symbol.lsy_flagsAlan Modra2-2/+6
* symbols.c (local_symbol_make): Init all of lsy_flags.
2020-05-19win32 typo fixAlan Modra2-1/+6
PR 25713 * bfdio.c (_bfd_real_fopen): Typo fix.
2020-05-19Automatic date update in version.inGDB Administrator1-1/+1
2020-05-18Avoid short i386 register names on Solaris/x86 [PR25981]Rainer Orth2-4/+20
This is the 32-bit companion to Remove unused ps_lgetLDT etc. on Solaris/x86 [PR25981] https://sourceware.org/pipermail/gdb-patches/2020-May/168713.html A 32-bit-default gdb fails to compile with the updated <sys/regset.h>. While it is also affected by the lack of a GS definition, which the compantion patch above fixes, it also fails to compile i386-sol2-nat.c like this /vol/src/gnu/gdb/hg/master/git/gdb/i386-sol2-nat.c:181:3: error: 'EAX' was not declared in this scope 181 | EAX, ECX, EDX, EBX, | ^~~ and several more. While this could be fixed by either including <ucontext.h> here or provding fallback definitions of the register macros, I chose to do what the 64-bit-default code in the same file (amd64_sol2_gregset32_reg_offset[]) does, namely just hardcode the numeric values instead. They are part of the ABI and thus guaranteed not to change. With this patch, a i386-pc-solaris2.11 configuration on master compiles again, however, it doesn't work. However, I could successfully test it on the gdb-9 branch. Compiling and testing proved to be messy, unfortunately: * For one, Solaris <sys/procfs.h> and largefile support used to be mutually exclusive (fixed in Solaris 11.4 and Illumos), which was exacerbated by the fact that g++ predefines _FILE_OFFSET_BITS=64 since GCC 9.1.0. For now I've worked around this by adding -U_FILE_OFFSET_BITS to CXXFLAGS and configuring with --disable-largefile. I hope to clean this up in a future patch. * gdb still defaults to startup-with-shell on. However, /bin/bash is a 64-bit executable which cannot be debugged by a 32-bit gdb. I hacked around that part by pointing $SHELL at a 32-bit bash before running make check. PR build/25981 * i386-sol2-nat.c [PR_MODEL_NATIVE != PR_MODEL_LP64] (regmap): Hardcode register numbers.
2020-05-18Remove unused ps_lgetLDT etc. on Solaris/x86 [PR25981]Rainer Orth4-117/+10
As reported in PR build/25981, a future Solaris 11.4 update will soon remove the short i386 register names like SS etc. from <sys/regset.h>. They could leak into user code (e.g. via <signal.h> -> <sys/signal.h> -> <sys/ucontext.h>) and pollute the user namespace. Affected code would have a hard time avoiding the issue: LLVM is one of those. While the short names are required to be present by the i386 psABI, that document only demands that they exist in <ucontext.h>, which is what the upcoming update assures. With this change, in a 64-bit-default configuration, procfs.c fails to compile on Solaris/x86: /vol/src/gnu/gdb/hg/master/git/gdb/procfs.c: In function 'ssd* procfs_find_LDT_entry(ptid_t)': /vol/src/gnu/gdb/hg/master/git/gdb/procfs.c:1643:18: error: 'GS' was not declared in this scope 1643 | key = (*gregs)[GS] & 0xffff; | ^~ make[2]: *** [Makefile:1607: procfs.o] Error 1 Initially I meant to provide a definition using the planned replacement macro, but closer inspection revealed a better way. procfs_find_LDT_entry and its helper proc_get_LDT_entry are only used to implement ps_lgetLDT, one of the callback functions required by libthread_db.so.1 (cf. <proc_service.h>). While that function is still documented as being required even in Solaris 11.4, I found that calls to it had been removed long ago in Solaris 9, so just removing the three functions above is the easiest fix. The following patch does just that. It compiled successfully on amd64-pc-solaris2.11, however, as reported in PR gdb/25939, master is completely broken on Solaris since the multi-target patch. The patch applies cleanly to the gdb-9 branch and there I could test it successfully. PR build/25981 * procfs.c [(__i386__ || __x86_64__) && sun] (proc_get_LDT_entry, procfs_find_LDT_entry): Remove. * procfs.h [(__i386__ || __x86_64__) && sun] (struct ssd, procfs_find_LDT_entry): Remove. * sol-thread.c [(__i386__ || __x86_64__) && sun] (ps_lgetLDT): Remove.
2020-05-18Fix a use-after-free bug in the BFD library when scanning a corrupt ELF file.Nick Clifton2-2/+13
PR 26005 * elf.c (bfd_section_from_shdr): Use bfd_malloc to allocate memory for the sections_being_created array.
2020-05-18[gdb/testsuite] Use with_test_prefix in gdb.base/gdb-caching-proc.expTom de Vries2-18/+28
When running test-case gdb.base/gdb-caching-proc.exp all passes are unique, but fails might not be. Fix this by using with_test_prefix. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-18 Tom de Vries <tdevries@suse.de> * gdb.base/gdb-caching-proc.exp: Use with_test_prefix.
2020-05-18Show AIX gc'd symbol address adjustments in map fileDouglas B Rupp16-16/+100
* ldemul.h (ldemul_print_symbol): New. (ld_emulation_xfer_type) <print_symbol): Likewise. * ldemul.c (ldemul_print_symbol): New. * ldlang.c (SECTION_NAME_MAP_LANGTH): Move to ... (print_one_symbol): Make global and move declaration to ... (print_all_symbols): Rename print_one_symbol to ldemul_print_symbol (print_input_section): Likewise * ldlang.h: ... here. * emultempl/aix.em (gld${EMULATION_NAME}_print_symbol): New. (ld_emulation_xfer_struct): Use it. * emultempl/armcoff.em (ld_emulation_xfer_struct): Add print_symbol and default to NULL. * emultempl/beos.em (ld_emulation_xfer_struct): Likewise * emultempl/elf.em (ld_emulation_xfer_struct): Likewise * emultempl/generic.em (ld_emulation_xfer_struct): Likewise * emultempl/linux.em (ld_emulation_xfer_struct): Likewise * emultempl/msp430.em (ld_emulation_xfer_struct): Likewise * emultempl/pe.em (ld_emulation_xfer_struct): Likewise * emultempl/pep.em (ld_emulation_xfer_struct): Likewise * emultempl/ticoff.em (ld_emulation_xfer_struct): Likewise * emultempl/vanilla.em (ld_emulation_xfer_struct): Likewise
2020-05-18[PATCH] ld: fix s/claimi/claim/ typoSergei Trofimovich2-1/+6
* ldmain.c (add_archive_element): Fix s/claimi/claim/ typo in info message.
2020-05-18Updated translations for the gprof and ld sub-directoriesNick Clifton4-1274/+5106
2020-05-18ECOFF slurp_relocs thinkoAlan Modra2-3/+8
In git commit 806470a219 I swapped the order of internal vs. external relocs memory allocation in ecoff_slurp_reloc_table, the idea being that the external reloc size can be sanity checked against file size. However, that fails badly with bfd_alloc memory where releasing any block also releases all more recently allocated blocks. * ecoff.c (ecoff_slurp_reloc_table): Malloc external_relocs so they can be freed without also freeing internal_relocs.
2020-05-18Fix the BFD library to handle Windows pathnames with more than 260 ↵Jaydeep Chauhan2-2/+17
characters and UNIX style directory separators. PR 25713 * bfdio.c (_bfd_real_fopen): Convert UNIX style sirectory separators into DOS style when creating a WIN32 fullpath.
2020-05-18Prevent a potential use-after-fee memory corruption bug in the linker (for ↵Nick Clifton3-12/+46
PE format files). PR 25993 * emultempl/pe.em (_after_open): Check for duplicate filename pointers before renaming the dll. * emultempl/pep.em (_after_open): Likewise.
2020-05-18Re: Fix tight loop on recursively-defined symbolsAlan Modra2-0/+6
sy_resolving ought to not be set for a struct local_symbol, but it is apparent from local_symbol_make that the field is not initialised. * symbols.c (resolve_symbol_value): Invoke LOCAL_SYMBOL_CHECK before looking at add_symbol->sy_flags.sy_resolving.
2020-05-18Don't handle lret/iret when -mlfence-before-ret=[or|not|shl|yes] since they ↵liuhongt14-182/+22
are invalid in SGX enclaves. gas/ChangeLog * gas/config/tc-i386.c: Not handle lret/iret. * gas/testsuite/gas/i386/lfence-ret-a.d: Adjust testcase. * gas/testsuite/gas/i386/lfence-ret-b.d: Ditto. * gas/testsuite/gas/i386/lfence-ret-c.d: Ditto. * gas/testsuite/gas/i386/lfence-ret-d.d: Ditto. * gas/testsuite/gas/i386/lfence-ret.s: Ditto. * gas/testsuite/gas/i386/x86-64-lfence-ret-a.d: Ditto. * gas/testsuite/gas/i386/x86-64-lfence-ret-b.d: Ditto. * gas/testsuite/gas/i386/x86-64-lfence-ret-c.d: Ditto. * gas/testsuite/gas/i386/x86-64-lfence-ret-d.d: Ditto. * gas/testsuite/gas/i386/x86-64-lfence-ret-e.d: Ditto. * gas/testsuite/gas/i386/x86-64-lfence-ret.s: Ditto. * gas/testsuite/gas/i386/x86-64-lfence-ret.e: Deleted.
2020-05-18Automatic date update in version.inGDB Administrator1-1/+1
2020-05-18binutils: Add myself as maintainer for OpenRISCStafford Horne2-0/+5
binutils/ChangeLog: yyyy-mm-dd Stafford Horne <shorne@gmail.com> * MAINTAINERS (OR1K): Add myself as maintainer.
2020-05-17Stop considering hw and sw breakpoint locations duplicates (PR gdb/25741)Pedro Alves4-86/+267
In the following conditions: - A target with hardware breakpoints available, and - A target that uses software single stepping, - An instruction at ADDRESS loops back to itself, Now consider the following steps: 1. The user places a hardware breakpoint at ADDRESS (an instruction that loops to itself), 2. The inferior runs and hits the breakpoint at ADDRESS, 3. The user tells GDB to 'continue'. In #3 when the user tells GDB to continue, GDB first disables the hardware breakpoint at ADDRESS, and then inserts a software single-step breakpoint at ADDRESS. The original user-created breakpoint was a hardware breakpoint, while the single-step breakpoint will be a software breakpoint. GDB continues and immediately hits the software single-step breakpoint. GDB then deletes the software single-step breakpoint by calling delete_single_step_breakpoints, which eventually calls delete_breakpoint, which, once the breakpoint (and its locations) are deleted, calls update_global_location_list. During update_global_location_list GDB spots that we have an old location (the software single step breakpoint location) that is inserted, but being deleted, and a location (the original hardware breakpoint) at the same address which we are keeping, but which is not currently inserted, GDB then calls breakpoint_locations_match on these two locations. Currently the locations do match, and so GDB calls swap_insertion which swaps the "inserted" state of the two locations. The user created hardware breakpoint is marked as inserted, while the GDB internal software single step breakpoint is now marked as not inserted. After this GDB returns through the call stack and leaves delete_single_step_breakpoints. After this GDB continues with its normal "stopping" process, as part of this stopping process GDB removes all the breakpoints from the target. Due to the swap it is now the user-created hardware breakpoint that is marked as inserted, so it is this breakpoint GDB tries to remove. The problem is that GDB inserted the software single-step breakpoint as a software breakpoint, but is now trying to remove the hardware breakpoint. The problem is removing a software breakpoint is very different to removing a hardware breakpoint, this could result is some undetected undefined behaviour, or as in the original bug report (PR gdb/25741), could result in the target throwing an error. With "set breakpoint always-inserted on", we can easily reproduce this against GDBserver. E.g.: (gdb) hbreak main Sending packet: $m400700,40#28...Packet received: 89e58b.... Sending packet: $m400736,1#fe...Packet received: 48 Hardware assisted breakpoint 1 at 0x400736: file threads.c, line 57. Sending packet: $Z1,400736,1#48...Packet received: OK Packet Z1 (hardware-breakpoint) is supported (gdb) b main Note: breakpoint 1 also set at pc 0x400736. Sending packet: $m400736,1#fe...Packet received: 48 Breakpoint 2 at 0x400736: file threads.c, line 57. (gdb) del Delete all breakpoints? (y or n) y Sending packet: $z0,400736,1#67...Packet received: E01 warning: Error removing breakpoint 2 This patch adds a testcase that does exactly that. Trying to enhance GDB to handle this scenario while continuing to avoid inserting redundant software and hardware breakpoints at the same address turns out futile, because, given non-stop and breakpoints always-inserted, if the user: #1 - inserts a hw breakpoint, then #2 - inserts a sw breakpoint at the same address, and then #3 - removes the original hw breakpoint, GDB would have to make sure to insert the sw breakpoint before removing the hw breakpoint, to avoid running threads missing the breakpoint. I.e., there's always going to be a window where a target needs to be able to handle both sw and a hw breakpoints installed at the same address. You can see more detailed description of that issue here: https://sourceware.org/pipermail/gdb-patches/2020-April/167738.html So the fix here is to just stop considering software breakpoints and hw breakpoints duplicates, and let GDB insert sw and hw breakpoints at the same address. The central change is to make breakpoint_locations_match consider the location's type too. There are several other changes necessary to actually make that that work correctly, however: - We need to handle the duplicates detection better. Take a look at the loop at the tail end of update_global_location_list. Currently, because breakpoint locations aren't sorted by type, we can end up with, at the same address, a sw break, then a hw break, then a sw break, etc. The result is that that second sw break won't be considered a duplicate of the first sw break. Seems like we already handle that incorrectly for range breakpoints. - The "set breakpoint auto-hw on" handling is moved out of insert_bp_location to update_global_location_list, before the duplicates determination. Moving "set breakpoint auto-hw off" handling as well and downgrading it to a warning+'disabling the location' was considered too, but in the end discarded, because we want to error out with internal and momentary breakpoints, like software single-step breakpoints. Disabling such locations at update_global_location_list time would make GDB lose control of the inferior. - In update_breakpoint_locations, the logic of matching old locations with new locations, in the have_ambiguous_names case, is updated to still consider sw vs hw locations the same. - Review all ALL_BP_LOCATIONS_AT_ADDR uses, and update those that might need to be updated, and update comments for those that don't. Note that that macro walks all locations at a given address, and doesn't call breakpoint_locations_match. The result against GDBserver (with "set breakpoint condition-evaluation host" to avoid seeing confusing reinsertions) is: (gdb) hbreak main Sending packet: $m400736,1#fe...Packet received: 48 Hardware assisted breakpoint 1 at 0x400736: file main.c, line 57. Sending packet: $Z1,400736,1#48...Packet received: OK (gdb) b main Note: breakpoint 1 also set at pc 0x400736. Sending packet: $m400736,1#fe...Packet received: 48 Breakpoint 4 at 0x400736: file main.c, line 57. Sending packet: $Z0,400736,1#47...Packet received: OK (gdb) del 3 Sending packet: $z1,400736,1#68...Packet received: OK gdb/ChangeLog: 2020-05-17 Pedro Alves <palves@redhat.com> Andrew Burgess <andrew.burgess@embecosm.com> Keno Fischer <keno@juliacomputing.com> PR gdb/25741 * breakpoint.c (build_target_condition_list): Update comments. (build_target_command_list): Update comments and skip matching locations. (insert_bp_location): Move "set breakpoint auto-hw on" handling to a separate function. Simplify "set breakpoint auto-hw off" handling. (insert_breakpoints): Update comment. (tracepoint_locations_match): New parameter. For breakpoints, compare location types too, if the caller wants to. (handle_automatic_hardware_breakpoints): New functions. (bp_location_is_less_than): Also sort by location type and hardware breakpoint length. (update_global_location_list): Handle "set breakpoint auto-hw on" here. (update_breakpoint_locations): Ask breakpoint_locations_match to ignore location types. gdb/testsuite/ChangeLog: 2020-05-17 Pedro Alves <palves@redhat.com> PR gdb/25741 * gdb.base/hw-sw-break-same-address.exp: New file.
2020-05-17Automatic date update in version.inGDB Administrator1-1/+1
2020-05-16Fix gdb.multi/multi-re-run.exp with native-gdbserverPedro Alves2-0/+12
The new exec-file-mismatch feature reveals that when running gdb.multi/multi-re-run.exp against --target_board=native-gdbserver, we've been starting gdbserver with the wrong program: (gdb) spawn /home/pedro/brno/pedro/gdb/binutils-gdb/build/gdb/testsuite/../../gdbserver/gdbserver --once localhost:2347 /home/pedro/brno/pedro/gdb/binutils-gdb/build/gdb/te stsuite/outputs/gdb.multi/multi-re-run/multi-re-run-2 Process /home/pedro/brno/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.multi/multi-re-run/multi-re-run-2 created; pid = 6280 Listening on port 2347 target remote localhost:2347 Remote debugging using localhost:2347 warning: Mismatch between current exec-file /home/pedro/brno/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.multi/multi-re-run/multi-re-run-1 and automatically determined exec-file /home/pedro/brno/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.multi/multi-re-run/multi-re-run-2 exec-file-mismatch handling is currently "ask" Load new symbol table from "/home/pedro/brno/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.multi/multi-re-run/multi-re-run-2"? (y or n) Quit (gdb) FAIL: gdb.multi/multi-re-run.exp: re_run_inf=1: iter=1: running to all_started in runto The problem is that gdb_reload uses the last loaded file as binary to spawn, but we load the program for inferior 2 and then switch to inferior 1 and run it, so the last loaded file is the program for inferior 2. Fix this by tweaking last_loaded_file. gdb/testsuite/ChangeLog: 2020-05-16 Pedro Alves <palves@redhat.com> * gdb.multi/multi-re-run.exp (test_re_run): Switch LAST_LOADED_FILE accordingly.
2020-05-16gdb: remove TYPE_NAME macroSimon Marchi46-331/+334
Remove `TYPE_NAME`, changing all the call sites to use `type::name` directly. This is quite a big diff, but this was mostly done using sed and coccinelle. A few call sites were done by hand. gdb/ChangeLog: * gdbtypes.h (TYPE_NAME): Remove. Change all cal sites to use type::name instead.
2020-05-16gdb: add type::name / type::set_nameSimon Marchi21-99/+114
Add the `name` and `set_name` methods on `struct type`, in order to remove the `TYPE_NAME` macro. In this patch, the `TYPE_NAME` macro is changed to use `type::name`, so all the call sites that are used to set the type name are changed to use `type::set_name`. The next patch will remove `TYPE_NAME` completely. gdb/ChangeLog: * gdbtypes.h (struct type) <name, set_name>: New methods. (TYPE_CODE): Use type::name. Change all call sites used to set the name to use type::set_name instead.
2020-05-16Remove ALL_UISTom Tromey4-7/+16
Continuing my goal of removing the "ALL_*" iterator macros, this removes ALL_UIS, replacing it with an iterator adaptor. gdb/ChangeLog 2020-05-16 Tom Tromey <tom@tromey.com> * top.c (quit_force): Update. * infrun.c (handle_no_resumed): Update. * top.h (all_uis): New function. (ALL_UIS): Remove.
2020-05-16gdb: fix -Wtautological-overlap-compare warning in mips-linux-tdep.cSimon Marchi2-4/+6
When building with clang 11, I get: CXX mips-linux-tdep.o /home/smarchi/src/binutils-gdb/gdb/mips-linux-tdep.c:643:30: error: overlapping comparisons always evaluate to true [-Werror,-Wtautological-overlap-compare] if (insn != 0x03e07821 || insn != 0x03e07825) ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ /home/smarchi/src/binutils-gdb/gdb/mips-linux-tdep.c:636:30: error: overlapping comparisons always evaluate to true [-Werror,-Wtautological-overlap-compare] if (insn != 0x03e0782d || insn != 0x03e07825) ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ Indeed, given two different values, `insn` will always be different to one of them, and these conditions always be true. This code is meant to return if `insn` isn't one of these two values, so the `||` should be replaced with `&&`. gdb/ChangeLog: * mips-linux-tdep.c (mips_linux_in_dynsym_stub): Fix condition.
2020-05-16Sync config with GCCH.J. Lu2-1/+17
Sync with GCC 2020-05-15 H.J. Lu <hongjiu.lu@intel.com> PR bootstrap/95147 * cet.m4 (GCC_CET_FLAGS): Also check if -fcf-protection works when defaulting to auto. 2020-05-14 H.J. Lu <hongjiu.lu@intel.com> * cet.m4 (GCC_CET_FLAGS): Change default to auto.
2020-05-16Fix IA64 GNU/Linux buildPedro Alves2-3/+12
This commit should fix: ../../gdb/ia64-linux-nat.c: In function ‘void enable_watchpoints_in_psr(ptid_t)’: ../../gdb/ia64-linux-nat.c:535:56: error: no matching function for call to ‘get_thread_regcache(ptid_t&)’ struct regcache *regcache = get_thread_regcache (ptid); ^ In file included from ../../gdb/ia64-linux-nat.c:25:0: ../../gdb/regcache.h:35:25: note: candidate: regcache* get_thread_regcache(process_stratum_target*, ptid_t) extern struct regcache *get_thread_regcache (process_stratum_target *target, ^ ../../gdb/regcache.h:35:25: note: candidate expects 2 arguments, 1 provided ../../gdb/regcache.h:39:25: note: candidate: regcache* get_thread_regcache(thread_info*) extern struct regcache *get_thread_regcache (thread_info *thread); ^ ../../gdb/regcache.h:39:25: note: no known conversion for argument 1 from ‘ptid_t’ to ‘thread_info*’ gdb/ChangeLog: 2020-05-16 Pedro Alves <palves@redhat.com> * ia64-linux-nat.c (ia64_linux_nat_target) <enable_watchpoints_in_psr(ptid_t)>: Declare method. (enable_watchpoints_in_psr): Now a method of ia64_linux_nat_target.
2020-05-16gdbserver/linux-ia64-low: fix a build-breaking typoTankut Baris Aktemur2-4/+10
During the gdbserver c++'ification refactoring, I apparently made a typo that broke build in ia64 targets. gdbserver/ChangeLog: 2020-05-16 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * linux-ia64-low.cc (ia64_target::sw_breakpoint_from_kind): Fix incorrect 'gdb_assert_no_reached' to 'gdb_assert_not_reached'. (ia64_target::low_breakpoint_at): Ditto.
2020-05-15gdb: remove unnecessary struct typedef in sparc64-tdep.cSimon Marchi2-4/+9
When building with clang 11, I get: CXX sparc64-tdep.o /home/smarchi/src/binutils-gdb/gdb/sparc64-tdep.c:89:15: error: anonymous non-C-compatible type given name for linkage purposes by typedef declaration; add a tag name here [-Werror,-Wnon-c-typedef-for-linkage] typedef struct ^ adi_stat_t /home/smarchi/src/binutils-gdb/gdb/sparc64-tdep.c:103:16: note: type is not C-compatible due to this default member initializer int tag_fd = 0; ^ /home/smarchi/src/binutils-gdb/gdb/sparc64-tdep.c:111:3: note: type is given name 'adi_stat_t' for linkage purposes by this typedef declaration } adi_stat_t; ^ The typedef is not needed in C++ anyway, just remove them. gdb/ChangeLog: * sparc64-tdep.c (adi_stat_t): Remove typedef (leaving struct). (sparc64_adi_info): Likewise.
2020-05-16Automatic date update in version.inGDB Administrator1-1/+1
2020-05-15Remove lookup_objfile_from_blockTom Tromey5-41/+41
lookup_objfile_from_block mostly duplicates the functionality of block_objfile, but in a less efficient way. This patch removes this function and changes the callers to use block_objfile instead. Tested by the buildbot. gdb/ChangeLog 2020-05-15 Tom Tromey <tom@tromey.com> * symtab.c (lookup_language_this, lookup_symbol_aux): Use block_objfile. (lookup_objfile_from_block): Remove. (lookup_symbol_in_block, lookup_symbol_in_static_block) (lookup_global_symbol): Use block_objfile. * symtab.h (lookup_objfile_from_block): Don't declare. * printcmd.c (clear_dangling_display_expressions): Use block_objfile. * parse.c (operator_check_standard): Use block_objfile.
2020-05-15Remove allocate_symbol et alTom Tromey11-71/+52
This removes allocate_symbol, allocate_template_symbol, and initialize_objfile_symbol in favor of changing the default values for symbol members, and updating the one per-arch caller. gdb/ChangeLog 2020-05-15 Tom Tromey <tom@tromey.com> * language.c (language_alloc_type_symbol): Set SYMBOL_SECTION. * symtab.c (initialize_objfile_symbol): Remove. (allocate_symbol): Remove. (allocate_template_symbol): Remove. * dwarf2/read.c (fixup_go_packaging): Use "new". (new_symbol): Use "new". (read_variable): Don't call initialize_objfile_symbol. Use "new". (read_func_scope): Use "new". * xcoffread.c (process_xcoff_symbol): Don't call initialize_objfile_symbol. (SYMBOL_DUP): Remove. * coffread.c (process_coff_symbol, coff_read_enum_type): Use "new". * symtab.h (allocate_symbol, initialize_objfile_symbol) (allocate_template_symbol): Don't declare. (struct symbol): Add copy constructor. Change defaults. * jit.c (finalize_symtab): Use "new". * ctfread.c (ctf_add_enum_member_cb, new_symbol, ctf_add_var_cb): Use "new". * stabsread.c (patch_block_stabs, define_symbol, read_enum_type) (common_block_end): Use "new". * mdebugread.c (parse_symbol): Use "new". (new_symbol): Likewise.
2020-05-15Update NEWS and documentation for help and apropos changes.Philippe Waroquiers4-10/+29
gdb/ChangeLog 2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS: Mention changes to help and apropos. gdb/doc/ChangeLog 2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Help): Document the help and apropos changes. (Aliases): Document new meaning of -a abbreviation flag.
2020-05-15Ensure class_alias is only used for user-defined aliases.Philippe Waroquiers11-32/+81
This commit finally does the (small) change that started this patch series. It ensures that the class_alias is only used for user-defined aliases. So, the few GDB pre-defined aliases that were using the 'class_alias' class are now using a real help class, typically the class of the aliased command. gdb/ChangeLog 2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be> * command.h (enum command_class): Improve comments, document that class_alias is for user-defined aliases, give the class name for each class, remove unused class_xdb. * cli/cli-decode.c (add_com_alias): Document THECLASS intended usage. * breakpoint.c (_initialize_breakpoint): Replace class_alias by a precise class. * infcmd.c (_initialize_infcmd): Likewise. * reverse.c (_initialize_reverse): Likewise. * stack.c (_initialize_stack): Likewise. * symfile.c (_initialize_symfile): Likewise. * tracepoint.c (_initialize_tracepoint): Likewise. gdb/testsuite/ChangeLog 2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/alias.exp: Verify 'help aliases' shows user defined aliases.
2020-05-15Fix/improve 'apropos' outputPhilippe Waroquiers4-30/+71
Similarly to 'help CLASS', apropos possibly shows several times the same help (for the command and for each of its aliases). This patch changes 'apropos' so that the help for a command and all its aliases is shown once. So, apropos_cmd now skips all aliases/abbreviations, as these are printed as part of the help of the aliased command. When 'apropos' prints the help of a command, function 'help_cmd' now unconditionally print the command name and its possible aliases (as we must indicate to the user the command/aliases for which the help is printed). When 'help somecommand' prints the help of a command, if the command is not aliased, the command name is not printed (to avoid a useless first line), but if it has aliases, then the command name and all its aliases are now printed. In addition to provide to the user the choice of the best way to type a command, it also avoids the strange behaviour that the output of 'help somealias' does not mention somealias. gdb/ChangeLog 2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be> * cli/cli-decode.c (apropos_cmd): Produce output for aliases when their aliased command is traversed. (help_cmd): Add fput_command_names_styled call to output command name and aliases when command has an alias. gdb/testsuite/ChangeLog 2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/help.exp: Test apropos and help for commands having aliases. Fixed comments not starting with an upper-case letter or not finishing with a dot.