aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2021-10-24asan: c4x, c54x coff_canonicalize_reloc buffer overflowAlan Modra6-17/+44
Sometimes the investigation of a fuzzing bug report leads into areas you'd rather not go. In this instance by the time I'd figured out the real cause was a target variant that had never been properly supported in binutils, the time needed to fix it was less than the time needed to rip it out. * coffcode.h (coff_set_alignment_hook): Call bfd_coff_swap_reloc_in not coff_swap_reloc_in. (coff_slurp_reloc_table): Likewise. Don't use RELOC type. (ticoff0_swap_table): Use coff_swap_reloc_v0_out and coff_swap_reloc_v0_in. * coffswap.h (coff_swap_reloc_v0_in, coff_swap_reloc_v0_out): New. * coff-tic54x.c (tic54x_lookup_howto): Don't abort. * coffgen.c (coff_get_normalized_symtab): Use PTR_ADD. * bfd-in.h (PTR_ADD, NPTR_ADD): Avoid warnings when passing an expression. * bfd-in2.h: Regenerate.
2021-10-24asan: arm-darwin: buffer overflowAlan Modra1-18/+21
PR 21813 * mach-o-arm.c (bfd_mach_o_arm_canonicalize_one_reloc): Sanity check PAIR reloc in other branch of condition as was done for PR21813. Formatting. Delete debug printf.
2021-10-24asan: aout: heap buffer overflowAlan Modra2-6/+4
* aoutx.h (aout_get_external_symbols): Sanity check before writing zero index entry. Remove outdated comment. * pdp11.c (aout_get_external_symbols): Likewise.
2021-10-24LoongArch ld supportliuzhensong22-1/+1146
2021-10-22 Chenghua Xu <xuchenghua@loongson.cn> Zhensong Liu <liuzhensong@loongson.cn> Weinan Liu <liuweinan@loongson.cn> Xiaolin Tang <tangxiaolin@loongson.cn> ld/ * Makefile.am: Add LoongArch. * NEWS: Mention LoongArch support. * configure.tgt: Add LoongArch. * emulparams/elf32loongarch-defs.sh: New. * emulparams/elf32loongarch.sh: Likewise. * emulparams/elf64loongarch-defs.sh: Likewise. * emulparams/elf64loongarch.sh: Likewise. * emultempl/loongarchelf.em: Likewise. * Makefile.in: Regenerate. * po/BLD-POTFILES.in: Regenerate. ld/testsuite/ * ld-loongarch-elf/disas-jirl.d: New. * ld-loongarch-elf/disas-jirl.s: Likewise. * ld-loongarch-elf/jmp_op.d: Likewise. * ld-loongarch-elf/jmp_op.s: Likewise. * ld-loongarch-elf/ld-loongarch-elf.exp: Likewise. * ld-loongarch-elf/macro_op.d: Likewise. * ld-loongarch-elf/macro_op.s: Likewise. * ld-loongarch-elf/syscall-0.s: Likewise. * ld-loongarch-elf/syscall-1.s: Likewise. * ld-loongarch-elf/syscall.d: Likewise. * ld-srec/srec.exp: Add LoongArch. * ld-unique/pr21529.d: Likewise.
2021-10-24LoongArch gas supportliuzhensong39-5/+4152
2021-10-22 Chenghua Xu <xuchenghua@loongson.cn> Zhensong Liu <liuzhensong@loongson.cn> Weinan Liu <liuweinan@loongson.cn> Xiaolin Tang <tangxiaolin@loongson.cn> gas/ * Makefile.am: Add LoongArch. * NEWS: Mention LoongArch support. * config/loongarch-lex-wrapper.c: New. * config/loongarch-lex.h: New. * config/loongarch-lex.l: New. * config/loongarch-parse.y: New. * config/tc-loongarch.c: New. * config/tc-loongarch.h: New. * configure.ac: Add LoongArch. * configure.tgt: Likewise. * doc/as.texi: Likewise. * doc/c-loongarch.texi: Likewise. * Makefile.in: Regenerate. * configure: Regenerate. * po/POTFILES.in: Regenerate. gas/testsuite/ * gas/all/gas.exp: Add LoongArch. * gas/elf/elf.exp: Likewise. * gas/loongarch/4opt_op.d: New. * gas/loongarch/4opt_op.s: Likewise. * gas/loongarch/fix_op.d: Likewise. * gas/loongarch/fix_op.s: Likewise. * gas/loongarch/float_op.d: Likewise. * gas/loongarch/float_op.s: Likewise. * gas/loongarch/imm_op.d: Likewise. * gas/loongarch/imm_op.s: Likewise. * gas/loongarch/jmp_op.d: Likewise. * gas/loongarch/jmp_op.s: Likewise. * gas/loongarch/load_store_op.d: Likewise. * gas/loongarch/load_store_op.s: Likewise. * gas/loongarch/loongarch.exp: Likewise. * gas/loongarch/macro_op.d: Likewise. * gas/loongarch/macro_op.s: Likewise. * gas/loongarch/nop.d: Likewise. * gas/loongarch/nop.s: Likewise. * gas/loongarch/privilege_op.d: Likewise. * gas/loongarch/privilege_op.s: Likewise. * gas/loongarch/syscall.d: Likewise. * gas/loongarch/syscall.s: Likewise. * lib/gas-defs.exp: Add LoongArch.
2021-10-24LoongArch binutils supportliuzhensong3-0/+27
2021-10-22 Chenghua Xu <xuchenghua@loongson.cn> Zhensong Liu <liuzhensong@loongson.cn> Weinan Liu <liuweinan@loongson.cn> binutils/ * NEWS: Mention LoongArch support. * readelf.c: Add LoongArch. * testsuite/binutils-all/objdump.exp: Add LoongArch.
2021-10-24LoongArch opcodes supportliuzhensong12-0/+1877
2021-10-22 Chenghua Xu <xuchenghua@loongson.cn> Zhensong Liu <liuzhensong@loongson.cn> Weinan Liu <liuweinan@loongson.cn> include/ * opcode/loongarch.h: New. * dis-asm.h: Declare print_loongarch_disassembler_options. opcodes/ * Makefile.am: Add LoongArch. * configure.ac: Likewise. * disassemble.c: Likewise. * disassemble.h: Declare print_insn_loongarch. * loongarch-coder.c: New. * loongarch-dis.c: New. * loongarch-opc.c: New. * Makefile.in: Regenerate. * configure: Regenerate. * po/POTFILES.in: Regenerate.
2021-10-24LoongArch bfd supportliuzhensong20-3/+4519
2021-10-22 Chenghua Xu <xuchenghua@loongson.cn> Zhensong Liu <liuzhensong@loongson.cn> Weinan Liu <liuweinan@loongson.cn> bfd/ * Makefile.am: Add LoongArch. * archures.c: Likewise. * config.bfd: Likewise. * configure.ac: Likewise. * cpu-loongarch.c: New. * elf-bfd.h: Add LoongArch. * elf.c: Add LoongArch elfcore_grok_xxx. * elfnn-loongarch.c: New. * elfxx-loongarch.c: New. * elfxx-loongarch.h: New. * reloc.c: Add LoongArch BFD RELOC ENUM. * targets.c: Add LoongArch target. * Makefile.in: Regenerate. * bfd-in2.h: Regenerate. * configure: Regenerate. * libbfd.h: Regenerate. * po/BLD-POTFILES.in: Regenerate. * po/SRC-POTFILES.in: Regenerate. include/ * elf/common.h: Add NT_LARCH_{CPUCFG,CSR,LSX,LASX}. * elf/loongarch.h: New.
2021-10-24Automatic date update in version.inGDB Administrator1-1/+1
2021-10-23Automatic date update in version.inGDB Administrator1-1/+1
2021-10-22x86: Add -muse-unaligned-vector-move to assemblerH.J. Lu7-0/+110
Unaligned load/store instructions on aligned memory or register are as fast as aligned load/store instructions on modern Intel processors. Add a command-line option, -muse-unaligned-vector-move, to x86 assembler to encode encode aligned vector load/store instructions as unaligned vector load/store instructions. * NEWS: Mention -muse-unaligned-vector-move. * config/tc-i386.c (use_unaligned_vector_move): New. (encode_with_unaligned_vector_move): Likewise. (md_assemble): Call encode_with_unaligned_vector_move for -muse-unaligned-vector-move. (OPTION_MUSE_UNALIGNED_VECTOR_MOVE): New. (md_longopts): Add -muse-unaligned-vector-move. (md_parse_option): Handle -muse-unaligned-vector-move. (md_show_usage): Add -muse-unaligned-vector-move. * doc/c-i386.texi: Document -muse-unaligned-vector-move. * testsuite/gas/i386/i386.exp: Run unaligned-vector-move and x86-64-unaligned-vector-move. * testsuite/gas/i386/unaligned-vector-move.d: New file. * testsuite/gas/i386/unaligned-vector-move.s: Likewise. * testsuite/gas/i386/x86-64-unaligned-vector-move.d: Likewise.
2021-10-22Fix 'uninstall' targetTom Tromey2-3/+14
This adds some missing code to the 'uninstall' targets in gdb and gdbserver. It also changes gdb's uninstall target so that it no longer tries to remove any man page -- this is already done (and more correctly) by doc/Makefile.in. I tested this with 'make install' followed by 'make uninstall', then examining the install tree for regular files. Only the 'dir' file remains, but this appears to just be how 'install-info' is intended to work.
2021-10-22Remove unused variables from gdbserver's MakefileTom Tromey1-26/+1
This removes a number of unused variables from gdbserver's Makefile. I found these while working on the subsequent patches, and figured it would be cleaner to have a separate patch for the deletions.
2021-10-22[gdb/testsuite] Fix gdb.threads/linux-dp.expTom de Vries1-1/+1
On openSUSE Tumbleweed with glibc-debuginfo installed I get: ... (gdb) PASS: gdb.threads/linux-dp.exp: continue to breakpoint: thread 5's print where^M #0 print_philosopher (n=3, left=33 '!', right=33 '!') at linux-dp.c:105^M #1 0x0000000000401628 in philosopher (data=0x40537c) at linux-dp.c:148^M #2 0x00007ffff7d56b37 in start_thread (arg=<optimized out>) \ at pthread_create.c:435^M #3 0x00007ffff7ddb640 in clone3 () \ at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81^M (gdb) PASS: gdb.threads/linux-dp.exp: first thread-specific breakpoint hit ... while without debuginfo installed I get instead: ... (gdb) PASS: gdb.threads/linux-dp.exp: continue to breakpoint: thread 5's print where^M #0 print_philosopher (n=3, left=33 '!', right=33 '!') at linux-dp.c:105^M #1 0x0000000000401628 in philosopher (data=0x40537c) at linux-dp.c:148^M #2 0x00007ffff7d56b37 in start_thread () from /lib64/libc.so.6^M #3 0x00007ffff7ddb640 in clone3 () from /lib64/libc.so.6^M (gdb) FAIL: gdb.threads/linux-dp.exp: first thread-specific breakpoint hit ... The problem is that the regexp used: ... "\(from .*libpthread\|at pthread_create\|in pthread_create\)" ... expects the 'from' part to match libpthread, but in glibc 2.34 libpthread has been merged into libc. Fix this by updating the regexp. Tested on x86_64-linux.
2021-10-22[gdb/testsuite] Fix FAILs in gdb.mi/mi-breakpoint-changed.expTom de Vries1-2/+2
Since commit e36788d1354 "[gdb/testsuite] Fix handling of nr_args < 3 in mi_gdb_test" we run into: ... PASS: gdb.mi/mi-breakpoint-changed.exp: test_auto_disable: mi runto main Expecting: ^(-break-insert -f pendfunc1[^M ]+)?((&.*)*.*~"Breakpoint 2 at.*\\n".*=breakpoint-created,\ bkpt=\{number="2",type="breakpoint".*\}.*\n\^done[^M ]+[(]gdb[)] ^M [ ]*) -break-insert -f pendfunc1^M ^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",\ addr="0x00007ffff7bd559e",func="pendfunc1",\ file="gdb/testsuite/gdb.mi/pendshr1.c",\ fullname="gdb/testsuite/gdb.mi/pendshr1.c",line="21",thread-groups=["i1"],\ times="0",original-location="pendfunc1"}^M (gdb) ^M FAIL: gdb.mi/mi-breakpoint-changed.exp: test_auto_disable: \ -break-insert -f pendfunc1 (unexpected output) ... The regexp expects a breakpoint-created event, but that's actually suppressed by the command: ... DEF_MI_CMD_MI_1 ("break-insert", mi_cmd_break_insert, &mi_suppress_notification.breakpoint), ... Fix this by updating the regexp. Likewise for the following: ... PASS: gdb.mi/mi-breakpoint-changed.exp: test_auto_disable: \ -break-insert -f pendfunc1 Expecting: ^(-break-enable count 1 2[^M ]+)?(=breakpoint-modified,\ bkpt=\{number="2",type="breakpoint",disp="dis",enabled="y".*\}.*\n\^done[^M ]+[(]gdb[)] ^M [ ]*) -break-enable count 1 2^M ^done^M (gdb) ^M FAIL: gdb.mi/mi-breakpoint-changed.exp: test_auto_disable: \ -break-enable count 1 2 (unexpected out\ put) ... Tested on x86_64-linux.
2021-10-22gdb/python: move gdb.Membuf support into a new fileAndrew Burgess5-179/+236
In a future commit I'm going to be creating gdb.Membuf objects from a new file within gdb/python/py*.c. Currently all gdb.Membuf objects are created directly within infpy_read_memory (as a result of calling gdb.Inferior.read_memory()). Initially I split out the Membuf creation code into a new function, and left the new function in gdb/python/py-inferior.c, however, it felt a little random that the Membuf creation code should live with the inferior handling code. So, then I moved all of the Membuf related code out into a new file, gdb/python/py-membuf.c, the interface is gdbpy_buffer_to_membuf, which wraps an array of bytes into a gdb.Membuf object. Most of the code is moved directly from py-inferior.c with only minor tweaks to layout and replacing NULL with nullptr, hence, I've left the copyright date on py-membuf.c as 2009-2021 to match py-inferior.c. Currently, the only user of this code is still py-inferior.c, but in later commits this will change. There should be no user visible changes after this commit.
2021-10-22gdb/python: new gdb.architecture_names functionAndrew Burgess6-0/+92
Add a new function to the Python API, gdb.architecture_names(). This function returns a list containing all of the supported architecture names within the current build of GDB. The values returned in this list are all of the possible values that can be returned from gdb.Architecture.name().
2021-10-22gdb: make disassembler fprintf callback a static member functionAndrew Burgess2-16/+18
The disassemble_info structure has four callbacks, we have three of them as static member functions within gdb_disassembler, the fourth is just a global static function. However, this fourth callback, is still only used from the disassemble_info struct, so there's no real reason for its special handling. This commit makes fprintf_disasm a static method within gdb_disassembler. There should be no user visible changes after this commit.
2021-10-22RISC-V: Added ld testcase for pcgp relaxation.Lewis Revill5-2/+36
Consider the the pcgp-relax-02 testcase, .text .globl _start _start: .L1: auipc a0, %pcrel_hi(data_a) .L2: auipc a1, %pcrel_hi(data_b) addi a0, a0, %pcrel_lo(.L1) addi a1, a1, %pcrel_lo(.L2) .data .word 0x0 .globl data_a data_a: .word 0x1 .section .rodata .globl data_b data_b: .word 0x2 If the first auipc is deleted, but we are still building the pcgp table (connect the high and low pcrel relocations), then there is an aliasing issue that we need some way to disambiguate which of the two symbols we are targeting. Therefore, Palmer thought of a way to use R_RISCV_DELETE to split this into two phases, so we could resolve the addresses before creating the ambiguities. This patch just add the ld testcase for the above case, in case we have changed something but break this. ld/ * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Renamed pcgp-relax to pcgp-relax-01, and added pcgp-relax-02. * testsuite/ld-riscv-elf/pcgp-relax-01.d: Renmaed from pcgp-relax. * testsuite/ld-riscv-elf/pcgp-relax-01.s: Likewise. * testsuite/ld-riscv-elf/pcgp-relax-02.d: New testcase. * testsuite/ld-riscv-elf/pcgp-relax-02.s: Likewise.
2021-10-22RISC-V: Don't separate pcgp relaxation to another relax pass.Lewis Revill9-216/+215
Commit abd20cb637008da9d32018b4b03973e119388a0a and ebdcad3fddf6ec21f6d4dcc702379a12718cf0c4 introduced additional complexity into the paths run by the RISC-V relaxation pass in order to resolve the issue of accurately keeping track of pcrel_hi and pcrel_lo pairs. The first commit split up relaxation of these relocs into a pass which occurred after other relaxations in order to prevent the situation where bytes were deleted in between a pcrel_lo/pcrel_hi pair, inhibiting our ability to find the corresponding pcrel_hi relocation from the address attached to the pcrel_lo. Since the relaxation was split into two passes the 'again' parameter could not be used to perform the entire relaxation process again and so the second commit added a way to restart ldelf_map_segments, thus starting the whole process again. Unfortunately this process could not account for the fact that we were not finished with the relaxation process so in some cases - such as the case where code would not fit in a memory region before the R_RISCV_ALIGN relocation was relaxed - sanity checks in generic code would fail. This patch fixes all three of these concerns by reverting back to a system of having only one target relax pass but updating entries in the table of pcrel_hi/pcrel_lo relocs every time any bytes are deleted. Thus we can keep track of the pairs accurately, and we can use the 'again' parameter to restart the entire target relax pass, behaving in the way that generic code expects. Unfortunately we must still have an additional pass to delay deleting AUIPC bytes to avoid ambiguity between pcrel_hi relocs stored in the table after deletion. This pass can only be run once so we may potentially miss out on relaxation opportunities but this is likely to be rare. https://sourceware.org/bugzilla/show_bug.cgi?id=28410 bfd/ * elfnn-riscv.c (riscv_elf_link_hash_table): Removed restart_relax. (riscv_elf_link_hash_table_create): Updated. (riscv_relax_delete_bytes): Moved after the riscv_update_pcgp_relocs. Update the pcgp_relocs table whenever bytes are deleted. (riscv_update_pcgp_relocs): Add function to update the section offset of pcrel_hi and pcrel_lo, and also update the symbol value of pcrel_hi. (_bfd_riscv_relax_call): Need to update the pcgp_relocs table when deleting codes. (_bfd_riscv_relax_lui): Likewise. (_bfd_riscv_relax_tls_le): Likewise. (_bfd_riscv_relax_align): Once we've handled an R_RISCV_ALIGN, we can't relax anything else, so set the sec->sec_flg0 to true. Besides, we don't need to update the pcgp_relocs table at this stage, so just pass NULL pointer as the pcgp_relocs table for riscv_relax_delete_bytes. (_bfd_riscv_relax_section): Use only one pass for all target relaxations. (_bfd_riscv_relax_delete): Likewise, we don't need to update the pcgp_relocs table at this stage, and don't need to set the `again' since restart_relax mechanism is abandoned. (bfd_elfNN_riscv_restart_relax_sections): Removed. (_bfd_riscv_relax_section): Updated. * elfxx-riscv.h (bfd_elf32_riscv_restart_relax_sections): Removed. (bfd_elf64_riscv_restart_relax_sections): Likewise. ld/ * emultempl/riscvelf.em: Revert restart_relax changes and set relax_pass to 3. * testsuite/ld-riscv-elf/align-small-region.d: New testcase. * testsuite/ld-riscv-elf/align-small-region.ld: Likewise. * testsuite/ld-riscv-elf/align-small-region.s: Likewise. * testsuite/ld-riscv-elf/restart-relax.d: Removed sine the restart_relax mechanism is abandoned. * testsuite/ld-riscv-elf/restart-relax.s: Likewise. * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
2021-10-22gdb: fix remote-sim.c buildSimon Marchi1-6/+3
Commit 183be222907a ("gdb, gdbserver: make target_waitstatus safe") broke the remote-sim.c build. In fact, it does some wrong changes, result of a bad sed invocation. Fix it by adjusting the code to the new target_waitstatus API. Change-Id: I3236ff7ef7681fc29215f68be210ff4263760e91
2021-10-22Automatic date update in version.inGDB Administrator1-1/+1
2021-10-21gdb, gdbserver: make target_waitstatus safeSimon Marchi44-705/+826
I stumbled on a bug caused by the fact that a code path read target_waitstatus::value::sig (expecting it to contain a gdb_signal value) while target_waitstatus::kind was TARGET_WAITKIND_FORKED. This meant that the active union field was in fact target_waitstatus::value::related_pid, and contained a ptid. The read signal value was therefore garbage, and that caused GDB to crash soon after. Or, since that GDB was built with ubsan, this nice error message: /home/simark/src/binutils-gdb/gdb/linux-nat.c:1271:12: runtime error: load of value 2686365, which is not a valid value for type 'gdb_signal' Despite being a large-ish change, I think it would be nice to make target_waitstatus safe against that kind of bug. As already done elsewhere (e.g. dynamic_prop), validate that the type of value read from the union matches what is supposed to be the active field. - Make the kind and value of target_waitstatus private. - Make the kind initialized to TARGET_WAITKIND_IGNORE on target_waitstatus construction. This is what most users appear to do explicitly. - Add setters, one for each kind. Each setter takes as a parameter the data associated to that kind, if any. This makes it impossible to forget to attach the associated data. - Add getters, one for each associated data type. Each getter validates that the data type fetched by the user matches the wait status kind. - Change "integer" to "exit_status", "related_pid" to "child_ptid", just because that's more precise terminology. - Fix all users. That last point is semi-mechanical. There are a lot of obvious changes, but some less obvious ones. For example, it's not possible to set the kind at some point and the associated data later, as some users did. But in any case, the intent of the code should not change in this patch. This was tested on x86-64 Linux (unix, native-gdbserver and native-extended-gdbserver boards). It was built-tested on x86-64 FreeBSD, NetBSD, MinGW and macOS. The rest of the changes to native files was done as a best effort. If I forgot any place to update in these files, it should be easy to fix (unless the change happens to reveal an actual bug). Change-Id: I0ae967df1ff6e28de78abbe3ac9b4b2ff4ad03b7
2021-10-21gdbserver: initialize the members of lwp_info in-classSimon Marchi2-29/+31
Add a constructor to initialize the waitstatus members. Initialize the others in the class directly. Change-Id: I10f885eb33adfae86e3c97b1e135335b540d7442
2021-10-21gdbserver: make thread_info non-PODSimon Marchi2-14/+18
Add a constructor and a destructor. The constructor takes care of the initialization that happened in add_thread, while the destructor takes care of the freeing that happened in free_one_thread. This is needed to make target_waitstatus non-POD, as thread_info contains a member of that type. Change-Id: I1db321b4de9dd233ede0d5c101950f1d6f1d13b7
2021-10-21Fix ARMv8.4 for hw watchpoint and breakpointAndrew Pinski2-0/+3
Just like my previoius patch for ARMv8.1 and v8.2 (49ecef2a7da2ee9df4), this adds ARMv8.4 debug arch as being compatible for hw watchpoint and breakpoints.
2021-10-21Refactor code slightly in nat/aarch64-linux-hw-point.c ↵Andrew Pinski1-6/+18
(aarch64_linux_get_debug_reg_capacity) Since the two locations which check the debug arch are the same code currently, it is a good idea to factor it out to a new function and just use that function from aarch64_linux_get_debug_reg_capacity. This is also the first step to support ARMv8.4 debug arch.
2021-10-21Fixes for gdb.mi/mi-break.expCarl Love1-4/+4
Update the expected pattern for two of the tests. Matching pattern \" doesn't work. Use .* to match the \* pattern.
2021-10-21[gdb/tui] Fix breakpoint display functionalityTom de Vries2-2/+38
In commit 81e6b8eb208 "Make tui-winsource not use breakpoint_chain", a loop body was transformed into a lambda function body: ... - for (bp = breakpoint_chain; - bp != NULL; - bp = bp->next) + iterate_over_breakpoints ([&] (breakpoint *bp) -> bool ... and consequently: - a continue was replaced by a return, and - a final return was added. Then in commit 240edef62f0 "gdb: remove iterate_over_breakpoints function", we transformed back to a loop body: ... - iterate_over_breakpoints ([&] (breakpoint *bp) -> bool + for (breakpoint *bp : all_breakpoints ()) ... but without reverting the changes that introduced the two returns. Consequently, breakpoints no longer show up in the tui source window. Fix this by reverting the changes that introduced the two returns. Build on x86_64-linux, tested with all .exp test-cases that contain tuiterm_env. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28483
2021-10-21Fix test step-and-next-inline.ccCarl Love2-2/+4
The test expect the runto_main to stop at the first line of the function. Depending on the optimization level, gdb may stop in the prolog or after the prolog at the first line. To ensure the test stops at the first line of main, have it explicitly stop at a break point on the first line of the function. On PowerPC, the test passes when compiled with no optimization but fails with all levels of optimization due to gdb stopping in the prolog.
2021-10-21Fix latent Ada bug when accessing field offsetsTom Tromey3-43/+75
The "add accessors for field (and call site) location" patch caused a gdb crash when running the internal AdaCore testsuite. This turned out to be a latent bug in ada-lang.c. The immediate cause of the bug is that find_struct_field unconditionally uses TYPE_FIELD_BITPOS. This causes an assert for a dynamic type. This patch fixes the problem by doing two things. First, it changes find_struct_field to use a dummy value for the field offset in the situation where the offset is not actually needed by the caller. This works because the offset isn't used in any other way -- only as a result. Second, this patch assures that calls to find_struct_field use a resolved type when the offset is needed. For value_tag_from_contents_and_address, this is done by resolving the type explicitly. In ada_value_struct_elt, this is done by passing nullptr for the out parameters when they are not needed (the second call in this function already uses a resolved type). Note that, while we believe the parent field probably can't occur at a variable offset, the patch still updates this code path, just in case. I've updated an existing test case to reproduce the crash. I'm checking this in.
2021-10-21-Waddress warning in ldelf.cAlan Modra1-1/+0
ldelf.c: In function 'ldelf_after_open': ldelf.c:1049:43: warning: the comparison will always evaluate as 'true' for the address of 'elf_header' will never be NULL [-Waddress] 1049 | && elf_tdata (abfd)->elf_header != NULL | ^~ In file included from ldelf.c:37: ../bfd/elf-bfd.h:1957:21: note: 'elf_header' declared here 1957 | Elf_Internal_Ehdr elf_header[1]; /* Actual data, but ref like ptr */ * ldelf.c (ldelf_after_open): Remove useless elf_header test.
2021-10-21Avoid -Waddress warnings in readelfAlan Modra1-86/+123
Mainline gcc: readelf.c: In function 'find_section': readelf.c:349:8: error: the comparison will always evaluate as 'true' for the pointer operand in 'filedata->section_headers + (sizetype)((long unsigned int)i * 80)' must not be NULL [-Werror=address] 349 | ((X) != NULL \ | ^~ readelf.c:761:9: note: in expansion of macro 'SECTION_NAME_VALID' 761 | if (SECTION_NAME_VALID (filedata->section_headers + i) | ^~~~~~~~~~~~~~~~~~ This will likely be fixed in gcc, but inline functions are nicer than macros. * readelf.c (SECTION_NAME, SECTION_NAME_VALID), (SECTION_NAME_PRINT, VALID_SYMBOL_NAME, VALID_DYNAMIC_NAME), (GET_DYNAMIC_NAME): Delete. Replace with.. (section_name, section_name_valid, section_name_print), (valid_symbol_name, valid_dynamic_name, get_dynamic_name): ..these new inline functions. Update use throughout file.
2021-10-21Automatic date update in version.inGDB Administrator1-1/+1
2021-10-21PR28417, std::string no longer allows accepting nullptr_tAlan Modra2-2/+2
PR 28417 * incremental.cc (Sized_relobj_incr::do_section_name): Avoid std:string undefined behaviour. * options.h (Search_directory::Search_directory): Likewise.
2021-10-21Re: PR27625, powerpc64 gold __tls_get_addr callsAlan Modra1-156/+36
My previous PR27625 patch had a problem or two. For one, the error "__tls_get_addr call lacks marker reloc" on processing some calls before hitting a call without markers typically isn't seen. Instead a gold assertion fails. Either way it would be a hard error, which triggers on a file contained in libphobos.a when running the gcc testsuite. A warning isn't even appropriate since the call involved is one built by hand without any of the arg setup relocations that might result in linker optimisation. So this patch reverts most of commit 0af4fcc25dd5, instead entirely ignoring the problem of mis-optimising old-style __tls_get_addr calls without marker relocs. We can't handle them gracefully without another pass over relocations before decisions are made about GOT entries in Scan::global or Scan::local. That seems too costly, just to link object files from 2009. What's more, there doesn't seem to be any way to allow the libphobos explicit __tls_get_addr call, but not old TLS sequences without marker relocs. Examining instructions before the __tls_get_addr call is out of the question: program flow might reach the call via a branch. Putting an R_PPC64_TLSGD marker with zero sym on the call might be a solution, but current linkers will then merrily optimise away the call! PR gold/27625 * powerpc.cc (Powerpc_relobj): Delete no_tls_marker_, tls_marker_, and tls_opt_error_ variables and accessors. Remove all uses.
2021-10-20Use std::string in print_one_catch_syscallTom Tromey1-13/+9
This changes print_one_catch_syscall to use std::string, removing a bit of manual memory management.
2021-10-20Use unique_xmalloc_ptr in breakpointTom Tromey6-63/+60
This changes struct breakpoint to use unique_xmalloc_ptr in a couple of spots, removing a bit of manual memory management.
2021-10-20Use unique_xmalloc_ptr in bp_locationTom Tromey2-10/+6
This changes struct bp_location to use a unique_xmalloc_ptr, removing a bit of manual memory management.
2021-10-20Use unique_xmalloc_ptr in watchpointTom Tromey4-25/+18
This changes struct watchpoint to use unique_xmalloc_ptr in a couple of places, removing a bit of manual memory management.
2021-10-20Use unique_xmalloc_ptr in exec_catchpointTom Tromey1-14/+5
This changes struct exec_catchpoint to use a unique_xmalloc_ptr, removing a bit of manual memory management.
2021-10-20Use unique_xmalloc_ptr in solib_catchpointTom Tromey1-12/+7
This changes struct solib_catchpoint to use a unique_xmalloc_ptr, removing a bit of manual memory management.
2021-10-20Make c-exp.y work with Bison 3.8+Christian Biesinger1-2/+3
When using Bison 3.8, we get this error: ../../gdb/c-exp.y:3455:1: error: 'void c_print_token(FILE*, int, YYSTYPE)' defined but not used [-Werror=unused-function] That's because bison 3.8 removed YYPRINT support: https://savannah.gnu.org/forum/forum.php?forum_id=10047 Accordingly, this patch only defines that function for Bison < 3.8. Change-Id: I3cbf2f317630bb72810b00f2d9b2c4b99fa812ad
2021-10-20Automatic date update in version.inGDB Administrator1-1/+1
2021-10-19[gdb/testsuite] Reimplement gdb.gdb/python-interrupts.exp as unittestTom de Vries4-50/+57
The test-case gdb.gdb/python-interrupts.exp: - runs to captured_command_loop - sets a breakpoint at set_active_ext_lang - calls a python command - verifies the command triggers the breakpoint - sends a signal and verifies the result The test-case is fragile, because (f.i. with -flto) it cannot be guaranteed that captured_command_loop and set_active_ext_lang are available for setting breakpoints. Reimplement the test-case as unittest, using: - execute_command_to_string to capture the output - try/catch to catch the "Error while executing Python code" exception - a new hook selftests::hook_set_active_ext_lang to raise the signal Tested on x86_64-linux.
2021-10-19Check index in type::fieldTom Tromey3-2/+3
This changes gdb to check the index that is passed to type::field. This caught one bug in the Ada code when running the test suite (actually I found the bug first, then realized that the check would have helped), so this patch fixes that as well. Regression tested on x86-64 Fedora 34.
2021-10-19Fix Rust lex selftest when using libiconvTom Tromey1-3/+10
The Rust lex selftest fails on our Windows build. I tracked this down to a use of UTF-32 as a parameter to convert_between_encodings. Here, iconv_open succeeds, but the actual conversion of a tab character fails with EILSEQ. I suspect that "UTF-32" is being interpreted as big-endian, as changing the call to use "UTF-32LE" makes it work. This patch implements this fix.
2021-10-19Fix format_pieces selftest on WindowsTom Tromey6-72/+127
The format_pieces selftest currently fails on Windows hosts. The selftest doesn't handle the "%ll" -> "%I64" rewrite that the formatter may perform, but also gdbsupport was missing a configure check for PRINTF_HAS_LONG_LONG. This patch fixes both issues.
2021-10-19Fix bug in dynamic type resolutionTom Tromey3-3/+35
A customer-reported problem led us to a bug in dynamic type resolution. resolve_dynamic_struct will recursively call resolve_dynamic_type_internal, passing it the sub-object for the particular field being resolved. While it offsets the address here, it does not also offset the "valaddr" -- the array of bytes describing the memory. This patch fixes the bug, by offsetting both. A test case is included that can be used to reproduce the bug.
2021-10-19Always use std::function for self-testsTom Tromey2-45/+6
Now that there is a register_test variant that accepts std::function, it seems to me that the 'selftest' struct and accompanying code is obsolete -- simply always using std::function is simpler. This patch implements this idea.