aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
6 daysgdb/gdbserver: pass inferior arguments as a single stringAndrew Burgess8-95/+265
GDB holds the inferior arguments as a single string. Currently when GDB needs to pass the inferior arguments to a remote target as part of a vRun packet, this is done by splitting the single argument string into its component arguments by calling gdb::remote_args::split, which uses the gdb_argv class to split the arguments for us. The same gdb_argv class is used when the user has asked GDB/gdbserver to start the inferior without first invoking a shell; the gdb_argv class is used to split the argument string into it component arguments, and each is passed as a separate argument to the execve call which spawns the inferior. There is however, a problem with using gdb_argv to split the arguments before passing them to a remote target. To understand this problem we must first understand how gdb_argv is used when invoking an inferior without a shell. And to understand how gdb_argv is used to start an inferior without a shell, I feel we need to first look at an example of starting an inferior with a shell. Consider these two cases: (a) (gdb) set args \$VAR (b) (gdb) set args $VAR When starting with a shell, in case (a) the user expects the inferior to receive a literal '$VAR' string as an argument, while in case (b) the user expects to see the shell expanded value of the variable $VAR. If the user does 'set startup-with-shell off', then in (a) GDB will strip the '\' while splitting the arguments, and the inferior will be passed a literal '$VAR'. In (b) there is no '\' to strip, so also in this case the inferior will receive a literal '$VAR', remember startup-with-shell is off, so there is no shell that can ever expand $VAR. Notice, that when startup-with-shell is off, we end up with a many to one mapping, both (a) and (b) result in the literal string $VAR being passed to the inferior. I think this is the correct behaviour in this case. However, as we use gdb_argv to split the remote arguments we have the same many to one mapping within the vRun packet. But the vRun packet will be used when startup-with-shell is both on and off. What this means is that when gdbserver receives a vRun packet containing '$VAR' it doesn't know if GDB actually had '$VAR', or if GDB had '\$VAR'. And this is a huge problem. We can address this by making the argument splitting for remote targets smarter, and I do have patches that try to do this in this series: https://inbox.sourceware.org/gdb-patches/cover.1730731085.git.aburgess@redhat.com That series was pretty long, and wasn't getting reviewed, so I'm pulling the individual patches out and posting them separately. This patch doesn't try to improve remote argument splitting. I think that splitting and then joining the arguments is a mistake which can only introduce problems. The patch in the above series which tries to make the splitting and joining "smarter" handles unquoted, single quoted, and double quoted strings. But that doesn't really address parameter substitution, command substitution, or arithmetic expansion. And even if we did try to address these cases, what rules exactly would we implement? Probably POSIX shell rules, but what if the remote target doesn't have a POSIX shell? The only reason we're talking about which shell rules to follow is because the splitting and joining logic needs to mirror those rules. If we stop splitting and joining then we no longer need to care about the target's shell. Clearly, for backward compatibility we need to maintain some degree of argument splitting and joining as we currently have; and that's why I have a later patch (see the series above) that tries to improve that splitting and joining a little. But I think, what we should really do, is add a new feature flag (as used by the qSupported packet) and, if GDB and the remote target agree, we should pass the inferior arguments as a single string. This solves all our problems. In the startup with shell case, we no longer need to worry about splitting at all. The arguments are passed unmodified to the remote target, that can then pass the arguments to the shell directly. In the 'startup-with-shell off' case it is now up to the remote target to split the arguments, though in gdbserver we already did this, so nothing really changes in this case. And if the remote target doesn't have a POSIX shell, well GDB just doesn't need to worry about it! Something similar to this was originally suggested in this series: https://inbox.sourceware.org/gdb-patches/20211022071933.3478427-1-m.weghorn@posteo.de/ though this series didn't try to maintain backward compatibility, which I think is an issue that my patch solves. Additionally, this series only passed the arguments as a single string in some cases, I've simplified this so that, when GDB and the remote agree, the arguments are always passed as a single string. I think this is a little cleaner. I've also added documentation and some tests with this commit, including ensuring that we test both the new single string approach, and the fallback split/join approach. I've credited the author of the referenced series as co-author as they did come to a similar conclusion, though I think my implementation is different enough that I'm happy to list myself as primary author. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28392 Co-Authored-By: Michael Weghorn <m.weghorn@posteo.de> Reviewed-By: Eli Zaretskii <eliz@gnu.org> Tested-By: Guinevere Larsen <guinevere@redhat.com> Approved-by: Kevin Buettner <kevinb@redhat.com>
6 daysgdb/gdbserver: add a '--no-escape-args' command line optionMichael Weghorn7-55/+441
This introduces a new '--no-escape-args' option for gdb and gdbserver. I (Andrew Burgess) have based this patch from work done in this series: https://inbox.sourceware.org/gdb-patches/20211022071933.3478427-1-m.weghorn@posteo.de/ I have changed things slightly from the original series. I think this work is close enough that I've left the original author (Michael) in place and added myself as co-author. Any bugs introduced by my modifications to the original patch should be considered mine. I've also added documentation and tests which were missing from the originally proposed patch. When the startup-with-shell option is enabled, arguments passed directly as 'gdb --args <args>' or 'gdbserver <args>', are by default escaped so that they are passed to the inferior as passed on the command line, no globbing or variable substitution happens within the shell GDB uses to start the inferior. For gdbserver, this is the case since commit: commit bea571ebd78ee29cb94adf648fbcda1e109e1be6 Date: Mon May 25 11:39:43 2020 -0400 Use construct_inferior_arguments which handles special chars Only arguments set via 'set args <args>', 'run <args>', or through the Python API are not escaped in standard upstream GDB right now. For the 'gdb --args' case, directly setting unescaped args on gdb invocation is possible e.g. by using the "--eval-command='set args <args>'", while this possibility does not exist for gdbserver. This commit adds a new '--no-escape-args' command line option for GDB and gdbserver. This option is used with GDB as a replacement for the current '--args' option, and for gdbserver this new option is a flag which changes how gdbserver handles inferior arguments on the command line. When '--no-escape-args' is used inferior arguments passed on the command line will not have escaping added by GDB or gdbserver. For gdbserver, using this new option allows having the behaviour from before commit bea571ebd78ee29cb94adf648fbcda1e109e1be6, while keeping the default behaviour unified between GDB and GDBserver. For GDB the --no-escape-args option can be used as a replacement for --args, like this: shell> gdb --no-escape-args my-program arg1 arg2 arg3 While for gdbserver, the --no-escape-args option is a flag, which can be used like: shell> gdbserver --no-escape-args --once localhost:54321 \ my-program arg1 arg2 arg3 Co-Authored-By: Andrew Burgess <aburgess@redhat.com> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28392 Reviewed-By: Eli Zaretskii <eliz@gnu.org> Tested-By: Guinevere Larsen <guinevere@redhat.com>
6 dayslibsframe: testsuite: Fix testsuite build on Solaris [PR33168]Rainer Orth15-135/+98
As reported in PR libsframe/33168, the libsframe tests don't build on Solaris. The failure is In file included from libsframe/testsuite/libsframe.decode/be-flipping.c:28: /usr/include/dejagnu.h:48:1: error: conflicting types for ‘wait’; have ‘void(void)’ 48 | wait (void) | ^~~~ In file included from /usr/include/stdlib.h:16, from libsframe/testsuite/libsframe.decode/be-flipping.c:21: /usr/include/sys/wait.h:85:14: note: previous declaration of ‘wait’ with type ‘pid_t(int *)’ {aka ‘long int(int *)’} 85 | extern pid_t wait(int *); | ^~~~ We have a combination of two factors here: * Solaris <stdlib.h> has and configure.ac predefines __EXTENSIONS__ due to the use of AC_USE_SYSTEM_EXTENSIONS. * This conflicts with <dejagnu.h>'s definition void wait (void) { ... } While this version of wait was removed in upstream DejaGnu, the removal only happened after the latest release, 1.6.3. To avoid this, I've moved all testsuite includes into a new sframe-test.h, adding a workaround for the wait conflict. -Wall and -I$(srcdir) have been removed from AM_CPPFLAGS since they don't seem to be needed. To fix the Makefile fragment duplication, the local.mk files now use $(testsuite_LDADD) and $(testsuite_CPPFLAGS) throughout. Tested on {i386,amd64}-pc-solaris2.11, {sparc,sparcv9}-sun-solaris2.11, {x86_64,i686}-pc-linux-gnu, and amd64-pc-freebsd14.0. Coauthored-By: Alan Modra <amodra@gmail.com> 2025-08-31 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> Alan Modra <amodra@gmail.com> libsframe: PR libsframe/33168 * testsuite/sframe-test.h: New file. * testsuite/libsframe.decode/be-flipping.c: Replace includes by sframe-test.h. * testsuite/libsframe.decode/frecnt-1.c: Likewise. * testsuite/libsframe.decode/frecnt-2.c: Likewise. * testsuite/libsframe.encode/encode-1.c: Likewise. * testsuite/libsframe.find/findfre-1.c: Likewise. * testsuite/libsframe.find/findfunc-1.c: Likewise. * testsuite/libsframe.find/plt-findfre-1.c: Likewise. * testsuite/libsframe.find/plt-findfre-2.c: Likewise. * Makefile.am (AM_CPPFLAGS): Remove -I$(srcdir). * Makefile.in: Regenerate. * testsuite/local.mk (testsuite_LDADD): New variable. (testsuite_CPPFLAGS): Likewise. * testsuite/libsframe.decode/local.mk: Use $(testsuite_LDADD), $(testsuite_CPPFLAGS). * testsuite/libsframe.encode/local.mk: Likewise. * testsuite/libsframe.find/local.mk: Likewise.
6 days[gdb/testsuite, tclint] Fix gdb.testsuiteTom de Vries3-8/+8
Running tclint on the test-cases in gdb.testsuite shows a few problems: ... board-sanity.exp:47:38: line has trailing whitespace [trailing-whitespace] board-sanity.exp:83:1: line has trailing whitespace [trailing-whitespace] board-sanity.exp:95:38: line has trailing whitespace [trailing-whitespace] gdb-caching-proc-consistency.exp:66:2: expected braced word or word without \ substitutions in argument interpreted as expr [command-args] gdb-caching-proc-consistency.exp:117:12: eval received an argument with a \ substitution, unable to parse its arguments [command-args] with-override.exp:53:18: expression with substitutions should be enclosed by \ braces [unbraced-expr] with-override.exp:57:18: expression with substitutions should be enclosed by \ braces [unbraced-expr] ... Fix these. Tested on x86_64-linux.
6 days[gdb/testsuite] Remove gdb.testsuite/lmap.expTom de Vries1-20/+0
Test-case gdb.testsuite/lmap.exp was added to test a local definition of lmap in lib/gdb.exp. That one has been removed in commit e447f3a122c ("Require Tcl 8.6.2"). Remove the unnecessary test-case.
6 daysRISC-V: Also, fixed more ld testcases for --with-arch and --with-abiNelson Chu6-6/+12
Well these testcases cannot be fixed by .option norvc simply, that is because current linker needs to check mapping symbols before doing any rvc relaxations, https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/393 Once we support the above features, we can revert this patch.
6 daysRISC-V: Fixed more testcases for --with-arch and --with-abiNelson Chu5-1/+5
Same as cabae1c1c87d5f4ba28b7fdafe735b7c6207fb78
6 daysAutomatic date update in version.inGDB Administrator1-1/+1
6 daysAdd Ada test case with long array indicesTom Tromey4-0/+104
This patch adds a test case to test that the previous two patches did their job. With the current gdb, this test fails: (gdb) print some_regular_access.all Value out of range. The bug here is that the array has an index type that is wider than 'int', which is perfectly acceptable in Ada. Note that this series doesn't quite go far enough: in Ada the index could be a 128-bit integer. This change would be more invasive; and in practice this doesn't really seem to come up much -- so I've deferred it.
6 daysUse LONGEST rather than int for array slicesTom Tromey4-12/+10
This patch started by removing the remaining calls to longest_to_int from ada-lang.c, then chasing down the callees to make sure they were also using LONGEST. This ended up with a small change to value_slice as well.
6 daysRemove some uses of longest_to_int from ada-lang.cTom Tromey1-10/+8
A few spots in ada-lang.c use longest_to_int -- but in a context where the value is immediately passed to a function accepting LONGEST. This patch removes the offending calls. It turned out to be easy to change find_struct_field as well, so I've included that in this patch.
7 days[gdb/testsuite, tclint] Drop lreverseTom de Vries1-13/+0
When running tclint with lib/future.exp, I get: ... $ tclint lib/future.exp $exp:756:5: redefinition of built-in command 'lreverse' [redefined-builtin] ... The code was added to handle pre-7.5 tcl versions without lreverse. Since we now require Tcl 8.6.2 (as per PR testsuite/33205), drop this. Tested by rerunning tclint. Approved-By: Simon Marchi <simon.marchi@efficios.com> PR testsuite/33403 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33403
7 days[gdb/testsuite, tclint] Fix syntax error in gdb.base/dtrace-probe.expTom de Vries1-2/+2
When running tclint with gdb.base/dtrace-probe.exp I get: ... $ tclint gdb.base/dtrace-probe.exp $exp:67:45: syntax error: expected newline or semicolon, got ] ... due to these lines: ... 67 runto "-probe-dtrace test:two-locations"] 68 runto "-probe-dtrace test:two-locations"] ... Fix this by dropping the trailing ']'. Tested by rerunning tclint. Approved-By: Simon Marchi <simon.marchi@efficios.com> PR testsuite/33403 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33403
7 days[gdb/testsuite, tclint] Fix unrecognized argument in ↵Tom de Vries1-2/+2
gdb.trace/mi-traceframe-changed.exp When running tclint on gdb.trace/mi-traceframe-changed.exp, I get: ... $ tclint gdb.trace/mi-traceframe-changed.exp $exp:94:1: unrecognized argument for append: -1 [command-args] $exp:95:1: unrecognized argument for append: -1 [command-args] ... for these lines: ... 94 append testfile -1 95 append binfile -1 ... This seems harmless to me, but since tclint complains, fix this by quoting the -1 arguments. Tested by rerunning tclint. Approved-By: Simon Marchi <simon.marchi@efficios.com> PR testsuite/33403 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33403
7 daysx86: Copy non_got_ref_without_indirect_extern_accessH.J. Lu6-0/+67
Copy non_got_ref_without_indirect_extern_access when copying indirect symbol for weak alias so that _bfd_x86_elf_adjust_dynamic_symbol will properly handle GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS. bfd/ PR ld/33409 * elfxx-x86.c (_bfd_x86_elf_copy_indirect_symbol): Copy non_got_ref_without_indirect_extern_access. ld/ PR ld/33409 * testsuite/config/default.exp (NO_DIRECT_EXTERN_ACCESS_CFLAGS): New. * testsuite/ld-elf/shared.exp: Run PR ld/33409 tests. * testsuite/ld-elf/pr33409a.c: New file. * testsuite/ld-elf/pr33409b.c: Likewise. * testsuite/ld-elf/pr33409c.c: Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
7 daysx86-64: Update R_X86_64_TPOFF32 error messageH.J. Lu7-7/+7
Change R_X86_64_TPOFF32 error message from relocation R_X86_64_TPOFF32 against symbol `foo' can not be used when making a shared object; replace local-exec with initial-exec TLS model to relocation R_X86_64_TPOFF32 against symbol `foo' can not be used when making a shared object; local-exec is incompatible with -shared bfd/ PR ld/33408 * elf64-x86-64.c (elf_x86_64_need_pic): Suggest "replace local-exec with initial-exec TLS model" for R_X86_64_TPOFF32. ld/ PR ld/33408 * testsuite/ld-x86-64/tls-le-pic-1-x32.d: Updated. * testsuite/ld-x86-64/tls-le-pic-1.d: Likewise. * testsuite/ld-x86-64/tls-le-pic-2-x32.d: Likewise. * testsuite/ld-x86-64/tls-le-pic-2.d: Likewise. * testsuite/ld-x86-64/tls-le-pic-3-x32.d: Likewise. * testsuite/ld-x86-64/tls-le-pic-3.d: Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
7 daystestsuite: RISC-V: Add '.option norvc' to ensure consistent results.Jiawei5-0/+5
Add `.option norvc` to several RISC-V tests to avoid compressed instruction generation. This ensures consistent disassembly and alignment behavior regardless of assembler default options. Discussion see: https://patchwork.sourceware.org/project/binutils/patch/20250910120916.1103023-1-jiawei@iscas.ac.cn/ gas/ChangeLog: * testsuite/gas/riscv/dis-partial-insn.s: Limit compressed. * testsuite/gas/riscv/no-relax-align.s: Ditto. * testsuite/gas/riscv/odd-padding.s: Ditto. * testsuite/gas/riscv/t_insns.s: Ditto. * testsuite/gas/riscv/tlsdesc.s: Ditto.
7 daysRISC-V: Remove ^M for odd-padding.s testcaseNelson Chu1-8/+8
7 daysFix unwinding when restoring a register from one of a greater sizeKevin Buettner7-5/+215
When debugging functions where a callee-saved register is moved to a register of a larger size (e.g., a 64-bit general-purpose register to a 128-bit vector register), GDB would crash when the user issued the "return" command. For example: ldgr %f0, %r11 ; Move 64-bit general-purpose register (r11) ; to 128-bit vector register (f0) .cfi_register r11, f0 ; DW_CFA_register: r11 is stored in f0 ... lgdr %r11, %f0 ; Restore r11 from f0 .cfi_restore r11 ; DW_CFA_restore: r11 is restored to its original ; register (This example uses instructions and registers for the S390x architecture, where this bug was originally found.) If GDB is stopped in the "..." section and the user issues the "return" command, GDB crashes due to a buffer size mismatch during unwinding. Specifically, in frame_register_unwind in frame.c, a buffer the size of the original register (the 64-bit r11 in this example) has been allocated and GDB would like to use memcpy to copy the contents of the register where the original register was saved (the 128-bit f0) to the buffer for the original register. But, fortunately, GDB has an assertion which prevents this from happening: gdb_assert (buffer.size () >= value->type ()->length ()); This patch ensures that GDB uses the original register's type (e.g., r11's type) when unwinding, even if it was marked as saved to a differently typed/sized register (e.g., f0) via .cfi_register (DW_CFA_register). The fix adds a 'struct type *' parameter to value_of_register_lazy() to explicitly track the original register's type. The function frame_unwind_got_register is updated to pass the correct type for the original register. The call chain from frame_register_unwind to frame_unwind_got_register is shown by this backtrace: #0 frame_unwind_got_register (frame=..., regnum=13, new_regnum=128) at gdb/frame-unwind.c:300 #1 0x000000000135d894 in dwarf2_frame_prev_register (this_frame=..., this_cache=0x2204528, regnum=13) at gdb/dwarf2/frame.c:1187 #2 0x00000000014d9186 in frame_unwind_legacy::prev_register ( this=0x211f428 <dwarf2_frame_unwind>, this_frame=..., this_prologue_cache=0x2204528, regnum=13) at gdb/frame-unwind.c:401 #3 0x00000000014e1d12 in frame_unwind_register_value (next_frame=..., regnum=13) at gdb/frame.c:1263 #4 0x00000000014e16b8 in frame_register_unwind (next_frame=..., regnum=13, optimizedp=0x3ffffff813c, unavailablep=0x3ffffff8138, lvalp=0x3ffffff8134, addrp=0x3ffffff8128, realnump=0x3ffffff8124, buffer=...) at gdb/frame.c:1189 The register numbers shown above are for s390x. On s390x, S390_R11_REGNUM has value 13. Vector registers (like f0) are numbered differently from floating-point registers of the same name, leading to regnum 128 for f0 despite S390_F0_REGNUM being assigned a different value in s390-tdep.h. New test cases for aarch64 and x86_64 check for this on more popular architectures and also without dependency on a particular compiler to generate an unusual prologue in which a general purpose register is being moved to a vector register. In both cases, the test simulates the bug found on s390x where a 64-bit frame pointer was being moved to a much wider vector register. These test cases will cause an internal error on their respective architecture, but will pass with this fix in place. When tested on s390x linux (native), this change fixes 59 GDB internal errors and around 200 failures overall. This is the list of internal errors that no longer occur on s390x: FAIL: gdb.base/call-sc.exp: tc: return foo; return call-sc-tc (GDB internal error) FAIL: gdb.base/call-sc.exp: td: return foo; return call-sc-td (GDB internal error) FAIL: gdb.base/call-sc.exp: te: return foo; return call-sc-te (GDB internal error) FAIL: gdb.base/call-sc.exp: tf: return foo; return call-sc-tf (GDB internal error) FAIL: gdb.base/call-sc.exp: ti: return foo; return call-sc-ti (GDB internal error) FAIL: gdb.base/call-sc.exp: tl: return foo; return call-sc-tl (GDB internal error) FAIL: gdb.base/call-sc.exp: tld: return foo; return call-sc-tld (GDB internal error) FAIL: gdb.base/call-sc.exp: tll: return foo; return call-sc-tll (GDB internal error) FAIL: gdb.base/call-sc.exp: ts: return foo; return call-sc-ts (GDB internal error) FAIL: gdb.base/gnu_vector.exp: return from vector-valued function (GDB internal error) FAIL: gdb.base/return-3.exp: in foo: return (GDB internal error) FAIL: gdb.base/return-nodebug.exp: double: return from function with no debug info with a cast (GDB internal error) FAIL: gdb.base/return-nodebug.exp: float: return from function with no debug info with a cast (GDB internal error) FAIL: gdb.base/return-nodebug.exp: int: return from function with no debug info with a cast (GDB internal error) FAIL: gdb.base/return-nodebug.exp: long-long: return from function with no debug info with a cast (GDB internal error) FAIL: gdb.base/return-nodebug.exp: long: return from function with no debug info with a cast (GDB internal error) FAIL: gdb.base/return-nodebug.exp: short: return from function with no debug info with a cast (GDB internal error) FAIL: gdb.base/return-nodebug.exp: signed-char: return from function with no debug info with a cast (GDB internal error) FAIL: gdb.base/return.exp: return value 5 (GDB internal error) FAIL: gdb.base/return.exp: return value 5.0 (GDB internal error) FAIL: gdb.base/return2.exp: return from char_func (GDB internal error) FAIL: gdb.base/return2.exp: return from double_func (GDB internal error) FAIL: gdb.base/return2.exp: return from float_func (GDB internal error) FAIL: gdb.base/return2.exp: return from int_func (GDB internal error) FAIL: gdb.base/return2.exp: return from long_func (GDB internal error) FAIL: gdb.base/return2.exp: return from long_long_func (GDB internal error) FAIL: gdb.base/return2.exp: return from short_func (GDB internal error) FAIL: gdb.base/return2.exp: return from void_func (GDB internal error) FAIL: gdb.base/sigstep.exp: return from handleri: leave handler (GDB internal error) FAIL: gdb.base/structs.exp: types=tc-ti: return foo<n>; return 2 structs-tc-ti (GDB internal error) FAIL: gdb.base/structs.exp: types=tc-tl: return foo<n>; return 2 structs-tc-tl (GDB internal error) FAIL: gdb.base/structs.exp: types=tc-ts: return foo<n>; return 2 structs-tc-ts (GDB internal error) FAIL: gdb.base/structs.exp: types=tc: return foo<n>; return 1 structs-tc (GDB internal error) FAIL: gdb.base/structs.exp: types=tc: return foo<n>; return 2 structs-tc (GDB internal error) FAIL: gdb.base/structs.exp: types=tc: return foo<n>; return 3 structs-tc (GDB internal error) FAIL: gdb.base/structs.exp: types=tc: return foo<n>; return 4 structs-tc (GDB internal error) FAIL: gdb.base/structs.exp: types=tc: return foo<n>; return 5 structs-tc (GDB internal error) FAIL: gdb.base/structs.exp: types=tc: return foo<n>; return 6 structs-tc (GDB internal error) FAIL: gdb.base/structs.exp: types=tc: return foo<n>; return 7 structs-tc (GDB internal error) FAIL: gdb.base/structs.exp: types=tc: return foo<n>; return 8 structs-tc (GDB internal error) FAIL: gdb.base/structs.exp: types=td-tf: return foo<n>; return 2 structs-td-tf (GDB internal error) FAIL: gdb.base/structs.exp: types=td: return foo<n>; return 1 structs-td (GDB internal error) FAIL: gdb.base/structs.exp: types=tf-tc: return foo<n>; return 2 structs-tf-tc (GDB internal error) FAIL: gdb.base/structs.exp: types=tf-td: return foo<n>; return 2 structs-tf-td (GDB internal error) FAIL: gdb.base/structs.exp: types=tf: return foo<n>; return 1 structs-tf (GDB internal error) FAIL: gdb.base/structs.exp: types=tf: return foo<n>; return 2 structs-tf (GDB internal error) FAIL: gdb.base/structs.exp: types=ti-tc: return foo<n>; return 2 structs-ti-tc (GDB internal error) FAIL: gdb.base/structs.exp: types=ti: return foo<n>; return 1 structs-ti (GDB internal error) FAIL: gdb.base/structs.exp: types=ti: return foo<n>; return 2 structs-ti (GDB internal error) FAIL: gdb.base/structs.exp: types=tl-tc: return foo<n>; return 2 structs-tl-tc (GDB internal error) FAIL: gdb.base/structs.exp: types=tl: return foo<n>; return 1 structs-tl (GDB internal error) FAIL: gdb.base/structs.exp: types=tl: return foo<n>; return 2 structs-tl (GDB internal error) FAIL: gdb.base/structs.exp: types=tld: return foo<n>; return 1 structs-tld (GDB internal error) FAIL: gdb.base/structs.exp: types=tll: return foo<n>; return 1 structs-tll (GDB internal error) FAIL: gdb.base/structs.exp: types=ts-tc: return foo<n>; return 2 structs-ts-tc (GDB internal error) FAIL: gdb.base/structs.exp: types=ts: return foo<n>; return 1 structs-ts (GDB internal error) FAIL: gdb.base/structs.exp: types=ts: return foo<n>; return 2 structs-ts (GDB internal error) FAIL: gdb.base/structs.exp: types=ts: return foo<n>; return 3 structs-ts (GDB internal error) FAIL: gdb.base/structs.exp: types=ts: return foo<n>; return 4 structs-ts (GDB internal error) I have tested this commit on Fedora Linux, with architectures s390x, x86_64, x86_64/-m32, aarch64, ppc64le, and riscv64, with no regressions found. This v2 version makes some changes suggested by Andrew Burgess: It adds an assert to frame_unwind_got_register() and always passes the type of REGNUM to value_of_register_lazy(). It also updates value.h's comment describing value_of_register_lazy(). In his approval message, Andrew requested some changes to the tests. Those have been made exactly as requested. Approved-By: Andrew Burgess <aburgess@redhat.com>
7 daysAutomatic date update in version.inGDB Administrator1-1/+1
7 daysRename expand_symtabs_matchingTom Tromey14-178/+140
After this series, expand_symtabs_matching is now misnamed. This patch renames it, renames some associated types, and also fixes up some comments that I previously missed. Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysRemove enter_symbol_lookupTom Tromey1-41/+0
The "enter_symbol_lookup" class was introduced to work around the lack of reentrancy in symbol lookup. There were two problems here: 1. The DWARF reader kept a mark bit on the dwarf2_per_cu_data object. This bit is gone now, replaced with a local mark vector. 2. Some spots in gdb first examined the expanded symbol tables, and then on failure expanded some symtabs and searched the newly expanded ones (skipping previousy-expanded ones). Fixing this has been the main point of this series. Now that both of these barriers are gone, I think enter_symbol_lookup can be removed. One proof of this idea is that, without the first fix mentioned above, py-symbol.exp regressed because gdbpy_lookup_static_symbols did not first ensure that the current language was set -- i.e., there was a latent bug in the enter_symbol_lookup patch anyway. Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysMake dw_expand_symtabs_matching_file_matcher staticTom Tromey2-10/+8
dw_expand_symtabs_matching_file_matcher is no longer needed outside of read.c, so it can be made static. Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysConvert lookup_symbol_in_objfileTom Tromey1-14/+2
This converts lookup_symbol_in_objfile to the callback approach by removing the call to lookup_symbol_in_objfile_symtabs. (The latter is not removed as there are still other callers.) Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16994 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16998 Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysConvert lookup_symbol_via_quick_fnsTom Tromey1-17/+22
This converts lookup_symbol_via_quick_fns to the callback approach, merging the search loop and the call to expand_symtabs_matching. Note that this changes lookup_symbol_via_quick_fns to use a best_symbol_tracker. Before this patch there was a discrepancy here between the two search functions. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16994 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16998 Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysAdd best_symbol_trackerTom Tromey3-40/+49
This adds a new best_symbol_tracker struct. This is used to implement the "best symbol" logic that is used sometimes in symtab.c. This approach makes it simpler and more efficient to track the "best" symbol when searching across multiple blocks. Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysSimplify block_lookup_symbolTom Tromey1-22/+1
One loop in block_lookup_symbol is identical to the code in block_lookup_symbol_primary. This patch simplifies the former by having it call the latter. This removes an assert. However, note that the assert is not needed -- it does not check any invariant that must be maintained. Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysPass lookup_name_info to block_lookup_symbol_primaryTom Tromey3-6/+6
This changes block_lookup_symbol_primary to accept a lookup_name_info. This follows the general trend of hoisting these objects to the outermost layer where they make sense -- somewhat reducing the cost of using them. Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysSimplify block_lookup_symbol_primaryTom Tromey1-8/+2
This simplifies block_lookup_symbol_primary by using block_iterator_range. Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysConvert linespec.c:iterate_over_all_matching_symtabsTom Tromey1-7/+10
This converts linespec.c:iterate_over_all_matching_symtabs to the callback approach, merging the search loop and the call to expand_symtabs_matching. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16994 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16998 Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysRemove objfile::expand_symtabs_for_functionTom Tromey3-37/+17
objfile::expand_symtabs_for_function only has a single caller now, so it can be removed. This also allows us to merge the expansion and searching phases, as done in other patches in this series. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16994 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16998 Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysSimplify basic_lookup_transparent_typeTom Tromey2-58/+4
This patch changes basic_lookup_transparent_type to always work via the "quick" API -- that is, no separate search of the already-expanded symtabs is needed. This is more efficient when many CUs have already been expanded. It also makes the lookup more consistent, as the result is no longer dependent on the order in which CUs were previously expanded. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16994 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16998 Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysRemove expand_symtabs_matchingTom Tromey2-34/+0
The last caller of the global expand_symtabs_matching function has been changed, so now we can remove this function. Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysConvert ada-lang.c:map_matching_symbolsTom Tromey1-11/+11
This converts ada-lang.c:map_matching_symbols to the callback approach, merging the search loop and the call to expand_symtabs_matching. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16994 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16998 Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysConvert ada_language_defn::collect_symbol_completion_matchesTom Tromey1-40/+27
This converts ada_language_defn::collect_symbol_completion_matches to the callback approach, merging the search loop and the call to expand_symtabs_matching. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16994 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16998 Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysConvert ada_add_global_exceptionsTom Tromey1-22/+25
This converts ada_add_global_exceptions to the callback approach, merging the search loop and the call to expand_symtabs_matching. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16994 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16998 Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysConvert gdbpy_lookup_static_symbolsTom Tromey1-9/+13
This changes gdbpy_lookup_static_symbols to the callback approach, merging the search loop and the call to expand_symtabs_matching. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16994 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16998 Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysConvert default_collect_symbol_completion_matches_break_onTom Tromey1-19/+14
This converts default_collect_symbol_completion_matches_break_on to the callback approach, merging the search loop and the call to expand_symtabs_matching. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16994 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16998 Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysRewrite the .gdb_index readerTom Tromey7-1040/+309
This patch rewrites the .gdb_index reader to create the same data structures that are created by the cooked indexer and the .debug_names reader. This is done in support of this series; but also because, from what I can tell, the "templates.exp" change didn't really work properly with this reader. In addition to fixing that problem, this patch removes a lot of code. Implementing this required a couple of hacks, as .gdb_index does not contain all the information that's used by the cooked index implementation. * The index-searching code likes to differentiate between the various DWARF tags when matching, but .gdb_index lumps many things into a single "other" category. To handle this, we introduce a phony tag that's used so that the match method can match on multiple domains. * Similarly, .gdb_index doesn't distinguish between the type and struct domains, so another phony tag is used for this. * The reader must attempt to guess the language of various symbols. This is somewhat finicky. "Plain" (unqualified) symbols are marked as language_unknown and then a couple of hacks are used to handle these -- one in expand_symtabs_matching and another when recognizing "main". For what it's worth, I consider .gdb_index to be near the end of its life. While .debug_names is not perfect -- we found a number of bugs in the standard while implementing it -- it is better than .gdb_index and also better documented. After this patch, we could conceivably remove dwarf_scanner_base. However, I have not done this. Finally, this patch also changes this reader to dump the content of the index, as the other DWARF readers do. This can be handy when debugging gdb. Acked-By: Simon Marchi <simon.marchi@efficios.com> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33316
7 daysHave expand_symtabs_matching work for already-expanded CUsTom Tromey2-17/+30
Currently, gdb will search the already-expanded symtabs in one loop, and then also expand matching symtabs in another loop. However, this is somewhat inefficient -- when searching the already-expanded symtabs, all such symtabs are examined. However, the various "quick" implementations already know which subset of symtabs might have a match. This changes the contract of expand_symtabs_matching to also call the callback for an already-expanded symtab. With this change, and some subsequent enabling changes, the number of searched symtabs should sometimes be reduced. This also cuts down on the amount of redundant code. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16994 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16998 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30736 Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysRemove dwarf2_per_cu_data::markTom Tromey3-46/+83
This removes dwarf2_per_cu_data::mark, replacing it with a locally-allocated boolean vector. It also inverts the sense of the flag -- now, the flag is true when a CU should be skipped, and false when the CU should be further examined. Also, the validity of the flag is no longer dependent on 'file_matcher != NULL'. This patch makes the subsequent patch to searching a bit simpler, so I've separated it out. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16994 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16998 Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysEntries from anon-struct.exp not in cooked indexTom Tromey3-0/+40
g++ will sometimes use a typedef to give a name to an otherwise anonymous type for linkage purposes. gdb tries to handle this odd scenario, which is enforced by anon-struct.exp. It's difficult to detect this problem in the current tree, but the cooked index does not include an entry for these DIEs. This patch changes gdb to add these to the index. This is needed by subsequent changes in this series. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32519 Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysRestore "ingestion" of .debug_str when writing .debug_namesTom Tromey1-10/+14
When I rewrote the .debug_names writer (commit 91a42a61), I changed the writer to not import .debug_str into the debug_str_lookup object. However, a later patch in this series needed this again. The issue here was that if a name occurs in the DWARF, and is also allocated, then there is a race, where the created index depends on which DIE is read first. This can cause index-file.exp failures. This patch restores the old approach, avoiding this problem. I also applied a couple of small cleanups to the class. And, I removed the old complaint from the "ingestion" function, as this was not necessary. Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysPut all CTF symbols in global scopeTom Tromey2-5/+5
The new approach to searching (solely via the quick API) is more sensitive to discrepancies between the partial and full readers. In CTF, there is some disagreement about which scope to use. CTF doesn't seem to really distinguish between the file and global scope, so this patch takes the simple approach of putting all CTF symbols into the global scope. This changes one test as well. It seems to me that the behavior here is arbitrary and the test is making unwarranted assumptions. Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysFix index's handling of DW_TAG_imported_declarationTom Tromey3-1/+10
Currently the full symbol reader puts DW_TAG_imported_declaration in TYPE_DOMAIN, in the global scope. This patch changes the cooked indexer to follow. Without this patch, a later patch in the series would cause nsalias.exp to regress. This also updates read-gdb-index.c to do something similar. Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysAda import functions not in indexTom Tromey6-23/+43
The cooked index does not currently contain entries for Ada import functions. This means that whether or not these are visible to "break" depends on which CUs were previously expanded -- clearly a bug. This patch fixes the issue. I think the comments in the patch explain the fix reasonably well. Perhaps one to-do item here is to change GNAT to use DW_TAG_imported_declaration for these imports. This may eventually let us remove some of the current hacks. This version includes a fix from Simon to initialize the new member. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32511 Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysEmit some type declarations in .gdb_indexTom Tromey1-8/+68
If you run struct-decl.exp with the .gdb_index board, you will see that "the_type" is not emitted in the index. This would cause a failure in this series. The fix is to ensure that certain necessary type declarations are emitted. However, a naive fix here will regress stub-array-size.exp, where a type declaration and a type definition are both seen -- but the declaration is seen first and causes a failure. This is handled by adding some code (including a mild hack) to filter out type declarations when a corresponding type definition is seen. Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysChange ada_decode to preserve upper-case in some situationsTom Tromey4-34/+69
This patch is needed to avoid regressions later in the series. The issue here is that ada_decode, when called with wide=false, would act as though the input needed verbatim quoting. That would happen because the 'W' character would be passed through; and then a later loop would reject the result due to that character. Similarly, with operators=false the upper-case-checking loop would be skipped, but then some names that did need verbatim quoting would pass through. Furthermore I noticed that there isn't a need to distinguish between the "wide" and "operators" cases -- all callers pass identical values to both. This patch cleans up the above, consolidating the parameters and changing how upper-case detection is handled, so that both the operator and wide cases pass-through without issue. I've added new unit tests for this. Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysAdd another minor hack to cooked_index_entry::full_nameTom Tromey1-0/+7
This patch adds another minor hack to cooked_index_entry::full_name. In particular, if GNAT emits non-hierarchical names (still the default as the hierarchical series is blocked on one tricky problem), then a request to compute the "linkage-style" name will now just return the 'name' field. Without this tweak, this series would regress ada-cold-name.exp, because the search would look for "name.cold" but the index would return "name[cold]" as the "linkage" name (which would be wrong). This area is a bit difficult to unravel. The best plan here, IMO, is to change Ada to work like the other languages in gdb: store the natural name and do searches with that name. I think this is achievable, but I didn't want to try it here. I've updated the relevant bug (tagged below) to reflect this. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32766 Acked-By: Simon Marchi <simon.marchi@efficios.com>
7 daysSkip some tests with "readnow" boardTom Tromey3-0/+12
This series pointed out a few tests that check that a particular index is in use. It seems to me that this does not really make sense when the "readnow" board is in use, as this actually skips index creation. The tests do pass today, but by accident. This patch adds the appropriate "require" line to the tests in question. Approved-By: Simon Marchi <simon.marchi@efficios.com> Acked-By: Simon Marchi <simon.marchi@efficios.com>