aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb')
-rw-r--r--gdb/Makefile.in3
-rw-r--r--gdb/NEWS12
-rw-r--r--gdb/aarch64-linux-nat.c14
-rw-r--r--gdb/aarch64-linux-tdep.c171
-rw-r--r--gdb/aarch64-tdep.c199
-rw-r--r--gdb/aarch64-tdep.h2
-rw-r--r--gdb/ada-exp.y4
-rw-r--r--gdb/ada-lang.c13
-rw-r--r--gdb/ada-tasks.c2
-rw-r--r--gdb/amd64-linux-nat.c21
-rw-r--r--gdb/amdgpu-tdep.c2
-rw-r--r--gdb/annotate.c2
-rw-r--r--gdb/arc-tdep.c2
-rw-r--r--gdb/arch-utils.c4
-rw-r--r--gdb/arch/aarch64-mte-linux.c56
-rw-r--r--gdb/arch/aarch64-mte-linux.h27
-rw-r--r--gdb/arch/aarch64-mte.c77
-rw-r--r--gdb/arch/aarch64-mte.h51
-rw-r--r--gdb/arm-linux-nat.c98
-rw-r--r--gdb/auto-load.c4
-rw-r--r--gdb/breakpoint.c58
-rw-r--r--gdb/build-id.c174
-rw-r--r--gdb/c-exp.y3
-rw-r--r--gdb/cli/cli-cmds.c19
-rw-r--r--gdb/command.h2
-rw-r--r--gdb/compile/compile.c4
-rwxr-xr-xgdb/configure2
-rw-r--r--gdb/configure.tgt3
-rw-r--r--gdb/d-exp.y3
-rw-r--r--gdb/doc/gdb.texinfo42
-rw-r--r--gdb/dwarf2/loc.c2
-rw-r--r--gdb/dwarf2/macro.c31
-rw-r--r--gdb/eval.c9
-rw-r--r--gdb/event-top.c2
-rw-r--r--gdb/f-exp.y39
-rw-r--r--gdb/fbsd-tdep.c14
-rw-r--r--gdb/frame.c2
-rw-r--r--gdb/gcore.in12
-rw-r--r--gdb/gdb-gdb.py.in2
-rw-r--r--gdb/gdbarch-gen.c (renamed from gdb/gdbarch.c)0
-rwxr-xr-xgdb/gdbarch.py2
-rw-r--r--gdb/go-exp.y4
-rw-r--r--gdb/guile/guile-internal.h28
-rw-r--r--gdb/guile/scm-objfile.c2
-rw-r--r--gdb/i386-linux-nat.c18
-rw-r--r--gdb/inf-child.c15
-rw-r--r--gdb/inf-child.h2
-rw-r--r--gdb/infcall.c2
-rw-r--r--gdb/infcmd.c13
-rw-r--r--gdb/infrun.c20
-rw-r--r--gdb/inline-frame.c51
-rw-r--r--gdb/jit.c4
-rw-r--r--gdb/linespec.c68
-rw-r--r--gdb/loongarch-linux-nat.c16
-rw-r--r--gdb/loongarch-tdep.c24
-rw-r--r--gdb/macrocmd.c93
-rw-r--r--gdb/macroscope.c6
-rw-r--r--gdb/macrotab.c89
-rw-r--r--gdb/macrotab.h21
-rw-r--r--gdb/mi/mi-cmd-file.c4
-rw-r--r--gdb/mips-linux-tdep.c7
-rw-r--r--gdb/nat/aarch64-mte-linux-ptrace.c9
-rw-r--r--gdb/nat/aarch64-scalable-linux-ptrace.c11
-rw-r--r--gdb/nat/fork-inferior.h7
-rw-r--r--gdb/nat/linux-namespaces.c2
-rw-r--r--gdb/objfiles.c135
-rw-r--r--gdb/objfiles.h59
-rw-r--r--gdb/p-exp.y4
-rw-r--r--gdb/parse.c7
-rw-r--r--gdb/printcmd.c4
-rw-r--r--gdb/progspace.c4
-rw-r--r--gdb/python/lib/gdb/dap/scopes.py23
-rw-r--r--gdb/python/py-objfile.c2
-rw-r--r--gdb/python/py-value.c3
-rw-r--r--gdb/python/python-internal.h5
-rw-r--r--gdb/python/python.c2
-rw-r--r--gdb/record-full.c1
-rw-r--r--gdb/remote-sim.c3
-rw-r--r--gdb/remote.c107
-rw-r--r--gdb/riscv-tdep.c2
-rw-r--r--gdb/solib-darwin.c14
-rw-r--r--gdb/solib-frv.c4
-rw-r--r--gdb/solib-svr4.c6
-rw-r--r--gdb/solib.c39
-rw-r--r--gdb/solib.h4
-rw-r--r--gdb/source.c20
-rw-r--r--gdb/source.h7
-rw-r--r--gdb/symfile.c37
-rw-r--r--gdb/symtab.c14
-rw-r--r--gdb/target.c41
-rw-r--r--gdb/target.h20
-rw-r--r--gdb/testsuite/gdb.ada/mi_task_arg.exp7
-rw-r--r--gdb/testsuite/gdb.ada/mi_var_access.exp3
-rw-r--r--gdb/testsuite/gdb.ada/variant_record_field.exp50
-rw-r--r--gdb/testsuite/gdb.ada/variant_record_field/foo.adb47
-rw-r--r--gdb/testsuite/gdb.arch/arm-pseudo-unwind-legacy.c9
-rw-r--r--gdb/testsuite/gdb.arch/arm-pseudo-unwind.c9
-rw-r--r--gdb/testsuite/gdb.base/assign.exp34
-rw-r--r--gdb/testsuite/gdb.base/bitfields.exp18
-rw-r--r--gdb/testsuite/gdb.base/build-id-seqno.c22
-rw-r--r--gdb/testsuite/gdb.base/build-id-seqno.exp134
-rw-r--r--gdb/testsuite/gdb.base/catch-syscall.exp2
-rw-r--r--gdb/testsuite/gdb.base/completion.exp8
-rw-r--r--gdb/testsuite/gdb.base/complex-parts.exp93
-rw-r--r--gdb/testsuite/gdb.base/cond-expr.exp8
-rw-r--r--gdb/testsuite/gdb.base/coredump-filter-build-id.exp2
-rw-r--r--gdb/testsuite/gdb.base/corefile.exp2
-rw-r--r--gdb/testsuite/gdb.base/cvexpr.exp264
-rw-r--r--gdb/testsuite/gdb.base/eval-skip.exp85
-rw-r--r--gdb/testsuite/gdb.base/examine-backward.exp56
-rw-r--r--gdb/testsuite/gdb.base/exprs.exp4
-rw-r--r--gdb/testsuite/gdb.base/fileio.exp10
-rw-r--r--gdb/testsuite/gdb.base/foll-exec.exp30
-rw-r--r--gdb/testsuite/gdb.base/gcorebg.c76
-rw-r--r--gdb/testsuite/gdb.base/gcorebg.exp82
-rw-r--r--gdb/testsuite/gdb.base/hbreak2.exp10
-rw-r--r--gdb/testsuite/gdb.base/history-duplicates.exp10
-rw-r--r--gdb/testsuite/gdb.base/index-cache.exp2
-rw-r--r--gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp2
-rw-r--r--gdb/testsuite/gdb.base/interact.exp6
-rw-r--r--gdb/testsuite/gdb.base/limited-length.c2
-rw-r--r--gdb/testsuite/gdb.base/limited-length.exp10
-rw-r--r--gdb/testsuite/gdb.base/list-dot-nodebug.exp37
-rw-r--r--gdb/testsuite/gdb.base/opaque.exp22
-rw-r--r--gdb/testsuite/gdb.base/pending.exp4
-rw-r--r--gdb/testsuite/gdb.base/printcmds.exp2
-rw-r--r--gdb/testsuite/gdb.base/recurse.exp18
-rw-r--r--gdb/testsuite/gdb.base/setshow.exp36
-rw-r--r--gdb/testsuite/gdb.base/setvar.exp8
-rw-r--r--gdb/testsuite/gdb.base/skip.exp8
-rw-r--r--gdb/testsuite/gdb.base/solib-display.exp2
-rw-r--r--gdb/testsuite/gdb.base/solib-search.exp6
-rw-r--r--gdb/testsuite/gdb.base/step-break.exp12
-rw-r--r--gdb/testsuite/gdb.base/step-into-other-file.c31
-rw-r--r--gdb/testsuite/gdb.base/step-into-other-file.exp36
-rw-r--r--gdb/testsuite/gdb.base/step-into-other-file.h18
-rw-r--r--gdb/testsuite/gdb.base/step-over-syscall.exp6
-rw-r--r--gdb/testsuite/gdb.base/sysroot-debug-lookup.exp13
-rw-r--r--gdb/testsuite/gdb.base/vla-optimized-out.exp6
-rw-r--r--gdb/testsuite/gdb.base/vla-ptr.exp8
-rw-r--r--gdb/testsuite/gdb.base/vla-sideeffect.exp12
-rw-r--r--gdb/testsuite/gdb.base/watch-vfork.exp4
-rw-r--r--gdb/testsuite/gdb.base/wchar.exp6
-rw-r--r--gdb/testsuite/gdb.base/whatis-ptype-typedefs.exp14
-rw-r--r--gdb/testsuite/gdb.cp/anon-ns.exp10
-rw-r--r--gdb/testsuite/gdb.cp/classes.exp2
-rw-r--r--gdb/testsuite/gdb.cp/exception.exp2
-rw-r--r--gdb/testsuite/gdb.cp/m-static.exp19
-rw-r--r--gdb/testsuite/gdb.cp/member-ptr.exp22
-rw-r--r--gdb/testsuite/gdb.cp/meth-typedefs.exp10
-rw-r--r--gdb/testsuite/gdb.cp/method2.exp4
-rw-r--r--gdb/testsuite/gdb.cp/misc.exp4
-rw-r--r--gdb/testsuite/gdb.cp/nested-types.exp4
-rw-r--r--gdb/testsuite/gdb.cp/ovldbreak.exp8
-rw-r--r--gdb/testsuite/gdb.cp/pass-by-ref-2.exp8
-rw-r--r--gdb/testsuite/gdb.cp/pass-by-ref.exp4
-rw-r--r--gdb/testsuite/gdb.cp/templates.exp15
-rw-r--r--gdb/testsuite/gdb.dap/rust-slices.exp6
-rw-r--r--gdb/testsuite/gdb.dap/step-out.exp14
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-anon-mptr.exp16
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-lines.exp6
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp17
-rw-r--r--gdb/testsuite/gdb.dwarf2/macro-complaints.exp198
-rw-r--r--gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp16
-rw-r--r--gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/entry-point.exp4
-rw-r--r--gdb/testsuite/gdb.fortran/intrinsics.exp8
-rw-r--r--gdb/testsuite/gdb.fortran/multi-dim.exp8
-rw-r--r--gdb/testsuite/gdb.fortran/size.exp4
-rw-r--r--gdb/testsuite/gdb.fortran/type-kinds.exp22
-rw-r--r--gdb/testsuite/gdb.fortran/types.exp19
-rw-r--r--gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp12
-rw-r--r--gdb/testsuite/gdb.fortran/vla-datatypes.exp10
-rw-r--r--gdb/testsuite/gdb.fortran/vla-ptype-sub.exp30
-rw-r--r--gdb/testsuite/gdb.fortran/vla-value-sub.exp38
-rw-r--r--gdb/testsuite/gdb.fortran/vla-value.exp18
-rw-r--r--gdb/testsuite/gdb.gdb/index-file.exp20
-rw-r--r--gdb/testsuite/gdb.gdb/python-helper.exp15
-rw-r--r--gdb/testsuite/gdb.guile/scm-frame.exp4
-rw-r--r--gdb/testsuite/gdb.guile/scm-parameter.exp24
-rw-r--r--gdb/testsuite/gdb.guile/scm-symbol.exp4
-rw-r--r--gdb/testsuite/gdb.guile/scm-type.exp28
-rw-r--r--gdb/testsuite/gdb.mi/mi-stepi.exp12
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-cmd.exp22
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-cp.cc6
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-display.exp12
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-invalidate.exp4
-rw-r--r--gdb/testsuite/gdb.mi/var-cmd.c12
-rw-r--r--gdb/testsuite/gdb.multi/base.exp4
-rw-r--r--gdb/testsuite/gdb.multi/dummy-frame-restore.exp8
-rw-r--r--gdb/testsuite/gdb.multi/pending-bp-lib.c22
-rw-r--r--gdb/testsuite/gdb.multi/pending-bp.c66
-rw-r--r--gdb/testsuite/gdb.multi/pending-bp.exp126
-rw-r--r--gdb/testsuite/gdb.opt/inline-bt.exp26
-rw-r--r--gdb/testsuite/gdb.opt/inline-cmds.exp18
-rw-r--r--gdb/testsuite/gdb.python/py-cmd.exp8
-rw-r--r--gdb/testsuite/gdb.python/py-disasm-exec.exp21
-rw-r--r--gdb/testsuite/gdb.python/py-disasm-obj.exp21
-rw-r--r--gdb/testsuite/gdb.python/py-disasm.exp.tcl (renamed from gdb/testsuite/gdb.python/py-disasm.exp)56
-rw-r--r--gdb/testsuite/gdb.python/py-disasm.py8
-rw-r--r--gdb/testsuite/gdb.python/py-format-string.exp8
-rw-r--r--gdb/testsuite/gdb.python/py-frame.exp8
-rw-r--r--gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-missing-debug.exp3
-rw-r--r--gdb/testsuite/gdb.python/py-progspace.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-type.exp34
-rw-r--r--gdb/testsuite/gdb.python/py-xmethods.exp4
-rw-r--r--gdb/testsuite/gdb.reverse/step-precsave.exp2
-rw-r--r--gdb/testsuite/gdb.server/build-id-seqno.c22
-rw-r--r--gdb/testsuite/gdb.server/build-id-seqno.exp200
-rw-r--r--gdb/testsuite/gdb.server/remote-read-msgs.exp3
-rw-r--r--gdb/testsuite/gdb.server/solib-list.exp2
-rw-r--r--gdb/testsuite/gdb.threads/leader-exit-attach.exp14
-rw-r--r--gdb/testsuite/gdb.threads/print-threads.exp6
-rw-r--r--gdb/testsuite/gdb.threads/schedlock.exp6
-rw-r--r--gdb/testsuite/gdb.trace/entry-values.exp4
-rw-r--r--gdb/testsuite/gdb.xml/tdesc-arch.exp8
-rw-r--r--gdb/testsuite/lib/cache.exp136
-rw-r--r--gdb/testsuite/lib/check-test-names.exp10
-rw-r--r--gdb/testsuite/lib/gdb-utils.exp8
-rw-r--r--gdb/testsuite/lib/gdb.exp136
-rw-r--r--gdb/testsuite/lib/mi-support.exp37
-rw-r--r--gdb/tid-parse.c2
-rw-r--r--gdb/tid-parse.h2
-rw-r--r--gdb/top.h2
-rw-r--r--gdb/trad-frame.c8
-rw-r--r--gdb/tui/tui-disasm.c6
-rw-r--r--gdb/tui/tui-hooks.c3
-rw-r--r--gdb/tui/tui-source.c5
-rw-r--r--gdb/tui/tui-winsource.c10
-rw-r--r--gdb/unittests/intrusive_list-selftests.c1
-rw-r--r--gdb/utils.c2
-rw-r--r--gdb/value.c93
-rw-r--r--gdb/value.h35
-rw-r--r--gdb/xml-support.c4
-rw-r--r--gdb/xml-support.h5
236 files changed, 3782 insertions, 1836 deletions
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 1c697bf..6744b82 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -746,6 +746,7 @@ ALL_64_TARGET_OBS = \
amd64-windows-tdep.o \
arch/aarch64.o \
arch/aarch64-insn.o \
+ arch/aarch64-mte.o \
arch/aarch64-mte-linux.o \
arch/aarch64-scalable-linux.o \
arch/amd64-linux-tdesc.o \
@@ -1551,6 +1552,7 @@ HFILES_NO_SRCDIR = \
arch/aarch32.h \
arch/aarch64.h \
arch/aarch64-insn.h \
+ arch/aarch64-mte.h \
arch/aarch64-mte-linux.h \
arch/aarch64-scalable-linux.h \
arch/amd64-linux-tdesc.h \
@@ -1664,6 +1666,7 @@ ALLDEPFILES = \
arch/aarch32.c \
arch/aarch64.c \
arch/aarch64-insn.c \
+ arch/aarch64-mte.c \
arch/aarch64-mte-linux.c \
arch/aarch64-scalable-linux.c \
arch/amd64.c \
diff --git a/gdb/NEWS b/gdb/NEWS
index 47677cb..50c033a 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -8,11 +8,18 @@
** The "scopes" request will now return a scope holding global
variables from the stack frame's compilation unit.
+ ** The "scopes" request will return a "returnValue" scope holding
+ the return value from the latest "stepOut" command, when
+ appropriate.
+
* For ARM targets, the offset of the pc in the jmp_buf has been fixed to match
glibc 2.20 and later. This should only matter when not using libc probes.
This may cause breakage when using an incompatible libc, like uclibc or
newlib, or an older glibc.
+* MTE (Memory Tagging Extension) debugging is now supported on AArch64 baremetal
+ targets.
+
*** Changes in GDB 15
* The MPX commands "show/set mpx bound" have been deprecated, as Intel
@@ -224,6 +231,11 @@ qIsAddressTagged
file is about, this new packet provides a more generic way to perform such
a check.
+vFile:stat
+ Return information about files on the remote system. Like
+ vFile:fstat but takes a filename rather than an open file
+ descriptor.
+
*** Changes in GDB 14
* GDB now supports the AArch64 Scalable Matrix Extension 2 (SME2), which
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 2e6541f..0fa5bee 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -496,12 +496,11 @@ fetch_tlsregs_from_thread (struct regcache *regcache)
gdb_assert (regno != -1);
gdb_assert (tdep->tls_register_count > 0);
- uint64_t tpidrs[tdep->tls_register_count];
- memset(tpidrs, 0, sizeof(tpidrs));
+ std::vector<uint64_t> tpidrs (tdep->tls_register_count);
struct iovec iovec;
- iovec.iov_base = tpidrs;
- iovec.iov_len = sizeof (tpidrs);
+ iovec.iov_base = tpidrs.data ();
+ iovec.iov_len = tpidrs.size () * sizeof (tpidrs[0]);
int tid = get_ptrace_pid (regcache->ptid ());
if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_TLS, &iovec) != 0)
@@ -524,8 +523,7 @@ store_tlsregs_to_thread (struct regcache *regcache)
gdb_assert (regno != -1);
gdb_assert (tdep->tls_register_count > 0);
- uint64_t tpidrs[tdep->tls_register_count];
- memset(tpidrs, 0, sizeof(tpidrs));
+ std::vector<uint64_t> tpidrs (tdep->tls_register_count);
for (int i = 0; i < tdep->tls_register_count; i++)
{
@@ -536,8 +534,8 @@ store_tlsregs_to_thread (struct regcache *regcache)
}
struct iovec iovec;
- iovec.iov_base = &tpidrs;
- iovec.iov_len = sizeof (tpidrs);
+ iovec.iov_base = tpidrs.data ();
+ iovec.iov_len = tpidrs.size () * sizeof (tpidrs[0]);
int tid = get_ptrace_pid (regcache->ptid ());
if (ptrace (PTRACE_SETREGSET, tid, NT_ARM_TLS, &iovec) != 0)
diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index a1296a8..c608a84 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -48,6 +48,7 @@
#include "record-full.h"
#include "linux-record.h"
+#include "arch/aarch64-mte.h"
#include "arch/aarch64-mte-linux.h"
#include "arch/aarch64-scalable-linux.h"
@@ -1297,8 +1298,7 @@ aarch64_linux_supply_za_regset (const struct regset *regset,
}
else
{
- gdb_byte za_zeroed[za_bytes];
- memset (za_zeroed, 0, za_bytes);
+ gdb::byte_vector za_zeroed (za_bytes, 0);
regcache->raw_supply (tdep->sme_za_regnum, za_zeroed);
}
}
@@ -2427,29 +2427,6 @@ aarch64_linux_gcc_target_options (struct gdbarch *gdbarch)
return {};
}
-/* Helper to get the allocation tag from a 64-bit ADDRESS.
-
- Return the allocation tag if successful and nullopt otherwise. */
-
-static std::optional<CORE_ADDR>
-aarch64_mte_get_atag (CORE_ADDR address)
-{
- gdb::byte_vector tags;
-
- /* Attempt to fetch the allocation tag. */
- if (!target_fetch_memtags (address, 1, tags,
- static_cast<int> (memtag_type::allocation)))
- return {};
-
- /* Only one tag should've been returned. Make sure we got exactly that. */
- if (tags.size () != 1)
- error (_("Target returned an unexpected number of tags."));
-
- /* Although our tags are 4 bits in size, they are stored in a
- byte. */
- return tags[0];
-}
-
/* Implement the tagged_address_p gdbarch method. */
static bool
@@ -2466,132 +2443,6 @@ aarch64_linux_tagged_address_p (struct gdbarch *gdbarch, CORE_ADDR address)
return true;
}
-/* Implement the memtag_matches_p gdbarch method. */
-
-static bool
-aarch64_linux_memtag_matches_p (struct gdbarch *gdbarch,
- struct value *address)
-{
- gdb_assert (address != nullptr);
-
- CORE_ADDR addr = value_as_address (address);
-
- /* Fetch the allocation tag for ADDRESS. */
- std::optional<CORE_ADDR> atag
- = aarch64_mte_get_atag (gdbarch_remove_non_address_bits (gdbarch, addr));
-
- if (!atag.has_value ())
- return true;
-
- /* Fetch the logical tag for ADDRESS. */
- gdb_byte ltag = aarch64_mte_get_ltag (addr);
-
- /* Are the tags the same? */
- return ltag == *atag;
-}
-
-/* Implement the set_memtags gdbarch method. */
-
-static bool
-aarch64_linux_set_memtags (struct gdbarch *gdbarch, struct value *address,
- size_t length, const gdb::byte_vector &tags,
- memtag_type tag_type)
-{
- gdb_assert (!tags.empty ());
- gdb_assert (address != nullptr);
-
- CORE_ADDR addr = value_as_address (address);
-
- /* Set the logical tag or the allocation tag. */
- if (tag_type == memtag_type::logical)
- {
- /* When setting logical tags, we don't care about the length, since
- we are only setting a single logical tag. */
- addr = aarch64_mte_set_ltag (addr, tags[0]);
-
- /* Update the value's content with the tag. */
- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- gdb_byte *srcbuf = address->contents_raw ().data ();
- store_unsigned_integer (srcbuf, sizeof (addr), byte_order, addr);
- }
- else
- {
- /* Remove the top byte. */
- addr = gdbarch_remove_non_address_bits (gdbarch, addr);
-
- /* With G being the number of tag granules and N the number of tags
- passed in, we can have the following cases:
-
- 1 - G == N: Store all the N tags to memory.
-
- 2 - G < N : Warn about having more tags than granules, but write G
- tags.
-
- 3 - G > N : This is a "fill tags" operation. We should use the tags
- as a pattern to fill the granules repeatedly until we have
- written G tags to memory.
- */
-
- size_t g = aarch64_mte_get_tag_granules (addr, length,
- AARCH64_MTE_GRANULE_SIZE);
- size_t n = tags.size ();
-
- if (g < n)
- warning (_("Got more tags than memory granules. Tags will be "
- "truncated."));
- else if (g > n)
- warning (_("Using tag pattern to fill memory range."));
-
- if (!target_store_memtags (addr, length, tags,
- static_cast<int> (memtag_type::allocation)))
- return false;
- }
- return true;
-}
-
-/* Implement the get_memtag gdbarch method. */
-
-static struct value *
-aarch64_linux_get_memtag (struct gdbarch *gdbarch, struct value *address,
- memtag_type tag_type)
-{
- gdb_assert (address != nullptr);
-
- CORE_ADDR addr = value_as_address (address);
- CORE_ADDR tag = 0;
-
- /* Get the logical tag or the allocation tag. */
- if (tag_type == memtag_type::logical)
- tag = aarch64_mte_get_ltag (addr);
- else
- {
- /* Remove the top byte. */
- addr = gdbarch_remove_non_address_bits (gdbarch, addr);
- std::optional<CORE_ADDR> atag = aarch64_mte_get_atag (addr);
-
- if (!atag.has_value ())
- return nullptr;
-
- tag = *atag;
- }
-
- /* Convert the tag to a value. */
- return value_from_ulongest (builtin_type (gdbarch)->builtin_unsigned_int,
- tag);
-}
-
-/* Implement the memtag_to_string gdbarch method. */
-
-static std::string
-aarch64_linux_memtag_to_string (struct gdbarch *gdbarch, struct value *tag_value)
-{
- if (tag_value == nullptr)
- return "";
-
- CORE_ADDR tag = value_as_address (tag_value);
-
- return string_printf ("0x%s", phex_nz (tag, sizeof (tag)));
-}
/* AArch64 Linux implementation of the report_signal_info gdbarch
hook. Displays information about possible memory tag violations. */
@@ -2900,24 +2751,6 @@ aarch64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
/* Register a hook for checking if an address is tagged or not. */
set_gdbarch_tagged_address_p (gdbarch, aarch64_linux_tagged_address_p);
- /* Register a hook for checking if there is a memory tag match. */
- set_gdbarch_memtag_matches_p (gdbarch,
- aarch64_linux_memtag_matches_p);
-
- /* Register a hook for setting the logical/allocation tags for
- a range of addresses. */
- set_gdbarch_set_memtags (gdbarch, aarch64_linux_set_memtags);
-
- /* Register a hook for extracting the logical/allocation tag from an
- address. */
- set_gdbarch_get_memtag (gdbarch, aarch64_linux_get_memtag);
-
- /* Set the allocation tag granule size to 16 bytes. */
- set_gdbarch_memtag_granule_size (gdbarch, AARCH64_MTE_GRANULE_SIZE);
-
- /* Register a hook for converting a memory tag to a string. */
- set_gdbarch_memtag_to_string (gdbarch, aarch64_linux_memtag_to_string);
-
set_gdbarch_report_signal_info (gdbarch,
aarch64_linux_report_signal_info);
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index e4bca6c..8a2a9b1 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -45,6 +45,7 @@
#include "aarch64-tdep.h"
#include "aarch64-ravenscar-thread.h"
+#include "arch/aarch64-mte.h"
#include "record.h"
#include "record-full.h"
@@ -1727,16 +1728,15 @@ pass_in_v (struct gdbarch *gdbarch,
{
int regnum = AARCH64_V0_REGNUM + info->nsrn;
/* Enough space for a full vector register. */
- gdb_byte reg[register_size (gdbarch, regnum)];
- gdb_assert (len <= sizeof (reg));
+ gdb::byte_vector reg (register_size (gdbarch, regnum), 0);
+ gdb_assert (len <= reg.size ());
info->argnum++;
info->nsrn++;
- memset (reg, 0, sizeof (reg));
/* PCS C.1, the argument is allocated to the least significant
bits of V register. */
- memcpy (reg, buf, len);
+ memcpy (reg.data (), buf, len);
regcache->cooked_write (regnum, reg);
aarch64_debug_printf ("arg %d in %s", info->argnum,
@@ -2543,8 +2543,8 @@ aarch64_extract_return_value (struct type *type, struct regcache *regs,
{
int regno = AARCH64_V0_REGNUM + i;
/* Enough space for a full vector register. */
- gdb_byte buf[register_size (gdbarch, regno)];
- gdb_assert (len <= sizeof (buf));
+ gdb::byte_vector buf (register_size (gdbarch, regno));
+ gdb_assert (len <= buf.size ());
aarch64_debug_printf
("read HFA or HVA return value element %d from %s",
@@ -2552,7 +2552,7 @@ aarch64_extract_return_value (struct type *type, struct regcache *regs,
regs->cooked_read (regno, buf);
- memcpy (valbuf, buf, len);
+ memcpy (valbuf, buf.data (), len);
valbuf += len;
}
}
@@ -2657,8 +2657,8 @@ aarch64_store_return_value (struct type *type, struct regcache *regs,
{
int regno = AARCH64_V0_REGNUM + i;
/* Enough space for a full vector register. */
- gdb_byte tmpbuf[register_size (gdbarch, regno)];
- gdb_assert (len <= sizeof (tmpbuf));
+ gdb::byte_vector tmpbuf (register_size (gdbarch, regno));
+ gdb_assert (len <= tmpbuf.size ());
aarch64_debug_printf
("write HFA or HVA return value element %d to %s",
@@ -2669,7 +2669,7 @@ aarch64_store_return_value (struct type *type, struct regcache *regs,
original contents of the register before overriding it with a new
value that has a potential size <= 16 bytes. */
regs->cooked_read (regno, tmpbuf);
- memcpy (tmpbuf, valbuf,
+ memcpy (tmpbuf.data (), valbuf,
len > V_REGISTER_SIZE ? V_REGISTER_SIZE : len);
regs->cooked_write (regno, tmpbuf);
valbuf += len;
@@ -3302,18 +3302,16 @@ aarch64_pseudo_write_1 (gdbarch *gdbarch, const frame_info_ptr &next_frame,
{
unsigned raw_regnum = AARCH64_V0_REGNUM + regnum_offset;
- /* Enough space for a full vector register. */
- int raw_reg_size = register_size (gdbarch, raw_regnum);
- gdb_byte raw_buf[raw_reg_size];
- static_assert (AARCH64_V0_REGNUM == AARCH64_SVE_Z0_REGNUM);
+ /* Enough space for a full vector register.
- /* Ensure the register buffer is zero, we want gdb writes of the
+ Ensure the register buffer is zero, we want gdb writes of the
various 'scalar' pseudo registers to behavior like architectural
writes, register width bytes are written the remainder are set to
zero. */
- memset (raw_buf, 0, register_size (gdbarch, AARCH64_V0_REGNUM));
+ gdb::byte_vector raw_buf (register_size (gdbarch, raw_regnum), 0);
+ static_assert (AARCH64_V0_REGNUM == AARCH64_SVE_Z0_REGNUM);
- gdb::array_view<gdb_byte> raw_view (raw_buf, raw_reg_size);
+ gdb::array_view<gdb_byte> raw_view (raw_buf);
copy (buf, raw_view.slice (0, buf.size ()));
put_frame_register (next_frame, raw_regnum, raw_view);
}
@@ -4088,6 +4086,156 @@ aarch64_stack_frame_destroyed_p (struct gdbarch *gdbarch, CORE_ADDR pc)
return streq (inst.opcode->name, "ret");
}
+/* Helper to get the allocation tag from a 64-bit ADDRESS.
+
+ Return the allocation tag if successful and nullopt otherwise. */
+
+std::optional<CORE_ADDR>
+aarch64_mte_get_atag (CORE_ADDR address)
+{
+ gdb::byte_vector tags;
+
+ /* Attempt to fetch the allocation tag. */
+ if (!target_fetch_memtags (address, 1, tags,
+ static_cast<int> (memtag_type::allocation)))
+ return {};
+
+ /* Only one tag should've been returned. Make sure we got exactly that. */
+ if (tags.size () != 1)
+ error (_("Target returned an unexpected number of tags."));
+
+ /* Although our tags are 4 bits in size, they are stored in a
+ byte. */
+ return tags[0];
+}
+
+/* Implement the memtag_matches_p gdbarch method. */
+
+static bool
+aarch64_memtag_matches_p (struct gdbarch *gdbarch,
+ struct value *address)
+{
+ gdb_assert (address != nullptr);
+
+ CORE_ADDR addr = value_as_address (address);
+
+ /* Fetch the allocation tag for ADDRESS. */
+ std::optional<CORE_ADDR> atag
+ = aarch64_mte_get_atag (gdbarch_remove_non_address_bits (gdbarch, addr));
+
+ if (!atag.has_value ())
+ return true;
+
+ /* Fetch the logical tag for ADDRESS. */
+ gdb_byte ltag = aarch64_mte_get_ltag (addr);
+
+ /* Are the tags the same? */
+ return ltag == *atag;
+}
+
+/* Implement the set_memtags gdbarch method. */
+
+static bool
+aarch64_set_memtags (struct gdbarch *gdbarch, struct value *address,
+ size_t length, const gdb::byte_vector &tags,
+ memtag_type tag_type)
+{
+ gdb_assert (!tags.empty ());
+ gdb_assert (address != nullptr);
+
+ CORE_ADDR addr = value_as_address (address);
+
+ /* Set the logical tag or the allocation tag. */
+ if (tag_type == memtag_type::logical)
+ {
+ /* When setting logical tags, we don't care about the length, since
+ we are only setting a single logical tag. */
+ addr = aarch64_mte_set_ltag (addr, tags[0]);
+
+ /* Update the value's content with the tag. */
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ gdb_byte *srcbuf = address->contents_raw ().data ();
+ store_unsigned_integer (srcbuf, sizeof (addr), byte_order, addr);
+ }
+ else
+ {
+ /* Remove the top byte. */
+ addr = gdbarch_remove_non_address_bits (gdbarch, addr);
+
+ /* With G being the number of tag granules and N the number of tags
+ passed in, we can have the following cases:
+
+ 1 - G == N: Store all the N tags to memory.
+
+ 2 - G < N : Warn about having more tags than granules, but write G
+ tags.
+
+ 3 - G > N : This is a "fill tags" operation. We should use the tags
+ as a pattern to fill the granules repeatedly until we have
+ written G tags to memory.
+ */
+
+ size_t g = aarch64_mte_get_tag_granules (addr, length,
+ AARCH64_MTE_GRANULE_SIZE);
+ size_t n = tags.size ();
+
+ if (g < n)
+ warning (_("Got more tags than memory granules. Tags will be "
+ "truncated."));
+ else if (g > n)
+ warning (_("Using tag pattern to fill memory range."));
+
+ if (!target_store_memtags (addr, length, tags,
+ static_cast<int> (memtag_type::allocation)))
+ return false;
+ }
+ return true;
+}
+
+/* Implement the get_memtag gdbarch method. */
+
+static struct value *
+aarch64_get_memtag (struct gdbarch *gdbarch, struct value *address,
+ memtag_type tag_type)
+{
+ gdb_assert (address != nullptr);
+
+ CORE_ADDR addr = value_as_address (address);
+ CORE_ADDR tag = 0;
+
+ /* Get the logical tag or the allocation tag. */
+ if (tag_type == memtag_type::logical)
+ tag = aarch64_mte_get_ltag (addr);
+ else
+ {
+ /* Remove the top byte. */
+ addr = gdbarch_remove_non_address_bits (gdbarch, addr);
+ std::optional<CORE_ADDR> atag = aarch64_mte_get_atag (addr);
+
+ if (!atag.has_value ())
+ return nullptr;
+
+ tag = *atag;
+ }
+
+ /* Convert the tag to a value. */
+ return value_from_ulongest (builtin_type (gdbarch)->builtin_unsigned_int,
+ tag);
+}
+
+/* Implement the memtag_to_string gdbarch method. */
+
+static std::string
+aarch64_memtag_to_string (struct gdbarch *gdbarch, struct value *tag_value)
+{
+ if (tag_value == nullptr)
+ return "";
+
+ CORE_ADDR tag = value_as_address (tag_value);
+
+ return string_printf ("0x%s", phex_nz (tag, sizeof (tag)));
+}
+
/* AArch64 implementation of the remove_non_address_bits gdbarch hook. Remove
non address bits from a pointer value. */
@@ -4504,6 +4652,23 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
aarch64_pseudo_register_reggroup_p);
set_gdbarch_cannot_store_register (gdbarch, aarch64_cannot_store_register);
+ /* Set the allocation tag granule size to 16 bytes. */
+ set_gdbarch_memtag_granule_size (gdbarch, AARCH64_MTE_GRANULE_SIZE);
+
+ /* Register a hook for checking if there is a memory tag match. */
+ set_gdbarch_memtag_matches_p (gdbarch, aarch64_memtag_matches_p);
+
+ /* Register a hook for setting the logical/allocation tags for
+ a range of addresses. */
+ set_gdbarch_set_memtags (gdbarch, aarch64_set_memtags);
+
+ /* Register a hook for extracting the logical/allocation tag from an
+ address. */
+ set_gdbarch_get_memtag (gdbarch, aarch64_get_memtag);
+
+ /* Register a hook for converting a memory tag to a string. */
+ set_gdbarch_memtag_to_string (gdbarch, aarch64_memtag_to_string);
+
/* ABI */
set_gdbarch_short_bit (gdbarch, 16);
set_gdbarch_int_bit (gdbarch, 32);
diff --git a/gdb/aarch64-tdep.h b/gdb/aarch64-tdep.h
index 0e6024b..50166fb 100644
--- a/gdb/aarch64-tdep.h
+++ b/gdb/aarch64-tdep.h
@@ -203,4 +203,6 @@ void aarch64_displaced_step_fixup (struct gdbarch *gdbarch,
bool aarch64_displaced_step_hw_singlestep (struct gdbarch *gdbarch);
+std::optional<CORE_ADDR> aarch64_mte_get_atag (CORE_ADDR address);
+
#endif /* aarch64-tdep.h */
diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index 0126db5..dfcbb2b 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -1857,7 +1857,9 @@ write_var_or_type (struct parser_state *par_state,
}
}
- if (!have_full_symbols () && !have_partial_symbols () && block == NULL)
+ if (!have_full_symbols (current_program_space)
+ && !have_partial_symbols (current_program_space)
+ && block == NULL)
error (_("No symbol table is loaded. Use the \"file\" command."));
if (block == par_state->expression_context_block)
error (_("No definition of \"%s\" in current context."), name0.ptr);
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 46c2057..1cf6ff5 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -11195,16 +11195,9 @@ ada_funcall_operation::evaluate (struct type *expect_type,
}
return call_function_by_hand (callee, expect_type, argvec);
case TYPE_CODE_INTERNAL_FUNCTION:
- if (noside == EVAL_AVOID_SIDE_EFFECTS)
- /* We don't know anything about what the internal
- function might return, but we have to return
- something. */
- return value::zero (builtin_type (exp->gdbarch)->builtin_int,
- not_lval);
- else
return call_internal_function (exp->gdbarch, exp->language_defn,
callee, nargs,
- argvec.data ());
+ argvec.data (), noside);
case TYPE_CODE_STRUCT:
{
@@ -13884,7 +13877,7 @@ static struct cmd_list_element *show_ada_list;
static void
ada_new_objfile_observer (struct objfile *objfile)
{
- ada_clear_symbol_cache (objfile->pspace);
+ ada_clear_symbol_cache (objfile->pspace ());
}
/* This module's 'free_objfile' observer. */
@@ -13892,7 +13885,7 @@ ada_new_objfile_observer (struct objfile *objfile)
static void
ada_free_objfile_observer (struct objfile *objfile)
{
- ada_clear_symbol_cache (objfile->pspace);
+ ada_clear_symbol_cache (objfile->pspace ());
}
/* Charsets known to GNAT. */
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index 83059d7..119b223 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -1495,7 +1495,7 @@ ada_tasks_clear_pspace_data (program_space *pspace)
static void
ada_tasks_new_objfile_observer (objfile *objfile)
{
- ada_tasks_clear_pspace_data (objfile->pspace);
+ ada_tasks_clear_pspace_data (objfile->pspace ());
}
/* The qcs command line flags for the "task apply" commands. Keep
diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
index aa9295d..823c1f7 100644
--- a/gdb/amd64-linux-nat.c
+++ b/gdb/amd64-linux-nat.c
@@ -235,22 +235,21 @@ amd64_linux_nat_target::fetch_registers (struct regcache *regcache, int regnum)
if (have_ptrace_getregset == TRIBOOL_TRUE)
{
- char xstateregs[tdep->xsave_layout.sizeof_xsave];
- struct iovec iov;
-
/* Pre-4.14 kernels have a bug (fixed by commit 0852b374173b
"x86/fpu: Add FPU state copying quirk to handle XRSTOR failure on
Intel Skylake CPUs") that sometimes causes the mxcsr location in
xstateregs not to be copied by PTRACE_GETREGSET. Make sure that
the location is at least initialized with a defined value. */
- memset (xstateregs, 0, sizeof (xstateregs));
- iov.iov_base = xstateregs;
- iov.iov_len = sizeof (xstateregs);
+ gdb::byte_vector xstateregs (tdep->xsave_layout.sizeof_xsave, 0);
+ struct iovec iov;
+
+ iov.iov_base = xstateregs.data ();
+ iov.iov_len = xstateregs.size ();
if (ptrace (PTRACE_GETREGSET, tid,
(unsigned int) NT_X86_XSTATE, (long) &iov) < 0)
perror_with_name (_("Couldn't get extended state status"));
- amd64_supply_xsave (regcache, -1, xstateregs);
+ amd64_supply_xsave (regcache, -1, xstateregs.data ());
}
else
{
@@ -300,16 +299,16 @@ amd64_linux_nat_target::store_registers (struct regcache *regcache, int regnum)
if (have_ptrace_getregset == TRIBOOL_TRUE)
{
- char xstateregs[tdep->xsave_layout.sizeof_xsave];
+ gdb::byte_vector xstateregs (tdep->xsave_layout.sizeof_xsave);
struct iovec iov;
- iov.iov_base = xstateregs;
- iov.iov_len = sizeof (xstateregs);
+ iov.iov_base = xstateregs.data ();
+ iov.iov_len = xstateregs.size ();
if (ptrace (PTRACE_GETREGSET, tid,
(unsigned int) NT_X86_XSTATE, (long) &iov) < 0)
perror_with_name (_("Couldn't get extended state status"));
- amd64_collect_xsave (regcache, regnum, xstateregs, 0);
+ amd64_collect_xsave (regcache, regnum, xstateregs.data (), 0);
if (ptrace (PTRACE_SETREGSET, tid,
(unsigned int) NT_X86_XSTATE, (long) &iov) < 0)
diff --git a/gdb/amdgpu-tdep.c b/gdb/amdgpu-tdep.c
index 49996ae..6fe7973 100644
--- a/gdb/amdgpu-tdep.c
+++ b/gdb/amdgpu-tdep.c
@@ -28,8 +28,6 @@
#include "gdbsupport/selftest.h"
#include "gdbtypes.h"
#include "inferior.h"
-#include "objfiles.h"
-#include "observable.h"
#include "producer.h"
#include "reggroups.h"
diff --git a/gdb/annotate.c b/gdb/annotate.c
index 8818029..c1d4229 100644
--- a/gdb/annotate.c
+++ b/gdb/annotate.c
@@ -457,7 +457,7 @@ annotate_source_line (struct symtab *s, int line, int mid_statement,
/* Update the current symtab and line. */
symtab_and_line sal;
- sal.pspace = s->compunit ()->objfile ()->pspace;
+ sal.pspace = s->compunit ()->objfile ()->pspace ();
sal.symtab = s;
sal.line = line;
set_current_source_symtab_and_line (sal);
diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c
index 9491107..4fc1ea1 100644
--- a/gdb/arc-tdep.c
+++ b/gdb/arc-tdep.c
@@ -861,7 +861,7 @@ arc_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr,
struct regcache *regcache)
{
*real_pc = funaddr;
- *bp_addr = entry_point_address ();
+ *bp_addr = entry_point_address (current_program_space);
return sp;
}
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 83e2947..13984eb 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -56,7 +56,7 @@ displaced_step_at_entry_point (struct gdbarch *gdbarch)
CORE_ADDR addr;
int bp_len;
- addr = entry_point_address ();
+ addr = entry_point_address (current_program_space);
/* Inferior calls also use the entry point as a breakpoint location.
We don't want displaced stepping to interfere with those
@@ -1192,7 +1192,7 @@ pstring_list (const char *const *list)
return ret;
}
-#include "gdbarch.c"
+#include "gdbarch-gen.c"
enum return_value_convention
default_gdbarch_return_value
diff --git a/gdb/arch/aarch64-mte-linux.c b/gdb/arch/aarch64-mte-linux.c
index e0b441e..49426d7 100644
--- a/gdb/arch/aarch64-mte-linux.c
+++ b/gdb/arch/aarch64-mte-linux.c
@@ -75,59 +75,3 @@ aarch64_mte_unpack_tags (gdb::byte_vector &tags, bool skip_first)
tags = std::move (unpacked_tags);
}
-/* See arch/aarch64-mte-linux.h */
-
-size_t
-aarch64_mte_get_tag_granules (CORE_ADDR addr, size_t len, size_t granule_size)
-{
- /* An empty range has 0 tag granules. */
- if (len == 0)
- return 0;
-
- /* Start address */
- CORE_ADDR s_addr = align_down (addr, granule_size);
- /* End address */
- CORE_ADDR e_addr = align_down (addr + len - 1, granule_size);
-
- /* We always have at least 1 granule because len is non-zero at this
- point. */
- return 1 + (e_addr - s_addr) / granule_size;
-}
-
-/* See arch/aarch64-mte-linux.h */
-
-CORE_ADDR
-aarch64_mte_make_ltag_bits (CORE_ADDR value)
-{
- return value & AARCH64_MTE_LOGICAL_MAX_VALUE;
-}
-
-/* See arch/aarch64-mte-linux.h */
-
-CORE_ADDR
-aarch64_mte_make_ltag (CORE_ADDR value)
-{
- return (aarch64_mte_make_ltag_bits (value)
- << AARCH64_MTE_LOGICAL_TAG_START_BIT);
-}
-
-/* See arch/aarch64-mte-linux.h */
-
-CORE_ADDR
-aarch64_mte_set_ltag (CORE_ADDR address, CORE_ADDR tag)
-{
- /* Remove the existing tag. */
- address &= ~aarch64_mte_make_ltag (AARCH64_MTE_LOGICAL_MAX_VALUE);
-
- /* Return the new tagged address. */
- return address | aarch64_mte_make_ltag (tag);
-}
-
-/* See arch/aarch64-mte-linux.h */
-
-CORE_ADDR
-aarch64_mte_get_ltag (CORE_ADDR address)
-{
- CORE_ADDR ltag_addr = address >> AARCH64_MTE_LOGICAL_TAG_START_BIT;
- return aarch64_mte_make_ltag_bits (ltag_addr);
-}
diff --git a/gdb/arch/aarch64-mte-linux.h b/gdb/arch/aarch64-mte-linux.h
index 460b10e..686749f 100644
--- a/gdb/arch/aarch64-mte-linux.h
+++ b/gdb/arch/aarch64-mte-linux.h
@@ -29,12 +29,6 @@
/* The MTE regset consists of a single 64-bit register. */
#define AARCH64_LINUX_SIZEOF_MTE 8
-/* We have one tag per 16 bytes of memory. */
-#define AARCH64_MTE_GRANULE_SIZE 16
-#define AARCH64_MTE_TAG_BIT_SIZE 4
-#define AARCH64_MTE_LOGICAL_TAG_START_BIT 56
-#define AARCH64_MTE_LOGICAL_MAX_VALUE 0xf
-
/* Memory tagging definitions. */
#ifndef SEGV_MTEAERR
# define SEGV_MTEAERR 8
@@ -50,27 +44,6 @@ enum class aarch64_memtag_type
mte_allocation
};
-/* Return the number of tag granules in the memory range
- [ADDR, ADDR + LEN) given GRANULE_SIZE. */
-extern size_t aarch64_mte_get_tag_granules (CORE_ADDR addr, size_t len,
- size_t granule_size);
-
-/* Return the 4-bit tag made from VALUE. */
-extern CORE_ADDR aarch64_mte_make_ltag_bits (CORE_ADDR value);
-
-/* Return the 4-bit tag that can be OR-ed to an address. */
-extern CORE_ADDR aarch64_mte_make_ltag (CORE_ADDR value);
-
-/* Helper to set the logical TAG for a 64-bit ADDRESS.
-
- It is always possible to set the logical tag. */
-extern CORE_ADDR aarch64_mte_set_ltag (CORE_ADDR address, CORE_ADDR tag);
-
-/* Helper to get the logical tag from a 64-bit ADDRESS.
-
- It is always possible to get the logical tag. */
-extern CORE_ADDR aarch64_mte_get_ltag (CORE_ADDR address);
-
/* Given a TAGS vector containing 1 MTE tag per byte, pack the data as
2 tags per byte and resize the vector. */
extern void aarch64_mte_pack_tags (gdb::byte_vector &tags);
diff --git a/gdb/arch/aarch64-mte.c b/gdb/arch/aarch64-mte.c
new file mode 100644
index 0000000..908e12c
--- /dev/null
+++ b/gdb/arch/aarch64-mte.c
@@ -0,0 +1,77 @@
+/* Common AArch64 functionality for MTE
+
+ Copyright (C) 2021-2024 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "arch/aarch64-mte.h"
+
+/* See arch/aarch64-mte.h */
+
+size_t
+aarch64_mte_get_tag_granules (CORE_ADDR addr, size_t len, size_t granule_size)
+{
+ /* An empty range has 0 tag granules. */
+ if (len == 0)
+ return 0;
+
+ /* Start address */
+ CORE_ADDR s_addr = align_down (addr, granule_size);
+ /* End address */
+ CORE_ADDR e_addr = align_down (addr + len - 1, granule_size);
+
+ /* We always have at least 1 granule because len is non-zero at this
+ point. */
+ return 1 + (e_addr - s_addr) / granule_size;
+}
+
+/* See arch/aarch64-mte.h */
+
+CORE_ADDR
+aarch64_mte_make_ltag_bits (CORE_ADDR value)
+{
+ return value & AARCH64_MTE_LOGICAL_MAX_VALUE;
+}
+
+/* See arch/aarch64-mte.h */
+
+CORE_ADDR
+aarch64_mte_make_ltag (CORE_ADDR value)
+{
+ return (aarch64_mte_make_ltag_bits (value)
+ << AARCH64_MTE_LOGICAL_TAG_START_BIT);
+}
+
+/* See arch/aarch64-mte.h */
+
+CORE_ADDR
+aarch64_mte_set_ltag (CORE_ADDR address, CORE_ADDR tag)
+{
+ /* Remove the existing tag. */
+ address &= ~aarch64_mte_make_ltag (AARCH64_MTE_LOGICAL_MAX_VALUE);
+
+ /* Return the new tagged address. */
+ return address | aarch64_mte_make_ltag (tag);
+}
+
+/* See arch/aarch64-mte.h */
+
+CORE_ADDR
+aarch64_mte_get_ltag (CORE_ADDR address)
+{
+ CORE_ADDR ltag_addr = address >> AARCH64_MTE_LOGICAL_TAG_START_BIT;
+ return aarch64_mte_make_ltag_bits (ltag_addr);
+}
diff --git a/gdb/arch/aarch64-mte.h b/gdb/arch/aarch64-mte.h
new file mode 100644
index 0000000..7d8445e
--- /dev/null
+++ b/gdb/arch/aarch64-mte.h
@@ -0,0 +1,51 @@
+/* Common AArch64 definitions for MTE
+
+ Copyright (C) 2021-2024 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef ARCH_AARCH64_MTE_H
+#define ARCH_AARCH64_MTE_H
+
+
+/* We have one tag per 16 bytes of memory. */
+#define AARCH64_MTE_GRANULE_SIZE 16
+#define AARCH64_MTE_TAG_BIT_SIZE 4
+#define AARCH64_MTE_LOGICAL_TAG_START_BIT 56
+#define AARCH64_MTE_LOGICAL_MAX_VALUE 0xf
+
+/* Return the number of tag granules in the memory range
+ [ADDR, ADDR + LEN) given GRANULE_SIZE. */
+extern size_t aarch64_mte_get_tag_granules (CORE_ADDR addr, size_t len,
+ size_t granule_size);
+
+/* Return the 4-bit tag made from VALUE. */
+extern CORE_ADDR aarch64_mte_make_ltag_bits (CORE_ADDR value);
+
+/* Return the 4-bit tag that can be OR-ed to an address. */
+extern CORE_ADDR aarch64_mte_make_ltag (CORE_ADDR value);
+
+/* Helper to set the logical TAG for a 64-bit ADDRESS.
+
+ It is always possible to set the logical tag. */
+extern CORE_ADDR aarch64_mte_set_ltag (CORE_ADDR address, CORE_ADDR tag);
+
+/* Helper to get the logical tag from a 64-bit ADDRESS.
+
+ It is always possible to get the logical tag. */
+extern CORE_ADDR aarch64_mte_get_ltag (CORE_ADDR address);
+
+#endif /* ARCH_AARCH64_MTE_H */
diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index ac53bed..7b4faac 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -876,6 +876,14 @@ arm_hwbp_control_is_enabled (arm_hwbp_control_t control)
return control & 0x1;
}
+/* Is the breakpoint control value CONTROL initialized? */
+
+static int
+arm_hwbp_control_is_initialized (arm_hwbp_control_t control)
+{
+ return control != 0;
+}
+
/* Change a breakpoint control word so that it is in the disabled state. */
static arm_hwbp_control_t
arm_hwbp_control_disable (arm_hwbp_control_t control)
@@ -1234,6 +1242,34 @@ arm_linux_nat_target::low_delete_thread (struct arch_lwp_info *arch_lwp)
xfree (arch_lwp);
}
+/* For PID, set the address register of hardware breakpoint pair I to
+ ADDRESS. */
+
+static void
+sethbpregs_hwbp_address (int pid, int i, unsigned int address)
+{
+ PTRACE_TYPE_ARG3 address_reg = (PTRACE_TYPE_ARG3) ((i << 1) + 1);
+
+ errno = 0;
+
+ if (ptrace (PTRACE_SETHBPREGS, pid, address_reg, &address) < 0)
+ perror_with_name (_("Unexpected error updating breakpoint address"));
+}
+
+/* For PID, set the control register of hardware breakpoint pair I to
+ CONTROL. */
+
+static void
+sethbpregs_hwbp_control (int pid, int i, arm_hwbp_control_t control)
+{
+ PTRACE_TYPE_ARG3 control_reg = (PTRACE_TYPE_ARG3) ((i << 1) + 2);
+
+ errno = 0;
+
+ if (ptrace (PTRACE_SETHBPREGS, pid, control_reg, &control) < 0)
+ perror_with_name (_("Unexpected error setting breakpoint control"));
+}
+
/* Called when resuming a thread.
The hardware debug registers are updated when there is any change. */
@@ -1257,16 +1293,58 @@ arm_linux_nat_target::low_prepare_to_resume (struct lwp_info *lwp)
for (i = 0; i < arm_linux_get_hw_breakpoint_count (); i++)
if (arm_lwp_info->bpts_changed[i])
{
- errno = 0;
- if (arm_hwbp_control_is_enabled (bpts[i].control))
- if (ptrace (PTRACE_SETHBPREGS, pid,
- (PTRACE_TYPE_ARG3) ((i << 1) + 1), &bpts[i].address) < 0)
- perror_with_name (_("Unexpected error setting breakpoint"));
-
- if (bpts[i].control != 0)
- if (ptrace (PTRACE_SETHBPREGS, pid,
- (PTRACE_TYPE_ARG3) ((i << 1) + 2), &bpts[i].control) < 0)
- perror_with_name (_("Unexpected error setting breakpoint"));
+ unsigned int address = bpts[i].address;
+ arm_hwbp_control_t control = bpts[i].control;
+
+ if (!arm_hwbp_control_is_initialized (control))
+ {
+ /* Nothing to do. */
+ }
+ else if (!arm_hwbp_control_is_enabled (control))
+ {
+ /* Disable hardware breakpoint, just write the control
+ register. */
+ sethbpregs_hwbp_control (pid, i, control);
+ }
+ else
+ {
+ /* We used to do here simply:
+ 1. address_reg = address
+ 2. control_reg = control
+ but the write to address_reg can fail for thumb2 instructions if
+ the address is not 4-byte aligned.
+
+ It's not clear whether this is a kernel bug or not, partly
+ because PTRACE_SETHBPREGS is undocumented.
+
+ The context is that we're using two ptrace calls to set the two
+ halves of a register pair. For each ptrace call, the kernel must
+ check the arguments, and return -1 and set errno appropriately if
+ something is wrong. One of the aspects that needs validation is
+ whether, in terms of hw_breakpoint_arch_parse, the breakpoint
+ address matches the breakpoint length. This aspect can only be
+ checked by looking in both registers, which only makes sense
+ once a pair is written in full.
+
+ The problem is that the kernel checks this aspect after each
+ ptrace call, and consequently for the first call it may be
+ checking this aspect using a default or previous value for the
+ part of the pair not written by the call. A possible fix for
+ this would be to only check this aspect when writing the
+ control reg.
+
+ Work around this by first using an inoffensive address, which is
+ guaranteed to hit the offset == 0 case in
+ hw_breakpoint_arch_parse. */
+ unsigned int aligned_address = address & ~0x7U;
+ if (aligned_address != address)
+ {
+ sethbpregs_hwbp_address (pid, i, aligned_address);
+ sethbpregs_hwbp_control (pid, i, control);
+ }
+ sethbpregs_hwbp_address (pid, i, address);
+ sethbpregs_hwbp_control (pid, i, control);
+ }
arm_lwp_info->bpts_changed[i] = 0;
}
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index afc98eb..839be08 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -783,7 +783,7 @@ auto_load_objfile_script_1 (struct objfile *objfile, const char *realname,
/* Add this script to the hash table too so
"info auto-load ${lang}-scripts" can print it. */
pspace_info
- = get_auto_load_pspace_data_for_loading (objfile->pspace);
+ = get_auto_load_pspace_data_for_loading (objfile->pspace ());
maybe_add_script_file (pspace_info, is_safe, debugfile, debugfile,
language);
@@ -1048,7 +1048,7 @@ source_section_scripts (struct objfile *objfile, const char *section_name,
const char *start, const char *end)
{
auto_load_pspace_info *pspace_info
- = get_auto_load_pspace_data_for_loading (objfile->pspace);
+ = get_auto_load_pspace_data_for_loading (objfile->pspace ());
for (const char *p = start; p < end; ++p)
{
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index a973518..670a3f7 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -283,9 +283,6 @@ static bool strace_marker_p (struct breakpoint *b);
static void bkpt_probe_create_sals_from_location_spec
(location_spec *locspec,
struct linespec_result *canonical);
-static void tracepoint_probe_create_sals_from_location_spec
- (location_spec *locspec,
- struct linespec_result *canonical);
const struct breakpoint_ops code_breakpoint_ops =
{
@@ -300,10 +297,11 @@ static const struct breakpoint_ops bkpt_probe_breakpoint_ops =
create_breakpoints_sal,
};
-/* Tracepoints set on probes. */
+/* Tracepoints set on probes. We use the same methods as for breakpoints
+ on probes. */
static const struct breakpoint_ops tracepoint_probe_breakpoint_ops =
{
- tracepoint_probe_create_sals_from_location_spec,
+ bkpt_probe_create_sals_from_location_spec,
create_breakpoints_sal,
};
@@ -3710,7 +3708,7 @@ create_longjmp_master_breakpoint (void)
{
set_current_program_space (pspace);
- for (objfile *obj : current_program_space->objfiles ())
+ for (objfile *obj : pspace->objfiles ())
{
/* Skip separate debug object, it's handled in the loop below. */
if (obj->separate_debug_objfile_backlink != nullptr)
@@ -3743,7 +3741,7 @@ create_std_terminate_master_breakpoint (void)
{
set_current_program_space (pspace);
- for (objfile *objfile : current_program_space->objfiles ())
+ for (objfile *objfile : pspace->objfiles ())
{
struct breakpoint *b;
struct breakpoint_objfile_data *bp_objfile_data;
@@ -6592,7 +6590,7 @@ print_one_breakpoint_location (struct breakpoint *b,
}
}
- if (loc != NULL && !header_of_multiple)
+ if (loc != nullptr && !header_of_multiple && !loc->shlib_disabled)
{
std::vector<int> inf_nums;
int mi_only = 1;
@@ -8092,7 +8090,7 @@ disable_breakpoints_in_freed_objfile (struct objfile *objfile)
if (loc.shlib_disabled != 0)
continue;
- if (objfile->pspace != loc.pspace)
+ if (objfile->pspace () != loc.pspace)
continue;
if (loc.loc_type != bp_loc_hardware_breakpoint
@@ -8825,8 +8823,6 @@ static void
parse_breakpoint_sals (location_spec *locspec,
struct linespec_result *canonical)
{
- struct symtab_and_line cursal;
-
if (locspec->type () == LINESPEC_LOCATION_SPEC)
{
const char *spec
@@ -8875,7 +8871,8 @@ parse_breakpoint_sals (location_spec *locspec,
ObjC: However, don't match an Objective-C method name which
may have a '+' or '-' succeeded by a '['. */
- cursal = get_current_source_symtab_and_line ();
+ symtab_and_line cursal
+ = get_current_source_symtab_and_line (current_program_space);
if (last_displayed_sal_is_valid ())
{
const char *spec = NULL;
@@ -12406,17 +12403,6 @@ tracepoint::print_recreate (struct ui_file *fp) const
gdb_printf (fp, " passcount %d\n", pass_count);
}
-/* Virtual table for tracepoints on static probes. */
-
-static void
-tracepoint_probe_create_sals_from_location_spec
- (location_spec *locspec,
- struct linespec_result *canonical)
-{
- /* We use the same method for breakpoint on probes. */
- bkpt_probe_create_sals_from_location_spec (locspec, canonical);
-}
-
void
dprintf_breakpoint::re_set ()
{
@@ -13215,17 +13201,6 @@ create_sals_from_location_spec_default (location_spec *locspec,
parse_breakpoint_sals (locspec, canonical);
}
-/* Reset a breakpoint. */
-
-static void
-breakpoint_re_set_one (breakpoint *b)
-{
- input_radix = b->input_radix;
- set_language (b->language);
-
- b->re_set ();
-}
-
/* Re-set breakpoint locations for the current program space.
Locations bound to other program spaces are left untouched. */
@@ -13237,12 +13212,11 @@ breakpoint_re_set (void)
scoped_restore save_input_radix = make_scoped_restore (&input_radix);
scoped_restore_current_pspace_and_thread restore_pspace_thread;
- /* breakpoint_re_set_one sets the current_language to the language
- of the breakpoint it is resetting (see prepare_re_set_context)
- before re-evaluating the breakpoint's location. This change can
- unfortunately get undone by accident if the language_mode is set
- to auto, and we either switch frames, or more likely in this context,
- we select the current frame.
+ /* To ::re_set each breakpoint we set the current_language to the
+ language of the breakpoint before re-evaluating the breakpoint's
+ location. This change can unfortunately get undone by accident if
+ the language_mode is set to auto, and we either switch frames, or
+ more likely in this context, we select the current frame.
We prevent this by temporarily turning the language_mode to
language_mode_manual. We restore it once all breakpoints
@@ -13259,7 +13233,9 @@ breakpoint_re_set (void)
{
try
{
- breakpoint_re_set_one (&b);
+ input_radix = b.input_radix;
+ set_language (b.language);
+ b.re_set ();
}
catch (const gdb_exception &ex)
{
diff --git a/gdb/build-id.c b/gdb/build-id.c
index 8ce94f1..32fbe17 100644
--- a/gdb/build-id.c
+++ b/gdb/build-id.c
@@ -73,50 +73,149 @@ build_id_verify (bfd *abfd, size_t check_len, const bfd_byte *check)
return retval;
}
-/* Helper for build_id_to_debug_bfd. LINK is a path to a potential
- build-id-based separate debug file, potentially a symlink to the real file.
- If the file exists and matches BUILD_ID, return a BFD reference to it. */
+/* Helper for build_id_to_debug_bfd. ORIGINAL_LINK with SUFFIX appended is
+ a path to a potential build-id-based separate debug file, potentially a
+ symlink to the real file. If the file exists and matches BUILD_ID,
+ return a BFD reference to it. */
static gdb_bfd_ref_ptr
-build_id_to_debug_bfd_1 (const std::string &link, size_t build_id_len,
- const bfd_byte *build_id)
+build_id_to_debug_bfd_1 (const std::string &original_link,
+ size_t build_id_len, const bfd_byte *build_id,
+ const char *suffix)
{
- separate_debug_file_debug_printf ("Trying %s...", link.c_str ());
-
- /* lrealpath() is expensive even for the usually non-existent files. */
- gdb::unique_xmalloc_ptr<char> filename_holder;
- const char *filename = nullptr;
- if (is_target_filename (link))
- filename = link.c_str ();
- else if (access (link.c_str (), F_OK) == 0)
+ tribool supports_target_stat = TRIBOOL_UNKNOWN;
+
+ /* Drop the 'target:' prefix if the target filesystem is local. */
+ std::string_view original_link_view (original_link);
+ if (is_target_filename (original_link) && target_filesystem_is_local ())
+ original_link_view
+ = original_link_view.substr (strlen (TARGET_SYSROOT_PREFIX));
+
+ /* The upper bound of '10' here is completely arbitrary. The loop should
+ terminate via 'break' when either (a) a readable symlink is found, or
+ (b) a non-existing entry is found.
+
+ However, for remote targets, we rely on the remote returning sane
+ error codes. If a remote sends back the wrong error code then it
+ might trick GDB into thinking that the symlink exists, but points to a
+ missing file, in which case GDB will try the next seqno. We don't
+ want a broken remote to cause GDB to spin here forever, hence a fixed
+ upper bound. */
+
+ for (unsigned seqno = 0; seqno < 10; seqno++)
{
- filename_holder.reset (lrealpath (link.c_str ()));
- filename = filename_holder.get ();
- }
+ std::string link (original_link_view);
- if (filename == NULL)
- {
- separate_debug_file_debug_printf ("unable to compute real path");
- return {};
- }
+ if (seqno > 0)
+ string_appendf (link, ".%u", seqno);
- /* We expect to be silent on the non-existing files. */
- gdb_bfd_ref_ptr debug_bfd = gdb_bfd_open (filename, gnutarget);
+ link += suffix;
- if (debug_bfd == NULL)
- {
- separate_debug_file_debug_printf ("unable to open.");
- return {};
- }
+ separate_debug_file_debug_printf ("Trying %s...", link.c_str ());
- if (!build_id_verify (debug_bfd.get(), build_id_len, build_id))
- {
- separate_debug_file_debug_printf ("build-id does not match.");
- return {};
+ gdb::unique_xmalloc_ptr<char> filename_holder;
+ const char *filename = nullptr;
+ if (is_target_filename (link))
+ {
+ gdb_assert (link.length () >= strlen (TARGET_SYSROOT_PREFIX));
+ const char *link_on_target
+ = link.c_str () + strlen (TARGET_SYSROOT_PREFIX);
+
+ fileio_error target_errno;
+ if (supports_target_stat != TRIBOOL_FALSE)
+ {
+ struct stat sb;
+ int res = target_fileio_stat (nullptr, link_on_target, &sb,
+ &target_errno);
+
+ if (res != 0 && target_errno != FILEIO_ENOSYS)
+ {
+ separate_debug_file_debug_printf ("path doesn't exist");
+ break;
+ }
+ else if (res != 0 && target_errno == FILEIO_ENOSYS)
+ supports_target_stat = TRIBOOL_FALSE;
+ else
+ {
+ supports_target_stat = TRIBOOL_TRUE;
+ filename = link.c_str ();
+ }
+ }
+
+ if (supports_target_stat == TRIBOOL_FALSE)
+ {
+ gdb_assert (filename == nullptr);
+
+ /* Connecting to a target that doesn't support 'stat'. Try
+ 'readlink' as an alternative. This isn't ideal, but is
+ maybe better than nothing. Returns EINVAL if the path
+ isn't a symbolic link, which hints that the path is
+ available -- there are other errors e.g. ENOENT for when
+ the path doesn't exist, but we just assume that anything
+ other than EINVAL indicates the path doesn't exist. */
+ std::optional<std::string> link_target
+ = target_fileio_readlink (nullptr, link_on_target,
+ &target_errno);
+ if (link_target.has_value ()
+ || target_errno == FILEIO_EINVAL)
+ filename = link.c_str ();
+ else
+ {
+ separate_debug_file_debug_printf ("path doesn't exist");
+ break;
+ }
+ }
+ }
+ else
+ {
+ struct stat buf;
+
+ /* The `access' call below automatically dereferences LINK, but
+ we want to stop incrementing SEQNO once we find a symlink
+ that doesn't exist. */
+ if (lstat (link.c_str (), &buf) != 0)
+ {
+ separate_debug_file_debug_printf ("path doesn't exist");
+ break;
+ }
+
+ /* Can LINK be accessed, or if LINK is a symlink, can the file
+ pointed too be accessed? Do this as lrealpath() is
+ expensive, even for the usually non-existent files. */
+ if (access (link.c_str (), F_OK) == 0)
+ {
+ filename_holder.reset (lrealpath (link.c_str ()));
+ filename = filename_holder.get ();
+ }
+ }
+
+ if (filename == nullptr)
+ {
+ separate_debug_file_debug_printf ("unable to compute real path");
+ continue;
+ }
+
+ /* We expect to be silent on the non-existing files. */
+ gdb_bfd_ref_ptr debug_bfd = gdb_bfd_open (filename, gnutarget);
+
+ if (debug_bfd == NULL)
+ {
+ separate_debug_file_debug_printf ("unable to open `%s`", filename);
+ continue;
+ }
+
+ if (!build_id_verify (debug_bfd.get(), build_id_len, build_id))
+ {
+ separate_debug_file_debug_printf ("build-id does not match");
+ continue;
+ }
+
+ separate_debug_file_debug_printf ("found a match");
+ return debug_bfd;
}
- separate_debug_file_debug_printf ("found a match");
- return debug_bfd;
+ separate_debug_file_debug_printf ("no suitable file found");
+ return {};
}
/* Common code for finding BFDs of a given build-id. This function
@@ -156,10 +255,8 @@ build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id,
while (size-- > 0)
string_appendf (link, "%02x", (unsigned) *data++);
- link += suffix;
-
gdb_bfd_ref_ptr debug_bfd
- = build_id_to_debug_bfd_1 (link, build_id_len, build_id);
+ = build_id_to_debug_bfd_1 (link, build_id_len, build_id, suffix);
if (debug_bfd != NULL)
return debug_bfd;
@@ -176,7 +273,8 @@ build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id,
|| !target_filesystem_is_local ()))
{
link = gdb_sysroot + link;
- debug_bfd = build_id_to_debug_bfd_1 (link, build_id_len, build_id);
+ debug_bfd = build_id_to_debug_bfd_1 (link, build_id_len, build_id,
+ suffix);
if (debug_bfd != NULL)
return debug_bfd;
}
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 6022317..a1a74a9 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -1213,7 +1213,8 @@ variable: name_not_typename
= lookup_bound_minimal_symbol (arg.c_str ());
if (msymbol.minsym == NULL)
{
- if (!have_full_symbols () && !have_partial_symbols ())
+ if (!have_full_symbols (current_program_space)
+ && !have_partial_symbols (current_program_space))
error (_("No symbol table is loaded. Use the \"file\" command."));
else
error (_("No symbol \"%s\" in current context."),
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 3af794c..92bb8fc 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -984,7 +984,7 @@ edit_command (const char *arg, int from_tty)
if (arg == 0)
{
set_default_source_symtab_and_line ();
- sal = get_current_source_symtab_and_line ();
+ sal = get_current_source_symtab_and_line (current_program_space);
}
/* Bare "edit" edits file with present line. */
@@ -1240,7 +1240,8 @@ list_command (const char *arg, int from_tty)
if (get_first_line_listed () == 0 && (arg == nullptr || arg[0] != '.'))
{
set_default_source_symtab_and_line ();
- list_around_line (arg, get_current_source_symtab_and_line ());
+ list_around_line
+ (arg, get_current_source_symtab_and_line (current_program_space));
}
/* "l" and "l +" lists the next few lines, unless we're listing past
@@ -1248,7 +1249,8 @@ list_command (const char *arg, int from_tty)
else if (arg == nullptr || arg[0] == '+')
{
set_default_source_symtab_and_line ();
- const symtab_and_line cursal = get_current_source_symtab_and_line ();
+ const symtab_and_line cursal
+ = get_current_source_symtab_and_line (current_program_space);
if (last_symtab_line (cursal.symtab) >= cursal.line)
print_source_lines (cursal.symtab,
source_lines_range (cursal.line), 0);
@@ -1262,7 +1264,8 @@ list_command (const char *arg, int from_tty)
else if (arg[0] == '-')
{
set_default_source_symtab_and_line ();
- const symtab_and_line cursal = get_current_source_symtab_and_line ();
+ const symtab_and_line cursal
+ = get_current_source_symtab_and_line (current_program_space);
if (get_first_line_listed () == 1)
error (_("Already at the start of %s."),
@@ -1295,7 +1298,7 @@ list_command (const char *arg, int from_tty)
{
/* The inferior is not running, so reset the current source
location to the default (usually the main function). */
- clear_current_source_symtab_and_line ();
+ clear_current_source_symtab_and_line (current_program_space);
try
{
set_default_source_symtab_and_line ();
@@ -1305,7 +1308,8 @@ list_command (const char *arg, int from_tty)
error (_("Insufficient debug info for showing source "
"lines at default location"));
}
- cursal = get_current_source_symtab_and_line ();
+ cursal
+ = get_current_source_symtab_and_line (current_program_space);
gdb_assert (cursal.symtab != nullptr);
}
@@ -1327,7 +1331,8 @@ list_command (const char *arg, int from_tty)
and clear NO_END; however, if one of the arguments is blank,
set DUMMY_BEG or DUMMY_END to record that fact. */
- if (!have_full_symbols () && !have_partial_symbols ())
+ if (!have_full_symbols (current_program_space)
+ && !have_partial_symbols (current_program_space))
error (_("No symbol table is loaded. Use the \"file\" command."));
std::vector<symtab_and_line> sals;
diff --git a/gdb/command.h b/gdb/command.h
index 615f4e5..0ceaf3e 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -876,7 +876,7 @@ extern void cmd_show_list (struct cmd_list_element *, int);
/* Used everywhere whenever at least one parameter is required and
none is specified. */
-extern void error_no_arg (const char *) ATTRIBUTE_NORETURN;
+[[noreturn]] extern void error_no_arg (const char *);
/* Command line saving and repetition.
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index 88531a2..8896b44 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -17,6 +17,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#include "progspace.h"
#include "ui.h"
#include "ui-out.h"
#include "command.h"
@@ -487,7 +488,8 @@ get_expr_block_and_pc (CORE_ADDR *pc)
if (block == NULL)
{
- struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+ symtab_and_line cursal
+ = get_current_source_symtab_and_line (current_program_space);
if (cursal.symtab)
block = cursal.symtab->compunit ()->blockvector ()->static_block ();
diff --git a/gdb/configure b/gdb/configure
index 15ececf..62deef2 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -31188,7 +31188,7 @@ build_warnings="-Wall -Wpointer-arith \
-Wredundant-move \
-Wmissing-declarations \
-Wstrict-null-sentinel \
--Wno-vla-cxx-extension \
+-Wvla \
"
# The -Wmissing-prototypes flag will be accepted by GCC, but results
diff --git a/gdb/configure.tgt b/gdb/configure.tgt
index 8326c45..5fb14b6 100644
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -59,7 +59,8 @@ amd64_tobjs="ravenscar-thread.o amd64-ravenscar-thread.o \
case "${targ}" in
aarch64*-*-*)
cpu_obs="aarch32-tdep.o aarch64-tdep.o arch/aarch32.o \
- arch/aarch64-insn.o arch/aarch64.o ravenscar-thread.o \
+ arch/aarch64-insn.o arch/aarch64.o arch/aarch64-mte.o \
+ ravenscar-thread.o \
aarch64-ravenscar-thread.o";;
alpha*-*-*)
diff --git a/gdb/d-exp.y b/gdb/d-exp.y
index 13d2cfa..6feacd8 100644
--- a/gdb/d-exp.y
+++ b/gdb/d-exp.y
@@ -466,7 +466,8 @@ PrimaryExpression:
msymbol = lookup_bound_minimal_symbol (copy.c_str ());
if (msymbol.minsym != NULL)
pstate->push_new<var_msym_value_operation> (msymbol);
- else if (!have_full_symbols () && !have_partial_symbols ())
+ else if (!have_full_symbols (current_program_space)
+ && !have_partial_symbols (current_program_space))
error (_("No symbol table is loaded. Use the \"file\" command"));
else
error (_("No symbol \"%s\" in current context."),
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 86cd420..3315c65 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -24534,6 +24534,10 @@ future connections is shown. The available settings are:
@tab @code{vFile:fstat}
@tab Host I/O
+@item @code{hostio-stat-packet}
+@tab @code{vFile:stat}
+@tab Host I/O
+
@item @code{hostio-setfs-packet}
@tab @code{vFile:setfs}
@tab Host I/O
@@ -29224,9 +29228,21 @@ files.
@cindex arguments, to user-defined commands
A @dfn{user-defined command} is a sequence of @value{GDBN} commands to
which you assign a new name as a command. This is done with the
-@code{define} command. User commands may accept an unlimited number of arguments
-separated by whitespace. Arguments are accessed within the user command
-via @code{$arg0@dots{}$argN}. A trivial example:
+@code{define} command.
+
+User commands may accept an unlimited number of arguments separated by
+whitespace. Arguments are accessed within the user command via
+@code{$arg0@dots{}$argN}. The arguments are text substitutions, so
+they may reference variables, use complex expressions, or even perform
+inferior functions calls. Note, however, that this textual
+substitution means that working with certain arguments is difficult.
+For example, there is no way for the user to pass an argument
+containing a space; and while stringifying an argument can be done
+using an expression like @code{"$arg1"}, this will fail if the
+argument contains a quote. For more complicated and robust commands,
+we recommend writing them in Python; see @ref{CLI Commands In Python}.
+
+A trivial example:
@smallexample
define adder
@@ -29243,9 +29259,7 @@ adder 1 2 3
@noindent
This defines the command @code{adder}, which prints the sum of
-its three arguments. Note the arguments are text substitutions, so they may
-reference variables, use complex expressions, or even perform inferior
-functions calls.
+its three arguments.
@cindex argument count in user-defined commands
@cindex how many arguments (user-defined commands)
@@ -41430,7 +41444,8 @@ This command is useful for debugging the agent version of dynamic
printf (@pxref{Dynamic Printf}).
@kindex maint info breakpoints
-@item @anchor{maint info breakpoints}maint info breakpoints
+@anchor{maint info breakpoints}
+@item maint info breakpoints
Using the same format as @samp{info breakpoints}, display both the
breakpoints you've set explicitly, and those @value{GDBN} is using for
internal purposes. Internal breakpoints are shown with negative
@@ -46326,6 +46341,13 @@ and the return value is the size of this attachment in bytes.
If an error occurs the return value is -1. The format of the
returned binary attachment is as described in @ref{struct stat}.
+@item vFile:stat: @var{filename}
+Get information about the file @var{filename} on the target.
+On success the information is returned as a binary attachment
+and the return value is the size of this attachment in bytes.
+If an error occurs the return value is -1. The format of the
+returned binary attachment is as described in @ref{struct stat}.
+
@item vFile:unlink: @var{filename}
Delete the file at @var{filename} on the target. Return 0,
or -1 if an error occurs. The @var{filename} is a string.
@@ -51011,7 +51033,7 @@ Richard M. Stallman and Roland H. Pesch, July 1991.
@format
@c man begin SYNOPSIS gcore
-gcore [-a] [-o @var{prefix}] @var{pid1} [@var{pid2}...@var{pidN}]
+gcore [-a] [-o @var{prefix}] [-d @var{directory}] @var{pid1} [@var{pid2}...@var{pidN}]
@c man end
@end format
@@ -51039,6 +51061,10 @@ when composing the file names of the core dumps. The file name is
composed as @file{@var{prefix}.@var{pid}}, where @var{pid} is the
process ID of the running program being analyzed by @command{gcore}.
If not specified, @var{prefix} defaults to @var{gcore}.
+
+@item -d @var{directory}
+Use @var{directory} as the data directory when invoking @value{GDBN} for running
+the gcore command. This argument is optional.
@end table
@c man end
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 5fea668..637c81f 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -2253,7 +2253,7 @@ dwarf2_get_symbol_read_needs (gdb::array_view<const gdb_byte> expr,
/* A helper function that throws an unimplemented error mentioning a
given DWARF operator. */
-static void ATTRIBUTE_NORETURN
+[[noreturn]] static void
unimplemented (unsigned int op)
{
const char *name = get_DW_OP_name (op);
diff --git a/gdb/dwarf2/macro.c b/gdb/dwarf2/macro.c
index bc781c2..5371acf 100644
--- a/gdb/dwarf2/macro.c
+++ b/gdb/dwarf2/macro.c
@@ -160,9 +160,7 @@ parse_macro_definition (struct macro_source_file *file, int line,
/* It's a function-like macro. */
gdb_assert (*p == '(');
std::string name (body, p - body);
- int argc = 0;
- int argv_size = 1;
- char **argv = XNEWVEC (char *, argv_size);
+ std::vector<std::string> argv;
p++;
@@ -178,18 +176,12 @@ parse_macro_definition (struct macro_source_file *file, int line,
p++;
if (! *p || p == arg_start)
- dwarf2_macro_malformed_definition_complaint (body);
- else
{
- /* Make sure argv has room for the new argument. */
- if (argc >= argv_size)
- {
- argv_size *= 2;
- argv = XRESIZEVEC (char *, argv, argv_size);
- }
-
- argv[argc++] = savestring (arg_start, p - arg_start);
+ dwarf2_macro_malformed_definition_complaint (body);
+ return;
}
+ else
+ argv.emplace_back (arg_start, p);
p = consume_improper_spaces (p, body);
@@ -208,16 +200,12 @@ parse_macro_definition (struct macro_source_file *file, int line,
if (*p == ' ')
/* Perfectly formed definition, no complaints. */
- macro_define_function (file, line, name.c_str (),
- argc, (const char **) argv,
- p + 1);
+ macro_define_function (file, line, name.c_str (), argv, p + 1);
else if (*p == '\0')
{
/* Complain, but do define it. */
dwarf2_macro_malformed_definition_complaint (body);
- macro_define_function (file, line, name.c_str (),
- argc, (const char **) argv,
- p);
+ macro_define_function (file, line, name.c_str (), argv, p);
}
else
/* Just complain. */
@@ -226,11 +214,6 @@ parse_macro_definition (struct macro_source_file *file, int line,
else
/* Just complain. */
dwarf2_macro_malformed_definition_complaint (body);
-
- for (int i = 0; i < argc; i++)
- xfree (argv[i]);
-
- xfree (argv);
}
/* Skip some bytes from BYTES according to the form given in FORM.
diff --git a/gdb/eval.c b/gdb/eval.c
index 40640ae..f6b8136 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -622,11 +622,7 @@ evaluate_subexp_do_call (expression *exp, enum noside noside,
if (ftype->code () == TYPE_CODE_INTERNAL_FUNCTION)
{
- /* We don't know anything about what the internal
- function might return, but we have to return
- something. */
- return value::zero (builtin_type (exp->gdbarch)->builtin_int,
- not_lval);
+ /* The call to call_internal_function below handles noside. */
}
else if (ftype->code () == TYPE_CODE_XMETHOD)
{
@@ -666,7 +662,8 @@ evaluate_subexp_do_call (expression *exp, enum noside noside,
{
case TYPE_CODE_INTERNAL_FUNCTION:
return call_internal_function (exp->gdbarch, exp->language_defn,
- callee, argvec.size (), argvec.data ());
+ callee, argvec.size (), argvec.data (),
+ noside);
case TYPE_CODE_XMETHOD:
return callee->call_xmethod (argvec);
default:
diff --git a/gdb/event-top.c b/gdb/event-top.c
index b81970d..cdc7874 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -894,7 +894,7 @@ unblock_signal (int sig)
/* Called to handle fatal signals. SIG is the signal number. */
-static void ATTRIBUTE_NORETURN
+[[noreturn]] static void
handle_fatal_signal (int sig)
{
#ifdef TUI
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
index bdf9c32..259f274 100644
--- a/gdb/f-exp.y
+++ b/gdb/f-exp.y
@@ -754,7 +754,11 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier */
| REAL_S8_KEYWORD
{ $$ = parse_f_type (pstate)->builtin_real_s8; }
| REAL_S16_KEYWORD
- { $$ = parse_f_type (pstate)->builtin_real_s16; }
+ { $$ = parse_f_type (pstate)->builtin_real_s16;
+ if ($$->code () == TYPE_CODE_ERROR)
+ error (_("unsupported type %s"),
+ TYPE_SAFE_NAME ($$));
+ }
| COMPLEX_KEYWORD
{ $$ = parse_f_type (pstate)->builtin_complex; }
| COMPLEX_S4_KEYWORD
@@ -762,7 +766,11 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier */
| COMPLEX_S8_KEYWORD
{ $$ = parse_f_type (pstate)->builtin_complex_s8; }
| COMPLEX_S16_KEYWORD
- { $$ = parse_f_type (pstate)->builtin_complex_s16; }
+ { $$ = parse_f_type (pstate)->builtin_complex_s16;
+ if ($$->code () == TYPE_CODE_ERROR)
+ error (_("unsupported type %s"),
+ TYPE_SAFE_NAME ($$));
+ }
| SINGLE PRECISION
{ $$ = parse_f_type (pstate)->builtin_real;}
| DOUBLE PRECISION
@@ -1156,12 +1164,9 @@ push_kind_type (LONGEST val, struct type *type)
type_stack->push (tp_kind);
}
-/* Called when a type has a '(kind=N)' modifier after it, for example
- 'character(kind=1)'. The BASETYPE is the type described by 'character'
- in our example, and KIND is the integer '1'. This function returns a
- new type that represents the basetype of a specific kind. */
+/* Helper function for convert_to_kind_type. */
static struct type *
-convert_to_kind_type (struct type *basetype, int kind)
+convert_to_kind_type_1 (struct type *basetype, int kind)
{
if (basetype == parse_f_type (pstate)->builtin_character)
{
@@ -1211,13 +1216,25 @@ convert_to_kind_type (struct type *basetype, int kind)
return parse_f_type (pstate)->builtin_integer_s8;
}
- error (_("unsupported kind %d for type %s"),
- kind, TYPE_SAFE_NAME (basetype));
-
- /* Should never get here. */
return nullptr;
}
+/* Called when a type has a '(kind=N)' modifier after it, for example
+ 'character(kind=1)'. The BASETYPE is the type described by 'character'
+ in our example, and KIND is the integer '1'. This function returns a
+ new type that represents the basetype of a specific kind. */
+static struct type *
+convert_to_kind_type (struct type *basetype, int kind)
+{
+ struct type *res = convert_to_kind_type_1 (basetype, kind);
+
+ if (res == nullptr || res->code () == TYPE_CODE_ERROR)
+ error (_("unsupported kind %d for type %s"),
+ kind, TYPE_SAFE_NAME (basetype));
+
+ return res;
+}
+
struct f_token
{
/* The string to match against. */
diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index 367f641..08a01c1 100644
--- a/gdb/fbsd-tdep.c
+++ b/gdb/fbsd-tdep.c
@@ -2034,21 +2034,23 @@ fbsd_get_thread_local_address (struct gdbarch *gdbarch, CORE_ADDR dtv_addr,
{
LONGEST tls_index = fbsd_get_tls_index (gdbarch, lm_addr);
- gdb_byte buf[gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT];
- if (target_read_memory (dtv_addr, buf, sizeof buf) != 0)
+ gdb::byte_vector buf (gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT);
+ if (target_read_memory (dtv_addr, buf.data (), buf.size ()) != 0)
throw_error (TLS_GENERIC_ERROR,
_("Cannot find thread-local variables on this target"));
const struct builtin_type *builtin = builtin_type (gdbarch);
- CORE_ADDR addr = gdbarch_pointer_to_address (gdbarch,
- builtin->builtin_data_ptr, buf);
+ CORE_ADDR addr
+ = gdbarch_pointer_to_address (gdbarch, builtin->builtin_data_ptr,
+ buf.data ());
addr += (tls_index + 1) * builtin->builtin_data_ptr->length ();
- if (target_read_memory (addr, buf, sizeof buf) != 0)
+ if (target_read_memory (addr, buf.data (), buf.size ()) != 0)
throw_error (TLS_GENERIC_ERROR,
_("Cannot find thread-local variables on this target"));
- addr = gdbarch_pointer_to_address (gdbarch, builtin->builtin_data_ptr, buf);
+ addr = gdbarch_pointer_to_address (gdbarch, builtin->builtin_data_ptr,
+ buf.data ());
return addr + offset;
}
diff --git a/gdb/frame.c b/gdb/frame.c
index 43efac0..e6ab547 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -2628,7 +2628,7 @@ inside_entry_func (const frame_info_ptr &this_frame)
{
CORE_ADDR entry_point;
- if (!entry_point_address_query (&entry_point))
+ if (!entry_point_address_query (current_program_space, &entry_point))
return false;
return get_frame_func (this_frame) == entry_point;
diff --git a/gdb/gcore.in b/gdb/gcore.in
index 982c854..0c40e5a 100644
--- a/gdb/gcore.in
+++ b/gdb/gcore.in
@@ -27,7 +27,9 @@ prefix=core
# to ensure gdb dumps all mappings (OS dependent).
dump_all_cmds=()
-while getopts :ao: opt; do
+data_directory_opt=()
+
+while getopts :ao:d: opt; do
case "$opt" in
a)
case "$OSTYPE" in
@@ -40,8 +42,11 @@ while getopts :ao: opt; do
o)
prefix=$OPTARG
;;
+ d)
+ data_directory_opt=("--data-directory" "$OPTARG")
+ ;;
*)
- echo "usage: @GCORE_TRANSFORM_NAME@ [-a] [-o prefix] pid1 [pid2...pidN]"
+ echo "usage: @GCORE_TRANSFORM_NAME@ [-a] [-o prefix] [-d data-directory] pid1 [pid2...pidN]"
exit 2
;;
esac
@@ -51,7 +56,7 @@ shift $((OPTIND-1))
if [ "$#" -eq "0" ]
then
- echo "usage: @GCORE_TRANSFORM_NAME@ [-a] [-o prefix] pid1 [pid2...pidN]"
+ echo "usage: @GCORE_TRANSFORM_NAME@ [-a] [-o prefix] [-d data-directory] pid1 [pid2...pidN]"
exit 2
fi
@@ -98,6 +103,7 @@ do
# `</dev/null' to avoid touching interactive terminal if it is
# available but not accessible as GDB would get stopped on SIGTTIN.
"$binary_path/@GDB_TRANSFORM_NAME@" </dev/null \
+ "${data_directory_opt[@]}" \
--nx --batch --readnever -iex 'set debuginfod enabled off' \
-ex "set pagination off" -ex "set height 0" -ex "set width 0" \
"${dump_all_cmds[@]}" \
diff --git a/gdb/gdb-gdb.py.in b/gdb/gdb-gdb.py.in
index b5a7fa4..7cab694 100644
--- a/gdb/gdb-gdb.py.in
+++ b/gdb/gdb-gdb.py.in
@@ -342,7 +342,7 @@ class IntrusiveListPrinter:
corresponding intrusive_list_node.
"""
- assert elem_ptr.type.code == gdb.TYPE_CODE_PTR
+ assert elem_ptr.type.strip_typedefs().code == gdb.TYPE_CODE_PTR
if self._uses_member_node():
# Node as a member: add the member node offset from to the element's
diff --git a/gdb/gdbarch.c b/gdb/gdbarch-gen.c
index 58e9ebb..58e9ebb 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch-gen.c
diff --git a/gdb/gdbarch.py b/gdb/gdbarch.py
index 4b4db66..19a888e 100755
--- a/gdb/gdbarch.py
+++ b/gdb/gdbarch.py
@@ -119,7 +119,7 @@ with open("gdbarch-gen.h", "w") as f:
file=f,
)
-with open("gdbarch.c", "w") as f:
+with open("gdbarch-gen.c", "w") as f:
print(copyright, file=f)
print(file=f)
print(file=f)
diff --git a/gdb/go-exp.y b/gdb/go-exp.y
index 1a6ebbe..115c71b 100644
--- a/gdb/go-exp.y
+++ b/gdb/go-exp.y
@@ -577,8 +577,8 @@ variable: name_not_typename
if (msymbol.minsym != NULL)
pstate->push_new<var_msym_value_operation>
(msymbol);
- else if (!have_full_symbols ()
- && !have_partial_symbols ())
+ else if (!have_full_symbols (current_program_space)
+ && !have_partial_symbols (current_program_space))
error (_("No symbol table is loaded. "
"Use the \"file\" command."));
else
diff --git a/gdb/guile/guile-internal.h b/gdb/guile/guile-internal.h
index be16fee..dea7884 100644
--- a/gdb/guile/guile-internal.h
+++ b/gdb/guile/guile-internal.h
@@ -326,32 +326,32 @@ extern SCM gdbscm_make_type_error (const char *subr, int arg_pos,
extern SCM gdbscm_make_invalid_object_error (const char *subr, int arg_pos,
SCM bad_value, const char *error);
-extern void gdbscm_invalid_object_error (const char *subr, int arg_pos,
- SCM bad_value, const char *error)
- ATTRIBUTE_NORETURN;
+[[noreturn]] extern void gdbscm_invalid_object_error (const char *subr,
+ int arg_pos,
+ SCM bad_value,
+ const char *error);
extern SCM gdbscm_make_out_of_range_error (const char *subr, int arg_pos,
SCM bad_value, const char *error);
-extern void gdbscm_out_of_range_error (const char *subr, int arg_pos,
- SCM bad_value, const char *error)
- ATTRIBUTE_NORETURN;
+[[noreturn]] extern void gdbscm_out_of_range_error (const char *subr,
+ int arg_pos, SCM bad_value,
+ const char *error);
extern SCM gdbscm_make_misc_error (const char *subr, int arg_pos,
SCM bad_value, const char *error);
-extern void gdbscm_misc_error (const char *subr, int arg_pos,
- SCM bad_value, const char *error)
- ATTRIBUTE_NORETURN;
+[[noreturn]] extern void gdbscm_misc_error (const char *subr, int arg_pos,
+ SCM bad_value, const char *error);
-extern void gdbscm_throw (SCM exception) ATTRIBUTE_NORETURN;
+[[noreturn]] extern void gdbscm_throw (SCM exception);
struct gdbscm_gdb_exception;
extern SCM gdbscm_scm_from_gdb_exception
(const gdbscm_gdb_exception &exception);
-extern void gdbscm_throw_gdb_exception (gdbscm_gdb_exception exception)
- ATTRIBUTE_NORETURN;
+[[noreturn]] extern void gdbscm_throw_gdb_exception
+ (gdbscm_gdb_exception exception);
extern void gdbscm_print_exception_with_stack (SCM port, SCM stack,
SCM key, SCM args);
@@ -368,8 +368,8 @@ extern excp_matcher_func gdbscm_user_error_p;
extern SCM gdbscm_make_memory_error (const char *subr, const char *msg,
SCM args);
-extern void gdbscm_memory_error (const char *subr, const char *msg, SCM args)
- ATTRIBUTE_NORETURN;
+[[noreturn]] extern void gdbscm_memory_error (const char *subr,
+ const char *msg, SCM args);
/* scm-safe-call.c */
diff --git a/gdb/guile/scm-objfile.c b/gdb/guile/scm-objfile.c
index bccf6ba..d6c0559 100644
--- a/gdb/guile/scm-objfile.c
+++ b/gdb/guile/scm-objfile.c
@@ -250,7 +250,7 @@ gdbscm_objfile_progspace (SCM self)
objfile_smob *o_smob
= ofscm_get_valid_objfile_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
- return psscm_scm_from_pspace (o_smob->objfile->pspace);
+ return psscm_scm_from_pspace (o_smob->objfile->pspace ());
}
/* (objfile-pretty-printers <gdb:objfile>) -> list
diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c
index bfe3fb8..0e360b1 100644
--- a/gdb/i386-linux-nat.c
+++ b/gdb/i386-linux-nat.c
@@ -315,19 +315,19 @@ fetch_xstateregs (struct regcache *regcache, int tid)
{
struct gdbarch *gdbarch = regcache->arch ();
const i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
- char xstateregs[tdep->xsave_layout.sizeof_xsave];
+ gdb::byte_vector xstateregs (tdep->xsave_layout.sizeof_xsave);
struct iovec iov;
if (have_ptrace_getregset != TRIBOOL_TRUE)
return 0;
- iov.iov_base = xstateregs;
- iov.iov_len = sizeof(xstateregs);
+ iov.iov_base = xstateregs.data ();
+ iov.iov_len = xstateregs.size ();
if (ptrace (PTRACE_GETREGSET, tid, (unsigned int) NT_X86_XSTATE,
&iov) < 0)
perror_with_name (_("Couldn't read extended state status"));
- i387_supply_xsave (regcache, -1, xstateregs);
+ i387_supply_xsave (regcache, -1, xstateregs.data ());
return 1;
}
@@ -340,19 +340,19 @@ store_xstateregs (const struct regcache *regcache, int tid, int regno)
{
struct gdbarch *gdbarch = regcache->arch ();
const i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
- char xstateregs[tdep->xsave_layout.sizeof_xsave];
+ gdb::byte_vector xstateregs (tdep->xsave_layout.sizeof_xsave);
struct iovec iov;
if (have_ptrace_getregset != TRIBOOL_TRUE)
return 0;
-
- iov.iov_base = xstateregs;
- iov.iov_len = sizeof(xstateregs);
+
+ iov.iov_base = xstateregs.data ();
+ iov.iov_len = xstateregs.size ();
if (ptrace (PTRACE_GETREGSET, tid, (unsigned int) NT_X86_XSTATE,
&iov) < 0)
perror_with_name (_("Couldn't read extended state status"));
- i387_collect_xsave (regcache, regno, xstateregs, 0);
+ i387_collect_xsave (regcache, regno, xstateregs.data (), 0);
if (ptrace (PTRACE_SETREGSET, tid, (unsigned int) NT_X86_XSTATE,
(int) &iov) < 0)
diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index 1318d6b..df993b6 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -320,6 +320,21 @@ inf_child_target::fileio_fstat (int fd, struct stat *sb, fileio_error *target_er
return ret;
}
+/* Implementation of to_fileio_stat. */
+
+int
+inf_child_target::fileio_stat (struct inferior *inf, const char *filename,
+ struct stat *sb, fileio_error *target_errno)
+{
+ int ret;
+
+ ret = lstat (filename, sb);
+ if (ret == -1)
+ *target_errno = host_to_fileio_error (errno);
+
+ return ret;
+}
+
/* Implementation of to_fileio_close. */
int
diff --git a/gdb/inf-child.h b/gdb/inf-child.h
index 91955a6..65d42e1 100644
--- a/gdb/inf-child.h
+++ b/gdb/inf-child.h
@@ -81,6 +81,8 @@ public:
int fileio_pread (int fd, gdb_byte *read_buf, int len,
ULONGEST offset, fileio_error *target_errno) override;
int fileio_fstat (int fd, struct stat *sb, fileio_error *target_errno) override;
+ int fileio_stat (struct inferior *inf, const char *filename,
+ struct stat *sb, fileio_error *target_errno) override;
int fileio_close (int fd, fileio_error *target_errno) override;
int fileio_unlink (struct inferior *inf,
const char *filename,
diff --git a/gdb/infcall.c b/gdb/infcall.c
index edac9a7..559fcb7 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -1271,7 +1271,7 @@ call_function_by_hand_dummy (struct value *function,
CORE_ADDR dummy_addr;
real_pc = funaddr;
- dummy_addr = entry_point_address ();
+ dummy_addr = entry_point_address (current_program_space);
/* A call dummy always consists of just a single breakpoint, so
its address is the same as the address of the dummy.
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 71514d5..a030788 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -383,7 +383,7 @@ run_command_1 (const char *args, int from_tty, enum run_how run_how)
/* Clean up any leftovers from other runs. Some other things from
this function should probably be moved into target_pre_inferior. */
- target_pre_inferior (from_tty);
+ target_pre_inferior ();
/* The comment here used to read, "The exec file is re-read every
time we do a generic_mourn_inferior, so we just have to worry
@@ -519,7 +519,7 @@ start_command (const char *args, int from_tty)
/* Some languages such as Ada need to search inside the program
minimal symbols for the location where to put the temporary
breakpoint before starting. */
- if (!have_minimal_symbols ())
+ if (!have_minimal_symbols (current_program_space))
error (_("No symbol table loaded. Use the \"file\" command."));
/* Run the program until reaching the main procedure... */
@@ -1078,7 +1078,8 @@ jump_command (const char *arg, int from_tty)
{
/* If multiple sal-objects were found, try dropping those that aren't
from the current symtab. */
- struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+ symtab_and_line cursal
+ = get_current_source_symtab_and_line (current_program_space);
sals.erase (std::remove_if (sals.begin (), sals.end (),
[&] (const symtab_and_line &sal)
{
@@ -2628,7 +2629,7 @@ attach_command (const char *args, int from_tty)
/* Clean up any leftovers from other runs. Some other things from
this function should probably be moved into target_pre_inferior. */
- target_pre_inferior (from_tty);
+ target_pre_inferior ();
gdb::unique_xmalloc_ptr<char> stripped = strip_bg_char (args, &async_exec);
args = stripped.get ();
@@ -2827,7 +2828,7 @@ detach_command (const char *args, int from_tty)
/* If the solist is global across inferiors, don't clear it when we
detach from a single inferior. */
if (!gdbarch_has_global_solist (inf->arch ()))
- no_shared_libraries (nullptr, from_tty);
+ no_shared_libraries (inf->pspace);
if (deprecated_detach_hook)
deprecated_detach_hook ();
@@ -2853,7 +2854,7 @@ disconnect_command (const char *args, int from_tty)
query_if_trace_running (from_tty);
disconnect_tracing ();
target_disconnect (args, from_tty);
- no_shared_libraries (nullptr, from_tty);
+ no_shared_libraries (current_program_space);
init_thread_list ();
update_previous_thread ();
if (deprecated_detach_hook)
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 1f32a63..05e81a0 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1317,7 +1317,7 @@ follow_exec (ptid_t ptid, const char *exec_file_target)
/* Also, loading a symbol file below may trigger symbol lookups, and
we don't want those to be satisfied by the libraries of the
previous incarnation of this process. */
- no_shared_libraries (nullptr, 0);
+ no_shared_libraries (current_program_space);
inferior *execing_inferior = current_inferior ();
inferior *following_inferior;
@@ -9296,12 +9296,24 @@ print_stop_location (const target_waitstatus &ws)
&& (tp->control.step_start_function
== find_pc_function (tp->stop_pc ())))
{
- /* Finished step, just print source line. */
- source_flag = SRC_LINE;
+ symtab_and_line sal = find_frame_sal (get_selected_frame (nullptr));
+ if (sal.symtab != tp->current_symtab)
+ {
+ /* Finished step in same frame but into different file, print
+ location and source line. */
+ source_flag = SRC_AND_LOC;
+ }
+ else
+ {
+ /* Finished step in same frame and same file, just print source
+ line. */
+ source_flag = SRC_LINE;
+ }
}
else
{
- /* Print location and source line. */
+ /* Finished step into different frame, print location and source
+ line. */
source_flag = SRC_AND_LOC;
}
break;
diff --git a/gdb/inline-frame.c b/gdb/inline-frame.c
index f65f39b..bed99dc 100644
--- a/gdb/inline-frame.c
+++ b/gdb/inline-frame.c
@@ -35,9 +35,9 @@
keep our own list. */
struct inline_state
{
- inline_state (thread_info *thread_, int skipped_frames_, CORE_ADDR saved_pc_,
+ inline_state (thread_info *thread_, CORE_ADDR saved_pc_,
std::vector<symbol *> &&skipped_symbols_)
- : thread (thread_), skipped_frames (skipped_frames_), saved_pc (saved_pc_),
+ : thread (thread_), saved_pc (saved_pc_),
skipped_symbols (std::move (skipped_symbols_))
{}
@@ -45,19 +45,14 @@ struct inline_state
stopped thread. */
thread_info *thread;
- /* The number of inlined functions we are skipping. Each of these
- functions can be stepped in to. */
- int skipped_frames;
-
- /* Only valid if SKIPPED_FRAMES is non-zero. This is the PC used
- when calculating SKIPPED_FRAMES; used to check whether we have
+ /* Only valid if SKIPPED_SYMBOLS is not empty. This is the PC used
+ when calculating SKIPPED_SYMBOLS; used to check whether we have
moved to a new location by user request. If so, we invalidate
any skipped frames. */
CORE_ADDR saved_pc;
- /* Only valid if SKIPPED_FRAMES is non-zero. This is the list of all
- function symbols that have been skipped, from inner most to outer
- most. It is used to find the call site of the current frame. */
+ /* The list of all function symbols that have been skipped, from inner most
+ to outer most. It is used to find the call site of the current frame. */
std::vector<struct symbol *> skipped_symbols;
};
@@ -247,10 +242,12 @@ inline_frame_sniffer (const struct frame_unwind *self,
/* If this is the topmost frame, or all frames above us are inlined,
then check whether we were requested to skip some frames (so they
can be stepped into later). */
- if (state != NULL && state->skipped_frames > 0 && next_frame == NULL)
+ if (state != nullptr
+ && !state->skipped_symbols.empty ()
+ && next_frame == nullptr)
{
- gdb_assert (depth >= state->skipped_frames);
- depth -= state->skipped_frames;
+ gdb_assert (depth >= state->skipped_symbols.size ());
+ depth -= state->skipped_symbols.size ();
}
/* If all the inlined functions here already have frames, then pass
@@ -343,7 +340,6 @@ skip_inline_frames (thread_info *thread, bpstat *stop_chain)
{
const struct block *frame_block, *cur_block;
std::vector<struct symbol *> skipped_syms;
- int skip_count = 0;
/* This function is called right after reinitializing the frame
cache. We try not to do more unwinding than absolutely
@@ -369,7 +365,6 @@ skip_inline_frames (thread_info *thread, bpstat *stop_chain)
if (stopped_by_user_bp_inline_frame (cur_block, stop_chain))
break;
- skip_count++;
skipped_syms.push_back (cur_block->function ());
}
else
@@ -383,11 +378,11 @@ skip_inline_frames (thread_info *thread, bpstat *stop_chain)
}
gdb_assert (find_inline_frame_state (thread) == NULL);
- inline_states.emplace_back (thread, skip_count, this_pc,
- std::move (skipped_syms));
- if (skip_count != 0)
+ if (!skipped_syms.empty ())
reinit_frame_cache ();
+
+ inline_states.emplace_back (thread, this_pc, std::move (skipped_syms));
}
/* Step into an inlined function by unhiding it. */
@@ -397,8 +392,10 @@ step_into_inline_frame (thread_info *thread)
{
inline_state *state = find_inline_frame_state (thread);
- gdb_assert (state != NULL && state->skipped_frames > 0);
- state->skipped_frames--;
+ gdb_assert (state != nullptr);
+ gdb_assert (!state->skipped_symbols.empty ());
+
+ state->skipped_symbols.pop_back ();
reinit_frame_cache ();
}
@@ -413,7 +410,7 @@ inline_skipped_frames (thread_info *thread)
if (state == NULL)
return 0;
else
- return state->skipped_frames;
+ return state->skipped_symbols.size ();
}
/* If one or more inlined functions are hidden, return the symbol for
@@ -426,13 +423,9 @@ inline_skipped_symbol (thread_info *thread)
gdb_assert (state != NULL);
/* This should only be called when we are skipping at least one frame,
- hence SKIPPED_FRAMES will be greater than zero when we get here.
- We initialise SKIPPED_FRAMES at the same time as we build
- SKIPPED_SYMBOLS, hence it should be true that SKIPPED_FRAMES never
- indexes outside of the SKIPPED_SYMBOLS vector. */
- gdb_assert (state->skipped_frames > 0);
- gdb_assert (state->skipped_frames <= state->skipped_symbols.size ());
- return state->skipped_symbols[state->skipped_frames - 1];
+ hence SKIPPED_SYMBOLS will have at least one item when we get here. */
+ gdb_assert (!state->skipped_symbols.empty ());
+ return state->skipped_symbols.back ();
}
/* Return the number of functions inlined into THIS_FRAME. Some of
diff --git a/gdb/jit.c b/gdb/jit.c
index 797be95..2744d03 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -660,8 +660,8 @@ jit_object_close_impl (struct gdb_symbol_callbacks *cb,
paddress (priv_data->gdbarch,
priv_data->entry.symfile_addr));
- objfile *objfile = objfile::make (nullptr, objfile_name.c_str (),
- OBJF_NOT_FILENAME);
+ objfile *objfile = objfile::make (nullptr, current_program_space,
+ objfile_name.c_str (), OBJF_NOT_FILENAME);
objfile->per_bfd->gdbarch = priv_data->gdbarch;
for (gdb_symtab &symtab : obj->symtabs)
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 7a1fbc2..9b0652c 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -1156,7 +1156,7 @@ iterate_over_all_matching_symtabs
set_current_program_space (pspace);
- for (objfile *objfile : current_program_space->objfiles ())
+ for (objfile *objfile : pspace->objfiles ())
{
objfile->expand_symtabs_matching (NULL, &lookup_name, NULL, NULL,
(SEARCH_GLOBAL_BLOCK
@@ -1544,15 +1544,15 @@ decode_line_2 (struct linespec_state *self,
/* Throw an appropriate error when SYMBOL is not found (optionally in
FILENAME). */
-static void ATTRIBUTE_NORETURN
+[[noreturn]] static void
symbol_not_found_error (const char *symbol, const char *filename)
{
if (symbol == NULL)
symbol = "";
- if (!have_full_symbols ()
- && !have_partial_symbols ()
- && !have_minimal_symbols ())
+ if (!have_full_symbols (current_program_space)
+ && !have_partial_symbols (current_program_space)
+ && !have_minimal_symbols (current_program_space))
throw_error (NOT_FOUND_ERROR,
_("No symbol table is loaded. Use the \"file\" command."));
@@ -1586,7 +1586,7 @@ symbol_not_found_error (const char *symbol, const char *filename)
/* Throw an appropriate error when an unexpected token is encountered
in the input. */
-static void ATTRIBUTE_NORETURN
+[[noreturn]] static void
unexpected_linespec_error (linespec_parser *parser)
{
linespec_token token;
@@ -1613,7 +1613,7 @@ unexpected_linespec_error (linespec_parser *parser)
/* Throw an undefined label error. */
-static void ATTRIBUTE_NORETURN
+[[noreturn]] static void
undefined_label_error (const char *function, const char *label)
{
if (function != NULL)
@@ -1628,7 +1628,7 @@ undefined_label_error (const char *function, const char *label)
/* Throw a source file not found error. */
-static void ATTRIBUTE_NORETURN
+[[noreturn]] static void
source_file_not_found_error (const char *name)
{
throw_error (NOT_FOUND_ERROR, _("No source file named %s."), name);
@@ -2172,7 +2172,7 @@ convert_linespec_to_sals (struct linespec_state *state, linespec *ls)
for (const auto &sym : ls->labels.label_symbols)
{
struct program_space *pspace
- = sym.symbol->symtab ()->compunit ()->objfile ()->pspace;
+ = sym.symbol->symtab ()->compunit ()->objfile ()->pspace ();
if (symbol_to_sal (&sal, state->funfirstline, sym.symbol)
&& maybe_add_address (state->addr_set, pspace, sal.pc))
@@ -2194,7 +2194,7 @@ convert_linespec_to_sals (struct linespec_state *state, linespec *ls)
for (const auto &sym : ls->function_symbols)
{
program_space *pspace
- = sym.symbol->symtab ()->compunit ()->objfile ()->pspace;
+ = sym.symbol->symtab ()->compunit ()->objfile ()->pspace ();
set_current_program_space (pspace);
/* Don't skip to the first line of the function if we
@@ -2256,7 +2256,7 @@ convert_linespec_to_sals (struct linespec_state *state, linespec *ls)
for (const auto &elem : ls->minimal_symbols)
{
- program_space *pspace = elem.objfile->pspace;
+ program_space *pspace = elem.objfile->pspace ();
set_current_program_space (pspace);
minsym_found (state, elem.objfile, elem.minsym, &sals);
}
@@ -3205,7 +3205,8 @@ decode_line_with_current_source (const char *string, int flags)
/* We use whatever is set as the current source line. We do not try
and get a default source symtab+line or it will recursively call us! */
- symtab_and_line cursal = get_current_source_symtab_and_line ();
+ symtab_and_line cursal
+ = get_current_source_symtab_and_line (current_program_space);
location_spec_up locspec = string_to_location_spec (&string,
current_language);
@@ -3255,9 +3256,9 @@ initialize_defaults (struct symtab **default_symtab, int *default_line)
/* Use whatever we have for the default source line. We don't use
get_current_or_default_symtab_and_line as it can recurse and call
us back! */
- struct symtab_and_line cursal =
- get_current_source_symtab_and_line ();
-
+ symtab_and_line cursal
+ = get_current_source_symtab_and_line (current_program_space);
+
*default_symtab = cursal.symtab;
*default_line = cursal.line;
}
@@ -3437,7 +3438,7 @@ lookup_prefix_sym (struct linespec_state *state,
{
/* Program spaces that are executing startup should have
been filtered out earlier. */
- program_space *pspace = elt->compunit ()->objfile ()->pspace;
+ program_space *pspace = elt->compunit ()->objfile ()->pspace ();
gdb_assert (!pspace->executing_startup);
set_current_program_space (pspace);
@@ -3459,8 +3460,8 @@ compare_symbols (const block_symbol &a, const block_symbol &b)
{
uintptr_t uia, uib;
- uia = (uintptr_t) a.symbol->symtab ()->compunit ()->objfile ()->pspace;
- uib = (uintptr_t) b.symbol->symtab ()->compunit ()->objfile ()->pspace;
+ uia = (uintptr_t) a.symbol->symtab ()->compunit ()->objfile ()->pspace ();
+ uib = (uintptr_t) b.symbol->symtab ()->compunit ()->objfile ()->pspace ();
if (uia < uib)
return true;
@@ -3483,8 +3484,8 @@ compare_msymbols (const bound_minimal_symbol &a, const bound_minimal_symbol &b)
{
uintptr_t uia, uib;
- uia = (uintptr_t) a.objfile->pspace;
- uib = (uintptr_t) a.objfile->pspace;
+ uia = (uintptr_t) a.objfile->pspace ();
+ uib = (uintptr_t) a.objfile->pspace ();
if (uia < uib)
return true;
@@ -3584,7 +3585,7 @@ find_method (struct linespec_state *self,
/* Program spaces that are executing startup should have
been filtered out earlier. */
- pspace = sym->symtab ()->compunit ()->objfile ()->pspace;
+ pspace = sym->symtab ()->compunit ()->objfile ()->pspace ();
gdb_assert (!pspace->executing_startup);
set_current_program_space (pspace);
t = check_typedef (sym->type ());
@@ -3596,7 +3597,7 @@ find_method (struct linespec_state *self,
if (ix == sym_classes->size () - 1
|| (pspace
!= (sym_classes->at (ix + 1).symbol->symtab ()
- ->compunit ()->objfile ()->pspace)))
+ ->compunit ()->objfile ()->pspace ())))
{
/* If we did not find a direct implementation anywhere in
this program space, consider superclasses. */
@@ -3716,7 +3717,8 @@ symtabs_from_filename (const char *filename,
if (result.empty ())
{
- if (!have_full_symbols () && !have_partial_symbols ())
+ if (!have_full_symbols (current_program_space)
+ && !have_partial_symbols (current_program_space))
throw_error (NOT_FOUND_ERROR,
_("No symbol table is loaded. "
"Use the \"file\" command."));
@@ -3963,7 +3965,7 @@ find_label_symbols (struct linespec_state *self,
{
fn_sym = elt.symbol;
set_current_program_space
- (fn_sym->symtab ()->compunit ()->objfile ()->pspace);
+ (fn_sym->symtab ()->compunit ()->objfile ()->pspace ());
block = fn_sym->value_block ();
find_label_symbols_in_block (block, name, fn_sym, completion_mode,
@@ -3992,7 +3994,7 @@ decode_digits_list_mode (struct linespec_state *self,
/* The logic above should ensure this. */
gdb_assert (elt != NULL);
- program_space *pspace = elt->compunit ()->objfile ()->pspace;
+ program_space *pspace = elt->compunit ()->objfile ()->pspace ();
set_current_program_space (pspace);
/* Simplistic search just for the list command. */
@@ -4027,7 +4029,7 @@ decode_digits_ordinary (struct linespec_state *self,
/* The logic above should ensure this. */
gdb_assert (elt != NULL);
- program_space *pspace = elt->compunit ()->objfile ()->pspace;
+ program_space *pspace = elt->compunit ()->objfile ()->pspace ();
set_current_program_space (pspace);
pcs = find_pcs_for_symtab_line (elt, line, best_entry);
@@ -4153,7 +4155,7 @@ minsym_found (struct linespec_state *self, struct objfile *objfile,
sal.section = msymbol->obj_section (objfile);
- if (maybe_add_address (self->addr_set, objfile->pspace, sal.pc))
+ if (maybe_add_address (self->addr_set, objfile->pspace (), sal.pc))
add_sal_to_sals (self, result, &sal, msymbol->natural_name (), 0);
}
@@ -4213,7 +4215,7 @@ search_minsyms_for_name (struct collect_info *info,
set_current_program_space (pspace);
- for (objfile *objfile : current_program_space->objfiles ())
+ for (objfile *objfile : pspace->objfiles ())
{
iterate_over_minimal_symbols (objfile, name,
[&] (struct minimal_symbol *msym)
@@ -4228,7 +4230,7 @@ search_minsyms_for_name (struct collect_info *info,
}
else
{
- program_space *pspace = symtab->compunit ()->objfile ()->pspace;
+ program_space *pspace = symtab->compunit ()->objfile ()->pspace ();
if (search_pspace == NULL || pspace == search_pspace)
{
@@ -4322,13 +4324,13 @@ add_matching_symbols_to_info (const char *name,
{ return info->add_symbol (bsym); });
search_minsyms_for_name (info, lookup_name, pspace, NULL);
}
- else if (pspace == NULL || pspace == elt->compunit ()->objfile ()->pspace)
+ else if (pspace == NULL || pspace == elt->compunit ()->objfile ()->pspace ())
{
int prev_len = info->result.symbols->size ();
/* Program spaces that are executing startup should have
been filtered out earlier. */
- program_space *elt_pspace = elt->compunit ()->objfile ()->pspace;
+ program_space *elt_pspace = elt->compunit ()->objfile ()->pspace ();
gdb_assert (!elt_pspace->executing_startup);
set_current_program_space (elt_pspace);
iterate_over_file_blocks (elt, lookup_name, SEARCH_VFT,
@@ -4369,7 +4371,7 @@ symbol_to_sal (struct symtab_and_line *result,
result->symbol = sym;
result->line = sym->line ();
result->pc = sym->value_address ();
- result->pspace = result->symtab->compunit ()->objfile ()->pspace;
+ result->pspace = result->symtab->compunit ()->objfile ()->pspace ();
result->explicit_pc = 1;
return 1;
}
@@ -4385,7 +4387,7 @@ symbol_to_sal (struct symtab_and_line *result,
result->symbol = sym;
result->line = sym->line ();
result->pc = sym->value_address ();
- result->pspace = result->symtab->compunit ()->objfile ()->pspace;
+ result->pspace = result->symtab->compunit ()->objfile ()->pspace ();
return 1;
}
}
diff --git a/gdb/loongarch-linux-nat.c b/gdb/loongarch-linux-nat.c
index 8736287..bc9927d 100644
--- a/gdb/loongarch-linux-nat.c
+++ b/gdb/loongarch-linux-nat.c
@@ -18,6 +18,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#include "cli/cli-cmds.h"
#include "elf/common.h"
#include "gregset.h"
#include "inferior.h"
@@ -765,4 +766,19 @@ _initialize_loongarch_linux_nat ()
{
linux_target = &the_loongarch_linux_nat_target;
add_inf_child_target (&the_loongarch_linux_nat_target);
+
+ /* Add a maintenance command to enable printing the LoongArch internal
+ debug registers mirror variables. */
+ add_setshow_boolean_cmd ("show-debug-regs", class_maintenance,
+ &show_debug_regs, _("\
+Set whether to show the LoongArch debug registers state."), _("\
+Show whether to show the LoongArch debug registers state."), _("\
+Use \"on\" to enable, \"off\" to disable.\n\
+If enabled, the debug registers values are shown when GDB inserts\n\
+or removes a hardware breakpoint or watchpoint, and when the inferior\n\
+triggers a breakpoint or watchpoint."),
+ NULL,
+ NULL,
+ &maintenance_set_cmdlist,
+ &maintenance_show_cmdlist);
}
diff --git a/gdb/loongarch-tdep.c b/gdb/loongarch-tdep.c
index 757f4ac..c50dd7f 100644
--- a/gdb/loongarch-tdep.c
+++ b/gdb/loongarch-tdep.c
@@ -36,14 +36,14 @@ static insn_t
loongarch_fetch_instruction (CORE_ADDR pc)
{
size_t insn_len = loongarch_insn_length (0);
- gdb_byte buf[insn_len];
+ gdb::byte_vector buf (insn_len);
int err;
- err = target_read_memory (pc, buf, insn_len);
+ err = target_read_memory (pc, buf.data (), insn_len);
if (err)
memory_error (TARGET_XFER_E_IO, pc);
- return extract_unsigned_integer (buf, insn_len, BFD_ENDIAN_LITTLE);
+ return extract_unsigned_integer (buf.data (), insn_len, BFD_ENDIAN_LITTLE);
}
/* Return TRUE if INSN is a unconditional branch instruction, otherwise return FALSE. */
@@ -1306,18 +1306,24 @@ loongarch_return_value (struct gdbarch *gdbarch, struct value *function,
and the signed integer scalars are sign-extended. */
if (writebuf)
{
- gdb_byte buf[regsize];
+ gdb::byte_vector buf (regsize);
if (type->is_unsigned ())
{
- ULONGEST data = extract_unsigned_integer (writebuf, len, BFD_ENDIAN_LITTLE);
- store_unsigned_integer (buf, regsize, BFD_ENDIAN_LITTLE, data);
+ ULONGEST data = extract_unsigned_integer (writebuf, len,
+ BFD_ENDIAN_LITTLE);
+ store_unsigned_integer (buf.data (), regsize,
+ BFD_ENDIAN_LITTLE, data);
}
else
{
- LONGEST data = extract_signed_integer (writebuf, len, BFD_ENDIAN_LITTLE);
- store_signed_integer (buf, regsize, BFD_ENDIAN_LITTLE, data);
+ LONGEST data
+ = extract_signed_integer (writebuf, len, BFD_ENDIAN_LITTLE);
+ store_signed_integer (buf.data (), regsize, BFD_ENDIAN_LITTLE,
+ data);
}
- loongarch_xfer_reg (regcache, a0, regsize, nullptr, buf, 0);
+
+ loongarch_xfer_reg (regcache, a0, regsize, nullptr, buf.data (),
+ 0);
}
else
loongarch_xfer_reg (regcache, a0, len, readbuf, nullptr, 0);
diff --git a/gdb/macrocmd.c b/gdb/macrocmd.c
index 6cf3a0d..2da5a5b 100644
--- a/gdb/macrocmd.c
+++ b/gdb/macrocmd.c
@@ -271,18 +271,17 @@ skip_ws (const char **expp)
}
/* Try to find the bounds of an identifier. If an identifier is
- found, returns a newly allocated string; otherwise returns NULL.
+ found, return it; otherwise return an empty string.
+
EXPP is a pointer to an input string; it is updated to point to the
text following the identifier. If IS_PARAMETER is true, this
function will also allow "..." forms as used in varargs macro
parameters. */
-static gdb::unique_xmalloc_ptr<char>
+static std::string
extract_identifier (const char **expp, int is_parameter)
{
- char *result;
const char *p = *expp;
- unsigned int len;
if (is_parameter && startswith (p, "..."))
{
@@ -291,67 +290,39 @@ extract_identifier (const char **expp, int is_parameter)
else
{
if (! *p || ! macro_is_identifier_nondigit (*p))
- return NULL;
+ return {};
+
for (++p;
*p && (macro_is_identifier_nondigit (*p) || macro_is_digit (*p));
++p)
;
}
- if (is_parameter && startswith (p, "..."))
+ if (is_parameter && startswith (p, "..."))
p += 3;
- len = p - *expp;
- result = (char *) xmalloc (len + 1);
- memcpy (result, *expp, len);
- result[len] = '\0';
- *expp += len;
- return gdb::unique_xmalloc_ptr<char> (result);
-}
+ std::string result (*expp, p);
+ *expp = p;
-struct temporary_macro_definition : public macro_definition
-{
- temporary_macro_definition ()
- {
- table = nullptr;
- kind = macro_object_like;
- argc = 0;
- argv = nullptr;
- replacement = nullptr;
- }
-
- ~temporary_macro_definition ()
- {
- int i;
-
- for (i = 0; i < argc; ++i)
- xfree ((char *) argv[i]);
- xfree ((char *) argv);
- /* Note that the 'replacement' field is not allocated. */
- }
-};
+ return result;
+}
static void
macro_define_command (const char *exp, int from_tty)
{
- temporary_macro_definition new_macro;
-
if (!exp)
error (_("usage: macro define NAME[(ARGUMENT-LIST)] [REPLACEMENT-LIST]"));
skip_ws (&exp);
- gdb::unique_xmalloc_ptr<char> name = extract_identifier (&exp, 0);
- if (name == NULL)
+
+ std::string name = extract_identifier (&exp, 0);
+ if (name.empty ())
error (_("Invalid macro name."));
+
if (*exp == '(')
{
/* Function-like macro. */
- int alloced = 5;
- char **argv = XNEWVEC (char *, alloced);
-
- new_macro.kind = macro_function_like;
- new_macro.argc = 0;
- new_macro.argv = (const char * const *) argv;
+ std::vector<std::string> argv;
/* Skip the '(' and whitespace. */
++exp;
@@ -359,23 +330,13 @@ macro_define_command (const char *exp, int from_tty)
while (*exp != ')')
{
- int i;
-
- if (new_macro.argc == alloced)
- {
- alloced *= 2;
- argv = (char **) xrealloc (argv, alloced * sizeof (char *));
- /* Must update new_macro as well... */
- new_macro.argv = (const char * const *) argv;
- }
- argv[new_macro.argc] = extract_identifier (&exp, 1).release ();
- if (! argv[new_macro.argc])
+ argv.emplace_back (extract_identifier (&exp, 1));
+ if (argv.back ().empty ())
error (_("Macro is missing an argument."));
- ++new_macro.argc;
- for (i = new_macro.argc - 2; i >= 0; --i)
+ for (const auto &other_arg : argv)
{
- if (! strcmp (argv[i], argv[new_macro.argc - 1]))
+ if (&other_arg != &argv.back () && other_arg == argv.back ())
error (_("Two macro arguments with identical names."));
}
@@ -388,18 +349,18 @@ macro_define_command (const char *exp, int from_tty)
else if (*exp != ')')
error (_("',' or ')' expected at end of macro arguments."));
}
+
/* Skip the closing paren. */
++exp;
skip_ws (&exp);
- macro_define_function (macro_main (macro_user_macros), -1, name.get (),
- new_macro.argc, (const char **) new_macro.argv,
- exp);
+ macro_define_function (macro_main (macro_user_macros), -1, name.c_str (),
+ argv, exp);
}
else
{
skip_ws (&exp);
- macro_define_object (macro_main (macro_user_macros), -1, name.get (),
+ macro_define_object (macro_main (macro_user_macros), -1, name.c_str (),
exp);
}
}
@@ -412,10 +373,12 @@ macro_undef_command (const char *exp, int from_tty)
error (_("usage: macro undef NAME"));
skip_ws (&exp);
- gdb::unique_xmalloc_ptr<char> name = extract_identifier (&exp, 0);
- if (name == nullptr)
+
+ std::string name = extract_identifier (&exp, 0);
+ if (name.empty ())
error (_("Invalid macro name."));
- macro_undef (macro_main (macro_user_macros), -1, name.get ());
+
+ macro_undef (macro_main (macro_user_macros), -1, name.c_str ());
}
diff --git a/gdb/macroscope.c b/gdb/macroscope.c
index 4c1304f..c1b2238 100644
--- a/gdb/macroscope.c
+++ b/gdb/macroscope.c
@@ -121,9 +121,9 @@ default_macro_scope (void)
symbol files loaded, then get_current_or_default would raise an
error. But `set width' shouldn't raise an error just because
it can't decide which scope to macro-expand its argument in. */
- struct symtab_and_line cursal
- = get_current_source_symtab_and_line ();
-
+ symtab_and_line cursal
+ = get_current_source_symtab_and_line (current_program_space);
+
sal.symtab = cursal.symtab;
sal.line = cursal.line;
}
diff --git a/gdb/macrotab.c b/gdb/macrotab.c
index 3a7f792..37ae0f2 100644
--- a/gdb/macrotab.c
+++ b/gdb/macrotab.c
@@ -545,10 +545,10 @@ macro_lookup_inclusion (struct macro_source_file *source, const char *name)
/* Construct a definition for a macro in table T. Cache all strings,
and the macro_definition structure itself, in T's bcache. */
-static struct macro_definition *
-new_macro_definition (struct macro_table *t,
- enum macro_kind kind,
- int argc, const char **argv,
+static macro_definition *
+new_macro_definition (macro_table *t, macro_kind kind,
+ macro_special_kind special_kind,
+ const std::vector<std::string> &argv,
const char *replacement)
{
struct macro_definition *d
@@ -558,22 +558,26 @@ new_macro_definition (struct macro_table *t,
d->table = t;
d->kind = kind;
d->replacement = macro_bcache_str (t, replacement);
- d->argc = argc;
if (kind == macro_function_like)
{
- int i;
- const char **cached_argv;
- int cached_argv_size = argc * sizeof (*cached_argv);
+ d->argc = argv.size ();
/* Bcache all the arguments. */
- cached_argv = (const char **) alloca (cached_argv_size);
- for (i = 0; i < argc; i++)
- cached_argv[i] = macro_bcache_str (t, argv[i]);
+ if (d->argc > 0)
+ {
+ std::vector<const char *> cached_argv;
- /* Now bcache the array of argument pointers itself. */
- d->argv = macro_bcache (t, cached_argv, cached_argv_size);
+ for (const auto &arg : argv)
+ cached_argv.push_back (macro_bcache_str (t, arg.c_str ()));
+
+ /* Now bcache the array of argument pointers itself. */
+ d->argv = macro_bcache (t, cached_argv.data (),
+ cached_argv.size () * sizeof (const char *));
+ }
}
+ else
+ d->argc = special_kind;
/* We don't bcache the entire definition structure because it's got
a pointer to the macro table in it; since each compilation unit
@@ -677,13 +681,12 @@ find_definition (const char *name,
/* If NAME already has a definition in scope at LINE in SOURCE, return
the key. If the old definition is different from the definition
- given by KIND, ARGC, ARGV, and REPLACEMENT, complain, too.
- Otherwise, return zero. (ARGC and ARGV are meaningless unless KIND
+ given by KIND, ARGV, and REPLACEMENT, complain, too.
+ Otherwise, return nullptr. (ARGV is meaningless unless KIND
is `macro_function_like'.) */
-static struct macro_key *
-check_for_redefinition (struct macro_source_file *source, int line,
- const char *name, enum macro_kind kind,
- int argc, const char **argv,
+static macro_key *
+check_for_redefinition (macro_source_file *source, int line, const char *name,
+ macro_kind kind, const std::vector<std::string> &argv,
const char *replacement)
{
splay_tree_node n = find_definition (name, source, line);
@@ -708,14 +711,14 @@ check_for_redefinition (struct macro_source_file *source, int line,
same = 0;
else if (kind == macro_function_like)
{
- if (argc != found_def->argc)
+ if (argv.size () != found_def->argc)
same = 0;
else
{
- int i;
+ int i = 0;
- for (i = 0; i < argc; i++)
- if (strcmp (argv[i], found_def->argv[i]))
+ for (const auto &arg : argv)
+ if (arg != found_def->argv[i++])
same = 0;
}
}
@@ -739,15 +742,18 @@ check_for_redefinition (struct macro_source_file *source, int line,
}
/* A helper function to define a new object-like or function-like macro
- according to KIND. When KIND is macro_object_like,
- the macro_special_kind must be provided as ARGC, and ARGV must be NULL.
- When KIND is macro_function_like, ARGC and ARGV are giving the function
- arguments. */
+ according to KIND.
+
+ When KIND is macro_object_like, the possible special kind is given by
+ SPECIAL_KIND, and ARGV is meaningless.
+
+ When KIND is macro_function_like, ARGV gives the macro argument names, and
+ SPECIAL_KIND is meaningless. */
static void
-macro_define_internal (struct macro_source_file *source, int line,
- const char *name, enum macro_kind kind,
- int argc, const char **argv,
+macro_define_internal (macro_source_file *source, int line, const char *name,
+ macro_kind kind, macro_special_kind special_kind,
+ const std::vector<std::string> &argv,
const char *replacement)
{
struct macro_table *t = source->table;
@@ -755,10 +761,7 @@ macro_define_internal (struct macro_source_file *source, int line,
struct macro_definition *d;
if (! t->redef_ok)
- k = check_for_redefinition (source, line,
- name, kind,
- argc, argv,
- replacement);
+ k = check_for_redefinition (source, line, name, kind, argv, replacement);
/* If we're redefining a symbol, and the existing key would be
identical to our new key, then the splay_tree_insert function
@@ -774,7 +777,7 @@ macro_define_internal (struct macro_source_file *source, int line,
return;
k = new_macro_key (t, name, source, line);
- d = new_macro_definition (t, kind, argc, argv, replacement);
+ d = new_macro_definition (t, kind, special_kind, argv, replacement);
splay_tree_insert (t->definitions, (splay_tree_key) k, (splay_tree_value) d);
}
@@ -785,10 +788,8 @@ macro_define_object_internal (struct macro_source_file *source, int line,
const char *name, const char *replacement,
enum macro_special_kind special_kind)
{
- macro_define_internal (source, line,
- name, macro_object_like,
- special_kind, NULL,
- replacement);
+ macro_define_internal (source, line, name, macro_object_like, special_kind,
+ {}, replacement);
}
void
@@ -811,14 +812,12 @@ macro_define_special (struct macro_table *table)
}
void
-macro_define_function (struct macro_source_file *source, int line,
- const char *name, int argc, const char **argv,
+macro_define_function (macro_source_file *source, int line, const char *name,
+ const std::vector<std::string> &argv,
const char *replacement)
{
- macro_define_internal (source, line,
- name, macro_function_like,
- argc, argv,
- replacement);
+ macro_define_internal (source, line, name, macro_function_like,
+ macro_ordinary, argv, replacement);
}
void
diff --git a/gdb/macrotab.h b/gdb/macrotab.h
index 789beed..d501595 100644
--- a/gdb/macrotab.h
+++ b/gdb/macrotab.h
@@ -242,26 +242,23 @@ struct macro_source_file *macro_lookup_inclusion
Record in SOURCE's macro table that, at line number LINE in SOURCE,
we #defined a preprocessor symbol named NAME, whose replacement
string is REPLACEMENT. This function makes copies of NAME and
- REPLACEMENT; the caller is responsible for freeing them. */
+ REPLACEMENT. */
void macro_define_object (struct macro_source_file *source, int line,
const char *name, const char *replacement);
-/* Record an function-like #definition (i.e., one with a parameter list).
+/* Record a function-like #definition (i.e., one with a parameter list).
Record in SOURCE's macro table that, at line number LINE in SOURCE,
- we #defined a preprocessor symbol named NAME, with ARGC arguments
- whose names are given in ARGV, whose replacement string is REPLACEMENT. If
- the macro takes a variable number of arguments, then ARGC should be
- one greater than the number of named arguments, and ARGV[ARGC-1]
- should be the string "...". This function makes its own copies of
- NAME, ARGV, and REPLACEMENT; the caller is responsible for freeing
- them. */
-void macro_define_function (struct macro_source_file *source, int line,
- const char *name, int argc, const char **argv,
+ we #defined a preprocessor symbol named NAME, with argument names given by
+ ARGV, whose replacement string is REPLACEMENT. If the macro takes a variable
+ number of arguments, then the last element of ARGV should be the string
+ "...". This function makes copies of NAME, ARGV, and REPLACEMENT. */
+void macro_define_function (macro_source_file *source, int line,
+ const char *name,
+ const std::vector<std::string> &argv,
const char *replacement);
-
/* Record an #undefinition.
Record in SOURCE's macro table that, at line number LINE in SOURCE,
we removed the definition for the preprocessor symbol named NAME. */
diff --git a/gdb/mi/mi-cmd-file.c b/gdb/mi/mi-cmd-file.c
index 3e2702e..f2fe435 100644
--- a/gdb/mi/mi-cmd-file.c
+++ b/gdb/mi/mi-cmd-file.c
@@ -35,7 +35,6 @@ void
mi_cmd_file_list_exec_source_file (const char *command,
const char *const *argv, int argc)
{
- struct symtab_and_line st;
struct ui_out *uiout = current_uiout;
if (!mi_valid_noargs ("-file-list-exec-source-file", argc, argv))
@@ -43,7 +42,8 @@ mi_cmd_file_list_exec_source_file (const char *command,
/* Set the default file and line, also get them. */
set_default_source_symtab_and_line ();
- st = get_current_source_symtab_and_line ();
+ symtab_and_line st
+ = get_current_source_symtab_and_line (current_program_space);
/* We should always get a symtab. Apparently, filename does not
need to be tested for NULL. The documentation in symtab.h
diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c
index 7bd96a8..fecefd7 100644
--- a/gdb/mips-linux-tdep.c
+++ b/gdb/mips-linux-tdep.c
@@ -99,16 +99,17 @@ mips_linux_get_longjmp_target (const frame_info_ptr &frame, CORE_ADDR *pc)
CORE_ADDR jb_addr;
struct gdbarch *gdbarch = get_frame_arch (frame);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- gdb_byte buf[gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT];
+ gdb::byte_vector buf (gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT);
jb_addr = get_frame_register_unsigned (frame, MIPS_A0_REGNUM);
if (target_read_memory ((jb_addr
+ MIPS_LINUX_JB_PC * MIPS_LINUX_JB_ELEMENT_SIZE),
- buf, gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT))
+ buf.data (),
+ gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT))
return 0;
- *pc = extract_unsigned_integer (buf,
+ *pc = extract_unsigned_integer (buf.data (),
gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT,
byte_order);
diff --git a/gdb/nat/aarch64-mte-linux-ptrace.c b/gdb/nat/aarch64-mte-linux-ptrace.c
index ace3e18..f215588 100644
--- a/gdb/nat/aarch64-mte-linux-ptrace.c
+++ b/gdb/nat/aarch64-mte-linux-ptrace.c
@@ -22,6 +22,7 @@
#include "linux-ptrace.h"
#include "arch/aarch64.h"
+#include "arch/aarch64-mte.h"
#include "arch/aarch64-mte-linux.h"
#include "nat/aarch64-linux.h"
#include "nat/aarch64-mte-linux-ptrace.h"
@@ -31,7 +32,7 @@
/* Helper function to display various possible errors when reading
MTE tags. */
-static void ATTRIBUTE_NORETURN
+[[noreturn]] static void
aarch64_mte_linux_peek_error (int error)
{
switch (error)
@@ -53,7 +54,7 @@ aarch64_mte_linux_peek_error (int error)
/* Helper function to display various possible errors when writing
MTE tags. */
-static void ATTRIBUTE_NORETURN
+[[noreturn]] static void
aarch64_mte_linux_poke_error (int error)
{
switch (error)
@@ -118,10 +119,10 @@ aarch64_mte_fetch_memtags (int tid, CORE_ADDR address, size_t len,
if (ntags == 0)
return true;
- gdb_byte tagbuf[ntags];
+ gdb::byte_vector tagbuf (ntags);
struct iovec iovec;
- iovec.iov_base = tagbuf;
+ iovec.iov_base = tagbuf.data ();
iovec.iov_len = ntags;
tags.clear ();
diff --git a/gdb/nat/aarch64-scalable-linux-ptrace.c b/gdb/nat/aarch64-scalable-linux-ptrace.c
index 81bb8ea..0f1bedf 100644
--- a/gdb/nat/aarch64-scalable-linux-ptrace.c
+++ b/gdb/nat/aarch64-scalable-linux-ptrace.c
@@ -920,8 +920,7 @@ aarch64_za_regs_copy_to_reg_buf (int tid, struct reg_buffer_common *reg_buf,
else
{
size_t za_bytes = header->vl * header->vl;
- gdb_byte za_zeroed[za_bytes];
- memset (za_zeroed, 0, za_bytes);
+ gdb::byte_vector za_zeroed (za_bytes, 0);
reg_buf->raw_supply (za_regnum, za_zeroed);
}
@@ -994,8 +993,7 @@ aarch64_za_regs_copy_from_reg_buf (int tid,
bool has_za_state = aarch64_has_za_state (tid);
size_t za_bytes = sve_vl_from_vg (old_svg) * sve_vl_from_vg (old_svg);
- gdb_byte za_zeroed[za_bytes];
- memset (za_zeroed, 0, za_bytes);
+ gdb::byte_vector za_zeroed (za_bytes, 0);
/* If the streaming vector length changed, zero out the contents of ZA in
the register cache. Otherwise, we will need to update the ZA contents
@@ -1007,8 +1005,7 @@ aarch64_za_regs_copy_from_reg_buf (int tid,
/* When we update svg, we don't automatically initialize the ZA buffer. If
we have no ZA state and the ZA register contents in the register cache are
zero, just return and leave the ZA register cache contents as zero. */
- if (!has_za_state
- && reg_buf->raw_compare (za_regnum, za_zeroed, 0))
+ if (!has_za_state && reg_buf->raw_compare (za_regnum, za_zeroed.data (), 0))
{
/* No ZA state in the thread or in the register cache. This was likely
just an adjustment of the streaming vector length. Let this fall
@@ -1020,7 +1017,7 @@ aarch64_za_regs_copy_from_reg_buf (int tid,
need to initialize the ZA data through ptrace. First we initialize
all the bytes of ZA to zero. */
if (!has_za_state
- && !reg_buf->raw_compare (za_regnum, za_zeroed, 0))
+ && !reg_buf->raw_compare (za_regnum, za_zeroed.data (), 0))
aarch64_initialize_za_regset (tid);
/* From this point onwards, it is assumed we have a ZA payload in
diff --git a/gdb/nat/fork-inferior.h b/gdb/nat/fork-inferior.h
index f3e2f54..0fd4218 100644
--- a/gdb/nat/fork-inferior.h
+++ b/gdb/nat/fork-inferior.h
@@ -84,13 +84,12 @@ extern void gdb_flush_out_err ();
/* Report an error that happened when starting to trace the inferior
(i.e., when the "traceme_fun" callback is called on fork_inferior)
and bail out. This function does not return. */
-extern void trace_start_error (const char *fmt, ...)
- ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
+[[noreturn]] extern void trace_start_error (const char *fmt, ...)
+ ATTRIBUTE_PRINTF (1, 2);
/* Like "trace_start_error", but the error message is constructed by
combining STRING with the system error message for errno. This
function does not return. */
-extern void trace_start_error_with_name (const char *string)
- ATTRIBUTE_NORETURN;
+[[noreturn]] extern void trace_start_error_with_name (const char *string);
#endif /* NAT_FORK_INFERIOR_H */
diff --git a/gdb/nat/linux-namespaces.c b/gdb/nat/linux-namespaces.c
index 36a245c..9abd3d6 100644
--- a/gdb/nat/linux-namespaces.c
+++ b/gdb/nat/linux-namespaces.c
@@ -548,7 +548,7 @@ mnsh_handle_readlink (int sock, const char *filename)
/* The helper process. Never returns. Must be async-signal-safe. */
-static void mnsh_main (int sock) ATTRIBUTE_NORETURN;
+[[noreturn]] static void mnsh_main (int sock);
static void
mnsh_main (int sock)
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 368e129..0e076fe 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -306,9 +306,10 @@ build_objfile_section_table (struct objfile *objfile)
requests for specific operations. Other bits like OBJF_SHARED are
simply copied through to the new objfile flags member. */
-objfile::objfile (gdb_bfd_ref_ptr bfd_, const char *name, objfile_flags flags_)
+objfile::objfile (gdb_bfd_ref_ptr bfd_, program_space *pspace,
+ const char *name, objfile_flags flags_)
: flags (flags_),
- pspace (current_program_space),
+ m_pspace (pspace),
obfd (std::move (bfd_))
{
const char *expanded_name;
@@ -345,13 +346,12 @@ objfile::objfile (gdb_bfd_ref_ptr bfd_, const char *name, objfile_flags flags_)
set_objfile_per_bfd (this);
}
-/* If there is a valid and known entry point, function fills *ENTRY_P with it
- and returns non-zero; otherwise it returns zero. */
+/* See objfiles.h. */
int
-entry_point_address_query (CORE_ADDR *entry_p)
+entry_point_address_query (program_space *pspace, CORE_ADDR *entry_p)
{
- objfile *objf = current_program_space->symfile_object_file;
+ objfile *objf = pspace->symfile_object_file;
if (objf == NULL || !objf->per_bfd->ei.entry_point_p)
return 0;
@@ -361,14 +361,14 @@ entry_point_address_query (CORE_ADDR *entry_p)
return 1;
}
-/* Get current entry point address. Call error if it is not known. */
+/* See objfiles.h. */
CORE_ADDR
-entry_point_address (void)
+entry_point_address (program_space *pspace)
{
CORE_ADDR retval;
- if (!entry_point_address_query (&retval))
+ if (!entry_point_address_query (pspace, &retval))
error (_("Entry point address is not known."));
return retval;
@@ -442,10 +442,11 @@ add_separate_debug_objfile (struct objfile *objfile, struct objfile *parent)
/* See objfiles.h. */
objfile *
-objfile::make (gdb_bfd_ref_ptr bfd_, const char *name_, objfile_flags flags_,
- objfile *parent)
+objfile::make (gdb_bfd_ref_ptr bfd_, program_space *pspace, const char *name_,
+ objfile_flags flags_, objfile *parent)
{
- objfile *result = new objfile (std::move (bfd_), name_, flags_);
+ objfile *result
+ = new objfile (std::move (bfd_), current_program_space, name_, flags_);
if (parent != nullptr)
add_separate_debug_objfile (result, parent);
@@ -463,7 +464,7 @@ objfile::make (gdb_bfd_ref_ptr bfd_, const char *name_, objfile_flags flags_,
void
objfile::unlink ()
{
- current_program_space->remove_objfile (this);
+ this->pspace ()->remove_objfile (this);
}
/* Free all separate debug objfile of OBJFILE, but don't free OBJFILE
@@ -561,14 +562,15 @@ objfile::~objfile ()
and if so, call clear_current_source_symtab_and_line. */
{
- struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+ symtab_and_line cursal
+ = get_current_source_symtab_and_line (this->pspace ());
if (cursal.symtab && cursal.symtab->compunit ()->objfile () == this)
- clear_current_source_symtab_and_line ();
+ clear_current_source_symtab_and_line (this->pspace ());
}
/* Rebuild section map next time we need it. */
- get_objfile_pspace_data (pspace)->section_map_dirty = 1;
+ get_objfile_pspace_data (m_pspace)->section_map_dirty = 1;
}
@@ -646,7 +648,7 @@ objfile_relocate1 (struct objfile *objfile,
objfile->section_offsets[i] = new_offsets[i];
/* Rebuild section map next time we need it. */
- get_objfile_pspace_data (objfile->pspace)->section_map_dirty = 1;
+ get_objfile_pspace_data (objfile->pspace ())->section_map_dirty = 1;
/* Update the table in exec_ops, used to read memory. */
for (obj_section *s : objfile->sections ())
@@ -731,67 +733,58 @@ objfile_rebase (struct objfile *objfile, CORE_ADDR slide)
if (changed)
breakpoint_re_set ();
}
-
-/* Return non-zero if OBJFILE has full symbols. */
-int
-objfile_has_full_symbols (struct objfile *objfile)
+/* See objfiles.h. */
+
+bool
+objfile_has_full_symbols (objfile *objfile)
{
- return objfile->compunit_symtabs != NULL;
+ return objfile->compunit_symtabs != nullptr;
}
-/* Return non-zero if OBJFILE has full or partial symbols, either directly
- or through a separate debug file. */
+/* See objfiles.h. */
-int
-objfile_has_symbols (struct objfile *objfile)
+bool
+objfile_has_symbols (objfile *objfile)
{
for (::objfile *o : objfile->separate_debug_objfiles ())
if (o->has_partial_symbols () || objfile_has_full_symbols (o))
- return 1;
- return 0;
-}
+ return true;
+ return false;
+}
-/* Many places in gdb want to test just to see if we have any partial
- symbols available. This function returns zero if none are currently
- available, nonzero otherwise. */
+/* See objfiles.h. */
-int
-have_partial_symbols (void)
+bool
+have_partial_symbols (program_space *pspace)
{
- for (objfile *ofp : current_program_space->objfiles ())
- {
- if (ofp->has_partial_symbols ())
- return 1;
- }
- return 0;
+ for (objfile *ofp : pspace->objfiles ())
+ if (ofp->has_partial_symbols ())
+ return true;
+
+ return false;
}
-/* Many places in gdb want to test just to see if we have any full
- symbols available. This function returns zero if none are currently
- available, nonzero otherwise. */
+/* See objfiles.h. */
-int
-have_full_symbols (void)
+bool
+have_full_symbols (program_space *pspace)
{
- for (objfile *ofp : current_program_space->objfiles ())
- {
- if (objfile_has_full_symbols (ofp))
- return 1;
- }
- return 0;
+ for (objfile *ofp : pspace->objfiles ())
+ if (objfile_has_full_symbols (ofp))
+ return true;
+
+ return false;
}
-/* This operations deletes all objfile entries that represent solibs that
- weren't explicitly loaded by the user, via e.g., the add-symbol-file
- command. */
+/* See objfiles.h. */
void
-objfile_purge_solibs (void)
+objfile_purge_solibs (program_space *pspace)
{
- for (objfile *objf : current_program_space->objfiles_safe ())
+ for (objfile *objf : pspace->objfiles_safe ())
{
/* We assume that the solib package has been purged already, or will
be soon. */
@@ -801,22 +794,16 @@ objfile_purge_solibs (void)
}
}
+/* See objfiles.h. */
-/* Many places in gdb want to test just to see if we have any minimal
- symbols available. This function returns zero if none are currently
- available, nonzero otherwise. */
-
-int
-have_minimal_symbols (void)
+bool
+have_minimal_symbols (program_space *pspace)
{
- for (objfile *ofp : current_program_space->objfiles ())
- {
- if (ofp->per_bfd->minimal_symbol_count > 0)
- {
- return 1;
- }
- }
- return 0;
+ for (objfile *ofp : pspace->objfiles ())
+ if (ofp->per_bfd->minimal_symbol_count > 0)
+ return true;
+
+ return false;
}
/* Qsort comparison function. */
@@ -1177,16 +1164,14 @@ pc_in_section (CORE_ADDR pc, const char *name)
&& s->the_bfd_section->name != nullptr
&& strcmp (s->the_bfd_section->name, name) == 0);
}
-
-/* Set section_map_dirty so section map will be rebuilt next time it
- is used. Called by reread_symbols. */
+/* See objfiles.h. */
void
-objfiles_changed (void)
+objfiles_changed (program_space *pspace)
{
/* Rebuild section map next time we need it. */
- get_objfile_pspace_data (current_program_space)->section_map_dirty = 1;
+ get_objfile_pspace_data (pspace)->section_map_dirty = 1;
}
/* See comments in objfiles.h. */
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 88dfb33..50bd6f8 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -423,7 +423,8 @@ struct objfile
private:
/* The only way to create an objfile is to call objfile::make. */
- objfile (gdb_bfd_ref_ptr, const char *, objfile_flags);
+ objfile (gdb_bfd_ref_ptr, program_space *pspace, const char *,
+ objfile_flags);
public:
@@ -436,15 +437,19 @@ public:
~objfile ();
/* Create an objfile. */
- static objfile *make (gdb_bfd_ref_ptr bfd_, const char *name_,
- objfile_flags flags_, objfile *parent = nullptr);
+ static objfile *make (gdb_bfd_ref_ptr bfd_, program_space *pspace,
+ const char *name_, objfile_flags flags_,
+ objfile *parent = nullptr);
- /* Remove an objfile from the current program space, and free
+ /* Remove this objfile from its program space's objfile list, and frees
it. */
void unlink ();
DISABLE_COPY_AND_ASSIGN (objfile);
+ /* Return the program space associated with this objfile. */
+ program_space *pspace () { return m_pspace; }
+
/* A range adapter that makes it possible to iterate over all
compunits in one objfile. */
@@ -716,10 +721,12 @@ public:
objfile_flags flags;
+private:
/* The program space associated with this objfile. */
- struct program_space *pspace;
+ program_space *m_pspace;
+public:
/* List of compunits.
These are used to do symbol lookups and file/line-number lookups. */
@@ -907,9 +914,15 @@ obj_section::set_offset (CORE_ADDR offset)
/* Declarations for functions defined in objfiles.c */
-extern int entry_point_address_query (CORE_ADDR *entry_p);
+/* If there is a valid and known entry point in PSPACE, fill *ENTRY_P with it
+ and return non-zero. */
-extern CORE_ADDR entry_point_address (void);
+extern int entry_point_address_query (program_space *pspace,
+ CORE_ADDR *entry_p);
+
+/* Get the entry point address in PSPACE. Call error if it is not known. */
+
+extern CORE_ADDR entry_point_address (program_space *pspace);
extern void build_objfile_section_table (struct objfile *);
@@ -918,18 +931,30 @@ extern void free_objfile_separate_debug (struct objfile *);
extern void objfile_relocate (struct objfile *, const section_offsets &);
extern void objfile_rebase (struct objfile *, CORE_ADDR);
-extern int objfile_has_full_symbols (struct objfile *objfile);
+/* Return true if OBJFILE has full symbols. */
+
+extern bool objfile_has_full_symbols (objfile *objfile);
-extern int objfile_has_symbols (struct objfile *objfile);
+/* Return true if OBJFILE has full or partial symbols, either directly
+ or through a separate debug file. */
-extern int have_partial_symbols (void);
+extern bool objfile_has_symbols (objfile *objfile);
-extern int have_full_symbols (void);
+/* Return true if any objfile of PSPACE has partial symbols. */
+
+extern bool have_partial_symbols (program_space *pspace);
+
+/* Return true if any objfile of PSPACE has full symbols. */
+
+extern bool have_full_symbols (program_space *pspace);
extern void objfile_set_sym_fns (struct objfile *objfile,
const struct sym_fns *sf);
-extern void objfiles_changed (void);
+/* Set section_map_dirty for PSPACE so the section map will be rebuilt next time
+ it is used. */
+
+extern void objfiles_changed (program_space *pspace);
/* Return true if ADDR maps into one of the sections of OBJFILE and false
otherwise. */
@@ -942,16 +967,18 @@ extern bool is_addr_in_objfile (CORE_ADDR addr, const struct objfile *objfile);
extern bool shared_objfile_contains_address_p (struct program_space *pspace,
CORE_ADDR address);
-/* This operation deletes all objfile entries that represent solibs that
- weren't explicitly loaded by the user, via e.g., the add-symbol-file
+/* This operation deletes all objfile entries in PSPACE that represent solibs
+ that weren't explicitly loaded by the user, via e.g., the add-symbol-file
command. */
-extern void objfile_purge_solibs (void);
+extern void objfile_purge_solibs (program_space *pspace);
/* Functions for dealing with the minimal symbol table, really a misc
address<->symbol mapping for things we don't have debug symbols for. */
-extern int have_minimal_symbols (void);
+/* Return true if any objfile of PSPACE has minimal symbols. */
+
+extern bool have_minimal_symbols (program_space *pspace);
extern struct obj_section *find_pc_section (CORE_ADDR pc);
diff --git a/gdb/p-exp.y b/gdb/p-exp.y
index f334db6..0a0fa95 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp.y
@@ -725,8 +725,8 @@ variable: name_not_typename
if (msymbol.minsym != NULL)
pstate->push_new<var_msym_value_operation>
(msymbol);
- else if (!have_full_symbols ()
- && !have_partial_symbols ())
+ else if (!have_full_symbols (current_program_space)
+ && !have_partial_symbols (current_program_space))
error (_("No symbol table is loaded. "
"Use the \"file\" command."));
else
diff --git a/gdb/parse.c b/gdb/parse.c
index 0a2b2a5..2541a2e 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -148,7 +148,8 @@ parser_state::push_symbol (const char *name, block_symbol sym)
struct bound_minimal_symbol msymbol = lookup_bound_minimal_symbol (name);
if (msymbol.minsym != NULL)
push_new<expr::var_msym_value_operation> (msymbol);
- else if (!have_full_symbols () && !have_partial_symbols ())
+ else if (!have_full_symbols (current_program_space)
+ && !have_partial_symbols (current_program_space))
error (_("No symbol table is loaded. Use the \"file\" command."));
else
error (_("No symbol \"%s\" in current context."), name);
@@ -374,8 +375,8 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc,
if (!expression_context_block)
{
- struct symtab_and_line cursal
- = get_current_source_symtab_and_line ();
+ symtab_and_line cursal
+ = get_current_source_symtab_and_line (current_program_space);
if (cursal.symtab)
expression_context_block
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 1d6a492..e37e30e 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -2294,11 +2294,11 @@ disable_display_command (const char *args, int from_tty)
static void
clear_dangling_display_expressions (struct objfile *objfile)
{
- program_space *pspace = objfile->pspace;
+ program_space *pspace = objfile->pspace ();
if (objfile->separate_debug_objfile_backlink)
{
objfile = objfile->separate_debug_objfile_backlink;
- gdb_assert (objfile->pspace == pspace);
+ gdb_assert (objfile->pspace () == pspace);
}
for (auto &d : all_displays)
diff --git a/gdb/progspace.c b/gdb/progspace.c
index d5b5ef2..28198c1 100644
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -115,7 +115,7 @@ program_space::~program_space ()
set_current_program_space (this);
breakpoint_program_space_exit (this);
- no_shared_libraries (NULL, 0);
+ no_shared_libraries (this);
free_all_objfiles ();
/* Defer breakpoint re-set because we don't want to create new
locations for this pspace which we're tearing down. */
@@ -128,7 +128,7 @@ void
program_space::free_all_objfiles ()
{
/* Any objfile reference would become stale. */
- for (const solib &so : current_program_space->solibs ())
+ for (const solib &so : this->solibs ())
gdb_assert (so.objfile == NULL);
while (!objfiles_list.empty ())
diff --git a/gdb/python/lib/gdb/dap/scopes.py b/gdb/python/lib/gdb/dap/scopes.py
index d0e9115..fb90f64 100644
--- a/gdb/python/lib/gdb/dap/scopes.py
+++ b/gdb/python/lib/gdb/dap/scopes.py
@@ -111,20 +111,19 @@ class _ScopeReference(BaseReference):
return symbol_value(self.var_list[idx], self.frame)
-# A _ScopeReference that prepends the most recent return value. Note
-# that this object is only created if such a value actually exists.
+# A _ScopeReference that wraps the 'finish' value. Note that this
+# object is only created if such a value actually exists.
class _FinishScopeReference(_ScopeReference):
- def __init__(self, *args):
- super().__init__(*args)
+ def __init__(self, frame):
+ super().__init__("Return", "returnValue", frame, ())
def child_count(self):
- return super().child_count() + 1
+ return 1
def fetch_one_child(self, idx):
- if idx == 0:
- global _last_return_value
- return ("(return)", _last_return_value)
- return super().fetch_one_child(idx - 1)
+ assert idx == 0
+ global _last_return_value
+ return ("(return)", _last_return_value)
class _RegisterReference(_ScopeReference):
@@ -159,11 +158,11 @@ def scopes(*, frameId: int, **extra):
# Make sure to handle the None case as well as the empty
# iterator case.
locs = tuple(frame.frame_locals() or ())
- if has_return_value:
- scopes.append(_FinishScopeReference("Locals", "locals", frame, locs))
- elif locs:
+ if locs:
scopes.append(_ScopeReference("Locals", "locals", frame, locs))
scopes.append(_RegisterReference("Registers", frame))
+ if has_return_value:
+ scopes.append(_FinishScopeReference(frame))
frame_to_scope[frameId] = scopes
global_scope = get_global_scope(frame)
if global_scope is not None:
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index 60a1483..6e8d5b5 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -183,7 +183,7 @@ objfpy_get_progspace (PyObject *self, void *closure)
objfile_object *obj = (objfile_object *) self;
if (obj->objfile)
- return pspace_to_pspace_object (obj->objfile->pspace).release ();
+ return pspace_to_pspace_object (obj->objfile->pspace ()).release ();
Py_RETURN_NONE;
}
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index dada8bf..5c62ef6 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -1258,7 +1258,8 @@ valpy_call (PyObject *self, PyObject *args, PyObject *keywords)
if (ftype->code () == TYPE_CODE_INTERNAL_FUNCTION)
return_value = call_internal_function (gdbpy_enter::get_gdbarch (),
current_language,
- function, args_count, vargs);
+ function, args_count, vargs,
+ EVAL_NORMAL);
else
return_value
= call_function_by_hand (function, NULL,
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index f25cd3b..5db3088 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -948,7 +948,7 @@ private:
int gdbpy_print_python_errors_p (void);
void gdbpy_print_stack (void);
void gdbpy_print_stack_or_quit ();
-void gdbpy_handle_exception () ATTRIBUTE_NORETURN;
+[[noreturn]] void gdbpy_handle_exception ();
/* A wrapper around calling 'error'. Prefixes the error message with an
'Error occurred in Python' string. Use this in C++ code if we spot
@@ -958,8 +958,7 @@ void gdbpy_handle_exception () ATTRIBUTE_NORETURN;
This always calls error, and never returns. */
-void gdbpy_error (const char *fmt, ...)
- ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2);
+[[noreturn]] void gdbpy_error (const char *fmt, ...) ATTRIBUTE_PRINTF (1, 2);
gdbpy_ref<> python_string_to_unicode (PyObject *obj);
gdb::unique_xmalloc_ptr<char> unicode_to_target_string (PyObject *unicode_str);
diff --git a/gdb/python/python.c b/gdb/python/python.c
index e9092b4..d86a031 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -963,7 +963,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
else
{
set_default_source_symtab_and_line ();
- def_sal = get_current_source_symtab_and_line ();
+ def_sal = get_current_source_symtab_and_line (current_program_space);
sals = def_sal;
}
}
diff --git a/gdb/record-full.c b/gdb/record-full.c
index eb62d18..ab854e0 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -2073,6 +2073,7 @@ record_full_core_target::resume (ptid_t ptid, int step,
enum gdb_signal signal)
{
record_full_resume_step = step;
+ record_full_resume_ptid = ptid;
record_full_resumed = 1;
record_full_execution_dir = ::execution_direction;
}
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index f92de61..67d3f4c 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -69,8 +69,7 @@ static void gdb_os_vprintf_filtered (host_callback *, const char *, va_list);
static void gdb_os_evprintf_filtered (host_callback *, const char *, va_list);
-static void gdb_os_error (host_callback *, const char *, ...)
- ATTRIBUTE_NORETURN;
+[[noreturn]] static void gdb_os_error (host_callback *, const char *, ...);
/* Naming convention:
diff --git a/gdb/remote.c b/gdb/remote.c
index 90a4bd5..4948a54 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -248,6 +248,7 @@ enum {
PACKET_vFile_unlink,
PACKET_vFile_readlink,
PACKET_vFile_fstat,
+ PACKET_vFile_stat,
PACKET_qXfer_auxv,
PACKET_qXfer_features,
PACKET_qXfer_exec_file,
@@ -1010,6 +1011,9 @@ public:
int fileio_fstat (int fd, struct stat *sb, fileio_error *target_errno) override;
+ int fileio_stat (struct inferior *inf, const char *filename,
+ struct stat *sb, fileio_error *target_errno) override;
+
int fileio_close (int fd, fileio_error *target_errno) override;
int fileio_unlink (struct inferior *inf,
@@ -1539,7 +1543,7 @@ static void remote_console_output (const char *msg, ui_file *stream);
static void remote_btrace_reset (remote_state *rs);
-static void remote_unpush_and_throw (remote_target *target);
+[[noreturn]] static void remote_unpush_and_throw (remote_target *target);
/* For "remote". */
@@ -2528,9 +2532,6 @@ packet_check_result (const char *buf)
/* "Enn" - definitely an error. */
return packet_result::make_numeric_error (buf + 1);
- /* Not every request accepts an error in a E.msg form.
- Some packets accepts only Enn, in this case E. is not
- defined and E. is treated as PACKET_OK. */
/* Always treat "E." as an error. This will be used for
more verbose error messages, such as E.memtypes. */
if (buf[0] == 'E' && buf[1] == '.')
@@ -3377,17 +3378,6 @@ struct gdb_ext_thread_info
whatever. */
};
-/* The volume of remote transfers can be limited by submitting
- a mask containing bits specifying the desired information.
- Use a union of these values as the 'selection' parameter to
- get_thread_info. FIXME: Make these TAG names more thread specific. */
-
-#define TAG_THREADID 1
-#define TAG_EXISTS 2
-#define TAG_DISPLAY 4
-#define TAG_THREADNAME 8
-#define TAG_MOREDISPLAY 16
-
#define BUF_THREAD_ID_SIZE (OPAQUETHREADBYTES * 2)
static const char *unpack_nibble (const char *buf, int *val);
@@ -5950,7 +5940,7 @@ remote_target::remote_query_supported ()
if (m_features.packet_set_cmd_state (PACKET_accept_error_message)
!= AUTO_BOOLEAN_FALSE)
- remote_query_supported_append (&q, "error-message+");
+ remote_query_supported_append (&q, "error-message+");
q = "qSupported:" + q;
putpkt (q.c_str ());
@@ -6150,7 +6140,7 @@ remote_unpush_target (remote_target *target)
fileio_handles_invalidate_target (target);
}
-static void
+[[noreturn]] static void
remote_unpush_and_throw (remote_target *target)
{
remote_unpush_target (target);
@@ -6271,7 +6261,7 @@ remote_target::open_1 (const char *name, int from_tty, int extended_p)
}
/* First delete any symbols previously loaded from shared libraries. */
- no_shared_libraries (NULL, 0);
+ no_shared_libraries (current_program_space);
/* Start the remote connection. If error() or QUIT, discard this
target (we'd otherwise be in an inconsistent state) and then
@@ -13048,6 +13038,41 @@ remote_target::fileio_readlink (struct inferior *inf, const char *filename,
return ret;
}
+/* Helper function to handle ::fileio_fstat and ::fileio_stat result
+ processing. When this function is called the remote syscall has been
+ performed and we know we didn't get an error back.
+
+ ATTACHMENT and ATTACHMENT_LEN are the attachment data extracted from the
+ remote syscall reply. EXPECTED_LEN is the length returned from the
+ fstat or stat call, this the length of the returned data (in ATTACHMENT)
+ once it has been decoded. The fstat/stat result (from the ATTACHMENT
+ data) is to be placed in ST. */
+
+static int
+fileio_process_fstat_and_stat_reply (const char *attachment,
+ int attachment_len,
+ int expected_len,
+ struct stat *st)
+{
+ struct fio_stat fst;
+
+ int read_len
+ = remote_unescape_input ((gdb_byte *) attachment, attachment_len,
+ (gdb_byte *) &fst, sizeof (fst));
+
+ if (read_len != expected_len)
+ error (_("vFile:fstat returned %d, but %d bytes."),
+ expected_len, read_len);
+
+ if (read_len != sizeof (fst))
+ error (_("vFile:fstat returned %d bytes, but expecting %d."),
+ read_len, (int) sizeof (fst));
+
+ remote_fileio_to_host_stat (&fst, st);
+
+ return 0;
+}
+
/* Implementation of to_fileio_fstat. */
int
@@ -13058,8 +13083,6 @@ remote_target::fileio_fstat (int fd, struct stat *st, fileio_error *remote_errno
int left = get_remote_packet_size ();
int attachment_len, ret;
const char *attachment;
- struct fio_stat fst;
- int read_len;
remote_buffer_add_string (&p, &left, "vFile:fstat:");
@@ -13091,19 +13114,41 @@ remote_target::fileio_fstat (int fd, struct stat *st, fileio_error *remote_errno
return 0;
}
- read_len = remote_unescape_input ((gdb_byte *) attachment, attachment_len,
- (gdb_byte *) &fst, sizeof (fst));
+ return fileio_process_fstat_and_stat_reply (attachment, attachment_len,
+ ret, st);
+}
- if (read_len != ret)
- error (_("vFile:fstat returned %d, but %d bytes."), ret, read_len);
+/* Implementation of to_fileio_stat. */
- if (read_len != sizeof (fst))
- error (_("vFile:fstat returned %d bytes, but expecting %d."),
- read_len, (int) sizeof (fst));
+int
+remote_target::fileio_stat (struct inferior *inf, const char *filename,
+ struct stat *st, fileio_error *remote_errno)
+{
+ struct remote_state *rs = get_remote_state ();
+ char *p = rs->buf.data ();
+ int left = get_remote_packet_size () - 1;
- remote_fileio_to_host_stat (&fst, st);
+ if (remote_hostio_set_filesystem (inf, remote_errno) != 0)
+ return {};
- return 0;
+ remote_buffer_add_string (&p, &left, "vFile:stat:");
+
+ remote_buffer_add_bytes (&p, &left, (const gdb_byte *) filename,
+ strlen (filename));
+
+ int attachment_len;
+ const char *attachment;
+ int ret = remote_hostio_send_command (p - rs->buf.data (), PACKET_vFile_stat,
+ remote_errno, &attachment,
+ &attachment_len);
+
+ /* Unlike ::fileio_fstat, the stat fileio call was added later on, and
+ has none of the legacy bfd issues, so we can just return the error. */
+ if (ret < 0)
+ return ret;
+
+ return fileio_process_fstat_and_stat_reply (attachment, attachment_len,
+ ret, st);
}
/* Implementation of to_filesystem_is_local. */
@@ -15444,7 +15489,7 @@ remote_objfile_changed_check_symbols (program_space *pspace)
static void
remote_new_objfile (struct objfile *objfile)
{
- remote_objfile_changed_check_symbols (objfile->pspace);
+ remote_objfile_changed_check_symbols (objfile->pspace ());
}
/* Pull all the tracepoints defined on the target and create local
@@ -16178,6 +16223,8 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL,
add_packet_config_cmd (PACKET_vFile_fstat, "vFile:fstat", "hostio-fstat", 0);
+ add_packet_config_cmd (PACKET_vFile_stat, "vFile:stat", "hostio-stat", 0);
+
add_packet_config_cmd (PACKET_vAttach, "vAttach", "attach", 0);
add_packet_config_cmd (PACKET_vRun, "vRun", "run", 0);
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index d592d2d..932708c 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -1015,7 +1015,7 @@ riscv_pseudo_register_write (struct gdbarch *gdbarch,
if (regnum == tdep->fflags_regnum || regnum == tdep->frm_regnum)
{
int fcsr_regnum = RISCV_CSR_FCSR_REGNUM;
- gdb_byte raw_buf[register_size (gdbarch, fcsr_regnum)];
+ gdb::byte_vector raw_buf (register_size (gdbarch, fcsr_regnum));
regcache->raw_read (fcsr_regnum, raw_buf);
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index f0828fd..dd4da93 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -239,18 +239,18 @@ darwin_current_sos ()
for (int i = 0; i < info->all_image.count; i++)
{
CORE_ADDR iinfo = info->all_image.info + i * image_info_size;
- gdb_byte buf[image_info_size];
+ gdb::byte_vector buf (image_info_size);
CORE_ADDR load_addr;
CORE_ADDR path_addr;
struct mach_o_header_external hdr;
unsigned long hdr_val;
/* Read image info from inferior. */
- if (target_read_memory (iinfo, buf, image_info_size))
+ if (target_read_memory (iinfo, buf.data (), image_info_size))
break;
- load_addr = extract_typed_address (buf, ptr_type);
- path_addr = extract_typed_address (buf + ptr_len, ptr_type);
+ load_addr = extract_typed_address (buf.data (), ptr_type);
+ path_addr = extract_typed_address (buf.data () + ptr_len, ptr_type);
/* Read Mach-O header from memory. */
if (target_read_memory (load_addr, (gdb_byte *) &hdr, sizeof (hdr) - 4))
@@ -333,14 +333,14 @@ darwin_read_exec_load_addr_from_dyld (struct darwin_info *info)
for (i = 0; i < info->all_image.count; i++)
{
CORE_ADDR iinfo = info->all_image.info + i * image_info_size;
- gdb_byte buf[image_info_size];
+ gdb::byte_vector buf (image_info_size);
CORE_ADDR load_addr;
/* Read image info from inferior. */
- if (target_read_memory (iinfo, buf, image_info_size))
+ if (target_read_memory (iinfo, buf.data (), image_info_size))
break;
- load_addr = extract_typed_address (buf, ptr_type);
+ load_addr = extract_typed_address (buf.data (), ptr_type);
if (darwin_validate_exec_header (load_addr) == load_addr)
return load_addr;
}
diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c
index 39508fa..f84ff89 100644
--- a/gdb/solib-frv.c
+++ b/gdb/solib-frv.c
@@ -382,6 +382,8 @@ frv_current_sos ()
li->map = loadmap;
li->got_value = got_addr;
li->lm_addr = lm_addr;
+ sop->lm_info = std::move (li);
+
/* Fetch the name. */
addr = extract_unsigned_integer (lm_buf.l_name,
sizeof (lm_buf.l_name),
@@ -687,7 +689,7 @@ enable_break (void)
return 0;
}
- if (!entry_point_address_query (&entry_point))
+ if (!entry_point_address_query (current_program_space, &entry_point))
{
solib_debug_printf ("Symbol file has no entry point.");
return 0;
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 5c8557e..9f377f4 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -1496,7 +1496,7 @@ svr4_current_sos ()
CORE_ADDR
svr4_fetch_objfile_link_map (struct objfile *objfile)
{
- struct svr4_info *info = get_svr4_info (objfile->pspace);
+ struct svr4_info *info = get_svr4_info (objfile->pspace ());
/* Cause svr4_current_sos() to be run if it hasn't been already. */
if (info->main_lm_addr == 0)
@@ -1625,7 +1625,7 @@ probes_table_htab_remove_objfile_probes (void **slot, void *info)
struct objfile *objfile = (struct objfile *) info;
if (pa->objfile == objfile)
- htab_clear_slot (get_svr4_info (objfile->pspace)->probes_table.get (),
+ htab_clear_slot (get_svr4_info (objfile->pspace ())->probes_table.get (),
slot);
return 1;
@@ -1636,7 +1636,7 @@ probes_table_htab_remove_objfile_probes (void **slot, void *info)
static void
probes_table_remove_objfile_probes (struct objfile *objfile)
{
- svr4_info *info = get_svr4_info (objfile->pspace);
+ svr4_info *info = get_svr4_info (objfile->pspace ());
if (info->probes_table != nullptr)
htab_traverse_noresize (info->probes_table.get (),
probes_table_htab_remove_objfile_probes, objfile);
diff --git a/gdb/solib.c b/gdb/solib.c
index 881f0d9..931fa57 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -710,15 +710,16 @@ solib_read_symbols (solib &so, symfile_add_flags flags)
return false;
}
-/* Return true if KNOWN->objfile is used by any other so_list object
- in the list of shared libraries. Return false otherwise. */
+/* Return true if KNOWN->objfile is used by any other solib object
+ in PSPACE's list of shared libraries. Return false otherwise. */
static bool
-solib_used (const solib &known)
+solib_used (program_space *pspace, const solib &known)
{
- for (const solib &pivot : current_program_space->solibs ())
+ for (const solib &pivot : pspace->solibs ())
if (&pivot != &known && pivot.objfile == known.objfile)
return true;
+
return false;
}
@@ -845,7 +846,7 @@ update_solib_list (int from_tty)
/* Unless the user loaded it explicitly, free SO's objfile. */
if (gdb_iter->objfile != nullptr
&& !(gdb_iter->objfile->flags & OBJF_USERLOADED)
- && !solib_used (*gdb_iter))
+ && !solib_used (current_program_space, *gdb_iter))
gdb_iter->objfile->unlink ();
/* Some targets' section tables might be referring to
@@ -1234,21 +1235,29 @@ sharedlibrary_command (const char *args, int from_tty)
solib_add (args, from_tty, 1);
}
-/* Implements the command "nosharedlibrary", which discards symbols
- that have been auto-loaded from shared libraries. Symbols from
- shared libraries that were added by explicit request of the user
- are not discarded. Also called from remote.c. */
+/* See solib.h. */
void
-no_shared_libraries (const char *ignored, int from_tty)
+no_shared_libraries (program_space *pspace)
{
/* The order of the two routines below is important: clear_solib notifies
the solib_unloaded observers, and some of these observers might need
access to their associated objfiles. Therefore, we can not purge the
solibs' objfiles before clear_solib has been called. */
- clear_solib (current_program_space);
- objfile_purge_solibs ();
+ clear_solib (pspace);
+ objfile_purge_solibs (pspace);
+}
+
+/* Implements the command "nosharedlibrary", which discards symbols
+ that have been auto-loaded from shared libraries. Symbols from
+ shared libraries that were added by explicit request of the user
+ are not discarded. */
+
+static void
+no_shared_libraries_command (const char *ignored, int from_tty)
+{
+ no_shared_libraries (current_program_space);
}
/* See solib.h. */
@@ -1313,7 +1322,7 @@ reload_shared_libraries_1 (int from_tty)
&& filename_cmp (found_pathname, so.so_name.c_str ()) != 0))
{
if (so.objfile && !(so.objfile->flags & OBJF_USERLOADED)
- && !solib_used (so))
+ && !solib_used (current_program_space, so))
so.objfile->unlink ();
current_program_space->remove_target_sections (&so);
so.clear ();
@@ -1700,7 +1709,7 @@ remove_user_added_objfile (struct objfile *objfile)
{
if (objfile->flags & OBJF_USERLOADED)
{
- for (solib &so : objfile->pspace->solibs ())
+ for (solib &so : objfile->pspace ()->solibs ())
if (so.objfile == objfile)
so.objfile = nullptr;
}
@@ -1725,7 +1734,7 @@ _initialize_solib ()
= add_info ("sharedlibrary", info_sharedlibrary_command,
_ ("Status of loaded shared object libraries."));
add_info_alias ("dll", info_sharedlibrary_cmd, 1);
- add_com ("nosharedlibrary", class_files, no_shared_libraries,
+ add_com ("nosharedlibrary", class_files, no_shared_libraries_command,
_ ("Unload all shared object library symbols."));
add_setshow_boolean_cmd ("auto-solib-add", class_support, &auto_solib_add,
diff --git a/gdb/solib.h b/gdb/solib.h
index f7a93c0..25ed77c 100644
--- a/gdb/solib.h
+++ b/gdb/solib.h
@@ -80,9 +80,9 @@ extern bool solib_keep_data_in_core (CORE_ADDR vaddr, unsigned long size);
extern bool in_solib_dynsym_resolve_code (CORE_ADDR);
-/* Discard symbols that were auto-loaded from shared libraries. */
+/* Discard symbols that were auto-loaded from shared libraries in PSPACE. */
-extern void no_shared_libraries (const char *ignored, int from_tty);
+extern void no_shared_libraries (program_space *pspace);
/* Synchronize GDB's shared object list with inferior's.
diff --git a/gdb/source.c b/gdb/source.c
index 9e528d3..25d6e71 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -231,16 +231,15 @@ get_source_location (program_space *pspace)
return loc;
}
-/* Return the current source file for listing and next line to list.
- NOTE: The returned sal pc and end fields are not valid. */
+/* See source.h. */
-struct symtab_and_line
-get_current_source_symtab_and_line (void)
+symtab_and_line
+get_current_source_symtab_and_line (program_space *pspace)
{
symtab_and_line cursal;
- current_source_location *loc = get_source_location (current_program_space);
+ current_source_location *loc = get_source_location (pspace);
- cursal.pspace = current_program_space;
+ cursal.pspace = pspace;
cursal.symtab = loc->symtab ();
cursal.line = loc->line ();
cursal.pc = 0;
@@ -260,8 +259,9 @@ get_current_source_symtab_and_line (void)
void
set_default_source_symtab_and_line (void)
{
- if (!have_full_symbols () && !have_partial_symbols ())
- error (_("No symbol table is loaded. Use the \"file\" command."));
+ if (!have_full_symbols (current_program_space)
+ && !have_partial_symbols (current_program_space))
+ error (_ ("No symbol table is loaded. Use the \"file\" command."));
/* Pull in a current source symtab if necessary. */
current_source_location *loc = get_source_location (current_program_space);
@@ -298,9 +298,9 @@ set_current_source_symtab_and_line (const symtab_and_line &sal)
/* Reset any information stored about a default file and line to print. */
void
-clear_current_source_symtab_and_line (void)
+clear_current_source_symtab_and_line (program_space *pspace)
{
- current_source_location *loc = get_source_location (current_program_space);
+ current_source_location *loc = get_source_location (pspace);
loc->set (nullptr, 0);
}
diff --git a/gdb/source.h b/gdb/source.h
index 144ee48..541ee3b 100644
--- a/gdb/source.h
+++ b/gdb/source.h
@@ -21,7 +21,9 @@
#include "gdbsupport/scoped_fd.h"
+struct program_space;
struct symtab;
+struct symtab_and_line;
/* See openp function definition for their description. */
@@ -107,7 +109,8 @@ extern int get_lines_to_list (void);
/* Return the current source file for listing and next line to list.
NOTE: The returned sal pc and end fields are not valid. */
-extern struct symtab_and_line get_current_source_symtab_and_line (void);
+extern symtab_and_line get_current_source_symtab_and_line
+ (program_space *pspace);
/* If the current source file for listing is not set, try and get a default.
Usually called before get_current_source_symtab_and_line() is called.
@@ -126,7 +129,7 @@ extern symtab_and_line set_current_source_symtab_and_line
(const symtab_and_line &sal);
/* Reset any information stored about a default file and line to print. */
-extern void clear_current_source_symtab_and_line (void);
+extern void clear_current_source_symtab_and_line (program_space *pspace);
/* Add a source path substitution rule. */
extern void add_substitute_path_rule (const char *, const char *);
diff --git a/gdb/symfile.c b/gdb/symfile.c
index b0510b4..06c7faf 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -91,8 +91,6 @@ static void symbol_file_add_main_1 (const char *args, symfile_add_flags add_flag
static const struct sym_fns *find_sym_fns (bfd *);
-static void overlay_invalidate_all (void);
-
static void simple_free_overlay_table (void);
static void read_target_long_array (CORE_ADDR, unsigned int *, int, int,
@@ -1026,7 +1024,6 @@ symbol_file_add_with_addrs (const gdb_bfd_ref_ptr &abfd, const char *name,
section_addr_info *addrs,
objfile_flags flags, struct objfile *parent)
{
- struct objfile *objfile;
const int from_tty = add_flags & SYMFILE_VERBOSE;
const int mainline = add_flags & SYMFILE_MAINLINE;
const int always_confirm = add_flags & SYMFILE_ALWAYS_CONFIRM;
@@ -1053,14 +1050,17 @@ symbol_file_add_with_addrs (const gdb_bfd_ref_ptr &abfd, const char *name,
if (from_tty
&& (always_confirm
- || ((have_full_symbols () || have_partial_symbols ())
+ || ((have_full_symbols (current_program_space)
+ || have_partial_symbols (current_program_space))
&& mainline))
- && !query (_("Load new symbol table from \"%s\"? "), name))
+ && !query (_ ("Load new symbol table from \"%s\"? "), name))
error (_("Not confirmed."));
if (mainline)
flags |= OBJF_MAINLINE;
- objfile = objfile::make (abfd, name, flags, parent);
+
+ objfile *objfile
+ = objfile::make (abfd, current_program_space, name, flags, parent);
/* We either created a new mapped symbol table, mapped an existing
symbol table file which has not had initial symbol reading
@@ -1199,7 +1199,8 @@ symbol_file_add_main_1 (const char *args, symfile_add_flags add_flags,
void
symbol_file_clear (int from_tty)
{
- if ((have_full_symbols () || have_partial_symbols ())
+ if ((have_full_symbols (current_program_space)
+ || have_partial_symbols (current_program_space))
&& from_tty
&& (current_program_space->symfile_object_file
? !query (_("Discard symbol table from `%s'? "),
@@ -1209,7 +1210,7 @@ symbol_file_clear (int from_tty)
/* solib descriptors may have handles to objfiles. Wipe them before their
objfiles get stale by free_all_objfiles. */
- no_shared_libraries (NULL, from_tty);
+ no_shared_libraries (current_program_space);
current_program_space->free_all_objfiles ();
@@ -2387,7 +2388,7 @@ remove_symbol_file_command (const char *args, int from_tty)
{
if ((objfile->flags & OBJF_USERLOADED) != 0
&& (objfile->flags & OBJF_SHARED) != 0
- && objfile->pspace == pspace
+ && objfile->pspace () == pspace
&& is_addr_in_objfile (addr, objfile))
{
objf = objfile;
@@ -2408,7 +2409,7 @@ remove_symbol_file_command (const char *args, int from_tty)
{
if ((objfile->flags & OBJF_USERLOADED) != 0
&& (objfile->flags & OBJF_SHARED) != 0
- && objfile->pspace == pspace
+ && objfile->pspace () == pspace
&& filename_cmp (filename.get (), objfile_name (objfile)) == 0)
{
objf = objfile;
@@ -2611,7 +2612,7 @@ reread_symbols (int from_tty)
making the dangling pointers point to correct data
again. */
- objfiles_changed ();
+ objfiles_changed (current_program_space);
/* Recompute section offsets and section indices. */
objfile->sf->sym_offsets (objfile, {});
@@ -2884,7 +2885,7 @@ clear_symtab_users (symfile_add_flags add_flags)
/* Clear the "current" symtab first, because it is no longer valid.
breakpoint_re_set may try to access the current symtab. */
- clear_current_source_symtab_and_line ();
+ clear_current_source_symtab_and_line (current_program_space);
clear_displays ();
clear_last_displayed_sal ();
@@ -2969,13 +2970,13 @@ section_is_overlay (struct obj_section *section)
return 0;
}
-/* Function: overlay_invalidate_all (void)
- Invalidate the mapped state of all overlay sections (mark it as stale). */
+/* Invalidate the mapped state of all overlay sections (mark it as stale) in
+ PSPACE. */
static void
-overlay_invalidate_all (void)
+overlay_invalidate_all (program_space *pspace)
{
- for (objfile *objfile : current_program_space->objfiles ())
+ for (objfile *objfile : pspace->objfiles ())
for (obj_section *sect : objfile->sections ())
if (section_is_overlay (sect))
sect->ovly_mapped = -1;
@@ -3011,7 +3012,7 @@ section_is_mapped (struct obj_section *osect)
{
if (overlay_cache_invalid)
{
- overlay_invalidate_all ();
+ overlay_invalidate_all (current_program_space);
overlay_cache_invalid = 0;
}
if (osect->ovly_mapped == -1)
@@ -3722,7 +3723,7 @@ static void
symfile_free_objfile (struct objfile *objfile)
{
/* Remove the target sections owned by this objfile. */
- objfile->pspace->remove_target_sections (objfile);
+ objfile->pspace ()->remove_target_sections (objfile);
}
/* Wrapper around the quick_symbol_functions expand_symtabs_matching "method".
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 41d71be..9d11703 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1755,7 +1755,7 @@ maintenance_print_symbol_cache_statistics (const char *args, int from_tty)
static void
symtab_new_objfile_observer (struct objfile *objfile)
{
- symbol_cache_flush (objfile->pspace);
+ symbol_cache_flush (objfile->pspace ());
}
/* This module's 'all_objfiles_removed' observer. */
@@ -1774,7 +1774,7 @@ symtab_all_objfiles_removed (program_space *pspace)
static void
symtab_free_objfile_observer (struct objfile *objfile)
{
- symbol_cache_flush (objfile->pspace);
+ symbol_cache_flush (objfile->pspace ());
}
/* See symtab.h. */
@@ -2439,7 +2439,7 @@ lookup_symbol_in_objfile_from_linkage_name (struct objfile *objfile,
/* A helper function that throws an exception when a symbol was found
in a psymtab but not in a symtab. */
-static void ATTRIBUTE_NORETURN
+[[noreturn]] static void
error_in_psymtab_expansion (enum block_enum block_index, const char *name,
struct compunit_symtab *cust)
{
@@ -4764,8 +4764,9 @@ info_sources_worker (struct ui_out *uiout,
static void
info_sources_command (const char *args, int from_tty)
{
- if (!have_full_symbols () && !have_partial_symbols ())
- error (_("No symbol table is loaded. Use the \"file\" command."));
+ if (!have_full_symbols (current_program_space)
+ && !have_partial_symbols (current_program_space))
+ error (_ ("No symbol table is loaded. Use the \"file\" command."));
filename_partial_match_opts match_opts;
auto group = make_info_sources_options_def_group (&match_opts);
@@ -6381,7 +6382,8 @@ make_source_files_completion_list (const char *text, const char *word)
const char *base_name;
struct add_partial_filename_data datum;
- if (!have_full_symbols () && !have_partial_symbols ())
+ if (!have_full_symbols (current_program_space)
+ && !have_partial_symbols (current_program_space))
return list;
filename_seen_cache filenames_seen;
diff --git a/gdb/target.c b/gdb/target.c
index 1b5aa11..a80b133 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -56,7 +56,7 @@
#include "cli/cli-decode.h"
#include "cli/cli-style.h"
-static void generic_tls_error (void) ATTRIBUTE_NORETURN;
+[[noreturn]] static void generic_tls_error (void);
static void default_rcmd (struct target_ops *, const char *, struct ui_file *);
@@ -64,7 +64,7 @@ static int default_verify_memory (struct target_ops *self,
const gdb_byte *data,
CORE_ADDR memaddr, ULONGEST size);
-static void tcomplain (void) ATTRIBUTE_NORETURN;
+[[noreturn]] static void tcomplain (void);
/* Mapping between target_info objects (which have address identity)
and corresponding open/factory function/callback. Each add_target
@@ -2428,7 +2428,7 @@ info_target_command (const char *args, int from_tty)
resets (things which might change between targets). */
void
-target_pre_inferior (int from_tty)
+target_pre_inferior ()
{
/* Clear out solib state. Otherwise the solib state of the previous
inferior might have survived and is entirely wrong for the new
@@ -2452,7 +2452,7 @@ target_pre_inferior (int from_tty)
memory regions and features. */
if (!gdbarch_has_global_solist (current_inferior ()->arch ()))
{
- no_shared_libraries (NULL, from_tty);
+ no_shared_libraries (current_program_space);
invalidate_target_mem_regions ();
@@ -2504,7 +2504,7 @@ target_preopen (int from_tty)
live process to a core of the same program. */
current_inferior ()->pop_all_targets_above (file_stratum);
- target_pre_inferior (from_tty);
+ target_pre_inferior ();
}
/* See target.h. */
@@ -3199,6 +3199,14 @@ target_ops::fileio_fstat (int fd, struct stat *sb, fileio_error *target_errno)
}
int
+target_ops::fileio_stat (struct inferior *inf, const char *filename,
+ struct stat *sb, fileio_error *target_errno)
+{
+ *target_errno = FILEIO_ENOSYS;
+ return -1;
+}
+
+int
target_ops::fileio_close (int fd, fileio_error *target_errno)
{
*target_errno = FILEIO_ENOSYS;
@@ -3318,6 +3326,29 @@ target_fileio_fstat (int fd, struct stat *sb, fileio_error *target_errno)
/* See target.h. */
int
+target_fileio_stat (struct inferior *inf, const char *filename,
+ struct stat *sb, fileio_error *target_errno)
+{
+ for (target_ops *t = default_fileio_target (); t != NULL; t = t->beneath ())
+ {
+ int ret = t->fileio_stat (inf, filename, sb, target_errno);
+
+ if (ret == -1 && *target_errno == FILEIO_ENOSYS)
+ continue;
+
+ target_debug_printf_nofunc ("target_fileio_stat (%s) = %d (%d)",
+ filename, ret,
+ ret != -1 ? 0 : *target_errno);
+ return ret;
+ }
+
+ *target_errno = FILEIO_ENOSYS;
+ return -1;
+}
+
+/* See target.h. */
+
+int
target_fileio_close (int fd, fileio_error *target_errno)
{
fileio_fh_t *fh = fileio_fd_to_fh (fd);
diff --git a/gdb/target.h b/gdb/target.h
index 81de4a6..dcf68a6 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1011,6 +1011,14 @@ struct target_ops
*TARGET_ERRNO). */
virtual int fileio_fstat (int fd, struct stat *sb, fileio_error *target_errno);
+ /* Get information about the file FILENAME and put it in SB. Look for
+ FILENAME in the filesystem as seen by INF. If INF is NULL, use the
+ filesystem seen by the debugger (GDB or, for remote targets, the
+ remote stub). Return 0 on success, or -1 if an error occurs (and
+ set *TARGET_ERRNO). */
+ virtual int fileio_stat (struct inferior *inf, const char *filename,
+ struct stat *sb, fileio_error *target_errno);
+
/* Close FD on the target. Return 0, or -1 if an error occurs
(and set *TARGET_ERRNO). */
virtual int fileio_close (int fd, fileio_error *target_errno);
@@ -2220,6 +2228,14 @@ extern int target_fileio_pread (int fd, gdb_byte *read_buf, int len,
extern int target_fileio_fstat (int fd, struct stat *sb,
fileio_error *target_errno);
+/* Get information about the file at FILENAME on the target and put it in
+ SB. Look in the filesystem as seen by INF. If INF is NULL, use the
+ filesystem seen by the debugger (GDB or, for remote targets, the remote
+ stub). Return 0 on success, or -1 if an error occurs (and set
+ *TARGET_ERRNO). */
+extern int target_fileio_stat (struct inferior *inf, const char *filename,
+ struct stat *sb, fileio_error *target_errno);
+
/* Close FD on the target. Return 0, or -1 if an error occurs
(and set *TARGET_ERRNO). */
extern int target_fileio_close (int fd, fileio_error *target_errno);
@@ -2427,7 +2443,7 @@ struct target_unpusher
typedef std::unique_ptr<struct target_ops, target_unpusher> target_unpush_up;
-extern void target_pre_inferior (int);
+extern void target_pre_inferior ();
extern void target_preopen (int);
@@ -2490,7 +2506,7 @@ extern int default_memory_insert_breakpoint (struct gdbarch *,
extern void initialize_targets (void);
-extern void noprocess (void) ATTRIBUTE_NORETURN;
+[[noreturn]] extern void noprocess (void);
extern void target_require_runnable (void);
diff --git a/gdb/testsuite/gdb.ada/mi_task_arg.exp b/gdb/testsuite/gdb.ada/mi_task_arg.exp
index 098396d..b4b7b49 100644
--- a/gdb/testsuite/gdb.ada/mi_task_arg.exp
+++ b/gdb/testsuite/gdb.ada/mi_task_arg.exp
@@ -49,7 +49,8 @@ set frame1 "frame=\{level=\"1\",args=\\\[${frame1_args}(,$frame1_opt_args)?\\\]\
# Frame for system.tasking.stages.task_wrapper
set frame2_args "(\{name=\"self_id\",value=\"($hex|<optimized out>)\"\})?"
set frame2 "frame=\{level=\"2\",args=\\\[$frame2_args\\\]\}"
-mi_gdb_test "-stack-list-arguments 1" \
- "\\^done,stack-args=\\\[$frame0,$frame1,$frame2,.*" \
- "-stack-list-arguments 1"
+set frames "$frame0,$frame1,${frame2}(,.*)?"
+mi_gdb_test "-stack-list-arguments 1" \
+ "\\^done,stack-args=\\\[$frames\\\]" \
+ "-stack-list-arguments 1"
diff --git a/gdb/testsuite/gdb.ada/mi_var_access.exp b/gdb/testsuite/gdb.ada/mi_var_access.exp
index b71c8f3..e797a15 100644
--- a/gdb/testsuite/gdb.ada/mi_var_access.exp
+++ b/gdb/testsuite/gdb.ada/mi_var_access.exp
@@ -42,8 +42,9 @@ mi_continue_to_line \
# to match possible values.
set re_ok "\\^done,name=\"A_String_Access\",numchild=\"$decimal\",.*"
set re_error "\\^error,msg=\"Value out of range\.\".*"
+set re_error2 "\\^error,msg=\"Cannot access memory at address $hex\""
mi_gdb_test "-var-create A_String_Access * A_String_Access" \
- "($re_ok|$re_error)" \
+ "($re_ok|$re_error|$re_error2)" \
"Create varobj"
set bp_location [gdb_get_line_number "STOP2" ${testdir}/mi_access.adb]
diff --git a/gdb/testsuite/gdb.ada/variant_record_field.exp b/gdb/testsuite/gdb.ada/variant_record_field.exp
new file mode 100644
index 0000000..f3baa25
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/variant_record_field.exp
@@ -0,0 +1,50 @@
+# Copyright 2024 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+load_lib "ada.exp"
+
+require allow_ada_tests
+
+standard_ada_testfile foo
+
+# The compiler used to emit an invalid DWARF expression for the record
+# size, so GDB could not 'print p_record' correctly: a direct 'print
+# p_record.i' worked, but iteration over the record fields was broken.
+#
+# Originally observed at -O2, and the bug was reproducible with just
+# -Og. The DWARF fix covered both optimization levels; not worth
+# making guarantees beyond -Og though, so test that.
+
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug optimize=-Og]] != ""} {
+ return -1
+}
+
+clean_restart ${testfile}
+
+set bp_location [gdb_get_line_number "BREAK" ${srcfile}]
+runto "${testfile}.adb:${bp_location}"
+
+set test "print p_record"
+gdb_test_multiple "$test" "$test" {
+ -re "\\(kind => five, i => 1200\\)" {
+ pass $test
+ }
+ -re "\\(kind => five, i => <error reading variable: access outside bounds of object>" {
+ if { [gcc_major_version] <= 14 } {
+ setup_xfail *-*-*
+ }
+ fail $test
+ }
+}
diff --git a/gdb/testsuite/gdb.ada/variant_record_field/foo.adb b/gdb/testsuite/gdb.ada/variant_record_field/foo.adb
new file mode 100644
index 0000000..2526a1d
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/variant_record_field/foo.adb
@@ -0,0 +1,47 @@
+-- Copyright 2024 Free Software Foundation, Inc.
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see <http://www.gnu.org/licenses/>.
+with Ada.Text_IO;
+
+procedure Foo is
+
+ package P is
+
+ type Int16 is range 0 .. 2 ** 16 - 1;
+ type Enum is (Zero, One, Two, Three, Four, Five, Six, Seven, Eight, Nine);
+
+ type Rec (Kind : Enum := Zero) is record
+ case Kind is
+ when Four .. Seven =>
+ I : Int16;
+ when others =>
+ null;
+ end case;
+ end record;
+
+ end P;
+
+ P_Record : P.Rec;
+ I : P.Int16;
+
+ procedure Dump is
+ begin
+ Ada.Text_IO.Put_Line ("P_Record.I => " & P_Record.I'Image); -- BREAK
+ end Dump;
+
+begin
+ I := P.Int16'(1200);
+ P_Record := (Kind => P.Five, I => I);
+ Dump;
+end Foo;
diff --git a/gdb/testsuite/gdb.arch/arm-pseudo-unwind-legacy.c b/gdb/testsuite/gdb.arch/arm-pseudo-unwind-legacy.c
index 49b0553..adda4b8 100644
--- a/gdb/testsuite/gdb.arch/arm-pseudo-unwind-legacy.c
+++ b/gdb/testsuite/gdb.arch/arm-pseudo-unwind-legacy.c
@@ -24,10 +24,17 @@ break_here_c (uint64_t value)
{
}
+__attribute__((target("arm")))
+uint64_t
+caller_trampoline (void)
+{
+ return caller ();
+}
+
int
main (void)
{
- uint64_t value = caller ();
+ uint64_t value = caller_trampoline ();
break_here_c (value);
return 0;
}
diff --git a/gdb/testsuite/gdb.arch/arm-pseudo-unwind.c b/gdb/testsuite/gdb.arch/arm-pseudo-unwind.c
index 49b0553..adda4b8 100644
--- a/gdb/testsuite/gdb.arch/arm-pseudo-unwind.c
+++ b/gdb/testsuite/gdb.arch/arm-pseudo-unwind.c
@@ -24,10 +24,17 @@ break_here_c (uint64_t value)
{
}
+__attribute__((target("arm")))
+uint64_t
+caller_trampoline (void)
+{
+ return caller ();
+}
+
int
main (void)
{
- uint64_t value = caller ();
+ uint64_t value = caller_trampoline ();
break_here_c (value);
return 0;
}
diff --git a/gdb/testsuite/gdb.base/assign.exp b/gdb/testsuite/gdb.base/assign.exp
index 675ded4..38c2b2e 100644
--- a/gdb/testsuite/gdb.base/assign.exp
+++ b/gdb/testsuite/gdb.base/assign.exp
@@ -60,7 +60,7 @@ gdb_test_multiple "print v_int+=57" "v_int+=57" {
}
}
-gdb_test_no_output "set variable v_int = 6" "set v_int to 6 (2)"
+gdb_test_no_output "set variable v_int = 6" "set v_int to 6, 2"
gdb_test_multiple "print v_int-=57" "v_int-=57" {
-re " = -51.*$gdb_prompt $" {
@@ -68,7 +68,7 @@ gdb_test_multiple "print v_int-=57" "v_int-=57" {
}
}
-gdb_test_no_output "set variable v_int = 6" "set v_int to 6 (3)"
+gdb_test_no_output "set variable v_int = 6" "set v_int to 6, 3"
gdb_test_multiple "print v_int*=5" "v_int*=5" {
-re " = 30.*$gdb_prompt $" {
@@ -76,7 +76,7 @@ gdb_test_multiple "print v_int*=5" "v_int*=5" {
}
}
-gdb_test_no_output "set variable v_int = 6" "set v_int to 6 (4)"
+gdb_test_no_output "set variable v_int = 6" "set v_int to 6, 4"
gdb_test_multiple "print v_int/=4" "v_int/=4" {
-re " = 1.*$gdb_prompt $" {
@@ -84,7 +84,7 @@ gdb_test_multiple "print v_int/=4" "v_int/=4" {
}
}
-gdb_test_no_output "set variable v_int = 6" "set v_int to 6 (5)"
+gdb_test_no_output "set variable v_int = 6" "set v_int to 6, 5"
gdb_test_multiple "print v_int%=4" "v_int%=4" {
-re " = 2.*$gdb_prompt $" {
@@ -92,7 +92,7 @@ gdb_test_multiple "print v_int%=4" "v_int%=4" {
}
}
-gdb_test_no_output "set variable v_int = 6" "set v_int to 6 (6)"
+gdb_test_no_output "set variable v_int = 6" "set v_int to 6, 6"
gdb_test_multiple "print v_int+=v_char" "v_int+=char" {
-re " = 71.*$gdb_prompt $" {
@@ -100,7 +100,7 @@ gdb_test_multiple "print v_int+=v_char" "v_int+=char" {
}
}
-gdb_test_no_output "set variable v_int = 6" "set v_int to 6 (7)"
+gdb_test_no_output "set variable v_int = 6" "set v_int to 6, 7"
gdb_test_multiple "print v_int+=v_signed_char" "v_int+=signed_char" {
-re " = 72.*$gdb_prompt $" {
@@ -108,7 +108,7 @@ gdb_test_multiple "print v_int+=v_signed_char" "v_int+=signed_char" {
}
}
-gdb_test_no_output "set variable v_int = 6" "set v_int to 6 (8)"
+gdb_test_no_output "set variable v_int = 6" "set v_int to 6, 8"
gdb_test_multiple "print v_int+=v_unsigned_char" "v_int+=unsigned_char" {
-re " = 73.*$gdb_prompt $" {
@@ -116,7 +116,7 @@ gdb_test_multiple "print v_int+=v_unsigned_char" "v_int+=unsigned_char" {
}
}
-gdb_test_no_output "set variable v_int = 6" "set v_int to 6 (9)"
+gdb_test_no_output "set variable v_int = 6" "set v_int to 6, 9"
gdb_test_multiple "print v_int+=v_short" "v_int+=short" {
-re " = 9.*$gdb_prompt $" {
@@ -124,7 +124,7 @@ gdb_test_multiple "print v_int+=v_short" "v_int+=short" {
}
}
-gdb_test_no_output "set variable v_int = 6" "set v_int to 6 (10)"
+gdb_test_no_output "set variable v_int = 6" "set v_int to 6, 10"
gdb_test_multiple "print v_int+=v_signed_short" "v_int+=signed_short" {
-re " = 10.*$gdb_prompt $" {
@@ -132,7 +132,7 @@ gdb_test_multiple "print v_int+=v_signed_short" "v_int+=signed_short" {
}
}
-gdb_test_no_output "set variable v_int = 6" "set v_int to 6 (11)"
+gdb_test_no_output "set variable v_int = 6" "set v_int to 6, 11"
gdb_test_multiple "print v_int+=v_unsigned_short" "v_int=+unsigned_short" {
-re " = 11.*$gdb_prompt $" {
@@ -140,7 +140,7 @@ gdb_test_multiple "print v_int+=v_unsigned_short" "v_int=+unsigned_short" {
}
}
-gdb_test_no_output "set variable v_int = 6" "set v_int to 6 (12)"
+gdb_test_no_output "set variable v_int = 6" "set v_int to 6, 12"
gdb_test_multiple "print v_int+=v_signed_int" "v_int+=signed_int" {
-re " = 13.*$gdb_prompt $" {
@@ -148,7 +148,7 @@ gdb_test_multiple "print v_int+=v_signed_int" "v_int+=signed_int" {
}
}
-gdb_test_no_output "set variable v_int = 6" "set v_int to 6 (13)"
+gdb_test_no_output "set variable v_int = 6" "set v_int to 6, 13"
gdb_test_multiple "print v_int+=v_unsigned_int" "v_int+=unsigned_int" {
-re " = 14.*$gdb_prompt $" {
@@ -156,7 +156,7 @@ gdb_test_multiple "print v_int+=v_unsigned_int" "v_int+=unsigned_int" {
}
}
-gdb_test_no_output "set variable v_int = 6" "set v_int to 6 (14)"
+gdb_test_no_output "set variable v_int = 6" "set v_int to 6, 14"
gdb_test_multiple "print v_int+=v_long" "v_int+=long" {
-re " = 15.*$gdb_prompt $" {
@@ -164,7 +164,7 @@ gdb_test_multiple "print v_int+=v_long" "v_int+=long" {
}
}
-gdb_test_no_output "set variable v_int = 6" "set v_int to 6 (15)"
+gdb_test_no_output "set variable v_int = 6" "set v_int to 6, 15"
gdb_test_multiple "print v_int+=v_signed_long" "v_int+=signed_long" {
-re " = 16.*$gdb_prompt $" {
@@ -172,7 +172,7 @@ gdb_test_multiple "print v_int+=v_signed_long" "v_int+=signed_long" {
}
}
-gdb_test_no_output "set variable v_int = 6" "set v_int to 6 (16)"
+gdb_test_no_output "set variable v_int = 6" "set v_int to 6, 16"
gdb_test_multiple "print v_int+=v_unsigned_long" "v_int+=unsigned_long" {
-re " = 17.*$gdb_prompt $" {
@@ -180,7 +180,7 @@ gdb_test_multiple "print v_int+=v_unsigned_long" "v_int+=unsigned_long" {
}
}
-gdb_test_no_output "set variable v_int = 6" "set v_int to 6 (17)"
+gdb_test_no_output "set variable v_int = 6" "set v_int to 6, 17"
gdb_test_multiple "print v_int+=v_float" "v_int+=v_float" {
-re " = 106.*$gdb_prompt $" {
@@ -188,7 +188,7 @@ gdb_test_multiple "print v_int+=v_float" "v_int+=v_float" {
}
}
-gdb_test_no_output "set variable v_int = 6" "set v_int to 6 (18)"
+gdb_test_no_output "set variable v_int = 6" "set v_int to 6, 18"
gdb_test_multiple "print v_int+=v_double" "v_int+=double" {
-re " = 206.*$gdb_prompt $" {
diff --git a/gdb/testsuite/gdb.base/bitfields.exp b/gdb/testsuite/gdb.base/bitfields.exp
index ce420fa..6954a35 100644
--- a/gdb/testsuite/gdb.base/bitfields.exp
+++ b/gdb/testsuite/gdb.base/bitfields.exp
@@ -45,23 +45,23 @@ proc bitfield_uniqueness {} {
# treat it correctly as a signed 1bit field (values 0 or -1) while
# printing its value does not cause a spurious failure. We do the
# signedness preservation test later.
- gdb_test "print flags" ".*uc = 0 .*, s1 = (1|-1), u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 0.*" "bitfield uniqueness (s1)"
+ gdb_test "print flags" ".*uc = 0 .*, s1 = (1|-1), u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 0.*" "bitfield uniqueness, s1"
gdb_test "cont" "Break.*break1 \\(\\) at .*$srcfile:$decimal.*" "continuing to break1 #2"
- gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 1, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 0.*" "bitfield uniqueness (u1)"
+ gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 1, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 0.*" "bitfield uniqueness, u1"
gdb_test "cont" "Break.*break1 \\(\\) at .*$srcfile:$decimal.*" "continuing to break1 #3"
- gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 1, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 0.*" "bitfield uniqueness (s2)"
+ gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 1, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 0.*" "bitfield uniqueness, s2"
gdb_test "cont" "Break.*break1 \\(\\) at .*$srcfile:$decimal.*" "continuing to break1 #4"
- gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 1, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 0.*" "bitfield uniqueness (u2)"
+ gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 1, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 0.*" "bitfield uniqueness, u2"
gdb_test "cont" "Break.*break1 \\(\\) at .*$srcfile:$decimal.*" "continuing to break1 #5"
- gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 1, u3 = 0, s9 = 0, u9 = 0, sc = 0.*" "bitfield uniqueness (s3)"
+ gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 1, u3 = 0, s9 = 0, u9 = 0, sc = 0.*" "bitfield uniqueness, s3"
gdb_test "cont" "Break.*break1 \\(\\) at .*$srcfile:$decimal.*" "continuing to break1 #6"
- gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 1, s9 = 0, u9 = 0, sc = 0.*" "bitfield uniqueness (u3)"
+ gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 1, s9 = 0, u9 = 0, sc = 0.*" "bitfield uniqueness, u3"
gdb_test "cont" "Break.*break1 \\(\\) at .*$srcfile:$decimal.*" "continuing to break1 #7"
- gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 1, u9 = 0, sc = 0.*" "bitfield uniqueness (s9)"
+ gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 1, u9 = 0, sc = 0.*" "bitfield uniqueness, s9"
gdb_test "cont" "Break.*break1 \\(\\) at .*$srcfile:$decimal.*" "continuing to break1 #8"
- gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 1, sc = 0.*" "bitfield uniqueness (u9)"
+ gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 1, sc = 0.*" "bitfield uniqueness, u9"
gdb_test "cont" "Break.*break1 \\(\\) at .*$srcfile:$decimal.*" "continuing to break1 #9"
- gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 1.*" "bitfield uniqueness (sc)"
+ gdb_test "print flags" ".*uc = 0 .*, s1 = 0, u1 = 0, s2 = 0, u2 = 0, s3 = 0, u3 = 0, s9 = 0, u9 = 0, sc = 1.*" "bitfield uniqueness, sc"
}
diff --git a/gdb/testsuite/gdb.base/build-id-seqno.c b/gdb/testsuite/gdb.base/build-id-seqno.c
new file mode 100644
index 0000000..e2119ba7
--- /dev/null
+++ b/gdb/testsuite/gdb.base/build-id-seqno.c
@@ -0,0 +1,22 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2024 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int
+main (void)
+{
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/build-id-seqno.exp b/gdb/testsuite/gdb.base/build-id-seqno.exp
new file mode 100644
index 0000000..9566933
--- /dev/null
+++ b/gdb/testsuite/gdb.base/build-id-seqno.exp
@@ -0,0 +1,134 @@
+# This testcase is part of GDB, the GNU debugger.
+#
+# Copyright 2024 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Setup a .build-id/ based debug directory containing multiple entries
+# for the same build-id, with each entry given a different sequence
+# number.
+#
+# Ensure that GDB will scan over broken symlinks for the same build-id
+# (but different sequence number) to find later working symlinks.
+#
+# This test only places debug information on the host, so it is always
+# local to GDB.
+
+require {!is_remote host}
+
+standard_testfile
+
+if {[build_executable "failed to prepare" $testfile $srcfile \
+ {debug build-id}] == -1} {
+ return -1
+}
+
+# Split out BINFILE.debug. Remove debug from BINFILE.
+if {[gdb_gnu_strip_debug $binfile] != 0} {
+ return -1
+}
+
+# Get the '.build-id/xx/xxx...xxx' part of the filename.
+set build_id_filename [build_id_debug_filename_get $binfile]
+
+# Hide (rename) BINFILE.debug, this should ensure GDB can't find it
+# directly but needs to look for the build-id based file in the debug
+# directory.
+set hidden_debuginfo [standard_output_file "hidden_$testfile.debug"]
+remote_exec build "mv ${binfile}.debug $hidden_debuginfo"
+
+# A filename that doesn't exist. Some symlinks will point at this
+# file.
+set missing_debuginfo [host_standard_output_file "missing_debuginfo"]
+
+# Create the debug directory, and the .build-id directory structure
+# within it.
+set debugdir [host_standard_output_file "debug"]
+remote_exec host "mkdir -p $debugdir/[file dirname $build_id_filename]"
+
+set host_hidden_debuginfo [gdb_remote_download host $hidden_debuginfo]
+remote_exec host "ln -fs $host_hidden_debuginfo $debugdir/$build_id_filename"
+
+# Start GDB and load global BINFILE. If FIND_DEBUGINFO is true then
+# we expect GDB to find the debug information matching BINFILE,
+# otherwise, we expect GDB not to find the debug information.
+proc load_binfile_check_debug_is_found { find_debuginfo testname } {
+ with_test_prefix "$testname" {
+ clean_restart
+
+ gdb_test_no_output "set debug-file-directory $::debugdir" \
+ "set debug-file-directory"
+
+ gdb_file_cmd $::binfile
+
+ if { $find_debuginfo } {
+ gdb_assert { [regexp [string_to_regexp \
+ "Reading symbols from $::hidden_debuginfo..."] \
+ $::gdb_file_cmd_msg] } \
+ "debuginfo was read via build-id"
+ } else {
+ gdb_assert { [regexp "\\(No debugging symbols found in \[^\r\n\]+/$::testfile\\)" \
+ $::gdb_file_cmd_msg] } \
+ }
+ }
+}
+
+# Return a copy of FILENAME, which should end '.debug', with NUMBER
+# added, e.g. add_seqno 1 "foo.debug" --> "foo.1.debug".
+proc add_seqno { number filename } {
+ return [regsub "\.debug\$" $filename ".${number}.debug"]
+}
+
+load_binfile_check_debug_is_found true \
+ "find debuginfo with a single build-id file"
+
+remote_exec host "ln -fs $host_hidden_debuginfo \
+ $debugdir/[add_seqno 1 $build_id_filename]"
+remote_exec host "ln -fs $host_hidden_debuginfo \
+ $debugdir/[add_seqno 2 $build_id_filename]"
+remote_exec host "ln -fs $host_hidden_debuginfo \
+ $debugdir/[add_seqno 3 $build_id_filename]"
+
+load_binfile_check_debug_is_found true \
+ "find debuginfo with 4 build-id files"
+
+remote_exec host "ln -fs $missing_debuginfo $debugdir/$build_id_filename"
+
+load_binfile_check_debug_is_found true \
+ "find debuginfo, first build-id file is bad"
+
+remote_exec host "ln -fs $missing_debuginfo \
+ $debugdir/[add_seqno 1 $build_id_filename]"
+remote_exec host "ln -fs $missing_debuginfo \
+ $debugdir/[add_seqno 3 $build_id_filename]"
+
+load_binfile_check_debug_is_found true \
+ "find debuginfo, first 2 build-id files are bad"
+
+remote_exec host "ln -fs $missing_debuginfo \
+ $debugdir/[add_seqno 2 $build_id_filename]"
+
+load_binfile_check_debug_is_found false \
+ "cannot find debuginfo, all build-id files are bad"
+
+remote_exec host "ln -fs $host_hidden_debuginfo \
+ $debugdir/[add_seqno 3 $build_id_filename]"
+
+load_binfile_check_debug_is_found true \
+ "find debuginfo, last build-id file is good"
+
+remote_exec host "rm -f $debugdir/[add_seqno 1 $build_id_filename]"
+
+load_binfile_check_debug_is_found false \
+ "cannot find debuginfo, file with seqno 1 is missing"
diff --git a/gdb/testsuite/gdb.base/catch-syscall.exp b/gdb/testsuite/gdb.base/catch-syscall.exp
index 075498a..431bfd5 100644
--- a/gdb/testsuite/gdb.base/catch-syscall.exp
+++ b/gdb/testsuite/gdb.base/catch-syscall.exp
@@ -171,7 +171,7 @@ proc insert_catch_syscall_with_arg { syscall } {
global decimal
# Trying to set the catchpoint
- set thistest "catch syscall with arguments ($syscall)"
+ set thistest "catch syscall with arguments, $syscall"
gdb_test "catch syscall $syscall" "Catchpoint $decimal \\(syscall \'?${syscall}\'?( \[${decimal}\])?\\)" $thistest
check_info_bp_specific_syscall $syscall
diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp
index 3dbdd0f..4a0a373 100644
--- a/gdb/testsuite/gdb.base/completion.exp
+++ b/gdb/testsuite/gdb.base/completion.exp
@@ -543,10 +543,10 @@ gdb_test_multiple "" "$test" {
# Eat the prompt
gdb_expect {
-re "$gdb_prompt " {
- pass "$test (eat prompt)"
+ pass "$test, eat prompt"
}
timeout {
- fail "(timeout) $test (eat prompt)"
+ fail "$test, eat prompt (timeout)"
}
}
@@ -572,10 +572,10 @@ gdb_test_multiple "" "$test" {
# Eat the prompt
gdb_expect {
-re "$gdb_prompt " {
- pass "$test (eat prompt)"
+ pass "$test, eat prompt"
}
timeout {
- fail "(timeout) $test (eat prompt)"
+ fail "$test, eat prompt (timeout)"
}
}
diff --git a/gdb/testsuite/gdb.base/complex-parts.exp b/gdb/testsuite/gdb.base/complex-parts.exp
index e678cfc..40f14f4 100644
--- a/gdb/testsuite/gdb.base/complex-parts.exp
+++ b/gdb/testsuite/gdb.base/complex-parts.exp
@@ -23,12 +23,13 @@ if {![runto_main]} {
return 0
}
-gdb_breakpoint [gdb_get_line_number "Break Here"]
-gdb_continue_to_breakpoint "breakpt" ".* Break Here\\. .*"
+set marker " Break Here. "
+gdb_breakpoint [gdb_get_line_number $marker]
+gdb_continue_to_breakpoint "breakpt" ".*[string_to_regexp $marker].*"
-gdb_test "p z1" " = 1.5 \\+ 4.5i"
-gdb_test "p z2" " = 2.5 \\+ -5.5i"
-gdb_test "p z3" " = 3.5 \\+ 6.5i"
+gdb_test "p z1" [string_to_regexp " = 1.5 + 4.5i"]
+gdb_test "p z2" [string_to_regexp " = 2.5 + -5.5i"]
+gdb_test "p z3" [string_to_regexp " = 3.5 + 6.5i"]
# The following 3 tests are broken for Clang.
# More info at https://github.com/llvm/llvm-project/issues/52996.
@@ -40,59 +41,71 @@ if {[test_compiler_info clang-*-*]} { setup_xfail *-*-* }
gdb_test "ptype z3" " = complex long double"
with_test_prefix "double imaginary" {
- gdb_test "p \$_cimag (z1)" " = 4.5"
- gdb_test "ptype \$" " = double"
+ set expr {$_cimag (z1)}
+ gdb_test "p $expr" " = 4.5"
+ gdb_test {ptype $} " = double"
+ gdb_test "ptype $expr" " = double"
}
with_test_prefix "float imaginary" {
- gdb_test "p \$_cimag (z2)" " = -5.5"
- gdb_test "ptype \$" " = float"
+ set expr {$_cimag (z2)}
+ gdb_test "p $expr" " = -5.5"
+ gdb_test {ptype $} " = float"
+ gdb_test "ptype $expr" " = float"
}
with_test_prefix "long double imaginary" {
- gdb_test "p \$_cimag (z3)" " = 6.5"
- gdb_test "ptype \$" " = long double"
+ set expr {$_cimag (z3)}
+ gdb_test "p $expr" " = 6.5"
+ gdb_test {ptype $} " = long double"
+ gdb_test "ptype $expr" " = long double"
}
with_test_prefix "double real" {
- gdb_test "p \$_creal (z1)" " = 1.5"
- gdb_test "ptype \$" " = double"
+ set expr {$_creal (z1)}
+ gdb_test "p $expr" " = 1.5"
+ gdb_test {ptype $} " = double"
+ gdb_test "ptype $expr" " = double"
}
with_test_prefix "float real" {
- gdb_test "p \$_creal (z2)" " = 2.5"
- gdb_test "ptype \$" " = float"
+ set expr {$_creal (z2)}
+ gdb_test "p $expr" " = 2.5"
+ gdb_test {ptype $} " = float"
+ gdb_test "ptype $expr" " = float"
}
with_test_prefix "long double real" {
- gdb_test "p \$_creal (z3)" " = 3.5"
- gdb_test "ptype \$" " = long double"
+ set expr {$_creal (z3)}
+ gdb_test "p $expr" " = 3.5"
+ gdb_test {ptype $} " = long double"
+ gdb_test "ptype $expr" " = long double"
}
-gdb_test "p \$_cimag (d1)" "expected a complex number"
-gdb_test "p \$_cimag (f1)" "expected a complex number"
-gdb_test "p \$_cimag (i1)" "expected a complex number"
+gdb_test {p $_cimag (d1)} "expected a complex number"
+gdb_test {p $_cimag (f1)} "expected a complex number"
+gdb_test {p $_cimag (i1)} "expected a complex number"
-gdb_test "p \$_creal (d1)" "expected a complex number"
-gdb_test "p \$_creal (f1)" "expected a complex number"
-gdb_test "p \$_creal (i1)" "expected a complex number"
+gdb_test {p $_creal (d1)} "expected a complex number"
+gdb_test {p $_creal (f1)} "expected a complex number"
+gdb_test {p $_creal (i1)} "expected a complex number"
#
# General complex number tests.
#
-gdb_test "print 23 + 7i" " = 23 \\+ 7i"
-gdb_test "print 23.125f + 7i" " = 23.125 \\+ 7i"
-gdb_test "print 23 + 7.25fi" " = 23 \\+ 7.25i"
-gdb_test "print (23 + 7i) + (17 + 10i)" " = 40 \\+ 17i"
-gdb_test "print 23 + -7i" " = 23 \\+ -7i"
-gdb_test "print 23 - 7i" " = 23 \\+ -7i"
+gdb_test "print 23 + 7i" [string_to_regexp " = 23 + 7i"]
+gdb_test "print 23.125f + 7i" [string_to_regexp " = 23.125 + 7i"]
+gdb_test "print 23 + 7.25fi" [string_to_regexp " = 23 + 7.25i"]
+gdb_test "print (23 + 7i) + (17 + 10i)" [string_to_regexp " = 40 + 17i"]
+gdb_test "print 23 + -7i" [string_to_regexp " = 23 + -7i"]
+gdb_test "print 23 - 7i" [string_to_regexp " = 23 + -7i"]
-gdb_test "print -(23 + 7i)" " = -23 \\+ -7i"
-gdb_test "print +(23 + 7i)" " = 23 \\+ 7i"
-gdb_test "print ~(23 + 7i)" " = 23 \\+ -7i"
+gdb_test "print -(23 + 7i)" [string_to_regexp " = -23 + -7i"]
+gdb_test "print +(23 + 7i)" [string_to_regexp " = 23 + 7i"]
+gdb_test "print ~(23 + 7i)" [string_to_regexp " = 23 + -7i"]
-gdb_test "print (5 + 5i) * (2 + 2i)" " = 0 \\+ 20i"
+gdb_test "print (5 + 5i) * (2 + 2i)" [string_to_regexp " = 0 + 20i"]
gdb_test "print (5 + 7i) == (5 + 7i)" " = 1"
gdb_test "print (5 + 7i) == (8 + 7i)" " = 0"
@@ -101,14 +114,16 @@ gdb_test "print (5 + 7i) != (5 + 7i)" " = 0"
gdb_test "print (5 + 7i) != (8 + 7i)" " = 1"
gdb_test "print (5 + 7i) != (5 + 92i)" " = 1"
-gdb_test "print (20 - 4i) / (3 + 2i)" " = 4 \\+ -4i"
+gdb_test "print (20 - 4i) / (3 + 2i)" [string_to_regexp " = 4 + -4i"]
-gdb_test "print (_Complex int) 4" " = 4 \\+ 0i"
-gdb_test "print (_Complex float) 4.5" " = 4.5 \\+ 0i"
+gdb_test "print (_Complex int) 4" [string_to_regexp " = 4 + 0i"]
+gdb_test "print (_Complex float) 4.5" [string_to_regexp " = 4.5 + 0i"]
gdb_test "ptype __complex__ short" " = _Complex short"
-gdb_test "print (_Complex int) (23.75 + 8.88i)" " = 23 \\+ 8i"
+gdb_test "print (_Complex int) (23.75 + 8.88i)" [string_to_regexp " = 23 + 8i"]
-set re_reject_arg "Argument to complex arithmetic operation not supported\\."
+set re_reject_arg \
+ [string_to_regexp \
+ "Argument to complex arithmetic operation not supported."]
gdb_test "print (void *)0 + 5i" $re_reject_arg
gdb_test "print (_Decimal32)0 + 5i" $re_reject_arg
@@ -117,4 +132,4 @@ clean_restart
gdb_test_no_output "set language c++"
# C++ type tests.
-gdb_test "print (bool)1 + 1i" " = 1 \\+ 1i"
+gdb_test "print (bool)1 + 1i" [string_to_regexp "= 1 + 1i"]
diff --git a/gdb/testsuite/gdb.base/cond-expr.exp b/gdb/testsuite/gdb.base/cond-expr.exp
index 5956d68..67918cf 100644
--- a/gdb/testsuite/gdb.base/cond-expr.exp
+++ b/gdb/testsuite/gdb.base/cond-expr.exp
@@ -47,22 +47,22 @@ if {![runto_main]} {
}
gdb_test "print (2 ? 3 : 4)" "\[0-9\]* = 3" \
- "print value of cond expr (const true)"
+ "print value of cond expr, const true"
gdb_test "print (0 ? 3 : 4)" "\[0-9\]* = 4" \
- "print value of cond expr (const false)"
+ "print value of cond expr, const false"
gdb_test_no_output "set variable x=14" "set variable x=14"
gdb_test_no_output "set variable y=2" "set variable y=2"
gdb_test_no_output "set variable z=3" "set variable z=3"
gdb_test "print (x ? y : z)" "\[0-9\]* = 2" \
- "print value of cond expr (var true)"
+ "print value of cond expr, var true"
gdb_test_no_output "set variable x=0" "set variable x=0"
gdb_test "print (x ? y : z)" "\[0-9\]* = 3" \
- "print value of cond expr (var false)"
+ "print value of cond expr, var false"
gdb_test "whatis (0 ? 3 : 4)" "type = int" \
"print whatis of cond expr"
diff --git a/gdb/testsuite/gdb.base/coredump-filter-build-id.exp b/gdb/testsuite/gdb.base/coredump-filter-build-id.exp
index b62796f..cddacce 100644
--- a/gdb/testsuite/gdb.base/coredump-filter-build-id.exp
+++ b/gdb/testsuite/gdb.base/coredump-filter-build-id.exp
@@ -30,7 +30,7 @@ if { ![istarget *-*-linux*] } {
}
require is_x86_64_m64_target
-if { [prepare_for_testing "failed to prepare" $testfile $srcfile debug] } {
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug build-id}] } {
return -1
}
diff --git a/gdb/testsuite/gdb.base/corefile.exp b/gdb/testsuite/gdb.base/corefile.exp
index 28b723e..79363c5 100644
--- a/gdb/testsuite/gdb.base/corefile.exp
+++ b/gdb/testsuite/gdb.base/corefile.exp
@@ -195,7 +195,7 @@ gdb_test "x/wx buf3" "$hex:\[ \t\]+0x00000000" \
# test reinit_frame_cache
gdb_load ${binfile}
-gdb_test "up" "#\[0-9\]* *(\[0-9xa-fH'\]* in)? .* \\(.*\\).*" "up (reinit)"
+gdb_test "up" "#\[0-9\]* *(\[0-9xa-fH'\]* in)? .* \\(.*\\).*" "up, reinit"
gdb_test "core" "No core file now."
diff --git a/gdb/testsuite/gdb.base/cvexpr.exp b/gdb/testsuite/gdb.base/cvexpr.exp
index fd15efe..439bf71 100644
--- a/gdb/testsuite/gdb.base/cvexpr.exp
+++ b/gdb/testsuite/gdb.base/cvexpr.exp
@@ -47,55 +47,55 @@ proc do_test {dir options} {
gdb_test "whatis (const char) v_char" \
"type = const char" \
- "(const char)"
+ "cast to const char"
gdb_test "whatis (const signed char) v_signed_char" \
"type = const signed char" \
- "(const signed char)"
+ "cast to const signed char"
gdb_test "whatis (const unsigned char) v_unsigned_char" \
"type = const (unsigned char|char)" \
- "(const unsigned char)"
+ "cast to const unsigned char"
gdb_test "whatis (const short) v_short" \
"type = const (short|short int)" \
- "(const short)"
+ "cast to const short"
gdb_test "whatis (const signed short) v_signed_short" \
"type = const (short|short int|signed short|signed short int)" \
- "(const signed short)"
+ "cast to const signed short"
gdb_test "whatis (const unsigned short) v_unsigned_short" \
"type = const (unsigned short|short unsigned int)" \
- "(const unsigned short)"
+ "cast to const unsigned short"
gdb_test "whatis (const int) v_int" \
"type = const int" \
- "(const int)"
+ "cast to const int"
gdb_test "whatis (const signed int) v_signed_int" \
"type = const (signed int|int)" \
- "(const signed int)"
+ "cast to const signed int"
gdb_test "whatis (const unsigned int) v_unsigned_int" \
"type = const unsigned int" \
- "(const unsigned int)"
+ "cast to const unsigned int"
gdb_test "whatis (const long) v_long" \
"type = const (long|long int)" \
- "(const long)"
+ "cast to const long"
gdb_test "whatis (const signed long) v_signed_long" \
"type = const (signed |)long( int|)" \
- "(const signed long)"
+ "cast to const signed long"
gdb_test "whatis (const unsigned long) v_unsigned_long" \
"type = const (unsigned long|long unsigned int)" \
- "(const unsigned long)"
+ "cast to const unsigned long"
gdb_test "whatis (const long long) v_long_long" \
"type = const long long( int|)" \
- "(const long long)"
+ "cast to const long long"
gdb_test "whatis (const signed long long) v_signed_long_long" \
"type = const (signed |)long long( int|)" \
- "(const signed long long)"
+ "cast to const signed long long"
gdb_test "whatis (const unsigned long long) v_unsigned_long_long" \
"type = const (unsigned long long|long long unsigned int)" \
- "(const unsigned long long)"
+ "cast to const unsigned long long"
gdb_test "whatis (const float) v_float" \
"type = const float" \
- "(const float)"
+ "cast to const float"
gdb_test "whatis (const double) v_double" \
"type = const double" \
- "(const double)"
+ "cast to const double"
#
# Test casting a scalar to volatile
@@ -103,55 +103,55 @@ proc do_test {dir options} {
gdb_test "whatis (volatile char) v_char" \
"type = volatile char" \
- "(volatile char)"
+ "cast to volatile char"
gdb_test "whatis (volatile signed char) v_signed_char" \
"type = volatile signed char" \
- "(volatile signed char)"
+ "cast to volatile signed char"
gdb_test "whatis (volatile unsigned char) v_unsigned_char" \
"type = volatile (unsigned char|char)" \
- "(volatile unsigned char)"
+ "cast to volatile unsigned char"
gdb_test "whatis (volatile short) v_short" \
"type = volatile (short|short int)" \
- "(volatile short)"
+ "cast to volatile short"
gdb_test "whatis (volatile signed short) v_signed_short" \
"type = volatile (short|short int|signed short|signed short int)" \
- "(volatile signed short)"
+ "cast to volatile signed short"
gdb_test "whatis (volatile unsigned short) v_unsigned_short" \
"type = volatile (unsigned short|short unsigned int)" \
- "(volatile unsigned short)"
+ "cast to volatile unsigned short"
gdb_test "whatis (volatile int) v_int" \
"type = volatile int" \
- "(volatile int)"
+ "cast to volatile int"
gdb_test "whatis (volatile signed int) v_signed_int" \
"type = volatile (signed int|int)" \
- "(volatile signed int)"
+ "cast to volatile signed int"
gdb_test "whatis (volatile unsigned int) v_unsigned_int" \
"type = volatile unsigned int" \
- "(volatile unsigned int)"
+ "cast to volatile unsigned int"
gdb_test "whatis (volatile long) v_long" \
"type = volatile (long|long int)" \
- "(volatile long)"
+ "cast to volatile long"
gdb_test "whatis (volatile signed long) v_signed_long" \
"type = volatile (signed |)long( int|)" \
- "(volatile signed long)"
+ "cast to volatile signed long"
gdb_test "whatis (volatile unsigned long) v_unsigned_long" \
"type = volatile (unsigned long|long unsigned int)" \
- "(volatile unsigned long)"
+ "cast to volatile unsigned long"
gdb_test "whatis (volatile long long) v_long_long" \
"type = volatile long long( int|)" \
- "(volatile long long)"
+ "cast to volatile long long"
gdb_test "whatis (volatile signed long long) v_signed_long_long" \
"type = volatile (signed |)long long( int|)" \
- "(volatile signed long long)"
+ "cast to volatile signed long long"
gdb_test "whatis (volatile unsigned long long) v_unsigned_long_long" \
"type = volatile (unsigned long long|long long unsigned int)" \
- "(volatile unsigned long long)"
+ "cast to volatile unsigned long long"
gdb_test "whatis (volatile float) v_float" \
"type = volatile float" \
- "(volatile float)"
+ "cast to volatile float"
gdb_test "whatis (volatile double) v_double" \
"type = volatile double" \
- "(volatile double)"
+ "cast to volatile double"
#
# Combine const and volatile
@@ -159,47 +159,47 @@ proc do_test {dir options} {
gdb_test "whatis (const volatile int) v_int" \
"type = const volatile int" \
- "(const volatile int)"
+ "cast to const volatile int"
gdb_test "whatis (volatile const int) v_int" \
"type = const volatile int" \
- "(volatile const int)"
+ "cast to volatile const int"
gdb_test "whatis (const int volatile) v_int" \
"type = const volatile int" \
- "(const int volatile)"
+ "cast to const int volatile"
gdb_test "whatis (volatile int const) v_int" \
"type = const volatile int" \
- "(volatile int const)"
+ "cast to volatile int const"
gdb_test "whatis (int const volatile) v_int" \
"type = const volatile int" \
- "(int const volatile)"
+ "cast to int const volatile"
gdb_test "whatis (int volatile const) v_int" \
"type = const volatile int" \
- "(int volatile const)"
+ "cast to int volatile const"
gdb_test "whatis (const volatile int *) v_int_pointer" \
"type = const volatile int${ws}\\*" \
- "(const volatile int *)"
+ "cast to const volatile int *"
gdb_test "whatis (volatile const int *) v_int_pointer" \
"type = const volatile int${ws}\\*" \
- "(volatile const int *)"
+ "cast to volatile const int *"
gdb_test "whatis (const int volatile *) v_int_pointer" \
"type = const volatile int${ws}\\*" \
- "(const int volatile *)"
+ "cast to const int volatile *"
gdb_test "whatis (volatile int const *) v_int_pointer" \
"type = const volatile int${ws}\\*" \
- "(volatile int const *)"
+ "cast to volatile int const *"
gdb_test "whatis (int const volatile *) v_int_pointer" \
"type = const volatile int${ws}\\*" \
- "(int const volatile *)"
+ "cast to int const volatile *"
gdb_test "whatis (int volatile const *) v_int_pointer" \
"type = const volatile int${ws}\\*" \
- "(int volatile const *)"
+ "cast to int volatile const *"
gdb_test "whatis (int * const volatile) v_int_pointer" \
"type = int${ws}\\*${ws}const volatile" \
- "(int * const volatile)"
+ "cast to int * const volatile"
gdb_test "whatis (int * volatile const) v_int_pointer" \
"type = int${ws}\\*${ws}const volatile" \
- "(int * volatile const)"
+ "cast to int * volatile const"
#
@@ -208,65 +208,65 @@ proc do_test {dir options} {
#gdb_test "whatis (signed const char) v_signed_char" \
# "type = const char" \
- # "(signed const char)"
+ # "cast to signed const char"
#gdb_test "whatis (unsigned const char) v_unsigned_char" \
# "type = const (unsigned char|char)" \
- # "(unsigned const char)"
+ # "cast to unsigned const char"
#gdb_test "whatis (signed const short) v_signed_short" \
# "type = const (short|short int|signed short|signed short int)" \
- # "(signed const short)"
+ # "cast to signed const short"
#gdb_test "whatis (unsigned const short) v_unsigned_short" \
# "type = const (unsigned short|short unsigned int)" \
- # "(unsigned const short)"
+ # "cast to unsigned const short"
#gdb_test "whatis (signed const int) v_signed_int" \
# "type = const (signed int|int)" \
- # "(signed const int)"
+ # "cast to signed const int"
#gdb_test "whatis (unsigned const int) v_unsigned_int" \
# "type = const unsigned int" \
- # "(unsigned const int)"
+ # "cast to unsigned const int"
#gdb_test "whatis (signed const long) v_signed_long" \
# "type = const (signed |)long( int|)" \
- # "(signed const long)"
+ # "cast to signed const long"
#gdb_test "whatis (unsigned const long) v_unsigned_long" \
# "type = const (unsigned long|long unsigned int)" \
- # "(unsigned const long)"
+ # "cast to unsigned const long"
#gdb_test "whatis (signed const long long) v_signed_long_long" \
# "type = const (signed |)long long( int|)" \
- # "(signed const long long)"
+ # "cast to signed const long long"
#gdb_test "whatis (unsigned const long long) v_unsigned_long_long" \
# "type = const (unsigned long long|long long unsigned int)" \
- # "(const unsigned long long)"
+ # "cast to const unsigned long long"
#gdb_test "whatis (signed volatile char) v_signed_char" \
# "type = volatile char" \
- # "(signed volatile char)"
+ # "cast to signed volatile char"
#gdb_test "whatis (unsigned volatile char) v_unsigned_char" \
# "type = volatile (unsigned char|char)" \
- # "(unsigned volatile char)"
+ # "cast to unsigned volatile char"
#gdb_test "whatis (signed volatile short) v_signed_short" \
# "type = volatile (short|short int|signed short|signed short int)" \
- # "(signed volatile short)"
+ # "cast to signed volatile short"
#gdb_test "whatis (unsigned volatile short) v_unsigned_short" \
# "type = volatile (unsigned short|short unsigned int)" \
- # "(unsigned volatile short)"
+ # "cast to unsigned volatile short"
#gdb_test "whatis (signed volatile int) v_signed_int" \
# "type = volatile (signed int|int)" \
- # "(signed volatile int)"
+ # "cast to signed volatile int"
#gdb_test "whatis (unsigned volatile int) v_unsigned_int" \
# "type = volatile unsigned int" \
- # "(unsigned volatile int)"
+ # "cast to unsigned volatile int"
#gdb_test "whatis (signed volatile long) v_signed_long" \
# "type = volatile (signed |)long( int|)" \
- # "(signed volatile long)"
+ # "cast to signed volatile long"
#gdb_test "whatis (unsigned volatile long) v_unsigned_long" \
# "type = volatile (unsigned long|long unsigned int)" \
- # "(unsigned volatile long)"
+ # "cast to unsigned volatile long"
#gdb_test "whatis (signed volatile long long) v_signed_long_long" \
# "type = volatile (signed |)long long( int|)" \
- # "(signed volatile long long)"
+ # "cast to signed volatile long long"
#gdb_test "whatis (unsigned volatile long long) v_unsigned_long_long" \
# "type = volatile (unsigned long long|long long unsigned int)" \
- # "(unsigned volatile long long)"
+ # "cast to unsigned volatile long long"
#
# Now put the 'const' and 'volatile' keywords after the base type.
@@ -274,107 +274,107 @@ proc do_test {dir options} {
gdb_test "whatis (char const) v_char" \
"type = const char" \
- "(char const)"
+ "cast to char const"
gdb_test "whatis (signed char const) v_signed_char" \
"type = const signed char" \
- "(signed char const)"
+ "cast to signed char const"
gdb_test "whatis (unsigned char const) v_unsigned_char" \
"type = const (unsigned char|char)" \
- "(unsigned char const)"
+ "cast to unsigned char const"
gdb_test "whatis (short const) v_short" \
"type = const (short|short int)" \
- "(short const)"
+ "cast to short const"
gdb_test "whatis (signed short const) v_signed_short" \
"type = const (short|short int|signed short|signed short int)" \
- "(signed short const)"
+ "cast to signed short const"
gdb_test "whatis (unsigned short const) v_unsigned_short" \
"type = const (unsigned short|short unsigned int)" \
- "(unsigned short const)"
+ "cast to unsigned short const"
gdb_test "whatis (int const) v_int" \
"type = const int" \
- "(int const)"
+ "cast to int const"
gdb_test "whatis (signed int const) v_signed_int" \
"type = const (signed int|int)" \
- "(signed int const)"
+ "cast to signed int const"
gdb_test "whatis (unsigned int const) v_unsigned_int" \
"type = const unsigned int" \
- "(unsigned int const)"
+ "cast to unsigned int const"
gdb_test "whatis (long const) v_long" \
"type = const (long|long int)" \
- "(long const)"
+ "cast to long const"
gdb_test "whatis (signed long const) v_signed_long" \
"type = const (signed |)long( int|)" \
- "(signed long const)"
+ "cast to signed long const"
gdb_test "whatis (unsigned long const) v_unsigned_long" \
"type = const (unsigned long|long unsigned int)" \
- "(unsigned long const)"
+ "cast to unsigned long const"
gdb_test "whatis (long long const) v_long_long" \
"type = const long long( int|)" \
- "(long long const)"
+ "cast to long long const"
gdb_test "whatis (signed long long const) v_signed_long_long" \
"type = const (signed |)long long( int|)" \
- "(signed long long const)"
+ "cast to signed long long const"
gdb_test "whatis (unsigned long long const) v_unsigned_long_long" \
"type = const (unsigned long long|long long unsigned int)" \
- "(unsigned long long const)"
+ "cast to unsigned long long const"
gdb_test "whatis (float const) v_float" \
"type = const float" \
- "(float const)"
+ "cast to float const"
gdb_test "whatis (double const) v_double" \
"type = const double" \
- "(double const)"
+ "cast to double const"
gdb_test "whatis (char volatile) v_char" \
"type = volatile char" \
- "(char volatile)"
+ "cast to char volatile"
gdb_test "whatis (signed char volatile) v_signed_char" \
"type = volatile signed char" \
- "(signed char volatile)"
+ "cast to signed char volatile"
gdb_test "whatis (unsigned char volatile) v_unsigned_char" \
"type = volatile (unsigned char|char)" \
- "(unsigned char volatile)"
+ "cast to unsigned char volatile"
gdb_test "whatis (short volatile) v_short" \
"type = volatile (short|short int)" \
- "(short volatile)"
+ "cast to short volatile"
gdb_test "whatis (signed short volatile) v_signed_short" \
"type = volatile (short|short int|signed short|signed short int)" \
- "(signed short volatile)"
+ "cast to signed short volatile"
gdb_test "whatis (unsigned short volatile) v_unsigned_short" \
"type = volatile (unsigned short|short unsigned int)" \
- "(unsigned short volatile)"
+ "cast to unsigned short volatile"
gdb_test "whatis (int volatile) v_int" \
"type = volatile int" \
- "(int volatile)"
+ "cast to int volatile"
gdb_test "whatis (signed int volatile) v_signed_int" \
"type = volatile (signed int|int)" \
- "(signed int volatile)"
+ "cast to signed int volatile"
gdb_test "whatis (unsigned int volatile) v_unsigned_int" \
"type = volatile unsigned int" \
- "(unsigned int volatile)"
+ "cast to unsigned int volatile"
gdb_test "whatis (long volatile) v_long" \
"type = volatile (long|long int)" \
- "(long volatile)"
+ "cast to long volatile"
gdb_test "whatis (signed long volatile) v_signed_long" \
"type = volatile (signed |)long( int|)" \
- "(signed long volatile)"
+ "cast to signed long volatile"
gdb_test "whatis (unsigned long volatile) v_unsigned_long" \
"type = volatile (unsigned long|long unsigned int)" \
- "(unsigned long volatile)"
+ "cast to unsigned long volatile"
gdb_test "whatis (long long volatile) v_long_long" \
"type = volatile long long( int|)" \
- "(long long volatile)"
+ "cast to long long volatile"
gdb_test "whatis (signed long long volatile) v_signed_long_long" \
"type = volatile (signed |)long long( int|)" \
- "(signed long long volatile)"
+ "cast to signed long long volatile"
gdb_test "whatis (unsigned long long volatile) v_unsigned_long_long" \
"type = volatile (unsigned long long|long long unsigned int)" \
- "(unsigned long long volatile)"
+ "cast to unsigned long long volatile"
gdb_test "whatis (float volatile) v_float" \
"type = volatile float" \
- "(float volatile)"
+ "cast to float volatile"
gdb_test "whatis (double volatile) v_double" \
"type = volatile double" \
- "(double volatile)"
+ "cast to double volatile"
#
# enums
@@ -382,16 +382,16 @@ proc do_test {dir options} {
gdb_test "whatis (const enum misordered) v_misordered" \
"type = const enum misordered" \
- "(const enum misordered)"
+ "cast to const enum misordered"
gdb_test "whatis (enum misordered const) v_misordered" \
"type = const enum misordered" \
- "(enum misordered const)"
+ "cast to enum misordered const"
gdb_test "whatis (volatile enum misordered) v_misordered" \
"type = volatile enum misordered" \
- "(volatile enum misordered)"
+ "cast to volatile enum misordered"
gdb_test "whatis (enum misordered volatile) v_misordered" \
"type = volatile enum misordered" \
- "(enum misordered volatile)"
+ "cast to enum misordered volatile"
#
# Pointers
@@ -399,41 +399,41 @@ proc do_test {dir options} {
gdb_test "whatis (const int *) v_int_pointer" \
"type = const int${ws}\\*" \
- "(const int *)"
+ "cast to const int *"
gdb_test "whatis (int const *) v_int_pointer" \
"type = const int${ws}\\*" \
- "(int const *)"
+ "cast to int const *"
gdb_test "whatis (int * const) v_int_pointer" \
"type = int \\*${ws}const" \
- "(int * const)"
+ "cast to int * const"
gdb_test "whatis (const int * const) v_int_pointer" \
"type = const int${ws}\\*${ws}const" \
- "(const int * const)"
+ "cast to const int * const"
gdb_test "whatis (int const * const) v_int_pointer" \
"type = const int${ws}\\*${ws}const" \
- "(int const * const)"
+ "cast to int const * const"
gdb_test "whatis (const int **) v_int_pointer_pointer" \
"type = const int${ws}\\*${ws}\\*" \
- "(const int **)"
+ "cast to const int **"
gdb_test "whatis (int const **) v_int_pointer_pointer" \
"type = const int${ws}\\*${ws}\\*" \
- "(int const **)"
+ "cast to int const **"
gdb_test "whatis (int ** const) v_int_pointer_pointer" \
"type = int \\*${ws}\\*${ws}const" \
- "(int ** const)"
+ "cast to int ** const"
gdb_test "whatis (const int * const *) v_int_pointer_pointer" \
"type = const int${ws}\\*${ws}const${ws}\\*" \
- "(const int * const *)"
+ "cast to const int * const *"
gdb_test "whatis (int const * const *) v_int_pointer_pointer" \
"type = const int${ws}\\*${ws}const${ws}\\*" \
- "(int const * const *)"
+ "cast to int const * const *"
gdb_test "whatis (const int * const * const) v_int_pointer_pointer" \
"type = const int${ws}\\*${ws}const${ws}\\*${ws}const" \
- "(const int * const * const)"
+ "cast to const int * const * const"
gdb_test "whatis (int const * const * const) v_int_pointer_pointer" \
"type = const int${ws}\\*${ws}const${ws}\\*${ws}const" \
- "(int const * const * const)"
+ "cast to int const * const * const"
#
# Arrays TODO
@@ -449,46 +449,46 @@ proc do_test {dir options} {
gdb_test "whatis (const struct t_struct) v_struct1" \
"type = const struct t_struct" \
- "(const struct t_struct)"
+ "cast to const struct t_struct"
gdb_test "whatis (const union t_union) v_union" \
"type = const union t_union" \
- "(const union t_union)"
+ "cast to const union t_union"
gdb_test "whatis (struct t_struct const) v_struct1" \
"type = const struct t_struct" \
- "(struct t_struct const)"
+ "cast to struct t_struct const"
gdb_test "whatis (union t_union const) v_union" \
"type = const union t_union" \
- "(union t_union const)"
+ "cast to union t_union const"
gdb_test "whatis (const struct t_struct *) &v_struct1" \
"type = const struct t_struct${ws}\\*" \
- "(const struct t_struct *)"
+ "cast to const struct t_struct *"
gdb_test "whatis (const union t_union *) &v_union" \
"type = const union t_union${ws}\\*" \
- "(const union t_union *)"
+ "cast to const union t_union *"
gdb_test "whatis (struct t_struct const *) &v_struct1" \
"type = const struct t_struct${ws}\\*" \
- "(struct t_struct const *)"
+ "cast to struct t_struct const *"
gdb_test "whatis (union t_union const *) &v_union" \
"type = const union t_union${ws}\\*" \
- "(union t_union const *)"
+ "cast to union t_union const *"
gdb_test "whatis (struct t_struct * const) &v_struct1" \
"type = struct t_struct${ws}\\*${ws}const" \
- "(struct t_struct * const)"
+ "cast to struct t_struct * const"
gdb_test "whatis (union t_union * const) &v_union" \
"type = union t_union${ws}\\*${ws}const" \
- "(union t_union * const)"
+ "cast to union t_union * const"
gdb_test "whatis (const struct t_struct * const) &v_struct1" \
"type = const struct t_struct${ws}\\*${ws}const" \
- "(const struct t_struct * const)"
+ "cast to const struct t_struct * const"
gdb_test "whatis (const union t_union * const) &v_union" \
"type = const union t_union${ws}\\*${ws}const" \
- "(const union t_union * const)"
+ "cast to const union t_union * const"
gdb_test "whatis (struct t_struct const * const) &v_struct1" \
"type = const struct t_struct${ws}\\*${ws}const" \
- "(struct t_struct const * const)"
+ "cast to struct t_struct const * const"
gdb_test "whatis (union t_union const * const) &v_union" \
"type = const union t_union${ws}\\*${ws}const" \
- "(union t_union const * const)"
+ "cast to union t_union const * const"
#
# Function pointers TODO
diff --git a/gdb/testsuite/gdb.base/eval-skip.exp b/gdb/testsuite/gdb.base/eval-skip.exp
index 7b28513..e8f766e 100644
--- a/gdb/testsuite/gdb.base/eval-skip.exp
+++ b/gdb/testsuite/gdb.base/eval-skip.exp
@@ -54,86 +54,63 @@ gdb_test_no_output "set variable y=2" "set variable y=2"
gdb_test_no_output "set variable z=2" "set variable z=2"
gdb_test_no_output "set variable w=3" "set variable w=3"
-gdb_test "print (0 && (x+y))" ".$decimal = $false" \
- "print value of (0 && (x+y))"
+proc test { val re } {
+ gdb_test "print $val" $re "print value of $val value"
+}
+
+test "(0 && (x+y))" ".$decimal = $false"
-gdb_test "print (0 && (x-y))" ".$decimal = $false" \
- "print value of (0 && (x-y))"
+test "(0 && (x-y))" ".$decimal = $false"
-gdb_test "print (0 && (x*y))" ".$decimal = $false" \
- "print value of (0 && (x*y))"
+test "(0 && (x*y))" ".$decimal = $false"
-gdb_test "print (0 && (x/y))" ".$decimal = $false" \
- "print value of (0 && (x/y))"
+test "(0 && (x/y))" ".$decimal = $false"
-gdb_test "print (0 && (x%y))" ".$decimal = $false" \
- "print value of (0 && (x%y))"
+test "(0 && (x%y))" ".$decimal = $false"
-gdb_test "print (0 && (x&&y))" ".$decimal = $false" \
- "print value of (0 && (x&&y))"
+test "(0 && (x&&y))" ".$decimal = $false"
-gdb_test "print (0 && (x||y))" ".$decimal = $false" \
- "print value of (0 && (x||y))"
+test "(0 && (x||y))" ".$decimal = $false"
-gdb_test "print (0 && (x&y))" ".$decimal = $false" \
- "print value of (0 && (x&y))"
+test "(0 && (x&y))" ".$decimal = $false"
-gdb_test "print (0 && (x|y))" ".$decimal = $false" \
- "print value of (0 && (x|y))"
+test "(0 && (x|y))" ".$decimal = $false"
-gdb_test "print (0 && (x^y))" ".$decimal = $false" \
- "print value of (0 && (x^y))"
+test "(0 && (x^y))" ".$decimal = $false"
-gdb_test "print (0 && (x < y))" ".$decimal = $false" \
- "print value of (0 && (x < y))"
+test "(0 && (x < y))" ".$decimal = $false"
-gdb_test "print (0 && (x <= y))" ".$decimal = $false" \
- "print value of (0 && (x <= y))"
+test "(0 && (x <= y))" ".$decimal = $false"
-gdb_test "print (0 && (x>y))" ".$decimal = $false" \
- "print value of (0 && (x>y))"
+test "(0 && (x>y))" ".$decimal = $false"
-gdb_test "print (0 && (x>=y))" ".$decimal = $false" \
- "print value of (0 && (x>=y))"
+test "(0 && (x>=y))" ".$decimal = $false"
-gdb_test "print (0 && (x==y))" ".$decimal = $false" \
- "print value of (0 && (x==y))"
+test "(0 && (x==y))" ".$decimal = $false"
-gdb_test "print (0 && (x!=y))" ".$decimal = $false" \
- "print value of (0 && (x!=y))"
+test "(0 && (x!=y))" ".$decimal = $false"
-gdb_test "print (0 && (x<<31))" ".$decimal = $false" \
- "print value of (0 && (x<<31))"
+test "(0 && (x<<31))" ".$decimal = $false"
-gdb_test "print (0 && (x>>31))" ".$decimal = $false" \
- "print value of (0 && (x>>31))"
+test "(0 && (x>>31))" ".$decimal = $false"
-gdb_test "print (0 && (!x))" ".$decimal = $false" \
- "print value of (0 && (!x))"
+test "(0 && (!x))" ".$decimal = $false"
-gdb_test "print (0 && (~x))" ".$decimal = $false" \
- "print value of (0 && (~x))"
+test "(0 && (~x))" ".$decimal = $false"
-gdb_test "print (0 && (-x))" ".$decimal = $false" \
- "print value of (0 && (-x))"
+test "(0 && (-x))" ".$decimal = $false"
-gdb_test "print (0 && (x++))" ".$decimal = $false" \
- "print value of (0 && (x++))"
+test "(0 && (x++))" ".$decimal = $false"
-gdb_test "print (0 && (++x))" ".$decimal = $false" \
- "print value of (0 && (++x))"
+test "(0 && (++x))" ".$decimal = $false"
-gdb_test "print (0 && (x--))" ".$decimal = $false" \
- "print value of (0 && (x--))"
+test "(0 && (x--))" ".$decimal = $false"
-gdb_test "print (0 && (--x))" ".$decimal = $false" \
- "print value of (0 && (--x))"
+test "(0 && (--x))" ".$decimal = $false"
-gdb_test "print (0 && (x+=7))" ".$decimal = $false" \
- "print value of (0 && (x+=7))"
+test "(0 && (x+=7))" ".$decimal = $false"
-gdb_test "print (0 && (x=y))" ".$decimal = $false" \
- "print value of (0 && (x=y))"
+test "(0 && (x=y))" ".$decimal = $false"
gdb_exit
diff --git a/gdb/testsuite/gdb.base/examine-backward.exp b/gdb/testsuite/gdb.base/examine-backward.exp
index dcb1371..fe3d13e 100644
--- a/gdb/testsuite/gdb.base/examine-backward.exp
+++ b/gdb/testsuite/gdb.base/examine-backward.exp
@@ -172,17 +172,17 @@ with_test_prefix "char-width=1, print-max=20" {
}
gdb_test "x/-xb" "0x39" "take 1 char backward again"
gdb_test "x/-s" "\"01234567890123456789\"\.\.\." \
- "take 1 string backward (1/6)"
+ "take 1 string backward, 1/6"
gdb_test "x/-s" "\".+\"" \
- "take 1 string backward (2/6)"
+ "take 1 string backward, 2/6"
gdb_test "x/-s" "\"\"" \
- "take 1 string backward (3/6)"
+ "take 1 string backward, 3/6"
gdb_test "x/-s" "\"\"" \
- "take 1 string backward (4/6)"
+ "take 1 string backward, 4/6"
gdb_test "x/-s" "\"GHIJKLMNOPQRSTUVWXYZ\"" \
- "take 1 string backward (5/6)"
+ "take 1 string backward, 5/6"
gdb_test "x/-s" "\"ABCDEFGHIJKLMNOPQRST\"\.\.\." \
- "take 1 string backward (6/6)"
+ "take 1 string backward, 6/6"
}
with_test_prefix "char-width=2, print-max=20" {
@@ -214,17 +214,17 @@ with_test_prefix "char-width=2, print-max=20" {
}
gdb_test "x/-xh" "0x0039" "take 1 char backward again"
gdb_test "x/-sh" "u\"01234567890123456789\"\.\.\." \
- "take 1 string backward (1/6)"
+ "take 1 string backward, 1/6"
gdb_test "x/-sh" "u\".+\"" \
- "take 1 string backward (2/6)"
+ "take 1 string backward, 2/6"
gdb_test "x/-sh" "u\"\"" \
- "take 1 string backward (3/6)"
+ "take 1 string backward, 3/6"
gdb_test "x/-sh" "u\"\"" \
- "take 1 string backward (4/6)"
+ "take 1 string backward, 4/6"
gdb_test "x/-sh" "u\"GHIJKLMNOPQRSTUVWXYZ\"" \
- "take 1 string backward (5/6)"
+ "take 1 string backward, 5/6"
gdb_test "x/-sh" "u\"ABCDEFGHIJKLMNOPQRST\"\.\.\." \
- "take 1 string backward (6/6)"
+ "take 1 string backward, 6/6"
}
with_test_prefix "char-width=4, print-max=20" {
@@ -256,17 +256,17 @@ with_test_prefix "char-width=4, print-max=20" {
}
gdb_test "x/-xw" "0x00000039" "take 1 char backward again"
gdb_test "x/-sw" "U\"01234567890123456789\"\.\.\." \
- "take 1 string backward (1/6)"
+ "take 1 string backward, 1/6"
gdb_test "x/-sw" "U\".+\"" \
- "take 1 string backward (2/6)"
+ "take 1 string backward, 2/6"
gdb_test "x/-sw" "U\"\"" \
- "take 1 string backward (3/6)"
+ "take 1 string backward, 3/6"
gdb_test "x/-sw" "U\"\"" \
- "take 1 string backward (4/6)"
+ "take 1 string backward, 4/6"
gdb_test "x/-sw" "U\"GHIJKLMNOPQRSTUVWXYZ\"" \
- "take 1 string backward (5/6)"
+ "take 1 string backward, 5/6"
gdb_test "x/-sw" "U\"ABCDEFGHIJKLMNOPQRST\"\.\.\." \
- "take 1 string backward (6/6)"
+ "take 1 string backward, 6/6"
}
with_test_prefix "char-width=2, print-max=0" {
@@ -299,17 +299,17 @@ with_test_prefix "char-width=2, print-max=0" {
}
gdb_test "x/-xh" "0x0000" "take 1 char backward"
gdb_test "x/-sh" "u\"!!!!!!\"" \
- "take 1 string backward (1/6)"
+ "take 1 string backward, 1/6"
gdb_test "x/-sh" "u\"012345678901234567890123456789\"" \
- "take 1 string backward (2/6)"
+ "take 1 string backward, 2/6"
gdb_test "x/-sh" "u\".+\"" \
- "take 1 string backward (3/6)"
+ "take 1 string backward, 3/6"
gdb_test "x/-sh" "u\"\"" \
- "take 1 string backward (4/6)"
+ "take 1 string backward, 4/6"
gdb_test "x/-sh" "u\"\"" \
- "take 1 string backward (5/6)"
+ "take 1 string backward, 5/6"
gdb_test "x/-sh" "u\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"" \
- "take 1 string backward (6/6)"
+ "take 1 string backward, 6/6"
}
with_test_prefix "char-width=1, print-max=4" {
@@ -326,13 +326,13 @@ with_test_prefix "char-width=1, print-max=4" {
"\"\""
}
gdb_test "x/-xb" "0x00" "take 1 byte backward"
- gdb_test_sequence "x/-4s" "take 4 strings backward (1/2)" {
+ gdb_test_sequence "x/-4s" "take 4 strings backward, 1/2" {
"\"TUVW\"\.\.\."
"\"XYZ\""
"\"\""
"\"\""
}
- gdb_test_sequence "x/-4s" "take 4 strings backward (2/2)" {
+ gdb_test_sequence "x/-4s" "take 4 strings backward, 2/2" {
"\"CDEF\"\.\.\."
"\"GHIJ\"\.\.\."
"\"KLMN\"\.\.\."
@@ -348,9 +348,9 @@ with_test_prefix "backward disassemble general" {
set main_re "main(\\(\\))?"
gdb_test "x/i main" "0x\[0-9a-fA-F\]+ <$main_re>:\t.*" \
- "move the current position to main (x/i)"
+ "move the current position to main, x/i"
gdb_test "x/-i" "0x\[0-9a-fA-F\]+ <$main_re>:\t.*" \
- "move the current position to main (x/-i)"
+ "move the current position to main, x/-i"
for {set i 0} {$i < [llength $length_to_examine]} {incr i} {
set len [lindex $length_to_examine $i]
set instructions [capture_command_output "x/${len}i" ""]
diff --git a/gdb/testsuite/gdb.base/exprs.exp b/gdb/testsuite/gdb.base/exprs.exp
index 0f8c53b..375af6b 100644
--- a/gdb/testsuite/gdb.base/exprs.exp
+++ b/gdb/testsuite/gdb.base/exprs.exp
@@ -46,9 +46,9 @@ proc test_expr { args } {
}
set last_ent [expr [llength $args] - 1]
set testname [lindex $args $last_ent]
- gdb_test [lindex $args 0] ".*" "$testname (setup)"
+ gdb_test [lindex $args 0] ".*" "$testname, setup"
for {set x 1} {$x < $last_ent} {set x [expr $x + 2]} {
- gdb_test [lindex $args $x] [lindex $args [expr $x + 1]] "$testname ([lindex $args $x])"
+ gdb_test [lindex $args $x] [lindex $args [expr $x + 1]] "$testname, [lindex $args $x]"
}
}
#
diff --git a/gdb/testsuite/gdb.base/fileio.exp b/gdb/testsuite/gdb.base/fileio.exp
index 4b01248..f31a775 100644
--- a/gdb/testsuite/gdb.base/fileio.exp
+++ b/gdb/testsuite/gdb.base/fileio.exp
@@ -149,23 +149,23 @@ gdb_test continue \
gdb_test continue \
"Continuing\\..*isatty 1:.*OK$stop_msg" \
-"Isatty (stdin)"
+"Isatty, stdin"
gdb_test continue \
"Continuing\\..*isatty 2:.*OK$stop_msg" \
-"Isatty (stdout)"
+"Isatty, stdout"
gdb_test continue \
"Continuing\\..*isatty 3:.*OK$stop_msg" \
-"Isatty (stderr)"
+"Isatty, stderr"
gdb_test continue \
"Continuing\\..*isatty 4:.*OK$stop_msg" \
-"Isatty (invalid fd)"
+"Isatty, invalid fd"
gdb_test continue \
"Continuing\\..*isatty 5:.*OK$stop_msg" \
-"Isatty (open file)"
+"Isatty, open file"
gdb_test_no_output "set debug remote 1"
set msg "System says shell is not available"
diff --git a/gdb/testsuite/gdb.base/foll-exec.exp b/gdb/testsuite/gdb.base/foll-exec.exp
index e162cdf..206e713 100644
--- a/gdb/testsuite/gdb.base/foll-exec.exp
+++ b/gdb/testsuite/gdb.base/foll-exec.exp
@@ -139,23 +139,23 @@ proc do_exec_tests {} {
send_gdb "print global_i\n"
gdb_expect {
-re ".* = 0.*$gdb_prompt $"\
- {pass "print execd-program/global_i (after execlp)"}
- -re "$gdb_prompt $" {fail "print execd-program/global_i (after execlp)"}
- timeout {fail "(timeout) print execd-program/global_i (after execlp)"}
+ {pass "print execd-program/global_i, after execlp"}
+ -re "$gdb_prompt $" {fail "print execd-program/global_i, after execlp"}
+ timeout {fail "(timeout) print execd-program/global_i, after execlp"}
}
send_gdb "print local_j\n"
gdb_expect {
-re ".* = 2.*$gdb_prompt $"\
- {pass "print execd-program/local_j (after execlp)"}
- -re "$gdb_prompt $" {fail "print execd-program/local_j (after execlp)"}
- timeout {fail "(timeout) print execd-program/local_j (after execlp)"}
+ {pass "print execd-program/local_j, after execlp"}
+ -re "$gdb_prompt $" {fail "print execd-program/local_j, after execlp"}
+ timeout {fail "(timeout) print execd-program/local_j, after execlp"}
}
send_gdb "print local_k\n"
gdb_expect {
-re "No symbol \"local_k\" in current context.*$gdb_prompt $"\
- {pass "print follow-exec/local_k (after execlp)"}
- -re "$gdb_prompt $" {fail "print follow-exec/local_k (after execlp)"}
- timeout {fail "(timeout) print follow-exec/local_k (after execlp)"}
+ {pass "print follow-exec/local_k, after execlp"}
+ -re "$gdb_prompt $" {fail "print follow-exec/local_k, after execlp"}
+ timeout {fail "(timeout) print follow-exec/local_k, after execlp"}
}
# Explicitly kill this program, or a subsequent rerun actually runs
@@ -288,9 +288,9 @@ proc do_exec_tests {} {
send_gdb "print local_j\n"
gdb_expect {
-re ".* = 3.*$gdb_prompt $"\
- {pass "print execd-program/local_j (after execl)"}
- -re "$gdb_prompt $" {fail "print execd-program/local_j (after execl)"}
- timeout {fail "(timeout) print execd-program/local_j (after execl)"}
+ {pass "print execd-program/local_j, after execl"}
+ -re "$gdb_prompt $" {fail "print execd-program/local_j, after execl"}
+ timeout {fail "(timeout) print execd-program/local_j, after execl"}
}
# Explicitly kill this program, or a subsequent rerun actually runs
@@ -349,9 +349,9 @@ proc do_exec_tests {} {
send_gdb "print local_j\n"
gdb_expect {
-re ".* = 2.*$gdb_prompt $"\
- {pass "print execd-program/local_j (after execv)"}
- -re "$gdb_prompt $" {fail "print execd-program/local_j (after execv)"}
- timeout {fail "(timeout) print execd-program/local_j (after execv)"}
+ {pass "print execd-program/local_j, after execv"}
+ -re "$gdb_prompt $" {fail "print execd-program/local_j, after execv"}
+ timeout {fail "(timeout) print execd-program/local_j, after execv"}
}
# Explicitly kill this program, or a subsequent rerun actually runs
diff --git a/gdb/testsuite/gdb.base/gcorebg.c b/gdb/testsuite/gdb.base/gcorebg.c
new file mode 100644
index 0000000..9b585b5
--- /dev/null
+++ b/gdb/testsuite/gdb.base/gcorebg.c
@@ -0,0 +1,76 @@
+/* Copyright 2007-2024 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <sys/wait.h>
+#include <errno.h>
+
+/* Expects 4 arguments:
+
+ 1. Either 'standard' or 'detached', where 'standard' tests
+ a general gcore script spawn with its controlling terminal available
+ and 'detached' tests gcore script spawn without its controlling
+ terminal available.
+ 2. Path to the gcore script.
+ 3. Path to the data-directory to pass to the gcore script.
+ 4. The core file output name. */
+
+int
+main (int argc, char **argv)
+{
+ pid_t pid = 0;
+ pid_t ppid;
+ char buf[1024*2 + 500];
+ int gotint, res;
+
+ assert (argc == 5);
+
+ pid = fork ();
+
+ switch (pid)
+ {
+ case 0:
+ if (strcmp (argv[1], "detached") == 0)
+ setpgrp ();
+ ppid = getppid ();
+ gotint = snprintf (buf, sizeof (buf), "%s -d %s -o %s %d",
+ argv[2], argv[3], argv[4], (int) ppid);
+ assert (gotint < sizeof (buf));
+ res = system (buf);
+ assert (res != -1);
+ break;
+
+ case -1:
+ perror ("fork err\n");
+ exit (1);
+ break;
+
+ default:
+ do
+ {
+ res = waitpid (pid, NULL, 0);
+ }
+ while (res == -1 && errno == EINTR);
+
+ assert (res == pid);
+ break;
+ }
+
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/gcorebg.exp b/gdb/testsuite/gdb.base/gcorebg.exp
new file mode 100644
index 0000000..c271251
--- /dev/null
+++ b/gdb/testsuite/gdb.base/gcorebg.exp
@@ -0,0 +1,82 @@
+# Copyright 2007-2024 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# This is a test for the gcore script (not the gcore command from
+# inside GDB). It also tests the gcore script being run without its
+# accessible terminal.
+
+standard_testfile
+require {!is_remote host}
+require {!is_remote target}
+require has_gcore_script
+require can_spawn_for_attach
+
+set corefile [standard_output_file ${testfile}.core]
+
+if {[build_executable "failed to build" $testfile ${srcfile}] == -1 } {
+ return -1
+}
+
+# Cleanup.
+
+proc core_clean {} {
+ global corefile
+
+ foreach file [glob -nocomplain [join [list $corefile *] ""]] {
+ verbose "Delete file $file" 1
+ remote_file target delete $file
+ }
+}
+core_clean
+
+# Generate the core file.
+proc test_body { detached } {
+ global binfile
+ global GCORE
+ global corefile
+ global GDB_DATA_DIRECTORY
+
+ # We can't use gdb_test_multiple here because GDB is not started.
+ set res [remote_spawn target "$binfile $detached $GCORE $GDB_DATA_DIRECTORY $corefile"]
+ if { ![gdb_assert { ![expr {$res < 0 || $res == ""}] } \
+ "spawned gcore"] } {
+ return
+ }
+
+ set saw_corefile_created false
+ set testname "Spawned gcore finished"
+ remote_expect target 20 {
+ timeout {
+ fail "$testname (timeout)"
+ remote_exec target "kill -9 -[exp_pid -i $res]"
+ return
+ }
+ -re "Saved corefile \[^\r\n\]+\r\n" {
+ set saw_corefile_created true
+ exp_continue
+ }
+ eof {
+ gdb_assert { $saw_corefile_created } $testname
+ }
+ }
+
+ gdb_assert {1 == [llength [glob -nocomplain [join [list $corefile *] ""]]]}\
+ "Core file generated by gcore"
+ core_clean
+}
+
+foreach_with_prefix detached { detached standard } {
+ test_body $detached
+}
diff --git a/gdb/testsuite/gdb.base/hbreak2.exp b/gdb/testsuite/gdb.base/hbreak2.exp
index 8f5735b..d22b363 100644
--- a/gdb/testsuite/gdb.base/hbreak2.exp
+++ b/gdb/testsuite/gdb.base/hbreak2.exp
@@ -150,7 +150,7 @@ delete_breakpoints
#
gdb_test "hbreak -q main" \
"Hardware assisted breakpoint.*at.* file .*$srcfile, line.*" \
- "hardware breakpoint function (2)"
+ "hardware breakpoint function, 2"
gdb_run_cmd
gdb_test "" \
"Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*" \
@@ -162,7 +162,7 @@ delete_breakpoints
#
gdb_test "hbreak $bp_location1" \
"Hardware assisted breakpoint.*at.* file .*$srcfile, line $bp_location1\\." \
- "hardware breakpoint line number (2)"
+ "hardware breakpoint line number, 2"
gdb_test "continue" \
"Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location1.*$bp_location1\[\t \]+printf.*factorial.*" \
"run until breakpoint set at a line number"
@@ -173,7 +173,7 @@ delete_breakpoints
#
gdb_test "hbreak $srcfile:factorial" \
"Hardware assisted breakpoint.*at.* file .*$srcfile, line.*" \
- "hardware breakpoint function in file (2)"
+ "hardware breakpoint function in file, 2"
for {set i 6} {$i >= 1} {incr i -1} {
gdb_test "continue" \
"Continuing\\..*Breakpoint \[0-9\]+, factorial \\(value=$i\\) at .*$srcfile:$bp_location7.*$bp_location7\[\t \]+.*if .value > 1. \{.*" \
@@ -186,7 +186,7 @@ delete_breakpoints
#
gdb_test "hbreak \"marker2\"" \
"Hardware assisted breakpoint.*at.* file .*$srcfile1, line.*" \
- "hardware breakpoint quoted function (2)"
+ "hardware breakpoint quoted function, 2"
gdb_test "continue" \
"Continuing\\..*Breakpoint \[0-9\]+, (0x\[0-9a-f\]+ in )?marker2 \\(a=43\\) at .*$srcfile1:$bp_location8.*" \
"run until quoted breakpoint"
@@ -196,7 +196,7 @@ delete_breakpoints
#
gdb_test "hbreak $srcfile:$bp_location2" \
"Hardware assisted breakpoint.*at.* file .*$srcfile, line $bp_location2\\." \
- "hardware breakpoint line number in file (2)"
+ "hardware breakpoint line number in file, 2"
gdb_test "continue" \
"Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location2.*$bp_location2\[\t \]+argc = \\(argc == 12345\\);.*" \
"run until file:linenum breakpoint"
diff --git a/gdb/testsuite/gdb.base/history-duplicates.exp b/gdb/testsuite/gdb.base/history-duplicates.exp
index b2f30e6..5ac4a35 100644
--- a/gdb/testsuite/gdb.base/history-duplicates.exp
+++ b/gdb/testsuite/gdb.base/history-duplicates.exp
@@ -46,7 +46,7 @@ proc run_print_on_each_thing { things } {
set index 0
foreach thing $things {
- gdb_test "print $thing" "" "printing $thing (item #$index)"
+ gdb_test "print $thing" "" "printing $thing, item #$index"
incr index
}
}
@@ -90,8 +90,8 @@ with_test_prefix "remove-duplicates=1" {
check_prev_history_entry "print 1"
check_prev_history_entry "print 2"
check_prev_history_entry "print 0"
- check_prev_history_entry "print 1" "(again)"
- check_prev_history_entry "print 0" "(again)"
+ check_prev_history_entry "print 1" ", again"
+ check_prev_history_entry "print 0" ", again"
}
@@ -104,9 +104,9 @@ with_test_prefix "remove-duplicates=0" {
run_print_on_each_thing { 0 0 1 1 }
check_prev_history_entry "print 1"
- check_prev_history_entry "print 1" "(again)"
+ check_prev_history_entry "print 1" ", again"
check_prev_history_entry "print 0"
- check_prev_history_entry "print 0" "(again)"
+ check_prev_history_entry "print 0" ", again"
}
diff --git a/gdb/testsuite/gdb.base/index-cache.exp b/gdb/testsuite/gdb.base/index-cache.exp
index 0e19bfb..af64faa 100644
--- a/gdb/testsuite/gdb.base/index-cache.exp
+++ b/gdb/testsuite/gdb.base/index-cache.exp
@@ -19,7 +19,7 @@
standard_testfile .c -2.c
if { [build_executable "failed to prepare" $testfile [list $srcfile $srcfile2] \
- {debug ldflags=-Wl,--build-id}] } {
+ {debug build-id}] } {
return
}
diff --git a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp
index 85e3cc3..45086f6 100644
--- a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp
+++ b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.exp
@@ -37,7 +37,7 @@
# mechanism such that the fact that "inline_frame" was inlined into
# "normal_frame" would cause GDB to trigger an assertion.
#
-# This text makes use of a Python unwinder which can fake the cyclic
+# This test makes use of a Python unwinder which can fake the cyclic
# stack cycle, further the test sets up multiple levels of normal and
# inline frames. At the point of testing the stack looks like this:
#
diff --git a/gdb/testsuite/gdb.base/interact.exp b/gdb/testsuite/gdb.base/interact.exp
index b7a30e0..5779efc 100644
--- a/gdb/testsuite/gdb.base/interact.exp
+++ b/gdb/testsuite/gdb.base/interact.exp
@@ -38,7 +38,7 @@ gdb_test "source $script" "$script_output" \
gdb_test "print 3" "= 3" "sanity check with interactive-mode auto"
gdb_test "show interactive-mode" \
"Debugger's interactive mode is auto \\(currently .*\\)\\." \
- "show interactive-mode (auto)"
+ "show interactive-mode, auto"
# Test sourcing of the script with interactive mode `on'.
# Verify that evaluating the script does not cause an unexpected
@@ -49,7 +49,7 @@ gdb_test "source $script" "$script_output" \
gdb_test "print 4" "= 4" "sanity check with interactive-mode on"
gdb_test "show interactive-mode" \
"Debugger's interactive mode is on\\." \
- "show interactive-mode (on)"
+ "show interactive-mode, on"
# Test sourcing of the script with interactive mode `off'.
# Verify that evaluating the script does not cause an unexpected
@@ -60,5 +60,5 @@ gdb_test "source $script" "$script_output" \
gdb_test "print 5" "= 5" "sanity check with interactive-mode off"
gdb_test "show interactive-mode" \
"Debugger's interactive mode is off\\." \
- "show interactive-mode (off)"
+ "show interactive-mode, off"
diff --git a/gdb/testsuite/gdb.base/limited-length.c b/gdb/testsuite/gdb.base/limited-length.c
index 627c34d..c8ece16 100644
--- a/gdb/testsuite/gdb.base/limited-length.c
+++ b/gdb/testsuite/gdb.base/limited-length.c
@@ -41,6 +41,8 @@ int large_2d_array[][10] = {
{90, 91, 92, 93, 94, 95, 96, 97, 98, 99}
};
+char large_empty_string[100000] = "";
+
int
main ()
{
diff --git a/gdb/testsuite/gdb.base/limited-length.exp b/gdb/testsuite/gdb.base/limited-length.exp
index a24adcb..2d160e1 100644
--- a/gdb/testsuite/gdb.base/limited-length.exp
+++ b/gdb/testsuite/gdb.base/limited-length.exp
@@ -240,3 +240,13 @@ with_test_prefix "with unlimited print elements" {
"value is not available" \
"output expression referring unavailable element from history"
}
+
+gdb_test_no_output "set max-value-size 10000"
+gdb_test_no_output "set print elements 200"
+
+gdb_test "print large_empty_string" \
+ " = \\\{0 '\\\\000' <repeats 10000 times>, <unavailable> <repeats 90000 times>\\\}" \
+ "print large empty string which is not fully available"
+gdb_test -nonl "output large_empty_string" \
+ "\\\{0 '\\\\000' <repeats 10000 times>, <unavailable> <repeats 90000 times>\\\}" \
+ "output large empty string which is not fully available"
diff --git a/gdb/testsuite/gdb.base/list-dot-nodebug.exp b/gdb/testsuite/gdb.base/list-dot-nodebug.exp
index c9d732e..b7359be 100644
--- a/gdb/testsuite/gdb.base/list-dot-nodebug.exp
+++ b/gdb/testsuite/gdb.base/list-dot-nodebug.exp
@@ -34,21 +34,36 @@ standard_testfile .c -extra.c
foreach_with_prefix debug {"none" "some"} {
- set flags "nodebug"
if {$debug == "some"} {
- set flags "debug"
- }
+ if {[prepare_for_testing_full "failed to prepare" \
+ [list ${testfile}-${debug} $linkflags \
+ $srcfile [list nodebug] \
+ $srcfile2 [list debug]]]} {
+ return -1
+ }
- if {[prepare_for_testing_full "failed to prepare" \
- [list ${testfile}-${debug} $linkflags \
- $srcfile [list nodebug] \
- $srcfile2 [list $debug]]]} {
- return -1
+ # We don't test "list ." before starting with some debug info
+ # because GDB will choose the symtab that has debuginfo, and
+ # print the copyright blurb. This test isn't interested (yet?)
+ # in checking if this default location choice is consistent.
+ } else {
+ set executable ${testfile}-none
+ if {[build_executable "failed to prepare" ${executable} \
+ [list $srcfile $srcfile2] $linkflags]} {
+ return -1
+ }
+
+ # Stripping is a backup in case the system has static libc debuginfo.
+ # We can continue the test even if it fails.
+ gdb_gnu_strip_debug $executable no-debuglink
+
+ clean_restart ${executable}
+
+ gdb_test "list ." \
+ "^Insufficient debug info for showing source lines at default location" \
+ "print before start"
}
- gdb_test "list ." \
- "^Insufficient debug info for showing source lines at default location" \
- "print before start"
if { ![runto bar] } {
return -1
diff --git a/gdb/testsuite/gdb.base/opaque.exp b/gdb/testsuite/gdb.base/opaque.exp
index 1bd1918..d803714 100644
--- a/gdb/testsuite/gdb.base/opaque.exp
+++ b/gdb/testsuite/gdb.base/opaque.exp
@@ -66,7 +66,7 @@ if {[istarget "rs6000-*-aix*"] && !$gcc_compiled} {
setup_xfail_on_opaque_pointer
gdb_test "whatis foop" \
"type = struct foo \[*\]+" \
- "whatis on opaque struct pointer (statically)"
+ "whatis on opaque struct pointer, statically"
# Ensure that we know the form of the structure that foop points to.
@@ -122,7 +122,7 @@ if ![runto_main] {
setup_xfail_on_opaque_pointer
gdb_test "whatis foop" \
"type = struct foo \[*\]+" \
- "whatis on opaque struct pointer (dynamically)"
+ "whatis on opaque struct pointer, dynamically"
# Ensure that we know the form of the thing foop points to.
@@ -131,18 +131,18 @@ setup_xfail_on_opaque_pointer
if {!$gcc_compiled} { setup_xfail "rs6000-*-*" }
gdb_test "ptype foop" \
"type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\} \[*\]+" \
- "ptype on opaque struct pointer (dynamically) 1"
+ "ptype on opaque struct pointer, dynamically 1"
gdb_test "whatis afoo" \
"type = struct foo" \
- "whatis on opaque struct instance (dynamically) 1"
+ "whatis on opaque struct instance, dynamically 1"
# Ensure that we know the form of afoo, an instance of a struct foo.
gdb_test "ptype afoo" \
"type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\}" \
- "ptype on opaque struct instance (dynamically) 1"
+ "ptype on opaque struct instance, dynamically 1"
# Ensure that we know the form of an explicit struct foo.
@@ -150,7 +150,7 @@ gdb_test "ptype afoo" \
if {!$gcc_compiled} { setup_xfail "rs6000-*-*" }
gdb_test "ptype struct foo" \
"type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\}" \
- "ptype on opaque struct tagname (dynamically) 1"
+ "ptype on opaque struct tagname, dynamically 1"
# Now reload the symbols again so we forget about anything we might
@@ -170,7 +170,7 @@ if ![runto getfoo] {
setup_xfail_on_opaque_pointer
gdb_test "whatis foop" \
"type = struct foo \[*\]+" \
- "whatis on opaque struct pointer (dynamically) 1"
+ "whatis on opaque struct pointer, dynamically 1"
# Ensure that we know the form of the thing foop points to.
@@ -178,22 +178,22 @@ gdb_test "whatis foop" \
setup_xfail_on_opaque_pointer
gdb_test "ptype foop" \
"type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\} \[*\]+" \
- "ptype on opaque struct pointer (dynamically) 2"
+ "ptype on opaque struct pointer, dynamically 2"
gdb_test "whatis afoo" \
"type = struct foo" \
- "whatis on opaque struct instance (dynamically) 2"
+ "whatis on opaque struct instance, dynamically 2"
# Ensure that we know the form of afoo, an instance of a struct foo.
gdb_test "ptype afoo" \
"type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\}" \
- "ptype on opaque struct instance (dynamically) 2"
+ "ptype on opaque struct instance, dynamically 2"
# Ensure that we know the form of an explicit struct foo.
gdb_test "ptype struct foo" \
"type = struct foo \{\[\r\n\]+ int a;\[\r\n\]+ int b;\[\r\n\]+\}" \
- "ptype on opaque struct tagname (dynamically) 2"
+ "ptype on opaque struct tagname, dynamically 2"
diff --git a/gdb/testsuite/gdb.base/pending.exp b/gdb/testsuite/gdb.base/pending.exp
index 737b0c4..5ee31d3 100644
--- a/gdb/testsuite/gdb.base/pending.exp
+++ b/gdb/testsuite/gdb.base/pending.exp
@@ -39,7 +39,7 @@ clean_restart
gdb_test_multiple "break pendfunc1" "set pending breakpoint" {
-re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
- gdb_test "y" "Breakpoint.*pendfunc1.*pending." "set pending breakpoint (without symbols)"
+ gdb_test "y" "Breakpoint.*pendfunc1.*pending." "set pending breakpoint, without symbols"
}
}
@@ -49,7 +49,7 @@ gdb_test "complete condition " "condition 1"
gdb_test "info break" \
"Num Type\[ \]+Disp Enb Address\[ \]+What.*
\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*" \
-"single pending breakpoint info (without symbols)"
+"single pending breakpoint info, without symbols"
with_test_prefix "first load" {
gdb_load ${binfile}
diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp
index 9132071a..40176c6 100644
--- a/gdb/testsuite/gdb.base/printcmds.exp
+++ b/gdb/testsuite/gdb.base/printcmds.exp
@@ -1186,7 +1186,7 @@ gdb_test_no_output "complete p -source"
gdb_file_cmd ${binfile}
-gdb_test "print \$pc" "No registers\\." "print \$pc (with file)"
+gdb_test {print $pc} [string_to_regexp "No registers."] {print $pc, with file}
gdb_test_no_output "set print sevenbit-strings"
gdb_test_no_output "set print address off"
diff --git a/gdb/testsuite/gdb.base/recurse.exp b/gdb/testsuite/gdb.base/recurse.exp
index f5f0760..01ba55a 100644
--- a/gdb/testsuite/gdb.base/recurse.exp
+++ b/gdb/testsuite/gdb.base/recurse.exp
@@ -52,15 +52,15 @@ proc recurse_tests {} {
# Continue inward for a few iterations
gdb_test "continue" "Breakpoint.* recurse \\(a=9\\).*" \
- "continue to recurse (a = 9)"
+ "continue to recurse, a = 9"
gdb_test "continue" "Breakpoint.* recurse \\(a=8\\).*" \
- "continue to recurse (a = 8)"
+ "continue to recurse, a = 8"
gdb_test "continue" "Breakpoint.* recurse \\(a=7\\).*" \
- "continue to recurse (a = 7)"
+ "continue to recurse, a = 7"
gdb_test "continue" "Breakpoint.* recurse \\(a=6\\).*" \
- "continue to recurse (a = 6)"
+ "continue to recurse, a = 6"
gdb_test "continue" "Breakpoint.* recurse \\(a=5\\).*" \
- "continue to recurse (a = 5)"
+ "continue to recurse, a = 5"
# Put a watchpoint on another instance of b
# First we need to step over the assignment of b, so it has a known
@@ -76,13 +76,13 @@ proc recurse_tests {} {
# Continue inward for a few iterations
gdb_test "continue" "Breakpoint.* recurse \\(a=4\\).*" \
- "continue to recurse (a = 4)"
+ "continue to recurse, a = 4"
gdb_test "continue" "Breakpoint.* recurse \\(a=3\\).*" \
- "continue to recurse (a = 3)"
+ "continue to recurse, a = 3"
gdb_test "continue" "Breakpoint.* recurse \\(a=2\\).*" \
- "continue to recurse (a = 2)"
+ "continue to recurse, a = 2"
gdb_test "continue" "Breakpoint.* recurse \\(a=1\\).*" \
- "continue to recurse (a = 1)"
+ "continue to recurse, a = 1"
# Continue until second set of b (second instance).
gdb_test "continue" \
diff --git a/gdb/testsuite/gdb.base/setshow.exp b/gdb/testsuite/gdb.base/setshow.exp
index 9eb44b3..9380331 100644
--- a/gdb/testsuite/gdb.base/setshow.exp
+++ b/gdb/testsuite/gdb.base/setshow.exp
@@ -67,12 +67,12 @@ proc_with_prefix test_setshow_annotate {} {
#test set annotate 1
gdb_test "set annotate 1" ".*post-prompt.*"
- gdb_test "show annotate" "Annotation_level is 1..*" "show annotate (1)"
+ gdb_test "show annotate" "Annotation_level is 1..*" "show annotate, 1"
#test annotation_level 1
gdb_test "info line 1" "Line 1 of .* is at address .* but contains no code.*:1:0:beg:0x.*" "annotation_level 1"
#test set annotate 0
gdb_test_no_output "set annotate 0" "set annotate 0"
- gdb_test "show annotate" "Annotation_level is 0..*" "show annotate (0)"
+ gdb_test "show annotate" "Annotation_level is 0..*" "show annotate, 0"
#test annotation_level 0
gdb_test "info line 1" "Line 1 of .* is at address .* but contains no code.*" "annotation_level 0"
}
@@ -121,13 +121,13 @@ proc_with_prefix test_setshow_check {} {
"_gdb_setting check range on"
#test show check range on
- gdb_test "show check range" "Range checking is \"on\"\..*" "show check range (on)"
+ gdb_test "show check range" "Range checking is \"on\"\..*" "show check range, on"
#test set check range off with trailing space
gdb_test_no_output "set check range off " "set check range off"
#test show check range off
- gdb_test "show check range" "Range checking is \"off\"\..*" "show check range (off)"
+ gdb_test "show check range" "Range checking is \"off\"\..*" "show check range, off"
gdb_test "p \$_gdb_setting(\"check range\")" " = \"off\"" \
"_gdb_setting check range off"
@@ -144,7 +144,7 @@ proc_with_prefix test_setshow_check {} {
# Test show check type on
gdb_test "show check type" "Strict type checking is on\..*" \
- "show check type (on)"
+ "show check type, on"
gdb_test "p \$_gdb_setting_str(\"check type\")" " = \"on\"" \
"_gdb_setting_str check type on"
gdb_test "p \$_gdb_setting(\"check type\")" " = 1" \
@@ -159,7 +159,7 @@ proc_with_prefix test_setshow_check {} {
# Test show check type off
gdb_test "show check type" "Strict type checking is off\..*" \
- "show check type (off)"
+ "show check type, off"
}
proc_with_prefix test_setshow_breakpoint_pending {} {
@@ -200,11 +200,11 @@ proc_with_prefix test_setshow_complaints {} {
#test set complaints 100
gdb_test_no_output "set complaints 100" "set complaints 100"
#test show complaints 100
- gdb_test "show complaints" "Max number of complaints about incorrect symbols is 100..*" "show complaints (100)"
+ gdb_test "show complaints" "Max number of complaints about incorrect symbols is 100..*" "show complaints, 100"
#test set complaints 0
gdb_test_no_output "set complaints 0" "set complaints 0"
#test show complaints 0
- gdb_test "show complaints" "Max number of complaints about incorrect symbols is 0..*" "show complaints (0)"
+ gdb_test "show complaints" "Max number of complaints about incorrect symbols is 0..*" "show complaints, 0"
}
proc_with_prefix test_setshow_confirm {} {
@@ -213,11 +213,11 @@ proc_with_prefix test_setshow_confirm {} {
#test set confirm off
gdb_test_no_output "set confirm off" "set confirm off"
#test show confirm off
- gdb_test "show confirm" "Whether to confirm potentially dangerous operations is off..*" "show confirm (off)"
+ gdb_test "show confirm" "Whether to confirm potentially dangerous operations is off..*" "show confirm, off"
#test set confirm on
gdb_test_no_output "set confirm on" "set confirm on"
#test show confirm on
- gdb_test "show confirm" "Whether to confirm potentially dangerous operations is on..*" "show confirm (on)"
+ gdb_test "show confirm" "Whether to confirm potentially dangerous operations is on..*" "show confirm, on"
}
proc_with_prefix test_setshow_editing {} {
@@ -331,7 +331,7 @@ proc_with_prefix test_setshow_history {} {
#test show history filename foobar.baz
gdb_test "show history filename" \
"The filename in which to record the command history is \"[string_to_regexp $PWD]/foobar.baz\"..*" \
- "show history filename (current_directory/foobar.baz)"
+ "show history filename, current_directory/foobar.baz"
#test set history save on
gdb_test_no_output "set history save on" "set history save on"
@@ -356,13 +356,13 @@ proc_with_prefix test_setshow_language {} {
gdb_test_no_output "set language asm"
#test show language asm
- gdb_test "show language" "The current source language is \"asm\"..*" "show language (asm)"
+ gdb_test "show language" "The current source language is \"asm\"..*" "show language, asm"
#test set language rust, with a trailing space
gdb_test_no_output "set language rust " "set language rust"
#test show language rust
- gdb_test "show language" "The current source language is \"rust\"..*" "show language (rust)"
+ gdb_test "show language" "The current source language is \"rust\"..*" "show language, rust"
#test completion for set language.
gdb_test "complete set language min" "set language minimal" \
@@ -372,7 +372,7 @@ proc_with_prefix test_setshow_language {} {
gdb_test_no_output "set language auto" "set language auto"
#test show language
- gdb_test "show language" "The current source language is \"auto.*\"..*" "show language (auto)"
+ gdb_test "show language" "The current source language is \"auto.*\"..*" "show language, auto"
}
proc_with_prefix test_setshow_listsize {} {
@@ -447,13 +447,13 @@ proc_with_prefix test_setshow_radix {} {
gdb_test "set radix 16" "Input and output radices now set to decimal 16, hex 10, octal 20..*"
#test show radix 16
- gdb_test "show radix" "Input and output radices set to decimal 16, hex 10, octal 20..*" "show radix (16)"
+ gdb_test "show radix" "Input and output radices set to decimal 16, hex 10, octal 20..*" "show radix, 16"
#test set radix 10
gdb_test "set radix" "Input and output radices now set to decimal 10, hex a, octal 12..*" "set radix 10"
#test show radix 10
- gdb_test "show radix" "Input and output radices set to decimal 10, hex a, octal 12..*" "show radix (10)"
+ gdb_test "show radix" "Input and output radices set to decimal 10, hex a, octal 12..*" "show radix, 10"
}
proc_with_prefix test_setshow_width {} {
@@ -492,13 +492,13 @@ proc_with_prefix test_setshow_verbose {} {
gdb_test_no_output "set verbose on" "set verbose on"
#test show verbose on
- gdb_test "show verbose" "Verbose printing of informational messages is on..*" "show verbose (on)"
+ gdb_test "show verbose" "Verbose printing of informational messages is on..*" "show verbose, on"
#test set verbose off
gdb_test_no_output "set verbose off" "set verbose off"
#test show verbose off
- gdb_test "show verbose" "Verbosity is off..*" "show verbose (off)"
+ gdb_test "show verbose" "Verbosity is off..*" "show verbose, off"
}
proc_with_prefix test_argument_preceded_by_space {} {
diff --git a/gdb/testsuite/gdb.base/setvar.exp b/gdb/testsuite/gdb.base/setvar.exp
index 9ac2402..416dcc6 100644
--- a/gdb/testsuite/gdb.base/setvar.exp
+++ b/gdb/testsuite/gdb.base/setvar.exp
@@ -390,13 +390,13 @@ set timeout $prev_timeout
if {[is_c_compiler_gcc]} {
gdb_test "print sef.field=sm1" ".*.\[0-9\]* = sm1"
- gdb_test "print sef.field" ".*.\[0-9\]* = sm1" "print sef.field (sm1)"
+ gdb_test "print sef.field" ".*.\[0-9\]* = sm1" "print sef.field, sm1"
gdb_test "print sef.field=s1" ".*.\[0-9\]* = s1"
- gdb_test "print sef.field" ".*.\[0-9\]* = s1" "print sef.field (s1)"
+ gdb_test "print sef.field" ".*.\[0-9\]* = s1" "print sef.field, s1"
gdb_test "print uef.field=u2" ".*.\[0-9\]* = u2"
- gdb_test "print uef.field" ".*.\[0-9\]* = u2" "print uef.field (u2)"
+ gdb_test "print uef.field" ".*.\[0-9\]* = u2" "print uef.field, u2"
gdb_test "print uef.field=u1" ".*.\[0-9\]* = u1"
- gdb_test "print uef.field" ".*.\[0-9\]* = u1" "print uef.field (u1)"
+ gdb_test "print uef.field" ".*.\[0-9\]* = u1" "print uef.field, u1"
# Test for truncation when assigning invalid values to bitfields.
gdb_test "print sef.field=7" \
diff --git a/gdb/testsuite/gdb.base/skip.exp b/gdb/testsuite/gdb.base/skip.exp
index d3936bb..ccc7ca3 100644
--- a/gdb/testsuite/gdb.base/skip.exp
+++ b/gdb/testsuite/gdb.base/skip.exp
@@ -31,9 +31,9 @@ set srcfile1 skip1.c
# Right after we start gdb, there's no default file or function to skip.
-gdb_test "skip file" "No default file now." "skip file (no default file)"
+gdb_test "skip file" "No default file now." "skip file, no default file"
gdb_test "skip function" "No default function now."
-gdb_test "skip" "No default function now." "skip (no default function)"
+gdb_test "skip" "No default function now." "skip, no default function"
# Test elided args.
@@ -59,8 +59,8 @@ gdb_test "info skip" "Not skipping any files or functions\." "info skip empty"
# Create a skiplist entry for the current file and function.
-gdb_test "skip file" "File .*$srcfile will be skipped when stepping\." "skip file ($srcfile)"
-gdb_test "skip" "Function main will be skipped when stepping\." "skip (main)"
+gdb_test "skip file" "File .*$srcfile will be skipped when stepping\." "skip file, $srcfile"
+gdb_test "skip" "Function main will be skipped when stepping\." "skip, main"
# Create a skiplist entry for a specified file and function.
diff --git a/gdb/testsuite/gdb.base/solib-display.exp b/gdb/testsuite/gdb.base/solib-display.exp
index 5c27f29..c9c66f6 100644
--- a/gdb/testsuite/gdb.base/solib-display.exp
+++ b/gdb/testsuite/gdb.base/solib-display.exp
@@ -126,7 +126,7 @@ foreach libsepdebug {NO IN SEP} { with_test_prefix "$libsepdebug" {
"1: \\(int\\) a_global = 41" \
"warning: .*b_global.*" \
"3: \\(int\\) c_global = 43" \
- ] "after rerun (2)"
+ ] "after rerun, 2"
# Now verify that displays which are not in the shared library
# are not cleared permaturely.
diff --git a/gdb/testsuite/gdb.base/solib-search.exp b/gdb/testsuite/gdb.base/solib-search.exp
index 581046a..f038a04 100644
--- a/gdb/testsuite/gdb.base/solib-search.exp
+++ b/gdb/testsuite/gdb.base/solib-search.exp
@@ -108,9 +108,9 @@ proc test_backtrace { expect_fail } {
set total_expected 5
if { $expect_fail } {
- set testname "backtrace (with wrong libs)"
+ set testname "backtrace, with wrong libs"
} else {
- set testname "backtrace (with right libs)"
+ set testname "backtrace, with right libs"
}
# N.B. The order of the tests here is important.
# We need to count each function in the backtrace, and expect matches
@@ -137,7 +137,7 @@ proc test_backtrace { expect_fail } {
exp_continue
}
-re "\[\r\n\]$gdb_prompt $" {
- pass "$testname (data collection)"
+ pass "$testname, data collection"
}
}
diff --git a/gdb/testsuite/gdb.base/step-break.exp b/gdb/testsuite/gdb.base/step-break.exp
index da804e3..7dc0492 100644
--- a/gdb/testsuite/gdb.base/step-break.exp
+++ b/gdb/testsuite/gdb.base/step-break.exp
@@ -34,9 +34,9 @@ gdb_test "break $bp_location" \
gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(\\) at .*$srcfile:$bp_location.*set breakpoint here.*" \
"run until breakpoint set at a line number"
-gdb_test "next 2" ".*place2.*" "next 2 (1)"
-gdb_test "next 2" ".*place3.*" "next 2 (2)"
-gdb_test "next 2" ".*place2.*" "next 2 (3)"
-gdb_test "next 2" ".*place3.*" "next 2 (4)"
-gdb_test "next 2" ".*place2.*" "next 2 (5)"
-gdb_test "next 2" ".*place3.*" "next 2 (6)"
+gdb_test "next 2" ".*place2.*" "next 2, 1"
+gdb_test "next 2" ".*place3.*" "next 2, 2"
+gdb_test "next 2" ".*place2.*" "next 2, 3"
+gdb_test "next 2" ".*place3.*" "next 2, 4"
+gdb_test "next 2" ".*place2.*" "next 2, 5"
+gdb_test "next 2" ".*place3.*" "next 2, 6"
diff --git a/gdb/testsuite/gdb.base/step-into-other-file.c b/gdb/testsuite/gdb.base/step-into-other-file.c
new file mode 100644
index 0000000..5ec7c33
--- /dev/null
+++ b/gdb/testsuite/gdb.base/step-into-other-file.c
@@ -0,0 +1,31 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2024 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int var;
+
+int
+foo (void)
+{
+ var = 1;
+#include "step-into-other-file.h"
+}
+
+int
+main ()
+{
+ return foo ();
+}
diff --git a/gdb/testsuite/gdb.base/step-into-other-file.exp b/gdb/testsuite/gdb.base/step-into-other-file.exp
new file mode 100644
index 0000000..f0e8c3f
--- /dev/null
+++ b/gdb/testsuite/gdb.base/step-into-other-file.exp
@@ -0,0 +1,36 @@
+# Copyright (C) 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Check that when stepping into another file, the file is shown.
+
+standard_testfile .c .h
+
+set flags {}
+lappend flags debug
+lappend_include_file flags $srcdir/$subdir/$srcfile2
+
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
+ $flags] == -1 } {
+ return -1
+}
+
+if ![runto_main] {
+ return -1
+}
+
+gdb_test step $srcfile:$decimal\r\n.*
+
+# Regression test for PR32011.
+gdb_test next $srcfile2:$decimal\r\n.*
diff --git a/gdb/testsuite/gdb.base/step-into-other-file.h b/gdb/testsuite/gdb.base/step-into-other-file.h
new file mode 100644
index 0000000..60b4816
--- /dev/null
+++ b/gdb/testsuite/gdb.base/step-into-other-file.h
@@ -0,0 +1,18 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2024 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+ return 1;
diff --git a/gdb/testsuite/gdb.base/step-over-syscall.exp b/gdb/testsuite/gdb.base/step-over-syscall.exp
index 8cacc09..c40b20f 100644
--- a/gdb/testsuite/gdb.base/step-over-syscall.exp
+++ b/gdb/testsuite/gdb.base/step-over-syscall.exp
@@ -99,13 +99,13 @@ proc setup { syscall } {
gdb_test "break \*$syscall" "Breakpoint \[0-9\]* at .*"
gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in )?(__libc_)?$syscall \\(\\).*" \
- "continue to $syscall (1st time)"
+ "continue to $syscall, 1st time"
# Hit the breakpoint on $syscall for the first time. In this time,
# we will let PLT resolution done, and the number single steps we will
# do later will be reduced.
gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in )?(__libc_)?$syscall \\(\\).*" \
- "continue to $syscall (2nd time)"
+ "continue to $syscall, 2nd time"
# Hit the breakpoint on $syscall for the second time. In this time,
# the address of syscall insn and next insn of syscall are recorded.
@@ -236,7 +236,7 @@ proc step_over_syscall { syscall } {
}
gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, (.* in )?(__libc_)?$syscall \\(\\).*" \
- "continue to $syscall (3rd time)"
+ "continue to $syscall, 3rd time"
# Hit the breakpoint on $syscall for the third time. In this time, we'll set
# breakpoint on the syscall insn we recorded previously, and single step over it.
diff --git a/gdb/testsuite/gdb.base/sysroot-debug-lookup.exp b/gdb/testsuite/gdb.base/sysroot-debug-lookup.exp
index 5f17315..36f6519 100644
--- a/gdb/testsuite/gdb.base/sysroot-debug-lookup.exp
+++ b/gdb/testsuite/gdb.base/sysroot-debug-lookup.exp
@@ -78,9 +78,8 @@ proc_with_prefix lookup_via_build_id {} {
gdb_assert { $::gdb_file_cmd_debug_info eq "debug" } \
"ensure debug information was found"
- if { $sysroot_prefix eq "" } {
- set lookup_filename $debug_filename
- } else {
+ if { $sysroot_prefix eq "target:"
+ && [target_info gdb_protocol] == "extended-remote"} {
# Only when using the extended-remote board will we have
# started a remote target by this point. In this case GDB
# will see the 'target:' prefix as remote, and so the
@@ -89,11 +88,9 @@ proc_with_prefix lookup_via_build_id {} {
# In all other cases we will still be using the default,
# initial target, in which case GDB considers the
# 'target:' prefix to indicate the local filesystem.
- if {[target_info gdb_protocol] == "extended-remote"} {
- set lookup_filename $sysroot_prefix$debug_symlink
- } else {
- set lookup_filename $debug_symlink
- }
+ set lookup_filename $sysroot_prefix$debug_symlink
+ } else {
+ set lookup_filename $debug_filename
}
set re [string_to_regexp "Reading symbols from $lookup_filename..."]
gdb_assert {[regexp $re $::gdb_file_cmd_msg]} \
diff --git a/gdb/testsuite/gdb.base/vla-optimized-out.exp b/gdb/testsuite/gdb.base/vla-optimized-out.exp
index a0762d5..b57e474 100644
--- a/gdb/testsuite/gdb.base/vla-optimized-out.exp
+++ b/gdb/testsuite/gdb.base/vla-optimized-out.exp
@@ -57,15 +57,15 @@ proc vla_optimized_out {exe_suffix options} {
# that case to reply with 'no such vector element'.
gdb_test "p a\[0\]" \
"(= <optimized out>|no such vector element)" \
- "print out of range element of vla (0)"
+ "print out of range element of vla, 0"
gdb_test "p a\[6\]" \
"no such vector element" \
- "print out of range element of vla (6)"
+ "print out of range element of vla, 6"
gdb_test "p a\[0xffffffff\]" \
"no such vector element" \
- "print out of range element of vla (0xffffffff)"
+ "print out of range element of vla, 0xffffffff"
}
set o1_sizeof_result "6"
diff --git a/gdb/testsuite/gdb.base/vla-ptr.exp b/gdb/testsuite/gdb.base/vla-ptr.exp
index a784c18..df1b8f0 100644
--- a/gdb/testsuite/gdb.base/vla-ptr.exp
+++ b/gdb/testsuite/gdb.base/vla-ptr.exp
@@ -29,13 +29,13 @@ set sizeof_int [get_sizeof "int" 4]
# Check that VLA passed to function (pointer) points to the first element.
gdb_breakpoint [gdb_get_line_number "foo_bp"]
gdb_continue_to_breakpoint "foo_bp"
-gdb_test "print vla_ptr" "\\\(int \\\*\\\) $hex" "print vla_ptr (foo)"
-gdb_test "print *vla_ptr" " = 2" "print *vla_ptr (foo)"
+gdb_test "print vla_ptr" "\\\(int \\\*\\\) $hex" "print vla_ptr, foo"
+gdb_test "print *vla_ptr" " = 2" "print *vla_ptr, foo"
gdb_breakpoint [gdb_get_line_number "bar_bp"]
gdb_continue_to_breakpoint "bar_bp"
-gdb_test "print vla_ptr" "\\\(int \\\*\\\) $hex" "print vla_ptr (bar)"
-gdb_test "print *vla_ptr" " = 2" "print *vla_ptr (bar)"
+gdb_test "print vla_ptr" "\\\(int \\\*\\\) $hex" "print vla_ptr, bar"
+gdb_test "print *vla_ptr" " = 2" "print *vla_ptr, bar"
gdb_breakpoint [gdb_get_line_number "vla_func_bp"]
gdb_continue_to_breakpoint "vla_func_bp"
diff --git a/gdb/testsuite/gdb.base/vla-sideeffect.exp b/gdb/testsuite/gdb.base/vla-sideeffect.exp
index e17037d..8215ec2 100644
--- a/gdb/testsuite/gdb.base/vla-sideeffect.exp
+++ b/gdb/testsuite/gdb.base/vla-sideeffect.exp
@@ -52,30 +52,30 @@ gdb_test "print vla1\[0\]" " = 10" \
gdb_test "print sizeof (vla2\[i++\])" " = ${sizeof_vla}"
gdb_test "print i" " = 1" \
- "print i - sizeof with side effects (1)"
+ "print i - sizeof with side effects, 1"
gdb_test "print sizeof (vla2\[i++ + sizeof(j++)\])" " = ${sizeof_vla}"
gdb_test "print i" " = 2" \
- "print i - sizeof with side effects (2)"
+ "print i - sizeof with side effects, 2"
gdb_test "print j" " = 0" \
"print j - sizeof with no side effects"
gdb_test "ptype vla2\[i++\]" "type = int \\\[10\\\]"
gdb_test "print i" " = 2" \
- "print i - ptype with side effects (1)"
+ "print i - ptype with side effects, 1"
gdb_test "ptype vla2\[i++ + sizeof(j++)\]" "type = int \\\[10\\\]"
gdb_test "print i" " = 2" \
- "print i - ptype with side effects (2)"
+ "print i - ptype with side effects, 2"
gdb_test "print j" " = 0" \
"print j - ptype with no side effects"
gdb_test "whatis vla2\[i++\]" "type = int \\\[10\\\]"
gdb_test "print i" " = 2" \
- "print i - whatis with side effects (1)"
+ "print i - whatis with side effects, 1"
gdb_test "whatis vla2\[i++ + sizeof(j++)\]" "type = int \\\[10\\\]"
gdb_test "print i" " = 2" \
- "print i - whatis with side effects (2)"
+ "print i - whatis with side effects, 2"
gdb_test "print j" " = 0" \
"print j - whatis with no side effects"
diff --git a/gdb/testsuite/gdb.base/watch-vfork.exp b/gdb/testsuite/gdb.base/watch-vfork.exp
index 617a975..f7e268f 100644
--- a/gdb/testsuite/gdb.base/watch-vfork.exp
+++ b/gdb/testsuite/gdb.base/watch-vfork.exp
@@ -37,11 +37,11 @@ proc test_watchpoint_across_vfork { hw teststr } {
gdb_test "watch global" \
"atchpoint .*: global" \
- "Watchpoint on global variable ($teststr)"
+ "Watchpoint on global variable, $teststr"
gdb_test "continue" \
"atchpoint .*: global.*" \
- "Watchpoint triggers after vfork ($teststr)"
+ "Watchpoint triggers after vfork, $teststr"
}
if { [allow_hw_watchpoint_tests] } {
diff --git a/gdb/testsuite/gdb.base/wchar.exp b/gdb/testsuite/gdb.base/wchar.exp
index a4127fc..0fc97cf 100644
--- a/gdb/testsuite/gdb.base/wchar.exp
+++ b/gdb/testsuite/gdb.base/wchar.exp
@@ -60,15 +60,15 @@ gdb_test "print repeat_p" \
gdb_test_no_output "set print null on"
gdb_test "print repeat" "= L\"A\", '$cent' <repeats 21 times>, \"B\"" \
- "print repeat (print null on)"
+ "print repeat, print null on"
gdb_test_no_output "set print elements 3"
gdb_test "print repeat" "= L\"A$cent$cent\"\.\.\." \
- "print repeat (print elements 3)"
+ "print repeat, print elements 3"
gdb_test "print repeat_p" "= $hex L\"A$cent$cent\"\.\.\." \
- "print repeat_p (print elements 3)"
+ "print repeat_p, print elements 3"
# From PR cli/14977, but here because it requires wchar_t.
gdb_test "printf \"%ls\\n\", 0" "\\(null\\)"
diff --git a/gdb/testsuite/gdb.base/whatis-ptype-typedefs.exp b/gdb/testsuite/gdb.base/whatis-ptype-typedefs.exp
index eb575b3..ebe009a 100644
--- a/gdb/testsuite/gdb.base/whatis-ptype-typedefs.exp
+++ b/gdb/testsuite/gdb.base/whatis-ptype-typedefs.exp
@@ -271,8 +271,11 @@ proc run_tests {lang} {
if {([string match "v_*" $to]
|| (![string match "v_*" $from] && ![string match "*method" $from])
|| [string match "*method" $to])} {
- gdb_test "whatis ($to) $from" "syntax error.*" "whatis ($to) $from (syntax)"
- gdb_test "ptype ($to) $from" "syntax error.*" "ptype ($to) $from (syntax)"
+ set cmd "whatis ($to) $from"
+ gdb_test $cmd "syntax error.*" "$cmd, syntax"
+
+ set cmd "ptype ($to) $from"
+ gdb_test $cmd "syntax error.*" "$cmd, syntax"
} elseif {([string match "*float*" $from] && [string match "*array*" $to])
|| (!$float_ptr_same_size
&& ([string match "float*" $to] && [string match "*array*" $from]
@@ -289,8 +292,11 @@ proc run_tests {lang} {
|| ([string match "*ftype2" $to] && [string match "*method" $from])
|| ([string match "*method_ptr*" $to] && [string match "*method" $from])
|| ([string match "*method_ptr*" $to] && [string match "*array*" $from])} {
- gdb_test "whatis ($to) $from" "Invalid cast." "whatis ($to) $from (invalid)"
- gdb_test "ptype ($to) $from" "Invalid cast." "ptype ($to) $from (invalid)"
+ set cmd "whatis ($to) $from"
+ gdb_test $cmd "Invalid cast." "$cmd, invalid"
+
+ set cmd "ptype ($to) $from"
+ gdb_test $cmd "Invalid cast." "$cmd, invalid"
} else {
gdb_test "whatis ($to) $from" "type = [string_to_regexp $to]"
gdb_test "ptype ($to) $from" "type = $ptype"
diff --git a/gdb/testsuite/gdb.cp/anon-ns.exp b/gdb/testsuite/gdb.cp/anon-ns.exp
index c01a3ab..2b2376d 100644
--- a/gdb/testsuite/gdb.cp/anon-ns.exp
+++ b/gdb/testsuite/gdb.cp/anon-ns.exp
@@ -55,12 +55,10 @@ foreach test $methods {
gdb_test "list $test" $result
gdb_test "list '$test'" $result
- if {[gdb_breakpoint $test]} {
- pass "break $test"
- }
- if {[gdb_breakpoint '$test']} {
- pass "break '$test'"
- }
+ gdb_assert { [gdb_breakpoint $test no-message] } \
+ "break $test, unquoted"
+ gdb_assert { [gdb_breakpoint '$test' no-message] } \
+ "break $test, single-quoted"
}
# PR c++/17976
diff --git a/gdb/testsuite/gdb.cp/classes.exp b/gdb/testsuite/gdb.cp/classes.exp
index 97dca29..4d29bf5 100644
--- a/gdb/testsuite/gdb.cp/classes.exp
+++ b/gdb/testsuite/gdb.cp/classes.exp
@@ -502,7 +502,7 @@ proc test_enums {} {
gdb_test "print obj_with_enum" \
"\\$\[0-9\]+ = \{priv_enum = (ClassWithEnum::)?green, x = 0\}" \
- "print obj_with_enum (2)"
+ "print obj_with_enum, 2"
# print the enum member
diff --git a/gdb/testsuite/gdb.cp/exception.exp b/gdb/testsuite/gdb.cp/exception.exp
index 0cc97fe..5489d0c 100644
--- a/gdb/testsuite/gdb.cp/exception.exp
+++ b/gdb/testsuite/gdb.cp/exception.exp
@@ -86,7 +86,7 @@ if { !$ok } {
return
}
-set name "info breakpoints (after inferior run)"
+set name "info breakpoints, after inferior run"
gdb_test_multiple "info breakpoints" $name {
-re "$re_head${ws}$re_2_bp${ws}$re_3_bp${ws}$re_4_bp\r\n$gdb_prompt $" {
pass $name
diff --git a/gdb/testsuite/gdb.cp/m-static.exp b/gdb/testsuite/gdb.cp/m-static.exp
index 45bc090..3d59a48 100644
--- a/gdb/testsuite/gdb.cp/m-static.exp
+++ b/gdb/testsuite/gdb.cp/m-static.exp
@@ -71,11 +71,18 @@ if { [is_aarch32_target] } {
gdb_test "print test5.single_constructor" \
{ = {single_constructor \*\(single_constructor \* const\)} 0x[0-9a-f]+ <single_constructor::single_constructor\(\)>} \
"simple object instance, print constructor"
- gdb_test "ptype test5.single_constructor" \
- {type = class single_constructor {\r\n public:\r\n single_constructor\(void\);\r\n ~single_constructor\(\);\r\n} \*\(single_constructor \* const\)} \
+
+ set re \
+ [multi_line_string_to_regexp \
+ "type = class single_constructor {" \
+ "" \
+ " public:" \
+ " single_constructor(void);" \
+ " ~single_constructor(void);" \
+ "} *(single_constructor * const)"]
+ gdb_test "ptype test5.single_constructor" $re \
"simple object instance, ptype constructor"
- gdb_test "ptype single_constructor::single_constructor" \
- {type = class single_constructor {\r\n public:\r\n single_constructor\(void\);\r\n ~single_constructor\(\);\r\n} \*\(single_constructor \* const\)} \
+ gdb_test "ptype single_constructor::single_constructor" $re \
"simple object class, ptype constructor"
gdb_test "print test1.~gnu_obj_1" \
@@ -168,12 +175,12 @@ if {[test_compiler_info {gcc-[0-3]-*}]
# and DW_AT_MIPS_linkage_name = _ZN9gnu_obj_47nowhereE .
setup_xfail *-*-*
}
-gdb_test "print test4.nowhere" "<optimized out>" "static const int initialized nowhere (print field)"
+gdb_test "print test4.nowhere" "<optimized out>" "static const int initialized nowhere, print field"
gdb_test "ptype test4.nowhere" "type = const int"
gdb_test "print test4.nowhere.nowhere" "Attempt to extract a component of a value that is not a structure."
# Same, but print the whole struct.
-gdb_test "print test4" "static nowhere = <optimized out>.*" "static const int initialized nowhere (whole struct)"
+gdb_test "print test4" "static nowhere = <optimized out>.*" "static const int initialized nowhere, whole struct"
# static const initialized in the class definition, PR gdb/11702.
if { $non_dwarf } { setup_xfail *-*-* }
diff --git a/gdb/testsuite/gdb.cp/member-ptr.exp b/gdb/testsuite/gdb.cp/member-ptr.exp
index 838fe96..d02a1ea 100644
--- a/gdb/testsuite/gdb.cp/member-ptr.exp
+++ b/gdb/testsuite/gdb.cp/member-ptr.exp
@@ -43,7 +43,7 @@ gdb_continue_to_breakpoint "continue to pmi = NULL"
# ptype on pointer to data member
-set name "ptype pmi (A::j)"
+set name "ptype pmi, A::j"
gdb_test_multiple "ptype pmi" $name {
-re "type = int A::\\*\r\n$gdb_prompt $" {
pass $name
@@ -52,7 +52,7 @@ gdb_test_multiple "ptype pmi" $name {
# print pointer to data member
-set name "print pmi (A::j) "
+set name "print pmi, A::j"
gdb_test_multiple "print pmi" $name {
-re "$vhn = &A::j\r\n$gdb_prompt $" {
pass $name
@@ -77,7 +77,7 @@ gdb_test_multiple "print pmi" $name {
# print dereferenced pointer to data member
-set name "print a.*pmi (A::j)"
+set name "print a.*pmi, A::j"
gdb_test_multiple "print a.*pmi" $name {
-re "$vhn = 121\r\n$gdb_prompt $" {
pass $name
@@ -97,7 +97,7 @@ gdb_test_multiple "print a.*pmi" $name {
# print dereferenced pointer to data member
# this time, dereferenced through a pointer
-set name "print a_p->*pmi (A::j)"
+set name "print a_p->*pmi, A::j"
gdb_test_multiple "print a_p->*pmi" $name {
-re "$vhn = 121\r\n$gdb_prompt $" {
pass $name
@@ -133,7 +133,7 @@ gdb_test_multiple "set var pmi = &A::jj" $name {
# print the pointer again
-set name "print pmi (A::jj)"
+set name "print pmi, A::jj"
gdb_test_multiple "print pmi" $name {
-re "$vhn = &A::jj\r\n$gdb_prompt $" {
pass $name
@@ -150,7 +150,7 @@ gdb_test_multiple "print pmi" $name {
# print dereferenced pointer to data member again
-set name "print a.*pmi (A::jj)"
+set name "print a.*pmi, A::jj"
gdb_test_multiple "print a.*pmi" $name {
-re "$vhn = 1331\r\n$gdb_prompt $" {
pass $name
@@ -181,7 +181,7 @@ gdb_test_multiple "set var pmi = &A::j" $name {
# print dereferenced pointer to data member yet again (extra check, why not)
-set name "print a.*pmi (A::j) (again)"
+set name "print a.*pmi, A::j, again"
gdb_test_multiple "print a.*pmi" $name {
-re "$vhn = 121\r\n$gdb_prompt $" {
pass $name
@@ -209,7 +209,7 @@ gdb_test_multiple "print a.*pmi = 33" $name {
# Now check that the data really was changed
-set name "print a.*pmi (A::j) (33)"
+set name "print a.*pmi, A::j, 33"
gdb_test_multiple "print a.*pmi" $name {
-re "$vhn = 33\r\n$gdb_prompt $" {
pass $name
@@ -223,7 +223,7 @@ gdb_test_multiple "print a.*pmi" $name {
# Double-check by printing a.
-set name "print a (j = 33)"
+set name "print a, j = 33"
gdb_test_multiple "print a" $name {
-re "$vhn = \{c = 120 'x', j = 33, jj = 1331, (static|static int) s = 10, (_vptr.A|_vptr\\$) = ($hex|$hex <A virtual table>)\}\r\n$gdb_prompt $" {
pass $name
@@ -257,7 +257,7 @@ gdb_test_multiple "print a_p->*pmi = 44" $name {
# Check that the data really was changed
-set name "print a_p->*pmi (44)"
+set name "print a_p->*pmi, 44"
gdb_test_multiple "print a_p->*pmi" $name {
-re "$vhn = 44\r\n$gdb_prompt $" {
pass $name
@@ -271,7 +271,7 @@ gdb_test_multiple "print a_p->*pmi" $name {
# Double-check by printing a.
-set name "print a (j = 44)"
+set name "print a, j = 44"
gdb_test_multiple "print a" $name {
-re "$vhn = \{c = 120 'x', j = 44, jj = 1331, (static|static int) s = 10, (_vptr.A|_vptr\\$) = ($hex|$hex <A virtual table>)\}\r\n$gdb_prompt $" {
pass $name
diff --git a/gdb/testsuite/gdb.cp/meth-typedefs.exp b/gdb/testsuite/gdb.cp/meth-typedefs.exp
index a1829a1..149f44c 100644
--- a/gdb/testsuite/gdb.cp/meth-typedefs.exp
+++ b/gdb/testsuite/gdb.cp/meth-typedefs.exp
@@ -152,12 +152,10 @@ foreach test $methods {
gdb_test "list -qualified $func" $result
gdb_test "list -qualified '$func'" $result
- if {[gdb_breakpoint "-qualified $func"]} {
- pass "break -qualified $func"
- }
- if {[gdb_breakpoint "-qualified '$func'"]} {
- pass "break -qualified '$func'"
- }
+ gdb_assert { [gdb_breakpoint "-qualified $func" no-message] } \
+ "break -qualified $func, unquoted"
+ gdb_assert { [gdb_breakpoint "-qualified '$func'" no-message] } \
+ "break -qualified $func, single-quoted"
}
# The tests above use -qualified to explicitly pick the one "test"
diff --git a/gdb/testsuite/gdb.cp/method2.exp b/gdb/testsuite/gdb.cp/method2.exp
index 9aa9bf0..0a07ff3 100644
--- a/gdb/testsuite/gdb.cp/method2.exp
+++ b/gdb/testsuite/gdb.cp/method2.exp
@@ -50,11 +50,11 @@ proc test_break { lang } {
incr idx
}
set expect [join $menu_items {.*[\r\n]*}]
- gdb_test_multiple "break A::method" "breaking in method ($lang)" {
+ gdb_test_multiple "break A::method" "breaking in method, $lang" {
-re $expect {
gdb_test "0" \
"canceled" \
- "breaking in method ($lang)"
+ $gdb_test_name
}
}
}
diff --git a/gdb/testsuite/gdb.cp/misc.exp b/gdb/testsuite/gdb.cp/misc.exp
index bcb20f8..3f5532e 100644
--- a/gdb/testsuite/gdb.cp/misc.exp
+++ b/gdb/testsuite/gdb.cp/misc.exp
@@ -51,10 +51,10 @@ proc test_expr { args } {
}
set last_ent [expr [llength $args] - 1]
set testname [lindex $args $last_ent]
- gdb_test_no_output [lindex $args 0] "$testname (setup)"
+ gdb_test_no_output [lindex $args 0] "$testname, setup"
for {set x 1} {$x < $last_ent} {set x [expr $x + 2]} {
- gdb_test [lindex $args $x] [lindex $args [expr $x + 1]] "$testname ([lindex $args $x])"
+ gdb_test [lindex $args $x] [lindex $args [expr $x + 1]] "$testname, [lindex $args $x]"
}
}
diff --git a/gdb/testsuite/gdb.cp/nested-types.exp b/gdb/testsuite/gdb.cp/nested-types.exp
index 5621fff..294358c 100644
--- a/gdb/testsuite/gdb.cp/nested-types.exp
+++ b/gdb/testsuite/gdb.cp/nested-types.exp
@@ -269,7 +269,7 @@ proc test_nested_limit {limit log} {
}
gdb_test "show print type nested-type-limit" \
"Will print $lstr nested types defined in a class" \
- "show print type nested-type-limit ($limit)"
+ "show print type nested-type-limit, $limit"
} else {
send_log "Tree to $limit levels:\n"
}
@@ -283,7 +283,7 @@ proc test_nested_limit {limit log} {
# the outermost node.
set result [lindex $result 0]
lassign $result type access key name children
- cp_test_ptype_class $name "ptype $name (limit = $limit)" $key \
+ cp_test_ptype_class $name "ptype $name, limit = $limit" $key \
$name $children
}
}
diff --git a/gdb/testsuite/gdb.cp/ovldbreak.exp b/gdb/testsuite/gdb.cp/ovldbreak.exp
index 882a83b..99d0a38 100644
--- a/gdb/testsuite/gdb.cp/ovldbreak.exp
+++ b/gdb/testsuite/gdb.cp/ovldbreak.exp
@@ -248,7 +248,7 @@ foreach ovld $overloads {
append bptable [format "\r\n\[0-9\]+\[\t \]+breakpoint\[\t \]+keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(%s\\) at.*$srcfile:%d" $ovld \
$line($type_map("$ovld"))]
}
-gdb_test "info break" $bptable "breakpoint info (after setting one-by-one)"
+gdb_test "info break" $bptable "breakpoint info, after setting one-by-one"
# Test choice "cancel".
# This is copy-and-paste from set_bp_overloaded.
@@ -288,7 +288,7 @@ gdb_expect {
}
}
-gdb_test "info break" $bptable "breakpoint info (after cancel)"
+gdb_test "info break" $bptable "breakpoint info, after cancel"
# Test that if the user selects multiple entries from the option list,
# GDB creates one breakpoint per entry.
@@ -325,7 +325,7 @@ gdb_expect {
}
}
-gdb_test "info breakpoints" "No breakpoints, watchpoints, tracepoints, or catchpoints." "breakpoint info (after delete)"
+gdb_test "info breakpoints" "No breakpoints, watchpoints, tracepoints, or catchpoints." "breakpoint info, after delete"
@@ -375,7 +375,7 @@ foreach ovld {void char signed_char unsigned_char short_int \
$types($ovld) $line($ovld)]
}
-gdb_test "info break" $bptable "breakpoint info (after setting on all)"
+gdb_test "info break" $bptable "breakpoint info, after setting on all"
# Run through each breakpoint.
proc continue_to_bp_overloaded {bpnumber might_fail line argtype argument} {
diff --git a/gdb/testsuite/gdb.cp/pass-by-ref-2.exp b/gdb/testsuite/gdb.cp/pass-by-ref-2.exp
index 3c7b19a..00141d8 100644
--- a/gdb/testsuite/gdb.cp/pass-by-ref-2.exp
+++ b/gdb/testsuite/gdb.cp/pass-by-ref-2.exp
@@ -72,22 +72,22 @@ gdb_test "print cbvDtorDel (*dtorDel)" \
# Test that GDB calls the correct copy ctor
gdb_test "print cbvFourCCtor (fourCctor_c0v0)" "13" \
- "call cbvFourCCtor (c0v0)"
+ "call cbvFourCCtor, c0v0"
gdb_test "print fourCctor_c0v0.x" "2" \
"cbv argument 'twoCctor_c0v0' should not change"
gdb_test "print cbvFourCCtor (fourCctor_c1v0)" "14" \
- "call cbvFourCCtor (c1v0)"
+ "call cbvFourCCtor, c1v0"
gdb_test "print fourCctor_c1v0.x" "2" \
"cbv argument 'twoCctor_c1v0' should not change"
gdb_test "print cbvFourCCtor (fourCctor_c0v1)" "15" \
- "call cbvFourCCtor (c0v1)"
+ "call cbvFourCCtor, c0v1"
gdb_test "print fourCctor_c0v1.x" "2" \
"cbv argument 'twoCctor_c0v1' should not change"
gdb_test "print cbvFourCCtor (fourCctor_c1v1)" "16" \
- "call cbvFourCCtor (c1v1)"
+ "call cbvFourCCtor, c1v1"
gdb_test "print fourCctor_c1v1.x" "2" \
"cbv argument 'twoCctor_c1v1' should not change"
diff --git a/gdb/testsuite/gdb.cp/pass-by-ref.exp b/gdb/testsuite/gdb.cp/pass-by-ref.exp
index 7b2a619..a1f1df4 100644
--- a/gdb/testsuite/gdb.cp/pass-by-ref.exp
+++ b/gdb/testsuite/gdb.cp/pass-by-ref.exp
@@ -396,12 +396,12 @@ proc test_for_class { prefix states cbvfun data_field length} {
gdb_test "print ${cbvfun}<$name> (${name}_var)" " = $expected" \
"call '$cbvfun'"
gdb_test "print ${name}_var.${data_field}\[0\]" " = $ORIGINAL" \
- "cbv argument should not change (item 0)"
+ "cbv argument should not change, item 0"
if {$length > 1} {
set last_index [expr $length - 1]
gdb_test "print ${name}_var.${data_field}\[$last_index\]" \
" = $ORIGINAL" \
- "cbv argument should not change (item $last_index)"
+ "cbv argument should not change, item $last_index"
}
if {$dtor == "explicit"} {
if {$cctor == "defaultedIn"
diff --git a/gdb/testsuite/gdb.cp/templates.exp b/gdb/testsuite/gdb.cp/templates.exp
index 52129d8..8dd0cdc 100644
--- a/gdb/testsuite/gdb.cp/templates.exp
+++ b/gdb/testsuite/gdb.cp/templates.exp
@@ -641,7 +641,8 @@ foreach t [list "int" "char" "Empty<int>"] {
gdb_test "break Foozle::fogey<$t>" "Breakpoint.*at.* \\(3 locations\\)"
foreach u [list "int" "char" "Empty<int>"] {
gdb_breakpoint "Foozle<$t>::fogey<$u>" message
- gdb_breakpoint "Foozle<$t>::fogey<$u> ($u)" message
+ gdb_assert { [gdb_breakpoint "Foozle<$t>::fogey<$u> ($u)" no-message] } \
+ "break Foozle<$t>::fogey<$u> ($u), success"
}
}
@@ -667,10 +668,14 @@ foreach t [list "Empty" "Foozle"] {
# Try a specific instance, both with and without whitespace
# after the template-template parameter.
- gdb_breakpoint "operator< <$tt> ($tt&, $tt&)" message
- gdb_breakpoint "operator< <$tt > ($tt&, $tt&)" message
- gdb_breakpoint "operator<< <$tt> ($tt&, $tt&)" message
- gdb_breakpoint "operator<< <$tt > ($tt&, $tt&)" message
+ set loc "operator< <$tt> ($tt&, $tt&)"
+ gdb_assert { [gdb_breakpoint $loc no-message] } "break $loc, success"
+ set loc "operator< <$tt > ($tt&, $tt&)"
+ gdb_assert { [gdb_breakpoint $loc no-message] } "break $loc, success"
+ set loc "operator<< <$tt> ($tt&, $tt&)"
+ gdb_assert { [gdb_breakpoint $loc no-message] } "break $loc, success"
+ set loc "operator<< <$tt > ($tt&, $tt&)"
+ gdb_assert { [gdb_breakpoint $loc no-message] } "break $loc, success"
}
# Test that "-qualified" finds no matching locations.
diff --git a/gdb/testsuite/gdb.dap/rust-slices.exp b/gdb/testsuite/gdb.dap/rust-slices.exp
index d3bd305..4af8c11 100644
--- a/gdb/testsuite/gdb.dap/rust-slices.exp
+++ b/gdb/testsuite/gdb.dap/rust-slices.exp
@@ -59,9 +59,9 @@ set scopes [dap_check_request_and_response "get scopes" scopes \
[format {o frameId [i %d]} $frame_id]]
set scopes [dict get [lindex $scopes 0] body scopes]
-# There are three scopes because an artificial symbol ends up in the
-# DWARF. See https://github.com/rust-lang/rust/issues/125126.
-gdb_assert {[llength $scopes] == 3} "three scopes"
+# There may be three scopes instead of two if an artificial symbol ends up in
+# the DWARF. See https://github.com/rust-lang/rust/issues/125126.
+gdb_assert { [llength $scopes] == 2 || [llength $scopes] == 3 } "two scopes"
lassign $scopes scope ignore
gdb_assert {[dict get $scope name] == "Locals"} "scope is locals"
diff --git a/gdb/testsuite/gdb.dap/step-out.exp b/gdb/testsuite/gdb.dap/step-out.exp
index 31c50bb..193264f 100644
--- a/gdb/testsuite/gdb.dap/step-out.exp
+++ b/gdb/testsuite/gdb.dap/step-out.exp
@@ -59,15 +59,21 @@ set scopes [dap_check_request_and_response "get scopes" scopes \
[format {o frameId [i %d]} $frame_id]]
set scopes [dict get [lindex $scopes 0] body scopes]
-gdb_assert {[llength $scopes] == 2} "two scopes"
+gdb_assert {[llength $scopes] == 3} "three scopes"
-lassign $scopes scope reg_scope
+lassign $scopes scope reg_scope return_scope
gdb_assert {[dict get $scope name] == "Locals"} "scope is locals"
gdb_assert {[dict get $scope presentationHint] == "locals"} \
"locals presentation hint"
-gdb_assert {[dict get $scope namedVariables] == 2} "two vars in scope"
+gdb_assert {[dict get $scope namedVariables] == 1} "one var in scope"
-set num [dict get $scope variablesReference]
+gdb_assert {[dict get $return_scope name] == "Return"} "scope is return"
+gdb_assert {[dict get $return_scope presentationHint] == "returnValue"} \
+ "returnValue presentation hint"
+gdb_assert {[dict get $return_scope namedVariables] == 1} \
+ "one var in return scope"
+
+set num [dict get $return_scope variablesReference]
set refs [lindex [dap_check_request_and_response "fetch arguments" \
"variables" \
[format {o variablesReference [i %d]} $num]] \
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-anon-mptr.exp b/gdb/testsuite/gdb.dwarf2/dw2-anon-mptr.exp
index 5935ba6..fa98e41 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-anon-mptr.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-anon-mptr.exp
@@ -36,5 +36,19 @@ gdb_test "show cp-abi" {The currently selected C\+\+ ABI is "gnu-v3".*}
gdb_load $binfile
+set re_address_class "@\[^\r\n\]+"
+
+set re_class_ptr_const \
+ [string cat \
+ [string_to_regexp "class {...} * const"] "( $re_address_class)?"]
+
gdb_test "ptype crash" \
- "type = class crash {\[\r\n \t\]*public:\[\r\n \t\]*crash\\(int \\(class {\\.\\.\\.}::\\*\\)\\(class {\\.\\.\\.} \\* const\\)\\);\[\r\n \t\]*}"
+ [multi_line \
+ "type = class crash {" \
+ "" \
+ " public:" \
+ [string cat \
+ [string_to_regexp " crash(int (class {...}::*)("] \
+ $re_class_ptr_const \
+ [string_to_regexp "));"]] \
+ "}"]
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-lines.exp b/gdb/testsuite/gdb.dwarf2/dw2-lines.exp
index af5b6b7..9617782 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-lines.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-lines.exp
@@ -122,9 +122,9 @@ proc test_1 { _cv _cdw64 _lv _ldw64 {_string_form ""}} {
gdb_breakpoint "bar_label"
gdb_continue_to_breakpoint "foo \\(1\\)"
- gdb_test "next" "foo \\(2\\).*" "next to foo (2)"
- gdb_test "next" "foo \\(3\\).*" "next to foo (3)"
- gdb_test "next" "foo \\(4\\).*" "next to foo (4)"
+ gdb_test "next" "foo \\(2\\).*" "next to foo(2)"
+ gdb_test "next" "foo \\(3\\).*" "next to foo(3)"
+ gdb_test "next" "foo \\(4\\).*" "next to foo(4)"
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp b/gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp
index cebed1d..d73f4a8 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp
@@ -126,6 +126,8 @@ proc build_test_program {} {
}
}
+set re_address_class "@\[^\r\n\]+"
+
# Test access to an optimized-out pointer-to-struct using the
# console interpreter.
@@ -210,13 +212,18 @@ proc do_mi_test {} {
# Test that -var-create for 'ptr' is successful.
mi_create_varobj "var1" "ptr" "create varobj for ptr"
+
+ set struct_foo_ptr \
+ [string cat \
+ [string_to_regexp "struct foo *"] "( $::re_address_class)?"]
# Test that -var-list-children of 'ptr' is successful.
- mi_list_varobj_children "var1" { \
- {var1.a a 0 integer} \
- {var1.x x 128 foo__array_type} \
- {var1.y y 3 "struct foo \\*"} \
- } "get children of var1 (ptr)"
+ mi_list_varobj_children "var1" \
+ [list \
+ {var1.a a 0 integer} \
+ {var1.x x 128 foo__array_type} \
+ [list "var1.y" "y" "3" $struct_foo_ptr]] \
+ "get children of var1 (ptr)"
# Test that dereferencing 'ptr' will throw an error.
mi_gdb_test "-var-create var2 * &((ptr)->a)" \
diff --git a/gdb/testsuite/gdb.dwarf2/macro-complaints.exp b/gdb/testsuite/gdb.dwarf2/macro-complaints.exp
new file mode 100644
index 0000000..01060b8
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/macro-complaints.exp
@@ -0,0 +1,198 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test complaints about .debug_macro section.
+
+load_lib dwarf.exp
+
+require dwarf2_support
+require !readnow
+
+standard_testfile main.c .S
+
+lassign [function_range main $srcdir/$subdir/$srcfile] \
+ main_start main_len
+
+set asm_file [standard_output_file $srcfile2]
+
+set line [gdb_get_line_number "return 0;"]
+
+Dwarf::assemble $asm_file {
+ declare_labels L cu_macro1
+
+ cu {} {
+ DW_TAG_compile_unit {
+ {DW_AT_name $::srcfile}
+ {DW_AT_macros $cu_macro1 DW_FORM_sec_offset}
+ {DW_AT_stmt_list $L DW_FORM_sec_offset}
+ } {
+ declare_labels int_type
+
+ int_type: DW_TAG_base_type {
+ {DW_AT_byte_size 4 DW_FORM_sdata}
+ {DW_AT_encoding @DW_ATE_signed}
+ {DW_AT_name int}
+ }
+ DW_TAG_subprogram {
+ {MACRO_AT_func {main}}
+ {type :$int_type}
+ }
+ }
+ }
+
+ lines {version 2} L {
+ file_name $::srcfile 1
+ program {
+ DW_LNE_set_address $::main_start
+ line $::line
+ DW_LNS_copy
+ DW_LNE_set_address "$::main_start + $::main_len"
+ DW_LNE_end_sequence
+ }
+ }
+
+ # Define the .debug_macro section.
+ macro {
+ cu_macro1: unit {
+ "debug-line-offset-label" $L
+ } {
+ define 0 "M1_01_BUILTIN_OK 1"
+ define 1 "M1_02_BUILTIN_BADLINE 1"
+
+ start_file 0 1
+
+ define 1 "M1_03_OK 1"
+ define 0 "M1_04_BADLINE 1"
+
+ start_file 1 1234
+ define 1 "M1_05_BADFILE 1"
+ end_file
+
+ define 1 "M1_06_OK "
+ define 1 "M1_07_MALFORMED"
+ define 1 "M1_08_OK() 1"
+ define 1 "M1_09_OK(ARG) (ARG)"
+ define 1 "M1_10_OK(ARG1,ARG2) (ARG1+ARG2)"
+
+ define 1 "M1_11_MALFORMED(ARG"
+ define 1 "M1_12_MALFORMED(ARG,"
+ define 1 "M1_13_MALFORMED(ARG,)"
+ define 1 "M1_14_MALFORMED()1"
+
+ end_file
+ }
+ }
+}
+
+if { [build_executable "failed to prepare" $testfile \
+ [list $srcfile $asm_file] {nodebug}] } {
+ return
+}
+
+clean_restart
+
+set re_complaint1 \
+ "debug info gives command-line macro definition with non-zero line 1: M1_02_BUILTIN_BADLINE 1"
+
+set re_complaint2 \
+ "debug info gives in-file macro definition with zero line 0: M1_04_BADLINE 1"
+
+set re_complaint3 \
+ [string_to_regexp "bad file number in macro information (1234)"]
+
+set re_complaint4 \
+ [multi_line \
+ "macro debug info contains a malformed macro definition:" \
+ "`M1_07_MALFORMED'"]
+
+set re_complaint5 \
+ [multi_line \
+ "macro debug info contains a malformed macro definition:" \
+ [string_to_regexp "`M1_11_MALFORMED(ARG'"]]
+
+set re_complaint6 \
+ [multi_line \
+ "macro debug info contains a malformed macro definition:" \
+ [string_to_regexp "`M1_12_MALFORMED(ARG,'"]]
+
+set re_complaint7 \
+ [multi_line \
+ "macro debug info contains a malformed macro definition:" \
+ [string_to_regexp "`M1_13_MALFORMED(ARG,)'"]]
+
+set re_complaint8 \
+ [multi_line \
+ "macro debug info contains a malformed macro definition:" \
+ [string_to_regexp "`M1_14_MALFORMED()1'"]]
+
+set prefix \
+ "During symbol reading"
+
+set re \
+ [multi_line \
+ "$prefix: $re_complaint1" \
+ "$prefix: $re_complaint2" \
+ "$prefix: $re_complaint3" \
+ "$prefix: $re_complaint4" \
+ "$prefix: $re_complaint5" \
+ "$prefix: $re_complaint6" \
+ "$prefix: $re_complaint7" \
+ "$prefix: $re_complaint8" \
+ [string cat [string_to_regexp {$}] "$decimal = \[^\r\n\]+"]]
+
+with_complaints 10 {
+ gdb_load $binfile
+ gdb_test "p main" ^$re "complaints"
+}
+
+set re_explicit \
+ [multi_line \
+ "Defined at $srcfile:0" \
+ "-DM1_01_BUILTIN_OK=1" \
+ "Defined at $srcfile:1" \
+ "#define M1_02_BUILTIN_BADLINE 1" \
+ "Defined at $srcfile:1" \
+ "#define M1_03_OK 1" \
+ "Defined at $srcfile:0" \
+ "-DM1_04_BADLINE=1" \
+ "Defined at <bad macro file number 1234>:1" \
+ " included at $srcfile:1" \
+ "#define M1_05_BADFILE 1" \
+ "Defined at $srcfile:1" \
+ "#define M1_06_OK " \
+ "Defined at $srcfile:1" \
+ "#define M1_07_MALFORMED " \
+ "Defined at $srcfile:1" \
+ [string_to_regexp "#define M1_08_OK() 1"] \
+ "Defined at $srcfile:1" \
+ [string_to_regexp "#define M1_09_OK(ARG) (ARG)"] \
+ "Defined at $srcfile:1" \
+ [string_to_regexp "#define M1_10_OK(ARG1, ARG2) (ARG1+ARG2)"] \
+ "Defined at $srcfile:1" \
+ [string_to_regexp "#define M1_13_MALFORMED(ARG) "]]
+
+set re_implicit \
+ [multi_line \
+ "Defined at $srcfile:-1" \
+ "#define __FILE__ \"$srcfile\"" \
+ "Defined at $srcfile:-1" \
+ "#define __LINE__ $line"]
+
+gdb_test "info macros $line" \
+ [multi_line \
+ $re_explicit \
+ $re_implicit]
diff --git a/gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp b/gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp
index c97c887..21ad111 100644
--- a/gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp
+++ b/gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp
@@ -34,5 +34,19 @@ gdb_test "show cp-abi" {The currently selected C\+\+ ABI is "gnu-v3".*}
gdb_load ${binfile}
+set re_address_class "@\[^\r\n\]+"
+
+set re_C_ptr \
+ [string cat \
+ [string_to_regexp "C *"] "( const)?( $re_address_class)?"]
+
gdb_test_no_output "set language c++"
-gdb_test "ptype c" "type = struct C {\[\r\n \t\]*private:\[\r\n \t\]*int \\(C::\\*fp\\)\\(C \\*( const)?\\);\[\r\n \t\]*}"
+gdb_test "ptype c" \
+ [multi_line \
+ "type = struct C {" \
+ " private:" \
+ [string cat \
+ [string_to_regexp " int (C::*fp)("] \
+ $re_C_ptr \
+ [string_to_regexp ");"]] \
+ "}"]
diff --git a/gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp b/gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp
index ef1ed19..7df68a9 100644
--- a/gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp
+++ b/gdb/testsuite/gdb.dwarf2/per-bfd-sharing.exp
@@ -19,7 +19,7 @@
standard_testfile
if { [build_executable "failed to prepare" $testfile $srcfile \
- {debug ldflags=-Wl,--build-id}] == -1 } {
+ {debug build-id}] == -1 } {
return
}
set host_binfile [gdb_remote_download host $binfile]
diff --git a/gdb/testsuite/gdb.fortran/entry-point.exp b/gdb/testsuite/gdb.fortran/entry-point.exp
index 4e4706d..51550ad 100644
--- a/gdb/testsuite/gdb.fortran/entry-point.exp
+++ b/gdb/testsuite/gdb.fortran/entry-point.exp
@@ -72,12 +72,12 @@ set entry_point_name "mod::mod_foo"
# GCC moves subroutines with entry points out of the module scope into the
# compile unit scope.
-if {[test_compiler_info {gcc-*}]} {
+if {[test_compiler_info {gcc-*}] || [test_compiler_info {clang-*}]} {
setup_xfail "gcc/105272" "*-*-*"
}
gdb_breakpoint $entry_point_name
-if {[test_compiler_info {gcc-*}]} {
+if {[test_compiler_info {gcc-*}] || [test_compiler_info {clang-*}]} {
setup_xfail "gcc/105272" "*-*-*"
}
gdb_continue_to_breakpoint "continue to breakpoint: $entry_point_name" \
diff --git a/gdb/testsuite/gdb.fortran/intrinsics.exp b/gdb/testsuite/gdb.fortran/intrinsics.exp
index 60c79f9..060bb53 100644
--- a/gdb/testsuite/gdb.fortran/intrinsics.exp
+++ b/gdb/testsuite/gdb.fortran/intrinsics.exp
@@ -112,10 +112,14 @@ gdb_test "ptype cmplx (4,4)" "= complex\\*4"
gdb_test "p cmplx (-14,-4)" "= \\(-14,-4\\)"
gdb_test "p cmplx (4,4,4)" "\\(4,4\\)"
gdb_test "p cmplx (4,4,8)" "\\(4,4\\)"
-gdb_test "p cmplx (4,4,16)" "\\(4,4\\)"
+set re_unsupported_kind_16 \
+ [string_to_regexp "unsupported kind 16 for type complex*4"]
+gdb_test "p cmplx (4,4,16)" \
+ ([string_to_regexp " = (4,4)"]|$re_unsupported_kind_16)
gdb_test "ptype cmplx (4,4,4)" "= complex\\*4"
gdb_test "ptype cmplx (4,4,8)" "= complex\\*8"
-gdb_test "ptype cmplx (4,4,16)" "= complex\\*16"
+gdb_test "ptype cmplx (4,4,16)" \
+ ([string_to_regexp " = complex*16"]|$re_unsupported_kind_16)
gdb_test "p cmplx (4,4,1)" "unsupported kind 1 for type complex\\*4"
gdb_test "p cmplx (4,4,-1)" "unsupported kind -1 for type complex\\*4"
diff --git a/gdb/testsuite/gdb.fortran/multi-dim.exp b/gdb/testsuite/gdb.fortran/multi-dim.exp
index 3325e52..eda2d6a 100644
--- a/gdb/testsuite/gdb.fortran/multi-dim.exp
+++ b/gdb/testsuite/gdb.fortran/multi-dim.exp
@@ -41,19 +41,19 @@ gdb_test "print foo(2,3,4)" \
gdb_test "print foo(0,0,0)" \
"no such vector element" \
- "print an invalid array index (0,0,0)"
+ "print an invalid array index @ 0,0,0"
gdb_test "print foo(2,3,5)" \
"no such vector element" \
- "print an invalid array index (2,3,5)"
+ "print an invalid array index @ 2,3,5"
gdb_test "print foo(2,4,4)" \
"no such vector element" \
- "print an invalid array index (2,4,4)"
+ "print an invalid array index @ 2,4,4"
gdb_test "print foo(3,3,4)" \
"no such vector element" \
- "print an invalid array index (3,3,4)"
+ "print an invalid array index @ 3,3,4"
gdb_test "print foo" \
{ = \(\(\(10, 10\) \(10, 10\) \(10, 10\)\) \(\(10, 10\) \(10, 10\) \(10, 10\)\) \(\(10, 10\) \(10, 10\) \(10, 10\)\) \(\(10, 10\) \(10, 10\) \(10, 20\)\)\)} \
diff --git a/gdb/testsuite/gdb.fortran/size.exp b/gdb/testsuite/gdb.fortran/size.exp
index 93fb444..925aeed 100644
--- a/gdb/testsuite/gdb.fortran/size.exp
+++ b/gdb/testsuite/gdb.fortran/size.exp
@@ -95,7 +95,7 @@ gdb_assert {$found_dealloc_breakpoint} "ran all compiled in tests"
foreach var {array_1d_p array_2d_p allocatable_array_1d \
allocatable_array_2d} {
- gdb_test_multiple "p size ($var, 3)" "p size ($var, 3)" {
+ gdb_test_multiple "p size ($var, 3)" "" {
-re -wrap "DIM argument to SIZE must be between 1 and \[1-2\]" {
pass $gdb_test_name
}
@@ -129,7 +129,7 @@ gdb_continue_to_breakpoint "Final Breakpoint"
foreach var {array_1d_p array_2d_p allocatable_array_1d \
allocatable_array_2d} {
- gdb_test_multiple "p size ($var)" "p size ($var)" {
+ gdb_test_multiple "p size ($var)" "" {
-re -wrap "SIZE can only be used on allocated/associated arrays" {
pass $gdb_test_name
}
diff --git a/gdb/testsuite/gdb.fortran/type-kinds.exp b/gdb/testsuite/gdb.fortran/type-kinds.exp
index ab5f19f..a6f2aa4 100644
--- a/gdb/testsuite/gdb.fortran/type-kinds.exp
+++ b/gdb/testsuite/gdb.fortran/type-kinds.exp
@@ -43,12 +43,20 @@ proc test_basic_parsing_of_type_kinds {} {
test_cast_1_to_type_kind "complex" "" "\\(1,0\\)" "8"
test_cast_1_to_type_kind "complex" "4" "\\(1,0\\)" "8"
test_cast_1_to_type_kind "complex" "8" "\\(1,0\\)" "16"
- test_cast_1_to_type_kind "complex" "16" "\\(1,0\\)" "32"
+ set re_unsupported_kind \
+ [string_to_regexp "unsupported kind 16 for type complex*4"]
+ test_cast_1_to_type_kind "complex" "16" \
+ [string_to_regexp (1,0)]|$re_unsupported_kind \
+ 32|$re_unsupported_kind
test_cast_1_to_type_kind "real" "" "1" "4"
test_cast_1_to_type_kind "real" "4" "1" "4"
test_cast_1_to_type_kind "real" "8" "1" "8"
- test_cast_1_to_type_kind "real" "16" "1" "16"
+ set re_unsupported_kind \
+ [string_to_regexp "unsupported kind 16 for type real*4"]
+ test_cast_1_to_type_kind "real" "16" \
+ 1|$re_unsupported_kind \
+ 16|$re_unsupported_kind
test_cast_1_to_type_kind "logical" "" "\\.TRUE\\." "4"
test_cast_1_to_type_kind "logical" "1" "\\.TRUE\\." "1"
@@ -83,11 +91,17 @@ proc test_old_star_type_sizes {} {
gdb_test "p ((complex*4) 1)" " = \\(1,0\\)"
gdb_test "p ((complex*8) 1)" " = \\(1,0\\)"
- gdb_test "p ((complex*16) 1)" " = \\(1,0\\)"
+ set re_unsupported_kind \
+ [string_to_regexp "unsupported kind 16 for type complex*4"]
+ gdb_test "p ((complex*16) 1)" \
+ [string_to_regexp " = (1,0)"]|$re_unsupported_kind
gdb_test "p ((real*4) 1)" " = 1"
gdb_test "p ((real*8) 1)" " = 1"
- gdb_test "p ((real*16) 1)" " = 1"
+ set re_unsupported_kind \
+ [string_to_regexp "unsupported kind 16 for type real*4"]
+ gdb_test "p ((real*16) 1)" \
+ "( = 1|$re_unsupported_kind)"
gdb_test "p ((logical*1) 1)" " = \\.TRUE\\."
gdb_test "p ((logical*4) 1)" " = \\.TRUE\\."
diff --git a/gdb/testsuite/gdb.fortran/types.exp b/gdb/testsuite/gdb.fortran/types.exp
index 83b1098..edbf5ab 100644
--- a/gdb/testsuite/gdb.fortran/types.exp
+++ b/gdb/testsuite/gdb.fortran/types.exp
@@ -94,7 +94,24 @@ proc test_primitive_types_known {} {
# While TYPE_KIND is allowed as input, GDB will always return the
# Fortran notation TYPE*KIND
regsub -all "_" $type "\*" type_res
- gdb_test "ptype $type" [string_to_regexp "type = $type_res"]
+ set re [string_to_regexp "type = $type_res"]
+ switch $type {
+ real*16 - complex*16 {
+ regexp {^[^*_]*} $type base
+ set re_unsupported \
+ [string_to_regexp \
+ "unsupported kind 16 for type $base*4"]
+ set re ($re|$re_unsupported)
+ }
+ real_16 - complex_16 {
+ set re_unsupported \
+ [string_to_regexp \
+ "unsupported type $type_res"]
+ set re ($re|$re_unsupported)
+ }
+ }
+
+ gdb_test "ptype $type" $re
}
}
diff --git a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
index 5e6c3f8..01717b0 100644
--- a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
+++ b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
@@ -32,32 +32,32 @@ if ![fortran_runto_main] {
gdb_breakpoint [gdb_get_line_number "vla1-allocated"]
gdb_continue_to_breakpoint "vla1-allocated"
gdb_test "print l" " = \\.TRUE\\." \
- "print vla1 allocation status (allocated)"
+ "print vla1 allocation status, allocated"
gdb_breakpoint [gdb_get_line_number "vla2-allocated"]
gdb_continue_to_breakpoint "vla2-allocated"
gdb_test "print l" " = \\.TRUE\\." \
- "print vla2 allocation status (allocated)"
+ "print vla2 allocation status, allocated"
gdb_breakpoint [gdb_get_line_number "pvla-associated"]
gdb_continue_to_breakpoint "pvla-associated"
gdb_test "print l" " = \\.TRUE\\." \
- "print pvla associated status (associated)"
+ "print pvla associated status, associated"
gdb_breakpoint [gdb_get_line_number "pvla-re-associated"]
gdb_continue_to_breakpoint "pvla-re-associated"
gdb_test "print l" " = \\.TRUE\\." \
- "print pvla associated status (re-associated)"
+ "print pvla associated status, re-associated"
gdb_breakpoint [gdb_get_line_number "pvla-deassociated"]
gdb_continue_to_breakpoint "pvla-deassociated"
gdb_test "print l" " = \\.FALSE\\." \
- "print pvla allocation status (deassociated)"
+ "print pvla allocation status, deassociated"
gdb_breakpoint [gdb_get_line_number "vla1-deallocated"]
gdb_continue_to_breakpoint "vla1-deallocated"
gdb_test "print l" " = \\.FALSE\\." \
- "print vla1 allocation status (deallocated)"
+ "print vla1 allocation status, deallocated"
gdb_test "print vla1" " = <not allocated>" \
"print deallocated vla1"
diff --git a/gdb/testsuite/gdb.fortran/vla-datatypes.exp b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
index ed3b0f1..8227f23 100644
--- a/gdb/testsuite/gdb.fortran/vla-datatypes.exp
+++ b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
@@ -74,12 +74,12 @@ gdb_test "print charactervla(5,5,5)" " = 'K'" \
gdb_breakpoint [gdb_get_line_number "vlas-modified"]
gdb_continue_to_breakpoint "vlas-modified"
-gdb_test "print intvla(5,5,5)" " = 42" "print intvla(5,5,5) (2nd)"
+gdb_test "print intvla(5,5,5)" " = 42" "print intvla(5,5,5), 2nd"
gdb_test "print realvla(5,5,5)" " = 4.13\\d+" \
- "print realvla(5,5,5) (2nd)"
+ "print realvla(5,5,5), 2nd"
gdb_test "print complexvla(5,5,5)" " = \\\(-3,2\\\)" \
- "print complexvla(5,5,5) (2nd)"
+ "print complexvla(5,5,5), 2nd"
gdb_test "print logicalvla(5,5,5)" " = \\.FALSE\\." \
- "print logicalvla(5,5,5) (2nd)"
+ "print logicalvla(5,5,5), 2nd"
gdb_test "print charactervla(5,5,5)" " = 'X'" \
- "print charactervla(5,5,5) (2nd)"
+ "print charactervla(5,5,5), 2nd"
diff --git a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
index cf3fcfe..78b711b 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
@@ -33,7 +33,7 @@ set real [fortran_real4]
# Pass fixed array to function and handle them as vla in function.
gdb_breakpoint [gdb_get_line_number "not-filled"]
-gdb_continue_to_breakpoint "not-filled (1st)"
+gdb_continue_to_breakpoint "not-filled, 1st"
gdb_test "ptype array1" "type = $int \\\(42,42\\\)" \
"ptype array1 (passed fixed)"
gdb_test "ptype array2" "type = $real \\\(42,42,42\\\)" \
@@ -44,15 +44,15 @@ gdb_test "ptype array2(13, 11, 5)" "type = $real" \
"ptype array2(13, 11, 5) (passed fixed)"
# Pass sub arrays to function and handle them as vla in function.
-gdb_continue_to_breakpoint "not-filled (2nd)"
+gdb_continue_to_breakpoint "not-filled, 2nd"
gdb_test "ptype array1" "type = $int \\\(6,6\\\)" \
- "ptype array1 (passed sub-array)"
+ "ptype array1, passed sub-array"
gdb_test "ptype array2" "type = $real \\\(6,6,6\\\)" \
- "ptype array2 (passed sub-array)"
+ "ptype array2, passed sub-array"
gdb_test "ptype array1(3, 3)" "type = $int" \
- "ptype array1(3, 3) (passed sub-array)"
+ "ptype array1(3, 3), passed sub-array"
gdb_test "ptype array2(4, 4, 4)" "type = $real" \
- "ptype array2(4, 4, 4) (passed sub-array)"
+ "ptype array2(4, 4, 4), passed sub-array"
# Check ptype outside of bounds. This should not crash GDB.
gdb_test "ptype array1(100, 100)" "no such vector element" \
@@ -61,15 +61,15 @@ gdb_test "ptype array2(100, 100, 100)" "no such vector element" \
"ptype array2(100, 100, 100) subarray do not crash (passed sub-array)"
# Pass vla to function.
-gdb_continue_to_breakpoint "not-filled (3rd)"
+gdb_continue_to_breakpoint "not-filled, 3rd"
gdb_test "ptype array1" "type = $int \\\(20,20\\\)" \
- "ptype array1 (passed vla)"
+ "ptype array1, passed vla"
gdb_test "ptype array2" "type = $real \\\(10,10,10\\\)" \
- "ptype array2 (passed vla)"
+ "ptype array2, passed vla"
gdb_test "ptype array1(3, 3)" "type = $int" \
- "ptype array1(3, 3) (passed vla)"
+ "ptype array1(3, 3), passed vla"
gdb_test "ptype array2(4, 4, 4)" "type = $real" \
- "ptype array2(4, 4, 4) (passed vla)"
+ "ptype array2(4, 4, 4), passed vla"
# Check ptype outside of bounds. This should not crash GDB.
gdb_test "ptype array1(100, 100)" "no such vector element" \
@@ -83,11 +83,11 @@ gdb_breakpoint [gdb_get_line_number "end-of-bar"]
gdb_continue_to_breakpoint "end-of-bar"
gdb_test "ptype array1" \
"type = (PTR TO -> \\( )?$int \\(\\*\\)\\)?" \
- "ptype array1 (arbitrary length)"
+ "ptype array1, arbitrary length"
gdb_test "ptype array2" \
"type = (PTR TO -> \\( )?$int \\(4:9,10:\\*\\)\\)?" \
- "ptype array2 (arbitrary length)"
+ "ptype array2, arbitrary length"
gdb_test "ptype array1(100)" "type = $int" \
- "ptype array1(100) (arbitrary length)"
+ "ptype array1(100), arbitrary length"
gdb_test "ptype array2(4,100)" "type = $int" \
- "ptype array2(4,100) (arbitrary length)"
+ "ptype array2(4,100), arbitrary length"
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub.exp b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
index cbeec34..23ee539 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
@@ -45,7 +45,7 @@ gdb_test "print array1(1, 1)" " = 30" \
"print array1(1, 1) after filled in foo (passed fixed array)"
gdb_breakpoint [gdb_get_line_number "array2-almost-filled"]
-gdb_continue_to_breakpoint "array2-almost-filled (1st)"
+gdb_continue_to_breakpoint "array2-almost-filled, 1st"
# array2 size is 296352 bytes.
gdb_test_no_output "set max-value-size 1024*1024"
gdb_test "print array2" " = \\( *\\( *\\( *30, *3, *3,\[()3, .\]*\\)" \
@@ -57,40 +57,40 @@ gdb_test "print array2" " = \\( *\\( *\\( *30, *20, *3,\[()3, .\]*\\)" \
# Try to access values from a fixed sub-array handled as VLA in subroutine.
-gdb_continue_to_breakpoint "not-filled (2nd)"
+gdb_continue_to_breakpoint "not-filled, 2nd"
gdb_test "print array1" " = \\(\[()5, .\]*\\)" \
- "print passed array1 in foo (passed sub-array)"
+ "print passed array1 in foo, passed sub-array"
-gdb_continue_to_breakpoint "array1-filled (2nd)"
+gdb_continue_to_breakpoint "array1-filled, 2nd"
gdb_test "print array1(5, 5)" " = 5" \
- "print array1(5, 5) after filled in foo (passed sub-array)"
+ "print array1(5, 5) after filled in foo, passed sub-array"
gdb_test "print array1(1, 1)" " = 30" \
- "print array1(1, 1) after filled in foo (passed sub-array)"
+ "print array1(1, 1) after filled in foo, passed sub-array"
-gdb_continue_to_breakpoint "array2-almost-filled (2nd)"
+gdb_continue_to_breakpoint "array2-almost-filled, 2nd"
gdb_test "print array2" " = \\( *\\( *\\( *30, *3, *3,\[()3, .\]*\\)" \
- "print array2 in foo after it was filled (passed sub-array)"
+ "print array2 in foo after it was filled, passed sub-array"
gdb_test "print array2(2,1,1)=20" " = 20" \
- "set array(2,2,2) to 20 in subroutine (passed sub-array)"
+ "set array(2,2,2) to 20 in subroutine, passed sub-array"
gdb_test "print array2" " = \\( *\\( *\\( *30, *20, *3,\[()3, .\]*\\)" \
- "print array2 in foo after it was mofified in debugger (passed sub-array)"
+ "print array2 in foo after it was mofified in debugger, passed sub-array"
# Try to access values from a VLA passed to subroutine.
-gdb_continue_to_breakpoint "not-filled (3rd)"
+gdb_continue_to_breakpoint "not-filled, 3rd"
gdb_test "print array1" " = \\(\[()42, .\]*\\)" \
- "print passed array1 in foo (passed vla)"
+ "print passed array1 in foo, passed vla"
-gdb_continue_to_breakpoint "array1-filled (3rd)"
+gdb_continue_to_breakpoint "array1-filled, 3rd"
gdb_test "print array1(5, 5)" " = 5" \
- "print array1(5, 5) after filled in foo (passed vla)"
+ "print array1(5, 5) after filled in foo, passed vla"
gdb_test "print array1(1, 1)" " = 30" \
- "print array1(1, 1) after filled in foo (passed vla)"
+ "print array1(1, 1) after filled in foo, passed vla"
-gdb_continue_to_breakpoint "array2-almost-filled (3rd)"
+gdb_continue_to_breakpoint "array2-almost-filled, 3rd"
gdb_test "print array2" " = \\( *\\( *\\( *30, *3, *3,\[()3, .\]*\\)" \
- "print array2 in foo after it was filled (passed vla)"
+ "print array2 in foo after it was filled, passed vla"
gdb_test "print array2(2,1,1)=20" " = 20" \
- "set array(2,2,2) to 20 in subroutine (passed vla)"
+ "set array(2,2,2) to 20 in subroutine, passed vla"
gdb_test "print array2" " = \\( *\\( *\\( *30, *20, *3,\[()3, .\]*\\)" \
- "print array2 in foo after it was mofified in debugger (passed vla)"
+ "print array2 in foo after it was mofified in debugger, passed vla"
diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp
index 587a491..a3f50d1 100644
--- a/gdb/testsuite/gdb.fortran/vla-value.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value.exp
@@ -39,10 +39,10 @@ gdb_test "print &vla1" \
" = \\\(PTR TO -> \\\( $real, allocatable \\\(:,:,:\\\) \\\)\\\) $hex" \
"print non-allocated &vla1"
gdb_test "print vla1(1,1,1)" "no such vector element \\\(vector not allocated\\\)" \
- "print member in non-allocated vla1 (1)"
+ "print member in non-allocated vla1, 1"
gdb_test "print vla1(101,202,303)" \
"no such vector element \\\(vector not allocated\\\)" \
- "print member in non-allocated vla1 (2)"
+ "print member in non-allocated vla1, 2"
gdb_test "print vla1(5,2,18)=1" "no such vector element \\\(vector not allocated\\\)" \
"set member in non-allocated vla1"
@@ -68,11 +68,11 @@ gdb_test "print vla1(9, 9, 9) = 999" " = 999" \
gdb_breakpoint [gdb_get_line_number "vla1-filled"]
gdb_continue_to_breakpoint "vla1-filled"
gdb_test "print vla1(3, 6, 9)" " = 42" \
- "print allocated vla1(3,6,9) after specific assignment (filled)"
+ "print allocated vla1(3,6,9) after specific assignment, filled"
gdb_test "print vla1(1, 3, 8)" " = 1001" \
- "print allocated vla1(1,3,8) after specific assignment (filled)"
+ "print allocated vla1(1,3,8) after specific assignment, filled"
gdb_test "print vla1(9, 9, 9)" " = 999" \
- "print allocated vla1(9,9,9) after assignment in debugger (filled)"
+ "print allocated vla1(9,9,9) after assignment in debugger, filled"
# Try to access values in undefined pointer to VLA (dangling)
gdb_test "print pvla" " = <not associated>" "print undefined pvla"
@@ -120,11 +120,11 @@ gdb_test "print pvla" " = <not associated>" \
gdb_breakpoint [gdb_get_line_number "vla1-deallocated"]
gdb_continue_to_breakpoint "vla1-deallocated"
gdb_test "print vla1(3, 6, 9)" "no such vector element \\\(vector not allocated\\\)" \
- "print allocated vla1(3,6,9) after specific assignment (deallocated)"
+ "print allocated vla1(3,6,9) after specific assignment, deallocated"
gdb_test "print vla1(1, 3, 8)" "no such vector element \\\(vector not allocated\\\)" \
- "print allocated vla1(1,3,8) after specific assignment (deallocated)"
+ "print allocated vla1(1,3,8) after specific assignment, deallocated"
gdb_test "print vla1(9, 9, 9)" "no such vector element \\\(vector not allocated\\\)" \
- "print allocated vla1(9,9,9) after assignment in debugger (deallocated)"
+ "print allocated vla1(9,9,9) after assignment in debugger, deallocated"
# Try to assign VLA to user variable
@@ -147,7 +147,7 @@ gdb_test "print \$myvar" \
" = \\( *\\( *\\( *1311, *1311, *1311,\[()1311, .\]*\\)" \
"print \$myvar set to vla1"
-gdb_test "next" "\\d+.*vla1\\(1, 3, 8\\) = 1001" "next (2)"
+gdb_test "next" "\\d+.*vla1\\(1, 3, 8\\) = 1001" "next, 2"
gdb_test "print \$myvar(3,6,9)" " = 1311"
gdb_breakpoint [gdb_get_line_number "pvla-associated"]
diff --git a/gdb/testsuite/gdb.gdb/index-file.exp b/gdb/testsuite/gdb.gdb/index-file.exp
index 72088ca..c30f417 100644
--- a/gdb/testsuite/gdb.gdb/index-file.exp
+++ b/gdb/testsuite/gdb.gdb/index-file.exp
@@ -38,12 +38,28 @@ with_timeout_factor $timeout_factor {
# Record how many worker threads GDB is using.
set worker_threads [gdb_get_worker_threads]
+if { $worker_threads eq "UNKNOWN" } {
+ unresolved "unable to get worker thread count"
+ return -1
+}
+
# Generate an index file.
set dir1 [standard_output_file "index_1"]
remote_exec host "mkdir -p ${dir1}"
with_timeout_factor $timeout_factor {
- gdb_test_no_output "save gdb-index $dir1" \
- "create gdb-index file"
+ set ok 0
+ gdb_test_multiple "save gdb-index $dir1" "create gdb-index file" {
+ -re -wrap "Error while writing index for \[^\r\n\]*: No debugging symbols" {
+ unsupported $gdb_test_name
+ }
+ -re -wrap "^" {
+ pass $gdb_test_name
+ set ok 1
+ }
+ }
+ if { ! $ok } {
+ return -1
+ }
gdb_test_no_output "save gdb-index -dwarf-5 $dir1" \
"create dwarf-index files"
diff --git a/gdb/testsuite/gdb.gdb/python-helper.exp b/gdb/testsuite/gdb.gdb/python-helper.exp
index 8a8afb1..4589edc 100644
--- a/gdb/testsuite/gdb.gdb/python-helper.exp
+++ b/gdb/testsuite/gdb.gdb/python-helper.exp
@@ -111,6 +111,16 @@ proc test_python_helper {} {
}
}
+ # Add a second inferior, useful to the intrusive_list pretty-printer test
+ # below.
+ send_inferior "add-inferior\n"
+ gdb_test_multiple "" "add second inferior in inner GDB" {
+ -i "$inferior_spawn_id"
+ -re "Added inferior 2\r\n$gdb_prompt $" {
+ pass $gdb_test_name
+ }
+ }
+
# Send Ctrl-C to the inner GDB, this should kick us back to the
# prompt of the outer GDB.
send_inferior "\003"
@@ -253,6 +263,11 @@ proc test_python_helper {} {
# Test the htab_t pretty-printer.
gdb_test -prompt $outer_prompt_re "print all_bfds" "htab_t with ${::decimal} elements = \\{${::hex}.*\\}"
+ # Test the intrusive_list pretty-printer. A bug occured in the
+ # pretty-printer for lists with more than one element. Verify that
+ # we see both elements of the inferior_list list being printed.
+ gdb_test -prompt $outer_prompt_re "print inferior_list" "intrusive list of inferior = {.*, num = 1,.*, num = 2,.*}"
+
return 0
}
diff --git a/gdb/testsuite/gdb.guile/scm-frame.exp b/gdb/testsuite/gdb.guile/scm-frame.exp
index 34c9f8c..bd54e63 100644
--- a/gdb/testsuite/gdb.guile/scm-frame.exp
+++ b/gdb/testsuite/gdb.guile/scm-frame.exp
@@ -91,9 +91,9 @@ gdb_test "guile (print (eq? bframe (newest-frame)))" \
#t "newest frame -vs- newest frame"
gdb_test "guile (print (eq? f0 f1))" \
- "#f" "test equality comparison (false)"
+ "#f" "test equality comparison, false"
gdb_test "guile (print (eq? f0 f0))" \
- "#t" "test equality comparison (true)"
+ "#t" "test equality comparison, true"
gdb_test "guile (print (frame-valid? f0))" \
"#t" "test frame-valid?"
gdb_test "guile (print (frame-name f0))" \
diff --git a/gdb/testsuite/gdb.guile/scm-parameter.exp b/gdb/testsuite/gdb.guile/scm-parameter.exp
index 20c601e..d10e9d2 100644
--- a/gdb/testsuite/gdb.guile/scm-parameter.exp
+++ b/gdb/testsuite/gdb.guile/scm-parameter.exp
@@ -62,11 +62,11 @@ gdb_test_multiline "Simple gdb boolean parameter" \
"end"
with_test_prefix "test-param" {
- gdb_test "guile (print (parameter-value test-param))" "= #t" "parameter value (true)"
+ gdb_test "guile (print (parameter-value test-param))" "= #t" "parameter value, true"
gdb_test "show print test-param" "The state of the Test Parameter is on." "show parameter on"
gdb_test_no_output "set print test-param off"
gdb_test "show print test-param" "The state of the Test Parameter is off." "show parameter off"
- gdb_test "guile (print (parameter-value test-param))" "= #f" "parameter value (false)"
+ gdb_test "guile (print (parameter-value test-param))" "= #f" "parameter value, false"
gdb_test "help show print test-param" "Show the state of the boolean test-param.*" "show help"
gdb_test "help set print test-param" "Set the state of the boolean test-param.*" "set help"
gdb_test "help set print" "set print test-param -- Set the state of the boolean test-param.*" "general help"
@@ -94,11 +94,11 @@ gdb_test_multiline "enum gdb parameter" \
"end"
with_test_prefix "test-enum-param" {
- gdb_test "guile (print (parameter-value test-enum-param))" "one" "enum parameter value (one)"
+ gdb_test "guile (print (parameter-value test-enum-param))" "one" "enum parameter value, one"
gdb_test "show print test-enum-param" "The state of the enum is one." "show initial value"
gdb_test_no_output "set print test-enum-param two"
gdb_test "show print test-enum-param" "The state of the enum is two." "show new value"
- gdb_test "guile (print (parameter-value test-enum-param))" "two" "enum parameter value (two)"
+ gdb_test "guile (print (parameter-value test-enum-param))" "two" "enum parameter value, two"
gdb_test "set print test-enum-param three" "Undefined item: \"three\".*" "set invalid enum parameter"
}
@@ -241,14 +241,14 @@ foreach_with_prefix kind {
with_test_prefix "test-$kind-param" {
gdb_test "guile (print (parameter-value test-$kind-param))" \
- 3 "$kind parameter value (3)"
+ 3 "$kind parameter value, 3"
gdb_test "show print test-$kind-param" \
"The state of $kind is 3." "show initial value"
gdb_test_no_output "set print test-$kind-param 2"
gdb_test "show print test-$kind-param" \
"The state of $kind is 2." "show new value"
gdb_test "guile (print (parameter-value test-$kind-param))" \
- 2 "$kind parameter value (2)"
+ 2 "$kind parameter value, 2"
scm_param_test_maybe_no_output \
"guile (set-parameter-value! test-$kind-param #:unlimited)" \
$param_set_unlimited
@@ -257,18 +257,18 @@ foreach_with_prefix kind {
"show unlimited value"
gdb_test_no_output "guile (set-parameter-value! test-$kind-param 1)"
gdb_test "guile (print (parameter-value test-$kind-param))" \
- 1 "$kind parameter value (1)"
+ 1 "$kind parameter value, 1"
gdb_test_no_output "guile (set-parameter-value! test-$kind-param 0)"
gdb_test "guile (print (parameter-value test-$kind-param))" \
- $param_get_zero "$kind parameter value (0)"
+ $param_get_zero "$kind parameter value, 0"
scm_param_test_maybe_no_output "set print test-$kind-param -1" \
$param_set_minus_one
gdb_test "guile (print (parameter-value test-$kind-param))" \
- $param_get_minus_one "$kind parameter value (-1)"
+ $param_get_minus_one "$kind parameter value, -1"
scm_param_test_maybe_no_output "set print test-$kind-param -2" \
$param_set_minus_two
gdb_test "guile (print (parameter-value test-$kind-param))" \
- $param_get_minus_two "$kind parameter value (-2)"
+ $param_get_minus_two "$kind parameter value, -2"
}
}
@@ -378,11 +378,11 @@ gdb_test_multiline "previously ambiguously named boolean parameter" \
gdb_test_no_output "guile (register-parameter! prev-ambig)"
with_test_prefix "previously-ambiguous" {
- gdb_test "guile (print (parameter-value prev-ambig))" "= #f" "parameter value (false)"
+ gdb_test "guile (print (parameter-value prev-ambig))" "= #f" "parameter value, false"
gdb_test "show print s" "Command is not documented is off." "show parameter off"
gdb_test_no_output "set print s on"
gdb_test "show print s" "Command is not documented is on." "show parameter on"
- gdb_test "guile (print (parameter-value prev-ambig))" "= #t" "parameter value (true)"
+ gdb_test "guile (print (parameter-value prev-ambig))" "= #t" "parameter value, true"
gdb_test "help show print s" "This command is not documented." "show help"
gdb_test "help set print s" "This command is not documented." "set help"
gdb_test "help set print" "set print s -- This command is not documented.*" "general help"
diff --git a/gdb/testsuite/gdb.guile/scm-symbol.exp b/gdb/testsuite/gdb.guile/scm-symbol.exp
index 0b85848..ad22a8b 100644
--- a/gdb/testsuite/gdb.guile/scm-symbol.exp
+++ b/gdb/testsuite/gdb.guile/scm-symbol.exp
@@ -37,9 +37,9 @@ gdb_install_guile_module
gdb_scm_test_silent_cmd "guile (define main-func (lookup-global-symbol \"main\"))" \
"lookup main"
gdb_test "guile (print (symbol-function? main-func))" \
- "= #t" "test (symbol-function? main)"
+ "= #t" "test, symbol-function? main"
gdb_test "guile (print (lookup-global-symbol \"junk\"))" \
- "= #f" "test (lookup-global-symbol junk)"
+ "= #f" "test, lookup-global-symbol junk"
gdb_test "guile (print (symbol-value main-func))" \
"= {int \\(int, char \[*\]\[*\]\\)} $hex \\<main\\>" "print value of main"
diff --git a/gdb/testsuite/gdb.guile/scm-type.exp b/gdb/testsuite/gdb.guile/scm-type.exp
index 71fbe5b..3a4f2d0 100644
--- a/gdb/testsuite/gdb.guile/scm-type.exp
+++ b/gdb/testsuite/gdb.guile/scm-type.exp
@@ -70,7 +70,7 @@ proc test_fields {lang} {
if {$lang == "c++"} {
# Test usage with a class.
- gdb_scm_test_silent_cmd "print c" "print value (c)"
+ gdb_scm_test_silent_cmd "print c" "print value, c"
gdb_scm_test_silent_cmd "guile (define c (history-ref 0))" \
"get value (c) from history"
gdb_scm_test_silent_cmd "guile (define fields (type-fields (value-type c)))" \
@@ -84,7 +84,7 @@ proc test_fields {lang} {
}
# Test normal fields usage in structs.
- gdb_scm_test_silent_cmd "print st" "print value (st)"
+ gdb_scm_test_silent_cmd "print st" "print value, st"
gdb_scm_test_silent_cmd "guile (define st (history-ref 0))" \
"get value (st) from history"
gdb_scm_test_silent_cmd "guile (define st-type (value-type st))" \
@@ -120,7 +120,7 @@ proc test_fields {lang} {
"check field iterator on bad type"
# Test type-array.
- gdb_scm_test_silent_cmd "print ar" "print value (ar)"
+ gdb_scm_test_silent_cmd "print ar" "print value, ar"
gdb_scm_test_silent_cmd "guile (define ar (history-ref 0))" \
"get value (ar) from history"
gdb_scm_test_silent_cmd "guile (define ar0 (value-subscript ar 0))" \
@@ -133,11 +133,11 @@ proc test_fields {lang} {
# Test type-vector.
# Note: vectors cast differently than arrays. Here ar[0] is replicated
# for the size of the vector.
- gdb_scm_test_silent_cmd "print vec_data_1" "print value (vec_data_1)"
+ gdb_scm_test_silent_cmd "print vec_data_1" "print value, vec_data_1"
gdb_scm_test_silent_cmd "guile (define vec_data_1 (history-ref 0))" \
"get value (vec_data_1) from history"
- gdb_scm_test_silent_cmd "print vec_data_2" "print value (vec_data_2)"
+ gdb_scm_test_silent_cmd "print vec_data_2" "print value, vec_data_2"
gdb_scm_test_silent_cmd "guile (define vec_data_2 (history-ref 0))" \
"get value (vec_data_2) from history"
@@ -192,7 +192,7 @@ proc test_equality {lang} {
proc test_enums {} {
with_test_prefix "test_enum" {
- gdb_scm_test_silent_cmd "print e" "print value (e)"
+ gdb_scm_test_silent_cmd "print e" "print value, e"
gdb_scm_test_silent_cmd "guile (define e (history-ref 0))" \
"get value (e) from history"
gdb_scm_test_silent_cmd "guile (define fields (type-fields (value-type e)))" \
@@ -208,9 +208,9 @@ proc test_enums {} {
gdb_test "guile (print (type-num-fields (value-type e)))" \
"= 3" "check the number of enum values"
gdb_test "guile (print (field-name (type-field (value-type e) \"v1\")))" \
- "= v1" "check enum field lookup by name (v1)"
+ "= v1" "check enum field lookup by name, v1"
gdb_test "guile (print (field-name (type-field (value-type e) \"v3\")))" \
- "= v3" "check enum field lookup by name (v3)"
+ "= v3" "check enum field lookup by name, v3"
gdb_test "guile (print (iterator-map field-enumval (make-field-iterator (value-type e))))" \
"\\(0 1 2\\)" "check enum fields iteration"
}
@@ -218,7 +218,7 @@ proc test_enums {} {
proc test_base_class {} {
with_test_prefix "test_base_class" {
- gdb_scm_test_silent_cmd "print d" "print value (d)"
+ gdb_scm_test_silent_cmd "print d" "print value, d"
gdb_scm_test_silent_cmd "guile (define d (history-ref 0))" \
"get value (d) from history"
gdb_scm_test_silent_cmd "guile (define fields (type-fields (value-type d)))" \
@@ -226,9 +226,9 @@ proc test_base_class {} {
gdb_test "guile (print (length fields))" \
"= 3" "check the number of fields"
gdb_test "guile (print (field-baseclass? (car fields)))" \
- "= #t" "check base class (fields\[0\])"
+ "= #t" {check base class, fields[0]}
gdb_test "guile (print (field-baseclass? (cadr fields)))" \
- "= #f" "check base class (fields\[1\])"
+ "= #f" {check base class, fields[1]}
}
}
@@ -236,7 +236,7 @@ proc test_range {} {
with_test_prefix "test_range" {
with_test_prefix "on ranged value" {
# Test a valid range request.
- gdb_scm_test_silent_cmd "print ar" "print value (ar)"
+ gdb_scm_test_silent_cmd "print ar" "print value, ar"
gdb_scm_test_silent_cmd "guile (define ar (history-ref 0))" \
"get value (ar) from history"
gdb_test "guile (print (length (type-range (value-type ar))))" \
@@ -247,7 +247,7 @@ proc test_range {} {
with_test_prefix "on unranged value" {
# Test where a range does not exist.
- gdb_scm_test_silent_cmd "print st" "print value (st)"
+ gdb_scm_test_silent_cmd "print st" "print value, st"
gdb_scm_test_silent_cmd "guile (define st (history-ref 0))" \
"get value (st) from history"
gdb_test "guile (print (type-range (value-type st)))" \
@@ -256,7 +256,7 @@ proc test_range {} {
}
with_test_prefix "on flexible array member" {
- gdb_scm_test_silent_cmd "print f" "print value (f)"
+ gdb_scm_test_silent_cmd "print f" "print value, f"
gdb_scm_test_silent_cmd "guile (define f (history-ref 0))" \
"get value (f) from history"
gdb_test "guile (print (type-range (field-type (type-field (value-type (value-dereference f)) \"items\"))))" \
diff --git a/gdb/testsuite/gdb.mi/mi-stepi.exp b/gdb/testsuite/gdb.mi/mi-stepi.exp
index 3f4fc03..28aa293 100644
--- a/gdb/testsuite/gdb.mi/mi-stepi.exp
+++ b/gdb/testsuite/gdb.mi/mi-stepi.exp
@@ -41,25 +41,25 @@ proc test_stepi_nexti {} {
set line [mi_execute_to "exec-step-instruction" "end-stepping-range" "main" "" \
".*basics.c" "\[0-9\]+" "" "step-instruction at main"]
if { $line >= $line_main_body && $line <= $line_main_hello } {
- pass "step-instruction at main (line check)"
+ pass "step-instruction at main, line check"
} else {
- fail "step-instruction at main (line check)"
+ fail "step-instruction at main, line check"
}
set line [mi_execute_to "exec-next-instruction" "end-stepping-range" "main" "" \
".*basics.c" "\[0-9\]+" "" "next-instruction at main"]
if { $line >= $line_main_body && $line <= $line_main_hello } {
- pass "next-instruction at main (line check)"
+ pass "next-instruction at main, line check"
} else {
- fail "next-instruction at main (line check)"
+ fail "next-instruction at main, line check"
}
set line [mi_execute_to "exec-next-instruction" "end-stepping-range" "main" "" \
".*basics.c" "\[0-9\]+" "" "next-instruction at main 2"]
if { $line >= $line_main_body && $line <= $line_main_hello } {
- pass "next-instruction at main 2 (line check)"
+ pass "next-instruction at main 2, line check"
} else {
- fail "next-instruction at main 2 (line check)"
+ fail "next-instruction at main 2, line check"
}
}
diff --git a/gdb/testsuite/gdb.mi/mi-var-cmd.exp b/gdb/testsuite/gdb.mi/mi-var-cmd.exp
index a4789e5..1f97200 100644
--- a/gdb/testsuite/gdb.mi/mi-var-cmd.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-cmd.exp
@@ -150,7 +150,7 @@ mi_gdb_test "-var-update *" \
"update all vars: linteger changed"
# Step over "lpinteger = &linteger;"
-mi_step_to "do_locals_tests" "" "var-cmd.c" [expr $line_dlt_linteger + 1] "step at do_locals_tests (2)"
+mi_step_to "do_locals_tests" "" "var-cmd.c" [expr $line_dlt_linteger + 1] "step at do_locals_tests, 2"
# Test: c_variable-2.3
# Desc: check whether only lpinteger changed
@@ -159,7 +159,7 @@ mi_gdb_test "-var-update *" \
"update all vars: lpinteger changed"
# Step over "lcharacter = 'a';"
-mi_step_to "do_locals_tests" "" "var-cmd.c" [expr $line_dlt_linteger + 2] "step at do_locals_tests (3)"
+mi_step_to "do_locals_tests" "" "var-cmd.c" [expr $line_dlt_linteger + 2] "step at do_locals_tests, 3"
# Test: c_variable-2.4
# Desc: check whether only lcharacter changed
@@ -168,7 +168,7 @@ mi_gdb_test "-var-update *" \
"update all vars: lcharacter changed"
# Step over "lpcharacter = &lcharacter;"
-mi_step_to "do_locals_tests" "" "var-cmd.c" [expr $line_dlt_linteger + 3] "step at do_locals_tests (4)"
+mi_step_to "do_locals_tests" "" "var-cmd.c" [expr $line_dlt_linteger + 3] "step at do_locals_tests, 4"
# Test: c_variable-2.5
# Desc: check whether only lpcharacter changed
@@ -189,7 +189,7 @@ mi_gdb_test "-var-update *" \
# lsimple.character = 'a';
mi_execute_to "exec-step 9" "end-stepping-range" "do_locals_tests" "" \
- "var-cmd.c" [expr $line_dlt_linteger + 12] "" "step at do_locals_tests (5)"
+ "var-cmd.c" [expr $line_dlt_linteger + 12] "" "step at do_locals_tests, 5"
# Test: c_variable-2.6
# Desc: check whether llong, lplong, lfloat, lpfloat, ldouble, lpdouble, lsimple.integer,
@@ -207,7 +207,7 @@ mi_gdb_test "-var-update *" \
set line_dlt_4321 [gdb_get_line_number "linteger = 4321;"]
mi_execute_to "exec-step 4" "end-stepping-range" "do_locals_tests" "" \
- "var-cmd.c" $line_dlt_4321 "" "step at do_locals_tests (6)"
+ "var-cmd.c" $line_dlt_4321 "" "step at do_locals_tests, 6"
# Test: c_variable-2.7
# Desc: check whether (lsimple.signed_character, lsimple.char_ptr) lpsimple, func changed
@@ -226,7 +226,7 @@ mi_gdb_test "-var-update *" \
# lsimple.character = 'b';
mi_execute_to "exec-step 8" "end-stepping-range" "do_locals_tests" "" \
- "var-cmd.c" [expr $line_dlt_4321 + 8] "" "step at do_locals_tests (7)"
+ "var-cmd.c" [expr $line_dlt_4321 + 8] "" "step at do_locals_tests, 7"
# Test: c_variable-2.8
# Desc: check whether linteger, lcharacter, llong, lfoat, ldouble, lsimple.integer,
@@ -374,7 +374,7 @@ mi_gdb_test "-var-assign func do_block_tests" \
mi_gdb_test "-var-update *" \
"\\^done,changelist=\\\[\\\]" \
- "assign same value to func (update)"
+ "assign same value to func, update"
mi_gdb_test "-var-create array_ptr * array_ptr" \
"\\^done,name=\"array_ptr\",numchild=\"1\",value=\"$hex <array>\",type=\"int \\*\",has_more=\"0\"" \
@@ -386,7 +386,7 @@ mi_gdb_test "-var-assign array_ptr array2" \
mi_gdb_test "-var-update *" \
"\\^done,changelist=\\\[\{name=\"array_ptr\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
- "assign array to pointer (update)"
+ "assign array to pointer, update"
mi_gdb_test "-var-assign array_ptr array2" \
"\\^done,value=\"$hex <array2>\"" \
@@ -394,7 +394,7 @@ mi_gdb_test "-var-assign array_ptr array2" \
mi_gdb_test "-var-update *" \
"\\^done,changelist=\\\[\\\]" \
- "assign same array to pointer (update)"
+ "assign same array to pointer, update"
######
@@ -434,7 +434,7 @@ mi_gdb_test "-var-update *" \
clear_xfail *-*-*
mi_step_to "subroutine1" "\{name=\"i\",value=\".*\"\},\{name=\"l\",value=\".*\"\}" \
- "var-cmd.c" [expr $line_subroutine1_body + 2] "step at subroutine1 (2)"
+ "var-cmd.c" [expr $line_subroutine1_body + 2] "step at subroutine1, 2"
# Test: c_variable-2.13
# Desc: change subroutine1 local i
@@ -443,7 +443,7 @@ mi_gdb_test "-var-update *" \
"update all vars: i changed"
mi_step_to "subroutine1" "\{name=\"i\",value=\".*\"\},\{name=\"l\",value=\".*\"\}" \
- "var-cmd.c" [expr $line_subroutine1_body + 3] "step at subroutine1 (3)"
+ "var-cmd.c" [expr $line_subroutine1_body + 3] "step at subroutine1, 3"
# Test: c_variable-2.14
# Desc: change do_locals_tests local llong
diff --git a/gdb/testsuite/gdb.mi/mi-var-cp.cc b/gdb/testsuite/gdb.mi/mi-var-cp.cc
index 4befab9..e8dd325 100644
--- a/gdb/testsuite/gdb.mi/mi-var-cp.cc
+++ b/gdb/testsuite/gdb.mi/mi-var-cp.cc
@@ -19,15 +19,15 @@ void reference_update_tests ()
int x = 167;
/*: mi_create_varobj "RX" "rx" "create varobj for rx" :*/
int& rx = x;
- /*: mi_varobj_update RX {RX} "update RX (1)"
+ /*: mi_varobj_update RX {RX} "update RX, 1"
mi_check_varobj_value RX 167 "check RX: expect 167"
:*/
x = 567;
- /*: mi_varobj_update RX {RX} "update RX (2)"
+ /*: mi_varobj_update RX {RX} "update RX, 2"
mi_check_varobj_value RX 567 "check RX: expect 567"
:*/
x = 567;
- /*: mi_varobj_update RX {} "update RX (3)"
+ /*: mi_varobj_update RX {} "update RX, 3"
mi_delete_varobj RX "delete RX"
:*/
/* Dummy assignment to keep 'x' in scope. */
diff --git a/gdb/testsuite/gdb.mi/mi-var-display.exp b/gdb/testsuite/gdb.mi/mi-var-display.exp
index 560a871..b420d12 100644
--- a/gdb/testsuite/gdb.mi/mi-var-display.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-display.exp
@@ -237,11 +237,11 @@ mi_list_varobj_children weird {
# Desc: change format of weird.func_ptr and weird.func_ptr_ptr
mi_gdb_test "-var-set-format weird.func_ptr hexadecimal" \
"\\^done,format=\"hexadecimal\",value=\"$hex\"" \
- "set format variable weird.func_ptr in hex (1)"
+ "set format variable weird.func_ptr in hex, 1"
mi_gdb_test "-var-show-format weird.func_ptr" \
"\\^done,format=\"hexadecimal\"" \
- "show format variable weird.func_ptr (hex)"
+ "show format variable weird.func_ptr, hex"
mi_gdb_test "-var-set-format weird.func_ptr_ptr hexadecimal" \
"\\^done,format=\"hexadecimal\",value=\"$hex\"" \
@@ -249,7 +249,7 @@ mi_gdb_test "-var-set-format weird.func_ptr_ptr hexadecimal" \
mi_gdb_test "-var-show-format weird.func_ptr_ptr" \
"\\^done,format=\"hexadecimal\"" \
- "show format variable weird.func_ptr_ptr (hex)"
+ "show format variable weird.func_ptr_ptr, hex"
mi_gdb_test "-var-set-format weird.func_ptr zero-hexadecimal" \
"\\^done,format=\"zero-hexadecimal\",value=\"$hex\"" \
@@ -257,7 +257,7 @@ mi_gdb_test "-var-set-format weird.func_ptr zero-hexadecimal" \
mi_gdb_test "-var-show-format weird.func_ptr" \
"\\^done,format=\"zero-hexadecimal\"" \
- "show format variable weird.func_ptr (zhex)"
+ "show format variable weird.func_ptr, zhex"
mi_gdb_test "-var-set-format weird.func_ptr_ptr zero-hexadecimal" \
"\\^done,format=\"zero-hexadecimal\",value=\"$hex\"" \
@@ -265,7 +265,7 @@ mi_gdb_test "-var-set-format weird.func_ptr_ptr zero-hexadecimal" \
mi_gdb_test "-var-show-format weird.func_ptr_ptr" \
"\\^done,format=\"zero-hexadecimal\"" \
- "show format variable weird.func_ptr_ptr (zhex)"
+ "show format variable weird.func_ptr_ptr, zhex"
# Test: c_variable-6.24
# Desc: format of weird and children
@@ -299,7 +299,7 @@ mi_gdb_test "-var-set-format weird.long_array natural" \
mi_gdb_test "-var-set-format weird.func_ptr hexadecimal" \
"\\^done,format=\"hexadecimal\",value=\"$hex\"" \
- "set format variable weird.func_ptr in hex (2)"
+ "set format variable weird.func_ptr in hex, 2"
mi_gdb_test "-var-set-format weird.func_ptr_struct hexadecimal" \
"\\^done,format=\"hexadecimal\",value=\"$hex\"" \
diff --git a/gdb/testsuite/gdb.mi/mi-var-invalidate.exp b/gdb/testsuite/gdb.mi/mi-var-invalidate.exp
index 7ea2d17..60e29a9 100644
--- a/gdb/testsuite/gdb.mi/mi-var-invalidate.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-invalidate.exp
@@ -80,7 +80,7 @@ mi_gdb_test "-var-update linteger" \
mi_gdb_test "-var-info-type linteger" \
"\\^done,type=\"\"" \
- "no type for invalid variable linteger (1)"
+ "no type for invalid variable linteger, 1"
# Check global variable is still correct.
mi_gdb_test "-var-update global_simple" \
@@ -105,7 +105,7 @@ mi_gdb_test "-var-update linteger" \
mi_gdb_test "-var-info-type linteger" \
"\\^done,type=\"\"" \
- "no type for invalid variable linteger (2)"
+ "no type for invalid variable linteger, 2"
# Check global variable are still correct.
mi_gdb_test "-var-update global_simple" \
diff --git a/gdb/testsuite/gdb.mi/var-cmd.c b/gdb/testsuite/gdb.mi/var-cmd.c
index 963bcd4..3aa5126 100644
--- a/gdb/testsuite/gdb.mi/var-cmd.c
+++ b/gdb/testsuite/gdb.mi/var-cmd.c
@@ -485,15 +485,15 @@ void do_at_tests ()
:*/
i++;
/*:
- mi_varobj_update F {F} "update F (1)"
- mi_check_varobj_value F 11 "check F (1)"
+ mi_varobj_update F {F} "update F, 1"
+ mi_check_varobj_value F 11 "check F, 1"
:*/
i++;
{
double i = 15;
/*:
- mi_varobj_update_with_type_change F "double" "0" "update F (2)"
- mi_check_varobj_value F 15 "check F (2)"
+ mi_varobj_update_with_type_change F "double" "0" "update F, 2"
+ mi_check_varobj_value F 15 "check F, 2"
:*/
i += 2.0;
}
@@ -506,8 +506,8 @@ void do_at_tests ()
}
i++;
/*:
- mi_varobj_update_with_type_change F "int" "0" "update F (3)"
- mi_check_varobj_value F 13 "check F (3)"
+ mi_varobj_update_with_type_change F "int" "0" "update F, 3"
+ mi_check_varobj_value F 13 "check F, 3"
:*/
i++;
do_at_tests_callee ();
diff --git a/gdb/testsuite/gdb.multi/base.exp b/gdb/testsuite/gdb.multi/base.exp
index db11bcd..834d961 100644
--- a/gdb/testsuite/gdb.multi/base.exp
+++ b/gdb/testsuite/gdb.multi/base.exp
@@ -139,14 +139,14 @@ gdb_test "list commonfun" "from hello.*" "list commonfun in hello"
gdb_test "print hglob" "1"
-gdb_test "print glob" "92" "print glob (${exec1})"
+gdb_test "print glob" "92" "print glob, ${exec1}"
gdb_test "inferior 3" ".*" "switch to inferior 3 to print globals"
gdb_test "print gglob" "2"
-gdb_test "print glob" "45" "print glob (${exec3})"
+gdb_test "print glob" "45" "print glob, ${exec3}"
gdb_test "list commonfun" "from goodbye.*" "list commonfun in goodbye"
diff --git a/gdb/testsuite/gdb.multi/dummy-frame-restore.exp b/gdb/testsuite/gdb.multi/dummy-frame-restore.exp
index 31d05e3..0bc5e6a 100644
--- a/gdb/testsuite/gdb.multi/dummy-frame-restore.exp
+++ b/gdb/testsuite/gdb.multi/dummy-frame-restore.exp
@@ -62,12 +62,12 @@ proc test { inf1 inf2 } {
with_test_prefix "inf $inf1 first" {
gdb_test "inferior 2" "witching to inferior 2 .*" \
- "switch to inferior 2 (1)"
+ "switch to inferior 2, 1"
check_bt 2 "before infcall"
gdb_test "p commonfun()" "Breakpoint .*The program being debugged stopped while in a function called from GDB.*" "infcall in inferior 2"
gdb_test "inferior 1" "witching to inferior 1 .*" \
- "switch to inferior 1 (1)"
+ "switch to inferior 1, 1"
check_bt 1 "before infcall"
gdb_test "p commonfun()" "Breakpoint .*The program being debugged stopped while in a function called from GDB.*" "infcall in inferior 1"
@@ -75,13 +75,13 @@ proc test { inf1 inf2 } {
"two dummy frames"
gdb_test "inferior $inf1" "witching to inferior $inf1 .*" \
- "switch to inferior $inf1 (2)"
+ "switch to inferior $inf1, 2"
gdb_test "finish" "Run till exit from #0 commonfun .*" \
"finish in inferior $inf1"
check_bt $inf1 "after infcall"
gdb_test "inferior $inf2" "witching to inferior $inf2 .*" \
- "switch to inferior $inf2 (2)"
+ "switch to inferior $inf2, 2"
gdb_test "finish" "Run till exit from #0 commonfun .*" \
"finish in inferior $inf2"
check_bt $inf2 "after infcall"
diff --git a/gdb/testsuite/gdb.multi/pending-bp-lib.c b/gdb/testsuite/gdb.multi/pending-bp-lib.c
new file mode 100644
index 0000000..c48e7f2
--- /dev/null
+++ b/gdb/testsuite/gdb.multi/pending-bp-lib.c
@@ -0,0 +1,22 @@
+/* Copyright 2023-2024 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int global_var = 0;
+
+void
+foo (int arg)
+{
+ global_var = arg;
+}
diff --git a/gdb/testsuite/gdb.multi/pending-bp.c b/gdb/testsuite/gdb.multi/pending-bp.c
new file mode 100644
index 0000000..17d9181
--- /dev/null
+++ b/gdb/testsuite/gdb.multi/pending-bp.c
@@ -0,0 +1,66 @@
+/* Copyright 2023-2024 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <dlfcn.h>
+#include <stdlib.h>
+
+void
+breakpt (void)
+{
+ /* Nothing. */
+}
+
+volatile int global_counter = 0;
+
+volatile int call_count = 1;
+
+int
+main (void)
+{
+ void *handle;
+ void (*func)(int);
+
+ /* Some filler work so that we don't initially stop on the breakpt call
+ below. */
+ ++global_counter;
+
+ breakpt (); /* Break before open. */
+
+ /* Now load the shared library. */
+ handle = dlopen (SHLIB_NAME, RTLD_LAZY);
+ if (handle == NULL)
+ abort ();
+
+ breakpt (); /* Break after open. */
+
+ /* Find the function symbol. */
+ func = (void (*)(int)) dlsym (handle, "foo");
+
+ for (; call_count > 0; --call_count)
+ {
+ /* Call the library function. */
+ func (1);
+ }
+
+ breakpt (); /* Break before close. */
+
+ /* Unload the shared library. */
+ if (dlclose (handle) != 0)
+ abort ();
+
+ breakpt (); /* Break after close. */
+
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.multi/pending-bp.exp b/gdb/testsuite/gdb.multi/pending-bp.exp
new file mode 100644
index 0000000..13f76f4
--- /dev/null
+++ b/gdb/testsuite/gdb.multi/pending-bp.exp
@@ -0,0 +1,126 @@
+# Copyright 2023-2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Tests related to pending breakpoints in a multi-inferior environment.
+
+require allow_shlib_tests !use_gdb_stub
+
+standard_testfile
+
+set libname $testfile-lib
+set srcfile_lib $srcdir/$subdir/$libname.c
+set binfile_lib [standard_output_file $libname.so]
+
+if { [gdb_compile_shlib $srcfile_lib $binfile_lib {}] != "" } {
+ untested "failed to compile shared library 1"
+ return -1
+}
+
+set binfile_lib_target [gdb_download_shlib $binfile_lib]
+
+if { [build_executable "failed to prepare" $testfile $srcfile \
+ [list debug \
+ additional_flags=-DSHLIB_NAME=\"$binfile_lib_target\" \
+ shlib_load]] } {
+ return -1
+}
+
+# Start two inferiors, both running the same test binary. The arguments
+# INF_1_STOP and INF_2_STOP are source code patterns that are passed to
+# gdb_get_line_number to figure out where each inferior should be stopped.
+#
+# This proc does a clean_restart and leaves inferior 2 selected. Also the
+# 'breakpoint pending' flag is enabled, so pending breakpoints can be created
+# without GDB prompting the user.
+proc do_test_setup { inf_1_stop inf_2_stop } {
+ clean_restart ${::binfile}
+
+ gdb_locate_shlib $::binfile_lib
+
+ if {![runto_main]} {
+ return false
+ }
+
+ gdb_breakpoint [gdb_get_line_number ${inf_1_stop}] temporary
+ gdb_continue_to_breakpoint "move inferior 1 into position"
+
+ gdb_test "add-inferior -exec ${::binfile}" \
+ "Added inferior 2.*" "add inferior 2"
+ gdb_test "inferior 2" "Switching to inferior 2 .*" "switch to inferior 2"
+
+ if {![runto_main]} {
+ return false
+ }
+
+ gdb_breakpoint [gdb_get_line_number ${inf_2_stop}] temporary
+ gdb_continue_to_breakpoint "move inferior 2 into position"
+
+ gdb_test_no_output "set breakpoint pending on"
+
+ return true
+}
+
+# Check that when a breakpoint is in the pending state, but that breakpoint
+# does have some locations (those locations themselves are pending), GDB
+# doesn't display the inferior list in the 'info breakpoints' output.
+proc_with_prefix test_no_inf_display {} {
+ do_test_setup "Break before open" "Break before open"
+
+ # Create a breakpoint on 'foo'. As the shared library (that
+ # contains foo) has not been loaded into any inferior yet, then
+ # there will be no locations and the breakpoint will be created
+ # pending. Pass the 'allow-pending' flag so the gdb_breakpoint
+ # correctly expects the new breakpoint to be pending.
+ gdb_breakpoint "foo" allow-pending
+ set bpnum [get_integer_valueof "\$bpnum" "*INVALID*" \
+ "get foo breakpoint number"]
+
+ # Check the 'info breakpoints' output; the breakpoint is pending with
+ # no 'inf X' appearing at the end of the line.
+ gdb_test "info breakpoint $bpnum" \
+ "$bpnum\\s+breakpoint\\s+keep\\s+y\\s+<PENDING>\\s+foo" \
+ "check info bp before locations have been created"
+
+ # Now select inferior 1 and allow the inferior to run forward to the
+ # point where a breakpoint location for foo will have been created.
+ gdb_test "inferior 1" "Switching to inferior 1 .*"
+ gdb_breakpoint [gdb_get_line_number "Break after open"] temporary
+ gdb_continue_to_breakpoint \
+ "move inferior 1 until a location has been added"
+
+ # Check the 'info breakpoints' output. Notice we display the inferior
+ # list at the end of the breakpoint line.
+ gdb_test "info breakpoint $bpnum" \
+ "$bpnum\\s+breakpoint\\s+keep\\s+y\\s+$::hex\\s+<foo\[^>\]*>\\s+inf 1" \
+ "check info breakpoints while breakpoint is inserted"
+
+ # Continue inferior 1 until the shared library has been unloaded. The
+ # breakpoint on 'foo' will return to the pending state. We will need to
+ # 'continue' twice as the first time will hit the 'foo' breakpoint.
+ gdb_breakpoint [gdb_get_line_number "Break after close"] temporary
+ gdb_continue_to_breakpoint "hit the breakpoint in foo"
+ gdb_continue_to_breakpoint "after close library"
+
+ # Check the 'info breakpoints' output, check there is no 'inf 1' at the
+ # end of the breakpoint line.
+ gdb_test "info breakpoint $bpnum" \
+ [multi_line \
+ "$bpnum\\s+breakpoint\\s+keep\\s+y\\s+<PENDING>\\s+foo" \
+ "\\s+breakpoint already hit 1 time"] \
+ "check info breakpoints while breakpoint is pending"
+}
+
+# Run all the tests.
+test_no_inf_display
diff --git a/gdb/testsuite/gdb.opt/inline-bt.exp b/gdb/testsuite/gdb.opt/inline-bt.exp
index 7220ec7..9e1fb19 100644
--- a/gdb/testsuite/gdb.opt/inline-bt.exp
+++ b/gdb/testsuite/gdb.opt/inline-bt.exp
@@ -32,23 +32,23 @@ if { [skip_inline_frame_tests] } {
set line1 [gdb_get_line_number "set breakpoint 1 here" ${srcfile2}]
gdb_breakpoint $srcfile2:$line1
-gdb_test "continue" ".*set breakpoint 1 here.*" "continue to bar (1)"
-gdb_test "backtrace" "#0 bar.*#1 .*main.*" "backtrace from bar (1)"
+gdb_test "continue" ".*set breakpoint 1 here.*" "continue to bar, 1"
+gdb_test "backtrace" "#0 bar.*#1 .*main.*" "backtrace from bar, 1"
gdb_test "info frame" ".*called by frame.*" "bar not inlined"
-gdb_test "continue" ".*set breakpoint 1 here.*" "continue to bar (2)"
+gdb_test "continue" ".*set breakpoint 1 here.*" "continue to bar, 2"
gdb_test "backtrace" "#0 bar.*#1 .*func1.*#2 .*main.*" \
- "backtrace from bar (2)"
-gdb_test "up" "#1 .*func1.*" "up from bar (2)"
-gdb_test "info frame" ".*inlined into frame.*" "func1 inlined (2)"
+ "backtrace from bar, 2"
+gdb_test "up" "#1 .*func1.*" "up from bar, 2"
+gdb_test "info frame" ".*inlined into frame.*" "func1 inlined, 2"
-gdb_test "continue" ".*set breakpoint 1 here.*" "continue to bar (3)"
+gdb_test "continue" ".*set breakpoint 1 here.*" "continue to bar, 3"
gdb_test "backtrace" "#0 bar.*#1 .*func1.*#2 .*func2.*#3 .*main.*" \
- "backtrace from bar (3)"
-gdb_test "up" "#1 .*func1.*" "up from bar (3)"
-gdb_test "info frame" ".*inlined into frame.*" "func1 inlined (3)"
-gdb_test "up" "#2 .*func2.*" "up from func1 (3)"
-gdb_test "info frame" ".*inlined into frame.*" "func2 inlined (3)"
+ "backtrace from bar, 3"
+gdb_test "up" "#1 .*func1.*" "up from bar, 3"
+gdb_test "info frame" ".*inlined into frame.*" "func1 inlined, 3"
+gdb_test "up" "#2 .*func2.*" "up from func1, 3"
+gdb_test "info frame" ".*inlined into frame.*" "func2 inlined, 3"
# A regression test for having a backtrace limit that forces unwinding
# to stop after an inline frame. GDB needs to compute the frame_id of
@@ -61,7 +61,7 @@ gdb_test "info frame" ".*inlined into frame.*" "func2 inlined (3)"
gdb_test_no_output "set backtrace limit 2"
# Force flushing the frame cache.
gdb_test "maint flush register-cache" "Register cache flushed."
-gdb_test "up" "#1 .*func1.*" "up from bar (4)"
+gdb_test "up" "#1 .*func1.*" "up from bar, 4"
gdb_test "info frame" ".*in func1.*" "info frame still works"
# Verify the user visible limit works as expected.
gdb_test "up" "Initial frame selected; you cannot go up." "up hits limit"
diff --git a/gdb/testsuite/gdb.opt/inline-cmds.exp b/gdb/testsuite/gdb.opt/inline-cmds.exp
index bd645e5..7a9f2e0 100644
--- a/gdb/testsuite/gdb.opt/inline-cmds.exp
+++ b/gdb/testsuite/gdb.opt/inline-cmds.exp
@@ -40,19 +40,19 @@ gdb_breakpoint $srcfile2:$line1
set line2 [gdb_get_line_number "set breakpoint 2 here" ${srcfile2}]
gdb_breakpoint $srcfile2:$line2
-gdb_test "continue" ".*set breakpoint 1 here.*" "continue to bar (1)"
+gdb_test "continue" ".*set breakpoint 1 here.*" "continue to bar, 1"
gdb_test "backtrace" "#0 bar.*#1 .*func1.*#2 .*main.*" \
- "backtrace from bar (1)"
-gdb_test "up" "#1 .*func1.*" "up from bar (1)"
-gdb_test "info frame" ".*inlined into frame.*" "func1 inlined (1)"
+ "backtrace from bar, 1"
+gdb_test "up" "#1 .*func1.*" "up from bar, 1"
+gdb_test "info frame" ".*inlined into frame.*" "func1 inlined, 1"
-gdb_test "continue" ".*set breakpoint 1 here.*" "continue to bar (2)"
+gdb_test "continue" ".*set breakpoint 1 here.*" "continue to bar, 2"
gdb_test "backtrace" "#0 bar.*#1 .*func1.*#2 .*func2.*#3 .*main.*" \
"backtrace from bar (2)"
-gdb_test "up" "#1 .*func1.*" "up from bar (2)"
-gdb_test "info frame" ".*inlined into frame.*" "func1 inlined (2)"
-gdb_test "up" "#2 .*func2.*" "up from func1 (2)"
-gdb_test "info frame" ".*inlined into frame.*" "func2 inlined (2)"
+gdb_test "up" "#1 .*func1.*" "up from bar, 2"
+gdb_test "info frame" ".*inlined into frame.*" "func1 inlined, 2"
+gdb_test "up" "#2 .*func2.*" "up from func1, 2"
+gdb_test "info frame" ".*inlined into frame.*" "func2 inlined, 2"
gdb_test "continue" ".*set breakpoint 2 here.*" "continue to marker"
gdb_test "backtrace" "#0 marker.*#1 .*main.*" "backtrace from marker"
diff --git a/gdb/testsuite/gdb.python/py-cmd.exp b/gdb/testsuite/gdb.python/py-cmd.exp
index 82cb4cb..b083a80 100644
--- a/gdb/testsuite/gdb.python/py-cmd.exp
+++ b/gdb/testsuite/gdb.python/py-cmd.exp
@@ -128,19 +128,19 @@ gdb_test "test_error_cmd ugh" "you lose!" "call error command"
gdb_test "python print (gdb.string_to_argv (\"1 2 3\"))" \
{\['1', '2', '3'\]} \
- "string_to_argv (\"1 2 3\")"
+ "string_to_argv (\"1 2 3\"), case 1"
gdb_test "python print (gdb.string_to_argv (\"'1 2' 3\"))" \
{\['1 2', '3'\]} \
- "string_to_argv (\"'1 2' 3\")"
+ "string_to_argv (\"'1 2' 3\"), case 2"
gdb_test "python print (gdb.string_to_argv ('\"1 2\" 3'))" \
{\['1 2', '3'\]} \
- "string_to_argv ('\"1 2\" 3')"
+ "string_to_argv ('\"1 2\" 3'), case 3"
gdb_test "python print (gdb.string_to_argv ('1\\ 2 3'))" \
{\['1 2', '3'\]} \
- "string_to_argv ('1\\ 2 3')"
+ "string_to_argv ('1\\ 2 3'), case 4"
# Test user-defined python commands.
gdb_test_multiline "input simple user-defined command" \
diff --git a/gdb/testsuite/gdb.python/py-disasm-exec.exp b/gdb/testsuite/gdb.python/py-disasm-exec.exp
new file mode 100644
index 0000000..546c4b8
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-disasm-exec.exp
@@ -0,0 +1,21 @@
+# Copyright (C) 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the GDB testsuite. It validates the Python
+# disassembler API.
+
+set kind exec
+
+source $srcdir/$subdir/py-disasm.exp.tcl
diff --git a/gdb/testsuite/gdb.python/py-disasm-obj.exp b/gdb/testsuite/gdb.python/py-disasm-obj.exp
new file mode 100644
index 0000000..37ff965
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-disasm-obj.exp
@@ -0,0 +1,21 @@
+# Copyright (C) 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the GDB testsuite. It validates the Python
+# disassembler API.
+
+set kind obj
+
+source $srcdir/$subdir/py-disasm.exp.tcl
diff --git a/gdb/testsuite/gdb.python/py-disasm.exp b/gdb/testsuite/gdb.python/py-disasm.exp.tcl
index 5d7d922..8ed634e 100644
--- a/gdb/testsuite/gdb.python/py-disasm.exp
+++ b/gdb/testsuite/gdb.python/py-disasm.exp.tcl
@@ -20,26 +20,54 @@ load_lib gdb-python.exp
require allow_python_tests
-standard_testfile
+standard_testfile py-disasm.c
-if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} "debug"] } {
- return -1
-}
+if { $kind == "obj" } {
+
+ set obj [standard_output_file ${gdb_test_file_name}.o]
+
+ if { [gdb_compile "$srcdir/$subdir/$srcfile" $obj object "debug"] != "" } {
+ untested "failed to compile object file [file tail $obj]"
+ return -1
+ }
+
+ clean_restart $obj
+
+} else {
+
+ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
+ return -1
+ }
+
+ if { ![runto_main] } {
+ fail "can't run to main"
+ return 0
+ }
-if {![runto_main]} {
- fail "can't run to main"
- return 0
}
-set pyfile [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py]
+set pyfile [gdb_remote_download host ${srcdir}/${subdir}/py-disasm.py]
gdb_test "source ${pyfile}" "Python script imported" \
"import python scripts"
-gdb_breakpoint [gdb_get_line_number "Break here."]
-gdb_continue_to_breakpoint "Break here."
+set line [gdb_get_line_number "Break here."]
-set curr_pc [get_valueof "/x" "\$pc" "*unknown*"]
+if { $kind == "obj" } {
+ set curr_pc "*unknown*"
+ set line [gdb_get_line_number "Break here."]
+ gdb_test_multiple "info line $line" "" {
+ -re -wrap "starts at address ($hex) \[^\r\n\]*" {
+ set curr_pc $expect_out(1,string)
+ pass $gdb_test_name
+ }
+ }
+} else {
+ gdb_breakpoint $line
+ gdb_continue_to_breakpoint "Break here."
+
+ set curr_pc [get_valueof "/x" "\$pc" "*unknown*"]
+}
gdb_test_no_output "python current_pc = ${curr_pc}"
@@ -67,7 +95,11 @@ proc py_remove_all_disassemblers {} {
# Python disassembler API.
set nop "(nop|nop\t0|[string_to_regexp nop\t{0}])"
set unknown_error_pattern "unknown disassembler error \\(error = -1\\)"
-set addr_pattern "\r\n=> ${curr_pc_pattern} <\[^>\]+>:\\s+"
+if { $kind == "obj" } {
+ set addr_pattern "\r\n ${curr_pc_pattern} <\[^>\]+>:\\s+"
+} else {
+ set addr_pattern "\r\n=> ${curr_pc_pattern} <\[^>\]+>:\\s+"
+}
set base_pattern "${addr_pattern}${nop}"
# Helper proc to format a Python exception of TYPE with MSG.
diff --git a/gdb/testsuite/gdb.python/py-disasm.py b/gdb/testsuite/gdb.python/py-disasm.py
index 2741fdb..f105657 100644
--- a/gdb/testsuite/gdb.python/py-disasm.py
+++ b/gdb/testsuite/gdb.python/py-disasm.py
@@ -252,7 +252,7 @@ class MemoryErrorEarlyDisassembler(TestDisassembler):
def disassemble(self, info):
tag = "## FAIL"
try:
- info.read_memory(1, -info.address + 2)
+ info.read_memory(1, -info.address - 1)
except gdb.MemoryError:
tag = "## AFTER ERROR"
result = builtin_disassemble_wrapper(info)
@@ -267,7 +267,7 @@ class MemoryErrorLateDisassembler(TestDisassembler):
def disassemble(self, info):
result = builtin_disassemble_wrapper(info)
# The following read will throw an error.
- info.read_memory(1, -info.address + 2)
+ info.read_memory(1, -info.address - 1)
return DisassemblerResult(1, "BAD")
@@ -276,9 +276,9 @@ class RethrowMemoryErrorDisassembler(TestDisassembler):
def disassemble(self, info):
try:
- info.read_memory(1, -info.address + 2)
+ info.read_memory(1, -info.address - 1)
except gdb.MemoryError as e:
- raise gdb.MemoryError("cannot read code at address 0x2")
+ raise gdb.MemoryError("cannot read code at address -1")
return DisassemblerResult(1, "BAD")
diff --git a/gdb/testsuite/gdb.python/py-format-string.exp b/gdb/testsuite/gdb.python/py-format-string.exp
index 0c70ad5..9209213 100644
--- a/gdb/testsuite/gdb.python/py-format-string.exp
+++ b/gdb/testsuite/gdb.python/py-format-string.exp
@@ -1104,10 +1104,16 @@ proc_with_prefix test_invalid_args {} {
"12" \
"TypeError.*: format_string\\(\\) takes 0 positional arguments but 1 were given.*"
+ # For python <= 3.12.
+ set re1 \
+ "TypeError.*: 'invalid' is an invalid keyword argument for this function"
+ # For python >= 3.13.
+ set re2 \
+ "TypeError.*: this function got an unexpected keyword argument 'invalid'"
check_format_string \
"a_point_t" \
"invalid=True" \
- "TypeError.*: 'invalid' is an invalid keyword argument for this function.*"
+ "($re1|$re2).*"
check_format_string \
"a_point_t" \
diff --git a/gdb/testsuite/gdb.python/py-frame.exp b/gdb/testsuite/gdb.python/py-frame.exp
index 8f776eb..0f1528e 100644
--- a/gdb/testsuite/gdb.python/py-frame.exp
+++ b/gdb/testsuite/gdb.python/py-frame.exp
@@ -127,10 +127,10 @@ gdb_test "python print (f1 == gdb.newest_frame())" False \
gdb_test "python print (bframe == gdb.newest_frame())" True \
"newest frame -vs- newest frame"
-gdb_test "python print ('result = %s' % (f0 == f1))" " = False" "test equality comparison (false)"
-gdb_test "python print ('result = %s' % (f0 == f0))" " = True" "test equality comparison (true)"
-gdb_test "python print ('result = %s' % (f0 != f1))" " = True" "test inequality comparison (true)"
-gdb_test "python print ('result = %s' % (f0 != f0))" " = False" "test inequality comparison (false)"
+gdb_test "python print ('result = %s' % (f0 == f1))" " = False" "test equality comparison, false"
+gdb_test "python print ('result = %s' % (f0 == f0))" " = True" "test equality comparison, true"
+gdb_test "python print ('result = %s' % (f0 != f1))" " = True" "test inequality comparison, true"
+gdb_test "python print ('result = %s' % (f0 != f0))" " = False" "test inequality comparison, false"
gdb_test "python print ('result = %s' % f0.is_valid ())" " = True" "test Frame.is_valid"
gdb_test "python print ('result = %s' % f0.name ())" " = f2" "test Frame.name"
gdb_test "python print ('result = %s' % (f0.type () == gdb.NORMAL_FRAME))" " = True" "test Frame.type"
diff --git a/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp b/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp
index 481eead..0e78f8d 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp
+++ b/gdb/testsuite/gdb.python/py-framefilter-invalidarg.exp
@@ -58,4 +58,4 @@ set remote_python_file [gdb_remote_download host \
${srcdir}/${subdir}/${testfile}.py]
gdb_test_no_output "source ${remote_python_file}" "load python file"
-gdb_test "bt" "niam \\(argc=<error reading variable: dwarf expression stack underflow>, argv=0x\[0-9a-f\]+\\) at py-framefilter-invalidarg.c:\[0-9\]+" "bt full with filters"
+gdb_test "bt" "niam \\(argc=<error reading variable: dwarf expression stack underflow>, argv=0x\[0-9a-f\]+\\) at \[^\r\n\]*py-framefilter-invalidarg.c:\[0-9\]+" "bt full with filters"
diff --git a/gdb/testsuite/gdb.python/py-missing-debug.exp b/gdb/testsuite/gdb.python/py-missing-debug.exp
index d1eef34..dfc0a46 100644
--- a/gdb/testsuite/gdb.python/py-missing-debug.exp
+++ b/gdb/testsuite/gdb.python/py-missing-debug.exp
@@ -19,7 +19,8 @@ require allow_python_tests
standard_testfile
-if {[build_executable "failed to prepare" ${testfile} ${srcfile}]} {
+if {[build_executable "failed to prepare" ${testfile} ${srcfile} \
+ {debug build-id}]} {
return -1
}
diff --git a/gdb/testsuite/gdb.python/py-progspace.exp b/gdb/testsuite/gdb.python/py-progspace.exp
index 0ae5b56..fe46537 100644
--- a/gdb/testsuite/gdb.python/py-progspace.exp
+++ b/gdb/testsuite/gdb.python/py-progspace.exp
@@ -42,7 +42,7 @@ gdb_py_test_silent_cmd "python progspace = gdb.current_progspace()" \
"Get current progspace" 1
gdb_test "python print (progspace.filename)" "py-progspace" \
- "current progspace filename (py-progspace)"
+ "current progspace filename, py-progspace"
gdb_test "python print (gdb.current_progspace().symbol_file)" \
"<gdb.Objfile filename=.*/py-progspace>" \
diff --git a/gdb/testsuite/gdb.python/py-type.exp b/gdb/testsuite/gdb.python/py-type.exp
index e524959..7e469c9 100644
--- a/gdb/testsuite/gdb.python/py-type.exp
+++ b/gdb/testsuite/gdb.python/py-type.exp
@@ -57,10 +57,10 @@ proc test_fields {lang} {
if {$lang == "c++"} {
# Test usage with a class
- gdb_py_test_silent_cmd "print (c)" "print value (c)" 1
+ gdb_py_test_silent_cmd "print (c)" "print value(c)" 1
gdb_py_test_silent_cmd "python c = gdb.history (0)" "get value (c) from history" 1
gdb_py_test_silent_cmd "python fields = c.type.fields()" "get fields from c.type" 1
- gdb_test "python print (len(fields))" "2" "check number of fields (c)"
+ gdb_test "python print (len(fields))" "2" "check number of fields, c"
gdb_test "python print (fields\[0\].name)" "c" "check class field c name"
gdb_test "python print (fields\[1\].name)" "d" "check class field d name"
@@ -94,12 +94,12 @@ proc test_fields {lang} {
}
# Test normal fields usage in structs.
- gdb_py_test_silent_cmd "print (st)" "print value (st)" 1
+ gdb_py_test_silent_cmd "print (st)" "print value(st)" 1
gdb_py_test_silent_cmd "python st = gdb.history (0)" "get value (st) from history" 1
gdb_py_test_silent_cmd "python fields = st.type.fields()" "get fields from st.type" 1
gdb_test "python print (st.type.objfile.filename == gdb.current_progspace ().filename)" "True" \
"check type.objfile"
- gdb_test "python print (len(fields))" "2" "check number of fields (st)"
+ gdb_test "python print (len(fields))" "2" "check number of fields, st"
gdb_test "python print (fields\[0\].name)" "a" "check structure field a name"
gdb_test "python print (fields\[1\].name)" "b" "check structure field b name"
@@ -118,7 +118,7 @@ proc test_fields {lang} {
"Check that dir includes name"
# Test Python mapping behavior of gdb.Type for structs/classes
- gdb_test "python print (len(st.type))" "2" "check number of fields (st.type)"
+ gdb_test "python print (len(st.type))" "2" "check number of fields, st.type"
gdb_test "python print (st.type\['a'\].name)" "a" "check fields lookup by name"
gdb_test "python print (\[v.bitpos for v in st.type.itervalues()\])" {\[0L?, 32L?\]} "Check fields iteration over values"
gdb_test "python print (\[(n, v.bitpos) for (n, v) in st.type.items()\])" {\[\('a', 0L?\), \('b', 32L?\)\]} "Check fields items list"
@@ -136,7 +136,7 @@ proc test_fields {lang} {
gdb_test "python print (not not st.type\['a'\].type)" "True"
# Test regression PR python/10805
- gdb_py_test_silent_cmd "print (ar)" "print value (ar)" 1
+ gdb_py_test_silent_cmd "print (ar)" "print value(ar)" 1
gdb_py_test_silent_cmd "python ar = gdb.history (0)" "get value (ar) from history" 1
gdb_test "python fields = ar.type.fields()"
gdb_test "python print (len(fields))" "1" "check the number of fields"
@@ -153,10 +153,10 @@ proc test_fields {lang} {
# Test gdb.Type.vector.
# Note: vectors cast differently than arrays. Here ar[0] is replicated
# for the size of the vector.
- gdb_py_test_silent_cmd "print (vec_data_1)" "print value (vec_data_1)" 1
+ gdb_py_test_silent_cmd "print (vec_data_1)" "print value(vec_data_1)" 1
gdb_py_test_silent_cmd "python vec_data_1 = gdb.history (0)" "get value (vec_data_1) from history" 1
- gdb_py_test_silent_cmd "print (vec_data_2)" "print value (vec_data_2)" 1
+ gdb_py_test_silent_cmd "print (vec_data_2)" "print value(vec_data_2)" 1
gdb_py_test_silent_cmd "python vec_data_2 = gdb.history (0)" "get value (vec_data_2) from history" 1
gdb_py_test_silent_cmd "python vec1 = vec_data_1.cast(ar\[0\].type.vector(1))" "set vec1" 1
@@ -179,7 +179,7 @@ proc test_fields {lang} {
proc test_enums {} {
with_test_prefix "test_enum" {
- gdb_py_test_silent_cmd "print (e)" "print value (e)" 1
+ gdb_py_test_silent_cmd "print (e)" "print value(e)" 1
gdb_py_test_silent_cmd "python (e) = gdb.history (0)" "get value (e) from history" 1
gdb_py_test_silent_cmd "python fields = e.type.fields()" "extract type fields from e" 1
gdb_test "python print (len(fields))" "3" "check the number of enum fields"
@@ -188,8 +188,8 @@ proc test_enums {} {
# Ditto but by mapping operations
gdb_test "python print (len(e.type))" "3" "check the number of type fields"
- gdb_test "python print (e.type\['v1'\].name)" "v1" "check enum field lookup by name (v1)"
- gdb_test "python print (e.type\['v3'\].name)" "v3" "check enum field lookup by name (v3)"
+ gdb_test "python print (e.type\['v1'\].name)" "v1" "check enum field lookup by name, v1"
+ gdb_test "python print (e.type\['v3'\].name)" "v3" "check enum field lookup by name, v3"
gdb_test "python print (\[v.enumval for v in e.type.itervalues()\])" {\[0L?, 1L?, 2L?\]} "Check num fields iteration over values"
gdb_test "python print (\[(n, v.enumval) for (n, v) in e.type.items()\])" {\[\('v1', 0L?\), \('v2', 1L?\), \('v3', 2L?\)\]} "Check enum fields items list"
}
@@ -197,12 +197,12 @@ proc test_enums {} {
proc test_base_class {} {
with_test_prefix "test_base_class" {
- gdb_py_test_silent_cmd "print (d)" "print value (d)" 1
+ gdb_py_test_silent_cmd "print (d)" "print value(d)" 1
gdb_py_test_silent_cmd "python d = gdb.history (0)" "get value (d) from history" 1
gdb_py_test_silent_cmd "python fields = d.type.fields()" "extract type fields from d" 1
gdb_test "python print (len(fields))" "3" "check the number of fields"
- gdb_test "python print (fields\[0\].is_base_class)" "True" "check base class (fields\[0\])"
- gdb_test "python print (fields\[1\].is_base_class)" "False" "check base class (fields\[1\])"
+ gdb_test "python print (fields\[0\].is_base_class)" "True" {check base class, fields[0]}
+ gdb_test "python print (fields\[1\].is_base_class)" "False" {check base class, fields[1]}
}
}
@@ -210,7 +210,7 @@ proc test_range {} {
with_test_prefix "test_range" {
with_test_prefix "on ranged value" {
# Test a valid range request.
- gdb_py_test_silent_cmd "print (ar)" "print value (ar)" 1
+ gdb_py_test_silent_cmd "print (ar)" "print value(ar)" 1
gdb_py_test_silent_cmd "python ar = gdb.history (0)" "get value (ar) from history" 1
gdb_test "python print (len(ar.type.range()))" "2" "check correct tuple length"
gdb_test "python print (ar.type.range()\[0\])" "0" "check range low bound"
@@ -219,7 +219,7 @@ proc test_range {} {
with_test_prefix "on ranged type" {
# Test a range request on a ranged type.
- gdb_py_test_silent_cmd "print (ar)" "print value (ar)" 1
+ gdb_py_test_silent_cmd "print (ar)" "print value(ar)" 1
gdb_py_test_silent_cmd "python ar = gdb.history (0)" "get value (ar) from history" 1
gdb_py_test_silent_cmd "python fields = ar.type.fields()" "get fields" 1
gdb_test "python print (fields\[0\].type.range()\[0\])" "0" "check range low bound"
@@ -228,7 +228,7 @@ proc test_range {} {
with_test_prefix "on unranged value" {
# Test where a range does not exist.
- gdb_py_test_silent_cmd "print (st)" "print value (st)" 1
+ gdb_py_test_silent_cmd "print (st)" "print value(st)" 1
gdb_py_test_silent_cmd "python st = gdb.history (0)" "get value (st) from history" 1
gdb_test "python print (st.type.range())" "RuntimeError.*: This type does not have a range.*" "check range for non ranged type."
}
diff --git a/gdb/testsuite/gdb.python/py-xmethods.exp b/gdb/testsuite/gdb.python/py-xmethods.exp
index 1ff7067..55ec66c 100644
--- a/gdb/testsuite/gdb.python/py-xmethods.exp
+++ b/gdb/testsuite/gdb.python/py-xmethods.exp
@@ -179,8 +179,8 @@ gdb_test_no_output "python gdb.set_parameter('max-value-size', 16)"
gdb_test "p a1.getarray()" \
"From Python <A_getarray>.*value requires $decimal bytes,\
which is more than max-value-size" \
- "after: a1.getarray (max-value-size)"
+ "after: a1.getarray, max-value-size"
gdb_test "p b1.getarray()" \
"From Python <B_getarray>.*value requires $decimal bytes,\
which is more than max-value-size" \
- "after: b1.getarray (max-value-size)"
+ "after: b1.getarray, max-value-size"
diff --git a/gdb/testsuite/gdb.reverse/step-precsave.exp b/gdb/testsuite/gdb.reverse/step-precsave.exp
index d937763..9ae67b3 100644
--- a/gdb/testsuite/gdb.reverse/step-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/step-precsave.exp
@@ -69,6 +69,8 @@ with_timeout_factor 10 {
gdb_test "kill" "" "kill process, prepare to debug log file" \
"Kill the program being debugged\\? \\(y or n\\) " "y"
+clean_restart ${binfile}
+
gdb_test "record restore $precsave" \
"Restored records from core file .*" \
"reload core file"
diff --git a/gdb/testsuite/gdb.server/build-id-seqno.c b/gdb/testsuite/gdb.server/build-id-seqno.c
new file mode 100644
index 0000000..e2119ba7
--- /dev/null
+++ b/gdb/testsuite/gdb.server/build-id-seqno.c
@@ -0,0 +1,22 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2024 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int
+main (void)
+{
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.server/build-id-seqno.exp b/gdb/testsuite/gdb.server/build-id-seqno.exp
new file mode 100644
index 0000000..7db1f11
--- /dev/null
+++ b/gdb/testsuite/gdb.server/build-id-seqno.exp
@@ -0,0 +1,200 @@
+# This testcase is part of GDB, the GNU debugger.
+#
+# Copyright 2024 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Setup a .build-id/ based debug directory containing multiple entries
+# for the same build-id, with each entry given a different sequence
+# number.
+#
+# Ensure that GDB will scan over broken symlinks for the same build-id
+# (but different sequence number) to find later working symlinks.
+#
+# This test places the build-id files within a directory next to where
+# gdbserver is started, and places a relative address in the
+# debug-file-directory, in this way we require GDB to find the debug
+# information via gdbserver.
+
+require {!is_remote host}
+
+load_lib gdbserver-support.exp
+
+require allow_gdbserver_tests
+
+standard_testfile
+
+if {[build_executable "failed to prepare" $testfile $srcfile] == -1} {
+ return -1
+}
+
+# Split out BINFILE.debug. Remove debug from BINFILE.
+if {[gdb_gnu_strip_debug $binfile] != 0} {
+ return -1
+}
+
+# Get the '.build-id/xx/xxx...xxx' part of the filename.
+set build_id_filename [build_id_debug_filename_get $binfile]
+
+# Hide (rename) BINFILE.debug, this should ensure GDB can't find it
+# directly but needs to look for the build-id based file in the debug
+# directory.
+set hidden_debuginfo [standard_output_file "hidden_$testfile.debug"]
+remote_exec build "mv ${binfile}.debug $hidden_debuginfo"
+
+# A filename that doesn't exist. Some symlinks will point at this
+# file.
+set missing_debuginfo "missing_debuginfo"
+
+# Helper called from gdb_finish when the 'target' is remote. Ensure the
+# debug directory we create is deleted.
+proc cleanup_remote_target {} {
+ remote_exec target "rm -fr debug/"
+}
+
+if { ![is_remote target] } {
+ set gdbserver_dir [standard_output_file "gdbserver-dir"]/
+} else {
+ lappend gdb_finish_hooks cleanup_remote_target
+ set gdbserver_dir ""
+}
+
+# Copy files to the target (if needed).
+set target_binfile [gdb_remote_download target $binfile]
+set target_debuginfo [gdb_remote_download target $hidden_debuginfo]
+
+# Setup the debug information on the target.
+set debugdir "${gdbserver_dir}debug"
+remote_exec target \
+ "mkdir -p $debugdir/[file dirname $build_id_filename]"
+remote_exec target \
+ "ln -sf $target_debuginfo $debugdir/$build_id_filename"
+
+# Start GDB and load global BINFILE. If DEBUGINFO_FILE is not the
+# empty string then this contains the '.build-id/xx/xxx....xxxx' part
+# of the filename which we expect GDB to read from the remote target.
+# If DEBUGINFO_FILE is the empty string then we don't expect GDB to
+# find any debug information.
+proc load_binfile_check_debug_is_found { debuginfo_file testname } {
+ with_test_prefix "$testname" {
+ with_timeout_factor 5 {
+ # Probing for .build-id based debug files on remote
+ # targets uses the vFile:stat packet by default, though
+ # there is a work around that avoids this which can be
+ # used if GDB is connected to an older gdbserver without
+ # 'stat' support.
+ #
+ # Check the work around works by disabling use of the
+ # vFile:stat packet.
+ foreach_with_prefix stat_pkt {auto off} {
+ clean_restart
+
+ gdb_test_no_output "set debug-file-directory debug" \
+ "set debug-file-directory"
+
+ gdb_test_no_output "set sysroot target:"
+
+ gdb_test "set remote hostio-stat-packet $stat_pkt"
+
+ # Make sure we're disconnected, in case we're testing with an
+ # extended-remote board, therefore already connected.
+ gdb_test "disconnect" ".*"
+
+ # Start gdbserver. This needs to be done after starting GDB. When
+ # gdbserver is running local to GDB, start gdbserver in a sub-directory,
+ # this prevents GDB from finding the debug information itself.
+ if { ![is_remote target] } {
+ with_cwd $::gdbserver_dir {
+ set res [gdbserver_start "" $::target_binfile]
+ }
+ } else {
+ set res [gdbserver_start "" $::target_binfile]
+ }
+ set gdbserver_protocol [lindex $res 0]
+ set gdbserver_gdbport [lindex $res 1]
+
+ # Connect to gdbserver. The output will be placed into the global
+ # GDB_TARGET_REMOTE_CMD_MSG, and we'll match against this below.
+ gdb_assert {[gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport] == 0} \
+ "connect to gdbserver"
+
+ if { $debuginfo_file ne "" } {
+ gdb_assert { [regexp "Reading symbols from target:debug/[string_to_regexp $debuginfo_file]\\.\\.\\." \
+ $::gdb_target_remote_cmd_msg] } \
+ "debuginfo was read via build-id"
+ gdb_assert { [regexp "Reading debug/[string_to_regexp $debuginfo_file] from remote target\\.\\.\\." \
+ $::gdb_target_remote_cmd_msg] } \
+ "debuginfo was read from remote target"
+ } else {
+ gdb_assert { [regexp "\\(No debugging symbols found in \[^\r\n\]+/$::testfile\\)" \
+ $::gdb_target_remote_cmd_msg] }
+ }
+ }
+ }
+ }
+}
+
+# Return a copy of FILENAME, which should end '.debug', with NUMBER
+# added, e.g. add_seqno 1 "foo.debug" --> "foo.1.debug".
+proc add_seqno { number filename } {
+ return [regsub "\.debug\$" $filename ".${number}.debug"]
+}
+
+# Precompute sequence numbered build-id filenames.
+set build_id_1_filename [add_seqno 1 $build_id_filename]
+set build_id_2_filename [add_seqno 2 $build_id_filename]
+set build_id_3_filename [add_seqno 3 $build_id_filename]
+
+load_binfile_check_debug_is_found $build_id_filename \
+ "find debuginfo with a single build-id file"
+
+remote_exec target "ln -fs $target_debuginfo \
+ $debugdir/$build_id_1_filename"
+remote_exec target "ln -fs $target_debuginfo \
+ $debugdir/$build_id_2_filename"
+remote_exec target "ln -fs $target_debuginfo \
+ $debugdir/$build_id_3_filename"
+
+load_binfile_check_debug_is_found $build_id_filename \
+ "find debuginfo with 4 build-id files"
+
+remote_exec target "ln -fs $missing_debuginfo $debugdir/$build_id_filename"
+
+load_binfile_check_debug_is_found $build_id_1_filename \
+ "find debuginfo, first build-id file is bad"
+
+remote_exec target "ln -fs $missing_debuginfo \
+ $debugdir/$build_id_1_filename"
+remote_exec target "ln -fs $missing_debuginfo \
+ $debugdir/$build_id_3_filename"
+
+load_binfile_check_debug_is_found $build_id_2_filename \
+ "find debuginfo, first 2 build-id files are bad"
+
+remote_exec target "ln -fs $missing_debuginfo \
+ $debugdir/$build_id_2_filename"
+
+load_binfile_check_debug_is_found "" \
+ "cannot find debuginfo, all build-id files are bad"
+
+remote_exec target "ln -fs $target_debuginfo \
+ $debugdir/$build_id_3_filename"
+
+load_binfile_check_debug_is_found $build_id_3_filename \
+ "find debuginfo, last build-id file is good"
+
+remote_exec target "rm -f $debugdir/$build_id_1_filename"
+
+load_binfile_check_debug_is_found "" \
+ "cannot find debuginfo, file with seqno 1 is missing"
diff --git a/gdb/testsuite/gdb.server/remote-read-msgs.exp b/gdb/testsuite/gdb.server/remote-read-msgs.exp
index d2d659a..e204655 100644
--- a/gdb/testsuite/gdb.server/remote-read-msgs.exp
+++ b/gdb/testsuite/gdb.server/remote-read-msgs.exp
@@ -30,7 +30,8 @@ require {!is_remote host}
standard_testfile
-if {[build_executable "failed to prepare" $testfile $srcfile] == -1} {
+if {[build_executable "failed to prepare" $testfile $srcfile \
+ {debug build-id}] == -1} {
return -1
}
diff --git a/gdb/testsuite/gdb.server/solib-list.exp b/gdb/testsuite/gdb.server/solib-list.exp
index b9cc6c8..bbc5df4 100644
--- a/gdb/testsuite/gdb.server/solib-list.exp
+++ b/gdb/testsuite/gdb.server/solib-list.exp
@@ -30,7 +30,7 @@ set srclibfile ${testfile}-lib.c
set binlibfile [standard_output_file ${testfile}.so]
if { [gdb_compile_shlib "${srcdir}/${subdir}/${srclibfile}" "${binlibfile}" {debug}] != ""
- || [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "shlib=${binlibfile}"] != "" } {
+ || [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "shlib=${binlibfile} build-id"] != "" } {
untested "failed to compile"
return -1
}
diff --git a/gdb/testsuite/gdb.threads/leader-exit-attach.exp b/gdb/testsuite/gdb.threads/leader-exit-attach.exp
index c1ed1ba..5334de2 100644
--- a/gdb/testsuite/gdb.threads/leader-exit-attach.exp
+++ b/gdb/testsuite/gdb.threads/leader-exit-attach.exp
@@ -41,32 +41,24 @@ set is_gdbserver [target_is_gdbserver]
set attached 0
gdb_test_multiple "attach $testpid" "attach" {
- -re "Attaching to process $testpid failed.*" {
+ -re -wrap "Attaching to process $testpid failed.*" {
# GNU/Linux gdbserver. Linux ptrace does not let you attach
# to zombie threads.
setup_kfail "gdb/31555" *-*-linux*
fail $gdb_test_name
}
- -re "warning: process $testpid is a zombie - the process has already terminated.*" {
+ -re -wrap "warning: process $testpid is a zombie - the process has already terminated.*" {
# Native GNU/Linux. Linux ptrace does not let you attach to
# zombie threads.
setup_kfail "gdb/31555" *-*-linux*
fail $gdb_test_name
}
- -re "Attaching to program: $escapedbinfile, process $testpid.*$gdb_prompt $" {
+ -re -wrap "Attaching to program: $escapedbinfile, process $testpid.*" {
pass $gdb_test_name
set attached 1
}
}
-# With gdbserver, after we failed to attach, we hit PR server/31554:
-# print $_inferior_thread_count
-# Remote connection closed
-# (gdb) KFAIL: gdb.threads/leader-exit-attach.exp: get valueof "$_inferior_thread_count"
-if {!$attached && $is_gdbserver} {
- setup_kfail "server/31554" "*-*-*"
-}
-
set thread_count [get_valueof "" "\$_inferior_thread_count" -1]
if {$thread_count == -1} {
diff --git a/gdb/testsuite/gdb.threads/print-threads.exp b/gdb/testsuite/gdb.threads/print-threads.exp
index e2be48b..6fae36a 100644
--- a/gdb/testsuite/gdb.threads/print-threads.exp
+++ b/gdb/testsuite/gdb.threads/print-threads.exp
@@ -93,7 +93,7 @@ gdb_test_no_output "set var slow = 0"
test_all_threads "fast" 0
runto_main
-gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*print-threads.c, line \[0-9\]*\\." "break thread_function (2)"
+gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*print-threads.c, line \[0-9\]*\\." "break thread_function, 2"
gdb_test_no_output "set var slow = 1"
# Extend the timeout for slower tests.
set timeout [expr $oldtimeout + 120]
@@ -101,8 +101,8 @@ test_all_threads "slow" 0
set timeout $oldtimeout
runto_main
-gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*print-threads.c, line \[0-9\]*\\." "break thread_function (3)"
-gdb_test_no_output "set var slow = 1" "set var slow = 1 (2)"
+gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*print-threads.c, line \[0-9\]*\\." "break thread_function, 3"
+gdb_test_no_output "set var slow = 1" "set var slow = 1, 2"
gdb_breakpoint "kill"
# Extend the timeout for slower tests.
set timeout [expr $oldtimeout + 120]
diff --git a/gdb/testsuite/gdb.threads/schedlock.exp b/gdb/testsuite/gdb.threads/schedlock.exp
index bd5d5d2..4e99961 100644
--- a/gdb/testsuite/gdb.threads/schedlock.exp
+++ b/gdb/testsuite/gdb.threads/schedlock.exp
@@ -45,7 +45,7 @@ proc get_args { description } {
append pattern ", (\[0-9\]+)"
}
- set test "listed args ($description)"
+ set test "listed args, $description"
gdb_test_multiple "print args" $test {
-re "\\\$\[0-9\]+ = {$pattern}.*$gdb_prompt $" {
pass $test
@@ -80,7 +80,7 @@ proc stop_process { description } {
proc get_current_thread { description } {
global gdb_prompt
- set test "find current thread ($description)"
+ set test "find current thread, $description"
gdb_test_multiple "bt" $test {
-re "thread_function \\(arg=0x(\[0-9\])\\).*$gdb_prompt $" {
@@ -124,7 +124,7 @@ proc step_ten_loops { cmd } {
for {set i 0} {[expr $i < 10]} {set i [expr $i + 1]} {
set other_step 0
- set test "$cmd to increment ($i)"
+ set test "$cmd to increment, $i"
gdb_test_multiple $cmd $test {
-re ".*myp\\) \\+\\+;\[\r\n\]+$gdb_prompt $" {
pass $test
diff --git a/gdb/testsuite/gdb.trace/entry-values.exp b/gdb/testsuite/gdb.trace/entry-values.exp
index 0711100..3b358cc 100644
--- a/gdb/testsuite/gdb.trace/entry-values.exp
+++ b/gdb/testsuite/gdb.trace/entry-values.exp
@@ -171,7 +171,7 @@ gdb_continue_to_breakpoint "foo"
gdb_test_no_output "set print entry-values both"
-gdb_test_sequence "bt" "bt (1)" {
+gdb_test_sequence "bt" "bt, 1" {
"\[\r\n\]#0 .* foo \\(i=[-]?[0-9]+, i@entry=2, j=[-]?[0-9]+, j@entry=3\\)"
"\[\r\n\]#1 .* bar \\(i=<optimized out>, i@entry=<optimized out>\\)"
"\[\r\n\]#2 .* \.?main \\(\\)"
@@ -183,7 +183,7 @@ gdb_test_sequence "bt" "bt (1)" {
gdb_test_no_output "set var *(int *) &global1=10"
gdb_test_no_output "set var *(int *) &global2=11"
-gdb_test_sequence "bt" "bt (2)" {
+gdb_test_sequence "bt" "bt, 2" {
"\[\r\n\]#0 .* foo \\(i=[-]?[0-9]+, i@entry=10, j=[-]?[0-9]+, j@entry=11\\)"
"\[\r\n\]#1 .* bar \\(i=<optimized out>, i@entry=<optimized out>\\)"
"\[\r\n\]#2 .* \.?main \\(\\)"
diff --git a/gdb/testsuite/gdb.xml/tdesc-arch.exp b/gdb/testsuite/gdb.xml/tdesc-arch.exp
index f9b037f..6c8c592 100644
--- a/gdb/testsuite/gdb.xml/tdesc-arch.exp
+++ b/gdb/testsuite/gdb.xml/tdesc-arch.exp
@@ -73,7 +73,7 @@ proc set_arch { arch which trans_mode } {
# Anchor the test output, so that error messages are detected.
set cmd "set tdesc filename $filename"
- set msg "set tdesc filename tdesc-arch.xml ($which architecture)"
+ set msg "set tdesc filename tdesc-arch.xml, $which architecture"
set cmd_regex [string_to_regexp $cmd]
gdb_test_multiple $cmd $msg {
-re "^$cmd_regex\r\n$gdb_prompt $" {
@@ -87,7 +87,7 @@ proc set_arch { arch which trans_mode } {
set cmd "show architecture"
gdb_test $cmd \
"The target architecture is set to \"auto\" \\(currently \"$arch\"\\)\\." \
- "$cmd ($which architecture)"
+ "$cmd, $which architecture"
remote_file host delete $filename
}
@@ -115,11 +115,11 @@ if {[is_remote host]} {
set cmd "set tdesc filename $filename"
gdb_test $cmd \
"warning:.*Target description specified unknown architecture.*" \
- "set tdesc filename tdesc-arch.xml (invalid architecture)"
+ "set tdesc filename tdesc-arch.xml, invalid architecture"
set cmd "show architecture"
gdb_test $cmd \
"The target architecture is set to \"auto\" \\(currently \"$default_arch\"\\)\\." \
- "$cmd (invalid architecture)"
+ "$cmd, invalid architecture"
remote_file host delete $filename
diff --git a/gdb/testsuite/lib/cache.exp b/gdb/testsuite/lib/cache.exp
index 8066734..092b7f1 100644
--- a/gdb/testsuite/lib/cache.exp
+++ b/gdb/testsuite/lib/cache.exp
@@ -46,6 +46,40 @@ proc gdb_do_cache_wrap {real_name args} {
return $result
}
+# Global written to by gdb_exit_called proc. Is set to true to
+# indicate that a caching proc has called gdb_exit.
+
+set gdb_exit_called false
+
+# This proc is called via TCL's trace mechanism whenever gdb_exit is
+# called during the execution of a caching proc. This sets the global
+# flag to indicate that gdb_exit has been called.
+
+proc gdb_exit_called { args } {
+ set ::gdb_exit_called true
+}
+
+# If DO_EXIT is false then this proc does nothing. If DO_EXIT is true
+# then call gdb_exit the first time this proc is called for each
+# unique value of NAME within a single test. Every subsequent time
+# this proc is called within a single test (for a given value of
+# NAME), don't call gdb_exit.
+
+proc gdb_cache_maybe_gdb_exit { name do_exit } {
+ if { !$do_exit } {
+ return
+ }
+
+ # To track if this proc has been called for NAME we create a
+ # global variable. In gdb_cleanup_globals (see gdb.exp) this
+ # global will be deleted when the test has finished.
+ set global_name __${name}__cached_gdb_exit_called
+ if { ![info exists ::${global_name}] } {
+ gdb_exit
+ set ::${global_name} true
+ }
+}
+
# A helper for gdb_caching_proc that handles the caching.
proc gdb_do_cache {name args} {
@@ -70,11 +104,13 @@ proc gdb_do_cache {name args} {
set cache_name [file join [target_info name] $name {*}$args]
set is_cached 0
- if {[info exists gdb_data_cache($cache_name)]} {
- set cached $gdb_data_cache($cache_name)
- verbose "$name: returning '$cached' from cache" 2
+ if {[info exists gdb_data_cache(${cache_name},value)]} {
+ set cached_value $gdb_data_cache(${cache_name},value)
+ set cached_exit $gdb_data_cache(${cache_name},exit)
+ verbose "$name: returning '$cached_value' from cache" 2
if { $cache_verify == 0 } {
- return $cached
+ gdb_cache_maybe_gdb_exit $name $cached_exit
+ return $cached_value
}
set is_cached 1
}
@@ -83,37 +119,105 @@ proc gdb_do_cache {name args} {
set cache_filename [make_gdb_parallel_path cache $cache_name]
if {[file exists $cache_filename]} {
set fd [open $cache_filename]
- set gdb_data_cache($cache_name) [read -nonewline $fd]
+ set content [split [read -nonewline $fd] \n]
close $fd
- set cached $gdb_data_cache($cache_name)
- verbose "$name: returning '$cached' from file cache" 2
+ set gdb_data_cache(${cache_name},value) [lindex $content 0]
+ set gdb_data_cache(${cache_name},exit) [lindex $content 1]
+ set cached_value $gdb_data_cache(${cache_name},value)
+ set cached_exit $gdb_data_cache(${cache_name},exit)
+ verbose "$name: returning '$cached_value' from file cache" 2
if { $cache_verify == 0 } {
- return $cached
+ gdb_cache_maybe_gdb_exit $name $cached_exit
+ return $cached_value
}
set is_cached 1
}
}
+ # Add a trace hook to gdb_exit. In the case of recursive calls to
+ # gdb_do_cache we only want to install the trace hook once, so we
+ # set a global to indicate that the trace is in place.
+ #
+ # We also set a local flag to indicate that this is the scope in
+ # which the debug trace needs to be removed.
+ if { ![info exists ::gdb_exit_trace_in_place] } {
+ trace add execution gdb_exit enter gdb_exit_called
+ set ::gdb_exit_trace_in_place true
+ set gdb_exit_trace_created true
+ } else {
+ set gdb_exit_trace_created false
+ }
+
+ # As above, we need to consider recursive calls into gdb_do_cache.
+ # Store the old value of gdb_exit_called global and then set the
+ # flag to false. Initially gdb_exit_called is always false, but
+ # for recursive calls to gdb_do_cache we can't know the state of
+ # gdb_exit_called.
+ #
+ # Before starting a recursive gdb_do_cache call we need
+ # gdb_exit_called to be false, that way the inner call can know if
+ # it invoked gdb_exit or not.
+ #
+ # Once the recursive call completes, if it did call gdb_exit then
+ # the outer, parent call to gdb_do_cache should also be considered
+ # as having called gdb_exit.
+ set old_gdb_exit_called $::gdb_exit_called
+ set ::gdb_exit_called false
+
set real_name gdb_real__$name
- set gdb_data_cache($cache_name) [gdb_do_cache_wrap $real_name {*}$args]
+ set gdb_data_cache(${cache_name},value) [gdb_do_cache_wrap $real_name {*}$args]
+ set gdb_data_cache(${cache_name},exit) $::gdb_exit_called
+
+ # See comment above where OLD_GDB_EXIT_CALLED is set: if
+ # GDB_EXIT_CALLED was previously true then this is a recursive
+ # call and the outer caching proc set the global true, so restore
+ # the true value now.
+ if { $old_gdb_exit_called } {
+ set ::gdb_exit_called true
+ }
+
+ # See comment above where GDB_EXIT_TRACE_CREATED is set: this is
+ # the frame in which the trace was installed. This must be the
+ # outer caching proc call (if an recursion occurred).
+ if { $gdb_exit_trace_created } {
+ trace remove execution gdb_exit enter gdb_exit_called
+ unset ::gdb_exit_trace_in_place
+ set ::gdb_exit_called false
+ }
+
+ # If a value being stored in the cache contains a newline then
+ # when we try to read the value back from an on-disk cache file
+ # we'll interpret the second line of the value as the ',exit' value.
+ if { [regexp "\[\r\n\]" $gdb_data_cache(${cache_name},value)] } {
+ set computed_value $gdb_data_cache(${cache_name},value)
+ error "Newline found in value for $cache_name: $computed_value"
+ }
+
if { $cache_verify == 1 && $is_cached == 1 } {
- set computed $gdb_data_cache($cache_name)
- if { $cached != $computed } {
- error [join [list "Inconsistent results for $cache_name:"
- "cached: $cached vs. computed: $computed"]]
+ set computed_value $gdb_data_cache(${cache_name},value)
+ set computed_exit $gdb_data_cache(${cache_name},exit)
+ if { $cached_value != $computed_value } {
+ error [join [list "Inconsistent value results for $cache_name:"
+ "cached: $cached_value vs. computed: $computed_value"]]
+ }
+ if { $cached_exit != $computed_exit } {
+ error [join [list "Inconsistent exit results for $cache_name:"
+ "cached: $cached_exit vs. computed: $computed_exit"]]
}
}
if {[info exists GDB_PARALLEL]} {
- verbose "$name: returning '$gdb_data_cache($cache_name)' and writing file" 2
+ verbose "$name: returning '$gdb_data_cache(${cache_name},value)' and writing file" 2
file mkdir [file dirname $cache_filename]
# Make sure to write the results file atomically.
set fd [open $cache_filename.[pid] w]
- puts $fd $gdb_data_cache($cache_name)
+ puts $fd $gdb_data_cache(${cache_name},value)
+ puts $fd $gdb_data_cache(${cache_name},exit)
close $fd
file rename -force -- $cache_filename.[pid] $cache_filename
}
- return $gdb_data_cache($cache_name)
+ gdb_cache_maybe_gdb_exit $name $gdb_data_cache(${cache_name},exit)
+ return $gdb_data_cache(${cache_name},value)
}
# Define a new proc named NAME, with optional args ARGS. BODY is the body of
diff --git a/gdb/testsuite/lib/check-test-names.exp b/gdb/testsuite/lib/check-test-names.exp
index 8f86f31..11aed63 100644
--- a/gdb/testsuite/lib/check-test-names.exp
+++ b/gdb/testsuite/lib/check-test-names.exp
@@ -64,6 +64,16 @@ namespace eval ::CheckTestNames {
proc _check_duplicates { message } {
variable all_test_names
+ # Remove test-case prefix, including the space separator.
+ set prefix [string_to_regexp "$::subdir/$::gdb_test_file_name.exp: "]
+ set message [regsub ^$prefix $message ""]
+
+ # Remove the "extra information" part.
+ set message [regsub { \([^()]*\)$} $message ""]
+
+ # Add back the test-case prefix.
+ set message "${prefix}$message"
+
# Initialise a count, or increment the count for this test name.
if {![info exists all_test_names($message)]} {
set all_test_names($message) 0
diff --git a/gdb/testsuite/lib/gdb-utils.exp b/gdb/testsuite/lib/gdb-utils.exp
index 95c53d0..41989da 100644
--- a/gdb/testsuite/lib/gdb-utils.exp
+++ b/gdb/testsuite/lib/gdb-utils.exp
@@ -38,6 +38,14 @@ proc string_to_regexp {str} {
return $result
}
+# Convenience function that calls string_to_regexp for each arg, and
+# joins the results using "\r\n".
+
+proc multi_line_string_to_regexp { args } {
+ set res [lmap arg $args {string_to_regexp $arg}]
+ return [multi_line {*}$res]
+}
+
# Given a list of strings, adds backslashes as needed to each string to
# create a regexp that will match the string, and join the result.
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index dfe19c9..acb932e 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -158,6 +158,23 @@ load_lib gdb-utils.exp
load_lib memory.exp
load_lib check-test-names.exp
+# The path to the GCORE script to test.
+global GCORE
+if {![info exists GCORE]} {
+ set GCORE [findfile $base_dir/../../gdb/gcore]
+}
+verbose "using GCORE = $GCORE" 2
+
+# Return 0 if the gcore scipt is missing.
+proc has_gcore_script {} {
+ global GCORE
+ if {$GCORE == ""} {
+ return 0
+ } else {
+ return 1
+ }
+}
+
# The path to the GDB binary to test.
global GDB
@@ -965,6 +982,31 @@ proc fill_in_default_prompt {prompt_regexp with_anchor} {
return $prompt_regexp
}
+# Generate message from COMMAND.
+#
+# This is not trivial in the case that the command contains parentheses.
+# Trailing text between parentheses prefixed with a space is interpreted as
+# extra information, and not as part of the test name [1]. Consequently,
+# "PASS: print (1)" and "PASS: print (2)" count as duplicates.
+#
+# We fix this here by using "PASS: gdb-command<print (1)>" and
+# "PASS: gdb-command<print (2)>".
+#
+# A trivial way to fix this in a test-case is by using gdb_test "print(1)",
+# which produces the nicer-looking "PASS: print(1)".
+#
+# [1] https://sourceware.org/gdb/wiki/GDBTestcaseCookbook#Do_not_use_.22tail_parentheses.22_on_test_messages
+
+proc command_to_message { command } {
+ set message $command
+
+ if { [regexp { \(([^()]*)\)$} $message] } {
+ set message gdb-command<$message>
+ }
+
+ return $message
+}
+
# gdb_test_multiple COMMAND MESSAGE [ -prompt PROMPT_REGEXP] [ -lbl ]
# EXPECT_ARGUMENTS
# Send a command to gdb; test the result.
@@ -1095,7 +1137,7 @@ proc gdb_test_multiple { command message args } {
set prompt_regexp [fill_in_default_prompt $prompt_regexp true]
if { $message == "" } {
- set message $command
+ set message [command_to_message $command]
}
if [string match "*\[\r\n\]" $command] {
@@ -1471,7 +1513,6 @@ proc gdb_test_multiline { name args } {
return 0
}
-
# gdb_test [-prompt PROMPT_REGEXP] [-lbl]
# COMMAND [PATTERN] [MESSAGE] [QUESTION RESPONSE]
# Send a command to gdb; test the result.
@@ -1529,7 +1570,7 @@ proc gdb_test { args } {
}
if { $message == "" } {
- set message $command
+ set message [command_to_message $command]
}
set prompt [fill_in_default_prompt $prompt [expr !${no-prompt-anchor}]]
@@ -1795,7 +1836,7 @@ proc gdb_test_lines { command message re args } {
}
if { $message == ""} {
- set message $command
+ set message [command_to_message $command]
}
set lines ""
@@ -2012,7 +2053,7 @@ proc gdb_test_stdio {command inferior_pattern {gdb_pattern ""} {message ""}} {
global gdb_prompt
if {$message == ""} {
- set message $command
+ set message [command_to_message $command]
}
set inferior_matched 0
@@ -5469,12 +5510,12 @@ proc gdb_compile {source dest type options} {
# enable it now.
if {[lsearch -exact $options build-id] > 0
&& [test_compiler_info "clang-*"]} {
- lappend new_options "additional_flags=-Wl,--build-id"
+ lappend new_options "ldflags=-Wl,--build-id"
}
# If the 'no-build-id' option is used then disable the build-id.
if {[lsearch -exact $options no-build-id] > 0} {
- lappend new_options "additional_flags=-Wl,--build-id=none"
+ lappend new_options "ldflags=-Wl,--build-id=none"
}
# Sanity check. If both 'build-id' and 'no-build-id' are used
@@ -6321,14 +6362,23 @@ proc gdb_exit { } {
catch default_gdb_exit
}
-# Helper function for can_spawn_for_attach. Try to spawn and attach, and
-# return 0 only if we cannot attach because it's unsupported.
+# Return true if we can spawn a program on the target and attach to
+# it.
-gdb_caching_proc can_spawn_for_attach_1 {} {
- # For the benefit of gdb-caching-proc-consistency.exp, which
- # calls can_spawn_for_attach_1 directly. Keep in sync with
- # can_spawn_for_attach.
- if { [is_remote target] || [target_info exists use_gdb_stub] } {
+gdb_caching_proc can_spawn_for_attach {} {
+ # We use exp_pid to get the inferior's pid, assuming that gives
+ # back the pid of the program. On remote boards, that would give
+ # us instead the PID of e.g., the ssh client, etc.
+ if {[is_remote target]} {
+ verbose -log "can't spawn for attach (target is remote)"
+ return 0
+ }
+
+ # The "attach" command doesn't make sense when the target is
+ # stub-like, where GDB finds the program already started on
+ # initial connection.
+ if {[target_info exists use_gdb_stub]} {
+ verbose -log "can't spawn for attach (target is stub)"
return 0
}
@@ -6353,6 +6403,9 @@ gdb_caching_proc can_spawn_for_attach_1 {} {
set test_spawn_id [spawn_wait_for_attach_1 $obj]
remote_file build delete $obj
+ # In case GDB is already running.
+ gdb_exit
+
gdb_start
set test_pid [spawn_id_get_pid $test_spawn_id]
@@ -6374,61 +6427,6 @@ gdb_caching_proc can_spawn_for_attach_1 {} {
return $res
}
-# Return true if we can spawn a program on the target and attach to
-# it. Calls gdb_exit for the first call in a test-case.
-
-proc can_spawn_for_attach { } {
- # We use exp_pid to get the inferior's pid, assuming that gives
- # back the pid of the program. On remote boards, that would give
- # us instead the PID of e.g., the ssh client, etc.
- if {[is_remote target]} {
- verbose -log "can't spawn for attach (target is remote)"
- return 0
- }
-
- # The "attach" command doesn't make sense when the target is
- # stub-like, where GDB finds the program already started on
- # initial connection.
- if {[target_info exists use_gdb_stub]} {
- verbose -log "can't spawn for attach (target is stub)"
- return 0
- }
-
- # The normal sequence to use for a runtime test like
- # can_spawn_for_attach_1 is:
- # - gdb_exit (don't use a running gdb, we don't know what state it is in),
- # - gdb_start (start a new gdb), and
- # - gdb_exit (cleanup).
- #
- # By making can_spawn_for_attach_1 a gdb_caching_proc, we make it
- # unpredictable which test-case will call it first, and consequently a
- # test-case may pass in say a full test run, but fail when run
- # individually, due to a can_spawn_for_attach call in a location where a
- # gdb_exit (as can_spawn_for_attach_1 does) breaks things.
- # To avoid this, we move the initial gdb_exit out of
- # can_spawn_for_attach_1, guaranteeing that we end up in the same state
- # regardless of whether can_spawn_for_attach_1 is called. However, that
- # is only necessary for the first call in a test-case, so cache the result
- # in a global (which should be reset after each test-case) to keep track
- # of that.
- #
- # In summary, we distinguish between three cases:
- # - first call in first test-case. Executes can_spawn_for_attach_1.
- # Calls gdb_exit, gdb_start, gdb_exit.
- # - first call in following test-cases. Uses cached result of
- # can_spawn_for_attach_1. Calls gdb_exit.
- # - rest. Use cached result in cache_can_spawn_for_attach_1. Calls no
- # gdb_start or gdb_exit.
- global cache_can_spawn_for_attach_1
- if { [info exists cache_can_spawn_for_attach_1] } {
- return $cache_can_spawn_for_attach_1
- }
- gdb_exit
-
- set cache_can_spawn_for_attach_1 [can_spawn_for_attach_1]
- return $cache_can_spawn_for_attach_1
-}
-
# Centralize the failure checking of "attach" command.
# Return 0 if attach failed, otherwise return 1.
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index aa0f9df..a79b133 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -1989,14 +1989,13 @@ proc get_mi_thread_list {name} {
return $thread_list
}
-# Check that MI and the console know of the same threads.
-# Appends NAME to all test names.
-proc check_mi_and_console_threads {name} {
+# Helper function for check_mi_and_console_threads.
+proc check_mi_and_console_threads_1 { name } {
global expect_out
mi_gdb_test "-thread-list-ids" \
{.*\^done,thread-ids={(thread-id="[0-9]+"(,)*)+},current-thread-id="[0-9]+",number-of-threads="[0-9]+"} \
- "-thread-list-ids ($name)"
+ "-thread-list-ids"
set mi_output {}
if {[info exists expect_out(buffer)]} {
set mi_output $expect_out(buffer)
@@ -2013,7 +2012,7 @@ proc check_mi_and_console_threads {name} {
# FIXME: kseitz/2002-09-05: Don't use the hack-cli method.
mi_gdb_test "info threads" \
{.*(~".*"[\r\n]*)+.*} \
- "info threads ($name)"
+ "info threads"
set console_output {}
if {[info exists expect_out(buffer)]} {
set console_output $expect_out(buffer)
@@ -2039,29 +2038,29 @@ proc check_mi_and_console_threads {name} {
}
}
if {$mi_result == ""} {
- fail "finding MI result string ($name)"
+ fail "finding MI result string"
} else {
- pass "finding MI result string ($name)"
+ pass "finding MI result string"
}
# Finally, extract the thread ids and compare them to the console
set num_mi_threads_str ""
if {![regexp {number-of-threads="[0-9]+"} $mi_result num_mi_threads_str]} {
- fail "finding number of threads in MI output ($name)"
+ fail "finding number of threads in MI output"
} else {
- pass "finding number of threads in MI output ($name)"
+ pass "finding number of threads in MI output"
# Extract the number of threads from the MI result
if {![scan $num_mi_threads_str {number-of-threads="%d"} num_mi_threads]} {
- fail "got number of threads from MI ($name)"
+ fail "got number of threads from MI"
} else {
- pass "got number of threads from MI ($name)"
+ pass "got number of threads from MI"
# Check if MI and console have same number of threads
if {$num_mi_threads != [llength $console_thread_list]} {
- fail "console and MI have same number of threads ($name)"
+ fail "console and MI have same number of threads"
} else {
- pass "console and MI have same number of threads ($name)"
+ pass "console and MI have same number of threads"
# Get MI thread list
set mi_thread_list [get_mi_thread_list $name]
@@ -2074,19 +2073,27 @@ proc check_mi_and_console_threads {name} {
}
}
if {$fails > 0} {
- fail "MI and console have same threads ($name)"
+ fail "MI and console have same threads"
# Send a list of failures to the log
send_log "Console has thread ids: $console_thread_list\n"
send_log "MI has thread ids: $mi_thread_list\n"
} else {
- pass "MI and console have same threads ($name)"
+ pass "MI and console have same threads"
}
}
}
}
}
+# Check that MI and the console know of the same threads.
+# Appends NAME to all test names.
+proc check_mi_and_console_threads { name } {
+ with_test_prefix $name {
+ check_mi_and_console_threads_1 $name
+ }
+}
+
# Set solib-search-path to allow gdb to locate shlib FILE.
proc mi_locate_shlib { file } {
global mi_spawn_id
diff --git a/gdb/tid-parse.c b/gdb/tid-parse.c
index 623f55e..1b8f343 100644
--- a/gdb/tid-parse.c
+++ b/gdb/tid-parse.c
@@ -24,7 +24,7 @@
/* See tid-parse.h. */
-void ATTRIBUTE_NORETURN
+[[noreturn]] void
invalid_thread_id_error (const char *string)
{
error (_("Invalid thread ID: %s"), string);
diff --git a/gdb/tid-parse.h b/gdb/tid-parse.h
index b7bd920..7bbdeab 100644
--- a/gdb/tid-parse.h
+++ b/gdb/tid-parse.h
@@ -26,7 +26,7 @@ struct thread_info;
/* Issue an invalid thread ID error, pointing at STRING, the invalid
ID. */
-extern void ATTRIBUTE_NORETURN invalid_thread_id_error (const char *string);
+[[noreturn]] extern void invalid_thread_id_error (const char *string);
/* Parse TIDSTR as a per-inferior thread ID, in either INF_NUM.THR_NUM
or THR_NUM form. In the latter case, the missing INF_NUM is filled
diff --git a/gdb/top.h b/gdb/top.h
index dc3f2aa..b57cc3b 100644
--- a/gdb/top.h
+++ b/gdb/top.h
@@ -42,7 +42,7 @@ extern void read_command_file (FILE *);
extern void init_history (void);
extern void command_loop (void);
extern int quit_confirm (void);
-extern void quit_force (int *, int) ATTRIBUTE_NORETURN;
+[[noreturn]] extern void quit_force (int *, int);
extern void quit_command (const char *, int);
extern void quit_cover (void);
extern void execute_command (const char *, int);
diff --git a/gdb/trad-frame.c b/gdb/trad-frame.c
index e64374a..35bf02e 100644
--- a/gdb/trad-frame.c
+++ b/gdb/trad-frame.c
@@ -154,12 +154,14 @@ trad_frame_set_reg_regmap (struct trad_frame_cache *this_trad_cache,
else
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- gdb_byte buf[slot_size];
+ gdb::byte_vector buf (slot_size);
- if (target_read_memory (addr + offs, buf, sizeof buf) == 0)
+ if (target_read_memory (addr + offs, buf.data (), buf.size ())
+ == 0)
{
LONGEST val
- = extract_unsigned_integer (buf, sizeof buf, byte_order);
+ = extract_unsigned_integer (buf.data (), buf.size (),
+ byte_order);
trad_frame_set_reg_value (this_trad_cache, regno, val);
}
}
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 0727d3a..53be866 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -389,10 +389,12 @@ tui_get_begin_asm_address (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
if (tui_location.addr () == 0)
{
- if (have_full_symbols () || have_partial_symbols ())
+ if (have_full_symbols (current_program_space)
+ || have_partial_symbols (current_program_space))
{
set_default_source_symtab_and_line ();
- struct symtab_and_line sal = get_current_source_symtab_and_line ();
+ symtab_and_line sal
+ = get_current_source_symtab_and_line (current_program_space);
if (sal.symtab != nullptr)
find_line_pc (sal.symtab, sal.line, &addr);
diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c
index e6673ab..25358d0 100644
--- a/gdb/tui/tui-hooks.c
+++ b/gdb/tui/tui-hooks.c
@@ -127,7 +127,8 @@ tui_refresh_frame_and_register_information ()
/* Make sure that the source window is displayed. */
tui_add_win_to_layout (SRC_WIN);
- struct symtab_and_line sal = get_current_source_symtab_and_line ();
+ symtab_and_line sal
+ = get_current_source_symtab_and_line (current_program_space);
tui_update_source_windows_with_line (sal);
}
}
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index 444c0f7..ee64e41 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -136,7 +136,8 @@ tui_source_window::do_scroll_vertical (int num_to_scroll)
if (!m_content.empty ())
{
struct symtab *s;
- struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+ symtab_and_line cursal
+ = get_current_source_symtab_and_line (current_program_space);
struct gdbarch *arch = m_gdbarch;
if (cursal.symtab == NULL)
@@ -220,7 +221,7 @@ void
tui_source_window::display_start_addr (struct gdbarch **gdbarch_p,
CORE_ADDR *addr_p)
{
- struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+ symtab_and_line cursal = get_current_source_symtab_and_line (current_program_space);
*gdbarch_p = m_gdbarch;
find_line_pc (cursal.symtab, m_start_line_or_addr.u.line_no, addr_p);
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 80297e5..b08fca7 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -440,8 +440,8 @@ tui_source_window_base::rerender ()
if (!m_content.empty ())
{
- struct symtab_and_line cursal
- = get_current_source_symtab_and_line ();
+ symtab_and_line cursal
+ = get_current_source_symtab_and_line (current_program_space);
if (m_start_line_or_addr.loa == LOA_LINE)
cursal.line = m_start_line_or_addr.u.line_no;
@@ -451,8 +451,8 @@ tui_source_window_base::rerender ()
}
else if (deprecated_safe_get_selected_frame () != NULL)
{
- struct symtab_and_line cursal
- = get_current_source_symtab_and_line ();
+ symtab_and_line cursal
+ = get_current_source_symtab_and_line (current_program_space);
frame_info_ptr frame = deprecated_safe_get_selected_frame ();
struct gdbarch *gdbarch = get_frame_arch (frame);
@@ -492,7 +492,7 @@ tui_source_window_base::refill ()
if (this == tui_src_win ())
{
- sal = get_current_source_symtab_and_line ();
+ sal = get_current_source_symtab_and_line (current_program_space);
if (sal.symtab == NULL)
{
frame_info_ptr fi = deprecated_safe_get_selected_frame ();
diff --git a/gdb/unittests/intrusive_list-selftests.c b/gdb/unittests/intrusive_list-selftests.c
index 28d0134..b17ce92 100644
--- a/gdb/unittests/intrusive_list-selftests.c
+++ b/gdb/unittests/intrusive_list-selftests.c
@@ -570,7 +570,6 @@ struct intrusive_list_test
{
/* Both lists empty. */
- item_type a ("a"), b ("b"), c ("c");
ListType list1;
ListType list2;
std::vector<const item_type *> expected;
diff --git a/gdb/utils.c b/gdb/utils.c
index 17498e0..9431030 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -192,7 +192,7 @@ verror (const char *string, va_list args)
/* Emit a message and abort. */
-static void ATTRIBUTE_NORETURN
+[[noreturn]] static void
abort_with_message (const char *msg)
{
if (current_ui == NULL)
diff --git a/gdb/value.c b/gdb/value.c
index e71f38b..aaa9ed2 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -61,7 +61,7 @@ struct internal_function
char *name;
/* The handler. */
- internal_function_fn handler;
+ internal_function_fn_noside handler;
/* User data for the handler. */
void *cookie;
@@ -1716,10 +1716,6 @@ value::record_latest ()
fetch_lazy ();
}
- ULONGEST limit = m_limited_length;
- if (limit != 0)
- mark_bytes_unavailable (limit, m_enclosing_type->length () - limit);
-
/* Mark the value as recorded in the history for the availability check. */
m_in_history = true;
@@ -2336,9 +2332,9 @@ internalvar_name (const struct internalvar *var)
static struct internal_function *
create_internal_function (const char *name,
- internal_function_fn handler, void *cookie)
+ internal_function_fn_noside handler, void *cookie)
{
- struct internal_function *ifn = XNEW (struct internal_function);
+ struct internal_function *ifn = new (struct internal_function);
ifn->name = xstrdup (name);
ifn->handler = handler;
@@ -2362,7 +2358,8 @@ value_internal_function_name (struct value *val)
struct value *
call_internal_function (struct gdbarch *gdbarch,
const struct language_defn *language,
- struct value *func, int argc, struct value **argv)
+ struct value *func, int argc, struct value **argv,
+ enum noside noside)
{
struct internal_function *ifn;
int result;
@@ -2371,7 +2368,7 @@ call_internal_function (struct gdbarch *gdbarch,
result = get_internalvar_function (VALUE_INTERNALVAR (func), &ifn);
gdb_assert (result);
- return (*ifn->handler) (gdbarch, language, ifn->cookie, argc, argv);
+ return ifn->handler (gdbarch, language, ifn->cookie, argc, argv, noside);
}
/* The 'function' command. This does nothing -- it is just a
@@ -2388,7 +2385,7 @@ function_command (const char *command, int from_tty)
static struct cmd_list_element *
do_add_internal_function (const char *name, const char *doc,
- internal_function_fn handler, void *cookie)
+ internal_function_fn_noside handler, void *cookie)
{
struct internal_function *ifn;
struct internalvar *var = lookup_internalvar (name);
@@ -2403,17 +2400,50 @@ do_add_internal_function (const char *name, const char *doc,
void
add_internal_function (const char *name, const char *doc,
- internal_function_fn handler, void *cookie)
+ internal_function_fn_noside handler, void *cookie)
{
do_add_internal_function (name, doc, handler, cookie);
}
+/* By default, internal functions are assumed to return int. Return a value
+ with that type to reflect this. If this is not correct for a specific
+ internal function, it should use an internal_function_fn_noside handler to
+ bypass this default. */
+
+static struct value *
+internal_function_default_return_type (struct gdbarch *gdbarch)
+{
+ return value::zero (builtin_type (gdbarch)->builtin_int, not_lval);
+}
+
+/* See value.h. */
+
+void
+add_internal_function (const char *name, const char *doc,
+ internal_function_fn handler, void *cookie)
+{
+ internal_function_fn_noside fn
+ = [=] (struct gdbarch *gdbarch,
+ const struct language_defn *language,
+ void *_cookie,
+ int argc,
+ struct value **argv,
+ enum noside noside)
+ {
+ if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ return internal_function_default_return_type (gdbarch);
+ return handler (gdbarch, language, _cookie, argc, argv);
+ };
+
+ do_add_internal_function (name, doc, fn, cookie);
+}
+
/* See value.h. */
void
add_internal_function (gdb::unique_xmalloc_ptr<char> &&name,
gdb::unique_xmalloc_ptr<char> &&doc,
- internal_function_fn handler, void *cookie)
+ internal_function_fn_noside handler, void *cookie)
{
struct cmd_list_element *cmd
= do_add_internal_function (name.get (), doc.get (), handler, cookie);
@@ -2426,6 +2456,31 @@ add_internal_function (gdb::unique_xmalloc_ptr<char> &&name,
cmd->name_allocated = 1;
}
+/* See value.h. */
+
+void
+add_internal_function (gdb::unique_xmalloc_ptr<char> &&name,
+ gdb::unique_xmalloc_ptr<char> &&doc,
+ internal_function_fn handler, void *cookie)
+{
+ internal_function_fn_noside fn
+ = [=] (struct gdbarch *gdbarch,
+ const struct language_defn *language,
+ void *_cookie,
+ int argc,
+ struct value **argv,
+ enum noside noside)
+ {
+ if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ return internal_function_default_return_type (gdbarch);
+ return handler (gdbarch, language, _cookie, argc, argv);
+ };
+
+ add_internal_function (std::forward<gdb::unique_xmalloc_ptr<char>>(name),
+ std::forward<gdb::unique_xmalloc_ptr<char>>(doc),
+ fn, cookie);
+}
+
void
value::preserve (struct objfile *objfile, htab_t copied_types)
{
@@ -3931,6 +3986,11 @@ value::fetch_lazy_memory ()
if (len > 0)
read_value_memory (this, 0, stack (), addr,
contents_all_raw ().data (), len);
+
+ /* If only part of an array was loaded, mark the rest as unavailable. */
+ if (m_limited_length > 0)
+ mark_bytes_unavailable (m_limited_length,
+ m_enclosing_type->length () - m_limited_length);
}
/* See value.h. */
@@ -4236,7 +4296,8 @@ isvoid_internal_fn (struct gdbarch *gdbarch,
static struct value *
creal_internal_fn (struct gdbarch *gdbarch,
const struct language_defn *language,
- void *cookie, int argc, struct value **argv)
+ void *cookie, int argc, struct value **argv,
+ enum noside noside)
{
if (argc != 1)
error (_("You must provide one argument for $_creal."));
@@ -4245,6 +4306,8 @@ creal_internal_fn (struct gdbarch *gdbarch,
type *ctype = check_typedef (cval->type ());
if (ctype->code () != TYPE_CODE_COMPLEX)
error (_("expected a complex number"));
+ if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ return value::zero (ctype->target_type (), not_lval);
return value_real_part (cval);
}
@@ -4255,7 +4318,7 @@ static struct value *
cimag_internal_fn (struct gdbarch *gdbarch,
const struct language_defn *language,
void *cookie, int argc,
- struct value **argv)
+ struct value **argv, enum noside noside)
{
if (argc != 1)
error (_("You must provide one argument for $_cimag."));
@@ -4264,6 +4327,8 @@ cimag_internal_fn (struct gdbarch *gdbarch,
type *ctype = check_typedef (cval->type ());
if (ctype->code () != TYPE_CODE_COMPLEX)
error (_("expected a complex number"));
+ if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ return value::zero (ctype->target_type (), not_lval);
return value_imaginary_part (cval);
}
diff --git a/gdb/value.h b/gdb/value.h
index 9d7e88d..13cfb00 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -1598,13 +1598,24 @@ extern struct value *find_function_in_inferior (const char *,
extern struct value *value_allocate_space_in_inferior (int);
-/* User function handler. */
-
-typedef struct value *(*internal_function_fn) (struct gdbarch *gdbarch,
- const struct language_defn *language,
- void *cookie,
- int argc,
- struct value **argv);
+/* User function handler. The internal_function_fn variant assumes return
+ type int. The internal_function_fn_noside returns some value with the
+ return type when passed noside == EVAL_AVOID_SIDE_EFFECTS. */
+
+using internal_function_fn
+ = std::function<struct value *(struct gdbarch *gdbarch,
+ const struct language_defn *language,
+ void *cookie,
+ int argc,
+ struct value **argv)>;
+
+using internal_function_fn_noside
+ = std::function<struct value *(struct gdbarch *gdbarch,
+ const struct language_defn *language,
+ void *cookie,
+ int argc,
+ struct value **argv,
+ enum noside noside)>;
/* Add a new internal function. NAME is the name of the function; DOC
is a documentation string describing the function. HANDLER is
@@ -1615,6 +1626,9 @@ typedef struct value *(*internal_function_fn) (struct gdbarch *gdbarch,
extern void add_internal_function (const char *name, const char *doc,
internal_function_fn handler,
void *cookie);
+extern void add_internal_function (const char *name, const char *doc,
+ internal_function_fn_noside handler,
+ void *cookie);
/* This overload takes an allocated documentation string. */
@@ -1622,11 +1636,16 @@ extern void add_internal_function (gdb::unique_xmalloc_ptr<char> &&name,
gdb::unique_xmalloc_ptr<char> &&doc,
internal_function_fn handler,
void *cookie);
+extern void add_internal_function (gdb::unique_xmalloc_ptr<char> &&name,
+ gdb::unique_xmalloc_ptr<char> &&doc,
+ internal_function_fn_noside handler,
+ void *cookie);
struct value *call_internal_function (struct gdbarch *gdbarch,
const struct language_defn *language,
struct value *function,
- int argc, struct value **argv);
+ int argc, struct value **argv,
+ enum noside noside);
const char *value_internal_function_name (struct value *);
diff --git a/gdb/xml-support.c b/gdb/xml-support.c
index b60b2c5..33c8e41 100644
--- a/gdb/xml-support.c
+++ b/gdb/xml-support.c
@@ -93,8 +93,8 @@ struct gdb_xml_parser
ATTRIBUTE_PRINTF (2, 0);
/* Issue an error message, and stop parsing. */
- void verror (const char *format, va_list ap)
- ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (2, 0);
+ [[noreturn]] void verror (const char *format, va_list ap)
+ ATTRIBUTE_PRINTF (2, 0);
void body_text (const XML_Char *text, int length);
void start_element (const XML_Char *name, const XML_Char **attrs);
diff --git a/gdb/xml-support.h b/gdb/xml-support.h
index b9bac7a..2ff0e3c 100644
--- a/gdb/xml-support.h
+++ b/gdb/xml-support.h
@@ -191,8 +191,9 @@ void gdb_xml_debug (struct gdb_xml_parser *parser, const char *format, ...)
/* Issue an error message from one of PARSER's handlers, and stop
parsing. */
-void gdb_xml_error (struct gdb_xml_parser *parser, const char *format, ...)
- ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (2, 3);
+[[noreturn]] void gdb_xml_error (struct gdb_xml_parser *parser,
+ const char *format, ...)
+ ATTRIBUTE_PRINTF (2, 3);
/* Find the attribute named NAME in the set of parsed attributes
ATTRIBUTES. Returns NULL if not found. */