aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2022-02-23gdb/linux-tdep.c: Add Perms to the 'info proc mappings' outputDominik 'Disconnect3d' Czarnota1-8/+8
Fixes #28914 and so it adds a 'Perms' (permissions) column to the 'info proc mappings' command output. This will allow users to know the memory pages permissions right away from GDB instead of having to fetch them from the /proc/$pid/maps file (which is also what GDB does internally, but it just did not print that column). Below I am also showing how an example output looks like before and after this commit in case someone wonders. On i386 targets - before this commit: ``` (gdb) info proc mappings process 3461464 Mapped address spaces: Start Addr End Addr Size Offset objfile 0x56555000 0x56556000 0x1000 0x0 /home/dc/src/binutils-gdb/build/a.out 0x56556000 0x56557000 0x1000 0x1000 /home/dc/src/binutils-gdb/build/a.out 0x56557000 0x56558000 0x1000 0x2000 /home/dc/src/binutils-gdb/build/a.out 0x56558000 0x5655a000 0x2000 0x2000 /home/dc/src/binutils-gdb/build/a.out 0xf7fc4000 0xf7fc8000 0x4000 0x0 [vvar] 0xf7fc8000 0xf7fca000 0x2000 0x0 [vdso] 0xf7fca000 0xf7fcb000 0x1000 0x0 /usr/lib/i386-linux-gnu/ld-2.33.so 0xf7fcb000 0xf7fee000 0x23000 0x1000 /usr/lib/i386-linux-gnu/ld-2.33.so 0xf7fee000 0xf7ffb000 0xd000 0x24000 /usr/lib/i386-linux-gnu/ld-2.33.so 0xf7ffb000 0xf7ffe000 0x3000 0x30000 /usr/lib/i386-linux-gnu/ld-2.33.so 0xfffdc000 0xffffe000 0x22000 0x0 [stack] (gdb) ``` On i386 targets - after this commit: ``` (gdb) info proc mappings process 3461464 Mapped address spaces: Start Addr End Addr Perms Size Offset objfile 0x56555000 0x56556000 r--p 0x1000 0x0 /home/dc/src/binutils-gdb/build/a.out 0x56556000 0x56557000 r-xp 0x1000 0x1000 /home/dc/src/binutils-gdb/build/a.out 0x56557000 0x56558000 r--p 0x1000 0x2000 /home/dc/src/binutils-gdb/build/a.out 0x56558000 0x5655a000 rw-p 0x2000 0x2000 /home/dc/src/binutils-gdb/build/a.out 0xf7fc4000 0xf7fc8000 r--p 0x4000 0x0 [vvar] 0xf7fc8000 0xf7fca000 r-xp 0x2000 0x0 [vdso] 0xf7fca000 0xf7fcb000 r--p 0x1000 0x0 /usr/lib/i386-linux-gnu/ld-2.33.so 0xf7fcb000 0xf7fee000 r-xp 0x23000 0x1000 /usr/lib/i386-linux-gnu/ld-2.33.so 0xf7fee000 0xf7ffb000 r--p 0xd000 0x24000 /usr/lib/i386-linux-gnu/ld-2.33.so 0xf7ffb000 0xf7ffe000 rw-p 0x3000 0x30000 /usr/lib/i386-linux-gnu/ld-2.33.so 0xfffdc000 0xffffe000 rw-p 0x22000 0x0 [stack] (gdb) ``` On amd64 targets - after this commit: ``` (gdb) info proc mappings process 3461869 Mapped address spaces: Start Addr End Addr Perms Size Offset objfile 0x555555554000 0x555555555000 r--p 0x1000 0x0 /home/dc/src/binutils-gdb/build/a.out 0x555555555000 0x555555556000 r-xp 0x1000 0x1000 /home/dc/src/binutils-gdb/build/a.out 0x555555556000 0x555555557000 r--p 0x1000 0x2000 /home/dc/src/binutils-gdb/build/a.out 0x555555557000 0x555555559000 rw-p 0x2000 0x2000 /home/dc/src/binutils-gdb/build/a.out 0x7ffff7fc3000 0x7ffff7fc7000 r--p 0x4000 0x0 [vvar] 0x7ffff7fc7000 0x7ffff7fc9000 r-xp 0x2000 0x0 [vdso] 0x7ffff7fc9000 0x7ffff7fca000 r--p 0x1000 0x0 /usr/lib/x86_64-linux-gnu/ld-2.33.so 0x7ffff7fca000 0x7ffff7ff1000 r-xp 0x27000 0x1000 /usr/lib/x86_64-linux-gnu/ld-2.33.so 0x7ffff7ff1000 0x7ffff7ffb000 r--p 0xa000 0x28000 /usr/lib/x86_64-linux-gnu/ld-2.33.so 0x7ffff7ffb000 0x7ffff7fff000 rw-p 0x4000 0x31000 /usr/lib/x86_64-linux-gnu/ld-2.33.so 0x7ffffffdd000 0x7ffffffff000 rw-p 0x22000 0x0 [stack] 0xffffffffff600000 0xffffffffff601000 --xp 0x1000 0x0 [vsyscall] (gdb) ``` Signed-off-by: Dominik 'Disconnect3d' Czarnota <dominik.b.czarnota@gmail.com> Change-Id: I4991f6cc758cd532eae3ae98c29d22e7bd9d9c36
2022-02-23RISC-V: PR28733, add missing extension info to 'unrecognized opcode' errorPatrick O'Neill5-36/+166
Currently we report errors as "unrecognized opcode `fence.i'" when the opcode isn't part of the selected extensions. This patch expands that error message to include the missing extension information. For example, now the error message would be "unrecognized opcode `fence.i', extension `zifencei' required". If the opcode is not a part of any extension, the error message reverts to "unrecognized opcode `<op statement>'". Signed-off-by: Patrick O'Neill <patrick@rivosinc.com> bfd/ pr 28733 * elfxx-riscv.c (riscv_multi_subset_supports_ext): New function, used to return the extension string for each INSN_CLASS_*. * elfxx-riscv.h: Added extern riscv_multi_subset_supports_ext. gas/ pr 28733 * config/tc-riscv.c (struct riscv_ip_error): New structure, contains information about errors that occur within the riscv_ip. (riscv_ip): Use struct riscv_ip_error to report more detailed errors. * testsuite/gas/riscv/c-fld-fsd-fail.l: Updated. * testsuite/gas/riscv/march-imply-i2p1-01.: Likewise.
2022-02-23RISC-V: PR28733, add missing extension info to 'invalid CSR' errorPatrick O'Neill5-711/+717
Currently we report errors as "invalid CSR 'fscr' for the current ISA" when the instruction isn't valid. This patch expands that error message to include the missing extension information. For example, now the error message would be "invalid CSR 'fscr' for the current ISA, CSR 'fscr' needs 'f' extension". Signed-off-by: Patrick O'Neill <patrick@rivosinc.com> gas/ pr 28733 * config/tc-riscv.c (riscv_csr_address): Report more details when the CSR is invalid. * testsuite/gas/riscv/csr-version-1p10.l: Updated detailed errors. * testsuite/gas/riscv/csr-version-1p11.l: Likewise. * testsuite/gas/riscv/csr-version-1p12.l: Likewise. * testsuite/gas/riscv/csr-version-1p9p1.l: Likewise.
2022-02-23binutils 2.38 vs. ppc32 linux kernelAlan Modra1-1/+24
Commit b25f942e18d6 made .machine more strict. Weaken it again. * config/tc-ppc.c (ppc_machine): Treat an early .machine specially, keeping sticky options to work around gcc bugs.
2022-02-23RISC-V: Updated CSRs to privileged spec v1.12 and debug spec v1.0.Nelson Chu12-279/+337
* Removed N extension CSRs, ustatus, uie, utvec, uscratch, uepc, ucause, utval and uip. * Removed two supervisor CSRs, sedeleg and sideleg. * Changed debug CSR address of scontext from 0x7aa to 0x5a8. We cannot support different versions of debug specs for now, so only supporting the latest one is the only way to move forward. * Added debug CSRs, mscontext (0x7aa), mcontrol6 (0x7a1, tdata1) and tmexttrigger ((0x7a1, tdata1). * Regarded hcontext as a debug CSR. include/ * opcode/riscv-opc.h: Updated CSRs to privileged spec v1.12 and debug spec v1.0. gas/ * testsuite/gas/riscv/csr.s: Updated CSRs to privileged spec v1.12 and debug spec v1.0. * testsuite/gas/riscv/csr-dw-regnums.d: Likewise. * testsuite/gas/riscv/csr-version-1p10.d: Likewise. * testsuite/gas/riscv/csr-version-1p10.l: Likewise. * testsuite/gas/riscv/csr-version-1p11.d: Likewise. * testsuite/gas/riscv/csr-version-1p11.l: Likewise. * testsuite/gas/riscv/csr-version-1p12.d: Likewise. * testsuite/gas/riscv/csr-version-1p12.l: Likewise. * testsuite/gas/riscv/csr-version-1p9p1.d: Likewise. * testsuite/gas/riscv/csr-version-1p9p1.l: Likewise. * testsuite/gas/riscv/csr-dw-regnums.d: Likewise. * testsuite/gas/riscv/csr-dw-regnums.s: Likewise.
2022-02-23RISC-V: Add Privileged Architecture 1.12 CSRsTsukasa OI12-0/+1387
This commit adds, * Most of CSRs as listed in the Privileged Architecture, version 1.12 (except scontext and mscontext). * Testcases for most CSRs added on the Privileged Architecture, version 1.12 (except moved "scontext" and new "mscontext"). include/ChangeLog: * opcode/riscv-opc.h (CSR_SENVCFG, CSR_MCONFIGPTR, CSR_MENVCFG, CSR_MSTATUSH, CSR_MENVCFGH, CSR_MTINST, CSR_MTVAL2, CSR_MSECCFG, CSR_MSECCFGH, CSR_PMPCFG4, CSR_PMPCFG5, CSR_PMPCFG6, CSR_PMPCFG7, CSR_PMPCFG8, CSR_PMPCFG9, CSR_PMPCFG10, CSR_PMPCFG11, CSR_PMPCFG12, CSR_PMPCFG13, CSR_PMPCFG14, CSR_PMPCFG15, CSR_PMPADDR16, CSR_PMPADDR17, CSR_PMPADDR18, CSR_PMPADDR19, CSR_PMPADDR20, CSR_PMPADDR21, CSR_PMPADDR22, CSR_PMPADDR23, CSR_PMPADDR24, CSR_PMPADDR25, CSR_PMPADDR26, CSR_PMPADDR27, CSR_PMPADDR28, CSR_PMPADDR29, CSR_PMPADDR30, CSR_PMPADDR31, CSR_PMPADDR32, CSR_PMPADDR33, CSR_PMPADDR34, CSR_PMPADDR35, CSR_PMPADDR36, CSR_PMPADDR37, CSR_PMPADDR38, CSR_PMPADDR39, CSR_PMPADDR40, CSR_PMPADDR41, CSR_PMPADDR42, CSR_PMPADDR43, CSR_PMPADDR44, CSR_PMPADDR45, CSR_PMPADDR46, CSR_PMPADDR47, CSR_PMPADDR48, CSR_PMPADDR49, CSR_PMPADDR50, CSR_PMPADDR51, CSR_PMPADDR52, CSR_PMPADDR53, CSR_PMPADDR54, CSR_PMPADDR55, CSR_PMPADDR56, CSR_PMPADDR57, CSR_PMPADDR58, CSR_PMPADDR59, CSR_PMPADDR60, CSR_PMPADDR61, CSR_PMPADDR62, CSR_PMPADDR63): New CSR macros. gas/ChangeLog: * testsuite/gas/riscv/csr-dw-regnums.s: Add new CSRs. * testsuite/gas/riscv/csr-dw-regnums.d: Likewise. * testsuite/gas/riscv/csr.s: Add new CSRs. * testsuite/gas/riscv/csr-version-1p9p1.d: Likewise. * testsuite/gas/riscv/csr-version-1p9p1.l: Likewise. * testsuite/gas/riscv/csr-version-1p10.d: Likewise. * testsuite/gas/riscv/csr-version-1p10.l: Likewise. * testsuite/gas/riscv/csr-version-1p11.d: Likewise. * testsuite/gas/riscv/csr-version-1p11.l: Likewise. * testsuite/gas/riscv/csr-version-1p12.d: Likewise. * testsuite/gas/riscv/csr-version-1p12.l: Likewise.
2022-02-23RISC-V: Reorganize testcases for CFI directivesTsukasa OI2-13/+86
This commit reorganizes and adds some CSRs to csr-dw-regnums.[sd] to make it test the same CSRs as csr.s. gas/ChangeLog: * testsuite/gas/riscv/csr-dw-regnums.s: Reorganize and add defined CSRs tested in csr.s. * testsuite/gas/riscv/csr-dw-regnums.d: Likewise.
2022-02-23Automatic date update in version.inGDB Administrator1-1/+1
2022-02-22NEWS: Note that the FreeBSD async target supports async mode.John Baldwin1-0/+2
2022-02-22inf-ptrace: Add an event_pipe to be used for async mode in subclasses.John Baldwin6-148/+78
Subclasses of inf_ptrace_target have to opt-in to using the event_pipe by implementing the can_async_p and async methods. For subclasses which do this, inf_ptrace_target provides is_async_p, async_wait_fd and closes the pipe in the close target method. inf_ptrace_target also provides wrapper routines around the event pipe (async_file_open, async_file_close, async_file_flush, and async_file_mark) for use in target methods such as async. inf_ptrace_target also exports a static async_file_mark_if_open function which can be used in SIGCHLD signal handlers.
2022-02-22Enable async mode in the target in attach_cmd.John Baldwin5-22/+4
If the attach target supports async mode, enable it after the attach target's ::attach method returns.
2022-02-22fbsd-nat: Return nullptr rather than failing ::thread_name.John Baldwin1-2/+2
ptrace on FreeBSD cannot be used against running processes and instead fails with EBUSY. This meant that 'info threads' would fail if any of the threads were running (for example when using schedule-multiple=on in gdb.base/fork-running-state.exp). Instead of throwing errors, just return nullptr as no thread name is better than causing info threads to fail completely.
2022-02-22fbsd-nat: Various cleanups to the ::resume entry debug message.John Baldwin1-2/+3
Move the message from 'show debug fbsd-lwp' to 'show debug fbsd-nat' since it is helpful for debugging async target support and not just LWP support. Use target_pid_to_str to format the ptid and log the step and signo arguments.
2022-02-22fbsd-nat: Include ptrace operation in error messages.John Baldwin1-16/+18
2022-02-22fbsd-nat: Implement async target support.John Baldwin2-2/+164
This is a fairly simple version of async target support. Synchronous mode still uses blocking waitpid() calls in inf_ptrace::wait() unlike the Linux native target which always uses WNOHANG and uses sigsuspend() for synchronous operation. Asynchronous mode registers an event pipe with the core as a file handle and writes to the pipe when SIGCHLD is raised. TARGET_WNOHANG is handled by inf_ptrace::wait().
2022-02-22inf-ptrace: Support async targets in inf_ptrace_target::wait.John Baldwin1-3/+24
- Handle TARGET_WNOHANG by passing WNOHANG to waitpid and returning TARGET_WAITKIND_IGNORE if there are no events to report. - Handle a race in async mode where SIGCHLD might signal the event pipe for an event that has already been reported. If the event was the exit of the last child process, waitpid() will fail with ECHILD rather than returning a pid of 0. For this case, return TARGET_WAITKIND_NO_RESUMED.
2022-02-22inf-ptrace: Return an IGNORE event if waitpid() fails.John Baldwin1-3/+2
Previously this returned a TARGET_WAITKIND_SIGNALLED event for inferior_ptid. However, inferior_ptid is invalid during ::wait() methods after the multi-target changes, so this was triggering an assertion further up the stack.
2022-02-22do_target_wait_1: Clear TARGET_WNOHANG if the target isn't async.John Baldwin1-1/+1
Previously, TARGET_WNOHANG was cleared if a target supported async mode even if async mode wasn't currently enabled. This change only permits TARGET_WNOHANG if async mode is enabled.
2022-02-22Don't enable async mode at the end of target ::resume methods.John Baldwin3-23/+0
Now that target_resume always enables async mode after target::resume returns, these calls are redundant. The other place that target resume methods are invoked outside of target_resume are as the beneath target in record_full_wait_1. In this case, async mode should already be enabled when supported by the target before the resume method is invoked due to the following: In general, targets which support async mode run as async until ::wait returns TARGET_WAITKIND_NO_RESUMED to indicate that there are no unwaited for children (either they have exited or are stopped). When that occurs, the loop in wait_one disables async mode. Later if a stopped child is resumed, async mode is re-enabled in do_target_resume before waiting for the next event. In the case of record_full_wait_1, this function is invoked from the ::wait target method when fetching an event. If the underlying target supports async mode, then an earlier call to do_target_resume to resume the child reporting an event in the loop in record_full_wait_1 would have already enabled async mode before ::wait was invoked. In addition, nothing in the code executed in the loop in record_full_wait_1 disables async mode. Async mode is only disabled higher in the call stack in wait_one after ::wait returns. It is also true that async mode can be disabled by an INF_EXEC_COMPLETE event passed to inferior_event_handle, but all of the places that invoke that are in the gdb core which is "above" a target ::wait method. Note that there is an earlier call to enable async mode in linux_nat_target::resume. That call also marks the async event pipe to report an existing event after enabling async mode, so it needs to stay.
2022-02-22Enable async mode on supported targets in target_resume.John Baldwin2-3/+3
Enabling async mode above the target layer removes duplicate code in ::resume methods of async-capable targets. Commit 5b6d1e4fa4f ("Multi-target support") enabled async mode in do_target_resume after target_resume returns which is a step in this direction. However, other callers of target_resume such as target_continue do not enable async mode. Rather than enabling async mode in each of the callers after target_resume returns, enable async mode at the end of target_resume.
2022-02-22gdbserver linux-low: Convert linux_event_pipe to the event_pipe class.John Baldwin1-32/+11
Use event_pipe from gdbsupport in place of the existing file descriptor array.
2022-02-22gdb linux-nat: Convert linux_nat_event_pipe to the event_pipe class.John Baldwin1-43/+16
Use event_pipe from gdbsupport in place of the existing file descriptor array.
2022-02-22gdbsupport: Add an event-pipe class.John Baldwin6-3/+190
This pulls out the implementation of an event pipe used to implement target async support in both linux-low.cc (gdbserver) and linux-nat.c (gdb). This will be used to replace the existing event pipe in linux-low.cc and linux-nat.c in future commits. Co-Authored-By: Lancelot SIX <lsix@lancelotsix.com>
2022-02-22gdb: fix detection of compilation and linking flags for source-highlightRuslan Kabatsayev2-12/+12
Currently there are two problems with the detection of source-highlight via pkg-config in GDB's configure script: 1. The LDFLAGS variable is used to pass the 'pkg-config --libs' output to AC_LINK_IFELSE, which results in the "-L/some/path -lsource-highlight" preceding the conftest.cpp, which can result in a failure to find symbols referenced in conftest.cpp, if the linker is using --as-needed by default. 2. The CFLAGS variable is used to pass the 'pkg-config --cflags' output to AC_LINK_IFELSE. However, as the current language is C++, AC_LINK_IFELSE will actuall use CXXFLAGS, not CFLAGS, so any flags returned from pkg-config will not be seen. This patch fixes both of these mistakes, allowing GDB to correctly configure and build using source-highlight installed into a custom prefix, e.g. ~/opt/gdb-git (because the system version of source-highlight is too old).
2022-02-22gdb/testsuite/README: point to default value of INTERNAL_GDBFLAGSPhilippe Blain2-7/+9
The INTERNAL_GDBFLAGS runtest variable was updated in 55c3ad88013 ([gdb/testsuite] Prevent pagination in GDB_INTERNALFLAGS, 2020-10-26) to disable pagination, and in aae1c79a03a (PR python/12227..., 2010-12-07) to point to the data directory, but its default value mentioned in the testsuite's README was not kept up to date. To avoid it getting out of sync even more, point the reader to the definition of the variable in lib/gdb.exp, and move the explanation of the different flags there. Also adjust the example in the README so it follows the flags added in 55c3ad88013. Change-Id: I3533608a7d6ae5198af09c7dc7743bde24c19ed7
2022-02-22RISC-V: Maintain a string to hold the canonical orderKito Cheng1-17/+5
Using dummy entry in riscv_supported_std_ext cause confusing and wrongly support `b` and `k` extensions. bfd/ * elfxx-riscv.c (riscv_supported_std_ext): Drop unsupported extensions. (riscv_ext_canonical_order): New. (riscv_init_ext_order): Use riscv_ext_canonical_order rather than riscv_supported_std_ext to compute canonical order. V2 Changes: - Use `*ext` rather than `*ext != NULL` for checking is reach end of string.
2022-02-22Automatic date update in version.inGDB Administrator1-1/+1
2022-02-22Re: ld: Support customized output section typeAlan Modra2-9/+16
"DO NOT EDIT!" says the comment at the top of bfd-in2.h. Move the new type field where it belongs. PR ld/28841 * section.c (struct bfd_section): Add type. Formatting. (BFD_FAKE_SECTION): Formatting. * bfd-in2.h: Regenerate.
2022-02-21sim: gdbinit: hoist setup to common codeMike Frysinger12-70/+11
This was left in subdirs because of the dynamic cgen usage. However, we can move this breakpoint call to runtime and let gdb detect whether the symbol exists.
2022-02-21gdb/testsuite: relax pattern in new gdb.mi/mi-multi-commands.exp testAndrew Burgess1-4/+4
I saw some failures in the test gdb.mi/mi-multi-commands.exp that I added recently. This test was added in commit: commit d08cbc5d3203118da5583296e49273cf82378042 Date: Wed Dec 22 12:57:44 2021 +0000 gdb: unbuffer all input streams when not using readline The failures I see only occurred when my machine was very heavily loaded. In this test I send multiple commands from dejagnu to gdb with a single send_gdb call. In a well behaving world what I want to happen is that the gdb console sees both commands arrive and echos the text of those commands. Then gdb starts processing the first command, prints the result, and then processes the second command, and prints the result. However, what I saw in my loaded environment was that only after sending the two commands, only the first command was echoed to gdb's terminal. Then gdb started processing the first command, and started to write the output. Now, mixed in with the first command output, the second command was echoed to gdb's terminal. Finally, gdb would finish printing the first command output, and would read and handle the second command. This mixing of command echoing with the first command output was causing the test matching patterns to fail. In this commit I change the command I use in the test from a CLI command to an MI command, this reduces the number of lines of output that come from the test, CLI commands sent through the MI interpreter are echoed back like this: (gdb) set $a = "FIRST COMMAND" &"set $a = \"FIRST COMMAND\"\n" ^done (gdb) While this is not the case for true MI command: (gdb) -data-evaluate-expression $a ^done,value="\"FIRST COMMAND\"" (gdb) Less output makes for simpler patterns to match against. Next, when sending two command to gdb I was previously trying to spot the output of the first command followed by the prompt with nothing between. This is not really needed, for the first command I can look for just the ^done,value="\"FIRST COMMAND\"" string, then I can start looking for the output of the second command. So long as the second pattern matches up to the gdb prompt, then I can be sure than nothing is left over in the expect buffer to muck up later matches. As to see the second command output gdb must have read in the second command, the second command output never suffers from the corruption that the first command output does. Since making this change, I've not seen a failure in this test.
2022-02-21gdb: avoid nullptr access in dbxread.c from read_dbx_symtabAndrew Burgess1-49/+88
This fixes a GDB crash reported in bug pr/28900, related to reading in some stabs debug information. In this commit my goal is to stop GDB crashing. I am not trying to ensure that GDB makes the best possible use of the available stabs debug information. At this point I consider stabs a legacy debug format, with only limited support in GDB. So, the problem appears to be that, when reading in the stabs data, we need to find a N_SO entry, this is the entry that defines the start of a compilation unit (or at least the location of a corresponding source file). It is while handling an N_SO that GDB creates a psymtab to hold the incoming debug information (symbols, etc). The problem we hit in the bug is that we encounter some symbol information (an N_PC entry) outside of an N_SO entry - that is we find some symbol information that is not associated with any source file. We already have some protection for this case, look (in read_dbx_symtab) at the handling of N_PC entries of type 'F' and 'f', if we have no psymtab (the pst variable is nullptr) then we issue a complaint. However, for whatever reason, in both 'f' and 'F' handling, there is one place where we assume that the pst variable (the psymtab) is not nullptr. This is a mistake. In this commit, I guard these two locations (in 'f' and 'F' handling) so we no longer assume pst is not nullptr. While I was at it, I audited all the other uses of pst in read_dbx_symtab, and in every potentially dangerous case I added a nullptr check, and issue a suitable complaint if pst is found to be nullptr. It might well be true that we could/should do something smarter if we see a debug symbol outside of an N_SO entry, and if anyone wanted to do that work, they're welcome too. But this commit is just about preventing the nullptr access, and the subsequent GDB crash. I don't have any tests for this change, I have no idea how to generate weird stabs data for testing. The original binary from the bug report now loads just fine without GDB crashing. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28900
2022-02-21gdb: make use of std::string in dbxread.c and xcoffread.cAndrew Burgess2-28/+8
While taking a look through dbxread.c I spotted a couple of places where making use of std::string would remove the need for manual memory allocation and memcpy. During review Simon pointed out that the same code exists in xcoffread.c, so I've applied the same fix there too. There should be no user visible changes after this commit.
2022-02-21Automatic date update in version.inGDB Administrator1-1/+1
2022-02-20gdb: Only paginate for filtered output in fputs_maybe_filteredLancelot SIX1-1/+2
A have had situation where a unfiltered output (done using fputs_unfiltered) ended up triggering pagination. The backtrace for this was: ... #24 0x000055839377ee4e in check_async_event_handlers () at ../../gdb/async-event.c:335 #25 0x0000558394b67b57 in gdb_do_one_event () at ../../gdbsupport/event-loop.cc:216 #26 0x0000558394587454 in gdb_readline_wrapper (prompt=0x7ffd907712d0 "--Type <RET> for more, q to quit, c to continue without paging--") at ../../gdb/top.c:1148 #27 0x0000558394707270 in prompt_for_continue () at ../../gdb/utils.c:1438 #28 0x00005583947088b3 in fputs_maybe_filtered (linebuffer=0x60c0000f4000 " [...quite big message...]", stream=0x60300028e9d0, filter=0) at ../../gdb/utils.c:1752 #29 0x0000558394708e57 in fputs_unfiltered (linebuffer=0x60c0000f4000 " [...quite big message...]", stream=0x60300028e9d0) at ../../gdb/utils.c:1811 ... This comes from what appears to be a oversight in fputs_maybe_filtered. This function has a FILTER parameter which if true makes the function pause after every screenful (i.e. triggers pagination). The filter parameter is correctly used to guard the first place where prompt_for_continue. There is a second place in the function which can call prompt_for_continue, but is currently unguarded. I believe that this is an oversight, this patch fixes that. Tested on Linux-x86_64, no regression observed. Change-Id: Iad8ffd50a87cf20077500878e2564b5a7dc81ece
2022-02-20Automatic date update in version.inGDB Administrator1-1/+1
2022-02-19gdb/darwin: remove not-so-harmless spurious call to `wait4`Dominique Quatravaux1-3/+0
As seen in https://sourceware.org/bugzilla/show_bug.cgi?id=24069 this code will typically wait4() a second time on the same process that was already wait4()'d a few lines above. While this used to be harmless/idempotent (when we assumed that the process already exited), this now causes a deadlock in the WIFSTOPPED case. The early (~2019) history of bug #24069 cautiously suggests to use WNOHANG instead of outright deleting the call. However, tests on the current version of Darwin (Big Sur) demonstrate that gdb runs just fine without a redundant call to wait4(), as would be expected. Notwithstanding the debatable value of conserving bug compatibility with an OS release that is more than a decade old, there is scant evidence of what that double-wait4() was supposed to achieve in the first place - A cursory investigation with `git blame` pinpoints commits bb00b29d7802 and a80b95ba67e2 from the 2008-2009 era, but fails to answer the "why" question conclusively. Co-Authored-By: Philippe Blain <levraiphilippeblain@gmail.com> Change-Id: Id4e4415d66d6ff6b3552b60d761693f17015e4a0
2022-02-19Automatic date update in version.inGDB Administrator1-1/+1
2022-02-18Add constructor to bound_minimal_symbolTom Tromey6-13/+20
This adds a constructor to bound_minimal_symbol, to avoid a build failure with clang that Simon pointed out. I also took the opportunity to remove some redundant initializations, and to change one use of push_back to emplace_back, as suggested by Simon.
2022-02-18Fix typo in ld.texiRoland McGrath2-5/+9
ld/ * ld.texi (Output Section Type): Fix typo in @code syntax.
2022-02-18gdb: remove newlines from some linux_nat_debug_printf callsSimon Marchi1-3/+3
Change-Id: I80328fab7096221356864b5a4fb30858b48d2c10
2022-02-18Automatic date update in version.inGDB Administrator1-1/+1
2022-02-17Updated Serbian translations for the bfd, gold, ld and opcodes directoriesNick Clifton8-3434/+3734
2022-02-17Automatic date update in version.inGDB Administrator1-1/+1
2022-02-16ld: Support customized output section typeFangrui Song14-29/+131
bfd/ PR ld/28841 * bfd-in2.h (struct bfd_section): Add type. (discarded_section): Add field. * elf.c (elf_fake_sections): Handle bfd_section::type. * section.c (BFD_FAKE_SECTION): Add field. * mri.c (mri_draw_tree): Update function call. ld/ PR ld/28841 * ld.texi: Document new output section type. * ldlex.l: Add new token TYPE. * ldgram.y: Handle TYPE=exp. * ldlang.h: Add type_section to list of section types. * ldlang.c (lang_add_section): Handle type_section. (map_input_to_output_sections): Handle type_section. * testsuite/ld-scripts/output-section-types.t: Add tests. * testsuite/ld-scripts/output-section-types.d: Update.
2022-02-16gdb/tui: add a missing white space characterAndrew Burgess1-1/+1
Just adds a missing space. There should be no user visible changes after this commit.
2022-02-16gdb: convert callback_handler_installed from int to boolAndrew Burgess1-3/+3
Simple int to bool conversion on callback_handler_installed in event-top.c. There should be no user visible changes after this commit.
2022-02-16gas local label and dollar label handlingAlan Modra5-131/+71
Much of the gas source and older BFD source use "long" for function parameters and variables, when other types would be more appropriate. This patch fixes one of those cases. Dollar labels and numeric local labels do not need large numbers. Small positive itegers are usually all that is required. Due to allowing longs, it was possible for fb_label_name and dollar_label_name to overflow their buffers. * symbols.c: Delete unnecessary forward declarations. (dollar_labels, dollar_label_instances): Use unsigned int. (dollar_label_defined, dollar_label_instance): Likewise. (define_dollar_label): Likewise. (fb_low_counter, fb_labels, fb_label_instances): Likewise. (fb_label_instance_inc, fb_label_instance): Likewise. (fb_label_count, fb_label_max): Make them size_t. (dollar_label_name, fb_label_name): Rewrite using sprintf. * symbols.h (dollar_label_defined): Update prototype. (define_dollar_label, dollar_label_name): Likewise. (fb_label_instance_inc, fb_label_name): Likewise. * config/bfin-lex.l (yylex): Remove unnecessary casts. * expr.c (integer_constant): Likewise. * read.c (read_a_source_file): Limit numeric label range to int.
2022-02-16ubsan: s_app_line integer overflowAlan Modra1-9/+8
There are quite a few ubsan warnings in gas. This one disappears with a code tidy. * read.c (s_app_line): Rename 'l' to 'linenum'. Avoid ubsan warning.
2022-02-16pe_ILF_make_a_symbol_reloc segfaultAlan Modra1-1/+1
pei-aarch64-little apparently lacks support for BFD_RELOC_RVA. * peicode.h (pe_ILF_make_a_symbol_reloc): Don't segfault on NULL howto.
2022-02-16What to do when sh_addralign isn't a power of twoAlan Modra1-6/+7
BFD generally doesn't handle anything but a power of two section alignment, and ELF sh_addralign is required to be an integral power of two (or zero) by the ELF spec. Of course this is ignored by fuzzers, and because bfd_log2 rounds up, we can end up with alignment_power being 32 on a 32-bit object or 64 on a 64-bit object. That then triggers ubsan warnings in places like bfd_update_compression_header where we want to convert from alignment_power back to an alignment. I suppose we could reject object files that have non-compliant sh_addralign, but I think it's also reasonable to use the greatest power of two divisor of sh_addralign, ie. the rightmost 1 bit. * elf.c (_bfd_elf_make_section_from_shdr): Use greatest power of two divisor of sh_addralign. (_bfd_elf_assign_file_position_for_section): Likewise. (assign_file_positions_for_non_load_sections): Likewise.