aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb')
-rw-r--r--gdb/MAINTAINERS1
-rw-r--r--gdb/Makefile.in401
-rw-r--r--gdb/NEWS79
-rw-r--r--gdb/README24
-rw-r--r--gdb/aarch64-linux-nat.c79
-rw-r--r--gdb/aarch64-linux-tdep.c204
-rw-r--r--gdb/aarch64-nat.h4
-rw-r--r--gdb/aarch64-tdep.c158
-rw-r--r--gdb/aarch64-tdep.h25
-rw-r--r--gdb/aclocal.m42
-rw-r--r--gdb/ada-exp.h50
-rw-r--r--gdb/ada-exp.y19
-rw-r--r--gdb/ada-lang.c630
-rw-r--r--gdb/ada-lang.h15
-rw-r--r--gdb/ada-lex.l23
-rw-r--r--gdb/ada-typeprint.c3
-rw-r--r--gdb/ada-valprint.c5
-rw-r--r--gdb/addrmap.c20
-rw-r--r--gdb/addrmap.h4
-rw-r--r--gdb/alpha-netbsd-tdep.c2
-rw-r--r--gdb/alpha-obsd-tdep.c2
-rw-r--r--gdb/alpha-tdep.c2
-rw-r--r--gdb/amd-dbgapi-target.c219
-rw-r--r--gdb/amd64-linux-nat.c19
-rw-r--r--gdb/amd64-linux-tdep.c224
-rwxr-xr-x[-rw-r--r--]gdb/amd64-tdep.c247
-rw-r--r--gdb/amd64-tdep.h9
-rw-r--r--gdb/arc-linux-tdep.c2
-rw-r--r--gdb/arch-utils.c12
-rw-r--r--gdb/arch-utils.h5
-rw-r--r--gdb/arch/aarch64-gcs-linux.h44
-rw-r--r--gdb/arch/aarch64.c8
-rw-r--r--gdb/arch/aarch64.h14
-rw-r--r--gdb/arch/amd64-linux-tdesc.c31
-rw-r--r--gdb/arch/amd64-linux-tdesc.h7
-rw-r--r--gdb/arch/amd64.c25
-rw-r--r--gdb/arch/amd64.h10
-rw-r--r--gdb/arch/i386-linux-tdesc.c29
-rw-r--r--gdb/arch/i386-linux-tdesc.h5
-rw-r--r--gdb/arch/i386.c19
-rw-r--r--gdb/arch/i386.h7
-rw-r--r--gdb/arch/x86-linux-tdesc-features.c60
-rw-r--r--gdb/arch/x86-linux-tdesc-features.h27
-rw-r--r--gdb/arm-fbsd-tdep.c2
-rw-r--r--gdb/arm-linux-nat.c10
-rw-r--r--gdb/arm-linux-tdep.c11
-rw-r--r--gdb/arm-netbsd-tdep.c2
-rw-r--r--gdb/arm-obsd-tdep.c2
-rw-r--r--gdb/arm-pikeos-tdep.c2
-rw-r--r--gdb/arm-tdep.c11
-rw-r--r--gdb/arm-wince-tdep.c2
-rw-r--r--gdb/auto-load.c3
-rw-r--r--gdb/ax-gdb.c5
-rw-r--r--gdb/block.c63
-rw-r--r--gdb/block.h27
-rw-r--r--gdb/break-catch-exec.c4
-rw-r--r--gdb/break-catch-fork.c2
-rw-r--r--gdb/break-catch-syscall.c3
-rw-r--r--gdb/break-catch-throw.c3
-rw-r--r--gdb/break-cond-parse.c4
-rw-r--r--gdb/breakpoint.c11
-rw-r--r--gdb/btrace.c5
-rw-r--r--gdb/c-exp.y462
-rw-r--r--gdb/c-lang.c11
-rw-r--r--gdb/c-support.h10
-rw-r--r--gdb/c-typeprint.c13
-rw-r--r--gdb/charset.c1
-rw-r--r--gdb/cli/cli-cmds.c16
-rw-r--r--gdb/cli/cli-decode.c9
-rw-r--r--gdb/cli/cli-dump.c1
-rw-r--r--gdb/cli/cli-option.c4
-rw-r--r--gdb/cli/cli-script.c7
-rw-r--r--gdb/cli/cli-setshow.c3
-rw-r--r--gdb/cli/cli-utils.c27
-rw-r--r--gdb/coff-pe-read.c3
-rw-r--r--gdb/coffread.c31
-rw-r--r--gdb/compile/compile-c-symbols.c6
-rw-r--r--gdb/compile/compile-cplus-symbols.c4
-rw-r--r--gdb/completer.c2
-rw-r--r--gdb/config.in3
-rwxr-xr-xgdb/configure749
-rw-r--r--gdb/configure.ac93
-rw-r--r--gdb/configure.tgt24
-rwxr-xr-xgdb/copyright.py11
-rw-r--r--gdb/corelow.c59
-rw-r--r--gdb/cp-name-parser.y11
-rw-r--r--gdb/cp-support.c46
-rw-r--r--gdb/cris-tdep.c2
-rw-r--r--gdb/ctfread.c46
-rw-r--r--gdb/d-exp.y34
-rw-r--r--gdb/darwin-nat.c1
-rw-r--r--gdb/data-directory/Makefile.in1
-rw-r--r--gdb/dictionary.c4
-rw-r--r--gdb/disasm.c1
-rw-r--r--gdb/doc/gdb.texinfo370
-rw-r--r--gdb/doc/python.texi21
-rw-r--r--gdb/dwarf2/abbrev.c9
-rw-r--r--gdb/dwarf2/abbrev.h8
-rw-r--r--gdb/dwarf2/ada-imported.c2
-rw-r--r--gdb/dwarf2/cooked-index-entry.c10
-rw-r--r--gdb/dwarf2/cooked-index-shard.c18
-rw-r--r--gdb/dwarf2/cooked-index-shard.h7
-rw-r--r--gdb/dwarf2/cooked-index-worker.h15
-rw-r--r--gdb/dwarf2/cooked-index.h10
-rw-r--r--gdb/dwarf2/cooked-indexer.c37
-rw-r--r--gdb/dwarf2/index-common.c10
-rw-r--r--gdb/dwarf2/index-write.c100
-rw-r--r--gdb/dwarf2/line-program.c720
-rw-r--r--gdb/dwarf2/line-program.h47
-rw-r--r--gdb/dwarf2/read-debug-names.c20
-rw-r--r--gdb/dwarf2/read-gdb-index.c1312
-rw-r--r--gdb/dwarf2/read-gdb-index.h14
-rw-r--r--gdb/dwarf2/read.c1229
-rw-r--r--gdb/dwarf2/read.h123
-rw-r--r--gdb/dwarf2/stringify.c6
-rw-r--r--gdb/dwarf2/tag.h12
-rw-r--r--gdb/elfread.c10
-rw-r--r--gdb/eval.c30
-rw-r--r--gdb/event-top.c3
-rw-r--r--gdb/exec.c11
-rw-r--r--gdb/expop.h48
-rw-r--r--gdb/expprint.c1
-rw-r--r--gdb/extension.c79
-rw-r--r--gdb/f-exp.y10
-rw-r--r--gdb/f-typeprint.c22
-rw-r--r--gdb/f-valprint.c2
-rw-r--r--gdb/fbsd-nat.c2
-rw-r--r--gdb/fbsd-tdep.c83
-rw-r--r--gdb/features/Makefile4
-rw-r--r--gdb/features/aarch64-gcs-linux.c21
-rw-r--r--gdb/features/aarch64-gcs-linux.xml18
-rw-r--r--gdb/features/aarch64-gcs.c14
-rw-r--r--gdb/features/aarch64-gcs.xml11
-rw-r--r--gdb/features/i386/32bit-ssp.c14
-rw-r--r--gdb/features/i386/32bit-ssp.xml11
-rw-r--r--gdb/features/i386/64bit-ssp.c14
-rw-r--r--gdb/features/i386/64bit-ssp.xml11
-rw-r--r--gdb/findcmd.c7
-rw-r--r--gdb/findvar.c16
-rw-r--r--gdb/frame-unwind.c10
-rw-r--r--gdb/frame.c34
-rw-r--r--gdb/frame.h3
-rwxr-xr-x[-rw-r--r--]gdb/gcore-1.in38
-rw-r--r--gdb/gcore.c14
-rw-r--r--gdb/gdb-gdb.gdb.in3
-rw-r--r--gdb/gdb_wchar.h4
-rw-r--r--gdb/gdbarch-gen.c134
-rw-r--r--gdb/gdbarch-gen.h87
-rw-r--r--gdb/gdbarch.h6
-rw-r--r--gdb/gdbarch_components.py99
-rw-r--r--gdb/gdbtypes.c90
-rw-r--r--gdb/gdbtypes.h18
-rw-r--r--gdb/gnu-nat.c3
-rw-r--r--gdb/gnu-v2-abi.c3
-rw-r--r--gdb/go-exp.y11
-rw-r--r--gdb/go-lang.c3
-rw-r--r--gdb/go32-nat.c1
-rwxr-xr-xgdb/gstack-1.in3
-rw-r--r--gdb/guile/scm-cmd.c1
-rw-r--r--gdb/guile/scm-symbol.c26
-rw-r--r--gdb/guile/scm-type.c2
-rw-r--r--gdb/hppa-bsd-tdep.c10
-rw-r--r--gdb/hppa-linux-tdep.c8
-rw-r--r--gdb/hppa-tdep.c8
-rw-r--r--gdb/i386-fbsd-tdep.c5
-rw-r--r--gdb/i386-fbsd-tdep.h5
-rw-r--r--gdb/i386-linux-tdep.c10
-rw-r--r--gdb/i386-linux-tdep.h32
-rw-r--r--gdb/i386-tdep.c74
-rw-r--r--gdb/i386-tdep.h27
-rw-r--r--gdb/ia64-linux-tdep.c5
-rw-r--r--gdb/ia64-tdep.c16
-rw-r--r--gdb/infcall.c26
-rw-r--r--gdb/infcmd.c18
-rw-r--r--gdb/inferior.c1
-rw-r--r--gdb/inferior.h2
-rw-r--r--gdb/infrun.c72
-rw-r--r--gdb/jit.c2
-rw-r--r--gdb/language.c3
-rw-r--r--gdb/linespec.c54
-rw-r--r--gdb/linux-fork.c3
-rw-r--r--gdb/linux-nat.c5
-rw-r--r--gdb/linux-tdep.c113
-rw-r--r--gdb/linux-tdep.h18
-rw-r--r--gdb/linux-thread-db.c1
-rw-r--r--gdb/location.c17
-rw-r--r--gdb/loongarch-linux-nat.c11
-rw-r--r--gdb/loongarch-tdep.c383
-rw-r--r--gdb/m2-exp.y6
-rw-r--r--gdb/machoread.c12
-rw-r--r--gdb/macroscope.c6
-rw-r--r--gdb/main.c75
-rw-r--r--gdb/maint.c9
-rw-r--r--gdb/mdebugread.c56
-rw-r--r--gdb/mi/mi-cmd-break.c3
-rw-r--r--gdb/mi/mi-cmd-stack.c4
-rw-r--r--gdb/mi/mi-cmd-var.c3
-rw-r--r--gdb/mi/mi-main.c1
-rw-r--r--gdb/mi/mi-parse.c11
-rw-r--r--gdb/microblaze-tdep.c94
-rw-r--r--gdb/microblaze-tdep.h2
-rw-r--r--gdb/mingw-hdep.c61
-rw-r--r--gdb/minsyms.c8
-rw-r--r--gdb/minsyms.h2
-rw-r--r--gdb/mips-fbsd-tdep.c14
-rw-r--r--gdb/mips-linux-tdep.c12
-rw-r--r--gdb/mips-netbsd-tdep.c14
-rw-r--r--gdb/mips-tdep.c2
-rw-r--r--gdb/moxie-tdep.c2
-rw-r--r--gdb/nat/aarch64-hw-point.c6
-rw-r--r--gdb/nat/linux-osdata.c15
-rw-r--r--gdb/nat/linux-ptrace.c41
-rw-r--r--gdb/nat/x86-gcc-cpuid.h153
-rw-r--r--gdb/nat/x86-linux-tdesc.c20
-rw-r--r--gdb/nat/x86-linux-tdesc.h7
-rw-r--r--gdb/nat/x86-linux.c59
-rw-r--r--gdb/nat/x86-linux.h4
-rw-r--r--gdb/netbsd-nat.c2
-rw-r--r--gdb/objc-lang.c13
-rw-r--r--gdb/objfiles.c52
-rw-r--r--gdb/objfiles.h81
-rw-r--r--gdb/or1k-linux-tdep.c2
-rw-r--r--gdb/or1k-tdep.c1
-rw-r--r--gdb/p-exp.y23
-rw-r--r--gdb/p-lang.c1
-rw-r--r--gdb/p-typeprint.c5
-rw-r--r--gdb/parse.c1
-rw-r--r--gdb/ppc-linux-tdep.c19
-rw-r--r--gdb/ppc-sysv-tdep.c6
-rw-r--r--gdb/printcmd.c43
-rw-r--r--gdb/probe.c3
-rw-r--r--gdb/procfs.c5
-rw-r--r--gdb/producer.c4
-rw-r--r--gdb/progspace.c15
-rw-r--r--gdb/progspace.h12
-rw-r--r--gdb/psymtab.c41
-rw-r--r--gdb/psymtab.h18
-rw-r--r--gdb/pyproject.toml3
-rw-r--r--gdb/python/lib/gdb/dap/breakpoint.py13
-rw-r--r--gdb/python/lib/gdb/dap/events.py4
-rw-r--r--gdb/python/lib/gdb/dap/next.py12
-rw-r--r--gdb/python/lib/gdb/dap/server.py27
-rw-r--r--gdb/python/lib/gdb/dap/startup.py10
-rw-r--r--gdb/python/lib/gdb/dap/varref.py10
-rw-r--r--gdb/python/lib/gdb/printing.py19
-rw-r--r--gdb/python/py-block.c3
-rw-r--r--gdb/python/py-disasm.c85
-rw-r--r--gdb/python/py-event-types.def2
-rw-r--r--gdb/python/py-finishbreakpoint.c6
-rw-r--r--gdb/python/py-framefilter.c2
-rw-r--r--gdb/python/py-infevents.c2
-rw-r--r--gdb/python/py-infthread.c33
-rw-r--r--gdb/python/py-mi.c6
-rw-r--r--gdb/python/py-micmd.c4
-rw-r--r--gdb/python/py-objfile.c12
-rw-r--r--gdb/python/py-record.c3
-rw-r--r--gdb/python/py-symbol.c44
-rw-r--r--gdb/python/py-type.c15
-rw-r--r--gdb/python/py-unwind.c2
-rw-r--r--gdb/python/py-value.c82
-rw-r--r--gdb/python/python-internal.h7
-rw-r--r--gdb/python/python.c32
-rw-r--r--gdb/quick-symbol.h66
-rw-r--r--gdb/record-full.c76
-rw-r--r--gdb/record.c9
-rw-r--r--gdb/regcache.c7
-rw-r--r--gdb/remote-sim.c1
-rw-r--r--gdb/remote.c210
-rw-r--r--gdb/riscv-fbsd-tdep.c2
-rw-r--r--gdb/riscv-linux-tdep.c28
-rw-r--r--gdb/riscv-tdep.c66
-rw-r--r--gdb/rs6000-aix-tdep.c9
-rw-r--r--gdb/rs6000-tdep.c2
-rw-r--r--gdb/rust-lang.c19
-rw-r--r--gdb/rust-parse.c6
-rw-r--r--gdb/s12z-tdep.c2
-rw-r--r--gdb/s390-tdep.c6
-rw-r--r--gdb/serial.c3
-rw-r--r--gdb/setup.cfg3
-rw-r--r--gdb/solib-aix.c18
-rw-r--r--gdb/solib-aix.h2
-rw-r--r--gdb/solib-darwin.c23
-rw-r--r--gdb/solib-darwin.h2
-rw-r--r--gdb/solib-dsbt.c34
-rw-r--r--gdb/solib-dsbt.h2
-rw-r--r--gdb/solib-frv.c48
-rw-r--r--gdb/solib-frv.h2
-rw-r--r--gdb/solib-rocm.c41
-rw-r--r--gdb/solib-svr4-linux.c8
-rw-r--r--gdb/solib-svr4-linux.h8
-rw-r--r--gdb/solib-svr4.c328
-rw-r--r--gdb/solib-svr4.h36
-rw-r--r--gdb/solib-target.c67
-rw-r--r--gdb/solib-target.h4
-rw-r--r--gdb/solib.c88
-rw-r--r--gdb/solib.h38
-rw-r--r--gdb/source.c34
-rw-r--r--gdb/sparc-sol2-tdep.c2
-rw-r--r--gdb/sparc-tdep.c2
-rw-r--r--gdb/sparc64-sol2-tdep.c2
-rw-r--r--gdb/stabsread.c98
-rw-r--r--gdb/stack.c48
-rw-r--r--gdb/stap-probe.c23
-rw-r--r--gdb/symfile-debug.c90
-rw-r--r--gdb/symfile.c106
-rw-r--r--gdb/symfile.h9
-rw-r--r--gdb/symmisc.c8
-rw-r--r--gdb/symtab.c333
-rw-r--r--gdb/symtab.h38
-rw-r--r--gdb/syscalls/riscv-linux.xml340
-rw-r--r--gdb/syscalls/riscv-linux.xml.in344
-rwxr-xr-xgdb/syscalls/update-linux-from-src.sh5
-rwxr-xr-xgdb/syscalls/update-linux.sh3
-rw-r--r--gdb/tclint.toml55
-rw-r--r--gdb/terminal.h6
-rw-r--r--gdb/testsuite/boards/native-extended-gdbserver.exp2
-rw-r--r--gdb/testsuite/gdb.ada/array_bounds.exp2
-rw-r--r--gdb/testsuite/gdb.ada/array_long_idx.exp36
-rw-r--r--gdb/testsuite/gdb.ada/array_long_idx/main.adb31
-rw-r--r--gdb/testsuite/gdb.ada/array_long_idx/pck.adb21
-rw-r--r--gdb/testsuite/gdb.ada/array_long_idx/pck.ads19
-rw-r--r--gdb/testsuite/gdb.ada/array_of_variant.exp2
-rw-r--r--gdb/testsuite/gdb.ada/arrayidx.exp16
-rw-r--r--gdb/testsuite/gdb.ada/call_pn.exp2
-rw-r--r--gdb/testsuite/gdb.ada/complete.exp2
-rw-r--r--gdb/testsuite/gdb.ada/exec_changed.exp2
-rw-r--r--gdb/testsuite/gdb.ada/extended-access.c38
-rw-r--r--gdb/testsuite/gdb.ada/extended-access.exp29
-rw-r--r--gdb/testsuite/gdb.ada/file-then-restart.exp2
-rw-r--r--gdb/testsuite/gdb.ada/finish-var-size.exp2
-rw-r--r--gdb/testsuite/gdb.ada/formatted_ref.exp6
-rw-r--r--gdb/testsuite/gdb.ada/frame_args.exp2
-rw-r--r--gdb/testsuite/gdb.ada/fun_in_declare.exp2
-rw-r--r--gdb/testsuite/gdb.ada/huge.exp2
-rw-r--r--gdb/testsuite/gdb.ada/import.exp28
-rw-r--r--gdb/testsuite/gdb.ada/limited-length.exp2
-rw-r--r--gdb/testsuite/gdb.ada/mi_catch_assert.exp2
-rw-r--r--gdb/testsuite/gdb.ada/mi_catch_ex.exp2
-rw-r--r--gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp2
-rw-r--r--gdb/testsuite/gdb.ada/mi_dyn_arr.exp2
-rw-r--r--gdb/testsuite/gdb.ada/mi_ex_cond.exp2
-rw-r--r--gdb/testsuite/gdb.ada/mi_exc_info.exp2
-rw-r--r--gdb/testsuite/gdb.ada/mi_interface.exp2
-rw-r--r--gdb/testsuite/gdb.ada/mi_prot.exp2
-rw-r--r--gdb/testsuite/gdb.ada/mi_ref_changeable.exp2
-rw-r--r--gdb/testsuite/gdb.ada/mi_string_access.exp2
-rw-r--r--gdb/testsuite/gdb.ada/mi_task_arg.exp2
-rw-r--r--gdb/testsuite/gdb.ada/mi_task_info.exp2
-rw-r--r--gdb/testsuite/gdb.ada/mi_var_access.exp2
-rw-r--r--gdb/testsuite/gdb.ada/mi_var_array.exp2
-rw-r--r--gdb/testsuite/gdb.ada/mi_var_union.exp2
-rw-r--r--gdb/testsuite/gdb.ada/mi_variant.exp2
-rw-r--r--gdb/testsuite/gdb.ada/mod_from_name.exp2
-rw-r--r--gdb/testsuite/gdb.ada/null_array.exp2
-rw-r--r--gdb/testsuite/gdb.ada/ref_param.exp2
-rw-r--r--gdb/testsuite/gdb.ada/return-small-char-array.exp40
-rw-r--r--gdb/testsuite/gdb.ada/return-small-char-array/proc.adb22
-rw-r--r--gdb/testsuite/gdb.ada/return-small-char-array/value.adb21
-rw-r--r--gdb/testsuite/gdb.ada/return-small-char-array/value.ads20
-rw-r--r--gdb/testsuite/gdb.ada/scalar_storage.exp2
-rw-r--r--gdb/testsuite/gdb.ada/taft_type.exp2
-rw-r--r--gdb/testsuite/gdb.ada/unchecked_union.exp2
-rw-r--r--gdb/testsuite/gdb.ada/var_arr_typedef/pack.adb2
-rw-r--r--gdb/testsuite/gdb.ada/var_arr_typedef/pack.ads4
-rw-r--r--gdb/testsuite/gdb.ada/var_arr_typedef/var_arr_typedef.adb2
-rw-r--r--gdb/testsuite/gdb.ada/verylong.exp6
-rw-r--r--gdb/testsuite/gdb.ada/whatis_array_val.exp2
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-frameptr-vecreg-unwind.c62
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-frameptr-vecreg-unwind.exp33
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-gcs-core.c123
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-gcs-core.exp116
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-gcs-disp-step.c140
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-gcs-disp-step.exp86
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-gcs-return.c105
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-gcs-return.exp132
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-gcs-tdesc-without-linux.xml65
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-gcs-wrong-tdesc.c26
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-gcs-wrong-tdesc.exp48
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-gcs.c180
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-gcs.exp99
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-mte-core.exp6
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-pseudo-unwind.exp2
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl6
-rw-r--r--gdb/testsuite/gdb.arch/alpha-step.exp3
-rw-r--r--gdb/testsuite/gdb.arch/altivec-abi.exp3
-rw-r--r--gdb/testsuite/gdb.arch/amd64-byte.exp2
-rw-r--r--gdb/testsuite/gdb.arch/amd64-dword.exp2
-rw-r--r--gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis-no-cfi.S117
-rw-r--r--gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis-offset.S112
-rw-r--r--gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis.S143
-rw-r--r--gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis.c56
-rw-r--r--gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis.exp208
-rw-r--r--gdb/testsuite/gdb.arch/amd64-frameptr-vecreg-unwind.c63
-rw-r--r--gdb/testsuite/gdb.arch/amd64-frameptr-vecreg-unwind.exp40
-rw-r--r--gdb/testsuite/gdb.arch/amd64-init-x87-values.exp8
-rw-r--r--gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp4
-rw-r--r--gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp4
-rw-r--r--gdb/testsuite/gdb.arch/amd64-prologue-skip.exp5
-rw-r--r--gdb/testsuite/gdb.arch/amd64-prologue-xmm.exp2
-rw-r--r--gdb/testsuite/gdb.arch/amd64-pseudo-unwind.exp2
-rw-r--r--gdb/testsuite/gdb.arch/amd64-shadow-stack-cmds.exp143
-rw-r--r--gdb/testsuite/gdb.arch/amd64-shadow-stack-corefile.c46
-rw-r--r--gdb/testsuite/gdb.arch/amd64-shadow-stack-corefile.exp119
-rw-r--r--gdb/testsuite/gdb.arch/amd64-shadow-stack-disp-step.exp84
-rw-r--r--gdb/testsuite/gdb.arch/amd64-shadow-stack.c40
-rw-r--r--gdb/testsuite/gdb.arch/amd64-shadow-stack.exp71
-rw-r--r--gdb/testsuite/gdb.arch/amd64-word.exp2
-rw-r--r--gdb/testsuite/gdb.arch/arm-pseudo-unwind-legacy.exp2
-rw-r--r--gdb/testsuite/gdb.arch/arm-pseudo-unwind.exp2
-rw-r--r--gdb/testsuite/gdb.arch/arm-pthread_cond_timedwait-bt.exp2
-rw-r--r--gdb/testsuite/gdb.arch/e500-prologue.exp3
-rw-r--r--gdb/testsuite/gdb.arch/e500-regs.exp3
-rw-r--r--gdb/testsuite/gdb.arch/gdb1291.exp3
-rw-r--r--gdb/testsuite/gdb.arch/gdb1431.exp3
-rw-r--r--gdb/testsuite/gdb.arch/gdb1558.exp3
-rw-r--r--gdb/testsuite/gdb.arch/i386-avx.exp4
-rw-r--r--gdb/testsuite/gdb.arch/i386-bp_permanent.exp2
-rw-r--r--gdb/testsuite/gdb.arch/i386-byte.exp2
-rw-r--r--gdb/testsuite/gdb.arch/i386-dr3-watch.exp2
-rw-r--r--gdb/testsuite/gdb.arch/i386-gnu-cfi.exp2
-rw-r--r--gdb/testsuite/gdb.arch/i386-permbkpt.exp2
-rw-r--r--gdb/testsuite/gdb.arch/i386-prologue-skip-cf-protection.exp2
-rw-r--r--gdb/testsuite/gdb.arch/i386-prologue.exp2
-rw-r--r--gdb/testsuite/gdb.arch/i386-signal.exp2
-rw-r--r--gdb/testsuite/gdb.arch/i386-size-overlap.exp2
-rw-r--r--gdb/testsuite/gdb.arch/i386-size.exp2
-rw-r--r--gdb/testsuite/gdb.arch/i386-sse.exp2
-rw-r--r--gdb/testsuite/gdb.arch/i386-unwind.exp2
-rw-r--r--gdb/testsuite/gdb.arch/i386-word.exp2
-rw-r--r--gdb/testsuite/gdb.arch/ia64-breakpoint-shadow.exp3
-rw-r--r--gdb/testsuite/gdb.arch/mips-fpregset-core.exp6
-rw-r--r--gdb/testsuite/gdb.arch/mips-octeon-bbit.exp3
-rw-r--r--gdb/testsuite/gdb.arch/pa-nullify.exp3
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-aix-prologue.exp3
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-altivec.exp3
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-altivec2.exp3
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-altivec3.exp3
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-d128-regs.exp2
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-fpscr-gcore.exp2
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-htm-regs.exp5
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-power10.exp3
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-power7.exp3
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-power8.exp3
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-power9.exp3
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp4
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-prologue-frame.exp2
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-prologue.exp2
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-tar.exp4
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-vector-regs.exp4
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-vsx-gcore.exp2
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-vsx.exp3
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-vsx2.exp3
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-vsx3.exp3
-rw-r--r--gdb/testsuite/gdb.arch/ppc-dfp.exp2
-rw-r--r--gdb/testsuite/gdb.arch/ppc-fp.exp2
-rw-r--r--gdb/testsuite/gdb.arch/ppc-longdouble.exp2
-rw-r--r--gdb/testsuite/gdb.arch/pr25124.exp2
-rw-r--r--gdb/testsuite/gdb.arch/sparc-sysstep.exp2
-rw-r--r--gdb/testsuite/gdb.arch/thumb-prologue.exp2
-rw-r--r--gdb/testsuite/gdb.arch/thumb2-it.exp2
-rw-r--r--gdb/testsuite/gdb.arch/vsx-regs.exp3
-rw-r--r--gdb/testsuite/gdb.asm/asm-source.exp30
-rw-r--r--gdb/testsuite/gdb.base/a2-run.exp7
-rw-r--r--gdb/testsuite/gdb.base/access-mem-running.exp3
-rw-r--r--gdb/testsuite/gdb.base/annota1.exp3
-rw-r--r--gdb/testsuite/gdb.base/annotate-symlink.exp2
-rw-r--r--gdb/testsuite/gdb.base/args.exp208
-rw-r--r--gdb/testsuite/gdb.base/arrayidx.exp3
-rw-r--r--gdb/testsuite/gdb.base/assign.exp3
-rw-r--r--gdb/testsuite/gdb.base/attach-fail-twice.exp3
-rw-r--r--gdb/testsuite/gdb.base/attach-non-pgrp-leader.exp6
-rw-r--r--gdb/testsuite/gdb.base/attach-twice.exp2
-rw-r--r--gdb/testsuite/gdb.base/attach-wait-input.exp3
-rw-r--r--gdb/testsuite/gdb.base/attach.c4
-rw-r--r--gdb/testsuite/gdb.base/attach.exp9
-rw-r--r--gdb/testsuite/gdb.base/auxv.exp3
-rw-r--r--gdb/testsuite/gdb.base/backtrace-through-cu-nodebug.exp5
-rw-r--r--gdb/testsuite/gdb.base/backtrace.exp6
-rw-r--r--gdb/testsuite/gdb.base/basic-edit-cmd.exp3
-rw-r--r--gdb/testsuite/gdb.base/bfp-test.exp3
-rw-r--r--gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.exp3
-rw-r--r--gdb/testsuite/gdb.base/bg-execution-repeat.exp3
-rw-r--r--gdb/testsuite/gdb.base/bigcore.exp3
-rw-r--r--gdb/testsuite/gdb.base/bitfields2.exp3
-rw-r--r--gdb/testsuite/gdb.base/bp-cmds-continue-ctrl-c.exp6
-rw-r--r--gdb/testsuite/gdb.base/bp-cond-failure.exp5
-rw-r--r--gdb/testsuite/gdb.base/bp-disabled-by-cond.exp3
-rw-r--r--gdb/testsuite/gdb.base/bp-permanent.exp3
-rw-r--r--gdb/testsuite/gdb.base/break-fun-addr.exp3
-rw-r--r--gdb/testsuite/gdb.base/break-idempotent.exp2
-rw-r--r--gdb/testsuite/gdb.base/break-interp.exp4
-rw-r--r--gdb/testsuite/gdb.base/bt-on-fatal-signal.exp3
-rw-r--r--gdb/testsuite/gdb.base/bt-selected-frame.exp3
-rw-r--r--gdb/testsuite/gdb.base/call-rt-st.exp3
-rw-r--r--gdb/testsuite/gdb.base/call-sc.exp2
-rw-r--r--gdb/testsuite/gdb.base/call-signal-resume.exp3
-rw-r--r--gdb/testsuite/gdb.base/callexit.exp3
-rw-r--r--gdb/testsuite/gdb.base/catch-syscall.exp12
-rw-r--r--gdb/testsuite/gdb.base/checkpoint.exp6
-rw-r--r--gdb/testsuite/gdb.base/chng-syms.exp3
-rw-r--r--gdb/testsuite/gdb.base/clear_non_user_bp.exp3
-rw-r--r--gdb/testsuite/gdb.base/cli-suppress-notification.exp2
-rw-r--r--gdb/testsuite/gdb.base/code-expr.exp3
-rw-r--r--gdb/testsuite/gdb.base/color-prompt.exp29
-rw-r--r--gdb/testsuite/gdb.base/cond-expr.exp3
-rw-r--r--gdb/testsuite/gdb.base/condbreak-bad.exp2
-rw-r--r--gdb/testsuite/gdb.base/condbreak-multi-context.exp15
-rw-r--r--gdb/testsuite/gdb.base/consecutive.exp4
-rw-r--r--gdb/testsuite/gdb.base/constvars.exp3
-rw-r--r--gdb/testsuite/gdb.base/continue-after-aborted-step-over.exp3
-rw-r--r--gdb/testsuite/gdb.base/corefile-exec-context.exp9
-rw-r--r--gdb/testsuite/gdb.base/corefile-shmem-zero-id.exp6
-rw-r--r--gdb/testsuite/gdb.base/corefile.exp13
-rw-r--r--gdb/testsuite/gdb.base/corefile2.exp7
-rw-r--r--gdb/testsuite/gdb.base/corefile3.exp4
-rw-r--r--gdb/testsuite/gdb.base/ctf-ptype.exp5
-rw-r--r--gdb/testsuite/gdb.base/cvexpr.exp2
-rw-r--r--gdb/testsuite/gdb.base/default-args.exp3
-rw-r--r--gdb/testsuite/gdb.base/default.exp55
-rw-r--r--gdb/testsuite/gdb.base/detach-sysroot-target.exp2
-rw-r--r--gdb/testsuite/gdb.base/detach-while-running.exp3
-rw-r--r--gdb/testsuite/gdb.base/detach.exp3
-rw-r--r--gdb/testsuite/gdb.base/dfp-test.exp3
-rw-r--r--gdb/testsuite/gdb.base/display.exp3
-rw-r--r--gdb/testsuite/gdb.base/dlmopen-ns-ids.exp173
-rw-r--r--gdb/testsuite/gdb.base/dlmopen.exp50
-rw-r--r--gdb/testsuite/gdb.base/dprintf-bp-same-addr.exp3
-rw-r--r--gdb/testsuite/gdb.base/dprintf-detach.exp6
-rw-r--r--gdb/testsuite/gdb.base/dprintf-execution-x-script.exp3
-rw-r--r--gdb/testsuite/gdb.base/dprintf-pending.exp3
-rw-r--r--gdb/testsuite/gdb.base/dprintf.exp3
-rw-r--r--gdb/testsuite/gdb.base/dso2dso.exp3
-rw-r--r--gdb/testsuite/gdb.base/dtrace-probe.exp7
-rw-r--r--gdb/testsuite/gdb.base/dump.c2
-rw-r--r--gdb/testsuite/gdb.base/dump.exp12
-rw-r--r--gdb/testsuite/gdb.base/duplicate-bp.exp3
-rw-r--r--gdb/testsuite/gdb.base/eh_return.exp3
-rw-r--r--gdb/testsuite/gdb.base/ending-run.exp2
-rw-r--r--gdb/testsuite/gdb.base/errno.exp6
-rw-r--r--gdb/testsuite/gdb.base/eval-skip.exp3
-rw-r--r--gdb/testsuite/gdb.base/exe-lock.exp3
-rw-r--r--gdb/testsuite/gdb.base/exec-invalid-sysroot.exp3
-rw-r--r--gdb/testsuite/gdb.base/execl-update-breakpoints.exp9
-rw-r--r--gdb/testsuite/gdb.base/exprs.exp8
-rw-r--r--gdb/testsuite/gdb.base/fileio.c4
-rw-r--r--gdb/testsuite/gdb.base/fileio.exp5
-rw-r--r--gdb/testsuite/gdb.base/find.exp3
-rw-r--r--gdb/testsuite/gdb.base/fixsection.exp3
-rw-r--r--gdb/testsuite/gdb.base/float128.exp3
-rw-r--r--gdb/testsuite/gdb.base/floatn.exp3
-rw-r--r--gdb/testsuite/gdb.base/foll-exec.exp.tcl18
-rw-r--r--gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen.exp3
-rw-r--r--gdb/testsuite/gdb.base/fork-print-inferior-events.exp3
-rw-r--r--gdb/testsuite/gdb.base/frame-args.exp3
-rw-r--r--gdb/testsuite/gdb.base/frame-info-consistent.exp3
-rw-r--r--gdb/testsuite/gdb.base/frame-view.exp3
-rw-r--r--gdb/testsuite/gdb.base/fullname.exp11
-rw-r--r--gdb/testsuite/gdb.base/gcore-buffer-overflow.exp3
-rw-r--r--gdb/testsuite/gdb.base/gcore-memory-usage.exp25
-rw-r--r--gdb/testsuite/gdb.base/gcore-relro-pie.exp6
-rw-r--r--gdb/testsuite/gdb.base/gcore-relro.exp6
-rw-r--r--gdb/testsuite/gdb.base/gcore-tls-pie.exp6
-rw-r--r--gdb/testsuite/gdb.base/gcore.exp3
-rw-r--r--gdb/testsuite/gdb.base/gcorebg.exp4
-rw-r--r--gdb/testsuite/gdb.base/gdb-index-err.exp6
-rw-r--r--gdb/testsuite/gdb.base/gdb1250.exp3
-rw-r--r--gdb/testsuite/gdb.base/gdb1555.exp3
-rw-r--r--gdb/testsuite/gdb.base/gdbindex-stabs.exp3
-rw-r--r--gdb/testsuite/gdb.base/gdbinit-history.exp2
-rw-r--r--gdb/testsuite/gdb.base/global-var-nested-by-dso.exp3
-rw-r--r--gdb/testsuite/gdb.base/gnu-ifunc.exp11
-rw-r--r--gdb/testsuite/gdb.base/gnu_vector.exp3
-rw-r--r--gdb/testsuite/gdb.base/hashline1.exp3
-rw-r--r--gdb/testsuite/gdb.base/hashline2.exp3
-rw-r--r--gdb/testsuite/gdb.base/hashline3.exp3
-rw-r--r--gdb/testsuite/gdb.base/hbreak-in-shr-unsupported.exp3
-rw-r--r--gdb/testsuite/gdb.base/hook-stop.exp3
-rw-r--r--gdb/testsuite/gdb.base/huge.exp3
-rw-r--r--gdb/testsuite/gdb.base/infcall-exec.exp3
-rw-r--r--gdb/testsuite/gdb.base/infcall-failure-2.exp37
-rw-r--r--gdb/testsuite/gdb.base/infcall-failure.exp3
-rw-r--r--gdb/testsuite/gdb.base/infcall-nested-structs.exp.tcl5
-rw-r--r--gdb/testsuite/gdb.base/infcall-timeout.exp3
-rw-r--r--gdb/testsuite/gdb.base/inferior-args.exp38
-rw-r--r--gdb/testsuite/gdb.base/inferior-died.exp3
-rw-r--r--gdb/testsuite/gdb.base/info-proc.exp3
-rw-r--r--gdb/testsuite/gdb.base/info-program.exp3
-rw-r--r--gdb/testsuite/gdb.base/info-types.exp.tcl2
-rw-r--r--gdb/testsuite/gdb.base/info_sources_2.exp38
-rw-r--r--gdb/testsuite/gdb.base/inline-frame-cycle-unwind.py4
-rw-r--r--gdb/testsuite/gdb.base/internal-string-values.exp3
-rw-r--r--gdb/testsuite/gdb.base/interrupt-daemon-attach.exp6
-rw-r--r--gdb/testsuite/gdb.base/interrupt-daemon.exp3
-rw-r--r--gdb/testsuite/gdb.base/jit-bfd-name.exp3
-rw-r--r--gdb/testsuite/gdb.base/jit-elf-fork.exp3
-rw-r--r--gdb/testsuite/gdb.base/jit-elf-so.exp3
-rw-r--r--gdb/testsuite/gdb.base/jit-elf.exp6
-rw-r--r--gdb/testsuite/gdb.base/jit-reader-exec.exp3
-rw-r--r--gdb/testsuite/gdb.base/jit-reader-simple.exp9
-rw-r--r--gdb/testsuite/gdb.base/jit-reader.exp3
-rw-r--r--gdb/testsuite/gdb.base/kill-during-detach.exp3
-rw-r--r--gdb/testsuite/gdb.base/killed-outside.exp3
-rw-r--r--gdb/testsuite/gdb.base/langs.exp3
-rw-r--r--gdb/testsuite/gdb.base/large-frame.exp4
-rw-r--r--gdb/testsuite/gdb.base/libsegfault.exp9
-rw-r--r--gdb/testsuite/gdb.base/lineinc.exp3
-rw-r--r--gdb/testsuite/gdb.base/list-missing-source.exp3
-rw-r--r--gdb/testsuite/gdb.base/list.exp9
-rw-r--r--gdb/testsuite/gdb.base/logical.exp3
-rw-r--r--gdb/testsuite/gdb.base/long_long.exp3
-rw-r--r--gdb/testsuite/gdb.base/longjmp.exp3
-rw-r--r--gdb/testsuite/gdb.base/macro-source-path.exp5
-rw-r--r--gdb/testsuite/gdb.base/macscp.exp3
-rw-r--r--gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.exp3
-rw-r--r--gdb/testsuite/gdb.base/maint-test-remote-args.exp40
-rw-r--r--gdb/testsuite/gdb.base/maint.exp3
-rw-r--r--gdb/testsuite/gdb.base/many-headers.exp1
-rw-r--r--gdb/testsuite/gdb.base/max-depth.exp.tcl4
-rw-r--r--gdb/testsuite/gdb.base/memops-watchpoint.exp153
-rw-r--r--gdb/testsuite/gdb.base/miscexprs.exp3
-rw-r--r--gdb/testsuite/gdb.base/msym-bp-shl.exp3
-rw-r--r--gdb/testsuite/gdb.base/multi-forks.exp9
-rw-r--r--gdb/testsuite/gdb.base/nodebug.exp3
-rw-r--r--gdb/testsuite/gdb.base/nofield.exp3
-rw-r--r--gdb/testsuite/gdb.base/nostdlib.exp3
-rw-r--r--gdb/testsuite/gdb.base/options.exp6
-rw-r--r--gdb/testsuite/gdb.base/paginate-after-ctrl-c-running.exp3
-rw-r--r--gdb/testsuite/gdb.base/paginate-bg-execution.exp3
-rw-r--r--gdb/testsuite/gdb.base/paginate-inferior-exit.exp3
-rw-r--r--gdb/testsuite/gdb.base/patch.exp6
-rw-r--r--gdb/testsuite/gdb.base/pc-not-saved.exp3
-rw-r--r--gdb/testsuite/gdb.base/pie-fork.exp3
-rw-r--r--gdb/testsuite/gdb.base/pointers.exp3
-rw-r--r--gdb/testsuite/gdb.base/pr11022.exp3
-rw-r--r--gdb/testsuite/gdb.base/print-symbol-loading.exp6
-rw-r--r--gdb/testsuite/gdb.base/prologue.exp3
-rw-r--r--gdb/testsuite/gdb.base/ptr-typedef.exp3
-rw-r--r--gdb/testsuite/gdb.base/ptype.exp5
-rw-r--r--gdb/testsuite/gdb.base/quit-live.exp3
-rw-r--r--gdb/testsuite/gdb.base/random-signal.exp6
-rw-r--r--gdb/testsuite/gdb.base/readline-ask.exp5
-rw-r--r--gdb/testsuite/gdb.base/readline-commands-eof.exp3
-rw-r--r--gdb/testsuite/gdb.base/readline.exp2
-rw-r--r--gdb/testsuite/gdb.base/readnever.exp2
-rw-r--r--gdb/testsuite/gdb.base/relativedebug.exp3
-rw-r--r--gdb/testsuite/gdb.base/remote-exec-file.exp7
-rw-r--r--gdb/testsuite/gdb.base/remote.exp3
-rw-r--r--gdb/testsuite/gdb.base/reread.exp3
-rw-r--r--gdb/testsuite/gdb.base/reset-catchpoint-cond.exp3
-rw-r--r--gdb/testsuite/gdb.base/restore.exp3
-rw-r--r--gdb/testsuite/gdb.base/return2.exp3
-rw-r--r--gdb/testsuite/gdb.base/rtld-step.exp3
-rw-r--r--gdb/testsuite/gdb.base/run-attach-while-running.exp3
-rw-r--r--gdb/testsuite/gdb.base/run-control-while-bg-execution.exp3
-rw-r--r--gdb/testsuite/gdb.base/run-fail-twice.exp3
-rw-r--r--gdb/testsuite/gdb.base/savedregs.exp3
-rw-r--r--gdb/testsuite/gdb.base/sep.exp6
-rw-r--r--gdb/testsuite/gdb.base/sepsymtab.exp3
-rw-r--r--gdb/testsuite/gdb.base/set-cwd.exp6
-rw-r--r--gdb/testsuite/gdb.base/set-inferior-tty.exp3
-rw-r--r--gdb/testsuite/gdb.base/setshow.exp6
-rw-r--r--gdb/testsuite/gdb.base/settings.exp3
-rw-r--r--gdb/testsuite/gdb.base/share-env-with-gdbserver.exp12
-rw-r--r--gdb/testsuite/gdb.base/shlib-call.exp6
-rw-r--r--gdb/testsuite/gdb.base/shlib-unload.exp12
-rw-r--r--gdb/testsuite/gdb.base/shreloc.exp3
-rw-r--r--gdb/testsuite/gdb.base/sigaltstack.exp3
-rw-r--r--gdb/testsuite/gdb.base/sigchld.exp3
-rw-r--r--gdb/testsuite/gdb.base/siginfo-obj.exp3
-rw-r--r--gdb/testsuite/gdb.base/siginfo-thread.exp6
-rw-r--r--gdb/testsuite/gdb.base/signals-state-child.exp3
-rw-r--r--gdb/testsuite/gdb.base/signals.exp3
-rw-r--r--gdb/testsuite/gdb.base/signull.exp3
-rw-r--r--gdb/testsuite/gdb.base/sigrepeat.exp3
-rw-r--r--gdb/testsuite/gdb.base/sigstep.exp3
-rw-r--r--gdb/testsuite/gdb.base/skip.exp3
-rw-r--r--gdb/testsuite/gdb.base/so-impl-ld.exp3
-rw-r--r--gdb/testsuite/gdb.base/solib-abort.exp3
-rw-r--r--gdb/testsuite/gdb.base/solib-disc.exp3
-rw-r--r--gdb/testsuite/gdb.base/solib-symbol.exp3
-rw-r--r--gdb/testsuite/gdb.base/solib-weak.exp3
-rw-r--r--gdb/testsuite/gdb.base/source-dir.exp55
-rw-r--r--gdb/testsuite/gdb.base/source-search.c127
-rw-r--r--gdb/testsuite/gdb.base/source-search.exp106
-rw-r--r--gdb/testsuite/gdb.base/stack-checking.exp3
-rw-r--r--gdb/testsuite/gdb.base/startup-with-shell.exp161
-rw-r--r--gdb/testsuite/gdb.base/step-over-no-symbols.exp3
-rw-r--r--gdb/testsuite/gdb.base/step-sw-breakpoint-adjust-pc.exp3
-rw-r--r--gdb/testsuite/gdb.base/step-test.exp3
-rw-r--r--gdb/testsuite/gdb.base/structs.exp2
-rw-r--r--gdb/testsuite/gdb.base/structs2.exp2
-rw-r--r--gdb/testsuite/gdb.base/style.exp19
-rw-r--r--gdb/testsuite/gdb.base/sym-file.exp6
-rw-r--r--gdb/testsuite/gdb.base/symtab-search-order.exp3
-rw-r--r--gdb/testsuite/gdb.base/testenv.exp8
-rw-r--r--gdb/testsuite/gdb.base/tls-common.exp.tcl2
-rw-r--r--gdb/testsuite/gdb.base/tls-dlobj-lib.c2
-rw-r--r--gdb/testsuite/gdb.base/tls-dlobj.c2
-rw-r--r--gdb/testsuite/gdb.base/tls-dlobj.exp8
-rw-r--r--gdb/testsuite/gdb.base/tls-multiobj.c2
-rw-r--r--gdb/testsuite/gdb.base/tls-multiobj.exp8
-rw-r--r--gdb/testsuite/gdb.base/tls-multiobj1.c2
-rw-r--r--gdb/testsuite/gdb.base/tls-multiobj2.c2
-rw-r--r--gdb/testsuite/gdb.base/tls-multiobj3.c2
-rw-r--r--gdb/testsuite/gdb.base/tls-nothreads.c2
-rw-r--r--gdb/testsuite/gdb.base/tls-nothreads.exp11
-rw-r--r--gdb/testsuite/gdb.base/twice.exp3
-rw-r--r--gdb/testsuite/gdb.base/type-opaque.exp3
-rw-r--r--gdb/testsuite/gdb.base/unload.exp3
-rw-r--r--gdb/testsuite/gdb.base/until-trailing-insns.exp16
-rw-r--r--gdb/testsuite/gdb.base/varargs.exp3
-rw-r--r--gdb/testsuite/gdb.base/watch_thread_num.exp3
-rw-r--r--gdb/testsuite/gdb.base/watchpoint-hw-attach.exp3
-rw-r--r--gdb/testsuite/gdb.base/watchpoint-running.exp3
-rw-r--r--gdb/testsuite/gdb.base/watchpoint-solib.exp3
-rw-r--r--gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.exp3
-rw-r--r--gdb/testsuite/gdb.base/watchpoint-unaligned.c37
-rw-r--r--gdb/testsuite/gdb.base/watchpoint-unaligned.exp111
-rw-r--r--gdb/testsuite/gdb.base/watchpoints.exp3
-rw-r--r--gdb/testsuite/gdb.base/with-mf.exp3
-rw-r--r--gdb/testsuite/gdb.base/with.exp9
-rw-r--r--gdb/testsuite/gdb.btrace/buffer-size.exp4
-rw-r--r--gdb/testsuite/gdb.btrace/data.exp4
-rw-r--r--gdb/testsuite/gdb.btrace/delta.exp4
-rw-r--r--gdb/testsuite/gdb.btrace/dlopen.exp2
-rw-r--r--gdb/testsuite/gdb.btrace/enable-new-thread.exp4
-rw-r--r--gdb/testsuite/gdb.btrace/enable-running.exp2
-rw-r--r--gdb/testsuite/gdb.btrace/enable.exp12
-rwxr-xr-xgdb/testsuite/gdb.btrace/exception.exp6
-rw-r--r--gdb/testsuite/gdb.btrace/function_call_history.exp6
-rw-r--r--gdb/testsuite/gdb.btrace/gcore.exp4
-rw-r--r--gdb/testsuite/gdb.btrace/instruction_history.exp4
-rw-r--r--gdb/testsuite/gdb.btrace/multi-inferior.exp8
-rw-r--r--gdb/testsuite/gdb.btrace/multi-thread-step.exp2
-rw-r--r--gdb/testsuite/gdb.btrace/nohist.exp4
-rw-r--r--gdb/testsuite/gdb.btrace/non-stop.exp2
-rw-r--r--gdb/testsuite/gdb.btrace/ptwrite.exp4
-rw-r--r--gdb/testsuite/gdb.btrace/reconnect.exp2
-rw-r--r--gdb/testsuite/gdb.btrace/record_goto-step.exp4
-rw-r--r--gdb/testsuite/gdb.btrace/record_goto.exp6
-rw-r--r--gdb/testsuite/gdb.btrace/rn-dl-bind.exp6
-rw-r--r--gdb/testsuite/gdb.btrace/segv.exp4
-rw-r--r--gdb/testsuite/gdb.btrace/step.exp4
-rw-r--r--gdb/testsuite/gdb.btrace/stepi.exp6
-rw-r--r--gdb/testsuite/gdb.btrace/tailcall-only.exp6
-rw-r--r--gdb/testsuite/gdb.btrace/tailcall.exp6
-rw-r--r--gdb/testsuite/gdb.btrace/tsx.exp4
-rw-r--r--gdb/testsuite/gdb.btrace/unknown_functions.exp6
-rw-r--r--gdb/testsuite/gdb.btrace/vdso.exp4
-rw-r--r--gdb/testsuite/gdb.compile/compile-cplus-print.exp7
-rw-r--r--gdb/testsuite/gdb.compile/compile-cplus.exp6
-rw-r--r--gdb/testsuite/gdb.compile/compile-ifunc.exp2
-rw-r--r--gdb/testsuite/gdb.compile/compile-ops.exp38
-rw-r--r--gdb/testsuite/gdb.compile/compile-print.exp2
-rw-r--r--gdb/testsuite/gdb.compile/compile-setjmp.exp2
-rw-r--r--gdb/testsuite/gdb.compile/compile-tls.exp2
-rw-r--r--gdb/testsuite/gdb.compile/compile.exp14
-rw-r--r--gdb/testsuite/gdb.cp/call-c.exp2
-rw-r--r--gdb/testsuite/gdb.cp/call-method-register.exp52
-rw-r--r--gdb/testsuite/gdb.cp/eval-reference-type.cc36
-rw-r--r--gdb/testsuite/gdb.cp/eval-reference-type.exp46
-rw-r--r--gdb/testsuite/gdb.cp/gdb2384.exp2
-rw-r--r--gdb/testsuite/gdb.cp/incomplete-type-overload.exp102
-rw-r--r--gdb/testsuite/gdb.cp/infcall-nodebug.exp.tcl4
-rw-r--r--gdb/testsuite/gdb.cp/method-ref-return.cc42
-rw-r--r--gdb/testsuite/gdb.cp/method-ref-return.exp70
-rw-r--r--gdb/testsuite/gdb.cp/nsalias.exp120
-rw-r--r--gdb/testsuite/gdb.cp/pr10728.exp2
-rw-r--r--gdb/testsuite/gdb.cp/print-global-stub.exp7
-rw-r--r--gdb/testsuite/gdb.cp/psmang.exp2
-rw-r--r--gdb/testsuite/gdb.cp/ref-params.exp2
-rw-r--r--gdb/testsuite/gdb.cp/rvalue-ref-params.exp2
-rw-r--r--gdb/testsuite/gdb.ctf/cross-tu-cyclic.exp4
-rw-r--r--gdb/testsuite/gdb.ctf/funcreturn.exp6
-rw-r--r--gdb/testsuite/gdb.dap/attach-fail.exp32
-rw-r--r--gdb/testsuite/gdb.dap/bt-nodebug.exp1
-rw-r--r--gdb/testsuite/gdb.dap/catch-exception.exp16
-rw-r--r--gdb/testsuite/gdb.dap/catch-exception/prog.adb5
-rw-r--r--gdb/testsuite/gdb.dap/eof.exp6
-rw-r--r--gdb/testsuite/gdb.dap/scopes.c2
-rw-r--r--gdb/testsuite/gdb.dap/scopes.exp44
-rw-r--r--gdb/testsuite/gdb.debuginfod/corefile-mapped-file.exp19
-rw-r--r--gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp24
-rw-r--r--gdb/testsuite/gdb.debuginfod/solib-with-soname.exp2
-rw-r--r--gdb/testsuite/gdb.disasm/am33.exp2
-rw-r--r--gdb/testsuite/gdb.disasm/basics.exp2
-rw-r--r--gdb/testsuite/gdb.disasm/hppa.exp14
-rw-r--r--gdb/testsuite/gdb.disasm/mn10300.exp2
-rw-r--r--gdb/testsuite/gdb.disasm/sh3.exp2
-rw-r--r--gdb/testsuite/gdb.dlang/circular.exp56
-rw-r--r--gdb/testsuite/gdb.dlang/demangle.exp2
-rw-r--r--gdb/testsuite/gdb.dlang/dlang-start-2.exp24
-rw-r--r--gdb/testsuite/gdb.dlang/expression.exp2
-rw-r--r--gdb/testsuite/gdb.dlang/primitive-types.exp2
-rw-r--r--gdb/testsuite/gdb.dlang/properties.exp2
-rw-r--r--gdb/testsuite/gdb.dlang/watch-loc.exp22
-rw-r--r--gdb/testsuite/gdb.dwarf2/DW_OP_piece_with_DW_OP_GNU_uninit.exp28
-rw-r--r--gdb/testsuite/gdb.dwarf2/ada-array-bound.exp45
-rw-r--r--gdb/testsuite/gdb.dwarf2/ada-cold-name.exp24
-rw-r--r--gdb/testsuite/gdb.dwarf2/ada-linkage-name.exp28
-rw-r--r--gdb/testsuite/gdb.dwarf2/ada-thick-pointer.exp44
-rw-r--r--gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp52
-rw-r--r--gdb/testsuite/gdb.dwarf2/arr-opt-out.exp44
-rw-r--r--gdb/testsuite/gdb.dwarf2/arr-stride.exp78
-rw-r--r--gdb/testsuite/gdb.dwarf2/arr-subrange.exp70
-rw-r--r--gdb/testsuite/gdb.dwarf2/assign-variable-value-to-register.exp28
-rw-r--r--gdb/testsuite/gdb.dwarf2/atomic-type.exp92
-rw-r--r--gdb/testsuite/gdb.dwarf2/backward-spec-inter-cu.exp30
-rw-r--r--gdb/testsuite/gdb.dwarf2/bad-regnum.exp32
-rw-r--r--gdb/testsuite/gdb.dwarf2/bitfield-parent-optimized-out.exp36
-rw-r--r--gdb/testsuite/gdb.dwarf2/calling-convention.exp20
-rw-r--r--gdb/testsuite/gdb.dwarf2/clang-cli-macro.exp20
-rw-r--r--gdb/testsuite/gdb.dwarf2/clztest.exp2
-rw-r--r--gdb/testsuite/gdb.dwarf2/comp-unit-lang.exp10
-rw-r--r--gdb/testsuite/gdb.dwarf2/corrupt.exp26
-rw-r--r--gdb/testsuite/gdb.dwarf2/count.exp85
-rw-r--r--gdb/testsuite/gdb.dwarf2/cpp-linkage-name.exp44
-rw-r--r--gdb/testsuite/gdb.dwarf2/cu-empty-name.exp8
-rw-r--r--gdb/testsuite/gdb.dwarf2/cu-no-addrs.exp10
-rw-r--r--gdb/testsuite/gdb.dwarf2/data-loc.exp136
-rw-r--r--gdb/testsuite/gdb.dwarf2/debug-aranges-duplicate-offset-warning.exp20
-rw-r--r--gdb/testsuite/gdb.dwarf2/debug-names-bad-cu-index.exp28
-rw-r--r--gdb/testsuite/gdb.dwarf2/debug-names-duplicate-cu.exp20
-rw-r--r--gdb/testsuite/gdb.dwarf2/debug-names-missing-cu.exp24
-rw-r--r--gdb/testsuite/gdb.dwarf2/debug-names-tu.exp.tcl36
-rw-r--r--gdb/testsuite/gdb.dwarf2/debug-names.exp20
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw-form-ref-addr-with-type-units.exp28
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw-form-strx.exp.tcl16
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-align.exp50
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-aranges.exp7
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-bad-abstract-origin.exp78
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp62
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-bad-mips-linkage-name.exp31
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-bad-unresolved.exp18
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-bfloat16.exp40
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-complex-parts.exp80
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-disasm-over-non-stmt.exp14
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-empty-file-name.exp10
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-entry-pc.exp152
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-entry-points.c17
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-entry-points.exp141
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-entry-value-2.exp36
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp.tcl44
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-fixed-point.exp170
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-gas-workaround.exp92
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-ifort-parameter.exp26
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-inline-header-1.exp34
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-inline-header-2.exp34
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-inline-header-3.exp34
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-inline-many-frames.exp142
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp34
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-inline-stepping.exp40
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp58
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-inter-cu-error-2.exp8
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-inter-cu-error.exp12
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-inter-cu-forth-and-back.exp16
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-inter-cu-symbol.exp32
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.exp18
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-is-stmt.exp24
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-lexical-block-bare.exp22
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-line-number-zero.exp18
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-lines.exp22
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-linkage-name-trust.exp2
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-main-no-line-number.exp8
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-missing-cu-tag.exp4
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-multiple-debug-info.exp2
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-namespaceless-anonymous.exp22
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-noloc.exp188
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp74
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-out-of-range-end-of-seq.exp14
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp22
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-prologue-end.exp16
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp20
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-ranges-func.exp58
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-ranges-overlap.exp10
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-ranges-psym-warning.exp34
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-ranges-psym.exp38
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-regno-invalid.exp22
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-skipped-line-entries.exp12
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-step-between-different-inline-functions.exp64
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-step-between-inline-func-blocks.exp44
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-step-out-of-function-no-stmt.exp14
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-symtab-includes-lookup.exp14
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-symtab-includes.exp6
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-unexpected-entry-pc.exp40
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.exp30
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-unusual-field-names.exp44
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp50
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-var-zero-addr.exp2
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-vendor-extended-opcode.exp10
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-weird-type-len.exp48
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-wrong-mangled-name.exp20
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp23
-rw-r--r--gdb/testsuite/gdb.dwarf2/dwz-unused-pu.exp18
-rw-r--r--gdb/testsuite/gdb.dwarf2/dwz.exp42
-rw-r--r--gdb/testsuite/gdb.dwarf2/dwzbuildid.tcl20
-rw-r--r--gdb/testsuite/gdb.dwarf2/dwznolink.exp10
-rw-r--r--gdb/testsuite/gdb.dwarf2/dyn-type-unallocated.exp64
-rw-r--r--gdb/testsuite/gdb.dwarf2/dynamic-bit-offset.exp45
-rw-r--r--gdb/testsuite/gdb.dwarf2/dynarr-ptr.exp136
-rw-r--r--gdb/testsuite/gdb.dwarf2/enqueued-cu-base-addr.exp24
-rw-r--r--gdb/testsuite/gdb.dwarf2/entry-value-typedef.exp2
-rw-r--r--gdb/testsuite/gdb.dwarf2/enum-type.exp70
-rw-r--r--gdb/testsuite/gdb.dwarf2/fission-absolute-dwo.exp64
-rw-r--r--gdb/testsuite/gdb.dwarf2/fission-base.exp2
-rw-r--r--gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp18
-rw-r--r--gdb/testsuite/gdb.dwarf2/fission-loclists-pie.exp2
-rw-r--r--gdb/testsuite/gdb.dwarf2/fission-loclists.exp2
-rw-r--r--gdb/testsuite/gdb.dwarf2/fission-mix.exp2
-rw-r--r--gdb/testsuite/gdb.dwarf2/fission-multi-cu.exp86
-rw-r--r--gdb/testsuite/gdb.dwarf2/fission-relative-dwo.exp64
-rw-r--r--gdb/testsuite/gdb.dwarf2/fission-reread.exp2
-rw-r--r--gdb/testsuite/gdb.dwarf2/fission-with-type-unit.exp22
-rw-r--r--gdb/testsuite/gdb.dwarf2/formdata16.exp30
-rw-r--r--gdb/testsuite/gdb.dwarf2/fortran-var-string.exp94
-rw-r--r--gdb/testsuite/gdb.dwarf2/forward-spec-inter-cu.exp30
-rw-r--r--gdb/testsuite/gdb.dwarf2/forward-spec.exp26
-rw-r--r--gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp50
-rw-r--r--gdb/testsuite/gdb.dwarf2/gdb-add-index-symlink.exp3
-rw-r--r--gdb/testsuite/gdb.dwarf2/gdb-add-index.exp2
-rw-r--r--gdb/testsuite/gdb.dwarf2/gdb-index-tilde.exp2
-rw-r--r--gdb/testsuite/gdb.dwarf2/gdb-index-types-dwarf5.exp6
-rw-r--r--gdb/testsuite/gdb.dwarf2/gdb-index.exp10
-rw-r--r--gdb/testsuite/gdb.dwarf2/implptr-64bit.exp68
-rw-r--r--gdb/testsuite/gdb.dwarf2/implptr-optimized-out.exp46
-rw-r--r--gdb/testsuite/gdb.dwarf2/implptrconst.exp44
-rw-r--r--gdb/testsuite/gdb.dwarf2/implptrpiece.exp54
-rw-r--r--gdb/testsuite/gdb.dwarf2/implref-array.exp50
-rw-r--r--gdb/testsuite/gdb.dwarf2/implref-const.exp34
-rw-r--r--gdb/testsuite/gdb.dwarf2/implref-global.exp36
-rw-r--r--gdb/testsuite/gdb.dwarf2/implref-struct.exp68
-rw-r--r--gdb/testsuite/gdb.dwarf2/imported-unit-abstract-const-value.exp32
-rw-r--r--gdb/testsuite/gdb.dwarf2/imported-unit-bp.exp.tcl32
-rw-r--r--gdb/testsuite/gdb.dwarf2/imported-unit-c.exp56
-rw-r--r--gdb/testsuite/gdb.dwarf2/imported-unit-runto-main.exp26
-rw-r--r--gdb/testsuite/gdb.dwarf2/imported-unit.exp60
-rw-r--r--gdb/testsuite/gdb.dwarf2/info-locals-optimized-out.exp24
-rw-r--r--gdb/testsuite/gdb.dwarf2/inlined_subroutine-inheritance.exp122
-rw-r--r--gdb/testsuite/gdb.dwarf2/intbits.exp191
-rw-r--r--gdb/testsuite/gdb.dwarf2/loc-sec-offset.exp24
-rw-r--r--gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp104
-rw-r--r--gdb/testsuite/gdb.dwarf2/loclists-multiple-cus.exp26
-rw-r--r--gdb/testsuite/gdb.dwarf2/loclists-sec-offset.exp74
-rw-r--r--gdb/testsuite/gdb.dwarf2/loclists-start-end.exp26
-rw-r--r--gdb/testsuite/gdb.dwarf2/macro-complaints.exp16
-rw-r--r--gdb/testsuite/gdb.dwarf2/macro-source-path-clang14-dw4.exp4
-rw-r--r--gdb/testsuite/gdb.dwarf2/macro-source-path-clang14-dw5.exp4
-rw-r--r--gdb/testsuite/gdb.dwarf2/macro-source-path-gcc11-ld234-dw5.exp4
-rw-r--r--gdb/testsuite/gdb.dwarf2/macro-source-path-gcc11-ld238-dw4.exp4
-rw-r--r--gdb/testsuite/gdb.dwarf2/macro-source-path-gcc11-ld238-dw5.exp4
-rw-r--r--gdb/testsuite/gdb.dwarf2/macro-source-path.exp.tcl26
-rw-r--r--gdb/testsuite/gdb.dwarf2/main-subprogram.exp24
-rw-r--r--gdb/testsuite/gdb.dwarf2/mega-enum.exp20
-rw-r--r--gdb/testsuite/gdb.dwarf2/method-ptr.exp38
-rw-r--r--gdb/testsuite/gdb.dwarf2/missing-line-table.exp18
-rw-r--r--gdb/testsuite/gdb.dwarf2/missing-sig-type.exp10
-rw-r--r--gdb/testsuite/gdb.dwarf2/missing-type-name-for-templates.exp88
-rw-r--r--gdb/testsuite/gdb.dwarf2/missing-type-name.exp52
-rw-r--r--gdb/testsuite/gdb.dwarf2/multidictionary.exp88
-rw-r--r--gdb/testsuite/gdb.dwarf2/nameless-enum.exp20
-rw-r--r--gdb/testsuite/gdb.dwarf2/negative-data-member-location.exp30
-rw-r--r--gdb/testsuite/gdb.dwarf2/nonvar-access.exp138
-rw-r--r--gdb/testsuite/gdb.dwarf2/nostaticblock.exp4
-rw-r--r--gdb/testsuite/gdb.dwarf2/opaque-type-lookup.exp104
-rw-r--r--gdb/testsuite/gdb.dwarf2/opt-out-not-implptr.exp48
-rw-r--r--gdb/testsuite/gdb.dwarf2/rnglists-multiple-cus.exp8
-rw-r--r--gdb/testsuite/gdb.dwarf2/rnglists-sec-offset.exp20
-rw-r--r--gdb/testsuite/gdb.dwarf2/rust-enum.exp64
-rw-r--r--gdb/testsuite/gdb.dwarf2/self-spec.exp14
-rw-r--r--gdb/testsuite/gdb.dwarf2/short-build-id.exp16
-rw-r--r--gdb/testsuite/gdb.dwarf2/shortpiece.exp74
-rw-r--r--gdb/testsuite/gdb.dwarf2/static-optimized-out.exp14
-rw-r--r--gdb/testsuite/gdb.dwarf2/staticvirtual.exp20
-rw-r--r--gdb/testsuite/gdb.dwarf2/struct-decl.exp22
-rw-r--r--gdb/testsuite/gdb.dwarf2/struct-with-sig-2.exp52
-rw-r--r--gdb/testsuite/gdb.dwarf2/struct-with-sig.exp52
-rw-r--r--gdb/testsuite/gdb.dwarf2/subrange-enum.exp42
-rw-r--r--gdb/testsuite/gdb.dwarf2/subrange.exp58
-rw-r--r--gdb/testsuite/gdb.dwarf2/symbol_needs_eval_fail.exp20
-rw-r--r--gdb/testsuite/gdb.dwarf2/symbol_needs_eval_timeout.exp36
-rw-r--r--gdb/testsuite/gdb.dwarf2/symtab-producer.exp42
-rw-r--r--gdb/testsuite/gdb.dwarf2/template-specification-full-name.exp18
-rw-r--r--gdb/testsuite/gdb.dwarf2/typeddwarf.exp2
-rw-r--r--gdb/testsuite/gdb.dwarf2/typedef-void-finish.exp28
-rw-r--r--gdb/testsuite/gdb.dwarf2/utf-rust.exp20
-rw-r--r--gdb/testsuite/gdb.dwarf2/var-access.exp148
-rw-r--r--gdb/testsuite/gdb.dwarf2/variant.exp128
-rw-r--r--gdb/testsuite/gdb.dwarf2/varval.exp238
-rw-r--r--gdb/testsuite/gdb.dwarf2/void-type.exp56
-rw-r--r--gdb/testsuite/gdb.fortran/allocated.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/array-bounds.exp4
-rw-r--r--gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp6
-rw-r--r--gdb/testsuite/gdb.fortran/array-slices.exp4
-rw-r--r--gdb/testsuite/gdb.fortran/associated.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/assumedrank.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/call-no-debug.exp4
-rw-r--r--gdb/testsuite/gdb.fortran/charset.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/class-allocatable-array.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/common-block.exp4
-rw-r--r--gdb/testsuite/gdb.fortran/completion.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/debug-expr.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/empty-string.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/exprs.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/huge.exp8
-rw-r--r--gdb/testsuite/gdb.fortran/info-main.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/intrinsic-precedence.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/intvar-array.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/intvar-dynamic-types.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/lbound-ubound.exp4
-rw-r--r--gdb/testsuite/gdb.fortran/library-module.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/limited-length.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/mixed-lang-stack.exp6
-rw-r--r--gdb/testsuite/gdb.fortran/module.exp4
-rw-r--r--gdb/testsuite/gdb.fortran/multi-dim.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/namelist.exp4
-rwxr-xr-xgdb/testsuite/gdb.fortran/nested-funcs.exp2
-rwxr-xr-xgdb/testsuite/gdb.fortran/oop_extend_type.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/pointer-to-pointer.exp2
-rwxr-xr-xgdb/testsuite/gdb.fortran/print_type.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/rank.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/shape.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/short-circuit-argument-list.exp8
-rw-r--r--gdb/testsuite/gdb.fortran/size.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/sizeof.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/types.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/vla-array.exp6
-rw-r--r--gdb/testsuite/gdb.fortran/vla-datatypes.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/vla-history.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/vla-ptr-info.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/vla-ptype-sub.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/vla-ptype.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/vla-sizeof.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/vla-value-sub.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/vla-value.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/whatis_type.exp2
-rw-r--r--gdb/testsuite/gdb.gdb/index-file.exp16
-rw-r--r--gdb/testsuite/gdb.gdb/python-helper.exp2
-rw-r--r--gdb/testsuite/gdb.gdb/selftest.exp8
-rw-r--r--gdb/testsuite/gdb.gdb/unittest.exp2
-rw-r--r--gdb/testsuite/gdb.go/basic-types.exp4
-rw-r--r--gdb/testsuite/gdb.go/integers.exp4
-rw-r--r--gdb/testsuite/gdb.go/package.exp2
-rw-r--r--gdb/testsuite/gdb.go/print.exp2
-rw-r--r--gdb/testsuite/gdb.guile/scm-arch.exp2
-rw-r--r--gdb/testsuite/gdb.guile/scm-block.exp2
-rw-r--r--gdb/testsuite/gdb.guile/scm-breakpoint.exp28
-rw-r--r--gdb/testsuite/gdb.guile/scm-cmd.exp2
-rw-r--r--gdb/testsuite/gdb.guile/scm-color.exp1
-rw-r--r--gdb/testsuite/gdb.guile/scm-disasm.exp2
-rw-r--r--gdb/testsuite/gdb.guile/scm-equal.exp2
-rw-r--r--gdb/testsuite/gdb.guile/scm-frame-args.exp2
-rw-r--r--gdb/testsuite/gdb.guile/scm-frame-inline.exp2
-rw-r--r--gdb/testsuite/gdb.guile/scm-frame.exp2
-rw-r--r--gdb/testsuite/gdb.guile/scm-iterator.exp2
-rw-r--r--gdb/testsuite/gdb.guile/scm-lazy-string.exp2
-rw-r--r--gdb/testsuite/gdb.guile/scm-math.exp10
-rw-r--r--gdb/testsuite/gdb.guile/scm-objfile-script.exp2
-rw-r--r--gdb/testsuite/gdb.guile/scm-objfile.exp2
-rw-r--r--gdb/testsuite/gdb.guile/scm-parameter.exp94
-rw-r--r--gdb/testsuite/gdb.guile/scm-ports.exp6
-rw-r--r--gdb/testsuite/gdb.guile/scm-pretty-print.exp9
-rw-r--r--gdb/testsuite/gdb.guile/scm-section-script.exp2
-rw-r--r--gdb/testsuite/gdb.guile/scm-symbol.exp8
-rw-r--r--gdb/testsuite/gdb.guile/scm-symtab.exp4
-rw-r--r--gdb/testsuite/gdb.guile/scm-type.exp9
-rw-r--r--gdb/testsuite/gdb.guile/scm-value-cc.exp2
-rw-r--r--gdb/testsuite/gdb.guile/scm-value.exp11
-rw-r--r--gdb/testsuite/gdb.guile/types-module.exp2
-rw-r--r--gdb/testsuite/gdb.linespec/cp-replace-typedefs-ns-template.exp4
-rw-r--r--gdb/testsuite/gdb.linespec/cpcompletion.exp2
-rw-r--r--gdb/testsuite/gdb.linespec/explicit.exp2
-rw-r--r--gdb/testsuite/gdb.linespec/keywords.exp2
-rw-r--r--gdb/testsuite/gdb.linespec/line-breakpoint-outside-function.exp2
-rw-r--r--gdb/testsuite/gdb.linespec/ls-errs.exp7
-rw-r--r--gdb/testsuite/gdb.linespec/macro-relative.exp2
-rw-r--r--gdb/testsuite/gdb.linespec/skip-two.exp4
-rw-r--r--gdb/testsuite/gdb.linespec/thread.exp2
-rw-r--r--gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp4
-rw-r--r--gdb/testsuite/gdb.mi/gdb2549.exp2
-rw-r--r--gdb/testsuite/gdb.mi/gdb669.exp2
-rw-r--r--gdb/testsuite/gdb.mi/gdb701.exp2
-rw-r--r--gdb/testsuite/gdb.mi/gdb792.exp2
-rw-r--r--gdb/testsuite/gdb.mi/interrupt-thread-group.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-add-inferior.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-async-run.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-async.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-break-qualified.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-break.exp4
-rw-r--r--gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp6
-rw-r--r--gdb/testsuite/gdb.mi/mi-breakpoint-multiple-locations.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-breakpoint-script.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.exp4
-rw-r--r--gdb/testsuite/gdb.mi/mi-catch-load.exp4
-rw-r--r--gdb/testsuite/gdb.mi/mi-cli.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-cmd-user-context.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-complete.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-condbreak-call-thr-state.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-condbreak-fail.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-condbreak-throw.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-console.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-corefile.exp1
-rw-r--r--gdb/testsuite/gdb.mi/mi-detach.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-disassemble.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-dlmopen.exp16
-rw-r--r--gdb/testsuite/gdb.mi/mi-dprintf-modified.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-dprintf-pending.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-dprintf.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-eval.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-exec-run.exp5
-rw-r--r--gdb/testsuite/gdb.mi/mi-exit-code.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-fill-memory.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-fortran-modules.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-frame-regs.exp4
-rw-r--r--gdb/testsuite/gdb.mi/mi-fullname-deleted.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-info-os.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-info-sources.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-inheritance-syntax-error.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-linespec-err-cp.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-logging.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-memory-changed.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-nonstop-exit.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-nonstop.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-ns-stale-regcache.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-nsintrall.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-nsmoribund.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-nsthrexec.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-pending.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-pthreads.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-py-modify-bp.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-read-memory.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-record-changed.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-reg-undefined.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-regs.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-return.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-reverse.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-simplerun.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-solib.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-stack.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-start.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-stepi.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-stepn.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-sym-info.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-syn-frame.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-thread-bp-deleted.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-thread-specific-bp.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-threads-interrupt.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-until.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-block.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-child-f.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-child.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-cmd.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-cp.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-create-rtti.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-display.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-invalidate.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-list-children-invalid-grandchild.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-rtti.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-vla-c99.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-vla-fortran.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-watch-nonstop.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-watch.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi2-cli-display.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi2-var-child.exp2
-rw-r--r--gdb/testsuite/gdb.mi/new-ui-mi-sync.exp2
-rw-r--r--gdb/testsuite/gdb.mi/pr11022.exp2
-rw-r--r--gdb/testsuite/gdb.mi/print-simple-values.exp2
-rw-r--r--gdb/testsuite/gdb.mi/run-with-two-mi-uis.exp2
-rw-r--r--gdb/testsuite/gdb.mi/user-selected-context-sync.exp2
-rw-r--r--gdb/testsuite/gdb.multi/attach-no-multi-process.exp2
-rw-r--r--gdb/testsuite/gdb.multi/attach-while-running.exp2
-rw-r--r--gdb/testsuite/gdb.multi/gdb-settings.exp15
-rw-r--r--gdb/testsuite/gdb.multi/inferior-specific-bp.exp8
-rw-r--r--gdb/testsuite/gdb.multi/interrupt-bg-exec.c47
-rw-r--r--gdb/testsuite/gdb.multi/interrupt-bg-exec.exp143
-rw-r--r--gdb/testsuite/gdb.multi/multi-arch-exec.exp6
-rw-r--r--gdb/testsuite/gdb.multi/multi-arch.exp6
-rw-r--r--gdb/testsuite/gdb.multi/multi-exit.exp2
-rw-r--r--gdb/testsuite/gdb.multi/multi-kill.exp2
-rw-r--r--gdb/testsuite/gdb.multi/multi-re-run.exp14
-rw-r--r--gdb/testsuite/gdb.multi/multi-target.exp.tcl14
-rw-r--r--gdb/testsuite/gdb.multi/multi-term-settings.exp10
-rw-r--r--gdb/testsuite/gdb.multi/pending-bp-del-inferior.exp2
-rw-r--r--gdb/testsuite/gdb.multi/pending-bp.exp2
-rw-r--r--gdb/testsuite/gdb.multi/remote-with-running-inferior.c38
-rw-r--r--gdb/testsuite/gdb.multi/remote-with-running-inferior.exp171
-rw-r--r--gdb/testsuite/gdb.multi/remove-inferiors.exp2
-rw-r--r--gdb/testsuite/gdb.multi/run-only-second-inf.exp2
-rw-r--r--gdb/testsuite/gdb.multi/sched-multi-add-inferior.exp109
-rw-r--r--gdb/testsuite/gdb.multi/start-inferior-specific.exp5
-rw-r--r--gdb/testsuite/gdb.multi/watchpoint-multi-exit.exp4
-rw-r--r--gdb/testsuite/gdb.multi/watchpoint-multi.exp2
-rw-r--r--gdb/testsuite/gdb.objc/basicclass.exp2
-rw-r--r--gdb/testsuite/gdb.objc/nondebug.exp2
-rw-r--r--gdb/testsuite/gdb.objc/objcdecode.exp2
-rw-r--r--gdb/testsuite/gdb.objc/print.exp2
-rw-r--r--gdb/testsuite/gdb.opencl/callfuncs.exp7
-rw-r--r--gdb/testsuite/gdb.opencl/vec_comps.exp50
-rw-r--r--gdb/testsuite/gdb.opt/inline-break.exp10
-rw-r--r--gdb/testsuite/gdb.opt/inline-cmds.exp2
-rw-r--r--gdb/testsuite/gdb.opt/inline-entry.exp4
-rw-r--r--gdb/testsuite/gdb.opt/inline-small-func.exp2
-rw-r--r--gdb/testsuite/gdb.opt/solib-intra-step.exp2
-rw-r--r--gdb/testsuite/gdb.pascal/floats.exp6
-rw-r--r--gdb/testsuite/gdb.pascal/gdb11492.exp4
-rw-r--r--gdb/testsuite/gdb.pascal/hello.exp2
-rw-r--r--gdb/testsuite/gdb.pascal/integers.exp4
-rw-r--r--gdb/testsuite/gdb.pascal/print.exp2
-rw-r--r--gdb/testsuite/gdb.pascal/types.exp2
-rw-r--r--gdb/testsuite/gdb.perf/backtrace.exp4
-rw-r--r--gdb/testsuite/gdb.perf/gmonster1.exp2
-rw-r--r--gdb/testsuite/gdb.perf/gmonster2.exp2
-rw-r--r--gdb/testsuite/gdb.perf/single-step.exp4
-rw-r--r--gdb/testsuite/gdb.perf/skip-command.exp8
-rw-r--r--gdb/testsuite/gdb.perf/skip-prologue.exp4
-rw-r--r--gdb/testsuite/gdb.perf/solib.exp4
-rw-r--r--gdb/testsuite/gdb.perf/template-breakpoints.exp4
-rw-r--r--gdb/testsuite/gdb.python/make-visualizer.exp176
-rw-r--r--gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-arch-reg-groups.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-arch-reg-names.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-arch.exp4
-rw-r--r--gdb/testsuite/gdb.python/py-as-string.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-auto-load-chaining.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-bp-locations.exp4
-rw-r--r--gdb/testsuite/gdb.python/py-breakpoint-create-fail.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-caller-is.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-color-pagination.exp137
-rw-r--r--gdb/testsuite/gdb.python/py-color-pagination.py46
-rw-r--r--gdb/testsuite/gdb.python/py-color.exp1
-rw-r--r--gdb/testsuite/gdb.python/py-disasm.exp.tcl10
-rw-r--r--gdb/testsuite/gdb.python/py-event-load.exp6
-rw-r--r--gdb/testsuite/gdb.python/py-exec-file.exp8
-rw-r--r--gdb/testsuite/gdb.python/py-explore-cc.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-explore.exp6
-rw-r--r--gdb/testsuite/gdb.python/py-finish-breakpoint.exp8
-rw-r--r--gdb/testsuite/gdb.python/py-finish-breakpoint2.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-format-address.exp12
-rw-r--r--gdb/testsuite/gdb.python/py-format-string.exp9
-rw-r--r--gdb/testsuite/gdb.python/py-frame-args.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-framefilter-addr.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-framefilter-mi.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-inferior.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-label-symbol-value.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-lazy-string.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-linetable-empty.exp8
-rw-r--r--gdb/testsuite/gdb.python/py-linetable.exp4
-rw-r--r--gdb/testsuite/gdb.python/py-mi-events.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-mi-objfile.exp4
-rw-r--r--gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-mi.exp4
-rw-r--r--gdb/testsuite/gdb.python/py-missing-objfile.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-objfile-script.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-objfile.exp11
-rw-r--r--gdb/testsuite/gdb.python/py-parameter.exp10
-rw-r--r--gdb/testsuite/gdb.python/py-pp-cast.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-pp-integral.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-pp-maint.exp8
-rw-r--r--gdb/testsuite/gdb.python/py-pp-re-notag.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-pp-registration.exp10
-rw-r--r--gdb/testsuite/gdb.python/py-prettyprint.exp9
-rw-r--r--gdb/testsuite/gdb.python/py-progspace.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-read-memory-leak.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-record-btrace.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-record-full.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-section-script.exp6
-rw-r--r--gdb/testsuite/gdb.python/py-source-styling.exp8
-rw-r--r--gdb/testsuite/gdb.python/py-startup-opt.exp1
-rw-r--r--gdb/testsuite/gdb.python/py-strfns.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-styled-execute.exp1
-rw-r--r--gdb/testsuite/gdb.python/py-sym-artificial.exp16
-rw-r--r--gdb/testsuite/gdb.python/py-symbol.exp10
-rw-r--r--gdb/testsuite/gdb.python/py-thread-exited.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-thread-exited.py2
-rw-r--r--gdb/testsuite/gdb.python/py-thrhandle.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-type.exp11
-rw-r--r--gdb/testsuite/gdb.python/py-value-cc.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-value.c9
-rw-r--r--gdb/testsuite/gdb.python/py-value.exp61
-rw-r--r--gdb/testsuite/gdb.python/py-varobj.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-xmethods.exp2
-rw-r--r--gdb/testsuite/gdb.python/python.exp4
-rw-r--r--gdb/testsuite/gdb.replay/connect.exp6
-rw-r--r--gdb/testsuite/gdb.replay/missing-thread.c61
-rw-r--r--gdb/testsuite/gdb.replay/missing-thread.exp237
-rw-r--r--gdb/testsuite/gdb.reverse/aarch64-mops.exp2
-rw-r--r--gdb/testsuite/gdb.reverse/amd64-tailcall-reverse.exp6
-rw-r--r--gdb/testsuite/gdb.reverse/break-reverse.exp2
-rw-r--r--gdb/testsuite/gdb.reverse/consecutive-precsave.exp6
-rw-r--r--gdb/testsuite/gdb.reverse/consecutive-reverse.exp8
-rw-r--r--gdb/testsuite/gdb.reverse/finish-precsave.exp4
-rw-r--r--gdb/testsuite/gdb.reverse/finish-reverse-bkpt.exp2
-rw-r--r--gdb/testsuite/gdb.reverse/finish-reverse-next.exp4
-rw-r--r--gdb/testsuite/gdb.reverse/finish-reverse.exp2
-rw-r--r--gdb/testsuite/gdb.reverse/fstatat-reverse.exp2
-rw-r--r--gdb/testsuite/gdb.reverse/getrandom.exp2
-rw-r--r--gdb/testsuite/gdb.reverse/getresuid-reverse.exp2
-rw-r--r--gdb/testsuite/gdb.reverse/i386-avx-reverse.exp2
-rw-r--r--gdb/testsuite/gdb.reverse/i386-reverse.exp2
-rw-r--r--gdb/testsuite/gdb.reverse/i386-sse-reverse.exp2
-rw-r--r--gdb/testsuite/gdb.reverse/i387-env-reverse.exp2
-rw-r--r--gdb/testsuite/gdb.reverse/insn-reverse.exp2
-rw-r--r--gdb/testsuite/gdb.reverse/machinestate-precsave.exp2
-rw-r--r--gdb/testsuite/gdb.reverse/machinestate.exp4
-rw-r--r--gdb/testsuite/gdb.reverse/maint-print-instruction.exp4
-rw-r--r--gdb/testsuite/gdb.reverse/map-to-same-line.exp16
-rw-r--r--gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.exp2
-rw-r--r--gdb/testsuite/gdb.reverse/pipe-reverse.exp2
-rw-r--r--gdb/testsuite/gdb.reverse/readv-reverse.exp2
-rw-r--r--gdb/testsuite/gdb.reverse/recursion.exp2
-rw-r--r--gdb/testsuite/gdb.reverse/recvmsg-reverse.exp2
-rw-r--r--gdb/testsuite/gdb.reverse/s390-mvcle.exp2
-rw-r--r--gdb/testsuite/gdb.reverse/sigall-precsave.exp10
-rw-r--r--gdb/testsuite/gdb.reverse/sigall-reverse.exp6
-rw-r--r--gdb/testsuite/gdb.reverse/singlejmp-reverse.exp6
-rw-r--r--gdb/testsuite/gdb.reverse/solib-precsave.exp4
-rw-r--r--gdb/testsuite/gdb.reverse/solib-reverse.exp6
-rw-r--r--gdb/testsuite/gdb.reverse/step-precsave.exp4
-rw-r--r--gdb/testsuite/gdb.reverse/step-reverse.exp4
-rw-r--r--gdb/testsuite/gdb.reverse/until-precsave.exp4
-rw-r--r--gdb/testsuite/gdb.reverse/until-reverse.exp6
-rw-r--r--gdb/testsuite/gdb.reverse/waitpid-reverse.exp2
-rw-r--r--gdb/testsuite/gdb.reverse/watch-reverse.exp2
-rw-r--r--gdb/testsuite/gdb.rocm/code-object-load-while-breakpoint-hit.exp3
-rw-r--r--gdb/testsuite/gdb.rocm/displaced-stepping.exp3
-rw-r--r--gdb/testsuite/gdb.rocm/fork-exec-gpu-to-non-gpu.exp3
-rw-r--r--gdb/testsuite/gdb.rocm/fork-exec-non-gpu-to-gpu.exp3
-rw-r--r--gdb/testsuite/gdb.rocm/mi-attach.cpp4
-rw-r--r--gdb/testsuite/gdb.rocm/multi-inferior-gpu.exp3
-rw-r--r--gdb/testsuite/gdb.rocm/precise-memory-exec.exp3
-rw-r--r--gdb/testsuite/gdb.rocm/precise-memory-multi-inferiors.exp6
-rw-r--r--gdb/testsuite/gdb.rocm/precise-memory-warning-sigsegv.exp3
-rw-r--r--gdb/testsuite/gdb.rocm/precise-memory.exp3
-rw-r--r--gdb/testsuite/gdb.rocm/simple.exp3
-rw-r--r--gdb/testsuite/gdb.rust/modules.exp2
-rw-r--r--gdb/testsuite/gdb.rust/traits.exp2
-rw-r--r--gdb/testsuite/gdb.server/argument-errors.exp81
-rw-r--r--gdb/testsuite/gdb.server/bkpt-other-inferior.exp2
-rw-r--r--gdb/testsuite/gdb.server/connect-stopped-target.exp2
-rw-r--r--gdb/testsuite/gdb.server/connect-with-no-symbol-file.exp2
-rw-r--r--gdb/testsuite/gdb.server/connect-without-multi-process.exp2
-rw-r--r--gdb/testsuite/gdb.server/exit-multiple-threads.exp5
-rw-r--r--gdb/testsuite/gdb.server/ext-attach.exp2
-rw-r--r--gdb/testsuite/gdb.server/ext-run.exp2
-rw-r--r--gdb/testsuite/gdb.server/extended-remote-restart.exp4
-rw-r--r--gdb/testsuite/gdb.server/inferior-args.c27
-rw-r--r--gdb/testsuite/gdb.server/inferior-args.exp156
-rw-r--r--gdb/testsuite/gdb.server/monitor-exit-quit.exp4
-rw-r--r--gdb/testsuite/gdb.server/non-existing-program.exp4
-rw-r--r--gdb/testsuite/gdb.server/reconnect-ctrl-c.exp2
-rw-r--r--gdb/testsuite/gdb.server/server-exec-info.exp2
-rw-r--r--gdb/testsuite/gdb.server/server-kill.exp2
-rw-r--r--gdb/testsuite/gdb.server/server-pipe.exp2
-rw-r--r--gdb/testsuite/gdb.server/server-run.exp2
-rw-r--r--gdb/testsuite/gdb.server/stop-reply-no-thread-multi.exp4
-rw-r--r--gdb/testsuite/gdb.server/stop-reply-no-thread.exp4
-rw-r--r--gdb/testsuite/gdb.testsuite/board-sanity.exp6
-rw-r--r--gdb/testsuite/gdb.testsuite/gdb-caching-proc-consistency.exp9
-rw-r--r--gdb/testsuite/gdb.testsuite/gdb-caching-proc.exp21
-rw-r--r--gdb/testsuite/gdb.testsuite/mount-point-map.exp49
-rw-r--r--gdb/testsuite/gdb.testsuite/with-override.exp8
-rw-r--r--gdb/testsuite/gdb.threads/access-mem-running-thread-exit.exp10
-rw-r--r--gdb/testsuite/gdb.threads/async.exp2
-rw-r--r--gdb/testsuite/gdb.threads/attach-into-signal.exp6
-rw-r--r--gdb/testsuite/gdb.threads/attach-non-stop.exp2
-rw-r--r--gdb/testsuite/gdb.threads/attach-stopped.exp6
-rw-r--r--gdb/testsuite/gdb.threads/bp_in_thread.exp2
-rw-r--r--gdb/testsuite/gdb.threads/break-while-running.exp8
-rw-r--r--gdb/testsuite/gdb.threads/check-libthread-db.exp6
-rw-r--r--gdb/testsuite/gdb.threads/clone-attach-detach.exp4
-rw-r--r--gdb/testsuite/gdb.threads/clone-thread_db.exp6
-rw-r--r--gdb/testsuite/gdb.threads/continue-pending-after-query.exp2
-rw-r--r--gdb/testsuite/gdb.threads/continue-pending-status.exp4
-rw-r--r--gdb/testsuite/gdb.threads/corethreads.exp1
-rw-r--r--gdb/testsuite/gdb.threads/create-fail.exp2
-rw-r--r--gdb/testsuite/gdb.threads/del-pending-thread-bp.exp2
-rw-r--r--gdb/testsuite/gdb.threads/detach-step-over.exp6
-rw-r--r--gdb/testsuite/gdb.threads/execl.exp2
-rw-r--r--gdb/testsuite/gdb.threads/foll-fork-other-thread.exp2
-rw-r--r--gdb/testsuite/gdb.threads/fork-child-threads.exp2
-rw-r--r--gdb/testsuite/gdb.threads/fork-plus-threads.exp2
-rw-r--r--gdb/testsuite/gdb.threads/fork-thread-pending.exp4
-rw-r--r--gdb/testsuite/gdb.threads/forking-threads-plus-breakpoint.exp4
-rw-r--r--gdb/testsuite/gdb.threads/gcore-thread.exp2
-rw-r--r--gdb/testsuite/gdb.threads/hand-call-in-threads.exp4
-rw-r--r--gdb/testsuite/gdb.threads/hand-call-new-thread.exp4
-rw-r--r--gdb/testsuite/gdb.threads/ia64-sigill.exp2
-rw-r--r--gdb/testsuite/gdb.threads/inf-thr-count.exp4
-rw-r--r--gdb/testsuite/gdb.threads/infcall-from-bp-cond-other-thread-event.exp2
-rw-r--r--gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp2
-rw-r--r--gdb/testsuite/gdb.threads/infcall-from-bp-cond-single.exp2
-rw-r--r--gdb/testsuite/gdb.threads/infcall-from-bp-cond-timeout.exp2
-rw-r--r--gdb/testsuite/gdb.threads/infcall-thread-announce.exp2
-rw-r--r--gdb/testsuite/gdb.threads/info-threads-cur-sal.exp2
-rw-r--r--gdb/testsuite/gdb.threads/info-threads-options.exp4
-rw-r--r--gdb/testsuite/gdb.threads/interrupt-while-step-over.exp10
-rw-r--r--gdb/testsuite/gdb.threads/interrupted-hand-call.exp2
-rw-r--r--gdb/testsuite/gdb.threads/kill.exp2
-rw-r--r--gdb/testsuite/gdb.threads/killed.exp14
-rw-r--r--gdb/testsuite/gdb.threads/leader-exit-attach.exp2
-rw-r--r--gdb/testsuite/gdb.threads/leader-exit.exp2
-rw-r--r--gdb/testsuite/gdb.threads/linux-dp.exp10
-rw-r--r--gdb/testsuite/gdb.threads/local-watch-wrong-thread.exp2
-rw-r--r--gdb/testsuite/gdb.threads/main-thread-exit-during-detach.exp2
-rw-r--r--gdb/testsuite/gdb.threads/manythreads.exp4
-rw-r--r--gdb/testsuite/gdb.threads/multi-create-ns-info-thr.exp2
-rw-r--r--gdb/testsuite/gdb.threads/multi-create.exp2
-rw-r--r--gdb/testsuite/gdb.threads/multiple-step-overs.exp2
-rw-r--r--gdb/testsuite/gdb.threads/multiple-successive-infcall.exp2
-rw-r--r--gdb/testsuite/gdb.threads/names.exp4
-rw-r--r--gdb/testsuite/gdb.threads/next-bp-other-thread.exp4
-rw-r--r--gdb/testsuite/gdb.threads/next-fork-exec-other-thread.exp2
-rw-r--r--gdb/testsuite/gdb.threads/next-fork-other-thread.exp2
-rw-r--r--gdb/testsuite/gdb.threads/no-unwaited-for-left.exp2
-rw-r--r--gdb/testsuite/gdb.threads/non-ldr-exc-1.exp2
-rw-r--r--gdb/testsuite/gdb.threads/non-ldr-exc-2.exp2
-rw-r--r--gdb/testsuite/gdb.threads/non-ldr-exc-3.exp2
-rw-r--r--gdb/testsuite/gdb.threads/non-ldr-exc-4.exp2
-rw-r--r--gdb/testsuite/gdb.threads/non-ldr-exit.exp2
-rw-r--r--gdb/testsuite/gdb.threads/non-stop-fair-events.exp2
-rw-r--r--gdb/testsuite/gdb.threads/omp-par-scope.exp4
-rw-r--r--gdb/testsuite/gdb.threads/pending-fork-event-detach-ns.exp2
-rw-r--r--gdb/testsuite/gdb.threads/pending-fork-event-detach.exp3
-rw-r--r--gdb/testsuite/gdb.threads/pending-step.exp2
-rw-r--r--gdb/testsuite/gdb.threads/print-threads.exp10
-rw-r--r--gdb/testsuite/gdb.threads/process-dies-while-detaching.exp20
-rw-r--r--gdb/testsuite/gdb.threads/process-dies-while-handling-bp.exp2
-rw-r--r--gdb/testsuite/gdb.threads/pthread_cond_wait.exp6
-rw-r--r--gdb/testsuite/gdb.threads/pthreads.exp2
-rw-r--r--gdb/testsuite/gdb.threads/queue-signal.exp4
-rw-r--r--gdb/testsuite/gdb.threads/schedlock-new-thread.exp6
-rw-r--r--gdb/testsuite/gdb.threads/schedlock-thread-exit.exp2
-rw-r--r--gdb/testsuite/gdb.threads/schedlock.exp10
-rw-r--r--gdb/testsuite/gdb.threads/siginfo-threads.exp2
-rw-r--r--gdb/testsuite/gdb.threads/signal-command-handle-nopass.exp2
-rw-r--r--gdb/testsuite/gdb.threads/signal-command-multiple-signals-pending.exp2
-rw-r--r--gdb/testsuite/gdb.threads/signal-delivered-right-thread.exp2
-rw-r--r--gdb/testsuite/gdb.threads/signal-sigtrap.exp2
-rw-r--r--gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp2
-rw-r--r--gdb/testsuite/gdb.threads/sigstep-threads.exp4
-rw-r--r--gdb/testsuite/gdb.threads/sigthread.exp2
-rw-r--r--gdb/testsuite/gdb.threads/staticthreads.exp10
-rw-r--r--gdb/testsuite/gdb.threads/step-N-all-progress.exp2
-rw-r--r--gdb/testsuite/gdb.threads/step-bg-decr-pc-switch-thread.exp4
-rw-r--r--gdb/testsuite/gdb.threads/step-over-exec.exp5
-rw-r--r--gdb/testsuite/gdb.threads/step-over-lands-on-breakpoint.exp2
-rw-r--r--gdb/testsuite/gdb.threads/step-over-thread-exit-while-stop-all-threads.exp2
-rw-r--r--gdb/testsuite/gdb.threads/step-over-thread-exit.exp2
-rw-r--r--gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.exp6
-rw-r--r--gdb/testsuite/gdb.threads/stepi-over-clone.exp8
-rw-r--r--gdb/testsuite/gdb.threads/stepi-random-signal.exp2
-rw-r--r--gdb/testsuite/gdb.threads/switch-threads.exp2
-rw-r--r--gdb/testsuite/gdb.threads/thread-bp-deleted.exp9
-rw-r--r--gdb/testsuite/gdb.threads/thread-execl.exp4
-rw-r--r--gdb/testsuite/gdb.threads/thread-find.exp2
-rw-r--r--gdb/testsuite/gdb.threads/thread-specific-bp.exp2
-rw-r--r--gdb/testsuite/gdb.threads/thread-specific.exp2
-rw-r--r--gdb/testsuite/gdb.threads/thread-unwindonsignal.exp2
-rw-r--r--gdb/testsuite/gdb.threads/thread_check.exp10
-rw-r--r--gdb/testsuite/gdb.threads/threadapply.exp12
-rw-r--r--gdb/testsuite/gdb.threads/threadcrash.exp13
-rw-r--r--gdb/testsuite/gdb.threads/threads-after-exec.exp4
-rw-r--r--gdb/testsuite/gdb.threads/threxit-hop-specific.exp2
-rw-r--r--gdb/testsuite/gdb.threads/tid-reuse.exp4
-rw-r--r--gdb/testsuite/gdb.threads/tls-core.exp4
-rw-r--r--gdb/testsuite/gdb.threads/tls-nodebug-pie.exp2
-rw-r--r--gdb/testsuite/gdb.threads/tls-nodebug.exp2
-rw-r--r--gdb/testsuite/gdb.threads/tls-sepdebug.exp2
-rw-r--r--gdb/testsuite/gdb.threads/tls-shared.exp4
-rw-r--r--gdb/testsuite/gdb.threads/tls-so_extern.exp2
-rw-r--r--gdb/testsuite/gdb.threads/tls-var.exp2
-rw-r--r--gdb/testsuite/gdb.threads/tls.exp18
-rw-r--r--gdb/testsuite/gdb.threads/vfork-follow-child-exec.exp2
-rw-r--r--gdb/testsuite/gdb.threads/vfork-follow-child-exit.exp2
-rw-r--r--gdb/testsuite/gdb.threads/vfork-multi-thread.exp2
-rw-r--r--gdb/testsuite/gdb.threads/watchpoint-fork.exp6
-rw-r--r--gdb/testsuite/gdb.threads/watchthreads-reorder.exp4
-rw-r--r--gdb/testsuite/gdb.threads/watchthreads.exp30
-rw-r--r--gdb/testsuite/gdb.threads/watchthreads2.exp6
-rw-r--r--gdb/testsuite/gdb.threads/wp-replication.exp4
-rw-r--r--gdb/testsuite/gdb.trace/ax.exp2
-rw-r--r--gdb/testsuite/gdb.trace/basic-libipa.exp2
-rw-r--r--gdb/testsuite/gdb.trace/entry-values.exp60
-rw-r--r--gdb/testsuite/gdb.trace/ftrace-lock.exp4
-rw-r--r--gdb/testsuite/gdb.trace/mi-trace-frame-collected.exp2
-rw-r--r--gdb/testsuite/gdb.trace/mi-trace-unavailable.exp2
-rw-r--r--gdb/testsuite/gdb.trace/mi-traceframe-changed.exp10
-rw-r--r--gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp7
-rw-r--r--gdb/testsuite/gdb.trace/mi-tsv-changed.exp7
-rw-r--r--gdb/testsuite/gdb.trace/packetlen.exp2
-rw-r--r--gdb/testsuite/gdb.trace/passc-dyn.exp2
-rw-r--r--gdb/testsuite/gdb.trace/report.exp2
-rw-r--r--gdb/testsuite/gdb.trace/tfile.exp4
-rw-r--r--gdb/testsuite/gdb.trace/tfind.exp2
-rw-r--r--gdb/testsuite/gdb.trace/trace-mt.exp22
-rw-r--r--gdb/testsuite/gdb.trace/tsv.exp4
-rw-r--r--gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp242
-rw-r--r--gdb/testsuite/gdb.trace/while-dyn.exp2
-rw-r--r--gdb/testsuite/gdb.tui/basic.exp6
-rw-r--r--gdb/testsuite/gdb.tui/color-prompt.exp10
-rw-r--r--gdb/testsuite/gdb.tui/color-prompt.exp.tcl80
-rw-r--r--gdb/testsuite/gdb.tui/compact-source.exp8
-rw-r--r--gdb/testsuite/gdb.tui/empty.exp2
-rwxr-xr-x[-rw-r--r--]gdb/testsuite/gdb.tui/gdb.sh (renamed from gdb/testsuite/gdb.testsuite/lmap.exp)14
-rw-r--r--gdb/testsuite/gdb.tui/main-2.exp6
-rw-r--r--gdb/testsuite/gdb.tui/main.exp5
-rw-r--r--gdb/testsuite/gdb.tui/new-layout.exp20
-rw-r--r--gdb/testsuite/gdb.tui/pr30056.exp117
-rw-r--r--gdb/testsuite/gdb.tui/source-search.c127
-rw-r--r--gdb/testsuite/gdb.tui/source-search.exp72
-rw-r--r--gdb/testsuite/gdb.tui/tui-disasm-long-lines.exp2
-rw-r--r--gdb/testsuite/gdb.tui/tui-disasm-styling.exp5
-rw-r--r--gdb/testsuite/gdb.tui/tui-focus.exp4
-rw-r--r--gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.S3
-rw-r--r--gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp14
-rw-r--r--gdb/testsuite/gdb.tui/tui-layout.exp6
-rw-r--r--gdb/testsuite/gdb.tui/tui-long-line.c24
-rw-r--r--gdb/testsuite/gdb.tui/tui-missing-src.exp7
-rw-r--r--gdb/testsuite/gdb.tui/tui-mode-switch.exp57
-rw-r--r--gdb/testsuite/gdb.tui/tuiterm-2.exp78
-rw-r--r--gdb/testsuite/gdb.tui/tuiterm.exp20
-rw-r--r--gdb/testsuite/gdb.tui/wrap-line.exp28
-rw-r--r--gdb/testsuite/lib/ada.exp3
-rw-r--r--gdb/testsuite/lib/cache.exp21
-rw-r--r--gdb/testsuite/lib/check-test-names.exp6
-rw-r--r--gdb/testsuite/lib/compile-support.exp10
-rw-r--r--gdb/testsuite/lib/dap-support.exp14
-rw-r--r--gdb/testsuite/lib/debuginfod-support.exp2
-rw-r--r--gdb/testsuite/lib/dwarf.exp100
-rw-r--r--gdb/testsuite/lib/future.exp13
-rw-r--r--gdb/testsuite/lib/gdb.exp696
-rw-r--r--gdb/testsuite/lib/gdb_watchdog.h75
-rw-r--r--gdb/testsuite/lib/gdbserver-support.exp2
-rw-r--r--gdb/testsuite/lib/mi-support.exp17
-rw-r--r--gdb/testsuite/lib/selftest-support.exp216
-rw-r--r--gdb/testsuite/lib/trace-support.exp4
-rw-r--r--gdb/testsuite/lib/tuiterm.exp2411
-rw-r--r--gdb/thread.c5
-rw-r--r--gdb/tic6x-tdep.c2
-rw-r--r--gdb/tid-parse.c7
-rw-r--r--gdb/top.c8
-rw-r--r--gdb/tracectf.c1
-rw-r--r--gdb/tracepoint.c26
-rw-r--r--gdb/tui/tui-disasm.c34
-rw-r--r--gdb/tui/tui-io.c4
-rw-r--r--gdb/tui/tui-layout.c7
-rw-r--r--gdb/tui/tui-status.c8
-rw-r--r--gdb/tui/tui-win.c3
-rw-r--r--gdb/tui/tui-winsource.c7
-rw-r--r--gdb/tui/tui.c13
-rw-r--r--gdb/type-stack.c6
-rw-r--r--gdb/type-stack.h143
-rw-r--r--gdb/typeprint.c7
-rw-r--r--gdb/ui-out.c2
-rw-r--r--gdb/ui-style.c6
-rw-r--r--gdb/unittests/command-def-selftests.c4
-rw-r--r--gdb/unittests/filtered_iterator-selftests.c52
-rw-r--r--gdb/unittests/format_pieces-selftests.c94
-rw-r--r--gdb/utils.c68
-rw-r--r--gdb/valops.c16
-rw-r--r--gdb/valprint.c1
-rw-r--r--gdb/value.c5
-rw-r--r--gdb/value.h9
-rw-r--r--gdb/version.in2
-rw-r--r--gdb/windows-nat.c6
-rw-r--r--gdb/windows-tdep.c92
-rw-r--r--gdb/windows-tdep.h1
-rw-r--r--gdb/x86-linux-nat.c50
-rw-r--r--gdb/x86-linux-nat.h11
-rw-r--r--gdb/x86-tdep.c21
-rw-r--r--gdb/x86-tdep.h9
-rw-r--r--gdb/xcoffread.c3
-rw-r--r--gdb/xml-support.c5
-rw-r--r--gdb/xstormy16-tdep.c8
-rw-r--r--gdb/z80-tdep.c18
1579 files changed, 24561 insertions, 13701 deletions
diff --git a/gdb/MAINTAINERS b/gdb/MAINTAINERS
index 37e1b4c..375068a 100644
--- a/gdb/MAINTAINERS
+++ b/gdb/MAINTAINERS
@@ -554,6 +554,7 @@ Paul Brook paul@codesourcery.com
Julian Brown julian@codesourcery.com
Iain Buclaw ibuclaw@gdcproject.org
Kevin Buettner kevinb@redhat.com
+Gopi Kumar Bulusu gopi@sankhya.com
Richard Bunt richard.bunt@linaro.org
Andrew Burgess aburgess@redhat.com
David Carlton carlton@bactrian.org
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index fc0c565..beacefc 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -907,13 +907,22 @@ ALL_TARGET_OBS = \
vax-tdep.o \
windows-tdep.o \
x86-tdep.o \
- xcoffread.o \
xstormy16-tdep.o \
xtensa-config.o \
xtensa-linux-tdep.o \
xtensa-tdep.o \
z80-tdep.o
+# Object files for reading specific types of debug information.
+coff_SRCS = coffread.c coff-pe-read.c
+dbx_SRCS = dbxread.c
+elf_SRCS = elfread.c stap-probe.c dtrace-probe.c
+macho_SRCS = machoread.c
+mips_SRCS = mipsread.c
+xcoff_SRCS = xcoffread.c
+FORMAT_SRCS = @FORMAT_SRCS@
+FORMAT_OBS = $(patsubst %.c,%.o,$(FORMAT_SRCS))
+
# The following native-target dependent variables are defined on
# configure.nat.
NAT_FILE = @NAT_FILE@
@@ -1070,8 +1079,6 @@ COMMON_SFILES = \
c-varobj.c \
charset.c \
cli-out.c \
- coff-pe-read.c \
- coffread.c \
complaints.c \
completer.c \
copying.c \
@@ -1085,7 +1092,6 @@ COMMON_SFILES = \
d-lang.c \
d-namespace.c \
d-valprint.c \
- dbxread.c \
dcache.c \
debug.c \
debuginfod-support.c \
@@ -1150,7 +1156,6 @@ COMMON_SFILES = \
memtag.c \
minidebug.c \
minsyms.c \
- mipsread.c \
namespace.c \
objc-lang.c \
objfiles.c \
@@ -1243,7 +1248,6 @@ SFILES = \
d-exp.y \
dtrace-probe.c \
elf-none-tdep.c \
- elfread.c \
f-exp.y \
gcore-elf.c \
gdb.c \
@@ -1271,31 +1275,67 @@ SFILES = \
# right, it is probably easiest just to list .h files here directly.
HFILES_NO_SRCDIR = \
+ aarch32-linux-nat.h \
aarch32-tdep.h \
+ aarch64-fbsd-tdep.h \
+ aarch64-linux-tdep.h \
+ aarch64-nat.h \
aarch64-ravenscar-thread.h \
aarch64-tdep.h \
+ ada-casefold.h \
+ ada-exp.h \
ada-lang.h \
addrmap.h \
alpha-bsd-tdep.h \
alpha-tdep.h \
- amd-dbgapi-target.h \
+ amd64-bsd-nat.h \
amd64-darwin-tdep.h \
+ amd64-fbsd-tdep.h \
amd64-linux-tdep.h \
amd64-nat.h \
amd64-ravenscar-thread.h \
amd64-tdep.h \
+ amd-dbgapi-target.h \
amdgpu-tdep.h \
annotate.h \
- arc-tdep.h \
+ arch/aarch32.h \
+ arch/aarch64-gcs-linux.h \
+ arch/aarch64.h \
+ arch/aarch64-insn.h \
+ arch/aarch64-mte.h \
+ arch/aarch64-mte-linux.h \
+ arch/aarch64-scalable-linux.h \
+ arch/amd64.h \
+ arch/amd64-linux-tdesc.h \
+ arch/arc.h \
+ arch/arm-get-next-pcs.h \
+ arch/arm.h \
+ arch/arm-linux.h \
+ arch/csky.h \
+ arch/i386.h \
+ arch/i386-linux-tdesc.h \
+ arch/loongarch.h \
+ arch/loongarch-insn.h \
+ arch/loongarch-syscall.h \
+ arch/ppc-linux-common.h \
+ arch/ppc-linux-tdesc.h \
+ arch/riscv.h \
+ arch/tic6x.h \
arch-utils.h \
+ arch/x86-linux-tdesc-features.h \
+ arch/x86-linux-tdesc.h \
+ arch/xtensa.h \
+ arc-linux-tdep.h \
+ arc-tdep.h \
+ arm-fbsd-tdep.h \
arm-linux-tdep.h \
arm-netbsd-tdep.h \
arm-tdep.h \
async-event.h \
auto-load.h \
auxv.h \
- ax.h \
ax-gdb.h \
+ ax.h \
bcache.h \
bfd-target.h \
bfin-tdep.h \
@@ -1304,96 +1344,161 @@ HFILES_NO_SRCDIR = \
breakpoint.h \
bsd-kvm.h \
bsd-uthread.h \
+ btrace.h \
bt-utils.h \
build-id.h \
- buildsym-legacy.h \
buildsym.h \
- c-lang.h \
+ buildsym-legacy.h \
+ c-exp.h \
+ cgen-remap.h \
charset.h \
charset-list.h \
+ c-lang.h \
+ cli/cli-cmds.h \
+ cli/cli-decode.h \
+ cli/cli-interp.h \
+ cli/cli-option.h \
+ cli/cli-script.h \
+ cli/cli-setshow.h \
+ cli/cli-style.h \
+ cli/cli-utils.h \
cli-out.h \
coff-pe-read.h \
command.h \
+ compile/compile-c.h \
+ compile/compile-cplus.h \
+ compile/compile.h \
+ compile/compile-internal.h \
+ compile/compile-object-load.h \
+ compile/compile-object-run.h \
+ compile/gcc-c-plugin.h \
+ compile/gcc-cp-plugin.h \
complaints.h \
completer.h \
+ config/djgpp/langinfo.h \
+ config/djgpp/nl_types.h \
+ config/i386/nm-x86-gnu.h \
+ config/nm-linux.h \
+ config/sparc/nm-sol2.h \
cp-abi.h \
cp-support.h \
+ cris-tdep.h \
csky-tdep.h \
- d-lang.h \
+ c-support.h \
+ ctfread.h \
darwin-nat.h \
dcache.h \
+ debuginfod-support.h \
defs.h \
dicos-tdep.h \
dictionary.h \
disasm-flags.h \
disasm.h \
+ disasm-selftests.h \
+ displaced-stepping.h \
+ d-lang.h \
dummy-frame.h \
+ dwarf2/abbrev.h \
+ dwarf2/abbrev-table-cache.h \
dwarf2/aranges.h \
- dwarf2/cooked-index.h \
+ dwarf2/attribute.h \
+ dwarf2/call-site.h \
dwarf2/cooked-index-entry.h \
+ dwarf2/cooked-indexer.h \
+ dwarf2/cooked-index.h \
dwarf2/cooked-index-shard.h \
dwarf2/cooked-index-worker.h \
- dwarf2/cooked-indexer.h \
dwarf2/cu.h \
- dwarf2/frame-tailcall.h \
- dwarf2/frame.h \
+ dwarf2/die.h \
+ dwarf2/dwz.h \
+ dwarf2/error.h \
dwarf2/expr.h \
+ dwarf2/file-and-dir.h \
+ dwarf2/frame.h \
+ dwarf2/frame-tailcall.h \
dwarf2/index-cache.h \
dwarf2/index-common.h \
+ dwarf2/index-write.h \
+ dwarf2/leb.h \
+ dwarf2/line-header.h \
+ dwarf2/line-program.h \
dwarf2/loc.h \
- dwarf2/read.h \
+ dwarf2/macro.h \
+ dwarf2/mapped-index.h \
+ dwarf2/parent-map.h \
+ dwarf2/public.h \
dwarf2/read-debug-names.h \
dwarf2/read-gdb-index.h \
+ dwarf2/read.h \
+ dwarf2/section.h \
+ dwarf2/sect-names.h \
+ dwarf2/stringify.h \
+ dwarf2/tag.h \
+ dwarf2/types.h \
+ dwarf2/unit-head.h \
+ elf-none-tdep.h \
event-top.h \
exceptions.h \
exec.h \
+ expop.h \
expression.h \
extension.h \
extension-priv.h \
extract-store-integer.h \
f-array-walker.h \
- f-lang.h \
fbsd-nat.h \
fbsd-tdep.h \
+ f-exp.h \
+ filename-seen-cache.h \
filesystem.h \
- frame.h \
+ f-lang.h \
frame-base.h \
+ frame.h \
+ frame-id.h \
frame-unwind.h \
frv-tdep.h \
ft32-tdep.h \
gcore-elf.h \
gcore.h \
+ gdbarch-gen.h \
+ gdbarch.h \
gdb_bfd.h \
+ gdbcore.h \
gdb_curses.h \
+ gdb-demangle.h \
gdb_expat.h \
gdb_proc_service.h \
gdb-stabs.h \
- gdb_vfork.h \
- gdb_wchar.h \
- gdbarch.h \
- gdbcore.h \
gdbthread.h \
gdbtypes.h \
+ gdb_vfork.h \
+ gdb_wchar.h \
glibc-tdep.h \
gmp-utils.h \
gnu-nat.h \
+ gnu-nat-mig.h \
go-lang.h \
gregset.h \
+ guile/guile.h \
+ guile/guile-internal.h \
hppa-bsd-tdep.h \
hppa-linux-offsets.h \
hppa-tdep.h \
i386-bsd-nat.h \
i386-darwin-tdep.h \
+ i386-fbsd-tdep.h \
i386-linux-tdep.h \
i386-tdep.h \
i387-tdep.h \
ia64-libunwind-tdep.h \
ia64-tdep.h \
+ infcall.h \
inf-child.h \
+ inferior.h \
+ inferior-iter.h \
inf-loop.h \
inf-ptrace.h \
- infcall.h \
- inferior.h \
+ infrun.h \
inline-frame.h \
interps.h \
jit.h \
@@ -1401,10 +1506,12 @@ HFILES_NO_SRCDIR = \
linespec.h \
linux-fork.h \
linux-nat.h \
+ linux-nat-trad.h \
linux-record.h \
linux-tdep.h \
location.h \
loongarch-tdep.h \
+ m2-exp.h \
m2-lang.h \
m32r-tdep.h \
m68k-tdep.h \
@@ -1412,106 +1519,209 @@ HFILES_NO_SRCDIR = \
macroscope.h \
macrotab.h \
main.h \
+ maint.h \
mdebugread.h \
memattr.h \
memory-map.h \
memrange.h \
+ memtag.h \
microblaze-tdep.h \
+ mi/mi-cmd-break.h \
+ mi/mi-cmds.h \
+ mi/mi-common.h \
+ mi/mi-console.h \
+ mi/mi-getopt.h \
+ mi/mi-interp.h \
+ mi/mi-main.h \
+ mi/mi-out.h \
+ mi/mi-parse.h \
+ minsyms.h \
+ mips-fbsd-tdep.h \
mips-linux-tdep.h \
mips-netbsd-tdep.h \
mips-tdep.h \
mn10300-tdep.h \
moxie-tdep.h \
+ namespace.h \
+ nat/aarch64-hw-point.h \
+ nat/aarch64-linux.h \
+ nat/aarch64-linux-hw-point.h \
+ nat/aarch64-mte-linux-ptrace.h \
+ nat/aarch64-scalable-linux-ptrace.h \
+ nat/aarch64-scalable-linux-sigcontext.h \
+ nat/amd64-linux-siginfo.h \
+ nat/fork-inferior.h \
+ nat/gdb_ptrace.h \
+ nat/gdb_thread_db.h \
+ nat/glibc_thread_db.h \
+ nat/i386-linux.h \
+ nat/linux-btrace.h \
+ nat/linux-namespaces.h \
+ nat/linux-nat.h \
+ nat/linux-osdata.h \
+ nat/linux-personality.h \
+ nat/linux-procfs.h \
+ nat/linux-ptrace.h \
+ nat/linux-waitpid.h \
+ nat/loongarch-hw-point.h \
+ nat/loongarch-linux.h \
+ nat/loongarch-linux-hw-point.h \
+ nat/mips-linux-watch.h \
+ nat/netbsd-nat.h \
+ nat/ppc-linux.h \
+ nat/riscv-linux-tdesc.h \
+ nat/windows-nat.h \
+ nat/x86-cpuid.h \
+ nat/x86-dregs.h \
+ nat/x86-gcc-cpuid.h \
+ nat/x86-linux-dregs.h \
+ nat/x86-linux.h \
+ nat/x86-linux-tdesc.h \
+ nat/x86-xstate.h \
+ nds32-tdep.h \
netbsd-nat.h \
netbsd-tdep.h \
- nds32-tdep.h \
- elf-none-tdep.h \
objc-lang.h \
+ objfile-flags.h \
objfiles.h \
obsd-nat.h \
obsd-tdep.h \
+ observable.h \
or1k-linux-tdep.h \
+ or1k-tdep.h \
osabi.h \
osdata.h \
- p-lang.h \
+ pager.h \
parser-defs.h \
+ p-lang.h \
+ ppc64-tdep.h \
ppc-fbsd-tdep.h \
ppc-linux-tdep.h \
ppc-netbsd-tdep.h \
ppc-obsd-tdep.h \
ppc-ravenscar-thread.h \
ppc-tdep.h \
- ppc64-tdep.h \
probe.h \
- proc-utils.h \
+ process-stratum-target.h \
procfs.h \
- progspace.h \
+ proc-utils.h \
+ producer.h \
progspace-and-thread.h \
+ progspace.h \
prologue-value.h \
psymtab.h \
+ python/py-color.h \
+ python/py-event.h \
+ python/py-events.h \
+ python/py-instruction.h \
+ python/py-record-btrace.h \
+ python/py-record-full.h \
+ python/py-record.h \
+ python/py-ref.h \
+ python/py-stopevent.h \
+ python/python.h \
+ python/python-internal.h \
+ python/py-uiout.h \
+ quick-symbol.h \
ravenscar-thread.h \
- record.h \
+ record-btrace.h \
record-full.h \
+ record.h \
regcache.h \
+ regformats/regdef.h \
reggroups.h \
+ registry.h \
regset.h \
- remote.h \
remote-fileio.h \
+ remote.h \
remote-notif.h \
riscv-fbsd-tdep.h \
+ riscv-linux-tdep.h \
riscv-ravenscar-thread.h \
riscv-tdep.h \
rs6000-aix-tdep.h \
run-on-main-thread.h \
+ rust-exp.h \
+ rust-lang.h \
s390-linux-tdep.h \
s390-tdep.h \
+ scoped-mock-context.h \
selftest-arch.h \
sentinel-frame.h \
ser-base.h \
ser-event.h \
+ serial.h \
ser-tcp.h \
ser-unix.h \
- serial.h \
sh-tdep.h \
sim-regno.h \
skip.h \
sol2-tdep.h \
- solib.h \
solib-aix.h \
solib-darwin.h \
+ solib-dsbt.h \
solib-frv.h \
+ solib.h \
solib-svr4.h \
solib-svr4-linux.h \
solib-target.h \
- source.h \
source-cache.h \
+ source.h \
+ sparc64-tdep.h \
sparc-nat.h \
sparc-ravenscar-thread.h \
sparc-tdep.h \
- sparc64-tdep.h \
split-name.h \
stabsread.h \
stack.h \
stap-probe.h \
svr4-tls-tdep.h \
+ symfile-add-flags.h \
symfile.h \
symtab.h \
- target.h \
+ target-connection.h \
target-dcache.h \
+ target-debug.h \
target-descriptions.h \
+ target-float.h \
+ target.h \
+ target/resume.h \
+ target-section.h \
+ target/target.h \
+ target/wait.h \
+ target/waitstatus.h \
terminal.h \
+ test-target.h \
+ thread-fsm.h \
+ thread-iter.h \
+ tic6x-tdep.h \
tid-parse.h \
+ tilegx-tdep.h \
top.h \
tracectf.h \
tracefile.h \
tracepoint.h \
trad-frame.h \
- target-float.h \
tramp-frame.h \
- type-stack.h \
+ tui/tui-command.h \
+ tui/tui-data.h \
+ tui/tui-disasm.h \
+ tui/tui-file.h \
+ tui/tui.h \
+ tui/tui-hooks.h \
+ tui/tui-io.h \
+ tui/tui-layout.h \
+ tui/tui-location.h \
+ tui/tui-regs.h \
+ tui/tui-source.h \
+ tui/tui-status.h \
+ tui/tui-wingeneral.h \
+ tui/tui-win.h \
+ tui/tui-winsource.h \
typeprint.h \
- ui.h \
+ type-stack.h \
ui-file.h \
+ ui.h \
ui-out.h \
ui-style.h \
user-regs.h \
@@ -1524,111 +1734,18 @@ HFILES_NO_SRCDIR = \
windows-nat.h \
windows-tdep.h \
x86-bsd-nat.h \
+ x86-fbsd-nat.h \
x86-linux-nat.h \
x86-nat.h \
+ x86-tdep.h \
xcoffread.h \
xml-builtin.h \
xml-support.h \
xml-syscall.h \
xml-tdesc.h \
xtensa-tdep.h \
- 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 \
- arch/arc.h \
- arch/arm.h \
- arch/i386-linux-tdesc.h \
- arch/i386.h \
- arch/loongarch.h \
- arch/ppc-linux-common.h \
- arch/ppc-linux-tdesc.h \
- arch/riscv.h \
- arch/x86-linux-tdesc-features.h \
- arch/x86-linux-tdesc.h \
- cli/cli-cmds.h \
- cli/cli-decode.h \
- cli/cli-script.h \
- cli/cli-setshow.h \
- cli/cli-style.h \
- cli/cli-utils.h \
- compile/compile.h \
- compile/compile-c.h \
- compile/compile-cplus.h \
- compile/compile-internal.h \
- compile/compile-object-load.h \
- compile/compile-object-run.h \
- compile/gcc-c-plugin.h \
- compile/gcc-cp-plugin.h \
- config/nm-linux.h \
- config/djgpp/langinfo.h \
- config/djgpp/nl_types.h \
- config/i386/nm-i386gnu.h \
- config/sparc/nm-sol2.h \
- mi/mi-cmds.h \
- mi/mi-common.h \
- mi/mi-console.h \
- mi/mi-getopt.h \
- mi/mi-main.h \
- mi/mi-out.h \
- mi/mi-parse.h \
- nat/aarch64-linux.h \
- nat/aarch64-linux-hw-point.h \
- nat/aarch64-mte-linux-ptrace.h \
- nat/aarch64-scalable-linux-ptrace.h \
- nat/aarch64-scalable-linux-sigcontext.h \
- nat/amd64-linux-siginfo.h \
- nat/gdb_ptrace.h \
- nat/gdb_thread_db.h \
- nat/fork-inferior.h \
- nat/i386-linux.h \
- nat/linux-btrace.h \
- nat/linux-namespaces.h \
- nat/linux-nat.h \
- nat/linux-osdata.h \
- nat/linux-personality.h \
- nat/linux-ptrace.h \
- nat/linux-waitpid.h \
- nat/loongarch-hw-point.h \
- nat/loongarch-linux.h \
- nat/loongarch-linux-hw-point.h \
- nat/mips-linux-watch.h \
- nat/ppc-linux.h \
- nat/x86-cpuid.h \
- nat/x86-dregs.h \
- nat/x86-gcc-cpuid.h \
- nat/x86-linux.h \
- nat/x86-linux-dregs.h \
- nat/x86-linux-tdesc.h \
- python/py-event.h \
- python/py-events.h \
- python/py-stopevent.h \
- python/python.h \
- python/python-internal.h \
- regformats/regdef.h \
- target/resume.h \
- target/target.h \
- target/wait.h \
- target/waitstatus.h \
- tui/tui.h \
- tui/tui-command.h \
- tui/tui-data.h \
- tui/tui-disasm.h \
- tui/tui-file.h \
- tui/tui-hooks.h \
- tui/tui-io.h \
- tui/tui-layout.h \
- tui/tui-location.h \
- tui/tui-regs.h \
- tui/tui-source.h \
- tui/tui-status.h \
- tui/tui-win.h \
- tui/tui-wingeneral.h \
- tui/tui-winsource.h \
- x86-tdep.h
+ yy-remap.h \
+ z80-tdep.h
# Header files that already have srcdir in them, or which are in objdir.
@@ -1870,7 +1987,6 @@ ALLDEPFILES = \
x86-gnu-nat.c \
x86-nat.c \
x86-tdep.c \
- xcoffread.c \
xstormy16-tdep.c \
xtensa-config.c \
xtensa-linux-nat.c \
@@ -1907,6 +2023,7 @@ DWARF2_SRCS = \
dwarf2/index-write.c \
dwarf2/leb.c \
dwarf2/line-header.c \
+ dwarf2/line-program.c \
dwarf2/loc.c \
dwarf2/macro.c \
dwarf2/parent-map.c \
@@ -1925,7 +2042,8 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \
$(patsubst %.c,%.o,$(COMMON_SFILES)) \
$(SUBDIR_CLI_OBS) \
$(SUBDIR_MI_OBS) \
- $(SUBDIR_TARGET_OBS)
+ $(SUBDIR_TARGET_OBS) \
+ $(FORMAT_OBS)
SUBDIRS = doc @subdirs@ data-directory
CLEANDIRS = $(SUBDIRS)
@@ -2282,8 +2400,7 @@ TAGS: $(TAGFILES_NO_SRCDIR) $(TAGFILES_WITH_SRCDIR)
echo $(srcdir)/$$i ; \
done ; for i in $(TAGFILES_WITH_SRCDIR); do \
echo $$i ; \
- done) | sed -e 's/\.o$$/\.c/'` \
- `find $(srcdir)/config -name '*.h' -print`
+ done) | sed -e 's/\.o$$/\.c/'`
tags: TAGS
diff --git a/gdb/NEWS b/gdb/NEWS
index 4c9aed4..b632cde 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -1,7 +1,45 @@
What has changed in GDB?
(Organized release by release)
-*** Changes since GDB 16
+*** Changes since GDB 17
+
+* Support for .gdb_index sections with version less than 7 has been
+ removed.
+
+* GDB now accepts --no-escape-args as an alternative to --args on the
+ command line. GDB will not escape special shell characters within
+ arguments after --no-escape-args.
+
+* gdbserver now accepts --no-escape-args as a command line flag. When
+ this flag is used gdbserver will not escape special shell characters
+ within the inferior arguments.
+
+* New targets
+
+GNU/Linux/MicroBlaze (gdbserver) microblazeel-*linux*
+
+* New commands
+
+maintenance test-remote-args ARGS
+ Test splitting and joining of inferior arguments ARGS as they would
+ be split and joined when being passed to a remote target.
+
+* Changed remote packets
+
+single-inf-arg in qSupported
+ The new single-inf-arg feature within the qSupported packet allows
+ GDB to inform the stub that it would like to send the inferior
+ arguments as a single string within the vRun packet. The stub can
+ reply with the single-inf-arg feature to indicate that it is able to
+ accept arguments as a single string.
+
+*** Changes in GDB 17
+
+* Debugging Linux programs that use x86-64 or x86-64 with 32-bit pointer
+ size (X32) Shadow Stacks are now supported.
+
+* Support for the shadow stack pointer register on x86-64 or x86-64 with
+ 32-bit pointer size (X32) GNU/Linux.
* Debugger Adapter Protocol changes
@@ -35,19 +73,31 @@
a -h or --help option, which prints each options and a brief
description.
+* The gcore script now has a -g option that lets you specify the GDB
+ binary invoked by gcore.
+
* On systems that support linker namespaces, the output of the command
"info sharedlibraries" may add one more column, NS, which identifies the
namespace into which the library was loaded, if more than one namespace
is active.
-* New built-in convenience variables $_active_linker_namespaces and
+* New built-in convenience variables $linker_namespace_count and
$_linker_namespace. These show the number of active linker
namespaces, and the namespace to which the current location belongs to.
- In systems that don't support linker namespaces, these always return
- the integers 1 and 0 respectively.
+ In systems that don't support linker namespaces, or if the inferior hasn't
+ started yet, these always return the integer 0.
* Add record full support for rv64gc architectures
+* Debugging Linux programs that use AArch64 Guarded Control Stacks is now
+ supported.
+
+* New "--binary-output" command line option instructs GDB to set the
+ translation mode of its stdout/stderr to binary mode. This disables
+ Line Feed translation. MS-Windows only.
+
+* The "catch syscall" command now works on riscv*-linux* targets.
+
* New commands
maintenance check psymtabs
@@ -59,12 +109,6 @@ maintenance check symtabs
maintenance canonicalize
Show the canonical form of a C++ name.
-maintenance set console-translation-mode <binary|text>
-maintenance show console-translation-mode
- Controls the translation mode of GDB stdout/stderr. MS-Windows only. In
- binary mode, no translation is done. In text mode, a Line Feed is
- translated into a Carriage Return-Line Feed combination.
-
set riscv numeric-register-names on|off
show riscv numeric-register-names
Controls whether GDB refers to risc-v registers by their numeric names
@@ -165,6 +209,10 @@ info threads [-gid] [-stopped] [-running] [ID]...
** New gdb.warning() function that takes a string and prints it as a
warning, with GDB's standard 'warning' prefix.
+ ** New attribute gdb.Value.is_unavailable, this checks for
+ unavailability like gdb.Value.is_optimized_out checks for
+ optimized out values.
+
* Guile API
** New type <gdb:color> for dealing with colors.
@@ -224,6 +272,17 @@ vFile:stat
* Support for stabs debugging format and the a.out/dbx object format is
deprecated, and will be removed in GDB 18.
+* Configure changes
+
+--enable-binary-file-formats=[FORMAT,...]
+--enable-binary-file-formats=all
+ A user can now decide to only compile support for certain file formats.
+ The available formats at this point are: dbx, coff, xcoff, elf, mach-o
+ and mips. Some targets require specific file formats to be available,
+ and in such cases, the configure script will warn the user and add
+ support anyway. By default, all formats will be compiled in, to
+ continue the behavior from before adding the switch.
+
* A new configure option was added, allowing support for the compile
subsystem to be disabled at configure time, in the form of
--disable-gdb-compile.
diff --git a/gdb/README b/gdb/README
index eca4181c..5dc2e7e 100644
--- a/gdb/README
+++ b/gdb/README
@@ -417,6 +417,30 @@ more obscure GDB `configure' options are not listed here.
There is no convenient way to generate a list of all available
targets.
+`--enable-binary-file-formats=FORMAT,FORMAT,...'
+`--enable-binary-file-formats=all'
+ Configure GDB to only be be able to read selected file formats.
+ The special value "all" causes all file formats to be compiled
+ in, and is the the default behavior of the option. This option
+ is meant for advanced users who are sure of what they expect,
+ if you are unsure which options you will need on your debugging
+ sessions, we recommend that you not use this feature. The
+ accepted options are:
+ * coff: Main format on Windows systems, this is required to
+ compile with windows target support;
+ * dbx (also known as a.out): Legacy file format, this is
+ recommended if you know you will be dealing with this
+ file format;
+ * elf: Main format on Linux systems, this is heavily
+ recommended when compiling with linux support;
+ * macho: Main format on MacOS systems, this is heavily
+ recommended when compiling for those targets;
+ * mips (also known as ecoff): Main file format for targets
+ running on MIPS CPUs, this is heavily recommended when
+ supporting those targets;
+ * xcoff: Main format on AIX systems, this is required to
+ compile for AIX targets and rs6000 CPUs.
+
`--with-gdb-datadir=PATH'
Set the GDB-specific data directory. GDB will look here for
certain supporting files or scripts. This defaults to the `gdb'
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 725c632..89ecedd 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -51,6 +51,7 @@
#include "gdb_proc_service.h"
#include "arch-utils.h"
+#include "arch/aarch64-gcs-linux.h"
#include "arch/aarch64-mte-linux.h"
#include "nat/aarch64-mte-linux-ptrace.h"
@@ -542,6 +543,67 @@ store_tlsregs_to_thread (struct regcache *regcache)
perror_with_name (_("unable to store TLS register"));
}
+/* Fill GDB's register array with the GCS register values from
+ the current thread. */
+
+static void
+fetch_gcsregs_from_thread (regcache *regcache)
+{
+ aarch64_gdbarch_tdep *tdep
+ = gdbarch_tdep<aarch64_gdbarch_tdep> (regcache->arch ());
+
+ gdb_assert (tdep->gcs_reg_base != -1);
+ gdb_assert (tdep->gcs_linux_reg_base != -1);
+
+ user_gcs user_gcs;
+ iovec iovec;
+
+ iovec.iov_base = &user_gcs;
+ iovec.iov_len = sizeof (user_gcs);
+
+ int tid = get_ptrace_pid (regcache->ptid ());
+ if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_GCS, &iovec) != 0)
+ perror_with_name (_("Unable to fetch GCS registers"));
+
+ regcache->raw_supply (tdep->gcs_reg_base, &user_gcs.gcspr_el0);
+ regcache->raw_supply (tdep->gcs_linux_reg_base, &user_gcs.features_enabled);
+ regcache->raw_supply (tdep->gcs_linux_reg_base + 1,
+ &user_gcs.features_locked);
+}
+
+/* Store to the current thread the valid GCS register set in the GDB's
+ register array. */
+
+static void
+store_gcsregs_to_thread (regcache *regcache)
+{
+ aarch64_gdbarch_tdep *tdep
+ = gdbarch_tdep<aarch64_gdbarch_tdep> (regcache->arch ());
+
+ gdb_assert (tdep->gcs_reg_base != -1);
+ gdb_assert (tdep->gcs_linux_reg_base != -1);
+
+ if (REG_VALID != regcache->get_register_status (tdep->gcs_reg_base)
+ || REG_VALID != regcache->get_register_status (tdep->gcs_linux_reg_base)
+ || REG_VALID
+ != regcache->get_register_status (tdep->gcs_linux_reg_base + 1))
+ return;
+
+ user_gcs user_gcs;
+ regcache->raw_collect (tdep->gcs_reg_base, &user_gcs.gcspr_el0);
+ regcache->raw_collect (tdep->gcs_linux_reg_base, &user_gcs.features_enabled);
+ regcache->raw_collect (tdep->gcs_linux_reg_base + 1,
+ &user_gcs.features_locked);
+
+ iovec iovec;
+ iovec.iov_base = &user_gcs;
+ iovec.iov_len = sizeof (user_gcs);
+
+ int tid = get_ptrace_pid (regcache->ptid ());
+ if (ptrace (PTRACE_SETREGSET, tid, NT_ARM_GCS, &iovec) != 0)
+ perror_with_name (_("Unable to store GCS registers"));
+}
+
/* The AArch64 version of the "fetch_registers" target_ops method. Fetch
REGNO from the target and place the result into REGCACHE. */
@@ -577,6 +639,9 @@ aarch64_fetch_registers (struct regcache *regcache, int regno)
if (tdep->has_sme2 ())
fetch_zt_from_thread (regcache);
+
+ if (tdep->has_gcs_linux ())
+ fetch_gcsregs_from_thread (regcache);
}
/* General purpose register? */
else if (regno < AARCH64_V0_REGNUM)
@@ -609,6 +674,11 @@ aarch64_fetch_registers (struct regcache *regcache, int regno)
&& regno >= tdep->tls_regnum_base
&& regno < tdep->tls_regnum_base + tdep->tls_register_count)
fetch_tlsregs_from_thread (regcache);
+ /* GCS register? */
+ else if (tdep->has_gcs_linux ()
+ && (regno == tdep->gcs_reg_base || regno == tdep->gcs_linux_reg_base
+ || regno == tdep->gcs_linux_reg_base + 1))
+ fetch_gcsregs_from_thread (regcache);
}
/* A version of the "fetch_registers" target_ops method used when running
@@ -680,6 +750,9 @@ aarch64_store_registers (struct regcache *regcache, int regno)
if (tdep->has_sme2 ())
store_zt_to_thread (regcache);
+
+ if (tdep->has_gcs_linux ())
+ store_gcsregs_to_thread (regcache);
}
/* General purpose register? */
else if (regno < AARCH64_V0_REGNUM)
@@ -706,6 +779,11 @@ aarch64_store_registers (struct regcache *regcache, int regno)
&& regno >= tdep->tls_regnum_base
&& regno < tdep->tls_regnum_base + tdep->tls_register_count)
store_tlsregs_to_thread (regcache);
+ /* GCS register? */
+ else if (tdep->has_gcs_linux ()
+ && (regno == tdep->gcs_reg_base || regno == tdep->gcs_linux_reg_base
+ || regno == tdep->gcs_linux_reg_base + 1))
+ store_gcsregs_to_thread (regcache);
/* PAuth registers are read-only. */
}
@@ -881,6 +959,7 @@ aarch64_linux_nat_target::read_description ()
active or not. */
features.vq = aarch64_sve_get_vq (tid);
features.pauth = hwcap & AARCH64_HWCAP_PACA;
+ features.gcs = features.gcs_linux = hwcap & HWCAP_GCS;
features.mte = hwcap2 & HWCAP2_MTE;
features.tls = aarch64_tls_register_count (tid);
/* SME feature check. */
diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index dd35eaf..048be4f 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -33,6 +33,7 @@
#include "symtab.h"
#include "tramp-frame.h"
#include "trad-frame.h"
+#include "dwarf2/frame.h"
#include "target.h"
#include "target/target.h"
#include "expop.h"
@@ -46,11 +47,11 @@
#include "parser-defs.h"
#include "user-regs.h"
#include "xml-syscall.h"
-#include <ctype.h>
#include "record-full.h"
#include "linux-record.h"
+#include "arch/aarch64-gcs-linux.h"
#include "arch/aarch64-mte.h"
#include "arch/aarch64-mte-linux.h"
#include "arch/aarch64-scalable-linux.h"
@@ -165,6 +166,7 @@
#define AARCH64_ZA_MAGIC 0x54366345
#define AARCH64_TPIDR2_MAGIC 0x54504902
#define AARCH64_ZT_MAGIC 0x5a544e01
+#define AARCH64_GCS_MAGIC 0x47435300
/* Defines for the extra_context that follows an AARCH64_EXTRA_MAGIC. */
#define AARCH64_EXTRA_DATAP_OFFSET 8
@@ -206,6 +208,11 @@
the signal context state. */
#define AARCH64_SME2_CONTEXT_REGS_OFFSET 16
+/* GCSPR register value offset in the GCS signal frame context. */
+#define AARCH64_GCS_CONTEXT_GCSPR_OFFSET 8
+/* features_enabled value offset in the GCS signal frame context. */
+#define AARCH64_GCS_CONTEXT_FEATURES_ENABLED_OFFSET 16
+
/* Holds information about the signal frame. */
struct aarch64_linux_sigframe
{
@@ -246,6 +253,13 @@ struct aarch64_linux_sigframe
bool za_payload = false;
/* True if we have a ZT entry in the signal context, false otherwise. */
bool zt_available = false;
+
+ /* True if we have a GCS entry in the signal context, false otherwise. */
+ bool gcs_availabe = false;
+ /* The Guarded Control Stack Pointer Register. */
+ uint64_t gcspr;
+ /* Flags indicating which GCS features are enabled for the thread. */
+ uint64_t gcs_features_enabled;
};
/* Read an aarch64_ctx, returning the magic value, and setting *SIZE to the
@@ -529,6 +543,39 @@ aarch64_linux_read_signal_frame_info (const frame_info_ptr &this_frame,
section += size;
break;
}
+ case AARCH64_GCS_MAGIC:
+ {
+ gdb_byte buf[8];
+
+ /* Extract the GCSPR. */
+ if (target_read_memory (section + AARCH64_GCS_CONTEXT_GCSPR_OFFSET,
+ buf, 8) != 0)
+ {
+ warning (_("Failed to read the GCS pointer from the GCS signal"
+ " frame context."));
+ section += size;
+ break;
+ }
+
+ signal_frame.gcspr = extract_unsigned_integer (buf, byte_order);
+
+ /* Extract the features_enabled field. */
+ if (target_read_memory (section
+ + AARCH64_GCS_CONTEXT_FEATURES_ENABLED_OFFSET,
+ buf, sizeof (buf)) != 0)
+ {
+ warning (_("Failed to read the enabled features from the GCS"
+ " signal frame context."));
+ section += size;
+ break;
+ }
+
+ signal_frame.gcs_features_enabled
+ = extract_unsigned_integer (buf, byte_order);
+ signal_frame.gcs_availabe = true;
+ section += size;
+ break;
+ }
case AARCH64_EXTRA_MAGIC:
{
/* Extra is always the last valid section in reserved and points to
@@ -703,6 +750,19 @@ aarch64_linux_sigframe_init (const struct tramp_frame *self,
+ AARCH64_TPIDR2_CONTEXT_TPIDR2_OFFSET);
}
+ /* Restore the GCS registers, if the target supports it and if there is
+ an entry for them. */
+ if (signal_frame.gcs_availabe && tdep->has_gcs_linux ())
+ {
+ /* Restore GCSPR. */
+ trad_frame_set_reg_value (this_cache, tdep->gcs_reg_base,
+ signal_frame.gcspr);
+ /* Restore gcs_features_enabled. */
+ trad_frame_set_reg_value (this_cache, tdep->gcs_linux_reg_base,
+ signal_frame.gcs_features_enabled);
+ /* gcs_features_locked isn't present in the GCS signal context. */
+ }
+
trad_frame_set_id (this_cache, frame_id_build (signal_frame.sp, func));
}
@@ -1605,6 +1665,27 @@ aarch64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
cb (".reg-aarch-tls", sizeof_tls_regset, sizeof_tls_regset,
&aarch64_linux_tls_regset, "TLS register", cb_data);
}
+
+ /* Handle GCS registers. */
+ if (tdep->has_gcs_linux ())
+ {
+ /* Create this on the fly in order to handle the variable regnums. */
+ const regcache_map_entry gcs_regmap[] =
+ {
+ { 1, tdep->gcs_linux_reg_base, 8 }, /* features_enabled */
+ { 1, tdep->gcs_linux_reg_base + 1, 8 }, /* features_locked */
+ { 1, tdep->gcs_reg_base, 8 }, /* GCSPR */
+ { 0 }
+ };
+
+ const regset aarch64_linux_gcs_regset =
+ {
+ gcs_regmap, regcache_supply_regset, regcache_collect_regset
+ };
+
+ cb (".reg-aarch-gcs", sizeof (user_gcs), sizeof (user_gcs),
+ &aarch64_linux_gcs_regset, "GCS registers", cb_data);
+ }
}
/* Implement the "core_read_description" gdbarch method. */
@@ -1629,6 +1710,7 @@ aarch64_linux_core_read_description (struct gdbarch *gdbarch,
length. */
features.vq = aarch64_linux_core_read_vq_from_sections (gdbarch, abfd);
features.pauth = hwcap & AARCH64_HWCAP_PACA;
+ features.gcs = features.gcs_linux = hwcap & HWCAP_GCS;
features.mte = hwcap2 & HWCAP2_MTE;
/* Handle the TLS section. */
@@ -1666,9 +1748,9 @@ aarch64_linux_core_read_description (struct gdbarch *gdbarch,
static int
aarch64_stap_is_single_operand (struct gdbarch *gdbarch, const char *s)
{
- return (*s == '#' || isdigit (*s) /* Literal number. */
+ return (*s == '#' || c_isdigit (*s) /* Literal number. */
|| *s == '[' /* Register indirection. */
- || isalpha (*s)); /* Register value. */
+ || c_isalpha (*s)); /* Register value. */
}
/* This routine is used to parse a special token in AArch64's assembly.
@@ -1699,7 +1781,7 @@ aarch64_stap_parse_special_token (struct gdbarch *gdbarch,
start = tmp;
/* Register name. */
- while (isalnum (*tmp))
+ while (c_isalnum (*tmp))
++tmp;
if (*tmp != ',')
@@ -1727,7 +1809,7 @@ aarch64_stap_parse_special_token (struct gdbarch *gdbarch,
else if (*tmp == '+')
++tmp;
- if (!isdigit (*tmp))
+ if (!c_isdigit (*tmp))
return {};
displacement = strtol (tmp, &endp, 10);
@@ -2453,6 +2535,80 @@ aarch64_linux_tagged_address_p (struct gdbarch *gdbarch, CORE_ADDR address)
return true;
}
+/* Implement the "get_shadow_stack_pointer" gdbarch method. */
+
+static std::optional<CORE_ADDR>
+aarch64_linux_get_shadow_stack_pointer (gdbarch *gdbarch, regcache *regcache,
+ bool &shadow_stack_enabled)
+{
+ aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+ shadow_stack_enabled = false;
+
+ if (!tdep->has_gcs_linux ())
+ return {};
+
+ uint64_t features_enabled;
+ register_status status = regcache->cooked_read (tdep->gcs_linux_reg_base,
+ &features_enabled);
+ if (status != REG_VALID)
+ error (_("Can't read $gcs_features_enabled."));
+
+ CORE_ADDR gcspr;
+ status = regcache->cooked_read (tdep->gcs_reg_base, &gcspr);
+ if (status != REG_VALID)
+ error (_("Can't read $gcspr."));
+
+ shadow_stack_enabled = features_enabled & PR_SHADOW_STACK_ENABLE;
+ return gcspr;
+}
+
+/* Implement Guarded Control Stack Pointer Register unwinding. For each
+ previous GCS pointer check if its address is still in the GCS memory
+ range. If it's outside the range set the returned value to unavailable,
+ otherwise return a value containing the new GCS pointer. */
+
+static value *
+aarch64_linux_dwarf2_prev_gcspr (const frame_info_ptr &this_frame,
+ void **this_cache, int regnum)
+{
+ value *v = frame_unwind_got_register (this_frame, regnum, regnum);
+ gdb_assert (v != nullptr);
+
+ gdbarch *gdbarch = get_frame_arch (this_frame);
+
+ if (v->entirely_available () && !v->optimized_out ())
+ {
+ int size = register_size (gdbarch, regnum);
+ bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ CORE_ADDR gcspr = extract_unsigned_integer (v->contents_all ().data (),
+ size, byte_order);
+
+ /* Starting with v6.13, the Linux kernel supports Guarded Control
+ Stack. Using /proc/PID/smaps we can only check if the current
+ GCSPR points to GCS memory. Only if this is the case a valid
+ previous GCS pointer can be calculated. */
+ std::pair<CORE_ADDR, CORE_ADDR> range;
+ if (linux_address_in_shadow_stack_mem_range (gcspr, &range))
+ {
+ /* The GCS grows downwards. To compute the previous GCS pointer,
+ we need to increment the GCSPR. */
+ CORE_ADDR new_gcspr = gcspr + 8;
+
+ /* If NEW_GCSPR still points within the current GCS memory range
+ we consider it to be valid. */
+ if (new_gcspr < range.second)
+ return frame_unwind_got_address (this_frame, regnum, new_gcspr);
+ }
+ }
+
+ /* Return a value which is marked as unavailable in case we could not
+ calculate a valid previous GCS pointer. */
+ value *retval
+ = value::allocate_register (get_next_frame_sentinel_okay (this_frame),
+ regnum, register_type (gdbarch, regnum));
+ retval->mark_bytes_unavailable (0, retval->type ()->length ());
+ return retval;
+}
/* AArch64 Linux implementation of the report_signal_info gdbarch
hook. Displays information about possible memory tag violations. */
@@ -2464,17 +2620,18 @@ aarch64_linux_report_signal_info (struct gdbarch *gdbarch,
{
aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
- if (!tdep->has_mte () || siggnal != GDB_SIGNAL_SEGV)
+ if (!(tdep->has_mte () || tdep->has_gcs ()) || siggnal != GDB_SIGNAL_SEGV)
return;
CORE_ADDR fault_addr = 0;
- long si_code = 0;
+ long si_code = 0, si_errno = 0;
try
{
/* Sigcode tells us if the segfault is actually a memory tag
violation. */
si_code = parse_and_eval_long ("$_siginfo.si_code");
+ si_errno = parse_and_eval_long ("$_siginfo.si_errno");
fault_addr
= parse_and_eval_long ("$_siginfo._sifields._sigfault.si_addr");
@@ -2485,13 +2642,18 @@ aarch64_linux_report_signal_info (struct gdbarch *gdbarch,
return;
}
- /* If this is not a memory tag violation, just return. */
- if (si_code != SEGV_MTEAERR && si_code != SEGV_MTESERR)
+ const char *meaning;
+
+ if (si_code == SEGV_MTEAERR || si_code == SEGV_MTESERR)
+ meaning = _("Memory tag violation");
+ else if (si_code == SEGV_CPERR && si_errno == 0)
+ meaning = _("Guarded Control Stack error");
+ else
return;
uiout->text ("\n");
- uiout->field_string ("sigcode-meaning", _("Memory tag violation"));
+ uiout->field_string ("sigcode-meaning", meaning);
/* For synchronous faults, show additional information. */
if (si_code == SEGV_MTESERR)
@@ -2517,7 +2679,7 @@ aarch64_linux_report_signal_info (struct gdbarch *gdbarch,
uiout->field_string ("logical-tag", hex_string (ltag));
}
}
- else
+ else if (si_code != SEGV_CPERR)
{
uiout->text ("\n");
uiout->text (_("Fault address unavailable"));
@@ -2766,6 +2928,13 @@ aarch64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
NULL };
aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (gdbarch);
+ if (tdep->has_gcs () && !tdep->has_gcs_linux ())
+ {
+ warning (_("Incomplete GCS support in the target: missing Linux part."
+ " GCS feature disabled."));
+ tdep->gcs_reg_base = -1;
+ }
+
tdep->lowest_pc = 0x8000;
linux_init_abi (info, gdbarch, 1);
@@ -2814,9 +2983,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);
- set_gdbarch_report_signal_info (gdbarch,
- aarch64_linux_report_signal_info);
-
/* Core file helpers. */
/* Core file helper to create a memory tag section for a particular
@@ -2833,6 +2999,9 @@ aarch64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
aarch64_linux_decode_memtag_section);
}
+ if (tdep->has_mte () || tdep->has_gcs ())
+ set_gdbarch_report_signal_info (gdbarch, aarch64_linux_report_signal_info);
+
/* Initialize the aarch64_linux_record_tdep. */
/* These values are the size of the type that will be used in a system
call. They are obtained from Linux Kernel source. */
@@ -3014,6 +3183,13 @@ aarch64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
sections. */
set_gdbarch_use_target_description_from_corefile_notes (gdbarch,
aarch64_use_target_description_from_corefile_notes);
+
+ if (tdep->has_gcs_linux ())
+ {
+ set_gdbarch_get_shadow_stack_pointer (gdbarch,
+ aarch64_linux_get_shadow_stack_pointer);
+ tdep->fn_prev_gcspr = aarch64_linux_dwarf2_prev_gcspr;
+ }
}
#if GDB_SELF_TEST
diff --git a/gdb/aarch64-nat.h b/gdb/aarch64-nat.h
index 3120bca..ec7c564 100644
--- a/gdb/aarch64-nat.h
+++ b/gdb/aarch64-nat.h
@@ -92,10 +92,6 @@ struct aarch64_nat_target : public BaseTarget
int remove_hw_breakpoint (struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt) override
{ return aarch64_remove_hw_breakpoint (gdbarch, bp_tgt); }
-
- bool watchpoint_addr_within_range (CORE_ADDR addr, CORE_ADDR start,
- int length) override
- { return start <= addr && start + length - 1 >= addr; }
};
#endif /* GDB_AARCH64_NAT_H */
diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index f2e3ce2..500ac77d 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -159,6 +159,18 @@ static const char *const aarch64_mte_register_names[] =
"tag_ctl"
};
+static const char *const aarch64_gcs_register_names[] = {
+ /* Guarded Control Stack Pointer Register. */
+ "gcspr"
+};
+
+static const char *const aarch64_gcs_linux_register_names[] = {
+ /* Field in struct user_gcs. */
+ "gcs_features_enabled",
+ /* Field in struct user_gcs. */
+ "gcs_features_locked",
+};
+
static int aarch64_stack_frame_destroyed_p (struct gdbarch *, CORE_ADDR);
/* AArch64 prologue cache structure. */
@@ -1396,6 +1408,12 @@ aarch64_dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
return;
}
}
+ if (tdep->has_gcs () && tdep->fn_prev_gcspr != nullptr
+ && regnum == tdep->gcs_reg_base)
+ {
+ reg->how = DWARF2_FRAME_REG_FN;
+ reg->loc.fn = tdep->fn_prev_gcspr;
+ }
}
/* Implement the execute_dwarf_cfa_vendor_op method. */
@@ -1875,6 +1893,55 @@ pass_in_v_vfp_candidate (struct gdbarch *gdbarch, struct regcache *regcache,
}
}
+/* Push LR_VALUE to the Guarded Control Stack. */
+
+static void
+aarch64_push_gcs_entry (regcache *regs, CORE_ADDR lr_value)
+{
+ gdbarch *arch = regs->arch ();
+ aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (arch);
+ CORE_ADDR gcs_addr;
+
+ register_status status = regs->cooked_read (tdep->gcs_reg_base, &gcs_addr);
+ if (status != REG_VALID)
+ error (_("Can't read $gcspr."));
+
+ gcs_addr -= 8;
+ gdb_byte buf[8];
+ store_integer (buf, gdbarch_byte_order (arch), lr_value);
+ if (target_write_memory (gcs_addr, buf, sizeof (buf)) != 0)
+ error (_("Can't write to Guarded Control Stack."));
+
+ /* Update GCSPR. */
+ regcache_cooked_write_unsigned (regs, tdep->gcs_reg_base, gcs_addr);
+}
+
+/* Remove the newest entry from the Guarded Control Stack. */
+
+static void
+aarch64_pop_gcs_entry (regcache *regs)
+{
+ gdbarch *arch = regs->arch ();
+ aarch64_gdbarch_tdep *tdep = gdbarch_tdep<aarch64_gdbarch_tdep> (arch);
+ CORE_ADDR gcs_addr;
+
+ register_status status = regs->cooked_read (tdep->gcs_reg_base, &gcs_addr);
+ if (status != REG_VALID)
+ error (_("Can't read $gcspr."));
+
+ /* Update GCSPR. */
+ regcache_cooked_write_unsigned (regs, tdep->gcs_reg_base, gcs_addr + 8);
+}
+
+/* Implement the "shadow_stack_push" gdbarch method. */
+
+static void
+aarch64_shadow_stack_push (gdbarch *gdbarch, CORE_ADDR new_addr,
+ regcache *regcache)
+{
+ aarch64_push_gcs_entry (regcache, new_addr);
+}
+
/* Implement the "push_dummy_call" gdbarch method. */
static CORE_ADDR
@@ -3557,6 +3624,9 @@ struct aarch64_displaced_step_copy_insn_closure
/* PC adjustment offset after displaced stepping. If 0, then we don't
write the PC back, assuming the PC is already the right address. */
int32_t pc_adjust = 0;
+
+ /* True if it's a branch instruction that saves the link register. */
+ bool linked_branch = false;
};
/* Data when visiting instructions for displaced stepping. */
@@ -3608,6 +3678,12 @@ aarch64_displaced_step_b (const int is_bl, const int32_t offset,
/* Update LR. */
regcache_cooked_write_unsigned (dsd->regs, AARCH64_LR_REGNUM,
data->insn_addr + 4);
+ dsd->dsc->linked_branch = true;
+ bool gcs_is_enabled;
+ gdbarch_get_shadow_stack_pointer (dsd->regs->arch (), dsd->regs,
+ gcs_is_enabled);
+ if (gcs_is_enabled)
+ aarch64_push_gcs_entry (dsd->regs, data->insn_addr + 4);
}
}
@@ -3766,6 +3842,12 @@ aarch64_displaced_step_others (const uint32_t insn,
aarch64_emit_insn (dsd->insn_buf, insn & 0xffdfffff);
regcache_cooked_write_unsigned (dsd->regs, AARCH64_LR_REGNUM,
data->insn_addr + 4);
+ dsd->dsc->linked_branch = true;
+ bool gcs_is_enabled;
+ gdbarch_get_shadow_stack_pointer (dsd->regs->arch (), dsd->regs,
+ gcs_is_enabled);
+ if (gcs_is_enabled)
+ aarch64_push_gcs_entry (dsd->regs, data->insn_addr + 4);
}
else
aarch64_emit_insn (dsd->insn_buf, insn);
@@ -3862,20 +3944,24 @@ aarch64_displaced_step_fixup (struct gdbarch *gdbarch,
CORE_ADDR from, CORE_ADDR to,
struct regcache *regs, bool completed_p)
{
+ aarch64_displaced_step_copy_insn_closure *dsc
+ = (aarch64_displaced_step_copy_insn_closure *) dsc_;
CORE_ADDR pc = regcache_read_pc (regs);
- /* If the displaced instruction didn't complete successfully then all we
- need to do is restore the program counter. */
+ /* If the displaced instruction didn't complete successfully then we need
+ to restore the program counter, and perhaps the Guarded Control Stack. */
if (!completed_p)
{
+ bool gcs_is_enabled;
+ gdbarch_get_shadow_stack_pointer (gdbarch, regs, gcs_is_enabled);
+ if (dsc->linked_branch && gcs_is_enabled)
+ aarch64_pop_gcs_entry (regs);
+
pc = from + (pc - to);
regcache_write_pc (regs, pc);
return;
}
- aarch64_displaced_step_copy_insn_closure *dsc
- = (aarch64_displaced_step_copy_insn_closure *) dsc_;
-
displaced_debug_printf ("PC after stepping: %s (was %s).",
paddress (gdbarch, pc), paddress (gdbarch, to));
@@ -4046,6 +4132,14 @@ aarch64_features_from_target_desc (const struct target_desc *tdesc)
features.sme2 = (tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.sme2")
!= nullptr);
+ /* Check for the GCS feature. */
+ features.gcs = (tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.gcs")
+ != nullptr);
+
+ /* Check for the GCS Linux feature. */
+ features.gcs_linux = (tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.gcs.linux")
+ != nullptr);
+
return features;
}
@@ -4590,6 +4684,48 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
int first_w_regnum = num_pseudo_regs;
num_pseudo_regs += 31;
+ const tdesc_feature *feature_gcs
+ = tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.gcs");
+ int first_gcs_regnum = -1;
+ /* Add the GCS registers. */
+ if (feature_gcs != nullptr)
+ {
+ first_gcs_regnum = num_regs;
+ /* Validate the descriptor provides the mandatory GCS registers and
+ allocate their numbers. */
+ for (i = 0; i < ARRAY_SIZE (aarch64_gcs_register_names); i++)
+ valid_p &= tdesc_numbered_register (feature_gcs, tdesc_data.get (),
+ first_gcs_regnum + i,
+ aarch64_gcs_register_names[i]);
+
+ num_regs += i;
+ }
+
+ if (!valid_p)
+ return nullptr;
+
+ const tdesc_feature *feature_gcs_linux
+ = tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.gcs.linux");
+ int first_gcs_linux_regnum = -1;
+ /* Add the GCS Linux registers. */
+ if (feature_gcs_linux != nullptr && feature_gcs == nullptr)
+ {
+ /* This feature depends on the GCS feature. */
+ return nullptr;
+ }
+ else if (feature_gcs_linux != nullptr)
+ {
+ first_gcs_linux_regnum = num_regs;
+ /* Validate the descriptor provides the mandatory GCS Linux registers
+ and allocate their numbers. */
+ for (i = 0; i < ARRAY_SIZE (aarch64_gcs_linux_register_names); i++)
+ valid_p &= tdesc_numbered_register (feature_gcs_linux, tdesc_data.get (),
+ first_gcs_linux_regnum + i,
+ aarch64_gcs_linux_register_names[i]);
+
+ num_regs += i;
+ }
+
if (!valid_p)
return nullptr;
@@ -4611,6 +4747,8 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
tdep->mte_reg_base = first_mte_regnum;
tdep->tls_regnum_base = first_tls_regnum;
tdep->tls_register_count = tls_register_count;
+ tdep->gcs_reg_base = first_gcs_regnum;
+ tdep->gcs_linux_reg_base = first_gcs_linux_regnum;
/* Set the SME register set details. The pseudo-registers will be adjusted
later. */
@@ -4638,7 +4776,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_sw_breakpoint_from_kind (gdbarch,
aarch64_breakpoint::bp_from_kind);
set_gdbarch_have_nonsteppable_watchpoint (gdbarch, 1);
- set_gdbarch_software_single_step (gdbarch, aarch64_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, aarch64_software_single_step);
/* Information about registers, etc. */
set_gdbarch_sp_regnum (gdbarch, AARCH64_SP_REGNUM);
@@ -4733,6 +4871,9 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_get_pc_address_flags (gdbarch, aarch64_get_pc_address_flags);
+ if (tdep->has_gcs ())
+ set_gdbarch_shadow_stack_push (gdbarch, aarch64_shadow_stack_push);
+
tdesc_use_registers (gdbarch, tdesc, std::move (tdesc_data));
/* Fetch the updated number of registers after we're done adding all
@@ -4905,6 +5046,11 @@ aarch64_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file)
pulongest (tdep->sme_tile_pseudo_base));
gdb_printf (file, _("aarch64_dump_tdep: sme_svq = %s\n"),
pulongest (tdep->sme_svq));
+
+ gdb_printf (file, _("aarch64_dump_tdep: gcs_reg_base = %d\n"),
+ tdep->gcs_reg_base);
+ gdb_printf (file, _("aarch64_dump_tdep: gcs_linux_reg_base = %d\n"),
+ tdep->gcs_linux_reg_base);
}
#if GDB_SELF_TEST
diff --git a/gdb/aarch64-tdep.h b/gdb/aarch64-tdep.h
index 3b8dcc2..99e7d26 100644
--- a/gdb/aarch64-tdep.h
+++ b/gdb/aarch64-tdep.h
@@ -23,6 +23,7 @@
#define GDB_AARCH64_TDEP_H
#include "arch/aarch64.h"
+#include "dwarf2/frame.h"
#include "displaced-stepping.h"
#include "infrun.h"
#include "gdbarch.h"
@@ -182,6 +183,30 @@ struct aarch64_gdbarch_tdep : gdbarch_tdep_base
{
return sme2_zt0_regnum > 0;
}
+
+ /* First GCS register. This is -1 if no GCS registers are available. */
+ int gcs_reg_base = -1;
+
+ /* First GCS Linux-specific register. This is -1 if no GCS Linux feature is
+ available. */
+ int gcs_linux_reg_base = -1;
+
+ /* Function to unwind the GCSPR from the given frame. */
+ fn_prev_register fn_prev_gcspr = nullptr;
+
+ /* Returns true if the target supports GCS. */
+ bool
+ has_gcs () const
+ {
+ return gcs_reg_base != -1;
+ }
+
+ /* Returns true if the target supports the Linux GCS feature. */
+ bool
+ has_gcs_linux () const
+ {
+ return gcs_linux_reg_base != -1;
+ }
};
const target_desc *aarch64_read_description (const aarch64_features &features);
diff --git a/gdb/aclocal.m4 b/gdb/aclocal.m4
index 9971423..cae0970 100644
--- a/gdb/aclocal.m4
+++ b/gdb/aclocal.m4
@@ -202,9 +202,11 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
m4_include([../config/acx.m4])
m4_include([../config/ax_pthread.m4])
m4_include([../config/bfd64.m4])
+m4_include([../config/clang-plugin.m4])
m4_include([../config/debuginfod.m4])
m4_include([../config/depstand.m4])
m4_include([../config/enable.m4])
+m4_include([../config/gcc-plugin.m4])
m4_include([../config/gettext-sister.m4])
m4_include([../config/gettext.m4])
m4_include([../config/intlmacosx.m4])
diff --git a/gdb/ada-exp.h b/gdb/ada-exp.h
index 8c9bfe8..7354d65 100644
--- a/gdb/ada-exp.h
+++ b/gdb/ada-exp.h
@@ -34,28 +34,10 @@ extern struct value *ada_abs (struct type *expect_type,
struct expression *exp,
enum noside noside, enum exp_opcode op,
struct value *arg1);
-extern struct value *ada_unop_in_range (struct type *expect_type,
- struct expression *exp,
- enum noside noside, enum exp_opcode op,
- struct value *arg1, struct type *type);
extern struct value *ada_mult_binop (struct type *expect_type,
struct expression *exp,
enum noside noside, enum exp_opcode op,
struct value *arg1, struct value *arg2);
-extern struct value *ada_equal_binop (struct type *expect_type,
- struct expression *exp,
- enum noside noside, enum exp_opcode op,
- struct value *arg1, struct value *arg2);
-extern struct value *ada_ternop_slice (struct expression *exp,
- enum noside noside,
- struct value *array,
- struct value *low_bound_val,
- struct value *high_bound_val);
-extern struct value *ada_binop_in_bounds (struct expression *exp,
- enum noside noside,
- struct value *arg1,
- struct value *arg2,
- int n);
extern struct value *ada_binop_minmax (struct type *expect_type,
struct expression *exp,
enum noside noside, enum exp_opcode op,
@@ -224,12 +206,7 @@ public:
value *evaluate (struct type *expect_type,
struct expression *exp,
- enum noside noside) override
- {
- value *val = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
- return ada_unop_in_range (expect_type, exp, noside, UNOP_IN_RANGE,
- val, std::get<1> (m_storage));
- }
+ enum noside noside) override;
enum exp_opcode opcode () const override
{ return UNOP_IN_RANGE; }
@@ -271,14 +248,7 @@ public:
value *evaluate (struct type *expect_type,
struct expression *exp,
- enum noside noside) override
- {
- value *arg1 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
- value *arg2 = std::get<2> (m_storage)->evaluate (arg1->type (),
- exp, noside);
- return ada_equal_binop (expect_type, exp, noside, std::get<0> (m_storage),
- arg1, arg2);
- }
+ enum noside noside) override;
void do_generate_ax (struct expression *exp,
struct agent_expr *ax,
@@ -307,13 +277,7 @@ public:
value *evaluate (struct type *expect_type,
struct expression *exp,
- enum noside noside) override
- {
- value *array = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
- value *low = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
- value *high = std::get<2> (m_storage)->evaluate (nullptr, exp, noside);
- return ada_ternop_slice (exp, noside, array, low, high);
- }
+ enum noside noside) override;
enum exp_opcode opcode () const override
{ return TERNOP_SLICE; }
@@ -335,13 +299,7 @@ public:
value *evaluate (struct type *expect_type,
struct expression *exp,
- enum noside noside) override
- {
- value *arg1 = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
- value *arg2 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
- return ada_binop_in_bounds (exp, noside, arg1, arg2,
- std::get<2> (m_storage));
- }
+ enum noside noside) override;
enum exp_opcode opcode () const override
{ return BINOP_IN_BOUNDS; }
diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index 1546ae9..ed5694e 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -35,7 +35,6 @@
%{
-#include <ctype.h>
#include "gdbsupport/unordered_map.h"
#include "expression.h"
#include "value.h"
@@ -1338,7 +1337,7 @@ write_object_renaming (struct parser_state *par_state,
SEARCH_VFT);
if (sym_info.symbol == NULL)
error (_("Could not find renamed variable: %s"), ada_decode (name).c_str ());
- else if (sym_info.symbol->aclass () == LOC_TYPEDEF)
+ else if (sym_info.symbol->loc_class () == LOC_TYPEDEF)
/* We have a renaming of an old-style renaming symbol. Don't
trust the block information. */
sym_info.block = orig_left_context;
@@ -1380,7 +1379,7 @@ write_object_renaming (struct parser_state *par_state,
[[fallthrough]];
case 'S':
renaming_expr += 1;
- if (isdigit (*renaming_expr))
+ if (c_isdigit (*renaming_expr))
{
char *next;
long val = strtol (renaming_expr, &next, 10);
@@ -1408,7 +1407,7 @@ write_object_renaming (struct parser_state *par_state,
SEARCH_VFT);
if (index_sym_info.symbol == NULL)
error (_("Could not find %s"), index_name);
- else if (index_sym_info.symbol->aclass () == LOC_TYPEDEF)
+ else if (index_sym_info.symbol->loc_class () == LOC_TYPEDEF)
/* Index is an old-style renaming symbol. */
index_sym_info.block = orig_left_context;
write_var_from_sym (par_state, index_sym_info);
@@ -1478,14 +1477,14 @@ block_lookup (const struct block *context, const char *raw_name)
= ada_lookup_symbol_list (name, context, SEARCH_FUNCTION_DOMAIN);
if (context == NULL
- && (syms.empty () || syms[0].symbol->aclass () != LOC_BLOCK))
+ && (syms.empty () || syms[0].symbol->loc_class () != LOC_BLOCK))
symtab = lookup_symtab (current_program_space, name);
else
symtab = NULL;
if (symtab != NULL)
result = symtab->compunit ()->blockvector ()->static_block ();
- else if (syms.empty () || syms[0].symbol->aclass () != LOC_BLOCK)
+ else if (syms.empty () || syms[0].symbol->loc_class () != LOC_BLOCK)
{
if (context == NULL)
error (_("No file or function \"%s\"."), raw_name);
@@ -1511,7 +1510,7 @@ select_possible_type_sym (const std::vector<struct block_symbol> &syms)
preferred_index = -1; preferred_type = NULL;
for (i = 0; i < syms.size (); i += 1)
- switch (syms[i].symbol->aclass ())
+ switch (syms[i].symbol->loc_class ())
{
case LOC_TYPEDEF:
if (ada_prefer_type (syms[i].symbol->type (), preferred_type))
@@ -1555,7 +1554,7 @@ find_primitive_type (struct parser_state *par_state, const char *name)
strcpy (expanded_name, "standard__");
strcat (expanded_name, name);
sym = ada_lookup_symbol (expanded_name, NULL, SEARCH_TYPE_DOMAIN).symbol;
- if (sym != NULL && sym->aclass () == LOC_TYPEDEF)
+ if (sym != NULL && sym->loc_class () == LOC_TYPEDEF)
type = sym->type ();
}
@@ -1888,7 +1887,7 @@ ada_parse_state::find_completion_bounds ()
const char *end = pstate->lexptr;
/* First the end of the prefix. Here we stop at the token start or
at '.' or space. */
- for (; end > m_original_expr && end[-1] != '.' && !isspace (end[-1]); --end)
+ for (; end > m_original_expr && end[-1] != '.' && !c_isspace (end[-1]); --end)
{
/* Nothing. */
}
@@ -1966,7 +1965,7 @@ write_name_assoc (struct parser_state *par_state, struct stoken name)
par_state->expression_context_block,
SEARCH_VFT);
- if (syms.size () != 1 || syms[0].symbol->aclass () == LOC_TYPEDEF)
+ if (syms.size () != 1 || syms[0].symbol->loc_class () == LOC_TYPEDEF)
pstate->push_new<ada_string_operation> (copy_name (name));
else
write_var_from_sym (par_state, syms[0]);
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 329d114..0dfcc10 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -18,7 +18,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include <ctype.h>
#include "event-top.h"
#include "exceptions.h"
#include "extract-store-integer.h"
@@ -183,7 +182,7 @@ static struct value *ada_search_struct_field (const char *, struct value *, int,
struct type *);
static int find_struct_field (const char *, struct type *, int,
- struct type **, int *, int *, int *, int *);
+ struct type **, int *, int *, int *, LONGEST *);
static int ada_resolve_function (std::vector<struct block_symbol> &,
struct value **, int, const char *,
@@ -875,7 +874,7 @@ is_compiler_suffix (const char *str)
{
gdb_assert (*str == '[');
++str;
- while (*str != '\0' && isalpha (*str))
+ while (*str != '\0' && c_isalpha (*str))
++str;
/* We accept a missing "]" in order to support completion. */
return *str == '\0' || (str[0] == ']' && str[1] == '\0');
@@ -1167,7 +1166,7 @@ ada_encode (const char *decoded, bool fold)
static int
is_lower_alphanum (const char c)
{
- return (isdigit (c) || (isalpha (c) && islower (c)));
+ return (c_isdigit (c) || (c_isalpha (c) && c_islower (c)));
}
/* ENCODED is the linkage name of a symbol and LEN contains its length.
@@ -1185,11 +1184,11 @@ is_lower_alphanum (const char c)
static void
ada_remove_trailing_digits (const char *encoded, int *len)
{
- if (*len > 1 && isdigit (encoded[*len - 1]))
+ if (*len > 1 && c_isdigit (encoded[*len - 1]))
{
int i = *len - 2;
- while (i > 0 && isdigit (encoded[i]))
+ while (i > 0 && c_isdigit (encoded[i]))
i--;
if (i >= 0 && encoded[i] == '.')
*len = i;
@@ -1220,7 +1219,7 @@ ada_remove_po_subprogram_suffix (const char *encoded, int *len)
if (*len > 1
&& encoded[*len - 1] == 'N'
- && (isdigit (encoded[*len - 2]) || islower (encoded[*len - 2])))
+ && (c_isdigit (encoded[*len - 2]) || c_islower (encoded[*len - 2])))
*len = *len - 1;
}
@@ -1232,7 +1231,7 @@ static int
remove_compiler_suffix (const char *encoded, int *len)
{
int offset = *len - 1;
- while (offset > 0 && isalpha (encoded[offset]))
+ while (offset > 0 && c_isalpha (encoded[offset]))
--offset;
if (offset > 0 && encoded[offset] == '.')
{
@@ -1252,7 +1251,7 @@ convert_hex (const char *str, int n, uint32_t *out)
for (int i = 0; i < n; ++i)
{
- if (!isxdigit (str[i]))
+ if (!c_isxdigit (str[i]))
return false;
result <<= 4;
result |= fromhex (str[i]);
@@ -1311,7 +1310,7 @@ convert_from_hex_encoded (std::string &out, const char *str, int n)
/* See ada-lang.h. */
std::string
-ada_decode (const char *encoded, bool wrap, bool operators, bool wide)
+ada_decode (const char *encoded, bool wrap, bool translate)
{
int i;
int len0;
@@ -1384,11 +1383,11 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide)
/* Remove trailing __{digit}+ or trailing ${digit}+. */
- if (len0 > 1 && isdigit (encoded[len0 - 1]))
+ if (len0 > 1 && c_isdigit (encoded[len0 - 1]))
{
i = len0 - 2;
- while ((i >= 0 && isdigit (encoded[i]))
- || (i >= 1 && encoded[i] == '_' && isdigit (encoded[i - 1])))
+ while ((i >= 0 && c_isdigit (encoded[i]))
+ || (i >= 1 && encoded[i] == '_' && c_isdigit (encoded[i - 1])))
i -= 1;
if (i > 1 && encoded[i] == '_' && encoded[i - 1] == '_')
len0 = i - 1;
@@ -1399,14 +1398,14 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide)
/* The first few characters that are not alphabetic are not part
of any encoding we use, so we can copy them over verbatim. */
- for (i = 0; i < len0 && !isalpha (encoded[i]); i += 1)
+ for (i = 0; i < len0 && !c_isalpha (encoded[i]); i += 1)
decoded.push_back (encoded[i]);
at_start_name = 1;
while (i < len0)
{
/* Is this a symbol function? */
- if (operators && at_start_name && encoded[i] == 'O')
+ if (at_start_name && encoded[i] == 'O')
{
int k;
@@ -1415,9 +1414,12 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide)
int op_len = strlen (ada_opname_table[k].encoded);
if ((strncmp (ada_opname_table[k].encoded + 1, encoded + i + 1,
op_len - 1) == 0)
- && !isalnum (encoded[i + op_len]))
+ && !c_isalnum (encoded[i + op_len]))
{
- decoded.append (ada_opname_table[k].decoded);
+ if (translate)
+ decoded.append (ada_opname_table[k].decoded);
+ else
+ decoded.append (ada_opname_table[k].encoded);
at_start_name = 0;
i += op_len;
break;
@@ -1440,11 +1442,11 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide)
if (len0 - i > 5 && encoded [i] == '_' && encoded [i+1] == '_'
&& encoded [i+2] == 'B' && encoded [i+3] == '_'
- && isdigit (encoded [i+4]))
+ && c_isdigit (encoded [i+4]))
{
int k = i + 5;
- while (k < len0 && isdigit (encoded[k]))
+ while (k < len0 && c_isdigit (encoded[k]))
k++; /* Skip any extra digit. */
/* Double-check that the "__B_{DIGITS}+" sequence we found
@@ -1467,11 +1469,11 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide)
internally generated. */
if (len0 - i > 3 && encoded [i] == '_' && encoded[i+1] == 'E'
- && isdigit (encoded[i+2]))
+ && c_isdigit (encoded[i+2]))
{
int k = i + 3;
- while (k < len0 && isdigit (encoded[k]))
+ while (k < len0 && c_isdigit (encoded[k]))
k++;
if (k < len0
@@ -1505,33 +1507,65 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide)
i++;
}
- if (wide && i < len0 + 3 && encoded[i] == 'U' && isxdigit (encoded[i + 1]))
+ /* Handle wide characters while respecting the arguments to the
+ function: we may want to copy them verbatim, but in this case
+ we do not want to register that we've copied an upper-case
+ character. */
+ if (i < len0 + 3 && encoded[i] == 'U' && c_isxdigit (encoded[i + 1]))
{
- if (convert_from_hex_encoded (decoded, &encoded[i + 1], 2))
+ if (translate)
{
- i += 3;
+ if (convert_from_hex_encoded (decoded, &encoded[i + 1], 2))
+ {
+ i += 3;
+ continue;
+ }
+ }
+ else
+ {
+ decoded.push_back (encoded[i]);
+ ++i;
continue;
}
}
- else if (wide && i < len0 + 5 && encoded[i] == 'W' && isxdigit (encoded[i + 1]))
+ else if (i < len0 + 5 && encoded[i] == 'W'
+ && c_isxdigit (encoded[i + 1]))
{
- if (convert_from_hex_encoded (decoded, &encoded[i + 1], 4))
+ if (translate)
{
- i += 5;
+ if (convert_from_hex_encoded (decoded, &encoded[i + 1], 4))
+ {
+ i += 5;
+ continue;
+ }
+ }
+ else
+ {
+ decoded.push_back (encoded[i]);
+ ++i;
continue;
}
}
- else if (wide && i < len0 + 10 && encoded[i] == 'W' && encoded[i + 1] == 'W'
- && isxdigit (encoded[i + 2]))
+ else if (i < len0 + 10 && encoded[i] == 'W' && encoded[i + 1] == 'W'
+ && c_isxdigit (encoded[i + 2]))
{
- if (convert_from_hex_encoded (decoded, &encoded[i + 2], 8))
+ if (translate)
{
- i += 10;
+ if (convert_from_hex_encoded (decoded, &encoded[i + 2], 8))
+ {
+ i += 10;
+ continue;
+ }
+ }
+ else
+ {
+ decoded.push_back (encoded[i]);
+ ++i;
continue;
}
}
- if (encoded[i] == 'X' && i != 0 && isalnum (encoded[i - 1]))
+ if (encoded[i] == 'X' && i != 0 && c_isalnum (encoded[i - 1]))
{
/* This is a X[bn]* sequence not separated from the previous
part of the name with a non-alpha-numeric character (in other
@@ -1553,6 +1587,12 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide)
at_start_name = 1;
i += 2;
}
+ else if (isupper (encoded[i]) || encoded[i] == ' ')
+ {
+ /* Decoded names should never contain any uppercase
+ character. */
+ goto Suppress;
+ }
else
{
/* It's a character part of the decoded name, so just copy it
@@ -1562,16 +1602,6 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide)
}
}
- /* Decoded names should never contain any uppercase character.
- Double-check this, and abort the decoding if we find one. */
-
- if (operators)
- {
- for (i = 0; i < decoded.length(); ++i)
- if (isupper (decoded[i]) || decoded[i] == ' ')
- goto Suppress;
- }
-
/* If the compiler added a suffix, append it now. */
if (suffix >= 0)
decoded = decoded + "[" + &encoded[suffix] + "]";
@@ -1597,6 +1627,13 @@ ada_decode_tests ()
/* This isn't valid, but used to cause a crash. PR gdb/30639. The
result does not really matter very much. */
SELF_CHECK (ada_decode ("44") == "44");
+
+ /* Check that the settings used by the DWARF reader have the desired
+ effect. */
+ SELF_CHECK (ada_decode ("symada__cS", false, false) == "");
+ SELF_CHECK (ada_decode ("pkg__Oxor", false, false) == "pkg.Oxor");
+ SELF_CHECK (ada_decode ("pack__func_W017b", false, false)
+ == "pack.func_W017b");
}
#endif
@@ -1677,8 +1714,6 @@ ada_decode_symbol (const struct general_symbol_info *arg)
void
ada_fixup_array_indexes_type (struct type *index_desc_type)
{
- int i;
-
if (index_desc_type == NULL)
return;
gdb_assert (index_desc_type->num_fields () > 0);
@@ -1696,13 +1731,13 @@ ada_fixup_array_indexes_type (struct type *index_desc_type)
return;
/* Fixup each field of INDEX_DESC_TYPE. */
- for (i = 0; i < index_desc_type->num_fields (); i++)
+ for (auto &field : index_desc_type->fields ())
{
- const char *name = index_desc_type->field (i).name ();
+ const char *name = field.name ();
struct type *raw_type = ada_check_typedef (ada_find_any_type (name));
if (raw_type)
- index_desc_type->field (i).set_type (raw_type);
+ field.set_type (raw_type);
}
}
@@ -1729,16 +1764,6 @@ desc_base_type (struct type *type)
return type;
}
-/* True iff TYPE indicates a "thin" array pointer type. */
-
-static int
-is_thin_pntr (struct type *type)
-{
- return
- is_suffix (ada_type_name (desc_base_type (type)), "___XUT")
- || is_suffix (ada_type_name (desc_base_type (type)), "___XUT___XVE");
-}
-
/* The descriptor type for thin pointer type TYPE. */
static struct type *
@@ -1777,14 +1802,45 @@ thin_data_pntr (struct value *val)
return value_from_longest (data_type, val->address ());
}
-/* True iff TYPE indicates a "thick" array pointer type. */
+/* Different kinds of Ada-specific pointers. */
+enum class pointer_kind
+{
+ /* Not a thin or thick pointer. */
+ NOT_SPECIAL,
+ /* A thin pointer. */
+ THIN,
+ /* Thick pointer where the bounds are accessed via the P_BOUNDS
+ member, a pointer to the bounds. */
+ P_BOUNDS,
+ /* Thick pointer where the bounds are accessed via the BOUNDS
+ member, which directly holds the bounds. */
+ EXTENDED_ACCESS,
+};
+
+/* Return a pointer_kind indicating whether TYPE is a special category
+ of pointer. Note that TYPE may be NULL, in which case NOT_SPECIAL
+ is returned. */
-static int
-is_thick_pntr (struct type *type)
+static pointer_kind
+categorize_pointer (struct type *type)
{
type = desc_base_type (type);
- return (type != NULL && type->code () == TYPE_CODE_STRUCT
- && lookup_struct_elt_type (type, "P_BOUNDS", 1) != NULL);
+ if (type == nullptr)
+ return pointer_kind::NOT_SPECIAL;
+
+ if (is_suffix (ada_type_name (type), "___XUT")
+ || is_suffix (ada_type_name (type), "___XUT___XVE"))
+ return pointer_kind::THIN;
+
+ if (type->code () == TYPE_CODE_STRUCT)
+ {
+ if (lookup_struct_elt_type (type, "P_BOUNDS", 1) != nullptr)
+ return pointer_kind::P_BOUNDS;
+ if (lookup_struct_elt_type (type, "BOUNDS", 1) != nullptr)
+ return pointer_kind::EXTENDED_ACCESS;
+ }
+
+ return pointer_kind::NOT_SPECIAL;
}
/* If TYPE is the type of an array descriptor (fat or thin pointer) or a
@@ -1795,11 +1851,9 @@ desc_bounds_type (struct type *type)
{
struct type *r;
+ pointer_kind kind = categorize_pointer (type);
type = desc_base_type (type);
-
- if (type == NULL)
- return NULL;
- else if (is_thin_pntr (type))
+ if (kind == pointer_kind::THIN)
{
type = thin_descriptor_type (type);
if (type == NULL)
@@ -1808,25 +1862,36 @@ desc_bounds_type (struct type *type)
if (r != NULL)
return ada_check_typedef (r);
}
- else if (type->code () == TYPE_CODE_STRUCT)
+ else if (kind == pointer_kind::P_BOUNDS
+ || kind == pointer_kind::EXTENDED_ACCESS)
{
- r = lookup_struct_elt_type (type, "P_BOUNDS", 1);
+ const char *field_name = (kind == pointer_kind::EXTENDED_ACCESS
+ ? "BOUNDS"
+ : "P_BOUNDS");
+ r = lookup_struct_elt_type (type, field_name, 1);
if (r != NULL)
- return ada_check_typedef (ada_check_typedef (r)->target_type ());
+ {
+ struct type *bounds_type = ada_check_typedef (r);
+ if (bounds_type->code () == TYPE_CODE_PTR)
+ bounds_type = ada_check_typedef (bounds_type->target_type ());
+ return bounds_type;
+ }
}
return NULL;
}
/* If ARR is an array descriptor (fat or thin pointer), or pointer to
- one, a pointer to its bounds data. Otherwise, throw an
- exception. */
+ one, return a pointer to its bounds data. For a fat pointer, this
+ means the structure holding the bounds -- so for extended access
+ pointers in particular, it will just return the descriptor itself.
+ Otherwise, throw an exception. */
static struct value *
desc_bounds (struct value *arr)
{
struct type *type = ada_check_typedef (arr->type ());
-
- if (is_thin_pntr (type))
+ pointer_kind kind = categorize_pointer (type);
+ if (kind == pointer_kind::THIN)
{
struct type *bounds_type =
desc_bounds_type (thin_descriptor_type (type));
@@ -1847,14 +1912,18 @@ desc_bounds (struct value *arr)
value_from_longest (lookup_pointer_type (bounds_type),
addr - bounds_type->length ());
}
-
- else if (is_thick_pntr (type))
+ else if (kind == pointer_kind::P_BOUNDS
+ || kind == pointer_kind::EXTENDED_ACCESS)
{
- struct value *p_bounds = value_struct_elt (&arr, {}, "P_BOUNDS", NULL,
- _("Bad GNAT array descriptor"));
+ const char *field_name = (kind == pointer_kind::EXTENDED_ACCESS
+ ? "BOUNDS"
+ : "P_BOUNDS");
+ struct value *p_bounds
+ = value_struct_elt (&arr, {}, field_name, nullptr,
+ _("Bad GNAT array descriptor"));
struct type *p_bounds_type = p_bounds->type ();
- if (p_bounds_type
+ if (p_bounds_type != nullptr
&& p_bounds_type->code () == TYPE_CODE_PTR)
{
struct type *target_type = p_bounds_type->target_type ();
@@ -1864,7 +1933,8 @@ desc_bounds (struct value *arr)
(ada_check_typedef (target_type)),
p_bounds);
}
- else
+ else if (p_bounds_type == nullptr
+ || kind != pointer_kind::EXTENDED_ACCESS)
error (_("Bad GNAT array descriptor"));
return p_bounds;
@@ -1904,12 +1974,13 @@ fat_pntr_bounds_bitsize (struct type *type)
static struct type *
desc_data_target_type (struct type *type)
{
+ pointer_kind kind = categorize_pointer (type);
type = desc_base_type (type);
-
/* NOTE: The following is bogus; see comment in desc_bounds. */
- if (is_thin_pntr (type))
+ if (kind == pointer_kind::THIN)
return desc_base_type (thin_descriptor_type (type)->field (1).type ());
- else if (is_thick_pntr (type))
+ else if (kind == pointer_kind::P_BOUNDS
+ || kind == pointer_kind::EXTENDED_ACCESS)
{
struct type *data_type = lookup_struct_elt_type (type, "P_ARRAY", 1);
@@ -1928,10 +1999,11 @@ static struct value *
desc_data (struct value *arr)
{
struct type *type = arr->type ();
-
- if (is_thin_pntr (type))
+ pointer_kind kind = categorize_pointer (type);
+ if (kind == pointer_kind::THIN)
return thin_data_pntr (arr);
- else if (is_thick_pntr (type))
+ else if (kind == pointer_kind::P_BOUNDS
+ || kind == pointer_kind::EXTENDED_ACCESS)
return value_struct_elt (&arr, {}, "P_ARRAY", NULL,
_("Bad GNAT array descriptor"));
else
@@ -2129,7 +2201,10 @@ ada_type_of_array (struct value *arr, int bounds)
return ada_check_typedef (arr->type ());
descriptor = desc_bounds (arr);
- if (value_as_long (descriptor) == 0)
+ /* In the extended access case, the bounds struct is "inline" so
+ the pointer cannot be NULL. */
+ if (ada_check_typedef (descriptor->type ())->code () == TYPE_CODE_PTR
+ && value_as_long (descriptor) == 0)
return NULL;
while (arity > 0)
{
@@ -2140,8 +2215,8 @@ ada_type_of_array (struct value *arr, int bounds)
arity -= 1;
struct type *range_type
= create_static_range_type (alloc, low->type (),
- longest_to_int (value_as_long (low)),
- longest_to_int (value_as_long (high)));
+ value_as_long (low),
+ value_as_long (high));
elt_type = create_array_type (alloc, elt_type, range_type);
INIT_GNAT_SPECIFIC (elt_type);
@@ -2270,7 +2345,8 @@ ada_is_unconstrained_packed_array_type (struct type *type)
/* If we saw GNAT encodings, then the above code is sufficient.
However, with minimal encodings, we will just have a thick
pointer instead. */
- if (is_thick_pntr (type))
+ pointer_kind kind = categorize_pointer (type);
+ if (kind == pointer_kind::P_BOUNDS || kind == pointer_kind::EXTENDED_ACCESS)
{
type = desc_base_type (type);
/* The structure's first field is a pointer to an array, so this
@@ -2322,7 +2398,9 @@ decode_packed_array_bitsize (struct type *type)
tail = strstr (raw_name, "___XP");
if (tail == nullptr)
{
- gdb_assert (is_thick_pntr (type));
+ pointer_kind kind = categorize_pointer (type);
+ gdb_assert (kind == pointer_kind::P_BOUNDS
+ || kind == pointer_kind::EXTENDED_ACCESS);
/* The structure's first field is a pointer to an array, so this
fetches the array type. */
type = type->field (0).type ()->target_type ();
@@ -2983,8 +3061,11 @@ value_assign_to_component (struct value *container, struct value *component,
bool
ada_is_access_to_unconstrained_array (struct type *type)
{
- return (type->code () == TYPE_CODE_TYPEDEF
- && is_thick_pntr (ada_typedef_target_type (type)));
+ if (type->code () != TYPE_CODE_TYPEDEF)
+ return false;
+ pointer_kind kind = categorize_pointer (ada_typedef_target_type (type));
+ return (kind == pointer_kind::P_BOUNDS
+ || kind == pointer_kind::EXTENDED_ACCESS);
}
/* The value of the element of array ARR at the ARITY indices given in IND.
@@ -3084,7 +3165,7 @@ ada_value_ptr_subscript (struct value *arr, int arity, struct value **ind)
this array is LOW, as per Ada rules. */
static struct value *
ada_value_slice_from_ptr (struct value *array_ptr, struct type *type,
- int low, int high)
+ LONGEST low, LONGEST high)
{
struct type *type0 = ada_check_typedef (type);
struct type *base_index_type = type0->index_type ()->target_type ();
@@ -3095,7 +3176,7 @@ ada_value_slice_from_ptr (struct value *array_ptr, struct type *type,
(alloc, type0->target_type (), index_type,
type0->dyn_prop (DYN_PROP_BYTE_STRIDE),
type0->field (0).bitsize ());
- int base_low = ada_discrete_type_low_bound (type0->index_type ());
+ LONGEST base_low = ada_discrete_type_low_bound (type0->index_type ());
std::optional<LONGEST> base_low_pos, low_pos;
CORE_ADDR base;
@@ -3119,7 +3200,7 @@ ada_value_slice_from_ptr (struct value *array_ptr, struct type *type,
static struct value *
-ada_value_slice (struct value *array, int low, int high)
+ada_value_slice (struct value *array, LONGEST low, LONGEST high)
{
struct type *type = ada_check_typedef (array->type ());
struct type *base_index_type = type->index_type ()->target_type ();
@@ -3392,7 +3473,7 @@ ada_array_length (struct value *arr, int n)
less than LOW, then LOW-1 is used. */
static struct value *
-empty_array (struct type *arr_type, int low, int high)
+empty_array (struct type *arr_type, LONGEST low, LONGEST high)
{
struct type *arr_type0 = ada_check_typedef (arr_type);
type_allocator alloc (arr_type0->index_type ()->target_type ());
@@ -3639,7 +3720,7 @@ See set/show multiple-symbol."));
if (syms[i].symbol == NULL)
continue;
- if (syms[i].symbol->aclass () == LOC_BLOCK)
+ if (syms[i].symbol->loc_class () == LOC_BLOCK)
{
struct symtab_and_line sal =
find_function_start_sal (syms[i].symbol, 1);
@@ -3661,7 +3742,7 @@ See set/show multiple-symbol."));
else
{
int is_enumeral =
- (syms[i].symbol->aclass () == LOC_CONST
+ (syms[i].symbol->loc_class () == LOC_CONST
&& syms[i].symbol->type () != NULL
&& syms[i].symbol->type ()->code () == TYPE_CODE_ENUM);
struct symtab *symtab = NULL;
@@ -3824,7 +3905,7 @@ ada_resolve_variable (struct symbol *sym, const struct block *block,
candidates.end (),
[] (block_symbol &bsym)
{
- switch (bsym.symbol->aclass ())
+ switch (bsym.symbol->loc_class ())
{
case LOC_REGISTER:
case LOC_ARG:
@@ -3847,7 +3928,7 @@ ada_resolve_variable (struct symbol *sym, const struct block *block,
candidates.end (),
[] (block_symbol &bsym)
{
- return bsym.symbol->aclass () == LOC_TYPEDEF;
+ return bsym.symbol->loc_class () == LOC_TYPEDEF;
}),
candidates.end ());
}
@@ -4002,7 +4083,7 @@ ada_args_match (struct symbol *func, struct value **actuals, int n_actuals)
int i;
struct type *func_type = func->type ();
- if (func->aclass () == LOC_CONST
+ if (func->loc_class () == LOC_CONST
&& func_type->code () == TYPE_CODE_ENUM)
return (n_actuals == 0);
else if (func_type == NULL || func_type->code () != TYPE_CODE_FUNC)
@@ -4312,7 +4393,7 @@ ada_parse_renaming (struct symbol *sym,
if (sym == NULL)
return ADA_NOT_RENAMING;
- switch (sym->aclass ())
+ switch (sym->loc_class ())
{
default:
return ADA_NOT_RENAMING;
@@ -4778,7 +4859,7 @@ is_nonfunction (const std::vector<struct block_symbol> &syms)
for (const block_symbol &sym : syms)
if (sym.symbol->type ()->code () != TYPE_CODE_FUNC
&& (sym.symbol->type ()->code () != TYPE_CODE_ENUM
- || sym.symbol->aclass () != LOC_CONST))
+ || sym.symbol->loc_class () != LOC_CONST))
return 1;
return 0;
@@ -4813,10 +4894,10 @@ lesseq_defined_than (struct symbol *sym0, struct symbol *sym1)
if (sym0 == sym1)
return 1;
if (sym0->domain () != sym1->domain ()
- || sym0->aclass () != sym1->aclass ())
+ || sym0->loc_class () != sym1->loc_class ())
return 0;
- switch (sym0->aclass ())
+ switch (sym0->loc_class ())
{
case LOC_UNDEF:
return 1;
@@ -4903,9 +4984,8 @@ ada_lookup_simple_minsym (const char *name, struct objfile *objfile)
symbol_name_matcher_ftype *match_name
= ada_get_symbol_name_matcher (lookup_name);
- gdbarch_iterate_over_objfiles_in_search_order
- (objfile != NULL ? objfile->arch () : current_inferior ()->arch (),
- [&result, lookup_name, match_name] (struct objfile *obj)
+ current_program_space->iterate_over_objfiles_in_search_order
+ ([&result, lookup_name, match_name] (struct objfile *obj)
{
for (minimal_symbol *msymbol : obj->msymbols ())
{
@@ -5071,7 +5151,7 @@ remove_extra_symbols (std::vector<struct block_symbol> &syms)
should be identical. */
else if (syms[i].symbol->linkage_name () != NULL
- && syms[i].symbol->aclass () == LOC_STATIC
+ && syms[i].symbol->loc_class () == LOC_STATIC
&& is_nondebugging_type (syms[i].symbol->type ()))
{
for (j = 0; !remove_p && j < syms.size (); j += 1)
@@ -5080,8 +5160,8 @@ remove_extra_symbols (std::vector<struct block_symbol> &syms)
&& syms[j].symbol->linkage_name () != NULL
&& strcmp (syms[i].symbol->linkage_name (),
syms[j].symbol->linkage_name ()) == 0
- && (syms[i].symbol->aclass ()
- == syms[j].symbol->aclass ())
+ && (syms[i].symbol->loc_class ()
+ == syms[j].symbol->loc_class ())
&& syms[i].symbol->value_address ()
== syms[j].symbol->value_address ())
remove_p = true;
@@ -5090,12 +5170,12 @@ remove_extra_symbols (std::vector<struct block_symbol> &syms)
/* Two functions with the same block are identical. */
- else if (syms[i].symbol->aclass () == LOC_BLOCK)
+ else if (syms[i].symbol->loc_class () == LOC_BLOCK)
{
for (j = 0; !remove_p && j < syms.size (); j += 1)
{
if (i != j
- && syms[j].symbol->aclass () == LOC_BLOCK
+ && syms[j].symbol->loc_class () == LOC_BLOCK
&& (syms[i].symbol->value_block ()
== syms[j].symbol->value_block ()))
remove_p = true;
@@ -5172,7 +5252,7 @@ is_package_name (const char *name)
static int
old_renaming_is_invisible (const struct symbol *sym, const char *function_name)
{
- if (sym->aclass () != LOC_TYPEDEF)
+ if (sym->loc_class () != LOC_TYPEDEF)
return 0;
std::string scope = xget_renaming_scope (sym->type ());
@@ -5251,7 +5331,7 @@ remove_irrelevant_renamings (std::vector<struct block_symbol> *syms,
const char *name;
const char *suffix;
- if (sym == NULL || sym->aclass () == LOC_TYPEDEF)
+ if (sym == NULL || sym->loc_class () == LOC_TYPEDEF)
continue;
name = sym->linkage_name ();
suffix = strstr (name, "___XR");
@@ -5376,7 +5456,7 @@ match_data::operator() (struct block_symbol *bsym)
}
else
{
- if (sym->aclass () == LOC_UNRESOLVED)
+ if (sym->loc_class () == LOC_UNRESOLVED)
return true;
else if (sym->is_argument ())
arg_sym = sym;
@@ -5475,22 +5555,19 @@ map_matching_symbols (struct objfile *objfile,
match_data &data)
{
data.objfile = objfile;
- objfile->expand_symtabs_matching (nullptr, &lookup_name,
- nullptr, nullptr,
- global
- ? SEARCH_GLOBAL_BLOCK
- : SEARCH_STATIC_BLOCK,
- domain);
const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
- for (compunit_symtab *symtab : objfile->compunits ())
+ auto callback = [&] (compunit_symtab *symtab)
{
const struct block *block
= symtab->blockvector ()->block (block_kind);
- if (!iterate_over_symbols_terminated (block, lookup_name,
- domain, data))
- break;
- }
+ return iterate_over_symbols_terminated (block, lookup_name,
+ domain, data);
+ };
+
+ objfile->search (nullptr, &lookup_name, nullptr, callback,
+ global ? SEARCH_GLOBAL_BLOCK : SEARCH_STATIC_BLOCK,
+ domain);
}
/* Add to RESULT all non-local symbols whose name and domain match
@@ -5732,10 +5809,10 @@ is_name_suffix (const char *str)
/* Skip optional leading __[0-9]+. */
- if (len > 3 && str[0] == '_' && str[1] == '_' && isdigit (str[2]))
+ if (len > 3 && str[0] == '_' && str[1] == '_' && c_isdigit (str[2]))
{
str += 3;
- while (isdigit (str[0]))
+ while (c_isdigit (str[0]))
str += 1;
}
@@ -5744,7 +5821,7 @@ is_name_suffix (const char *str)
if (str[0] == '.' || str[0] == '$')
{
matching = str + 1;
- while (isdigit (matching[0]))
+ while (c_isdigit (matching[0]))
matching += 1;
if (matching[0] == '\0')
return 1;
@@ -5755,7 +5832,7 @@ is_name_suffix (const char *str)
if (len > 3 && str[0] == '_' && str[1] == '_' && str[2] == '_')
{
matching = str + 3;
- while (isdigit (matching[0]))
+ while (c_isdigit (matching[0]))
matching += 1;
if (matching[0] == '\0')
return 1;
@@ -5784,10 +5861,10 @@ is_name_suffix (const char *str)
#endif
/* _E[0-9]+[bs]$ */
- if (len > 3 && str[0] == '_' && str [1] == 'E' && isdigit (str[2]))
+ if (len > 3 && str[0] == '_' && str [1] == 'E' && c_isdigit (str[2]))
{
matching = str + 3;
- while (isdigit (matching[0]))
+ while (c_isdigit (matching[0]))
matching += 1;
if ((matching[0] == 'b' || matching[0] == 's')
&& matching [1] == '\0')
@@ -5837,17 +5914,17 @@ is_name_suffix (const char *str)
return 1;
return 0;
}
- if (!isdigit (str[2]))
+ if (!c_isdigit (str[2]))
return 0;
for (k = 3; str[k] != '\0'; k += 1)
- if (!isdigit (str[k]) && str[k] != '_')
+ if (!c_isdigit (str[k]) && str[k] != '_')
return 0;
return 1;
}
- if (str[0] == '$' && isdigit (str[1]))
+ if (str[0] == '$' && c_isdigit (str[1]))
{
for (k = 2; str[k] != '\0'; k += 1)
- if (!isdigit (str[k]) && str[k] != '_')
+ if (!c_isdigit (str[k]) && str[k] != '_')
return 0;
return 1;
}
@@ -5870,7 +5947,7 @@ is_valid_name_for_wild_match (const char *name0)
return 0;
for (i=0; decoded_name[i] != '\0'; i++)
- if (isalpha (decoded_name[i]) && !islower (decoded_name[i]))
+ if (c_isalpha (decoded_name[i]) && !c_islower (decoded_name[i]))
return 0;
return 1;
@@ -5981,7 +6058,7 @@ ada_add_block_symbols (std::vector<struct block_symbol> &result,
{
if (sym->matches (domain))
{
- if (sym->aclass () != LOC_UNRESOLVED)
+ if (sym->loc_class () != LOC_UNRESOLVED)
{
if (sym->is_argument ())
arg_sym = sym;
@@ -6030,7 +6107,7 @@ ada_add_block_symbols (std::vector<struct block_symbol> &result,
if (cmp == 0
&& is_name_suffix (sym->linkage_name () + name_len + 5))
{
- if (sym->aclass () != LOC_UNRESOLVED)
+ if (sym->loc_class () != LOC_UNRESOLVED)
{
if (sym->is_argument ())
arg_sym = sym;
@@ -6094,7 +6171,7 @@ ada_lookup_name_info::matches
angle bracket notation. */
const char *tmp;
- for (tmp = sym_name; *tmp != '\0' && !isupper (*tmp); tmp++);
+ for (tmp = sym_name; *tmp != '\0' && !c_isupper (*tmp); tmp++);
if (*tmp != '\0')
match = false;
}
@@ -6209,7 +6286,7 @@ ada_is_ignored_field (struct type *type, int field_num)
{
/* Wrapper field. */
}
- else if (isupper (name[0]))
+ else if (c_isupper (name[0]))
return 1;
}
@@ -6433,7 +6510,7 @@ ada_get_tsd_type (struct inferior *inf)
if (data->tsd_type == 0)
data->tsd_type
- = lookup_transparent_type ("<ada__tags__type_specific_data>",
+ = lookup_transparent_type ("ada.tags.type_specific_data",
SEARCH_TYPE_DOMAIN);
return data->tsd_type;
}
@@ -6720,14 +6797,14 @@ ada_scan_number (const char str[], int k, LONGEST * R, int *new_k)
{
ULONGEST RU;
- if (!isdigit (str[k]))
+ if (!c_isdigit (str[k]))
return 0;
/* Do it the hard way so as not to make any assumption about
the relationship of unsigned long (%lu scan format code) and
LONGEST. */
RU = 0;
- while (isdigit (str[k]))
+ while (c_isdigit (str[k]))
{
RU = RU * 10 + (str[k] - '0');
k += 1;
@@ -6901,7 +6978,7 @@ static int
find_struct_field (const char *name, struct type *type, int offset,
struct type **field_type_p,
int *byte_offset_p, int *bit_offset_p, int *bit_size_p,
- int *index_p)
+ LONGEST *index_p)
{
int i;
int parent_offset = -1;
@@ -7015,12 +7092,10 @@ find_struct_field (const char *name, struct type *type, int offset,
/* Number of user-visible fields in record type TYPE. */
-static int
+static LONGEST
num_visible_fields (struct type *type)
{
- int n;
-
- n = 0;
+ LONGEST n = 0;
find_struct_field (NULL, type, 0, NULL, NULL, NULL, NULL, &n);
return n;
}
@@ -7080,17 +7155,16 @@ ada_search_struct_field (const char *name, struct value *arg, int offset,
else if (ada_is_variant_part (type, i))
{
/* PNH: Do we ever get here? See find_struct_field. */
- int j;
struct type *field_type = ada_check_typedef (type->field (i).type ());
int var_offset = offset + type->field (i).loc_bitpos () / 8;
- for (j = 0; j < field_type->num_fields (); j += 1)
+ for (const auto &field : field_type->fields ())
{
- struct value *v = ada_search_struct_field /* Force line
- break. */
- (name, arg,
- var_offset + field_type->field (j).loc_bitpos () / 8,
- field_type->field (j).type ());
+ struct value *v
+ = (ada_search_struct_field
+ (name, arg,
+ var_offset + field.loc_bitpos () / 8,
+ field.type ()));
if (v != NULL)
return v;
@@ -7384,10 +7458,10 @@ field_alignment (struct type *type, int f)
len = strlen (name);
- if (!isdigit (name[len - 1]))
+ if (!c_isdigit (name[len - 1]))
return 1;
- if (isdigit (name[len - 2]))
+ if (c_isdigit (name[len - 2]))
align_offset = len - 2;
else
align_offset = len - 1;
@@ -8182,12 +8256,11 @@ ada_is_redundant_index_type_desc (struct type *array_type,
struct type *desc_type)
{
struct type *this_layer = check_typedef (array_type);
- int i;
- for (i = 0; i < desc_type->num_fields (); i++)
+ for (const auto &field : desc_type->fields ())
{
if (!ada_is_redundant_range_encoding (this_layer->index_type (),
- desc_type->field (i).type ()))
+ field.type ()))
return 0;
this_layer = check_typedef (this_layer->target_type ());
}
@@ -8784,9 +8857,9 @@ ada_atr_enum_val (struct expression *exp, enum noside noside, struct type *type,
error (_("'Enum_Val requires integral argument"));
LONGEST value = value_as_long (arg);
- for (int i = 0; i < type->num_fields (); ++i)
+ for (const auto &field : type->fields ())
{
- if (type->field (i).loc_enumval () == value)
+ if (field.loc_enumval () == value)
return value_from_longest (original_type, value);
}
@@ -8969,7 +9042,7 @@ ada_unqualify_enum_name (const char *name)
{
while ((tmp = strstr (name, "__")) != NULL)
{
- if (isdigit (tmp[2]))
+ if (c_isdigit (tmp[2]))
break;
else
name = tmp + 2;
@@ -9012,7 +9085,7 @@ ada_enum_name (const char *name)
else
return name;
- if (isascii (v) && isprint (v))
+ if (c_isascii (v) && c_isprint (v))
storage = string_printf ("'%c'", v);
else if (name[1] == 'U')
storage = string_printf ("'[\"%02x\"]'", v);
@@ -9540,12 +9613,12 @@ void
ada_name_association::assign (aggregate_assigner &assigner,
operation_up &op)
{
- int index;
+ LONGEST index;
if (ada_is_direct_array_type (assigner.lhs->type ()))
{
value *tem = m_val->evaluate (nullptr, assigner.exp, EVAL_NORMAL);
- index = longest_to_int (value_as_long (tem));
+ index = value_as_long (tem);
}
else
{
@@ -10046,14 +10119,19 @@ ada_unop_neg (struct type *expect_type,
return value_neg (arg1);
}
-/* A helper function for UNOP_IN_RANGE. */
+namespace expr
+{
+
+/* Implement UNOP_IN_RANGE. */
value *
-ada_unop_in_range (struct type *expect_type,
- struct expression *exp,
- enum noside noside, enum exp_opcode op,
- struct value *arg1, struct type *type)
+ada_unop_range_operation::evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside)
{
+ value *arg1 = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
+ struct type *type = std::get<1> (m_storage);
+
struct value *arg2, *arg3;
switch (type->code ())
{
@@ -10080,6 +10158,8 @@ ada_unop_in_range (struct type *expect_type,
}
}
+} /* namespace expr */
+
/* A helper function for OP_ATR_TAG. */
value *
@@ -10167,14 +10247,21 @@ ada_mult_binop (struct type *expect_type,
}
}
-/* A helper function for BINOP_EQUAL and BINOP_NOTEQUAL. */
+namespace expr
+{
+
+/* Implement BINOP_EQUAL and BINOP_NOTEQUAL. */
value *
-ada_equal_binop (struct type *expect_type,
- struct expression *exp,
- enum noside noside, enum exp_opcode op,
- struct value *arg1, struct value *arg2)
+ada_binop_equal_operation::evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside)
{
+ enum exp_opcode op = std::get<0> (m_storage);
+ value *arg1 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
+ value *arg2 = std::get<2> (m_storage)->evaluate (arg1->type (),
+ exp, noside);
+
int tem;
if (noside == EVAL_AVOID_SIDE_EFFECTS)
tem = 0;
@@ -10189,14 +10276,19 @@ ada_equal_binop (struct type *expect_type,
return value_from_longest (type, tem);
}
-/* A helper function for TERNOP_SLICE. */
+/* Implement TERNOP_SLICE. */
value *
-ada_ternop_slice (struct expression *exp,
- enum noside noside,
- struct value *array, struct value *low_bound_val,
- struct value *high_bound_val)
+ada_ternop_slice_operation::evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside)
{
+ value *array = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
+ value *low_bound_val
+ = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
+ value *high_bound_val
+ = std::get<2> (m_storage)->evaluate (nullptr, exp, noside);
+
LONGEST low_bound;
LONGEST high_bound;
@@ -10257,8 +10349,7 @@ ada_ternop_slice (struct expression *exp,
to_fixed_array_type (type0->target_type (), NULL, 1);
return ada_value_slice_from_ptr (array, arr_type0,
- longest_to_int (low_bound),
- longest_to_int (high_bound));
+ low_bound, high_bound);
}
}
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
@@ -10266,16 +10357,20 @@ ada_ternop_slice (struct expression *exp,
else if (high_bound < low_bound)
return empty_array (array->type (), low_bound, high_bound);
else
- return ada_value_slice (array, longest_to_int (low_bound),
- longest_to_int (high_bound));
+ return ada_value_slice (array, low_bound, high_bound);
}
-/* A helper function for BINOP_IN_BOUNDS. */
+/* Implement BINOP_IN_BOUNDS. */
value *
-ada_binop_in_bounds (struct expression *exp, enum noside noside,
- struct value *arg1, struct value *arg2, int n)
+ada_binop_in_bounds_operation::evaluate (struct type *expect_type,
+ struct expression *exp,
+ enum noside noside)
{
+ value *arg1 = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
+ value *arg2 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
+ int n = std::get<2> (m_storage);
+
if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
struct type *type = language_bool_type (exp->language_defn,
@@ -10300,6 +10395,8 @@ ada_binop_in_bounds (struct expression *exp, enum noside noside,
|| value_equal (arg2, arg1)));
}
+} /* namespace expr */
+
/* A helper function for some attribute operations. */
static value *
@@ -10502,7 +10599,6 @@ static LONGEST
convert_char_literal (struct type *type, LONGEST val)
{
char name[12];
- int f;
if (type == NULL)
return val;
@@ -10519,17 +10615,17 @@ convert_char_literal (struct type *type, LONGEST val)
else
xsnprintf (name, sizeof (name), "QWW%08lx", (unsigned long) val);
size_t len = strlen (name);
- for (f = 0; f < type->num_fields (); f += 1)
+ for (const auto &field : type->fields ())
{
/* Check the suffix because an enum constant in a package will
have a name like "pkg__QUxx". This is safe enough because we
already have the correct type, and because mangling means
there can't be clashes. */
- const char *ename = type->field (f).name ();
+ const char *ename = field.name ();
size_t elen = strlen (ename);
if (elen >= len && strcmp (name, ename + elen - len) == 0)
- return type->field (f).loc_enumval ();
+ return field.loc_enumval ();
}
return val;
}
@@ -11004,7 +11100,9 @@ ada_unop_ind_operation::evaluate (struct type *expect_type,
if (arrType == NULL)
error (_("Attempt to dereference null array pointer."));
- if (is_thick_pntr (type))
+ pointer_kind kind = categorize_pointer (type);
+ if (kind == pointer_kind::P_BOUNDS
+ || kind == pointer_kind::EXTENDED_ACCESS)
return arg1;
return value_at_lazy (arrType, 0);
}
@@ -11712,9 +11810,9 @@ ada_has_this_exception_support (const struct exception_support_info *einfo)
/* Make sure that the symbol we found corresponds to a function. */
- if (sym->aclass () != LOC_BLOCK)
+ if (sym->loc_class () != LOC_BLOCK)
error (_("Symbol \"%s\" is not a function (class = %d)"),
- sym->linkage_name (), sym->aclass ());
+ sym->linkage_name (), sym->loc_class ());
sym = standard_lookup (einfo->catch_handlers_sym, NULL,
SEARCH_FUNCTION_DOMAIN);
@@ -11734,9 +11832,9 @@ ada_has_this_exception_support (const struct exception_support_info *einfo)
/* Make sure that the symbol we found corresponds to a function. */
- if (sym->aclass () != LOC_BLOCK)
+ if (sym->loc_class () != LOC_BLOCK)
error (_("Symbol \"%s\" is not a function (class = %d)"),
- sym->linkage_name (), sym->aclass ());
+ sym->linkage_name (), sym->loc_class ());
return 1;
}
@@ -12536,7 +12634,7 @@ catch_ada_exception_command_split (const char *args,
args = skip_spaces (args);
if (startswith (args, "if")
- && (isspace (args[2]) || args[2] == '\0'))
+ && (c_isspace (args[2]) || args[2] == '\0'))
{
args += 2;
args = skip_spaces (args);
@@ -12691,7 +12789,7 @@ ada_exception_sal (enum ada_exception_catchpoint_kind ex)
throw_error (NOT_FOUND_ERROR, _("Catchpoint symbol not found: %s"),
sym_name);
- if (sym->aclass () != LOC_BLOCK)
+ if (sym->loc_class () != LOC_BLOCK)
error (_("Unable to insert catchpoint. %s is not a function."), sym_name);
return find_function_start_sal (sym, 1);
@@ -12813,7 +12911,7 @@ catch_ada_assert_command_split (const char *args, std::string &cond_string)
/* Check whether a condition was provided. */
if (startswith (args, "if")
- && (isspace (args[2]) || args[2] == '\0'))
+ && (c_isspace (args[2]) || args[2] == '\0'))
{
args += 2;
args = skip_spaces (args);
@@ -12857,10 +12955,10 @@ ada_is_exception_sym (struct symbol *sym)
{
const char *type_name = sym->type ()->name ();
- return (sym->aclass () != LOC_TYPEDEF
- && sym->aclass () != LOC_BLOCK
- && sym->aclass () != LOC_CONST
- && sym->aclass () != LOC_UNRESOLVED
+ return (sym->loc_class () != LOC_TYPEDEF
+ && sym->loc_class () != LOC_BLOCK
+ && sym->loc_class () != LOC_CONST
+ && sym->loc_class () != LOC_UNRESOLVED
&& type_name != NULL && strcmp (type_name, "exception") == 0);
}
@@ -12993,7 +13091,7 @@ ada_add_exceptions_from_frame (compiled_regex *preg,
{
for (struct symbol *sym : block_iterator_range (block))
{
- switch (sym->aclass ())
+ switch (sym->loc_class ())
{
case LOC_TYPEDEF:
case LOC_BLOCK:
@@ -13044,31 +13142,11 @@ ada_add_global_exceptions (compiled_regex *preg,
return preg == nullptr || preg->exec (name, 0, NULL, 0) == 0;
};
-
- /* In Ada, the symbol "search name" is a linkage name, whereas the
- regular expression used to do the matching refers to the natural
- name. So match against the decoded name. */
- expand_symtabs_matching (NULL,
- lookup_name_info::match_any (),
- [&] (const char *search_name)
- {
- std::string decoded = ada_decode (search_name);
- return name_matches_regex (decoded.c_str ());
- },
- NULL,
- SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
- SEARCH_VAR_DOMAIN,
- [&] (enum language lang)
- {
- /* Try to skip non-Ada CUs. */
- return lang == language_ada;
- });
-
/* Iterate over all objfiles irrespective of scope or linker namespaces
so we get all exceptions anywhere in the progspace. */
for (objfile *objfile : current_program_space->objfiles ())
{
- for (compunit_symtab *s : objfile->compunits ())
+ auto callback = [&] (compunit_symtab *s)
{
const struct blockvector *bv = s->blockvector ();
int i;
@@ -13087,7 +13165,30 @@ ada_add_global_exceptions (compiled_regex *preg,
exceptions->push_back (info);
}
}
- }
+
+ return true;
+ };
+
+ /* In Ada, the symbol "search name" is a linkage name, whereas
+ the regular expression used to do the matching refers to the
+ natural name. So match against the decoded name. */
+ auto any = lookup_name_info::match_any ();
+ objfile->search
+ (nullptr,
+ &any,
+ [&] (const char *search_name)
+ {
+ std::string decoded = ada_decode (search_name);
+ return name_matches_regex (decoded.c_str ());
+ },
+ callback,
+ SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
+ SEARCH_VAR_DOMAIN,
+ [&] (enum language lang)
+ {
+ /* Try to skip non-Ada CUs. */
+ return lang == language_ada;
+ });
}
}
@@ -13217,7 +13318,7 @@ do_full_match (const char *symbol_search_name,
&& symbol_search_name[1] == '_')
{
symbol_search_name += 2;
- while (isdigit (*symbol_search_name))
+ while (c_isdigit (*symbol_search_name))
++symbol_search_name;
if (symbol_search_name[0] == '_'
&& symbol_search_name[1] == '_')
@@ -13294,7 +13395,7 @@ ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name)
else
m_standard_p = false;
- m_decoded_name = ada_decode (m_encoded_name.c_str (), true, false, false);
+ m_decoded_name = ada_decode (m_encoded_name.c_str (), true, false);
/* If the name contains a ".", then the user is entering a fully
qualified entity name, and the match must not be done in wild
@@ -13595,20 +13696,12 @@ public:
const char *text, const char *word,
enum type_code code) const override
{
- const struct block *b, *surrounding_static_block = 0;
+ const struct block *surrounding_static_block = 0;
gdb_assert (code == TYPE_CODE_UNDEF);
lookup_name_info lookup_name (text, name_match_type, true);
- /* First, look at the partial symtab symbols. */
- expand_symtabs_matching (NULL,
- lookup_name,
- NULL,
- NULL,
- SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
- SEARCH_ALL_DOMAINS);
-
/* At this point scan through the misc symbol vectors and add each
symbol you find to the list. Eventually we want to ignore
anything that isn't a text symbol (everything else will be
@@ -13650,7 +13743,9 @@ public:
/* Search upwards from currently selected frame (so that we can
complete on local vars. */
- for (b = get_selected_block (0); b != NULL; b = b->superblock ())
+ for (const block *b = get_selected_block (0);
+ b != nullptr;
+ b = b->superblock ())
{
if (b->is_static_block ())
surrounding_static_block = b; /* For elmin of dups */
@@ -13672,43 +13767,36 @@ public:
for (objfile *objfile : current_program_space->objfiles ())
{
- for (compunit_symtab *s : objfile->compunits ())
+ auto callback = [&] (compunit_symtab *s)
{
QUIT;
- b = s->blockvector ()->global_block ();
- for (struct symbol *sym : block_iterator_range (b))
+ for (const block *b = s->blockvector ()->static_block ();
+ b != nullptr;
+ b = b->superblock ())
{
- if (completion_skip_symbol (mode, sym))
- continue;
+ /* Don't do this block twice. */
+ if (b == surrounding_static_block)
+ break;
- completion_list_add_name (tracker,
- sym->language (),
- sym->linkage_name (),
- lookup_name, text, word);
+ for (struct symbol *sym : block_iterator_range (b))
+ {
+ if (completion_skip_symbol (mode, sym))
+ continue;
+
+ completion_list_add_name (tracker,
+ sym->language (),
+ sym->linkage_name (),
+ lookup_name, text, word);
+ }
}
- }
- }
- for (objfile *objfile : current_program_space->objfiles ())
- {
- for (compunit_symtab *s : objfile->compunits ())
- {
- QUIT;
- b = s->blockvector ()->static_block ();
- /* Don't do this block twice. */
- if (b == surrounding_static_block)
- continue;
- for (struct symbol *sym : block_iterator_range (b))
- {
- if (completion_skip_symbol (mode, sym))
- continue;
+ return true;
+ };
- completion_list_add_name (tracker,
- sym->language (),
- sym->linkage_name (),
- lookup_name, text, word);
- }
- }
+ objfile->search
+ (nullptr, &lookup_name, nullptr, callback,
+ SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
+ SEARCH_ALL_DOMAINS);
}
}
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index c125fbc..5e08c3b 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -218,16 +218,13 @@ extern const char *ada_decode_symbol (const struct general_symbol_info *);
simply wrapped in <...>. If WRAP is false, then the empty string
will be returned.
- When OPERATORS is false, operator names will not be decoded. By
- default, they are decoded, e.g., 'Oadd' will be transformed to
- '"+"'.
-
- When WIDE is false, wide characters will be left as-is. By
- default, they converted from their hex encoding to the host
- charset. */
+ TRANSLATE has two effects. When true (the default), operator names
+ and wide characters will be decoded. E.g., 'Oadd' will be
+ transformed to '"+"', and wide characters converted from their hex
+ encoding to the host charset. When false, these will be left
+ alone. */
extern std::string ada_decode (const char *name, bool wrap = true,
- bool operators = true,
- bool wide = true);
+ bool translate = true);
extern std::vector<struct block_symbol> ada_lookup_symbol_list
(const char *, const struct block *, domain_search_flags);
diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l
index 0cfa0c8..eec80cf 100644
--- a/gdb/ada-lex.l
+++ b/gdb/ada-lex.l
@@ -335,7 +335,6 @@ false { return FALSEKEYWORD; }
. { error (_("Invalid character '%s' in expression."), yytext); }
%%
-#include <ctype.h>
/* Initialize the lexer for processing new expression. */
static void
@@ -355,7 +354,7 @@ canonicalizeNumeral (char *s1, const char *s2)
{
if (*s2 != '_')
{
- *s1 = tolower(*s2);
+ *s1 = c_tolower(*s2);
s1 += 1;
}
}
@@ -411,7 +410,7 @@ processInt (struct parser_state *par_state, const char *base0,
exp = strtol(exp0, (char **) NULL, 10);
gdb_mpz result;
- while (isxdigit (*num0))
+ while (c_isxdigit (*num0))
{
int dig = fromhex (*num0);
if (dig >= base)
@@ -527,7 +526,7 @@ processId (const char *name0, int len)
struct stoken result;
result.ptr = name;
- while (len > 0 && isspace (name0[len-1]))
+ while (len > 0 && c_isspace (name0[len-1]))
len -= 1;
if (name0[0] == '<' || strstr (name0, "___") != NULL)
@@ -549,12 +548,12 @@ processId (const char *name0, int len)
}
else if (in_quotes)
name[i++] = name0[i0++];
- else if (isalnum (name0[i0]))
+ else if (c_isalnum (name0[i0]))
{
- name[i] = tolower (name0[i0]);
+ name[i] = c_tolower (name0[i0]);
i += 1; i0 += 1;
}
- else if (isspace (name0[i0]))
+ else if (c_isspace (name0[i0]))
i0 += 1;
else if (name0[i0] == '\'')
{
@@ -634,10 +633,10 @@ find_dot_all (const char *str)
do
i += 1;
- while (isspace (str[i]));
+ while (c_isspace (str[i]));
if (strncasecmp (str + i, "all", 3) == 0
- && !isalnum (str[i + 3]) && str[i + 3] != '_')
+ && !c_isalnum (str[i + 3]) && str[i + 3] != '_')
return i0;
}
return -1;
@@ -653,7 +652,7 @@ subseqMatch (const char *subseq, const char *str)
return 1;
else if (str[0] == '\0')
return 0;
- else if (tolower (subseq[0]) == tolower (str[0]))
+ else if (c_tolower (subseq[0]) == c_tolower (str[0]))
return subseqMatch (subseq+1, str+1) || subseqMatch (subseq, str+1);
else
return subseqMatch (subseq, str+1);
@@ -690,7 +689,7 @@ processAttribute (const char *str)
{
gdb_assert (*str == '\'');
++str;
- while (isspace (*str))
+ while (c_isspace (*str))
++str;
int len = strlen (str);
@@ -749,7 +748,7 @@ static void
rewind_to_char (int ch)
{
pstate->lexptr -= yyleng;
- while (toupper (*pstate->lexptr) != toupper (ch))
+ while (c_toupper (*pstate->lexptr) != c_toupper (ch))
pstate->lexptr -= 1;
yyrestart (NULL);
}
diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
index defd828..5829a9b 100644
--- a/gdb/ada-typeprint.c
+++ b/gdb/ada-typeprint.c
@@ -23,7 +23,6 @@
#include "cli/cli-style.h"
#include "typeprint.h"
#include "ada-lang.h"
-#include <ctype.h>
static int print_selected_record_field_types (struct type *, struct type *,
int, int,
@@ -70,7 +69,7 @@ decoded_type_name (struct type *type)
if (s == name_buffer)
return name_buffer;
- if (!islower (s[1]))
+ if (!c_islower (s[1]))
return NULL;
for (s = q = name_buffer; *s != '\0'; q += 1)
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 7c6826e..c198fa5 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -17,7 +17,6 @@
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 <ctype.h>
#include "event-top.h"
#include "extract-store-integer.h"
#include "gdbtypes.h"
@@ -265,10 +264,10 @@ ada_emit_char (int c, struct type *type, struct ui_file *stream,
/* If this character fits in the normal ASCII range, and is
a printable character, then print the character as if it was
an ASCII character, even if this is a wide character.
- The UCHAR_MAX check is necessary because the isascii function
+ The UCHAR_MAX check is necessary because the c_isascii function
requires that its argument have a value of an unsigned char,
or EOF (EOF is obviously not printable). */
- if (c <= UCHAR_MAX && isascii (c) && isprint (c))
+ if (c <= UCHAR_MAX && c_isascii (c) && c_isprint (c))
{
if (c == quoter && c == '"')
gdb_printf (stream, "\"\"");
diff --git a/gdb/addrmap.c b/gdb/addrmap.c
index 4549350..2b333a1 100644
--- a/gdb/addrmap.c
+++ b/gdb/addrmap.c
@@ -201,10 +201,11 @@ xfree_wrapper (splay_tree_key key)
xfree ((void *) key);
}
-void
+bool
addrmap_mutable::set_empty (CORE_ADDR start, CORE_ADDR end_inclusive,
void *obj)
{
+ bool full_range = true;
splay_tree_node n, next;
void *prior_value;
@@ -234,7 +235,12 @@ addrmap_mutable::set_empty (CORE_ADDR start, CORE_ADDR end_inclusive,
n && addrmap_node_key (n) <= end_inclusive;
n = splay_tree_successor (addrmap_node_key (n)))
{
- if (! addrmap_node_value (n))
+ if (addrmap_node_value (n))
+ {
+ /* Already mapped. */
+ full_range = false;
+ }
+ else
addrmap_node_set_value (n, obj);
}
@@ -254,6 +260,8 @@ addrmap_mutable::set_empty (CORE_ADDR start, CORE_ADDR end_inclusive,
else
prior_value = addrmap_node_value (n);
}
+
+ return full_range;
}
@@ -433,7 +441,9 @@ test_addrmap ()
check_addrmap_find (map, array, 0, 19, nullptr);
/* Insert address range into mutable addrmap. */
- map.set_empty (core_addr (&array[10]), core_addr (&array[12]), val1);
+ bool full_range_p
+ = map.set_empty (core_addr (&array[10]), core_addr (&array[12]), val1);
+ SELF_CHECK (full_range_p);
check_addrmap_find (map, array, 0, 9, nullptr);
check_addrmap_find (map, array, 10, 12, val1);
check_addrmap_find (map, array, 13, 19, nullptr);
@@ -469,7 +479,9 @@ test_addrmap ()
check_addrmap_find (*map2, array, 14, 19, nullptr);
/* Insert partially overlapping address range into mutable addrmap. */
- map.set_empty (core_addr (&array[11]), core_addr (&array[13]), val2);
+ full_range_p
+ = map.set_empty (core_addr (&array[11]), core_addr (&array[13]), val2);
+ SELF_CHECK (!full_range_p);
check_addrmap_find (map, array, 0, 9, nullptr);
check_addrmap_find (map, array, 10, 12, val1);
check_addrmap_find (map, array, 13, 13, val2);
diff --git a/gdb/addrmap.h b/gdb/addrmap.h
index 179e1f8..398bdd8 100644
--- a/gdb/addrmap.h
+++ b/gdb/addrmap.h
@@ -152,7 +152,7 @@ public:
/* In the mutable address map MAP, associate the addresses from START
to END_INCLUSIVE that are currently associated with NULL with OBJ
instead. Addresses mapped to an object other than NULL are left
- unchanged.
+ unchanged. Return true if the full range is mapped to OBJ.
As the name suggests, END_INCLUSIVE is also mapped to OBJ. This
convention is unusual, but it allows callers to accurately specify
@@ -186,7 +186,7 @@ public:
semantics than to provide an interface which allows it to be
implemented efficiently, but doesn't reveal too much of the
representation. */
- void set_empty (CORE_ADDR start, CORE_ADDR end_inclusive,
+ bool set_empty (CORE_ADDR start, CORE_ADDR end_inclusive,
void *obj);
/* Clear this addrmap. */
diff --git a/gdb/alpha-netbsd-tdep.c b/gdb/alpha-netbsd-tdep.c
index 0f5e305..56143ee 100644
--- a/gdb/alpha-netbsd-tdep.c
+++ b/gdb/alpha-netbsd-tdep.c
@@ -261,7 +261,7 @@ alphanbsd_init_abi (struct gdbarch_info info,
/* NetBSD/alpha does not provide single step support via ptrace(2); we
must use software single-stepping. */
- set_gdbarch_software_single_step (gdbarch, alpha_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, alpha_software_single_step);
/* NetBSD/alpha has SVR4-style shared libraries. */
set_solib_svr4_ops (gdbarch, make_svr4_lp64_solib_ops);
diff --git a/gdb/alpha-obsd-tdep.c b/gdb/alpha-obsd-tdep.c
index 63f9050..a84dfa8 100644
--- a/gdb/alpha-obsd-tdep.c
+++ b/gdb/alpha-obsd-tdep.c
@@ -106,7 +106,7 @@ alphaobsd_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
/* OpenBSD/alpha 3.0 and earlier does not provide single step
support via ptrace(2); use software single-stepping for now. */
- set_gdbarch_software_single_step (gdbarch, alpha_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, alpha_software_single_step);
/* OpenBSD/alpha has SVR4-style shared libraries. */
set_solib_svr4_ops (gdbarch, make_svr4_lp64_solib_ops);
diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
index d655c13..59e0162 100644
--- a/gdb/alpha-tdep.c
+++ b/gdb/alpha-tdep.c
@@ -1797,7 +1797,7 @@ alpha_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_cannot_step_breakpoint (gdbarch, 1);
/* Handles single stepping of atomic sequences. */
- set_gdbarch_software_single_step (gdbarch, alpha_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, alpha_software_single_step);
/* Hook in ABI-specific overrides, if they have been registered. */
gdbarch_init_osabi (info, gdbarch);
diff --git a/gdb/amd-dbgapi-target.c b/gdb/amd-dbgapi-target.c
index a0210f4..666e404 100644
--- a/gdb/amd-dbgapi-target.c
+++ b/gdb/amd-dbgapi-target.c
@@ -345,15 +345,15 @@ static const registry<inferior>::key<amd_dbgapi_inferior_info>
/* Fetch the amd_dbgapi_inferior_info data for the given inferior. */
-static struct amd_dbgapi_inferior_info *
-get_amd_dbgapi_inferior_info (struct inferior *inferior)
+static amd_dbgapi_inferior_info &
+get_amd_dbgapi_inferior_info (inferior *inferior)
{
amd_dbgapi_inferior_info *info = amd_dbgapi_inferior_data.get (inferior);
if (info == nullptr)
info = amd_dbgapi_inferior_data.emplace (inferior, inferior);
- return info;
+ return *info;
}
/* The async event handler registered with the event loop, indicating that we
@@ -430,11 +430,11 @@ wave_coordinates::fetch ()
static wave_info &
get_thread_wave_info (thread_info *tp)
{
- amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (tp->inf);
+ amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (tp->inf);
amd_dbgapi_wave_id_t wave_id = get_amd_dbgapi_wave_id (tp->ptid);
- auto it = info->wave_info_map.find (wave_id.handle);
- gdb_assert (it != info->wave_info_map.end ());
+ auto it = info.wave_info_map.find (wave_id.handle);
+ gdb_assert (it != info.wave_info_map.end ());
return it->second;
}
@@ -495,10 +495,10 @@ require_forward_progress (ptid_t ptid, process_stratum_target *proc_target,
if (ptid != minus_one_ptid && inf->pid != ptid.pid ())
continue;
- amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (inf);
+ amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (inf);
- if (info->process_id != AMD_DBGAPI_PROCESS_NONE)
- require_forward_progress (*info, require);
+ if (info.process_id != AMD_DBGAPI_PROCESS_NONE)
+ require_forward_progress (info, require);
/* If ptid targets a single inferior and we have found it, no need to
continue. */
@@ -512,7 +512,7 @@ require_forward_progress (ptid_t ptid, process_stratum_target *proc_target,
amd_dbgapi_process_id_t
get_amd_dbgapi_process_id (inferior *inf)
{
- return get_amd_dbgapi_inferior_info (inf)->process_id;
+ return get_amd_dbgapi_inferior_info (inf).process_id;
}
/* A breakpoint dbgapi wants us to insert, to handle shared library
@@ -547,7 +547,7 @@ void
amd_dbgapi_target_breakpoint::check_status (struct bpstat *bs)
{
struct inferior *inf = current_inferior ();
- amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (inf);
+ amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (inf);
amd_dbgapi_status_t status;
bs->stop = 0;
@@ -555,13 +555,13 @@ amd_dbgapi_target_breakpoint::check_status (struct bpstat *bs)
/* Find the address the breakpoint is set at. */
auto match_breakpoint
- = [bs] (const decltype (info->breakpoint_map)::value_type &value)
+ = [bs] (const decltype (info.breakpoint_map)::value_type &value)
{ return value.second == bs->breakpoint_at; };
auto it
- = std::find_if (info->breakpoint_map.begin (), info->breakpoint_map.end (),
+ = std::find_if (info.breakpoint_map.begin (), info.breakpoint_map.end (),
match_breakpoint);
- if (it == info->breakpoint_map.end ())
+ if (it == info.breakpoint_map.end ())
error (_("Could not find breakpoint_id for breakpoint at %s"),
paddress (inf->arch (), bs->bp_location_at->address));
@@ -582,12 +582,12 @@ amd_dbgapi_target_breakpoint::check_status (struct bpstat *bs)
if (action == AMD_DBGAPI_BREAKPOINT_ACTION_RESUME)
return;
- require_forward_progress (*info, false);
+ require_forward_progress (info, false);
/* If the action is AMD_DBGAPI_BREAKPOINT_ACTION_HALT, we need to wait until
a breakpoint resume event for this breakpoint_id is seen. */
amd_dbgapi_event_id_t resume_event_id
- = process_event_queue (*info, AMD_DBGAPI_EVENT_KIND_BREAKPOINT_RESUME);
+ = process_event_queue (info, AMD_DBGAPI_EVENT_KIND_BREAKPOINT_RESUME);
/* We should always get a breakpoint_resume event after processing all
events generated by reporting the breakpoint hit. */
@@ -647,12 +647,12 @@ amd_dbgapi_target::pid_to_str (ptid_t ptid)
process_stratum_target *proc_target = current_inferior ()->process_target ();
inferior *inf = find_inferior_pid (proc_target, ptid.pid ());
gdb_assert (inf != nullptr);
- amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (inf);
+ const amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (inf);
auto wave_id = get_amd_dbgapi_wave_id (ptid);
- auto it = info->wave_info_map.find (wave_id.handle);
- if (it != info->wave_info_map.end ())
+ auto it = info.wave_info_map.find (wave_id.handle);
+ if (it != info.wave_info_map.end ())
return it->second.coords.to_string ();
/* A wave we don't know about. Shouldn't usually happen, but
@@ -908,7 +908,7 @@ amd_dbgapi_target::stop (ptid_t ptid)
if (m_report_thread_events)
{
- get_amd_dbgapi_inferior_info (thread->inf)->wave_events.emplace_back
+ get_amd_dbgapi_inferior_info (thread->inf).wave_events.emplace_back
(thread->ptid, target_waitstatus ().set_thread_exited (0));
if (target_is_async_p ())
@@ -976,18 +976,19 @@ private:
static void
dbgapi_notifier_handler (int err, gdb_client_data client_data)
{
- amd_dbgapi_inferior_info *info = (amd_dbgapi_inferior_info *) client_data;
+ amd_dbgapi_inferior_info &info
+ = *static_cast<amd_dbgapi_inferior_info *> (client_data);
int ret;
/* Drain the notifier pipe. */
do
{
char buf;
- ret = read (info->notifier, &buf, 1);
+ ret = read (info.notifier, &buf, 1);
}
while (ret >= 0 || (ret == -1 && errno == EINTR));
- if (info->inf->target_is_pushed (&the_amd_dbgapi_target))
+ if (info.inf->target_is_pushed (&the_amd_dbgapi_target))
{
/* The amd-dbgapi target is pushed: signal our async handler, the event
will be consumed through our wait method. */
@@ -1004,7 +1005,7 @@ dbgapi_notifier_handler (int err, gdb_client_data client_data)
amd_dbgapi_event_id_t event_id;
amd_dbgapi_event_kind_t event_kind;
amd_dbgapi_status_t status
- = amd_dbgapi_process_next_pending_event (info->process_id, &event_id,
+ = amd_dbgapi_process_next_pending_event (info.process_id, &event_id,
&event_kind);
if (status != AMD_DBGAPI_STATUS_SUCCESS)
error (_("next_pending_event failed (%s)"), get_status_string (status));
@@ -1028,17 +1029,17 @@ dbgapi_notifier_handler (int err, gdb_client_data client_data)
switch (runtime_state)
{
case AMD_DBGAPI_RUNTIME_STATE_LOADED_SUCCESS:
- gdb_assert (info->runtime_state == AMD_DBGAPI_RUNTIME_STATE_UNLOADED);
- info->runtime_state = runtime_state;
+ gdb_assert (info.runtime_state == AMD_DBGAPI_RUNTIME_STATE_UNLOADED);
+ info.runtime_state = runtime_state;
amd_dbgapi_debug_printf ("pushing amd-dbgapi target");
- info->inf->push_target (&the_amd_dbgapi_target);
+ info.inf->push_target (&the_amd_dbgapi_target);
/* The underlying target will already be async if we are running, but not if
we are attaching. */
- if (info->inf->process_target ()->is_async_p ())
+ if (info.inf->process_target ()->is_async_p ())
{
scoped_restore_current_thread restore_thread;
- switch_to_inferior_no_thread (info->inf);
+ switch_to_inferior_no_thread (info.inf);
/* Make sure our async event handler is created. */
target_async (true);
@@ -1046,14 +1047,14 @@ dbgapi_notifier_handler (int err, gdb_client_data client_data)
break;
case AMD_DBGAPI_RUNTIME_STATE_UNLOADED:
- gdb_assert (info->runtime_state
+ gdb_assert (info.runtime_state
== AMD_DBGAPI_RUNTIME_STATE_LOADED_ERROR_RESTRICTION);
- info->runtime_state = runtime_state;
+ info.runtime_state = runtime_state;
break;
case AMD_DBGAPI_RUNTIME_STATE_LOADED_ERROR_RESTRICTION:
- gdb_assert (info->runtime_state == AMD_DBGAPI_RUNTIME_STATE_UNLOADED);
- info->runtime_state = runtime_state;
+ gdb_assert (info.runtime_state == AMD_DBGAPI_RUNTIME_STATE_UNLOADED);
+ info.runtime_state = runtime_state;
warning (_("amd-dbgapi: unable to enable GPU debugging "
"due to a restriction error"));
break;
@@ -1082,10 +1083,10 @@ amd_dbgapi_target::async (bool enable)
for (inferior *inf : all_non_exited_inferiors (proc_target))
{
- amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (inf);
+ amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (inf);
- if (info->notifier != -1)
- add_file_handler (info->notifier, dbgapi_notifier_handler, info,
+ if (info.notifier != -1)
+ add_file_handler (info.notifier, dbgapi_notifier_handler, &info,
string_printf ("amd-dbgapi notifier for pid %d",
inf->pid));
}
@@ -1105,10 +1106,11 @@ amd_dbgapi_target::async (bool enable)
for (inferior *inf : all_inferiors ())
{
- amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (inf);
+ const amd_dbgapi_inferior_info &info
+ = get_amd_dbgapi_inferior_info (inf);
- if (info->notifier != -1)
- delete_file_handler (info->notifier);
+ if (info.notifier != -1)
+ delete_file_handler (info.notifier);
}
delete_async_event_handler (&amd_dbgapi_async_event_handler);
@@ -1132,11 +1134,11 @@ amd_dbgapi_thread_deleted (thread_info *tp)
if (tp->inf->target_at (arch_stratum) == &the_amd_dbgapi_target
&& ptid_is_gpu (tp->ptid))
{
- amd_dbgapi_inferior_info *info = amd_dbgapi_inferior_data.get (tp->inf);
+ amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (tp->inf);
auto wave_id = get_amd_dbgapi_wave_id (tp->ptid);
- auto it = info->wave_info_map.find (wave_id.handle);
- gdb_assert (it != info->wave_info_map.end ());
- info->wave_info_map.erase (it);
+ auto it = info.wave_info_map.find (wave_id.handle);
+ gdb_assert (it != info.wave_info_map.end ());
+ info.wave_info_map.erase (it);
}
}
@@ -1147,11 +1149,11 @@ static thread_info *
add_gpu_thread (inferior *inf, ptid_t wave_ptid)
{
process_stratum_target *proc_target = inf->process_target ();
- amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (inf);
+ amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (inf);
auto wave_id = get_amd_dbgapi_wave_id (wave_ptid);
- if (!info->wave_info_map.try_emplace (wave_id.handle,
+ if (!info.wave_info_map.try_emplace (wave_id.handle,
wave_info (wave_id)).second)
internal_error ("wave ID %ld already in map", wave_id.handle);
@@ -1399,13 +1401,13 @@ static std::pair<ptid_t, target_waitstatus>
consume_one_event (int pid)
{
auto *target = current_inferior ()->process_target ();
- struct amd_dbgapi_inferior_info *info = nullptr;
+ amd_dbgapi_inferior_info *info = nullptr;
if (pid == -1)
{
for (inferior *inf : all_inferiors (target))
{
- info = get_amd_dbgapi_inferior_info (inf);
+ info = &get_amd_dbgapi_inferior_info (inf);
if (!info->wave_events.empty ())
break;
}
@@ -1417,7 +1419,7 @@ consume_one_event (int pid)
inferior *inf = find_inferior_pid (target, pid);
gdb_assert (inf != nullptr);
- info = get_amd_dbgapi_inferior_info (inf);
+ info = &get_amd_dbgapi_inferior_info (inf);
}
if (info->wave_events.empty ())
@@ -1481,8 +1483,9 @@ amd_dbgapi_target::wait (ptid_t ptid, struct target_waitstatus *ws,
{
/* Drain the events for the current inferior from the amd_dbgapi and
preserve the ordering. */
- auto info = get_amd_dbgapi_inferior_info (current_inferior ());
- process_event_queue (*info);
+ amd_dbgapi_inferior_info &info
+ = get_amd_dbgapi_inferior_info (current_inferior ());
+ process_event_queue (info);
std::tie (event_ptid, gpu_waitstatus) = consume_one_event (ptid.pid ());
if (event_ptid == minus_one_ptid)
@@ -1504,7 +1507,7 @@ amd_dbgapi_target::wait (ptid_t ptid, struct target_waitstatus *ws,
for (inferior *inf : all_inferiors ())
if (inf->target_at (arch_stratum) == &the_amd_dbgapi_target
- && get_amd_dbgapi_inferior_info (inf)->runtime_state
+ && get_amd_dbgapi_inferior_info (inf).runtime_state
== AMD_DBGAPI_RUNTIME_STATE_LOADED_SUCCESS)
{
ws->set_ignore ();
@@ -1605,20 +1608,20 @@ attach_amd_dbgapi (inferior *inf)
if (inf->vfork_parent != nullptr)
return;
- auto *info = get_amd_dbgapi_inferior_info (inf);
+ amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (inf);
/* Are we already attached? */
- if (info->process_id != AMD_DBGAPI_PROCESS_NONE)
+ if (info.process_id != AMD_DBGAPI_PROCESS_NONE)
{
amd_dbgapi_debug_printf
- ("already attached: process_id = %" PRIu64, info->process_id.handle);
+ ("already attached: process_id = %" PRIu64, info.process_id.handle);
return;
}
amd_dbgapi_status_t status
= amd_dbgapi_process_attach
(reinterpret_cast<amd_dbgapi_client_process_id_t> (inf),
- &info->process_id);
+ &info.process_id);
if (status == AMD_DBGAPI_STATUS_ERROR_RESTRICTION)
{
warning (_("amd-dbgapi: unable to enable GPU debugging due to a "
@@ -1633,29 +1636,29 @@ attach_amd_dbgapi (inferior *inf)
return;
}
- if (amd_dbgapi_process_get_info (info->process_id,
+ if (amd_dbgapi_process_get_info (info.process_id,
AMD_DBGAPI_PROCESS_INFO_NOTIFIER,
- sizeof (info->notifier), &info->notifier)
+ sizeof (info.notifier), &info.notifier)
!= AMD_DBGAPI_STATUS_SUCCESS)
{
- amd_dbgapi_process_detach (info->process_id);
- info->process_id = AMD_DBGAPI_PROCESS_NONE;
+ amd_dbgapi_process_detach (info.process_id);
+ info.process_id = AMD_DBGAPI_PROCESS_NONE;
warning (_("amd-dbgapi: could not retrieve process %d's notifier, GPU "
"debugging will not be available."), inf->pid);
return;
}
amd_dbgapi_debug_printf ("process_id = %" PRIu64 ", notifier fd = %d",
- info->process_id.handle, info->notifier);
+ info.process_id.handle, info.notifier);
- set_process_memory_precision (*info);
+ set_process_memory_precision (info);
/* If GDB is attaching to a process that has the runtime loaded, there will
already be a "runtime loaded" event available. Consume it and push the
target. */
- dbgapi_notifier_handler (0, info);
+ dbgapi_notifier_handler (0, &info);
- add_file_handler (info->notifier, dbgapi_notifier_handler, info,
+ add_file_handler (info.notifier, dbgapi_notifier_handler, &info,
"amd-dbgapi notifier");
}
@@ -1672,30 +1675,30 @@ detach_amd_dbgapi (inferior *inf)
{
AMD_DBGAPI_SCOPED_DEBUG_START_END ("inf num = %d", inf->num);
- auto *info = get_amd_dbgapi_inferior_info (inf);
+ amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (inf);
- if (info->process_id == AMD_DBGAPI_PROCESS_NONE)
+ if (info.process_id == AMD_DBGAPI_PROCESS_NONE)
return;
- info->runtime_state = AMD_DBGAPI_RUNTIME_STATE_UNLOADED;
+ info.runtime_state = AMD_DBGAPI_RUNTIME_STATE_UNLOADED;
- amd_dbgapi_status_t status = amd_dbgapi_process_detach (info->process_id);
+ amd_dbgapi_status_t status = amd_dbgapi_process_detach (info.process_id);
if (status != AMD_DBGAPI_STATUS_SUCCESS)
warning (_("amd-dbgapi: could not detach from process %d (%s)"),
inf->pid, get_status_string (status));
- gdb_assert (info->notifier != -1);
- delete_file_handler (info->notifier);
+ gdb_assert (info.notifier != -1);
+ delete_file_handler (info.notifier);
/* This is a noop if the target is not pushed. */
inf->unpush_target (&the_amd_dbgapi_target);
/* Delete the breakpoints that are still active. */
- for (auto &&value : info->breakpoint_map)
+ for (auto &&value : info.breakpoint_map)
delete_breakpoint (value.second);
/* Reset the amd_dbgapi_inferior_info, except for precise_memory_mode. */
- *info = amd_dbgapi_inferior_info (inf, info->precise_memory.requested);
+ info = amd_dbgapi_inferior_info (inf, info.precise_memory.requested);
maybe_reset_amd_dbgapi ();
}
@@ -1971,10 +1974,10 @@ amd_dbgapi_target::displaced_step_prepare (thread_info *thread,
}
/* Save the displaced stepping id in the per-inferior info. */
- amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (thread->inf);
+ amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (thread->inf);
bool inserted
- = info->stepping_id_map.emplace (thread, stepping_id.handle).second;
+ = info.stepping_id_map.emplace (thread, stepping_id.handle).second;
gdb_assert (inserted);
/* Get the new (displaced) PC. */
@@ -2006,8 +2009,8 @@ amd_dbgapi_target::displaced_step_finish (thread_info *thread,
gdb_assert (thread->displaced_step_state.in_progress ());
/* Find the displaced stepping id for this thread. */
- amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (thread->inf);
- auto entry = info->stepping_id_map.extract (thread);
+ amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (thread->inf);
+ auto entry = info.stepping_id_map.extract (thread);
gdb_assert (entry.has_value ());
amd_dbgapi_displaced_stepping_id_t stepping_id {entry->second};
@@ -2064,14 +2067,16 @@ static void
amd_dbgapi_target_inferior_cloned (inferior *original_inferior,
inferior *new_inferior)
{
- auto *orig_info = get_amd_dbgapi_inferior_info (original_inferior);
- auto *new_info = get_amd_dbgapi_inferior_info (new_inferior);
+ const amd_dbgapi_inferior_info &orig_info
+ = get_amd_dbgapi_inferior_info (original_inferior);
+ amd_dbgapi_inferior_info &new_info
+ = get_amd_dbgapi_inferior_info (new_inferior);
/* At this point, the process is not started. Therefore it is sufficient to
copy the precise memory request, it will be applied when the process
starts. */
- gdb_assert (new_info->process_id == AMD_DBGAPI_PROCESS_NONE);
- new_info->precise_memory.requested = orig_info->precise_memory.requested;
+ gdb_assert (new_info.process_id == AMD_DBGAPI_PROCESS_NONE);
+ new_info.precise_memory.requested = orig_info.precise_memory.requested;
}
/* inferior_execd observer. */
@@ -2087,8 +2092,8 @@ amd_dbgapi_inferior_execd (inferior *exec_inf, inferior *follow_inf)
/* If using "follow-exec-mode new", carry over the precise-memory setting
to the new inferior (otherwise, FOLLOW_INF and ORIG_INF point to the same
inferior, so this is a no-op). */
- get_amd_dbgapi_inferior_info (follow_inf)->precise_memory.requested
- = get_amd_dbgapi_inferior_info (exec_inf)->precise_memory.requested;
+ get_amd_dbgapi_inferior_info (follow_inf).precise_memory.requested
+ = get_amd_dbgapi_inferior_info (exec_inf).precise_memory.requested;
attach_amd_dbgapi (follow_inf);
}
@@ -2102,12 +2107,12 @@ amd_dbgapi_inferior_forked (inferior *parent_inf, inferior *child_inf,
if (child_inf != nullptr)
{
/* Copy precise-memory requested value from parent to child. */
- amd_dbgapi_inferior_info *parent_info
+ const amd_dbgapi_inferior_info &parent_info
= get_amd_dbgapi_inferior_info (parent_inf);
- amd_dbgapi_inferior_info *child_info
+ amd_dbgapi_inferior_info &child_info
= get_amd_dbgapi_inferior_info (child_inf);
- child_info->precise_memory.requested
- = parent_info->precise_memory.requested;
+ child_info.precise_memory.requested
+ = parent_info.precise_memory.requested;
if (fork_kind != TARGET_WAITKIND_VFORKED)
{
@@ -2181,10 +2186,10 @@ amd_dbgapi_insert_breakpoint_callback
amd_dbgapi_breakpoint_id_t breakpoint_id)
{
inferior *inf = reinterpret_cast<inferior *> (client_process_id);
- struct amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (inf);
+ amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (inf);
- auto it = info->breakpoint_map.find (breakpoint_id.handle);
- if (it != info->breakpoint_map.end ())
+ auto it = info.breakpoint_map.find (breakpoint_id.handle);
+ if (it != info.breakpoint_map.end ())
return AMD_DBGAPI_STATUS_ERROR_INVALID_BREAKPOINT_ID;
/* We need to find the address in the given inferior's program space. */
@@ -2201,7 +2206,7 @@ amd_dbgapi_insert_breakpoint_callback
breakpoint *bp = install_breakpoint (true, std::move (bp_up), 1);
- info->breakpoint_map.emplace (breakpoint_id.handle, bp);
+ info.breakpoint_map.emplace (breakpoint_id.handle, bp);
return AMD_DBGAPI_STATUS_SUCCESS;
}
@@ -2213,14 +2218,14 @@ amd_dbgapi_remove_breakpoint_callback
amd_dbgapi_breakpoint_id_t breakpoint_id)
{
inferior *inf = reinterpret_cast<inferior *> (client_process_id);
- struct amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (inf);
+ amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (inf);
- auto it = info->breakpoint_map.find (breakpoint_id.handle);
- if (it == info->breakpoint_map.end ())
+ auto it = info.breakpoint_map.find (breakpoint_id.handle);
+ if (it == info.breakpoint_map.end ())
return AMD_DBGAPI_STATUS_ERROR_INVALID_BREAKPOINT_ID;
delete_breakpoint (it->second);
- info->breakpoint_map.erase (it);
+ info.breakpoint_map.erase (it);
return AMD_DBGAPI_STATUS_SUCCESS;
}
@@ -2274,10 +2279,10 @@ amd_dbgapi_xfer_global_memory_callback
static void
amd_dbgapi_target_signal_received (gdb_signal sig)
{
- amd_dbgapi_inferior_info *info
+ const amd_dbgapi_inferior_info &info
= get_amd_dbgapi_inferior_info (current_inferior ());
- if (info->process_id == AMD_DBGAPI_PROCESS_NONE)
+ if (info.process_id == AMD_DBGAPI_PROCESS_NONE)
return;
if (!ptid_is_gpu (inferior_thread ()->ptid))
@@ -2286,7 +2291,7 @@ amd_dbgapi_target_signal_received (gdb_signal sig)
if (sig != GDB_SIGNAL_SEGV && sig != GDB_SIGNAL_BUS)
return;
- if (!info->precise_memory.enabled)
+ if (!info.precise_memory.enabled)
gdb_printf (_("\
Warning: precise memory violation signal reporting is not enabled, reported\n\
location may not be accurate. See \"show amdgpu precise-memory\".\n"));
@@ -2367,14 +2372,14 @@ static void
show_precise_memory_mode (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
- amd_dbgapi_inferior_info *info
+ const amd_dbgapi_inferior_info &info
= get_amd_dbgapi_inferior_info (current_inferior ());
gdb_printf (file,
_("AMDGPU precise memory access reporting is %s "
"(currently %s).\n"),
- info->precise_memory.requested ? "on" : "off",
- info->precise_memory.enabled ? "enabled" : "disabled");
+ info.precise_memory.requested ? "on" : "off",
+ info.precise_memory.enabled ? "enabled" : "disabled");
}
/* Callback for "set amdgpu precise-memory". */
@@ -2382,13 +2387,13 @@ show_precise_memory_mode (struct ui_file *file, int from_tty,
static void
set_precise_memory_mode (bool value)
{
- amd_dbgapi_inferior_info *info
+ amd_dbgapi_inferior_info &info
= get_amd_dbgapi_inferior_info (current_inferior ());
- info->precise_memory.requested = value;
+ info.precise_memory.requested = value;
- if (info->process_id != AMD_DBGAPI_PROCESS_NONE)
- set_process_memory_precision (*info);
+ if (info.process_id != AMD_DBGAPI_PROCESS_NONE)
+ set_process_memory_precision (info);
}
/* Return whether precise-memory is requested for the current inferior. */
@@ -2396,10 +2401,10 @@ set_precise_memory_mode (bool value)
static bool
get_precise_memory_mode ()
{
- amd_dbgapi_inferior_info *info
+ const amd_dbgapi_inferior_info &info
= get_amd_dbgapi_inferior_info (current_inferior ());
- return info->precise_memory.requested;
+ return info.precise_memory.requested;
}
/* List of set/show amdgpu commands. */
@@ -2472,9 +2477,9 @@ maybe_reset_amd_dbgapi ()
{
for (inferior *inf : all_non_exited_inferiors ())
{
- amd_dbgapi_inferior_info *info = get_amd_dbgapi_inferior_info (inf);
+ const amd_dbgapi_inferior_info &info = get_amd_dbgapi_inferior_info (inf);
- if (info->process_id != AMD_DBGAPI_PROCESS_NONE)
+ if (info.process_id != AMD_DBGAPI_PROCESS_NONE)
return;
}
diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
index dbb9b32..4b23fd9 100644
--- a/gdb/amd64-linux-nat.c
+++ b/gdb/amd64-linux-nat.c
@@ -32,6 +32,7 @@
#include "amd64-tdep.h"
#include "amd64-linux-tdep.h"
#include "i386-linux-tdep.h"
+#include "x86-tdep.h"
#include "gdbsupport/x86-xstate.h"
#include "x86-linux-nat.h"
@@ -86,6 +87,8 @@ static int amd64_linux_gregset32_reg_offset[] =
-1, -1, -1, -1, -1, -1, -1, -1, /* k0 ... k7 (AVX512) */
-1, -1, -1, -1, -1, -1, -1, -1, /* zmm0 ... zmm7 (AVX512) */
-1, /* PKEYS register PKRU */
+ -1, /* SSP register. */
+ -1, -1, /* fs/gs base registers. */
ORIG_RAX * 8 /* "orig_eax" */
};
@@ -237,6 +240,14 @@ amd64_linux_nat_target::fetch_registers (struct regcache *regcache, int regnum)
if (have_ptrace_getregset == TRIBOOL_TRUE)
{
+ if ((regnum == -1 && tdep->ssp_regnum != -1)
+ || (regnum != -1 && regnum == tdep->ssp_regnum))
+ {
+ x86_linux_fetch_ssp (regcache, tid);
+ if (regnum != -1)
+ return;
+ }
+
/* 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
@@ -302,6 +313,14 @@ amd64_linux_nat_target::store_registers (struct regcache *regcache, int regnum)
if (have_ptrace_getregset == TRIBOOL_TRUE)
{
gdb::byte_vector xstateregs (tdep->xsave_layout.sizeof_xsave);
+ if ((regnum == -1 && tdep->ssp_regnum != -1)
+ || (regnum != -1 && regnum == tdep->ssp_regnum))
+ {
+ x86_linux_store_ssp (regcache, tid);
+ if (regnum != -1)
+ return;
+ }
+
struct iovec iov;
iov.iov_base = xstateregs.data ();
diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index ce62a42..a21f8a9 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -47,6 +47,9 @@
#include "expop.h"
#include "arch/amd64-linux-tdesc.h"
#include "inferior.h"
+#include "x86-tdep.h"
+#include "dwarf2/frame.h"
+#include "frame-unwind.h"
/* The syscall's XML filename for i386. */
#define XML_SYSCALL_FILENAME_AMD64 "syscalls/amd64-linux.xml"
@@ -108,6 +111,7 @@ int amd64_linux_gregset_reg_offset[] =
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, /* PKEYS register pkru */
+ -1, /* CET user mode register PL3_SSP. */
/* End of hardware registers */
21 * 8, 22 * 8, /* fs_base and gs_base. */
@@ -1592,6 +1596,15 @@ amd64_linux_record_signal (struct gdbarch *gdbarch,
return 0;
}
+/* Return true if the core file ABFD contains shadow stack pointer state.
+ Otherwise, return false. */
+
+static bool
+amd64_linux_core_read_ssp_state_p (bfd *abfd)
+{
+ return bfd_get_section_by_name (abfd, ".reg-ssp") != nullptr;
+}
+
/* Get Linux/x86 target description from core dump. */
static const struct target_desc *
@@ -1601,11 +1614,14 @@ amd64_linux_core_read_description (struct gdbarch *gdbarch,
{
/* Linux/x86-64. */
x86_xsave_layout layout;
- uint64_t xcr0 = i386_linux_core_read_xsave_info (abfd, layout);
- if (xcr0 == 0)
- xcr0 = X86_XSTATE_SSE_MASK;
+ uint64_t xstate_bv = i386_linux_core_read_xsave_info (abfd, layout);
+ if (xstate_bv == 0)
+ xstate_bv = X86_XSTATE_SSE_MASK;
- return amd64_linux_read_description (xcr0 & X86_XSTATE_ALL_MASK,
+ if (amd64_linux_core_read_ssp_state_p (abfd))
+ xstate_bv |= X86_XSTATE_CET_U;
+
+ return amd64_linux_read_description (xstate_bv & X86_XSTATE_ALL_MASK,
gdbarch_ptr_bit (gdbarch) == 32);
}
@@ -1636,6 +1652,37 @@ static const struct regset amd64_linux_xstateregset =
amd64_linux_collect_xstateregset
};
+/* Supply shadow stack pointer register from SSP to the register cache
+ REGCACHE. */
+
+static void
+amd64_linux_supply_ssp (const regset *regset,
+ regcache *regcache, int regnum,
+ const void *ssp, size_t len)
+{
+ gdb_assert (len == sizeof (uint64_t));
+ x86_supply_ssp (regcache, *static_cast<const uint64_t *> (ssp));
+}
+
+/* Collect the shadow stack pointer register from the register cache
+ REGCACHE and store it in SSP. */
+
+static void
+amd64_linux_collect_ssp (const regset *regset,
+ const regcache *regcache, int regnum,
+ void *ssp, size_t len)
+{
+ gdb_assert (len == sizeof (uint64_t));
+ x86_collect_ssp (regcache, *static_cast<uint64_t *> (ssp));
+}
+
+/* Shadow stack pointer register. */
+
+static const struct regset amd64_linux_ssp_register
+ {
+ NULL, amd64_linux_supply_ssp, amd64_linux_collect_ssp
+ };
+
/* Iterate over core file register note sections. */
static void
@@ -1652,6 +1699,14 @@ amd64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
cb (".reg-xstate", tdep->xsave_layout.sizeof_xsave,
tdep->xsave_layout.sizeof_xsave, &amd64_linux_xstateregset,
"XSAVE extended state", cb_data);
+
+ /* SSP can be unavailable. Thus, we need to check the register status
+ in case we write a core file (regcache != nullptr). */
+ if (tdep->ssp_regnum != -1
+ && (regcache == nullptr
+ || REG_VALID == regcache->get_register_status (tdep->ssp_regnum)))
+ cb (".reg-ssp", 8, 8, &amd64_linux_ssp_register,
+ "shadow stack pointer", cb_data);
}
/* The instruction sequences used in x86_64 machines for a
@@ -1868,6 +1923,162 @@ amd64_linux_get_tls_dtv_addr (struct gdbarch *gdbarch, ptid_t ptid,
return dtv_addr;
}
+/* Return the number of bytes required to update the shadow stack pointer
+ by one element. For x32 the shadow stack elements are still 64-bit
+ aligned. Thus, gdbarch_addr_bit cannot be used to compute the new
+ stack pointer. */
+
+static inline int
+amd64_linux_shadow_stack_element_size_aligned (gdbarch *gdbarch)
+{
+ const bfd_arch_info *binfo = gdbarch_bfd_arch_info (gdbarch);
+ return (binfo->bits_per_word / binfo->bits_per_byte);
+}
+
+/* Read the shadow stack pointer register and return its value, if
+ possible. */
+
+static std::optional<CORE_ADDR>
+amd64_linux_get_shadow_stack_pointer (gdbarch *gdbarch, regcache *regcache,
+ bool &shadow_stack_enabled)
+{
+ shadow_stack_enabled = false;
+ const i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+
+ if (tdep->ssp_regnum < 0)
+ return {};
+
+ CORE_ADDR ssp;
+ if (regcache_raw_read_unsigned (regcache, tdep->ssp_regnum, &ssp)
+ != REG_VALID)
+ return {};
+
+ /* Dependent on the target in case the shadow stack pointer is
+ unavailable, the ssp register can be invalid or 0x0 when shadow stack
+ is supported by HW and the linux kernel but not enabled for the
+ current thread. */
+ if (ssp == 0x0)
+ return {};
+
+ /* In case there is a shadow stack pointer available which is non-null,
+ the shadow stack feature is enabled. */
+ shadow_stack_enabled = true;
+ return ssp;
+}
+
+/* If shadow stack is enabled, push the address NEW_ADDR to the shadow
+ stack and increment the shadow stack pointer accordingly. */
+
+static void
+amd64_linux_shadow_stack_push (gdbarch *gdbarch, CORE_ADDR new_addr,
+ regcache *regcache)
+{
+ bool shadow_stack_enabled;
+ std::optional<CORE_ADDR> ssp
+ = amd64_linux_get_shadow_stack_pointer (gdbarch, regcache,
+ shadow_stack_enabled);
+
+ /* For amd64/Linux, if SSP has a value that means shadow stack is
+ enabled. */
+ if (!ssp.has_value ())
+ return;
+ else
+ gdb_assert (shadow_stack_enabled);
+
+ /* The shadow stack grows downwards. To push addresses to the stack,
+ we need to decrement SSP. */
+ const int element_size
+ = amd64_linux_shadow_stack_element_size_aligned (gdbarch);
+ const CORE_ADDR new_ssp = *ssp - element_size;
+
+ /* Using /proc/PID/smaps we can only check if NEW_SSP points to shadow
+ stack memory. If it doesn't, we assume the stack is full. */
+ std::pair<CORE_ADDR, CORE_ADDR> memrange;
+ if (!linux_address_in_shadow_stack_mem_range (new_ssp, &memrange))
+ error (_("No space left on the shadow stack."));
+
+ /* On x86 there can be a shadow stack token at bit 63. For x32, the
+ address size is only 32 bit. Always write back the full 8 bytes to
+ include the shadow stack token. */
+ const bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ write_memory_unsigned_integer (new_ssp, element_size, byte_order,
+ (ULONGEST) new_addr);
+
+ i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+ gdb_assert (tdep->ssp_regnum > -1);
+
+ regcache_raw_write_unsigned (regcache, tdep->ssp_regnum, new_ssp);
+}
+
+/* Implement shadow stack pointer unwinding. For each new shadow stack
+ pointer check if its address is still in the shadow stack memory range.
+ If it's outside the range set the returned value to unavailable,
+ otherwise return a value containing the new shadow stack pointer. */
+
+static value *
+amd64_linux_dwarf2_prev_ssp (const frame_info_ptr &this_frame,
+ void **this_cache, int regnum)
+{
+ value *v = frame_unwind_got_register (this_frame, regnum, regnum);
+ gdb_assert (v != nullptr);
+
+ gdbarch *gdbarch = get_frame_arch (this_frame);
+
+ if (v->entirely_available () && !v->optimized_out ())
+ {
+ int size = register_size (gdbarch, regnum);
+ bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ CORE_ADDR ssp = extract_unsigned_integer (v->contents_all ().data (),
+ size, byte_order);
+
+ /* Using /proc/PID/smaps we can only check if the current shadow
+ stack pointer SSP points to shadow stack memory. Only if this is
+ the case a valid previous shadow stack pointer can be
+ calculated. */
+ std::pair<CORE_ADDR, CORE_ADDR> range;
+ if (linux_address_in_shadow_stack_mem_range (ssp, &range))
+ {
+ /* The shadow stack grows downwards. To compute the previous
+ shadow stack pointer, we need to increment SSP. */
+ CORE_ADDR new_ssp
+ = ssp + amd64_linux_shadow_stack_element_size_aligned (gdbarch);
+
+ /* There can be scenarios where we have a shadow stack pointer
+ but the shadow stack is empty, as no call instruction has
+ been executed yet. If NEW_SSP points to the end of or before
+ (<=) the current shadow stack memory range we consider
+ NEW_SSP as valid (but empty). */
+ if (new_ssp <= range.second)
+ return frame_unwind_got_address (this_frame, regnum, new_ssp);
+ }
+ }
+
+ /* Return a value which is marked as unavailable in case we could not
+ calculate a valid previous shadow stack pointer. */
+ value *retval
+ = value::allocate_register (get_next_frame_sentinel_okay (this_frame),
+ regnum, register_type (gdbarch, regnum));
+ retval->mark_bytes_unavailable (0, retval->type ()->length ());
+ return retval;
+}
+
+/* Implement the "init_reg" dwarf2_frame_ops method. */
+
+static void
+amd64_init_reg (gdbarch *gdbarch, int regnum, dwarf2_frame_state_reg *reg,
+ const frame_info_ptr &this_frame)
+{
+ if (regnum == gdbarch_pc_regnum (gdbarch))
+ reg->how = DWARF2_FRAME_REG_RA;
+ else if (regnum == gdbarch_sp_regnum (gdbarch))
+ reg->how = DWARF2_FRAME_REG_CFA;
+ else if (regnum == AMD64_PL3_SSP_REGNUM)
+ {
+ reg->how = DWARF2_FRAME_REG_FN;
+ reg->loc.fn = amd64_linux_dwarf2_prev_ssp;
+ }
+}
+
static void
amd64_linux_init_abi_common (struct gdbarch_info info, struct gdbarch *gdbarch,
int num_disp_step_buffers)
@@ -1925,6 +2136,11 @@ amd64_linux_init_abi_common (struct gdbarch_info info, struct gdbarch *gdbarch,
set_gdbarch_remove_non_address_bits_watchpoint
(gdbarch, amd64_linux_remove_non_address_bits_watchpoint);
+
+ set_gdbarch_shadow_stack_push (gdbarch, amd64_linux_shadow_stack_push);
+ set_gdbarch_get_shadow_stack_pointer (gdbarch,
+ amd64_linux_get_shadow_stack_pointer);
+ dwarf2_frame_set_init_reg (gdbarch, amd64_init_reg);
}
static void
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 82dd1e0..9245889 100644..100755
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -513,20 +513,19 @@ amd64_has_unaligned_fields (struct type *type)
if (type->code () == TYPE_CODE_STRUCT
|| type->code () == TYPE_CODE_UNION)
{
- for (int i = 0; i < type->num_fields (); i++)
+ for (const auto &field : type->fields ())
{
- struct type *subtype = check_typedef (type->field (i).type ());
+ struct type *subtype = check_typedef (field.type ());
/* Ignore static fields, empty fields (for example nested
empty structures), and bitfields (these are handled by
the caller). */
- if (type->field (i).is_static ()
- || (type->field (i).bitsize () == 0
- && subtype->length () == 0)
- || type->field (i).is_packed ())
+ if (field.is_static ()
+ || (field.bitsize () == 0 && subtype->length () == 0)
+ || field.is_packed ())
continue;
- int bitpos = type->field (i).loc_bitpos ();
+ int bitpos = field.loc_bitpos ();
if (bitpos % 8 != 0)
return true;
@@ -1182,6 +1181,15 @@ vex3_prefix_p (gdb_byte pfx)
return pfx == 0xc4;
}
+/* True if PFX is the start of an XOP prefix. */
+
+static bool
+xop_prefix_p (const gdb_byte *pfx)
+{
+ gdb_byte m = pfx[1] & 0x1f;
+ return pfx[0] == 0x8f && m >= 8;
+}
+
/* Return true if PFX is the start of the 4-byte EVEX prefix. */
static bool
@@ -1352,7 +1360,7 @@ amd64_get_insn_details (gdb_byte *insn, struct amd64_insn *details)
details->enc_prefix_offset = insn - start;
insn += 2;
}
- else if (vex3_prefix_p (*insn))
+ else if (vex3_prefix_p (*insn) || xop_prefix_p (insn))
{
details->enc_prefix_offset = insn - start;
insn += 3;
@@ -1384,13 +1392,12 @@ amd64_get_insn_details (gdb_byte *insn, struct amd64_insn *details)
}
else if (prefix != nullptr && vex2_prefix_p (*prefix))
{
- need_modrm = twobyte_has_modrm[*insn];
+ /* All VEX2 instructions need ModR/M, except vzeroupper/vzeroall. */
+ need_modrm = *insn != 0x77 ? 1 : 0;
details->opcode_len = 2;
}
else if (prefix != nullptr && vex3_prefix_p (*prefix))
{
- need_modrm = twobyte_has_modrm[*insn];
-
gdb_byte m = prefix[1] & 0x1f;
if (m == 0)
{
@@ -1399,12 +1406,16 @@ amd64_get_insn_details (gdb_byte *insn, struct amd64_insn *details)
}
else if (m == 1)
{
- /* Escape 0x0f. */
+ /* Escape 0x0f. All VEX3 instructions in this map need ModR/M,
+ except vzeroupper/vzeroall. */
+ need_modrm = *insn != 0x77 ? 1 : 0;
details->opcode_len = 2;
}
else if (m == 2 || m == 3)
{
- /* Escape 0x0f 0x38 or 0x0f 0x3a. */
+ /* Escape 0x0f 0x38 or 0x0f 0x3a. All VEX3 instructions in
+ this map need ModR/M. */
+ need_modrm = 1;
details->opcode_len = 3;
}
else if (m == 7)
@@ -1420,7 +1431,8 @@ amd64_get_insn_details (gdb_byte *insn, struct amd64_insn *details)
}
else if (prefix != nullptr && evex_prefix_p (*prefix))
{
- need_modrm = twobyte_has_modrm[*insn];
+ /* All EVEX instructions need ModR/M. */
+ need_modrm = 1;
gdb_byte m = prefix[1] & 0x7;
if (m == 1)
@@ -1439,6 +1451,11 @@ amd64_get_insn_details (gdb_byte *insn, struct amd64_insn *details)
return;
}
}
+ else if (prefix != nullptr && xop_prefix_p (prefix))
+ {
+ details->opcode_len = 1;
+ need_modrm = 1;
+ }
else if (*insn == TWO_BYTE_OPCODE_ESCAPE)
{
/* Two or three-byte opcode. */
@@ -1509,7 +1526,7 @@ fixup_riprel (const struct amd64_insn &details, gdb_byte *insn,
{
/* VEX.!B is set implicitly. */
}
- else if (vex3_prefix_p (pfx[0]))
+ else if (vex3_prefix_p (pfx[0]) || xop_prefix_p (pfx))
pfx[1] |= VEX3_NOT_B;
else if (evex_prefix_p (pfx[0]))
{
@@ -1917,6 +1934,22 @@ amd64_displaced_step_fixup (struct gdbarch *gdbarch,
displaced_debug_printf ("relocated return addr at %s to %s",
paddress (gdbarch, rsp),
paddress (gdbarch, retaddr));
+
+ /* If shadow stack is enabled, we need to correct the return address
+ on the shadow stack too. */
+ bool shadow_stack_enabled;
+ std::optional<CORE_ADDR> ssp
+ = gdbarch_get_shadow_stack_pointer (gdbarch, regs,
+ shadow_stack_enabled);
+ if (shadow_stack_enabled)
+ {
+ gdb_assert (ssp.has_value ());
+ write_memory_unsigned_integer (*ssp, retaddr_len, byte_order,
+ retaddr);
+ displaced_debug_printf ("relocated shadow stack return addr at %s "
+ "to %s", paddress (gdbarch, *ssp),
+ paddress (gdbarch, retaddr));
+ }
}
}
@@ -2553,6 +2586,124 @@ amd64_analyze_frame_setup (gdbarch *gdbarch, CORE_ADDR pc,
return pc;
}
+/* Check whether PC points at code pushing registers onto the stack. If so,
+ update CACHE and return pc after those pushes or CURRENT_PC, whichever is
+ smaller. Otherwise, return PC passed to this function.
+
+ In AMD64 prologue, we only expect GPRs being pushed onto the stack. */
+
+static CORE_ADDR
+amd64_analyze_register_saves (CORE_ADDR pc, CORE_ADDR current_pc,
+ amd64_frame_cache *cache)
+{
+ gdb_byte op;
+
+ /* Limit iterating to 16 GPRs available. */
+ for (int i = 0; i < 16 && pc < current_pc; i++)
+ {
+ int reg = 0;
+ int pc_offset = 0;
+
+ if (target_read_code (pc, &op, 1) == -1)
+ return pc;
+
+ /* push %r8 - %r15 REX prefix. We expect only REX.B to be set, but
+ because, for example, REX.R would be "unused" if it were there,
+ we mask opcode with 0xF1 in case compilers don't get rid of it
+ "because it doesn't matter anyway". */
+ if ((op & 0xF1) == 0x41)
+ {
+ reg += 8;
+ pc_offset = 1;
+
+ if (target_read_code (pc + 1, &op, 1) == -1)
+ return pc;
+ }
+
+ /* push %rax|%rcx|%rdx|%rbx|%rsp|%rbp|%rsi|%rdi
+
+ or with 0x41 prefix:
+ push %r8|%r9|%r10|%r11|%r12|%r13|%r14|%r15. */
+ if (op < 0x50 || op > 0x57)
+ break;
+
+ reg += op - 0x50;
+
+ int regnum = amd64_arch_reg_to_regnum (reg);
+ cache->sp_offset += 8;
+ cache->saved_regs[regnum] = -cache->sp_offset;
+
+ pc += 1 + pc_offset;
+ }
+
+ return pc;
+}
+
+/* Check whether PC points at code allocating space on the stack.
+ If so, update CACHE and return pc past it or CURRENT_PC, whichever is
+ smaller. Otherwise, return PC passed to this function. */
+
+static CORE_ADDR
+amd64_analyze_stack_alloc (gdbarch *arch, CORE_ADDR pc, CORE_ADDR current_pc,
+ amd64_frame_cache *cache)
+{
+ static const gdb_byte sub_imm8_rsp[] = { 0x83, 0xec };
+ static const gdb_byte sub_imm32_rsp[] = { 0x81, 0xec };
+ static const gdb_byte lea_disp_rsp[] = { 0x8D, 0x64 };
+
+ bfd_endian byte_order = gdbarch_byte_order (arch);
+ const CORE_ADDR start_pc = pc;
+
+ gdb_byte op;
+ if (target_read_code (pc, &op, 1) == -1)
+ return pc;
+
+ /* Check for REX.W, indicating 64-bit operand size (in this case, for
+ %rsp). */
+ if (op == 0x48)
+ pc++;
+
+ if (current_pc <= pc)
+ return current_pc;
+
+ gdb_byte buf[2];
+ read_code (pc, buf, 2);
+
+ /* Check for instruction allocating space on the stack, which looks like
+ sub imm8/32, %rsp
+ or
+ lea -imm (%rsp), %rsp
+
+ and forward pc past it + update cache. */
+
+ /* sub imm8, %rsp. */
+ if (memcmp (buf, sub_imm8_rsp, 2) == 0)
+ {
+ /* Instruction is 3 bytes long. The imm8 arg is the 3rd, single
+ byte. */
+ cache->sp_offset += read_code_integer (pc + 2, 1, byte_order);
+ return pc + 3;
+ }
+ /* sub imm32, %rsp. */
+ else if (memcmp (buf, sub_imm32_rsp, 2) == 0)
+ {
+ /* Instruction is 6 bytes long. The imm32 arg is stored in 4 bytes,
+ starting from 3rd one. */
+ cache->sp_offset += read_code_integer (pc + 2, 4, byte_order);
+ return pc + 6;
+ }
+ /* lea -imm (%rsp), %rsp. */
+ else if (memcmp (buf, lea_disp_rsp, 2) == 0)
+ {
+ /* Instruction is 4 bytes long. The imm arg is the 4th, single
+ byte. */
+ cache->sp_offset += -1 * read_code_integer (pc + 3, 1, byte_order);
+ return pc + 4;
+ }
+
+ return start_pc;
+}
+
/* Do a limited analysis of the prologue at PC and update CACHE
accordingly. Bail out early if CURRENT_PC is reached. Return the
address where the analysis stopped.
@@ -2594,7 +2745,15 @@ amd64_analyze_prologue (gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR current_pc,
if (current_pc <= pc)
return current_pc;
- return amd64_analyze_frame_setup (gdbarch, pc, current_pc, cache);
+ pc = amd64_analyze_frame_setup (gdbarch, pc, current_pc, cache);
+ if (current_pc <= pc)
+ return current_pc;
+
+ pc = amd64_analyze_register_saves (pc, current_pc, cache);
+ if (current_pc <= pc)
+ return current_pc;
+
+ return amd64_analyze_stack_alloc (gdbarch, pc, current_pc, cache);
}
/* Work around false termination of prologue - GCC PR debug/48827.
@@ -3395,6 +3554,9 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch,
tdep->num_pkeys_regs = 1;
}
+ if (tdesc_find_feature (tdesc, "org.gnu.gdb.i386.pl3_ssp") != nullptr)
+ tdep->ssp_regnum = AMD64_PL3_SSP_REGNUM;
+
tdep->num_byte_regs = 20;
tdep->num_word_regs = 16;
tdep->num_dword_regs = 16;
@@ -3551,23 +3713,24 @@ amd64_x32_none_init_abi (gdbarch_info info, gdbarch *arch)
amd64_target_description (X86_XSTATE_SSE_MASK, true));
}
-/* Return the target description for a specified XSAVE feature mask. */
+/* See amd64-tdep.h. */
const struct target_desc *
-amd64_target_description (uint64_t xcr0, bool segments)
+amd64_target_description (uint64_t xstate_bv, bool segments)
{
static target_desc *amd64_tdescs \
- [2/*AVX*/][2/*AVX512*/][2/*PKRU*/][2/*segments*/] = {};
+ [2/*AVX*/][2/*AVX512*/][2/*PKRU*/][2/*CET_U*/][2/*segments*/] = {};
target_desc **tdesc;
- tdesc = &amd64_tdescs[(xcr0 & X86_XSTATE_AVX) ? 1 : 0]
- [(xcr0 & X86_XSTATE_AVX512) ? 1 : 0]
- [(xcr0 & X86_XSTATE_PKRU) ? 1 : 0]
+ tdesc = &amd64_tdescs[(xstate_bv & X86_XSTATE_AVX) ? 1 : 0]
+ [(xstate_bv & X86_XSTATE_AVX512) ? 1 : 0]
+ [(xstate_bv & X86_XSTATE_PKRU) ? 1 : 0]
+ [(xstate_bv & X86_XSTATE_CET_U) ? 1 : 0]
[segments ? 1 : 0];
if (*tdesc == NULL)
- *tdesc = amd64_create_target_description (xcr0, false, false,
- segments);
+ *tdesc = amd64_create_target_description (xstate_bv, false,
+ false, segments);
return *tdesc;
}
@@ -3756,6 +3919,42 @@ test_amd64_get_insn_details (void)
= { 0x62, 0xf1, 0x7c, 0x48, 0x28, 0x81, 0x00, 0xfc, 0xff, 0xff };
fixup_riprel (details, insn.data (), ECX_REG_NUM);
SELF_CHECK (insn == updated_insn);
+
+ /* INSN: vpblendw $0x7,%xmm4,%xmm6,%xmm2, vex3 prefix. */
+ insn = { 0xc4, 0xe3, 0x49, 0x0e, 0xd4, 0x07 };
+ amd64_get_insn_details (insn.data (), &details);
+ SELF_CHECK (details.opcode_len == 3);
+ SELF_CHECK (details.enc_prefix_offset == 0);
+ SELF_CHECK (details.opcode_offset == 3);
+ SELF_CHECK (details.modrm_offset == 4);
+
+ /* INSN: vpblendw $0x7,0xff(%rip),%ymm6,%ymm2, vex3 prefix. */
+ insn = { 0xc4, 0xe3, 0x4d, 0x0e, 0x15, 0xff, 0x00, 0x00, 0x00, 0x07 };
+ amd64_get_insn_details (insn.data (), &details);
+ SELF_CHECK (details.opcode_len == 3);
+ SELF_CHECK (details.enc_prefix_offset == 0);
+ SELF_CHECK (details.opcode_offset == 3);
+ SELF_CHECK (details.modrm_offset == 4);
+
+ /* INSN: vpblendw $0x7,0xff(%ecx),%ymm6,%ymm2, vex3 prefix. */
+ fixup_riprel (details, insn.data (), ECX_REG_NUM);
+ updated_insn
+ = { 0xc4, 0xe3, 0x4d, 0x0e, 0x91, 0xff, 0x00, 0x00, 0x00, 0x07 };
+ SELF_CHECK (insn == updated_insn);
+
+ /* INSN: vpcomtrueuq 0x0(%rip),%xmm7,%xmm0, xop prefix. */
+ insn = { 0x8f, 0xe8, 0x40, 0xef, 0x05, 0x00, 0x00, 0x00, 0x00, 0x07 };
+ amd64_get_insn_details (insn.data (), &details);
+ SELF_CHECK (details.opcode_len == 1);
+ SELF_CHECK (details.enc_prefix_offset == 0);
+ SELF_CHECK (details.opcode_offset == 3);
+ SELF_CHECK (details.modrm_offset == 4);
+
+ /* INSN: vpcomtrueuq 0x0(%ecx),%xmm7,%xmm0, xop prefix. */
+ fixup_riprel (details, insn.data (), ECX_REG_NUM);
+ updated_insn
+ = { 0x8f, 0xe8, 0x40, 0xef, 0x81, 0x00, 0x00, 0x00, 0x00, 0x07 };
+ SELF_CHECK (insn == updated_insn);
}
static void
diff --git a/gdb/amd64-tdep.h b/gdb/amd64-tdep.h
index cbf8a97..e663288 100644
--- a/gdb/amd64-tdep.h
+++ b/gdb/amd64-tdep.h
@@ -81,6 +81,7 @@ enum amd64_regnum
AMD64_ZMM0H_REGNUM,
AMD64_ZMM31H_REGNUM = AMD64_ZMM0H_REGNUM + 31,
AMD64_PKRU_REGNUM,
+ AMD64_PL3_SSP_REGNUM,
AMD64_FSBASE_REGNUM,
AMD64_GSBASE_REGNUM
};
@@ -108,8 +109,12 @@ extern void amd64_init_abi (struct gdbarch_info info,
extern void amd64_x32_init_abi (struct gdbarch_info info,
struct gdbarch *gdbarch,
const target_desc *default_tdesc);
-extern const struct target_desc *amd64_target_description (uint64_t xcr0,
- bool segments);
+
+/* Return the target description for the specified xsave features as
+ defined in XSTATE_BV and SEGMENTS. */
+
+extern const struct target_desc *amd64_target_description
+ (uint64_t xstate_bv, bool segments);
/* Fill register REGNUM in REGCACHE with the appropriate
floating-point or SSE register value from *FXSAVE. If REGNUM is
diff --git a/gdb/arc-linux-tdep.c b/gdb/arc-linux-tdep.c
index edbb3f8..6a4f4b1 100644
--- a/gdb/arc-linux-tdep.c
+++ b/gdb/arc-linux-tdep.c
@@ -728,7 +728,7 @@ arc_linux_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch)
arc_linux_sw_breakpoint_from_kind);
set_gdbarch_fetch_tls_load_module_address (gdbarch,
svr4_fetch_objfile_link_map);
- set_gdbarch_software_single_step (gdbarch, arc_linux_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, arc_linux_software_single_step);
set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
set_gdbarch_skip_solib_resolver (gdbarch, arc_linux_skip_solib_resolver);
set_gdbarch_iterate_over_regset_sections
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index f320d3d..f2af80e 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -48,7 +48,7 @@
bool
default_displaced_step_hw_singlestep (struct gdbarch *gdbarch)
{
- return !gdbarch_software_single_step_p (gdbarch);
+ return !gdbarch_get_next_pcs_p (gdbarch);
}
CORE_ADDR
@@ -1218,6 +1218,16 @@ default_gdbarch_return_value
readbuf, writebuf);
}
+/* See arch-utils.h. */
+
+std::optional<CORE_ADDR>
+default_get_shadow_stack_pointer (gdbarch *gdbarch, regcache *regcache,
+ bool &shadow_stack_enabled)
+{
+ shadow_stack_enabled = false;
+ return {};
+}
+
obstack *gdbarch_obstack (gdbarch *arch)
{
return &arch->obstack;
diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
index 1509cb7..14a84b7 100644
--- a/gdb/arch-utils.h
+++ b/gdb/arch-utils.h
@@ -414,4 +414,9 @@ extern enum return_value_convention default_gdbarch_return_value
struct regcache *regcache, struct value **read_value,
const gdb_byte *writebuf);
+/* Default implementation of gdbarch default_get_shadow_stack_pointer
+ method. */
+extern std::optional<CORE_ADDR> default_get_shadow_stack_pointer
+ (gdbarch *gdbarch, regcache *regcache, bool &shadow_stack_enabled);
+
#endif /* GDB_ARCH_UTILS_H */
diff --git a/gdb/arch/aarch64-gcs-linux.h b/gdb/arch/aarch64-gcs-linux.h
new file mode 100644
index 0000000..018ca37
--- /dev/null
+++ b/gdb/arch/aarch64-gcs-linux.h
@@ -0,0 +1,44 @@
+/* Common Linux target-dependent definitions for AArch64 GCS
+
+ Copyright (C) 2025 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 GDB_ARCH_AARCH64_GCS_LINUX_H
+#define GDB_ARCH_AARCH64_GCS_LINUX_H
+
+#include <stdint.h>
+
+/* Feature check for Guarded Control Stack. */
+#ifndef HWCAP_GCS
+#define HWCAP_GCS (1ULL << 32)
+#endif
+
+/* Make sure we only define these if the kernel header doesn't. */
+#ifndef GCS_MAGIC
+
+/* GCS state (NT_ARM_GCS). */
+
+struct user_gcs
+{
+ uint64_t features_enabled;
+ uint64_t features_locked;
+ uint64_t gcspr_el0;
+};
+
+#endif /* GCS_MAGIC */
+
+#endif /* GDB_ARCH_AARCH64_GCS_LINUX_H */
diff --git a/gdb/arch/aarch64.c b/gdb/arch/aarch64.c
index 3e1ca05..dff2bc1 100644
--- a/gdb/arch/aarch64.c
+++ b/gdb/arch/aarch64.c
@@ -26,6 +26,8 @@
#include "../features/aarch64-sme.c"
#include "../features/aarch64-sme2.c"
#include "../features/aarch64-tls.c"
+#include "../features/aarch64-gcs.c"
+#include "../features/aarch64-gcs-linux.c"
/* See arch/aarch64.h. */
@@ -65,6 +67,12 @@ aarch64_create_target_description (const aarch64_features &features)
if (features.sme2)
regnum = create_feature_aarch64_sme2 (tdesc.get (), regnum);
+ if (features.gcs)
+ regnum = create_feature_aarch64_gcs (tdesc.get (), regnum);
+
+ if (features.gcs_linux)
+ regnum = create_feature_aarch64_gcs_linux (tdesc.get (), regnum);
+
return tdesc.release ();
}
diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h
index ee18b74..0fcdba7 100644
--- a/gdb/arch/aarch64.h
+++ b/gdb/arch/aarch64.h
@@ -51,6 +51,12 @@ struct aarch64_features
/* Whether SME2 is supported. */
bool sme2 = false;
+
+ /* Whether Guarded Control Stack is supported. */
+ bool gcs = false;
+
+ /* Whether Guarded Control Stack Linux features are supported. */
+ bool gcs_linux = false;
};
inline bool operator==(const aarch64_features &lhs, const aarch64_features &rhs)
@@ -60,7 +66,9 @@ inline bool operator==(const aarch64_features &lhs, const aarch64_features &rhs)
&& lhs.mte == rhs.mte
&& lhs.tls == rhs.tls
&& lhs.svq == rhs.svq
- && lhs.sme2 == rhs.sme2;
+ && lhs.sme2 == rhs.sme2
+ && lhs.gcs == rhs.gcs
+ && lhs.gcs_linux == rhs.gcs_linux;
}
namespace std
@@ -86,6 +94,10 @@ namespace std
/* SME2 feature. */
h = h << 1 | features.sme2;
+
+ h = h << 1 | features.gcs;
+ h = h << 1 | features.gcs_linux;
+
return h;
}
};
diff --git a/gdb/arch/amd64-linux-tdesc.c b/gdb/arch/amd64-linux-tdesc.c
index 91de758..8796662 100644
--- a/gdb/arch/amd64-linux-tdesc.c
+++ b/gdb/arch/amd64-linux-tdesc.c
@@ -26,34 +26,35 @@
/* See arch/amd64-linux-tdesc.h. */
const struct target_desc *
-amd64_linux_read_description (uint64_t xcr0, bool is_x32)
+amd64_linux_read_description (uint64_t xstate_bv, bool is_x32)
{
/* The type used for the amd64 and x32 target description caches. */
using tdesc_cache_type = std::unordered_map<uint64_t, const target_desc_up>;
/* Caches for the previously seen amd64 and x32 target descriptions,
- indexed by the xcr0 value that created the target description. These
- need to be static within this function to ensure they are initialised
- before first use. */
+ indexed by the xstate_bv value that created the target
+ description. These need to be static within this function to ensure
+ they are initialised before first use. */
static tdesc_cache_type amd64_tdesc_cache, x32_tdesc_cache;
tdesc_cache_type &tdesc_cache = is_x32 ? x32_tdesc_cache : amd64_tdesc_cache;
- /* Only some bits are checked when creating a tdesc, but the XCR0 value
- contains other feature bits that are not relevant for tdesc creation.
- When indexing into the TDESC_CACHE we need to use a consistent xcr0
- value otherwise we might fail to find an existing tdesc which has the
- same set of relevant bits set. */
- xcr0 &= is_x32
- ? x86_linux_x32_xcr0_feature_mask ()
- : x86_linux_amd64_xcr0_feature_mask ();
+ /* Only some bits are checked when creating a tdesc, but the
+ xstate_bv value contains other feature bits that are not
+ relevant for tdesc creation.
+ When indexing into the TDESC_CACHE we need to use a consistent
+ xstate_bv value otherwise we might fail to find an existing
+ tdesc which has the same set of relevant bits set. */
+ xstate_bv &= is_x32
+ ? x86_linux_x32_xstate_bv_feature_mask ()
+ : x86_linux_amd64_xstate_bv_feature_mask ();
- const auto it = tdesc_cache.find (xcr0);
+ const auto it = tdesc_cache.find (xstate_bv);
if (it != tdesc_cache.end ())
return it->second.get ();
/* Create the previously unseen target description. */
- target_desc_up tdesc (amd64_create_target_description (xcr0, is_x32,
+ target_desc_up tdesc (amd64_create_target_description (xstate_bv, is_x32,
true, true));
x86_linux_post_init_tdesc (tdesc.get (), true);
@@ -61,6 +62,6 @@ amd64_linux_read_description (uint64_t xcr0, bool is_x32)
target_desc_up. This is safe as the cache (and the pointers contained
within it) are not deleted until GDB exits. */
target_desc *ptr = tdesc.get ();
- tdesc_cache.emplace (xcr0, std::move (tdesc));
+ tdesc_cache.emplace (xstate_bv, std::move (tdesc));
return ptr;
}
diff --git a/gdb/arch/amd64-linux-tdesc.h b/gdb/arch/amd64-linux-tdesc.h
index 8806a13..4c0c591 100644
--- a/gdb/arch/amd64-linux-tdesc.h
+++ b/gdb/arch/amd64-linux-tdesc.h
@@ -22,9 +22,10 @@
struct target_desc;
-/* Return the AMD64 target descriptions corresponding to XCR0 and IS_X32. */
+/* Return the AMD64 target descriptions corresponding to XSTATE_BV and
+ IS_X32. */
-extern const target_desc *amd64_linux_read_description (uint64_t xcr0,
- bool is_x32);
+extern const target_desc *amd64_linux_read_description
+ (uint64_t xstate_bv, bool is_x32);
#endif /* GDB_ARCH_AMD64_LINUX_TDESC_H */
diff --git a/gdb/arch/amd64.c b/gdb/arch/amd64.c
index 252650b..9fbe802 100644
--- a/gdb/arch/amd64.c
+++ b/gdb/arch/amd64.c
@@ -28,16 +28,15 @@
#include "../features/i386/64bit-sse.c"
#include "../features/i386/pkeys.c"
+#include "../features/i386/64bit-ssp.c"
+#include "../features/i386/32bit-ssp.c"
#include "../features/i386/x32-core.c"
-/* Create amd64 target descriptions according to XCR0. If IS_X32 is
- true, create the x32 ones. If IS_LINUX is true, create target
- descriptions for Linux. If SEGMENTS is true, then include
- the "org.gnu.gdb.i386.segments" feature registers. */
+/* See arch/amd64.h. */
target_desc *
-amd64_create_target_description (uint64_t xcr0, bool is_x32, bool is_linux,
- bool segments)
+amd64_create_target_description (uint64_t xstate_bv, bool is_x32,
+ bool is_linux, bool segments)
{
target_desc_up tdesc = allocate_target_description ();
@@ -62,14 +61,22 @@ amd64_create_target_description (uint64_t xcr0, bool is_x32, bool is_linux,
if (segments)
regnum = create_feature_i386_64bit_segments (tdesc.get (), regnum);
- if (xcr0 & X86_XSTATE_AVX)
+ if (xstate_bv & X86_XSTATE_AVX)
regnum = create_feature_i386_64bit_avx (tdesc.get (), regnum);
- if (xcr0 & X86_XSTATE_AVX512)
+ if (xstate_bv & X86_XSTATE_AVX512)
regnum = create_feature_i386_64bit_avx512 (tdesc.get (), regnum);
- if (xcr0 & X86_XSTATE_PKRU)
+ if (xstate_bv & X86_XSTATE_PKRU)
regnum = create_feature_i386_pkeys (tdesc.get (), regnum);
+ if (xstate_bv & X86_XSTATE_CET_U)
+ {
+ if (!is_x32)
+ regnum = create_feature_i386_64bit_ssp (tdesc.get (), regnum);
+ else
+ regnum = create_feature_i386_32bit_ssp (tdesc.get (), regnum);
+ }
+
return tdesc.release ();
}
diff --git a/gdb/arch/amd64.h b/gdb/arch/amd64.h
index 695660c..60c17eb 100644
--- a/gdb/arch/amd64.h
+++ b/gdb/arch/amd64.h
@@ -21,7 +21,13 @@
#include "gdbsupport/tdesc.h"
#include <stdint.h>
-target_desc *amd64_create_target_description (uint64_t xcr0, bool is_x32,
- bool is_linux, bool segments);
+/* Create amd64 target descriptions according to XSTATE_BV. If
+ IS_X32 is true, create the x32 ones. If IS_LINUX is true, create
+ target descriptions for Linux. If SEGMENTS is true, then include
+ the "org.gnu.gdb.i386.segments" feature registers. */
+
+target_desc *amd64_create_target_description (uint64_t xstate_bv,
+ bool is_x32, bool is_linux,
+ bool segments);
#endif /* GDB_ARCH_AMD64_H */
diff --git a/gdb/arch/i386-linux-tdesc.c b/gdb/arch/i386-linux-tdesc.c
index 5151317..bd736eb 100644
--- a/gdb/arch/i386-linux-tdesc.c
+++ b/gdb/arch/i386-linux-tdesc.c
@@ -25,32 +25,35 @@
/* See arch/i386-linux-tdesc.h. */
const target_desc *
-i386_linux_read_description (uint64_t xcr0)
+i386_linux_read_description (uint64_t xstate_bv)
{
- /* Cache of previously seen i386 target descriptions, indexed by the xcr0
- value that created the target description. This needs to be static
- within this function to ensure it is initialised before first use. */
+ /* Cache of previously seen i386 target descriptions, indexed by the
+ xstate_bv value that created the target description. This
+ needs to be static within this function to ensure it is initialised
+ before first use. */
static std::unordered_map<uint64_t, const target_desc_up> i386_tdesc_cache;
- /* Only some bits are checked when creating a tdesc, but the XCR0 value
- contains other feature bits that are not relevant for tdesc creation.
- When indexing into the I386_TDESC_CACHE we need to use a consistent
- xcr0 value otherwise we might fail to find an existing tdesc which has
- the same set of relevant bits set. */
- xcr0 &= x86_linux_i386_xcr0_feature_mask ();
+ /* Only some bits are checked when creating a tdesc, but the
+ XSTATE_BV value contains other feature bits that are not relevant
+ for tdesc creation. When indexing into the I386_TDESC_CACHE
+ we need to use a consistent XSTATE_BV value otherwise we might fail
+ to find an existing tdesc which has the same set of relevant bits
+ set. */
+ xstate_bv &= x86_linux_i386_xstate_bv_feature_mask ();
- const auto it = i386_tdesc_cache.find (xcr0);
+ const auto it = i386_tdesc_cache.find (xstate_bv);
if (it != i386_tdesc_cache.end ())
return it->second.get ();
/* Create the previously unseen target description. */
- target_desc_up tdesc (i386_create_target_description (xcr0, true, false));
+ target_desc_up tdesc
+ (i386_create_target_description (xstate_bv, true, false));
x86_linux_post_init_tdesc (tdesc.get (), false);
/* Add to the cache, and return a pointer borrowed from the
target_desc_up. This is safe as the cache (and the pointers contained
within it) are not deleted until GDB exits. */
target_desc *ptr = tdesc.get ();
- i386_tdesc_cache.emplace (xcr0, std::move (tdesc));
+ i386_tdesc_cache.emplace (xstate_bv, std::move (tdesc));
return ptr;
}
diff --git a/gdb/arch/i386-linux-tdesc.h b/gdb/arch/i386-linux-tdesc.h
index 2c3c174..1cf2931 100644
--- a/gdb/arch/i386-linux-tdesc.h
+++ b/gdb/arch/i386-linux-tdesc.h
@@ -22,8 +22,9 @@
struct target_desc;
-/* Return the i386 target description corresponding to XCR0. */
+/* Return the i386 target description corresponding to XSTATE_BV. */
-extern const struct target_desc *i386_linux_read_description (uint64_t xcr0);
+extern const struct target_desc *i386_linux_read_description
+ (uint64_t xstate_bv);
#endif /* GDB_ARCH_I386_LINUX_TDESC_H */
diff --git a/gdb/arch/i386.c b/gdb/arch/i386.c
index 835df53..4ec4f10 100644
--- a/gdb/arch/i386.c
+++ b/gdb/arch/i386.c
@@ -28,11 +28,13 @@
#include "../features/i386/32bit-avx512.c"
#include "../features/i386/32bit-segments.c"
#include "../features/i386/pkeys.c"
+#include "../features/i386/32bit-ssp.c"
-/* Create i386 target descriptions according to XCR0. */
+/* See arch/i386.h. */
target_desc *
-i386_create_target_description (uint64_t xcr0, bool is_linux, bool segments)
+i386_create_target_description (uint64_t xstate_bv, bool is_linux,
+ bool segments)
{
target_desc_up tdesc = allocate_target_description ();
@@ -44,10 +46,10 @@ i386_create_target_description (uint64_t xcr0, bool is_linux, bool segments)
long regnum = 0;
- if (xcr0 & X86_XSTATE_X87)
+ if (xstate_bv & X86_XSTATE_X87)
regnum = create_feature_i386_32bit_core (tdesc.get (), regnum);
- if (xcr0 & X86_XSTATE_SSE)
+ if (xstate_bv & X86_XSTATE_SSE)
regnum = create_feature_i386_32bit_sse (tdesc.get (), regnum);
if (is_linux)
@@ -56,14 +58,17 @@ i386_create_target_description (uint64_t xcr0, bool is_linux, bool segments)
if (segments)
regnum = create_feature_i386_32bit_segments (tdesc.get (), regnum);
- if (xcr0 & X86_XSTATE_AVX)
+ if (xstate_bv & X86_XSTATE_AVX)
regnum = create_feature_i386_32bit_avx (tdesc.get (), regnum);
- if (xcr0 & X86_XSTATE_AVX512)
+ if (xstate_bv & X86_XSTATE_AVX512)
regnum = create_feature_i386_32bit_avx512 (tdesc.get (), regnum);
- if (xcr0 & X86_XSTATE_PKRU)
+ if (xstate_bv & X86_XSTATE_PKRU)
regnum = create_feature_i386_pkeys (tdesc.get (), regnum);
+ if (xstate_bv & X86_XSTATE_CET_U)
+ regnum = create_feature_i386_32bit_ssp (tdesc.get (), regnum);
+
return tdesc.release ();
}
diff --git a/gdb/arch/i386.h b/gdb/arch/i386.h
index 1fc4101..91a581f 100644
--- a/gdb/arch/i386.h
+++ b/gdb/arch/i386.h
@@ -21,7 +21,12 @@
#include "gdbsupport/tdesc.h"
#include <stdint.h>
-target_desc *i386_create_target_description (uint64_t xcr0, bool is_linux,
+/* Create i386 target descriptions according to XSTATE_BV. If IS_LINUX is
+ true, create target descriptions for Linux. If SEGMENTS is true, then
+ include the "org.gnu.gdb.i386.segments" feature registers. */
+
+target_desc *i386_create_target_description (uint64_t xstate_bv,
+ bool is_linux,
bool segments);
#endif /* GDB_ARCH_I386_H */
diff --git a/gdb/arch/x86-linux-tdesc-features.c b/gdb/arch/x86-linux-tdesc-features.c
index f65920c..bc34378 100644
--- a/gdb/arch/x86-linux-tdesc-features.c
+++ b/gdb/arch/x86-linux-tdesc-features.c
@@ -28,18 +28,21 @@
We want to cache target descriptions, and this is currently done in
three separate caches, one each for i386, amd64, and x32. Additionally,
- the caching we're discussing here is Linux only, and for Linux, the only
- thing that has an impact on target description creation is the xcr0
- value.
-
- In order to ensure the cache functions correctly we need to filter out
- only those xcr0 feature bits that are relevant, we can then cache target
- descriptions based on the relevant feature bits. Two xcr0 values might
- be different, but have the same relevant feature bits. In this case we
- would expect the two xcr0 values to map to the same cache entry. */
+ the caching we're discussing here is Linux only. Currently for Linux,
+ the only thing that has an impact on target description creation are
+ the supported features in xsave which are modelled by a xstate_bv
+ value, which has the same format than the state component bitmap.
+
+ In order to ensure the cache functions correctly we need to filter only
+ those xstate_bv feature bits that are relevant, we can then cache
+ target descriptions based on the relevant feature bits. Two xstate_bv
+ values might be different, but have the same relevant feature bits. In
+ this case we would expect the two xstate_bv values to map to the same
+ cache entry. */
struct x86_xstate_feature {
- /* The xstate feature mask. This is a mask against an xcr0 value. */
+ /* The xstate feature mask. This is a mask against the state component
+ bitmap. */
uint64_t feature;
/* Is this feature checked when creating an i386 target description. */
@@ -56,12 +59,13 @@ struct x86_xstate_feature {
checked when building a target description for i386, amd64, or x32.
If in the future, due to simplifications or refactoring, this table ever
- ends up with 'true' for every xcr0 feature on every target type, then this
- is an indication that this table should probably be removed, and that the
- rest of the code in this file can be simplified. */
+ ends up with 'true' for every xsave feature on every target type, then
+ this is an indication that this table should probably be removed, and
+ that the rest of the code in this file can be simplified. */
static constexpr x86_xstate_feature x86_linux_all_xstate_features[] = {
/* Feature, i386, amd64, x32. */
+ { X86_XSTATE_CET_U, false, true, true },
{ X86_XSTATE_PKRU, true, true, true },
{ X86_XSTATE_AVX512, true, true, true },
{ X86_XSTATE_AVX, true, true, true },
@@ -73,7 +77,7 @@ static constexpr x86_xstate_feature x86_linux_all_xstate_features[] = {
that are checked for when building an i386 target description. */
static constexpr uint64_t
-x86_linux_i386_xcr0_feature_mask_1 ()
+x86_linux_i386_xstate_bv_feature_mask_1 ()
{
uint64_t mask = 0;
@@ -88,7 +92,7 @@ x86_linux_i386_xcr0_feature_mask_1 ()
that are checked for when building an amd64 target description. */
static constexpr uint64_t
-x86_linux_amd64_xcr0_feature_mask_1 ()
+x86_linux_amd64_xstate_bv_feature_mask_1 ()
{
uint64_t mask = 0;
@@ -103,7 +107,7 @@ x86_linux_amd64_xcr0_feature_mask_1 ()
that are checked for when building an x32 target description. */
static constexpr uint64_t
-x86_linux_x32_xcr0_feature_mask_1 ()
+x86_linux_x32_xstate_bv_feature_mask_1 ()
{
uint64_t mask = 0;
@@ -117,25 +121,25 @@ x86_linux_x32_xcr0_feature_mask_1 ()
/* See arch/x86-linux-tdesc-features.h. */
uint64_t
-x86_linux_i386_xcr0_feature_mask ()
+x86_linux_i386_xstate_bv_feature_mask ()
{
- return x86_linux_i386_xcr0_feature_mask_1 ();
+ return x86_linux_i386_xstate_bv_feature_mask_1 ();
}
/* See arch/x86-linux-tdesc-features.h. */
uint64_t
-x86_linux_amd64_xcr0_feature_mask ()
+x86_linux_amd64_xstate_bv_feature_mask ()
{
- return x86_linux_amd64_xcr0_feature_mask_1 ();
+ return x86_linux_amd64_xstate_bv_feature_mask_1 ();
}
/* See arch/x86-linux-tdesc-features.h. */
uint64_t
-x86_linux_x32_xcr0_feature_mask ()
+x86_linux_x32_xstate_bv_feature_mask ()
{
- return x86_linux_x32_xcr0_feature_mask_1 ();
+ return x86_linux_x32_xstate_bv_feature_mask_1 ();
}
#ifdef GDBSERVER
@@ -143,7 +147,7 @@ x86_linux_x32_xcr0_feature_mask ()
/* See arch/x86-linux-tdesc-features.h. */
int
-x86_linux_xcr0_to_tdesc_idx (uint64_t xcr0)
+x86_linux_xstate_bv_to_tdesc_idx (uint64_t xstate_bv)
{
/* The following table shows which features are checked for when creating
the target descriptions (see nat/x86-linux-tdesc.c), the feature order
@@ -160,7 +164,7 @@ x86_linux_xcr0_to_tdesc_idx (uint64_t xcr0)
for (int i = 0; i < ARRAY_SIZE (x86_linux_all_xstate_features); ++i)
{
- if ((xcr0 & x86_linux_all_xstate_features[i].feature)
+ if ((xstate_bv & x86_linux_all_xstate_features[i].feature)
== x86_linux_all_xstate_features[i].feature)
idx |= (1 << i);
}
@@ -250,17 +254,17 @@ x86_linux_i386_tdesc_count ()
/* See arch/x86-linux-tdesc-features.h. */
uint64_t
-x86_linux_tdesc_idx_to_xcr0 (int idx)
+x86_linux_tdesc_idx_to_xstate_bv (int idx)
{
- uint64_t xcr0 = 0;
+ uint64_t xstate_bv = 0;
for (int i = 0; i < ARRAY_SIZE (x86_linux_all_xstate_features); ++i)
{
if ((idx & (1 << i)) != 0)
- xcr0 |= x86_linux_all_xstate_features[i].feature;
+ xstate_bv |= x86_linux_all_xstate_features[i].feature;
}
- return xcr0;
+ return xstate_bv;
}
#endif /* IN_PROCESS_AGENT */
diff --git a/gdb/arch/x86-linux-tdesc-features.h b/gdb/arch/x86-linux-tdesc-features.h
index 89fe7ce..bc72727 100644
--- a/gdb/arch/x86-linux-tdesc-features.h
+++ b/gdb/arch/x86-linux-tdesc-features.h
@@ -27,17 +27,20 @@
the set of features which are checked for when creating the target
description for each of amd64, x32, and i386. */
-extern uint64_t x86_linux_amd64_xcr0_feature_mask ();
-extern uint64_t x86_linux_x32_xcr0_feature_mask ();
-extern uint64_t x86_linux_i386_xcr0_feature_mask ();
+extern uint64_t x86_linux_amd64_xstate_bv_feature_mask ();
+extern uint64_t x86_linux_x32_xstate_bv_feature_mask ();
+extern uint64_t x86_linux_i386_xstate_bv_feature_mask ();
#ifdef GDBSERVER
-/* Convert an xcr0 value into an integer. The integer will be passed from
- gdbserver to the in-process-agent where it will then be passed through
- x86_linux_tdesc_idx_to_xcr0 to get back the original xcr0 value. */
+/* Convert an XSTATE_BV value into an integer. XSTATE_BV has the same
+ format than the state component bitmap and does include user and
+ supervisor state components. The integer will be passed from gdbserver
+ to the in-process-agent where it will then be passed through
+ x86_linux_tdesc_idx_to_xstate_bv to get back the original value. */
-extern int x86_linux_xcr0_to_tdesc_idx (uint64_t xcr0);
+
+extern int x86_linux_xstate_bv_to_tdesc_idx (uint64_t xstate_bv);
#endif /* GDBSERVER */
@@ -51,11 +54,13 @@ extern int x86_linux_amd64_tdesc_count ();
extern int x86_linux_x32_tdesc_count ();
extern int x86_linux_i386_tdesc_count ();
-/* Convert an index number (as returned from x86_linux_xcr0_to_tdesc_idx)
- into an xcr0 value which can then be used to create a target
- description. */
+/* Convert an index number (as returned from
+ x86_linux_xstate_bv_to_tdesc_idx) into an xstate_bv value which can
+ then be used to create a target description.
+ The return mask has the same format than the state component bitmap
+ and does include user and supervisor state components. */
-extern uint64_t x86_linux_tdesc_idx_to_xcr0 (int idx);
+extern uint64_t x86_linux_tdesc_idx_to_xstate_bv (int idx);
#endif /* IN_PROCESS_AGENT */
diff --git a/gdb/arm-fbsd-tdep.c b/gdb/arm-fbsd-tdep.c
index a37d8b7..fc81818 100644
--- a/gdb/arm-fbsd-tdep.c
+++ b/gdb/arm-fbsd-tdep.c
@@ -318,7 +318,7 @@ arm_fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
}
/* Single stepping. */
- set_gdbarch_software_single_step (gdbarch, arm_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, arm_software_single_step);
}
INIT_GDB_FILE (arm_fbsd_tdep)
diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index 813da8c..dc5165e 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -90,8 +90,6 @@ public:
bool stopped_data_address (CORE_ADDR *) override;
- bool watchpoint_addr_within_range (CORE_ADDR, CORE_ADDR, int) override;
-
const struct target_desc *read_description () override;
/* Override linux_nat_target low methods. */
@@ -1206,14 +1204,6 @@ arm_linux_nat_target::stopped_by_watchpoint ()
return stopped_data_address (&addr);
}
-bool
-arm_linux_nat_target::watchpoint_addr_within_range (CORE_ADDR addr,
- CORE_ADDR start,
- int length)
-{
- return start <= addr && start + length - 1 >= addr;
-}
-
/* Handle thread creation. We need to copy the breakpoints and watchpoints
in the parent thread to the child thread. */
void
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index 08526d8..ff20ed8 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -56,7 +56,6 @@
#include "stap-probe.h"
#include "parser-defs.h"
#include "user-regs.h"
-#include <ctype.h>
#include "elf/common.h"
/* Under ARM GNU/Linux the traditional way of performing a breakpoint
@@ -1167,10 +1166,10 @@ arm_linux_displaced_step_copy_insn (struct gdbarch *gdbarch,
static int
arm_stap_is_single_operand (struct gdbarch *gdbarch, const char *s)
{
- return (*s == '#' || *s == '$' || isdigit (*s) /* Literal number. */
+ return (*s == '#' || *s == '$' || c_isdigit (*s) /* Literal number. */
|| *s == '[' /* Register indirection or
displacement. */
- || isalpha (*s)); /* Register value. */
+ || c_isalpha (*s)); /* Register value. */
}
/* This routine is used to parse a special token in ARM's assembly.
@@ -1202,7 +1201,7 @@ arm_stap_parse_special_token (struct gdbarch *gdbarch,
start = tmp;
/* Register name. */
- while (isalnum (*tmp))
+ while (c_isalnum (*tmp))
++tmp;
if (*tmp != ',')
@@ -1212,7 +1211,7 @@ arm_stap_parse_special_token (struct gdbarch *gdbarch,
regname = (char *) alloca (len + 2);
offset = 0;
- if (isdigit (*start))
+ if (c_isdigit (*start))
{
/* If we are dealing with a register whose name begins with a
digit, it means we should prefix the name with the letter
@@ -1805,7 +1804,7 @@ arm_linux_init_abi (struct gdbarch_info info,
set_solib_svr4_ops (gdbarch, make_linux_ilp32_svr4_solib_ops);
/* Single stepping. */
- set_gdbarch_software_single_step (gdbarch, arm_linux_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, arm_linux_software_single_step);
/* Shared library handling. */
set_gdbarch_skip_trampoline_code (gdbarch, arm_linux_skip_trampoline_code);
diff --git a/gdb/arm-netbsd-tdep.c b/gdb/arm-netbsd-tdep.c
index 82ba0c6..571d6f2 100644
--- a/gdb/arm-netbsd-tdep.c
+++ b/gdb/arm-netbsd-tdep.c
@@ -139,7 +139,7 @@ arm_netbsd_init_abi_common (struct gdbarch_info info,
set_gdbarch_iterate_over_regset_sections
(gdbarch, arm_nbsd_iterate_over_regset_sections);
/* Single stepping. */
- set_gdbarch_software_single_step (gdbarch, arm_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, arm_software_single_step);
}
static void
diff --git a/gdb/arm-obsd-tdep.c b/gdb/arm-obsd-tdep.c
index 00e4bfd..8a48b95 100644
--- a/gdb/arm-obsd-tdep.c
+++ b/gdb/arm-obsd-tdep.c
@@ -96,7 +96,7 @@ armobsd_init_abi (struct gdbarch_info info,
tdep->struct_return = pcc_struct_return;
/* Single stepping. */
- set_gdbarch_software_single_step (gdbarch, arm_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, arm_software_single_step);
/* Breakpoints. */
switch (info.byte_order)
diff --git a/gdb/arm-pikeos-tdep.c b/gdb/arm-pikeos-tdep.c
index 12fd9c3..8d24342 100644
--- a/gdb/arm-pikeos-tdep.c
+++ b/gdb/arm-pikeos-tdep.c
@@ -26,7 +26,7 @@ static void
arm_pikeos_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
/* Single stepping. */
- set_gdbarch_software_single_step (gdbarch, arm_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, arm_software_single_step);
}
/* The ARM PikeOS OSABI sniffer (see gdbarch_register_osabi_sniffer).
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index a764825..940d05f 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -18,7 +18,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include <ctype.h>
#include "extract-store-integer.h"
#include "frame.h"
@@ -2504,15 +2503,15 @@ static const registry<bfd>::key<arm_exidx_data> arm_exidx_data_key;
static struct obj_section *
arm_obj_section_from_vma (struct objfile *objfile, bfd_vma vma)
{
- for (obj_section *osect : objfile->sections ())
- if (bfd_section_flags (osect->the_bfd_section) & SEC_ALLOC)
+ for (obj_section &osect : objfile->sections ())
+ if (bfd_section_flags (osect.the_bfd_section) & SEC_ALLOC)
{
bfd_vma start, size;
- start = bfd_section_vma (osect->the_bfd_section);
- size = bfd_section_size (osect->the_bfd_section);
+ start = bfd_section_vma (osect.the_bfd_section);
+ size = bfd_section_size (osect.the_bfd_section);
if (start <= vma && vma < start + size)
- return osect;
+ return &osect;
}
return NULL;
diff --git a/gdb/arm-wince-tdep.c b/gdb/arm-wince-tdep.c
index b9ea59c..f14c8e8 100644
--- a/gdb/arm-wince-tdep.c
+++ b/gdb/arm-wince-tdep.c
@@ -135,7 +135,7 @@ arm_wince_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_skip_trampoline_code (gdbarch, arm_pe_skip_trampoline_code);
/* Single stepping. */
- set_gdbarch_software_single_step (gdbarch, arm_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, arm_software_single_step);
/* Skip call to __gccmain that gcc places in main. */
set_gdbarch_skip_main_prologue (gdbarch, arm_wince_skip_main_prologue);
diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index 114a7d5..8817bd1 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -17,7 +17,6 @@
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 <ctype.h>
#include "auto-load.h"
#include "gdbsupport/gdb_vecs.h"
#include "progspace.h"
@@ -1045,7 +1044,7 @@ execute_script_contents (struct auto_load_pspace_info *pspace_info,
buf = name_holder.c_str ();
for (p = buf; *p != '\0'; ++p)
{
- if (isspace (*p))
+ if (c_isspace (*p))
break;
}
/* We don't allow nameless scripts, they're not helpful to the user. */
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index 08f542c..54717bf 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -525,7 +525,7 @@ gen_var_ref (struct agent_expr *ax, struct axs_value *value, struct symbol *var)
return computed_ops->tracepoint_var_ref (var, ax, value);
/* I'm imitating the code in read_var_value. */
- switch (var->aclass ())
+ switch (var->loc_class ())
{
case LOC_CONST: /* A constant, like an enum value. */
ax_const_l (ax, (LONGEST) var->value_longest ());
@@ -538,8 +538,7 @@ gen_var_ref (struct agent_expr *ax, struct axs_value *value, struct symbol *var)
break;
case LOC_CONST_BYTES:
- internal_error (_("gen_var_ref: LOC_CONST_BYTES "
- "symbols are not supported"));
+ error (_("gen_var_ref: LOC_CONST_BYTES symbols are not supported"));
/* Variable at a fixed location in memory. Easy. */
case LOC_STATIC:
diff --git a/gdb/block.c b/gdb/block.c
index 1866c0f..2450ebd 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -618,7 +618,7 @@ block_iterator_next (struct block_iterator *iterator)
bool
best_symbol (struct symbol *a, const domain_search_flags domain)
{
- if (a->aclass () == LOC_UNRESOLVED)
+ if (a->loc_class () == LOC_UNRESOLVED)
return false;
if ((domain & SEARCH_VAR_DOMAIN) != 0)
@@ -644,10 +644,10 @@ better_symbol (struct symbol *a, struct symbol *b,
if (b->matches (domain) && !a->matches (domain))
return b;
- if (a->aclass () != LOC_UNRESOLVED && b->aclass () == LOC_UNRESOLVED)
+ if (a->loc_class () != LOC_UNRESOLVED && b->loc_class () == LOC_UNRESOLVED)
return a;
- if (b->aclass () != LOC_UNRESOLVED && a->aclass () == LOC_UNRESOLVED)
+ if (b->loc_class () != LOC_UNRESOLVED && a->loc_class () == LOC_UNRESOLVED)
return b;
return a;
@@ -670,22 +670,9 @@ block_lookup_symbol (const struct block *block, const lookup_name_info &name,
{
if (!block->function ())
{
- struct symbol *other = NULL;
-
- for (struct symbol *sym : block_iterator_range (block, &name))
- {
- /* See comment related to PR gcc/debug/91507 in
- block_lookup_symbol_primary. */
- if (best_symbol (sym, domain))
- return sym;
- /* This is a bit of a hack, but symbol_matches_domain might ignore
- STRUCT vs VAR domain symbols. So if a matching symbol is found,
- make sure there is no "better" matching symbol, i.e., one with
- exactly the same domain. PR 16253. */
- if (sym->matches (domain))
- other = better_symbol (other, sym, domain);
- }
- return other;
+ best_symbol_tracker tracker;
+ tracker.search (nullptr, block, name, domain);
+ return tracker.currently_best.symbol;
}
else
{
@@ -717,24 +704,13 @@ block_lookup_symbol (const struct block *block, const lookup_name_info &name,
/* See block.h. */
-struct symbol *
-block_lookup_symbol_primary (const struct block *block, const char *name,
+bool
+best_symbol_tracker::search (compunit_symtab *symtab,
+ const struct block *block,
+ const lookup_name_info &name,
const domain_search_flags domain)
{
- struct symbol *sym, *other;
- struct mdict_iterator mdict_iter;
-
- lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
-
- /* Verify BLOCK is STATIC_BLOCK or GLOBAL_BLOCK. */
- gdb_assert (block->superblock () == NULL
- || block->superblock ()->superblock () == NULL);
-
- other = NULL;
- for (sym = mdict_iter_match_first (block->multidict (), lookup_name,
- &mdict_iter);
- sym != NULL;
- sym = mdict_iter_match_next (lookup_name, &mdict_iter))
+ for (symbol *sym : block_iterator_range (block, &name))
{
/* With the fix for PR gcc/debug/91507, we get for:
...
@@ -764,17 +740,28 @@ block_lookup_symbol_primary (const struct block *block, const char *name,
the only option to make this work is improve the fallback to use the
size of the minimal symbol. Filed as PR exp/24989. */
if (best_symbol (sym, domain))
- return sym;
+ {
+ best_symtab = symtab;
+ currently_best = { sym, block };
+ return true;
+ }
/* This is a bit of a hack, but 'matches' might ignore
STRUCT vs VAR domain symbols. So if a matching symbol is found,
make sure there is no "better" matching symbol, i.e., one with
exactly the same domain. PR 16253. */
if (sym->matches (domain))
- other = better_symbol (other, sym, domain);
+ {
+ symbol *better = better_symbol (sym, currently_best.symbol, domain);
+ if (better != currently_best.symbol)
+ {
+ best_symtab = symtab;
+ currently_best = { better, block };
+ }
+ }
}
- return other;
+ return false;
}
/* See block.h. */
diff --git a/gdb/block.h b/gdb/block.h
index 76fa203..4ea5294 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -630,14 +630,27 @@ extern struct symbol *block_lookup_symbol (const struct block *block,
const lookup_name_info &name,
const domain_search_flags domain);
-/* Search BLOCK for symbol NAME in DOMAIN but only in primary symbol table of
- BLOCK. BLOCK must be STATIC_BLOCK or GLOBAL_BLOCK. Function is useful if
- one iterates all global/static blocks of an objfile. */
+/* When searching for a symbol, the "best" symbol is preferred over
+ one that is merely acceptable. See 'best_symbol'. This class
+ keeps track of this distinction while searching. */
-extern struct symbol *block_lookup_symbol_primary
- (const struct block *block,
- const char *name,
- const domain_search_flags domain);
+struct best_symbol_tracker
+{
+ /* The symtab in which the currently best symbol appears. */
+ compunit_symtab *best_symtab = nullptr;
+
+ /* The currently best (really "better") symbol. */
+ block_symbol currently_best {};
+
+ /* Search BLOCK (which must have come from SYMTAB) for a symbol
+ matching NAME and DOMAIN. When a symbol is found, update
+ 'currently_best'. If a best symbol is found, return true.
+ Otherwise, return false. SYMTAB can be nullptr if the caller
+ does not care about this tracking. */
+ bool search (compunit_symtab *symtab,
+ const block *block, const lookup_name_info &name,
+ domain_search_flags domain);
+};
/* Find symbol NAME in BLOCK and in DOMAIN. This will return a
matching symbol whose type is not a "opaque", see TYPE_IS_OPAQUE.
diff --git a/gdb/break-catch-exec.c b/gdb/break-catch-exec.c
index 570018c..9bfdb44 100644
--- a/gdb/break-catch-exec.c
+++ b/gdb/break-catch-exec.c
@@ -164,7 +164,7 @@ ep_parse_optional_if_clause (const char **arg)
{
const char *cond_string;
- if (((*arg)[0] != 'i') || ((*arg)[1] != 'f') || !isspace ((*arg)[2]))
+ if (((*arg)[0] != 'i') || ((*arg)[1] != 'f') || !c_isspace ((*arg)[2]))
return NULL;
/* Skip the "if" keyword. */
@@ -204,7 +204,7 @@ catch_exec_command_1 (const char *arg, int from_tty,
First, check if there's an if clause. */
cond_string = ep_parse_optional_if_clause (&arg);
- if ((*arg != '\0') && !isspace (*arg))
+ if ((*arg != '\0') && !c_isspace (*arg))
error (_("Junk at end of arguments."));
std::unique_ptr<exec_catchpoint> c
diff --git a/gdb/break-catch-fork.c b/gdb/break-catch-fork.c
index c8a6330..535040c9 100644
--- a/gdb/break-catch-fork.c
+++ b/gdb/break-catch-fork.c
@@ -221,7 +221,7 @@ catch_fork_command_1 (const char *arg, int from_tty,
First, check if there's an if clause. */
cond_string = ep_parse_optional_if_clause (&arg);
- if ((*arg != '\0') && !isspace (*arg))
+ if ((*arg != '\0') && !c_isspace (*arg))
error (_("Junk at end of arguments."));
/* If this target supports it, create a fork or vfork catchpoint
diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c
index 96f22a1..fad76e7 100644
--- a/gdb/break-catch-syscall.c
+++ b/gdb/break-catch-syscall.c
@@ -17,7 +17,6 @@
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 <ctype.h>
#include "breakpoint.h"
#include "inferior.h"
#include "cli/cli-utils.h"
@@ -369,7 +368,7 @@ catch_syscall_split_args (const char *arg)
/* Skip whitespace. */
arg = skip_spaces (arg);
- for (i = 0; i < 127 && arg[i] && !isspace (arg[i]); ++i)
+ for (i = 0; i < 127 && arg[i] && !c_isspace (arg[i]); ++i)
cur_name[i] = arg[i];
cur_name[i] = '\0';
arg += i;
diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index 6da38eb..1a45d7c 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -18,7 +18,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "arch-utils.h"
-#include <ctype.h>
#include "breakpoint.h"
#include "exceptions.h"
#include "inferior.h"
@@ -420,7 +419,7 @@ catch_exception_event (enum exception_event_kind ex_event,
cond_string = ep_parse_optional_if_clause (&arg);
- if ((*arg != '\0') && !isspace (*arg))
+ if ((*arg != '\0') && !c_isspace (*arg))
error (_("Junk at end of arguments."));
if (ex_event != EX_EVENT_THROW
diff --git a/gdb/break-cond-parse.c b/gdb/break-cond-parse.c
index 31b5343..b771344 100644
--- a/gdb/break-cond-parse.c
+++ b/gdb/break-cond-parse.c
@@ -66,12 +66,12 @@ find_next_token (const char **curr, parse_direction direction)
{
gdb_assert (direction == parse_direction::backward);
- while (isspace (**curr))
+ while (c_isspace (**curr))
--(*curr);
tok_end = *curr;
- while (!isspace (**curr))
+ while (!c_isspace (**curr))
--(*curr);
tok_start = (*curr) + 1;
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index d704ad1..5d87fb9 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -18,7 +18,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "arch-utils.h"
-#include <ctype.h>
#include "event-top.h"
#include "exceptions.h"
#include "gdbsupport/gdb_vecs.h"
@@ -1288,7 +1287,7 @@ condition_completer (struct cmd_list_element *cmd,
{
tracker.advance_custom_word_point_by (1);
/* We don't support completion of history indices. */
- if (!isdigit (text[1]))
+ if (!c_isdigit (text[1]))
complete_internalvar (tracker, &text[1]);
return;
}
@@ -10465,7 +10464,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
int len;
len = exp_end - exp_start;
- while (len > 0 && isspace (exp_start[len - 1]))
+ while (len > 0 && c_isspace (exp_start[len - 1]))
len--;
error (_("Cannot watch constant value `%.*s'."), len, exp_start);
}
@@ -14004,9 +14003,7 @@ int
insert_single_step_breakpoints (struct gdbarch *gdbarch)
{
regcache *regcache = get_thread_regcache (inferior_thread ());
- std::vector<CORE_ADDR> next_pcs;
-
- next_pcs = gdbarch_software_single_step (gdbarch, regcache);
+ std::vector<CORE_ADDR> next_pcs = gdbarch_get_next_pcs (gdbarch, regcache);
if (!next_pcs.empty ())
{
@@ -14113,7 +14110,7 @@ strace_command (const char *arg, int from_tty)
/* Decide if we are dealing with a static tracepoint marker (`-m'),
or with a normal static tracepoint. */
- if (arg && startswith (arg, "-m") && isspace (arg[2]))
+ if (arg && startswith (arg, "-m") && c_isspace (arg[2]))
{
ops = &strace_marker_breakpoint_ops;
locspec = new_linespec_location_spec (&arg,
diff --git a/gdb/btrace.c b/gdb/btrace.c
index b23de88..3d43261 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -39,7 +39,6 @@
#include "record-btrace.h"
#include <inttypes.h>
-#include <ctype.h>
#include <algorithm>
#include <string>
@@ -3258,7 +3257,7 @@ get_uint (const char **arg)
begin = *arg;
pos = skip_spaces (begin);
- if (!isdigit (*pos))
+ if (!c_isdigit (*pos))
error (_("Expected positive number, got: %s."), pos);
number = strtoul (pos, &end, 10);
@@ -3277,7 +3276,7 @@ get_context_size (const char **arg)
{
const char *pos = skip_spaces (*arg);
- if (!isdigit (*pos))
+ if (!c_isdigit (*pos))
error (_("Expected positive number, got: %s."), pos);
char *end;
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 14d4b70..11f0d88 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -35,7 +35,6 @@
%{
-#include <ctype.h>
#include "expression.h"
#include "value.h"
#include "parser-defs.h"
@@ -106,8 +105,35 @@ struct c_parse_state
/* The type stack. */
struct type_stack type_stack;
+
+ /* When set, a name token is not looked up. This can be useful when
+ the search domain is known by context. TYPE_CODE_UNDEF is used
+ to mean "unset" here -- typically only types with tags (enum,
+ struct, class, union) use this feature, but TYPE_CODE_VOID is
+ also used to avoid the lookup for field names. */
+ type_code assume_classification = TYPE_CODE_UNDEF;
+};
+
+/* Used for field names, which skip name lookup. */
+struct qualified_name_token
+{
+ /* The prefix, if any. This can be nullptr. */
+ const char *prefix;
+ /* The field name itself. */
+ const char *name;
+ /* True if the COMPLETE token was seen. */
+ bool complete;
};
+/* A convenient overload of copy_name. */
+static std::string
+copy_name (qualified_name_token token)
+{
+ if (token.prefix == nullptr)
+ return token.name;
+ return std::string (token.prefix) + "::" + token.name;
+}
+
/* This is set and cleared in c_parse. */
static struct c_parse_state *cpstate;
@@ -120,6 +146,8 @@ static void yyerror (const char *);
static int type_aggregate_p (struct type *);
+static void handle_qualified_field_name (qualified_name_token token);
+
using namespace expr;
%}
@@ -140,6 +168,7 @@ using namespace expr;
} typed_val_float;
struct type *tval;
struct stoken sval;
+ qualified_name_token qval;
struct typed_stoken tsval;
struct ttype tsym;
struct symtoken ssym;
@@ -160,7 +189,7 @@ using namespace expr;
static int parse_number (struct parser_state *par_state,
const char *, int, int, YYSTYPE *);
static struct stoken operator_stoken (const char *);
-static struct stoken typename_stoken (const char *);
+static qualified_name_token typename_stoken (const char *);
static void check_parameter_typelist (std::vector<struct type *> *);
#if defined(YYBISON) && YYBISON < 30800
@@ -171,7 +200,7 @@ static void c_print_token (FILE *file, int type, YYSTYPE value);
%type <voidval> exp exp1 type_exp start variable qualified_name lcurly function_method
%type <lval> rcurly
-%type <tval> type typebase scalar_type
+%type <tval> type typebase scalar_type tag_name_or_complete
%type <tvec> nonempty_typelist func_mod parameter_typelist
/* %type <bval> block */
@@ -202,7 +231,9 @@ static void c_print_token (FILE *file, int type, YYSTYPE value);
%token <voidval> COMPLETE
%token <tsym> TYPENAME
%token <theclass> CLASSNAME /* ObjC Class name */
-%type <sval> name field_name
+%type <sval> name
+%type <qval> qual_field_name field_name field_name_or_complete
+%type <qval> field_or_destructor
%type <svec> string_exp
%type <ssym> name_not_typename
%type <tsym> type_name
@@ -364,117 +395,73 @@ exp : ALIGNOF '(' type_exp ')' %prec UNARY
{ pstate->wrap<unop_alignof_operation> (); }
;
-exp : exp ARROW field_name
- {
- pstate->push_new<structop_ptr_operation>
- (pstate->pop (), copy_name ($3));
- }
- ;
-
-exp : exp ARROW field_name COMPLETE
+exp : exp ARROW
{
- structop_base_operation *op
- = new structop_ptr_operation (pstate->pop (),
- copy_name ($3));
- pstate->mark_struct_expression (op);
- pstate->push (operation_up (op));
+ cpstate->assume_classification = TYPE_CODE_VOID;
}
- ;
-
-exp : exp ARROW COMPLETE
+ field_name_or_complete
{
- structop_base_operation *op
- = new structop_ptr_operation (pstate->pop (), "");
- pstate->mark_struct_expression (op);
- pstate->push (operation_up (op));
- }
- ;
+ cpstate->assume_classification = TYPE_CODE_UNDEF;
-exp : exp ARROW '~' name
- {
- pstate->push_new<structop_ptr_operation>
- (pstate->pop (), "~" + copy_name ($4));
- }
- ;
-
-exp : exp ARROW '~' name COMPLETE
- {
- structop_base_operation *op
- = new structop_ptr_operation (pstate->pop (),
- "~" + copy_name ($4));
- pstate->mark_struct_expression (op);
- pstate->push (operation_up (op));
+ if ($4.prefix != nullptr)
+ {
+ handle_qualified_field_name ($4);
+ /* exp->type::name becomes exp->*(&type::name) */
+ /* Note: this doesn't work if name is a
+ static member! FIXME */
+ pstate->wrap<unop_addr_operation> ();
+ pstate->wrap2<structop_mptr_operation> ();
+ }
+ else
+ {
+ structop_base_operation *op
+ = new structop_ptr_operation (pstate->pop (),
+ copy_name ($4));
+ if ($4.complete)
+ pstate->mark_struct_expression (op);
+ pstate->push (operation_up (op));
+ }
}
;
-exp : exp ARROW qualified_name
- { /* exp->type::name becomes exp->*(&type::name) */
- /* Note: this doesn't work if name is a
- static member! FIXME */
- pstate->wrap<unop_addr_operation> ();
- pstate->wrap2<structop_mptr_operation> (); }
- ;
-
exp : exp ARROW_STAR exp
{ pstate->wrap2<structop_mptr_operation> (); }
;
-exp : exp '.' field_name
- {
- if (pstate->language ()->la_language
- == language_opencl)
- pstate->push_new<opencl_structop_operation>
- (pstate->pop (), copy_name ($3));
- else
- pstate->push_new<structop_operation>
- (pstate->pop (), copy_name ($3));
- }
- ;
-
-exp : exp '.' field_name COMPLETE
- {
- structop_base_operation *op
- = new structop_operation (pstate->pop (),
- copy_name ($3));
- pstate->mark_struct_expression (op);
- pstate->push (operation_up (op));
- }
- ;
-
-exp : exp '.' COMPLETE
+exp : exp '.'
{
- structop_base_operation *op
- = new structop_operation (pstate->pop (), "");
- pstate->mark_struct_expression (op);
- pstate->push (operation_up (op));
+ cpstate->assume_classification = TYPE_CODE_VOID;
}
- ;
-
-exp : exp '.' '~' name
+ field_name_or_complete
{
- pstate->push_new<structop_operation>
- (pstate->pop (), "~" + copy_name ($4));
- }
- ;
+ cpstate->assume_classification = TYPE_CODE_UNDEF;
-exp : exp '.' '~' name COMPLETE
- {
- structop_base_operation *op
- = new structop_operation (pstate->pop (),
- "~" + copy_name ($4));
- pstate->mark_struct_expression (op);
- pstate->push (operation_up (op));
+ if ($4.prefix != nullptr)
+ {
+ handle_qualified_field_name ($4);
+ /* exp.type::name becomes exp.*(&type::name) */
+ /* Note: this doesn't work if name is a
+ static member! FIXME */
+ pstate->wrap<unop_addr_operation> ();
+ pstate->wrap2<structop_member_operation> ();
+ }
+ else if (pstate->language ()->la_language
+ == language_opencl
+ && !$4.complete)
+ pstate->push_new<opencl_structop_operation>
+ (pstate->pop (), copy_name ($4));
+ else
+ {
+ structop_base_operation *op
+ = new structop_operation (pstate->pop (),
+ copy_name ($4));
+ if ($4.complete)
+ pstate->mark_struct_expression (op);
+ pstate->push (operation_up (op));
+ }
}
;
-exp : exp '.' qualified_name
- { /* exp.type::name becomes exp.*(&type::name) */
- /* Note: this doesn't work if name is a
- static member! FIXME */
- pstate->wrap<unop_addr_operation> ();
- pstate->wrap2<structop_member_operation> (); }
- ;
-
exp : exp DOT_STAR exp
{ pstate->wrap2<structop_member_operation> (); }
;
@@ -1261,12 +1248,12 @@ single_qualifier:
{ cpstate->type_stack.insert (tp_restrict); }
| '@' NAME
{
- cpstate->type_stack.insert (pstate,
+ cpstate->type_stack.insert (pstate->gdbarch (),
copy_name ($2.stoken).c_str ());
}
| '@' UNKNOWN_CPP_NAME
{
- cpstate->type_stack.insert (pstate,
+ cpstate->type_stack.insert (pstate->gdbarch (),
copy_name ($2.stoken).c_str ());
}
;
@@ -1316,15 +1303,13 @@ direct_abs_decl: '(' abs_decl ')'
| direct_abs_decl array_mod
{
cpstate->type_stack.push ($1);
- cpstate->type_stack.push ($2);
- cpstate->type_stack.push (tp_array);
+ cpstate->type_stack.push (tp_array, $2);
$$ = cpstate->type_stack.create ();
cpstate->type_stacks.emplace_back ($$);
}
| array_mod
{
- cpstate->type_stack.push ($1);
- cpstate->type_stack.push (tp_array);
+ cpstate->type_stack.push (tp_array, $1);
$$ = cpstate->type_stack.create ();
cpstate->type_stacks.emplace_back ($$);
}
@@ -1504,71 +1489,37 @@ typebase
{
$$ = init_complex_type (nullptr, $2);
}
- | STRUCT name
- { $$
- = lookup_struct (copy_name ($2).c_str (),
- pstate->expression_context_block);
- }
- | STRUCT COMPLETE
+ | STRUCT
{
- pstate->mark_completion_tag (TYPE_CODE_STRUCT,
- "", 0);
- $$ = NULL;
+ cpstate->assume_classification = TYPE_CODE_STRUCT;
}
- | STRUCT name COMPLETE
+ tag_name_or_complete
{
- pstate->mark_completion_tag (TYPE_CODE_STRUCT,
- $2.ptr, $2.length);
- $$ = NULL;
- }
- | CLASS name
- { $$ = lookup_struct
- (copy_name ($2).c_str (),
- pstate->expression_context_block);
+ $$ = $3;
}
- | CLASS COMPLETE
+ | CLASS
{
- pstate->mark_completion_tag (TYPE_CODE_STRUCT,
- "", 0);
- $$ = NULL;
+ cpstate->assume_classification = TYPE_CODE_STRUCT;
}
- | CLASS name COMPLETE
+ tag_name_or_complete
{
- pstate->mark_completion_tag (TYPE_CODE_STRUCT,
- $2.ptr, $2.length);
- $$ = NULL;
+ $$ = $3;
}
- | UNION name
- { $$
- = lookup_union (copy_name ($2).c_str (),
- pstate->expression_context_block);
- }
- | UNION COMPLETE
+ | ENUM
{
- pstate->mark_completion_tag (TYPE_CODE_UNION,
- "", 0);
- $$ = NULL;
+ cpstate->assume_classification = TYPE_CODE_ENUM;
}
- | UNION name COMPLETE
+ tag_name_or_complete
{
- pstate->mark_completion_tag (TYPE_CODE_UNION,
- $2.ptr, $2.length);
- $$ = NULL;
- }
- | ENUM name
- { $$ = lookup_enum (copy_name ($2).c_str (),
- pstate->expression_context_block);
+ $$ = $3;
}
- | ENUM COMPLETE
+ | UNION
{
- pstate->mark_completion_tag (TYPE_CODE_ENUM, "", 0);
- $$ = NULL;
+ cpstate->assume_classification = TYPE_CODE_UNION;
}
- | ENUM name COMPLETE
+ tag_name_or_complete
{
- pstate->mark_completion_tag (TYPE_CODE_ENUM, $2.ptr,
- $2.length);
- $$ = NULL;
+ $$ = $3;
}
/* It appears that this rule for templates is never
reduced; template recognition happens by lookahead
@@ -1793,13 +1744,66 @@ oper: OPERATOR NEW
}
;
+qual_field_name:
+ qual_field_name COLONCOLON name
+ {
+ $$.complete = false;
+ if ($1.prefix == nullptr)
+ $$.prefix = $1.name;
+ else
+ $$.prefix = obconcat (&cpstate->expansion_obstack,
+ $1.prefix, "::", $1.name, nullptr);
+ $$.name = obstack_strndup (&cpstate->expansion_obstack,
+ $3.ptr, $3.length);
+ }
+ | name
+ {
+ $$.complete = false;
+ $$.prefix = nullptr;
+ $$.name = obstack_strndup (&cpstate->expansion_obstack,
+ $1.ptr, $1.length);
+ }
+ ;
+
+field_or_destructor:
+ qual_field_name
+ | qual_field_name COLONCOLON '~' name
+ {
+ $$.complete = false;
+ if ($1.prefix == nullptr)
+ $$.prefix = $1.name;
+ else
+ $$.prefix = obconcat (&cpstate->expansion_obstack,
+ $1.prefix, "::", $1.name, nullptr);
+ char *name
+ = (char *) obstack_alloc (&cpstate->expansion_obstack,
+ $4.length + 2);
+ name[0] = '~';
+ memcpy (&name[1], $4.ptr, $4.length);
+ name[$4.length + 1] = '\0';
+ $$.name = name;
+ }
+ | '~' name
+ {
+ $$.complete = false;
+ $$.prefix = nullptr;
+ char *name
+ = (char *) obstack_alloc (&cpstate->expansion_obstack,
+ $2.length + 2);
+ name[0] = '~';
+ memcpy (&name[1], $2.ptr, $2.length);
+ name[$2.length + 1] = '\0';
+ $$.name = name;
+ }
+ ;
+
/* This rule exists in order to allow some tokens that would not normally
match the 'name' rule to appear as fields within a struct. The example
that initially motivated this was the RISC-V target which models the
floating point registers as a union with fields called 'float' and
'double'. */
field_name
- : name
+ : field_or_destructor
| DOUBLE_KEYWORD { $$ = typename_stoken ("double"); }
| FLOAT_KEYWORD { $$ = typename_stoken ("float"); }
| INT_KEYWORD { $$ = typename_stoken ("int"); }
@@ -1809,6 +1813,61 @@ field_name
| UNSIGNED { $$ = typename_stoken ("unsigned"); }
;
+field_name_or_complete
+ : field_name
+ | field_name COMPLETE
+ {
+ $$ = $1;
+ $$.complete = true;
+ }
+ | COMPLETE
+ {
+ $$ = typename_stoken ("");
+ $$.complete = true;
+ }
+ ;
+
+/* This rule is used when the preceding token is a keyword that takes
+ a tag name (e.g., "struct"). The "caller" should disable name
+ lookup, see c_parse_state::assume_classification. */
+tag_name_or_complete
+ : NAME
+ {
+ switch (cpstate->assume_classification)
+ {
+ case TYPE_CODE_STRUCT:
+ $$ = lookup_struct (copy_name ($1.stoken).c_str (),
+ pstate->expression_context_block);
+ break;
+ case TYPE_CODE_ENUM:
+ $$ = lookup_enum (copy_name ($1.stoken).c_str (),
+ pstate->expression_context_block);
+ break;
+ case TYPE_CODE_UNION:
+ $$ = lookup_union (copy_name ($1.stoken).c_str (),
+ pstate->expression_context_block);
+ break;
+ default:
+ gdb_assert_not_reached ();
+ }
+ cpstate->assume_classification = TYPE_CODE_UNDEF;
+ }
+ | COMPLETE
+ {
+ pstate->mark_completion_tag (cpstate->assume_classification,
+ "", 0);
+ cpstate->assume_classification = TYPE_CODE_UNDEF;
+ $$ = nullptr;
+ }
+ | NAME COMPLETE
+ {
+ pstate->mark_completion_tag (cpstate->assume_classification,
+ $1.stoken.ptr, $1.stoken.length);
+ cpstate->assume_classification = TYPE_CODE_UNDEF;
+ $$ = nullptr;
+ }
+ ;
+
name : NAME { $$ = $1.stoken; }
| BLOCKNAME { $$ = $1.stoken; }
| TYPENAME { $$ = $1.stoken; }
@@ -1866,12 +1925,10 @@ operator_stoken (const char *op)
/* Returns a stoken of the type named TYPE. */
-static struct stoken
+static qualified_name_token
typename_stoken (const char *type)
{
- struct stoken st = { type, 0 };
- st.length = strlen (type);
- return st;
+ return qualified_name_token { nullptr, type, false };
};
/* Return true if the type is aggregate-like. */
@@ -1969,13 +2026,13 @@ parse_number (struct parser_state *par_state,
len -= 2;
}
/* Handle suffixes: 'f' for float, 'l' for long double. */
- else if (len >= 1 && TOLOWER (buf[len - 1]) == 'f')
+ else if (len >= 1 && c_tolower (buf[len - 1]) == 'f')
{
putithere->typed_val_float.type
= parse_type (par_state)->builtin_float;
len -= 1;
}
- else if (len >= 1 && TOLOWER (buf[len - 1]) == 'l')
+ else if (len >= 1 && c_tolower (buf[len - 1]) == 'l')
{
putithere->typed_val_float.type
= parse_type (par_state)->builtin_long_double;
@@ -2181,9 +2238,9 @@ c_parse_escape (const char **ptr, struct obstack *output)
if (output)
obstack_grow_str (output, "\\x");
++tokptr;
- if (!ISXDIGIT (*tokptr))
+ if (!c_isxdigit (*tokptr))
error (_("\\x escape without a following hex digit"));
- while (ISXDIGIT (*tokptr))
+ while (c_isxdigit (*tokptr))
{
if (output)
obstack_1grow (output, *tokptr);
@@ -2206,7 +2263,7 @@ c_parse_escape (const char **ptr, struct obstack *output)
if (output)
obstack_grow_str (output, "\\");
for (i = 0;
- i < 3 && ISDIGIT (*tokptr) && *tokptr != '8' && *tokptr != '9';
+ i < 3 && c_isdigit (*tokptr) && *tokptr != '8' && *tokptr != '9';
++i)
{
if (output)
@@ -2231,9 +2288,9 @@ c_parse_escape (const char **ptr, struct obstack *output)
obstack_1grow (output, *tokptr);
}
++tokptr;
- if (!ISXDIGIT (*tokptr))
+ if (!c_isxdigit (*tokptr))
error (_("\\%c escape without a following hex digit"), c);
- for (i = 0; i < len && ISXDIGIT (*tokptr); ++i)
+ for (i = 0; i < len && c_isxdigit (*tokptr); ++i)
{
if (output)
obstack_1grow (output, *tokptr);
@@ -2818,7 +2875,7 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name)
size_t len = strlen ("selector");
if (strncmp (p, "selector", len) == 0
- && (p[len] == '\0' || ISSPACE (p[len])))
+ && (p[len] == '\0' || c_isspace (p[len])))
{
pstate->lexptr = p + len;
return SELECTOR;
@@ -2827,7 +2884,7 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name)
goto parse_string;
}
- while (ISSPACE (*p))
+ while (c_isspace (*p))
p++;
size_t len = strlen ("entry");
if (strncmp (p, "entry", len) == 0 && !c_ident_is_alnum (p[len])
@@ -3046,7 +3103,7 @@ classify_name (struct parser_state *par_state, const struct block *block,
par_state->language ()->name_of_this ()
? &is_a_field_of_this : NULL);
- if (bsym.symbol && bsym.symbol->aclass () == LOC_BLOCK)
+ if (bsym.symbol && bsym.symbol->loc_class () == LOC_BLOCK)
{
yylval.ssym.sym = bsym;
yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
@@ -3094,7 +3151,7 @@ classify_name (struct parser_state *par_state, const struct block *block,
}
}
- if (bsym.symbol && bsym.symbol->aclass () == LOC_TYPEDEF)
+ if (bsym.symbol && bsym.symbol->loc_class () == LOC_TYPEDEF)
{
yylval.tsym.type = bsym.symbol->type ();
return TYPENAME;
@@ -3189,7 +3246,7 @@ classify_inner_name (struct parser_state *par_state,
return ERROR;
}
- switch (yylval.ssym.sym.symbol->aclass ())
+ switch (yylval.ssym.sym.symbol->loc_class ())
{
case LOC_BLOCK:
case LOC_LABEL:
@@ -3218,6 +3275,48 @@ classify_inner_name (struct parser_state *par_state,
internal_error (_("not reached"));
}
+/* A helper function for the specific case of a qualified field name,
+ like "obj->type1::type2::field". This takes the type prefix
+ ("type1::type2" in the example) and finds the corresponding type.
+ It will either throw an exception, or push a scope_operation on the
+ operation stack. */
+static void
+handle_qualified_field_name (qualified_name_token token)
+{
+ struct type *type = nullptr;
+ std::string accum;
+ for (const auto name : split_name (token.prefix, split_style::CXX))
+ {
+ std::string current (name);
+
+ if (accum.empty ())
+ accum = name;
+ else
+ accum = accum + "::" + current;
+
+ yylval.ssym.stoken.ptr = current.c_str ();
+ yylval.ssym.stoken.length = current.size ();
+ yylval.ssym.sym = {};
+ yylval.ssym.is_a_field_of_this = 0;
+
+ int kind = classify_inner_name (pstate,
+ pstate->expression_context_block,
+ type);
+ if (kind != TYPENAME)
+ error (_("could not find type '%s'"), accum.c_str ());
+
+ type = yylval.tsym.type;
+ }
+
+ type = check_typedef (type);
+ if (!type_aggregate_p (type))
+ error (_("`%s' is not defined as an aggregate type."),
+ TYPE_SAFE_NAME (type));
+ if (token.name[0] == '~')
+ destructor_name_p (token.name, type);
+ pstate->push_new<scope_operation> (type, token.name);
+}
+
/* The outer level of a two-level lexer. This calls the inner lexer
to return tokens. It then either returns these tokens, or
aggregates them into a larger token. This lets us work around a
@@ -3250,12 +3349,16 @@ yylex (void)
subsequent code is C++-only; but also depends on seeing a "::" or
name-like token. */
current.token = lex_one_token (pstate, &is_quoted_name);
- if (current.token == NAME)
+ if (cpstate->assume_classification == TYPE_CODE_UNDEF
+ && current.token == NAME)
current.token = classify_name (pstate, pstate->expression_context_block,
is_quoted_name, last_lex_was_structop);
if (pstate->language ()->la_language != language_cplus
|| (current.token != TYPENAME && current.token != COLONCOLON
- && current.token != FILENAME))
+ && current.token != FILENAME
+ && (cpstate->assume_classification == TYPE_CODE_UNDEF
+ || current.token != NAME))
+ || cpstate->assume_classification == TYPE_CODE_VOID)
return current.token;
/* Read any sequence of alternating "::" and name-like tokens into
@@ -3296,7 +3399,8 @@ yylex (void)
search_block = NULL;
else
{
- gdb_assert (current.token == TYPENAME);
+ gdb_assert (current.token == TYPENAME
+ || cpstate->assume_classification != TYPE_CODE_UNDEF);
search_block = pstate->expression_context_block;
obstack_grow (&name_obstack, current.value.sval.ptr,
current.value.sval.length);
@@ -3319,8 +3423,11 @@ yylex (void)
int classification;
yylval = next.value;
- classification = classify_inner_name (pstate, search_block,
- context_type);
+ if (cpstate->assume_classification != TYPE_CODE_UNDEF)
+ classification = NAME;
+ else
+ classification = classify_inner_name (pstate, search_block,
+ context_type);
/* We keep going until we either run out of names, or until
we have a qualified name which is not a type. */
if (classification != TYPENAME && classification != NAME)
@@ -3330,7 +3437,7 @@ yylex (void)
checkpoint = next_to_examine;
/* Update the partial name we are constructing. */
- if (context_type != NULL)
+ if (next_to_examine > 1)
{
/* We don't want to put a leading "::" into the name. */
obstack_grow_str (&name_obstack, "::");
@@ -3345,7 +3452,8 @@ yylex (void)
last_was_coloncolon = 0;
- if (classification == NAME)
+ if (cpstate->assume_classification == TYPE_CODE_UNDEF
+ && classification == NAME)
break;
context_type = yylval.tsym.type;
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 9fccc1f..e8e66a6 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -33,7 +33,6 @@
#include "cp-abi.h"
#include "cp-support.h"
#include "gdbsupport/gdb_obstack.h"
-#include <ctype.h>
#include "gdbcore.h"
#include "gdbarch.h"
#include "c-exp.h"
@@ -408,7 +407,7 @@ convert_ucn (const char *p, const char *limit, const char *dest_charset,
gdb_byte data[4];
int i;
- for (i = 0; i < length && p < limit && ISXDIGIT (*p); ++i, ++p)
+ for (i = 0; i < length && p < limit && c_isxdigit (*p); ++i, ++p)
result = (result << 4) + fromhex (*p);
for (i = 3; i >= 0; --i)
@@ -450,7 +449,7 @@ convert_octal (struct type *type, const char *p,
unsigned long value = 0;
for (i = 0;
- i < 3 && p < limit && ISDIGIT (*p) && *p != '8' && *p != '9';
+ i < 3 && p < limit && c_isdigit (*p) && *p != '8' && *p != '9';
++i)
{
value = 8 * value + fromhex (*p);
@@ -473,7 +472,7 @@ convert_hex (struct type *type, const char *p,
{
unsigned long value = 0;
- while (p < limit && ISXDIGIT (*p))
+ while (p < limit && c_isxdigit (*p))
{
value = 16 * value + fromhex (*p);
++p;
@@ -518,7 +517,7 @@ convert_escape (struct type *type, const char *dest_charset,
case 'x':
advance ();
- if (!ISXDIGIT (*p))
+ if (!c_isxdigit (*p))
error (_("\\x used with no following hex digits."));
p = convert_hex (type, p, limit, output);
break;
@@ -540,7 +539,7 @@ convert_escape (struct type *type, const char *dest_charset,
int length = *p == 'u' ? 4 : 8;
advance ();
- if (!ISXDIGIT (*p))
+ if (!c_isxdigit (*p))
error (_("\\u used with no following hex digits"));
p = convert_ucn (p, limit, dest_charset, output, length);
}
diff --git a/gdb/c-support.h b/gdb/c-support.h
index 47f4066..5fd1118 100644
--- a/gdb/c-support.h
+++ b/gdb/c-support.h
@@ -19,9 +19,7 @@
#ifndef GDB_C_SUPPORT_H
#define GDB_C_SUPPORT_H
-#include "safe-ctype.h"
-
-/* Like ISALPHA, but also returns true for the union of all UTF-8
+/* Like isalpha, but also returns true for the union of all UTF-8
multi-byte sequence bytes and non-ASCII characters in
extended-ASCII charsets (e.g., Latin1). I.e., returns true if the
high bit is set. Note that not all UTF-8 ranges are allowed in C++
@@ -32,15 +30,15 @@
static inline bool
c_ident_is_alpha (unsigned char ch)
{
- return ISALPHA (ch) || ch >= 0x80;
+ return c_isalpha (ch) || ch >= 0x80;
}
-/* Similarly, but Like ISALNUM. */
+/* Similarly, but Like isalnum. */
static inline bool
c_ident_is_alnum (unsigned char ch)
{
- return ISALNUM (ch) || ch >= 0x80;
+ return c_isalnum (ch) || ch >= 0x80;
}
#endif /* GDB_C_SUPPORT_H */
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index df7bdbe..be19987 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -251,8 +251,8 @@ cp_type_print_method_args (struct type *mtype, const char *prefix,
enum language language,
const struct type_print_options *flags)
{
- struct field *args = mtype->fields ();
- int nargs = mtype->num_fields ();
+ auto args = mtype->fields ();
+ int nargs = args.size ();
int varargs = mtype->has_varargs ();
int i;
@@ -515,16 +515,15 @@ c_type_print_args (struct type *type, struct ui_file *stream,
int linkage_name, enum language language,
const struct type_print_options *flags)
{
- int i;
int printed_any = 0;
gdb_printf (stream, "(");
- for (i = 0; i < type->num_fields (); i++)
+ for (const auto &field : type->fields ())
{
struct type *param_type;
- if (type->field (i).is_artificial () && linkage_name)
+ if (field.is_artificial () && linkage_name)
continue;
if (printed_any)
@@ -533,7 +532,7 @@ c_type_print_args (struct type *type, struct ui_file *stream,
stream->wrap_here (4);
}
- param_type = type->field (i).type ();
+ param_type = field.type ();
if (language == language_cplus && linkage_name)
{
@@ -815,7 +814,7 @@ c_type_print_template_args (const struct type_print_options *flags,
{
struct symbol *sym = TYPE_TEMPLATE_ARGUMENT (type, i);
- if (sym->aclass () != LOC_TYPEDEF)
+ if (sym->loc_class () != LOC_TYPEDEF)
continue;
if (first)
diff --git a/gdb/charset.c b/gdb/charset.c
index 2593625..fe725ef 100644
--- a/gdb/charset.c
+++ b/gdb/charset.c
@@ -24,7 +24,6 @@
#include "charset-list.h"
#include "gdbsupport/environ.h"
#include "arch-utils.h"
-#include <ctype.h>
#ifdef USE_WIN32API
#include <windows.h>
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index a15a04a..d353654 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -301,8 +301,8 @@ with_command_completer_1 (const char *set_cmd_prefix,
command as if it was a "set" command. */
if (delim == text
|| delim == nullptr
- || !isspace (delim[-1])
- || !(isspace (delim[2]) || delim[2] == '\0'))
+ || !c_isspace (delim[-1])
+ || !(c_isspace (delim[2]) || delim[2] == '\0'))
{
std::string new_text = std::string (set_cmd_prefix) + text;
tracker.advance_custom_word_point_by (-(int) strlen (set_cmd_prefix));
@@ -785,14 +785,14 @@ source_command (const char *args, int from_tty)
if (args[0] != '-')
break;
- if (args[1] == 'v' && isspace (args[2]))
+ if (args[1] == 'v' && c_isspace (args[2]))
{
source_verbose = 1;
/* Skip passed -v. */
args = &args[3];
}
- else if (args[1] == 's' && isspace (args[2]))
+ else if (args[1] == 's' && c_isspace (args[2]))
{
search_path = 1;
@@ -1184,7 +1184,7 @@ pipe_command_completer (struct cmd_list_element *ignore,
delimiter = opts.delimiter.c_str ();
/* Check if we're past option values already. */
- if (text > org_text && !isspace (text[-1]))
+ if (text > org_text && !c_isspace (text[-1]))
return;
const char *delim = strstr (text, delimiter);
@@ -1669,7 +1669,7 @@ disassemble_command (const char *arg, int from_tty)
if (*p == '\0')
error (_("Missing modifier."));
- while (*p && ! isspace (*p))
+ while (*p && ! c_isspace (*p))
{
switch (*p++)
{
@@ -1938,8 +1938,8 @@ alias_command_completer (struct cmd_list_element *ignore,
typing COMMAND DEFAULT-ARGS... */
if (delim != text
&& delim != nullptr
- && isspace (delim[-1])
- && (isspace (delim[1]) || delim[1] == '\0'))
+ && c_isspace (delim[-1])
+ && (c_isspace (delim[1]) || delim[1] == '\0'))
{
std::string new_text = std::string (delim + 1);
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 48a3466..2b30a6e 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -16,7 +16,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "symtab.h"
-#include <ctype.h>
#include "gdbsupport/gdb_regex.h"
#include "completer.h"
#include "ui-out.h"
@@ -2053,8 +2052,8 @@ print_doc_line (struct ui_file *stream, const char *str,
if (for_value_prefix)
{
char &c = (*line_buffer)[0];
- if (islower (c))
- c = toupper (c);
+ if (c_islower (c))
+ c = c_toupper (c);
if (line_buffer->back () == '.')
line_buffer->pop_back ();
}
@@ -2227,7 +2226,7 @@ valid_cmd_char_p (int c)
/* Alas "42" is a legitimate user-defined command.
In the interests of not breaking anything we preserve that. */
- return isalnum (c) || c == '-' || c == '_' || c == '.';
+ return c_isalnum (c) || c == '-' || c == '_' || c == '.';
}
/* See command.h. */
@@ -2491,7 +2490,7 @@ lookup_cmd (const char **line, struct cmd_list_element *list,
}
else
{
- if (c->type == set_cmd && **line != '\0' && !isspace (**line))
+ if (c->type == set_cmd && **line != '\0' && !c_isspace (**line))
error (_("Argument must be preceded by space."));
/* We've got something. It may still not be what the caller
diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c
index afbbea6..3cdd9a3 100644
--- a/gdb/cli/cli-dump.c
+++ b/gdb/cli/cli-dump.c
@@ -23,7 +23,6 @@
#include "cli/cli-cmds.h"
#include "value.h"
#include "completer.h"
-#include <ctype.h>
#include "target.h"
#include "readline/tilde.h"
#include "gdbcore.h"
diff --git a/gdb/cli/cli-option.c b/gdb/cli/cli-option.c
index a30261e..5da8c73 100644
--- a/gdb/cli/cli-option.c
+++ b/gdb/cli/cli-option.c
@@ -227,7 +227,7 @@ parse_option (gdb::array_view<const option_def_group> options_group,
match = &o;
match_ctx = grp.ctx;
- if ((isspace (arg[len]) || arg[len] == '\0')
+ if ((c_isspace (arg[len]) || arg[len] == '\0')
&& strlen (o.name) == len)
break; /* Exact match. */
}
@@ -635,7 +635,7 @@ complete_options (completion_tracker &tracker,
if (ov
&& !tracker.have_completions ()
&& **args == '\0'
- && *args > text && !isspace ((*args)[-1]))
+ && *args > text && !c_isspace ((*args)[-1]))
{
tracker.advance_custom_word_point_by
(*args - text);
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 3ea80a5..048d391 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -19,7 +19,6 @@
#include "event-top.h"
#include "value.h"
-#include <ctype.h>
#include "ui-out.h"
#include "top.h"
@@ -829,7 +828,7 @@ locate_arg (const char *p)
while ((p = strchr (p, '$')))
{
if (startswith (p, "$arg")
- && (isdigit (p[4]) || p[4] == 'c'))
+ && (c_isdigit (p[4]) || p[4] == 'c'))
return p;
p++;
}
@@ -1324,9 +1323,9 @@ validate_comname (const char **comname)
/* Find the last word of the argument. */
p = *comname + strlen (*comname);
- while (p > *comname && isspace (p[-1]))
+ while (p > *comname && c_isspace (p[-1]))
p--;
- while (p > *comname && !isspace (p[-1]))
+ while (p > *comname && !c_isspace (p[-1]))
p--;
last_word = p;
diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index 4d4695f..8528ac5 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -17,7 +17,6 @@
#include "readline/tilde.h"
#include "value.h"
-#include <ctype.h>
#include "arch-utils.h"
#include "observable.h"
#include "interps.h"
@@ -49,7 +48,7 @@ parse_auto_binary_operation (const char *arg)
{
int length = strlen (arg);
- while (isspace (arg[length - 1]) && length > 0)
+ while (c_isspace (arg[length - 1]) && length > 0)
length--;
/* Note that "o" is ambiguous. */
diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c
index 23706e0..d0ca594 100644
--- a/gdb/cli/cli-utils.c
+++ b/gdb/cli/cli-utils.c
@@ -20,7 +20,6 @@
#include "cli/cli-utils.h"
#include "value.h"
-#include <ctype.h>
/* See documentation in cli-utils.h. */
@@ -46,7 +45,7 @@ get_ulongest (const char **pp, int trailer)
/* Internal variable. Make a copy of the name, so we can
null-terminate it to pass to lookup_internalvar(). */
const char *start = ++p;
- while (isalnum (*p) || *p == '_')
+ while (c_isalnum (*p) || *p == '_')
p++;
std::string varname (start, p - start);
if (!get_internalvar_integer (lookup_internalvar (varname.c_str ()),
@@ -67,7 +66,7 @@ get_ulongest (const char **pp, int trailer)
p = end;
}
- if (!(isspace (*p) || *p == '\0' || *p == trailer))
+ if (!(c_isspace (*p) || *p == '\0' || *p == trailer))
error (_("Trailing junk at: %s"), p);
p = skip_spaces (p);
*pp = p;
@@ -111,7 +110,7 @@ get_number_trailer (const char **pp, int trailer)
const char *start = ++p;
LONGEST longest_val;
- while (isalnum (*p) || *p == '_')
+ while (c_isalnum (*p) || *p == '_')
p++;
varname = (char *) alloca (p - start + 1);
strncpy (varname, start, p - start);
@@ -136,7 +135,7 @@ get_number_trailer (const char **pp, int trailer)
/* There is no number here. (e.g. "cond a == b"). */
{
/* Skip non-numeric token. */
- while (*p && !isspace((int) *p))
+ while (*p && !c_isspace((int) *p))
++p;
/* Return zero, which caller must interpret as error. */
retval = 0;
@@ -144,10 +143,10 @@ get_number_trailer (const char **pp, int trailer)
else
retval = atoi (p1);
}
- if (!(isspace (*p) || *p == '\0' || *p == trailer))
+ if (!(c_isspace (*p) || *p == '\0' || *p == trailer))
{
/* Trailing junk: return 0 and let caller print error msg. */
- while (!(isspace (*p) || *p == '\0' || *p == trailer))
+ while (!(c_isspace (*p) || *p == '\0' || *p == trailer))
++p;
retval = 0;
}
@@ -262,8 +261,8 @@ number_or_range_parser::get_number ()
option rather than an incomplete range, so check for end of
string as well. */
if (m_cur_tok[0] == '-'
- && !(isspace (m_cur_tok[-1])
- && (isalpha (m_cur_tok[1])
+ && !(c_isspace (m_cur_tok[-1])
+ && (c_isalpha (m_cur_tok[1])
|| m_cur_tok[1] == '-'
|| m_cur_tok[1] == '\0')))
{
@@ -293,7 +292,7 @@ number_or_range_parser::get_number ()
}
else
{
- if (isdigit (*(m_cur_tok + 1)))
+ if (c_isdigit (*(m_cur_tok + 1)))
error (_("negative value"));
if (*(m_cur_tok + 1) == '$')
{
@@ -330,9 +329,9 @@ number_or_range_parser::finished () const
integer, convenience var or negative convenience var. */
return (m_cur_tok == NULL || *m_cur_tok == '\0'
|| (!m_in_range
- && !(isdigit (*m_cur_tok) || *m_cur_tok == '$')
+ && !(c_isdigit (*m_cur_tok) || *m_cur_tok == '$')
&& !(*m_cur_tok == '-'
- && (isdigit (m_cur_tok[1]) || m_cur_tok[1] == '$'))));
+ && (c_isdigit (m_cur_tok[1]) || m_cur_tok[1] == '$'))));
}
/* Accept a number and a string-form list of numbers such as is
@@ -370,7 +369,7 @@ number_is_in_list (const char *list, int number)
const char *
remove_trailing_whitespace (const char *start, const char *s)
{
- while (s > start && isspace (*(s - 1)))
+ while (s > start && c_isspace (*(s - 1)))
--s;
return s;
@@ -420,7 +419,7 @@ int
check_for_argument (const char **str, const char *arg, int arg_len)
{
if (strncmp (*str, arg, arg_len) == 0
- && ((*str)[arg_len] == '\0' || isspace ((*str)[arg_len])))
+ && ((*str)[arg_len] == '\0' || c_isspace ((*str)[arg_len])))
{
*str += arg_len;
*str = skip_spaces (*str);
diff --git a/gdb/coff-pe-read.c b/gdb/coff-pe-read.c
index 0061007..9255555 100644
--- a/gdb/coff-pe-read.c
+++ b/gdb/coff-pe-read.c
@@ -35,7 +35,6 @@
#include "gdbsupport/common-utils.h"
#include "coff/internal.h"
-#include <ctype.h>
/* Internal section information */
@@ -189,7 +188,7 @@ add_pe_forwarded_sym (minimal_symbol_reader &reader,
int i;
for (i = 0; i < forward_dll_name_len; i++)
- forward_qualified_name[i] = tolower (forward_qualified_name[i]);
+ forward_qualified_name[i] = c_tolower (forward_qualified_name[i]);
msymbol = lookup_minimal_symbol (current_program_space,
forward_qualified_name.c_str ());
}
diff --git a/gdb/coffread.c b/gdb/coffread.c
index db18c43..44e761a 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -25,7 +25,6 @@
#include "bfd.h"
#include "gdbsupport/gdb_obstack.h"
-#include <ctype.h>
#include "coff/internal.h"
#include "libcoff.h"
@@ -336,7 +335,7 @@ coff_locate_sections (bfd *abfd, asection *sectp, void *csip)
/* We can have multiple .stab sections if linked with
--split-by-reloc. */
for (s = name + sizeof ".stab" - 1; *s != '\0'; s++)
- if (!isdigit (*s))
+ if (!c_isdigit (*s))
break;
if (*s == '\0')
csi->stabsects->push_back (sectp);
@@ -525,9 +524,9 @@ is_import_fixup_symbol (struct coff_symbol *cs,
/* The name must start with "__fu<digits>__". */
if (!startswith (cs->c_name, "__fu"))
return 0;
- if (! isdigit (cs->c_name[4]))
+ if (! c_isdigit (cs->c_name[4]))
return 0;
- for (i = 5; cs->c_name[i] != '\0' && isdigit (cs->c_name[i]); i++)
+ for (i = 5; cs->c_name[i] != '\0' && c_isdigit (cs->c_name[i]); i++)
/* Nothing, just incrementing index past all digits. */;
if (cs->c_name[i] != '_' || cs->c_name[i + 1] != '_')
return 0;
@@ -1567,7 +1566,7 @@ patch_opaque_types (struct symtab *s)
Remove syms from the chain when their types are stored,
but search the whole chain, as there may be several syms
from different files with the same name. */
- if (real_sym->aclass () == LOC_TYPEDEF
+ if (real_sym->loc_class () == LOC_TYPEDEF
&& real_sym->domain () == TYPE_DOMAIN
&& real_sym->type ()->code () == TYPE_CODE_PTR
&& real_sym->type ()->target_type ()->length () != 0)
@@ -1614,7 +1613,7 @@ static const struct symbol_register_ops coff_register_funcs = {
coff_reg_to_regnum
};
-/* The "aclass" index for computed COFF symbols. */
+/* The "loc_class" index for computed COFF symbols. */
static int coff_register_index;
@@ -1646,7 +1645,7 @@ process_coff_symbol (struct coff_symbol *cs,
(lookup_function_type (decode_function_type (cs, cs->c_type,
aux, objfile)));
- sym->set_aclass_index (LOC_BLOCK);
+ sym->set_loc_class_index (LOC_BLOCK);
if (cs->c_sclass == C_STAT || cs->c_sclass == C_THUMBSTAT
|| cs->c_sclass == C_THUMBSTATFUNC)
add_symbol_to_list (sym, get_file_symbols ());
@@ -1663,14 +1662,14 @@ process_coff_symbol (struct coff_symbol *cs,
break;
case C_AUTO:
- sym->set_aclass_index (LOC_LOCAL);
+ sym->set_loc_class_index (LOC_LOCAL);
add_symbol_to_list (sym, get_local_symbols ());
break;
case C_THUMBEXT:
case C_THUMBEXTFUNC:
case C_EXT:
- sym->set_aclass_index (LOC_STATIC);
+ sym->set_loc_class_index (LOC_STATIC);
sym->set_value_address ((CORE_ADDR) cs->c_value
+ objfile->section_offsets[SECT_OFF_TEXT (objfile)]);
add_symbol_to_list (sym, get_global_symbols ());
@@ -1679,7 +1678,7 @@ process_coff_symbol (struct coff_symbol *cs,
case C_THUMBSTAT:
case C_THUMBSTATFUNC:
case C_STAT:
- sym->set_aclass_index (LOC_STATIC);
+ sym->set_loc_class_index (LOC_STATIC);
sym->set_value_address ((CORE_ADDR) cs->c_value
+ objfile->section_offsets[SECT_OFF_TEXT (objfile)]);
if (within_function)
@@ -1698,7 +1697,7 @@ process_coff_symbol (struct coff_symbol *cs,
case C_GLBLREG:
#endif
case C_REG:
- sym->set_aclass_index (coff_register_index);
+ sym->set_loc_class_index (coff_register_index);
sym->set_value_longest (cs->c_value);
add_symbol_to_list (sym, get_local_symbols ());
break;
@@ -1708,20 +1707,20 @@ process_coff_symbol (struct coff_symbol *cs,
break;
case C_ARG:
- sym->set_aclass_index (LOC_ARG);
+ sym->set_loc_class_index (LOC_ARG);
sym->set_is_argument (1);
add_symbol_to_list (sym, get_local_symbols ());
break;
case C_REGPARM:
- sym->set_aclass_index (coff_register_index);
+ sym->set_loc_class_index (coff_register_index);
sym->set_is_argument (1);
sym->set_value_longest (cs->c_value);
add_symbol_to_list (sym, get_local_symbols ());
break;
case C_TPDEF:
- sym->set_aclass_index (LOC_TYPEDEF);
+ sym->set_loc_class_index (LOC_TYPEDEF);
sym->set_domain (TYPE_DOMAIN);
/* If type has no name, give it one. */
@@ -1776,7 +1775,7 @@ process_coff_symbol (struct coff_symbol *cs,
case C_STRTAG:
case C_UNTAG:
case C_ENTAG:
- sym->set_aclass_index (LOC_TYPEDEF);
+ sym->set_loc_class_index (LOC_TYPEDEF);
sym->set_domain (STRUCT_DOMAIN);
/* Some compilers try to be helpful by inventing "fake"
@@ -2165,7 +2164,7 @@ coff_read_enum_type (int index, int length, int lastsym,
name = obstack_strdup (&objfile->objfile_obstack, name);
sym->set_linkage_name (name);
- sym->set_aclass_index (LOC_CONST);
+ sym->set_loc_class_index (LOC_CONST);
sym->set_domain (VAR_DOMAIN);
sym->set_value_longest (ms->c_value);
add_symbol_to_list (sym, symlist);
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
index b31592f..6578977 100644
--- a/gdb/compile/compile-c-symbols.c
+++ b/gdb/compile/compile-c-symbols.c
@@ -61,7 +61,7 @@ convert_one_symbol (compile_c_instance *context,
context->error_symbol_once (sym.symbol);
- if (sym.symbol->aclass () == LOC_LABEL)
+ if (sym.symbol->loc_class () == LOC_LABEL)
sym_type = 0;
else
sym_type = context->convert_type (sym.symbol->type ());
@@ -79,7 +79,7 @@ convert_one_symbol (compile_c_instance *context,
CORE_ADDR addr = 0;
gdb::unique_xmalloc_ptr<char> symbol_name;
- switch (sym.symbol->aclass ())
+ switch (sym.symbol->loc_class ())
{
case LOC_TYPEDEF:
kind = GCC_C_SYMBOL_TYPEDEF;
@@ -536,7 +536,7 @@ generate_c_for_for_one_variable (compile_instance *compiler,
}
else
{
- switch (sym->aclass ())
+ switch (sym->loc_class ())
{
case LOC_REGISTER:
case LOC_ARG:
diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c
index b03c4b9..96ebd84 100644
--- a/gdb/compile/compile-cplus-symbols.c
+++ b/gdb/compile/compile-cplus-symbols.c
@@ -53,7 +53,7 @@ convert_one_symbol (compile_cplus_instance *instance,
instance->error_symbol_once (sym.symbol);
- if (sym.symbol->aclass () == LOC_LABEL)
+ if (sym.symbol->loc_class () == LOC_LABEL)
sym_type = 0;
else
sym_type = instance->convert_type (sym.symbol->type ());
@@ -70,7 +70,7 @@ convert_one_symbol (compile_cplus_instance *instance,
std::string name;
gdb::unique_xmalloc_ptr<char> symbol_name;
- switch (sym.symbol->aclass ())
+ switch (sym.symbol->loc_class ())
{
case LOC_TYPEDEF:
if (sym.symbol->type ()->code () == TYPE_CODE_TYPEDEF)
diff --git a/gdb/completer.c b/gdb/completer.c
index deecbc2..b919b4c 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -3006,7 +3006,7 @@ gdb_printable_part (char *pathname)
temp = strrchr (pathname, '/');
#if defined (__MSDOS__)
- if (temp == 0 && ISALPHA ((unsigned char)pathname[0]) && pathname[1] == ':')
+ if (temp == 0 && c_isalpha (pathname[0]) && pathname[1] == ':')
temp = pathname + 1;
#endif
diff --git a/gdb/config.in b/gdb/config.in
index 149aeaf..efc3100 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -745,6 +745,9 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
+/* Which binary file formats were requested at configure time. */
+#undef SUPPORTED_BINARY_FILE_FORMATS
+
/* automatically load a system-wide gdbinit file */
#undef SYSTEM_GDBINIT
diff --git a/gdb/configure b/gdb/configure
index 8fc3b04..db63481 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -706,6 +706,7 @@ LIBGUI
LTLIBLZMA
LIBLZMA
HAVE_LIBLZMA
+FORMAT_SRCS
SER_HARDWIRE
WERROR_CFLAGS
WARN_CFLAGS
@@ -820,6 +821,7 @@ DSYMUTIL
AWK
RANLIB
AR
+LLVM_CONFIG
OBJDUMP
LN_S
NM
@@ -932,6 +934,7 @@ with_relocated_sources
with_auto_load_dir
with_auto_load_safe_path
enable_targets
+enable_binary_file_formats
enable_gdb_mdebug_support
enable_gdb_dwarf_support
with_amd_dbgapi
@@ -1645,6 +1648,10 @@ Optional Features:
--disable-nls do not use Native Language Support
--enable-targets=TARGETS
alternative target configurations
+ --enable-binary-file-formats=FORMATS
+ enable support for selected file formats (default
+ 'all') available formats: coff, dbx, elf, macho,
+ mips, xcoff, all
--enable-gdb-mdebug-support
Enable support for the mdebug debuginfo format
(default 'yes')
@@ -6481,8 +6488,266 @@ test -z "$deplibs_check_method" && deplibs_check_method=unknown
-plugin_option=
+
+# Try CLANG_PLUGIN_FILE first since GCC_PLUGIN_OPTION may return the
+# wrong plugin_option with clang.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clang" >&5
+$as_echo_n "checking for clang... " >&6; }
+if ${clang_cv_is_clang+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#ifdef __clang__
+ yes
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "yes" >/dev/null 2>&1; then :
+ clang_cv_is_clang=yes
+else
+ clang_cv_is_clang=no
+fi
+rm -f conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $clang_cv_is_clang" >&5
+$as_echo "$clang_cv_is_clang" >&6; }
+ plugin_file=
+ if test $clang_cv_is_clang = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clang plugin file" >&5
+$as_echo_n "checking for clang plugin file... " >&6; }
+ plugin_names="LLVMgold.so"
+ for plugin in $plugin_names; do
+ plugin_file=`${CC} ${CFLAGS} --print-file-name $plugin`
+ if test x$plugin_file = x$plugin; then
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}llvm-config", so it can be a program name with args.
+set dummy ${ac_tool_prefix}llvm-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_LLVM_CONFIG+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$LLVM_CONFIG"; then
+ ac_cv_prog_LLVM_CONFIG="$LLVM_CONFIG" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_LLVM_CONFIG="${ac_tool_prefix}llvm-config"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+LLVM_CONFIG=$ac_cv_prog_LLVM_CONFIG
+if test -n "$LLVM_CONFIG"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LLVM_CONFIG" >&5
+$as_echo "$LLVM_CONFIG" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_LLVM_CONFIG"; then
+ ac_ct_LLVM_CONFIG=$LLVM_CONFIG
+ # Extract the first word of "llvm-config", so it can be a program name with args.
+set dummy llvm-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_LLVM_CONFIG+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_LLVM_CONFIG"; then
+ ac_cv_prog_ac_ct_LLVM_CONFIG="$ac_ct_LLVM_CONFIG" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_LLVM_CONFIG="llvm-config"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_LLVM_CONFIG=$ac_cv_prog_ac_ct_LLVM_CONFIG
+if test -n "$ac_ct_LLVM_CONFIG"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LLVM_CONFIG" >&5
+$as_echo "$ac_ct_LLVM_CONFIG" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_LLVM_CONFIG" = x; then
+ LLVM_CONFIG=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ LLVM_CONFIG=$ac_ct_LLVM_CONFIG
+ fi
+else
+ LLVM_CONFIG="$ac_cv_prog_LLVM_CONFIG"
+fi
+
+ if test "$?" != 0; then
+ as_fn_error $? "Required tool 'llvm-config' not found on PATH." "$LINENO" 5
+ fi
+ clang_lib_dir=`$LLVM_CONFIG --libdir`
+ if test -f $clang_lib_dir/$plugin; then
+ plugin_file=$clang_lib_dir/$plugin
+ fi
+ if test x$plugin_file != x$plugin; then
+ break;
+ fi
+ fi
+ done
+ if test -z $plugin_file; then
+ as_fn_error $? "Couldn't find clang plugin file for $CC." "$LINENO" 5
+ fi
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ar; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_AR+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$AR"; then
+ ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_AR="${ac_tool_prefix}ar"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+$as_echo "$AR" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_AR"; then
+ ac_ct_AR=$AR
+ # Extract the first word of "ar", so it can be a program name with args.
+set dummy ar; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_AR+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_AR"; then
+ ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_AR="ar"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+$as_echo "$ac_ct_AR" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_AR" = x; then
+ AR=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ AR=$ac_ct_AR
+ fi
+else
+ AR="$ac_cv_prog_AR"
+fi
+
+ if test "${AR}" = "" ; then
+ as_fn_error $? "Required archive tool 'ar' not found on PATH." "$LINENO" 5
+ fi
+ plugin_option="--plugin $plugin_file"
+ touch conftest.c
+ ${AR} $plugin_option rc conftest.a conftest.c
+ if test "$?" != 0; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Failed: $AR $plugin_option rc" >&5
+$as_echo "$as_me: WARNING: Failed: $AR $plugin_option rc" >&2;}
+ plugin_file=
+ fi
+ rm -f conftest.*
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $plugin_file" >&5
+$as_echo "$plugin_file" >&6; }
+ fi
+ plugin_file="$plugin_file"
+
+if test -n "$plugin_file"; then
+ plugin_option="--plugin $plugin_file"
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -plugin option" >&5
+$as_echo_n "checking for -plugin option... " >&6; }
+
plugin_names="liblto_plugin.so liblto_plugin-0.dll cyglto_plugin-0.dll"
+plugin_option=
for plugin in $plugin_names; do
plugin_so=`${CC} ${CFLAGS} --print-prog-name $plugin`
if test x$plugin_so = x$plugin; then
@@ -6493,7 +6758,119 @@ for plugin in $plugin_names; do
break
fi
done
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ar; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_AR+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$AR"; then
+ ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_AR="${ac_tool_prefix}ar"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+$as_echo "$AR" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_AR"; then
+ ac_ct_AR=$AR
+ # Extract the first word of "ar", so it can be a program name with args.
+set dummy ar; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_AR+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_AR"; then
+ ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_AR="ar"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+$as_echo "$ac_ct_AR" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_AR" = x; then
+ AR=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ AR=$ac_ct_AR
+ fi
+else
+ AR="$ac_cv_prog_AR"
+fi
+
+if test "${AR}" = "" ; then
+ as_fn_error $? "Required archive tool 'ar' not found on PATH." "$LINENO" 5
+fi
+touch conftest.c
+${AR} $plugin_option rc conftest.a conftest.c
+if test "$?" != 0; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Failed: $AR $plugin_option rc" >&5
+$as_echo "$as_me: WARNING: Failed: $AR $plugin_option rc" >&2;}
+ plugin_option=
+fi
+rm -f conftest.*
+if test -n "$plugin_option"; then
+ plugin_option="$plugin_option"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $plugin_option" >&5
+$as_echo "$plugin_option" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+fi
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
set dummy ${ac_tool_prefix}ar; ac_word=$2
@@ -6588,17 +6965,15 @@ fi
test -z "$AR" && AR=ar
if test -n "$plugin_option"; then
- if $AR --help 2>&1 | grep -q "\--plugin"; then
- touch conftest.c
- $AR $plugin_option rc conftest.a conftest.c
- if test "$?" != 0; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Failed: $AR $plugin_option rc" >&5
-$as_echo "$as_me: WARNING: Failed: $AR $plugin_option rc" >&2;}
- else
+ case "$AR" in
+ *"$plugin_option"*)
+ ;;
+ *)
+ if $AR --help 2>&1 | grep -q "\--plugin"; then
AR="$AR $plugin_option"
fi
- rm -f conftest.*
- fi
+ ;;
+ esac
fi
test -z "$AR_FLAGS" && AR_FLAGS=cru
@@ -6805,9 +7180,15 @@ fi
test -z "$RANLIB" && RANLIB=:
if test -n "$plugin_option" && test "$RANLIB" != ":"; then
- if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
- RANLIB="$RANLIB $plugin_option"
- fi
+ case "$RANLIB" in
+ *"$plugin_option"*)
+ ;;
+ *)
+ if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
+ RANLIB="$RANLIB $plugin_option"
+ fi
+ ;;
+ esac
fi
@@ -11507,7 +11888,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11510 "configure"
+#line 11891 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11613,7 +11994,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11616 "configure"
+#line 11997 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -19231,118 +19612,6 @@ fi
# Set the 'development' global.
. $srcdir/../bfd/development.sh
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
-$as_echo_n "checking for ANSI C header files... " >&6; }
-if ${ac_cv_header_stdc+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_header_stdc=yes
-else
- ac_cv_header_stdc=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-if test $ac_cv_header_stdc = yes; then
- # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "memchr" >/dev/null 2>&1; then :
-
-else
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "free" >/dev/null 2>&1; then :
-
-else
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
- if test "$cross_compiling" = yes; then :
- :
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <ctype.h>
-#include <stdlib.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) \
- (('a' <= (c) && (c) <= 'i') \
- || ('j' <= (c) && (c) <= 'r') \
- || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
- int i;
- for (i = 0; i < 256; i++)
- if (XOR (islower (i), ISLOWER (i))
- || toupper (i) != TOUPPER (i))
- return 2;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-
-else
- ac_cv_header_stdc=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
-$as_echo "$ac_cv_header_stdc" >&6; }
-if test $ac_cv_header_stdc = yes; then
-
-$as_echo "#define STDC_HEADERS 1" >>confdefs.h
-
-fi
-
# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
# for constant arguments. Useless!
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5
@@ -24882,6 +25151,18 @@ esac
fi
+# Check whether --enable-binary_file_formats was given.
+if test "${enable_binary_file_formats+set}" = set; then :
+ enableval=$enable_binary_file_formats; case "${enableval}" in
+ yes | "") as_fn_error $? "enable-binary-file-formats option must specify file formats or 'all'" "$LINENO" 5
+ ;;
+ no) enable_binary_file_formats= ;;
+ *) enable_binary_file_formats=$enableval ;;
+esac
+else
+ enable_binary_file_formats=all
+fi
+
# Check whether to support mdebug/ecoff debug information.
# Check whether --enable-gdb-mdebug-support was given.
@@ -24986,10 +25267,21 @@ TARGET_OBS=
all_targets=
HAVE_NATIVE_GCORE_TARGET=
+# File formats that will be enabled based on the selected
+# target(s). These are chosen because they are required to
+# compile one or more of the selected targets.
+target_formats=
+
+# If all targets were requested, this is all formats that should
+# accompany them. These are just the ones required for compilation
+# to succeed, not the formats suggested based on targets.
+all_target_formats="coff xcoff"
+
for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
do
if test "$targ_alias" = "all"; then
all_targets=true
+ target_formats=$all_target_formats
else
# Canonicalize the secondary target names.
result=`$ac_config_sub $targ_alias 2>/dev/null`
@@ -29150,118 +29442,6 @@ fi
# Checks for header files. #
# ------------------------- #
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
-$as_echo_n "checking for ANSI C header files... " >&6; }
-if ${ac_cv_header_stdc+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_header_stdc=yes
-else
- ac_cv_header_stdc=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-if test $ac_cv_header_stdc = yes; then
- # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "memchr" >/dev/null 2>&1; then :
-
-else
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "free" >/dev/null 2>&1; then :
-
-else
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
- if test "$cross_compiling" = yes; then :
- :
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <ctype.h>
-#include <stdlib.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) \
- (('a' <= (c) && (c) <= 'i') \
- || ('j' <= (c) && (c) <= 'r') \
- || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
- int i;
- for (i = 0; i < 256; i++)
- if (XOR (islower (i), ISLOWER (i))
- || toupper (i) != TOUPPER (i))
- return 2;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-
-else
- ac_cv_header_stdc=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
-$as_echo "$ac_cv_header_stdc" >&6; }
-if test $ac_cv_header_stdc = yes; then
-
-$as_echo "#define STDC_HEADERS 1" >>confdefs.h
-
-fi
-
for ac_header in \
IOKit/serial/ioss.h \
asm/termios.h \
@@ -31628,6 +31808,12 @@ fi
# Note that WIN32APILIBS is set by GDB_AC_COMMON.
WIN32LIBS="$WIN32LIBS $WIN32APILIBS"
+# Object files to be used when building with support for all file formats.
+# This should not have elf or macho, as support for those formats depends
+# on BFD enabling them as well.
+all_binary_file_srcs="\$(dbx_SRCS) \$(mips_SRCS) \$(coff_SRCS) \$(xcoff_SRCS)"
+
+bfd_supports_elf=no
# Add ELF support to GDB, but only if BFD includes ELF support.
OLD_CFLAGS=$CFLAGS
@@ -31645,7 +31831,7 @@ WIN32LIBS="$WIN32LIBS $WIN32APILIBS"
CC="./libtool --quiet --mode=link $CC"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ELF support in BFD" >&5
$as_echo_n "checking for ELF support in BFD... " >&6; }
-if ${gdb_cv_var_elf+:} false; then :
+if ${gdb_cv_var_bfd_elf+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -31664,24 +31850,23 @@ return bfd_get_elf_phdr_upper_bound (NULL);
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
- gdb_cv_var_elf=yes
+ gdb_cv_var_bfd_elf=yes
else
- gdb_cv_var_elf=no
+ gdb_cv_var_bfd_elf=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_var_elf" >&5
-$as_echo "$gdb_cv_var_elf" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_var_bfd_elf" >&5
+$as_echo "$gdb_cv_var_bfd_elf" >&6; }
CC=$OLD_CC
CFLAGS=$OLD_CFLAGS
LDFLAGS=$OLD_LDFLAGS
LIBS=$OLD_LIBS
-if test "$gdb_cv_var_elf" = yes; then
- CONFIG_OBS="$CONFIG_OBS elfread.o stap-probe.o dtrace-probe.o \
- gcore-elf.o elf-none-tdep.o"
+if test "$gdb_cv_var_bfd_elf" = yes; then
+ CONFIG_OBS="$CONFIG_OBS gcore-elf.o elf-none-tdep.o"
$as_echo "#define HAVE_ELF 1" >>confdefs.h
@@ -31744,9 +31929,12 @@ if test "$ac_res" != no; then :
fi
fi
+ bfd_supports_elf=yes
+ all_binary_file_srcs="$all_binary_file_srcs \$(elf_SRCS)"
fi
# Add macho support to GDB, but only if BFD includes it.
+bfd_supports_macho=no
OLD_CFLAGS=$CFLAGS
OLD_LDFLAGS=$LDFLAGS
@@ -31763,7 +31951,7 @@ fi
CC="./libtool --quiet --mode=link $CC"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mach-O support in BFD" >&5
$as_echo_n "checking for Mach-O support in BFD... " >&6; }
-if ${gdb_cv_var_macho+:} false; then :
+if ${gdb_cv_var_bfd_macho+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -31782,30 +31970,81 @@ return bfd_mach_o_lookup_command (NULL, 0, NULL);
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
- gdb_cv_var_macho=yes
+ gdb_cv_var_bfd_macho=yes
else
- gdb_cv_var_macho=no
+ gdb_cv_var_bfd_macho=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_var_macho" >&5
-$as_echo "$gdb_cv_var_macho" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_var_bfd_macho" >&5
+$as_echo "$gdb_cv_var_bfd_macho" >&6; }
CC=$OLD_CC
CFLAGS=$OLD_CFLAGS
LDFLAGS=$OLD_LDFLAGS
LIBS=$OLD_LIBS
-if test "$gdb_cv_var_macho" = yes; then
- CONFIG_OBS="$CONFIG_OBS machoread.o"
+if test "$gdb_cv_var_bfd_macho" = yes; then
+ bfd_supports_macho=yes
+ all_binary_file_srcs="$all_binary_file_srcs \$(macho_SRCS)"
fi
+FORMAT_SRCS=
+
+if test "$enable_binary_file_formats" != "all"; then
+ # Formats that are required by some requested target(s).
+ # Warn users that they are added, so no one is surprised.
+ for req in $target_formats; do
+ case ,$enable_binary_file_formats, in
+ *,$req,*)
+ # Do nothing.
+ ;;
+ *)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \"$req is required to support one or more requested targets. Adding it\"" >&5
+$as_echo "$as_me: WARNING: \"$req is required to support one or more requested targets. Adding it\"" >&2;}
+ enable_binary_file_formats="${enable_binary_file_formats},$req"
+ ;;
+ esac
+ done
+
+
+cat >>confdefs.h <<_ACEOF
+#define SUPPORTED_BINARY_FILE_FORMATS "$enable_binary_file_formats"
+_ACEOF
+
+fi
+
+enable_binary_file_formats=$(echo $enable_binary_file_formats | sed 's/,/ /g')
+
+# Go through all requested and required binary file formats to compile
+# GDB, and double check that we can compile them.
+for format in $enable_binary_file_formats
+do
+ if test "$format" = "elf" && test "$bfd_supports_elf" != "yes"; then
+ as_fn_error but BFD does not support it." "\"elf support was requested" "$LINENO" 5;
+ elif test "$format" = "macho" && test "$bfd_supports_macho" != "yes"; then
+ as_fn_error but BFD does not support it." "\"Mach-O support was requested" "$LINENO" 5;
+ fi
+
+ if test "$format" = "all"; then
+ FORMAT_SRCS="$all_binary_file_srcs"
+ # We don't break here in case the user requested Mach-O or ELF, but
+ # BFD is not configured to support it. If we were to break, we would
+ # silently drop the requested support instead of erroring out.
+ else
+ fmt=$(echo "$format _SRCS" | sed 's/ //')
+ FORMAT_SRCS="$FORMAT_SRCS \$($fmt)"
+ fi
+done
+
+
+
# Add any host-specific objects to GDB.
CONFIG_OBS="${CONFIG_OBS} ${gdb_host_obs}"
# If building on ELF, look for lzma support for embedded compressed debug info.
-if test "$gdb_cv_var_elf" = yes; then
+if test "$gdb_cv_var_bfd_elf" = yes; then
# Check whether --with-lzma was given.
if test "${with_lzma+set}" = set; then :
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 226e27e..5292410 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -191,6 +191,16 @@ AS_HELP_STRING([--enable-targets=TARGETS], [alternative target configurations]),
;;
esac])
+AC_ARG_ENABLE(binary_file_formats,
+ AS_HELP_STRING([--enable-binary-file-formats=FORMATS],
+ [enable support for selected file formats (default 'all')
+ available formats: coff, dbx, elf, macho, mips, xcoff, all]),
+[case "${enableval}" in
+ yes | "") AC_MSG_ERROR(enable-binary-file-formats option must specify file formats or 'all')
+ ;;
+ no) enable_binary_file_formats= ;;
+ *) enable_binary_file_formats=$enableval ;;
+esac], [enable_binary_file_formats=all])
# Check whether to support mdebug/ecoff debug information.
AC_ARG_ENABLE(gdb-mdebug-support,
@@ -240,10 +250,21 @@ TARGET_OBS=
all_targets=
HAVE_NATIVE_GCORE_TARGET=
+# File formats that will be enabled based on the selected
+# target(s). These are chosen because they are required to
+# compile one or more of the selected targets.
+target_formats=
+
+# If all targets were requested, this is all formats that should
+# accompany them. These are just the ones required for compilation
+# to succeed, not the formats suggested based on targets.
+all_target_formats="coff xcoff"
+
for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
do
if test "$targ_alias" = "all"; then
all_targets=true
+ target_formats=$all_target_formats
else
# Canonicalize the secondary target names.
result=`$ac_config_sub $targ_alias 2>/dev/null`
@@ -1355,7 +1376,6 @@ AC_SUBST(SRCHIGH_CFLAGS)
# Checks for header files. #
# ------------------------- #
-AC_HEADER_STDC
AC_CHECK_HEADERS([ \
IOKit/serial/ioss.h \
asm/termios.h \
@@ -1952,32 +1972,87 @@ fi
# Note that WIN32APILIBS is set by GDB_AC_COMMON.
WIN32LIBS="$WIN32LIBS $WIN32APILIBS"
+# Object files to be used when building with support for all file formats.
+# This should not have elf or macho, as support for those formats depends
+# on BFD enabling them as well.
+all_binary_file_srcs="\$(dbx_SRCS) \$(mips_SRCS) \$(coff_SRCS) \$(xcoff_SRCS)"
+
+bfd_supports_elf=no
# Add ELF support to GDB, but only if BFD includes ELF support.
-GDB_AC_CHECK_BFD([for ELF support in BFD], gdb_cv_var_elf,
+GDB_AC_CHECK_BFD([for ELF support in BFD], gdb_cv_var_bfd_elf,
[bfd_get_elf_phdr_upper_bound (NULL)], elf-bfd.h)
-if test "$gdb_cv_var_elf" = yes; then
- CONFIG_OBS="$CONFIG_OBS elfread.o stap-probe.o dtrace-probe.o \
- gcore-elf.o elf-none-tdep.o"
+if test "$gdb_cv_var_bfd_elf" = yes; then
+ CONFIG_OBS="$CONFIG_OBS gcore-elf.o elf-none-tdep.o"
AC_DEFINE(HAVE_ELF, 1,
[Define if ELF support should be included.])
# -ldl is provided by bfd/Makefile.am (LIBDL) <PLUGINS>.
if test "$plugins" = "yes"; then
AC_SEARCH_LIBS(dlopen, dl)
fi
+ bfd_supports_elf=yes
+ all_binary_file_srcs="$all_binary_file_srcs \$(elf_SRCS)"
fi
# Add macho support to GDB, but only if BFD includes it.
-GDB_AC_CHECK_BFD([for Mach-O support in BFD], gdb_cv_var_macho,
+bfd_supports_macho=no
+GDB_AC_CHECK_BFD([for Mach-O support in BFD], gdb_cv_var_bfd_macho,
[bfd_mach_o_lookup_command (NULL, 0, NULL)], mach-o.h)
-if test "$gdb_cv_var_macho" = yes; then
- CONFIG_OBS="$CONFIG_OBS machoread.o"
+if test "$gdb_cv_var_bfd_macho" = yes; then
+ bfd_supports_macho=yes
+ all_binary_file_srcs="$all_binary_file_srcs \$(macho_SRCS)"
+fi
+
+FORMAT_SRCS=
+
+if test "$enable_binary_file_formats" != "all"; then
+ # Formats that are required by some requested target(s).
+ # Warn users that they are added, so no one is surprised.
+ for req in $target_formats; do
+ case ,$enable_binary_file_formats, in
+ *,$req,*)
+ # Do nothing.
+ ;;
+ *)
+ AC_MSG_WARN("$req is required to support one or more requested targets. Adding it")
+ enable_binary_file_formats="${enable_binary_file_formats},$req"
+ ;;
+ esac
+ done
+
+ AC_DEFINE_UNQUOTED(SUPPORTED_BINARY_FILE_FORMATS, "$enable_binary_file_formats",
+ Which binary file formats were requested at configure time. )
fi
+enable_binary_file_formats=$(echo $enable_binary_file_formats | sed 's/,/ /g')
+
+# Go through all requested and required binary file formats to compile
+# GDB, and double check that we can compile them.
+for format in $enable_binary_file_formats
+do
+ if test "$format" = "elf" && test "$bfd_supports_elf" != "yes"; then
+ AC_MSG_ERROR("elf support was requested, but BFD does not support it.");
+ elif test "$format" = "macho" && test "$bfd_supports_macho" != "yes"; then
+ AC_MSG_ERROR("Mach-O support was requested, but BFD does not support it.");
+ fi
+
+ if test "$format" = "all"; then
+ FORMAT_SRCS="$all_binary_file_srcs"
+ # We don't break here in case the user requested Mach-O or ELF, but
+ # BFD is not configured to support it. If we were to break, we would
+ # silently drop the requested support instead of erroring out.
+ else
+ fmt=$(echo "$format _SRCS" | sed 's/ //')
+ FORMAT_SRCS="$FORMAT_SRCS \$($fmt)"
+ fi
+done
+
+AC_SUBST(FORMAT_SRCS)
+
# Add any host-specific objects to GDB.
CONFIG_OBS="${CONFIG_OBS} ${gdb_host_obs}"
# If building on ELF, look for lzma support for embedded compressed debug info.
-if test "$gdb_cv_var_elf" = yes; then
+if test "$gdb_cv_var_bfd_elf" = yes; then
AC_ARG_WITH(lzma,
AS_HELP_STRING([--with-lzma], [support lzma compression (auto/yes/no)]),
[], [with_lzma=auto])
diff --git a/gdb/configure.tgt b/gdb/configure.tgt
index 255c77e..34ae503 100644
--- a/gdb/configure.tgt
+++ b/gdb/configure.tgt
@@ -326,7 +326,7 @@ i[34567]86-*-linux*)
arch/x86-linux-tdesc-features.o"
if test "x$have_64_bit_bfd" = "xyes"; then
# Target: GNU/Linux x86-64
- gdb_target_obs="amd64-linux-tdep.o \
+ gdb_target_obs="amd64-linux-tdep.o svr4-tls-tdep.o \
arch/amd64-linux-tdesc.o ${gdb_target_obs}"
fi
;;
@@ -505,7 +505,7 @@ powerpc-*-openbsd*)
;;
powerpc-*-aix* | rs6000-*-* | powerpc64-*-aix*)
# Target: PowerPC running AIX
- gdb_target_obs="rs6000-tdep.o rs6000-aix-tdep.o xcoffread.o \
+ gdb_target_obs="rs6000-tdep.o rs6000-aix-tdep.o \
ppc-sysv-tdep.o solib-aix.o \
ravenscar-thread.o ppc-ravenscar-thread.o"
;;
@@ -522,8 +522,8 @@ powerpc*-*-linux*)
powerpc-*-lynx*178)
# Target: PowerPC running Lynx178.
gdb_target_obs="rs6000-tdep.o rs6000-lynx178-tdep.o \
- xcoffread.o ppc-sysv-tdep.o \
- ravenscar-thread.o ppc-ravenscar-thread.o"
+ ppc-sysv-tdep.o ravenscar-thread.o \
+ ppc-ravenscar-thread.o"
;;
powerpc*-*-*)
# Target: PowerPC running eabi
@@ -754,7 +754,7 @@ x86_64-*-rtems*)
;;
x86_64-*-gnu*)
# Target: x86_64 running the GNU Hurd
- gdb_target_obs="amd64-gnu-tdep.o glibc-tdep.o solib-svr4.o"
+ gdb_target_obs="amd64-gnu-tdep.o i386-gnu-tdep.o glibc-tdep.o solib-svr4.o"
;;
xtensa*-*-*linux*)
# Target: GNU/Linux Xtensa
@@ -835,3 +835,17 @@ for t in x ${gdb_target_obs}; do
gdb_have_gcore=true
fi
done
+
+# Decide which file formats are absolutely required based on
+# the requested targets. Warn later that they are added, in
+# case the user didn't manually request them, or all readers.
+# It's fine to add the same format multiple times since the
+# loop that reads the options to FORMAT_OBS will ensure that
+# they are only added once.
+for i in $gdb_target_obs; do
+ case "${i}" in
+ *"windows-tdep.o" ) target_formats="${target_formats} coff";;
+ "rs6000-aix-tdep.o" ) target_formats="${target_formats} xcoff";;
+ "rs6000-lynx178-tdep.o" ) target_formats="${target_formats} xcoff";;
+ esac
+done
diff --git a/gdb/copyright.py b/gdb/copyright.py
index bd854dc..425b7d2 100755
--- a/gdb/copyright.py
+++ b/gdb/copyright.py
@@ -191,11 +191,20 @@ def main(argv: list[str]) -> int | None:
if BY_HAND:
print()
print(
- "\033[31mREMINDER: The following files must be updated by hand." "\033[0m"
+ "\033[31mREMINDER: The following files must be updated by hand:" "\033[0m"
)
for filename in BY_HAND:
print(" ", filename)
+ print()
+ print(
+ "\033[31mREMINDER: The following files contain code to print a copyright "
+ "notice at runtime, they must be updated by hand:\033[0m"
+ )
+ print(" gdb/top.c")
+ print(" gdbserver/gdbreplay.cc")
+ print(" gdbserver/server.cc")
+
############################################################################
#
diff --git a/gdb/corelow.c b/gdb/corelow.c
index a74cb05..29eafe8 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -790,10 +790,13 @@ core_file_command (const char *filename, int from_tty)
.reg/1, .reg2/1, .reg/2, .reg2/2
After calling this function the rest of the core file handling code can
- treat this core file just like any other core file. */
+ treat this core file just like any other core file.
+
+ CBFD is the core file being loaded, and INF is the inferior through
+ which the core file will be examined. */
static void
-rename_vmcore_idle_reg_sections (bfd *abfd, inferior *inf)
+rename_vmcore_idle_reg_sections (bfd *cbfd, inferior *inf)
{
/* Map from the bfd section to its lwpid (the /NN number). */
std::vector<std::pair<asection *, int>> sections_and_lwpids;
@@ -808,7 +811,7 @@ rename_vmcore_idle_reg_sections (bfd *abfd, inferior *inf)
/* Look for all the .reg sections. Record the section object and the
lwpid which is extracted from the section name. Spot if any have an
lwpid of zero. */
- for (asection *sect : gdb_bfd_sections (current_program_space->core_bfd ()))
+ for (asection *sect : gdb_bfd_sections (cbfd))
{
if (startswith (bfd_section_name (sect), ".reg/"))
{
@@ -841,7 +844,7 @@ rename_vmcore_idle_reg_sections (bfd *abfd, inferior *inf)
std::string replacement_lwpid_str;
auto iter = sections_and_lwpids.begin ();
int replacement_lwpid = 0;
- for (asection *sect : gdb_bfd_sections (current_program_space->core_bfd ()))
+ for (asection *sect : gdb_bfd_sections (cbfd))
{
if (iter != sections_and_lwpids.end () && sect == iter->first)
{
@@ -879,7 +882,7 @@ rename_vmcore_idle_reg_sections (bfd *abfd, inferior *inf)
static_cast<int> (len - 2),
name, replacement_lwpid);
char *name_buf
- = static_cast<char *> (bfd_alloc (abfd, name_str.size () + 1));
+ = static_cast<char *> (bfd_alloc (cbfd, name_str.size () + 1));
if (name_buf == nullptr)
error (_("failed to allocate space for section name '%s'"),
name_str.c_str ());
@@ -1049,16 +1052,17 @@ core_target_open (const char *arg, int from_tty)
target_preopen (from_tty);
+ /* The target_preopen call will remove any existing process stratum
+ target, which includes any existing core_target. */
+ gdb_assert (current_inferior ()->process_target () == nullptr);
+
+ /* Which will clear up any existing core file BFD. */
+ gdb_assert (current_program_space->core_bfd () == nullptr);
+
std::string filename = extract_single_filename_arg (arg);
if (filename.empty ())
- {
- if (current_program_space->core_bfd ())
- error (_("No core file specified. (Use `detach' "
- "to stop debugging a core file.)"));
- else
- error (_("No core file specified."));
- }
+ error (_("No core file specified."));
if (!IS_ABSOLUTE_PATH (filename.c_str ()))
filename = gdb_abspath (filename);
@@ -1628,9 +1632,9 @@ core_target::xfer_partial (enum target_object object, const char *annex,
return TARGET_XFER_E_IO;
else
{
- *xfered_len = gdbarch_core_xfer_shared_libraries (m_core_gdbarch,
- readbuf,
- offset, len);
+ *xfered_len = gdbarch_core_xfer_shared_libraries
+ (m_core_gdbarch, *current_program_space->core_bfd (),
+ readbuf, offset, len);
if (*xfered_len == 0)
return TARGET_XFER_EOF;
@@ -1649,9 +1653,9 @@ core_target::xfer_partial (enum target_object object, const char *annex,
else
{
*xfered_len
- = gdbarch_core_xfer_shared_libraries_aix (m_core_gdbarch,
- readbuf, offset,
- len);
+ = gdbarch_core_xfer_shared_libraries_aix
+ (m_core_gdbarch, *current_program_space->core_bfd (),
+ readbuf, offset, len);
if (*xfered_len == 0)
return TARGET_XFER_EOF;
@@ -1667,8 +1671,10 @@ core_target::xfer_partial (enum target_object object, const char *annex,
if (m_core_gdbarch != nullptr
&& gdbarch_core_xfer_siginfo_p (m_core_gdbarch))
{
- LONGEST l = gdbarch_core_xfer_siginfo (m_core_gdbarch, readbuf,
- offset, len);
+ struct bfd *cbfd = current_program_space->core_bfd ();
+ gdb_assert (cbfd != nullptr);
+ LONGEST l = gdbarch_core_xfer_siginfo (m_core_gdbarch, *cbfd,
+ readbuf, offset, len);
if (l >= 0)
{
@@ -1794,7 +1800,11 @@ core_target::thread_name (struct thread_info *thr)
{
if (m_core_gdbarch != nullptr
&& gdbarch_core_thread_name_p (m_core_gdbarch))
- return gdbarch_core_thread_name (m_core_gdbarch, thr);
+ {
+ bfd *cbfd = current_program_space->core_bfd ();
+ gdb_assert (cbfd != nullptr);
+ return gdbarch_core_thread_name (m_core_gdbarch, *cbfd, thr);
+ }
return NULL;
}
@@ -1826,7 +1836,8 @@ core_target::info_proc (const char *args, enum info_proc_what request)
/* Since this is the core file target, call the 'core_info_proc'
method on gdbarch, not 'info_proc'. */
if (gdbarch_core_info_proc_p (gdbarch))
- gdbarch_core_info_proc (gdbarch, args, request);
+ gdbarch_core_info_proc (gdbarch, current_program_space->core_bfd (),
+ args, request);
return true;
}
@@ -1901,7 +1912,9 @@ core_target::fetch_x86_xsave_layout ()
gdbarch_core_read_x86_xsave_layout_p (m_core_gdbarch))
{
x86_xsave_layout layout;
- if (!gdbarch_core_read_x86_xsave_layout (m_core_gdbarch, layout))
+ bfd *cbfd = current_program_space->core_bfd ();
+ gdb_assert (cbfd != nullptr);
+ if (!gdbarch_core_read_x86_xsave_layout (m_core_gdbarch, *cbfd, layout))
return {};
return layout;
diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y
index cafd6b2..7221b78 100644
--- a/gdb/cp-name-parser.y
+++ b/gdb/cp-name-parser.y
@@ -39,7 +39,6 @@
#include <unistd.h>
-#include "gdbsupport/gdb-safe-ctype.h"
#include "demangle.h"
#include "cp-support.h"
#include "c-support.h"
@@ -1362,7 +1361,7 @@ cpname_state::parse_number (const char *p, int len, int parsed_float,
/* See if it has `f' or `l' suffix (float or long double). */
- c = TOLOWER (p[len - 1]);
+ c = c_tolower (p[len - 1]);
if (c == 'f')
{
@@ -1374,7 +1373,7 @@ cpname_state::parse_number (const char *p, int len, int parsed_float,
len--;
type = make_builtin_type ("long double");
}
- else if (ISDIGIT (c) || c == '.')
+ else if (c_isdigit (c) || c == '.')
type = make_builtin_type ("double");
else
return ERROR;
@@ -1439,10 +1438,10 @@ cpname_state::parse_number (const char *p, int len, int parsed_float,
for (int off = 0; off < len; ++off)
{
int dig;
- if (ISDIGIT (p[off]))
+ if (c_isdigit (p[off]))
dig = p[off] - '0';
else
- dig = TOLOWER (p[off]) - 'a' + 10;
+ dig = c_tolower (p[off]) - 'a' + 10;
if (dig >= base)
return ERROR;
value *= base;
@@ -1769,7 +1768,7 @@ yylex (YYSTYPE *lvalp, cpname_state *state)
}
/* We will take any letters or digits. parse_number will
complain if past the radix, or if L or U are not final. */
- else if (! ISALNUM (*p))
+ else if (! c_isalnum (*p))
break;
if (no_tick.has_value ())
no_tick->push_back (*p);
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index cab7110..7cfb545 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -35,7 +35,6 @@
#include "namespace.h"
#include <signal.h>
#include "gdbsupport/gdb_setjmp.h"
-#include "gdbsupport/gdb-safe-ctype.h"
#include "gdbsupport/selftest.h"
#include "gdbsupport/gdb-sigmask.h"
#include <atomic>
@@ -105,7 +104,7 @@ static int
cp_already_canonical (const char *string)
{
/* Identifier start character [a-zA-Z_]. */
- if (!ISIDST (string[0]))
+ if (!c_isalpha (string[0]) || string[0] == '_')
return 0;
/* These are the only two identifiers which canonicalize to other
@@ -117,7 +116,7 @@ cp_already_canonical (const char *string)
return 0;
/* Identifier character [a-zA-Z0-9_]. */
- while (ISIDNUM (string[1]))
+ while (c_isalpha (string[1]) || c_isdigit (string[1]) || string[1] == '_')
string++;
if (string[1] == '\0')
@@ -150,7 +149,8 @@ inspect_type (struct demangle_parse_info *info,
try
{
- sym = lookup_symbol (name, 0, SEARCH_VFT, 0).symbol;
+ sym = lookup_symbol (name, 0, (SEARCH_TYPE_DOMAIN
+ | SEARCH_STRUCT_DOMAIN), 0).symbol;
}
catch (const gdb_exception &except)
{
@@ -504,7 +504,8 @@ replace_typedefs (struct demangle_parse_info *info,
try
{
sym = lookup_symbol (local_name.get (), 0,
- SEARCH_VFT, 0).symbol;
+ (SEARCH_TYPE_DOMAIN
+ | SEARCH_STRUCT_DOMAIN), 0).symbol;
}
catch (const gdb_exception &except)
{
@@ -1135,7 +1136,7 @@ cp_find_first_component_aux (const char *name, int permissive)
&& startswith (name + index, CP_OPERATOR_STR))
{
index += CP_OPERATOR_LEN;
- while (ISSPACE(name[index]))
+ while (c_isspace(name[index]))
++index;
switch (name[index])
{
@@ -1472,17 +1473,14 @@ add_symbol_overload_list_qualified (const char *func_name,
? selected_block->objfile ()
: nullptr);
- gdbarch_iterate_over_objfiles_in_search_order
- (current_objfile ? current_objfile->arch () : current_inferior ()->arch (),
- [func_name, surrounding_static_block, &overload_list]
+ lookup_name_info base_lookup (func_name, symbol_name_match_type::FULL);
+ lookup_name_info lookup_name = base_lookup.make_ignore_params ();
+
+ current_program_space->iterate_over_objfiles_in_search_order
+ ([func_name, surrounding_static_block, &overload_list, lookup_name]
(struct objfile *obj)
{
- /* Look through the partial symtabs for all symbols which
- begin by matching FUNC_NAME. Make sure we read that
- symbol table in. */
- obj->expand_symtabs_for_function (func_name);
-
- for (compunit_symtab *cust : obj->compunits ())
+ auto callback = [&] (compunit_symtab *cust)
{
QUIT;
const struct block *b = cust->blockvector ()->global_block ();
@@ -1490,11 +1488,17 @@ add_symbol_overload_list_qualified (const char *func_name,
b = cust->blockvector ()->static_block ();
/* Don't do this block twice. */
- if (b == surrounding_static_block)
- continue;
+ if (b != surrounding_static_block)
+ add_symbol_overload_list_block (func_name, b, overload_list);
+ return true;
+ };
- add_symbol_overload_list_block (func_name, b, overload_list);
- }
+ /* Look through the partial symtabs for all symbols which
+ begin by matching FUNC_NAME. Make sure we read that
+ symbol table in. */
+ obj->search (nullptr, &lookup_name, nullptr, callback,
+ SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
+ SEARCH_FUNCTION_DOMAIN);
return 0;
}, current_objfile);
@@ -1518,7 +1522,7 @@ cp_lookup_rtti_type (const char *name, const struct block *block)
return NULL;
}
- if (rtti_sym->aclass () != LOC_TYPEDEF)
+ if (rtti_sym->loc_class () != LOC_TYPEDEF)
{
warning (_("RTTI symbol for class '%s' is not a type"), name);
return NULL;
@@ -2349,7 +2353,7 @@ find_toplevel_char (const char *s, char c)
scan += CP_OPERATOR_LEN;
if (*scan == c)
return scan;
- while (ISSPACE (*scan))
+ while (c_isspace (*scan))
{
++scan;
if (*scan == c)
diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index b49e641..9cfc1eb 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -3993,7 +3993,7 @@ cris_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_cannot_store_register (gdbarch, cris_cannot_store_register);
set_gdbarch_cannot_fetch_register (gdbarch, cris_cannot_fetch_register);
- set_gdbarch_software_single_step (gdbarch, cris_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, cris_software_single_step);
break;
case 32:
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index e568f15..4761b36 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -328,7 +328,7 @@ set_symbol_address (struct objfile *of, struct symbol *sym, const char *name)
if (msym.minsym != NULL)
{
sym->set_value_address (msym.value_address ());
- sym->set_aclass_index (LOC_STATIC);
+ sym->set_loc_class_index (LOC_STATIC);
sym->set_section_index (msym.minsym->section_index ());
}
}
@@ -447,7 +447,7 @@ ctf_add_enum_member_cb (const char *name, int enum_value, void *arg)
sym->set_language (language_c, &ccp->of->objfile_obstack);
sym->compute_and_set_names (name, false, ccp->of->per_bfd);
- sym->set_aclass_index (LOC_CONST);
+ sym->set_loc_class_index (LOC_CONST);
sym->set_domain (VAR_DOMAIN);
sym->set_type (fip->ptype);
add_symbol_to_list (sym, ccp->builder->get_global_symbols ());
@@ -477,7 +477,7 @@ new_symbol (struct ctf_context *ccp, struct type *type, ctf_id_t tid)
sym->set_language (language_c, &objfile->objfile_obstack);
sym->compute_and_set_names (name, false, objfile->per_bfd);
sym->set_domain (VAR_DOMAIN);
- sym->set_aclass_index (LOC_OPTIMIZED_OUT);
+ sym->set_loc_class_index (LOC_OPTIMIZED_OUT);
if (type != nullptr)
sym->set_type (type);
@@ -488,11 +488,11 @@ new_symbol (struct ctf_context *ccp, struct type *type, ctf_id_t tid)
case CTF_K_STRUCT:
case CTF_K_UNION:
case CTF_K_ENUM:
- sym->set_aclass_index (LOC_TYPEDEF);
+ sym->set_loc_class_index (LOC_TYPEDEF);
sym->set_domain (STRUCT_DOMAIN);
break;
case CTF_K_FUNCTION:
- sym->set_aclass_index (LOC_STATIC);
+ sym->set_loc_class_index (LOC_STATIC);
set_symbol_address (objfile, sym, sym->linkage_name ());
break;
case CTF_K_CONST:
@@ -502,7 +502,7 @@ new_symbol (struct ctf_context *ccp, struct type *type, ctf_id_t tid)
case CTF_K_TYPEDEF:
case CTF_K_INTEGER:
case CTF_K_FLOAT:
- sym->set_aclass_index (LOC_TYPEDEF);
+ sym->set_loc_class_index (LOC_TYPEDEF);
sym->set_domain (TYPE_DOMAIN);
break;
case CTF_K_POINTER:
@@ -516,7 +516,7 @@ new_symbol (struct ctf_context *ccp, struct type *type, ctf_id_t tid)
break;
}
- add_symbol_to_list (sym, ccp->builder->get_file_symbols ());
+ add_symbol_to_list (sym, ccp->builder->get_global_symbols ());
}
return sym;
@@ -1169,9 +1169,9 @@ ctf_add_var_cb (const char *name, ctf_id_t id, void *arg)
OBJSTAT (ccp->of, n_syms++);
sym->set_type (type);
sym->set_domain (VAR_DOMAIN);
- sym->set_aclass_index (LOC_OPTIMIZED_OUT);
+ sym->set_loc_class_index (LOC_OPTIMIZED_OUT);
sym->compute_and_set_names (name, false, ccp->of->per_bfd);
- add_symbol_to_list (sym, ccp->builder->get_file_symbols ());
+ add_symbol_to_list (sym, ccp->builder->get_global_symbols ());
break;
default:
complaint (_("ctf_add_var_cb: kind unsupported (%d)"), kind);
@@ -1205,7 +1205,7 @@ add_stt_entries (struct ctf_context *ccp, int functions)
OBJSTAT (ccp->of, n_syms++);
sym->set_type (type);
sym->set_domain (VAR_DOMAIN);
- sym->set_aclass_index (LOC_STATIC);
+ sym->set_loc_class_index (LOC_STATIC);
sym->compute_and_set_names (tname, false, ccp->of->per_bfd);
add_symbol_to_list (sym, ccp->builder->get_global_symbols ());
set_symbol_address (ccp->of, sym, tname);
@@ -1309,7 +1309,7 @@ ctf_psymtab_add_stt_entries (ctf_dict_t *cfp, ctf_psymtab *pst,
while ((tid = ctf_symbol_next (cfp, &i, &tname, functions)) != CTF_ERR)
{
uint32_t kind = ctf_type_kind (cfp, tid);
- address_class aclass;
+ location_class loc_class;
domain_enum tdomain;
switch (kind)
{
@@ -1324,14 +1324,14 @@ ctf_psymtab_add_stt_entries (ctf_dict_t *cfp, ctf_psymtab *pst,
}
if (kind == CTF_K_FUNCTION)
- aclass = LOC_STATIC;
+ loc_class = LOC_STATIC;
else if (kind == CTF_K_CONST)
- aclass = LOC_CONST;
+ loc_class = LOC_CONST;
else
- aclass = LOC_TYPEDEF;
+ loc_class = LOC_TYPEDEF;
pst->add_psymbol (tname, true,
- tdomain, aclass, -1,
+ tdomain, loc_class, -1,
psymbol_placement::GLOBAL,
unrelocated_addr (0),
language_c, pst->context.partial_symtabs, of);
@@ -1465,7 +1465,7 @@ ctf_psymtab_type_cb (ctf_id_t tid, void *arg)
ccp = (struct ctf_context *) arg;
domain_enum domain = UNDEF_DOMAIN;
- enum address_class aclass = LOC_UNDEF;
+ location_class loc_class = LOC_UNDEF;
kind = ctf_type_kind (ccp->fp, tid);
switch (kind)
{
@@ -1475,29 +1475,29 @@ ctf_psymtab_type_cb (ctf_id_t tid, void *arg)
case CTF_K_STRUCT:
case CTF_K_UNION:
domain = STRUCT_DOMAIN;
- aclass = LOC_TYPEDEF;
+ loc_class = LOC_TYPEDEF;
break;
case CTF_K_FUNCTION:
case CTF_K_FORWARD:
domain = VAR_DOMAIN;
- aclass = LOC_STATIC;
+ loc_class = LOC_STATIC;
section = SECT_OFF_TEXT (ccp->of);
break;
case CTF_K_CONST:
domain = VAR_DOMAIN;
- aclass = LOC_STATIC;
+ loc_class = LOC_STATIC;
break;
case CTF_K_TYPEDEF:
case CTF_K_POINTER:
case CTF_K_VOLATILE:
case CTF_K_RESTRICT:
domain = VAR_DOMAIN;
- aclass = LOC_TYPEDEF;
+ loc_class = LOC_TYPEDEF;
break;
case CTF_K_INTEGER:
case CTF_K_FLOAT:
domain = VAR_DOMAIN;
- aclass = LOC_TYPEDEF;
+ loc_class = LOC_TYPEDEF;
break;
case CTF_K_ARRAY:
case CTF_K_UNKNOWN:
@@ -1509,8 +1509,8 @@ ctf_psymtab_type_cb (ctf_id_t tid, void *arg)
return 0;
ccp->pst->add_psymbol (name, false,
- domain, aclass, section,
- psymbol_placement::STATIC,
+ domain, loc_class, section,
+ psymbol_placement::GLOBAL,
unrelocated_addr (0),
language_c, ccp->partial_symtabs, ccp->of);
diff --git a/gdb/d-exp.y b/gdb/d-exp.y
index e0ee758..e774dee 100644
--- a/gdb/d-exp.y
+++ b/gdb/d-exp.y
@@ -38,7 +38,6 @@
%{
-#include <ctype.h>
#include "expression.h"
#include "value.h"
#include "parser-defs.h"
@@ -444,7 +443,7 @@ PrimaryExpression:
sym = lookup_symbol (copy.c_str (),
pstate->expression_context_block,
SEARCH_VFT, &is_a_field_of_this);
- if (sym.symbol && sym.symbol->aclass () != LOC_TYPEDEF)
+ if (sym.symbol && sym.symbol->loc_class () != LOC_TYPEDEF)
{
if (symbol_read_needs_frame (sym.symbol))
pstate->block_tracker->update (sym);
@@ -614,11 +613,9 @@ BasicType2:
| '*' BasicType2
{ type_stack->push (tp_pointer); }
| '[' INTEGER_LITERAL ']'
- { type_stack->push ($2.val);
- type_stack->push (tp_array); }
+ { type_stack->push (tp_array, $2.val); }
| '[' INTEGER_LITERAL ']' BasicType2
- { type_stack->push ($2.val);
- type_stack->push (tp_array); }
+ { type_stack->push (tp_array, $2.val); }
;
BasicType:
@@ -684,15 +681,15 @@ parse_number (struct parser_state *ps, const char *p,
len = strlen (s);
/* Check suffix for `i' , `fi' or `li' (idouble, ifloat or ireal). */
- if (len >= 1 && tolower (s[len - 1]) == 'i')
+ if (len >= 1 && c_tolower (s[len - 1]) == 'i')
{
- if (len >= 2 && tolower (s[len - 2]) == 'f')
+ if (len >= 2 && c_tolower (s[len - 2]) == 'f')
{
putithere->typed_val_float.type
= parse_d_type (ps)->builtin_ifloat;
len -= 2;
}
- else if (len >= 2 && tolower (s[len - 2]) == 'l')
+ else if (len >= 2 && c_tolower (s[len - 2]) == 'l')
{
putithere->typed_val_float.type
= parse_d_type (ps)->builtin_ireal;
@@ -706,13 +703,13 @@ parse_number (struct parser_state *ps, const char *p,
}
}
/* Check suffix for `f' or `l'' (float or real). */
- else if (len >= 1 && tolower (s[len - 1]) == 'f')
+ else if (len >= 1 && c_tolower (s[len - 1]) == 'f')
{
putithere->typed_val_float.type
= parse_d_type (ps)->builtin_float;
len -= 1;
}
- else if (len >= 1 && tolower (s[len - 1]) == 'l')
+ else if (len >= 1 && c_tolower (s[len - 1]) == 'l')
{
putithere->typed_val_float.type
= parse_d_type (ps)->builtin_real;
@@ -1133,8 +1130,8 @@ lex_one_token (struct parser_state *par_state)
/* Hex exponents start with 'p', because 'e' is a valid hex
digit and thus does not indicate a floating point number
when the radix is hex. */
- if ((!hex && !got_e && tolower (p[0]) == 'e')
- || (hex && !got_e && tolower (p[0] == 'p')))
+ if ((!hex && !got_e && c_tolower (p[0]) == 'e')
+ || (hex && !got_e && c_tolower (p[0] == 'p')))
got_dot = got_e = 1;
/* A '.' always indicates a decimal floating point number
regardless of the radix. If we have a '..' then its the
@@ -1142,7 +1139,8 @@ lex_one_token (struct parser_state *par_state)
else if (!got_dot && (p[0] == '.' && p[1] != '.'))
got_dot = 1;
/* This is the sign of the exponent, not the end of the number. */
- else if (got_e && (tolower (p[-1]) == 'e' || tolower (p[-1]) == 'p')
+ else if (got_e && (c_tolower (p[-1]) == 'e'
+ || c_tolower (p[-1]) == 'p')
&& (*p == '-' || *p == '+'))
continue;
/* We will take any letters or digits, ignoring any embedded '_'.
@@ -1167,9 +1165,9 @@ lex_one_token (struct parser_state *par_state)
const char *p = &tokstart[1];
size_t len = strlen ("entry");
- while (isspace (*p))
+ while (c_isspace (*p))
p++;
- if (strncmp (p, "entry", len) == 0 && !isalnum (p[len])
+ if (strncmp (p, "entry", len) == 0 && !c_isalnum (p[len])
&& p[len] != '_')
{
pstate->lexptr = &p[len];
@@ -1334,7 +1332,7 @@ classify_name (struct parser_state *par_state, const struct block *block)
std::string copy = copy_name (yylval.sval);
sym = lookup_symbol (copy.c_str (), block, SEARCH_VFT, &is_a_field_of_this);
- if (sym.symbol && sym.symbol->aclass () == LOC_TYPEDEF)
+ if (sym.symbol && sym.symbol->loc_class () == LOC_TYPEDEF)
{
yylval.tsym.type = sym.symbol->type ();
return TYPENAME;
@@ -1383,7 +1381,7 @@ classify_inner_name (struct parser_state *par_state,
if (yylval.ssym.sym.symbol == NULL)
return ERROR;
- if (yylval.ssym.sym.symbol->aclass () == LOC_TYPEDEF)
+ if (yylval.ssym.sym.symbol->loc_class () == LOC_TYPEDEF)
{
yylval.tsym.type = yylval.ssym.sym.symbol->type ();
return TYPENAME;
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 7acf639..e73b5a1 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -47,7 +47,6 @@
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
-#include <ctype.h>
#include <sys/sysctl.h>
#include <sys/proc.h>
#include <libproc.h>
diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in
index 2ca2b8e..d7f4c98 100644
--- a/gdb/data-directory/Makefile.in
+++ b/gdb/data-directory/Makefile.in
@@ -61,6 +61,7 @@ GEN_SYSCALLS_FILES = \
mips-o32-linux.xml \
ppc-linux.xml \
ppc64-linux.xml \
+ riscv-linux.xml \
s390-linux.xml \
s390x-linux.xml \
sparc-linux.xml \
diff --git a/gdb/dictionary.c b/gdb/dictionary.c
index 28e900d..e53331b 100644
--- a/gdb/dictionary.c
+++ b/gdb/dictionary.c
@@ -20,12 +20,10 @@
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 <ctype.h>
#include "gdbsupport/gdb_obstack.h"
#include "symtab.h"
#include "buildsym.h"
#include "dictionary.h"
-#include "gdbsupport/gdb-safe-ctype.h"
#include "gdbsupport/unordered_map.h"
#include "language.h"
@@ -772,7 +770,7 @@ language_defn::search_name_hash (const char *string0) const
if (c == 'B' && string[3] == '_')
{
- for (string += 4; ISDIGIT (*string); ++string)
+ for (string += 4; c_isdigit (*string); ++string)
;
continue;
}
diff --git a/gdb/disasm.c b/gdb/disasm.c
index b731192..c8e830e 100644
--- a/gdb/disasm.c
+++ b/gdb/disasm.c
@@ -28,7 +28,6 @@
#include "cli/cli-cmds.h"
#include "dis-asm.h"
#include "source.h"
-#include "gdbsupport/gdb-safe-ctype.h"
#include <algorithm>
#include <optional>
#include "valprint.h"
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 2bbaf14..a13d5c0 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -898,14 +898,17 @@ debugger attached to a bare board, there may not be any notion of
``process'', and there is often no way to get a core dump. @value{GDBN}
will warn you if it is unable to attach or to read core dumps.
-You can optionally have @code{@value{GDBP}} pass any arguments after the
-executable file to the inferior using @code{--args}. This option stops
-option processing.
+You can optionally have @code{@value{GDBP}} pass any arguments after
+the executable file to the inferior using @code{--args} or
+@code{--no-escape-args}. These options stop option processing.
@smallexample
@value{GDBP} --args gcc -O2 -c foo.c
@end smallexample
This will cause @code{@value{GDBP}} to debug @code{gcc}, and to set
-@code{gcc}'s command-line arguments (@pxref{Arguments}) to @samp{-O2 -c foo.c}.
+@code{gcc}'s command-line arguments (@pxref{Arguments}) to @samp{-O2
+-c foo.c}. For the differences between @code{--args} and
+@code{--no-escape-args}, see @ref{--args and --no-escape-args options,
+,@code{--args} and @code{--no-escape-args}}.
You can run @code{@value{GDBP}} without printing the front material, which describes
@value{GDBN}'s non-warranty, by specifying @code{--silent}
@@ -1212,6 +1215,17 @@ Run @value{GDBN} using @var{directory} as its data directory.
The data directory is where @value{GDBN} searches for its
auxiliary files. @xref{Data Files}.
+@item -binary-output
+@cindex @code{--binary-output}
+
+Instructs @value{GDBN} to set the translation mode of its
+@code{stdout}/@code{stderr} to binary. MS-Windows only. Useful for
+running the @value{GDBN} testsuite. By default, @value{GDBN} opens
+@code{stdout}/@code{stderr} in text mode, and translates @samp{\n}
+(LF, a single Line Feed) into @samp{\r\n} (CR-LF, a Carriage
+Return-Line Feed combination). If this option is set, no translation
+is done.
+
@item -fullname
@itemx -f
@cindex @code{--fullname}
@@ -1240,12 +1254,67 @@ that control @value{GDBN}, and level 2 has been deprecated.
The annotation mechanism has largely been superseded by @sc{gdb/mi}
(@pxref{GDB/MI}).
+@anchor{--args and --no-escape-args options}
@item --args
@cindex @code{--args}
Change interpretation of command line so that arguments following the
executable file are passed as command line arguments to the inferior.
This option stops option processing.
+Arguments supplied using @code{--args} will have backslashes applied
+to escape any special shell characters. This ensures that when the
+inferior starts it is passed arguments exactly as @value{GDBN}
+receives them.
+
+For example, consider the following command run under a shell:
+
+@smallexample
+$ @value{GDBP} --args ls *.c
+@end smallexample
+
+@noindent
+In this case the shell will expand @kbd{*.c} at the time @value{GDBN}
+is invoked, not at the time that the inferior is invoked. As a
+result, if an additional @kbd{.c} file is created after @value{GDBN}
+is started, but before the inferior is started, then the inferior will
+not show the file in its output; the list of matching files was
+resolved at the time @value{GDBN} was started.
+
+If you quote the @kbd{*} character used on the @value{GDBN} command
+line argument then this will prevent the shell that starts
+@value{GDBN} from expanding the @kbd{*.c} pattern, however, this
+quoting will also be passed to the shell that @value{GDBN} invokes in
+order to start the inferior (@pxref{set startup-with-shell}), and this
+will prevent the @kbd{*.c} pattern being expanded at this point either:
+
+@smallexample
+$ @value{GDBP} --args ls '*.c'
+(@value{GDBP}) show args
+Argument list to give program being debugged when it is started is "\*.log".
+@end smallexample
+
+@noindent
+If this quoting behaviour does not meet your needs, then you could use
+@code{--no-escape-args} instead, which is described below.
+
+@item --no-escape-args
+@cindex @code{--no-escape-args}
+Change interpretation of command line so that arguments following the
+executable file are passed as command line arguments to the inferior.
+This option stops option processing.
+
+Unlike @code{--args}, arguments after the executable name will not
+have any escaping applied to them. As a result, any special shell
+characters that are not expanded by the shell that invokes
+@value{GDBN} will be expanded by the shell that @value{GDBN} uses to
+start the inferior.
+
+@smallexample
+$ @value{GDBP} --no-escape-args ls '*.c'
+(@value{GDBP}) show args
+Argument list to give program being debugged when it is started is "*.log".
+@end smallexample
+
@item -baud @var{bps}
@itemx -b @var{bps}
@cindex @code{--baud}
@@ -13104,11 +13173,11 @@ variable which may be @samp{truecolor} or @samp{24bit}. Other color spaces are
determined by the "Co" termcap which in turn depends on the @env{TERM}
environment variable.
-@vindex $_active_linker_namespaces@r{, convenience variable}
-@item $_active_linker_namespaces
+@vindex $_linker_namespace_count@r{, convenience variable}
+@item $_linker_namespace_count
Number of active linker namespaces in the inferior (@pxref{Files}). In systems
-with no support for linker namespaces, this variable will always be set to
-@samp{1}.
+with no support for linker namespaces or if the inferior hasn't started, this
+variable will always be set to @samp{0}.
@vindex $_linker_namespace@r{, convenience variable}
@item $_linker_namespace
@@ -26996,6 +27065,32 @@ information automatically from the core file, and will show one of the above
messages depending on whether the synchronous or asynchronous mode is selected.
@xref{Memory Tagging}. @xref{Memory}.
+@subsubsection AArch64 Guarded Control Stack
+@cindex Guarded Control Stack, AArch64
+@cindex GCS, AArch64
+
+When @value{GDBN} is debugging the AArch64 architecture, the program is
+using the feature Guarded Control Stack (GCS), the operating system kernel
+is Linux and it supports GCS, @value{GDBN} will make a couple of special
+registers --- @code{gcs_features_enabled} and @code{gcs_features_locked}
+--- available through the @code{org.gnu.gdb.aarch64.gcs.linux} feature.
+These registers expose some options that can be controlled at runtime and
+emulate the @code{prctl} option @code{PR_SET_SHADOW_STACK_STATUS}. For
+further information, see the
+@uref{https://www.kernel.org/doc/html/latest/arch/arm64/gcs.html,ignored,
+documentation} in the Linux kernel.
+
+Naturally the Guarded Control Stack pointer at @code{EL0} is also
+available, as the @code{gcspr} register.
+
+To aid debugging, @value{GDBN} will note when SIGSEGV signals are generated
+as a result of a Guarded Control Stack error:
+
+@smallexample
+Program received signal SIGSEGV, Segmentation fault
+Guarded Control Stack error.
+@end smallexample
+
@node x86
@subsection x86
@@ -27037,6 +27132,46 @@ registers
@end itemize
+@subsubsection Intel Control-Flow Enforcement Technology.
+@cindex Intel Control-Flow Enforcement Technology.
+
+The @dfn{Intel Control-Flow Enforcement Technology} (@acronym{Intel CET})
+provides two capabilities to defend against ``Return-oriented Programming''
+and ``call/jmp-oriented programming'' style control-flow attacks:
+
+@itemize @bullet
+@item Shadow Stack:
+A shadow stack is a second stack for a program. It holds the return
+addresses pushed by the call instruction. The @code{RET} instruction pops the
+return addresses from both call and shadow stack. If the return addresses from
+the two stacks do not match, the processor signals a control protection
+exception.
+@item Indirect Branch Tracking (IBT):
+When IBT is enabled, the CPU implements a state machine that tracks
+indirect @code{JMP} and @code{CALL} instructions. The state machine can
+be either IDLE or WAIT_FOR_ENDBRANCH. When a @code{JMP} or @code{CALL} is
+executed the state machine chages to the WAIT_FOR_ENDBRANCH state. In
+WAIT_FOR_ENDBRANCH state the next instruction in the program stream
+must be an @code{ENDBR} instruction, otherwise the processor signals a
+control protection exception. After executing a @code{ENDBR} instruction
+the state machine returns to the IDLE state.
+@end itemize
+
+Impact on @value{GDBN} commands:
+@itemize @bullet
+@item Call/Print:
+Inferior calls in @value{GDBN} reset the current PC to the beginning of the
+function that is called. No call instruction is executed, but the @code{RET}
+instruction actually is. To avoid a control protection exception due to the
+missing return address on the shadow stack, @value{GDBN} pushes the new return
+address to the shadow stack and updates the shadow stack pointer.
+@item Step:
+With displaced stepping, @value{GDBN} may run an out of line copy of a call
+instruction. In this case, the wrong return address is pushed to the shadow
+stack. @value{GDBN} corrects this value to avoid a control protection
+exception. For more details on displaced stepping, see @ref{displaced-stepping}.
+@end itemize
+
@node Alpha
@subsection Alpha
@@ -38880,7 +39015,7 @@ Example output:
@smallexample
(gdb) -list-features
-^done,result=["feature1","feature2"]
+^done,features=["feature1","feature2"]
@end smallexample
The current list of features is:
@@ -38945,7 +39080,7 @@ Example output:
@smallexample
(gdb) -list-target-features
-^done,result=["async"]
+^done,features=["async"]
@end smallexample
The current list of features is:
@@ -41277,6 +41412,14 @@ Configure @value{GDBN} for cross-debugging programs running on the
specified list of targets. The special value @samp{all} configures
@value{GDBN} for debugging programs running on any target it supports.
+@item --enable-binary-file-formats=@r{[}@var{format}@r{]}@dots{}
+@itemx --enable-binary-file-formats=all
+Configure @value{GDBN} to support certain binary file formats. If a
+format is the main (or only) file format for a given target, the
+configure script may add support to it anyway, and warn the user.
+If not given, all file formats that @value{GDBN} supports are compiled
+in.
+
@item --with-gdb-datadir=@var{path}
Set the @value{GDBN}-specific data directory. @value{GDBN} will look
here for certain supporting files or scripts. This defaults to the
@@ -41722,6 +41865,7 @@ GLOBAL Disassembler_2 (Matches current architecture)
@cindex out-of-line single-stepping
@item set displaced-stepping
@itemx show displaced-stepping
+@anchor{displaced-stepping}
Control whether or not @value{GDBN} will do @dfn{displaced stepping}
if the target supports it. Displaced stepping is a way to single-step
over breakpoints without removing them from the inferior, by executing
@@ -42698,6 +42842,26 @@ These are representative commands for each @var{kind} of setting type
@value{GDBN} supports. They are used by the testsuite for exercising
the settings infrastructure.
+@kindex maint test-remote-args
+@item maint test-remote-args @var{args}
+For targets that don't support passing inferior arguments as a single
+string (@pxref{single-inf-arg}), @value{GDBN} will attempt to split
+the inferior arguments before passing them to the remote target, and
+the remote target might choose to join the inferior arguments upon
+receipt. Historically gdbserver did join inferior arguments, but now
+it will request inferior arguments be passed as a single string if
+@value{GDBN} supports this feature.
+
+This maintenance command splits @var{args} as @value{GDBN} would
+normally split such an argument string before passing the arguments to
+a remote target, the split arguments are then printed.
+
+The split arguments are then joined together as gdbserver would join
+them, and the result is printed.
+
+This command is intended to help diagnose issues passing inferior
+arguments to remote targets.
+
@kindex maint set backtrace-on-fatal-signal
@kindex maint show backtrace-on-fatal-signal
@item maint set backtrace-on-fatal-signal [on|off]
@@ -42766,22 +42930,6 @@ reports and error and the command is aborted.
@item show watchdog
Show the current setting of the target wait timeout.
-@kindex maint set console-translation-mode
-@kindex maint show console-translation-mode
-@item maint set console-translation-mode @r{[}binary|text@r{]}
-@itemx maint show console-translation-mode
-Controls the translation mode of @value{GDBN} stdout/stderr. MS-Windows
-only. Useful for running the @value{GDBN} testsuite.
-
-The translation mode values are as follows:
-@table @code
-@item binary
-No translation.
-@item text
-Translate @samp{\n} (LF, a single Line Feed) into @samp{\r\n} (CR-LF, a
-Carriage Return-Line Feed combination).
-@end table
-
@end table
@node Remote Protocol
@@ -43638,6 +43786,12 @@ command line. The file and arguments are hex-encoded strings. If
(e.g.@: the last program run). The program is created in the stopped
state.
+If @value{GDBN} sent the @samp{single-inf-arg} feature in the
+@samp{qSupported} packet (@pxref{single-inf-arg}), and the stub replied
+with @samp{single-inf-arg+}, then there will only be a single
+@var{argument} string, which includes all inferior arguments,
+separated with whitespace.
+
@c FIXME: What about non-stop mode?
This packet is only available in extended mode (@pxref{extended mode}).
@@ -44879,7 +45033,8 @@ packets.)
@anchor{qSearch memory}
Search @var{length} bytes at @var{address} for @var{search-pattern}.
Both @var{address} and @var{length} are encoded in hex;
-@var{search-pattern} is a sequence of bytes, also hex encoded.
+@var{search-pattern} is a sequence of binary-encoded bytes
+(@pxref{Binary Data}).
Reply:
@table @samp
@@ -45021,6 +45176,14 @@ didn't support @samp{E.@var{errtext}}, and older versions of
New packets should be written to support @samp{E.@var{errtext}}
regardless of this feature being true or not.
+
+@anchor{single-inf-arg}
+@item single-inf-arg
+This feature indicates that @value{GDBN} would like to send the
+inferior arguments as a single string within the @samp{vRun} packet.
+@value{GDBN} will not send the arguments as a single string unless the
+stub also reports that it supports this behaviour by including
+@samp{single-inf-arg+} in its @samp{qSupported} reply.
@end table
Stubs should ignore any unknown values for
@@ -45324,6 +45487,11 @@ These are the currently defined stub features and their properties:
@tab @samp{-}
@tab No
+@item @samp{single-inf-arg}
+@tab No
+@tab @samp{-}
+@tab No
+
@end multitable
These are the currently defined stub features, in more detail:
@@ -45573,6 +45741,12 @@ if it sent the @samp{error-message} feature.
@item binary-upload
The remote stub supports the @samp{x} packet (@pxref{x packet}).
+
+@item single-inf-arg
+The remote stub would like to receive the inferior arguments as a
+single string within the @samp{vRun} packet. The stub should only
+send this feature if @value{GDBN} sent @samp{single-inf-arg+} in the
+@samp{qSupported} packet.
@end table
@item qSymbol::
@@ -49554,6 +49728,63 @@ of bytes.
Extra registers are allowed in this feature, but they will not affect
@value{GDBN}.
+@subsubsection AArch64 GCS registers feature
+
+The @samp{org.gnu.gdb.aarch64.gcs} feature is optional. If present, it
+means the target supports Guarded Control Stacks and must contain the
+following register:
+
+@itemize @minus
+
+@item
+@code{gcspr}, which points to the thread's Guarded Control Stack. It is 64
+bits in size and has a type of @samp{data_ptr}.
+
+@end itemize
+
+The @samp{org.gnu.gdb.aarch64.gcs.linux} feature is optional. If present,
+then the @samp{org.gnu.gdb.aarch64.gcs} feature must also be present. The
+@samp{org.gnu.gdb.aarch64.gcs.linux} feature represents facilities provided
+by the Linux kernel for GCS support and should contain the following:
+
+@itemize @minus
+
+@item
+@code{gcs_features_enabled} shows the features currently enabled via the
+prctl or ptrace system calls. It is represented as if it were a 64-bit
+register with a custom flags type.
+
+@item
+@code{gcs_features_locked} shows the features currently locked via the
+prctl or ptrace system calls. It is represented as if it were a 64-bit
+register with a custom flags type.
+
+@end itemize
+
+The custom flags type allows @value{GDBN} to print a human-friendly
+representation of the contents of @code{gcs_features_enabled} and
+@code{gcs_features_locked} and should contain:
+
+@itemize @minus
+
+@item
+@code{PR_SHADOW_STACK_ENABLE}
+
+@item
+@code{PR_SHADOW_STACK_WRITE}
+
+@item
+@code{PR_SHADOW_STACK_PUSH}
+
+@end itemize
+
+For further information, see the
+@uref{https://www.kernel.org/doc/html/latest/arch/arm64/gcs.html,ignored,
+documentation} in the Linux kernel.
+
+Extra registers are allowed in these features, but they will not affect
+@value{GDBN}.
+
@node Alpha Features
@subsection Alpha Features
@cindex target descriptions, Alpha Features
@@ -50028,6 +50259,12 @@ The @samp{org.gnu.gdb.i386.pkeys} feature is optional. It should
describe a single register, @samp{pkru}. It is a 32-bit register
valid for i386 and amd64.
+The @samp{org.gnu.gdb.i386.pl3_ssp} feature is optional. It should
+describe the user mode register @samp{pl3_ssp} which has 64 bits on
+amd64, 32 bits on amd64 with 32-bit pointer size (X32) and 32 bits on i386.
+Following the restriction of the Linux kernel, only @value{GDBN} for amd64
+targets makes use of this feature for now.
+
@node LoongArch Features
@subsection LoongArch Features
@cindex target descriptions, LoongArch Features
@@ -50547,17 +50784,13 @@ unless otherwise noted:
@enumerate
@item
-The version number, currently 9. Versions 1, 2 and 3 are obsolete.
-Version 4 uses a different hashing function from versions 5 and 6.
-Version 6 includes symbols for inlined functions, whereas versions 4
-and 5 do not. Version 7 adds attributes to the CU indices in the
-symbol table. Version 8 specifies that symbols from DWARF type units
+The version number, currently 9. Versions 1 through 6 are obsolete.
+Version 7 adds attributes to the CU indices in the symbol table.
+Version 8 specifies that symbols from DWARF type units
(@samp{DW_TAG_type_unit}) refer to the type unit's symbol table and not the
compilation unit (@samp{DW_TAG_comp_unit}) using the type. Version 9 adds
the name and the language of the main function to the index.
-@value{GDBN} will only read version 4, 5, or 6 indices
-by specifying @code{set use-deprecated-index-sections on}.
GDB has a workaround for potentially broken version 7 indices so it is
currently not flagged as deprecated.
@@ -50576,7 +50809,8 @@ The offset, from the start of the file, of the address area.
The offset, from the start of the file, of the symbol table.
@item
-The offset, from the start of the file, of the shortcut table.
+The offset, from the start of the file, of the shortcut table. This
+field was introduced with index version 9.
@item
The offset, from the start of the file, of the constant pool.
@@ -50669,6 +50903,8 @@ in the constant pool. This value must be ignored if the value for the language
of main is zero.
@end table
+This data structure was introduced in index version 9.
+
@item
The constant pool. This is simply a bunch of bytes. It is organized
so that alignment is correct: CU vectors are stored first, followed by
@@ -51101,9 +51337,10 @@ Note that targets that give their output via @value{GDBN}, as opposed to writing
directly to @code{stdout}, will also be made silent.
@item --args @var{prog} [@var{arglist}]
-Change interpretation of command line so that arguments following this
-option are passed as arguments to the inferior. As an example, take
-the following command:
+@itemx --no-escape-args @var{prog} [@var{arglist}]
+Change interpretation of command line so that arguments following
+either of these options are passed as arguments to the inferior. As
+an example, take the following command:
@smallexample
gdb ./a.out -q
@@ -51118,7 +51355,44 @@ gdb --args ./a.out -q
@end smallexample
@noindent
-starts @value{GDBN} with the introductory message, and passes the option to the inferior.
+starts @value{GDBN} with the introductory message, and passes the
+option @code{-q} to the inferior.
+
+The difference between @option{--args} and @option{--no-escape-args}
+is whether @value{GDBN} applies escapes to the arguments it sees:
+
+@smallexample
+gdb --args ./a.out *.c
+@end smallexample
+
+@noindent
+in this case the @code{*.c} is expanded by the shell that invokes
+@value{GDBN}, the list of matching files will be fixed in the inferior
+argument list. If instead this is used:
+
+@smallexample
+gdb --args ./a.out '*.c'
+@end smallexample
+
+@noindent
+then the shell that invokes @value{GDBN} will not expand @code{*.c},
+instead @value{GDBN} will escape the @code{*} character, so when a.out
+is invoked it will be passed a literal @code{*.c}. If instead this is
+used:
+
+@smallexample
+gdb --no-escape-args ./a.out '*.c'
+@end smallexample
+
+@noindent
+now @value{GDBN} will not escape the @code{*} character. When the
+inferior is invoked the @code{*.c} will be expanded, and the inferior
+will be passed the list of files as present at the time the inferior
+is invoked.
+
+This change of behaviour can be important if the list of matching
+files could change between the time that @value{GDBN} is started, and
+the time the inferior is started.
@item --pid=@var{pid}
Attach @value{GDBN} to an already running program, with the PID @var{pid}.
@@ -51460,6 +51734,18 @@ additional connections are possible. However, if you start @code{gdbserver}
with the @option{--once} option, it will stop listening for any further
connection attempts after connecting to the first @value{GDBN} session.
+@item --no-escape-args
+By default, inferior arguments passed on the @command{gdbserver}
+command line will have any special shell characters escaped by
+@command{gdbserver}. This ensures that when @command{gdbserver}
+invokes the inferior, the arguments passed to the inferior are
+identical to the arguments passed to @command{gdbserver}.
+
+To disable this escaping, use @option{--no-escape-args}. With this
+option special shell characters will not be escaped. When
+@command{gdbserver} starts a new shell in order to invoke the
+inferior, this new shell will expand any special shell characters.
+
@c --disable-packet is not documented for users.
@c --disable-randomization and --no-disable-randomization are superseded by
@@ -51522,6 +51808,12 @@ 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{core}.
+@item -g @var{gdb}
+Use @var{gdb} as the executable binary to invoke @value{GDBN} for
+running the gcore command. This argument is optional, and defaults to
+invoking the @value{GDBN} binary that is installed alongside
+@command{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.
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index 6fa2285..3763eee 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -910,7 +910,26 @@ this attribute holds @code{None}.
@cindex optimized out value in Python
@defvar Value.is_optimized_out
This read-only boolean attribute is true if the compiler optimized out
-this value, thus it is not available for fetching from the inferior.
+this value, or any part of this value, and thus it is not available
+for fetching from the inferior.
+@end defvar
+
+@cindex unavailable values in Python
+@defvar Value.is_unavailable
+This read-only boolean attribute is true if this value, or any part of
+this value, is not available to @value{GDBN}. Where an optimized out
+value has been removed from the program by the compiler, an
+unavailable value does exist in the program, but @value{GDBN} is
+unable to fetch it.
+
+Some reasons why this might occur include, but are not limited to: a
+core file format that @value{GDBN} doesn't fully understand; during
+live debugging if the debug API has no mechanism to access the
+required state, e.g.@: the kernel gives an error when trying to read a
+particular register set; or reading a value from @value{GDBN}'s
+history, when only a partial value was stored, e.g.@: due to the
+@kbd{max-value-size} setting (@pxref{set
+max-value-size,,max-value-size}).
@end defvar
@defvar Value.type
diff --git a/gdb/dwarf2/abbrev.c b/gdb/dwarf2/abbrev.c
index 5cfff69..e3c268e 100644
--- a/gdb/dwarf2/abbrev.c
+++ b/gdb/dwarf2/abbrev.c
@@ -108,6 +108,8 @@ abbrev_table::read (struct dwarf2_section_info *section,
cur_abbrev->has_children = read_1_byte (abfd, abbrev_ptr);
abbrev_ptr += 1;
+ cur_abbrev->maybe_ada_import = false;
+
unsigned int size = 0;
unsigned int sibling_offset = -1;
bool is_csize = true;
@@ -242,7 +244,12 @@ abbrev_table::read (struct dwarf2_section_info *section,
}
else if (has_hardcoded_declaration
&& (cur_abbrev->tag != DW_TAG_variable || !has_external))
- cur_abbrev->interesting = false;
+ {
+ cur_abbrev->interesting = false;
+ if (cur_abbrev->tag == DW_TAG_subprogram && has_name
+ && has_linkage_name)
+ cur_abbrev->maybe_ada_import = true;
+ }
else if (!tag_interesting_for_index (cur_abbrev->tag))
cur_abbrev->interesting = false;
else
diff --git a/gdb/dwarf2/abbrev.h b/gdb/dwarf2/abbrev.h
index 6fc61b1..a36bb8c 100644
--- a/gdb/dwarf2/abbrev.h
+++ b/gdb/dwarf2/abbrev.h
@@ -51,6 +51,14 @@ struct abbrev_info
/* True if the DIE has children. */
bool has_children;
bool interesting;
+ /* In Ada, an imported subprogram DIE will be marked as a
+ declaration, but will have both a name and a linkage name. This
+ declaration may be the only spot where that name is associated
+ with an object, so it has to show up in the index. But, because
+ abbrevs are CU-independent, we can't check the language when
+ computing them and instead we keep a separate flag to indicate
+ that the scanner should check this DIE. */
+ bool maybe_ada_import;
unsigned short size_if_constant;
unsigned short sibling_offset;
/* Number of attributes. */
diff --git a/gdb/dwarf2/ada-imported.c b/gdb/dwarf2/ada-imported.c
index 1e25966..48e6fcc 100644
--- a/gdb/dwarf2/ada-imported.c
+++ b/gdb/dwarf2/ada-imported.c
@@ -109,7 +109,7 @@ ada_alias_get_block_value (const struct symbol *sym)
if (real_symbol.symbol == nullptr)
error (_("could not find alias '%s' for function '%s'"),
name, sym->print_name ());
- if (real_symbol.symbol->aclass () != LOC_BLOCK)
+ if (real_symbol.symbol->loc_class () != LOC_BLOCK)
error (_("alias '%s' for function '%s' is not a function"),
name, sym->print_name ());
diff --git a/gdb/dwarf2/cooked-index-entry.c b/gdb/dwarf2/cooked-index-entry.c
index 863ddd6..0482b64 100644
--- a/gdb/dwarf2/cooked-index-entry.c
+++ b/gdb/dwarf2/cooked-index-entry.c
@@ -19,7 +19,6 @@
#include "dwarf2/cooked-index-entry.h"
#include "dwarf2/tag.h"
-#include "gdbsupport/gdb-safe-ctype.h"
#include "gdbsupport/selftest.h"
/* See cooked-index-entry.h. */
@@ -57,7 +56,7 @@ cooked_index_entry::compare (const char *stra, const char *strb,
template functions" section in the manual. */
if (c == '<')
return '\0';
- return TOLOWER ((unsigned char) c);
+ return c_tolower (c);
};
unsigned char a = munge (*stra);
@@ -189,8 +188,15 @@ cooked_index_entry::full_name (struct obstack *storage,
break;
case language_ada:
+ /* If GNAT emits hierarchical names (patches not in at the time
+ of writing), then we need to compute the linkage name here.
+ However for traditional GNAT, the linkage name will be in
+ 'name'. Detect this by looking for "__"; see also
+ cooked_index_shard::finalize. */
if ((name_flags & FOR_ADA_LINKAGE_NAME) != 0)
{
+ if (strstr (name, "__") != nullptr)
+ return name;
sep = "__";
break;
}
diff --git a/gdb/dwarf2/cooked-index-shard.c b/gdb/dwarf2/cooked-index-shard.c
index c717bbb..e440d85 100644
--- a/gdb/dwarf2/cooked-index-shard.c
+++ b/gdb/dwarf2/cooked-index-shard.c
@@ -86,7 +86,21 @@ cooked_index_shard::add (sect_offset die_offset, enum dwarf_tag tag,
implicit "main" discovery. */
if ((flags & IS_MAIN) != 0)
m_main = result;
- else if ((flags & IS_PARENT_DEFERRED) == 0
+ /* The language check here is subtle: it exists solely to work
+ around a bug in .gdb_index. That index does not record
+ languages, but it might emit an entry for "main". However,
+ recognizing this "main" as being the main program would be wrong
+ -- for example, an Ada program has a C "main" but this is not the
+ desired target of the "start" command. Requiring the language to
+ be set here avoids over-eagerly setting the "main" when using
+ .gdb_index. Should .gdb_index ever be removed (PR symtab/31363),
+ the language_unknown check here could also be removed.
+
+ Note that this explicit check isn't truly needed (it is covered
+ by language_may_use_plain_main as well), but it's handy as a spot
+ to document. */
+ else if (lang != language_unknown
+ && (flags & IS_PARENT_DEFERRED) == 0
&& parent_entry.resolved == nullptr
&& m_main == nullptr
&& language_may_use_plain_main (lang)
@@ -108,7 +122,7 @@ cooked_index_shard::handle_gnat_encoded_entry
characters are left as-is. This is done to make name matching a
bit simpler; and for wide characters, it means the choice of Ada
source charset does not affect the indexer directly. */
- std::string canonical = ada_decode (entry->name, false, false, false);
+ std::string canonical = ada_decode (entry->name, false, false);
if (canonical.empty ())
{
entry->canonical = entry->name;
diff --git a/gdb/dwarf2/cooked-index-shard.h b/gdb/dwarf2/cooked-index-shard.h
index 925960b..3a8e34d 100644
--- a/gdb/dwarf2/cooked-index-shard.h
+++ b/gdb/dwarf2/cooked-index-shard.h
@@ -48,6 +48,13 @@ public:
cooked_index_entry_ref parent_entry,
dwarf2_per_cu *per_cu);
+ /* Add a copy of NAME to the index. Return a pointer to the
+ copy. */
+ const char *add (std::string_view name)
+ {
+ return m_names.insert (name);
+ }
+
/* Install a new fixed addrmap from the given mutable addrmap. */
void install_addrmap (addrmap_mutable *map)
{
diff --git a/gdb/dwarf2/cooked-index-worker.h b/gdb/dwarf2/cooked-index-worker.h
index 8b9766c..433515b 100644
--- a/gdb/dwarf2/cooked-index-worker.h
+++ b/gdb/dwarf2/cooked-index-worker.h
@@ -87,6 +87,13 @@ public:
name, parent_entry, per_cu);
}
+ /* Add a copy of NAME to the index. Return a pointer to the
+ copy. */
+ const char *add (std::string_view name)
+ {
+ return m_shard->add (name);
+ }
+
/* Install the current addrmap into the shard being constructed,
then transfer ownership of the index to the caller. */
cooked_index_shard_up release_shard ()
@@ -103,6 +110,12 @@ public:
return &m_addrmap;
}
+ /* Set the mutable addrmap. */
+ void set_addrmap (addrmap_mutable new_map)
+ {
+ m_addrmap = std::move (new_map);
+ }
+
/* Return the parent_map that is currently being created. */
parent_map *get_parent_map ()
{
@@ -210,7 +223,7 @@ enum class cooked_state
This is an abstract base class that defines the basic behavior of
scanners. Separate concrete implementations exist for scanning
- .debug_names and .debug_info. */
+ .debug_names, .gdb_index, and .debug_info. */
class cooked_index_worker
{
diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h
index 43b2723..42d7ec3 100644
--- a/gdb/dwarf2/cooked-index.h
+++ b/gdb/dwarf2/cooked-index.h
@@ -237,15 +237,15 @@ struct cooked_index_functions : public dwarf2_base_index_functions
dwarf2_base_index_functions::expand_all_symtabs (objfile);
}
- bool expand_symtabs_matching
+ bool search
(struct objfile *objfile,
- expand_symtabs_file_matcher file_matcher,
+ search_symtabs_file_matcher file_matcher,
const lookup_name_info *lookup_name,
- expand_symtabs_symbol_matcher symbol_matcher,
- expand_symtabs_expansion_listener expansion_notify,
+ search_symtabs_symbol_matcher symbol_matcher,
+ search_symtabs_expansion_listener listener,
block_search_flags search_flags,
domain_search_flags domain,
- expand_symtabs_lang_matcher lang_matcher) override;
+ search_symtabs_lang_matcher lang_matcher) override;
struct compunit_symtab *find_pc_sect_compunit_symtab
(struct objfile *objfile, bound_minimal_symbol msymbol,
diff --git a/gdb/dwarf2/cooked-indexer.c b/gdb/dwarf2/cooked-indexer.c
index d4557c45..913ff77 100644
--- a/gdb/dwarf2/cooked-indexer.c
+++ b/gdb/dwarf2/cooked-indexer.c
@@ -20,6 +20,9 @@
#include "dwarf2/cooked-indexer.h"
#include "dwarf2/cooked-index-worker.h"
#include "dwarf2/error.h"
+#include "dwarf2/read.h"
+#include "cp-support.h"
+#include "demangle.h"
/* See cooked-indexer.h. */
@@ -297,7 +300,7 @@ cooked_indexer::scan_attributes (dwarf2_per_cu *scanning_per_cu,
|| abbrev->tag == DW_TAG_namespace)
&& abbrev->has_children)
*flags |= IS_TYPE_DECLARATION;
- else
+ else if (!is_ada_import_or_export (reader->cu (), *name, *linkage_name))
{
*linkage_name = nullptr;
*name = nullptr;
@@ -506,7 +509,8 @@ cooked_indexer::index_dies (cutu_reader *reader,
/* If a DIE parent is a DW_TAG_subprogram, then the DIE is only
interesting if it's a DW_TAG_subprogram or a DW_TAG_entry_point. */
bool die_interesting
- = (abbrev->interesting
+ = ((abbrev->interesting
+ || (m_language == language_ada && abbrev->maybe_ada_import))
&& (parent_entry == nullptr
|| parent_entry->tag != DW_TAG_subprogram
|| abbrev->tag == DW_TAG_subprogram
@@ -542,6 +546,11 @@ cooked_indexer::index_dies (cutu_reader *reader,
flags &= ~IS_STATIC;
flags |= parent_entry->flags & IS_STATIC;
}
+ else if (abbrev->tag == DW_TAG_imported_declaration)
+ {
+ /* Match the full reader. */
+ flags &= ~IS_STATIC;
+ }
if (abbrev->tag == DW_TAG_namespace
&& m_language == language_cplus
@@ -554,6 +563,30 @@ cooked_indexer::index_dies (cutu_reader *reader,
name = nullptr;
}
+ /* An otherwise anonymous type might be given a name (via
+ typedef) for linkage purposes, and gdb tries to handle this
+ case. See anon-struct.exp. In this case, GCC will emit a
+ funny thing: a linkage name for the type, but in "type" form.
+ That is, it will not start with _Z. */
+ if ((abbrev->tag == DW_TAG_class_type
+ || abbrev->tag == DW_TAG_structure_type
+ || abbrev->tag == DW_TAG_union_type)
+ && m_language == language_cplus
+ && name == nullptr
+ && linkage_name != nullptr)
+ {
+ gdb::unique_xmalloc_ptr<char> dem
+ = gdb_demangle (linkage_name, DMGL_GNU_V3 | DMGL_TYPES);
+ if (dem != nullptr)
+ {
+ /* We're only interested in the last component. */
+ std::vector<std::string_view> split
+ = split_name (dem.get (), split_style::CXX);
+ name = m_index_storage->add (split.back ());
+ linkage_name = nullptr;
+ }
+ }
+
cooked_index_entry *this_entry = nullptr;
if (name != nullptr)
{
diff --git a/gdb/dwarf2/index-common.c b/gdb/dwarf2/index-common.c
index c24c8fc..a314ce7 100644
--- a/gdb/dwarf2/index-common.c
+++ b/gdb/dwarf2/index-common.c
@@ -31,7 +31,7 @@ mapped_index_string_hash (int index_version, const void *p)
while ((c = *str++) != 0)
{
if (index_version >= 5)
- c = tolower (c);
+ c = c_tolower (c);
r = r * 67 + c - 113;
}
@@ -45,12 +45,12 @@ dwarf5_djb_hash (const char *str_)
{
const unsigned char *str = (const unsigned char *) str_;
- /* Note: tolower here ignores UTF-8, which isn't fully compliant.
+ /* Note: c_tolower here ignores UTF-8, which isn't fully compliant.
See http://dwarfstd.org/ShowIssue.php?issue=161027.1. */
uint32_t hash = 5381;
while (int c = *str++)
- hash = hash * 33 + tolower (c);
+ hash = hash * 33 + c_tolower (c);
return hash;
}
@@ -59,11 +59,11 @@ dwarf5_djb_hash (const char *str_)
uint32_t
dwarf5_djb_hash (std::string_view str)
{
- /* Note: tolower here ignores UTF-8, which isn't fully compliant.
+ /* Note: c_tolower here ignores UTF-8, which isn't fully compliant.
See http://dwarfstd.org/ShowIssue.php?issue=161027.1. */
uint32_t hash = 5381;
for (char c : str)
- hash = hash * 33 + tolower (c & 0xff);
+ hash = hash * 33 + c_tolower (c & 0xff);
return hash;
}
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
index d5b198b..37e66a5 100644
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -55,7 +55,7 @@
#define DW2_GDB_INDEX_SYMBOL_KIND_SET_VALUE(cu_index, value) \
do { \
gdb_assert ((value) >= GDB_INDEX_SYMBOL_KIND_TYPE \
- && (value) <= GDB_INDEX_SYMBOL_KIND_OTHER); \
+ && (value) <= GDB_INDEX_SYMBOL_KIND_UNUSED5); \
GDB_INDEX_SYMBOL_KIND_SET_VALUE((cu_index), (value)); \
} while (0)
@@ -422,10 +422,47 @@ symtab_index_entry::minimize ()
if (name == nullptr || cu_indices.empty ())
return;
- std::sort (cu_indices.begin (), cu_indices.end ());
+ /* We sort the indexes in a funny way: GDB_INDEX_SYMBOL_KIND_UNUSED5
+ is always sorted last; then otherwise we sort by numeric value.
+ This ensures that we prefer the definition when both a definition
+ and a declaration (stub type) are seen. */
+ std::sort (cu_indices.begin (), cu_indices.end (),
+ [] (offset_type vala, offset_type valb)
+ {
+ auto kinda = GDB_INDEX_SYMBOL_KIND_VALUE (vala);
+ auto kindb = GDB_INDEX_SYMBOL_KIND_VALUE (valb);
+ if (kinda != kindb)
+ {
+ /* Declaration sorts last. */
+ if (kinda == GDB_INDEX_SYMBOL_KIND_UNUSED5)
+ return false;
+ if (kindb == GDB_INDEX_SYMBOL_KIND_UNUSED5)
+ return true;
+ }
+ return vala < valb;
+ });
auto from = std::unique (cu_indices.begin (), cu_indices.end ());
cu_indices.erase (from, cu_indices.end ());
+ /* Rewrite GDB_INDEX_SYMBOL_KIND_UNUSED5. This ensures that a type
+ declaration will be deleted by the subsequent squashing step, if
+ warranted. */
+ for (auto &val : cu_indices)
+ {
+ gdb_index_symbol_kind kind = GDB_INDEX_SYMBOL_KIND_VALUE (val);
+ if (kind != GDB_INDEX_SYMBOL_KIND_UNUSED5)
+ continue;
+
+ offset_type newval = 0;
+ DW2_GDB_INDEX_CU_SET_VALUE (newval, GDB_INDEX_CU_VALUE (val));
+ DW2_GDB_INDEX_SYMBOL_STATIC_SET_VALUE
+ (newval, GDB_INDEX_SYMBOL_STATIC_VALUE (val));
+ DW2_GDB_INDEX_SYMBOL_KIND_SET_VALUE (newval,
+ GDB_INDEX_SYMBOL_KIND_TYPE);
+
+ val = newval;
+ }
+
/* We don't want to enter a type more than once, so
remove any such duplicates from the list as well. When doing
this, we want to keep the entry from the first CU -- but this is
@@ -720,7 +757,7 @@ public:
});
m_name_table_string_offs.push_back_reorder
- (m_debugstrlookup.lookup (name.c_str ())); /* ??? */
+ (m_debugstrlookup.lookup (name.c_str ()));
m_name_table_entry_offs.push_back_reorder (m_entry_pool.size ());
for (const cooked_index_entry *entry : these_entries)
@@ -885,10 +922,21 @@ private:
{
public:
- /* Object constructor to be called for current DWARF2_PER_BFD. */
- debug_str_lookup (dwarf2_per_bfd *per_bfd)
+ /* Object constructor to be called for current DWARF2_PER_BFD.
+ All .debug_str section strings are automatically stored. */
+ explicit debug_str_lookup (dwarf2_per_bfd *per_bfd)
: m_per_bfd (per_bfd)
{
+ gdb_assert (per_bfd->str.readin);
+ const gdb_byte *data = per_bfd->str.buffer;
+ if (data == nullptr)
+ return;
+ while (data < per_bfd->str.buffer + per_bfd->str.size)
+ {
+ const char *const s = reinterpret_cast<const char *> (data);
+ m_str_table.emplace (c_str_view (s), data - per_bfd->str.buffer);
+ data += strlen (s) + 1;
+ }
}
/* Return offset of symbol name S in the .debug_str section. Add
@@ -896,13 +944,6 @@ private:
yet. */
size_t lookup (const char *s)
{
- /* Most strings will have come from the string table
- already. */
- const gdb_byte *b = (const gdb_byte *) s;
- if (b >= m_per_bfd->str.buffer
- && b < m_per_bfd->str.buffer + m_per_bfd->str.size)
- return b - m_per_bfd->str.buffer;
-
const auto it = m_str_table.find (c_str_view (s));
if (it != m_str_table.end ())
return it->second;
@@ -1212,6 +1253,21 @@ write_cooked_index (cooked_index *table,
const cu_index_map &cu_index_htab,
struct mapped_symtab *symtab)
{
+ gdb::unordered_set<const cooked_index_entry *> required_decl_entries;
+ for (const cooked_index_entry *entry : table->all_entries ())
+ {
+ /* Any type declaration that is used as a (non-trivial) parent
+ entry must be written out. */
+ if ((entry->flags & IS_TYPE_DECLARATION) == 0)
+ {
+ for (const cooked_index_entry *parent = entry->get_parent ();
+ parent != nullptr;
+ parent = parent->get_parent ())
+ if ((parent->flags & IS_TYPE_DECLARATION) != 0)
+ required_decl_entries.insert (parent);
+ }
+ }
+
for (const cooked_index_entry *entry : table->all_entries ())
{
const auto it = cu_index_htab.find (entry->per_cu);
@@ -1237,11 +1293,10 @@ write_cooked_index (cooked_index *table,
be redundant are rare and not worth supporting. */
continue;
}
- else if ((entry->flags & IS_TYPE_DECLARATION) != 0)
- {
- /* Don't add type declarations to the index. */
- continue;
- }
+ /* Don't add most type declarations to the index. */
+ else if ((entry->flags & IS_TYPE_DECLARATION) != 0
+ && !required_decl_entries.contains (entry))
+ continue;
gdb_index_symbol_kind kind;
if (entry->tag == DW_TAG_subprogram
@@ -1252,7 +1307,16 @@ write_cooked_index (cooked_index *table,
|| entry->tag == DW_TAG_enumerator)
kind = GDB_INDEX_SYMBOL_KIND_VARIABLE;
else if (tag_is_type (entry->tag))
- kind = GDB_INDEX_SYMBOL_KIND_TYPE;
+ {
+ /* If we added a type declaration, we want to note this
+ fact for later, because we don't want a type declaration
+ to cause the real definition to be omitted from the
+ index. GDB_INDEX_SYMBOL_KIND_UNUSED5 is used here, but
+ rewritten later before the index is written. */
+ kind = ((entry->flags & IS_TYPE_DECLARATION) == 0
+ ? GDB_INDEX_SYMBOL_KIND_TYPE
+ : GDB_INDEX_SYMBOL_KIND_UNUSED5);
+ }
else
kind = GDB_INDEX_SYMBOL_KIND_OTHER;
diff --git a/gdb/dwarf2/line-program.c b/gdb/dwarf2/line-program.c
new file mode 100644
index 0000000..c30f70d
--- /dev/null
+++ b/gdb/dwarf2/line-program.c
@@ -0,0 +1,720 @@
+/* DWARF 2 debugging format support for GDB.
+
+ Copyright (C) 1994-2025 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 "dwarf2/line-program.h"
+#include "dwarf2/cu.h"
+#include "dwarf2/line-header.h"
+#include "dwarf2/read.h"
+#include "buildsym.h"
+#include "complaints.h"
+#include "filenames.h"
+#include "gdbarch.h"
+
+static void
+dwarf2_debug_line_missing_file_complaint ()
+{
+ complaint (_(".debug_line section has line data without a file"));
+}
+
+static void
+dwarf2_debug_line_missing_end_sequence_complaint ()
+{
+ complaint (_(".debug_line section has line "
+ "program sequence without an end"));
+}
+
+/* State machine to track the state of the line number program. */
+
+class lnp_state_machine
+{
+public:
+ /* Initialize a machine state for the start of a line number
+ program. */
+ lnp_state_machine (struct dwarf2_cu *cu, gdbarch *arch, line_header *lh);
+
+ file_entry *current_file ()
+ {
+ /* lh->file_names is 0-based, but the file name numbers in the
+ statement program are 1-based. */
+ return m_line_header->file_name_at (m_file);
+ }
+
+ /* Record the line in the state machine. END_SEQUENCE is true if
+ we're processing the end of a sequence. */
+ void record_line (bool end_sequence);
+
+ /* Check ADDRESS is -1, -2, or zero and less than UNRELOCATED_LOWPC, and if
+ true nop-out rest of the lines in this sequence. */
+ void check_line_address (struct dwarf2_cu *cu,
+ const gdb_byte *line_ptr,
+ unrelocated_addr unrelocated_lowpc,
+ unrelocated_addr address);
+
+ void handle_set_discriminator (unsigned int discriminator)
+ {
+ m_discriminator = discriminator;
+ m_line_has_non_zero_discriminator |= discriminator != 0;
+ }
+
+ /* Handle DW_LNE_set_address. */
+ void handle_set_address (unrelocated_addr address)
+ {
+ m_op_index = 0;
+ m_address
+ = (unrelocated_addr) gdbarch_adjust_dwarf2_line (m_gdbarch,
+ (CORE_ADDR) address,
+ false);
+ }
+
+ /* Handle DW_LNS_advance_pc. */
+ void handle_advance_pc (CORE_ADDR adjust);
+
+ /* Handle a special opcode. */
+ void handle_special_opcode (unsigned char op_code);
+
+ /* Handle DW_LNS_advance_line. */
+ void handle_advance_line (int line_delta)
+ {
+ advance_line (line_delta);
+ }
+
+ /* Handle DW_LNS_set_file. */
+ void handle_set_file (file_name_index file);
+
+ /* Handle DW_LNS_negate_stmt. */
+ void handle_negate_stmt ()
+ {
+ m_flags ^= LEF_IS_STMT;
+ }
+
+ /* Handle DW_LNS_const_add_pc. */
+ void handle_const_add_pc ();
+
+ /* Handle DW_LNS_fixed_advance_pc. */
+ void handle_fixed_advance_pc (CORE_ADDR addr_adj)
+ {
+ addr_adj = gdbarch_adjust_dwarf2_line (m_gdbarch, addr_adj, true);
+ m_address = (unrelocated_addr) ((CORE_ADDR) m_address + addr_adj);
+ m_op_index = 0;
+ }
+
+ /* Handle DW_LNS_copy. */
+ void handle_copy ()
+ {
+ record_line (false);
+ m_discriminator = 0;
+ m_flags &= ~LEF_PROLOGUE_END;
+ m_flags &= ~LEF_EPILOGUE_BEGIN;
+ }
+
+ /* Handle DW_LNE_end_sequence. */
+ void handle_end_sequence ()
+ {
+ m_currently_recording_lines = true;
+ }
+
+ /* Handle DW_LNS_set_prologue_end. */
+ void handle_set_prologue_end ()
+ {
+ m_flags |= LEF_PROLOGUE_END;
+ }
+
+ void handle_set_epilogue_begin ()
+ {
+ m_flags |= LEF_EPILOGUE_BEGIN;
+ }
+
+private:
+ /* Advance the line by LINE_DELTA. */
+ void advance_line (int line_delta)
+ {
+ m_line += line_delta;
+
+ if (line_delta != 0)
+ m_line_has_non_zero_discriminator = m_discriminator != 0;
+ }
+
+ bool record_line_p ();
+ void finish_line ();
+ void record_line_1 (unsigned int line, linetable_entry_flags flags);
+
+ struct dwarf2_cu *m_cu;
+
+ /* The builder associated with the CU. */
+ buildsym_compunit *m_builder;
+
+ gdbarch *m_gdbarch;
+
+ /* The line number header. */
+ line_header *m_line_header;
+
+ /* These are part of the standard DWARF line number state machine,
+ and initialized according to the DWARF spec. */
+
+ unsigned char m_op_index = 0;
+ /* The line table index of the current file. */
+ file_name_index m_file = 1;
+ unsigned int m_line = 1;
+
+ /* These are initialized in the constructor. */
+
+ unrelocated_addr m_address;
+ linetable_entry_flags m_flags;
+ unsigned int m_discriminator = 0;
+
+ /* Additional bits of state we need to track. */
+
+ /* The last file a line number was recorded for. */
+ struct subfile *m_last_subfile = NULL;
+
+ /* The address of the last line entry. */
+ unrelocated_addr m_last_address;
+
+ /* Set to true when a previous line at the same address (using
+ m_last_address) had LEF_IS_STMT set in m_flags. This is reset to false
+ when a line entry at a new address (m_address different to
+ m_last_address) is processed. */
+ bool m_stmt_at_address = false;
+
+ /* When true, record the lines we decode. */
+ bool m_currently_recording_lines = true;
+
+ /* The last line number that was recorded, used to coalesce
+ consecutive entries for the same line. This can happen, for
+ example, when discriminators are present. PR 17276. */
+ unsigned int m_last_line = 0;
+ bool m_line_has_non_zero_discriminator = false;
+};
+
+void
+lnp_state_machine::handle_advance_pc (CORE_ADDR adjust)
+{
+ CORE_ADDR addr_adj = (((m_op_index + adjust)
+ / m_line_header->maximum_ops_per_instruction)
+ * m_line_header->minimum_instruction_length);
+ addr_adj = gdbarch_adjust_dwarf2_line (m_gdbarch, addr_adj, true);
+ m_address = (unrelocated_addr) ((CORE_ADDR) m_address + addr_adj);
+ m_op_index = ((m_op_index + adjust)
+ % m_line_header->maximum_ops_per_instruction);
+}
+
+void
+lnp_state_machine::handle_special_opcode (unsigned char op_code)
+{
+ unsigned char adj_opcode = op_code - m_line_header->opcode_base;
+ unsigned char adj_opcode_d = adj_opcode / m_line_header->line_range;
+ unsigned char adj_opcode_r = adj_opcode % m_line_header->line_range;
+ CORE_ADDR addr_adj = (((m_op_index + adj_opcode_d)
+ / m_line_header->maximum_ops_per_instruction)
+ * m_line_header->minimum_instruction_length);
+ addr_adj = gdbarch_adjust_dwarf2_line (m_gdbarch, addr_adj, true);
+ m_address = (unrelocated_addr) ((CORE_ADDR) m_address + addr_adj);
+ m_op_index = ((m_op_index + adj_opcode_d)
+ % m_line_header->maximum_ops_per_instruction);
+
+ int line_delta = m_line_header->line_base + adj_opcode_r;
+ advance_line (line_delta);
+ record_line (false);
+ m_discriminator = 0;
+ m_flags &= ~LEF_PROLOGUE_END;
+ m_flags &= ~LEF_EPILOGUE_BEGIN;
+}
+
+void
+lnp_state_machine::handle_set_file (file_name_index file)
+{
+ m_file = file;
+
+ const file_entry *fe = current_file ();
+ if (fe == NULL)
+ dwarf2_debug_line_missing_file_complaint ();
+ else
+ {
+ m_line_has_non_zero_discriminator = m_discriminator != 0;
+ dwarf2_start_subfile (m_cu, *fe, *m_line_header);
+ }
+}
+
+void
+lnp_state_machine::handle_const_add_pc ()
+{
+ CORE_ADDR adjust
+ = (255 - m_line_header->opcode_base) / m_line_header->line_range;
+
+ CORE_ADDR addr_adj
+ = (((m_op_index + adjust)
+ / m_line_header->maximum_ops_per_instruction)
+ * m_line_header->minimum_instruction_length);
+
+ addr_adj = gdbarch_adjust_dwarf2_line (m_gdbarch, addr_adj, true);
+ m_address = (unrelocated_addr) ((CORE_ADDR) m_address + addr_adj);
+ m_op_index = ((m_op_index + adjust)
+ % m_line_header->maximum_ops_per_instruction);
+}
+
+/* Return true if we should add LINE to the line number table.
+ LINE is the line to add, LAST_LINE is the last line that was added,
+ LAST_SUBFILE is the subfile for LAST_LINE.
+ LINE_HAS_NON_ZERO_DISCRIMINATOR is non-zero if LINE has ever
+ had a non-zero discriminator.
+
+ We have to be careful in the presence of discriminators.
+ E.g., for this line:
+
+ for (i = 0; i < 100000; i++);
+
+ clang can emit four line number entries for that one line,
+ each with a different discriminator.
+ See gdb.dwarf2/dw2-single-line-discriminators.exp for an example.
+
+ However, we want gdb to coalesce all four entries into one.
+ Otherwise the user could stepi into the middle of the line and
+ gdb would get confused about whether the pc really was in the
+ middle of the line.
+
+ Things are further complicated by the fact that two consecutive
+ line number entries for the same line is a heuristic used by gcc
+ to denote the end of the prologue. So we can't just discard duplicate
+ entries, we have to be selective about it. The heuristic we use is
+ that we only collapse consecutive entries for the same line if at least
+ one of those entries has a non-zero discriminator. PR 17276.
+
+ Note: Addresses in the line number state machine can never go backwards
+ within one sequence, thus this coalescing is ok. */
+
+bool
+lnp_state_machine::record_line_p ()
+{
+ if (m_builder->get_current_subfile () != m_last_subfile)
+ return true;
+ if (m_line != m_last_line)
+ return true;
+ /* Same line for the same file that we've seen already.
+ As a last check, for pr 17276, only record the line if the line
+ has never had a non-zero discriminator. */
+ if (!m_line_has_non_zero_discriminator)
+ return true;
+ return false;
+}
+
+/* Use the CU's builder to record line number LINE with the given
+ flags. */
+
+void
+lnp_state_machine::record_line_1 (unsigned int line,
+ linetable_entry_flags flags)
+{
+ if (m_currently_recording_lines)
+ {
+ unrelocated_addr addr
+ = unrelocated_addr (gdbarch_addr_bits_remove (m_gdbarch,
+ (CORE_ADDR) m_address));
+
+ if (dwarf_line_debug)
+ gdb_printf (gdb_stdlog, "Recording line %u, file %s, address %s\n",
+ m_line, lbasename (m_last_subfile->name.c_str ()),
+ paddress (m_gdbarch, (CORE_ADDR) addr));
+
+ m_builder->record_line (m_last_subfile, line, addr, flags);
+ }
+}
+
+/* Subroutine of dwarf_decode_lines_1 to simplify it.
+ Mark the end of a set of line number records. */
+
+void
+lnp_state_machine::finish_line ()
+{
+ if (m_last_subfile == nullptr)
+ return;
+
+ if (dwarf_line_debug)
+ {
+ gdb_printf (gdb_stdlog,
+ "Finishing current line, file %s, address %s\n",
+ lbasename (m_last_subfile->name.c_str ()),
+ paddress (m_gdbarch, (CORE_ADDR) m_address));
+ }
+
+ record_line_1 (0, LEF_IS_STMT);
+}
+
+void
+lnp_state_machine::record_line (bool end_sequence)
+{
+ if (dwarf_line_debug)
+ {
+ gdb_printf (gdb_stdlog,
+ "Processing actual line %u: file %u,"
+ " address %s, is_stmt %u, prologue_end %u,"
+ " epilogue_begin %u, discrim %u%s\n",
+ m_line, m_file,
+ paddress (m_gdbarch, (CORE_ADDR) m_address),
+ (m_flags & LEF_IS_STMT) != 0,
+ (m_flags & LEF_PROLOGUE_END) != 0,
+ (m_flags & LEF_EPILOGUE_BEGIN) != 0,
+ m_discriminator,
+ (end_sequence ? "\t(end sequence)" : ""));
+ }
+
+ file_entry *fe = current_file ();
+
+ if (fe == NULL)
+ dwarf2_debug_line_missing_file_complaint ();
+ /* For now we ignore lines not starting on an instruction boundary.
+ But not when processing end_sequence for compatibility with the
+ previous version of the code. */
+ else if (m_op_index == 0 || end_sequence)
+ {
+ /* When we switch files we insert an end maker in the first file,
+ switch to the second file and add a new line entry. The
+ problem is that the end marker inserted in the first file will
+ discard any previous line entries at the same address. If the
+ line entries in the first file are marked as is-stmt, while
+ the new line in the second file is non-stmt, then this means
+ the end marker will discard is-stmt lines so we can have a
+ non-stmt line. This means that there are less addresses at
+ which the user can insert a breakpoint.
+
+ To improve this we track the last address in m_last_address,
+ and whether we have seen an is-stmt at this address. Then
+ when switching files, if we have seen a stmt at the current
+ address, and we are switching to create a non-stmt line, then
+ discard the new line. */
+ bool file_changed = m_last_subfile != m_builder->get_current_subfile ();
+ bool ignore_this_line
+ = ((file_changed && !end_sequence && m_last_address == m_address
+ && ((m_flags & LEF_IS_STMT) == 0)
+ && m_stmt_at_address)
+ || (!end_sequence && m_line == 0));
+
+ if ((file_changed && !ignore_this_line) || end_sequence)
+ finish_line ();
+
+ if (!end_sequence && !ignore_this_line)
+ {
+ linetable_entry_flags lte_flags = m_flags;
+ if (m_cu->producer_is_codewarrior ())
+ lte_flags |= LEF_IS_STMT;
+
+ if (record_line_p ())
+ {
+ m_last_subfile = m_builder->get_current_subfile ();
+ record_line_1 (m_line, lte_flags);
+ m_last_line = m_line;
+ }
+ }
+ }
+
+ /* Track whether we have seen any IS_STMT true at m_address in case we
+ have multiple line table entries all at m_address. */
+ if (m_last_address != m_address)
+ {
+ m_stmt_at_address = false;
+ m_last_address = m_address;
+ }
+ m_stmt_at_address |= (m_flags & LEF_IS_STMT) != 0;
+}
+
+lnp_state_machine::lnp_state_machine (struct dwarf2_cu *cu, gdbarch *arch,
+ line_header *lh)
+ : m_cu (cu),
+ m_builder (cu->get_builder ()),
+ m_gdbarch (arch),
+ m_line_header (lh),
+ /* Call `gdbarch_adjust_dwarf2_line' on the initial 0 address as
+ if there was a line entry for it so that the backend has a
+ chance to adjust it and also record it in case it needs it.
+ This is currently used by MIPS code,
+ cf. `mips_adjust_dwarf2_line'. */
+ m_address ((unrelocated_addr) gdbarch_adjust_dwarf2_line (arch, 0, 0)),
+ m_flags (lh->default_is_stmt ? LEF_IS_STMT : (linetable_entry_flags) 0),
+ m_last_address (m_address)
+{
+}
+
+void
+lnp_state_machine::check_line_address (struct dwarf2_cu *cu,
+ const gdb_byte *line_ptr,
+ unrelocated_addr unrelocated_lowpc,
+ unrelocated_addr address)
+{
+ /* Linkers resolve a symbolic relocation referencing a GC'd function to 0,
+ -1 or -2 (-2 is used by certain lld versions, see
+ https://github.com/llvm/llvm-project/commit/e618ccbf431f6730edb6d1467a127c3a52fd57f7).
+ If ADDRESS is 0, ignoring the opcode will err if the text section is
+ located at 0x0. In this case, additionally check that if
+ ADDRESS < UNRELOCATED_LOWPC. */
+
+ if ((address == (unrelocated_addr) 0 && address < unrelocated_lowpc)
+ || address == (unrelocated_addr) -1
+ || address == (unrelocated_addr) -2)
+ {
+ /* This line table is for a function which has been
+ GCd by the linker. Ignore it. PR gdb/12528 */
+
+ struct objfile *objfile = cu->per_objfile->objfile;
+ long line_offset = line_ptr - get_debug_line_section (cu)->buffer;
+
+ complaint (_(".debug_line address at offset 0x%lx is 0 [in module %s]"),
+ line_offset, objfile_name (objfile));
+ m_currently_recording_lines = false;
+ /* Note: m_currently_recording_lines is left as false until we see
+ DW_LNE_end_sequence. */
+ }
+}
+
+/* Subroutine of dwarf_decode_lines to simplify it.
+ Process the line number information in LH. */
+
+static void
+dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
+ unrelocated_addr lowpc)
+{
+ const gdb_byte *line_ptr, *extended_end;
+ const gdb_byte *line_end;
+ unsigned int bytes_read, extended_len;
+ unsigned char op_code, extended_op;
+ struct objfile *objfile = cu->per_objfile->objfile;
+ bfd *abfd = objfile->obfd.get ();
+ struct gdbarch *gdbarch = objfile->arch ();
+
+ line_ptr = lh->statement_program_start;
+ line_end = lh->statement_program_end;
+
+ /* Read the statement sequences until there's nothing left. */
+ while (line_ptr < line_end)
+ {
+ /* The DWARF line number program state machine. Reset the state
+ machine at the start of each sequence. */
+ lnp_state_machine state_machine (cu, gdbarch, lh);
+ bool end_sequence = false;
+
+ /* Start a subfile for the current file of the state
+ machine. */
+ const file_entry *fe = state_machine.current_file ();
+
+ if (fe != NULL)
+ dwarf2_start_subfile (cu, *fe, *lh);
+
+ /* Decode the table. */
+ while (line_ptr < line_end && !end_sequence)
+ {
+ op_code = read_1_byte (abfd, line_ptr);
+ line_ptr += 1;
+
+ if (op_code >= lh->opcode_base)
+ {
+ /* Special opcode. */
+ state_machine.handle_special_opcode (op_code);
+ }
+ else switch (op_code)
+ {
+ case DW_LNS_extended_op:
+ extended_len = read_unsigned_leb128 (abfd, line_ptr,
+ &bytes_read);
+ line_ptr += bytes_read;
+ extended_end = line_ptr + extended_len;
+ extended_op = read_1_byte (abfd, line_ptr);
+ line_ptr += 1;
+ if (DW_LNE_lo_user <= extended_op
+ && extended_op <= DW_LNE_hi_user)
+ {
+ /* Vendor extension, ignore. */
+ line_ptr = extended_end;
+ break;
+ }
+ switch (extended_op)
+ {
+ case DW_LNE_end_sequence:
+ state_machine.handle_end_sequence ();
+ end_sequence = true;
+ break;
+ case DW_LNE_set_address:
+ {
+ unrelocated_addr address
+ = cu->header.read_address (abfd, line_ptr, &bytes_read);
+ line_ptr += bytes_read;
+
+ state_machine.check_line_address (cu, line_ptr, lowpc,
+ address);
+ state_machine.handle_set_address (address);
+ }
+ break;
+ case DW_LNE_define_file:
+ {
+ const char *cur_file;
+ unsigned int mod_time, length;
+ dir_index dindex;
+
+ cur_file = read_direct_string (abfd, line_ptr,
+ &bytes_read);
+ line_ptr += bytes_read;
+ dindex = (dir_index)
+ read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+ line_ptr += bytes_read;
+ mod_time =
+ read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+ line_ptr += bytes_read;
+ length =
+ read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+ line_ptr += bytes_read;
+ lh->add_file_name (cur_file, dindex, mod_time, length);
+ }
+ break;
+ case DW_LNE_set_discriminator:
+ {
+ /* The discriminator is not interesting to the
+ debugger; just ignore it. We still need to
+ check its value though:
+ if there are consecutive entries for the same
+ (non-prologue) line we want to coalesce them.
+ PR 17276. */
+ unsigned int discr
+ = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+ line_ptr += bytes_read;
+
+ state_machine.handle_set_discriminator (discr);
+ }
+ break;
+ default:
+ complaint (_("mangled .debug_line section"));
+ return;
+ }
+ /* Make sure that we parsed the extended op correctly. If e.g.
+ we expected a different address size than the producer used,
+ we may have read the wrong number of bytes. */
+ if (line_ptr != extended_end)
+ {
+ complaint (_("mangled .debug_line section"));
+ return;
+ }
+ break;
+ case DW_LNS_copy:
+ state_machine.handle_copy ();
+ break;
+ case DW_LNS_advance_pc:
+ {
+ CORE_ADDR adjust
+ = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+ line_ptr += bytes_read;
+
+ state_machine.handle_advance_pc (adjust);
+ }
+ break;
+ case DW_LNS_advance_line:
+ {
+ int line_delta
+ = read_signed_leb128 (abfd, line_ptr, &bytes_read);
+ line_ptr += bytes_read;
+
+ state_machine.handle_advance_line (line_delta);
+ }
+ break;
+ case DW_LNS_set_file:
+ {
+ file_name_index file
+ = (file_name_index) read_unsigned_leb128 (abfd, line_ptr,
+ &bytes_read);
+ line_ptr += bytes_read;
+
+ state_machine.handle_set_file (file);
+ }
+ break;
+ case DW_LNS_set_column:
+ (void) read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+ line_ptr += bytes_read;
+ break;
+ case DW_LNS_negate_stmt:
+ state_machine.handle_negate_stmt ();
+ break;
+ case DW_LNS_set_basic_block:
+ break;
+ /* Add to the address register of the state machine the
+ address increment value corresponding to special opcode
+ 255. I.e., this value is scaled by the minimum
+ instruction length since special opcode 255 would have
+ scaled the increment. */
+ case DW_LNS_const_add_pc:
+ state_machine.handle_const_add_pc ();
+ break;
+ case DW_LNS_fixed_advance_pc:
+ {
+ CORE_ADDR addr_adj = read_2_bytes (abfd, line_ptr);
+ line_ptr += 2;
+
+ state_machine.handle_fixed_advance_pc (addr_adj);
+ }
+ break;
+ case DW_LNS_set_prologue_end:
+ state_machine.handle_set_prologue_end ();
+ break;
+ case DW_LNS_set_epilogue_begin:
+ state_machine.handle_set_epilogue_begin ();
+ break;
+ default:
+ {
+ /* Unknown standard opcode, ignore it. */
+ int i;
+
+ for (i = 0; i < lh->standard_opcode_lengths[op_code]; i++)
+ {
+ (void) read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
+ line_ptr += bytes_read;
+ }
+ }
+ }
+ }
+
+ if (!end_sequence)
+ dwarf2_debug_line_missing_end_sequence_complaint ();
+
+ /* We got a DW_LNE_end_sequence (or we ran off the end of the buffer,
+ in which case we still finish recording the last line). */
+ state_machine.record_line (true);
+ }
+}
+
+/* See dwarf2/line-program.h. */
+
+void
+dwarf_decode_lines (struct line_header *lh, struct dwarf2_cu *cu,
+ unrelocated_addr lowpc, bool decode_mapping)
+{
+ if (decode_mapping)
+ dwarf_decode_lines_1 (lh, cu, lowpc);
+
+ /* Make sure a symtab is created for every file, even files
+ which contain only variables (i.e. no code with associated
+ line numbers). */
+ buildsym_compunit *builder = cu->get_builder ();
+ struct compunit_symtab *cust = builder->get_compunit_symtab ();
+
+ for (auto &fe : lh->file_names ())
+ {
+ dwarf2_start_subfile (cu, fe, *lh);
+ subfile *sf = builder->get_current_subfile ();
+
+ if (sf->symtab == nullptr)
+ sf->symtab = allocate_symtab (cust, sf->name.c_str (),
+ sf->name_for_id.c_str ());
+
+ fe.symtab = sf->symtab;
+ }
+}
diff --git a/gdb/dwarf2/line-program.h b/gdb/dwarf2/line-program.h
new file mode 100644
index 0000000..824f18f
--- /dev/null
+++ b/gdb/dwarf2/line-program.h
@@ -0,0 +1,47 @@
+/* DWARF 2 debugging format support for GDB.
+
+ Copyright (C) 1994-2025 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 GDB_DWARF2_LINE_PROGRAM_H
+#define GDB_DWARF2_LINE_PROGRAM_H
+
+/* Decode the Line Number Program (LNP) for the given line_header
+ structure and CU. The actual information extracted and the type
+ of structures created from the LNP depends on the value of PST.
+
+ FND holds the CU file name and directory, if known.
+ It is used for relative paths in the line table.
+
+ NOTE: It is important that psymtabs have the same file name (via
+ strcmp) as the corresponding symtab. Since the directory is not
+ used in the name of the symtab we don't use it in the name of the
+ psymtabs we create. E.g. expand_line_sal requires this when
+ finding psymtabs to expand. A good testcase for this is
+ mb-inline.exp.
+
+ LOWPC is the lowest address in CU (or 0 if not known).
+
+ Boolean DECODE_MAPPING specifies we need to fully decode .debug_line
+ for its PC<->lines mapping information. Otherwise only the filename
+ table is read in. */
+
+extern void dwarf_decode_lines (struct line_header *lh,
+ struct dwarf2_cu *cu,
+ unrelocated_addr lowpc, bool decode_mapping);
+
+#endif /* GDB_DWARF2_LINE_PROGRAM_H */
diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c
index 97677c0..ddf4935 100644
--- a/gdb/dwarf2/read-debug-names.c
+++ b/gdb/dwarf2/read-debug-names.c
@@ -768,12 +768,12 @@ build_and_check_cu_lists_from_debug_names (dwarf2_per_bfd *per_bfd,
return build_and_check_cu_list_from_debug_names (per_bfd, dwz_map, dwz->info);
}
-/* This does all the work for dwarf2_read_debug_names, but putting it
- into a separate function makes some cleanup a bit simpler. */
+/* See read-debug-names.h. */
-static bool
-do_dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile)
+bool
+dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile)
{
+ scoped_remove_all_units remove_all_units (*per_objfile->per_bfd);
mapped_debug_names_reader map;
mapped_debug_names_reader dwz_map;
struct objfile *objfile = per_objfile->objfile;
@@ -850,17 +850,7 @@ do_dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile)
(per_objfile, std::move (map)));
auto idx = std::make_unique<debug_names_index> (std::move (cidn));
per_bfd->start_reading (std::move (idx));
+ remove_all_units.disable ();
return true;
}
-
-/* See read-debug-names.h. */
-
-bool
-dwarf2_read_debug_names (dwarf2_per_objfile *per_objfile)
-{
- bool result = do_dwarf2_read_debug_names (per_objfile);
- if (!result)
- per_objfile->per_bfd->all_units.clear ();
- return result;
-}
diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c
index 76317fe..5354263 100644
--- a/gdb/dwarf2/read-gdb-index.c
+++ b/gdb/dwarf2/read-gdb-index.c
@@ -27,16 +27,67 @@
#include "event-top.h"
#include "gdb/gdb-index.h"
#include "gdbsupport/gdb-checked-static-cast.h"
-#include "mapped-index.h"
+#include "cooked-index.h"
#include "read.h"
#include "extract-store-integer.h"
#include "cp-support.h"
#include "symtab.h"
#include "gdbsupport/selftest.h"
+#include "tag.h"
/* When true, do not reject deprecated .gdb_index sections. */
static bool use_deprecated_index_sections = false;
+struct dwarf2_gdb_index : public cooked_index_functions
+{
+ /* This dumps minimal information about the index.
+ It is called via "mt print objfiles".
+ One use is to verify .gdb_index has been loaded by the
+ gdb.dwarf2/gdb-index.exp testcase. */
+ void dump (struct objfile *objfile) override;
+};
+
+/* This is a cooked index as ingested from .gdb_index. */
+
+class cooked_gdb_index : public cooked_index
+{
+public:
+
+ cooked_gdb_index (cooked_index_worker_up worker,
+ int version)
+ : cooked_index (std::move (worker)),
+ version (version)
+ { }
+
+ /* This can't be used to write an index. */
+ cooked_index *index_for_writing () override
+ { return nullptr; }
+
+ quick_symbol_functions_up make_quick_functions () const override
+ { return quick_symbol_functions_up (new dwarf2_gdb_index); }
+
+ bool version_check () const override
+ {
+ return version >= 8;
+ }
+
+ /* Index data format version. */
+ int version;
+};
+
+/* See above. */
+
+void
+dwarf2_gdb_index::dump (struct objfile *objfile)
+{
+ dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
+
+ cooked_gdb_index *index = (gdb::checked_static_cast<cooked_gdb_index *>
+ (per_objfile->per_bfd->index_table.get ()));
+ gdb_printf (".gdb_index: version %d\n", index->version);
+ cooked_index_functions::dump (objfile);
+}
+
/* This is a view into the index that converts from bytes to an
offset_type, and allows indexing. Unaligned bytes are specifically
allowed here, and handled via unpacking. */
@@ -77,43 +128,11 @@ private:
gdb::array_view<const gdb_byte> m_bytes;
};
-/* An index into a (C++) symbol name component in a symbol name as
- recorded in the mapped_index's symbol table. For each C++ symbol
- in the symbol table, we record one entry for the start of each
- component in the symbol in a table of name components, and then
- sort the table, in order to be able to binary search symbol names,
- ignoring leading namespaces, both completion and regular look up.
- For example, for symbol "A::B::C", we'll have an entry that points
- to "A::B::C", another that points to "B::C", and another for "C".
- Note that function symbols in GDB index have no parameter
- information, just the function/method names. You can convert a
- name_component to a "const char *" using the
- 'mapped_index::symbol_name_at(offset_type)' method. */
-
-struct name_component
-{
- /* Offset in the symbol name where the component starts. Stored as
- a (32-bit) offset instead of a pointer to save memory and improve
- locality on 64-bit architectures. */
- offset_type name_offset;
-
- /* The symbol's index in the symbol and constant pool tables of a
- mapped_index. */
- offset_type idx;
-};
-
-/* A description of .gdb_index index. The file format is described in
- a comment by the code that writes the index. */
+/* A worker for reading .gdb_index. The file format is described in
+ the manual. */
-struct mapped_gdb_index : public dwarf_scanner_base
+struct mapped_gdb_index
{
- /* The name_component table (a sorted vector). See name_component's
- description above. */
- std::vector<name_component> name_components;
-
- /* How NAME_COMPONENTS is sorted. */
- enum case_sensitivity name_components_casing;
-
/* Index data format version. */
int version = 0;
@@ -136,6 +155,15 @@ struct mapped_gdb_index : public dwarf_scanner_base
/* An address map that maps from PC to dwarf2_per_cu. */
addrmap_fixed *index_addrmap = nullptr;
+ /* The name of 'main', or nullptr if not known. */
+ const char *main_name = nullptr;
+
+ /* The language of 'main', if known. */
+ enum language main_lang = language_minimal;
+
+ /* The result we're constructing. */
+ cooked_index_worker_result result;
+
/* Return the index into the constant pool of the name of the IDXth
symbol in the symbol table. */
offset_type symbol_name_index (offset_type idx) const
@@ -152,221 +180,41 @@ struct mapped_gdb_index : public dwarf_scanner_base
/* Return whether the name at IDX in the symbol table should be
ignored. */
- virtual bool symbol_name_slot_invalid (offset_type idx) const
+ bool symbol_name_slot_invalid (offset_type idx) const
{
- return (symbol_name_index (idx) == 0
- && symbol_vec_index (idx) == 0);
+ return symbol_name_index (idx) == 0 && symbol_vec_index (idx) == 0;
}
/* Convenience method to get at the name of the symbol at IDX in the
symbol table. */
- virtual const char *symbol_name_at
- (offset_type idx, dwarf2_per_objfile *per_objfile) const
+ const char *symbol_name_at (offset_type idx,
+ dwarf2_per_objfile *per_objfile) const
{
return (const char *) (this->constant_pool.data ()
+ symbol_name_index (idx));
}
- virtual size_t symbol_name_count () const
+ size_t symbol_name_count () const
{ return this->symbol_table.size () / 2; }
+ /* Set the name and language of the main function from the shortcut
+ table. */
+ void set_main_name (dwarf2_per_objfile *per_objfile);
+
/* Build the symbol name component sorted vector, if we haven't
yet. */
void build_name_components (dwarf2_per_objfile *per_objfile);
-
- /* Returns the lower (inclusive) and upper (exclusive) bounds of the
- possible matches for LN_NO_PARAMS in the name component
- vector. */
- std::pair<std::vector<name_component>::const_iterator,
- std::vector<name_component>::const_iterator>
- find_name_components_bounds (const lookup_name_info &ln_no_params,
- enum language lang,
- dwarf2_per_objfile *per_objfile) const;
-
- quick_symbol_functions_up make_quick_functions () const override;
-
- bool version_check () const override
- {
- return version >= 8;
- }
-
- dwarf2_per_cu *lookup (unrelocated_addr addr) override
- {
- if (index_addrmap == nullptr)
- return nullptr;
-
- void *obj = index_addrmap->find (static_cast<CORE_ADDR> (addr));
- return static_cast<dwarf2_per_cu *> (obj);
- }
-
- cooked_index *index_for_writing () override
- { return nullptr; }
};
-
-/* Starting from a search name, return the string that finds the upper
- bound of all strings that start with SEARCH_NAME in a sorted name
- list. Returns the empty string to indicate that the upper bound is
- the end of the list. */
-
-static std::string
-make_sort_after_prefix_name (const char *search_name)
-{
- /* When looking to complete "func", we find the upper bound of all
- symbols that start with "func" by looking for where we'd insert
- the closest string that would follow "func" in lexicographical
- order. Usually, that's "func"-with-last-character-incremented,
- i.e. "fund". Mind non-ASCII characters, though. Usually those
- will be UTF-8 multi-byte sequences, but we can't be certain.
- Especially mind the 0xff character, which is a valid character in
- non-UTF-8 source character sets (e.g. Latin1 'ÿ'), and we can't
- rule out compilers allowing it in identifiers. Note that
- conveniently, strcmp/strcasecmp are specified to compare
- characters interpreted as unsigned char. So what we do is treat
- the whole string as a base 256 number composed of a sequence of
- base 256 "digits" and add 1 to it. I.e., adding 1 to 0xff wraps
- to 0, and carries 1 to the following more-significant position.
- If the very first character in SEARCH_NAME ends up incremented
- and carries/overflows, then the upper bound is the end of the
- list. The string after the empty string is also the empty
- string.
-
- Some examples of this operation:
-
- SEARCH_NAME => "+1" RESULT
-
- "abc" => "abd"
- "ab\xff" => "ac"
- "\xff" "a" "\xff" => "\xff" "b"
- "\xff" => ""
- "\xff\xff" => ""
- "" => ""
-
- Then, with these symbols for example:
-
- func
- func1
- fund
-
- completing "func" looks for symbols between "func" and
- "func"-with-last-character-incremented, i.e. "fund" (exclusive),
- which finds "func" and "func1", but not "fund".
-
- And with:
-
- funcÿ (Latin1 'ÿ' [0xff])
- funcÿ1
- fund
-
- completing "funcÿ" looks for symbols between "funcÿ" and "fund"
- (exclusive), which finds "funcÿ" and "funcÿ1", but not "fund".
-
- And with:
-
- ÿÿ (Latin1 'ÿ' [0xff])
- ÿÿ1
-
- completing "ÿ" or "ÿÿ" looks for symbols between between "ÿÿ" and
- the end of the list.
- */
- std::string after = search_name;
- while (!after.empty () && (unsigned char) after.back () == 0xff)
- after.pop_back ();
- if (!after.empty ())
- after.back () = (unsigned char) after.back () + 1;
- return after;
-}
-
-/* See declaration. */
-
-std::pair<std::vector<name_component>::const_iterator,
- std::vector<name_component>::const_iterator>
-mapped_gdb_index::find_name_components_bounds
- (const lookup_name_info &lookup_name_without_params, language lang,
- dwarf2_per_objfile *per_objfile) const
-{
- auto *name_cmp
- = this->name_components_casing == case_sensitive_on ? strcmp : strcasecmp;
-
- const char *lang_name
- = lookup_name_without_params.language_lookup_name (lang);
-
- /* Comparison function object for lower_bound that matches against a
- given symbol name. */
- auto lookup_compare_lower = [&] (const name_component &elem,
- const char *name)
- {
- const char *elem_qualified = this->symbol_name_at (elem.idx, per_objfile);
- const char *elem_name = elem_qualified + elem.name_offset;
- return name_cmp (elem_name, name) < 0;
- };
-
- /* Comparison function object for upper_bound that matches against a
- given symbol name. */
- auto lookup_compare_upper = [&] (const char *name,
- const name_component &elem)
- {
- const char *elem_qualified = this->symbol_name_at (elem.idx, per_objfile);
- const char *elem_name = elem_qualified + elem.name_offset;
- return name_cmp (name, elem_name) < 0;
- };
-
- auto begin = this->name_components.begin ();
- auto end = this->name_components.end ();
-
- /* Find the lower bound. */
- auto lower = [&] ()
- {
- if (lookup_name_without_params.completion_mode () && lang_name[0] == '\0')
- return begin;
- else
- return std::lower_bound (begin, end, lang_name, lookup_compare_lower);
- } ();
-
- /* Find the upper bound. */
- auto upper = [&] ()
- {
- if (lookup_name_without_params.completion_mode ())
- {
- /* In completion mode, we want UPPER to point past all
- symbols names that have the same prefix. I.e., with
- these symbols, and completing "func":
-
- function << lower bound
- function1
- other_function << upper bound
-
- We find the upper bound by looking for the insertion
- point of "func"-with-last-character-incremented,
- i.e. "fund". */
- std::string after = make_sort_after_prefix_name (lang_name);
- if (after.empty ())
- return end;
- return std::lower_bound (lower, end, after.c_str (),
- lookup_compare_lower);
- }
- else
- return std::upper_bound (lower, end, lang_name, lookup_compare_upper);
- } ();
-
- return {lower, upper};
-}
-
/* See declaration. */
void
mapped_gdb_index::build_name_components (dwarf2_per_objfile *per_objfile)
{
- if (!this->name_components.empty ())
- return;
+ std::vector<std::pair<std::string_view, std::vector<cooked_index_entry *>>>
+ need_parents;
+ gdb::unordered_map<std::string_view, cooked_index_entry *> by_name;
- this->name_components_casing = case_sensitivity;
- auto *name_cmp
- = this->name_components_casing == case_sensitive_on ? strcmp : strcasecmp;
-
- /* The code below only knows how to break apart components of C++
- symbol names (and other languages that use '::' as
- namespace/module separator) and Ada symbol names. */
auto count = this->symbol_name_count ();
for (offset_type idx = 0; idx < count; idx++)
{
@@ -375,813 +223,186 @@ mapped_gdb_index::build_name_components (dwarf2_per_objfile *per_objfile)
const char *name = this->symbol_name_at (idx, per_objfile);
- /* Add each name component to the name component table. */
- unsigned int previous_len = 0;
+ /* This code only knows how to break apart components of C++
+ symbol names (and other languages that use '::' as
+ namespace/module separator) and Ada symbol names.
+ It's unfortunate that we need the language, but since it is
+ really only used to rebuild full names, pairing it with the
+ split method is fine. */
+ enum language lang;
+ std::vector<std::string_view> components;
if (strstr (name, "::") != nullptr)
{
- for (unsigned int current_len = cp_find_first_component (name);
- name[current_len] != '\0';
- current_len += cp_find_first_component (name + current_len))
- {
- gdb_assert (name[current_len] == ':');
- this->name_components.push_back ({previous_len, idx});
- /* Skip the '::'. */
- current_len += 2;
- previous_len = current_len;
- }
+ components = split_name (name, split_style::CXX);
+ lang = language_cplus;
}
- else
+ else if (strchr (name, '<') != nullptr)
{
- /* Handle the Ada encoded (aka mangled) form here. */
- for (const char *iter = strstr (name, "__");
- iter != nullptr;
- iter = strstr (iter, "__"))
- {
- this->name_components.push_back ({previous_len, idx});
- iter += 2;
- previous_len = iter - name;
- }
+ /* Guess that this is a template and so a C++ name. */
+ components.emplace_back (name);
+ lang = language_cplus;
}
-
- this->name_components.push_back ({previous_len, idx});
- }
-
- /* Sort name_components elements by name. */
- auto name_comp_compare = [&] (const name_component &left,
- const name_component &right)
- {
- const char *left_qualified
- = this->symbol_name_at (left.idx, per_objfile);
- const char *right_qualified
- = this->symbol_name_at (right.idx, per_objfile);
-
- const char *left_name = left_qualified + left.name_offset;
- const char *right_name = right_qualified + right.name_offset;
-
- return name_cmp (left_name, right_name) < 0;
- };
-
- std::sort (this->name_components.begin (),
- this->name_components.end (),
- name_comp_compare);
-}
-
-/* Helper for dw2_expand_symtabs_matching that works with a
- mapped_index_base instead of the containing objfile. This is split
- to a separate function in order to be able to unit test the
- name_components matching using a mock mapped_index_base. For each
- symbol name that matches, calls MATCH_CALLBACK, passing it the
- symbol's index in the mapped_index_base symbol table. */
-
-static bool
-dw2_expand_symtabs_matching_symbol
- (mapped_gdb_index &index,
- const lookup_name_info &lookup_name_in,
- expand_symtabs_symbol_matcher symbol_matcher,
- gdb::function_view<bool (offset_type)> match_callback,
- dwarf2_per_objfile *per_objfile,
- expand_symtabs_lang_matcher lang_matcher)
-{
- lookup_name_info lookup_name_without_params
- = lookup_name_in.make_ignore_params ();
-
- /* Build the symbol name component sorted vector, if we haven't
- yet. */
- index.build_name_components (per_objfile);
-
- /* The same symbol may appear more than once in the range though.
- E.g., if we're looking for symbols that complete "w", and we have
- a symbol named "w1::w2", we'll find the two name components for
- that same symbol in the range. To be sure we only call the
- callback once per symbol, we first collect the symbol name
- indexes that matched in a temporary vector and ignore
- duplicates. */
- std::vector<offset_type> matches;
-
- struct name_and_matcher
- {
- symbol_name_matcher_ftype *matcher;
- const char *name;
-
- bool operator== (const name_and_matcher &other) const
- {
- return matcher == other.matcher && strcmp (name, other.name) == 0;
- }
- };
-
- /* A vector holding all the different symbol name matchers, for all
- languages. */
- std::vector<name_and_matcher> matchers;
-
- for (int i = 0; i < nr_languages; i++)
- {
- enum language lang_e = (enum language) i;
- if (lang_matcher != nullptr && !lang_matcher (lang_e))
- continue;
-
- const language_defn *lang = language_def (lang_e);
- symbol_name_matcher_ftype *name_matcher
- = lang->get_symbol_name_matcher (lookup_name_without_params);
-
- name_and_matcher key {
- name_matcher,
- lookup_name_without_params.language_lookup_name (lang_e)
- };
-
- /* Don't insert the same comparison routine more than once.
- Note that we do this linear walk. This is not a problem in
- practice because the number of supported languages is
- low. */
- if (std::find (matchers.begin (), matchers.end (), key)
- != matchers.end ())
- continue;
- matchers.push_back (std::move (key));
-
- auto bounds
- = index.find_name_components_bounds (lookup_name_without_params,
- lang_e, per_objfile);
-
- /* Now for each symbol name in range, check to see if we have a name
- match, and if so, call the MATCH_CALLBACK callback. */
-
- for (; bounds.first != bounds.second; ++bounds.first)
+ else if (strstr (name, "__") != nullptr)
{
- const char *qualified
- = index.symbol_name_at (bounds.first->idx, per_objfile);
-
- if (!name_matcher (qualified, lookup_name_without_params, NULL)
- || (symbol_matcher != NULL && !symbol_matcher (qualified)))
- continue;
-
- matches.push_back (bounds.first->idx);
+ /* The Ada case is handled during finalization, because gdb
+ does not write the synthesized package names into the
+ index. */
+ components.emplace_back (name);
+ lang = language_ada;
}
- }
-
- std::sort (matches.begin (), matches.end ());
-
- /* Finally call the callback, once per match. */
- ULONGEST prev = -1;
- bool result = true;
- for (offset_type idx : matches)
- {
- if (prev != idx)
+ else
{
- if (!match_callback (idx))
- {
- result = false;
- break;
- }
- prev = idx;
+ components = split_name (name, split_style::DOT_STYLE);
+ /* Mark ordinary names as having an unknown language. This
+ is a hack to avoid problems with some Ada names. */
+ lang = (components.size () == 1) ? language_unknown : language_go;
}
- }
-
- /* Above we use a type wider than idx's for 'prev', since 0 and
- (offset_type)-1 are both possible values. */
- static_assert (sizeof (prev) > sizeof (offset_type), "");
-
- return result;
-}
-
-#if GDB_SELF_TEST
-
-namespace selftests { namespace dw2_expand_symtabs_matching {
-
-/* A mock .gdb_index/.debug_names-like name index table, enough to
- exercise dw2_expand_symtabs_matching_symbol, which works with the
- mapped_index_base interface. Builds an index from the symbol list
- passed as parameter to the constructor. */
-class mock_mapped_index : public mapped_gdb_index
-{
-public:
- mock_mapped_index (gdb::array_view<const char *> symbols)
- : m_symbol_table (symbols)
- {}
-
- DISABLE_COPY_AND_ASSIGN (mock_mapped_index);
-
- bool symbol_name_slot_invalid (offset_type idx) const override
- { return false; }
-
- /* Return the number of names in the symbol table. */
- size_t symbol_name_count () const override
- {
- return m_symbol_table.size ();
- }
-
- /* Get the name of the symbol at IDX in the symbol table. */
- const char *symbol_name_at
- (offset_type idx, dwarf2_per_objfile *per_objfile) const override
- {
- return m_symbol_table[idx];
- }
-
- quick_symbol_functions_up make_quick_functions () const override
- {
- return nullptr;
- }
-
-private:
- gdb::array_view<const char *> m_symbol_table;
-};
-
-/* Convenience function that converts a NULL pointer to a "<null>"
- string, to pass to print routines. */
-
-static const char *
-string_or_null (const char *str)
-{
- return str != NULL ? str : "<null>";
-}
-
-/* Check if a lookup_name_info built from
- NAME/MATCH_TYPE/COMPLETION_MODE matches the symbols in the mock
- index. EXPECTED_LIST is the list of expected matches, in expected
- matching order. If no match expected, then an empty list is
- specified. Returns true on success. On failure prints a warning
- indicating the file:line that failed, and returns false. */
-
-static bool
-check_match (const char *file, int line,
- mock_mapped_index &mock_index,
- const char *name, symbol_name_match_type match_type,
- bool completion_mode,
- std::initializer_list<const char *> expected_list,
- dwarf2_per_objfile *per_objfile)
-{
- lookup_name_info lookup_name (name, match_type, completion_mode);
-
- bool matched = true;
-
- auto mismatch = [&] (const char *expected_str,
- const char *got)
- {
- warning (_("%s:%d: match_type=%s, looking-for=\"%s\", "
- "expected=\"%s\", got=\"%s\"\n"),
- file, line,
- (match_type == symbol_name_match_type::FULL
- ? "FULL" : "WILD"),
- name, string_or_null (expected_str), string_or_null (got));
- matched = false;
- };
-
- auto expected_it = expected_list.begin ();
- auto expected_end = expected_list.end ();
-
- dw2_expand_symtabs_matching_symbol (mock_index, lookup_name,
- nullptr,
- [&] (offset_type idx)
- {
- const char *matched_name = mock_index.symbol_name_at (idx, per_objfile);
- const char *expected_str
- = expected_it == expected_end ? NULL : *expected_it++;
-
- if (expected_str == NULL || strcmp (expected_str, matched_name) != 0)
- mismatch (expected_str, matched_name);
- return true;
- }, per_objfile, nullptr);
-
- const char *expected_str
- = expected_it == expected_end ? NULL : *expected_it++;
- if (expected_str != NULL)
- mismatch (expected_str, NULL);
-
- return matched;
-}
-
-/* The symbols added to the mock mapped_index for testing (in
- canonical form). */
-static const char *test_symbols[] = {
- "function",
- "std::bar",
- "std::zfunction",
- "std::zfunction2",
- "w1::w2",
- "ns::foo<char*>",
- "ns::foo<int>",
- "ns::foo<long>",
- "ns2::tmpl<int>::foo2",
- "(anonymous namespace)::A::B::C",
-
- /* These are used to check that the increment-last-char in the
- matching algorithm for completion doesn't match "t1_fund" when
- completing "t1_func". */
- "t1_func",
- "t1_func1",
- "t1_fund",
- "t1_fund1",
-
- /* A UTF-8 name with multi-byte sequences to make sure that
- cp-name-parser understands this as a single identifier ("função"
- is "function" in PT). */
- (const char *)u8"u8função",
-
- /* Test a symbol name that ends with a 0xff character, which is a
- valid character in non-UTF-8 source character sets (e.g. Latin1
- 'ÿ'), and we can't rule out compilers allowing it in identifiers.
- We test this because the completion algorithm finds the upper
- bound of symbols by looking for the insertion point of
- "func"-with-last-character-incremented, i.e. "fund", and adding 1
- to 0xff should wraparound and carry to the previous character.
- See comments in make_sort_after_prefix_name. */
- "yfunc\377",
-
- /* Some more symbols with \377 (0xff). See above. */
- "\377",
- "\377\377123",
-
- /* A name with all sorts of complications. Starts with "z" to make
- it easier for the completion tests below. */
-#define Z_SYM_NAME \
- "z::std::tuple<(anonymous namespace)::ui*, std::bar<(anonymous namespace)::ui> >" \
- "::tuple<(anonymous namespace)::ui*, " \
- "std::default_delete<(anonymous namespace)::ui>, void>"
-
- Z_SYM_NAME
-};
-/* Returns true if the mapped_index_base::find_name_component_bounds
- method finds EXPECTED_SYMS in INDEX when looking for SEARCH_NAME,
- in completion mode. */
-
-static bool
-check_find_bounds_finds (mapped_gdb_index &index,
- const char *search_name,
- gdb::array_view<const char *> expected_syms,
- dwarf2_per_objfile *per_objfile)
-{
- lookup_name_info lookup_name (search_name,
- symbol_name_match_type::FULL, true);
-
- auto bounds = index.find_name_components_bounds (lookup_name,
- language_cplus,
- per_objfile);
-
- size_t distance = std::distance (bounds.first, bounds.second);
- if (distance != expected_syms.size ())
- return false;
-
- for (size_t exp_elem = 0; exp_elem < distance; exp_elem++)
- {
- auto nc_elem = bounds.first + exp_elem;
- const char *qualified = index.symbol_name_at (nc_elem->idx, per_objfile);
- if (strcmp (qualified, expected_syms[exp_elem]) != 0)
- return false;
- }
-
- return true;
-}
-
-/* Test the lower-level mapped_index::find_name_component_bounds
- method. */
-
-static void
-test_mapped_index_find_name_component_bounds ()
-{
- mock_mapped_index mock_index (test_symbols);
-
- mock_index.build_name_components (NULL /* per_objfile */);
-
- /* Test the lower-level mapped_index::find_name_component_bounds
- method in completion mode. */
- {
- static const char *expected_syms[] = {
- "t1_func",
- "t1_func1",
- };
-
- SELF_CHECK (check_find_bounds_finds
- (mock_index, "t1_func", expected_syms,
- NULL /* per_objfile */));
- }
-
- /* Check that the increment-last-char in the name matching algorithm
- for completion doesn't get confused with Ansi1 'ÿ' / 0xff. See
- make_sort_after_prefix_name. */
- {
- static const char *expected_syms1[] = {
- "\377",
- "\377\377123",
- };
- SELF_CHECK (check_find_bounds_finds
- (mock_index, "\377", expected_syms1, NULL /* per_objfile */));
-
- static const char *expected_syms2[] = {
- "\377\377123",
- };
- SELF_CHECK (check_find_bounds_finds
- (mock_index, "\377\377", expected_syms2,
- NULL /* per_objfile */));
- }
-}
-
-/* Test dw2_expand_symtabs_matching_symbol. */
-
-static void
-test_dw2_expand_symtabs_matching_symbol ()
-{
- mock_mapped_index mock_index (test_symbols);
-
- /* We let all tests run until the end even if some fails, for debug
- convenience. */
- bool any_mismatch = false;
-
- /* Create the expected symbols list (an initializer_list). Needed
- because lists have commas, and we need to pass them to CHECK,
- which is a macro. */
-#define EXPECT(...) { __VA_ARGS__ }
-
- /* Wrapper for check_match that passes down the current
- __FILE__/__LINE__. */
-#define CHECK_MATCH(NAME, MATCH_TYPE, COMPLETION_MODE, EXPECTED_LIST) \
- any_mismatch |= !check_match (__FILE__, __LINE__, \
- mock_index, \
- NAME, MATCH_TYPE, COMPLETION_MODE, \
- EXPECTED_LIST, NULL)
-
- /* Identity checks. */
- for (const char *sym : test_symbols)
- {
- /* Should be able to match all existing symbols. */
- CHECK_MATCH (sym, symbol_name_match_type::FULL, false,
- EXPECT (sym));
-
- /* Should be able to match all existing symbols with
- parameters. */
- std::string with_params = std::string (sym) + "(int)";
- CHECK_MATCH (with_params.c_str (), symbol_name_match_type::FULL, false,
- EXPECT (sym));
-
- /* Should be able to match all existing symbols with
- parameters and qualifiers. */
- with_params = std::string (sym) + " ( int ) const";
- CHECK_MATCH (with_params.c_str (), symbol_name_match_type::FULL, false,
- EXPECT (sym));
-
- /* This should really find sym, but cp-name-parser.y doesn't
- know about lvalue/rvalue qualifiers yet. */
- with_params = std::string (sym) + " ( int ) &&";
- CHECK_MATCH (with_params.c_str (), symbol_name_match_type::FULL, false,
- {});
- }
-
- /* Check that the name matching algorithm for completion doesn't get
- confused with Latin1 'ÿ' / 0xff. See
- make_sort_after_prefix_name. */
- {
- static const char str[] = "\377";
- CHECK_MATCH (str, symbol_name_match_type::FULL, true,
- EXPECT ("\377", "\377\377123"));
- }
-
- /* Check that the increment-last-char in the matching algorithm for
- completion doesn't match "t1_fund" when completing "t1_func". */
- {
- static const char str[] = "t1_func";
- CHECK_MATCH (str, symbol_name_match_type::FULL, true,
- EXPECT ("t1_func", "t1_func1"));
- }
-
- /* Check that completion mode works at each prefix of the expected
- symbol name. */
- {
- static const char str[] = "function(int)";
- size_t len = strlen (str);
- std::string lookup;
-
- for (size_t i = 1; i < len; i++)
- {
- lookup.assign (str, i);
- CHECK_MATCH (lookup.c_str (), symbol_name_match_type::FULL, true,
- EXPECT ("function"));
- }
- }
-
- /* While "w" is a prefix of both components, the match function
- should still only be called once. */
- {
- CHECK_MATCH ("w", symbol_name_match_type::FULL, true,
- EXPECT ("w1::w2"));
- CHECK_MATCH ("w", symbol_name_match_type::WILD, true,
- EXPECT ("w1::w2"));
- }
-
- /* Same, with a "complicated" symbol. */
- {
- static const char str[] = Z_SYM_NAME;
- size_t len = strlen (str);
- std::string lookup;
-
- for (size_t i = 1; i < len; i++)
- {
- lookup.assign (str, i);
- CHECK_MATCH (lookup.c_str (), symbol_name_match_type::FULL, true,
- EXPECT (Z_SYM_NAME));
- }
- }
-
- /* In FULL mode, an incomplete symbol doesn't match. */
- {
- CHECK_MATCH ("std::zfunction(int", symbol_name_match_type::FULL, false,
- {});
- }
-
- /* A complete symbol with parameters matches any overload, since the
- index has no overload info. */
- {
- CHECK_MATCH ("std::zfunction(int)", symbol_name_match_type::FULL, true,
- EXPECT ("std::zfunction", "std::zfunction2"));
- CHECK_MATCH ("zfunction(int)", symbol_name_match_type::WILD, true,
- EXPECT ("std::zfunction", "std::zfunction2"));
- CHECK_MATCH ("zfunc", symbol_name_match_type::WILD, true,
- EXPECT ("std::zfunction", "std::zfunction2"));
- }
-
- /* Check that whitespace is ignored appropriately. A symbol with a
- template argument list. */
- {
- static const char expected[] = "ns::foo<int>";
- CHECK_MATCH ("ns :: foo < int > ", symbol_name_match_type::FULL, false,
- EXPECT (expected));
- CHECK_MATCH ("foo < int > ", symbol_name_match_type::WILD, false,
- EXPECT (expected));
- }
-
- /* Check that whitespace is ignored appropriately. A symbol with a
- template argument list that includes a pointer. */
- {
- static const char expected[] = "ns::foo<char*>";
- /* Try both completion and non-completion modes. */
- static const bool completion_mode[2] = {false, true};
- for (size_t i = 0; i < 2; i++)
- {
- CHECK_MATCH ("ns :: foo < char * >", symbol_name_match_type::FULL,
- completion_mode[i], EXPECT (expected));
- CHECK_MATCH ("foo < char * >", symbol_name_match_type::WILD,
- completion_mode[i], EXPECT (expected));
-
- CHECK_MATCH ("ns :: foo < char * > (int)", symbol_name_match_type::FULL,
- completion_mode[i], EXPECT (expected));
- CHECK_MATCH ("foo < char * > (int)", symbol_name_match_type::WILD,
- completion_mode[i], EXPECT (expected));
- }
- }
-
- {
- /* Check method qualifiers are ignored. */
- static const char expected[] = "ns::foo<char*>";
- CHECK_MATCH ("ns :: foo < char * > ( int ) const",
- symbol_name_match_type::FULL, true, EXPECT (expected));
- CHECK_MATCH ("ns :: foo < char * > ( int ) &&",
- symbol_name_match_type::FULL, true, EXPECT (expected));
- CHECK_MATCH ("foo < char * > ( int ) const",
- symbol_name_match_type::WILD, true, EXPECT (expected));
- CHECK_MATCH ("foo < char * > ( int ) &&",
- symbol_name_match_type::WILD, true, EXPECT (expected));
- }
-
- /* Test lookup names that don't match anything. */
- {
- CHECK_MATCH ("bar2", symbol_name_match_type::WILD, false,
- {});
-
- CHECK_MATCH ("doesntexist", symbol_name_match_type::FULL, false,
- {});
- }
-
- /* Some wild matching tests, exercising "(anonymous namespace)",
- which should not be confused with a parameter list. */
- {
- static const char *syms[] = {
- "A::B::C",
- "B::C",
- "C",
- "A :: B :: C ( int )",
- "B :: C ( int )",
- "C ( int )",
- };
-
- for (const char *s : syms)
- {
- CHECK_MATCH (s, symbol_name_match_type::WILD, false,
- EXPECT ("(anonymous namespace)::A::B::C"));
- }
- }
-
- {
- static const char expected[] = "ns2::tmpl<int>::foo2";
- CHECK_MATCH ("tmp", symbol_name_match_type::WILD, true,
- EXPECT (expected));
- CHECK_MATCH ("tmpl<", symbol_name_match_type::WILD, true,
- EXPECT (expected));
- }
-
- SELF_CHECK (!any_mismatch);
-
-#undef EXPECT
-#undef CHECK_MATCH
-}
-
-static void
-run_test ()
-{
- test_mapped_index_find_name_component_bounds ();
- test_dw2_expand_symtabs_matching_symbol ();
-}
-
-}} /* namespace selftests::dw2_expand_symtabs_matching */
-
-#endif /* GDB_SELF_TEST */
-
-struct dwarf2_gdb_index : public dwarf2_base_index_functions
-{
- /* This dumps minimal information about the index.
- It is called via "mt print objfiles".
- One use is to verify .gdb_index has been loaded by the
- gdb.dwarf2/gdb-index.exp testcase. */
- void dump (struct objfile *objfile) override;
-
- bool expand_symtabs_matching
- (struct objfile *objfile,
- expand_symtabs_file_matcher file_matcher,
- const lookup_name_info *lookup_name,
- expand_symtabs_symbol_matcher symbol_matcher,
- expand_symtabs_expansion_listener expansion_notify,
- block_search_flags search_flags,
- domain_search_flags domain,
- expand_symtabs_lang_matcher lang_matcher) override;
-};
-
-/* This dumps minimal information about the index.
- It is called via "mt print objfiles".
- One use is to verify .gdb_index has been loaded by the
- gdb.dwarf2/gdb-index.exp testcase. */
-
-void
-dwarf2_gdb_index::dump (struct objfile *objfile)
-{
- dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
-
- mapped_gdb_index *index = (gdb::checked_static_cast<mapped_gdb_index *>
- (per_objfile->per_bfd->index_table.get ()));
- gdb_printf (".gdb_index: version %d\n", index->version);
- gdb_printf ("\n");
-}
-
-/* Helper for dw2_expand_matching symtabs. Called on each symbol
- matched, to expand corresponding CUs that were marked. IDX is the
- index of the symbol name that matched. */
-
-static bool
-dw2_expand_marked_cus (dwarf2_per_objfile *per_objfile, offset_type idx,
- expand_symtabs_file_matcher file_matcher,
- expand_symtabs_expansion_listener expansion_notify,
- block_search_flags search_flags,
- domain_search_flags kind,
- expand_symtabs_lang_matcher lang_matcher)
-{
- offset_type vec_len, vec_idx;
- bool global_seen = false;
- mapped_gdb_index &index
- = *(gdb::checked_static_cast<mapped_gdb_index *>
- (per_objfile->per_bfd->index_table.get ()));
-
- offset_view vec (index.constant_pool.slice (index.symbol_vec_index (idx)));
- vec_len = vec[0];
- for (vec_idx = 0; vec_idx < vec_len; ++vec_idx)
- {
- offset_type cu_index_and_attrs = vec[vec_idx + 1];
- /* This value is only valid for index versions >= 7. */
- int is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (cu_index_and_attrs);
- gdb_index_symbol_kind symbol_kind =
- GDB_INDEX_SYMBOL_KIND_VALUE (cu_index_and_attrs);
- int cu_index = GDB_INDEX_CU_VALUE (cu_index_and_attrs);
- /* Only check the symbol attributes if they're present.
- Indices prior to version 7 don't record them,
- and indices >= 7 may elide them for certain symbols
- (gold does this). */
- int attrs_valid =
- (index.version >= 7
- && symbol_kind != GDB_INDEX_SYMBOL_KIND_NONE);
-
- /* Work around gold/15646. */
- if (attrs_valid
- && !is_static
- && symbol_kind == GDB_INDEX_SYMBOL_KIND_TYPE)
+ std::vector<cooked_index_entry *> these_entries;
+ offset_view vec (constant_pool.slice (symbol_vec_index (idx)));
+ offset_type vec_len = vec[0];
+ bool global_seen = false;
+ for (offset_type vec_idx = 0; vec_idx < vec_len; ++vec_idx)
{
- if (global_seen)
+ offset_type cu_index_and_attrs = vec[vec_idx + 1];
+ gdb_index_symbol_kind symbol_kind
+ = GDB_INDEX_SYMBOL_KIND_VALUE (cu_index_and_attrs);
+ /* Only use a symbol if the attributes are present. Indices
+ prior to version 7 don't record them, and indices >= 7
+ may elide them for certain symbols (gold does this). */
+ if (symbol_kind == GDB_INDEX_SYMBOL_KIND_NONE)
continue;
- global_seen = true;
- }
+ int is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (cu_index_and_attrs);
- /* Only check the symbol's kind if it has one. */
- if (attrs_valid)
- {
- if (is_static)
+ int cu_index = GDB_INDEX_CU_VALUE (cu_index_and_attrs);
+ /* Don't crash on bad data. */
+ if (cu_index >= units.size ())
{
- if ((search_flags & SEARCH_STATIC_BLOCK) == 0)
- continue;
- }
- else
- {
- if ((search_flags & SEARCH_GLOBAL_BLOCK) == 0)
- continue;
+ complaint (_(".gdb_index entry has bad CU index"
+ " [in module %s]"),
+ objfile_name (per_objfile->objfile));
+ continue;
}
+ dwarf2_per_cu *per_cu = units[cu_index];
- domain_search_flags mask = 0;
+ enum language this_lang = lang;
+ dwarf_tag tag;
switch (symbol_kind)
{
case GDB_INDEX_SYMBOL_KIND_VARIABLE:
- mask = SEARCH_VAR_DOMAIN;
+ tag = DW_TAG_variable;
break;
case GDB_INDEX_SYMBOL_KIND_FUNCTION:
- mask = SEARCH_FUNCTION_DOMAIN;
+ tag = DW_TAG_subprogram;
break;
case GDB_INDEX_SYMBOL_KIND_TYPE:
- mask = SEARCH_TYPE_DOMAIN | SEARCH_STRUCT_DOMAIN;
+ if (is_static)
+ tag = (dwarf_tag) DW_TAG_GDB_INDEX_TYPE;
+ else
+ {
+ /* Work around gold/15646. */
+ if (global_seen)
+ continue;
+ global_seen = true;
+
+ tag = DW_TAG_structure_type;
+ this_lang = language_cplus;
+ }
break;
+ /* The "default" should not happen, but we mention it to
+ avoid an uninitialized warning. */
+ default:
case GDB_INDEX_SYMBOL_KIND_OTHER:
- mask = SEARCH_MODULE_DOMAIN;
+ tag = (dwarf_tag) DW_TAG_GDB_INDEX_OTHER;
break;
}
- if ((kind & mask) == 0)
- continue;
- }
- /* Don't crash on bad data. */
- if (cu_index >= index.units.size ())
- {
- complaint (_(".gdb_index entry has bad CU index"
- " [in module %s]"), objfile_name (per_objfile->objfile));
- continue;
+ cooked_index_flag flags = 0;
+ if (is_static)
+ flags |= IS_STATIC;
+ if (main_name != nullptr
+ && tag == DW_TAG_subprogram
+ && strcmp (name, main_name) == 0)
+ {
+ flags |= IS_MAIN;
+ this_lang = main_lang;
+ /* Don't bother looking for another. */
+ main_name = nullptr;
+ }
+
+ /* Note that this assumes the final component ends in \0. */
+ cooked_index_entry *entry = result.add (per_cu->sect_off, tag,
+ flags, this_lang,
+ components.back ().data (),
+ nullptr, per_cu);
+ /* Don't bother pushing if we do not need a parent. */
+ if (components.size () > 1)
+ these_entries.push_back (entry);
+
+ /* We don't care exactly which entry ends up in this
+ map. */
+ by_name[std::string_view (name)] = entry;
}
- dwarf2_per_cu *per_cu = index.units[cu_index];
+ if (components.size () > 1)
+ {
+ std::string_view penultimate = components[components.size () - 2];
+ std::string_view prefix (name, &penultimate.back () + 1 - name);
- if (!dw2_expand_symtabs_matching_one (per_cu, per_objfile, file_matcher,
- expansion_notify, lang_matcher))
- return false;
+ need_parents.emplace_back (prefix, std::move (these_entries));
+ }
}
- return true;
+ for (const auto &[prefix, entries] : need_parents)
+ {
+ auto iter = by_name.find (prefix);
+ /* If we can't find the parent entry, just lose. It should
+ always be there. We could synthesize it from the components,
+ if we kept those, but that seems like overkill. */
+ if (iter != by_name.end ())
+ {
+ for (cooked_index_entry *entry : entries)
+ entry->set_parent (iter->second);
+ }
+ }
}
-bool
-dwarf2_gdb_index::expand_symtabs_matching
- (objfile *objfile,
- expand_symtabs_file_matcher file_matcher,
- const lookup_name_info *lookup_name,
- expand_symtabs_symbol_matcher symbol_matcher,
- expand_symtabs_expansion_listener expansion_notify,
- block_search_flags search_flags,
- domain_search_flags domain,
- expand_symtabs_lang_matcher lang_matcher)
+/* The worker that reads a mapped index and fills in a
+ cooked_index_worker_result. */
+
+class gdb_index_worker : public cooked_index_worker
{
- dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
+public:
- dw_expand_symtabs_matching_file_matcher (per_objfile, file_matcher);
+ gdb_index_worker (dwarf2_per_objfile *per_objfile,
+ std::unique_ptr<mapped_gdb_index> map)
+ : cooked_index_worker (per_objfile),
+ map (std::move (map))
+ { }
- /* This invariant is documented in quick-functions.h. */
- gdb_assert (lookup_name != nullptr || symbol_matcher == nullptr);
- if (lookup_name == nullptr)
- {
- for (dwarf2_per_cu *per_cu : all_units_range (per_objfile->per_bfd))
- {
- QUIT;
+ void do_reading () override;
- if (!dw2_expand_symtabs_matching_one (per_cu, per_objfile,
- file_matcher,
- expansion_notify,
- lang_matcher))
- return false;
- }
- return true;
- }
+ /* The map we're reading. */
+ std::unique_ptr<mapped_gdb_index> map;
+};
- mapped_gdb_index &index
- = *(gdb::checked_static_cast<mapped_gdb_index *>
- (per_objfile->per_bfd->index_table.get ()));
+void
+gdb_index_worker::do_reading ()
+{
+ complaint_interceptor complaint_handler;
+ map->build_name_components (m_per_objfile);
- bool result
- = dw2_expand_symtabs_matching_symbol (index, *lookup_name,
- symbol_matcher,
- [&] (offset_type idx)
- {
- if (!dw2_expand_marked_cus (per_objfile, idx, file_matcher,
- expansion_notify, search_flags, domain,
- lang_matcher))
- return false;
- return true;
- }, per_objfile, lang_matcher);
+ m_results.push_back (std::move (map->result));
+ m_results[0].done_reading (complaint_handler.release ());
- return result;
-}
+ /* No longer needed. */
+ map.reset ();
-quick_symbol_functions_up
-mapped_gdb_index::make_quick_functions () const
-{
- return quick_symbol_functions_up (new dwarf2_gdb_index);
+ done_reading ();
+
+ bfd_thread_cleanup ();
}
/* A helper function that reads the .gdb_index from BUFFER and fills
@@ -1210,11 +431,9 @@ read_gdb_index_from_buffer (const char *filename,
/* Version check. */
offset_type version = metadata[0];
- /* Versions earlier than 3 emitted every copy of a psymbol. This
- causes the index to behave very poorly for certain requests. Version 3
- contained incomplete addrmap. So, it seems better to just ignore such
- indices. */
- if (version < 4)
+ /* GDB now requires the symbol attributes, which were added in
+ version 7. */
+ if (version < 7)
{
static int warning_printed = 0;
if (!warning_printed)
@@ -1225,30 +444,6 @@ read_gdb_index_from_buffer (const char *filename,
}
return 0;
}
- /* Index version 4 uses a different hash function than index version
- 5 and later.
-
- Versions earlier than 6 did not emit psymbols for inlined
- functions. Using these files will cause GDB not to be able to
- set breakpoints on inlined functions by name, so we ignore these
- indices unless the user has done
- "set use-deprecated-index-sections on". */
- if (version < 6 && !deprecated_ok)
- {
- static int warning_printed = 0;
- if (!warning_printed)
- {
- warning (_("\
-Skipping deprecated .gdb_index section in %s.\n\
-Do \"%ps\" before the file is read\n\
-to use the section anyway."),
- filename,
- styled_string (command_style.style (),
- "set use-deprecated-index-sections on"));
- warning_printed = 1;
- }
- return 0;
- }
/* Version 7 indices generated by gold refer to the CU for a symbol instead
of the TU (for symbols coming from TUs),
http://sourceware.org/bugzilla/show_bug.cgi?id=15021.
@@ -1395,13 +590,13 @@ create_signatured_type_table_from_gdb_index
per_bfd->signatured_types = std::move (sig_types_hash);
}
-/* Read the address map data from the mapped GDB index. */
+/* Read the address map data from the mapped GDB index. Return true if no
+ errors were found, otherwise return false. */
-static void
+static bool
create_addrmap_from_gdb_index (dwarf2_per_objfile *per_objfile,
mapped_gdb_index *index)
{
- dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
const gdb_byte *iter, *end;
addrmap_mutable mutable_map;
@@ -1419,40 +614,48 @@ create_addrmap_from_gdb_index (dwarf2_per_objfile *per_objfile,
cu_index = extract_unsigned_integer (iter, 4, BFD_ENDIAN_LITTLE);
iter += 4;
- if (lo > hi)
+ if (lo >= hi)
{
- complaint (_(".gdb_index address table has invalid range (%s - %s)"),
- hex_string (lo), hex_string (hi));
- continue;
+ warning (_(".gdb_index address table has invalid range (%s - %s),"
+ " ignoring .gdb_index"),
+ hex_string (lo), hex_string (hi));
+ return false;
}
if (cu_index >= index->units.size ())
{
- complaint (_(".gdb_index address table has invalid CU number %u"),
- (unsigned) cu_index);
- continue;
+ warning (_(".gdb_index address table has invalid CU number %u,"
+ " ignoring .gdb_index"),
+ (unsigned) cu_index);
+ return false;
}
- mutable_map.set_empty (lo, hi - 1, index->units[cu_index]);
+ bool full_range_p
+ = mutable_map.set_empty (lo, hi - 1, index->units[cu_index]);
+ if (!full_range_p)
+ {
+ warning (_(".gdb_index address table has a range (%s - %s) that"
+ " overlaps with an earlier range, ignoring .gdb_index"),
+ hex_string (lo), hex_string (hi));
+ return false;
+ }
}
- index->index_addrmap
- = new (&per_bfd->obstack) addrmap_fixed (&per_bfd->obstack, &mutable_map);
-}
+ index->result.set_addrmap (std::move (mutable_map));
-/* Sets the name and language of the main function from the shortcut table. */
+ return true;
+}
-static void
-set_main_name_from_gdb_index (dwarf2_per_objfile *per_objfile,
- mapped_gdb_index *index)
+void
+mapped_gdb_index::set_main_name (dwarf2_per_objfile *per_objfile)
{
const auto expected_size = 2 * sizeof (offset_type);
- if (index->shortcut_table.size () < expected_size)
+ if (this->shortcut_table.size () < expected_size)
/* The data in the section is not present, is corrupted or is in a version
we don't know about. Regardless, we can't make use of it. */
return;
- auto ptr = index->shortcut_table.data ();
+ auto ptr = this->shortcut_table.data ();
const auto dw_lang = extract_unsigned_integer (ptr, 4, BFD_ENDIAN_LITTLE);
if (dw_lang >= DW_LANG_hi_user)
{
@@ -1468,13 +671,11 @@ set_main_name_from_gdb_index (dwarf2_per_objfile *per_objfile,
}
ptr += 4;
- const auto lang = dwarf_lang_to_enum_language (dw_lang);
+ main_lang = dwarf_lang_to_enum_language (dw_lang);
const auto name_offset = extract_unsigned_integer (ptr,
sizeof (offset_type),
BFD_ENDIAN_LITTLE);
- const auto name = (const char *) (index->constant_pool.data () + name_offset);
-
- set_objfile_main_name (per_objfile->objfile, name, (enum language) lang);
+ main_name = (const char *) (this->constant_pool.data () + name_offset);
}
/* See read-gdb-index.h. */
@@ -1489,6 +690,7 @@ dwarf2_read_gdb_index
offset_type cu_list_elements, types_list_elements, dwz_list_elements = 0;
struct objfile *objfile = per_objfile->objfile;
dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
+ scoped_remove_all_units remove_all_units (*per_bfd);
gdb::array_view<const gdb_byte> main_index_contents
= get_gdb_index_contents (objfile, per_bfd);
@@ -1544,10 +746,7 @@ dwarf2_read_gdb_index
an index. */
if (per_bfd->infos.size () > 1
|| per_bfd->types.size () > 1)
- {
- per_bfd->all_units.clear ();
- return false;
- }
+ return false;
dwarf2_section_info *section
= (per_bfd->types.size () == 1
@@ -1561,11 +760,19 @@ dwarf2_read_gdb_index
finalize_all_units (per_bfd);
- create_addrmap_from_gdb_index (per_objfile, map.get ());
+ if (!create_addrmap_from_gdb_index (per_objfile, map.get ()))
+ return false;
- set_main_name_from_gdb_index (per_objfile, map.get ());
+ map->set_main_name (per_objfile);
- per_bfd->index_table = std::move (map);
+ int version = map->version;
+ auto worker = std::make_unique<gdb_index_worker> (per_objfile,
+ std::move (map));
+ auto idx = std::make_unique<cooked_gdb_index> (std::move (worker),
+ version);
+
+ per_bfd->start_reading (std::move (idx));
+ remove_all_units.disable ();
return true;
}
@@ -1583,9 +790,4 @@ Warning: This option must be enabled before gdb reads the file."),
NULL,
NULL,
&setlist, &showlist);
-
-#if GDB_SELF_TEST
- selftests::register_test ("dw2_expand_symtabs_matching",
- selftests::dw2_expand_symtabs_matching::run_test);
-#endif
}
diff --git a/gdb/dwarf2/read-gdb-index.h b/gdb/dwarf2/read-gdb-index.h
index 5107d63..c8f1fd0 100644
--- a/gdb/dwarf2/read-gdb-index.h
+++ b/gdb/dwarf2/read-gdb-index.h
@@ -27,6 +27,20 @@ struct dwarf2_per_objfile;
struct dwz_file;
struct objfile;
+/* .gdb_index doesn't distinguish between the various "other" symbols
+ -- but the symbol search machinery really wants to. For example,
+ an imported decl is "other" but is really a namespace and thus in
+ TYPE_DOMAIN; whereas a Fortran module is also "other" but is in the
+ MODULE_DOMAIN. We use this value internally to represent the
+ "other" case so that matching can work. The exact value does not
+ matter, all that matters here is that it won't overlap with any
+ symbol that gdb might create. */
+#define DW_TAG_GDB_INDEX_OTHER 0xffff
+
+/* Similarly, .gdb_index can't distinguish between the type and struct
+ domains. This is a special tag that inhabits both. */
+#define DW_TAG_GDB_INDEX_TYPE 0xfffe
+
/* Callback types for dwarf2_read_gdb_index. */
typedef gdb::function_view
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index ec8d376..8019179 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -38,6 +38,7 @@
#include "dwarf2/index-cache.h"
#include "dwarf2/leb.h"
#include "dwarf2/line-header.h"
+#include "dwarf2/line-program.h"
#include "dwarf2/dwz.h"
#include "dwarf2/macro.h"
#include "dwarf2/die.h"
@@ -147,7 +148,7 @@ static const registry<bfd>::key<dwarf2_per_bfd> dwarf2_per_bfd_bfd_data_key;
static const registry<objfile>::key<dwarf2_per_bfd>
dwarf2_per_bfd_objfile_data_key;
-/* The "aclass" indices for various kinds of computed DWARF symbols. */
+/* The "loc_class" indices for various kinds of computed DWARF symbols. */
static int dwarf2_locexpr_index;
static int dwarf2_loclist_index;
@@ -787,13 +788,6 @@ static line_header_up dwarf_decode_line_header (sect_offset sect_off,
struct dwarf2_cu *cu,
const char *comp_dir);
-static void dwarf_decode_lines (struct line_header *,
- struct dwarf2_cu *,
- unrelocated_addr, int decode_mapping);
-
-static void dwarf2_start_subfile (dwarf2_cu *cu, const file_entry &fe,
- const line_header &lh);
-
static struct symbol *new_symbol (struct die_info *, struct type *,
struct dwarf2_cu *, struct symbol * = NULL);
@@ -857,6 +851,11 @@ static struct dwarf2_section_info *cu_debug_loc_section (struct dwarf2_cu *cu);
static struct dwarf2_section_info *cu_debug_rnglists_section
(struct dwarf2_cu *cu, dwarf_tag tag);
+static void dw_search_file_matcher
+ (dwarf2_per_objfile *per_objfile,
+ auto_bool_vector &cus_to_skip,
+ search_symtabs_file_matcher file_matcher);
+
static void get_scope_pc_bounds (struct die_info *,
unrelocated_addr *, unrelocated_addr *,
struct dwarf2_cu *);
@@ -987,9 +986,6 @@ static void queue_comp_unit (dwarf2_per_cu *per_cu,
static void process_queue (dwarf2_per_objfile *per_objfile);
-static bool is_ada_import_or_export (dwarf2_cu *cu, const char *name,
- const char *linkagename);
-
/* Class, the destructor of which frees all allocated queue entries. This
will only have work to do if an error was thrown while processing the
dwarf. If no error was thrown then the queue entries should have all
@@ -1043,12 +1039,6 @@ dwarf2_per_cu_deleter::operator() (dwarf2_per_cu *data)
delete data;
}
-static const char *compute_include_file_name
- (const struct line_header *lh,
- const file_entry &fe,
- const file_and_directory &cu_info,
- std::string &name_holder);
-
static struct dwo_unit *lookup_dwo_unit_in_dwp
(dwarf2_per_bfd *per_bfd, struct dwp_file *dwp_file,
const char *comp_dir, ULONGEST signature, int is_debug_types);
@@ -1063,19 +1053,6 @@ static void process_cu_includes (dwarf2_per_objfile *per_objfile);
/* Various complaints about symbol reading that don't abort the process. */
static void
-dwarf2_debug_line_missing_file_complaint (void)
-{
- complaint (_(".debug_line section has line data without a file"));
-}
-
-static void
-dwarf2_debug_line_missing_end_sequence_complaint (void)
-{
- complaint (_(".debug_line section has line "
- "program sequence without an end"));
-}
-
-static void
dwarf2_complex_location_expr_complaint (void)
{
complaint (_("location expression too complex"));
@@ -1553,16 +1530,37 @@ struct readnow_functions : public dwarf2_base_index_functions
{
}
- bool expand_symtabs_matching
- (struct objfile *objfile,
- expand_symtabs_file_matcher file_matcher,
- const lookup_name_info *lookup_name,
- expand_symtabs_symbol_matcher symbol_matcher,
- expand_symtabs_expansion_listener expansion_notify,
- block_search_flags search_flags,
- domain_search_flags domain,
- expand_symtabs_lang_matcher lang_matcher) override
+ bool search (struct objfile *objfile,
+ search_symtabs_file_matcher file_matcher,
+ const lookup_name_info *lookup_name,
+ search_symtabs_symbol_matcher symbol_matcher,
+ search_symtabs_expansion_listener listener,
+ block_search_flags search_flags,
+ domain_search_flags domain,
+ search_symtabs_lang_matcher lang_matcher) override
{
+ dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
+ auto_bool_vector cus_to_skip;
+ dw_search_file_matcher (per_objfile, cus_to_skip, file_matcher);
+
+ for (const auto &per_cu : per_objfile->per_bfd->all_units)
+ {
+ QUIT;
+
+ /* Skip various types of unit that should not be searched
+ directly: partial units and dummy units. */
+ if (/* Note that we request the non-strict unit type here. If
+ there was an error while reading, like in
+ dw-form-strx-out-of-bounds.exp, then the unit type may
+ not be set. */
+ per_cu->unit_type (false) == DW_UT_partial
+ || per_cu->unit_type (false) == 0
+ || per_objfile->get_symtab (per_cu.get ()) == nullptr)
+ continue;
+ if (!dw2_search_one (per_cu.get (), per_objfile, cus_to_skip,
+ file_matcher, listener, lang_matcher))
+ return false;
+ }
return true;
}
};
@@ -1711,6 +1709,75 @@ dwarf2_per_bfd::allocate_signatured_type (dwarf2_section_info *section,
return result;
}
+/* Subroutine of dw2_get_file_names_reader to simplify it.
+ Return the file name for the given file_entry.
+ CU_INFO describes the CU's DW_AT_name and DW_AT_comp_dir.
+ If space for the result is malloc'd, *NAME_HOLDER will be set.
+ Returns NULL if FILE_INDEX should be ignored, i.e., it is
+ equivalent to CU_INFO. */
+
+static const char *
+compute_include_file_name (const struct line_header *lh, const file_entry &fe,
+ const file_and_directory &cu_info,
+ std::string &name_holder)
+{
+ const char *include_name = fe.name;
+ const char *include_name_to_compare = include_name;
+
+ const char *dir_name = fe.include_dir (lh);
+
+ std::string hold_compare;
+ if (!IS_ABSOLUTE_PATH (include_name)
+ && (dir_name != nullptr || cu_info.get_comp_dir () != nullptr))
+ {
+ /* Avoid creating a duplicate name for CU_INFO.
+ We do this by comparing INCLUDE_NAME and CU_INFO.
+ Before we do the comparison, however, we need to account
+ for DIR_NAME and COMP_DIR.
+ First prepend dir_name (if non-NULL). If we still don't
+ have an absolute path prepend comp_dir (if non-NULL).
+ However, the directory we record in the include-file's
+ psymtab does not contain COMP_DIR (to match the
+ corresponding symtab(s)).
+
+ Example:
+
+ bash$ cd /tmp
+ bash$ gcc -g ./hello.c
+ include_name = "hello.c"
+ dir_name = "."
+ DW_AT_comp_dir = comp_dir = "/tmp"
+ DW_AT_name = "./hello.c"
+
+ */
+
+ if (dir_name != NULL)
+ {
+ name_holder = path_join (dir_name, include_name);
+ include_name = name_holder.c_str ();
+ include_name_to_compare = include_name;
+ }
+ if (!IS_ABSOLUTE_PATH (include_name)
+ && cu_info.get_comp_dir () != nullptr)
+ {
+ hold_compare = path_join (cu_info.get_comp_dir (), include_name);
+ include_name_to_compare = hold_compare.c_str ();
+ }
+ }
+
+ std::string copied_name;
+ const char *cu_filename = cu_info.get_name ();
+ if (!IS_ABSOLUTE_PATH (cu_filename) && cu_info.get_comp_dir () != nullptr)
+ {
+ copied_name = path_join (cu_info.get_comp_dir (), cu_filename);
+ cu_filename = copied_name.c_str ();
+ }
+
+ if (FILENAME_CMP (include_name_to_compare, cu_filename) == 0)
+ return nullptr;
+ return include_name;
+}
+
/* die_reader_func for dw2_get_file_names. */
static void
@@ -1930,14 +1997,16 @@ dwarf2_base_index_functions::expand_all_symtabs (struct objfile *objfile)
/* See read.h. */
bool
-dw2_expand_symtabs_matching_one
+dw2_search_one
(dwarf2_per_cu *per_cu,
dwarf2_per_objfile *per_objfile,
- expand_symtabs_file_matcher file_matcher,
- expand_symtabs_expansion_listener expansion_notify,
- expand_symtabs_lang_matcher lang_matcher)
+ auto_bool_vector &cus_to_skip,
+ search_symtabs_file_matcher file_matcher,
+ search_symtabs_expansion_listener listener,
+ search_symtabs_lang_matcher lang_matcher)
{
- if (file_matcher != nullptr && !per_cu->mark)
+ /* Already visited, or intentionally skipped. */
+ if (cus_to_skip.is_set (per_cu->index))
return true;
if (lang_matcher != nullptr)
@@ -1949,22 +2018,27 @@ dw2_expand_symtabs_matching_one
return true;
}
- bool symtab_was_null = !per_objfile->symtab_set_p (per_cu);
compunit_symtab *symtab
= dw2_instantiate_symtab (per_cu, per_objfile, false);
gdb_assert (symtab != nullptr);
- if (expansion_notify != NULL && symtab_was_null)
- return expansion_notify (symtab);
+ if (listener != nullptr)
+ {
+ cus_to_skip.set (per_cu->index, true);
+ return listener (symtab);
+ }
return true;
}
-/* See read.h. */
+/* If FILE_MATCHER is non-NULL, update CUS_TO_SKIP as appropriate
+ based on FILE_MATCHER. */
-void
-dw_expand_symtabs_matching_file_matcher
- (dwarf2_per_objfile *per_objfile, expand_symtabs_file_matcher file_matcher)
+static void
+dw_search_file_matcher
+ (dwarf2_per_objfile *per_objfile,
+ auto_bool_vector &cus_to_skip,
+ search_symtabs_file_matcher file_matcher)
{
if (file_matcher == NULL)
return;
@@ -1980,54 +2054,50 @@ dw_expand_symtabs_matching_file_matcher
QUIT;
if (per_cu->is_debug_types)
- continue;
- per_cu->mark = 0;
-
- /* We only need to look at symtabs not already expanded. */
- if (per_objfile->symtab_set_p (per_cu.get ()))
- continue;
+ {
+ cus_to_skip.set (per_cu->index, true);
+ continue;
+ }
if (per_cu->fnd != nullptr)
{
file_and_directory *fnd = per_cu->fnd.get ();
if (file_matcher (fnd->get_name (), false))
- {
- per_cu->mark = 1;
- continue;
- }
+ continue;
/* Before we invoke realpath, which can get expensive when many
files are involved, do a quick comparison of the basenames. */
if ((basenames_may_differ
|| file_matcher (lbasename (fnd->get_name ()), true))
&& file_matcher (fnd->get_fullname (), false))
- {
- per_cu->mark = 1;
- continue;
- }
+ continue;
}
quick_file_names *file_data = dw2_get_file_names (per_cu.get (),
per_objfile);
if (file_data == NULL)
- continue;
+ {
+ cus_to_skip.set (per_cu->index, true);
+ continue;
+ }
if (visited_not_found.contains (file_data))
- continue;
- else if (visited_found.contains (file_data))
{
- per_cu->mark = 1;
+ cus_to_skip.set (per_cu->index, true);
continue;
}
+ else if (visited_found.contains (file_data))
+ continue;
+ bool matched = false;
for (int j = 0; j < file_data->num_file_names; ++j)
{
const char *this_real_name;
if (file_matcher (file_data->file_names[j], false))
{
- per_cu->mark = 1;
+ matched = true;
break;
}
@@ -2041,15 +2111,18 @@ dw_expand_symtabs_matching_file_matcher
this_real_name = dw2_get_real_path (per_objfile, file_data, j);
if (file_matcher (this_real_name, false))
{
- per_cu->mark = 1;
+ matched = true;
break;
}
}
- if (per_cu->mark)
+ if (matched)
visited_found.insert (file_data);
else
- visited_not_found.insert (file_data);
+ {
+ cus_to_skip.set (per_cu->index, true);
+ visited_not_found.insert (file_data);
+ }
}
}
@@ -3679,6 +3752,10 @@ read_comp_units_from_section (dwarf2_per_objfile *per_objfile,
void
finalize_all_units (dwarf2_per_bfd *per_bfd)
{
+ /* Sanity check. */
+ gdb_assert (per_bfd->all_units.size ()
+ == per_bfd->num_comp_units + per_bfd->num_type_units);
+
/* Ensure that the all_units vector is in the expected order for
dwarf2_find_containing_unit to be able to perform a binary search. */
std::sort (per_bfd->all_units.begin (), per_bfd->all_units.end (),
@@ -3694,6 +3771,7 @@ void
create_all_units (dwarf2_per_objfile *per_objfile)
{
gdb_assert (per_objfile->per_bfd->all_units.empty ());
+ scoped_remove_all_units remove_all_units (*per_objfile->per_bfd);
signatured_type_set sig_types;
@@ -3714,8 +3792,6 @@ create_all_units (dwarf2_per_objfile *per_objfile)
if (!dwz->types.empty ())
{
- per_objfile->per_bfd->all_units.clear ();
-
/* See enhancement PR symtab/30838. */
error (_(DWARF_ERROR_PREFIX
".debug_types section not supported in dwz file"));
@@ -3725,6 +3801,7 @@ create_all_units (dwarf2_per_objfile *per_objfile)
per_objfile->per_bfd->signatured_types = std::move (sig_types);
finalize_all_units (per_objfile->per_bfd);
+ remove_all_units.disable ();
}
/* Return the initial uleb128 in the die at INFO_PTR. */
@@ -4257,7 +4334,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
struct symbol *sym = list->symbol[i];
if (sym->language () == language_go
- && sym->aclass () == LOC_BLOCK)
+ && sym->loc_class () == LOC_BLOCK)
{
gdb::unique_xmalloc_ptr<char> this_package_name
= go_symbol_package_name (sym);
@@ -4294,7 +4371,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
sym->set_language (language_go, &objfile->objfile_obstack);
sym->compute_and_set_names (saved_package_name, false, objfile->per_bfd);
sym->set_domain (TYPE_DOMAIN);
- sym->set_aclass_index (LOC_TYPEDEF);
+ sym->set_loc_class_index (LOC_TYPEDEF);
sym->set_type (type);
add_symbol_to_list (sym, cu->get_builder ()->get_global_symbols ());
@@ -4504,9 +4581,9 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
else
{
struct type *disr_type = nullptr;
- for (int i = 0; i < type->num_fields (); ++i)
+ for (const auto &field : type->fields ())
{
- disr_type = type->field (i).type ();
+ disr_type = field.type ();
if (disr_type->code () != TYPE_CODE_STRUCT)
{
@@ -4545,7 +4622,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
field *new_fields
= (struct field *) TYPE_ZALLOC (type, ((type->num_fields () + 1)
* sizeof (struct field)));
- memcpy (new_fields + 1, type->fields (),
+ memcpy (new_fields + 1, type->fields ().data (),
type->num_fields () * sizeof (struct field));
type->set_fields (new_fields);
type->set_num_fields (type->num_fields () + 1);
@@ -4559,13 +4636,12 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
variant name. For convenience we build a map here. */
struct type *enum_type = disr_field->type ();
gdb::unordered_map<std::string_view, ULONGEST> discriminant_map;
- for (int i = 0; i < enum_type->num_fields (); ++i)
+ for (const auto &field : enum_type->fields ())
{
- if (enum_type->field (i).loc_kind () == FIELD_LOC_KIND_ENUMVAL)
+ if (field.loc_kind () == FIELD_LOC_KIND_ENUMVAL)
{
- const char *name
- = rust_last_path_segment (enum_type->field (i).name ());
- discriminant_map[name] = enum_type->field (i).loc_enumval ();
+ const char *name = rust_last_path_segment (field.name ());
+ discriminant_map[name] = field.loc_enumval ();
}
}
@@ -4601,7 +4677,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
if (sub_type->num_fields () > 0)
{
sub_type->set_num_fields (sub_type->num_fields () - 1);
- sub_type->set_fields (sub_type->fields () + 1);
+ sub_type->set_fields (sub_type->fields ().data () + 1);
}
type->field (i).set_name (variant_name);
sub_type->set_name
@@ -5681,7 +5757,7 @@ read_alias (struct die_info *die, struct dwarf2_cu *cu)
type = die_type (d, imported_cu);
struct symbol *sym = new_symbol (die, type, cu);
attr = dwarf2_attr (d, DW_AT_location, imported_cu);
- sym->set_aclass_index (LOC_UNRESOLVED);
+ sym->set_loc_class_index (LOC_UNRESOLVED);
if (attr != nullptr)
var_decode_location (attr, sym, cu);
return true;
@@ -6048,7 +6124,7 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
sect_offset line_offset = (sect_offset) attr->as_unsigned ();
line_header_up lh = dwarf_decode_line_header (line_offset, cu,
fnd.get_comp_dir ());
- if (lh->version == 5 && lh->is_valid_file_index (1))
+ if (lh->version == 5 && lh->include_dir_at (1) != nullptr)
{
std::string dir = lh->include_dir_at (1);
fnd.set_comp_dir (std::move (dir));
@@ -10629,7 +10705,6 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
smash_to_method_type (fnp->type, type,
this_type->target_type (),
this_type->fields (),
- this_type->num_fields (),
this_type->has_varargs ());
/* Handle static member functions.
@@ -10851,8 +10926,7 @@ quirk_gcc_member_function_pointer (struct type *type, struct objfile *objfile)
self_type = pfn_type->field (0).type ()->target_type ();
new_type = type_allocator (type).new_type ();
smash_to_method_type (new_type, self_type, pfn_type->target_type (),
- pfn_type->fields (), pfn_type->num_fields (),
- pfn_type->has_varargs ());
+ pfn_type->fields (), pfn_type->has_varargs ());
smash_to_methodptr_type (type, new_type);
}
@@ -12411,7 +12485,7 @@ mark_common_block_symbol_computed (struct symbol *sym,
gdb_assert (ptr - baton->data == baton->size);
SYMBOL_LOCATION_BATON (sym) = baton;
- sym->set_aclass_index (dwarf2_locexpr_index);
+ sym->set_loc_class_index (dwarf2_locexpr_index);
}
/* Create appropriate locally-scoped variables for all the
@@ -12773,8 +12847,7 @@ read_tag_ptr_to_member_type (struct die_info *die, struct dwarf2_cu *cu)
= type_allocator (cu->per_objfile->objfile, cu->lang ()).new_type ();
smash_to_method_type (new_type, domain, to_type->target_type (),
- to_type->fields (), to_type->num_fields (),
- to_type->has_varargs ());
+ to_type->fields (), to_type->has_varargs ());
type = lookup_methodptr_type (new_type);
}
else
@@ -13396,7 +13469,7 @@ ada_get_gnat_encoded_number (const char *encoding, int &k, gdb_mpz *result)
{
/* The next character should be an underscore ('_') followed
by a digit. */
- if (encoding[k] != '_' || !isdigit (encoding[k + 1]))
+ if (encoding[k] != '_' || !c_isdigit (encoding[k + 1]))
return false;
/* Skip the underscore. */
@@ -13404,7 +13477,7 @@ ada_get_gnat_encoded_number (const char *encoding, int &k, gdb_mpz *result)
int start = k;
/* Determine the number of digits for our number. */
- while (isdigit (encoding[k]))
+ while (c_isdigit (encoding[k]))
k++;
if (k == start)
return false;
@@ -14520,21 +14593,22 @@ cooked_index_functions::find_compunit_symtab_by_address
}
bool
-cooked_index_functions::expand_symtabs_matching
+cooked_index_functions::search
(objfile *objfile,
- expand_symtabs_file_matcher file_matcher,
+ search_symtabs_file_matcher file_matcher,
const lookup_name_info *lookup_name,
- expand_symtabs_symbol_matcher symbol_matcher,
- expand_symtabs_expansion_listener expansion_notify,
+ search_symtabs_symbol_matcher symbol_matcher,
+ search_symtabs_expansion_listener listener,
block_search_flags search_flags,
domain_search_flags domain,
- expand_symtabs_lang_matcher lang_matcher)
+ search_symtabs_lang_matcher lang_matcher)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
cooked_index *table = wait (objfile, true);
- dw_expand_symtabs_matching_file_matcher (per_objfile, file_matcher);
+ auto_bool_vector cus_to_skip;
+ dw_search_file_matcher (per_objfile, cus_to_skip, file_matcher);
/* This invariant is documented in quick-functions.h. */
gdb_assert (lookup_name != nullptr || symbol_matcher == nullptr);
@@ -14544,10 +14618,8 @@ cooked_index_functions::expand_symtabs_matching
{
QUIT;
- if (!dw2_expand_symtabs_matching_one (per_cu, per_objfile,
- file_matcher,
- expansion_notify,
- lang_matcher))
+ if (!dw2_search_one (per_cu, per_objfile, cus_to_skip, file_matcher,
+ listener, lang_matcher))
return false;
}
return true;
@@ -14622,13 +14694,8 @@ cooked_index_functions::expand_symtabs_matching
{
QUIT;
- /* No need to consider symbols from expanded CUs. */
- if (per_objfile->symtab_set_p (entry->per_cu))
- continue;
-
- /* If file-matching was done, we don't need to consider
- symbols from unmarked CUs. */
- if (file_matcher != nullptr && !entry->per_cu->mark)
+ /* We don't need to consider symbols from some CUs. */
+ if (cus_to_skip.is_set (entry->per_cu->index))
continue;
/* See if the symbol matches the type filter. */
@@ -14645,13 +14712,26 @@ cooked_index_functions::expand_symtabs_matching
continue;
}
+ /* This is a bit of a hack to support .gdb_index. Since
+ .gdb_index does not record languages, and since we want
+ to know the language to avoid excessive CU expansion due
+ to false matches, if we see a symbol with an unknown
+ language we find the CU's language. Only the .gdb_index
+ reader creates such symbols. */
+ enum language entry_lang = entry->lang;
+ if (entry_lang == language_unknown)
+ {
+ entry->per_cu->ensure_lang (per_objfile);
+ entry_lang = entry->per_cu->lang ();
+ }
+
/* We've found the base name of the symbol; now walk its
parentage chain, ensuring that each component
matches. */
bool found = true;
const cooked_index_entry *parent = entry->get_parent ();
- const language_defn *lang_def = language_def (entry->lang);
+ const language_defn *lang_def = language_def (entry_lang);
for (int i = name_vec.size () - 1; i > 0; --i)
{
/* If we ran out of entries, or if this segment doesn't
@@ -14661,17 +14741,15 @@ cooked_index_functions::expand_symtabs_matching
found = false;
break;
}
- if (parent->lang != language_unknown)
+
+ symbol_name_matcher_ftype *name_matcher
+ = (lang_def->get_symbol_name_matcher
+ (segment_lookup_names[i-1]));
+ if (!name_matcher (parent->canonical,
+ segment_lookup_names[i-1], nullptr))
{
- symbol_name_matcher_ftype *name_matcher
- = lang_def->get_symbol_name_matcher
- (segment_lookup_names[i-1]);
- if (!name_matcher (parent->canonical,
- segment_lookup_names[i-1], nullptr))
- {
- found = false;
- break;
- }
+ found = false;
+ break;
}
parent = parent->get_parent ();
@@ -14694,27 +14772,23 @@ cooked_index_functions::expand_symtabs_matching
seems like the loop above could just examine every
element of the name, avoiding the need to check here; but
this is hard. See PR symtab/32733. */
- if (symbol_matcher != nullptr || entry->lang != language_unknown)
+ auto_obstack temp_storage;
+ const char *full_name = entry->full_name (&temp_storage,
+ FOR_ADA_LINKAGE_NAME);
+ if (symbol_matcher == nullptr)
{
- auto_obstack temp_storage;
- const char *full_name = entry->full_name (&temp_storage,
- FOR_ADA_LINKAGE_NAME);
- if (symbol_matcher == nullptr)
- {
- symbol_name_matcher_ftype *name_matcher
- = (lang_def->get_symbol_name_matcher
- (lookup_name_without_params));
- if (!name_matcher (full_name, lookup_name_without_params,
- nullptr))
- continue;
- }
- else if (!symbol_matcher (full_name))
+ symbol_name_matcher_ftype *name_matcher
+ = (lang_def->get_symbol_name_matcher
+ (lookup_name_without_params));
+ if (!name_matcher (full_name, lookup_name_without_params,
+ nullptr))
continue;
}
+ else if (!symbol_matcher (full_name))
+ continue;
- if (!dw2_expand_symtabs_matching_one (entry->per_cu, per_objfile,
- file_matcher,
- expansion_notify, nullptr))
+ if (!dw2_search_one (entry->per_cu, per_objfile, cus_to_skip,
+ file_matcher, listener, nullptr))
return false;
}
}
@@ -15759,9 +15833,9 @@ die_specification (struct die_info *die, struct dwarf2_cu **spec_cu)
return follow_die_ref (die, spec_attr, spec_cu);
}
-/* A convenience function to find the proper .debug_line section for a CU. */
+/* See dwarf2/read.h. */
-static struct dwarf2_section_info *
+struct dwarf2_section_info *
get_debug_line_section (struct dwarf2_cu *cu)
{
struct dwarf2_section_info *section;
@@ -15812,808 +15886,9 @@ dwarf_decode_line_header (sect_offset sect_off, struct dwarf2_cu *cu,
comp_dir);
}
-/* Subroutine of dwarf_decode_lines to simplify it.
- Return the file name for the given file_entry.
- CU_INFO describes the CU's DW_AT_name and DW_AT_comp_dir.
- If space for the result is malloc'd, *NAME_HOLDER will be set.
- Returns NULL if FILE_INDEX should be ignored, i.e., it is
- equivalent to CU_INFO. */
-
-static const char *
-compute_include_file_name (const struct line_header *lh, const file_entry &fe,
- const file_and_directory &cu_info,
- std::string &name_holder)
-{
- const char *include_name = fe.name;
- const char *include_name_to_compare = include_name;
-
- const char *dir_name = fe.include_dir (lh);
-
- std::string hold_compare;
- if (!IS_ABSOLUTE_PATH (include_name)
- && (dir_name != nullptr || cu_info.get_comp_dir () != nullptr))
- {
- /* Avoid creating a duplicate name for CU_INFO.
- We do this by comparing INCLUDE_NAME and CU_INFO.
- Before we do the comparison, however, we need to account
- for DIR_NAME and COMP_DIR.
- First prepend dir_name (if non-NULL). If we still don't
- have an absolute path prepend comp_dir (if non-NULL).
- However, the directory we record in the include-file's
- psymtab does not contain COMP_DIR (to match the
- corresponding symtab(s)).
-
- Example:
-
- bash$ cd /tmp
- bash$ gcc -g ./hello.c
- include_name = "hello.c"
- dir_name = "."
- DW_AT_comp_dir = comp_dir = "/tmp"
- DW_AT_name = "./hello.c"
-
- */
-
- if (dir_name != NULL)
- {
- name_holder = path_join (dir_name, include_name);
- include_name = name_holder.c_str ();
- include_name_to_compare = include_name;
- }
- if (!IS_ABSOLUTE_PATH (include_name)
- && cu_info.get_comp_dir () != nullptr)
- {
- hold_compare = path_join (cu_info.get_comp_dir (), include_name);
- include_name_to_compare = hold_compare.c_str ();
- }
- }
-
- std::string copied_name;
- const char *cu_filename = cu_info.get_name ();
- if (!IS_ABSOLUTE_PATH (cu_filename) && cu_info.get_comp_dir () != nullptr)
- {
- copied_name = path_join (cu_info.get_comp_dir (), cu_filename);
- cu_filename = copied_name.c_str ();
- }
-
- if (FILENAME_CMP (include_name_to_compare, cu_filename) == 0)
- return nullptr;
- return include_name;
-}
-
-/* State machine to track the state of the line number program. */
-
-class lnp_state_machine
-{
-public:
- /* Initialize a machine state for the start of a line number
- program. */
- lnp_state_machine (struct dwarf2_cu *cu, gdbarch *arch, line_header *lh);
-
- file_entry *current_file ()
- {
- /* lh->file_names is 0-based, but the file name numbers in the
- statement program are 1-based. */
- return m_line_header->file_name_at (m_file);
- }
-
- /* Record the line in the state machine. END_SEQUENCE is true if
- we're processing the end of a sequence. */
- void record_line (bool end_sequence);
-
- /* Check ADDRESS is -1, -2, or zero and less than UNRELOCATED_LOWPC, and if
- true nop-out rest of the lines in this sequence. */
- void check_line_address (struct dwarf2_cu *cu,
- const gdb_byte *line_ptr,
- unrelocated_addr unrelocated_lowpc,
- unrelocated_addr address);
-
- void handle_set_discriminator (unsigned int discriminator)
- {
- m_discriminator = discriminator;
- m_line_has_non_zero_discriminator |= discriminator != 0;
- }
-
- /* Handle DW_LNE_set_address. */
- void handle_set_address (unrelocated_addr address)
- {
- m_op_index = 0;
- m_address
- = (unrelocated_addr) gdbarch_adjust_dwarf2_line (m_gdbarch,
- (CORE_ADDR) address,
- false);
- }
-
- /* Handle DW_LNS_advance_pc. */
- void handle_advance_pc (CORE_ADDR adjust);
-
- /* Handle a special opcode. */
- void handle_special_opcode (unsigned char op_code);
-
- /* Handle DW_LNS_advance_line. */
- void handle_advance_line (int line_delta)
- {
- advance_line (line_delta);
- }
-
- /* Handle DW_LNS_set_file. */
- void handle_set_file (file_name_index file);
-
- /* Handle DW_LNS_negate_stmt. */
- void handle_negate_stmt ()
- {
- m_flags ^= LEF_IS_STMT;
- }
-
- /* Handle DW_LNS_const_add_pc. */
- void handle_const_add_pc ();
-
- /* Handle DW_LNS_fixed_advance_pc. */
- void handle_fixed_advance_pc (CORE_ADDR addr_adj)
- {
- addr_adj = gdbarch_adjust_dwarf2_line (m_gdbarch, addr_adj, true);
- m_address = (unrelocated_addr) ((CORE_ADDR) m_address + addr_adj);
- m_op_index = 0;
- }
-
- /* Handle DW_LNS_copy. */
- void handle_copy ()
- {
- record_line (false);
- m_discriminator = 0;
- m_flags &= ~LEF_PROLOGUE_END;
- m_flags &= ~LEF_EPILOGUE_BEGIN;
- }
-
- /* Handle DW_LNE_end_sequence. */
- void handle_end_sequence ()
- {
- m_currently_recording_lines = true;
- }
-
- /* Handle DW_LNS_set_prologue_end. */
- void handle_set_prologue_end ()
- {
- m_flags |= LEF_PROLOGUE_END;
- }
-
- void handle_set_epilogue_begin ()
- {
- m_flags |= LEF_EPILOGUE_BEGIN;
- }
-
-private:
- /* Advance the line by LINE_DELTA. */
- void advance_line (int line_delta)
- {
- m_line += line_delta;
-
- if (line_delta != 0)
- m_line_has_non_zero_discriminator = m_discriminator != 0;
- }
-
- struct dwarf2_cu *m_cu;
-
- gdbarch *m_gdbarch;
-
- /* The line number header. */
- line_header *m_line_header;
-
- /* These are part of the standard DWARF line number state machine,
- and initialized according to the DWARF spec. */
-
- unsigned char m_op_index = 0;
- /* The line table index of the current file. */
- file_name_index m_file = 1;
- unsigned int m_line = 1;
-
- /* These are initialized in the constructor. */
-
- unrelocated_addr m_address;
- linetable_entry_flags m_flags;
- unsigned int m_discriminator = 0;
-
- /* Additional bits of state we need to track. */
-
- /* The last file a line number was recorded for. */
- struct subfile *m_last_subfile = NULL;
-
- /* The address of the last line entry. */
- unrelocated_addr m_last_address;
-
- /* Set to true when a previous line at the same address (using
- m_last_address) had LEF_IS_STMT set in m_flags. This is reset to false
- when a line entry at a new address (m_address different to
- m_last_address) is processed. */
- bool m_stmt_at_address = false;
-
- /* When true, record the lines we decode. */
- bool m_currently_recording_lines = true;
-
- /* The last line number that was recorded, used to coalesce
- consecutive entries for the same line. This can happen, for
- example, when discriminators are present. PR 17276. */
- unsigned int m_last_line = 0;
- bool m_line_has_non_zero_discriminator = false;
-};
-
-void
-lnp_state_machine::handle_advance_pc (CORE_ADDR adjust)
-{
- CORE_ADDR addr_adj = (((m_op_index + adjust)
- / m_line_header->maximum_ops_per_instruction)
- * m_line_header->minimum_instruction_length);
- addr_adj = gdbarch_adjust_dwarf2_line (m_gdbarch, addr_adj, true);
- m_address = (unrelocated_addr) ((CORE_ADDR) m_address + addr_adj);
- m_op_index = ((m_op_index + adjust)
- % m_line_header->maximum_ops_per_instruction);
-}
-
-void
-lnp_state_machine::handle_special_opcode (unsigned char op_code)
-{
- unsigned char adj_opcode = op_code - m_line_header->opcode_base;
- unsigned char adj_opcode_d = adj_opcode / m_line_header->line_range;
- unsigned char adj_opcode_r = adj_opcode % m_line_header->line_range;
- CORE_ADDR addr_adj = (((m_op_index + adj_opcode_d)
- / m_line_header->maximum_ops_per_instruction)
- * m_line_header->minimum_instruction_length);
- addr_adj = gdbarch_adjust_dwarf2_line (m_gdbarch, addr_adj, true);
- m_address = (unrelocated_addr) ((CORE_ADDR) m_address + addr_adj);
- m_op_index = ((m_op_index + adj_opcode_d)
- % m_line_header->maximum_ops_per_instruction);
-
- int line_delta = m_line_header->line_base + adj_opcode_r;
- advance_line (line_delta);
- record_line (false);
- m_discriminator = 0;
- m_flags &= ~LEF_PROLOGUE_END;
- m_flags &= ~LEF_EPILOGUE_BEGIN;
-}
-
-void
-lnp_state_machine::handle_set_file (file_name_index file)
-{
- m_file = file;
-
- const file_entry *fe = current_file ();
- if (fe == NULL)
- dwarf2_debug_line_missing_file_complaint ();
- else
- {
- m_line_has_non_zero_discriminator = m_discriminator != 0;
- dwarf2_start_subfile (m_cu, *fe, *m_line_header);
- }
-}
-
-void
-lnp_state_machine::handle_const_add_pc ()
-{
- CORE_ADDR adjust
- = (255 - m_line_header->opcode_base) / m_line_header->line_range;
-
- CORE_ADDR addr_adj
- = (((m_op_index + adjust)
- / m_line_header->maximum_ops_per_instruction)
- * m_line_header->minimum_instruction_length);
-
- addr_adj = gdbarch_adjust_dwarf2_line (m_gdbarch, addr_adj, true);
- m_address = (unrelocated_addr) ((CORE_ADDR) m_address + addr_adj);
- m_op_index = ((m_op_index + adjust)
- % m_line_header->maximum_ops_per_instruction);
-}
-
-/* Return non-zero if we should add LINE to the line number table.
- LINE is the line to add, LAST_LINE is the last line that was added,
- LAST_SUBFILE is the subfile for LAST_LINE.
- LINE_HAS_NON_ZERO_DISCRIMINATOR is non-zero if LINE has ever
- had a non-zero discriminator.
-
- We have to be careful in the presence of discriminators.
- E.g., for this line:
-
- for (i = 0; i < 100000; i++);
-
- clang can emit four line number entries for that one line,
- each with a different discriminator.
- See gdb.dwarf2/dw2-single-line-discriminators.exp for an example.
-
- However, we want gdb to coalesce all four entries into one.
- Otherwise the user could stepi into the middle of the line and
- gdb would get confused about whether the pc really was in the
- middle of the line.
-
- Things are further complicated by the fact that two consecutive
- line number entries for the same line is a heuristic used by gcc
- to denote the end of the prologue. So we can't just discard duplicate
- entries, we have to be selective about it. The heuristic we use is
- that we only collapse consecutive entries for the same line if at least
- one of those entries has a non-zero discriminator. PR 17276.
-
- Note: Addresses in the line number state machine can never go backwards
- within one sequence, thus this coalescing is ok. */
-
-static int
-dwarf_record_line_p (struct dwarf2_cu *cu,
- unsigned int line, unsigned int last_line,
- int line_has_non_zero_discriminator,
- struct subfile *last_subfile)
-{
- if (cu->get_builder ()->get_current_subfile () != last_subfile)
- return 1;
- if (line != last_line)
- return 1;
- /* Same line for the same file that we've seen already.
- As a last check, for pr 17276, only record the line if the line
- has never had a non-zero discriminator. */
- if (!line_has_non_zero_discriminator)
- return 1;
- return 0;
-}
-
-/* Use the CU's builder to record line number LINE beginning at
- address ADDRESS in the line table of subfile SUBFILE. */
-
-static void
-dwarf_record_line_1 (struct gdbarch *gdbarch, struct subfile *subfile,
- unsigned int line, unrelocated_addr address,
- linetable_entry_flags flags,
- struct dwarf2_cu *cu)
-{
- unrelocated_addr addr
- = unrelocated_addr (gdbarch_addr_bits_remove (gdbarch,
- (CORE_ADDR) address));
-
- if (cu != nullptr)
- {
- if (dwarf_line_debug)
- gdb_printf (gdb_stdlog, "Recording line %u, file %s, address %s\n",
- line, lbasename (subfile->name.c_str ()),
- paddress (gdbarch, (CORE_ADDR) address));
-
- cu->get_builder ()->record_line (subfile, line, addr, flags);
- }
-}
-
-/* Subroutine of dwarf_decode_lines_1 to simplify it.
- Mark the end of a set of line number records.
- The arguments are the same as for dwarf_record_line_1.
- If SUBFILE is NULL the request is ignored. */
-
-static void
-dwarf_finish_line (struct gdbarch *gdbarch, struct subfile *subfile,
- unrelocated_addr address, struct dwarf2_cu *cu)
-{
- if (subfile == NULL)
- return;
-
- if (dwarf_line_debug)
- {
- gdb_printf (gdb_stdlog,
- "Finishing current line, file %s, address %s\n",
- lbasename (subfile->name.c_str ()),
- paddress (gdbarch, (CORE_ADDR) address));
- }
-
- dwarf_record_line_1 (gdbarch, subfile, 0, address, LEF_IS_STMT, cu);
-}
-
-void
-lnp_state_machine::record_line (bool end_sequence)
-{
- if (dwarf_line_debug)
- {
- gdb_printf (gdb_stdlog,
- "Processing actual line %u: file %u,"
- " address %s, is_stmt %u, prologue_end %u,"
- " epilogue_begin %u, discrim %u%s\n",
- m_line, m_file,
- paddress (m_gdbarch, (CORE_ADDR) m_address),
- (m_flags & LEF_IS_STMT) != 0,
- (m_flags & LEF_PROLOGUE_END) != 0,
- (m_flags & LEF_EPILOGUE_BEGIN) != 0,
- m_discriminator,
- (end_sequence ? "\t(end sequence)" : ""));
- }
-
- file_entry *fe = current_file ();
-
- if (fe == NULL)
- dwarf2_debug_line_missing_file_complaint ();
- /* For now we ignore lines not starting on an instruction boundary.
- But not when processing end_sequence for compatibility with the
- previous version of the code. */
- else if (m_op_index == 0 || end_sequence)
- {
- /* When we switch files we insert an end maker in the first file,
- switch to the second file and add a new line entry. The
- problem is that the end marker inserted in the first file will
- discard any previous line entries at the same address. If the
- line entries in the first file are marked as is-stmt, while
- the new line in the second file is non-stmt, then this means
- the end marker will discard is-stmt lines so we can have a
- non-stmt line. This means that there are less addresses at
- which the user can insert a breakpoint.
-
- To improve this we track the last address in m_last_address,
- and whether we have seen an is-stmt at this address. Then
- when switching files, if we have seen a stmt at the current
- address, and we are switching to create a non-stmt line, then
- discard the new line. */
- bool file_changed
- = m_last_subfile != m_cu->get_builder ()->get_current_subfile ();
- bool ignore_this_line
- = ((file_changed && !end_sequence && m_last_address == m_address
- && ((m_flags & LEF_IS_STMT) == 0)
- && m_stmt_at_address)
- || (!end_sequence && m_line == 0));
-
- if ((file_changed && !ignore_this_line) || end_sequence)
- {
- dwarf_finish_line (m_gdbarch, m_last_subfile, m_address,
- m_currently_recording_lines ? m_cu : nullptr);
- }
-
- if (!end_sequence && !ignore_this_line)
- {
- linetable_entry_flags lte_flags = m_flags;
- if (m_cu->producer_is_codewarrior ())
- lte_flags |= LEF_IS_STMT;
-
- if (dwarf_record_line_p (m_cu, m_line, m_last_line,
- m_line_has_non_zero_discriminator,
- m_last_subfile))
- {
- buildsym_compunit *builder = m_cu->get_builder ();
- dwarf_record_line_1 (m_gdbarch,
- builder->get_current_subfile (),
- m_line, m_address, lte_flags,
- m_currently_recording_lines ? m_cu : nullptr);
-
- m_last_subfile = m_cu->get_builder ()->get_current_subfile ();
- m_last_line = m_line;
- }
- }
- }
-
- /* Track whether we have seen any IS_STMT true at m_address in case we
- have multiple line table entries all at m_address. */
- if (m_last_address != m_address)
- {
- m_stmt_at_address = false;
- m_last_address = m_address;
- }
- m_stmt_at_address |= (m_flags & LEF_IS_STMT) != 0;
-}
-
-lnp_state_machine::lnp_state_machine (struct dwarf2_cu *cu, gdbarch *arch,
- line_header *lh)
- : m_cu (cu),
- m_gdbarch (arch),
- m_line_header (lh),
- /* Call `gdbarch_adjust_dwarf2_line' on the initial 0 address as
- if there was a line entry for it so that the backend has a
- chance to adjust it and also record it in case it needs it.
- This is currently used by MIPS code,
- cf. `mips_adjust_dwarf2_line'. */
- m_address ((unrelocated_addr) gdbarch_adjust_dwarf2_line (arch, 0, 0)),
- m_flags (lh->default_is_stmt ? LEF_IS_STMT : (linetable_entry_flags) 0),
- m_last_address (m_address)
-{
-}
+/* See dwarf2/read.h. */
void
-lnp_state_machine::check_line_address (struct dwarf2_cu *cu,
- const gdb_byte *line_ptr,
- unrelocated_addr unrelocated_lowpc,
- unrelocated_addr address)
-{
- /* Linkers resolve a symbolic relocation referencing a GC'd function to 0,
- -1 or -2 (-2 is used by certain lld versions, see
- https://github.com/llvm/llvm-project/commit/e618ccbf431f6730edb6d1467a127c3a52fd57f7).
- If ADDRESS is 0, ignoring the opcode will err if the text section is
- located at 0x0. In this case, additionally check that if
- ADDRESS < UNRELOCATED_LOWPC. */
-
- if ((address == (unrelocated_addr) 0 && address < unrelocated_lowpc)
- || address == (unrelocated_addr) -1
- || address == (unrelocated_addr) -2)
- {
- /* This line table is for a function which has been
- GCd by the linker. Ignore it. PR gdb/12528 */
-
- struct objfile *objfile = cu->per_objfile->objfile;
- long line_offset = line_ptr - get_debug_line_section (cu)->buffer;
-
- complaint (_(".debug_line address at offset 0x%lx is 0 [in module %s]"),
- line_offset, objfile_name (objfile));
- m_currently_recording_lines = false;
- /* Note: m_currently_recording_lines is left as false until we see
- DW_LNE_end_sequence. */
- }
-}
-
-/* Subroutine of dwarf_decode_lines to simplify it.
- Process the line number information in LH. */
-
-static void
-dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
- unrelocated_addr lowpc)
-{
- const gdb_byte *line_ptr, *extended_end;
- const gdb_byte *line_end;
- unsigned int bytes_read, extended_len;
- unsigned char op_code, extended_op;
- struct objfile *objfile = cu->per_objfile->objfile;
- bfd *abfd = objfile->obfd.get ();
- struct gdbarch *gdbarch = objfile->arch ();
-
- line_ptr = lh->statement_program_start;
- line_end = lh->statement_program_end;
-
- /* Read the statement sequences until there's nothing left. */
- while (line_ptr < line_end)
- {
- /* The DWARF line number program state machine. Reset the state
- machine at the start of each sequence. */
- lnp_state_machine state_machine (cu, gdbarch, lh);
- bool end_sequence = false;
-
- /* Start a subfile for the current file of the state
- machine. */
- const file_entry *fe = state_machine.current_file ();
-
- if (fe != NULL)
- dwarf2_start_subfile (cu, *fe, *lh);
-
- /* Decode the table. */
- while (line_ptr < line_end && !end_sequence)
- {
- op_code = read_1_byte (abfd, line_ptr);
- line_ptr += 1;
-
- if (op_code >= lh->opcode_base)
- {
- /* Special opcode. */
- state_machine.handle_special_opcode (op_code);
- }
- else switch (op_code)
- {
- case DW_LNS_extended_op:
- extended_len = read_unsigned_leb128 (abfd, line_ptr,
- &bytes_read);
- line_ptr += bytes_read;
- extended_end = line_ptr + extended_len;
- extended_op = read_1_byte (abfd, line_ptr);
- line_ptr += 1;
- if (DW_LNE_lo_user <= extended_op
- && extended_op <= DW_LNE_hi_user)
- {
- /* Vendor extension, ignore. */
- line_ptr = extended_end;
- break;
- }
- switch (extended_op)
- {
- case DW_LNE_end_sequence:
- state_machine.handle_end_sequence ();
- end_sequence = true;
- break;
- case DW_LNE_set_address:
- {
- unrelocated_addr address
- = cu->header.read_address (abfd, line_ptr, &bytes_read);
- line_ptr += bytes_read;
-
- state_machine.check_line_address (cu, line_ptr, lowpc,
- address);
- state_machine.handle_set_address (address);
- }
- break;
- case DW_LNE_define_file:
- {
- const char *cur_file;
- unsigned int mod_time, length;
- dir_index dindex;
-
- cur_file = read_direct_string (abfd, line_ptr,
- &bytes_read);
- line_ptr += bytes_read;
- dindex = (dir_index)
- read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
- line_ptr += bytes_read;
- mod_time =
- read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
- line_ptr += bytes_read;
- length =
- read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
- line_ptr += bytes_read;
- lh->add_file_name (cur_file, dindex, mod_time, length);
- }
- break;
- case DW_LNE_set_discriminator:
- {
- /* The discriminator is not interesting to the
- debugger; just ignore it. We still need to
- check its value though:
- if there are consecutive entries for the same
- (non-prologue) line we want to coalesce them.
- PR 17276. */
- unsigned int discr
- = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
- line_ptr += bytes_read;
-
- state_machine.handle_set_discriminator (discr);
- }
- break;
- default:
- complaint (_("mangled .debug_line section"));
- return;
- }
- /* Make sure that we parsed the extended op correctly. If e.g.
- we expected a different address size than the producer used,
- we may have read the wrong number of bytes. */
- if (line_ptr != extended_end)
- {
- complaint (_("mangled .debug_line section"));
- return;
- }
- break;
- case DW_LNS_copy:
- state_machine.handle_copy ();
- break;
- case DW_LNS_advance_pc:
- {
- CORE_ADDR adjust
- = read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
- line_ptr += bytes_read;
-
- state_machine.handle_advance_pc (adjust);
- }
- break;
- case DW_LNS_advance_line:
- {
- int line_delta
- = read_signed_leb128 (abfd, line_ptr, &bytes_read);
- line_ptr += bytes_read;
-
- state_machine.handle_advance_line (line_delta);
- }
- break;
- case DW_LNS_set_file:
- {
- file_name_index file
- = (file_name_index) read_unsigned_leb128 (abfd, line_ptr,
- &bytes_read);
- line_ptr += bytes_read;
-
- state_machine.handle_set_file (file);
- }
- break;
- case DW_LNS_set_column:
- (void) read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
- line_ptr += bytes_read;
- break;
- case DW_LNS_negate_stmt:
- state_machine.handle_negate_stmt ();
- break;
- case DW_LNS_set_basic_block:
- break;
- /* Add to the address register of the state machine the
- address increment value corresponding to special opcode
- 255. I.e., this value is scaled by the minimum
- instruction length since special opcode 255 would have
- scaled the increment. */
- case DW_LNS_const_add_pc:
- state_machine.handle_const_add_pc ();
- break;
- case DW_LNS_fixed_advance_pc:
- {
- CORE_ADDR addr_adj = read_2_bytes (abfd, line_ptr);
- line_ptr += 2;
-
- state_machine.handle_fixed_advance_pc (addr_adj);
- }
- break;
- case DW_LNS_set_prologue_end:
- state_machine.handle_set_prologue_end ();
- break;
- case DW_LNS_set_epilogue_begin:
- state_machine.handle_set_epilogue_begin ();
- break;
- default:
- {
- /* Unknown standard opcode, ignore it. */
- int i;
-
- for (i = 0; i < lh->standard_opcode_lengths[op_code]; i++)
- {
- (void) read_unsigned_leb128 (abfd, line_ptr, &bytes_read);
- line_ptr += bytes_read;
- }
- }
- }
- }
-
- if (!end_sequence)
- dwarf2_debug_line_missing_end_sequence_complaint ();
-
- /* We got a DW_LNE_end_sequence (or we ran off the end of the buffer,
- in which case we still finish recording the last line). */
- state_machine.record_line (true);
- }
-}
-
-/* Decode the Line Number Program (LNP) for the given line_header
- structure and CU. The actual information extracted and the type
- of structures created from the LNP depends on the value of PST.
-
- FND holds the CU file name and directory, if known.
- It is used for relative paths in the line table.
-
- NOTE: It is important that psymtabs have the same file name (via
- strcmp) as the corresponding symtab. Since the directory is not
- used in the name of the symtab we don't use it in the name of the
- psymtabs we create. E.g. expand_line_sal requires this when
- finding psymtabs to expand. A good testcase for this is
- mb-inline.exp.
-
- LOWPC is the lowest address in CU (or 0 if not known).
-
- Boolean DECODE_MAPPING specifies we need to fully decode .debug_line
- for its PC<->lines mapping information. Otherwise only the filename
- table is read in. */
-
-static void
-dwarf_decode_lines (struct line_header *lh, struct dwarf2_cu *cu,
- unrelocated_addr lowpc, int decode_mapping)
-{
- if (decode_mapping)
- dwarf_decode_lines_1 (lh, cu, lowpc);
-
- /* Make sure a symtab is created for every file, even files
- which contain only variables (i.e. no code with associated
- line numbers). */
- buildsym_compunit *builder = cu->get_builder ();
- struct compunit_symtab *cust = builder->get_compunit_symtab ();
-
- for (auto &fe : lh->file_names ())
- {
- dwarf2_start_subfile (cu, fe, *lh);
- subfile *sf = builder->get_current_subfile ();
-
- if (sf->symtab == nullptr)
- sf->symtab = allocate_symtab (cust, sf->name.c_str (),
- sf->name_for_id.c_str ());
-
- fe.symtab = sf->symtab;
- }
-}
-
-/* Start a subfile for DWARF. FILENAME is the name of the file and
- DIRNAME the name of the source directory which contains FILENAME
- or NULL if not known.
- This routine tries to keep line numbers from identical absolute and
- relative file names in a common subfile.
-
- Using the `list' example from the GDB testsuite, which resides in
- /srcdir and compiling it with Irix6.2 cc in /compdir using a filename
- of /srcdir/list0.c yields the following debugging information for list0.c:
-
- DW_AT_name: /srcdir/list0.c
- DW_AT_comp_dir: /compdir
- files.files[0].name: list0.h
- files.files[0].dir: /srcdir
- files.files[1].name: list0.c
- files.files[1].dir: /srcdir
-
- The line number information for list0.c has to end up in a single
- subfile, so that `break /srcdir/list0.c:1' works as expected.
- start_subfile will ensure that this happens provided that we pass the
- concatenation of files.files[1].dir and files.files[1].name as the
- subfile's name. */
-
-static void
dwarf2_start_subfile (dwarf2_cu *cu, const file_entry &fe,
const line_header &lh)
{
@@ -16659,7 +15934,7 @@ var_decode_location (struct attribute *attr, struct symbol *sym,
variable has been optimized away. */
if (attr->form_is_block () && attr->as_block ()->size == 0)
{
- sym->set_aclass_index (LOC_OPTIMIZED_OUT);
+ sym->set_loc_class_index (LOC_OPTIMIZED_OUT);
return;
}
@@ -16689,7 +15964,7 @@ var_decode_location (struct attribute *attr, struct symbol *sym,
else
tem = read_addr_index_from_leb128 (cu, block->data + 1, &dummy);
sym->set_value_address ((CORE_ADDR) tem);
- sym->set_aclass_index (LOC_STATIC);
+ sym->set_loc_class_index (LOC_STATIC);
fixup_symbol_section (sym, objfile);
sym->set_value_address
(sym->value_address ()
@@ -16726,20 +16001,20 @@ add_ada_export_symbol (struct symbol *orig, const char *new_name,
= new (&cu->per_objfile->objfile->objfile_obstack) symbol (*orig);
copy->set_linkage_name (new_name);
SYMBOL_LOCATION_BATON (copy) = (void *) orig_name;
- copy->set_aclass_index (copy->aclass () == LOC_BLOCK
+ copy->set_loc_class_index (copy->loc_class () == LOC_BLOCK
? ada_block_index
: ada_imported_index);
add_symbol_to_list (copy, list_to_add);
}
-/* A helper function that decides if a given symbol is an Ada Pragma
- Import or Pragma Export. */
+/* See read.h. */
-static bool
+bool
is_ada_import_or_export (dwarf2_cu *cu, const char *name,
const char *linkagename)
{
return (cu->lang () == language_ada
+ && name != nullptr
&& linkagename != nullptr
&& !streq (name, linkagename)
/* The following exclusions are necessary because symbols
@@ -16826,7 +16101,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
/* Default assumptions.
Use the passed type or decode it from the die. */
sym->set_domain (UNDEF_DOMAIN);
- sym->set_aclass_index (LOC_OPTIMIZED_OUT);
+ sym->set_loc_class_index (LOC_OPTIMIZED_OUT);
if (type != NULL)
sym->set_type (type);
else
@@ -16876,10 +16151,10 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
CORE_ADDR addr = per_objfile->relocate (attr->as_address ());
sym->set_section_index (SECT_OFF_TEXT (objfile));
sym->set_value_address (addr);
- sym->set_aclass_index (LOC_LABEL);
+ sym->set_loc_class_index (LOC_LABEL);
}
else
- sym->set_aclass_index (LOC_OPTIMIZED_OUT);
+ sym->set_loc_class_index (LOC_OPTIMIZED_OUT);
sym->set_type (builtin_type (objfile)->builtin_core_addr);
sym->set_domain (LABEL_DOMAIN);
list_to_add = cu->list_in_scope;
@@ -16888,7 +16163,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
/* SYMBOL_BLOCK_VALUE (sym) will be filled in later by
finish_block. */
sym->set_domain (FUNCTION_DOMAIN);
- sym->set_aclass_index (LOC_BLOCK);
+ sym->set_loc_class_index (LOC_BLOCK);
/* DW_TAG_entry_point provides an additional entry_point to an
existing sub_program. Therefore, we inherit the "external"
attribute from the sub_program to which the entry_point
@@ -16903,7 +16178,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
/* SYMBOL_BLOCK_VALUE (sym) will be filled in later by
finish_block. */
sym->set_domain (FUNCTION_DOMAIN);
- sym->set_aclass_index (LOC_BLOCK);
+ sym->set_loc_class_index (LOC_BLOCK);
attr2 = dwarf2_attr (die, DW_AT_external, cu);
if ((attr2 != nullptr && attr2->as_boolean ())
|| cu->lang () == language_ada
@@ -16932,7 +16207,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
/* For Import, create a symbol using the source
name, and have it refer to the linkage name. */
SYMBOL_LOCATION_BATON (sym) = (void *) linkagename;
- sym->set_aclass_index (ada_block_index);
+ sym->set_loc_class_index (ada_block_index);
}
else
{
@@ -16948,7 +16223,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
/* SYMBOL_BLOCK_VALUE (sym) will be filled in later by
finish_block. */
sym->set_domain (FUNCTION_DOMAIN);
- sym->set_aclass_index (LOC_BLOCK);
+ sym->set_loc_class_index (LOC_BLOCK);
sym->set_is_inlined (1);
list_to_add = cu->list_in_scope;
break;
@@ -17000,7 +16275,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
&& die->parent->tag == DW_TAG_common_block)
attr2 = NULL;
- if (sym->aclass () == LOC_STATIC
+ if (sym->loc_class () == LOC_STATIC
&& sym->value_address () == 0
&& !per_objfile->per_bfd->has_section_at_zero)
{
@@ -17011,7 +16286,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
}
else if (attr2 != nullptr && attr2->as_boolean ())
{
- if (sym->aclass () == LOC_STATIC
+ if (sym->loc_class () == LOC_STATIC
&& (objfile->flags & OBJF_MAINLINE) == 0
&& per_objfile->per_bfd->can_copy)
{
@@ -17080,7 +16355,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
? cu->get_builder ()->get_global_symbols ()
: cu->list_in_scope);
SYMBOL_LOCATION_BATON (sym) = (void *) linkagename;
- sym->set_aclass_index (ada_imported_index);
+ sym->set_loc_class_index (ada_imported_index);
}
else if (attr2 != nullptr && attr2->as_boolean ()
&& dwarf2_attr (die, DW_AT_type, cu) != NULL)
@@ -17093,12 +16368,12 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
? cu->get_builder ()->get_global_symbols ()
: cu->list_in_scope);
- sym->set_aclass_index (LOC_UNRESOLVED);
+ sym->set_loc_class_index (LOC_UNRESOLVED);
}
else if (!die_is_declaration (die, cu))
{
/* Use the default LOC_OPTIMIZED_OUT class. */
- gdb_assert (sym->aclass () == LOC_OPTIMIZED_OUT);
+ gdb_assert (sym->loc_class () == LOC_OPTIMIZED_OUT);
if (!suppress_add)
list_to_add = cu->list_in_scope;
}
@@ -17154,13 +16429,13 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
there's a special hack for C++ in the matching code,
so we don't need to enter a separate typedef for the
tag. */
- sym->set_aclass_index (LOC_TYPEDEF);
+ sym->set_loc_class_index (LOC_TYPEDEF);
sym->set_domain (STRUCT_DOMAIN);
}
else
{
/* Other languages don't have a tag namespace. */
- sym->set_aclass_index (LOC_TYPEDEF);
+ sym->set_loc_class_index (LOC_TYPEDEF);
sym->set_domain (TYPE_DOMAIN);
}
@@ -17205,7 +16480,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
case DW_TAG_base_type:
case DW_TAG_subrange_type:
case DW_TAG_generic_subrange:
- sym->set_aclass_index (LOC_TYPEDEF);
+ sym->set_loc_class_index (LOC_TYPEDEF);
sym->set_domain (TYPE_DOMAIN);
list_to_add = cu->list_in_scope;
break;
@@ -17229,21 +16504,21 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
case DW_TAG_imported_declaration:
case DW_TAG_namespace:
sym->set_domain (TYPE_DOMAIN);
- sym->set_aclass_index (LOC_TYPEDEF);
+ sym->set_loc_class_index (LOC_TYPEDEF);
list_to_add = cu->get_builder ()->get_global_symbols ();
break;
case DW_TAG_module:
- sym->set_aclass_index (LOC_TYPEDEF);
+ sym->set_loc_class_index (LOC_TYPEDEF);
sym->set_domain (MODULE_DOMAIN);
list_to_add = cu->get_builder ()->get_global_symbols ();
break;
case DW_TAG_common_block:
- sym->set_aclass_index (LOC_COMMON_BLOCK);
+ sym->set_loc_class_index (LOC_COMMON_BLOCK);
sym->set_domain (COMMON_BLOCK_DOMAIN);
list_to_add = cu->list_in_scope;
break;
case DW_TAG_namelist:
- sym->set_aclass_index (LOC_STATIC);
+ sym->set_loc_class_index (LOC_STATIC);
sym->set_domain (VAR_DOMAIN);
list_to_add = cu->list_in_scope;
break;
@@ -17396,17 +16671,17 @@ dwarf2_const_value (const struct attribute *attr, struct symbol *sym,
if (baton != NULL)
{
SYMBOL_LOCATION_BATON (sym) = baton;
- sym->set_aclass_index (dwarf2_locexpr_index);
+ sym->set_loc_class_index (dwarf2_locexpr_index);
}
else if (bytes != NULL)
{
sym->set_value_bytes (bytes);
- sym->set_aclass_index (LOC_CONST_BYTES);
+ sym->set_loc_class_index (LOC_CONST_BYTES);
}
else
{
sym->set_value_longest (value);
- sym->set_aclass_index (LOC_CONST);
+ sym->set_loc_class_index (LOC_CONST);
}
}
@@ -17773,9 +17048,11 @@ anonymous_struct_prefix (struct die_info *die, struct dwarf2_cu *cu)
return NULL;
attr = dw2_linkage_name_attr (die, cu);
+ if (attr == nullptr)
+ return nullptr;
const char *attr_name = attr->as_string ();
- if (attr == NULL || attr_name == NULL)
- return NULL;
+ if (attr_name == nullptr)
+ return nullptr;
/* dwarf2_name had to be already called. */
gdb_assert (attr->canonical_string_p ());
@@ -18977,7 +18254,7 @@ decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu,
case DW_OP_deref:
/* If we're not the last op, then we definitely can't encode
- this using GDB's address_class enum. This is valid for partial
+ this using GDB's location_class enum. This is valid for partial
global symbols, although the variable's address will be bogus
in the psymtab. */
if (i < size)
@@ -19219,7 +18496,7 @@ dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym,
complaint (_("Location list used without "
"specifying the CU base address."));
- sym->set_aclass_index ((is_block
+ sym->set_loc_class_index ((is_block
? dwarf2_loclist_block_index
: dwarf2_loclist_index));
SYMBOL_LOCATION_BATON (sym) = baton;
@@ -19252,7 +18529,7 @@ dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym,
baton->size = 0;
}
- sym->set_aclass_index ((is_block
+ sym->set_loc_class_index ((is_block
? dwarf2_locexpr_block_index
: dwarf2_locexpr_index));
SYMBOL_LOCATION_BATON (sym) = baton;
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index 4e3f8d7..2f9ad05 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -54,6 +54,7 @@ struct dwarf2_cu;
struct dwarf2_debug_sections;
struct dwarf2_per_bfd;
struct dwarf2_per_cu;
+struct file_entry;
struct mapped_index;
struct mapped_debug_names;
struct signatured_type;
@@ -127,7 +128,6 @@ struct dwarf2_per_cu
lto_artificial (false),
queued (false),
m_header_read_in (false),
- mark (false),
files_read (false),
scanned (false),
section (section),
@@ -195,10 +195,6 @@ public:
it private at the moment. */
mutable packed<bool, 1> m_header_read_in;
- /* A temporary mark bit used when iterating over all CUs in
- expand_symtabs_matching. */
- packed<unsigned int, 1> mark;
-
/* True if we've tried to read the file table. There will be no
point in trying to read it again next time. */
packed<bool, 1> files_read;
@@ -673,6 +669,36 @@ public:
std::string captured_debug_dir;
};
+/* Scoped object to remove all units from PER_BFD and clear other associated
+ fields in case of failure. */
+
+struct scoped_remove_all_units
+{
+ explicit scoped_remove_all_units (dwarf2_per_bfd &per_bfd)
+ : m_per_bfd (&per_bfd)
+ {}
+
+ DISABLE_COPY_AND_ASSIGN (scoped_remove_all_units);
+
+ ~scoped_remove_all_units ()
+ {
+ if (m_per_bfd == nullptr)
+ return;
+
+ m_per_bfd->all_units.clear ();
+ m_per_bfd->num_comp_units = 0;
+ m_per_bfd->num_type_units = 0;
+ }
+
+ /* Disable this object. Call this to keep the units of M_PER_BFD on the
+ success path. */
+ void disable () { m_per_bfd = nullptr; }
+
+private:
+ /* This is nullptr if the object is disabled. */
+ dwarf2_per_bfd *m_per_bfd;
+};
+
/* An iterator for all_units that is based on index. This
approach makes it possible to iterate over all_units safely,
when some caller in the loop may add new units. */
@@ -1192,25 +1218,44 @@ struct dwarf2_base_index_functions : public quick_symbol_functions
bool need_fullname) override;
};
-/* If FILE_MATCHER is NULL or if PER_CU has
- dwarf2_per_cu_quick_data::MARK set (see
- dw_expand_symtabs_matching_file_matcher), expand the CU and call
- EXPANSION_NOTIFY on it. */
+/* This is used to track whether a CU has already been visited during
+ symbol expansion. It is an auto-resizing bool vector. */
+class auto_bool_vector
+{
+public:
-extern bool dw2_expand_symtabs_matching_one
- (dwarf2_per_cu *per_cu,
- dwarf2_per_objfile *per_objfile,
- expand_symtabs_file_matcher file_matcher,
- expand_symtabs_expansion_listener expansion_notify,
- expand_symtabs_lang_matcher lang_matcher);
+ auto_bool_vector () = default;
+
+ /* Return true if element I is set. */
+ bool is_set (size_t i) const
+ {
+ if (i < m_vec.size ())
+ return m_vec[i];
+ return false;
+ }
+
+ /* Set a value in this vector, growing it automatically. */
+ void set (size_t i, bool value)
+ {
+ if (m_vec.size () < i + 1)
+ m_vec.resize (i + 1);
+ m_vec[i] = value;
+ }
+
+private:
+ std::vector<bool> m_vec;
+};
-/* If FILE_MATCHER is non-NULL, set all the
- dwarf2_per_cu_quick_data::MARK of the current DWARF2_PER_OBJFILE
- that match FILE_MATCHER. */
+/* If FILE_MATCHER is NULL and if CUS_TO_SKIP does not include the
+ CU's index, expand the CU and call LISTENER on it. */
-extern void dw_expand_symtabs_matching_file_matcher
- (dwarf2_per_objfile *per_objfile,
- expand_symtabs_file_matcher file_matcher);
+extern bool dw2_search_one
+ (dwarf2_per_cu *per_cu,
+ dwarf2_per_objfile *per_objfile,
+ auto_bool_vector &cus_to_skip,
+ search_symtabs_file_matcher file_matcher,
+ search_symtabs_expansion_listener listener,
+ search_symtabs_lang_matcher lang_matcher);
/* Return pointer to string at .debug_str offset STR_OFFSET. */
@@ -1321,4 +1366,40 @@ extern file_and_directory &find_file_and_directory (die_info *die,
extern const dwarf2_section_info &get_section_for_ref
(const attribute &attr, dwarf2_cu *cu);
+/* A convenience function to find the proper .debug_line section for a CU. */
+
+extern struct dwarf2_section_info *get_debug_line_section
+ (struct dwarf2_cu *cu);
+
+/* Start a subfile for DWARF. FILENAME is the name of the file and
+ DIRNAME the name of the source directory which contains FILENAME
+ or NULL if not known.
+ This routine tries to keep line numbers from identical absolute and
+ relative file names in a common subfile.
+
+ Using the `list' example from the GDB testsuite, which resides in
+ /srcdir and compiling it with Irix6.2 cc in /compdir using a filename
+ of /srcdir/list0.c yields the following debugging information for list0.c:
+
+ DW_AT_name: /srcdir/list0.c
+ DW_AT_comp_dir: /compdir
+ files.files[0].name: list0.h
+ files.files[0].dir: /srcdir
+ files.files[1].name: list0.c
+ files.files[1].dir: /srcdir
+
+ The line number information for list0.c has to end up in a single
+ subfile, so that `break /srcdir/list0.c:1' works as expected.
+ start_subfile will ensure that this happens provided that we pass the
+ concatenation of files.files[1].dir and files.files[1].name as the
+ subfile's name. */
+extern void dwarf2_start_subfile (dwarf2_cu *cu, const file_entry &fe,
+ const line_header &lh);
+
+/* A helper function that decides if a given symbol is an Ada Pragma
+ Import or Pragma Export. */
+
+extern bool is_ada_import_or_export (dwarf2_cu *cu, const char *name,
+ const char *linkagename);
+
#endif /* GDB_DWARF2_READ_H */
diff --git a/gdb/dwarf2/stringify.c b/gdb/dwarf2/stringify.c
index c9625e8..bdb5125 100644
--- a/gdb/dwarf2/stringify.c
+++ b/gdb/dwarf2/stringify.c
@@ -25,6 +25,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "dwarf2.h"
+#include "dwarf2/read-gdb-index.h"
#include "dwarf2/stringify.h"
/* A convenience function that returns an "unknown" DWARF name,
@@ -44,6 +45,11 @@ dwarf_unknown (const char *str, unsigned v)
const char *
dwarf_tag_name (unsigned tag)
{
+ if (tag == DW_TAG_GDB_INDEX_OTHER)
+ return "DW_TAG_GDB_INDEX_OTHER";
+ else if (tag == DW_TAG_GDB_INDEX_TYPE)
+ return "DW_TAG_GDB_INDEX_TYPE";
+
const char *name = get_DW_TAG_name (tag);
if (name == NULL)
diff --git a/gdb/dwarf2/tag.h b/gdb/dwarf2/tag.h
index ed730c0..9b5c775 100644
--- a/gdb/dwarf2/tag.h
+++ b/gdb/dwarf2/tag.h
@@ -22,6 +22,7 @@
#include "dwarf2.h"
#include "symtab.h"
+#include "read-gdb-index.h"
/* Return true if TAG represents a type, false otherwise. */
@@ -102,6 +103,10 @@ tag_matches_domain (dwarf_tag tag, domain_search_flags search, language lang)
}
break;
+ case DW_TAG_imported_declaration:
+ /* DW_TAG_imported_declaration isn't necessarily a type, but the
+ scanner doesn't track the referent, and the full reader
+ also currently puts it in TYPE_DOMAIN. */
case DW_TAG_padding:
case DW_TAG_array_type:
case DW_TAG_pointer_type:
@@ -140,6 +145,13 @@ tag_matches_domain (dwarf_tag tag, domain_search_flags search, language lang)
else
flags = SEARCH_MODULE_DOMAIN;
break;
+
+ case DW_TAG_GDB_INDEX_OTHER:
+ flags = SEARCH_MODULE_DOMAIN | SEARCH_TYPE_DOMAIN;
+ break;
+ case DW_TAG_GDB_INDEX_TYPE:
+ flags = SEARCH_STRUCT_DOMAIN | SEARCH_TYPE_DOMAIN;
+ break;
}
return (flags & search) != 0;
diff --git a/gdb/elfread.c b/gdb/elfread.c
index ae74978..c8e976a 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -776,9 +776,8 @@ elf_gnu_ifunc_resolve_by_cache (const char *name, CORE_ADDR *addr_p)
To search other namespaces, we would need to provide context, e.g. in
form of an objfile in that namespace. */
- gdbarch_iterate_over_objfiles_in_search_order
- (current_inferior ()->arch (),
- [name, &addr_p, &found] (struct objfile *objfile)
+ current_program_space->iterate_over_objfiles_in_search_order
+ ([name, &addr_p, &found] (struct objfile *objfile)
{
htab_t htab;
elf_gnu_ifunc_cache *entry_p;
@@ -830,9 +829,8 @@ elf_gnu_ifunc_resolve_by_got (const char *name, CORE_ADDR *addr_p)
To search other namespaces, we would need to provide context, e.g. in
form of an objfile in that namespace. */
- gdbarch_iterate_over_objfiles_in_search_order
- (current_inferior ()->arch (),
- [name, name_got_plt, &addr_p, &found] (struct objfile *objfile)
+ current_program_space->iterate_over_objfiles_in_search_order
+ ([name, name_got_plt, &addr_p, &found] (struct objfile *objfile)
{
bfd *obfd = objfile->obfd.get ();
struct gdbarch *gdbarch = objfile->arch ();
diff --git a/gdb/eval.c b/gdb/eval.c
index 539b700..07fa0af 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -38,7 +38,6 @@
#include "gdbsupport/gdb_obstack.h"
#include "objfiles.h"
#include "typeprint.h"
-#include <ctype.h>
#include "expop.h"
#include "c-exp.h"
#include "inferior.h"
@@ -492,7 +491,7 @@ fake_method::fake_method (type_instance_flags flags,
fake_method::~fake_method ()
{
- xfree (m_type.fields ());
+ xfree (m_type.fields ().data ());
}
namespace expr
@@ -1181,8 +1180,8 @@ ternop_slice_operation::evaluate (struct type *expect_type,
struct value *upper
= std::get<2> (m_storage)->evaluate (nullptr, exp, noside);
- int lowbound = value_as_long (low);
- int upperbound = value_as_long (upper);
+ LONGEST lowbound = value_as_long (low);
+ LONGEST upperbound = value_as_long (upper);
return value_slice (array, lowbound, upperbound - lowbound + 1);
}
@@ -2285,14 +2284,18 @@ logical_and_operation::evaluate (struct type *expect_type,
}
else
{
+ type *type = language_bool_type (exp->language_defn,
+ exp->gdbarch);
+ if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ return value::zero (type, not_lval);
+
bool tem = value_logical_not (arg1);
if (!tem)
{
arg2 = std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
tem = value_logical_not (arg2);
}
- struct type *type = language_bool_type (exp->language_defn,
- exp->gdbarch);
+
return value_from_longest (type, !tem);
}
}
@@ -2314,6 +2317,11 @@ logical_or_operation::evaluate (struct type *expect_type,
}
else
{
+ type *type = language_bool_type (exp->language_defn,
+ exp->gdbarch);
+ if (noside == EVAL_AVOID_SIDE_EFFECTS)
+ return value::zero (type, not_lval);
+
bool tem = value_logical_not (arg1);
if (tem)
{
@@ -2321,8 +2329,6 @@ logical_or_operation::evaluate (struct type *expect_type,
tem = value_logical_not (arg2);
}
- struct type *type = language_bool_type (exp->language_defn,
- exp->gdbarch);
return value_from_longest (type, !tem);
}
}
@@ -2678,11 +2684,11 @@ var_value_operation::evaluate_for_address (struct expression *exp,
if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
struct type *type = lookup_pointer_type (var->type ());
- enum address_class sym_class = var->aclass ();
+ location_class loc_class = var->loc_class ();
- if (sym_class == LOC_CONST
- || sym_class == LOC_CONST_BYTES
- || sym_class == LOC_REGISTER)
+ if (loc_class == LOC_CONST
+ || loc_class == LOC_CONST_BYTES
+ || loc_class == LOC_REGISTER)
error (_("Attempt to take address of register or constant."));
return value::zero (type, not_lval);
diff --git a/gdb/event-top.c b/gdb/event-top.c
index f96982a..3138e8c 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -1180,6 +1180,9 @@ quit (void)
throw_forced_quit ("SIGTERM");
}
+ /* Pressing ^C cancels i-search. Tell readline that a ^C happened. */
+ rl_callback_sigcleanup ();
+
#ifdef __MSDOS__
/* No steenking SIGINT will ever be coming our way when the
program is resumed. Don't lie. */
diff --git a/gdb/exec.c b/gdb/exec.c
index c2a1f8a..a904f5c 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -42,7 +42,6 @@
#include "readline/tilde.h"
#include "gdbcore.h"
-#include <ctype.h>
#include <sys/stat.h>
#include "solib.h"
#include <algorithm>
@@ -653,13 +652,13 @@ program_space::add_target_sections (struct objfile *objfile)
gdb_assert (objfile != nullptr);
/* Compute the number of sections to add. */
- for (obj_section *osect : objfile->sections ())
+ for (obj_section &osect : objfile->sections ())
{
- if (bfd_section_size (osect->the_bfd_section) == 0)
+ if (bfd_section_size (osect.the_bfd_section) == 0)
continue;
- m_target_sections.emplace_back (osect->addr (), osect->endaddr (),
- osect->the_bfd_section, objfile);
+ m_target_sections.emplace_back (osect.addr (), osect.endaddr (),
+ osect.the_bfd_section, objfile);
}
}
@@ -1015,7 +1014,7 @@ set_section_command (const char *args, int from_tty)
error (_("Must specify section name and its virtual address"));
/* Parse out section name. */
- for (secname = args; !isspace (*args); args++);
+ for (secname = args; !c_isspace (*args); args++);
unsigned seclen = args - secname;
/* Parse out new virtual address. */
diff --git a/gdb/expop.h b/gdb/expop.h
index a3541d4..e755df5 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -308,6 +308,25 @@ dump_for_expression (struct ui_file *stream, int depth,
op->dump (stream, depth);
}
+/* If evaluating with noside == EVAL_AVOID_SIDE_EFFECTS, we are essentially
+ interested in the type of ARG. However, if ARG is of reference type,
+ this would give us a memory value that would cause a failure if GDB
+ attempts to access the contents. Convert to the target type to avoid
+ such problems. */
+
+static value *
+convert_reference_to_target_type (value *arg, enum noside noside)
+{
+ struct type *type = check_typedef (arg->type ());
+ if (noside == EVAL_AVOID_SIDE_EFFECTS && TYPE_IS_REFERENCE (type))
+ {
+ struct type *target_type = check_typedef (type->target_type ());
+ return value::zero (target_type, not_lval);
+ }
+
+ return arg;
+}
+
extern void dump_for_expression (struct ui_file *stream, int depth,
enum exp_opcode op);
extern void dump_for_expression (struct ui_file *stream, int depth,
@@ -476,11 +495,11 @@ check_constant (const gdb_mpz &cst)
static inline bool
check_constant (struct symbol *sym)
{
- enum address_class sc = sym->aclass ();
- return (sc == LOC_BLOCK
- || sc == LOC_CONST
- || sc == LOC_CONST_BYTES
- || sc == LOC_LABEL);
+ location_class lc = sym->loc_class ();
+ return (lc == LOC_BLOCK
+ || lc == LOC_CONST
+ || lc == LOC_CONST_BYTES
+ || lc == LOC_LABEL);
}
static inline bool
@@ -953,7 +972,7 @@ public:
struct value *val
= std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
- if (value_logical_not (val))
+ if (noside != EVAL_AVOID_SIDE_EFFECTS && value_logical_not (val))
return std::get<2> (m_storage)->evaluate (nullptr, exp, noside);
return std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
}
@@ -1187,6 +1206,10 @@ public:
= std::get<0> (m_storage)->evaluate_with_coercion (exp, noside);
value *rhs
= std::get<1> (m_storage)->evaluate_with_coercion (exp, noside);
+
+ lhs = convert_reference_to_target_type (lhs, noside);
+ rhs = convert_reference_to_target_type (rhs, noside);
+
return eval_op_add (expect_type, exp, noside, lhs, rhs);
}
@@ -1223,6 +1246,10 @@ public:
= std::get<0> (m_storage)->evaluate_with_coercion (exp, noside);
value *rhs
= std::get<1> (m_storage)->evaluate_with_coercion (exp, noside);
+
+ lhs = convert_reference_to_target_type (lhs, noside);
+ rhs = convert_reference_to_target_type (rhs, noside);
+
return eval_op_sub (expect_type, exp, noside, lhs, rhs);
}
@@ -1265,6 +1292,10 @@ public:
= std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
value *rhs
= std::get<1> (m_storage)->evaluate (nullptr, exp, noside);
+
+ lhs = convert_reference_to_target_type (lhs, noside);
+ rhs = convert_reference_to_target_type (rhs, noside);
+
return FUNC (expect_type, exp, noside, OP, lhs, rhs);
}
@@ -1340,6 +1371,10 @@ public:
value *rhs
= std::get<1> (this->m_storage)->evaluate (lhs->type (), exp,
noside);
+
+ lhs = convert_reference_to_target_type (lhs, noside);
+ rhs = convert_reference_to_target_type (rhs, noside);
+
return FUNC (expect_type, exp, noside, OP, lhs, rhs);
}
};
@@ -1434,6 +1469,7 @@ public:
enum noside noside) override
{
value *val = std::get<0> (m_storage)->evaluate (nullptr, exp, noside);
+ val = convert_reference_to_target_type (val, noside);
return FUNC (expect_type, exp, noside, OP, val);
}
diff --git a/gdb/expprint.c b/gdb/expprint.c
index c87be74..a32b7ac 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -33,7 +33,6 @@
#include "expop.h"
#include "ada-exp.h"
-#include <ctype.h>
/* Meant to be used in debug sessions, so don't export it in a header file. */
extern void ATTRIBUTE_USED debug_exp (struct expression *exp);
diff --git a/gdb/extension.c b/gdb/extension.c
index d34dbcd..1e967c5 100644
--- a/gdb/extension.c
+++ b/gdb/extension.c
@@ -34,6 +34,8 @@
#include <array>
#include "inferior.h"
#include "gdbsupport/scoped_signal_handler.h"
+#include "gdbsupport/scoped_ignore_signal.h"
+#include "run-on-main-thread.h"
static script_sourcer_func source_gdb_script;
static objfile_script_sourcer_func source_gdb_objfile_script;
@@ -638,7 +640,7 @@ breakpoint_ext_lang_cond_says_stop (struct breakpoint *b)
This requires cooperation with the extension languages so the support
is defined here. */
-#if CXX_STD_THREAD
+#if CXX_STD_THREAD && defined __MINGW32__
#include <mutex>
@@ -648,10 +650,19 @@ breakpoint_ext_lang_cond_says_stop (struct breakpoint *b)
available, DAP will not start.
This lock is held for accesses to quit_flag, active_ext_lang, and
- cooperative_sigint_handling_disabled. */
+ cooperative_sigint_handling_disabled.
+
+ This lock is only required for targets that don't support kill(), and,
+ it is assumed, handle SIGINT not as a signal, but as a new thread. For
+ these targets this mutex prevents multiple threads adjusting the above
+ state at the same time.
+
+ For targets that support kill() gdb.interrupt is implemented by just
+ sending SIGINT to the process, which is then handled in the "normal"
+ way. */
static std::recursive_mutex ext_lang_mutex;
-#endif /* CXX_STD_THREAD */
+#endif /* CXX_STD_THREAD && defined (__MINGW32__)*/
/* This flag tracks quit requests when we haven't called out to an
extension language. it also holds quit requests when we transition to
@@ -700,6 +711,44 @@ void (*hook_set_active_ext_lang) () = nullptr;
}
#endif
+namespace gdb
+{
+/* Wrapper that acquires the global EXT_LANG_MUTEX, but only for hosts
+ that might call quit related functions from a separate thread.
+ Specifically, this is hosts that don't support Unix like signals
+ (currently only Mingw).
+
+ For hosts with signal support, we don't try to use a mutex as a signal
+ might interrupt the lock acquisition, in which case deadlock will
+ occur. However, for these hosts, all the quit related functions are
+ called on the main thread (there's an assert for this), so the lack of
+ locking shouldn't be an issue.
+
+ For Mingw, without signals, the implementation of the Python
+ gdb.interrupt function can call set_quit_flag() from a second thread,
+ and additionally, the emulation of SIGINT involves the creation of a
+ temporary thread which calls the sigint handler. So for Mingw, we do
+ need the mutex, but that's OK, as no signal can interrupt the lock
+ acquisition. */
+struct ext_lang_guard
+{
+ ext_lang_guard ()
+ {
+#if CXX_STD_THREAD && !defined __MINGW32__
+ gdb_assert (is_main_thread ());
+#endif /* CXX_STD_THREAD && ! defined __MINGW32__ */
+ }
+
+ ~ext_lang_guard () { /* Nothing. */ }
+
+private:
+#if CXX_STD_THREAD && defined __MINGW32__
+ std::lock_guard<typeof (ext_lang_mutex)> m_guard { ext_lang_mutex };
+#endif
+};
+
+}
+
/* True if cooperative SIGINT handling is disabled. This is needed so
that calls to set_active_ext_lang do not re-enable cooperative
handling, which if enabled would make set_quit_flag store the
@@ -708,9 +757,7 @@ static bool cooperative_sigint_handling_disabled = false;
scoped_disable_cooperative_sigint_handling::scoped_disable_cooperative_sigint_handling ()
{
-#if CXX_STD_THREAD
- std::lock_guard guard (ext_lang_mutex);
-#endif /* CXX_STD_THREAD */
+ gdb::ext_lang_guard guard;
/* Force the active extension language to the GDB scripting
language. This ensures that a previously saved SIGINT is moved
@@ -729,9 +776,7 @@ scoped_disable_cooperative_sigint_handling::scoped_disable_cooperative_sigint_ha
scoped_disable_cooperative_sigint_handling::~scoped_disable_cooperative_sigint_handling ()
{
-#if CXX_STD_THREAD
- std::lock_guard guard (ext_lang_mutex);
-#endif /* CXX_STD_THREAD */
+ gdb::ext_lang_guard guard;
cooperative_sigint_handling_disabled = m_prev_cooperative_sigint_handling_disabled;
restore_active_ext_lang (m_prev_active_ext_lang_state);
@@ -771,9 +816,7 @@ scoped_disable_cooperative_sigint_handling::~scoped_disable_cooperative_sigint_h
struct active_ext_lang_state *
set_active_ext_lang (const struct extension_language_defn *now_active)
{
-#if CXX_STD_THREAD
- std::lock_guard guard (ext_lang_mutex);
-#endif /* CXX_STD_THREAD */
+ gdb::ext_lang_guard guard;
#if GDB_SELF_TEST
if (selftests::hook_set_active_ext_lang)
@@ -827,9 +870,7 @@ set_active_ext_lang (const struct extension_language_defn *now_active)
void
restore_active_ext_lang (struct active_ext_lang_state *previous)
{
-#if CXX_STD_THREAD
- std::lock_guard guard (ext_lang_mutex);
-#endif /* CXX_STD_THREAD */
+ gdb::ext_lang_guard guard;
if (cooperative_sigint_handling_disabled)
{
@@ -861,9 +902,7 @@ restore_active_ext_lang (struct active_ext_lang_state *previous)
void
set_quit_flag ()
{
-#if CXX_STD_THREAD
- std::lock_guard guard (ext_lang_mutex);
-#endif /* CXX_STD_THREAD */
+ gdb::ext_lang_guard guard;
if (active_ext_lang->ops != NULL
&& active_ext_lang->ops->set_quit_flag != NULL)
@@ -886,9 +925,7 @@ set_quit_flag ()
bool
check_quit_flag ()
{
-#if CXX_STD_THREAD
- std::lock_guard guard (ext_lang_mutex);
-#endif /* CXX_STD_THREAD */
+ gdb::ext_lang_guard guard;
bool result = false;
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
index 44ea11b..a8ee9a3 100644
--- a/gdb/f-exp.y
+++ b/gdb/f-exp.y
@@ -48,7 +48,6 @@
#include "language.h"
#include "f-lang.h"
#include "block.h"
-#include <ctype.h>
#include <algorithm>
#include "type-stack.h"
#include "f-exp.h"
@@ -1061,8 +1060,8 @@ parse_number (struct parser_state *par_state,
while (len-- > 0)
{
c = *p++;
- if (isupper (c))
- c = tolower (c);
+ if (c_isupper (c))
+ c = c_tolower (c);
if (len == 0 && c == 'l')
long_p = 1;
else if (len == 0 && c == 'u')
@@ -1160,8 +1159,7 @@ push_kind_type (LONGEST val, struct type *type)
ival = static_cast <int> (val);
}
- type_stack->push (ival);
- type_stack->push (tp_kind);
+ type_stack->push (tp_kind, ival);
}
/* Helper function for convert_to_kind_type. */
@@ -1663,7 +1661,7 @@ yylex (void)
{
result = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
domain, NULL);
- if (result.symbol && result.symbol->aclass () == LOC_TYPEDEF)
+ if (result.symbol && result.symbol->loc_class () == LOC_TYPEDEF)
{
yylval.tsym.type = result.symbol->type ();
return TYPENAME;
diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
index 7d0cdc0..04eca74 100644
--- a/gdb/f-typeprint.c
+++ b/gdb/f-typeprint.c
@@ -299,8 +299,6 @@ void
f_language::f_type_print_base (struct type *type, struct ui_file *stream,
int show, int level) const
{
- int index;
-
QUIT;
stream->wrap_here (4);
@@ -414,28 +412,30 @@ f_language::f_type_print_base (struct type *type, struct ui_file *stream,
if (show > 0)
f_type_print_derivation_info (type, stream);
- gdb_puts (" ", stream);
-
- gdb_puts (type->name (), stream);
+ if (type->name () != nullptr)
+ {
+ gdb_puts (" ", stream);
+ gdb_puts (type->name (), stream);
+ }
/* According to the definition,
we only print structure elements in case show > 0. */
if (show > 0)
{
gdb_puts ("\n", stream);
- for (index = 0; index < type->num_fields (); index++)
+ for (const auto &field : type->fields ())
{
- f_type_print_base (type->field (index).type (), stream,
- show - 1, level + 4);
+ f_type_print_base (field.type (), stream, show - 1, level + 4);
gdb_puts (" :: ", stream);
- fputs_styled (type->field (index).name (),
+ fputs_styled (field.name (),
variable_name_style.style (), stream);
- f_type_print_varspec_suffix (type->field (index).type (),
+ f_type_print_varspec_suffix (field.type (),
stream, show - 1, 0, 0, 0, false);
gdb_puts ("\n", stream);
}
gdb_printf (stream, "%*sEnd Type ", level, "");
- gdb_puts (type->name (), stream);
+ if (type->name () != nullptr)
+ gdb_puts (type->name (), stream);
}
break;
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index a0812b3..935bf02 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -631,7 +631,7 @@ info_common_command_for_block (const struct block *block, const char *comname,
const struct common_block *common = sym->value_common_block ();
size_t index;
- gdb_assert (sym->aclass () == LOC_COMMON_BLOCK);
+ gdb_assert (sym->loc_class () == LOC_COMMON_BLOCK);
if (comname && (!sym->linkage_name ()
|| strcmp (comname, sym->linkage_name ()) != 0))
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index 935b947..81bd6d9 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -304,7 +304,7 @@ fbsd_nat_target::info_proc (const char *args, enum info_proc_what what)
if (pid == 0)
error (_("No current process: you must name one."));
}
- else if (built_argv.count () == 1 && isdigit (built_argv[0][0]))
+ else if (built_argv.count () == 1 && c_isdigit (built_argv[0][0]))
pid = strtol (built_argv[0], NULL, 10);
else
error (_("Invalid arguments."));
diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index 39e1e86..32571b8 100644
--- a/gdb/fbsd-tdep.c
+++ b/gdb/fbsd-tdep.c
@@ -548,7 +548,8 @@ fbsd_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid)
string in a static buffer. */
static const char *
-fbsd_core_thread_name (struct gdbarch *gdbarch, struct thread_info *thr)
+fbsd_core_thread_name (struct gdbarch *gdbarch, bfd &cbfd,
+ struct thread_info *thr)
{
static char buf[80];
struct bfd_section *section;
@@ -564,16 +565,15 @@ fbsd_core_thread_name (struct gdbarch *gdbarch, struct thread_info *thr)
extract the null-terminated name from the start of the
note. */
thread_section_name section_name (".thrmisc", thr->ptid);
- bfd *cbfd = current_program_space->core_bfd ();
- section = bfd_get_section_by_name (cbfd, section_name.c_str ());
+ section = bfd_get_section_by_name (&cbfd, section_name.c_str ());
if (section != NULL && bfd_section_size (section) > 0)
{
/* Truncate the name if it is longer than "buf". */
size = bfd_section_size (section);
if (size > sizeof buf - 1)
size = sizeof buf - 1;
- if (bfd_get_section_contents (cbfd, section, buf, (file_ptr) 0, size)
+ if (bfd_get_section_contents (&cbfd, section, buf, (file_ptr) 0, size)
&& buf[0] != '\0')
{
buf[size] = '\0';
@@ -582,7 +582,7 @@ fbsd_core_thread_name (struct gdbarch *gdbarch, struct thread_info *thr)
as its thread name instead of an empty name if a name
has not been set explicitly. Return a NULL name in
that case. */
- if (strcmp (buf, elf_tdata (cbfd)->core->program) != 0)
+ if (strcmp (buf, elf_tdata (&cbfd)->core->program) != 0)
return buf;
}
}
@@ -594,8 +594,8 @@ fbsd_core_thread_name (struct gdbarch *gdbarch, struct thread_info *thr)
/* Implement the "core_xfer_siginfo" gdbarch method. */
static LONGEST
-fbsd_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf,
- ULONGEST offset, ULONGEST len)
+fbsd_core_xfer_siginfo (struct gdbarch *gdbarch, struct bfd &cbfd,
+ gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
{
size_t siginfo_size;
@@ -607,13 +607,12 @@ fbsd_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf,
return -1;
thread_section_name section_name (".note.freebsdcore.lwpinfo", inferior_ptid);
- bfd *cbfd = current_program_space->core_bfd ();
- asection *section = bfd_get_section_by_name (cbfd, section_name.c_str ());
+ asection *section = bfd_get_section_by_name (&cbfd, section_name.c_str ());
if (section == NULL)
return -1;
gdb_byte buf[4];
- if (!bfd_get_section_contents (cbfd, section, buf,
+ if (!bfd_get_section_contents (&cbfd, section, buf,
LWPINFO_OFFSET + LWPINFO_PL_FLAGS, 4))
return -1;
@@ -630,7 +629,7 @@ fbsd_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf,
else
siginfo_offset = LWPINFO_OFFSET + LWPINFO64_PL_SIGINFO;
- if (!bfd_get_section_contents (cbfd, section, readbuf,
+ if (!bfd_get_section_contents (&cbfd, section, readbuf,
siginfo_offset + offset, len))
return -1;
@@ -1015,12 +1014,11 @@ fbsd_info_proc_files_entry (int kf_type, int kf_fd, int kf_flags,
gdb_printf ("\n");
}
-/* Implement "info proc files" for a corefile. */
+/* Implement "info proc files" for corefile CBFD. */
static void
-fbsd_core_info_proc_files (struct gdbarch *gdbarch)
+fbsd_core_info_proc_files (struct gdbarch *gdbarch, bfd *cbfd)
{
- bfd *cbfd = current_program_space->core_bfd ();
asection *section = bfd_get_section_by_name (cbfd, ".note.freebsdcore.files");
if (section == NULL)
{
@@ -1143,15 +1141,14 @@ fbsd_info_proc_mappings_entry (int addr_bit, ULONGEST kve_start,
}
}
-/* Implement "info proc mappings" for a corefile. */
+/* Implement "info proc mappings" for corefile CBFD. */
static void
-fbsd_core_info_proc_mappings (struct gdbarch *gdbarch)
+fbsd_core_info_proc_mappings (struct gdbarch *gdbarch, bfd *cbfd)
{
asection *section;
unsigned char *descdata, *descend;
size_t note_size;
- bfd *cbfd = current_program_space->core_bfd ();
section = bfd_get_section_by_name (cbfd, ".note.freebsdcore.vmmap");
if (section == NULL)
@@ -1194,15 +1191,14 @@ fbsd_core_info_proc_mappings (struct gdbarch *gdbarch)
}
/* Fetch the pathname of a vnode for a single file descriptor from the
- file table core note. */
+ file table core note in CBFD. */
static gdb::unique_xmalloc_ptr<char>
-fbsd_core_vnode_path (struct gdbarch *gdbarch, int fd)
+fbsd_core_vnode_path (struct gdbarch *gdbarch, bfd *cbfd, int fd)
{
asection *section;
unsigned char *descdata, *descend;
size_t note_size;
- bfd *cbfd = current_program_space->core_bfd ();
section = bfd_get_section_by_name (cbfd, ".note.freebsdcore.files");
if (section == NULL)
@@ -1242,14 +1238,12 @@ fbsd_core_vnode_path (struct gdbarch *gdbarch, int fd)
return nullptr;
}
-/* Helper function to read a struct timeval. */
+/* Helper function to read a struct timeval from core file CBFD. */
static void
-fbsd_core_fetch_timeval (struct gdbarch *gdbarch, unsigned char *data,
- LONGEST &sec, ULONGEST &usec)
+fbsd_core_fetch_timeval (struct gdbarch *gdbarch, bfd *cbfd,
+ unsigned char *data, LONGEST &sec, ULONGEST &usec)
{
- bfd *cbfd = current_program_space->core_bfd ();
-
if (gdbarch_addr_bit (gdbarch) == 64)
{
sec = bfd_get_signed_64 (cbfd, data);
@@ -1267,12 +1261,11 @@ fbsd_core_fetch_timeval (struct gdbarch *gdbarch, unsigned char *data,
}
}
-/* Print out the contents of a signal set. */
+/* Print out the contents of a signal set SIGSET in core file CBFD. */
static void
-fbsd_print_sigset (const char *descr, unsigned char *sigset)
+fbsd_print_sigset (bfd *cbfd, const char *descr, unsigned char *sigset)
{
- bfd *cbfd = current_program_space->core_bfd ();
gdb_printf ("%s: ", descr);
for (int i = 0; i < SIG_WORDS; i++)
gdb_printf ("%08x ",
@@ -1280,10 +1273,10 @@ fbsd_print_sigset (const char *descr, unsigned char *sigset)
gdb_printf ("\n");
}
-/* Implement "info proc status" for a corefile. */
+/* Implement "info proc status" for corefile CBFD. */
static void
-fbsd_core_info_proc_status (struct gdbarch *gdbarch)
+fbsd_core_info_proc_status (struct gdbarch *gdbarch, bfd *cbfd)
{
const struct kinfo_proc_layout *kp;
asection *section;
@@ -1292,7 +1285,6 @@ fbsd_core_info_proc_status (struct gdbarch *gdbarch)
size_t note_size;
ULONGEST value;
LONGEST sec;
- bfd *cbfd = current_program_space->core_bfd ();
section = bfd_get_section_by_name (cbfd, ".note.freebsdcore.proc");
if (section == NULL)
@@ -1387,25 +1379,25 @@ fbsd_core_info_proc_status (struct gdbarch *gdbarch)
value = bfd_get (long_bit, cbfd,
descdata + kp->ki_rusage_ch + kp->ru_majflt);
gdb_printf ("Major faults, children: %s\n", pulongest (value));
- fbsd_core_fetch_timeval (gdbarch,
+ fbsd_core_fetch_timeval (gdbarch, cbfd,
descdata + kp->ki_rusage + kp->ru_utime,
sec, value);
gdb_printf ("utime: %s.%06d\n", plongest (sec), (int) value);
- fbsd_core_fetch_timeval (gdbarch,
+ fbsd_core_fetch_timeval (gdbarch, cbfd,
descdata + kp->ki_rusage + kp->ru_stime,
sec, value);
gdb_printf ("stime: %s.%06d\n", plongest (sec), (int) value);
- fbsd_core_fetch_timeval (gdbarch,
+ fbsd_core_fetch_timeval (gdbarch, cbfd,
descdata + kp->ki_rusage_ch + kp->ru_utime,
sec, value);
gdb_printf ("utime, children: %s.%06d\n", plongest (sec), (int) value);
- fbsd_core_fetch_timeval (gdbarch,
+ fbsd_core_fetch_timeval (gdbarch, cbfd,
descdata + kp->ki_rusage_ch + kp->ru_stime,
sec, value);
gdb_printf ("stime, children: %s.%06d\n", plongest (sec), (int) value);
gdb_printf ("'nice' value: %d\n",
(int) bfd_get_signed_8 (core_bfd, descdata + kp->ki_nice));
- fbsd_core_fetch_timeval (gdbarch, descdata + kp->ki_start, sec, value);
+ fbsd_core_fetch_timeval (gdbarch, cbfd, descdata + kp->ki_start, sec, value);
gdb_printf ("Start time: %s.%06d\n", plongest (sec), (int) value);
gdb_printf ("Virtual memory size: %s kB\n",
pulongest (bfd_get (addr_bit, cbfd,
@@ -1426,15 +1418,15 @@ fbsd_core_info_proc_status (struct gdbarch *gdbarch)
pulongest (bfd_get (long_bit, cbfd,
descdata + kp->ki_rusage
+ kp->ru_maxrss)));
- fbsd_print_sigset ("Ignored Signals", descdata + kp->ki_sigignore);
- fbsd_print_sigset ("Caught Signals", descdata + kp->ki_sigcatch);
+ fbsd_print_sigset (cbfd, "Ignored Signals", descdata + kp->ki_sigignore);
+ fbsd_print_sigset (cbfd, "Caught Signals", descdata + kp->ki_sigcatch);
}
/* Implement the "core_info_proc" gdbarch method. */
static void
-fbsd_core_info_proc (struct gdbarch *gdbarch, const char *args,
- enum info_proc_what what)
+fbsd_core_info_proc (struct gdbarch *gdbarch, struct bfd *cbfd,
+ const char *args, enum info_proc_what what)
{
bool do_cmdline = false;
bool do_cwd = false;
@@ -1482,7 +1474,6 @@ fbsd_core_info_proc (struct gdbarch *gdbarch, const char *args,
return;
}
- bfd *cbfd = current_program_space->core_bfd ();
pid = bfd_core_file_pid (cbfd);
if (pid != 0)
gdb_printf (_("process %d\n"), pid);
@@ -1500,7 +1491,7 @@ fbsd_core_info_proc (struct gdbarch *gdbarch, const char *args,
if (do_cwd)
{
gdb::unique_xmalloc_ptr<char> cwd =
- fbsd_core_vnode_path (gdbarch, KINFO_FILE_FD_TYPE_CWD);
+ fbsd_core_vnode_path (gdbarch, cbfd, KINFO_FILE_FD_TYPE_CWD);
if (cwd)
gdb_printf ("cwd = '%s'\n", cwd.get ());
else
@@ -1509,18 +1500,18 @@ fbsd_core_info_proc (struct gdbarch *gdbarch, const char *args,
if (do_exe)
{
gdb::unique_xmalloc_ptr<char> exe =
- fbsd_core_vnode_path (gdbarch, KINFO_FILE_FD_TYPE_TEXT);
+ fbsd_core_vnode_path (gdbarch, cbfd, KINFO_FILE_FD_TYPE_TEXT);
if (exe)
gdb_printf ("exe = '%s'\n", exe.get ());
else
warning (_("unable to read executable path name"));
}
if (do_files)
- fbsd_core_info_proc_files (gdbarch);
+ fbsd_core_info_proc_files (gdbarch, cbfd);
if (do_mappings)
- fbsd_core_info_proc_mappings (gdbarch);
+ fbsd_core_info_proc_mappings (gdbarch, cbfd);
if (do_status)
- fbsd_core_info_proc_status (gdbarch);
+ fbsd_core_info_proc_status (gdbarch, cbfd);
}
/* Print descriptions of FreeBSD-specific AUXV entries to FILE. */
diff --git a/gdb/features/Makefile b/gdb/features/Makefile
index 750508a..d17c349 100644
--- a/gdb/features/Makefile
+++ b/gdb/features/Makefile
@@ -204,6 +204,8 @@ FEATURE_XMLFILES = aarch64-core.xml \
aarch64-fpu.xml \
aarch64-pauth.xml \
aarch64-mte.xml \
+ aarch64-gcs.xml \
+ aarch64-gcs-linux.xml \
arc/v1-core.xml \
arc/v1-aux.xml \
arc/v2-core.xml \
@@ -226,6 +228,7 @@ FEATURE_XMLFILES = aarch64-core.xml \
i386/32bit-avx.xml \
i386/32bit-avx512.xml \
i386/32bit-segments.xml \
+ i386/32bit-ssp.xml \
i386/64bit-avx512.xml \
i386/64bit-core.xml \
i386/64bit-segments.xml \
@@ -233,6 +236,7 @@ FEATURE_XMLFILES = aarch64-core.xml \
i386/64bit-linux.xml \
i386/64bit-sse.xml \
i386/pkeys.xml \
+ i386/64bit-ssp.xml \
i386/x32-core.xml \
loongarch/base32.xml \
loongarch/base64.xml \
diff --git a/gdb/features/aarch64-gcs-linux.c b/gdb/features/aarch64-gcs-linux.c
new file mode 100644
index 0000000..6b0d25b
--- /dev/null
+++ b/gdb/features/aarch64-gcs-linux.c
@@ -0,0 +1,21 @@
+/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
+ Original: aarch64-gcs-linux.xml */
+
+#include "gdbsupport/tdesc.h"
+
+static int
+create_feature_aarch64_gcs_linux (struct target_desc *result, long regnum)
+{
+ struct tdesc_feature *feature;
+
+ feature = tdesc_create_feature (result, "org.gnu.gdb.aarch64.gcs.linux");
+ tdesc_type_with_fields *type_with_fields;
+ type_with_fields = tdesc_create_flags (feature, "features_flags", 8);
+ tdesc_add_flag (type_with_fields, 0, "PR_SHADOW_STACK_ENABLE");
+ tdesc_add_flag (type_with_fields, 1, "PR_SHADOW_STACK_WRITE");
+ tdesc_add_flag (type_with_fields, 2, "PR_SHADOW_STACK_PUSH");
+
+ tdesc_create_reg (feature, "gcs_features_enabled", regnum++, 1, "system", 64, "features_flags");
+ tdesc_create_reg (feature, "gcs_features_locked", regnum++, 1, "system", 64, "features_flags");
+ return regnum;
+}
diff --git a/gdb/features/aarch64-gcs-linux.xml b/gdb/features/aarch64-gcs-linux.xml
new file mode 100644
index 0000000..8d9d2ce
--- /dev/null
+++ b/gdb/features/aarch64-gcs-linux.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2025 Free Software Foundation, Inc.
+
+ Copying and distribution of this file, with or without modification,
+ are permitted in any medium without royalty provided the copyright
+ notice and this notice are preserved. -->
+
+<!DOCTYPE feature SYSTEM "gdb-target.dtd">
+<feature name="org.gnu.gdb.aarch64.gcs.linux">
+ <flags id="features_flags" size="8">
+ <field name="PR_SHADOW_STACK_ENABLE" start="0" end="0"/>
+ <field name="PR_SHADOW_STACK_WRITE" start="1" end="1"/>
+ <field name="PR_SHADOW_STACK_PUSH" start="2" end="2"/>
+ </flags>
+
+ <reg name="gcs_features_enabled" bitsize="64" type="features_flags" group="system"/>
+ <reg name="gcs_features_locked" bitsize="64" type="features_flags" group="system"/>
+</feature>
diff --git a/gdb/features/aarch64-gcs.c b/gdb/features/aarch64-gcs.c
new file mode 100644
index 0000000..2b2caf2
--- /dev/null
+++ b/gdb/features/aarch64-gcs.c
@@ -0,0 +1,14 @@
+/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
+ Original: aarch64-gcs.xml */
+
+#include "gdbsupport/tdesc.h"
+
+static int
+create_feature_aarch64_gcs (struct target_desc *result, long regnum)
+{
+ struct tdesc_feature *feature;
+
+ feature = tdesc_create_feature (result, "org.gnu.gdb.aarch64.gcs");
+ tdesc_create_reg (feature, "gcspr", regnum++, 1, "system", 64, "data_ptr");
+ return regnum;
+}
diff --git a/gdb/features/aarch64-gcs.xml b/gdb/features/aarch64-gcs.xml
new file mode 100644
index 0000000..bbee5e0
--- /dev/null
+++ b/gdb/features/aarch64-gcs.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2025 Free Software Foundation, Inc.
+
+ Copying and distribution of this file, with or without modification,
+ are permitted in any medium without royalty provided the copyright
+ notice and this notice are preserved. -->
+
+<!DOCTYPE feature SYSTEM "gdb-target.dtd">
+<feature name="org.gnu.gdb.aarch64.gcs">
+ <reg name="gcspr" bitsize="64" type="data_ptr" group="system"/>
+</feature>
diff --git a/gdb/features/i386/32bit-ssp.c b/gdb/features/i386/32bit-ssp.c
new file mode 100644
index 0000000..991bae3
--- /dev/null
+++ b/gdb/features/i386/32bit-ssp.c
@@ -0,0 +1,14 @@
+/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
+ Original: 32bit-ssp.xml */
+
+#include "gdbsupport/tdesc.h"
+
+static int
+create_feature_i386_32bit_ssp (struct target_desc *result, long regnum)
+{
+ struct tdesc_feature *feature;
+
+ feature = tdesc_create_feature (result, "org.gnu.gdb.i386.pl3_ssp");
+ tdesc_create_reg (feature, "pl3_ssp", regnum++, 1, NULL, 32, "data_ptr");
+ return regnum;
+}
diff --git a/gdb/features/i386/32bit-ssp.xml b/gdb/features/i386/32bit-ssp.xml
new file mode 100644
index 0000000..d17e700
--- /dev/null
+++ b/gdb/features/i386/32bit-ssp.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2022-2024 Free Software Foundation, Inc.
+
+ Copying and distribution of this file, with or without modification,
+ are permitted in any medium without royalty provided the copyright
+ notice and this notice are preserved. -->
+
+<!DOCTYPE feature SYSTEM "gdb-target.dtd">
+<feature name="org.gnu.gdb.i386.pl3_ssp">
+ <reg name="pl3_ssp" bitsize="32" type="data_ptr"/>
+</feature>
diff --git a/gdb/features/i386/64bit-ssp.c b/gdb/features/i386/64bit-ssp.c
new file mode 100644
index 0000000..5468099
--- /dev/null
+++ b/gdb/features/i386/64bit-ssp.c
@@ -0,0 +1,14 @@
+/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
+ Original: 64bit-ssp.xml */
+
+#include "gdbsupport/tdesc.h"
+
+static int
+create_feature_i386_64bit_ssp (struct target_desc *result, long regnum)
+{
+ struct tdesc_feature *feature;
+
+ feature = tdesc_create_feature (result, "org.gnu.gdb.i386.pl3_ssp");
+ tdesc_create_reg (feature, "pl3_ssp", regnum++, 1, NULL, 64, "data_ptr");
+ return regnum;
+}
diff --git a/gdb/features/i386/64bit-ssp.xml b/gdb/features/i386/64bit-ssp.xml
new file mode 100644
index 0000000..a0688d0
--- /dev/null
+++ b/gdb/features/i386/64bit-ssp.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2022-2024 Free Software Foundation, Inc.
+
+ Copying and distribution of this file, with or without modification,
+ are permitted in any medium without royalty provided the copyright
+ notice and this notice are preserved. -->
+
+<!DOCTYPE feature SYSTEM "gdb-target.dtd">
+<feature name="org.gnu.gdb.i386.pl3_ssp">
+ <reg name="pl3_ssp" bitsize="64" type="data_ptr"/>
+</feature>
diff --git a/gdb/findcmd.c b/gdb/findcmd.c
index 4e47877..03c3fcc 100644
--- a/gdb/findcmd.c
+++ b/gdb/findcmd.c
@@ -18,7 +18,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "arch-utils.h"
-#include <ctype.h>
#include "cli/cli-cmds.h"
#include "value.h"
#include "target.h"
@@ -76,12 +75,12 @@ parse_find_args (const char *args, ULONGEST *max_countp,
{
++s;
- while (*s != '\0' && *s != '/' && !isspace (*s))
+ while (*s != '\0' && *s != '/' && !c_isspace (*s))
{
- if (isdigit (*s))
+ if (c_isdigit (*s))
{
max_count = atoi (s);
- while (isdigit (*s))
+ while (c_isdigit (*s))
++s;
continue;
}
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 9da5c48..41efc8d 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -65,14 +65,15 @@ value_of_register (int regnum, const frame_info_ptr &next_frame)
/* See value.h. */
value *
-value_of_register_lazy (const frame_info_ptr &next_frame, int regnum)
+value_of_register_lazy (const frame_info_ptr &next_frame, int regnum,
+ struct type *type)
{
gdbarch *gdbarch = frame_unwind_arch (next_frame);
gdb_assert (regnum < gdbarch_num_cooked_regs (gdbarch));
gdb_assert (next_frame != nullptr);
- return value::allocate_register_lazy (next_frame, regnum);
+ return value::allocate_register_lazy (next_frame, regnum, type);
}
/* Given a pointer of type TYPE in target form in BUF, return the
@@ -124,7 +125,7 @@ symbol_read_needs (struct symbol *sym)
computed_ops != nullptr)
return computed_ops->get_symbol_read_needs (sym);
- switch (sym->aclass ())
+ switch (sym->loc_class ())
{
/* All cases listed explicitly so that gcc -Wall will detect it if
we failed to consider one. */
@@ -306,7 +307,7 @@ language_defn::read_var_value (struct symbol *var,
if (const symbol_computed_ops *computed_ops = var->computed_ops ())
return computed_ops->read_variable (var, frame);
- switch (var->aclass ())
+ switch (var->loc_class ())
{
case LOC_CONST:
if (is_dynamic_type (type))
@@ -429,7 +430,7 @@ language_defn::read_var_value (struct symbol *var,
const symbol_register_ops *reg_ops = var->register_ops ();
int regno = reg_ops->register_number (var, get_frame_arch (frame));
- if (var->aclass () == LOC_REGPARM_ADDR)
+ if (var->loc_class () == LOC_REGPARM_ADDR)
addr = value_as_address
(value_from_register (lookup_pointer_type (type), regno, frame));
else
@@ -445,9 +446,8 @@ language_defn::read_var_value (struct symbol *var,
struct obj_section *obj_section;
bound_minimal_symbol bmsym;
- gdbarch_iterate_over_objfiles_in_search_order
- (var->arch (),
- [var, &bmsym] (objfile *objfile)
+ current_program_space->iterate_over_objfiles_in_search_order
+ ([var, &bmsym] (objfile *objfile)
{
bmsym = lookup_minimal_symbol (current_program_space,
var->linkage_name (), objfile);
diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c
index 95768fa..3709215 100644
--- a/gdb/frame-unwind.c
+++ b/gdb/frame-unwind.c
@@ -297,8 +297,16 @@ struct value *
frame_unwind_got_register (const frame_info_ptr &frame,
int regnum, int new_regnum)
{
+ struct gdbarch *gdbarch = frame_unwind_arch (frame);
+ struct type *regnum_type = register_type (gdbarch, regnum);
+ struct type *new_regnum_type = register_type (gdbarch, new_regnum);
+
+ /* REGNUM has been copied into NEW_REGNUM, therefore, the former
+ must be smaller or equal in size to the latter. */
+ gdb_assert (regnum_type->length () <= new_regnum_type->length ());
+
return value_of_register_lazy (get_next_frame_sentinel_okay (frame),
- new_regnum);
+ new_regnum, regnum_type);
}
/* Return a value which indicates that FRAME saved REGNUM in memory at
diff --git a/gdb/frame.c b/gdb/frame.c
index fc4cbca..5c41dcd 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -2617,7 +2617,7 @@ inside_main_func (const frame_info_ptr &this_frame)
SEARCH_FUNCTION_DOMAIN, nullptr);
/* This lookup should always yield a block-valued symbol. */
- if (bs.symbol != nullptr && bs.symbol->aclass () == LOC_BLOCK)
+ if (bs.symbol != nullptr && bs.symbol->loc_class () == LOC_BLOCK)
{
const struct block *block = bs.symbol->value_block ();
gdb_assert (block != nullptr);
@@ -2663,15 +2663,14 @@ get_prev_frame (const frame_info_ptr &this_frame)
{
FRAME_SCOPED_DEBUG_ENTER_EXIT;
- CORE_ADDR frame_pc;
- int frame_pc_p;
+ std::optional<CORE_ADDR> frame_pc;
/* There is always a frame. If this assertion fails, suspect that
something should be calling get_selected_frame() or
get_current_frame(). */
gdb_assert (this_frame != NULL);
- frame_pc_p = get_frame_pc_if_available (this_frame, &frame_pc);
+ frame_pc = get_frame_pc_if_available (this_frame);
/* tausq/2004-12-07: Dummy frames are skipped because it doesn't make much
sense to stop unwinding at a dummy frame. One place where a dummy
@@ -2686,7 +2685,7 @@ get_prev_frame (const frame_info_ptr &this_frame)
if (this_frame->level >= 0
&& get_frame_type (this_frame) == NORMAL_FRAME
&& !user_set_backtrace_options.backtrace_past_main
- && frame_pc_p
+ && frame_pc.has_value ()
&& inside_main_func (this_frame))
/* Don't unwind past main(). Note, this is done _before_ the
frame has been marked as previously unwound. That way if the
@@ -2733,7 +2732,7 @@ get_prev_frame (const frame_info_ptr &this_frame)
if (this_frame->level >= 0
&& get_frame_type (this_frame) == NORMAL_FRAME
&& !user_set_backtrace_options.backtrace_past_entry
- && frame_pc_p
+ && frame_pc.has_value ()
&& inside_entry_func (this_frame))
{
frame_debug_got_null_frame (this_frame, "inside entry func");
@@ -2747,7 +2746,7 @@ get_prev_frame (const frame_info_ptr &this_frame)
&& (get_frame_type (this_frame) == NORMAL_FRAME
|| get_frame_type (this_frame) == INLINE_FRAME)
&& get_frame_type (get_next_frame (this_frame)) == NORMAL_FRAME
- && frame_pc_p && frame_pc == 0)
+ && frame_pc.has_value () && *frame_pc == 0)
{
frame_debug_got_null_frame (this_frame, "zero PC");
return NULL;
@@ -2763,25 +2762,24 @@ get_frame_pc (const frame_info_ptr &frame)
return frame_unwind_pc (frame_info_ptr (frame->next));
}
-bool
-get_frame_pc_if_available (const frame_info_ptr &frame, CORE_ADDR *pc)
+std::optional<CORE_ADDR>
+get_frame_pc_if_available (const frame_info_ptr &frame)
{
+ std::optional<CORE_ADDR> pc;
gdb_assert (frame->next != NULL);
try
{
- *pc = frame_unwind_pc (frame_info_ptr (frame->next));
+ pc = frame_unwind_pc (frame_info_ptr (frame->next));
}
catch (const gdb_exception_error &ex)
{
- if (ex.error == NOT_AVAILABLE_ERROR)
- return false;
- else
+ if (ex.error != NOT_AVAILABLE_ERROR)
throw;
}
- return true;
+ return pc;
}
/* Return an address that falls within THIS_FRAME's code block. */
@@ -2870,7 +2868,7 @@ find_frame_sal (const frame_info_ptr &frame)
{
frame_info_ptr next_frame;
int notcurrent;
- CORE_ADDR pc;
+ std::optional<CORE_ADDR> pc;
if (frame_inlined_callees (frame) > 0)
{
@@ -2914,11 +2912,11 @@ find_frame_sal (const frame_info_ptr &frame)
PC and such a PC indicates the current (rather than next)
instruction/line, consequently, for such cases, want to get the
line containing fi->pc. */
- if (!get_frame_pc_if_available (frame, &pc))
+ if (!(pc = get_frame_pc_if_available (frame)))
return {};
- notcurrent = (pc != get_frame_address_in_block (frame));
- return find_pc_line (pc, notcurrent);
+ notcurrent = (*pc != get_frame_address_in_block (frame));
+ return find_pc_line (*pc, notcurrent);
}
/* Per "frame.h", return the ``address'' of the frame. Code should
diff --git a/gdb/frame.h b/gdb/frame.h
index b240662..99a7983 100644
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -504,7 +504,8 @@ extern CORE_ADDR get_frame_pc (const frame_info_ptr &);
/* Same as get_frame_pc, but return a boolean indication of whether
the PC is actually available, instead of throwing an error. */
-extern bool get_frame_pc_if_available (const frame_info_ptr &frame, CORE_ADDR *pc);
+extern std::optional<CORE_ADDR> get_frame_pc_if_available
+ (const frame_info_ptr &frame);
/* An address (not necessarily aligned to an instruction boundary)
that falls within THIS frame's code block.
diff --git a/gdb/gcore-1.in b/gdb/gcore-1.in
index 2f6eb02..fe2bb3d 100644..100755
--- a/gdb/gcore-1.in
+++ b/gdb/gcore-1.in
@@ -32,12 +32,15 @@ dump_all_cmds=()
data_directory_opt=()
+# The GDB binary to run.
+gdb_binary=
+
function print_usage() {
prefix="Usage: $0"
padding=$(printf '%*s' ${#prefix})
echo "$prefix [-h|--help] [-v|--version]"
- echo "$padding [-a] [-o prefix] [-d data-directory]"
+ echo "$padding [-a] [-o prefix] [-g gdb] [-d data-directory]"
echo "$padding pid1 [pid2...pidN]"
}
@@ -55,6 +58,8 @@ function print_help() {
echo " -a Dump all memory mappings."
echo " -o prefix Use 'prefix.pid' as the core file name."
echo " The default prefix is 'core'."
+ echo " -g gdb The GDB binary to run."
+ echo " Defaults to GDB installed alongside gcore."
echo " -d dir Pass '--data-directory dir' as an argument"
echo " to GDB."
}
@@ -63,10 +68,10 @@ function print_version() {
echo "GNU gcore (${PKGVERSION}) ${VERSION}"
}
-while getopts vhao:d:-: OPT; do
+while getopts vhao:g:d:-: OPT; do
if [ "$OPT" = "-" ]; then
OPT="${OPTARG%%=*}"
- OPTARG="${OPTARG#'$OPT'}"
+ OPTARG="${OPTARG#"$OPT"}"
OPTARG="${OPTARG#=}"
fi
@@ -82,6 +87,9 @@ while getopts vhao:d:-: OPT; do
o)
prefix=$OPTARG
;;
+ g)
+ gdb_binary="$OPTARG"
+ ;;
d)
data_directory_opt=("--data-directory" "$OPTARG")
;;
@@ -119,13 +127,13 @@ fi
# Attempt to fetch the absolute path to the gcore script that was
# called.
-binary_path=`dirname "$0"`
+binary_path=$(dirname "$0")
-if test "x$binary_path" = x. ; then
+if test "$binary_path" = . ; then
# We got "." back as a path. This means the user executed
# the gcore script locally (i.e. ./gcore) or called the
# script via a shell interpreter (i.e. sh gcore).
- binary_basename=`basename "$0"`
+ binary_basename=$(basename "$0")
# If the gcore script was called like "sh gcore" and the script
# lives in the current directory, "which" will not give us "gcore".
@@ -139,15 +147,21 @@ if test "x$binary_path" = x. ; then
# The gcore script was not found in ".", which means the script
# was called from somewhere else in $PATH by "sh gcore".
# Extract the correct path now.
- binary_path_from_env=`which "$0"`
- binary_path=`dirname "$binary_path_from_env"`
+ binary_path_from_env=$(which "$0")
+ binary_path=$(dirname "$binary_path_from_env")
fi
fi
+if [ -z "$gdb_binary" ]; then
+ gdb_binary="$binary_path/@GDB_TRANSFORM_NAME@"
+fi
+
+gdb_binary_basename=$(basename "$gdb_binary")
+
# Check if the GDB binary is in the expected path. If not, just
# quit with a message.
-if [ ! -f "$binary_path/@GDB_TRANSFORM_NAME@" ]; then
- echo "gcore: GDB binary (${binary_path}/@GDB_TRANSFORM_NAME@) not found"
+if [ ! -f "$gdb_binary" ]; then
+ echo "gcore: GDB binary ($gdb_binary) not found"
exit 1
fi
@@ -159,7 +173,7 @@ for pid in "$@"
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 \
+ "$gdb_binary" </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" \
@@ -169,7 +183,7 @@ do
if [ -r "$prefix.$pid" ] ; then
rc=0
else
- echo "@GCORE_TRANSFORM_NAME@: failed to create $prefix.$pid"
+ echo "$gdb_binary_basename: failed to create $prefix.$pid"
rc=1
break
fi
diff --git a/gdb/gcore.c b/gdb/gcore.c
index d532652..ce5f570 100644
--- a/gdb/gcore.c
+++ b/gdb/gcore.c
@@ -425,13 +425,13 @@ gcore_create_callback (CORE_ADDR vaddr, unsigned long size, int read,
If so, we can avoid copying its contents by clearing SEC_LOAD. */
for (objfile *objfile : current_program_space->objfiles ())
- for (obj_section *objsec : objfile->sections ())
+ for (obj_section &objsec : objfile->sections ())
{
bfd *abfd = objfile->obfd.get ();
- asection *asec = objsec->the_bfd_section;
+ asection *asec = objsec.the_bfd_section;
bfd_vma align = (bfd_vma) 1 << bfd_section_alignment (asec);
- bfd_vma start = objsec->addr () & -align;
- bfd_vma end = (objsec->endaddr () + align - 1) & -align;
+ bfd_vma start = objsec.addr () & -align;
+ bfd_vma end = (objsec.endaddr () + align - 1) & -align;
/* Match if either the entire memory region lies inside the
section (i.e. a mapping covering some pages of a large
@@ -533,9 +533,9 @@ objfile_find_memory_regions (struct target_ops *self,
/* Call callback function for each objfile section. */
for (objfile *objfile : current_program_space->objfiles ())
- for (obj_section *objsec : objfile->sections ())
+ for (obj_section &objsec : objfile->sections ())
{
- asection *isec = objsec->the_bfd_section;
+ asection *isec = objsec.the_bfd_section;
flagword flags = bfd_section_flags (isec);
/* Separate debug info files are irrelevant for gcore. */
@@ -547,7 +547,7 @@ objfile_find_memory_regions (struct target_ops *self,
int size = bfd_section_size (isec);
int ret;
- ret = (*func) (objsec->addr (), size,
+ ret = (*func) (objsec.addr (), size,
1, /* All sections will be readable. */
(flags & SEC_READONLY) == 0, /* Writable. */
(flags & SEC_CODE) != 0, /* Executable. */
diff --git a/gdb/gdb-gdb.gdb.in b/gdb/gdb-gdb.gdb.in
index d5d533a..34ce5f0 100644
--- a/gdb/gdb-gdb.gdb.in
+++ b/gdb/gdb-gdb.gdb.in
@@ -37,3 +37,6 @@ document pdie
Pretty print a DWARF DIE.
Syntax: pdie die [depth]
end
+
+# Trivial and uninteresting functions to skip.
+skip -rfu "^gdb::ref_ptr<.*>::get"
diff --git a/gdb/gdb_wchar.h b/gdb/gdb_wchar.h
index 417d5ba..9db0d5e 100644
--- a/gdb/gdb_wchar.h
+++ b/gdb/gdb_wchar.h
@@ -113,8 +113,8 @@ typedef char gdb_wchar_t;
typedef int gdb_wint_t;
#define gdb_wcslen strlen
-#define gdb_iswprint isprint
-#define gdb_iswxdigit isxdigit
+#define gdb_iswprint c_isprint
+#define gdb_iswxdigit c_isxdigit
#define gdb_btowc /* empty */
#define gdb_WEOF EOF
diff --git a/gdb/gdbarch-gen.c b/gdb/gdbarch-gen.c
index fc570d3..7887b13 100644
--- a/gdb/gdbarch-gen.c
+++ b/gdb/gdbarch-gen.c
@@ -153,7 +153,7 @@ struct gdbarch
gdbarch_set_memtags_ftype *set_memtags = default_set_memtags;
gdbarch_get_memtag_ftype *get_memtag = default_get_memtag;
CORE_ADDR memtag_granule_size = 0;
- gdbarch_software_single_step_ftype *software_single_step = nullptr;
+ gdbarch_get_next_pcs_ftype *get_next_pcs = nullptr;
gdbarch_single_step_through_delay_ftype *single_step_through_delay = nullptr;
gdbarch_print_insn_ftype *print_insn = default_print_insn;
gdbarch_skip_trampoline_code_ftype *skip_trampoline_code = generic_skip_trampoline_code;
@@ -240,7 +240,6 @@ struct gdbarch
gdbarch_gen_return_address_ftype *gen_return_address = default_gen_return_address;
gdbarch_info_proc_ftype *info_proc = nullptr;
gdbarch_core_info_proc_ftype *core_info_proc = nullptr;
- gdbarch_iterate_over_objfiles_in_search_order_ftype *iterate_over_objfiles_in_search_order = default_iterate_over_objfiles_in_search_order;
struct ravenscar_arch_ops * ravenscar_ops = NULL;
gdbarch_insn_is_call_ftype *insn_is_call = default_insn_is_call;
gdbarch_insn_is_ret_ftype *insn_is_ret = default_insn_is_ret;
@@ -262,6 +261,8 @@ struct gdbarch
gdbarch_read_core_file_mappings_ftype *read_core_file_mappings = default_read_core_file_mappings;
gdbarch_use_target_description_from_corefile_notes_ftype *use_target_description_from_corefile_notes = default_use_target_description_from_corefile_notes;
gdbarch_core_parse_exec_context_ftype *core_parse_exec_context = default_core_parse_exec_context;
+ gdbarch_shadow_stack_push_ftype *shadow_stack_push = nullptr;
+ gdbarch_get_shadow_stack_pointer_ftype *get_shadow_stack_pointer = default_get_shadow_stack_pointer;
};
/* Create a new ``struct gdbarch'' based on information provided by
@@ -421,7 +422,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of set_memtags, invalid_p == 0. */
/* Skip verify of get_memtag, invalid_p == 0. */
/* Skip verify of memtag_granule_size, invalid_p == 0. */
- /* Skip verify of software_single_step, has predicate. */
+ /* Skip verify of get_next_pcs, has predicate. */
/* Skip verify of single_step_through_delay, has predicate. */
/* Skip verify of print_insn, invalid_p == 0. */
/* Skip verify of skip_trampoline_code, invalid_p == 0. */
@@ -513,7 +514,6 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of gen_return_address, invalid_p == 0. */
/* Skip verify of info_proc, has predicate. */
/* Skip verify of core_info_proc, has predicate. */
- /* Skip verify of iterate_over_objfiles_in_search_order, invalid_p == 0. */
/* Skip verify of ravenscar_ops, invalid_p == 0. */
/* Skip verify of insn_is_call, invalid_p == 0. */
/* Skip verify of insn_is_ret, invalid_p == 0. */
@@ -535,6 +535,8 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of read_core_file_mappings, invalid_p == 0. */
/* Skip verify of use_target_description_from_corefile_notes, invalid_p == 0. */
/* Skip verify of core_parse_exec_context, invalid_p == 0. */
+ /* Skip verify of shadow_stack_push, has predicate. */
+ /* Skip verify of get_shadow_stack_pointer, invalid_p == 0. */
if (!log.empty ())
internal_error (_("verify_gdbarch: the following are invalid ...%s"),
log.c_str ());
@@ -948,11 +950,11 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
"gdbarch_dump: memtag_granule_size = %s\n",
core_addr_to_string_nz (gdbarch->memtag_granule_size));
gdb_printf (file,
- "gdbarch_dump: gdbarch_software_single_step_p() = %d\n",
- gdbarch_software_single_step_p (gdbarch));
+ "gdbarch_dump: gdbarch_get_next_pcs_p() = %d\n",
+ gdbarch_get_next_pcs_p (gdbarch));
gdb_printf (file,
- "gdbarch_dump: software_single_step = <%s>\n",
- host_address_to_string (gdbarch->software_single_step));
+ "gdbarch_dump: get_next_pcs = <%s>\n",
+ host_address_to_string (gdbarch->get_next_pcs));
gdb_printf (file,
"gdbarch_dump: gdbarch_single_step_through_delay_p() = %d\n",
gdbarch_single_step_through_delay_p (gdbarch));
@@ -1338,9 +1340,6 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
"gdbarch_dump: core_info_proc = <%s>\n",
host_address_to_string (gdbarch->core_info_proc));
gdb_printf (file,
- "gdbarch_dump: iterate_over_objfiles_in_search_order = <%s>\n",
- host_address_to_string (gdbarch->iterate_over_objfiles_in_search_order));
- gdb_printf (file,
"gdbarch_dump: ravenscar_ops = %s\n",
host_address_to_string (gdbarch->ravenscar_ops));
gdb_printf (file,
@@ -1406,6 +1405,15 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
gdb_printf (file,
"gdbarch_dump: core_parse_exec_context = <%s>\n",
host_address_to_string (gdbarch->core_parse_exec_context));
+ gdb_printf (file,
+ "gdbarch_dump: gdbarch_shadow_stack_push_p() = %d\n",
+ gdbarch_shadow_stack_push_p (gdbarch));
+ gdb_printf (file,
+ "gdbarch_dump: shadow_stack_push = <%s>\n",
+ host_address_to_string (gdbarch->shadow_stack_push));
+ gdb_printf (file,
+ "gdbarch_dump: get_shadow_stack_pointer = <%s>\n",
+ host_address_to_string (gdbarch->get_shadow_stack_pointer));
if (gdbarch->dump_tdep != NULL)
gdbarch->dump_tdep (gdbarch, file);
}
@@ -3388,27 +3396,27 @@ set_gdbarch_memtag_granule_size (struct gdbarch *gdbarch,
}
bool
-gdbarch_software_single_step_p (struct gdbarch *gdbarch)
+gdbarch_get_next_pcs_p (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
- return gdbarch->software_single_step != NULL;
+ return gdbarch->get_next_pcs != NULL;
}
std::vector<CORE_ADDR>
-gdbarch_software_single_step (struct gdbarch *gdbarch, struct regcache *regcache)
+gdbarch_get_next_pcs (struct gdbarch *gdbarch, struct regcache *regcache)
{
gdb_assert (gdbarch != NULL);
- gdb_assert (gdbarch->software_single_step != NULL);
+ gdb_assert (gdbarch->get_next_pcs != NULL);
if (gdbarch_debug >= 2)
- gdb_printf (gdb_stdlog, "gdbarch_software_single_step called\n");
- return gdbarch->software_single_step (regcache);
+ gdb_printf (gdb_stdlog, "gdbarch_get_next_pcs called\n");
+ return gdbarch->get_next_pcs (regcache);
}
void
-set_gdbarch_software_single_step (struct gdbarch *gdbarch,
- gdbarch_software_single_step_ftype software_single_step)
+set_gdbarch_get_next_pcs (struct gdbarch *gdbarch,
+ gdbarch_get_next_pcs_ftype get_next_pcs)
{
- gdbarch->software_single_step = software_single_step;
+ gdbarch->get_next_pcs = get_next_pcs;
}
bool
@@ -3470,13 +3478,13 @@ set_gdbarch_skip_trampoline_code (struct gdbarch *gdbarch,
}
solib_ops_up
-gdbarch_make_solib_ops (struct gdbarch *gdbarch)
+gdbarch_make_solib_ops (struct gdbarch *gdbarch, program_space *pspace)
{
gdb_assert (gdbarch != NULL);
gdb_assert (gdbarch->make_solib_ops != NULL);
if (gdbarch_debug >= 2)
gdb_printf (gdb_stdlog, "gdbarch_make_solib_ops called\n");
- return gdbarch->make_solib_ops ();
+ return gdbarch->make_solib_ops (pspace);
}
void
@@ -3962,13 +3970,13 @@ gdbarch_core_xfer_shared_libraries_p (struct gdbarch *gdbarch)
}
ULONGEST
-gdbarch_core_xfer_shared_libraries (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
+gdbarch_core_xfer_shared_libraries (struct gdbarch *gdbarch, struct bfd &cbfd, gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
{
gdb_assert (gdbarch != NULL);
gdb_assert (gdbarch->core_xfer_shared_libraries != NULL);
if (gdbarch_debug >= 2)
gdb_printf (gdb_stdlog, "gdbarch_core_xfer_shared_libraries called\n");
- return gdbarch->core_xfer_shared_libraries (gdbarch, readbuf, offset, len);
+ return gdbarch->core_xfer_shared_libraries (gdbarch, cbfd, readbuf, offset, len);
}
void
@@ -3986,13 +3994,13 @@ gdbarch_core_xfer_shared_libraries_aix_p (struct gdbarch *gdbarch)
}
ULONGEST
-gdbarch_core_xfer_shared_libraries_aix (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
+gdbarch_core_xfer_shared_libraries_aix (struct gdbarch *gdbarch, struct bfd &cbfd, gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
{
gdb_assert (gdbarch != NULL);
gdb_assert (gdbarch->core_xfer_shared_libraries_aix != NULL);
if (gdbarch_debug >= 2)
gdb_printf (gdb_stdlog, "gdbarch_core_xfer_shared_libraries_aix called\n");
- return gdbarch->core_xfer_shared_libraries_aix (gdbarch, readbuf, offset, len);
+ return gdbarch->core_xfer_shared_libraries_aix (gdbarch, cbfd, readbuf, offset, len);
}
void
@@ -4034,13 +4042,13 @@ gdbarch_core_thread_name_p (struct gdbarch *gdbarch)
}
const char *
-gdbarch_core_thread_name (struct gdbarch *gdbarch, struct thread_info *thr)
+gdbarch_core_thread_name (struct gdbarch *gdbarch, struct bfd &cbfd, struct thread_info *thr)
{
gdb_assert (gdbarch != NULL);
gdb_assert (gdbarch->core_thread_name != NULL);
if (gdbarch_debug >= 2)
gdb_printf (gdb_stdlog, "gdbarch_core_thread_name called\n");
- return gdbarch->core_thread_name (gdbarch, thr);
+ return gdbarch->core_thread_name (gdbarch, cbfd, thr);
}
void
@@ -4058,13 +4066,13 @@ gdbarch_core_xfer_siginfo_p (struct gdbarch *gdbarch)
}
LONGEST
-gdbarch_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
+gdbarch_core_xfer_siginfo (struct gdbarch *gdbarch, struct bfd &cbfd, gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
{
gdb_assert (gdbarch != NULL);
gdb_assert (gdbarch->core_xfer_siginfo != NULL);
if (gdbarch_debug >= 2)
gdb_printf (gdb_stdlog, "gdbarch_core_xfer_siginfo called\n");
- return gdbarch->core_xfer_siginfo (gdbarch, readbuf, offset, len);
+ return gdbarch->core_xfer_siginfo (gdbarch, cbfd, readbuf, offset, len);
}
void
@@ -4082,13 +4090,13 @@ gdbarch_core_read_x86_xsave_layout_p (struct gdbarch *gdbarch)
}
bool
-gdbarch_core_read_x86_xsave_layout (struct gdbarch *gdbarch, x86_xsave_layout &xsave_layout)
+gdbarch_core_read_x86_xsave_layout (struct gdbarch *gdbarch, struct bfd &cbfd, x86_xsave_layout &xsave_layout)
{
gdb_assert (gdbarch != NULL);
gdb_assert (gdbarch->core_read_x86_xsave_layout != NULL);
if (gdbarch_debug >= 2)
gdb_printf (gdb_stdlog, "gdbarch_core_read_x86_xsave_layout called\n");
- return gdbarch->core_read_x86_xsave_layout (gdbarch, xsave_layout);
+ return gdbarch->core_read_x86_xsave_layout (gdbarch, cbfd, xsave_layout);
}
void
@@ -5155,13 +5163,13 @@ gdbarch_core_info_proc_p (struct gdbarch *gdbarch)
}
void
-gdbarch_core_info_proc (struct gdbarch *gdbarch, const char *args, enum info_proc_what what)
+gdbarch_core_info_proc (struct gdbarch *gdbarch, struct bfd *cbfd, const char *args, enum info_proc_what what)
{
gdb_assert (gdbarch != NULL);
gdb_assert (gdbarch->core_info_proc != NULL);
if (gdbarch_debug >= 2)
gdb_printf (gdb_stdlog, "gdbarch_core_info_proc called\n");
- gdbarch->core_info_proc (gdbarch, args, what);
+ gdbarch->core_info_proc (gdbarch, cbfd, args, what);
}
void
@@ -5171,23 +5179,6 @@ set_gdbarch_core_info_proc (struct gdbarch *gdbarch,
gdbarch->core_info_proc = core_info_proc;
}
-void
-gdbarch_iterate_over_objfiles_in_search_order (struct gdbarch *gdbarch, iterate_over_objfiles_in_search_order_cb_ftype cb, struct objfile *current_objfile)
-{
- gdb_assert (gdbarch != NULL);
- gdb_assert (gdbarch->iterate_over_objfiles_in_search_order != NULL);
- if (gdbarch_debug >= 2)
- gdb_printf (gdb_stdlog, "gdbarch_iterate_over_objfiles_in_search_order called\n");
- gdbarch->iterate_over_objfiles_in_search_order (gdbarch, cb, current_objfile);
-}
-
-void
-set_gdbarch_iterate_over_objfiles_in_search_order (struct gdbarch *gdbarch,
- gdbarch_iterate_over_objfiles_in_search_order_ftype iterate_over_objfiles_in_search_order)
-{
- gdbarch->iterate_over_objfiles_in_search_order = iterate_over_objfiles_in_search_order;
-}
-
struct ravenscar_arch_ops *
gdbarch_ravenscar_ops (struct gdbarch *gdbarch)
{
@@ -5551,3 +5542,44 @@ set_gdbarch_core_parse_exec_context (struct gdbarch *gdbarch,
{
gdbarch->core_parse_exec_context = core_parse_exec_context;
}
+
+bool
+gdbarch_shadow_stack_push_p (struct gdbarch *gdbarch)
+{
+ gdb_assert (gdbarch != NULL);
+ return gdbarch->shadow_stack_push != NULL;
+}
+
+void
+gdbarch_shadow_stack_push (struct gdbarch *gdbarch, CORE_ADDR new_addr, regcache *regcache)
+{
+ gdb_assert (gdbarch != NULL);
+ gdb_assert (gdbarch->shadow_stack_push != NULL);
+ if (gdbarch_debug >= 2)
+ gdb_printf (gdb_stdlog, "gdbarch_shadow_stack_push called\n");
+ gdbarch->shadow_stack_push (gdbarch, new_addr, regcache);
+}
+
+void
+set_gdbarch_shadow_stack_push (struct gdbarch *gdbarch,
+ gdbarch_shadow_stack_push_ftype shadow_stack_push)
+{
+ gdbarch->shadow_stack_push = shadow_stack_push;
+}
+
+std::optional<CORE_ADDR>
+gdbarch_get_shadow_stack_pointer (struct gdbarch *gdbarch, regcache *regcache, bool &shadow_stack_enabled)
+{
+ gdb_assert (gdbarch != NULL);
+ gdb_assert (gdbarch->get_shadow_stack_pointer != NULL);
+ if (gdbarch_debug >= 2)
+ gdb_printf (gdb_stdlog, "gdbarch_get_shadow_stack_pointer called\n");
+ return gdbarch->get_shadow_stack_pointer (gdbarch, regcache, shadow_stack_enabled);
+}
+
+void
+set_gdbarch_get_shadow_stack_pointer (struct gdbarch *gdbarch,
+ gdbarch_get_shadow_stack_pointer_ftype get_shadow_stack_pointer)
+{
+ gdbarch->get_shadow_stack_pointer = get_shadow_stack_pointer;
+}
diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h
index 281b97b..24fa8ba 100644
--- a/gdb/gdbarch-gen.h
+++ b/gdb/gdbarch-gen.h
@@ -792,11 +792,11 @@ extern void set_gdbarch_memtag_granule_size (struct gdbarch *gdbarch, CORE_ADDR
the condition is true, so that we ensure forward progress when stepping
past a conditional branch to self. */
-extern bool gdbarch_software_single_step_p (struct gdbarch *gdbarch);
+extern bool gdbarch_get_next_pcs_p (struct gdbarch *gdbarch);
-typedef std::vector<CORE_ADDR> (gdbarch_software_single_step_ftype) (struct regcache *regcache);
-extern std::vector<CORE_ADDR> gdbarch_software_single_step (struct gdbarch *gdbarch, struct regcache *regcache);
-extern void set_gdbarch_software_single_step (struct gdbarch *gdbarch, gdbarch_software_single_step_ftype *software_single_step);
+typedef std::vector<CORE_ADDR> (gdbarch_get_next_pcs_ftype) (struct regcache *regcache);
+extern std::vector<CORE_ADDR> gdbarch_get_next_pcs (struct gdbarch *gdbarch, struct regcache *regcache);
+extern void set_gdbarch_get_next_pcs (struct gdbarch *gdbarch, gdbarch_get_next_pcs_ftype *get_next_pcs);
/* Return non-zero if the processor is executing a delay slot and a
further single-step is needed before the instruction finishes. */
@@ -820,8 +820,8 @@ extern void set_gdbarch_skip_trampoline_code (struct gdbarch *gdbarch, gdbarch_s
/* Return a newly-allocated solib_ops object capable of providing the solibs for this architecture. */
-typedef solib_ops_up (gdbarch_make_solib_ops_ftype) ();
-extern solib_ops_up gdbarch_make_solib_ops (struct gdbarch *gdbarch);
+typedef solib_ops_up (gdbarch_make_solib_ops_ftype) (program_space *pspace);
+extern solib_ops_up gdbarch_make_solib_ops (struct gdbarch *gdbarch, program_space *pspace);
extern void set_gdbarch_make_solib_ops (struct gdbarch *gdbarch, gdbarch_make_solib_ops_ftype *make_solib_ops);
/* If in_solib_dynsym_resolve_code() returns true, and SKIP_SOLIB_RESOLVER
@@ -1029,8 +1029,8 @@ extern void set_gdbarch_decode_memtag_section (struct gdbarch *gdbarch, gdbarch_
extern bool gdbarch_core_xfer_shared_libraries_p (struct gdbarch *gdbarch);
-typedef ULONGEST (gdbarch_core_xfer_shared_libraries_ftype) (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len);
-extern ULONGEST gdbarch_core_xfer_shared_libraries (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len);
+typedef ULONGEST (gdbarch_core_xfer_shared_libraries_ftype) (struct gdbarch *gdbarch, struct bfd &cbfd, gdb_byte *readbuf, ULONGEST offset, ULONGEST len);
+extern ULONGEST gdbarch_core_xfer_shared_libraries (struct gdbarch *gdbarch, struct bfd &cbfd, gdb_byte *readbuf, ULONGEST offset, ULONGEST len);
extern void set_gdbarch_core_xfer_shared_libraries (struct gdbarch *gdbarch, gdbarch_core_xfer_shared_libraries_ftype *core_xfer_shared_libraries);
/* Read offset OFFSET of TARGET_OBJECT_LIBRARIES_AIX formatted shared
@@ -1039,8 +1039,8 @@ extern void set_gdbarch_core_xfer_shared_libraries (struct gdbarch *gdbarch, gdb
extern bool gdbarch_core_xfer_shared_libraries_aix_p (struct gdbarch *gdbarch);
-typedef ULONGEST (gdbarch_core_xfer_shared_libraries_aix_ftype) (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len);
-extern ULONGEST gdbarch_core_xfer_shared_libraries_aix (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len);
+typedef ULONGEST (gdbarch_core_xfer_shared_libraries_aix_ftype) (struct gdbarch *gdbarch, struct bfd &cbfd, gdb_byte *readbuf, ULONGEST offset, ULONGEST len);
+extern ULONGEST gdbarch_core_xfer_shared_libraries_aix (struct gdbarch *gdbarch, struct bfd &cbfd, gdb_byte *readbuf, ULONGEST offset, ULONGEST len);
extern void set_gdbarch_core_xfer_shared_libraries_aix (struct gdbarch *gdbarch, gdbarch_core_xfer_shared_libraries_aix_ftype *core_xfer_shared_libraries_aix);
/* How the core target converts a PTID from a core file to a string. */
@@ -1051,31 +1051,31 @@ typedef std::string (gdbarch_core_pid_to_str_ftype) (struct gdbarch *gdbarch, pt
extern std::string gdbarch_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid);
extern void set_gdbarch_core_pid_to_str (struct gdbarch *gdbarch, gdbarch_core_pid_to_str_ftype *core_pid_to_str);
-/* How the core target extracts the name of a thread from a core file. */
+/* How the core target extracts the name of a thread from core file CBFD. */
extern bool gdbarch_core_thread_name_p (struct gdbarch *gdbarch);
-typedef const char * (gdbarch_core_thread_name_ftype) (struct gdbarch *gdbarch, struct thread_info *thr);
-extern const char * gdbarch_core_thread_name (struct gdbarch *gdbarch, struct thread_info *thr);
+typedef const char * (gdbarch_core_thread_name_ftype) (struct gdbarch *gdbarch, struct bfd &cbfd, struct thread_info *thr);
+extern const char * gdbarch_core_thread_name (struct gdbarch *gdbarch, struct bfd &cbfd, struct thread_info *thr);
extern void set_gdbarch_core_thread_name (struct gdbarch *gdbarch, gdbarch_core_thread_name_ftype *core_thread_name);
/* Read offset OFFSET of TARGET_OBJECT_SIGNAL_INFO signal information
- from core file into buffer READBUF with length LEN. Return the number
+ from core file CBFD into buffer READBUF with length LEN. Return the number
of bytes read (zero indicates EOF, a negative value indicates failure). */
extern bool gdbarch_core_xfer_siginfo_p (struct gdbarch *gdbarch);
-typedef LONGEST (gdbarch_core_xfer_siginfo_ftype) (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len);
-extern LONGEST gdbarch_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len);
+typedef LONGEST (gdbarch_core_xfer_siginfo_ftype) (struct gdbarch *gdbarch, struct bfd &cbfd, gdb_byte *readbuf, ULONGEST offset, ULONGEST len);
+extern LONGEST gdbarch_core_xfer_siginfo (struct gdbarch *gdbarch, struct bfd &cbfd, gdb_byte *readbuf, ULONGEST offset, ULONGEST len);
extern void set_gdbarch_core_xfer_siginfo (struct gdbarch *gdbarch, gdbarch_core_xfer_siginfo_ftype *core_xfer_siginfo);
-/* Read x86 XSAVE layout information from core file into XSAVE_LAYOUT.
+/* Read x86 XSAVE layout information from core file CBFD into XSAVE_LAYOUT.
Returns true if the layout was read successfully. */
extern bool gdbarch_core_read_x86_xsave_layout_p (struct gdbarch *gdbarch);
-typedef bool (gdbarch_core_read_x86_xsave_layout_ftype) (struct gdbarch *gdbarch, x86_xsave_layout &xsave_layout);
-extern bool gdbarch_core_read_x86_xsave_layout (struct gdbarch *gdbarch, x86_xsave_layout &xsave_layout);
+typedef bool (gdbarch_core_read_x86_xsave_layout_ftype) (struct gdbarch *gdbarch, struct bfd &cbfd, x86_xsave_layout &xsave_layout);
+extern bool gdbarch_core_read_x86_xsave_layout (struct gdbarch *gdbarch, struct bfd &cbfd, x86_xsave_layout &xsave_layout);
extern void set_gdbarch_core_read_x86_xsave_layout (struct gdbarch *gdbarch, gdbarch_core_read_x86_xsave_layout_ftype *core_read_x86_xsave_layout);
/* BFD target to use when generating a core file. */
@@ -1148,7 +1148,7 @@ extern void set_gdbarch_displaced_step_copy_insn (struct gdbarch *gdbarch, gdbar
the displaced instruction buffer).
The default implementation returns false on all targets that provide a
- gdbarch_software_single_step routine, and true otherwise. */
+ gdbarch_get_next_pcs routine, and true otherwise. */
typedef bool (gdbarch_displaced_step_hw_singlestep_ftype) (struct gdbarch *gdbarch);
extern bool gdbarch_displaced_step_hw_singlestep (struct gdbarch *gdbarch);
@@ -1626,27 +1626,14 @@ extern void set_gdbarch_info_proc (struct gdbarch *gdbarch, gdbarch_info_proc_ft
/* Implement the "info proc" command for core files. Note that there
are two "info_proc"-like methods on gdbarch -- one for core files,
- one for live targets. */
+ one for live targets. CBFD is the core file being read from. */
extern bool gdbarch_core_info_proc_p (struct gdbarch *gdbarch);
-typedef void (gdbarch_core_info_proc_ftype) (struct gdbarch *gdbarch, const char *args, enum info_proc_what what);
-extern void gdbarch_core_info_proc (struct gdbarch *gdbarch, const char *args, enum info_proc_what what);
+typedef void (gdbarch_core_info_proc_ftype) (struct gdbarch *gdbarch, struct bfd *cbfd, const char *args, enum info_proc_what what);
+extern void gdbarch_core_info_proc (struct gdbarch *gdbarch, struct bfd *cbfd, const char *args, enum info_proc_what what);
extern void set_gdbarch_core_info_proc (struct gdbarch *gdbarch, gdbarch_core_info_proc_ftype *core_info_proc);
-/* Iterate over all objfiles in the order that makes the most sense
- for the architecture to make global symbol searches.
-
- CB is a callback function passed an objfile to be searched. The iteration stops
- if this function returns nonzero.
-
- If not NULL, CURRENT_OBJFILE corresponds to the objfile being
- inspected when the symbol search was requested. */
-
-typedef void (gdbarch_iterate_over_objfiles_in_search_order_ftype) (struct gdbarch *gdbarch, iterate_over_objfiles_in_search_order_cb_ftype cb, struct objfile *current_objfile);
-extern void gdbarch_iterate_over_objfiles_in_search_order (struct gdbarch *gdbarch, iterate_over_objfiles_in_search_order_cb_ftype cb, struct objfile *current_objfile);
-extern void set_gdbarch_iterate_over_objfiles_in_search_order (struct gdbarch *gdbarch, gdbarch_iterate_over_objfiles_in_search_order_ftype *iterate_over_objfiles_in_search_order);
-
/* Ravenscar arch-dependent ops. */
extern struct ravenscar_arch_ops * gdbarch_ravenscar_ops (struct gdbarch *gdbarch);
@@ -1802,3 +1789,31 @@ extern void set_gdbarch_use_target_description_from_corefile_notes (struct gdbar
typedef core_file_exec_context (gdbarch_core_parse_exec_context_ftype) (struct gdbarch *gdbarch, bfd *cbfd);
extern core_file_exec_context gdbarch_core_parse_exec_context (struct gdbarch *gdbarch, bfd *cbfd);
extern void set_gdbarch_core_parse_exec_context (struct gdbarch *gdbarch, gdbarch_core_parse_exec_context_ftype *core_parse_exec_context);
+
+/* Some targets support special hardware-assisted control-flow protection
+ technologies. For example, the Intel Control-Flow Enforcement Technology
+ (Intel CET) on x86 provides a shadow stack and indirect branch tracking.
+ To enable shadow stack support for inferior calls the shadow_stack_push
+ gdbarch hook has to be provided. The get_shadow_stack_pointer gdbarch
+ hook has to be provided to enable displaced stepping.
+
+ Push NEW_ADDR to the shadow stack and update the shadow stack pointer. */
+
+extern bool gdbarch_shadow_stack_push_p (struct gdbarch *gdbarch);
+
+typedef void (gdbarch_shadow_stack_push_ftype) (struct gdbarch *gdbarch, CORE_ADDR new_addr, regcache *regcache);
+extern void gdbarch_shadow_stack_push (struct gdbarch *gdbarch, CORE_ADDR new_addr, regcache *regcache);
+extern void set_gdbarch_shadow_stack_push (struct gdbarch *gdbarch, gdbarch_shadow_stack_push_ftype *shadow_stack_push);
+
+/* If possible, return the shadow stack pointer. If the shadow stack
+ feature is enabled then set SHADOW_STACK_ENABLED to true, otherwise
+ set SHADOW_STACK_ENABLED to false. This hook has to be provided to enable
+ displaced stepping for shadow stack enabled programs.
+ On some architectures, the shadow stack pointer is available even if the
+ feature is disabled. So dependent on the target, an implementation of
+ this function may return a valid shadow stack pointer, but set
+ SHADOW_STACK_ENABLED to false. */
+
+typedef std::optional<CORE_ADDR> (gdbarch_get_shadow_stack_pointer_ftype) (struct gdbarch *gdbarch, regcache *regcache, bool &shadow_stack_enabled);
+extern std::optional<CORE_ADDR> gdbarch_get_shadow_stack_pointer (struct gdbarch *gdbarch, regcache *regcache, bool &shadow_stack_enabled);
+extern void set_gdbarch_get_shadow_stack_pointer (struct gdbarch *gdbarch, gdbarch_get_shadow_stack_pointer_ftype *get_shadow_stack_pointer);
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 6accbd2..2049761 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -75,12 +75,6 @@ struct gdbarch_tdep_base
using gdbarch_tdep_up = std::unique_ptr<gdbarch_tdep_base>;
-/* Callback type for the 'iterate_over_objfiles_in_search_order'
- gdbarch method. */
-
-using iterate_over_objfiles_in_search_order_cb_ftype
- = gdb::function_view<bool(objfile *)>;
-
/* Callback type for regset section iterators. The callback usually
invokes the REGSET's supply or collect method, to which it must
pass a buffer - for collects this buffer will need to be created using
diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py
index 91c867e..3820ae3 100644
--- a/gdb/gdbarch_components.py
+++ b/gdb/gdbarch_components.py
@@ -1395,7 +1395,7 @@ the condition is true, so that we ensure forward progress when stepping
past a conditional branch to self.
""",
type="std::vector<CORE_ADDR>",
- name="software_single_step",
+ name="get_next_pcs",
params=[("struct regcache *", "regcache")],
predicate=True,
)
@@ -1435,7 +1435,7 @@ Function(
comment="Return a newly-allocated solib_ops object capable of providing the solibs for this architecture.",
type="solib_ops_up",
name="make_solib_ops",
- params=[],
+ params=[("program_space *", "pspace")],
predefault="make_target_solib_ops",
invalid=False,
)
@@ -1738,7 +1738,12 @@ failed, otherwise, return the red length of READBUF.
""",
type="ULONGEST",
name="core_xfer_shared_libraries",
- params=[("gdb_byte *", "readbuf"), ("ULONGEST", "offset"), ("ULONGEST", "len")],
+ params=[
+ ("struct bfd &", "cbfd"),
+ ("gdb_byte *", "readbuf"),
+ ("ULONGEST", "offset"),
+ ("ULONGEST", "len"),
+ ],
predicate=True,
)
@@ -1750,7 +1755,12 @@ Return the number of bytes read (zero indicates failure).
""",
type="ULONGEST",
name="core_xfer_shared_libraries_aix",
- params=[("gdb_byte *", "readbuf"), ("ULONGEST", "offset"), ("ULONGEST", "len")],
+ params=[
+ ("struct bfd &", "cbfd"),
+ ("gdb_byte *", "readbuf"),
+ ("ULONGEST", "offset"),
+ ("ULONGEST", "len"),
+ ],
predicate=True,
)
@@ -1766,34 +1776,39 @@ How the core target converts a PTID from a core file to a string.
Method(
comment="""
-How the core target extracts the name of a thread from a core file.
+How the core target extracts the name of a thread from core file CBFD.
""",
type="const char *",
name="core_thread_name",
- params=[("struct thread_info *", "thr")],
+ params=[("struct bfd &", "cbfd"), ("struct thread_info *", "thr")],
predicate=True,
)
Method(
comment="""
Read offset OFFSET of TARGET_OBJECT_SIGNAL_INFO signal information
-from core file into buffer READBUF with length LEN. Return the number
+from core file CBFD into buffer READBUF with length LEN. Return the number
of bytes read (zero indicates EOF, a negative value indicates failure).
""",
type="LONGEST",
name="core_xfer_siginfo",
- params=[("gdb_byte *", "readbuf"), ("ULONGEST", "offset"), ("ULONGEST", "len")],
+ params=[
+ ("struct bfd &", "cbfd"),
+ ("gdb_byte *", "readbuf"),
+ ("ULONGEST", "offset"),
+ ("ULONGEST", "len"),
+ ],
predicate=True,
)
Method(
comment="""
-Read x86 XSAVE layout information from core file into XSAVE_LAYOUT.
+Read x86 XSAVE layout information from core file CBFD into XSAVE_LAYOUT.
Returns true if the layout was read successfully.
""",
type="bool",
name="core_read_x86_xsave_layout",
- params=[("x86_xsave_layout &", "xsave_layout")],
+ params=[("struct bfd &", "cbfd"), ("x86_xsave_layout &", "xsave_layout")],
predicate=True,
)
@@ -1891,7 +1906,7 @@ receive control again (e.g. by placing a software breakpoint instruction into
the displaced instruction buffer).
The default implementation returns false on all targets that provide a
-gdbarch_software_single_step routine, and true otherwise.
+gdbarch_get_next_pcs routine, and true otherwise.
""",
type="bool",
name="displaced_step_hw_singlestep",
@@ -2554,33 +2569,16 @@ Method(
comment="""
Implement the "info proc" command for core files. Note that there
are two "info_proc"-like methods on gdbarch -- one for core files,
-one for live targets.
+one for live targets. CBFD is the core file being read from.
""",
type="void",
name="core_info_proc",
- params=[("const char *", "args"), ("enum info_proc_what", "what")],
- predicate=True,
-)
-
-Method(
- comment="""
-Iterate over all objfiles in the order that makes the most sense
-for the architecture to make global symbol searches.
-
-CB is a callback function passed an objfile to be searched. The iteration stops
-if this function returns nonzero.
-
-If not NULL, CURRENT_OBJFILE corresponds to the objfile being
-inspected when the symbol search was requested.
-""",
- type="void",
- name="iterate_over_objfiles_in_search_order",
params=[
- ("iterate_over_objfiles_in_search_order_cb_ftype", "cb"),
- ("struct objfile *", "current_objfile"),
+ ("struct bfd *", "cbfd"),
+ ("const char *", "args"),
+ ("enum info_proc_what", "what"),
],
- predefault="default_iterate_over_objfiles_in_search_order",
- invalid=False,
+ predicate=True,
)
Value(
@@ -2848,3 +2846,38 @@ which all assume current_inferior() is the one to read from.
predefault="default_core_parse_exec_context",
invalid=False,
)
+
+Method(
+ comment="""
+Some targets support special hardware-assisted control-flow protection
+technologies. For example, the Intel Control-Flow Enforcement Technology
+(Intel CET) on x86 provides a shadow stack and indirect branch tracking.
+To enable shadow stack support for inferior calls the shadow_stack_push
+gdbarch hook has to be provided. The get_shadow_stack_pointer gdbarch
+hook has to be provided to enable displaced stepping.
+
+Push NEW_ADDR to the shadow stack and update the shadow stack pointer.
+""",
+ type="void",
+ name="shadow_stack_push",
+ params=[("CORE_ADDR", "new_addr"), ("regcache *", "regcache")],
+ predicate=True,
+)
+
+Method(
+ comment="""
+If possible, return the shadow stack pointer. If the shadow stack
+feature is enabled then set SHADOW_STACK_ENABLED to true, otherwise
+set SHADOW_STACK_ENABLED to false. This hook has to be provided to enable
+displaced stepping for shadow stack enabled programs.
+On some architectures, the shadow stack pointer is available even if the
+feature is disabled. So dependent on the target, an implementation of
+this function may return a valid shadow stack pointer, but set
+SHADOW_STACK_ENABLED to false.
+""",
+ type="std::optional<CORE_ADDR>",
+ name="get_shadow_stack_pointer",
+ params=[("regcache *", "regcache"), ("bool &", "shadow_stack_enabled")],
+ predefault="default_get_shadow_stack_pointer",
+ invalid=False,
+)
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 14a903b..24e6d0b 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1080,10 +1080,10 @@ get_discrete_low_bound (struct type *type)
entries. */
LONGEST low = type->field (0).loc_enumval ();
- for (int i = 0; i < type->num_fields (); i++)
+ for (const auto &field : type->fields ())
{
- if (type->field (i).loc_enumval () < low)
- low = type->field (i).loc_enumval ();
+ if (field.loc_enumval () < low)
+ low = field.loc_enumval ();
}
return low;
@@ -1147,10 +1147,10 @@ get_discrete_high_bound (struct type *type)
entries. */
LONGEST high = type->field (0).loc_enumval ();
- for (int i = 0; i < type->num_fields (); i++)
+ for (const auto &field : type->fields ())
{
- if (type->field (i).loc_enumval () > high)
- high = type->field (i).loc_enumval ();
+ if (field.loc_enumval () > high)
+ high = field.loc_enumval ();
}
return high;
@@ -1602,15 +1602,15 @@ smash_to_methodptr_type (struct type *type, struct type *to_type)
void
smash_to_method_type (struct type *type, struct type *self_type,
- struct type *to_type, struct field *args,
- int nargs, int varargs)
+ struct type *to_type, gdb::array_view<struct field> args,
+ int varargs)
{
smash_type (type);
type->set_code (TYPE_CODE_METHOD);
type->set_target_type (to_type);
set_type_self_type (type, self_type);
- type->set_fields (args);
- type->set_num_fields (nargs);
+ type->set_fields (args.data ());
+ type->set_num_fields (args.size ());
if (varargs)
type->set_has_varargs (true);
@@ -2494,23 +2494,22 @@ resolve_dynamic_union (struct type *type,
const frame_info_ptr &frame)
{
struct type *resolved_type;
- int i;
unsigned int max_len = 0;
gdb_assert (type->code () == TYPE_CODE_UNION);
resolved_type = copy_type (type);
resolved_type->copy_fields (type);
- for (i = 0; i < resolved_type->num_fields (); ++i)
+ for (auto &field : resolved_type->fields ())
{
struct type *t;
- if (type->field (i).is_static ())
+ if (field.is_static ())
continue;
- t = resolve_dynamic_type_internal (resolved_type->field (i).type (),
- addr_stack, frame, false);
- resolved_type->field (i).set_type (t);
+ t = resolve_dynamic_type_internal (field.type (), addr_stack,
+ frame, false);
+ field.set_type (t);
struct type *real_type = check_typedef (t);
if (real_type->length () > max_len)
@@ -2791,7 +2790,6 @@ resolve_dynamic_struct (struct type *type,
const frame_info_ptr &frame)
{
struct type *resolved_type;
- int i;
unsigned resolved_type_bit_length = 0;
gdb_assert (type->code () == TYPE_CODE_STRUCT);
@@ -2812,22 +2810,21 @@ resolve_dynamic_struct (struct type *type,
resolved_type->copy_fields (type);
}
- for (i = 0; i < resolved_type->num_fields (); ++i)
+ for (auto &field : resolved_type->fields ())
{
unsigned new_bit_length;
- if (resolved_type->field (i).is_static ())
+ if (field.is_static ())
continue;
- resolve_dynamic_field (resolved_type->field (i), addr_stack, frame);
+ resolve_dynamic_field (field, addr_stack, frame);
- new_bit_length = resolved_type->field (i).loc_bitpos ();
- if (resolved_type->field (i).bitsize () != 0)
- new_bit_length += resolved_type->field (i).bitsize ();
+ new_bit_length = field.loc_bitpos ();
+ if (field.bitsize () != 0)
+ new_bit_length += field.bitsize ();
else
{
- struct type *real_type
- = check_typedef (resolved_type->field (i).type ());
+ struct type *real_type = check_typedef (field.type ());
new_bit_length += (real_type->length () * TARGET_CHAR_BIT);
}
@@ -3394,7 +3391,8 @@ check_stub_method (struct type *type, int method_id, int signature_id)
/* MTYPE may currently be a function (TYPE_CODE_FUNC).
We want a method (TYPE_CODE_METHOD). */
smash_to_method_type (mtype, type, mtype->target_type (),
- argtypes, argcount, p[-2] == '.');
+ gdb::make_array_view (argtypes, argcount),
+ p[-2] == '.');
mtype->set_is_stub (false);
TYPE_FN_FIELD_STUB (f, signature_id) = 0;
}
@@ -3698,12 +3696,12 @@ type_align (struct type *type)
case TYPE_CODE_UNION:
{
int number_of_non_static_fields = 0;
- for (unsigned i = 0; i < type->num_fields (); ++i)
+ for (const auto &field : type->fields ())
{
- if (!type->field (i).is_static ())
+ if (!field.is_static ())
{
number_of_non_static_fields++;
- ULONGEST f_align = type_align (type->field (i).type ());
+ ULONGEST f_align = type_align (field.type ());
if (f_align == 0)
{
/* Don't pretend we know something we don't. */
@@ -5038,19 +5036,14 @@ rank_one_type (struct type *parm, struct type *arg, struct value *value)
situation. */
static void
-print_args (struct field *args, int nargs, int spaces)
+print_args (gdb::array_view<struct field> args, int spaces)
{
- if (args != NULL)
+ for (int i = 0; i < args.size (); i++)
{
- int i;
-
- for (i = 0; i < nargs; i++)
- {
- gdb_printf
- ("%*s[%d] name '%s'\n", spaces, "", i,
- args[i].name () != NULL ? args[i].name () : "<NULL>");
- recursive_dump_type (args[i].type (), spaces + 2);
- }
+ gdb_printf
+ ("%*s[%d] name '%s'\n", spaces, "", i,
+ args[i].name () != NULL ? args[i].name () : "<NULL>");
+ recursive_dump_type (args[i].type (), spaces + 2);
}
}
@@ -5091,9 +5084,8 @@ dump_fn_fieldlists (struct type *type, int spaces)
gdb_printf
("%*sargs %s\n", spaces + 8, "",
- host_address_to_string (TYPE_FN_FIELD_ARGS (f, overload_idx)));
+ host_address_to_string (TYPE_FN_FIELD_ARGS (f, overload_idx).data ()));
print_args (TYPE_FN_FIELD_ARGS (f, overload_idx),
- TYPE_FN_FIELD_TYPE (f, overload_idx)->num_fields (),
spaces + 8 + 2);
gdb_printf
("%*sfcontext %s\n", spaces + 8, "",
@@ -5375,7 +5367,7 @@ recursive_dump_type (struct type *type, int spaces)
}
gdb_printf ("\n");
}
- gdb_printf ("%s\n", host_address_to_string (type->fields ()));
+ gdb_printf ("%s\n", host_address_to_string (type->fields ().data ()));
for (idx = 0; idx < type->num_fields (); idx++)
{
field &fld = type->field (idx);
@@ -5756,7 +5748,7 @@ append_composite_type_field_raw (struct type *t, const char *name,
struct field *f;
t->set_num_fields (t->num_fields () + 1);
- t->set_fields (XRESIZEVEC (struct field, t->fields (),
+ t->set_fields (XRESIZEVEC (struct field, t->fields ().data (),
t->num_fields ()));
f = &t->field (t->num_fields () - 1);
memset (f, 0, sizeof f[0]);
@@ -5907,7 +5899,7 @@ type::alloc_fields (unsigned int nfields, bool init)
return;
}
- size_t size = nfields * sizeof (*this->fields ());
+ size_t size = nfields * sizeof (struct field);
struct field *fields
= (struct field *) (init
? TYPE_ZALLOC (this, size)
@@ -5926,8 +5918,8 @@ type::copy_fields (struct type *src)
if (nfields == 0)
return;
- size_t size = nfields * sizeof (*this->fields ());
- memcpy (this->fields (), src->fields (), size);
+ size_t size = nfields * sizeof (struct field);
+ memcpy (this->fields ().data (), src->fields ().data (), size);
}
/* See gdbtypes.h. */
@@ -5940,8 +5932,8 @@ type::copy_fields (std::vector<struct field> &src)
if (nfields == 0)
return;
- size_t size = nfields * sizeof (*this->fields ());
- memcpy (this->fields (), src.data (), size);
+ size_t size = nfields * sizeof (struct field);
+ memcpy (this->fields ().data (), src.data (), size);
}
/* See gdbtypes.h. */
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 9e2efe9..75c77b3 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1080,12 +1080,6 @@ struct type
this->main_type->m_nfields = num_fields;
}
- /* Get the fields array of this type. */
- struct field *fields () const
- {
- return this->main_type->flds_bnds.fields;
- }
-
/* Get the field at index IDX. */
struct field &field (int idx) const
{
@@ -1093,6 +1087,13 @@ struct type
return this->fields ()[idx];
}
+ /* Return an array view of the fields. */
+ gdb::array_view<struct field> fields () const
+ {
+ return gdb::make_array_view (this->main_type->flds_bnds.fields,
+ num_fields ());
+ }
+
/* Set the fields array of this type. */
void set_fields (struct field *fields)
{
@@ -2470,8 +2471,9 @@ extern struct type *lookup_memberptr_type (struct type *, struct type *);
extern struct type *lookup_methodptr_type (struct type *);
extern void smash_to_method_type (struct type *type, struct type *self_type,
- struct type *to_type, struct field *args,
- int nargs, int varargs);
+ struct type *to_type,
+ gdb::array_view<struct field> args,
+ int varargs);
extern void smash_to_memberptr_type (struct type *, struct type *,
struct type *);
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index dd639fe..33391ba 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -50,7 +50,6 @@ extern "C"
}
-#include <ctype.h>
#include <setjmp.h>
#include <signal.h>
#include <sys/ptrace.h>
@@ -2926,7 +2925,7 @@ set_sig_thread_cmd (const char *args, int from_tty)
{
struct inf *inf = cur_inf ();
- if (!args || (!isdigit (*args) && strcmp (args, "none") != 0))
+ if (!args || (!c_isdigit (*args) && strcmp (args, "none") != 0))
error (_("Illegal argument to \"set signal-thread\" command.\n"
"Should be a thread ID, or \"none\"."));
diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c
index 9246788..1fbc41d 100644
--- a/gdb/gnu-v2-abi.c
+++ b/gdb/gnu-v2-abi.c
@@ -26,7 +26,6 @@
#include "gdb-demangle.h"
#include "cp-abi.h"
#include "cp-support.h"
-#include <ctype.h>
static cp_abi_ops gnu_v2_abi_ops;
@@ -46,7 +45,7 @@ static enum ctor_kinds
gnuv2_is_constructor_name (const char *name)
{
if ((name[0] == '_' && name[1] == '_'
- && (isdigit (name[2]) || strchr ("Qt", name[2])))
+ && (c_isdigit (name[2]) || strchr ("Qt", name[2])))
|| startswith (name, "__ct__"))
return complete_object_ctor;
else
diff --git a/gdb/go-exp.y b/gdb/go-exp.y
index 8823503..5da8cef 100644
--- a/gdb/go-exp.y
+++ b/gdb/go-exp.y
@@ -51,7 +51,6 @@
%{
-#include <ctype.h>
#include "expression.h"
#include "value.h"
#include "parser-defs.h"
@@ -663,13 +662,13 @@ parse_number (struct parser_state *par_state,
/* Handle suffixes: 'f' for float32, 'l' for long double.
FIXME: This appears to be an extension -- do we want this? */
- if (len >= 1 && tolower (p[len - 1]) == 'f')
+ if (len >= 1 && c_tolower (p[len - 1]) == 'f')
{
putithere->typed_val_float.type
= builtin_go_types->builtin_float32;
len--;
}
- else if (len >= 1 && tolower (p[len - 1]) == 'l')
+ else if (len >= 1 && c_tolower (p[len - 1]) == 'l')
{
putithere->typed_val_float.type
= parse_type (par_state)->builtin_long_double;
@@ -1113,9 +1112,9 @@ lex_one_token (struct parser_state *par_state)
const char *p = &tokstart[1];
size_t len = strlen ("entry");
- while (isspace (*p))
+ while (c_isspace (*p))
p++;
- if (strncmp (p, "entry", len) == 0 && !isalnum (p[len])
+ if (strncmp (p, "entry", len) == 0 && !c_isalnum (p[len])
&& p[len] != '_')
{
par_state->lexptr = &p[len];
@@ -1290,7 +1289,7 @@ package_name_p (const char *name, const struct block *block)
&is_a_field_of_this).symbol;
if (sym
- && sym->aclass () == LOC_TYPEDEF
+ && sym->loc_class () == LOC_TYPEDEF
&& sym->type ()->code () == TYPE_CODE_MODULE)
return 1;
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index bad2ccf..23ffedb 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -41,7 +41,6 @@
#include "parser-defs.h"
#include "gdbarch.h"
-#include <ctype.h>
/* The main function in the main package. */
static const char GO_MAIN_MAIN[] = "main.main";
@@ -292,7 +291,7 @@ unpack_mangled_go_symbol (const char *mangled_name,
while (p > buf)
{
int current = *(const unsigned char *) --p;
- int current_is_digit = isdigit (current);
+ int current_is_digit = c_isdigit (current);
if (saw_digit)
{
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index 4d8e6c9..ab13b57 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -103,7 +103,6 @@
#include "cli/cli-utils.h"
#include "inf-child.h"
-#include <ctype.h>
#include <unistd.h>
#include <sys/utsname.h>
#include <io.h>
diff --git a/gdb/gstack-1.in b/gdb/gstack-1.in
index 25339d9..ac5e8d4 100755
--- a/gdb/gstack-1.in
+++ b/gdb/gstack-1.in
@@ -64,7 +64,7 @@ function print_version() {
while getopts hv-: OPT; do
if [ "$OPT" = "-" ]; then
OPT="${OPTARG%%=*}"
- OPTARG="${OPTARG#'$OPT'}"
+ OPTARG="${OPTARG#"$OPT"}"
OPTARG="${OPTARG#=}"
fi
@@ -132,6 +132,7 @@ EOF
)
# Run GDB and remove some unwanted noise.
+# shellcheck disable=SC2086
"$GDB" --quiet -nx $GDBARGS <<EOF |
set width 0
set height 0
diff --git a/gdb/guile/scm-cmd.c b/gdb/guile/scm-cmd.c
index 19fb742..ef4c9d6 100644
--- a/gdb/guile/scm-cmd.c
+++ b/gdb/guile/scm-cmd.c
@@ -20,7 +20,6 @@
/* See README file in this directory for implementation notes, coding
conventions, et.al. */
-#include <ctype.h>
#include "charset.h"
#include "cli/cli-cmds.h"
#include "cli/cli-decode.h"
diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c
index 8c2ae24..1d3fb29 100644
--- a/gdb/guile/scm-symbol.c
+++ b/gdb/guile/scm-symbol.c
@@ -405,7 +405,7 @@ gdbscm_symbol_addr_class (SCM self)
= syscm_get_valid_symbol_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
const struct symbol *symbol = s_smob->symbol;
- return scm_from_int (symbol->aclass ());
+ return scm_from_int (symbol->loc_class ());
}
/* (symbol-argument? <gdb:symbol>) -> boolean */
@@ -428,11 +428,9 @@ gdbscm_symbol_constant_p (SCM self)
symbol_smob *s_smob
= syscm_get_valid_symbol_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
const struct symbol *symbol = s_smob->symbol;
- enum address_class theclass;
+ location_class loc_class = symbol->loc_class ();
- theclass = symbol->aclass ();
-
- return scm_from_bool (theclass == LOC_CONST || theclass == LOC_CONST_BYTES);
+ return scm_from_bool (loc_class == LOC_CONST || loc_class == LOC_CONST_BYTES);
}
/* (symbol-function? <gdb:symbol>) -> boolean */
@@ -443,11 +441,9 @@ gdbscm_symbol_function_p (SCM self)
symbol_smob *s_smob
= syscm_get_valid_symbol_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
const struct symbol *symbol = s_smob->symbol;
- enum address_class theclass;
-
- theclass = symbol->aclass ();
+ location_class loc_class = symbol->loc_class ();
- return scm_from_bool (theclass == LOC_BLOCK);
+ return scm_from_bool (loc_class == LOC_BLOCK);
}
/* (symbol-variable? <gdb:symbol>) -> boolean */
@@ -458,14 +454,12 @@ gdbscm_symbol_variable_p (SCM self)
symbol_smob *s_smob
= syscm_get_valid_symbol_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
const struct symbol *symbol = s_smob->symbol;
- enum address_class theclass;
-
- theclass = symbol->aclass ();
+ location_class loc_class = symbol->loc_class ();
return scm_from_bool (!symbol->is_argument ()
- && (theclass == LOC_LOCAL || theclass == LOC_REGISTER
- || theclass == LOC_STATIC || theclass == LOC_COMPUTED
- || theclass == LOC_OPTIMIZED_OUT));
+ && (loc_class == LOC_LOCAL || loc_class == LOC_REGISTER
+ || loc_class == LOC_STATIC || loc_class == LOC_COMPUTED
+ || loc_class == LOC_OPTIMIZED_OUT));
}
/* (symbol-needs-frame? <gdb:symbol>) -> boolean
@@ -526,7 +520,7 @@ gdbscm_symbol_value (SCM self, SCM rest)
if (!gdbscm_is_false (frame_scm))
f_smob = frscm_get_frame_smob_arg_unsafe (frame_scm, frame_pos, FUNC_NAME);
- if (symbol->aclass () == LOC_TYPEDEF)
+ if (symbol->loc_class () == LOC_TYPEDEF)
{
gdbscm_out_of_range_error (FUNC_NAME, SCM_ARG1, self,
_("cannot get the value of a typedef"));
diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c
index 5114579..13676ce 100644
--- a/gdb/guile/scm-type.c
+++ b/gdb/guile/scm-type.c
@@ -510,7 +510,7 @@ tyscm_field_smob_to_field (field_smob *f_smob)
struct type *type = tyscm_field_smob_containing_type (f_smob);
/* This should be non-NULL by construction. */
- gdb_assert (type->fields () != NULL);
+ gdb_assert (type->fields ().data () != nullptr);
return &type->field (f_smob->field_num);
}
diff --git a/gdb/hppa-bsd-tdep.c b/gdb/hppa-bsd-tdep.c
index 715e794..b9cd61e 100644
--- a/gdb/hppa-bsd-tdep.c
+++ b/gdb/hppa-bsd-tdep.c
@@ -54,12 +54,12 @@ hppabsd_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
faddr_sec = find_pc_section (faddr);
if (faddr_sec != NULL)
{
- for (struct obj_section *sec : faddr_sec->objfile->sections ())
+ for (struct obj_section &sec : faddr_sec->objfile->sections ())
{
- if (strcmp (sec->the_bfd_section->name, ".dynamic") == 0)
+ if (strcmp (sec.the_bfd_section->name, ".dynamic") == 0)
{
- CORE_ADDR addr = sec->addr ();
- CORE_ADDR endaddr = sec->endaddr ();
+ CORE_ADDR addr = sec.addr ();
+ CORE_ADDR endaddr = sec.endaddr ();
while (addr < endaddr)
{
@@ -81,7 +81,7 @@ hppabsd_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
DT_PLTGOT, so we have to do it ourselves. */
pltgot = extract_unsigned_integer (buf, sizeof buf,
byte_order);
- pltgot += sec->objfile->text_section_offset ();
+ pltgot += sec.objfile->text_section_offset ();
return pltgot;
}
diff --git a/gdb/hppa-linux-tdep.c b/gdb/hppa-linux-tdep.c
index 2eb8d46..d0bb562 100644
--- a/gdb/hppa-linux-tdep.c
+++ b/gdb/hppa-linux-tdep.c
@@ -362,14 +362,14 @@ hppa_linux_find_global_pointer (struct gdbarch *gdbarch,
faddr_sect = find_pc_section (faddr);
if (faddr_sect != NULL)
{
- for (obj_section *osect : faddr_sect->objfile->sections ())
+ for (obj_section &osect : faddr_sect->objfile->sections ())
{
- if (strcmp (osect->the_bfd_section->name, ".dynamic") == 0)
+ if (strcmp (osect.the_bfd_section->name, ".dynamic") == 0)
{
CORE_ADDR addr, endaddr;
- addr = osect->addr ();
- endaddr = osect->endaddr ();
+ addr = osect.addr ();
+ endaddr = osect.endaddr ();
while (addr < endaddr)
{
diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index 61e6cb2..6f0cebe 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -920,12 +920,12 @@ hppa64_convert_code_addr_to_fptr (struct gdbarch *gdbarch, CORE_ADDR code)
if (!(sec->the_bfd_section->flags & SEC_CODE))
return code;
- for (obj_section *opd : sec->objfile->sections ())
+ for (obj_section &opd : sec->objfile->sections ())
{
- if (strcmp (opd->the_bfd_section->name, ".opd") == 0)
+ if (strcmp (opd.the_bfd_section->name, ".opd") == 0)
{
- for (CORE_ADDR addr = opd->addr ();
- addr < opd->endaddr ();
+ for (CORE_ADDR addr = opd.addr ();
+ addr < opd.endaddr ();
addr += 2 * 8)
{
ULONGEST opdaddr;
diff --git a/gdb/i386-fbsd-tdep.c b/gdb/i386-fbsd-tdep.c
index 827d53c..a32880e 100644
--- a/gdb/i386-fbsd-tdep.c
+++ b/gdb/i386-fbsd-tdep.c
@@ -274,11 +274,10 @@ i386_fbsd_core_read_xsave_info (bfd *abfd, x86_xsave_layout &layout)
/* See i386-fbsd-tdep.h. */
bool
-i386_fbsd_core_read_x86_xsave_layout (struct gdbarch *gdbarch,
+i386_fbsd_core_read_x86_xsave_layout (struct gdbarch *gdbarch, bfd &cbfd,
x86_xsave_layout &layout)
{
- return i386_fbsd_core_read_xsave_info (current_program_space->core_bfd (),
- layout) != 0;
+ return i386_fbsd_core_read_xsave_info (&cbfd, layout) != 0;
}
/* Implement the core_read_description gdbarch method. */
diff --git a/gdb/i386-fbsd-tdep.h b/gdb/i386-fbsd-tdep.h
index 70ad32f..acc5776 100644
--- a/gdb/i386-fbsd-tdep.h
+++ b/gdb/i386-fbsd-tdep.h
@@ -32,8 +32,9 @@
uint64_t i386_fbsd_core_read_xsave_info (bfd *abfd, x86_xsave_layout &layout);
/* Implement the core_read_x86_xsave_layout gdbarch method. */
-bool i386_fbsd_core_read_x86_xsave_layout (struct gdbarch *gdbarch,
- x86_xsave_layout &layout);
+extern bool i386_fbsd_core_read_x86_xsave_layout (struct gdbarch *gdbarch,
+ bfd &cbfd,
+ x86_xsave_layout &layout);
/* The format of the XSAVE extended area is determined by hardware.
Cores store the XSAVE extended area in a NT_X86_XSTATE note that
diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
index efbde6a..34e1391 100644
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -1044,6 +1044,8 @@ int i386_linux_gregset_reg_offset[] =
-1, -1, -1, -1, -1, -1, -1, -1, /* k0 ... k7 (AVX512) */
-1, -1, -1, -1, -1, -1, -1, -1, /* zmm0 ... zmm7 (AVX512) */
-1, /* PKRU register */
+ -1, /* SSP register. */
+ -1, -1, /* fs/gs base registers. */
11 * 4, /* "orig_eax" */
};
@@ -1105,11 +1107,10 @@ i386_linux_core_read_xsave_info (bfd *abfd, x86_xsave_layout &layout)
/* See i386-linux-tdep.h. */
bool
-i386_linux_core_read_x86_xsave_layout (struct gdbarch *gdbarch,
+i386_linux_core_read_x86_xsave_layout (struct gdbarch *gdbarch, bfd &cbfd,
x86_xsave_layout &layout)
{
- return i386_linux_core_read_xsave_info (current_program_space->core_bfd (),
- layout) != 0;
+ return i386_linux_core_read_xsave_info (&cbfd, layout) != 0;
}
/* See arch/x86-linux-tdesc.h. */
@@ -1492,6 +1493,9 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
INIT_GDB_FILE (i386_linux_tdep)
{
+ gdb_assert (ARRAY_SIZE (i386_linux_gregset_reg_offset)
+ == I386_LINUX_NUM_REGS);
+
gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_LINUX,
i386_linux_init_abi);
}
diff --git a/gdb/i386-linux-tdep.h b/gdb/i386-linux-tdep.h
index de98256..8a1a244 100644
--- a/gdb/i386-linux-tdep.h
+++ b/gdb/i386-linux-tdep.h
@@ -21,20 +21,29 @@
#define GDB_I386_LINUX_TDEP_H
#include "gdbsupport/x86-xstate.h"
+#include "i386-tdep.h"
-/* The Linux kernel pretends there is an additional "orig_eax"
- register. Since GDB needs access to that register to be able to
- properly restart system calls when necessary (see
- i386-linux-tdep.c) we need our own versions of a number of
- functions that deal with GDB's register cache. */
+/* Additional register numbers for i386 Linux, these are in addition to
+ the register numbers found in 'enum i386_regnum', see i386-tdep.h. */
-/* Register number for the "orig_eax" pseudo-register. If this
- pseudo-register contains a value >= 0 it is interpreted as the
- system call number that the kernel is supposed to restart. */
-#define I386_LINUX_ORIG_EAX_REGNUM (I386_PKRU_REGNUM + 1)
+enum i386_linux_regnum
+{
+ /* STOP! The values in this enum are numbered after the values in the
+ enum i386_regnum. New entries should be placed after the ORIG_EAX
+ entry. */
-/* Total number of registers for GNU/Linux. */
-#define I386_LINUX_NUM_REGS (I386_LINUX_ORIG_EAX_REGNUM + 1)
+ /* Register number for the "orig_eax" pseudo-register. GDB needs access
+ to this register to be able to properly restart system calls when
+ necessary (see i386-linux-tdep.c). If this pseudo-register contains a
+ value >= 0 it is interpreted as the system call number that the kernel
+ is supposed to restart. */
+ I386_LINUX_ORIG_EAX_REGNUM = I386_NUM_REGS,
+
+ /* Total number of registers for GNU/Linux. */
+ I386_LINUX_NUM_REGS
+
+ /* STOP! Add new entries before I386_LINUX_NUM_REGS. */
+};
/* Read the XSAVE extended state xcr0 value from the ABFD core file.
If it appears to be valid, return it and fill LAYOUT with values
@@ -47,6 +56,7 @@ extern uint64_t i386_linux_core_read_xsave_info (bfd *abfd,
/* Implement the core_read_x86_xsave_layout gdbarch method. */
extern bool i386_linux_core_read_x86_xsave_layout (struct gdbarch *gdbarch,
+ bfd &cbfd,
x86_xsave_layout &layout);
extern int i386_linux_gregset_reg_offset[];
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 21a5a28..d3ad402 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -61,7 +61,6 @@
#include "stap-probe.h"
#include "user-regs.h"
#include "expression.h"
-#include <ctype.h>
#include <algorithm>
#include <unordered_set>
#include "producer.h"
@@ -897,6 +896,22 @@ i386_displaced_step_fixup (struct gdbarch *gdbarch,
displaced_debug_printf ("relocated return addr at %s to %s",
paddress (gdbarch, esp),
paddress (gdbarch, retaddr));
+
+ /* If shadow stack is enabled, we need to correct the return address
+ on the shadow stack too. */
+ bool shadow_stack_enabled;
+ std::optional<CORE_ADDR> ssp
+ = gdbarch_get_shadow_stack_pointer (gdbarch, regs,
+ shadow_stack_enabled);
+ if (shadow_stack_enabled)
+ {
+ gdb_assert (ssp.has_value ());
+ write_memory_unsigned_integer (*ssp, retaddr_len, byte_order,
+ retaddr);
+ displaced_debug_printf ("relocated shadow stack return addr at %s "
+ "to %s", paddress (gdbarch, *ssp),
+ paddress (gdbarch, retaddr));
+ }
}
}
@@ -3879,9 +3894,9 @@ int
i386_stap_is_single_operand (struct gdbarch *gdbarch, const char *s)
{
return (*s == '$' /* Literal number. */
- || (isdigit (*s) && s[1] == '(' && s[2] == '%') /* Displacement. */
+ || (c_isdigit (*s) && s[1] == '(' && s[2] == '%') /* Displacement. */
|| (*s == '(' && s[1] == '%') /* Register indirection. */
- || (*s == '%' && isalpha (s[1]))); /* Register access. */
+ || (*s == '%' && c_isalpha (s[1]))); /* Register access. */
}
/* Helper function for i386_stap_parse_special_token.
@@ -3898,7 +3913,7 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch,
{
const char *s = p->arg;
- if (isdigit (*s) || *s == '-' || *s == '+')
+ if (c_isdigit (*s) || *s == '-' || *s == '+')
{
bool got_minus[3];
int i;
@@ -3916,7 +3931,7 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch,
got_minus[0] = true;
}
- if (!isdigit ((unsigned char) *s))
+ if (!c_isdigit (*s))
return {};
displacements[0] = strtol (s, &endp, 10);
@@ -3937,7 +3952,7 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch,
got_minus[1] = true;
}
- if (!isdigit ((unsigned char) *s))
+ if (!c_isdigit (*s))
return {};
displacements[1] = strtol (s, &endp, 10);
@@ -3958,7 +3973,7 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch,
got_minus[2] = true;
}
- if (!isdigit ((unsigned char) *s))
+ if (!c_isdigit (*s))
return {};
displacements[2] = strtol (s, &endp, 10);
@@ -3970,7 +3985,7 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch,
s += 2;
start = s;
- while (isalnum (*s))
+ while (c_isalnum (*s))
++s;
if (*s++ != ')')
@@ -4031,7 +4046,7 @@ i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch,
{
const char *s = p->arg;
- if (isdigit (*s) || *s == '(' || *s == '-' || *s == '+')
+ if (c_isdigit (*s) || *s == '(' || *s == '-' || *s == '+')
{
bool offset_minus = false;
long offset = 0;
@@ -4049,10 +4064,10 @@ i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch,
offset_minus = true;
}
- if (offset_minus && !isdigit (*s))
+ if (offset_minus && !c_isdigit (*s))
return {};
- if (isdigit (*s))
+ if (c_isdigit (*s))
{
char *endp;
@@ -4066,7 +4081,7 @@ i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch,
s += 2;
start = s;
- while (isalnum (*s))
+ while (c_isalnum (*s))
++s;
if (*s != ',' || s[1] != '%')
@@ -4082,7 +4097,7 @@ i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch,
s += 2;
start = s;
- while (isalnum (*s))
+ while (c_isalnum (*s))
++s;
len_index = s - start;
@@ -8580,7 +8595,8 @@ i386_validate_tdesc_p (i386_gdbarch_tdep *tdep,
const struct tdesc_feature *feature_core;
const struct tdesc_feature *feature_sse, *feature_avx, *feature_avx512,
- *feature_pkeys, *feature_segments;
+ *feature_pkeys, *feature_segments,
+ *feature_pl3_ssp;
int i, num_regs, valid_p;
if (! tdesc_has_registers (tdesc))
@@ -8606,6 +8622,9 @@ i386_validate_tdesc_p (i386_gdbarch_tdep *tdep,
/* Try PKEYS */
feature_pkeys = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.pkeys");
+ /* Try Shadow Stack. */
+ feature_pl3_ssp = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.pl3_ssp");
+
valid_p = 1;
/* The XCR0 bits. */
@@ -8721,6 +8740,15 @@ i386_validate_tdesc_p (i386_gdbarch_tdep *tdep,
tdep->pkeys_register_names[i]);
}
+ if (feature_pl3_ssp != nullptr)
+ {
+ if (tdep->ssp_regnum < 0)
+ tdep->ssp_regnum = I386_PL3_SSP_REGNUM;
+
+ valid_p &= tdesc_numbered_register (feature_pl3_ssp, tdesc_data,
+ tdep->ssp_regnum, "pl3_ssp");
+ }
+
return valid_p;
}
@@ -9097,23 +9125,25 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
-/* Return the target description for a specified XSAVE feature mask. */
+/* See i386-tdep.h. */
const struct target_desc *
-i386_target_description (uint64_t xcr0, bool segments)
+i386_target_description (uint64_t xstate_bv, bool segments)
{
static target_desc *i386_tdescs \
- [2/*SSE*/][2/*AVX*/][2/*AVX512*/][2/*PKRU*/][2/*segments*/] = {};
+ [2/*SSE*/][2/*AVX*/][2/*AVX512*/][2/*PKRU*/][2/*CET_U*/] \
+ [2/*segments*/] = {};
target_desc **tdesc;
- tdesc = &i386_tdescs[(xcr0 & X86_XSTATE_SSE) ? 1 : 0]
- [(xcr0 & X86_XSTATE_AVX) ? 1 : 0]
- [(xcr0 & X86_XSTATE_AVX512) ? 1 : 0]
- [(xcr0 & X86_XSTATE_PKRU) ? 1 : 0]
+ tdesc = &i386_tdescs[(xstate_bv & X86_XSTATE_SSE) ? 1 : 0]
+ [(xstate_bv & X86_XSTATE_AVX) ? 1 : 0]
+ [(xstate_bv & X86_XSTATE_AVX512) ? 1 : 0]
+ [(xstate_bv & X86_XSTATE_PKRU) ? 1 : 0]
+ [(xstate_bv & X86_XSTATE_CET_U) ? 1 : 0]
[segments ? 1 : 0];
if (*tdesc == NULL)
- *tdesc = i386_create_target_description (xcr0, false, segments);
+ *tdesc = i386_create_target_description (xstate_bv, false, segments);
return *tdesc;
}
diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h
index e4895b1..cfe0d73 100644
--- a/gdb/i386-tdep.h
+++ b/gdb/i386-tdep.h
@@ -195,6 +195,10 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base
/* PKEYS register names. */
const char * const *pkeys_register_names = nullptr;
+ /* Register number for the shadow stack pointer register. If supported,
+ set this to a value >= 0. */
+ int ssp_regnum = -1;
+
/* Register number for %fsbase. If supported, set this to a value
>= 0. */
int fsbase_regnum = -1;
@@ -297,8 +301,16 @@ enum i386_regnum
I386_ZMM0H_REGNUM, /* %zmm0h */
I386_ZMM7H_REGNUM = I386_ZMM0H_REGNUM + 7,
I386_PKRU_REGNUM,
+ I386_PL3_SSP_REGNUM,
I386_FSBASE_REGNUM,
- I386_GSBASE_REGNUM
+ I386_GSBASE_REGNUM,
+
+ I386_NUM_REGS, /* Calculated from last *_REGNUM entry. */
+ I386_SSE_NUM_REGS = I386_MXCSR_REGNUM + 1,
+ I386_AVX_NUM_REGS = I386_YMM7H_REGNUM + 1,
+ I386_AVX512_NUM_REGS = I386_ZMM7H_REGNUM + 1,
+ I386_PKEYS_NUM_REGS = I386_PKRU_REGNUM + 1
+ /* STOP! New *_REGNUM entries should be added before I386_NUM_REGS. */
};
/* Register numbers of RECORD_REGMAP. */
@@ -335,12 +347,6 @@ enum record_i386_regnum
#define I386_NUM_GREGS 16
#define I386_NUM_XREGS 9
-#define I386_SSE_NUM_REGS (I386_MXCSR_REGNUM + 1)
-#define I386_AVX_NUM_REGS (I386_YMM7H_REGNUM + 1)
-#define I386_AVX512_NUM_REGS (I386_ZMM7H_REGNUM + 1)
-#define I386_PKEYS_NUM_REGS (I386_PKRU_REGNUM + 1)
-#define I386_NUM_REGS (I386_GSBASE_REGNUM + 1)
-
/* Size of the largest register. */
#define I386_MAX_REGISTER_SIZE 64
@@ -454,8 +460,11 @@ extern int i386_svr4_reg_to_regnum (struct gdbarch *gdbarch, int reg);
extern int i386_process_record (struct gdbarch *gdbarch,
struct regcache *regcache, CORE_ADDR addr);
-extern const struct target_desc *i386_target_description (uint64_t xcr0,
- bool segments);
+
+/* Return the target description for the specified xsave features as
+ defined in XSTATE_BV and SEGMENTS. */
+extern const struct target_desc *i386_target_description
+ (uint64_t xstate_bv, bool segments);
/* Functions and variables exported from i386-bsd-tdep.c. */
diff --git a/gdb/ia64-linux-tdep.c b/gdb/ia64-linux-tdep.c
index 6afffee..8b4e1f9 100644
--- a/gdb/ia64-linux-tdep.c
+++ b/gdb/ia64-linux-tdep.c
@@ -29,7 +29,6 @@
#include "solib-svr4-linux.h"
#include "regset.h"
-#include <ctype.h>
/* The sigtramp code is in a non-readable (executable-only) region
of memory called the ``gate page''. The addresses in question
@@ -128,9 +127,9 @@ ia64_linux_write_pc (struct regcache *regcache, CORE_ADDR pc)
static int
ia64_linux_stap_is_single_operand (struct gdbarch *gdbarch, const char *s)
{
- return ((isdigit (*s) && s[1] == '[' && s[2] == 'r') /* Displacement. */
+ return ((c_isdigit (*s) && s[1] == '[' && s[2] == 'r') /* Displacement. */
|| *s == 'r' /* Register value. */
- || isdigit (*s)); /* Literal number. */
+ || c_isdigit (*s)); /* Literal number. */
}
/* Core file support. */
diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
index 7c6526a..6cf2986 100644
--- a/gdb/ia64-tdep.c
+++ b/gdb/ia64-tdep.c
@@ -3432,12 +3432,12 @@ ia64_find_global_pointer_from_dynamic_section (struct gdbarch *gdbarch,
faddr_sect = find_pc_section (faddr);
if (faddr_sect != NULL)
{
- for (obj_section *osect : faddr_sect->objfile->sections ())
+ for (obj_section &osect : faddr_sect->objfile->sections ())
{
- if (strcmp (osect->the_bfd_section->name, ".dynamic") == 0)
+ if (strcmp (osect.the_bfd_section->name, ".dynamic") == 0)
{
- CORE_ADDR addr = osect->addr ();
- CORE_ADDR endaddr = osect->endaddr ();
+ CORE_ADDR addr = osect.addr ();
+ CORE_ADDR endaddr = osect.endaddr ();
while (addr < endaddr)
{
@@ -3513,12 +3513,12 @@ find_extant_func_descr (struct gdbarch *gdbarch, CORE_ADDR faddr)
if (faddr_sect != NULL)
{
- for (obj_section *osect : faddr_sect->objfile->sections ())
+ for (obj_section &osect : faddr_sect->objfile->sections ())
{
- if (strcmp (osect->the_bfd_section->name, ".opd") == 0)
+ if (strcmp (osect.the_bfd_section->name, ".opd") == 0)
{
- CORE_ADDR addr = osect->addr ();
- CORE_ADDR endaddr = osect->endaddr ();
+ CORE_ADDR addr = osect.addr ();
+ CORE_ADDR endaddr = osect.endaddr ();
while (addr < endaddr)
{
diff --git a/gdb/infcall.c b/gdb/infcall.c
index 2b5936d..c4b4c8f 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -887,9 +887,9 @@ run_inferior_call (std::unique_ptr<call_thread_fsm> sm,
call async_enable_stdin. This changes the prompt state to
PROMPT_NEEDED.
- If the previous prompt state was PROMPT_NEEDED, then as
- async_enable_stdin has already been called, nothing additional
- needs to be done here. */
+ If the previous prompt state was PROMPT_NEEDED, then async_enable_stdin
+ may or may not have been called, so do the same changes as in
+ async_enable_stdin. */
if (current_ui->prompt_state == PROMPT_BLOCKED)
{
if (call_thread->thread_fsm ()->finished_p ())
@@ -897,6 +897,12 @@ run_inferior_call (std::unique_ptr<call_thread_fsm> sm,
else
async_enable_stdin ();
}
+ else if (current_ui->prompt_state == PROMPT_NEEDED)
+ {
+ /* Copied from async_enable_stdin. */
+ target_terminal::ours ();
+ current_ui->register_file_handler ();
+ }
/* If the infcall does NOT succeed, normal_stop will have already
finished the thread states. However, on success, normal_stop
@@ -1448,10 +1454,16 @@ call_function_by_hand_dummy (struct value *function,
/* Create the dummy stack frame. Pass in the call dummy address as,
presumably, the ABI code knows where, in the call dummy, the
return address should be pointed. */
- sp = gdbarch_push_dummy_call (gdbarch, function,
- get_thread_regcache (inferior_thread ()),
- bp_addr, args.size (), args.data (),
- sp, return_method, struct_addr);
+ regcache *regcache = get_thread_regcache (inferior_thread ());
+ sp = gdbarch_push_dummy_call (gdbarch, function, regcache, bp_addr,
+ args.size (), args.data (), sp,
+ return_method, struct_addr);
+
+ /* Push the return address of the inferior (bp_addr) to the shadow stack
+ and update the shadow stack pointer. As we don't execute a call
+ instruction to call the function we need to handle this manually. */
+ if (gdbarch_shadow_stack_push_p (gdbarch))
+ gdbarch_shadow_stack_push (gdbarch, bp_addr, regcache);
/* Set up a frame ID for the dummy frame so we can pass it to
set_momentary_breakpoint. We need to give the breakpoint a frame
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 8978c8a..bf68a95 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -25,6 +25,7 @@
#include "inferior.h"
#include "infrun.h"
#include "gdbsupport/environ.h"
+#include "gdbsupport/common-inferior.h"
#include "value.h"
#include "cli/cli-cmds.h"
#include "cli/cli-style.h"
@@ -39,7 +40,6 @@
#include "reggroups.h"
#include "block.h"
#include "solib.h"
-#include <ctype.h>
#include "observable.h"
#include "target-descriptions.h"
#include "user-regs.h"
@@ -209,7 +209,7 @@ strip_bg_char (const char *args, int *bg_char_p)
if (p[-1] == '&')
{
p--;
- while (p > args && isspace (p[-1]))
+ while (p > args && c_isspace (p[-1]))
p--;
*bg_char_p = 1;
@@ -260,7 +260,8 @@ post_create_inferior (int from_tty, bool set_pspace_solib_ops)
if (set_pspace_solib_ops)
current_program_space->set_solib_ops
- (gdbarch_make_solib_ops (current_inferior ()->arch ()));
+ (gdbarch_make_solib_ops (current_inferior ()->arch (),
+ current_program_space));
if (current_program_space->exec_bfd ())
{
@@ -494,6 +495,11 @@ run_command_1 (const char *args, int from_tty, enum run_how run_how)
thr->set_pending_waitstatus (ws);
}
+ /* Still call clear_proceed_status; in schedule multiple mode the proceed
+ can resume threads from other inferiors, which might need clearing
+ prior to a proceed call. */
+ clear_proceed_status (0);
+
/* Start the target running. Do not use -1 continuation as it would skip
breakpoint right at the entry point. */
proceed (regcache_read_pc (get_thread_regcache (inferior_thread ())),
@@ -989,7 +995,7 @@ prepare_one_step (thread_info *tp, struct step_command_fsm *sm)
if (inline_skipped_frames (tp) > 0)
{
const symbol *sym = inline_skipped_symbol (tp);
- if (sym->aclass () == LOC_BLOCK)
+ if (sym->loc_class () == LOC_BLOCK)
{
const block *block = sym->value_block ();
if (block->end () < tp->control.step_range_end)
@@ -2307,12 +2313,12 @@ registers_info (const char *addr_exp, int fpregs)
resembling a register following it. */
if (addr_exp[0] == '$')
addr_exp++;
- if (isspace ((*addr_exp)) || (*addr_exp) == '\0')
+ if (c_isspace ((*addr_exp)) || (*addr_exp) == '\0')
error (_("Missing register name"));
/* Find the start/end of this register name/num/group. */
start = addr_exp;
- while ((*addr_exp) != '\0' && !isspace ((*addr_exp)))
+ while ((*addr_exp) != '\0' && !c_isspace ((*addr_exp)))
addr_exp++;
end = addr_exp;
diff --git a/gdb/inferior.c b/gdb/inferior.c
index e8a28cd..eb895f2 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -19,6 +19,7 @@
#include "exec.h"
#include "inferior.h"
+#include "gdbsupport/common-inferior.h"
#include "target.h"
#include "command.h"
#include "completer.h"
diff --git a/gdb/inferior.h b/gdb/inferior.h
index fe94e28..8455b79 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -54,10 +54,8 @@ struct thread_info;
#include "symfile-add-flags.h"
#include "gdbsupport/refcounted-object.h"
#include "gdbsupport/forward-scope-exit.h"
-#include "gdbsupport/gdb_unique_ptr.h"
#include "gdbsupport/intrusive_list.h"
-#include "gdbsupport/common-inferior.h"
#include "gdbthread.h"
#include "process-stratum-target.h"
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 9d3e1b7..2e59af2 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -22,7 +22,6 @@
#include "cli/cli-style.h"
#include "displaced-stepping.h"
#include "infrun.h"
-#include <ctype.h>
#include "exceptions.h"
#include "symtab.h"
#include "frame.h"
@@ -1381,8 +1380,9 @@ follow_exec (ptid_t ptid, const char *exec_file_target)
registers. */
target_find_description ();
- current_program_space->set_solib_ops
- (gdbarch_make_solib_ops (following_inferior->arch ()));
+ following_inferior->pspace->set_solib_ops
+ (gdbarch_make_solib_ops (following_inferior->arch (),
+ following_inferior->pspace));
gdb::observers::inferior_execd.notify (execing_inferior, following_inferior);
breakpoint_re_set ();
@@ -2370,7 +2370,7 @@ maybe_software_singlestep (struct gdbarch *gdbarch)
bool hw_step = true;
if (execution_direction == EXEC_FORWARD
- && gdbarch_software_single_step_p (gdbarch))
+ && gdbarch_get_next_pcs_p (gdbarch))
hw_step = !insert_single_step_breakpoints (gdbarch);
return hw_step;
@@ -4393,6 +4393,11 @@ wait_for_inferior (inferior *inf)
scoped_finish_thread_state finish_state
(inf->process_target (), minus_one_ptid);
+ /* The commit_resumed_state of INF should already be false at this point
+ as INF will be a newly started remote target. This might not be true
+ for other targets but this will be handled in stop_all_threads. */
+ gdb_assert (!inf->process_target ()->commit_resumed_state);
+
while (1)
{
execution_control_state ecs;
@@ -5699,6 +5704,8 @@ stop_all_threads (const char *reason, inferior *inf)
debug_prefixed_printf ("infrun", "stop_all_threads", "done");
};
+ scoped_disable_commit_resumed disable_commit_resumed ("stop all threads");
+
/* Request threads to stop, and then wait for the stops. Because
threads we already know about can spawn more threads while we're
trying to stop them, and we only learn about new threads when we
@@ -9525,6 +9532,7 @@ normal_stop ()
here, so do this before any filtered output. */
ptid_t finish_ptid = null_ptid;
+ process_stratum_target *finish_target = nullptr;
if (!non_stop)
finish_ptid = minus_one_ptid;
@@ -9537,17 +9545,30 @@ normal_stop ()
linux-fork.c automatically switches to another fork from
within target_mourn_inferior. */
if (inferior_ptid != null_ptid)
- finish_ptid = ptid_t (inferior_ptid.pid ());
+ {
+ finish_ptid = ptid_t (inferior_ptid.pid ());
+ finish_target = current_inferior ()->process_target ();
+ }
}
else if (last.kind () != TARGET_WAITKIND_NO_RESUMED
&& last.kind () != TARGET_WAITKIND_THREAD_EXITED)
- finish_ptid = inferior_ptid;
+ {
+ finish_ptid = inferior_ptid;
+ finish_target = current_inferior ()->process_target ();
+ }
std::optional<scoped_finish_thread_state> maybe_finish_thread_state;
if (finish_ptid != null_ptid)
{
- maybe_finish_thread_state.emplace
- (user_visible_resume_target (finish_ptid), finish_ptid);
+ /* It might be tempting to use user_visible_resume_target to compute
+ FINISH_TARGET from FINISH_PTID, however, that is the wrong choice
+ in this case.
+
+ When resuming, we only resume the current target unless
+ schedule-multiple is in effect. However, when handling a stop, if
+ FINISH_PTID is minus_one_ptid, then we really do want to look for
+ stop events from _any_ target. */
+ maybe_finish_thread_state.emplace (finish_target, finish_ptid);
}
/* As we're presenting a stop, and potentially removing breakpoints,
@@ -9561,7 +9582,38 @@ normal_stop ()
update_thread_list ();
if (last.kind () == TARGET_WAITKIND_STOPPED && stopped_by_random_signal)
- notify_signal_received (inferior_thread ()->stop_signal ());
+ {
+ gdb_assert (inferior_ptid != null_ptid);
+
+ /* Calling update_thread_list pulls information from the target. For
+ native targets we can be (reasonably) sure that the information we
+ get back is sane, but for remote targets, we cannot reply on the
+ returned thread list to be correct.
+
+ Specifically, a remote target (not gdbserver), has been seen to
+ prematurely remove threads from the thread list after sending a
+ signal stop event. The consequence of this, is that the thread
+ might now be exited. This is bad as, trying to calling
+ notify_signal_received will cause GDB to read registers for the
+ current thread, but requesting the regcache for an exited thread
+ will trigger an assertion.
+
+ Check for the exited thread case here, and convert the stop reason
+ to a spurious stop event. The thread exiting will have already
+ been reported (when the thread list was parsed), so making this a
+ spurious stop will cause GDB to drop back to the prompt. */
+ if (inferior_thread ()->state != THREAD_EXITED)
+ notify_signal_received (inferior_thread ()->stop_signal ());
+ else
+ {
+ warning (_("command aborted, %s unexpectedly exited after signal stop event"),
+ target_pid_to_str (inferior_thread ()->ptid).c_str ());
+
+ /* Mark this as a spurious stop. GDB will return to the
+ prompt. The warning above tells the user why. */
+ last.set_spurious ();
+ }
+ }
/* As with the notification of thread events, we want to delay
notifying the user that we've switched thread context until
@@ -9842,7 +9894,7 @@ handle_command (const char *args, int from_tty)
for (char *arg : built_argv)
{
wordlen = strlen (arg);
- for (digits = 0; isdigit (arg[digits]); digits++)
+ for (digits = 0; c_isdigit (arg[digits]); digits++)
{;
}
allsigs = 0;
diff --git a/gdb/jit.c b/gdb/jit.c
index 0ea7bd9..b105697 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -584,7 +584,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
/* The name. */
block_name->set_domain (FUNCTION_DOMAIN);
- block_name->set_aclass_index (LOC_BLOCK);
+ block_name->set_loc_class_index (LOC_BLOCK);
block_name->set_symtab (filetab);
block_name->set_type (lookup_function_type (block_type));
block_name->set_value_block (new_block);
diff --git a/gdb/language.c b/gdb/language.c
index 80f9b01..c070169 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -28,7 +28,6 @@
return data out of a "language-specific" struct pointer that is set
whenever the working language changes. That would be a lot faster. */
-#include <ctype.h>
#include "symtab.h"
#include "gdbtypes.h"
#include "value.h"
@@ -976,7 +975,7 @@ language_arch_info::type_and_symbol::alloc_type_symbol
symbol->set_section_index (0);
symbol->set_type (type);
symbol->set_domain (TYPE_DOMAIN);
- symbol->set_aclass_index (LOC_TYPEDEF);
+ symbol->set_loc_class_index (LOC_TYPEDEF);
return symbol;
}
diff --git a/gdb/linespec.c b/gdb/linespec.c
index b59c055..2ddc495 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -35,7 +35,6 @@
#include "interps.h"
#include "target.h"
#include "arch-utils.h"
-#include <ctype.h>
#include "cli/cli-utils.h"
#include "filenames.h"
#include "ada-lang.h"
@@ -230,7 +229,7 @@ collect_info::add_symbol (block_symbol *bsym)
{
/* In list mode, add all matching symbols, regardless of class.
This allows the user to type "list a_global_variable". */
- if (bsym->symbol->aclass () == LOC_BLOCK || this->state->list_mode)
+ if (bsym->symbol->loc_class () == LOC_BLOCK || this->state->list_mode)
this->result.symbols->push_back (*bsym);
/* Continue iterating. */
@@ -459,7 +458,7 @@ linespec_lexer_lex_number (linespec_parser *parser, linespec_token *tokenp)
++(parser->lexer.stream);
}
- while (isdigit (*parser->lexer.stream))
+ while (c_isdigit (*parser->lexer.stream))
{
++tokenp->data.string.length;
++(parser->lexer.stream);
@@ -468,7 +467,7 @@ linespec_lexer_lex_number (linespec_parser *parser, linespec_token *tokenp)
/* If the next character in the input buffer is not a space, comma,
quote, or colon, this input does not represent a number. */
if (*parser->lexer.stream != '\0'
- && !isspace (*parser->lexer.stream) && *parser->lexer.stream != ','
+ && !c_isspace (*parser->lexer.stream) && *parser->lexer.stream != ','
&& *parser->lexer.stream != ':'
&& !strchr (linespec_quote_characters, *parser->lexer.stream))
{
@@ -512,7 +511,7 @@ linespec_lexer_lex_keyword (const char *p)
if (i == FORCE_KEYWORD_INDEX && p[len] == '\0')
return linespec_keywords[i];
- if (!isspace (p[len]))
+ if (!c_isspace (p[len]))
continue;
if (i == FORCE_KEYWORD_INDEX)
@@ -524,7 +523,7 @@ linespec_lexer_lex_keyword (const char *p)
int nextlen = strlen (linespec_keywords[j]);
if (strncmp (p, linespec_keywords[j], nextlen) == 0
- && isspace (p[nextlen]))
+ && c_isspace (p[nextlen]))
return linespec_keywords[i];
}
}
@@ -538,7 +537,7 @@ linespec_lexer_lex_keyword (const char *p)
int nextlen = strlen (linespec_keywords[j]);
if (strncmp (p, linespec_keywords[j], nextlen) == 0
- && isspace (p[nextlen]))
+ && c_isspace (p[nextlen]))
return NULL;
}
}
@@ -763,7 +762,7 @@ linespec_lexer_lex_string (linespec_parser *parser)
while (1)
{
- if (isspace (*parser->lexer.stream))
+ if (c_isspace (*parser->lexer.stream))
{
p = skip_spaces (parser->lexer.stream);
/* When we get here we know we've found something followed by
@@ -841,14 +840,14 @@ linespec_lexer_lex_string (linespec_parser *parser)
{
const char *op = parser->lexer.stream;
- while (op > start && isspace (op[-1]))
+ while (op > start && c_isspace (op[-1]))
op--;
if (op - start >= CP_OPERATOR_LEN)
{
op -= CP_OPERATOR_LEN;
if (strncmp (op, CP_OPERATOR_STR, CP_OPERATOR_LEN) == 0
&& (op == start
- || !(isalnum (op[-1]) || op[-1] == '_')))
+ || !(c_isalnum (op[-1]) || op[-1] == '_')))
{
/* This is an operator name. Keep going. */
++(parser->lexer.stream);
@@ -1140,12 +1139,7 @@ iterate_over_all_matching_symtabs
for (objfile *objfile : pspace->objfiles ())
{
- objfile->expand_symtabs_matching (NULL, &lookup_name, NULL, NULL,
- (SEARCH_GLOBAL_BLOCK
- | SEARCH_STATIC_BLOCK),
- domain);
-
- for (compunit_symtab *cu : objfile->compunits ())
+ auto expand_callback = [&] (compunit_symtab *cu)
{
struct symtab *symtab = cu->primary_filetab ();
@@ -1172,7 +1166,12 @@ iterate_over_all_matching_symtabs
});
}
}
- }
+
+ return true;
+ };
+
+ objfile->search (nullptr, &lookup_name, nullptr, expand_callback,
+ SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, domain);
}
}
}
@@ -1642,7 +1641,7 @@ linespec_parse_line_offset (const char *string)
else
line_offset.sign = LINE_OFFSET_NONE;
- if (*string != '\0' && !isdigit (*string))
+ if (*string != '\0' && !c_isdigit (*string))
error (_("malformed line offset: \"%s\""), start);
/* Right now, we only allow base 10 for offsets. */
@@ -2129,7 +2128,7 @@ create_sals_line_offset (struct linespec_state *self,
line 16 will also result in a breakpoint in main, at line 17. */
if (!was_exact
&& sym != nullptr
- && sym->aclass () == LOC_BLOCK
+ && sym->loc_class () == LOC_BLOCK
&& sal.pc == sym->value_block ()->entry_pc ()
&& val.line < sym->line ())
continue;
@@ -2224,7 +2223,7 @@ convert_linespec_to_sals (struct linespec_state *state, linespec *ls)
if (state->funfirstline
&& !ls->minimal_symbols.empty ()
- && sym.symbol->aclass () == LOC_BLOCK)
+ && sym.symbol->loc_class () == LOC_BLOCK)
{
const CORE_ADDR addr
= sym.symbol->value_block ()->entry_pc ();
@@ -3361,7 +3360,7 @@ decode_compound_collector::operator () (block_symbol *bsym)
struct type *t;
struct symbol *sym = bsym->symbol;
- if (sym->aclass () != LOC_TYPEDEF)
+ if (sym->loc_class () != LOC_TYPEDEF)
return true; /* Continue iterating. */
t = sym->type ();
@@ -3768,7 +3767,7 @@ find_linespec_symbols (struct linespec_state *state,
if (canon != nullptr)
lookup_name = canon.get ();
- /* It's important to not call expand_symtabs_matching unnecessarily
+ /* It's important to not call search unnecessarily
as it can really slow things down (by unnecessarily expanding
potentially 1000s of symtabs, which when debugging some apps can
cost 100s of seconds). Avoid this to some extent by *first* calling
@@ -4113,7 +4112,12 @@ minsym_found (struct linespec_state *self, struct objfile *objfile,
sal.pspace = current_program_space;
}
- sal.section = msymbol->obj_section (objfile);
+ /* Don't use the section from the msymbol, the code above might have
+ adjusted FUNC_ADDR, in which case the msymbol's section might not be
+ the section containing FUNC_ADDR. It might not even be in the same
+ objfile. As the section is primarily to assist with overlay
+ debugging, it should reflect the SAL's pc value. */
+ sal.section = find_pc_overlay (sal.pc);
if (self->maybe_add_address (objfile->pspace (), sal.pc))
add_sal_to_sals (self, result, &sal, msymbol->natural_name (), false);
@@ -4316,14 +4320,14 @@ static bool
symbol_to_sal (struct symtab_and_line *result,
bool funfirstline, struct symbol *sym)
{
- if (sym->aclass () == LOC_BLOCK)
+ if (sym->loc_class () == LOC_BLOCK)
{
*result = find_function_start_sal (sym, funfirstline);
return true;
}
else
{
- if (sym->aclass () == LOC_LABEL && sym->value_address () != 0)
+ if (sym->loc_class () == LOC_LABEL && sym->value_address () != 0)
{
*result = {};
result->symtab = sym->symtab ();
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 9e986d8..0171259 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -37,7 +37,6 @@
#include "gdbsupport/eintr.h"
#include "target/waitstatus.h"
#include <dirent.h>
-#include <ctype.h>
#include <list>
@@ -421,7 +420,7 @@ fork_save_infrun_state (struct fork_info *fp)
/* Now find actual file positions. */
rewinddir (d);
while ((de = readdir (d)) != NULL)
- if (isdigit (de->d_name[0]))
+ if (c_isdigit (de->d_name[0]))
{
tmp = strtol (&de->d_name[0], NULL, 10);
fp->filepos[tmp] = call_lseek (tmp, 0, SEEK_CUR);
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index f317927..87fb800 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -42,7 +42,6 @@
#include "elf-bfd.h"
#include "gregset.h"
#include "gdbcore.h"
-#include <ctype.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "inf-loop.h"
@@ -549,8 +548,8 @@ linux_nat_target::follow_fork (inferior *child_inf, ptid_t child_ptid,
/* Note that we consult the parent's architecture instead of
the child's because there's no inferior for the child at
this point. */
- if (!gdbarch_software_single_step_p (target_thread_architecture
- (parent_ptid)))
+ if (!gdbarch_get_next_pcs_p (target_thread_architecture
+ (parent_ptid)))
{
int status;
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index 5c4bbf6..4b679c8 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -46,7 +46,7 @@
#include "cli/cli-style.h"
#include "gdbsupport/unordered_map.h"
-#include <ctype.h>
+#include <algorithm>
/* This enum represents the values that the user can choose when
informing the Linux kernel about which memory mappings will be
@@ -96,6 +96,10 @@ struct smaps_vmflags
/* Memory map has memory tagging enabled. */
unsigned int memory_tagging : 1;
+
+ /* Memory map used for shadow stack. */
+
+ unsigned int shadow_stack_memory : 1;
};
/* Data structure that holds the information contained in the
@@ -483,7 +487,7 @@ read_mapping (const char *line)
p = skip_spaces (p);
const char *permissions_start = p;
- while (*p && !isspace (*p))
+ while (*p && !c_isspace (*p))
p++;
mapping.permissions = std::string (permissions_start,
(size_t) (p - permissions_start));
@@ -492,7 +496,7 @@ read_mapping (const char *line)
p = skip_spaces (p);
const char *device_start = p;
- while (*p && !isspace (*p))
+ while (*p && !c_isspace (*p))
p++;
mapping.device = {device_start, (size_t) (p - device_start)};
@@ -537,6 +541,8 @@ decode_vmflags (char *p, struct smaps_vmflags *v)
v->shared_mapping = 1;
else if (strcmp (s, "mt") == 0)
v->memory_tagging = 1;
+ else if (strcmp (s, "ss") == 0)
+ v->shadow_stack_memory = 1;
}
}
@@ -836,7 +842,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
char filename[100];
fileio_error target_errno;
- if (args && isdigit (args[0]))
+ if (args && c_isdigit (args[0]))
{
char *tem;
@@ -1147,8 +1153,8 @@ linux_read_core_file_mappings
}
gdb::byte_vector contents (note_size);
- if (!bfd_get_section_contents (current_program_space->core_bfd (), section,
- contents.data (), 0, note_size))
+ if (!bfd_get_section_contents (cbfd, section, contents.data (), 0,
+ note_size))
{
warning (_("could not get core note contents"));
return;
@@ -1163,13 +1169,10 @@ linux_read_core_file_mappings
return;
}
- ULONGEST count = bfd_get (addr_size_bits, current_program_space->core_bfd (),
- descdata);
+ ULONGEST count = bfd_get (addr_size_bits, cbfd, descdata);
descdata += addr_size;
- ULONGEST page_size = bfd_get (addr_size_bits,
- current_program_space->core_bfd (),
- descdata);
+ ULONGEST page_size = bfd_get (addr_size_bits, cbfd, descdata);
descdata += addr_size;
if (note_size < 2 * addr_size + count * 3 * addr_size)
@@ -1216,12 +1219,11 @@ linux_read_core_file_mappings
for (int i = 0; i < count; i++)
{
- ULONGEST start = bfd_get (addr_size_bits, current_program_space->core_bfd (), descdata);
+ ULONGEST start = bfd_get (addr_size_bits, cbfd, descdata);
descdata += addr_size;
- ULONGEST end = bfd_get (addr_size_bits, current_program_space->core_bfd (), descdata);
+ ULONGEST end = bfd_get (addr_size_bits, cbfd, descdata);
descdata += addr_size;
- ULONGEST file_ofs
- = bfd_get (addr_size_bits, current_program_space->core_bfd (), descdata) * page_size;
+ ULONGEST file_ofs = bfd_get (addr_size_bits, cbfd, descdata) * page_size;
descdata += addr_size;
char * filename = filenames;
filenames += strlen ((char *) filenames) + 1;
@@ -1235,14 +1237,15 @@ linux_read_core_file_mappings
}
}
-/* Implement "info proc mappings" for a corefile. */
+/* Implement "info proc mappings" for corefile CBFD. */
static void
-linux_core_info_proc_mappings (struct gdbarch *gdbarch, const char *args)
+linux_core_info_proc_mappings (struct gdbarch *gdbarch, struct bfd *cbfd,
+ const char *args)
{
std::optional<ui_out_emit_table> emitter;
- linux_read_core_file_mappings (gdbarch, current_program_space->core_bfd (),
+ linux_read_core_file_mappings (gdbarch, cbfd,
[&] (ULONGEST count)
{
gdb_printf (_("Mapped address spaces:\n\n"));
@@ -1271,19 +1274,18 @@ linux_core_info_proc_mappings (struct gdbarch *gdbarch, const char *args)
});
}
-/* Implement "info proc" for a corefile. */
+/* Implement "info proc" for corefile CBFD. */
static void
-linux_core_info_proc (struct gdbarch *gdbarch, const char *args,
- enum info_proc_what what)
+linux_core_info_proc (struct gdbarch *gdbarch, struct bfd *cbfd,
+ const char *args, enum info_proc_what what)
{
int exe_f = (what == IP_MINIMAL || what == IP_EXE || what == IP_ALL);
int mappings_f = (what == IP_MAPPINGS || what == IP_ALL);
if (exe_f)
{
- const char *exe
- = bfd_core_file_failing_command (current_program_space->core_bfd ());
+ const char *exe = bfd_core_file_failing_command (cbfd);
if (exe != NULL)
gdb_printf ("exe = '%s'\n", exe);
@@ -1292,7 +1294,7 @@ linux_core_info_proc (struct gdbarch *gdbarch, const char *args,
}
if (mappings_f)
- linux_core_info_proc_mappings (gdbarch, args);
+ linux_core_info_proc_mappings (gdbarch, cbfd, args);
if (!exe_f && !mappings_f)
error (_("unable to handle request"));
@@ -1304,18 +1306,15 @@ linux_core_info_proc (struct gdbarch *gdbarch, const char *args,
interface. */
static LONGEST
-linux_core_xfer_siginfo (struct gdbarch *gdbarch, gdb_byte *readbuf,
- ULONGEST offset, ULONGEST len)
+linux_core_xfer_siginfo (struct gdbarch *gdbarch, struct bfd &cbfd,
+ gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
{
thread_section_name section_name (".note.linuxcore.siginfo", inferior_ptid);
- asection *section
- = bfd_get_section_by_name (current_program_space->core_bfd (),
- section_name.c_str ());
- if (section == NULL)
+ asection *section = bfd_get_section_by_name (&cbfd, section_name.c_str ());
+ if (section == nullptr)
return -1;
- if (!bfd_get_section_contents (current_program_space->core_bfd (), section,
- readbuf, offset, len))
+ if (!bfd_get_section_contents (&cbfd, section, readbuf, offset, len))
return -1;
return len;
@@ -2227,7 +2226,7 @@ linux_fill_prpsinfo (struct elf_internal_linux_prpsinfo *p)
specifically under the entry of `/proc/[pid]/stat'. */
/* Getting rid of the PID, since we already have it. */
- while (isdigit (*proc_stat))
+ while (c_isdigit (*proc_stat))
++proc_stat;
proc_stat = skip_spaces (proc_stat);
@@ -2299,10 +2298,10 @@ linux_fill_prpsinfo (struct elf_internal_linux_prpsinfo *p)
{
/* Advancing the pointer to the beginning of the UID. */
tmpstr += sizeof ("Uid:");
- while (*tmpstr != '\0' && !isdigit (*tmpstr))
+ while (*tmpstr != '\0' && !c_isdigit (*tmpstr))
++tmpstr;
- if (isdigit (*tmpstr))
+ if (c_isdigit (*tmpstr))
p->pr_uid = strtol (tmpstr, &tmpstr, 10);
}
@@ -2312,10 +2311,10 @@ linux_fill_prpsinfo (struct elf_internal_linux_prpsinfo *p)
{
/* Advancing the pointer to the beginning of the GID. */
tmpstr += sizeof ("Gid:");
- while (*tmpstr != '\0' && !isdigit (*tmpstr))
+ while (*tmpstr != '\0' && !c_isdigit (*tmpstr))
++tmpstr;
- if (isdigit (*tmpstr))
+ if (c_isdigit (*tmpstr))
p->pr_gid = strtol (tmpstr, &tmpstr, 10);
}
@@ -3036,6 +3035,46 @@ show_dump_excluded_mappings (struct ui_file *file, int from_tty,
" flag is %s.\n"), value);
}
+/* See linux-tdep.h. */
+
+bool
+linux_address_in_shadow_stack_mem_range
+ (CORE_ADDR addr, std::pair<CORE_ADDR, CORE_ADDR> *range)
+{
+ if (!target_has_execution () || current_inferior ()->fake_pid_p)
+ return false;
+
+ const int pid = current_inferior ()->pid;
+
+ std::string smaps_file = string_printf ("/proc/%d/smaps", pid);
+
+ gdb::unique_xmalloc_ptr<char> data
+ = target_fileio_read_stralloc (nullptr, smaps_file.c_str ());
+
+ if (data == nullptr)
+ return false;
+
+ const std::vector<smaps_data> smaps
+ = parse_smaps_data (data.get (), std::move (smaps_file));
+
+ auto find_addr_mem_range = [&addr] (const smaps_data &map)
+ {
+ bool addr_in_mem_range
+ = (addr >= map.start_address && addr < map.end_address);
+ return (addr_in_mem_range && map.vmflags.shadow_stack_memory);
+ };
+ auto it = std::find_if (smaps.begin (), smaps.end (), find_addr_mem_range);
+
+ if (it != smaps.end ())
+ {
+ range->first = it->start_address;
+ range->second = it->end_address;
+ return true;
+ }
+
+ return false;
+}
+
/* To be called from the various GDB_OSABI_LINUX handlers for the
various GNU/Linux architectures and machine types.
diff --git a/gdb/linux-tdep.h b/gdb/linux-tdep.h
index 3d82ea5..a4f0f53 100644
--- a/gdb/linux-tdep.h
+++ b/gdb/linux-tdep.h
@@ -27,6 +27,17 @@
struct inferior;
struct regcache;
+#ifndef SEGV_CPERR
+#define SEGV_CPERR 10 /* Control protection error. */
+#endif
+
+/* Flag which enables shadow stack in PR_SET_SHADOW_STACK_STATUS prctl. */
+#ifndef PR_SHADOW_STACK_ENABLE
+#define PR_SHADOW_STACK_ENABLE (1UL << 0)
+#define PR_SHADOW_STACK_WRITE (1UL << 1)
+#define PR_SHADOW_STACK_PUSH (1UL << 2)
+#endif
+
/* Enum used to define the extra fields of the siginfo type used by an
architecture. */
enum linux_siginfo_extra_field_values
@@ -113,4 +124,11 @@ extern CORE_ADDR linux_get_hwcap2 (const std::optional<gdb::byte_vector> &auxv,
extern CORE_ADDR linux_get_hwcap2 ();
+/* Returns true if ADDR belongs to a shadow stack memory range. If this
+ is the case, assign the shadow stack memory range to RANGE
+ [start_address, end_address). */
+
+extern bool linux_address_in_shadow_stack_mem_range
+ (CORE_ADDR addr, std::pair<CORE_ADDR, CORE_ADDR> *range);
+
#endif /* GDB_LINUX_TDEP_H */
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index 8d49508..82bfe08 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -43,7 +43,6 @@
#include "auto-load.h"
#include "cli/cli-utils.h"
#include <signal.h>
-#include <ctype.h>
#include "nat/linux-namespaces.h"
#include <algorithm>
#include "gdbsupport/pathstuff.h"
diff --git a/gdb/location.c b/gdb/location.c
index 378fafc..197c47b 100644
--- a/gdb/location.c
+++ b/gdb/location.c
@@ -26,7 +26,6 @@
#include "probe.h"
#include "cp-support.h"
-#include <ctype.h>
#include <string.h>
static std::string
@@ -408,15 +407,15 @@ explicit_location_spec_lex_one (const char **inp,
whitespace or comma. */
if (*start == '-' || *start == '+')
{
- while (*inp[0] != '\0' && *inp[0] != ',' && !isspace (*inp[0]))
+ while (*inp[0] != '\0' && *inp[0] != ',' && !c_isspace (*inp[0]))
++(*inp);
}
else
{
/* Handle numbers first, stopping at the next whitespace or ','. */
- while (isdigit (*inp[0]))
+ while (c_isdigit (*inp[0]))
++(*inp);
- if (*inp[0] == '\0' || isspace (*inp[0]) || *inp[0] == ',')
+ if (*inp[0] == '\0' || c_isspace (*inp[0]) || *inp[0] == ',')
return gdb::unique_xmalloc_ptr<char> (savestring (start,
*inp - start));
@@ -425,7 +424,7 @@ explicit_location_spec_lex_one (const char **inp,
*inp = start;
while ((*inp)[0]
&& (*inp)[0] != ','
- && !(isspace ((*inp)[0])
+ && !(c_isspace ((*inp)[0])
|| linespec_lexer_lex_keyword (&(*inp)[1])))
{
/* Special case: C++ operator,. */
@@ -454,14 +453,14 @@ is_cp_operator (const char *start, const char *comma)
{
const char *p = comma;
- while (p > start && isspace (p[-1]))
+ while (p > start && c_isspace (p[-1]))
p--;
if (p - start >= CP_OPERATOR_LEN)
{
p -= CP_OPERATOR_LEN;
if (strncmp (p, CP_OPERATOR_STR, CP_OPERATOR_LEN) == 0
&& (p == start
- || !(isalnum (p[-1]) || p[-1] == '_')))
+ || !(c_isalnum (p[-1]) || p[-1] == '_')))
{
return true;
}
@@ -624,7 +623,7 @@ string_to_explicit_location_spec (const char **argp,
if (argp == NULL
|| *argp == NULL
|| *argp[0] != '-'
- || !isalpha ((*argp)[1])
+ || !c_isalpha ((*argp)[1])
|| ((*argp)[0] == '-' && (*argp)[1] == 'p'))
return NULL;
@@ -728,7 +727,7 @@ string_to_explicit_location_spec (const char **argp,
}
/* Only emit an "invalid argument" error for options
that look like option strings. */
- else if (opt.get ()[0] == '-' && !isdigit (opt.get ()[1]))
+ else if (opt.get ()[0] == '-' && !c_isdigit (opt.get ()[1]))
{
if (completion_info == NULL)
error (_("invalid explicit location argument, \"%s\""), opt.get ());
diff --git a/gdb/loongarch-linux-nat.c b/gdb/loongarch-linux-nat.c
index 2b59b36..1360acf 100644
--- a/gdb/loongarch-linux-nat.c
+++ b/gdb/loongarch-linux-nat.c
@@ -72,8 +72,6 @@ public:
struct expression *cond) override;
int remove_watchpoint (CORE_ADDR addr, int len, enum target_hw_bp_type type,
struct expression *cond) override;
- bool watchpoint_addr_within_range (CORE_ADDR addr, CORE_ADDR start,
- int length) override;
/* Add our hardware breakpoint and watchpoint implementation. */
bool stopped_by_watchpoint () override;
@@ -581,15 +579,6 @@ loongarch_linux_nat_target::remove_watchpoint (CORE_ADDR addr, int len,
}
-bool
-loongarch_linux_nat_target::watchpoint_addr_within_range (CORE_ADDR addr,
- CORE_ADDR start,
- int length)
-{
- return start <= addr && start + length - 1 >= addr;
-}
-
-
/* Implement the "stopped_data_address" target_ops method. */
bool
diff --git a/gdb/loongarch-tdep.c b/gdb/loongarch-tdep.c
index cc75cd4..e94b88b 100644
--- a/gdb/loongarch-tdep.c
+++ b/gdb/loongarch-tdep.c
@@ -22,10 +22,12 @@
#include "dwarf2/frame.h"
#include "elf-bfd.h"
#include "extract-store-integer.h"
+#include "frame-base.h"
#include "frame-unwind.h"
#include "gdbcore.h"
#include "linux-record.h"
#include "loongarch-tdep.h"
+#include "prologue-value.h"
#include "record.h"
#include "record-full.h"
#include "reggroups.h"
@@ -34,6 +36,33 @@
#include "trad-frame.h"
#include "user-regs.h"
+/* LoongArch frame cache structure. */
+struct loongarch_frame_cache
+{
+ /* The program counter at the start of the function. It is used to
+ identify this frame as a prologue frame. */
+ CORE_ADDR func;
+
+ /* The stack pointer at the time this frame was created; i.e. the
+ caller's stack pointer when this function was called. It is used
+ to identify this frame. */
+ CORE_ADDR prev_sp;
+
+ CORE_ADDR pc;
+
+ int available_p;
+
+ /* This register stores the frame base of the frame. */
+ int framebase_reg;
+
+ /* The framebase_offset is the distance from frame base to the prev_sp,
+ so the value of framebase_reg is just prev_sp - framebase_offset. */
+ int framebase_offset;
+
+ /* Saved register offsets. */
+ trad_frame_saved_reg *saved_regs;
+};
+
/* Fetch the instruction at PC. */
static insn_t
@@ -98,7 +127,9 @@ static bool
loongarch_insn_is_ll (insn_t insn)
{
if ((insn & 0xff000000) == 0x20000000 /* ll.w */
- || (insn & 0xff000000) == 0x22000000) /* ll.d */
+ || (insn & 0xff000000) == 0x22000000 /* ll.d */
+ || (insn & 0xfffffc00) == 0x38578000 /* llacq.w */
+ || (insn & 0xfffffc00) == 0x38578800) /* llacq.d */
return true;
return false;
}
@@ -109,7 +140,10 @@ static bool
loongarch_insn_is_sc (insn_t insn)
{
if ((insn & 0xff000000) == 0x21000000 /* sc.w */
- || (insn & 0xff000000) == 0x23000000) /* sc.d */
+ || (insn & 0xff000000) == 0x23000000 /* sc.d */
+ || (insn & 0xffff8000) == 0x38570000 /* sc.q */
+ || (insn & 0xfffffc00) == 0x38578400 /* screl.w */
+ || (insn & 0xfffffc00) == 0x38578c00) /* screl.d */
return true;
return false;
}
@@ -120,13 +154,23 @@ loongarch_insn_is_sc (insn_t insn)
static CORE_ADDR
loongarch_scan_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc,
CORE_ADDR limit_pc, const frame_info_ptr &this_frame,
- struct trad_frame_cache *this_cache)
+ struct loongarch_frame_cache *this_cache)
{
CORE_ADDR cur_pc = start_pc, prologue_end = 0;
int32_t sp = LOONGARCH_SP_REGNUM;
int32_t fp = LOONGARCH_FP_REGNUM;
+ int32_t ra = LOONGARCH_RA_REGNUM;
int32_t reg_value[32] = {0};
int32_t reg_used[32] = {1, 0};
+ int i;
+
+ /* Track 32 GPR, ORIG_A0, PC, BADV in prologue. */
+ pv_t regs[LOONGARCH_USED_NUM_GREGSET];
+
+ for (i = 0; i < LOONGARCH_USED_NUM_GREGSET; i++)
+ regs[i] = pv_register (i, 0);
+
+ pv_area stack (LOONGARCH_SP_REGNUM, gdbarch_addr_bit (gdbarch));
while (cur_pc < limit_pc)
{
@@ -136,27 +180,40 @@ loongarch_scan_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc,
int32_t rj = loongarch_decode_imm ("5:5", insn, 0);
int32_t rk = loongarch_decode_imm ("10:5", insn, 0);
int32_t si12 = loongarch_decode_imm ("10:12", insn, 1);
+ int32_t si14 = loongarch_decode_imm ("10:14", insn, 1);
int32_t si20 = loongarch_decode_imm ("5:20", insn, 1);
if ((insn & 0xffc00000) == 0x02c00000 /* addi.d sp,sp,si12 */
&& rd == sp && rj == sp && si12 < 0)
{
prologue_end = cur_pc + insn_len;
+ regs[rd] = pv_add_constant (regs[rj], si12);
}
else if ((insn & 0xffc00000) == 0x02c00000 /* addi.d fp,sp,si12 */
&& rd == fp && rj == sp && si12 > 0)
{
prologue_end = cur_pc + insn_len;
+ regs[rd] = pv_add_constant (regs[rj], si12);
}
else if ((insn & 0xffc00000) == 0x29c00000 /* st.d rd,sp,si12 */
&& rj == sp)
{
prologue_end = cur_pc + insn_len;
+ /* ra, fp, s0~s8 are saved by callee with sp as a base */
+ if ((rd >= fp && rd <= fp + 9) || rd == ra)
+ {
+ stack.store (pv_add_constant (regs[sp], si12), register_size (gdbarch, rd), regs[rd]);
+ }
}
else if ((insn & 0xff000000) == 0x27000000 /* stptr.d rd,sp,si14 */
&& rj == sp)
{
prologue_end = cur_pc + insn_len;
+ /* ra, fp, s0~s8 are saved by callee with sp as a base */
+ if ((rd >= fp && rd <= fp + 9) || rd == ra)
+ {
+ stack.store (pv_add_constant (regs[sp], si14), register_size (gdbarch, rd), regs[rd]);
+ }
}
else if ((insn & 0xfe000000) == 0x14000000) /* lu12i.w rd,si20 */
{
@@ -191,6 +248,38 @@ loongarch_scan_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc,
if (prologue_end == 0)
prologue_end = cur_pc;
+ if (this_cache == NULL)
+ return prologue_end;
+
+ if (pv_is_register (regs[LOONGARCH_FP_REGNUM], LOONGARCH_SP_REGNUM))
+ {
+ /* Frame pointer is fp. */
+ this_cache->framebase_reg = LOONGARCH_FP_REGNUM;
+ this_cache->framebase_offset = -regs[LOONGARCH_FP_REGNUM].k;
+ }
+ else if (pv_is_register (regs[LOONGARCH_SP_REGNUM], LOONGARCH_SP_REGNUM))
+ {
+ /* Try the stack pointer. */
+ this_cache->framebase_reg = LOONGARCH_SP_REGNUM;
+ this_cache->framebase_offset = -regs[LOONGARCH_SP_REGNUM].k;
+ }
+ else
+ {
+ /* We're just out of luck. We don't know where the frame is. */
+ this_cache->framebase_reg = -1;
+ this_cache->framebase_offset = 0;
+ }
+
+ for (i = 0; i < LOONGARCH_USED_NUM_GREGSET; i++)
+ {
+ CORE_ADDR offset;
+
+ if (stack.find_reg (gdbarch, i, &offset))
+ {
+ this_cache->saved_regs[i].set_addr (offset);
+ }
+ }
+
return prologue_end;
}
@@ -339,13 +428,50 @@ loongarch_next_pc (struct regcache *regcache, CORE_ADDR cur_pc)
return next_pc;
}
+/* Calculate the destination address of a condition branch instruction under an
+ assumed true condition */
+
+static CORE_ADDR
+cond_branch_destination_address (CORE_ADDR cur_pc, insn_t insn)
+{
+ size_t insn_len = loongarch_insn_length (insn);
+ CORE_ADDR next_pc = cur_pc + insn_len;
+
+ if ((insn & 0xfc000000) == 0x58000000) /* beq rj, rd, offs16 */
+ next_pc = cur_pc + loongarch_decode_imm ("10:16<<2", insn, 1);
+ else if ((insn & 0xfc000000) == 0x5c000000) /* bne rj, rd, offs16 */
+ next_pc = cur_pc + loongarch_decode_imm ("10:16<<2", insn, 1);
+ else if ((insn & 0xfc000000) == 0x60000000) /* blt rj, rd, offs16 */
+ next_pc = cur_pc + loongarch_decode_imm ("10:16<<2", insn, 1);
+ else if ((insn & 0xfc000000) == 0x64000000) /* bge rj, rd, offs16 */
+ next_pc = cur_pc + loongarch_decode_imm ("10:16<<2", insn, 1);
+ else if ((insn & 0xfc000000) == 0x68000000) /* bltu rj, rd, offs16 */
+ next_pc = cur_pc + loongarch_decode_imm ("10:16<<2", insn, 1);
+ else if ((insn & 0xfc000000) == 0x6c000000) /* bgeu rj, rd, offs16 */
+ next_pc = cur_pc + loongarch_decode_imm ("10:16<<2", insn, 1);
+ else if ((insn & 0xfc000000) == 0x40000000) /* beqz rj, offs21 */
+ next_pc = cur_pc + loongarch_decode_imm ("0:5|10:16<<2", insn, 1);
+ else if ((insn & 0xfc000000) == 0x44000000) /* bnez rj, offs21 */
+ next_pc = cur_pc + loongarch_decode_imm ("0:5|10:16<<2", insn, 1);
+ else if ((insn & 0xfc000300) == 0x48000000) /* bceqz cj, offs21 */
+ next_pc = cur_pc + loongarch_decode_imm ("0:5|10:16<<2", insn, 1);
+ else if ((insn & 0xfc000300) == 0x48000100) /* bcnez cj, offs21 */
+ next_pc = cur_pc + loongarch_decode_imm ("0:5|10:16<<2", insn, 1);
+
+ return next_pc;
+}
+
/* We can't put a breakpoint in the middle of a ll/sc atomic sequence,
- so look for the end of the sequence and put the breakpoint there. */
+ so a breakpoint should be outside of atomic sequence in any case,
+ just look for the start and end of the sequence, and then restrict
+ the breakpoint outside of the atomic sequence. */
static std::vector<CORE_ADDR>
loongarch_deal_with_atomic_sequence (struct regcache *regcache, CORE_ADDR cur_pc)
{
CORE_ADDR next_pc;
+ CORE_ADDR ll_insn_addr;
+ CORE_ADDR sc_insn_addr;
std::vector<CORE_ADDR> next_pcs;
insn_t insn = loongarch_fetch_instruction (cur_pc);
size_t insn_len = loongarch_insn_length (insn);
@@ -356,6 +482,30 @@ loongarch_deal_with_atomic_sequence (struct regcache *regcache, CORE_ADDR cur_pc
if (!loongarch_insn_is_ll (insn))
return {};
+ /* Record the address of a Load Linked instruction */
+ ll_insn_addr = cur_pc;
+
+ for (int insn_count = 0; insn_count < atomic_sequence_length; ++insn_count)
+ {
+ cur_pc += insn_len;
+ insn = loongarch_fetch_instruction (cur_pc);
+
+ if (loongarch_insn_is_sc (insn))
+ {
+ /* Record the address of a Store Conditional instruction */
+ sc_insn_addr = cur_pc;
+ found_atomic_sequence_endpoint = true;
+ break;
+ }
+ }
+
+ /* We didn't find a closing Store Conditional instruction, fallback to the standard code. */
+ if (!found_atomic_sequence_endpoint)
+ return {};
+
+ /* Restore current PC with the address of a Load Linked instruction */
+ cur_pc = ll_insn_addr;
+
/* Assume that no atomic sequence is longer than "atomic_sequence_length" instructions. */
for (int insn_count = 0; insn_count < atomic_sequence_length; ++insn_count)
{
@@ -371,24 +521,20 @@ loongarch_deal_with_atomic_sequence (struct regcache *regcache, CORE_ADDR cur_pc
which is outside of the ll/sc atomic instruction sequence. */
else if (loongarch_insn_is_cond_branch (insn))
{
- next_pc = loongarch_next_pc (regcache, cur_pc);
- if (next_pc != cur_pc + insn_len)
+ next_pc = cond_branch_destination_address (cur_pc, insn);
+ /* Restrict the breakpoint outside of the atomic sequence. */
+ if (next_pc < ll_insn_addr || next_pc > sc_insn_addr)
next_pcs.push_back (next_pc);
}
/* Look for a Store Conditional instruction which closes the atomic sequence. */
else if (loongarch_insn_is_sc (insn))
{
- found_atomic_sequence_endpoint = true;
next_pc = cur_pc + insn_len;
next_pcs.push_back (next_pc);
break;
}
}
- /* We didn't find a closing Store Conditional instruction, fallback to the standard code. */
- if (!found_atomic_sequence_endpoint)
- return {};
-
return next_pcs;
}
@@ -426,38 +572,157 @@ loongarch_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr)
return align_down (addr, 16);
}
+/* Analyze the function prologue for THIS_FRAME and populate the frame
+ cache CACHE. */
+
+static void
+loongarch_analyze_prologue (const frame_info_ptr &this_frame,
+ struct loongarch_frame_cache *cache)
+{
+ CORE_ADDR block_addr = get_frame_address_in_block (this_frame);
+ CORE_ADDR prologue_start = 0;
+ CORE_ADDR prologue_end = 0;
+ CORE_ADDR pc = get_frame_pc (this_frame);
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+
+ cache->pc = pc;
+
+ /* Assume we do not find a frame. */
+ cache->framebase_reg = -1;
+ cache->framebase_offset = 0;
+
+
+ if (find_pc_partial_function (block_addr, NULL, &prologue_start,
+ &prologue_end))
+ {
+ struct symtab_and_line sal = find_pc_line (prologue_start, 0);
+
+ if (sal.line == 0)
+ {
+ /* No line info so use the current PC. */
+ prologue_end = pc;
+ }
+ else if (sal.end < prologue_end)
+ {
+ if (sal.symtab != NULL && sal.symtab->language () == language_asm)
+ {
+ /* This sal.end usually cannot point to prologue_end correctly
+ in asm file. */
+ prologue_end = pc;
+ }
+ else
+ {
+ /* The next line begins after the prologue_end. */
+ prologue_end = sal.end;
+ }
+ }
+
+ }
+ else
+ {
+ /* We're in the boondocks: we have no idea where the start of the
+ function is. */
+ return;
+ }
+
+ prologue_end = std::min (prologue_end, pc);
+ loongarch_scan_prologue (gdbarch, prologue_start, prologue_end, nullptr, cache);
+}
+
+/* Fill in *CACHE with information about the prologue of *THIS_FRAME. */
+
+static void
+loongarch_frame_cache_1 (const frame_info_ptr &this_frame,
+ struct loongarch_frame_cache *cache)
+{
+ CORE_ADDR unwound_fp;
+ int reg;
+
+ loongarch_analyze_prologue (this_frame, cache);
+
+ if (cache->framebase_reg == -1)
+ return;
+
+ unwound_fp = get_frame_register_unsigned (this_frame, cache->framebase_reg);
+ if (unwound_fp == 0)
+ return;
+
+ cache->prev_sp = unwound_fp;
+ cache->prev_sp += cache->framebase_offset;
+
+ /* Calculate actual addresses of saved registers using offsets
+ determined by loongarch_scan_prologue. */
+ for (reg = 0; reg < gdbarch_num_regs (get_frame_arch (this_frame)); reg++)
+ if (cache->saved_regs[reg].is_addr ())
+ cache->saved_regs[reg].set_addr (cache->saved_regs[reg].addr ()
+ + cache->prev_sp);
+
+ cache->func = get_frame_func (this_frame);
+
+ cache->available_p = 1;
+}
+
/* Generate, or return the cached frame cache for frame unwinder. */
-static struct trad_frame_cache *
+static struct loongarch_frame_cache *
loongarch_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
{
- struct trad_frame_cache *cache;
- CORE_ADDR pc;
+ struct loongarch_frame_cache *cache;
- if (*this_cache != nullptr)
- return (struct trad_frame_cache *) *this_cache;
+ if (*this_cache != NULL)
+ return (struct loongarch_frame_cache *) *this_cache;
- cache = trad_frame_cache_zalloc (this_frame);
+ cache = FRAME_OBSTACK_ZALLOC (struct loongarch_frame_cache);
+ cache->saved_regs = trad_frame_alloc_saved_regs (this_frame);
*this_cache = cache;
- trad_frame_set_reg_realreg (cache, LOONGARCH_PC_REGNUM, LOONGARCH_RA_REGNUM);
-
- pc = get_frame_address_in_block (this_frame);
- trad_frame_set_id (cache, frame_id_build_unavailable_stack (pc));
+ try
+ {
+ loongarch_frame_cache_1 (this_frame, cache);
+ }
+ catch (const gdb_exception_error &ex)
+ {
+ if (ex.error != NOT_AVAILABLE_ERROR)
+ throw;
+ }
return cache;
}
+/* Implement the "stop_reason" frame_unwind method. */
+
+static enum unwind_stop_reason
+loongarch_frame_unwind_stop_reason (const frame_info_ptr &this_frame,
+ void **this_cache)
+{
+ struct loongarch_frame_cache *cache
+ = loongarch_frame_cache (this_frame, this_cache);
+
+ if (!cache->available_p)
+ return UNWIND_UNAVAILABLE;
+
+ /* We've hit a wall, stop. */
+ if (cache->prev_sp == 0)
+ return UNWIND_OUTERMOST;
+
+ return UNWIND_NO_REASON;
+}
+
/* Implement the this_id callback for frame unwinder. */
static void
loongarch_frame_this_id (const frame_info_ptr &this_frame, void **prologue_cache,
struct frame_id *this_id)
{
- struct trad_frame_cache *info;
+ struct loongarch_frame_cache *cache
+ = loongarch_frame_cache (this_frame, prologue_cache);
- info = loongarch_frame_cache (this_frame, prologue_cache);
- trad_frame_get_id (info, this_id);
+ /* Our frame ID for a normal frame is the current function's starting
+ PC and the caller's SP when we were called. */
+ if (!cache->available_p)
+ *this_id = frame_id_build_unavailable_stack (cache->func);
+ else
+ *this_id = frame_id_build (cache->prev_sp, cache->func);
}
/* Implement the prev_register callback for frame unwinder. */
@@ -466,17 +731,55 @@ static struct value *
loongarch_frame_prev_register (const frame_info_ptr &this_frame,
void **prologue_cache, int regnum)
{
- struct trad_frame_cache *info;
+ struct loongarch_frame_cache *cache
+ = loongarch_frame_cache (this_frame, prologue_cache);
+
+ /* If we are asked to unwind the PC, then we need to return the RA
+ instead. The prologue may save PC, but it will point into this
+ frame's prologue, not the previou frame's resume location. */
+ if (regnum == LOONGARCH_PC_REGNUM)
+ {
+ CORE_ADDR ra;
+ ra = frame_unwind_register_unsigned (this_frame, LOONGARCH_RA_REGNUM);
+
+ return frame_unwind_got_constant (this_frame, regnum, ra);
+ }
+
+ /* SP is generally not saved to the stack, but this frame is
+ identified by the next frame's stack pointer at the time of the
+ call. The value was already reconstructed into PREV_SP. */
+ /*
+ addi.d $sp, $sp, -32
+ st.d $ra, $sp, 24
+ st.d $fp, $sp, 16
+ addi.d $fp, $sp, 32
+
+ +->+----------+
+ | | saved ra |
+ | | saved fp |
+ | | |
+ | | |
+ | +----------+ <- Previous SP == FP
+ | | saved ra |
+ +--| saved fp |
+ | |
+ | |
+ +----------+ <- SP
+ */
+
+ if (regnum == LOONGARCH_SP_REGNUM)
+ return frame_unwind_got_constant (this_frame, regnum, cache->prev_sp);
+
+ return trad_frame_get_prev_register (this_frame, cache->saved_regs, regnum);
- info = loongarch_frame_cache (this_frame, prologue_cache);
- return trad_frame_get_register (info, this_frame, regnum);
}
+/* LoongArch prologue unwinder. */
static const struct frame_unwind_legacy loongarch_frame_unwind (
"loongarch prologue",
/*.type =*/NORMAL_FRAME,
/*.unwinder_class=*/FRAME_UNWIND_ARCH,
- /*.stop_reason =*/default_frame_unwind_stop_reason,
+ /*.stop_reason =*/loongarch_frame_unwind_stop_reason,
/*.this_id =*/loongarch_frame_this_id,
/*.prev_register =*/loongarch_frame_prev_register,
/*.unwind_data =*/nullptr,
@@ -485,6 +788,26 @@ static const struct frame_unwind_legacy loongarch_frame_unwind (
/*.prev_arch =*/nullptr
);
+/* Return the frame base address of *THIS_FRAME. */
+
+static CORE_ADDR
+loongarch_frame_base_address (const frame_info_ptr &this_frame, void **this_cache)
+{
+ struct loongarch_frame_cache *cache
+ = loongarch_frame_cache (this_frame, this_cache);
+
+ return cache->prev_sp - cache->framebase_offset;
+}
+
+/* LoongArch default frame base information. */
+static frame_base loongarch_frame_base =
+{
+ &loongarch_frame_unwind,
+ loongarch_frame_base_address,
+ loongarch_frame_base_address,
+ loongarch_frame_base_address
+};
+
/* Write the contents of buffer VAL into the general-purpose argument
register defined by GAR in REGCACHE. GAR indicates the available
general-purpose argument registers which should be a value in the
@@ -1895,7 +2218,7 @@ loongarch_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_frame_align (gdbarch, loongarch_frame_align);
/* Breakpoint manipulation. */
- set_gdbarch_software_single_step (gdbarch, loongarch_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, loongarch_software_single_step);
set_gdbarch_breakpoint_kind_from_pc (gdbarch, loongarch_breakpoint::kind_from_pc);
set_gdbarch_sw_breakpoint_from_kind (gdbarch, loongarch_breakpoint::bp_from_kind);
set_gdbarch_have_nonsteppable_watchpoint (gdbarch, 1);
@@ -1905,6 +2228,8 @@ loongarch_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
dwarf2_append_unwinders (gdbarch);
frame_unwind_append_unwinder (gdbarch, &loongarch_frame_unwind);
+ frame_base_set_default (gdbarch, &loongarch_frame_base);
+
/* Hook in OS ABI-specific overrides, if they have been registered. */
gdbarch_init_osabi (info, gdbarch);
set_gdbarch_register_reggroup_p (gdbarch, loongarch_register_reggroup_p);
diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y
index 5c31a5e..55d5f2e 100644
--- a/gdb/m2-exp.y
+++ b/gdb/m2-exp.y
@@ -507,7 +507,7 @@ fblock : block COLONCOLON BLOCKNAME
{ struct symbol *tem
= lookup_symbol (copy_name ($3).c_str (), $1,
SEARCH_VFT, 0).symbol;
- if (!tem || tem->aclass () != LOC_BLOCK)
+ if (!tem || tem->loc_class () != LOC_BLOCK)
error (_("No function \"%s\" in specified context."),
copy_name ($3).c_str ());
$$ = tem;
@@ -928,7 +928,7 @@ yylex (void)
sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
SEARCH_VFT, 0).symbol;
- if (sym && sym->aclass () == LOC_BLOCK)
+ if (sym && sym->loc_class () == LOC_BLOCK)
return BLOCKNAME;
if (lookup_typename (pstate->language (),
tmp.c_str (), pstate->expression_context_block, 1))
@@ -936,7 +936,7 @@ yylex (void)
if(sym)
{
- switch(sym->aclass ())
+ switch(sym->loc_class ())
{
case LOC_STATIC:
case LOC_REGISTER:
diff --git a/gdb/machoread.c b/gdb/machoread.c
index ffee181..30d376c 100644
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -901,13 +901,13 @@ macho_symfile_offsets (struct objfile *objfile,
for (i = 0; i < addrs.size (); i++)
{
- for (obj_section *osect : objfile->sections ())
+ for (obj_section &osect : objfile->sections ())
{
- const char *bfd_sect_name = osect->the_bfd_section->name;
+ const char *bfd_sect_name = osect.the_bfd_section->name;
if (bfd_sect_name == addrs[i].name)
{
- osect->set_offset (addrs[i].addr);
+ osect.set_offset (addrs[i].addr);
break;
}
}
@@ -915,10 +915,10 @@ macho_symfile_offsets (struct objfile *objfile,
objfile->sect_index_text = 0;
- for (obj_section *osect : objfile->sections ())
+ for (obj_section &osect : objfile->sections ())
{
- const char *bfd_sect_name = osect->the_bfd_section->name;
- int sect_index = osect - objfile->sections_start;
+ const char *bfd_sect_name = osect.the_bfd_section->name;
+ int sect_index = &osect - objfile->sections_start;
if (startswith (bfd_sect_name, "LC_SEGMENT."))
bfd_sect_name += 11;
diff --git a/gdb/macroscope.c b/gdb/macroscope.c
index 7aa0784..a8b78c9 100644
--- a/gdb/macroscope.c
+++ b/gdb/macroscope.c
@@ -97,12 +97,12 @@ default_macro_scope ()
{
struct symtab_and_line sal;
frame_info_ptr frame;
- CORE_ADDR pc;
+ std::optional<CORE_ADDR> pc;
/* If there's a selected frame, use its PC. */
frame = deprecated_safe_get_selected_frame ();
- if (frame && get_frame_pc_if_available (frame, &pc))
- sal = find_pc_line (pc, 0);
+ if (frame && (pc = get_frame_pc_if_available (frame)))
+ sal = find_pc_line (*pc, 0);
/* Fall back to the current listing position. */
else
diff --git a/gdb/main.c b/gdb/main.c
index bb8ddc3..3d56a31 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -19,6 +19,7 @@
#include "annotate.h"
#include "exceptions.h"
+#include "gdbsupport/common-inferior.h"
#include "top.h"
#include "ui.h"
#include "target.h"
@@ -29,7 +30,6 @@
#include <sys/types.h>
#include <sys/stat.h>
-#include <ctype.h>
#include "gdbsupport/event-loop.h"
#include "ui-out.h"
@@ -59,6 +59,7 @@
#include "serial.h"
#include "cli-out.h"
#include "bt-utils.h"
+#include "terminal.h"
/* The selected interpreter. */
std::string interpreter_p;
@@ -617,9 +618,20 @@ captured_main_1 (struct captured_main_args *context)
char **argv = context->argv;
static int quiet = 0;
- static int set_args = 0;
static int inhibit_home_gdbinit = 0;
+ /* Has the user passed inferior arguments on the command line. */
+ enum {
+ /* No arguments passed. */
+ NO_ARGS,
+
+ /* Arguments passed with --args. */
+ SET_ESC_ARGS,
+
+ /* Arguments passed with --no-escape-args. */
+ SET_NO_ESC_ARGS
+ } set_args = NO_ARGS;
+
/* Pointers to various arguments from command line. */
char *symarg = NULL;
char *execarg = NULL;
@@ -769,7 +781,12 @@ captured_main_1 (struct captured_main_args *context)
OPT_EIX,
OPT_EIEX,
OPT_READNOW,
- OPT_READNEVER
+ OPT_READNEVER,
+ OPT_SET_ESC_ARGS,
+ OPT_SET_NO_ESC_ARGS,
+#ifdef USE_WIN32API
+ OPT_BINARY_OUTPUT,
+#endif
};
/* This struct requires int* in the struct, but write_files is a bool.
So use this temporary int that we write back after argument parsing. */
@@ -842,9 +859,13 @@ captured_main_1 (struct captured_main_args *context)
{"windows", no_argument, NULL, OPT_WINDOWS},
{"statistics", no_argument, 0, OPT_STATISTICS},
{"write", no_argument, &write_files_1, 1},
- {"args", no_argument, &set_args, 1},
+ {"args", no_argument, nullptr, OPT_SET_ESC_ARGS},
+ {"no-escape-args", no_argument, nullptr, OPT_SET_NO_ESC_ARGS},
{"l", required_argument, 0, 'l'},
{"return-child-result", no_argument, &return_child_result, 1},
+#ifdef USE_WIN32API
+ {"binary-output", no_argument, 0, OPT_BINARY_OUTPUT},
+#endif
{0, no_argument, 0, 0}
};
@@ -852,9 +873,14 @@ captured_main_1 (struct captured_main_args *context)
{
int option_index;
+ /* If the previous argument was --args or --no-escape-args, then
+ stop argument processing. */
+ if (set_args != NO_ARGS)
+ break;
+
c = getopt_long_only (argc, argv, "",
long_options, &option_index);
- if (c == EOF || set_args)
+ if (c == EOF)
break;
/* Long option that takes an argument. */
@@ -935,6 +961,12 @@ captured_main_1 (struct captured_main_args *context)
case OPT_EIEX:
cmdarg_vec.emplace_back (CMDARG_EARLYINIT_COMMAND, optarg);
break;
+ case OPT_SET_ESC_ARGS:
+ set_args = SET_ESC_ARGS;
+ break;
+ case OPT_SET_NO_ESC_ARGS:
+ set_args = SET_NO_ESC_ARGS;
+ break;
case 'B':
batch_flag = batch_silent = 1;
gdb_stdout = new null_file ();
@@ -1018,6 +1050,12 @@ captured_main_1 (struct captured_main_args *context)
}
break;
+#ifdef USE_WIN32API
+ case OPT_BINARY_OUTPUT:
+ set_output_translation_mode_binary ();
+ break;
+#endif
+
case '?':
error (_("Use `%s --help' for a complete list of options."),
gdb_program_name);
@@ -1068,7 +1106,7 @@ captured_main_1 (struct captured_main_args *context)
/* Now that gdb_init has created the initial inferior, we're in
position to set args for that inferior. */
- if (set_args)
+ if (set_args != NO_ARGS)
{
/* The remaining options are the command-line options for the
inferior. The first one is the sym/exec file, and the rest
@@ -1080,10 +1118,9 @@ captured_main_1 (struct captured_main_args *context)
symarg = argv[optind];
execarg = argv[optind];
++optind;
- current_inferior ()->set_args
- (gdb::array_view<char * const> (&argv[optind], argc - optind),
- startup_with_shell);
- }
+ gdb::array_view<char * const> arg_view (&argv[optind], argc - optind);
+ current_inferior ()->set_args (arg_view, (set_args == SET_ESC_ARGS));
+ }
else
{
/* OK, that's all the options. */
@@ -1253,7 +1290,7 @@ captured_main_1 (struct captured_main_args *context)
If pid_or_core_arg's first character is a digit, try attach
first and then corefile. Otherwise try just corefile. */
- if (isdigit (pid_or_core_arg[0]))
+ if (c_isdigit (pid_or_core_arg[0]))
{
ret = catch_command_errors (attach_command, pid_or_core_arg,
!batch_flag);
@@ -1330,10 +1367,8 @@ captured_main_1 (struct captured_main_args *context)
}
static void
-captured_main (void *data)
+captured_main (captured_main_args *context)
{
- struct captured_main_args *context = (struct captured_main_args *) data;
-
captured_main_1 (context);
/* NOTE: cagney/1999-11-07: There is probably no reason for not
@@ -1402,7 +1437,8 @@ This is the GNU debugger. Usage:\n\n\
gdb_puts (_("\
Selection of debuggee and its files:\n\n\
--args Arguments after executable-file are passed to inferior.\n\
- --core=COREFILE Analyze the core dump COREFILE.\n\
+ --no-escape-args Like --args, but arguments are not escaped.\n \
+ --core=COREFILE Analyze the core dump COREFILE.\n \
--exec=EXECFILE Use EXECFILE as the executable.\n\
--pid=PID Attach to running process PID.\n\
--directory=DIR Search for source files in DIR.\n\
@@ -1459,8 +1495,13 @@ Remote debugging options:\n\n\
Other options:\n\n\
--cd=DIR Change current directory to DIR.\n\
--data-directory=DIR, -D\n\
- Set GDB's data-directory to DIR.\n\
-"), stream);
+ Set GDB's data-directory to DIR.\n"
+#ifdef USE_WIN32API
+"\
+ --binary-output Set the translation mode of stdout/stderr to binary,\n\
+ disabling CRLF translation.\n"
+#endif
+), stream);
gdb_puts (_("\n\
At startup, GDB reads the following early init files and executes their\n\
commands:\n\
diff --git a/gdb/maint.c b/gdb/maint.c
index 78dea22..8bc2856 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -21,7 +21,6 @@
#include "arch-utils.h"
-#include <ctype.h>
#include <cmath>
#include <signal.h>
#include "command.h"
@@ -571,9 +570,9 @@ maintenance_translate_address (const char *arg, int from_tty)
sect = NULL;
p = arg;
- if (!isdigit (*p))
+ if (!c_isdigit (*p))
{ /* See if we have a valid section name. */
- while (*p && !isspace (*p)) /* Find end of section name. */
+ while (*p && !c_isspace (*p)) /* Find end of section name. */
p++;
if (*p == '\000') /* End of command? */
error (_("Need to specify section name and address"));
@@ -582,9 +581,9 @@ maintenance_translate_address (const char *arg, int from_tty)
p = skip_spaces (p + 1);
for (objfile *objfile : current_program_space->objfiles ())
- for (obj_section *iter : objfile->sections ())
+ for (obj_section &iter : objfile->sections ())
{
- if (strncmp (iter->the_bfd_section->name, arg, arg_len) == 0)
+ if (strncmp (iter.the_bfd_section->name, arg, arg_len) == 0)
goto found;
}
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 5bb15c2..a7d26c3 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -248,7 +248,7 @@ static struct type *parse_type (int, union aux_ext *, unsigned int, int *,
int, const char *);
static struct symbol *mylookup_symbol (const char *, const struct block *,
- domain_enum, enum address_class);
+ domain_enum, location_class);
static void sort_blocks (struct symtab *);
@@ -550,7 +550,7 @@ static const struct symbol_register_ops mdebug_register_funcs = {
mdebug_reg_to_regnum
};
-/* The "aclass" indices for computed symbols. */
+/* The "loc_class" indices for computed symbols. */
static int mdebug_register_index;
static int mdebug_regparm_index;
@@ -559,11 +559,11 @@ static int mdebug_regparm_index;
static void
add_data_symbol (SYMR *sh, union aux_ext *ax, int bigend,
- struct symbol *s, int aclass_index, struct block *b,
+ struct symbol *s, int loc_class_index, struct block *b,
struct objfile *objfile, const char *name)
{
s->set_domain (VAR_DOMAIN);
- s->set_aclass_index (aclass_index);
+ s->set_loc_class_index (loc_class_index);
add_symbol (s, top_stack->cur_st, b);
/* Type could be missing if file is compiled without debugging info. */
@@ -688,19 +688,19 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
{
case scRegister:
/* Pass by value in register. */
- s->set_aclass_index (mdebug_register_index);
+ s->set_loc_class_index (mdebug_register_index);
break;
case scVar:
/* Pass by reference on stack. */
- s->set_aclass_index (LOC_REF_ARG);
+ s->set_loc_class_index (LOC_REF_ARG);
break;
case scVarRegister:
/* Pass by reference in register. */
- s->set_aclass_index (mdebug_regparm_index);
+ s->set_loc_class_index (mdebug_regparm_index);
break;
default:
/* Pass by value on stack. */
- s->set_aclass_index (LOC_ARG);
+ s->set_loc_class_index (LOC_ARG);
break;
}
s->set_value_longest (svalue);
@@ -711,7 +711,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
case stLabel: /* label, goes into current block. */
s = new_symbol (name);
s->set_domain (LABEL_DOMAIN); /* So that it can be used */
- s->set_aclass_index (LOC_LABEL); /* but not misused. */
+ s->set_loc_class_index (LOC_LABEL); /* but not misused. */
s->set_section_index (section_index);
s->set_value_address (sh->value);
s->set_type (builtin_type (objfile)->builtin_int);
@@ -753,7 +753,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
}
s = new_symbol (name);
s->set_domain (FUNCTION_DOMAIN);
- s->set_aclass_index (LOC_BLOCK);
+ s->set_loc_class_index (LOC_BLOCK);
s->set_section_index (section_index);
/* Type of the return value. */
if (SC_IS_UNDEF (sh->sc) || sh->sc == scNil)
@@ -1034,7 +1034,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
t->set_code (type_code);
t->set_length (sh->value);
t->alloc_fields (nfields);
- f = t->fields();
+ f = t->fields ().data ();
if (type_code == TYPE_CODE_ENUM)
{
@@ -1074,7 +1074,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
enum_sym->set_linkage_name
(obstack_strdup (&mdebugread_objfile->objfile_obstack,
f->name ()));
- enum_sym->set_aclass_index (LOC_CONST);
+ enum_sym->set_loc_class_index (LOC_CONST);
enum_sym->set_type (t);
enum_sym->set_domain (VAR_DOMAIN);
enum_sym->set_value_longest (tsym.value);
@@ -1107,7 +1107,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
s = new_symbol (name);
s->set_domain (STRUCT_DOMAIN);
- s->set_aclass_index (LOC_TYPEDEF);
+ s->set_loc_class_index (LOC_TYPEDEF);
s->set_value_longest (0);
s->set_type (t);
add_symbol (s, top_stack->cur_st, top_stack->cur_block);
@@ -1164,7 +1164,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
/* Make up special symbol to contain procedure specific info. */
s = new_symbol (MDEBUG_EFI_SYMBOL_NAME);
s->set_domain (LABEL_DOMAIN);
- s->set_aclass_index (LOC_CONST);
+ s->set_loc_class_index (LOC_CONST);
s->set_type (builtin_type (mdebugread_objfile)->builtin_void);
e = OBSTACK_ZALLOC (&mdebugread_objfile->objfile_obstack,
mdebug_extra_func_info);
@@ -1297,7 +1297,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
break;
s = new_symbol (name);
s->set_domain (TYPE_DOMAIN);
- s->set_aclass_index (LOC_TYPEDEF);
+ s->set_loc_class_index (LOC_TYPEDEF);
s->set_value_block (top_stack->cur_block);
s->set_type (t);
add_symbol (s, top_stack->cur_st, top_stack->cur_block);
@@ -3369,7 +3369,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
for (cur_sdx = 0; cur_sdx < fh->csym;)
{
char *sym_name;
- enum address_class theclass;
+ location_class loc_class;
unrelocated_addr minsym_value;
int section = -1;
@@ -3526,7 +3526,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
reader.record_with_info (sym_name, minsym_value,
mst_file_bss,
SECT_OFF_BSS (objfile));
- theclass = LOC_STATIC;
+ loc_class = LOC_STATIC;
break;
case stIndirect: /* Irix5 forward declaration */
@@ -3538,11 +3538,11 @@ parse_partial_symbols (minimal_symbol_reader &reader,
structs from alpha and mips cc. */
if (sh.iss == 0 || has_opaque_xref (fh, &sh))
goto skip;
- theclass = LOC_TYPEDEF;
+ loc_class = LOC_TYPEDEF;
break;
case stConstant: /* Constant decl */
- theclass = LOC_CONST;
+ loc_class = LOC_CONST;
break;
case stUnion:
@@ -3600,7 +3600,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
}
/* Use this gdb symbol. */
pst->add_psymbol (sym_name, true,
- VAR_DOMAIN, theclass, section,
+ VAR_DOMAIN, loc_class, section,
psymbol_placement::STATIC,
unrelocated_addr (sh.value),
psymtab_language,
@@ -3616,7 +3616,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
PST_PRIVATE (save_pst)->extern_tab = ext_ptr;
for (; --cur_sdx >= 0; ext_ptr++)
{
- enum address_class theclass;
+ location_class loc_class;
SYMR *psh;
CORE_ADDR svalue;
int section;
@@ -3663,7 +3663,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
Ignore them, as parse_external will ignore them too. */
continue;
case stLabel:
- theclass = LOC_LABEL;
+ loc_class = LOC_LABEL;
break;
default:
unknown_ext_complaint (debug_info->ssext + psh->iss);
@@ -3675,12 +3675,12 @@ parse_partial_symbols (minimal_symbol_reader &reader,
if (SC_IS_COMMON (psh->sc))
continue;
- theclass = LOC_STATIC;
+ loc_class = LOC_STATIC;
break;
}
char *sym_name = debug_info->ssext + psh->iss;
pst->add_psymbol (sym_name, true,
- VAR_DOMAIN, theclass,
+ VAR_DOMAIN, loc_class,
section,
psymbol_placement::GLOBAL,
unrelocated_addr (svalue),
@@ -3991,7 +3991,7 @@ mdebug_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
struct symbol *s = new_symbol (MDEBUG_EFI_SYMBOL_NAME);
s->set_domain (LABEL_DOMAIN);
- s->set_aclass_index (LOC_CONST);
+ s->set_loc_class_index (LOC_CONST);
s->set_type (builtin_type (objfile)->builtin_void);
s->set_value_bytes ((gdb_byte *) e);
e->pdr.framereg = -1;
@@ -4464,7 +4464,7 @@ cross_ref (int fd, union aux_ext *ax, struct type **tpp,
static struct symbol *
mylookup_symbol (const char *name, const struct block *block,
- domain_enum domain, enum address_class theclass)
+ domain_enum domain, location_class loc_class)
{
int inc;
@@ -4473,14 +4473,14 @@ mylookup_symbol (const char *name, const struct block *block,
{
if (sym->linkage_name ()[0] == inc
&& sym->domain () == domain
- && sym->aclass () == theclass
+ && sym->loc_class () == loc_class
&& strcmp (sym->linkage_name (), name) == 0)
return sym;
}
block = block->superblock ();
if (block)
- return mylookup_symbol (name, block, domain, theclass);
+ return mylookup_symbol (name, block, domain, loc_class);
return 0;
}
diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c
index e4cb2e7..1cb8435 100644
--- a/gdb/mi/mi-cmd-break.c
+++ b/gdb/mi/mi-cmd-break.c
@@ -28,7 +28,6 @@
#include "language.h"
#include "location.h"
#include "linespec.h"
-#include <ctype.h>
#include "tracepoint.h"
enum
@@ -133,7 +132,7 @@ mi_argv_to_format (const char *const *argv, int argc)
result += "\\\"";
break;
default:
- if (isprint (argv[0][i]))
+ if (c_isprint (argv[0][i]))
result += argv[0][i];
else
{
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index cc26747..52ae11b 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -29,10 +29,8 @@
#include "valprint.h"
#include "mi-getopt.h"
#include "extension.h"
-#include <ctype.h>
#include "mi-parse.h"
#include <optional>
-#include "gdbsupport/gdb-safe-ctype.h"
#include "inferior.h"
enum what_to_list { locals, arguments, all };
@@ -604,7 +602,7 @@ list_args_or_locals (const frame_print_options &fp_opts,
{
int print_me = 0;
- switch (sym->aclass ())
+ switch (sym->loc_class ())
{
default:
case LOC_UNDEF: /* catches errors */
diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c
index 9cbb857..09d6107 100644
--- a/gdb/mi/mi-cmd-var.c
+++ b/gdb/mi/mi-cmd-var.c
@@ -25,7 +25,6 @@
#include "varobj.h"
#include "language.h"
#include "value.h"
-#include <ctype.h>
#include "mi-getopt.h"
#include "gdbthread.h"
#include "mi-parse.h"
@@ -109,7 +108,7 @@ mi_cmd_var_create (const char *command, const char *const *argv, int argc)
gen_name = varobj_gen_name ();
name = gen_name.c_str ();
}
- else if (!isalpha (name[0]))
+ else if (!c_isalpha (name[0]))
error (_("-var-create: name of object must begin with a letter"));
if (strcmp (frame, "*") == 0)
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 789e6fa..bcc32f9 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -52,7 +52,6 @@
#include <optional>
#include "gdbsupport/byte-vector.h"
-#include <ctype.h>
#include "gdbsupport/run-time-clock.h"
#include <chrono>
#include "progspace-and-thread.h"
diff --git a/gdb/mi/mi-parse.c b/gdb/mi/mi-parse.c
index 0af90cb..58bdf4a 100644
--- a/gdb/mi/mi-parse.c
+++ b/gdb/mi/mi-parse.c
@@ -22,7 +22,6 @@
#include "mi-cmds.h"
#include "mi-parse.h"
-#include <ctype.h>
#include "cli/cli-utils.h"
#include "language.h"
@@ -61,7 +60,7 @@ mi_parse_escape (const char **string_ptr)
while (++count < 3)
{
c = (**string_ptr);
- if (isdigit (c) && c != '8' && c != '9')
+ if (c_isdigit (c) && c != '8' && c != '9')
{
(*string_ptr)++;
i *= 8;
@@ -162,7 +161,7 @@ mi_parse::parse_argv ()
return;
}
/* Insist on trailing white space. */
- if (chp[1] != '\0' && !isspace (chp[1]))
+ if (chp[1] != '\0' && !c_isspace (chp[1]))
{
freeargv (argv);
return;
@@ -193,7 +192,7 @@ mi_parse::parse_argv ()
int len;
const char *start = chp;
- while (*chp != '\0' && !isspace (*chp))
+ while (*chp != '\0' && !c_isspace (*chp))
{
chp++;
}
@@ -313,7 +312,7 @@ mi_parse::mi_parse (const char *cmd, std::string *token)
{
const char *tmp = chp + 1; /* discard ``-'' */
- for (; *chp && !isspace (*chp); chp++)
+ for (; *chp && !c_isspace (*chp); chp++)
;
this->command = make_unique_xstrndup (tmp, chp - tmp);
}
@@ -391,7 +390,7 @@ mi_parse::mi_parse (const char *cmd, std::string *token)
else
break;
- if (*chp != '\0' && !isspace (*chp))
+ if (*chp != '\0' && !c_isspace (*chp))
error (_("Invalid value for the '%s' option"), option);
chp = skip_spaces (chp);
}
diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
index 7b58220..404e4cd 100644
--- a/gdb/microblaze-tdep.c
+++ b/gdb/microblaze-tdep.c
@@ -590,6 +590,98 @@ microblaze_stabs_argument_has_addr (struct gdbarch *gdbarch, struct type *type)
return (type->length () == 16);
}
+/* Return next pc values : next in sequence and/or branch/return target. */
+
+static std::vector<CORE_ADDR>
+microblaze_get_next_pcs (regcache *regcache)
+{
+ CORE_ADDR pc = regcache_read_pc (regcache);
+ unsigned long insn = microblaze_fetch_instruction (pc);
+
+ enum microblaze_instr_type insn_type;
+ short delay_slots;
+ bool isunsignednum;
+
+ /* If the current instruction is an imm, look at the inst after. */
+
+ get_insn_microblaze (insn, &isunsignednum, &insn_type, &delay_slots);
+
+ int imm;
+ bool immfound = false;
+
+ if (insn_type == immediate_inst)
+ {
+ int rd, ra, rb;
+ immfound = true;
+ microblaze_decode_insn (insn, &rd, &ra, &rb, &imm);
+ pc += INST_WORD_SIZE;
+ insn = microblaze_fetch_instruction (pc);
+ get_insn_microblaze (insn, &isunsignednum, &insn_type, &delay_slots);
+ }
+
+ std::optional<CORE_ADDR> next_pc, branch_or_return_pc;
+
+ /* Compute next instruction address - skip delay slots if any. */
+
+ if (insn_type != return_inst)
+ next_pc = pc + INST_WORD_SIZE + (delay_slots * INST_WORD_SIZE);
+
+ microblaze_debug ("single-step insn_type=0x%x pc=%s insn=0x%lx",
+ insn_type, core_addr_to_string_nz (pc), insn);
+
+ /* Compute target instruction address for branch or return instruction. */
+ if (insn_type == branch_inst || insn_type == return_inst)
+ {
+ int limm;
+ int lrd, lra, lrb;
+ bool targetvalid;
+ bool unconditionalbranch;
+
+ microblaze_decode_insn (insn, &lrd, &lra, &lrb, &limm);
+
+ ULONGEST ra = regcache_raw_get_unsigned (regcache, lra);
+ ULONGEST rb = regcache_raw_get_unsigned (regcache, lrb);
+
+ branch_or_return_pc
+ = microblaze_get_target_address (insn, immfound,
+ imm, pc, ra, rb, &targetvalid,
+ &unconditionalbranch);
+
+ microblaze_debug ("single-step uncondbr=%d targetvalid=%d target=%s",
+ unconditionalbranch, targetvalid,
+ core_addr_to_string_nz (*branch_or_return_pc));
+
+ /* Can't reach next address. */
+ if (unconditionalbranch)
+ next_pc.reset ();
+
+ /* Can't reach a distinct (not here) target address. */
+ if (!targetvalid
+ || branch_or_return_pc == pc
+ || (next_pc.has_value () && (branch_or_return_pc == next_pc)))
+ branch_or_return_pc.reset ();
+ } /* if (branch or return instruction). */
+
+ /* Create next_pcs vector to return. */
+
+ std::vector<CORE_ADDR> next_pcs;
+
+ if (next_pc.has_value ())
+ {
+ next_pcs.push_back (*next_pc);
+ microblaze_debug ("push_back next_pc(%s)",
+ core_addr_to_string_nz (*next_pc));
+ }
+
+ if (branch_or_return_pc.has_value ())
+ {
+ next_pcs.push_back (*branch_or_return_pc);
+ microblaze_debug ("push_back branch_or_return_pc(%s)",
+ core_addr_to_string_nz (*branch_or_return_pc));
+ }
+
+ return next_pcs;
+}
static int dwarf2_to_reg_map[78] =
{ 0 /* r0 */, 1 /* r1 */, 2 /* r2 */, 3 /* r3 */, /* 0- 3 */
@@ -715,6 +807,8 @@ microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_sw_breakpoint_from_kind (gdbarch,
microblaze_breakpoint::bp_from_kind);
+ set_gdbarch_get_next_pcs (gdbarch, microblaze_get_next_pcs);
+
set_gdbarch_frame_args_skip (gdbarch, 8);
set_gdbarch_unwind_pc (gdbarch, microblaze_unwind_pc);
diff --git a/gdb/microblaze-tdep.h b/gdb/microblaze-tdep.h
index b2fb5e7..852c9eb 100644
--- a/gdb/microblaze-tdep.h
+++ b/gdb/microblaze-tdep.h
@@ -118,6 +118,6 @@ struct microblaze_frame_cache
/* MICROBLAZE_BREAKPOINT defines the breakpoint that should be used.
Only used for native debugging. */
-#define MICROBLAZE_BREAKPOINT {0xb9, 0xcc, 0x00, 0x60}
+#define MICROBLAZE_BREAKPOINT {0xba, 0x0c, 0x00, 0x18}
#endif /* GDB_MICROBLAZE_TDEP_H */
diff --git a/gdb/mingw-hdep.c b/gdb/mingw-hdep.c
index a4e9cf5..f24d2f5 100644
--- a/gdb/mingw-hdep.c
+++ b/gdb/mingw-hdep.c
@@ -25,6 +25,7 @@
#include "cli/cli-style.h"
#include "command.h"
#include "cli/cli-cmds.h"
+#include "terminal.h"
#include <windows.h>
#include <signal.h>
@@ -448,61 +449,11 @@ install_sigint_handler (c_c_handler_ftype *fn)
return result;
}
-/* Set stdout and stderr handles to translation mode MODE. */
+/* See terminal.h. */
-static void
-set_console_translation_mode (int mode)
-{
- setmode (fileno (stdout), mode);
- setmode (fileno (stderr), mode);
-}
-
-/* Arg in "maint set console-translation-mode <arg>. */
-
-static std::string maint_console_translation_mode;
-
-/* Current value of "maint set/show console-translation-mode". */
-
-static std::string console_translation_mode = "unknown";
-
-/* Sets the console translation mode. */
-
-static void
-set_maint_console_translation_mode (const char *args, int from_tty,
- struct cmd_list_element *c)
-{
- if (maint_console_translation_mode == "binary")
- set_console_translation_mode (O_BINARY);
- else if (maint_console_translation_mode == "text")
- set_console_translation_mode (O_TEXT);
- else
- error (_("Invalid console translation mode: %s"),
- maint_console_translation_mode.c_str ());
-
- console_translation_mode = maint_console_translation_mode;
-}
-
-/* Shows the console translation mode. */
-
-static void
-show_maint_console_translation_mode (struct ui_file *file, int from_tty,
- struct cmd_list_element *c,
- const char *value)
-{
- gdb_printf (file, _("Console translation mode is %s.\n"),
- console_translation_mode.c_str ());
-}
-
-INIT_GDB_FILE (mingw_hdep)
+void
+set_output_translation_mode_binary ()
{
- add_setshow_string_cmd ("console-translation-mode",
- class_maintenance,
- &maint_console_translation_mode, _("\
-Set the translation mode of stdout/stderr."), _("\
-Show the translation mode of stdout/stderr."), _("\
-Use \"binary\", or \"text\""),
- set_maint_console_translation_mode,
- show_maint_console_translation_mode,
- &maintenance_set_cmdlist,
- &maintenance_show_cmdlist);
+ setmode (fileno (stdout), O_BINARY);
+ setmode (fileno (stderr), O_BINARY);
}
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 4a6459a..c4a0fa8 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -36,7 +36,6 @@
to figure out what full symbol table entries need to be read in. */
-#include <ctype.h>
#include "maint.h"
#include "symtab.h"
#include "bfd.h"
@@ -52,7 +51,6 @@
#include "cli/cli-utils.h"
#include "gdbsupport/symbol.h"
#include <algorithm>
-#include "gdbsupport/gdb-safe-ctype.h"
#include "gdbsupport/parallel-for.h"
#include "inferior.h"
@@ -712,11 +710,11 @@ static int
frob_address (struct objfile *objfile, CORE_ADDR pc,
unrelocated_addr *unrel_addr)
{
- for (obj_section *iter : objfile->sections ())
+ for (obj_section &iter : objfile->sections ())
{
- if (iter->contains (pc))
+ if (iter.contains (pc))
{
- *unrel_addr = unrelocated_addr (pc - iter->offset ());
+ *unrel_addr = unrelocated_addr (pc - iter.offset ());
return 1;
}
}
diff --git a/gdb/minsyms.h b/gdb/minsyms.h
index 709faa5..dcab475 100644
--- a/gdb/minsyms.h
+++ b/gdb/minsyms.h
@@ -195,7 +195,7 @@ unsigned int msymbol_hash_iw (const char *);
requirements. */
#define SYMBOL_HASH_NEXT(hash, c) \
- ((hash) * 67 + TOLOWER ((unsigned char) (c)) - 113)
+ ((hash) * 67 + c_tolower (c) - 113)
diff --git a/gdb/mips-fbsd-tdep.c b/gdb/mips-fbsd-tdep.c
index c1b5f9c..dc549b5 100644
--- a/gdb/mips-fbsd-tdep.c
+++ b/gdb/mips-fbsd-tdep.c
@@ -480,6 +480,8 @@ mips_fbsd_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc)
struct mips_fbsd_ilp32_solib_ops : public svr4_solib_ops
{
+ using svr4_solib_ops::svr4_solib_ops;
+
/* FreeBSD/MIPS uses a slightly different `struct link_map' than the
other FreeBSD platforms as it includes an additional `l_off' member. */
@@ -489,9 +491,9 @@ struct mips_fbsd_ilp32_solib_ops : public svr4_solib_ops
/* Return a new solib_ops for ILP32 FreeBSD/MIPS systems. */
static solib_ops_up
-make_mips_fbsd_ilp32_solib_ops ()
+make_mips_fbsd_ilp32_solib_ops (program_space *pspace)
{
- return std::make_unique<mips_fbsd_ilp32_solib_ops> ();
+ return std::make_unique<mips_fbsd_ilp32_solib_ops> (pspace);
}
/* See mips_fbsd_ilp32_solib_ops. */
@@ -528,6 +530,8 @@ mips_fbsd_ilp32_solib_ops::fetch_link_map_offsets () const
struct mips_fbsd_lp64_solib_ops : public svr4_solib_ops
{
+ using svr4_solib_ops::svr4_solib_ops;
+
/* FreeBSD/MIPS uses a slightly different `struct link_map' than the
other FreeBSD platforms as it includes an additional `l_off' member. */
@@ -537,9 +541,9 @@ struct mips_fbsd_lp64_solib_ops : public svr4_solib_ops
/* Return a new solib_ops for LP64 FreeBSD/MIPS systems. */
static solib_ops_up
-make_mips_fbsd_lp64_solib_ops ()
+make_mips_fbsd_lp64_solib_ops (program_space *pspace)
{
- return std::make_unique<mips_fbsd_lp64_solib_ops> ();
+ return std::make_unique<mips_fbsd_lp64_solib_ops> (pspace);
}
/* See mips_fbsd_lp64_solib_ops. */
@@ -580,7 +584,7 @@ mips_fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
/* Generic FreeBSD support. */
fbsd_init_abi (info, gdbarch);
- set_gdbarch_software_single_step (gdbarch, mips_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, mips_software_single_step);
switch (abi)
{
diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c
index e4fa243..b668bcb 100644
--- a/gdb/mips-linux-tdep.c
+++ b/gdb/mips-linux-tdep.c
@@ -671,6 +671,8 @@ mips_linux_in_dynsym_stub (CORE_ADDR pc)
template <typename Base>
struct mips_linux_svr4_solib_ops : public Base
{
+ using Base::Base;
+
bool in_dynsym_resolve_code (CORE_ADDR pc) const override;
};
@@ -700,9 +702,9 @@ using mips_linux_ilp32_svr4_solib_ops
/* Return a new solib_ops for ILP32 Linux/MIPS systems. */
static solib_ops_up
-make_mips_linux_ilp32_svr4_solib_ops ()
+make_mips_linux_ilp32_svr4_solib_ops (program_space *pspace)
{
- return std::make_unique<mips_linux_ilp32_svr4_solib_ops> ();
+ return std::make_unique<mips_linux_ilp32_svr4_solib_ops> (pspace);
}
/* solib_ops for LP64 Linux/MIPS systems. */
@@ -713,9 +715,9 @@ using mips_linux_lp64_svr4_solib_ops
/* Return a new solib_ops for LP64 Linux/MIPS systems. */
static solib_ops_up
-make_mips_linux_lp64_svr4_solib_ops ()
+make_mips_linux_lp64_svr4_solib_ops (program_space *pspace)
{
- return std::make_unique<mips_linux_lp64_svr4_solib_ops> ();
+ return std::make_unique<mips_linux_lp64_svr4_solib_ops> (pspace);
}
/* See the comments for SKIP_SOLIB_RESOLVER at the top of infrun.c,
@@ -1605,7 +1607,7 @@ mips_linux_init_abi (struct gdbarch_info info,
set_gdbarch_skip_solib_resolver (gdbarch, mips_linux_skip_resolver);
- set_gdbarch_software_single_step (gdbarch, mips_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, mips_software_single_step);
/* Enable TLS support. */
set_gdbarch_fetch_tls_load_module_address (gdbarch,
diff --git a/gdb/mips-netbsd-tdep.c b/gdb/mips-netbsd-tdep.c
index 42eb515..3c54c32 100644
--- a/gdb/mips-netbsd-tdep.c
+++ b/gdb/mips-netbsd-tdep.c
@@ -292,6 +292,8 @@ mipsnbsd_cannot_store_register (struct gdbarch *gdbarch, int regno)
struct mips_nbsd_ilp32_svr4_solib_ops : public svr4_solib_ops
{
+ using svr4_solib_ops::svr4_solib_ops;
+
/* NetBSD/MIPS uses a slightly different `struct link_map' than the
other NetBSD platforms. */
link_map_offsets *fetch_link_map_offsets () const override;
@@ -300,9 +302,9 @@ struct mips_nbsd_ilp32_svr4_solib_ops : public svr4_solib_ops
/* Return a new solib_ops for ILP32 NetBSD/MIPS systems. */
static solib_ops_up
-make_mips_nbsd_ilp32_svr4_solib_ops ()
+make_mips_nbsd_ilp32_svr4_solib_ops (program_space *pspace)
{
- return std::make_unique<mips_nbsd_ilp32_svr4_solib_ops> ();
+ return std::make_unique<mips_nbsd_ilp32_svr4_solib_ops> (pspace);
}
/* See mips_nbsd_ilp32_svr4_solib_ops. */
@@ -340,6 +342,8 @@ mips_nbsd_ilp32_svr4_solib_ops::fetch_link_map_offsets () const
struct mips_nbsd_lp64_svr4_solib_ops : public svr4_solib_ops
{
+ using svr4_solib_ops::svr4_solib_ops;
+
/* NetBSD/MIPS uses a slightly different `struct link_map' than the
other NetBSD platforms. */
link_map_offsets *fetch_link_map_offsets () const override;
@@ -348,9 +352,9 @@ struct mips_nbsd_lp64_svr4_solib_ops : public svr4_solib_ops
/* Return a new solib_ops for LP64 NetBSD/MIPS systems. */
static solib_ops_up
-make_mips_nbsd_lp64_svr4_solib_ops ()
+make_mips_nbsd_lp64_svr4_solib_ops (program_space *pspace)
{
- return std::make_unique<mips_nbsd_lp64_svr4_solib_ops> ();
+ return std::make_unique<mips_nbsd_lp64_svr4_solib_ops> (pspace);
}
/* See mips_nbsd_lp64_svr4_solib_ops. */
@@ -399,7 +403,7 @@ mipsnbsd_init_abi (struct gdbarch_info info,
set_gdbarch_cannot_fetch_register (gdbarch, mipsnbsd_cannot_fetch_register);
set_gdbarch_cannot_store_register (gdbarch, mipsnbsd_cannot_store_register);
- set_gdbarch_software_single_step (gdbarch, mips_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, mips_software_single_step);
/* NetBSD/mips has SVR4-style shared libraries. */
set_solib_svr4_ops (gdbarch, (gdbarch_ptr_bit (gdbarch) == 32
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 32f832b..d072b9a 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -487,7 +487,7 @@ msymbol_is_micromips (struct minimal_symbol *msym)
static void
mips_make_symbol_special (struct symbol *sym, struct objfile *objfile)
{
- if (sym->aclass () == LOC_BLOCK)
+ if (sym->loc_class () == LOC_BLOCK)
{
/* We are in symbol reading so it is OK to cast away constness. */
struct block *block = (struct block *) sym->value_block ();
diff --git a/gdb/moxie-tdep.c b/gdb/moxie-tdep.c
index 2239406..bb48877 100644
--- a/gdb/moxie-tdep.c
+++ b/gdb/moxie-tdep.c
@@ -1088,7 +1088,7 @@ moxie_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
frame_unwind_append_unwinder (gdbarch, &moxie_frame_unwind);
/* Single stepping. */
- set_gdbarch_software_single_step (gdbarch, moxie_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, moxie_software_single_step);
/* Support simple overlay manager. */
set_gdbarch_overlay_update (gdbarch, simple_overlay_update);
diff --git a/gdb/nat/aarch64-hw-point.c b/gdb/nat/aarch64-hw-point.c
index 6d8dce8..8c0854b 100644
--- a/gdb/nat/aarch64-hw-point.c
+++ b/gdb/nat/aarch64-hw-point.c
@@ -710,10 +710,8 @@ aarch64_stopped_data_address (const struct aarch64_debug_reg_state *state,
itself. For instance, the access size of an stp instruction is 16.
So, if we use stp to store to address p, and set a watchpoint on
address p + 8, the reported ADDR_TRAP can be p + 8 (observed on
- RK3399 SOC). But it also can be p (observed on M1 SOC). Checking
- for this situation introduces the possibility of false positives,
- so we only do this for hw_write watchpoints. */
- const CORE_ADDR max_access_size = type == hw_write ? 16 : 8;
+ RK3399 SOC). But it also can be p (observed on M1 SOC). */
+ const CORE_ADDR max_access_size = 16;
const CORE_ADDR addr_watch_base = addr_watch_aligned -
(max_access_size - AARCH64_HWP_MAX_LEN_PER_REG);
if (!(addr_trap >= addr_watch_base
diff --git a/gdb/nat/linux-osdata.c b/gdb/nat/linux-osdata.c
index b52a8ed..0a309b8 100644
--- a/gdb/nat/linux-osdata.c
+++ b/gdb/nat/linux-osdata.c
@@ -21,7 +21,6 @@
#include <sys/types.h>
#include <sys/sysinfo.h>
-#include <ctype.h>
#include <utmp.h>
#include <time.h>
#include <unistd.h>
@@ -205,7 +204,7 @@ get_cores_used_by_process (PID_T pid, int *cores, const int num_cores)
PID_T tid;
int core;
- if (!isdigit (dp->d_name[0])
+ if (!c_isdigit (dp->d_name[0])
|| NAMELEN (dp) > MAX_PID_T_STRLEN)
continue;
@@ -310,7 +309,7 @@ linux_xfer_osdata_processes ()
std::string cores_str;
int i;
- if (!isdigit (dp->d_name[0])
+ if (!c_isdigit (dp->d_name[0])
|| NAMELEN (dp) > MAX_PID_T_STRLEN)
continue;
@@ -419,7 +418,7 @@ linux_xfer_osdata_processgroups ()
{
PID_T pid, pgid;
- if (!isdigit (dp->d_name[0])
+ if (!c_isdigit (dp->d_name[0])
|| NAMELEN (dp) > MAX_PID_T_STRLEN)
continue;
@@ -483,7 +482,7 @@ linux_xfer_osdata_threads ()
struct stat statbuf;
char procentry[sizeof ("/proc/4294967295")];
- if (!isdigit (dp->d_name[0])
+ if (!c_isdigit (dp->d_name[0])
|| NAMELEN (dp) > sizeof ("4294967295") - 1)
continue;
@@ -513,7 +512,7 @@ linux_xfer_osdata_threads ()
PID_T tid;
int core;
- if (!isdigit (dp2->d_name[0])
+ if (!c_isdigit (dp2->d_name[0])
|| NAMELEN (dp2) > sizeof ("4294967295") - 1)
continue;
@@ -633,7 +632,7 @@ linux_xfer_osdata_fds ()
struct stat statbuf;
char procentry[sizeof ("/proc/4294967295")];
- if (!isdigit (dp->d_name[0])
+ if (!c_isdigit (dp->d_name[0])
|| NAMELEN (dp) > sizeof ("4294967295") - 1)
continue;
@@ -662,7 +661,7 @@ linux_xfer_osdata_fds ()
char buf[1000];
ssize_t rslt;
- if (!isdigit (dp2->d_name[0]))
+ if (!c_isdigit (dp2->d_name[0]))
continue;
std::string fdname
diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c
index f73058b..7df85c1 100644
--- a/gdb/nat/linux-ptrace.c
+++ b/gdb/nat/linux-ptrace.c
@@ -24,12 +24,46 @@
#endif
#include "gdbsupport/eintr.h"
#include "gdbsupport/signals-state-save-restore.h"
+#include "gdbsupport/gdb_file.h"
/* Stores the ptrace options supported by the running kernel.
A value of -1 means we did not check for features yet. A value
of 0 means there are no supported features. */
static int supported_ptrace_options = -1;
+/* The file from which the kernel.yama.ptrace_scope setting is read. */
+
+static constexpr char ptrace_scope_filename[]
+ = "/proc/sys/kernel/yama/ptrace_scope";
+
+/* Reads the yama ptrace_scope value from /proc. Returns the integer value
+ of ptrace_scope (0, 1, 2, or 3) or -1 if the file cannot be read (e.g.,
+ yama is not enabled). */
+
+static int
+get_ptrace_scope ()
+{
+ int ptrace_scope = -1;
+
+ /* The /proc file that contains the system-wide ptrace scope setting. */
+ gdb_file_up fp (fopen (ptrace_scope_filename, "r"));
+ if (fp != nullptr)
+ {
+ if (fscanf (fp.get (), "%d", &ptrace_scope) != 1)
+ {
+ /* If fscanf fails then we couldn't parse the number. But just
+ to be safe, set the scope back to -1 to indicate no value is
+ available. */
+ ptrace_scope = -1;
+ }
+ }
+
+ /* If fp is NULL, it's likely because the yama security module is not
+ active. In this case, we return -1 to indicate that the scope is
+ unknown or not applicable. */
+ return ptrace_scope;
+}
+
/* Find all possible reasons we could fail to attach PID and return these
as a string. An empty string is returned if we didn't find any reason. */
@@ -44,6 +78,13 @@ linux_ptrace_attach_fail_reason (pid_t pid)
_("process %d is already traced by process %d"),
(int) pid, (int) tracerpid);
+ int ptrace_scope = get_ptrace_scope ();
+ if (ptrace_scope > 0)
+ string_appendf (result,
+ _("the %s setting of %d might prevent attaching, "
+ "see 'man 2 ptrace'"),
+ ptrace_scope_filename, ptrace_scope);
+
if (linux_proc_pid_is_zombie_nowarn (pid))
string_appendf (result,
_("process %d is a zombie - the process has already "
diff --git a/gdb/nat/x86-gcc-cpuid.h b/gdb/nat/x86-gcc-cpuid.h
index 1498100..9e27fd8 100644
--- a/gdb/nat/x86-gcc-cpuid.h
+++ b/gdb/nat/x86-gcc-cpuid.h
@@ -1,5 +1,5 @@
/*
- * Helper cpuid.h file copied from gcc-6.0.0. Code in gdb should not
+ * Helper cpuid.h file copied from gcc-14.2.0. Code in gdb should not
* include this directly, but pull in x86-cpuid.h and use that func.
*/
@@ -55,7 +55,7 @@
#define bit_SSE (1 << 25)
#define bit_SSE2 (1 << 26)
-/* Extended Features */
+/* Extended Features (%eax == 0x80000001) */
/* %ecx */
#define bit_LAHF_LM (1 << 0)
#define bit_ABM (1 << 5)
@@ -68,29 +68,28 @@
#define bit_MWAITX (1 << 29)
/* %edx */
-#define bit_AVX5124VNNIW (1 << 2)
-#define bit_AVX5124FMAPS (1 << 3)
#define bit_MMXEXT (1 << 22)
#define bit_LM (1 << 29)
#define bit_3DNOWP (1 << 30)
-#define bit_3DNOW (1 << 31)
+#define bit_3DNOW (1u << 31)
-/* %ebx. */
+/* %ebx */
#define bit_CLZERO (1 << 0)
+#define bit_WBNOINVD (1 << 9)
-/* Extended Features (%eax == 7) */
+/* Extended Features Leaf (%eax == 7, %ecx == 0) */
/* %ebx */
#define bit_FSGSBASE (1 << 0)
-#define bit_BMI (1 << 3)
-#define bit_HLE (1 << 4)
+#define bit_SGX (1 << 2)
+#define bit_BMI (1 << 3)
+#define bit_HLE (1 << 4)
#define bit_AVX2 (1 << 5)
#define bit_BMI2 (1 << 8)
-#define bit_RTM (1 << 11)
-#define bit_MPX (1 << 14)
+#define bit_RTM (1 << 11)
#define bit_AVX512F (1 << 16)
#define bit_AVX512DQ (1 << 17)
#define bit_RDSEED (1 << 18)
-#define bit_ADX (1 << 19)
+#define bit_ADX (1 << 19)
#define bit_AVX512IFMA (1 << 21)
#define bit_CLFLUSHOPT (1 << 23)
#define bit_CLWB (1 << 24)
@@ -99,23 +98,85 @@
#define bit_AVX512CD (1 << 28)
#define bit_SHA (1 << 29)
#define bit_AVX512BW (1 << 30)
-#define bit_AVX512VL (1 << 31)
+#define bit_AVX512VL (1u << 31)
/* %ecx */
-#define bit_PREFETCHWT1 (1 << 0)
+#define bit_PREFETCHWT1 (1 << 0)
#define bit_AVX512VBMI (1 << 1)
-#define bit_PKU (1 << 3)
+#define bit_PKU (1 << 3)
#define bit_OSPKE (1 << 4)
+#define bit_WAITPKG (1 << 5)
+#define bit_AVX512VBMI2 (1 << 6)
+#define bit_SHSTK (1 << 7)
+#define bit_GFNI (1 << 8)
+#define bit_VAES (1 << 9)
+#define bit_VPCLMULQDQ (1 << 10)
+#define bit_AVX512VNNI (1 << 11)
+#define bit_AVX512BITALG (1 << 12)
+#define bit_AVX512VPOPCNTDQ (1 << 14)
+#define bit_RDPID (1 << 22)
+#define bit_KL (1 << 23)
+#define bit_CLDEMOTE (1 << 25)
+#define bit_MOVDIRI (1 << 27)
+#define bit_MOVDIR64B (1 << 28)
+#define bit_ENQCMD (1 << 29)
-/* XFEATURE_ENABLED_MASK register bits (%eax == 13, %ecx == 0) */
-#define bit_BNDREGS (1 << 3)
-#define bit_BNDCSR (1 << 4)
+/* %edx */
+#define bit_AVX5124VNNIW (1 << 2)
+#define bit_AVX5124FMAPS (1 << 3)
+#define bit_UINTR (1 << 5)
+#define bit_AVX512VP2INTERSECT (1 << 8)
+#define bit_SERIALIZE (1 << 14)
+#define bit_TSXLDTRK (1 << 16)
+#define bit_PCONFIG (1 << 18)
+#define bit_IBT (1 << 20)
+#define bit_AMX_BF16 (1 << 22)
+#define bit_AVX512FP16 (1 << 23)
+#define bit_AMX_TILE (1 << 24)
+#define bit_AMX_INT8 (1 << 25)
+
+/* Extended Features Sub-leaf (%eax == 7, %ecx == 1) */
+/* %eax */
+#define bit_SHA512 (1 << 0)
+#define bit_SM3 (1 << 1)
+#define bit_SM4 (1 << 2)
+#define bit_RAOINT (1 << 3)
+#define bit_AVXVNNI (1 << 4)
+#define bit_AVX512BF16 (1 << 5)
+#define bit_CMPCCXADD (1 << 7)
+#define bit_AMX_COMPLEX (1 << 8)
+#define bit_AMX_FP16 (1 << 21)
+#define bit_HRESET (1 << 22)
+#define bit_AVXIFMA (1 << 23)
-/* Extended State Enumeration Sub-leaf (%eax == 13, %ecx == 1) */
+/* %edx */
+#define bit_AVXVNNIINT8 (1 << 4)
+#define bit_AVXNECONVERT (1 << 5)
+#define bit_AVXVNNIINT16 (1 << 10)
+#define bit_PREFETCHI (1 << 14)
+#define bit_USER_MSR (1 << 15)
+#define bit_AVX10 (1 << 19)
+#define bit_APX_F (1 << 21)
+
+/* Extended State Enumeration Sub-leaf (%eax == 0xd, %ecx == 1) */
#define bit_XSAVEOPT (1 << 0)
#define bit_XSAVEC (1 << 1)
#define bit_XSAVES (1 << 3)
+/* PT sub leaf (%eax == 0x14, %ecx == 0) */
+/* %ebx */
+#define bit_PTWRITE (1 << 4)
+
+/* Keylocker leaf (%eax == 0x19) */
+/* %ebx */
+#define bit_AESKLE ( 1<<0 )
+#define bit_WIDEKL ( 1<<2 )
+
+/* AVX10 sub leaf (%eax == 0x24) */
+/* %ebx */
+#define bit_AVX10_256 (1 << 17)
+#define bit_AVX10_512 (1 << 18)
+
/* Signatures for different CPU implementations as returned in uses
of cpuid with level 0. */
#define signature_AMD_ebx 0x68747541
@@ -170,19 +231,40 @@
#define signature_VORTEX_ecx 0x436f5320
#define signature_VORTEX_edx 0x36387865
-#define __cpuid(level, a, b, c, d) \
- __asm__ ("cpuid\n\t" \
- : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \
- : "0" (level))
+#define signature_SHANGHAI_ebx 0x68532020
+#define signature_SHANGHAI_ecx 0x20206961
+#define signature_SHANGHAI_edx 0x68676e61
-#define __cpuid_count(level, count, a, b, c, d) \
- __asm__ ("cpuid\n\t" \
- : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \
- : "0" (level), "2" (count))
+#ifndef __x86_64__
+/* At least one cpu (Winchip 2) does not set %ebx and %ecx
+ for cpuid leaf 1. Forcibly zero the two registers before
+ calling cpuid as a precaution. */
+#define __cpuid(level, a, b, c, d) \
+ do { \
+ if (__builtin_constant_p (level) && (level) != 1) \
+ __asm__ __volatile__ ("cpuid\n\t" \
+ : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \
+ : "0" (level)); \
+ else \
+ __asm__ __volatile__ ("cpuid\n\t" \
+ : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \
+ : "0" (level), "1" (0), "2" (0)); \
+ } while (0)
+#else
+#define __cpuid(level, a, b, c, d) \
+ __asm__ __volatile__ ("cpuid\n\t" \
+ : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \
+ : "0" (level))
+#endif
+
+#define __cpuid_count(level, count, a, b, c, d) \
+ __asm__ __volatile__ ("cpuid\n\t" \
+ : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \
+ : "0" (level), "2" (count))
/* Return highest supported input value for cpuid instruction. ext can
- be either 0x0 or 0x8000000 to return highest supported value for
+ be either 0x0 or 0x80000000 to return highest supported value for
basic or extended cpuid information. Function returns 0 if cpuid
is not supported or whatever cpuid returns in eax register. If sig
pointer is non-null, then first four bytes of the signature
@@ -225,7 +307,7 @@ __get_cpuid_max (unsigned int __ext, unsigned int *__sig)
: "i" (0x00200000));
#endif
- if (!((__eax ^ __ebx) & 0x00200000))
+ if (__builtin_expect (!((__eax ^ __ebx) & 0x00200000), 0))
return 0;
#endif
@@ -249,8 +331,9 @@ __get_cpuid (unsigned int __leaf,
unsigned int *__ecx, unsigned int *__edx)
{
unsigned int __ext = __leaf & 0x80000000;
+ unsigned int __maxlevel = __get_cpuid_max (__ext, 0);
- if (__get_cpuid_max (__ext, 0) < __leaf)
+ if (__maxlevel == 0 || __maxlevel < __leaf)
return 0;
__cpuid (__leaf, *__eax, *__ebx, *__ecx, *__edx);
@@ -265,12 +348,20 @@ __get_cpuid_count (unsigned int __leaf, unsigned int __subleaf,
unsigned int *__ecx, unsigned int *__edx)
{
unsigned int __ext = __leaf & 0x80000000;
+ unsigned int __maxlevel = __get_cpuid_max (__ext, 0);
- if (__get_cpuid_max (__ext, 0) < __leaf)
+ if (__builtin_expect (__maxlevel == 0, 0) || __maxlevel < __leaf)
return 0;
__cpuid_count (__leaf, __subleaf, *__eax, *__ebx, *__ecx, *__edx);
return 1;
}
+static __inline void
+__cpuidex (int __cpuid_info[4], int __leaf, int __subleaf)
+{
+ __cpuid_count (__leaf, __subleaf, __cpuid_info[0], __cpuid_info[1],
+ __cpuid_info[2], __cpuid_info[3]);
+}
+
#endif /* GDB_NAT_X86_GCC_CPUID_H */
diff --git a/gdb/nat/x86-linux-tdesc.c b/gdb/nat/x86-linux-tdesc.c
index 80e4337..5bc36b6 100644
--- a/gdb/nat/x86-linux-tdesc.c
+++ b/gdb/nat/x86-linux-tdesc.c
@@ -43,7 +43,7 @@
/* See nat/x86-linux-tdesc.h. */
const target_desc *
-x86_linux_tdesc_for_tid (int tid, uint64_t *xcr0_storage,
+x86_linux_tdesc_for_tid (int tid, uint64_t *xstate_bv_storage,
x86_xsave_layout *xsave_layout_storage)
{
#ifdef __x86_64__
@@ -96,30 +96,34 @@ x86_linux_tdesc_for_tid (int tid, uint64_t *xcr0_storage,
these bits being set we generate a completely empty tdesc for
i386 which will be rejected by GDB. */
have_ptrace_getregset = TRIBOOL_FALSE;
- *xcr0_storage = X86_XSTATE_SSE_MASK;
+ *xstate_bv_storage = X86_XSTATE_SSE_MASK;
}
else
{
have_ptrace_getregset = TRIBOOL_TRUE;
/* Get XCR0 from XSAVE extended state. */
- *xcr0_storage = xstateregs[(I386_LINUX_XSAVE_XCR0_OFFSET
+ uint64_t xcr0 = xstateregs[(I386_LINUX_XSAVE_XCR0_OFFSET
/ sizeof (uint64_t))];
*xsave_layout_storage
- = x86_fetch_xsave_layout (*xcr0_storage, x86_xsave_length ());
+ = x86_fetch_xsave_layout (xcr0, x86_xsave_length ());
+
+ *xstate_bv_storage = xcr0;
+ if (x86_check_ssp_support (tid))
+ *xstate_bv_storage |= X86_XSTATE_CET_U;
}
}
- /* Use cached xcr0 value. */
- uint64_t xcr0_features_bits = *xcr0_storage & X86_XSTATE_ALL_MASK;
+ /* Use cached XSTATE_BV_STORAGE value. */
+ uint64_t xstate_bv_features_bits = *xstate_bv_storage & X86_XSTATE_ALL_MASK;
#ifdef __x86_64__
if (is_64bit)
- return amd64_linux_read_description (xcr0_features_bits, is_x32);
+ return amd64_linux_read_description (xstate_bv_features_bits, is_x32);
else
#endif
- return i386_linux_read_description (xcr0_features_bits);
+ return i386_linux_read_description (xstate_bv_features_bits);
}
#endif /* !IN_PROCESS_AGENT */
diff --git a/gdb/nat/x86-linux-tdesc.h b/gdb/nat/x86-linux-tdesc.h
index 38c71f1..19aa84f 100644
--- a/gdb/nat/x86-linux-tdesc.h
+++ b/gdb/nat/x86-linux-tdesc.h
@@ -27,9 +27,9 @@ struct x86_xsave_layout;
/* Return the target description for Linux thread TID.
- The storage pointed to by XCR0_STORAGE and XSAVE_LAYOUT_STORAGE must
+ The storage pointed to by XSTATE_BV_STORAGE and XSAVE_LAYOUT_STORAGE must
exist until the program (GDB or gdbserver) terminates, this storage is
- used to cache the xcr0 and xsave layout values. The values pointed to
+ used to cache the xstate_bv and xsave layout values. The values pointed to
by these arguments are only updated at most once, the first time this
function is called if the have_ptrace_getregset global is set to
TRIBOOL_UNKNOWN.
@@ -45,6 +45,7 @@ struct x86_xsave_layout;
returned. */
extern const target_desc *x86_linux_tdesc_for_tid
- (int tid, uint64_t *xcr0_storage, x86_xsave_layout *xsave_layout_storage);
+ (int tid, uint64_t *xstate_bv_storage,
+ x86_xsave_layout *xsave_layout_storage);
#endif /* GDB_NAT_X86_LINUX_TDESC_H */
diff --git a/gdb/nat/x86-linux.c b/gdb/nat/x86-linux.c
index 0bdff73..5515826 100644
--- a/gdb/nat/x86-linux.c
+++ b/gdb/nat/x86-linux.c
@@ -17,6 +17,12 @@
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 "elf/common.h"
+#include "gdbsupport/common-defs.h"
+#include "nat/gdb_ptrace.h"
+#include "nat/linux-ptrace.h"
+#include "nat/x86-cpuid.h"
+#include <sys/uio.h>
#include "x86-linux.h"
#include "x86-linux-dregs.h"
#include "nat/gdb_ptrace.h"
@@ -126,3 +132,56 @@ x86_linux_ptrace_get_arch_size (int tid)
return x86_linux_arch_size (false, false);
#endif
}
+
+/* See nat/x86-linux.h. */
+
+bool
+x86_check_ssp_support (const int tid)
+{
+ /* It's not enough to check shadow stack support with the ptrace call
+ below only, as we cannot distinguish between shadow stack not enabled
+ for the current thread and shadow stack is not supported by HW. In
+ both scenarios the ptrace call fails with ENODEV. In case shadow
+ stack is not enabled for the current thread, we still want to return
+ true. */
+ unsigned int eax, ebx, ecx, edx;
+ eax = ebx = ecx = edx = 0;
+
+ if (!__get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx))
+ return false;
+
+ if ((ecx & bit_SHSTK) == 0)
+ return false;
+
+ /* Further check for NT_X86_SHSTK kernel support. */
+ uint64_t ssp;
+ iovec iov {&ssp, sizeof (ssp) };
+
+ errno = 0;
+ int res = ptrace (PTRACE_GETREGSET, tid, NT_X86_SHSTK, &iov);
+ if (res < 0)
+ {
+ if (errno == EINVAL)
+ {
+ /* The errno EINVAL for a PTRACE_GETREGSET call indicates that
+ kernel support is not available. */
+ return false;
+ }
+ else if (errno == ENODEV)
+ {
+ /* At this point, since we already checked CPUID, the errno
+ ENODEV for a PTRACE_GETREGSET call indicates that shadow
+ stack is not enabled for the current thread. As it could be
+ enabled later, we still want to return true here. */
+ return true;
+ }
+ else
+ {
+ warning (_("Unknown ptrace error for NT_X86_SHSTK: %s"),
+ safe_strerror (errno));
+ return false;
+ }
+ }
+
+ return true;
+}
diff --git a/gdb/nat/x86-linux.h b/gdb/nat/x86-linux.h
index dbdef08..1783aae 100644
--- a/gdb/nat/x86-linux.h
+++ b/gdb/nat/x86-linux.h
@@ -75,4 +75,8 @@ private:
extern x86_linux_arch_size x86_linux_ptrace_get_arch_size (int tid);
+/* Check shadow stack hardware and kernel support. */
+
+extern bool x86_check_ssp_support (const int tid);
+
#endif /* GDB_NAT_X86_LINUX_H */
diff --git a/gdb/netbsd-nat.c b/gdb/netbsd-nat.c
index 060134f..207e69c 100644
--- a/gdb/netbsd-nat.c
+++ b/gdb/netbsd-nat.c
@@ -318,7 +318,7 @@ nbsd_nat_target::info_proc (const char *args, enum info_proc_what what)
if (pid == 0)
error (_("No current process: you must name one."));
}
- else if (built_argv.count () == 1 && isdigit (built_argv[0][0]))
+ else if (built_argv.count () == 1 && c_isdigit (built_argv[0][0]))
pid = strtol (built_argv[0], NULL, 10);
else
error (_("Invalid arguments."));
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 6bba8d3..492020d 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -46,7 +46,6 @@
#include "cli/cli-utils.h"
#include "c-exp.h"
-#include <ctype.h>
#include <algorithm>
struct objc_object {
@@ -850,9 +849,9 @@ parse_selector (char *method, char **selector)
for (;;)
{
- if (isalnum (*s2) || (*s2 == '_') || (*s2 == ':'))
+ if (c_isalnum (*s2) || (*s2 == '_') || (*s2 == ':'))
*s1++ = *s2;
- else if (isspace (*s2))
+ else if (c_isspace (*s2))
;
else if ((*s2 == '\0') || (*s2 == '\''))
break;
@@ -914,7 +913,7 @@ parse_method (char *method, char *type, char **theclass,
s1++;
nclass = s1;
- while (isalnum (*s1) || (*s1 == '_'))
+ while (c_isalnum (*s1) || (*s1 == '_'))
s1++;
s2 = s1;
@@ -925,7 +924,7 @@ parse_method (char *method, char *type, char **theclass,
s2++;
s2 = skip_spaces (s2);
ncategory = s2;
- while (isalnum (*s2) || (*s2 == '_'))
+ while (c_isalnum (*s2) || (*s2 == '_'))
s2++;
*s2++ = '\0';
}
@@ -938,9 +937,9 @@ parse_method (char *method, char *type, char **theclass,
for (;;)
{
- if (isalnum (*s2) || (*s2 == '_') || (*s2 == ':'))
+ if (c_isalnum (*s2) || (*s2 == '_') || (*s2 == ':'))
*s1++ = *s2;
- else if (isspace (*s2))
+ else if (c_isspace (*s2))
;
else if (*s2 == ']')
break;
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index d25d1a0..d0eb678 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -189,7 +189,7 @@ objfile_lookup_static_link (struct objfile *objfile,
static void
add_to_objfile_sections (struct bfd *abfd, struct bfd_section *asect,
- struct objfile *objfile, int force)
+ struct objfile *objfile, int force)
{
struct obj_section *section;
@@ -521,8 +521,8 @@ relocate_one_symbol (struct symbol *sym, struct objfile *objfile,
any symbols in STRUCT_DOMAIN or UNDEF_DOMAIN.
But I'm leaving out that test, on the theory that
they can't possibly pass the tests below. */
- if ((sym->aclass () == LOC_LABEL
- || sym->aclass () == LOC_STATIC)
+ if ((sym->loc_class () == LOC_LABEL
+ || sym->loc_class () == LOC_STATIC)
&& sym->section_index () >= 0)
sym->set_value_address (sym->value_address ()
+ delta[sym->section_index ()]);
@@ -587,12 +587,12 @@ objfile_relocate1 (struct objfile *objfile,
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 ())
+ for (obj_section &s : objfile->sections ())
{
- int idx = s - objfile->sections_start;
+ int idx = &s - objfile->sections_start;
exec_set_section_address (bfd_get_filename (objfile->obfd.get ()), idx,
- s->addr ());
+ s.addr ());
}
/* Data changed. */
@@ -790,10 +790,10 @@ sort_cmp (const struct obj_section *sect1, const obj_section *sect2)
second case shouldn't occur during normal use, but std::sort
does check that '!(a < a)' when compiled in debug mode. */
- for (const obj_section *osect : objfile1->sections ())
- if (osect == sect2)
+ for (const obj_section &osect : objfile1->sections ())
+ if (&osect == sect2)
return false;
- else if (osect == sect1)
+ else if (&osect == sect1)
return true;
/* We should have found one of the sections before getting here. */
@@ -994,8 +994,8 @@ update_section_map (struct program_space *pspace,
alloc_size = 0;
for (objfile *objfile : pspace->objfiles ())
- for (obj_section *s : objfile->sections ())
- if (insert_section_p (objfile->obfd.get (), s->the_bfd_section))
+ for (obj_section &s : objfile->sections ())
+ if (insert_section_p (objfile->obfd.get (), s.the_bfd_section))
alloc_size += 1;
/* This happens on detach/attach (e.g. in gdb.base/attach.exp). */
@@ -1010,9 +1010,9 @@ update_section_map (struct program_space *pspace,
i = 0;
for (objfile *objfile : pspace->objfiles ())
- for (obj_section *s : objfile->sections ())
- if (insert_section_p (objfile->obfd.get (), s->the_bfd_section))
- map[i++] = s;
+ for (obj_section &s : objfile->sections ())
+ if (insert_section_p (objfile->obfd.get (), s.the_bfd_section))
+ map[i++] = &s;
std::sort (map, map + alloc_size, sort_cmp);
map_size = filter_debuginfo_sections(map, alloc_size);
@@ -1127,12 +1127,12 @@ is_addr_in_objfile (CORE_ADDR addr, const struct objfile *objfile)
if (objfile == NULL)
return false;
- for (obj_section *osect : objfile->sections ())
+ for (obj_section &osect : objfile->sections ())
{
- if (section_is_overlay (osect) && !section_is_mapped (osect))
+ if (section_is_overlay (&osect) && !section_is_mapped (&osect))
continue;
- if (osect->contains (addr))
+ if (osect.contains (addr))
return true;
}
return false;
@@ -1154,24 +1154,6 @@ shared_objfile_contains_address_p (struct program_space *pspace,
return false;
}
-/* The default implementation for the "iterate_over_objfiles_in_search_order"
- gdbarch method. It is equivalent to use the objfiles iterable,
- searching the objfiles in the order they are stored internally,
- ignoring CURRENT_OBJFILE.
-
- On most platforms, it should be close enough to doing the best
- we can without some knowledge specific to the architecture. */
-
-void
-default_iterate_over_objfiles_in_search_order
- (gdbarch *gdbarch, iterate_over_objfiles_in_search_order_cb_ftype cb,
- objfile *current_objfile)
-{
- for (objfile *objfile : current_program_space->objfiles ())
- if (cb (objfile))
- return;
-}
-
/* See objfiles.h. */
const char *
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 4a34758..1ce5092 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -395,7 +395,9 @@ struct obj_section
return addr >= this->addr () && addr < endaddr ();
}
- /* BFD section pointer */
+ /* BFD section pointer. This is nullptr if the corresponding BFD section is
+ not allocatable (!SEC_ALLOC), in which case this obj_section can be
+ considered NULL / empty. */
struct bfd_section *the_bfd_section;
/* Objfile this section is part of. */
@@ -583,10 +585,6 @@ public:
/* See quick_symbol_functions. */
void dump ();
- /* Find all the symbols in OBJFILE named FUNC_NAME, and ensure that
- the corresponding symbol tables are loaded. */
- void expand_symtabs_for_function (const char *func_name);
-
/* See quick_symbol_functions. */
void expand_all_symtabs ();
@@ -598,14 +596,14 @@ public:
void expand_symtabs_with_fullname (const char *fullname);
/* See quick_symbol_functions. */
- bool expand_symtabs_matching
- (expand_symtabs_file_matcher file_matcher,
+ bool search
+ (search_symtabs_file_matcher file_matcher,
const lookup_name_info *lookup_name,
- expand_symtabs_symbol_matcher symbol_matcher,
- expand_symtabs_expansion_listener expansion_notify,
+ search_symtabs_symbol_matcher symbol_matcher,
+ search_symtabs_expansion_listener listener,
block_search_flags search_flags,
domain_search_flags domain,
- expand_symtabs_lang_matcher lang_matcher = nullptr);
+ search_symtabs_lang_matcher lang_matcher = nullptr);
/* See quick_symbol_functions. */
struct compunit_symtab *
@@ -655,61 +653,18 @@ public:
this->section_offsets[idx] = offset;
}
- class section_iterator
+ /* Filter function for section_iterator. */
+ struct filter_out_null_bfd_section
{
- public:
- section_iterator (const section_iterator &) = default;
- section_iterator (section_iterator &&) = default;
- section_iterator &operator= (const section_iterator &) = default;
- section_iterator &operator= (section_iterator &&) = default;
-
- typedef section_iterator self_type;
- typedef obj_section *value_type;
-
- value_type operator* ()
- { return m_iter; }
-
- section_iterator &operator++ ()
- {
- ++m_iter;
- skip_null ();
- return *this;
- }
-
- bool operator== (const section_iterator &other) const
- { return m_iter == other.m_iter && m_end == other.m_end; }
-
- bool operator!= (const section_iterator &other) const
- { return !(*this == other); }
-
- private:
-
- friend class objfile;
-
- section_iterator (obj_section *iter, obj_section *end)
- : m_iter (iter),
- m_end (end)
- {
- skip_null ();
- }
-
- void skip_null ()
- {
- while (m_iter < m_end && m_iter->the_bfd_section == nullptr)
- ++m_iter;
- }
-
- value_type m_iter;
- value_type m_end;
+ bool operator() (const obj_section &sec) const noexcept
+ { return sec.the_bfd_section != nullptr; }
};
- iterator_range<section_iterator> sections ()
- {
- return (iterator_range<section_iterator>
- (section_iterator (sections_start, sections_end),
- section_iterator (sections_end, sections_end)));
- }
+ using section_iterator = filtered_iterator<obj_section *, filter_out_null_bfd_section>;
+ /* Return an iterable that yields the "non-null" sections of this objfile.
+ That is, the sections for which obj_section::the_bfd_section is
+ non-nullptr. */
iterator_range<section_iterator> sections () const
{
return (iterator_range<section_iterator>
@@ -1010,10 +965,6 @@ in_plt_section (CORE_ADDR pc)
extern scoped_restore_tmpl<int> inhibit_section_map_updates
(struct program_space *pspace);
-extern void default_iterate_over_objfiles_in_search_order
- (gdbarch *gdbarch, iterate_over_objfiles_in_search_order_cb_ftype cb,
- objfile *current_objfile);
-
/* Reset the per-BFD storage area on OBJ. */
void set_objfile_per_bfd (struct objfile *obj);
diff --git a/gdb/or1k-linux-tdep.c b/gdb/or1k-linux-tdep.c
index afefefe..9fbf75f 100644
--- a/gdb/or1k-linux-tdep.c
+++ b/gdb/or1k-linux-tdep.c
@@ -153,7 +153,7 @@ or1k_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
/* GNU/Linux uses the dynamic linker included in the GNU C Library. */
set_gdbarch_skip_solib_resolver (gdbarch, glibc_skip_solib_resolver);
- set_gdbarch_software_single_step (gdbarch, or1k_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, or1k_software_single_step);
/* Enable TLS support. */
set_gdbarch_fetch_tls_load_module_address (gdbarch,
diff --git a/gdb/or1k-tdep.c b/gdb/or1k-tdep.c
index 2774840..2db207d 100644
--- a/gdb/or1k-tdep.c
+++ b/gdb/or1k-tdep.c
@@ -29,7 +29,6 @@
#include "gdbtypes.h"
#include "target.h"
#include "regcache.h"
-#include "gdbsupport/gdb-safe-ctype.h"
#include "reggroups.h"
#include "arch-utils.h"
#include "frame-unwind.h"
diff --git a/gdb/p-exp.y b/gdb/p-exp.y
index cbf6b44..a68443a 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp.y
@@ -43,7 +43,6 @@
Probably also lots of other problems, less well defined PM. */
%{
-#include <ctype.h>
#include "expression.h"
#include "value.h"
#include "parser-defs.h"
@@ -817,13 +816,13 @@ parse_number (struct parser_state *par_state,
{
/* Handle suffixes: 'f' for float, 'l' for long double.
FIXME: This appears to be an extension -- do we want this? */
- if (len >= 1 && tolower (p[len - 1]) == 'f')
+ if (len >= 1 && c_tolower (p[len - 1]) == 'f')
{
putithere->typed_val_float.type
= parse_type (par_state)->builtin_float;
len--;
}
- else if (len >= 1 && tolower (p[len - 1]) == 'l')
+ else if (len >= 1 && c_tolower (p[len - 1]) == 'l')
{
putithere->typed_val_float.type
= parse_type (par_state)->builtin_long_double;
@@ -1089,9 +1088,9 @@ yylex (void)
if (explen > 2)
for (const auto &token : tokentab3)
if (strncasecmp (tokstart, token.oper, 3) == 0
- && (!isalpha (token.oper[0]) || explen == 3
- || (!isalpha (tokstart[3])
- && !isdigit (tokstart[3]) && tokstart[3] != '_')))
+ && (!c_isalpha (token.oper[0]) || explen == 3
+ || (!c_isalpha (tokstart[3])
+ && !c_isdigit (tokstart[3]) && tokstart[3] != '_')))
{
pstate->lexptr += 3;
yylval.opcode = token.opcode;
@@ -1102,9 +1101,9 @@ yylex (void)
if (explen > 1)
for (const auto &token : tokentab2)
if (strncasecmp (tokstart, token.oper, 2) == 0
- && (!isalpha (token.oper[0]) || explen == 2
- || (!isalpha (tokstart[2])
- && !isdigit (tokstart[2]) && tokstart[2] != '_')))
+ && (!c_isalpha (token.oper[0]) || explen == 2
+ || (!c_isalpha (tokstart[2])
+ && !c_isdigit (tokstart[2]) && tokstart[2] != '_')))
{
pstate->lexptr += 2;
yylval.opcode = token.opcode;
@@ -1519,7 +1518,7 @@ yylex (void)
/* Call lookup_symtab, not lookup_partial_symtab, in case there are
no psymtabs (coff, xcoff, or some future change to blow away the
psymtabs once once symbols are read). */
- if ((sym && sym->aclass () == LOC_BLOCK)
+ if ((sym && sym->loc_class () == LOC_BLOCK)
|| lookup_symtab (current_program_space, tmp.c_str ()))
{
yylval.ssym.sym.symbol = sym;
@@ -1528,7 +1527,7 @@ yylex (void)
free (uptokstart);
return BLOCKNAME;
}
- if (sym && sym->aclass () == LOC_TYPEDEF)
+ if (sym && sym->loc_class () == LOC_TYPEDEF)
{
#if 1
/* Despite the following flaw, we need to keep this code enabled.
@@ -1597,7 +1596,7 @@ yylex (void)
SEARCH_VFT, NULL).symbol;
if (cur_sym)
{
- if (cur_sym->aclass () == LOC_TYPEDEF)
+ if (cur_sym->loc_class () == LOC_TYPEDEF)
{
best_sym = cur_sym;
pstate->lexptr = p;
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 3ded152..1dc1a34 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -30,7 +30,6 @@
#include "p-lang.h"
#include "valprint.h"
#include "value.h"
-#include <ctype.h>
#include "c-lang.h"
#include "gdbarch.h"
#include "cli/cli-style.h"
diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c
index 7994ccf..8b5f2b5 100644
--- a/gdb/p-typeprint.c
+++ b/gdb/p-typeprint.c
@@ -30,7 +30,6 @@
#include "p-lang.h"
#include "typeprint.h"
#include "gdb-demangle.h"
-#include <ctype.h>
#include "cli/cli-style.h"
/* See language.h. */
@@ -138,13 +137,13 @@ pascal_language::type_print_method_args (const char *physname,
{
gdb_puts (" (", stream);
/* We must demangle this. */
- while (isdigit (physname[0]))
+ while (c_isdigit (physname[0]))
{
int len = 0;
int i, j;
char *argname;
- while (isdigit (physname[len]))
+ while (c_isdigit (physname[len]))
{
len++;
}
diff --git a/gdb/parse.c b/gdb/parse.c
index 6ad4e71..e24a0d0 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -29,7 +29,6 @@
during the process of parsing; the lower levels of the tree always
come first in the result. */
-#include <ctype.h>
#include "arch-utils.h"
#include "symtab.h"
#include "gdbtypes.h"
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index 5067b89..b5f8bbf 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -61,7 +61,6 @@
#include "cli/cli-utils.h"
#include "parser-defs.h"
#include "user-regs.h"
-#include <ctype.h>
#include "elf-bfd.h"
#include "producer.h"
#include "target-float.h"
@@ -309,6 +308,8 @@ static const struct ppc_insn_pattern powerpc32_plt_stub_so_2[] =
struct ppc_linux_ilp32_svr4_solib_ops : public linux_ilp32_svr4_solib_ops
{
+ using linux_ilp32_svr4_solib_ops::linux_ilp32_svr4_solib_ops;
+
/* Check if PC is in PLT stub. For non-secure PLT, stub is in .plt
section. For secure PLT, stub is in .text and we need to check
instruction patterns. */
@@ -319,9 +320,9 @@ struct ppc_linux_ilp32_svr4_solib_ops : public linux_ilp32_svr4_solib_ops
/* Return a new solib_ops for ILP32 PowerPC/Linux systems. */
static solib_ops_up
-make_ppc_linux_ilp32_svr4_solib_ops ()
+make_ppc_linux_ilp32_svr4_solib_ops (program_space *pspace)
{
- return std::make_unique<ppc_linux_ilp32_svr4_solib_ops> ();
+ return std::make_unique<ppc_linux_ilp32_svr4_solib_ops> (pspace);
}
/* See ppc_linux_ilp32_svr4_solib_ops. */
@@ -1710,10 +1711,10 @@ static int
ppc_stap_is_single_operand (struct gdbarch *gdbarch, const char *s)
{
return (*s == 'i' /* Literal number. */
- || (isdigit (*s) && s[1] == '('
- && isdigit (s[2])) /* Displacement. */
- || (*s == '(' && isdigit (s[1])) /* Register indirection. */
- || isdigit (*s)); /* Register value. */
+ || (c_isdigit (*s) && s[1] == '('
+ && c_isdigit (s[2])) /* Displacement. */
+ || (*s == '(' && c_isdigit (s[1])) /* Register indirection. */
+ || c_isdigit (*s)); /* Register value. */
}
/* Implementation of `gdbarch_stap_parse_special_token', as defined in
@@ -1723,7 +1724,7 @@ static expr::operation_up
ppc_stap_parse_special_token (struct gdbarch *gdbarch,
struct stap_parse_info *p)
{
- if (isdigit (*p->arg))
+ if (c_isdigit (*p->arg))
{
/* This temporary pointer is needed because we have to do a lookahead.
We could be dealing with a register displacement, and in such case
@@ -1732,7 +1733,7 @@ ppc_stap_parse_special_token (struct gdbarch *gdbarch,
char *regname;
int len;
- while (isdigit (*s))
+ while (c_isdigit (*s))
++s;
if (*s == '(')
diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
index cae5aa6..f872f73 100644
--- a/gdb/ppc-sysv-tdep.c
+++ b/gdb/ppc-sysv-tdep.c
@@ -2060,10 +2060,12 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function,
}
/* Small character arrays are returned, right justified, in r3. */
- if (valtype->code () == TYPE_CODE_ARRAY
+ if (tdep->elf_abi == POWERPC_ELF_V1
+ && valtype->code () == TYPE_CODE_ARRAY
&& !valtype->is_vector ()
&& valtype->length () <= 8
- && valtype->target_type ()->code () == TYPE_CODE_INT
+ && (valtype->target_type ()->code () == TYPE_CODE_INT
+ || valtype->target_type ()->code () == TYPE_CODE_CHAR)
&& valtype->target_type ()->length () == 1)
{
int regnum = tdep->ppc_gp0_regnum + 3;
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 19fbc20..661d721 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -54,7 +54,6 @@
#include "source.h"
#include "gdbsupport/byte-vector.h"
#include <optional>
-#include "gdbsupport/gdb-safe-ctype.h"
#include "inferior.h"
/* Chain containing all defined memory-tag subcommands. */
@@ -753,10 +752,10 @@ pc_prefix (CORE_ADDR addr)
if (has_stack_frames ())
{
frame_info_ptr frame;
- CORE_ADDR pc;
+ std::optional<CORE_ADDR> pc;
frame = get_selected_frame (NULL);
- if (get_frame_pc_if_available (frame, &pc) && pc == addr)
+ if ((pc = get_frame_pc_if_available (frame)) && *pc == addr)
return "=> ";
}
return " ";
@@ -1290,7 +1289,9 @@ should_validate_memtags (gdbarch *gdbarch, struct value *value)
return false;
/* We do. Check whether it includes any tags. */
- return target_is_address_tagged (gdbarch, value_as_address (value));
+ struct type *val_type = value->type ();
+ const gdb_byte *data = value->contents ().data ();
+ return target_is_address_tagged (gdbarch, unpack_pointer (val_type, data));
}
/* Helper for parsing arguments for print_command_1. */
@@ -1492,27 +1493,27 @@ info_symbol_command (const char *arg, int from_tty)
addr = parse_and_eval_address (arg);
for (objfile *objfile : current_program_space->objfiles ())
- for (obj_section *osect : objfile->sections ())
+ for (obj_section &osect : objfile->sections ())
{
/* Only process each object file once, even if there's a separate
debug file. */
if (objfile->separate_debug_objfile_backlink)
continue;
- sect_addr = overlay_mapped_address (addr, osect);
+ sect_addr = overlay_mapped_address (addr, &osect);
- if (osect->contains (sect_addr)
+ if (osect.contains (sect_addr)
&& (msymbol
= lookup_minimal_symbol_by_pc_section (sect_addr,
- osect).minsym))
+ &osect).minsym))
{
const char *obj_name, *mapped, *sec_name, *msym_name;
const char *loc_string;
matches = 1;
offset = sect_addr - msymbol->value_address (objfile);
- mapped = section_is_mapped (osect) ? _("mapped") : _("unmapped");
- sec_name = osect->the_bfd_section->name;
+ mapped = section_is_mapped (&osect) ? _("mapped") : _("unmapped");
+ sec_name = osect.the_bfd_section->name;
msym_name = msymbol->print_name ();
/* Don't print the offset if it is zero.
@@ -1526,12 +1527,12 @@ info_symbol_command (const char *arg, int from_tty)
else
loc_string = msym_name;
- gdb_assert (osect->objfile && objfile_name (osect->objfile));
- obj_name = objfile_name (osect->objfile);
+ gdb_assert (osect.objfile && objfile_name (osect.objfile));
+ obj_name = objfile_name (osect.objfile);
if (current_program_space->multi_objfile_p ())
- if (pc_in_unmapped_range (addr, osect))
- if (section_is_overlay (osect))
+ if (pc_in_unmapped_range (addr, &osect))
+ if (section_is_overlay (&osect))
gdb_printf (_("%s in load address range of "
"%s overlay section %s of %s\n"),
loc_string, mapped, sec_name, obj_name);
@@ -1540,15 +1541,15 @@ info_symbol_command (const char *arg, int from_tty)
"section %s of %s\n"),
loc_string, sec_name, obj_name);
else
- if (section_is_overlay (osect))
+ if (section_is_overlay (&osect))
gdb_printf (_("%s in %s overlay section %s of %s\n"),
loc_string, mapped, sec_name, obj_name);
else
gdb_printf (_("%s in section %s of %s\n"),
loc_string, sec_name, obj_name);
else
- if (pc_in_unmapped_range (addr, osect))
- if (section_is_overlay (osect))
+ if (pc_in_unmapped_range (addr, &osect))
+ if (section_is_overlay (&osect))
gdb_printf (_("%s in load address range of %s overlay "
"section %s\n"),
loc_string, mapped, sec_name);
@@ -1557,7 +1558,7 @@ info_symbol_command (const char *arg, int from_tty)
(_("%s in load address range of section %s\n"),
loc_string, sec_name);
else
- if (section_is_overlay (osect))
+ if (section_is_overlay (&osect))
gdb_printf (_("%s in %s overlay section %s\n"),
loc_string, mapped, sec_name);
else
@@ -1653,7 +1654,7 @@ info_address_command (const char *exp, int from_tty)
return;
}
- switch (sym->aclass ())
+ switch (sym->loc_class ())
{
case LOC_CONST:
case LOC_CONST_BYTES:
@@ -2702,7 +2703,6 @@ ui_printf (const char *arg, struct ui_file *stream)
{
int nargs_wanted;
int i;
- const char *current_substring;
nargs_wanted = 0;
for (auto &&piece : fpieces)
@@ -2731,7 +2731,8 @@ ui_printf (const char *arg, struct ui_file *stream)
i = 0;
for (auto &&piece : fpieces)
{
- current_substring = piece.string;
+ const char *current_substring = fpieces.piece_str (piece);
+
switch (piece.argclass)
{
case string_arg:
diff --git a/gdb/probe.c b/gdb/probe.c
index 6679f39..c2b8270 100644
--- a/gdb/probe.c
+++ b/gdb/probe.c
@@ -33,7 +33,6 @@
#include "ax.h"
#include "ax-gdb.h"
#include "location.h"
-#include <ctype.h>
#include <algorithm>
#include <optional>
@@ -826,7 +825,7 @@ probe_is_linespec_by_keyword (const char **linespecp, const char *const *keyword
const char *keyword = *csp;
size_t len = strlen (keyword);
- if (strncmp (s, keyword, len) == 0 && isspace (s[len]))
+ if (strncmp (s, keyword, len) == 0 && c_isspace (s[len]))
{
*linespecp += len + 1;
return 1;
diff --git a/gdb/procfs.c b/gdb/procfs.c
index a10574a..ca7ecbb 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -38,7 +38,6 @@
#include <sys/syscall.h>
#include "gdbsupport/gdb_wait.h"
#include <signal.h>
-#include <ctype.h>
#include "gdb_bfd.h"
#include "auxv.h"
#include "procfs.h"
@@ -3304,7 +3303,7 @@ procfs_target::info_proc (const char *args, enum info_proc_what what)
gdb_argv built_argv (args);
for (char *arg : built_argv)
{
- if (isdigit (arg[0]))
+ if (c_isdigit (arg[0]))
{
pid = strtoul (arg, &tmp, 10);
if (*tmp == '/')
@@ -3415,7 +3414,7 @@ proc_trace_syscalls (const char *args, int from_tty, int entry_or_exit, int mode
error_no_arg (_("system call to trace"));
pi = find_procinfo_or_die (inferior_ptid.pid (), 0);
- if (isdigit (args[0]))
+ if (c_isdigit (args[0]))
{
const int syscallnum = atoi (args);
diff --git a/gdb/producer.c b/gdb/producer.c
index 5d754fa..71e1b92 100644
--- a/gdb/producer.c
+++ b/gdb/producer.c
@@ -66,9 +66,9 @@ producer_is_gcc (const char *producer, int *major, int *minor)
"GNU Fortran 4.8.2 20140120 (Red Hat 4.8.2-16) -mtune=generic ..."
"GNU C++14 5.0.0 20150123 (experimental)"
*/
- while (*cs && !isspace (*cs))
+ while (*cs && !c_isspace (*cs))
cs++;
- if (*cs && isspace (*cs))
+ if (*cs && c_isspace (*cs))
cs++;
if (sscanf (cs, "%d.%d", major, minor) == 2)
return 1;
diff --git a/gdb/progspace.c b/gdb/progspace.c
index 1c27165..9928c16 100644
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -146,6 +146,21 @@ program_space::free_all_objfiles ()
/* See progspace.h. */
void
+program_space::iterate_over_objfiles_in_search_order
+ (iterate_over_objfiles_in_search_order_cb_ftype cb, objfile *current_objfile)
+{
+ if (m_solib_ops != nullptr)
+ return m_solib_ops->iterate_over_objfiles_in_search_order
+ (cb, current_objfile);
+
+ for (const auto objfile : this->objfiles ())
+ if (cb (objfile))
+ return;
+}
+
+/* See progspace.h. */
+
+void
program_space::add_objfile (std::unique_ptr<objfile> &&objfile,
struct objfile *before)
{
diff --git a/gdb/progspace.h b/gdb/progspace.h
index a761e62..270a71d 100644
--- a/gdb/progspace.h
+++ b/gdb/progspace.h
@@ -212,6 +212,18 @@ struct program_space
(objfiles_range (objfiles_iterator (m_objfiles_list.begin ())));
}
+ /* Iterate over all objfiles of the program space in the order that makes the
+ most sense to make global symbol searches.
+
+ CB is a callback function passed an objfile to be searched. The iteration stops
+ if this function returns true.
+
+ If not nullptr, CURRENT_OBJFILE corresponds to the objfile being
+ inspected when the symbol search was requested. */
+ void iterate_over_objfiles_in_search_order
+ (iterate_over_objfiles_in_search_order_cb_ftype cb,
+ objfile *current_objfile);
+
/* Add OBJFILE to the list of objfiles, putting it just before
BEFORE. If BEFORE is nullptr, it will go at the end of the
list. */
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 516ba72..6d19e76 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -228,7 +228,7 @@ find_pc_sect_psymbol (struct objfile *objfile,
for (const partial_symbol *p : psymtab->global_psymbols)
{
if (p->domain == VAR_DOMAIN
- && p->aclass == LOC_BLOCK
+ && p->loc_class == LOC_BLOCK
&& pc >= p->address (objfile)
&& (p->address (objfile) > best_pc
|| (psymtab->text_low (objfile) == 0
@@ -248,7 +248,7 @@ find_pc_sect_psymbol (struct objfile *objfile,
for (const partial_symbol *p : psymtab->static_psymbols)
{
if (p->domain == VAR_DOMAIN
- && p->aclass == LOC_BLOCK
+ && p->loc_class == LOC_BLOCK
&& pc >= p->address (objfile)
&& (p->address (objfile) > best_pc
|| (psymtab->text_low (objfile) == 0
@@ -537,7 +537,7 @@ print_partial_symbols (struct gdbarch *gdbarch, struct objfile *objfile,
gdb_puts ("<invalid domain>, ", outfile);
break;
}
- switch (p->aclass)
+ switch (p->loc_class)
{
case LOC_UNDEF:
gdb_puts ("undefined", outfile);
@@ -790,7 +790,7 @@ psymtab_to_fullname (struct partial_symtab *ps)
return ps->fullname;
}
-/* A helper for psym_expand_symtabs_matching that handles searching
+/* A helper for psymbol_functions::search that handles searching
included psymtabs. This returns true if a symbol is found, and
false otherwise. It also updates the 'searched_flag' on the
various psymtabs that it searches. */
@@ -800,7 +800,7 @@ recursively_search_psymtabs (partial_symtab *ps, objfile *objfile,
block_search_flags search_flags,
domain_search_flags domain,
const lookup_name_info &lookup_name,
- expand_symtabs_symbol_matcher sym_matcher)
+ search_symtabs_symbol_matcher sym_matcher)
{
int keep_going = 1;
enum psymtab_search_status result = PST_SEARCHED_AND_NOT_FOUND;
@@ -885,19 +885,19 @@ recursively_search_psymtabs (partial_symtab *ps, objfile *objfile,
return result == PST_SEARCHED_AND_FOUND;
}
-/* Psymtab version of expand_symtabs_matching. See its definition in
+/* Psymtab version of search. See its definition in
the definition of quick_symbol_functions in symfile.h. */
bool
-psymbol_functions::expand_symtabs_matching
+psymbol_functions::search
(struct objfile *objfile,
- expand_symtabs_file_matcher file_matcher,
+ search_symtabs_file_matcher file_matcher,
const lookup_name_info *lookup_name,
- expand_symtabs_symbol_matcher symbol_matcher,
- expand_symtabs_expansion_listener expansion_notify,
+ search_symtabs_symbol_matcher symbol_matcher,
+ search_symtabs_expansion_listener listener,
block_search_flags search_flags,
domain_search_flags domain,
- expand_symtabs_lang_matcher lang_matcher ATTRIBUTE_UNUSED)
+ search_symtabs_lang_matcher lang_matcher ATTRIBUTE_UNUSED)
{
/* Clear the search flags. */
for (partial_symtab *ps : partial_symbols (objfile))
@@ -914,9 +914,6 @@ psymbol_functions::expand_symtabs_matching
{
QUIT;
- if (ps->readin_p (objfile))
- continue;
-
if (file_matcher)
{
bool match;
@@ -944,8 +941,8 @@ psymbol_functions::expand_symtabs_matching
{
compunit_symtab *cust = psymtab_to_symtab (objfile, ps);
- if (cust != nullptr && expansion_notify != nullptr)
- if (!expansion_notify (cust))
+ if (cust != nullptr && listener != nullptr)
+ if (!listener (cust))
return false;
}
}
@@ -1022,12 +1019,12 @@ psymbol_bcache::hash (const void *addr, int length)
struct partial_symbol *psymbol = (struct partial_symbol *) addr;
unsigned int lang = psymbol->ginfo.language ();
unsigned int domain = psymbol->domain;
- unsigned int theclass = psymbol->aclass;
+ unsigned int loc_class = psymbol->loc_class;
h = fast_hash (&psymbol->ginfo.m_value, sizeof (psymbol->ginfo.m_value), h);
h = fast_hash (&lang, sizeof (unsigned int), h);
h = fast_hash (&domain, sizeof (unsigned int), h);
- h = fast_hash (&theclass, sizeof (unsigned int), h);
+ h = fast_hash (&loc_class, sizeof (unsigned int), h);
/* Note that psymbol names are interned via compute_and_set_names, so
there's no need to hash the contents of the name here. */
h = fast_hash (&psymbol->ginfo.m_name, sizeof (psymbol->ginfo.m_name), h);
@@ -1047,7 +1044,7 @@ psymbol_bcache::compare (const void *addr1, const void *addr2, int length)
sizeof (sym1->ginfo.m_value)) == 0
&& sym1->ginfo.language () == sym2->ginfo.language ()
&& sym1->domain == sym2->domain
- && sym1->aclass == sym2->aclass
+ && sym1->loc_class == sym2->loc_class
/* Note that psymbol names are interned via
compute_and_set_names, so there's no need to compare the
contents of the name here. */
@@ -1085,7 +1082,7 @@ partial_symtab::add_psymbol (const partial_symbol &psymbol,
void
partial_symtab::add_psymbol (std::string_view name, bool copy_name,
domain_enum domain,
- enum address_class theclass,
+ location_class loc_class,
int section,
psymbol_placement where,
unrelocated_addr coreaddr,
@@ -1099,7 +1096,7 @@ partial_symtab::add_psymbol (std::string_view name, bool copy_name,
psymbol.set_unrelocated_address (coreaddr);
psymbol.ginfo.set_section_index (section);
psymbol.domain = domain;
- psymbol.aclass = theclass;
+ psymbol.loc_class = loc_class;
psymbol.ginfo.set_language (language, partial_symtabs->obstack ());
psymbol.ginfo.compute_and_set_names (name, copy_name, objfile->per_bfd);
@@ -1498,7 +1495,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
{
/* Skip symbols for inlined functions without address. These may
or may not have a match in the full symtab. */
- if (psym->aclass == LOC_BLOCK
+ if (psym->loc_class == LOC_BLOCK
&& psym->ginfo.value_address () == 0)
continue;
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index ad0b2ff..b1c3ad7 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -184,10 +184,10 @@ struct partial_symbol
ENUM_BITFIELD(domain_enum) domain : SYMBOL_DOMAIN_BITS;
/* Address class (for info_symbols). Note that we don't allow
- synthetic "aclass" values here at present, simply because there's
+ synthetic "loc_class" values here at present, simply because there's
no need. */
- ENUM_BITFIELD(address_class) aclass : SYMBOL_ACLASS_BITS;
+ ENUM_BITFIELD(location_class) loc_class : SYMBOL_LOC_CLASS_BITS;
};
/* A convenience enum to give names to some constants used when
@@ -333,7 +333,7 @@ struct partial_symtab
If COPY_NAME is true, make a copy of NAME, otherwise use the passed
reference.
- THECLASS is the type of symbol.
+ LOC_CLASS is the type of symbol.
SECTION is the index of the section of OBJFILE in which the symbol is found.
@@ -348,7 +348,7 @@ struct partial_symtab
void add_psymbol (std::string_view name,
bool copy_name, domain_enum domain,
- enum address_class theclass,
+ location_class loc_class,
int section,
psymbol_placement where,
unrelocated_addr coreaddr,
@@ -626,15 +626,15 @@ struct psymbol_functions : public quick_symbol_functions
void expand_all_symtabs (struct objfile *objfile) override;
- bool expand_symtabs_matching
+ bool search
(struct objfile *objfile,
- expand_symtabs_file_matcher file_matcher,
+ search_symtabs_file_matcher file_matcher,
const lookup_name_info *lookup_name,
- expand_symtabs_symbol_matcher symbol_matcher,
- expand_symtabs_expansion_listener expansion_notify,
+ search_symtabs_symbol_matcher symbol_matcher,
+ search_symtabs_expansion_listener listener,
block_search_flags search_flags,
domain_search_flags kind,
- expand_symtabs_lang_matcher lang_matcher) override;
+ search_symtabs_lang_matcher lang_matcher) override;
struct compunit_symtab *find_pc_sect_compunit_symtab
(struct objfile *objfile, bound_minimal_symbol msymbol, CORE_ADDR pc,
diff --git a/gdb/pyproject.toml b/gdb/pyproject.toml
index 4469f1c..144c489 100644
--- a/gdb/pyproject.toml
+++ b/gdb/pyproject.toml
@@ -3,3 +3,6 @@ include = "\\.py(\\.in)?$"
[tool.pyright]
typeCheckingMode = "strict"
+
+[tool.isort]
+profile = "black"
diff --git a/gdb/python/lib/gdb/dap/breakpoint.py b/gdb/python/lib/gdb/dap/breakpoint.py
index 4d4ca18..3162911 100644
--- a/gdb/python/lib/gdb/dap/breakpoint.py
+++ b/gdb/python/lib/gdb/dap/breakpoint.py
@@ -373,10 +373,12 @@ def set_insn_breakpoints(
@in_gdb_thread
def _catch_exception(filterId, **args):
if filterId in ("assert", "exception", "throw", "rethrow", "catch"):
- cmd = "-catch-" + filterId
+ cmd = ["-catch-" + filterId]
else:
raise DAPException("Invalid exception filterID: " + str(filterId))
- result = exec_mi_and_log(cmd)
+ if "exception" in args and args["exception"] is not None:
+ cmd += ["-e", args["exception"]]
+ result = exec_mi_and_log(*cmd)
# While the Ada catchpoints emit a "bkptno" field here, the C++
# ones do not. So, instead we look at the "number" field.
num = result["bkpt"]["number"]
@@ -404,6 +406,13 @@ def _rewrite_exception_breakpoint(
# Note that exception breakpoints do not support a hit count.
**args,
):
+ if filterId == "exception":
+ # Treat Ada exceptions specially -- in particular the
+ # condition is just an exception name, not an expression.
+ return {
+ "filterId": filterId,
+ "exception": condition,
+ }
return {
"filterId": filterId,
"condition": condition,
diff --git a/gdb/python/lib/gdb/dap/events.py b/gdb/python/lib/gdb/dap/events.py
index e8f2655..778acc5 100644
--- a/gdb/python/lib/gdb/dap/events.py
+++ b/gdb/python/lib/gdb/dap/events.py
@@ -161,7 +161,7 @@ _expected_pause = False
@in_gdb_thread
-def exec_and_expect_stop(cmd, expected_pause=False, propagate_exception=False):
+def exec_and_expect_stop(cmd, expected_pause=False):
"""A wrapper for exec_and_log that sets the continue-suppression flag.
When EXPECTED_PAUSE is True, a stop that looks like a pause (e.g.,
@@ -174,7 +174,7 @@ def exec_and_expect_stop(cmd, expected_pause=False, propagate_exception=False):
# continuing.
_suppress_cont = not expected_pause
# FIXME if the call fails should we clear _suppress_cont?
- exec_and_log(cmd, propagate_exception)
+ exec_and_log(cmd)
# Map from gdb stop reasons to DAP stop reasons. Some of these can't
diff --git a/gdb/python/lib/gdb/dap/next.py b/gdb/python/lib/gdb/dap/next.py
index 898fff1..993e9d2 100644
--- a/gdb/python/lib/gdb/dap/next.py
+++ b/gdb/python/lib/gdb/dap/next.py
@@ -17,7 +17,7 @@ import gdb
from .events import exec_and_expect_stop
from .server import capability, request
-from .startup import in_gdb_thread
+from .startup import DAPException, exec_and_log, in_gdb_thread
from .state import set_thread
@@ -36,11 +36,9 @@ def _handle_thread_step(thread_id, single_thread, select=False):
result = False
arg = "off"
try:
- # This can fail, depending on the target, so catch the error
- # and report to our caller. We can't use exec_and_log because
- # that does not propagate exceptions.
- gdb.execute("set scheduler-locking " + arg, from_tty=True, to_string=True)
- except gdb.error:
+ # This can fail, depending on the target, so catch any error.
+ exec_and_log("set scheduler-locking " + arg)
+ except DAPException:
result = False
# Other DAP code may select a frame, and the "finish" command uses
# the selected frame.
@@ -76,7 +74,7 @@ def step_in(
@request("stepOut")
def step_out(*, threadId: int, singleThread: bool = False, **args):
_handle_thread_step(threadId, singleThread, True)
- exec_and_expect_stop("finish &", propagate_exception=True)
+ exec_and_expect_stop("finish &")
@request("continue")
diff --git a/gdb/python/lib/gdb/dap/server.py b/gdb/python/lib/gdb/dap/server.py
index 7dab582..98a8084 100644
--- a/gdb/python/lib/gdb/dap/server.py
+++ b/gdb/python/lib/gdb/dap/server.py
@@ -398,7 +398,7 @@ class Server:
# responses are flushed to the client before exiting.
self._write_queue.put(None)
json_writer.join()
- send_gdb("quit")
+ send_gdb(lambda: exec_and_log("quit"))
@in_dap_thread
def set_defer_events(self):
@@ -614,7 +614,7 @@ def terminate(**args):
@capability("supportTerminateDebuggee")
def disconnect(*, terminateDebuggee: bool = False, **args):
if terminateDebuggee:
- send_gdb_with_response("kill")
+ send_gdb_with_response(lambda: exec_and_log("kill"))
_server.shutdown()
@@ -633,18 +633,6 @@ def cancel(**args):
return None
-class Invoker(object):
- """A simple class that can invoke a gdb command."""
-
- def __init__(self, cmd):
- self._cmd = cmd
-
- # This is invoked in the gdb thread to run the command.
- @in_gdb_thread
- def __call__(self):
- exec_and_log(self._cmd)
-
-
class Cancellable(object):
def __init__(self, fn, result_q=None):
@@ -677,25 +665,16 @@ class Cancellable(object):
def send_gdb(cmd):
"""Send CMD to the gdb thread.
- CMD can be either a function or a string.
- If it is a string, it is passed to gdb.execute."""
- if isinstance(cmd, str):
- cmd = Invoker(cmd)
-
+ CMD is a function."""
# Post the event and don't wait for the result.
gdb.post_event(Cancellable(cmd))
def send_gdb_with_response(fn):
"""Send FN to the gdb thread and return its result.
- If FN is a string, it is passed to gdb.execute and None is
- returned as the result.
If FN throws an exception, this function will throw the
same exception in the calling thread.
"""
- if isinstance(fn, str):
- fn = Invoker(fn)
-
# Post the event and wait for the result in result_q.
result_q = DAPQueue()
gdb.post_event(Cancellable(fn, result_q))
diff --git a/gdb/python/lib/gdb/dap/startup.py b/gdb/python/lib/gdb/dap/startup.py
index ab3e8fd..0c95ada 100644
--- a/gdb/python/lib/gdb/dap/startup.py
+++ b/gdb/python/lib/gdb/dap/startup.py
@@ -204,7 +204,7 @@ def log_stack(level=LogLevel.DEFAULT):
@in_gdb_thread
-def exec_and_log(cmd, propagate_exception=False):
+def exec_and_log(cmd):
"""Execute the gdb command CMD.
If logging is enabled, log the command and its output."""
log("+++ " + cmd)
@@ -213,10 +213,10 @@ def exec_and_log(cmd, propagate_exception=False):
if output != "":
log(">>> " + output)
except gdb.error as e:
- if propagate_exception:
- raise DAPException(str(e)) from e
- else:
- log_stack()
+ # Don't normally want to see this, as it interferes with the
+ # test suite.
+ log_stack(LogLevel.FULL)
+ raise DAPException(str(e)) from e
@in_gdb_thread
diff --git a/gdb/python/lib/gdb/dap/varref.py b/gdb/python/lib/gdb/dap/varref.py
index 8a13c51..d18197b 100644
--- a/gdb/python/lib/gdb/dap/varref.py
+++ b/gdb/python/lib/gdb/dap/varref.py
@@ -146,6 +146,10 @@ class BaseReference(ABC):
if self._children is None:
self._children = [None] * self.child_count()
for idx in range(start, start + count):
+ if idx >= len(self._children):
+ raise DAPException(
+ f"requested child {idx} outside range of variable {self._ref}"
+ )
if self._children[idx] is None:
(name, value) = self.fetch_one_child(idx)
name = self._compute_name(name)
@@ -242,7 +246,11 @@ class VariableReference(BaseReference):
# changed DAP to allow memory references for any of the
# variable response requests, and to lift the restriction
# to pointer-to-function from Variable.
- if self._value.type.strip_typedefs().code == gdb.TYPE_CODE_PTR:
+ if (
+ self._value.type.strip_typedefs().code == gdb.TYPE_CODE_PTR
+ and not self._value.is_optimized_out
+ and not self._value.is_unavailable
+ ):
result["memoryReference"] = hex(int(self._value))
if client_bool_capability("supportsVariableType"):
result["type"] = str(self._value.type)
diff --git a/gdb/python/lib/gdb/printing.py b/gdb/python/lib/gdb/printing.py
index cba27d2..f1ac19d 100644
--- a/gdb/python/lib/gdb/printing.py
+++ b/gdb/python/lib/gdb/printing.py
@@ -415,10 +415,21 @@ def make_visualizer(value):
result = NoOpArrayPrinter(ty, value)
elif ty.code in (gdb.TYPE_CODE_STRUCT, gdb.TYPE_CODE_UNION):
result = NoOpStructPrinter(ty, value)
- elif ty.code in (
- gdb.TYPE_CODE_PTR,
- gdb.TYPE_CODE_REF,
- gdb.TYPE_CODE_RVALUE_REF,
+ elif (
+ ty.code
+ in (
+ gdb.TYPE_CODE_PTR,
+ gdb.TYPE_CODE_REF,
+ gdb.TYPE_CODE_RVALUE_REF,
+ )
+ # Avoid "void *" here because those pointers can't be
+ # dereferenced without a cast.
+ and ty.target().code != gdb.TYPE_CODE_VOID
+ # An optimized-out or unavailable pointer should just be
+ # treated as a scalar, since there's no way to dereference
+ # it.
+ and not value.is_optimized_out
+ and not value.is_unavailable
):
result = NoOpPointerReferencePrinter(value)
else:
diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c
index fa7dd19..66ccad7 100644
--- a/gdb/python/py-block.c
+++ b/gdb/python/py-block.c
@@ -356,6 +356,9 @@ block_to_block_object (const struct block *block, struct objfile *objfile)
}
result = PyObject_New (block_object, &block_object_type);
+ if (result == nullptr)
+ return nullptr;
+
result->block = block;
result->objfile = objfile;
diff --git a/gdb/python/py-disasm.c b/gdb/python/py-disasm.c
index 17064dc..47ae99c 100644
--- a/gdb/python/py-disasm.c
+++ b/gdb/python/py-disasm.c
@@ -254,15 +254,15 @@ disasm_info_object_is_valid (disasm_info_object *obj)
/* Fill in OBJ with all the other arguments. */
static void
-disasm_info_fill (disasm_info_object *obj, struct gdbarch *gdbarch,
+disasm_info_fill (disasm_info_object &obj, struct gdbarch *gdbarch,
program_space *progspace, bfd_vma address,
disassemble_info *di, disasm_info_object *next)
{
- obj->gdbarch = gdbarch;
- obj->program_space = progspace;
- obj->address = address;
- obj->gdb_info = di;
- obj->next = next;
+ obj.gdbarch = gdbarch;
+ obj.program_space = progspace;
+ obj.address = address;
+ obj.gdb_info = di;
+ obj.next = next;
}
/* Implement DisassembleInfo.__init__. Takes a single argument that must
@@ -281,7 +281,7 @@ disasm_info_init (PyObject *self, PyObject *args, PyObject *kwargs)
disasm_info_object *other = (disasm_info_object *) info_obj;
disasm_info_object *info = (disasm_info_object *) self;
- disasm_info_fill (info, other->gdbarch, other->program_space,
+ disasm_info_fill (*info, other->gdbarch, other->program_space,
other->address, other->gdb_info, other->next);
other->next = info;
@@ -1156,19 +1156,18 @@ gdbpy_disassembler::gdbpy_disassembler (disasm_info_object *obj)
happens when gdbpy_print_insn returns. This class is responsible for
marking the DisassembleInfo as invalid in its destructor. */
-struct scoped_disasm_info_object
+struct scoped_invalidate_disasm_info
{
- /* Constructor. */
- scoped_disasm_info_object (struct gdbarch *gdbarch, CORE_ADDR memaddr,
- disassemble_info *info)
- : m_disasm_info (allocate_disasm_info_object ())
+ /* Constructor. Just cache DISASM_INFO for use in the destructor. */
+ scoped_invalidate_disasm_info
+ (gdbpy_ref<disasm_info_object> disasm_info)
+ : m_disasm_info (std::move (disasm_info))
{
- disasm_info_fill (m_disasm_info.get (), gdbarch, current_program_space,
- memaddr, info, nullptr);
+ /* Nothing. */
}
/* Upon destruction mark m_disasm_info as invalid. */
- ~scoped_disasm_info_object ()
+ ~scoped_invalidate_disasm_info ()
{
/* Invalidate the original DisassembleInfo object as well as any copies
that the user might have made. */
@@ -1178,30 +1177,15 @@ struct scoped_disasm_info_object
obj->gdb_info = nullptr;
}
- /* Return a pointer to the underlying disasm_info_object instance. */
- disasm_info_object *
- get () const
- {
- return m_disasm_info.get ();
- }
-
private:
- /* Wrapper around the call to PyObject_New, this wrapper function can be
- called from the constructor initialization list, while PyObject_New, a
- macro, can't. */
- static disasm_info_object *
- allocate_disasm_info_object ()
- {
- return (disasm_info_object *) PyObject_New (disasm_info_object,
- &disasm_info_object_type);
- }
-
/* A reference to a gdb.disassembler.DisassembleInfo object. When this
- containing instance goes out of scope this reference is released,
- however, the user might be holding other references to the
- DisassembleInfo object in Python code, so the underlying object might
- not be deleted. */
+ object goes out of scope this reference is released, however, the user
+ might be holding other references to the DisassembleInfo (either
+ directly, or via copies of this object), in which case the underlying
+ object will not be deleted. The destructor of this class ensures
+ that this DisassembleInfo object, and any copies, are all marked
+ invalid. */
gdbpy_ref<disasm_info_object> m_disasm_info;
};
@@ -1242,17 +1226,30 @@ gdbpy_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr,
return {};
}
- /* Create the new DisassembleInfo object we will pass into Python. This
- object will be marked as invalid when we leave this scope. */
- scoped_disasm_info_object scoped_disasm_info (gdbarch, memaddr, info);
- disasm_info_object *disasm_info = scoped_disasm_info.get ();
+ /* Create the new DisassembleInfo object we will pass into Python. */
+ gdbpy_ref<disasm_info_object> disasm_info
+ ((disasm_info_object *) PyObject_New (disasm_info_object,
+ &disasm_info_object_type));
+ if (disasm_info == nullptr)
+ {
+ gdbpy_print_stack ();
+ return {};
+ }
+
+ /* Initialise the DisassembleInfo object. */
+ disasm_info_fill (*disasm_info.get (), gdbarch, current_program_space,
+ memaddr, info, nullptr);
+
+ /* Ensure the DisassembleInfo, along with any copies the user makes, are
+ marked as invalid when we leave this scope. */
+ scoped_invalidate_disasm_info invalidate_disasm (disasm_info);
/* Call into the registered disassembler to (possibly) perform the
disassembly. */
- PyObject *insn_disas_obj = (PyObject *) disasm_info;
- gdbpy_ref<> result (PyObject_CallFunctionObjArgs (hook.get (),
- insn_disas_obj,
- nullptr));
+ gdbpy_ref<> result
+ (PyObject_CallFunctionObjArgs (hook.get (),
+ (PyObject *) disasm_info.get (),
+ nullptr));
if (result == nullptr)
{
diff --git a/gdb/python/py-event-types.def b/gdb/python/py-event-types.def
index 15cd9fa..83167f3 100644
--- a/gdb/python/py-event-types.def
+++ b/gdb/python/py-event-types.def
@@ -54,7 +54,7 @@ GDB_PY_DEFINE_EVENT_TYPE (new_thread,
GDB_PY_DEFINE_EVENT_TYPE (thread_exited,
"ThreadExitedEvent",
"GDB thread exited event object",
- event_object_type);
+ thread_event_object_type);
GDB_PY_DEFINE_EVENT_TYPE (new_inferior,
"NewInferiorEvent",
diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c
index 0ea629f..70e1684 100644
--- a/gdb/python/py-finishbreakpoint.c
+++ b/gdb/python/py-finishbreakpoint.c
@@ -175,7 +175,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
struct frame_id frame_id;
PyObject *internal = NULL;
int internal_bp = 0;
- CORE_ADDR pc;
+ std::optional<CORE_ADDR> pc;
if (!gdb_PyArg_ParseTupleAndKeywords (args, kwargs, "|OO", keywords,
&frame_obj, &internal))
@@ -249,9 +249,9 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
try
{
- if (get_frame_pc_if_available (frame, &pc))
+ if ((pc = get_frame_pc_if_available (frame)))
{
- struct symbol *function = find_pc_function (pc);
+ struct symbol *function = find_pc_function (*pc);
if (function != nullptr)
{
struct type *ret_type =
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
index adf4233..db8c274 100644
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -168,7 +168,7 @@ mi_should_print (struct symbol *sym, enum mi_print_types type)
{
int print_me = 0;
- switch (sym->aclass ())
+ switch (sym->loc_class ())
{
default:
case LOC_UNDEF: /* catches errors */
diff --git a/gdb/python/py-infevents.c b/gdb/python/py-infevents.c
index e63ba52..f74fb01 100644
--- a/gdb/python/py-infevents.c
+++ b/gdb/python/py-infevents.c
@@ -40,7 +40,7 @@ create_inferior_call_event_object (inferior_call_kind flag, ptid_t ptid,
gdb_assert_not_reached ("invalid inferior_call_kind");
}
- gdbpy_ref<> ptid_obj (gdbpy_create_ptid_object (ptid));
+ gdbpy_ref<> ptid_obj = gdbpy_create_ptid_object (ptid);
if (ptid_obj == NULL)
return NULL;
diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c
index 4f1f8d4..08533fe 100644
--- a/gdb/python/py-infthread.c
+++ b/gdb/python/py-infthread.c
@@ -190,7 +190,7 @@ thpy_get_ptid (PyObject *self, void *closure)
THPY_REQUIRE_VALID (thread_obj);
- return gdbpy_create_ptid_object (thread_obj->thread->ptid);
+ return gdbpy_create_ptid_object (thread_obj->thread->ptid).release ();
}
/* Implement gdb.InferiorThread.ptid_string attribute. */
@@ -361,23 +361,14 @@ thpy_repr (PyObject *self)
target_pid_to_str (thr->ptid).c_str ());
}
-/* Return a reference to a new Python object representing a ptid_t.
- The object is a tuple containing (pid, lwp, tid). */
-PyObject *
+/* See python-internal.h. */
+
+gdbpy_ref<>
gdbpy_create_ptid_object (ptid_t ptid)
{
- int pid;
- long lwp;
- ULONGEST tid;
- PyObject *ret;
-
- ret = PyTuple_New (3);
- if (!ret)
- return NULL;
-
- pid = ptid.pid ();
- lwp = ptid.lwp ();
- tid = ptid.tid ();
+ int pid = ptid.pid ();
+ long lwp = ptid.lwp ();
+ ULONGEST tid = ptid.tid ();
gdbpy_ref<> pid_obj = gdb_py_object_from_longest (pid);
if (pid_obj == nullptr)
@@ -389,10 +380,14 @@ gdbpy_create_ptid_object (ptid_t ptid)
if (tid_obj == nullptr)
return nullptr;
+ gdbpy_ref<> ret (PyTuple_New (3));
+ if (ret == nullptr)
+ return nullptr;
+
/* Note that these steal references, hence the use of 'release'. */
- PyTuple_SET_ITEM (ret, 0, pid_obj.release ());
- PyTuple_SET_ITEM (ret, 1, lwp_obj.release ());
- PyTuple_SET_ITEM (ret, 2, tid_obj.release ());
+ PyTuple_SET_ITEM (ret.get (), 0, pid_obj.release ());
+ PyTuple_SET_ITEM (ret.get (), 1, lwp_obj.release ());
+ PyTuple_SET_ITEM (ret.get (), 2, tid_obj.release ());
return ret;
}
diff --git a/gdb/python/py-mi.c b/gdb/python/py-mi.c
index 9b871d4..b2ab4e2 100644
--- a/gdb/python/py-mi.c
+++ b/gdb/python/py-mi.c
@@ -218,11 +218,11 @@ py_object_to_mi_key (PyObject *key_obj)
{
gdb_assert (name != nullptr);
- if (*name == '\0' || !isalpha (*name))
+ if (*name == '\0' || !c_isalpha (*name))
return false;
for (; *name != '\0'; ++name)
- if (!isalnum (*name) && *name != '_' && *name != '-')
+ if (!c_isalnum (*name) && *name != '_' && *name != '-')
return false;
return true;
@@ -363,7 +363,7 @@ gdbpy_notify_mi (PyObject *self, PyObject *args, PyObject *kwargs)
}
for (int i = 0; i < name_len; i++)
{
- if (!isalnum (name[i]) && name[i] != '-')
+ if (!c_isalnum (name[i]) && name[i] != '-')
{
PyErr_Format
(PyExc_ValueError,
diff --git a/gdb/python/py-micmd.c b/gdb/python/py-micmd.c
index 72f427f..07db0cc 100644
--- a/gdb/python/py-micmd.c
+++ b/gdb/python/py-micmd.c
@@ -350,7 +350,7 @@ micmdpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
PyErr_SetString (PyExc_ValueError, _("MI command name is empty."));
return -1;
}
- else if ((name_len < 2) || (name[0] != '-') || !isalnum (name[1]))
+ else if ((name_len < 2) || (name[0] != '-') || !c_isalnum (name[1]))
{
PyErr_SetString (PyExc_ValueError,
_("MI command name does not start with '-'"
@@ -361,7 +361,7 @@ micmdpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
{
for (int i = 2; i < name_len; i++)
{
- if (!isalnum (name[i]) && name[i] != '-')
+ if (!c_isalnum (name[i]) && name[i] != '-')
{
PyErr_Format
(PyExc_ValueError,
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index 1c6f569..a9f5754 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -556,7 +556,7 @@ objfpy_build_id_ok (const char *string)
return 0;
for (i = 0; i < n; ++i)
{
- if (!isxdigit (string[i]))
+ if (!c_isxdigit (string[i]))
return 0;
}
return 1;
@@ -619,9 +619,8 @@ gdbpy_lookup_objfile (PyObject *self, PyObject *args, PyObject *kw)
struct objfile *objfile = nullptr;
if (by_build_id)
- gdbarch_iterate_over_objfiles_in_search_order
- (current_inferior ()->arch (),
- [&objfile, name] (struct objfile *obj)
+ current_program_space->iterate_over_objfiles_in_search_order
+ ([&objfile, name] (struct objfile *obj)
{
/* Don't return separate debug files. */
if (obj->separate_debug_objfile_backlink != nullptr)
@@ -642,9 +641,8 @@ gdbpy_lookup_objfile (PyObject *self, PyObject *args, PyObject *kw)
return 1;
}, gdbpy_current_objfile);
else
- gdbarch_iterate_over_objfiles_in_search_order
- (current_inferior ()->arch (),
- [&objfile, name] (struct objfile *obj)
+ current_program_space->iterate_over_objfiles_in_search_order
+ ([&objfile, name] (struct objfile *obj)
{
/* Don't return separate debug files. */
if (obj->separate_debug_objfile_backlink != nullptr)
diff --git a/gdb/python/py-record.c b/gdb/python/py-record.c
index 7e7904b..89c2e77 100644
--- a/gdb/python/py-record.c
+++ b/gdb/python/py-record.c
@@ -696,6 +696,9 @@ gdbpy_current_recording (PyObject *self, PyObject *args)
Py_RETURN_NONE;
ret = PyObject_New (recpy_record_object, &recpy_record_type);
+ if (ret == nullptr)
+ return nullptr;
+
ret->thread = inferior_thread ();
ret->method = target_record_method (ret->thread->ptid);
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index 3028a30..284e385 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -126,7 +126,7 @@ sympy_get_addr_class (PyObject *self, void *closure)
SYMPY_REQUIRE_VALID (self, symbol);
- return gdb_py_object_from_longest (symbol->aclass ()).release ();
+ return gdb_py_object_from_longest (symbol->loc_class ()).release ();
}
/* Implement gdb.Symbol.domain attribute. Return the domain as an
@@ -156,42 +156,39 @@ static PyObject *
sympy_is_constant (PyObject *self, void *closure)
{
struct symbol *symbol = NULL;
- enum address_class theclass;
SYMPY_REQUIRE_VALID (self, symbol);
- theclass = symbol->aclass ();
+ location_class loc_class = symbol->loc_class ();
- return PyBool_FromLong (theclass == LOC_CONST || theclass == LOC_CONST_BYTES);
+ return PyBool_FromLong (loc_class == LOC_CONST || loc_class == LOC_CONST_BYTES);
}
static PyObject *
sympy_is_function (PyObject *self, void *closure)
{
struct symbol *symbol = NULL;
- enum address_class theclass;
SYMPY_REQUIRE_VALID (self, symbol);
- theclass = symbol->aclass ();
+ location_class loc_class = symbol->loc_class ();
- return PyBool_FromLong (theclass == LOC_BLOCK);
+ return PyBool_FromLong (loc_class == LOC_BLOCK);
}
static PyObject *
sympy_is_variable (PyObject *self, void *closure)
{
struct symbol *symbol = NULL;
- enum address_class theclass;
SYMPY_REQUIRE_VALID (self, symbol);
- theclass = symbol->aclass ();
+ location_class loc_class = symbol->loc_class ();
return PyBool_FromLong (!symbol->is_argument ()
- && (theclass == LOC_LOCAL || theclass == LOC_REGISTER
- || theclass == LOC_STATIC || theclass == LOC_COMPUTED
- || theclass == LOC_OPTIMIZED_OUT));
+ && (loc_class == LOC_LOCAL || loc_class == LOC_REGISTER
+ || loc_class == LOC_STATIC || loc_class == LOC_COMPUTED
+ || loc_class == LOC_OPTIMIZED_OUT));
}
/* Implementation of Symbol.is_artificial. */
@@ -279,7 +276,7 @@ sympy_value (PyObject *self, PyObject *args)
}
SYMPY_REQUIRE_VALID (self, symbol);
- if (symbol->aclass () == LOC_TYPEDEF)
+ if (symbol->loc_class () == LOC_TYPEDEF)
{
PyErr_SetString (PyExc_TypeError, "cannot get the value of a typedef");
return NULL;
@@ -605,17 +602,15 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw)
/* Expand any symtabs that contain potentially matching symbols. */
lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
- expand_symtabs_matching (NULL, lookup_name, NULL, NULL,
- SEARCH_STATIC_BLOCK, flags);
for (objfile *objfile : current_program_space->objfiles ())
{
- for (compunit_symtab *cust : objfile->compunits ())
+ auto callback = [&] (compunit_symtab *cust)
{
/* Skip included compunits to prevent including compunits from
being searched twice. */
if (cust->user != nullptr)
- continue;
+ return true;
const struct blockvector *bv = cust->blockvector ();
const struct block *block = bv->static_block ();
@@ -628,13 +623,18 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw)
if (symbol != nullptr)
{
PyObject *sym_obj = symbol_to_symbol_object (symbol);
- if (sym_obj == nullptr)
- return nullptr;
- if (PyList_Append (return_list.get (), sym_obj) == -1)
- return nullptr;
+ if (sym_obj == nullptr
+ || PyList_Append (return_list.get (), sym_obj) == -1)
+ return false;
}
}
- }
+
+ return true;
+ };
+
+ if (!objfile->search (nullptr, &lookup_name, nullptr, callback,
+ SEARCH_STATIC_BLOCK, flags))
+ return nullptr;
}
}
catch (const gdb_exception &except)
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index c546aa7..a2c5939 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -1045,9 +1045,9 @@ typy_template_argument (PyObject *self, PyObject *args)
}
sym = TYPE_TEMPLATE_ARGUMENT (type, argno);
- if (sym->aclass () == LOC_TYPEDEF)
+ if (sym->loc_class () == LOC_TYPEDEF)
return type_to_type_object (sym->type ());
- else if (sym->aclass () == LOC_OPTIMIZED_OUT)
+ else if (sym->loc_class () == LOC_OPTIMIZED_OUT)
{
PyErr_Format (PyExc_RuntimeError,
_("Template argument is optimized out"));
@@ -1312,10 +1312,9 @@ static PyObject *
typy_has_key (PyObject *self, PyObject *args)
{
struct type *type = ((type_object *) self)->type;
- const char *field;
- int i;
+ const char *field_name;
- if (!PyArg_ParseTuple (args, "s", &field))
+ if (!PyArg_ParseTuple (args, "s", &field_name))
return NULL;
/* We want just fields of this type, not of base types, so instead of
@@ -1326,11 +1325,11 @@ typy_has_key (PyObject *self, PyObject *args)
if (type == NULL)
return NULL;
- for (i = 0; i < type->num_fields (); i++)
+ for (const auto &field : type->fields ())
{
- const char *t_field_name = type->field (i).name ();
+ const char *t_field_name = field.name ();
- if (t_field_name && (strcmp_iw (t_field_name, field) == 0))
+ if (t_field_name && (strcmp_iw (t_field_name, field_name) == 0))
Py_RETURN_TRUE;
}
Py_RETURN_FALSE;
diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c
index dc078ec..43125bb 100644
--- a/gdb/python/py-unwind.c
+++ b/gdb/python/py-unwind.c
@@ -287,6 +287,8 @@ pyuw_create_unwind_info (PyObject *pyo_pending_frame,
unwind_info_object *unwind_info
= PyObject_New (unwind_info_object, &unwind_info_object_type);
+ if (unwind_info == nullptr)
+ return nullptr;
unwind_info->frame_id = frame_id;
Py_INCREF (pyo_pending_frame);
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index 8a2e263..5d8fab9 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -478,6 +478,9 @@ valpy_get_dynamic_type (PyObject *self, void *closure)
type = value_rtti_type (val, NULL, NULL, NULL);
else
type = val->type ();
+
+ if (type == nullptr)
+ type = val->type ();
}
catch (const gdb_exception &except)
{
@@ -1288,6 +1291,30 @@ valpy_get_is_optimized_out (PyObject *self, void *closure)
Py_RETURN_FALSE;
}
+/* Implements gdb.Value.is_unavailable. Return true if any part of the
+ value is unavailable. */
+
+static PyObject *
+valpy_get_is_unavailable (PyObject *self, void *closure)
+{
+ struct value *value = ((value_object *) self)->value;
+ bool entirely_available = false;
+
+ try
+ {
+ entirely_available = value->entirely_available ();
+ }
+ catch (const gdb_exception &except)
+ {
+ return gdbpy_handle_gdb_exception (nullptr, except);
+ }
+
+ if (!entirely_available)
+ Py_RETURN_TRUE;
+
+ Py_RETURN_FALSE;
+}
+
/* Implements gdb.Value.is_lazy. */
static PyObject *
valpy_get_is_lazy (PyObject *self, void *closure)
@@ -1842,7 +1869,7 @@ valpy_long (PyObject *self)
{
struct value *value = ((value_object *) self)->value;
struct type *type = value->type ();
- LONGEST l = 0;
+ PyObject *result;
try
{
@@ -1858,17 +1885,57 @@ valpy_long (PyObject *self)
&& type->code () != TYPE_CODE_PTR)
error (_("Cannot convert value to long."));
- l = value_as_long (value);
+ gdb::array_view<const gdb_byte> contents = value->contents ();
+#if PY_VERSION_HEX >= 0x030d0000
+ int flags = (type_byte_order (type) == BFD_ENDIAN_BIG
+ ? Py_ASNATIVEBYTES_BIG_ENDIAN
+ : Py_ASNATIVEBYTES_LITTLE_ENDIAN);
+ if (type->is_unsigned ())
+ flags |= Py_ASNATIVEBYTES_UNSIGNED_BUFFER;
+ result = PyLong_FromNativeBytes (contents.data (), contents.size (),
+ flags);
+#else
+ /* Here we construct a call to "int.from_bytes", passing in the
+ appropriate arguments. We need a somewhat roundabout
+ approach because int.from_bytes requires "signed" to be a
+ keyword arg. */
+
+ /* PyObject_Call requires a tuple argument. */
+ gdbpy_ref<> empty_tuple (PyTuple_New (0));
+ if (empty_tuple == nullptr)
+ return nullptr;
+
+ /* Since we need a dictionary anyway, we pass all arguments as
+ keywords, building the dictionary here. */
+ gdbpy_ref<> args
+ (Py_BuildValue ("{sy#sssO}",
+ "bytes", contents.data (),
+ (Py_ssize_t) contents.size (),
+ "byteorder",
+ (type_byte_order (type) == BFD_ENDIAN_BIG
+ ? "big" : "little"),
+ "signed",
+ type->is_unsigned ()
+ ? Py_False : Py_True));
+ if (args == nullptr)
+ return nullptr;
+
+ /* Find the "int.from_bytes" callable. */
+ gdbpy_ref<> callable (PyObject_GetAttrString ((PyObject *) &PyLong_Type,
+ "from_bytes"));
+ if (callable == nullptr)
+ return nullptr;
+
+ result = PyObject_Call (callable.get (), empty_tuple.get (),
+ args.get ());
+#endif
}
catch (const gdb_exception &except)
{
return gdbpy_handle_gdb_exception (nullptr, except);
}
- if (type->is_unsigned ())
- return gdb_py_object_from_ulongest (l).release ();
- else
- return gdb_py_object_from_longest (l).release ();
+ return result;
}
/* Implements conversion to float. */
@@ -2194,6 +2261,9 @@ static gdb_PyGetSetDef value_object_getset[] = {
"Boolean telling whether the value is optimized "
"out (i.e., not available).",
NULL },
+ { "is_unavailable", valpy_get_is_unavailable, nullptr,
+ "Boolean telling whether the value is unavailable.",
+ nullptr },
{ "type", valpy_get_type, NULL, "Type of the value.", NULL },
{ "dynamic_type", valpy_get_dynamic_type, NULL,
"Dynamic type of the value.", NULL },
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index 7f4237e..f61a175 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -503,7 +503,12 @@ PyObject *gdbpy_create_lazy_string_object (CORE_ADDR address, long length,
const char *encoding,
struct type *type);
PyObject *gdbpy_inferiors (PyObject *unused, PyObject *unused2);
-PyObject *gdbpy_create_ptid_object (ptid_t ptid);
+
+/* Return a reference to a new Python Tuple object representing a ptid_t.
+ The object is a tuple containing (pid, lwp, tid). */
+
+extern gdbpy_ref<> gdbpy_create_ptid_object (ptid_t ptid);
+
PyObject *gdbpy_selected_thread (PyObject *self, PyObject *args);
PyObject *gdbpy_selected_inferior (PyObject *self, PyObject *args);
PyObject *gdbpy_string_to_argv (PyObject *self, PyObject *args);
diff --git a/gdb/python/python.c b/gdb/python/python.c
index cb0d642..740b196 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -31,7 +31,6 @@
#include "python.h"
#include "extension-priv.h"
#include "cli/cli-utils.h"
-#include <ctype.h>
#include "location.h"
#include "run-on-main-thread.h"
#include "observable.h"
@@ -1202,15 +1201,22 @@ gdbpy_post_event (PyObject *self, PyObject *args)
static PyObject *
gdbpy_interrupt (PyObject *self, PyObject *args)
{
+#ifdef __MINGW32__
{
- /* Make sure the interrupt isn't delivered immediately somehow.
- This probably is not truly needed, but at the same time it
- seems more clear to be explicit about the intent. */
gdbpy_allow_threads temporarily_exit_python;
scoped_disable_cooperative_sigint_handling no_python_sigint;
set_quit_flag ();
}
+#else
+ {
+ /* For targets with support kill() just send SIGINT. This will be
+ handled as if the user hit Ctrl+C. This isn't exactly the same as
+ the above, which directly sets the quit flag. Consider, for
+ example, every place that install_sigint_handler is called. */
+ kill (getpid (), SIGINT);
+ }
+#endif
Py_RETURN_NONE;
}
@@ -1570,21 +1576,21 @@ gdbpy_write (PyObject *self, PyObject *args, PyObject *kw)
try
{
+ ui_file *stream;
switch (stream_type)
{
case 1:
- {
- gdb_printf (gdb_stderr, "%s", arg);
- break;
- }
+ stream = gdb_stderr;
+ break;
case 2:
- {
- gdb_printf (gdb_stdlog, "%s", arg);
- break;
- }
+ stream = gdb_stdlog;
+ break;
default:
- gdb_printf (gdb_stdout, "%s", arg);
+ stream = gdb_stdout;
+ break;
}
+
+ gdb_puts (arg, stream);
}
catch (const gdb_exception &except)
{
diff --git a/gdb/quick-symbol.h b/gdb/quick-symbol.h
index 9db1f18..b5308dc 100644
--- a/gdb/quick-symbol.h
+++ b/gdb/quick-symbol.h
@@ -37,30 +37,29 @@ DEF_ENUM_FLAGS_TYPE (enum block_search_flag_values, block_search_flags);
using symbol_filename_listener
= gdb::function_view<void (const char *filename, const char *fullname)>;
-/* Callback for quick_symbol_functions::expand_symtabs_matching
- to match a file name. */
+/* Callback for quick_symbol_functions::search to match a file
+ name. */
-using expand_symtabs_file_matcher
+using search_symtabs_file_matcher
= gdb::function_view<bool (const char *filename, bool basenames)>;
-/* Callback for quick_symbol_functions::expand_symtabs_matching
- to match a symbol name. */
+/* Callback for quick_symbol_functions::search to match a symbol
+ name. */
-using expand_symtabs_symbol_matcher
+using search_symtabs_symbol_matcher
= gdb::function_view<bool (const char *name)>;
-/* Callback for quick_symbol_functions::expand_symtabs_matching
- to match a language. */
+/* Callback for quick_symbol_functions::search to match a
+ language. */
-using expand_symtabs_lang_matcher
+using search_symtabs_lang_matcher
= gdb::function_view<bool (enum language lang)>;
-/* Callback for quick_symbol_functions::expand_symtabs_matching
- to be called after a symtab has been expanded. If this returns
- true, more symtabs are checked; if it returns false, iteration
- stops. */
+/* Callback for quick_symbol_functions::search to be called when
+ symtab matches (perhaps expanding it first). If this returns true,
+ more symtabs are checked; if it returns false, iteration stops. */
-using expand_symtabs_expansion_listener
+using search_symtabs_expansion_listener
= gdb::function_view<bool (compunit_symtab *symtab)>;
/* The "quick" symbol functions exist so that symbol readers can
@@ -71,13 +70,6 @@ using expand_symtabs_expansion_listener
The quick symbol functions are generally opaque: the underlying
representation is hidden from the caller.
- In general, these functions should only look at whatever special
- index the symbol reader creates -- looking through the symbol
- tables themselves is handled by generic code. If a function is
- defined as returning a "symbol table", this means that the function
- should only return a newly-created symbol table; it should not
- examine pre-existing ones.
-
The exact list of functions here was determined in an ad hoc way
based on gdb's history. */
@@ -130,11 +122,11 @@ struct quick_symbol_functions
/* Read all symbol tables associated with OBJFILE. */
virtual void expand_all_symtabs (struct objfile *objfile) = 0;
- /* Expand all symbol tables in OBJFILE matching some criteria.
+ /* Search all symbol tables in OBJFILE matching some criteria.
- If LANG_MATCHER returns false, expansion of the symbol table may be
- skipped. It may also not be skipped, which the caller needs to take into
- account.
+ If LANG_MATCHER returns false, search of the symbol table may be
+ skipped. It may also not be skipped, which the caller needs to
+ take into account.
FILE_MATCHER is called for each file in OBJFILE. The file name
is passed to it. If the matcher returns false, the file is
@@ -144,7 +136,7 @@ struct quick_symbol_functions
part).
If the file is not skipped, and SYMBOL_MATCHER and LOOKUP_NAME are NULL,
- the symbol table is expanded.
+ the symbol table is searched.
Otherwise, individual symbols are considered.
@@ -156,19 +148,23 @@ struct quick_symbol_functions
Note that if SYMBOL_MATCHER is non-NULL, then LOOKUP_NAME must
also be provided.
- Otherwise, the symbol's symbol table is expanded and EXPANSION_NOTIFY is
- called. If EXPANSION_NOTIFY returns false, execution stops and this method
- returns false. Otherwise, more files are considered. This method returns
- true if all calls to EXPANSION_NOTIFY return true. */
- virtual bool expand_symtabs_matching
+ Otherwise, the symbol's symbol table is expanded if needed.
+
+ Then (regardless of whether the symbol table was already
+ expanded, or just expanded in response to this search), LISTENER
+ is called. If LISTENER returns false, execution stops and this
+ method returns false. Otherwise, more files are considered.
+ This method returns true if all calls to LISTENER return
+ true. */
+ virtual bool search
(struct objfile *objfile,
- expand_symtabs_file_matcher file_matcher,
+ search_symtabs_file_matcher file_matcher,
const lookup_name_info *lookup_name,
- expand_symtabs_symbol_matcher symbol_matcher,
- expand_symtabs_expansion_listener expansion_notify,
+ search_symtabs_symbol_matcher symbol_matcher,
+ search_symtabs_expansion_listener listener,
block_search_flags search_flags,
domain_search_flags domain,
- expand_symtabs_lang_matcher lang_matcher = nullptr) = 0;
+ search_symtabs_lang_matcher lang_matcher = nullptr) = 0;
/* Return the comp unit from OBJFILE that contains PC and
SECTION. Return NULL if there is no such compunit. This
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 7e3da27..e2298b3 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -908,7 +908,7 @@ record_full_exec_insn (struct regcache *regcache,
}
}
-static void record_full_restore (void);
+static void record_full_restore (struct bfd &cbfd);
/* Asynchronous signal handle registered as event loop source for when
we have pending events ready to be passed to the core. */
@@ -921,10 +921,11 @@ record_full_async_inferior_event_handler (gdb_client_data data)
inferior_event_handler (INF_REG_EVENT);
}
-/* Open the process record target for 'core' files. */
+/* Open the process record target for 'core' files. CBFD is the core file
+ containing the record information. */
static void
-record_full_core_open_1 ()
+record_full_core_open_1 (struct bfd &cbfd)
{
regcache *regcache = get_thread_regcache (inferior_thread ());
int regnum = gdbarch_num_regs (regcache->arch ());
@@ -937,11 +938,10 @@ record_full_core_open_1 ()
for (i = 0; i < regnum; i ++)
record_full_core_regbuf->raw_supply (i, *regcache);
- record_full_core_sections
- = build_section_table (current_program_space->core_bfd ());
+ record_full_core_sections = build_section_table (&cbfd);
current_inferior ()->push_target (&record_full_core_ops);
- record_full_restore ();
+ record_full_restore (cbfd);
}
/* Open the process record target for 'live' processes. */
@@ -987,8 +987,8 @@ record_full_open (const char *args, int from_tty)
record_full_list = &record_full_first;
record_full_list->next = NULL;
- if (current_program_space->core_bfd ())
- record_full_core_open_1 ();
+ if (current_program_space->core_bfd () != nullptr)
+ record_full_core_open_1 (*current_program_space->core_bfd ());
else
record_full_open_1 ();
@@ -1084,14 +1084,15 @@ record_full_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
if (!RECORD_FULL_IS_REPLAY)
{
- struct gdbarch *gdbarch = target_thread_architecture (ptid);
+ struct regcache *regcache = get_thread_regcache (inferior_thread ());
+ struct gdbarch *gdbarch = regcache->arch ();
- record_full_message (get_thread_regcache (inferior_thread ()), signal);
+ record_full_message (regcache, signal);
if (!step)
{
/* This is not hard single step. */
- if (!gdbarch_software_single_step_p (gdbarch))
+ if (!gdbarch_get_next_pcs_p (gdbarch))
{
/* This is a normal continue. */
step = 1;
@@ -1266,7 +1267,7 @@ record_full_wait_1 (struct target_ops *ops,
process_stratum_target *proc_target
= current_inferior ()->process_target ();
- if (gdbarch_software_single_step_p (gdbarch))
+ if (gdbarch_get_next_pcs_p (gdbarch))
{
/* Try to insert the software single step breakpoint.
If insert success, set step to 0. */
@@ -2332,9 +2333,10 @@ netorder32 (uint32_t input)
return ret;
}
-/* Restore the execution log from a core_bfd file. */
+/* Restore the execution log from core file CBFD. */
+
static void
-record_full_restore (void)
+record_full_restore (struct bfd &cbfd)
{
uint32_t magic;
struct record_full_entry *rec;
@@ -2342,11 +2344,6 @@ record_full_restore (void)
uint32_t osec_size;
int bfd_offset = 0;
- /* We restore the execution log from the open core bfd,
- if there is one. */
- if (current_program_space->core_bfd () == nullptr)
- return;
-
/* "record_full_restore" can only be called when record list is empty. */
gdb_assert (record_full_first.next == NULL);
@@ -2354,7 +2351,7 @@ record_full_restore (void)
gdb_printf (gdb_stdlog, "Restoring recording from core file.\n");
/* Now need to find our special note section. */
- osec = bfd_get_section_by_name (current_program_space->core_bfd (), "null0");
+ osec = bfd_get_section_by_name (&cbfd, "null0");
if (record_debug)
gdb_printf (gdb_stdlog, "Find precord section %s.\n",
osec ? "succeeded" : "failed");
@@ -2365,11 +2362,10 @@ record_full_restore (void)
gdb_printf (gdb_stdlog, "%s", bfd_section_name (osec));
/* Check the magic code. */
- bfdcore_read (current_program_space->core_bfd (), osec, &magic,
- sizeof (magic), &bfd_offset);
+ bfdcore_read (&cbfd, osec, &magic, sizeof (magic), &bfd_offset);
if (magic != RECORD_FULL_FILE_MAGIC)
error (_("Version mismatch or file format error in core file %s."),
- bfd_get_filename (current_program_space->core_bfd ()));
+ bfd_get_filename (&cbfd));
if (record_debug)
gdb_printf (gdb_stdlog,
" Reading 4-byte magic cookie "
@@ -2395,23 +2391,21 @@ record_full_restore (void)
/* We are finished when offset reaches osec_size. */
if (bfd_offset >= osec_size)
break;
- bfdcore_read (current_program_space->core_bfd (), osec, &rectype,
- sizeof (rectype), &bfd_offset);
+ bfdcore_read (&cbfd, osec, &rectype, sizeof (rectype), &bfd_offset);
switch (rectype)
{
case record_full_reg: /* reg */
/* Get register number to regnum. */
- bfdcore_read (current_program_space->core_bfd (), osec, &regnum,
- sizeof (regnum), &bfd_offset);
+ bfdcore_read (&cbfd, osec, &regnum, sizeof (regnum),
+ &bfd_offset);
regnum = netorder32 (regnum);
rec = record_full_reg_alloc (regcache, regnum);
/* Get val. */
- bfdcore_read (current_program_space->core_bfd (), osec,
- record_full_get_loc (rec), rec->u.reg.len,
- &bfd_offset);
+ bfdcore_read (&cbfd, osec, record_full_get_loc (rec),
+ rec->u.reg.len, &bfd_offset);
if (record_debug)
gdb_printf (gdb_stdlog,
@@ -2424,21 +2418,18 @@ record_full_restore (void)
case record_full_mem: /* mem */
/* Get len. */
- bfdcore_read (current_program_space->core_bfd (), osec, &len,
- sizeof (len), &bfd_offset);
+ bfdcore_read (&cbfd, osec, &len, sizeof (len), &bfd_offset);
len = netorder32 (len);
/* Get addr. */
- bfdcore_read (current_program_space->core_bfd (), osec, &addr,
- sizeof (addr), &bfd_offset);
+ bfdcore_read (&cbfd, osec, &addr, sizeof (addr), &bfd_offset);
addr = netorder64 (addr);
rec = record_full_mem_alloc (addr, len);
/* Get val. */
- bfdcore_read (current_program_space->core_bfd (), osec,
- record_full_get_loc (rec), rec->u.mem.len,
- &bfd_offset);
+ bfdcore_read (&cbfd, osec, record_full_get_loc (rec),
+ rec->u.mem.len, &bfd_offset);
if (record_debug)
gdb_printf (gdb_stdlog,
@@ -2456,14 +2447,13 @@ record_full_restore (void)
record_full_insn_num ++;
/* Get signal value. */
- bfdcore_read (current_program_space->core_bfd (), osec, &signal,
- sizeof (signal), &bfd_offset);
+ bfdcore_read (&cbfd, osec, &signal, sizeof (signal),
+ &bfd_offset);
signal = netorder32 (signal);
rec->u.end.sigval = (enum gdb_signal) signal;
/* Get insn count. */
- bfdcore_read (current_program_space->core_bfd (), osec, &count,
- sizeof (count), &bfd_offset);
+ bfdcore_read (&cbfd, osec, &count, sizeof (count), &bfd_offset);
count = netorder32 (count);
rec->u.end.insn_num = count;
record_full_insn_count = count + 1;
@@ -2479,7 +2469,7 @@ record_full_restore (void)
default:
error (_("Bad entry type in core file %s."),
- bfd_get_filename (current_program_space->core_bfd ()));
+ bfd_get_filename (&cbfd));
break;
}
@@ -2509,7 +2499,7 @@ record_full_restore (void)
/* Succeeded. */
gdb_printf (_("Restored records from core file %s.\n"),
- bfd_get_filename (current_program_space->core_bfd ()));
+ bfd_get_filename (&cbfd));
print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC, 1);
}
diff --git a/gdb/record.c b/gdb/record.c
index 248cfaa..de1a7a8 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -28,7 +28,6 @@
#include "interps.h"
#include "top.h"
-#include <ctype.h>
/* This is the debug switch for process record. */
unsigned int record_debug = 0;
@@ -423,7 +422,7 @@ get_insn_number (const char **arg)
begin = *arg;
pos = skip_spaces (begin);
- if (!isdigit (*pos))
+ if (!c_isdigit (*pos))
error (_("Expected positive number, got: %s."), pos);
number = strtoulst (pos, &end, 10);
@@ -443,7 +442,7 @@ get_context_size (const char **arg)
pos = skip_spaces (*arg);
- if (!isdigit (*pos))
+ if (!c_isdigit (*pos))
error (_("Expected positive number, got: %s."), pos);
long result = strtol (pos, &end, 10);
@@ -483,7 +482,7 @@ get_insn_history_modifiers (const char **arg)
for (; *args; ++args)
{
- if (isspace (*args))
+ if (c_isspace (*args))
break;
if (*args == '/')
@@ -627,7 +626,7 @@ get_call_history_modifiers (const char **arg)
for (; *args; ++args)
{
- if (isspace (*args))
+ if (c_isspace (*args))
break;
if (*args == '/')
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 9892c54..cf4c5dd 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -1841,9 +1841,10 @@ reg_buffer_raw_compare_zero_len_test ()
const regcache *regcache
= get_thread_arch_regcache (&inf, ptid_t (1, 1), inf.arch ());
- /* The buffer address is irrelevant since we end up comparing 0 bytes, we just
- need to pass something. */
- gdb_byte buf;
+ /* The buffer address is irrelevant since we end up comparing 0 bytes, we
+ just need to pass something. The variable needs to be initialized to
+ avoid compiler warnings about uninitialized values. */
+ gdb_byte buf = 0;
SELF_CHECK (regcache->raw_compare (0, &buf, register_size (inf.arch (), 0)));
}
diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index 425e50d..a325ffa 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -25,7 +25,6 @@
#include "inferior.h"
#include "infrun.h"
#include "value.h"
-#include <ctype.h>
#include <fcntl.h>
#include <signal.h>
#include <setjmp.h>
diff --git a/gdb/remote.c b/gdb/remote.c
index 6208a90..9fc8712 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -19,9 +19,9 @@
/* See the GDB User Guide for details of the GDB remote protocol. */
-#include <ctype.h>
#include <fcntl.h>
#include "exceptions.h"
+#include "gdbsupport/common-inferior.h"
#include "inferior.h"
#include "infrun.h"
#include "bfd.h"
@@ -81,6 +81,7 @@
#include "gdbsupport/selftest.h"
#include "cli/cli-style.h"
#include "gdbsupport/remote-args.h"
+#include "gdbsupport/gdb_argv_vec.h"
/* The remote target. */
@@ -401,6 +402,10 @@ enum {
errors, and so they should not need to check for this feature. */
PACKET_accept_error_message,
+ /* Not really a packet; this indicates support for sending the vRun
+ inferior arguments as a single string. */
+ PACKET_vRun_single_argument,
+
PACKET_MAX
};
@@ -826,6 +831,11 @@ struct remote_features
bool remote_memory_tagging_p () const
{ return packet_support (PACKET_memory_tagging_feature) == PACKET_ENABLE; }
+ /* Returns true if there is support for sending vRun inferior arguments
+ as a single string. */
+ bool remote_vrun_single_arg_p () const
+ { return packet_support (PACKET_vRun_single_argument) == PACKET_ENABLE; }
+
/* Reset all packets back to "unknown support". Called when opening a
new connection to a remote target. */
void reset_all_packet_configs_support ();
@@ -1387,7 +1397,8 @@ public: /* Remote specific methods. */
void remote_kill_k ();
void extended_remote_disable_randomization (int val);
- int extended_remote_run (const std::string &args);
+ int extended_remote_run (const std::string &remote_exec_file,
+ const std::string &args);
void send_environment_packet (const char *action,
const char *packet,
@@ -1515,14 +1526,7 @@ remote_register_is_expedited (int regnum)
}
/* Per-program-space data key. */
-static const registry<program_space>::key<char, gdb::xfree_deleter<char>>
- remote_pspace_data;
-
-/* The variable registered as the control variable used by the
- remote exec-file commands. While the remote exec-file setting is
- per-program-space, the set/show machinery uses this as the
- location of the remote exec-file value. */
-static std::string remote_exec_file_var;
+static const registry<program_space>::key<std::string> remote_pspace_data;
/* The size to align memory write packets, when practical. The protocol
does not guarantee any alignment, and gdb will generate short
@@ -1852,47 +1856,47 @@ remote_target::get_remote_state ()
/* Fetch the remote exec-file from the current program space. */
-static const char *
+static const std::string &
get_remote_exec_file (void)
{
- char *remote_exec_file;
-
- remote_exec_file = remote_pspace_data.get (current_program_space);
- if (remote_exec_file == NULL)
- return "";
-
- return remote_exec_file;
+ const std::string *remote_exec_file
+ = remote_pspace_data.get (current_program_space);
+ if (remote_exec_file == nullptr)
+ remote_exec_file = remote_pspace_data.emplace (current_program_space);
+ return *remote_exec_file;
}
/* Set the remote exec file for PSPACE. */
static void
set_pspace_remote_exec_file (struct program_space *pspace,
- const char *remote_exec_file)
+ const std::string &filename)
{
- char *old_file = remote_pspace_data.get (pspace);
-
- xfree (old_file);
- remote_pspace_data.set (pspace, xstrdup (remote_exec_file));
+ remote_pspace_data.clear (pspace);
+ remote_pspace_data.emplace (pspace, filename);
}
-/* The "set/show remote exec-file" set command hook. */
+/* The "set remote exec-file" callback. */
static void
-set_remote_exec_file (const char *ignored, int from_tty,
- struct cmd_list_element *c)
+set_remote_exec_file_cb (const std::string &filename)
{
set_pspace_remote_exec_file (current_program_space,
- remote_exec_file_var.c_str ());
+ filename);
}
-/* The "set/show remote exec-file" show command hook. */
+/* Implement the "show remote exec-file" command. */
static void
show_remote_exec_file (struct ui_file *file, int from_tty,
struct cmd_list_element *cmd, const char *value)
{
- gdb_printf (file, "%s\n", get_remote_exec_file ());
+ const std::string &filename = get_remote_exec_file ();
+ if (filename.empty ())
+ gdb_printf (file, _("The remote exec-file is unset, the default remote "
+ "executable will be used.\n"));
+ else
+ gdb_printf (file, "The remote exec-file is \"%s\".\n", filename.c_str ());
}
static int
@@ -2558,7 +2562,7 @@ packet_check_result (const char *buf)
/* The stub recognized the packet request. Check that the
operation succeeded. */
if (buf[0] == 'E'
- && isxdigit (buf[1]) && isxdigit (buf[2])
+ && c_isxdigit (buf[1]) && c_isxdigit (buf[2])
&& buf[3] == '\0')
/* "Enn" - definitely an error. */
return packet_result::make_numeric_error (buf + 1);
@@ -2903,6 +2907,10 @@ remote_target::remote_add_inferior (bool fake_pid_p, int pid, int attached,
inf = add_inferior_with_spaces ();
}
switch_to_inferior_no_thread (inf);
+
+ /* Clear any data left by previous executions. */
+ target_pre_inferior ();
+
inf->push_target (this);
inferior_appeared (inf, pid);
}
@@ -3028,6 +3036,12 @@ remote_target::remote_notice_new_inferior (ptid_t currthread, bool executing)
inf = remote_add_inferior (fake_pid_p,
currthread.pid (), -1, 1);
+
+ /* Fetch the target description for this inferior. Make sure to
+ leave the currently selected inferior unchanged. */
+ scoped_restore_current_thread restore_thread;
+ switch_to_inferior_no_thread (inf);
+ target_find_description ();
}
/* This is really a new thread. Add it. */
@@ -4658,8 +4672,6 @@ remote_target::get_offsets ()
if (bss_addr != data_addr)
warning (_("Target reported unsupported offsets: %s"), buf);
}
- else
- lose = 1;
}
else if (startswith (ptr, "TextSeg="))
{
@@ -4868,7 +4880,11 @@ remote_target::add_current_inferior_and_thread (const char *wait_status)
fake_pid_p = true;
}
- remote_add_inferior (fake_pid_p, curr_ptid.pid (), -1, 1);
+ const auto inf = remote_add_inferior (fake_pid_p, curr_ptid.pid (), -1, 1);
+ switch_to_inferior_no_thread (inf);
+
+ /* Fetch the target description for this inferior. */
+ target_find_description ();
/* Add the main thread and switch to it. Don't try reading
registers yet, since we haven't fetched the target description
@@ -5007,6 +5023,24 @@ remote_target::process_initial_stop_replies (int from_tty)
the inferiors. */
if (!non_stop)
{
+ /* Ensure changes to the thread state are propagated to the
+ frontend. In non-stop mode only the current inferior will be
+ stopped, but in all-stop mode, all inferiors will change, and
+ the frontend will need updating. */
+ process_stratum_target *finish_target;
+ ptid_t finish_ptid;
+ if (non_stop)
+ {
+ finish_target = current_inferior ()->process_target ();
+ finish_ptid = ptid_t (current_inferior ()->pid);
+ }
+ else
+ {
+ finish_target = nullptr;
+ finish_ptid = minus_one_ptid;
+ }
+ scoped_finish_thread_state finish_state (finish_target, finish_ptid);
+
{
/* At this point, the remote target is not async. It needs to be for
the poll in stop_all_threads to consider events from it, so enable
@@ -5864,6 +5898,8 @@ static const struct protocol_feature remote_protocol_features[] = {
{ "error-message", PACKET_ENABLE, remote_supported_packet,
PACKET_accept_error_message },
{ "binary-upload", PACKET_DISABLE, remote_supported_packet, PACKET_x },
+ { "single-inf-arg", PACKET_DISABLE, remote_supported_packet,
+ PACKET_vRun_single_argument },
};
static char *remote_support_xml;
@@ -5975,6 +6011,10 @@ remote_target::remote_query_supported ()
!= AUTO_BOOLEAN_FALSE)
remote_query_supported_append (&q, "memory-tagging+");
+ if (m_features.packet_set_cmd_state (PACKET_vRun_single_argument)
+ != AUTO_BOOLEAN_FALSE)
+ remote_query_supported_append (&q, "single-inf-arg+");
+
/* Keep this one last to work around a gdbserver <= 7.10 bug in
the qSupported:xmlRegisters=i386 handling. */
if (remote_support_xml != NULL
@@ -6166,6 +6206,7 @@ remote_unpush_target (remote_target *target)
/* We have to unpush the target from all inferiors, even those that
aren't running. */
scoped_restore_current_inferior restore_current_inferior;
+ scoped_restore_current_program_space restore_program_space;
for (inferior *inf : all_inferiors (target))
{
@@ -10816,11 +10857,11 @@ remote_target::extended_remote_disable_randomization (int val)
}
int
-remote_target::extended_remote_run (const std::string &args)
+remote_target::extended_remote_run (const std::string &remote_exec_file,
+ const std::string &args)
{
struct remote_state *rs = get_remote_state ();
int len;
- const char *remote_exec_file = get_remote_exec_file ();
/* If the user has disabled vRun support, or we have detected that
support is not available, do not try it. */
@@ -10830,14 +10871,19 @@ remote_target::extended_remote_run (const std::string &args)
strcpy (rs->buf.data (), "vRun;");
len = strlen (rs->buf.data ());
- if (strlen (remote_exec_file) * 2 + len >= get_remote_packet_size ())
+ if (remote_exec_file.size () * 2 + len >= get_remote_packet_size ())
error (_("Remote file name too long for run packet"));
- len += 2 * bin2hex ((gdb_byte *) remote_exec_file, rs->buf.data () + len,
- strlen (remote_exec_file));
+ len += 2 * bin2hex ((gdb_byte *) remote_exec_file.data (),
+ rs->buf.data () + len,
+ remote_exec_file.size ());
if (!args.empty ())
{
- std::vector<std::string> split_args = gdb::remote_args::split (args);
+ std::vector<std::string> split_args;
+ if (!m_features.remote_vrun_single_arg_p ())
+ split_args = gdb::remote_args::split (args);
+ else
+ split_args.push_back (args);
for (const auto &a : split_args)
{
@@ -10873,7 +10919,7 @@ remote_target::extended_remote_run (const std::string &args)
"try \"set remote exec-file\"?"));
else
error (_("Running \"%s\" on the remote target failed"),
- remote_exec_file);
+ remote_exec_file.c_str ());
default:
gdb_assert_not_reached ("bad switch");
}
@@ -10993,7 +11039,7 @@ extended_remote_target::create_inferior (const char *exec_file,
int run_worked;
char *stop_reply;
struct remote_state *rs = get_remote_state ();
- const char *remote_exec_file = get_remote_exec_file ();
+ const std::string &remote_exec_file = get_remote_exec_file ();
/* If running asynchronously, register the target file descriptor
with the event loop. */
@@ -11023,7 +11069,7 @@ Remote replied unexpectedly while setting startup-with-shell: %s"),
extended_remote_set_inferior_cwd ();
/* Now restart the remote server. */
- run_worked = extended_remote_run (args) != -1;
+ run_worked = extended_remote_run (remote_exec_file, args) != -1;
if (!run_worked)
{
/* vRun was not supported. Fail if we need it to do what the
@@ -11936,7 +11982,7 @@ remote_target::xfer_partial (enum target_object object,
while (annex[i] && (i < (get_remote_packet_size () - 8)))
{
/* Bad caller may have sent forbidden characters. */
- gdb_assert (isprint (annex[i]) && annex[i] != '$' && annex[i] != '#');
+ gdb_assert (c_isprint (annex[i]) && annex[i] != '$' && annex[i] != '#');
*p2++ = annex[i];
i++;
}
@@ -12186,7 +12232,7 @@ private:
for (int i = 0; i < buf.size (); ++i)
{
gdb_byte c = buf[i];
- if (isprint (c))
+ if (c_isprint (c))
gdb_putc (c, &stb);
else
gdb_printf (&stb, "\\x%02x", (unsigned char) c);
@@ -12233,6 +12279,51 @@ cli_packet_command (const char *args, int from_tty)
send_remote_packet (view, &cb);
}
+/* Implement 'maint test-remote-args' command.
+
+ Treat ARGS as an argument string. Split the remote arguments using
+ gdb::remote_args::split, and then join using gdb::remote_args::join.
+ The split and joined arguments are printed out. Additionally, the
+ joined arguments are split and joined a second time, and compared to the
+ result of the first join, this provides some basic validation that GDB
+ sess the joined arguments as equivalent to the original argument
+ string. */
+
+static void
+test_remote_args_command (const char *args, int from_tty)
+{
+ std::vector<std::string> split_args = gdb::remote_args::split (args);
+
+ gdb_printf ("Input (%s)\n", args);
+ for (const std::string &a : split_args)
+ gdb_printf (" (%s)\n", a.c_str ());
+
+ gdb::argv_vec tmp_split_args;
+ for (const std::string &a : split_args)
+ tmp_split_args.emplace_back (xstrdup (a.c_str ()));
+
+ std::string joined_args = gdb::remote_args::join (tmp_split_args.get ());
+
+ gdb_printf ("Output (%s)\n", joined_args.c_str ());
+
+ std::vector<std::string> resplit = gdb::remote_args::split (joined_args);
+
+ tmp_split_args.clear ();
+ for (const std::string &a : resplit)
+ tmp_split_args.emplace_back (xstrdup (a.c_str ()));
+
+ std::string rejoined = gdb::remote_args::join (tmp_split_args.get ());
+
+ if (joined_args != rejoined || split_args != resplit)
+ {
+ gdb_printf ("FAILURE ON REJOINING\n");
+ gdb_printf ("Resplit args:\n");
+ for (const auto & a : resplit)
+ gdb_printf (" (%s)\n", a.c_str ());
+ gdb_printf ("Rejoined (%s)\n", rejoined.c_str ());
+ }
+}
+
#if 0
/* --------- UNIT_TEST for THREAD oriented PACKETS ------------------- */
@@ -16540,6 +16631,10 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL,
add_packet_config_cmd (PACKET_accept_error_message,
"error-message", "error-message", 0);
+ add_packet_config_cmd (PACKET_vRun_single_argument,
+ "single-inferior-argument-feature",
+ "single-inferior-argument-feature", 0);
+
/* Assert that we've registered "set remote foo-packet" commands
for all packet configs. */
{
@@ -16609,10 +16704,15 @@ Transfer files to and from the remote target system."),
&remote_cmdlist);
add_setshow_string_noescape_cmd ("exec-file", class_files,
- &remote_exec_file_var, _("\
-Set the remote pathname for \"run\"."), _("\
-Show the remote pathname for \"run\"."), NULL,
- set_remote_exec_file,
+ _("\
+Set the remote file name for starting inferiors."), _("\
+Show the remote file name for starting inferiors."), _("\
+This is the file name, on the remote target, used when starting an\n\
+inferior, for example with the \"run\", \"start\", or \"starti\"\n\
+commands. This setting is only useful when debugging a remote target,\n\
+otherwise, this setting is not used."),
+ set_remote_exec_file_cb,
+ get_remote_exec_file,
show_remote_exec_file,
&remote_set_cmdlist,
&remote_show_cmdlist);
@@ -16672,6 +16772,20 @@ from the target."),
/* Eventually initialize fileio. See fileio.c */
initialize_remote_fileio (&remote_set_cmdlist, &remote_show_cmdlist);
+ add_cmd ("test-remote-args", class_maintenance,
+ test_remote_args_command, _("\
+Test remote argument splitting and joining.\n \
+ maintenance test-remote-args ARGS\n\
+For remote targets that don't support passing inferior arguments as a\n\
+single string, GDB needs to split the inferior arguments before passing\n\
+them, and gdbserver needs to join the arguments it receives.\n\
+This command splits ARGS just as GDB would before passing them to a\n\
+remote target, and prints the result. This command then joins the\n\
+arguments just as gdbserver would, and prints the results.\n\
+This command is useful in diagnosing problems when passing arguments\n\
+between GDB and a remote target."),
+ &maintenancelist);
+
#if GDB_SELF_TEST
selftests::register_test ("remote_memory_tagging",
selftests::test_memory_tagging_functions);
diff --git a/gdb/riscv-fbsd-tdep.c b/gdb/riscv-fbsd-tdep.c
index 7bdc6e7..7999bd3 100644
--- a/gdb/riscv-fbsd-tdep.c
+++ b/gdb/riscv-fbsd-tdep.c
@@ -189,7 +189,7 @@ riscv_fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
/* Generic FreeBSD support. */
fbsd_init_abi (info, gdbarch);
- set_gdbarch_software_single_step (gdbarch, riscv_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, riscv_software_single_step);
set_solib_svr4_ops (gdbarch, (riscv_isa_xlen (gdbarch) == 4
? make_svr4_ilp32_solib_ops
diff --git a/gdb/riscv-linux-tdep.c b/gdb/riscv-linux-tdep.c
index e5d77e7..0a94611 100644
--- a/gdb/riscv-linux-tdep.c
+++ b/gdb/riscv-linux-tdep.c
@@ -502,6 +502,28 @@ riscv_linux_get_tls_dtp_offset (struct gdbarch *gdbarch, ptid_t ptid,
return 0;
}
+/* Function to extract syscall number. */
+
+static LONGEST
+riscv_linux_get_syscall_number (struct gdbarch *gdbarch, thread_info *thread)
+{
+ struct regcache *regcache = get_thread_regcache (thread);
+ LONGEST ret;
+
+ /* Getting the system call number from the register.
+ When dealing with riscv architecture, this information
+ is stored in $a7 register. */
+ if (regcache->cooked_read (RISCV_A7_REGNUM, &ret)
+ != register_status::REG_VALID)
+ {
+ warning (_ ("Can not read a7 register"));
+ return -1;
+ }
+
+ /* The result. */
+ return ret;
+}
+
/* Initialize RISC-V Linux ABI info. */
static void
@@ -511,7 +533,7 @@ riscv_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
linux_init_abi (info, gdbarch, 0);
- set_gdbarch_software_single_step (gdbarch, riscv_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, riscv_software_single_step);
set_solib_svr4_ops (gdbarch, (riscv_isa_xlen (gdbarch) == 4
? make_linux_ilp32_svr4_solib_ops
@@ -540,6 +562,10 @@ riscv_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
tdep->riscv_syscall_record = riscv_linux_syscall_record;
riscv64_linux_record_tdep_init (gdbarch, riscv_linux_record_tdep);
+
+ /* Functions for 'catch syscall'. */
+ set_gdbarch_xml_syscall_file (gdbarch, "syscalls/riscv-linux.xml");
+ set_gdbarch_get_syscall_number (gdbarch, riscv_linux_get_syscall_number);
}
/* Initialize RISC-V Linux target support. */
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index f5b8523..697071b 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -56,7 +56,6 @@
#include "arch/riscv.h"
#include "record-full.h"
#include "riscv-ravenscar-thread.h"
-#include "gdbsupport/gdb-safe-ctype.h"
#include <vector>
@@ -4183,9 +4182,9 @@ riscv_print_insn (bfd_vma addr, struct disassemble_info *info)
static int
riscv_stap_is_single_operand (struct gdbarch *gdbarch, const char *s)
{
- return (ISDIGIT (*s) /* Literal number. */
+ return (c_isdigit (*s) /* Literal number. */
|| *s == '(' /* Register indirection. */
- || ISALPHA (*s)); /* Register value. */
+ || c_isalpha (*s)); /* Register value. */
}
/* String that appears before a register name in a SystemTap register
@@ -4924,6 +4923,8 @@ public:
/* Corner cases. */
ECALL,
EBREAK,
+ SRET,
+ MRET,
};
private:
@@ -5008,6 +5009,14 @@ private:
return (ival >> OP_SH_CSR) & OP_MASK_CSR;
}
+ /* Set any record type. Always returns true. */
+ bool
+ set_record_type (record_type type) noexcept
+ {
+ m_record_type = type;
+ return true;
+ }
+
/* Set ordinary record type. Always returns true. */
bool
set_ordinary_record_type () noexcept
@@ -5066,7 +5075,8 @@ private:
return (is_beq_insn (ival) || is_bne_insn (ival) || is_blt_insn (ival)
|| is_bge_insn (ival) || is_bltu_insn (ival) || is_bgeu_insn (ival)
|| is_fence_insn (ival) || is_pause_insn (ival)
- || is_fence_i_insn (ival));
+ || is_fence_i_insn (ival) || is_wfi_insn (ival)
+ || is_sfence_vma_insn (ival));
}
/* Returns true if instruction is classified. */
@@ -5270,14 +5280,26 @@ private:
if (is_ecall_insn (ival))
{
- m_record_type = record_type::ECALL;
- return true;
+ return set_record_type (record_type::ECALL);
}
if (is_ebreak_insn (ival))
{
- m_record_type = record_type::EBREAK;
- return true;
+ return set_record_type (record_type::EBREAK);
+ }
+
+ if (is_sret_insn (ival))
+ {
+ return (!save_reg (RISCV_CSR_SSTATUS_REGNUM)
+ || !save_reg (RISCV_CSR_MEPC_REGNUM)
+ || set_record_type (record_type::SRET));
+ }
+
+ if (is_mret_insn (ival))
+ {
+ return (!save_reg (RISCV_CSR_MSTATUS_REGNUM)
+ || !save_reg (RISCV_CSR_MEPC_REGNUM)
+ || set_record_type (record_type::MRET));
}
if (try_save_pc (ival) || try_save_pc_rd (ival) || try_save_pc_fprd (ival)
@@ -5371,8 +5393,7 @@ private:
if (is_c_ebreak_insn (ival))
{
- m_record_type = record_type::EBREAK;
- return true;
+ return set_record_type (record_type::EBREAK);
}
if (is_c_jalr_insn (ival))
@@ -5414,8 +5435,20 @@ public:
gdb_assert (regcache != nullptr);
int m_length = 0;
+ ULONGEST ival = 0;
m_xlen = riscv_isa_xlen (gdbarch);
- ULONGEST ival = riscv_insn::fetch_instruction (gdbarch, addr, &m_length);
+
+ /* Since fetch_instruction can throw an exception,
+ it must be wrapped in a try-catch block. */
+ try
+ {
+ ival = riscv_insn::fetch_instruction (gdbarch, addr, &m_length);
+ }
+ catch (const gdb_exception_error &ex)
+ {
+ warning ("%s", ex.what ());
+ return false;
+ }
if (!save_reg (RISCV_PC_REGNUM))
return false;
@@ -5509,6 +5542,9 @@ riscv_record_insn_details (struct gdbarch *gdbarch, struct regcache *regcache,
switch (insn.get_record_type ())
{
case riscv_recorded_insn::record_type::ORDINARY:
+ case riscv_recorded_insn::record_type::EBREAK:
+ case riscv_recorded_insn::record_type::SRET:
+ case riscv_recorded_insn::record_type::MRET:
break;
case riscv_recorded_insn::record_type::ECALL:
@@ -5524,9 +5560,6 @@ riscv_record_insn_details (struct gdbarch *gdbarch, struct regcache *regcache,
return tdep->riscv_syscall_record (regcache, reg_val);
}
- case riscv_recorded_insn::record_type::EBREAK:
- break;
-
default:
return -1;
}
@@ -5546,10 +5579,7 @@ riscv_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
riscv_recorded_insn insn;
if (!insn.record (gdbarch, regcache, addr))
- {
- record_full_arch_list_add_end ();
- return -1;
- }
+ return -1;
int ret_val = riscv_record_insn_details (gdbarch, regcache, insn);
diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c
index 853a66e..536f647 100644
--- a/gdb/rs6000-aix-tdep.c
+++ b/gdb/rs6000-aix-tdep.c
@@ -1330,6 +1330,7 @@ rs6000_aix_ld_info_to_xml (struct gdbarch *gdbarch, const gdb_byte *ldi_buf,
static ULONGEST
rs6000_aix_core_xfer_shared_libraries_aix (struct gdbarch *gdbarch,
+ struct bfd &cbfd,
gdb_byte *readbuf,
ULONGEST offset,
ULONGEST len)
@@ -1337,8 +1338,7 @@ rs6000_aix_core_xfer_shared_libraries_aix (struct gdbarch *gdbarch,
struct bfd_section *ldinfo_sec;
int ldinfo_size;
- ldinfo_sec = bfd_get_section_by_name (current_program_space->core_bfd (),
- ".ldinfo");
+ ldinfo_sec = bfd_get_section_by_name (&cbfd, ".ldinfo");
if (ldinfo_sec == NULL)
error (_("cannot find .ldinfo section from core file: %s"),
bfd_errmsg (bfd_get_error ()));
@@ -1346,8 +1346,7 @@ rs6000_aix_core_xfer_shared_libraries_aix (struct gdbarch *gdbarch,
gdb::byte_vector ldinfo_buf (ldinfo_size);
- if (! bfd_get_section_contents (current_program_space->core_bfd (),
- ldinfo_sec, ldinfo_buf.data (), 0,
+ if (! bfd_get_section_contents (&cbfd, ldinfo_sec, ldinfo_buf.data (), 0,
ldinfo_size))
error (_("unable to read .ldinfo section from core file: %s"),
bfd_errmsg (bfd_get_error ()));
@@ -1362,7 +1361,7 @@ rs6000_aix_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch)
ppc_gdbarch_tdep *tdep = gdbarch_tdep<ppc_gdbarch_tdep> (gdbarch);
/* RS6000/AIX does not support PT_STEP. Has to be simulated. */
- set_gdbarch_software_single_step (gdbarch, rs6000_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, rs6000_software_single_step);
/* Displaced stepping is currently not supported in combination with
software single-stepping. These override the values set by
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index 1c75bb7..75079b9 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -8458,7 +8458,7 @@ rs6000_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_sofun_address_maybe_missing (gdbarch, 1);
/* Handles single stepping of atomic sequences. */
- set_gdbarch_software_single_step (gdbarch, ppc_deal_with_atomic_sequence);
+ set_gdbarch_get_next_pcs (gdbarch, ppc_deal_with_atomic_sequence);
/* Not sure on this. FIXMEmgo */
set_gdbarch_frame_args_skip (gdbarch, 8);
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 3957413..4626685 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -18,7 +18,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include <ctype.h>
#include "block.h"
#include "c-lang.h"
@@ -126,15 +125,15 @@ rust_underscore_fields (struct type *type)
if (type->code () != TYPE_CODE_STRUCT)
return false;
- for (int i = 0; i < type->num_fields (); ++i)
+ for (const auto &field : type->fields ())
{
- if (!type->field (i).is_static ())
+ if (!field.is_static ())
{
char buf[20];
xsnprintf (buf, sizeof (buf), "%d", field_number);
- const char *field_name = type->field (i).name ();
+ const char *field_name = field.name ();
if (startswith (field_name, "__"))
field_name += 2;
if (strcmp (buf, field_name) != 0)
@@ -376,11 +375,11 @@ rust_array_like_element_type (struct type *type)
{
/* Caller must check this. */
gdb_assert (rust_slice_type_p (type));
- for (int i = 0; i < type->num_fields (); ++i)
+ for (const auto &field : type->fields ())
{
- if (strcmp (type->field (i).name (), "data_ptr") == 0)
+ if (strcmp (field.name (), "data_ptr") == 0)
{
- struct type *base_type = type->field (i).type ()->target_type ();
+ struct type *base_type = field.type ()->target_type ();
if (rewrite_slice_type (base_type, nullptr, 0, nullptr))
return nullptr;
return base_type;
@@ -1017,9 +1016,9 @@ rust_internal_print_type (struct type *type, const char *varstring,
}
gdb_puts ("{\n", stream);
- for (int i = 0; i < type->num_fields (); ++i)
+ for (const auto &field : type->fields ())
{
- const char *name = type->field (i).name ();
+ const char *name = field.name ();
QUIT;
@@ -1788,7 +1787,7 @@ rust_language::emitchar (int ch, struct type *chtype,
gdb_puts ("\\t", stream);
else if (ch == '\0')
gdb_puts ("\\0", stream);
- else if (ch >= 32 && ch <= 127 && isprint (ch))
+ else if (ch >= 32 && ch <= 127 && c_isprint (ch))
gdb_putc (ch, stream);
else if (ch <= 255)
gdb_printf (stream, "\\x%02x", ch);
diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c
index b428b97..6ad6542 100644
--- a/gdb/rust-parse.c
+++ b/gdb/rust-parse.c
@@ -335,7 +335,7 @@ struct rust_parser
return std::string (current_string_val.ptr, current_string_val.length);
}
- /* A pointer to this is installed globally. */
+ /* Storage for use while parsing. */
auto_obstack obstack;
/* The parser state gdb gave us. */
@@ -1232,14 +1232,14 @@ rust_parser::name_to_operation (const std::string &name)
struct block_symbol sym = lookup_symbol (name.c_str (),
pstate->expression_context_block,
SEARCH_VFT);
- if (sym.symbol != nullptr && sym.symbol->aclass () != LOC_TYPEDEF)
+ if (sym.symbol != nullptr && sym.symbol->loc_class () != LOC_TYPEDEF)
return make_operation<var_value_operation> (sym);
struct type *type = nullptr;
if (sym.symbol != nullptr)
{
- gdb_assert (sym.symbol->aclass () == LOC_TYPEDEF);
+ gdb_assert (sym.symbol->loc_class () == LOC_TYPEDEF);
type = sym.symbol->type ();
}
if (type == nullptr)
diff --git a/gdb/s12z-tdep.c b/gdb/s12z-tdep.c
index 28d5635..0d49f98 100644
--- a/gdb/s12z-tdep.c
+++ b/gdb/s12z-tdep.c
@@ -516,7 +516,7 @@ s12z_print_ccw_info (struct gdbarch *gdbarch,
gdb_putc (ccw_bits[b], file);
}
else
- gdb_putc (tolower (ccw_bits[b]), file);
+ gdb_putc (c_tolower (ccw_bits[b]), file);
}
gdb_putc ('\n', file);
}
diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c
index 8a2b405..0cef5f4 100644
--- a/gdb/s390-tdep.c
+++ b/gdb/s390-tdep.c
@@ -7057,10 +7057,10 @@ s390_gnu_triplet_regexp (struct gdbarch *gdbarch)
static int
s390_stap_is_single_operand (struct gdbarch *gdbarch, const char *s)
{
- return ((isdigit (*s) && s[1] == '(' && s[2] == '%') /* Displacement
+ return ((c_isdigit (*s) && s[1] == '(' && s[2] == '%') /* Displacement
or indirection. */
|| *s == '%' /* Register access. */
- || isdigit (*s)); /* Literal number. */
+ || c_isdigit (*s)); /* Literal number. */
}
/* gdbarch init. */
@@ -7300,7 +7300,7 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
s390_displaced_step_copy_insn);
set_gdbarch_displaced_step_fixup (gdbarch, s390_displaced_step_fixup);
set_gdbarch_displaced_step_hw_singlestep (gdbarch, s390_displaced_step_hw_singlestep);
- set_gdbarch_software_single_step (gdbarch, s390_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, s390_software_single_step);
set_gdbarch_max_insn_length (gdbarch, S390_MAX_INSTR_SIZE);
/* Prologue analysis. */
diff --git a/gdb/serial.c b/gdb/serial.c
index d66c637..d047fdf 100644
--- a/gdb/serial.c
+++ b/gdb/serial.c
@@ -17,7 +17,6 @@
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 <ctype.h>
#include "serial.h"
#include "cli/cli-cmds.h"
#include "cli/cli-utils.h"
@@ -116,7 +115,7 @@ serial_logchar (struct ui_file *stream, int ch_type, int ch, int timeout)
break;
default:
gdb_printf (stream,
- isprint (ch) ? "%c" : "\\x%02x", ch & 0xFF);
+ c_isprint (ch) ? "%c" : "\\x%02x", ch & 0xFF);
break;
}
}
diff --git a/gdb/setup.cfg b/gdb/setup.cfg
index d33058e..2e83eb5 100644
--- a/gdb/setup.cfg
+++ b/gdb/setup.cfg
@@ -7,6 +7,3 @@
# E701: Multiple statements on one line (colon)
# W503: line break before binary operator
ignore = E203,E501,E701,W503
-
-[isort]
-profile = black
diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c
index b246df8..308ff80 100644
--- a/gdb/solib-aix.c
+++ b/gdb/solib-aix.c
@@ -28,6 +28,8 @@
struct aix_solib_ops : public solib_ops
{
+ using solib_ops::solib_ops;
+
void relocate_section_addresses (solib &so, target_section *) const override;
void create_inferior_hook (int from_tty) const override;
owning_intrusive_list<solib> current_sos () const override;
@@ -37,9 +39,9 @@ struct aix_solib_ops : public solib_ops
/* See solib-aix.h. */
solib_ops_up
-make_aix_solib_ops ()
+make_aix_solib_ops (program_space *pspace)
{
- return std::make_unique<aix_solib_ops> ();
+ return std::make_unique<aix_solib_ops> (pspace);
}
/* Our private data in struct solib. */
@@ -493,10 +495,8 @@ aix_solib_ops::current_sos () const
}
/* Add it to the list. */
- auto &new_solib = sos.emplace_back (*this);
- new_solib.original_name = so_name;
- new_solib.name = so_name;
- new_solib.lm_info = std::make_unique<lm_info_aix> (info);
+ sos.emplace_back (std::make_unique<lm_info_aix> (info), so_name, so_name,
+ *this);
}
return sos;
@@ -620,9 +620,9 @@ aix_solib_ops::bfd_open (const char *pathname) const
static struct obj_section *
data_obj_section_from_objfile (struct objfile *objfile)
{
- for (obj_section *osect : objfile->sections ())
- if (strcmp (bfd_section_name (osect->the_bfd_section), ".data") == 0)
- return osect;
+ for (obj_section &osect : objfile->sections ())
+ if (strcmp (bfd_section_name (osect.the_bfd_section), ".data") == 0)
+ return &osect;
return NULL;
}
diff --git a/gdb/solib-aix.h b/gdb/solib-aix.h
index 628b7c8..887487d 100644
--- a/gdb/solib-aix.h
+++ b/gdb/solib-aix.h
@@ -24,6 +24,6 @@ extern CORE_ADDR solib_aix_get_toc_value (CORE_ADDR pc);
/* Return a new solib_ops for AIX systems. */
-solib_ops_up make_aix_solib_ops ();
+solib_ops_up make_aix_solib_ops (program_space *pspace);
#endif /* GDB_SOLIB_AIX_H */
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index aac8ab2..a6f5504 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -37,6 +37,8 @@
struct darwin_solib_ops : public solib_ops
{
+ using solib_ops::solib_ops;
+
void relocate_section_addresses (solib &so, target_section *) const override;
void clear_solib (program_space *pspace) const override;
void create_inferior_hook (int from_tty) const override;
@@ -47,9 +49,9 @@ struct darwin_solib_ops : public solib_ops
/* See solib-darwin.h. */
solib_ops_up
-make_darwin_solib_ops ()
+make_darwin_solib_ops (program_space *pspace)
{
- return std::make_unique<darwin_solib_ops> ();
+ return std::make_unique<darwin_solib_ops> (pspace);
}
struct gdb_dyld_image_info
@@ -156,8 +158,12 @@ darwin_load_image_infos (struct darwin_info *info)
struct lm_info_darwin final : public lm_info
{
+ explicit lm_info_darwin (CORE_ADDR lm_addr)
+ : lm_addr (lm_addr)
+ {}
+
/* The target location of lm. */
- CORE_ADDR lm_addr = 0;
+ CORE_ADDR lm_addr;
};
/* Lookup the value for a specific symbol. */
@@ -267,15 +273,8 @@ darwin_solib_ops::current_sos () const
break;
/* Create and fill the new struct solib element. */
- auto &newobj = sos.emplace_back (*this);
-
- auto li = std::make_unique<lm_info_darwin> ();
-
- newobj.name = file_path.get ();
- newobj.original_name = newobj.name;
- li->lm_addr = load_addr;
-
- newobj.lm_info = std::move (li);
+ sos.emplace_back (std::make_unique<lm_info_darwin> (load_addr),
+ file_path.get (), file_path.get (), *this);
}
return sos;
diff --git a/gdb/solib-darwin.h b/gdb/solib-darwin.h
index f5bcdd1..fc28b2c 100644
--- a/gdb/solib-darwin.h
+++ b/gdb/solib-darwin.h
@@ -24,6 +24,6 @@
/* Return a new solib_ops for Darwin systems. */
-extern solib_ops_up make_darwin_solib_ops ();
+extern solib_ops_up make_darwin_solib_ops (program_space *pspace);
#endif /* GDB_SOLIB_DARWIN_H */
diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c
index 13623fc..719678b 100644
--- a/gdb/solib-dsbt.c
+++ b/gdb/solib-dsbt.c
@@ -123,6 +123,8 @@ struct dbst_ext_link_map
struct dsbt_solib_ops : public solib_ops
{
+ using solib_ops::solib_ops;
+
void relocate_section_addresses (solib &so, target_section *) const override;
void clear_solib (program_space *pspace) const override;
void create_inferior_hook (int from_tty) const override;
@@ -133,22 +135,28 @@ struct dsbt_solib_ops : public solib_ops
/* See solib-dsbt.h. */
solib_ops_up
-make_dsbt_solib_ops ()
+make_dsbt_solib_ops (program_space *pspace)
{
- return std::make_unique<dsbt_solib_ops> ();
+ return std::make_unique<dsbt_solib_ops> (pspace);
}
/* Link map info to include in an allocated solib entry */
struct lm_info_dsbt final : public lm_info
{
+ explicit lm_info_dsbt (int_elf32_dsbt_loadmap *map)
+ : map (map)
+ {}
+
+ DISABLE_COPY_AND_ASSIGN (lm_info_dsbt);
+
~lm_info_dsbt ()
{
xfree (this->map);
}
/* The loadmap, digested into an easier to use form. */
- int_elf32_dsbt_loadmap *map = NULL;
+ int_elf32_dsbt_loadmap *map;
};
/* Per pspace dsbt specific data. */
@@ -602,9 +610,6 @@ dsbt_solib_ops::current_sos () const
break;
}
- auto &sop = sos.emplace_back (*this);
- auto li = std::make_unique<lm_info_dsbt> ();
- li->map = loadmap;
/* Fetch the name. */
addr = extract_unsigned_integer (lm_buf.l_name,
sizeof (lm_buf.l_name),
@@ -619,12 +624,12 @@ dsbt_solib_ops::current_sos () const
if (solib_dsbt_debug)
gdb_printf (gdb_stdlog, "current_sos: name = %s\n",
name_buf.get ());
-
- sop.name = name_buf.get ();
- sop.original_name = sop.name;
}
- sop.lm_info = std::move (li);
+ sos.emplace_back (std::make_unique<lm_info_dsbt> (loadmap),
+ name_buf != nullptr ? name_buf.get () : "",
+ name_buf != nullptr ? name_buf.get () : "",
+ *this);
}
else
{
@@ -807,23 +812,22 @@ dsbt_relocate_main_executable (void)
ldm = info->exec_loadmap;
delete info->main_executable_lm_info;
- info->main_executable_lm_info = new lm_info_dsbt;
- info->main_executable_lm_info->map = ldm;
+ info->main_executable_lm_info = new lm_info_dsbt (ldm);
objfile *objf = current_program_space->symfile_object_file;
section_offsets new_offsets (objf->section_offsets.size ());
changed = 0;
- for (obj_section *osect : objf->sections ())
+ for (obj_section &osect : objf->sections ())
{
CORE_ADDR orig_addr, addr, offset;
int osect_idx;
int seg;
- osect_idx = osect - objf->sections_start;
+ osect_idx = &osect - objf->sections_start;
/* Current address of section. */
- addr = osect->addr ();
+ addr = osect.addr ();
/* Offset from where this section started. */
offset = objf->section_offsets[osect_idx];
/* Original address prior to any past relocations. */
diff --git a/gdb/solib-dsbt.h b/gdb/solib-dsbt.h
index d44613c..00f7791 100644
--- a/gdb/solib-dsbt.h
+++ b/gdb/solib-dsbt.h
@@ -24,6 +24,6 @@
/* Return a new solib_ops for DSBT systems. */
-solib_ops_up make_dsbt_solib_ops ();
+solib_ops_up make_dsbt_solib_ops (program_space *pspace);
#endif /* GDB_SOLIB_DSBT_H */
diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c
index b48efe5..ac5872e 100644
--- a/gdb/solib-frv.c
+++ b/gdb/solib-frv.c
@@ -31,6 +31,8 @@
struct frv_solib_ops : public solib_ops
{
+ using solib_ops::solib_ops;
+
void relocate_section_addresses (solib &so, target_section *) const override;
void clear_solib (program_space *pspace) const override;
void create_inferior_hook (int from_tty) const override;
@@ -41,9 +43,9 @@ struct frv_solib_ops : public solib_ops
/* See solib-frv.h. */
solib_ops_up
-make_frv_solib_ops ()
+make_frv_solib_ops (program_space *pspace)
{
- return std::make_unique<frv_solib_ops> ();
+ return std::make_unique<frv_solib_ops> (pspace);
}
/* FR-V pointers are four bytes wide. */
@@ -216,6 +218,13 @@ struct ext_link_map
struct lm_info_frv final : public lm_info
{
+ lm_info_frv (int_elf32_fdpic_loadmap *map, CORE_ADDR got_value,
+ CORE_ADDR lm_addr)
+ : map (map), got_value (got_value), lm_addr (lm_addr)
+ {}
+
+ DISABLE_COPY_AND_ASSIGN (lm_info_frv);
+
~lm_info_frv ()
{
xfree (this->map);
@@ -224,11 +233,11 @@ struct lm_info_frv final : public lm_info
}
/* The loadmap, digested into an easier to use form. */
- int_elf32_fdpic_loadmap *map = NULL;
+ int_elf32_fdpic_loadmap *map;
/* The GOT address for this link map entry. */
- CORE_ADDR got_value = 0;
+ CORE_ADDR got_value;
/* The link map address, needed for frv_fetch_objfile_link_map(). */
- CORE_ADDR lm_addr = 0;
+ CORE_ADDR lm_addr;
/* Cached dynamic symbol table and dynamic relocs initialized and
used only by find_canonical_descriptor_in_load_object().
@@ -383,13 +392,6 @@ frv_solib_ops::current_sos () const
break;
}
- auto &sop = sos.emplace_back (*this);
- auto li = std::make_unique<lm_info_frv> ();
- 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),
@@ -401,11 +403,12 @@ frv_solib_ops::current_sos () const
if (name_buf == nullptr)
warning (_("Can't read pathname for link map entry."));
- else
- {
- sop.name = name_buf.get ();
- sop.original_name = sop.name;
- }
+
+ sos.emplace_back (std::make_unique<lm_info_frv> (loadmap, got_addr,
+ lm_addr),
+ name_buf != nullptr ? name_buf.get () : "",
+ name_buf != nullptr ? name_buf.get () : "",
+ *this);
}
else
{
@@ -741,23 +744,22 @@ frv_relocate_main_executable (void)
error (_("Unable to load the executable's loadmap."));
delete main_executable_lm_info;
- main_executable_lm_info = new lm_info_frv;
- main_executable_lm_info->map = ldm;
+ main_executable_lm_info = new lm_info_frv (ldm, 0, 0);
objfile *objf = current_program_space->symfile_object_file;
section_offsets new_offsets (objf->section_offsets.size ());
changed = 0;
- for (obj_section *osect : objf->sections ())
+ for (obj_section &osect : objf->sections ())
{
CORE_ADDR orig_addr, addr, offset;
int osect_idx;
int seg;
-
- osect_idx = osect - objf->sections_start;
+
+ osect_idx = &osect - objf->sections_start;
/* Current address of section. */
- addr = osect->addr ();
+ addr = osect.addr ();
/* Offset from where this section started. */
offset = objf->section_offsets[osect_idx];
/* Original address prior to any past relocations. */
diff --git a/gdb/solib-frv.h b/gdb/solib-frv.h
index a2f3558..33d156c 100644
--- a/gdb/solib-frv.h
+++ b/gdb/solib-frv.h
@@ -23,6 +23,6 @@
/* Return a new solib_ops for FR-V systems. */
-solib_ops_up make_frv_solib_ops ();
+solib_ops_up make_frv_solib_ops (program_space *pspace);
#endif /* GDB_SOLIB_FRV_H */
diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c
index 2d26c3c..3b121e6 100644
--- a/gdb/solib-rocm.c
+++ b/gdb/solib-rocm.c
@@ -160,8 +160,8 @@ struct rocm_solib_ops : public solib_ops
{
/* HOST_OPS is the host solib_ops that rocm_solib_ops hijacks / wraps,
in order to provide support for ROCm code objects. */
- explicit rocm_solib_ops (solib_ops_up host_ops)
- : m_host_ops (std::move (host_ops))
+ explicit rocm_solib_ops (program_space *pspace, solib_ops_up host_ops)
+ : solib_ops (pspace), m_host_ops (std::move (host_ops))
{
}
@@ -211,6 +211,14 @@ struct rocm_solib_ops : public solib_ops
std::vector<const solib *> get_solibs_in_ns (int nsid) const override
{ return m_host_ops->get_solibs_in_ns (nsid); }
+ void iterate_over_objfiles_in_search_order
+ (iterate_over_objfiles_in_search_order_cb_ftype cb,
+ objfile *current_objfile) const override
+ {
+ return m_host_ops->iterate_over_objfiles_in_search_order
+ (cb, current_objfile);
+ }
+
private:
owning_intrusive_list<solib>
solibs_from_rocm_sos (const std::vector<rocm_so> &sos) const;
@@ -272,13 +280,8 @@ rocm_solib_ops::solibs_from_rocm_sos (const std::vector<rocm_so> &sos) const
owning_intrusive_list<solib> dst;
for (const rocm_so &so : sos)
- {
- auto &newobj = dst.emplace_back (*this);
-
- newobj.lm_info = std::make_unique<lm_info_svr4> (*so.lm_info);
- newobj.name = so.name;
- newobj.original_name = so.unique_name;
- }
+ dst.emplace_back (std::make_unique<lm_info_svr4> (*so.lm_info),
+ so.unique_name, so.name, *this);
return dst;
}
@@ -503,7 +506,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
protocol_end += protocol_delim.length ();
std::transform (protocol.begin (), protocol.end (), protocol.begin (),
- [] (unsigned char c) { return std::tolower (c); });
+ [] (unsigned char c) { return c_tolower (c); });
std::string_view path;
size_t path_end = uri.find_first_of ("#?", protocol_end);
@@ -518,8 +521,8 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior)
for (size_t i = 0; i < path.length (); ++i)
if (path[i] == '%'
&& i < path.length () - 2
- && std::isxdigit (path[i + 1])
- && std::isxdigit (path[i + 2]))
+ && c_isxdigit (path[i + 1])
+ && c_isxdigit (path[i + 2]))
{
std::string_view hex_digits = path.substr (i + 1, 2);
decoded_path += std::stoi (std::string (hex_digits), 0, 16);
@@ -788,7 +791,8 @@ rocm_update_solib_list ()
gdb::unique_xmalloc_ptr<char> uri_bytes_holder (uri_bytes);
- lm_info_svr4_up li = std::make_unique<lm_info_svr4> ();
+ /* Pass a dummy debug base. */
+ lm_info_svr4_up li = std::make_unique<lm_info_svr4> (-1);
li->l_addr = l_addr;
/* Generate a unique name so that code objects with the same URI but
@@ -807,7 +811,8 @@ rocm_solib_target_inferior_created (inferior *inf)
get_solib_info (inf)->solib_list.clear ();
auto prev_ops = inf->pspace->release_solib_ops ();
- auto rocm_ops = std::make_unique<rocm_solib_ops> (std::move (prev_ops));
+ auto rocm_ops
+ = std::make_unique<rocm_solib_ops> (inf->pspace, std::move (prev_ops));
inf->pspace->set_solib_ops (std::move (rocm_ops));
rocm_update_solib_list ();
@@ -825,9 +830,11 @@ rocm_solib_target_inferior_execd (inferior *exec_inf, inferior *follow_inf)
if (get_amd_dbgapi_process_id (follow_inf) == AMD_DBGAPI_PROCESS_NONE)
return;
- auto prev_ops = follow_inf->pspace->release_solib_ops ();
- auto rocm_ops = std::make_unique<rocm_solib_ops> (std::move (prev_ops));
- follow_inf->pspace->set_solib_ops (std::move (rocm_ops));
+ auto pspace = follow_inf->pspace;
+ auto prev_ops = pspace->release_solib_ops ();
+ auto rocm_ops
+ = std::make_unique<rocm_solib_ops> (pspace, std::move (prev_ops));
+ pspace->set_solib_ops (std::move (rocm_ops));
get_solib_info (exec_inf)->solib_list.clear ();
}
diff --git a/gdb/solib-svr4-linux.c b/gdb/solib-svr4-linux.c
index fd86cf0..fe82e5d 100644
--- a/gdb/solib-svr4-linux.c
+++ b/gdb/solib-svr4-linux.c
@@ -22,9 +22,9 @@
/* See solib-svr4-linux.h. */
solib_ops_up
-make_linux_ilp32_svr4_solib_ops ()
+make_linux_ilp32_svr4_solib_ops (program_space *pspace)
{
- return std::make_unique<linux_ilp32_svr4_solib_ops> ();
+ return std::make_unique<linux_ilp32_svr4_solib_ops> (pspace);
}
/* See solib-svr4-linux.h. */
@@ -61,9 +61,9 @@ linux_ilp32_svr4_solib_ops::fetch_link_map_offsets () const
/* See solib-svr4-linux.h. */
solib_ops_up
-make_linux_lp64_svr4_solib_ops ()
+make_linux_lp64_svr4_solib_ops (program_space *pspace)
{
- return std::make_unique<linux_lp64_svr4_solib_ops> ();
+ return std::make_unique<linux_lp64_svr4_solib_ops> (pspace);
}
/* See linux-tdep.h. */
diff --git a/gdb/solib-svr4-linux.h b/gdb/solib-svr4-linux.h
index 623013c..af040ff 100644
--- a/gdb/solib-svr4-linux.h
+++ b/gdb/solib-svr4-linux.h
@@ -26,6 +26,8 @@
struct linux_ilp32_svr4_solib_ops : public svr4_solib_ops
{
+ using svr4_solib_ops::svr4_solib_ops;
+
link_map_offsets *fetch_link_map_offsets () const override;
};
@@ -33,15 +35,17 @@ struct linux_ilp32_svr4_solib_ops : public svr4_solib_ops
struct linux_lp64_svr4_solib_ops : public svr4_solib_ops
{
+ using svr4_solib_ops::svr4_solib_ops;
+
link_map_offsets *fetch_link_map_offsets () const override;
};
/* Return a new solib_ops for ILP32 Linux systems. */
-extern solib_ops_up make_linux_ilp32_svr4_solib_ops ();
+extern solib_ops_up make_linux_ilp32_svr4_solib_ops (program_space *pspace);
/* Return a new solib_ops for LP64 Linux systems. */
-extern solib_ops_up make_linux_lp64_svr4_solib_ops ();
+extern solib_ops_up make_linux_lp64_svr4_solib_ops (program_space *pspace);
#endif /* GDB_SOLIB_SVR4_LINUX_H */
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index af08b75..27e0343 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -49,10 +49,6 @@
static void svr4_relocate_main_executable (void);
static void probes_table_remove_objfile_probes (struct objfile *objfile);
-static void svr4_iterate_over_objfiles_in_search_order
- (gdbarch *gdbarch, iterate_over_objfiles_in_search_order_cb_ftype cb,
- objfile *current_objfile);
-
/* On SVR4 systems, a list of symbols in the dynamic linker where
GDB can try to place a breakpoint to monitor shared library
@@ -116,11 +112,17 @@ static const struct probe_info probe_info[] =
#define NUM_PROBES ARRAY_SIZE (probe_info)
-/* Return non-zero if GDB_SO_NAME and INFERIOR_SO_NAME represent
- the same shared library. */
+static lm_info_svr4 &
+get_lm_info_svr4 (const solib &solib)
+{
+ return gdb::checked_static_cast<lm_info_svr4 &> (*solib.lm_info);
+}
-static int
-svr4_same_1 (const char *gdb_so_name, const char *inferior_so_name)
+/* Return true if GDB_SO_NAME and INFERIOR_SO_NAME represent the same shared
+ library. */
+
+static bool
+svr4_same_name (const char *gdb_so_name, const char *inferior_so_name)
{
if (strcmp (gdb_so_name, inferior_so_name) == 0)
return 1;
@@ -153,29 +155,33 @@ svr4_same (const char *gdb_name, const char *inferior_name,
const lm_info_svr4 &gdb_lm_info,
const lm_info_svr4 &inferior_lm_info)
{
- if (!svr4_same_1 (gdb_name, inferior_name))
+ /* There may be different instances of the same library, in different
+ namespaces. Each instance is typically loaded at a different address
+ so its relocation offset would be different. */
+ if (gdb_lm_info.l_addr_inferior != inferior_lm_info.l_addr_inferior)
return false;
- /* There may be different instances of the same library, in different
- namespaces. Each instance, however, must have been loaded at a
- different address so its relocation offset would be different. */
- return gdb_lm_info.l_addr_inferior == inferior_lm_info.l_addr_inferior;
+ /* There may be multiple entries for the same dynamic linker instance (at
+ the same address) visible in different namespaces. Those are considered
+ different instances. */
+ if (gdb_lm_info.debug_base != inferior_lm_info.debug_base)
+ return false;
+
+ return svr4_same_name (gdb_name, inferior_name);
}
bool
svr4_solib_ops::same (const solib &gdb, const solib &inferior) const
{
- auto *lmg
- = gdb::checked_static_cast<const lm_info_svr4 *> (gdb.lm_info.get ());
- auto *lmi
- = gdb::checked_static_cast<const lm_info_svr4 *> (inferior.lm_info.get ());
+ auto &lmg = get_lm_info_svr4 (gdb);
+ auto &lmi = get_lm_info_svr4 (inferior);
return svr4_same (gdb.original_name.c_str (),
- inferior.original_name.c_str (), *lmg, *lmi);
+ inferior.original_name.c_str (), lmg, lmi);
}
lm_info_svr4_up
-svr4_solib_ops::read_lm_info (CORE_ADDR lm_addr) const
+svr4_solib_ops::read_lm_info (CORE_ADDR lm_addr, CORE_ADDR debug_base) const
{
link_map_offsets *lmo = this->fetch_link_map_offsets ();
lm_info_svr4_up lm_info;
@@ -190,7 +196,7 @@ svr4_solib_ops::read_lm_info (CORE_ADDR lm_addr) const
type *ptr_type
= builtin_type (current_inferior ()->arch ())->builtin_data_ptr;
- lm_info = std::make_unique<lm_info_svr4> ();
+ lm_info = std::make_unique<lm_info_svr4> (debug_base);
lm_info->lm_addr = lm_addr;
lm_info->l_addr_inferior = extract_typed_address (&lm[lmo->l_addr_offset],
@@ -218,19 +224,19 @@ svr4_solib_ops::has_lm_dynamic_from_link_map () const
CORE_ADDR
svr4_solib_ops::lm_addr_check (const solib &so, bfd *abfd) const
{
- auto *li = gdb::checked_static_cast<lm_info_svr4 *> (so.lm_info.get ());
+ auto &li = get_lm_info_svr4 (so);
- if (!li->l_addr_p)
+ if (!li.l_addr_p)
{
struct bfd_section *dyninfo_sect;
CORE_ADDR l_addr, l_dynaddr, dynaddr;
- l_addr = li->l_addr_inferior;
+ l_addr = li.l_addr_inferior;
if (!abfd || !this->has_lm_dynamic_from_link_map ())
goto set_addr;
- l_dynaddr = li->l_ld;
+ l_dynaddr = li.l_ld;
dyninfo_sect = bfd_get_section_by_name (abfd, ".dynamic");
if (dyninfo_sect == NULL)
@@ -314,11 +320,11 @@ svr4_solib_ops::lm_addr_check (const solib &so, bfd *abfd) const
}
set_addr:
- li->l_addr = l_addr;
- li->l_addr_p = 1;
+ li.l_addr = l_addr;
+ li.l_addr_p = 1;
}
- return li->l_addr;
+ return li.l_addr;
}
struct svr4_so
@@ -335,8 +341,11 @@ struct svr4_so
struct svr4_info
{
- /* Base of dynamic linker structures in default namespace. */
- CORE_ADDR debug_base = 0;
+ /* Base of dynamic linker structures in default namespace.
+
+ The value is fetched from the inferior every time we need it. This field
+ represents the last known value. */
+ CORE_ADDR default_debug_base = 0;
/* Validity flag for debug_loader_offset. */
int debug_loader_offset_p = 0;
@@ -435,12 +444,6 @@ svr4_maybe_add_namespace (svr4_info *info, CORE_ADDR lmid)
info->namespace_id.push_back (lmid);
info->active_namespaces.insert (i);
-
- /* Create or update the convenience variable "active_namespaces".
- It only needs to be updated here, as this only changes when a
- dlmopen or dlclose call happens. */
- set_internalvar_integer (lookup_internalvar ("_active_linker_namespaces"),
- info->active_namespaces.size ());
}
/* Return whether DEBUG_BASE is the default namespace of INFO. */
@@ -448,7 +451,7 @@ svr4_maybe_add_namespace (svr4_info *info, CORE_ADDR lmid)
static bool
svr4_is_default_namespace (const svr4_info *info, CORE_ADDR debug_base)
{
- return (debug_base == info->debug_base);
+ return debug_base == info->default_debug_base;
}
/* Free the probes table. */
@@ -713,8 +716,8 @@ scan_dyntag_auxv (const int desired_dyntag, CORE_ADDR *ptr,
return 0;
}
-/* Locate the base address of dynamic linker structs for SVR4 elf
- targets.
+/* Locate the base address the dynamic linker structure for the default
+ namespace.
For SVR4 elf targets the address of the dynamic linker's runtime
structure is contained within the dynamic info section in the
@@ -723,10 +726,13 @@ scan_dyntag_auxv (const int desired_dyntag, CORE_ADDR *ptr,
real address before starting the inferior, we have to read in the
dynamic info section from the inferior address space.
If there are any errors while trying to find the address, we
- silently return 0, otherwise the found address is returned. */
+ silently return 0, otherwise the found address is returned.
+
+ If we try to read the address before the dynamic linker had a change to
+ fill in the real address, this will also typically return 0. */
static CORE_ADDR
-elf_locate_base (void)
+locate_default_debug_base ()
{
CORE_ADDR dyn_ptr, dyn_ptr_addr;
@@ -790,6 +796,38 @@ elf_locate_base (void)
return 0;
}
+/* See solib-svr4.h. */
+
+CORE_ADDR
+svr4_solib_ops::default_debug_base (svr4_info *info, bool *changed) const
+{
+ CORE_ADDR default_debug_base = locate_default_debug_base ();
+
+ if (changed != nullptr)
+ *changed = default_debug_base != info->default_debug_base;
+
+ if (default_debug_base != info->default_debug_base)
+ {
+ /* Update the debug base value for existing solibs. The only known case
+ where this is required is when a struct solib was created for the
+ dynamic linker itself by svr4_solib_ops::default_sos, before the
+ default debug base was known. */
+ for (const auto &solib : m_pspace->solibs ())
+ {
+ if (&solib.ops () != this)
+ continue;
+
+ if (auto &li = get_lm_info_svr4 (solib);
+ li.debug_base == info->default_debug_base)
+ li.debug_base = default_debug_base;
+ }
+
+ info->default_debug_base = default_debug_base;
+ }
+
+ return info->default_debug_base;
+}
+
/* Find the first element in the inferior's dynamic link map, and
return its address in the inferior. Return zero if the address
could not be determined.
@@ -828,8 +866,10 @@ svr4_solib_ops::find_r_brk (svr4_info *info) const
type *ptr_type
= builtin_type (current_inferior ()->arch ())->builtin_data_ptr;
- return read_memory_typed_address (info->debug_base + lmo->r_brk_offset,
- ptr_type);
+ gdb_assert (info->default_debug_base != 0);
+
+ return read_memory_typed_address ((info->default_debug_base
+ + lmo->r_brk_offset), ptr_type);
}
/* Find the link map for the dynamic linker (if it is not in the
@@ -844,12 +884,15 @@ svr4_solib_ops::find_r_ldsomap (svr4_info *info) const
enum bfd_endian byte_order = type_byte_order (ptr_type);
ULONGEST version = 0;
+ gdb_assert (info->default_debug_base != 0);
+
try
{
/* Check version, and return zero if `struct r_debug' doesn't have
the r_ldsomap member. */
version
- = read_memory_unsigned_integer (info->debug_base + lmo->r_version_offset,
+ = read_memory_unsigned_integer ((info->default_debug_base
+ + lmo->r_version_offset),
lmo->r_version_size, byte_order);
}
catch (const gdb_exception_error &ex)
@@ -860,7 +903,8 @@ svr4_solib_ops::find_r_ldsomap (svr4_info *info) const
if (version < 2 || lmo->r_ldsomap_offset == -1)
return 0;
- return read_memory_typed_address (info->debug_base + lmo->r_ldsomap_offset,
+ return read_memory_typed_address ((info->default_debug_base
+ + lmo->r_ldsomap_offset),
ptr_type);
}
@@ -909,16 +953,17 @@ svr4_solib_ops::keep_data_in_core (CORE_ADDR vaddr, unsigned long size) const
CORE_ADDR name_lm;
info = get_svr4_info (current_program_space);
+ CORE_ADDR default_debug_base = this->default_debug_base (info);
- info->debug_base = elf_locate_base ();
- if (info->debug_base == 0)
+ if (default_debug_base == 0)
return false;
ldsomap = this->find_r_ldsomap (info);
if (!ldsomap)
return false;
- std::unique_ptr<lm_info_svr4> li = this->read_lm_info (ldsomap);
+ std::unique_ptr<lm_info_svr4> li
+ = this->read_lm_info (ldsomap, info->default_debug_base);
name_lm = li != NULL ? li->l_name : 0;
return (name_lm >= vaddr && name_lm < vaddr + size);
@@ -945,13 +990,13 @@ svr4_solib_ops::open_symbol_file_object (int from_tty) const
if (!query (_("Attempt to reload symbols from process? ")))
return false;
- /* Always locate the debug struct, in case it has moved. */
- info->debug_base = elf_locate_base ();
- if (info->debug_base == 0)
+ CORE_ADDR default_debug_base = this->default_debug_base (info);
+
+ if (default_debug_base == 0)
return false; /* failed somehow... */
/* First link map member should be the executable. */
- lm = this->read_r_map (info->debug_base);
+ lm = this->read_r_map (default_debug_base);
if (lm == 0)
return false; /* failed somehow... */
@@ -1013,10 +1058,7 @@ svr4_free_objfile_observer (struct objfile *objfile)
void
svr4_solib_ops::clear_so (const solib &so) const
{
- auto *li = gdb::checked_static_cast<lm_info_svr4 *> (so.lm_info.get ());
-
- if (li != NULL)
- li->l_addr_p = 0;
+ get_lm_info_svr4 (so).l_addr_p = 0;
}
/* Create the solib objects equivalent to the svr4_sos in SOS. */
@@ -1027,13 +1069,8 @@ svr4_solib_ops::solibs_from_svr4_sos (const std::vector<svr4_so> &sos) const
owning_intrusive_list<solib> dst;
for (const svr4_so &so : sos)
- {
- auto &newobj = dst.emplace_back (*this);
-
- newobj.name = so.name;
- newobj.original_name = so.name;
- newobj.lm_info = std::make_unique<lm_info_svr4> (*so.lm_info);
- }
+ dst.emplace_back (std::make_unique<lm_info_svr4> (*so.lm_info), so.name,
+ so.name, *this);
return dst;
}
@@ -1061,28 +1098,33 @@ library_list_start_library (struct gdb_xml_parser *parser,
ULONGEST *l_ldp
= (ULONGEST *) xml_find_attribute (attributes, "l_ld")->value.get ();
- lm_info_svr4_up li = std::make_unique<lm_info_svr4> ();
- li->lm_addr = *lmp;
- li->l_addr_inferior = *l_addrp;
- li->l_ld = *l_ldp;
-
std::vector<svr4_so> *solist;
/* Older versions did not supply lmid. Put the element into the flat
list of the special namespace zero in that case. */
gdb_xml_value *at_lmid = xml_find_attribute (attributes, "lmid");
svr4_info *info = get_svr4_info (current_program_space);
+ ULONGEST lmid;
+
if (at_lmid == nullptr)
{
solist = list->cur_list;
svr4_maybe_add_namespace (info, 0);
+ lmid = 0;
}
else
{
- ULONGEST lmid = *(ULONGEST *) at_lmid->value.get ();
+ lmid = *(ULONGEST *) at_lmid->value.get ();
solist = &list->solib_lists[lmid];
svr4_maybe_add_namespace (info, lmid);
}
+
+ lm_info_svr4_up li = std::make_unique<lm_info_svr4> (lmid);
+
+ li->lm_addr = *lmp;
+ li->l_addr_inferior = *l_addrp;
+ li->l_ld = *l_ldp;
+
solist->emplace_back (name, std::move (li));
}
@@ -1121,7 +1163,7 @@ static const struct gdb_xml_attribute svr4_library_attributes[] =
{ "lm", GDB_XML_AF_NONE, gdb_xml_parse_attr_ulongest, NULL },
{ "l_addr", GDB_XML_AF_NONE, gdb_xml_parse_attr_ulongest, NULL },
{ "l_ld", GDB_XML_AF_NONE, gdb_xml_parse_attr_ulongest, NULL },
- { "lmid", GDB_XML_AF_NONE, gdb_xml_parse_attr_ulongest, NULL },
+ { "lmid", GDB_XML_AF_OPTIONAL, gdb_xml_parse_attr_ulongest, NULL },
{ NULL, GDB_XML_AF_NONE, NULL, NULL }
};
@@ -1221,18 +1263,15 @@ svr4_solib_ops::default_sos (svr4_info *info) const
if (!info->debug_loader_offset_p)
return {};
- auto li = std::make_unique<lm_info_svr4> ();
+ auto li = std::make_unique<lm_info_svr4> (0);
/* Nothing will ever check the other fields if we set l_addr_p. */
li->l_addr = li->l_addr_inferior = info->debug_loader_offset;
li->l_addr_p = 1;
owning_intrusive_list<solib> sos;
- auto &newobj = sos.emplace_back (*this);
-
- newobj.lm_info = std::move (li);
- newobj.name = info->debug_loader_name;
- newobj.original_name = newobj.name;
+ sos.emplace_back (std::move (li), info->debug_loader_name,
+ info->debug_loader_name, *this);
return sos;
}
@@ -1246,14 +1285,15 @@ svr4_solib_ops::default_sos (svr4_info *info) const
int
svr4_solib_ops::read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm,
- std::vector<svr4_so> &sos, int ignore_first) const
+ CORE_ADDR debug_base, std::vector<svr4_so> &sos,
+ int ignore_first) const
{
CORE_ADDR first_l_name = 0;
CORE_ADDR next_lm;
for (; lm != 0; prev_lm = lm, lm = next_lm)
{
- lm_info_svr4_up li = this->read_lm_info (lm);
+ lm_info_svr4_up li = this->read_lm_info (lm, debug_base);
if (li == NULL)
return 0;
@@ -1354,8 +1394,9 @@ svr4_solib_ops::current_sos_direct (svr4_info *info) const
/* If we can't find the dynamic linker's base structure, this
must not be a dynamically linked executable. Hmm. */
- info->debug_base = elf_locate_base ();
- if (info->debug_base == 0)
+ CORE_ADDR default_debug_base = this->default_debug_base (info);
+
+ if (default_debug_base == 0)
return;
/* Assume that everything is a library if the dynamic loader was loaded
@@ -1374,7 +1415,8 @@ svr4_solib_ops::current_sos_direct (svr4_info *info) const
});
/* Collect the sos in each namespace. */
- CORE_ADDR debug_base = info->debug_base;
+ CORE_ADDR debug_base = default_debug_base;
+
for (; debug_base != 0;
ignore_first = false, debug_base = this->read_r_next (debug_base))
{
@@ -1383,8 +1425,8 @@ svr4_solib_ops::current_sos_direct (svr4_info *info) const
if (lm != 0)
{
svr4_maybe_add_namespace (info, debug_base);
- this->read_so_list (info, lm, 0, info->solib_lists[debug_base],
- ignore_first);
+ this->read_so_list (info, lm, 0, debug_base,
+ info->solib_lists[debug_base], ignore_first);
}
}
@@ -1404,7 +1446,7 @@ svr4_solib_ops::current_sos_direct (svr4_info *info) const
if (info->solib_lists.find (debug_base) == info->solib_lists.end ())
{
svr4_maybe_add_namespace (info, debug_base);
- this->read_so_list (info, debug_base, 0,
+ this->read_so_list (info, debug_base, 0, debug_base,
info->solib_lists[debug_base], 0);
}
}
@@ -1462,6 +1504,15 @@ owning_intrusive_list<solib>
svr4_solib_ops::current_sos () const
{
svr4_info *info = get_svr4_info (current_program_space);
+
+ /* Call this for the side-effect of updating the debug base in existing
+ solibs' lm_info_svr4, if needed. It is possible for the core to have
+ an solib with a stale lm_info_svr4::debug_base. In that case, we are
+ about to return the same solib, but with an updated debug_base. If we
+ didn't do this call, then it would appear as two different libraries to
+ the core, and it would appear as a spurious unload / load. */
+ this->default_debug_base (info);
+
owning_intrusive_list<solib> sos = this->current_sos_1 (info);
struct mem_range vsyscall_range;
@@ -1515,9 +1566,9 @@ svr4_solib_ops::current_sos () const
[ 9] .dynamic DYNAMIC ffffffffff700580 000580 0000f0
*/
- auto *li = gdb::checked_static_cast<lm_info_svr4 *> (so->lm_info.get ());
+ const auto &li = get_lm_info_svr4 (*so);
- if (vsyscall_range.contains (li->l_ld))
+ if (vsyscall_range.contains (li.l_ld))
{
so = sos.erase (so);
break;
@@ -1549,12 +1600,7 @@ svr4_fetch_objfile_link_map (struct objfile *objfile)
of shared libraries. */
for (const solib &so : current_program_space->solibs ())
if (so.objfile == objfile)
- {
- auto *li
- = gdb::checked_static_cast<lm_info_svr4 *> (so.lm_info.get ());
-
- return li->lm_addr;
- }
+ return get_lm_info_svr4 (so).lm_addr;
/* Not found! */
return 0;
@@ -1577,8 +1623,8 @@ is_thread_local_section (struct bfd_section *bfd_sect)
static bool
has_thread_local_section (const objfile *objf)
{
- for (obj_section *objsec : objf->sections ())
- if (is_thread_local_section (objsec->the_bfd_section))
+ for (obj_section &objsec : objf->sections ())
+ if (is_thread_local_section (objsec.the_bfd_section))
return true;
return false;
}
@@ -1638,8 +1684,9 @@ musl_link_map_to_tls_module_id (CORE_ADDR lm_addr)
if (has_thread_local_section (so))
mod_id++;
- auto *li = gdb::checked_static_cast<lm_info_svr4 *> (so.lm_info.get ());
- if (li->lm_addr == lm_addr)
+ const auto &li = get_lm_info_svr4 (so);
+
+ if (li.lm_addr == lm_addr)
return mod_id;
}
return 0;
@@ -2074,7 +2121,7 @@ svr4_solib_ops::update_incremental (svr4_info *info, CORE_ADDR debug_base,
above check and deferral to solist_update_full ensures
that this call to svr4_read_so_list will never see the
first element. */
- if (!this->read_so_list (info, lm, prev_lm, solist, 0))
+ if (!this->read_so_list (info, lm, prev_lm, debug_base, solist, 0))
return 0;
}
@@ -2173,17 +2220,14 @@ svr4_solib_ops::handle_event () const
if (debug_base == 0)
return;
- /* If the global _r_debug object moved, we need to reload everything
- since we cannot identify namespaces (by the location of their
- r_debug_ext object) anymore. */
- CORE_ADDR global_debug_base = elf_locate_base ();
- if (global_debug_base != info->debug_base)
- {
- info->debug_base = global_debug_base;
- action = FULL_RELOAD;
- }
+ bool default_debug_base_changed;
+ CORE_ADDR default_debug_base
+ = this->default_debug_base (info, &default_debug_base_changed);
+
+ if (default_debug_base_changed)
+ action = FULL_RELOAD;
- if (info->debug_base == 0)
+ if (default_debug_base == 0)
{
/* It's possible for the reloc_complete probe to be triggered before
the linker has set the DT_DEBUG pointer (for example, when the
@@ -2474,7 +2518,6 @@ svr4_solib_ops::enable_break (svr4_info *info, int from_tty) const
{
const char * const *bkpt_namep;
asection *interp_sect;
- CORE_ADDR sym_addr;
info->interp_text_sect_low = info->interp_text_sect_high = 0;
info->interp_plt_sect_low = info->interp_plt_sect_high = 0;
@@ -2485,8 +2528,11 @@ svr4_solib_ops::enable_break (svr4_info *info, int from_tty) const
is the object containing r_brk. */
solib_add (NULL, from_tty, auto_solib_add);
- sym_addr = 0;
- if (info->debug_base && this->read_r_map (info->debug_base) != 0)
+
+ CORE_ADDR sym_addr = 0;
+ CORE_ADDR default_debug_base = this->default_debug_base (info);
+
+ if (default_debug_base != 0 && this->read_r_map (default_debug_base) != 0)
sym_addr = this->find_r_brk (info);
if (sym_addr != 0)
@@ -2595,7 +2641,7 @@ svr4_solib_ops::enable_break (svr4_info *info, int from_tty) const
address from the shared library table. */
for (const solib &so : current_program_space->solibs ())
{
- if (svr4_same_1 (interp_name, so.original_name.c_str ()))
+ if (svr4_same_name (interp_name, so.original_name.c_str ()))
{
load_addr_found = 1;
loader_found_in_list = 1;
@@ -3308,7 +3354,7 @@ void
svr4_solib_ops::clear_solib (program_space *pspace) const
{
svr4_info *info = get_svr4_info (pspace);
- info->debug_base = 0;
+ info->default_debug_base = 0;
info->debug_loader_offset_p = 0;
info->debug_loader_offset = 0;
info->debug_loader_name.clear ();
@@ -3453,16 +3499,14 @@ void
set_solib_svr4_ops (gdbarch *gdbarch, gdbarch_make_solib_ops_ftype make_solib_ops)
{
set_gdbarch_make_solib_ops (gdbarch, make_solib_ops);
- set_gdbarch_iterate_over_objfiles_in_search_order
- (gdbarch, svr4_iterate_over_objfiles_in_search_order);
}
/* See solib-svr4.h. */
solib_ops_up
-make_svr4_ilp32_solib_ops ()
+make_svr4_ilp32_solib_ops (program_space *pspace)
{
- return std::make_unique<ilp32_svr4_solib_ops> ();
+ return std::make_unique<ilp32_svr4_solib_ops> (pspace);
}
/* Most OS'es that have SVR4-style ELF dynamic libraries define a
@@ -3505,15 +3549,17 @@ ilp32_svr4_solib_ops::fetch_link_map_offsets () const
struct lp64_svr4_solib_ops : public svr4_solib_ops
{
+ using svr4_solib_ops::svr4_solib_ops;
+
link_map_offsets *fetch_link_map_offsets () const override;
};
/* See solib-svr4.h. */
solib_ops_up
-make_svr4_lp64_solib_ops ()
+make_svr4_lp64_solib_ops (program_space *pspace)
{
- return std::make_unique<lp64_svr4_solib_ops> ();
+ return std::make_unique<lp64_svr4_solib_ops> (pspace);
}
/* Fetch (and possibly build) an appropriate `struct link_map_offsets'
@@ -3588,16 +3634,9 @@ find_debug_base_for_solib (const solib *solib)
svr4_info *info = get_svr4_info (solib->objfile->pspace ());
gdb_assert (info != nullptr);
- auto *lm_info
- = gdb::checked_static_cast<const lm_info_svr4 *> (solib->lm_info.get ());
-
- for (const auto &[debug_base, sos] : info->solib_lists)
- for (const svr4_so &so : sos)
- if (svr4_same (solib->original_name.c_str (), so.name.c_str (), *lm_info,
- *so.lm_info))
- return debug_base;
+ auto &lm_info = get_lm_info_svr4 (*solib);
- return 0;
+ return lm_info.debug_base;
}
/* Search order for ELF DSOs linked with -Bsymbolic. Those DSOs have a
@@ -3606,10 +3645,10 @@ find_debug_base_for_solib (const solib *solib)
stay in the same namespace as that file. Otherwise, we only consider
the initial namespace. */
-static void
-svr4_iterate_over_objfiles_in_search_order
- (gdbarch *gdbarch, iterate_over_objfiles_in_search_order_cb_ftype cb,
- objfile *current_objfile)
+void
+svr4_solib_ops::iterate_over_objfiles_in_search_order
+ (iterate_over_objfiles_in_search_order_cb_ftype cb,
+ objfile *current_objfile) const
{
bool checked_current_objfile = false;
if (current_objfile != nullptr)
@@ -3619,11 +3658,14 @@ svr4_iterate_over_objfiles_in_search_order
if (current_objfile->separate_debug_objfile_backlink != nullptr)
current_objfile = current_objfile->separate_debug_objfile_backlink;
- if (current_objfile == current_program_space->symfile_object_file)
- abfd = current_program_space->exec_bfd ();
+ if (current_objfile == m_pspace->symfile_object_file)
+ abfd = m_pspace->exec_bfd ();
else
abfd = current_objfile->obfd.get ();
+ /* gdb_bfd_scan_elf_dyntag relies on the current program space. */
+ gdb_assert (m_pspace == current_program_space);
+
if (abfd != nullptr
&& gdb_bfd_scan_elf_dyntag (DT_SYMBOLIC, abfd, nullptr, nullptr) == 1)
{
@@ -3633,15 +3675,19 @@ svr4_iterate_over_objfiles_in_search_order
}
}
+ /* elf_locate_base relies on the current program space. */
+ gdb_assert (m_pspace == current_program_space);
+
/* The linker namespace to iterate identified by the address of its
r_debug object, defaulting to the initial namespace. */
- CORE_ADDR initial = elf_locate_base ();
+ svr4_info *info = get_svr4_info (current_program_space);
+ CORE_ADDR default_debug_base = this->default_debug_base (info);
const solib *curr_solib = find_solib_for_objfile (current_objfile);
CORE_ADDR debug_base = find_debug_base_for_solib (curr_solib);
if (debug_base == 0)
- debug_base = initial;
+ debug_base = default_debug_base;
- for (objfile *objfile : current_program_space->objfiles ())
+ for (objfile *objfile : m_pspace->objfiles ())
{
if (checked_current_objfile && objfile == current_objfile)
continue;
@@ -3654,7 +3700,7 @@ svr4_iterate_over_objfiles_in_search_order
const solib *solib = find_solib_for_objfile (objfile);
CORE_ADDR solib_base = find_debug_base_for_solib (solib);
if (solib_base == 0)
- solib_base = initial;
+ solib_base = default_debug_base;
/* Ignore objfiles that were added to a different namespace. */
if (solib_base != debug_base)
@@ -3668,8 +3714,7 @@ svr4_iterate_over_objfiles_in_search_order
std::optional<CORE_ADDR>
svr4_solib_ops::find_solib_addr (solib &so) const
{
- auto *li = gdb::checked_static_cast<lm_info_svr4 *> (so.lm_info.get ());
- return li->l_addr_inferior;
+ return get_lm_info_svr4 (so).l_addr_inferior;
}
int
@@ -3719,15 +3764,14 @@ svr4_solib_ops::get_solibs_in_ns (int nsid) const
for (const solib &so: current_program_space->solibs ())
{
- auto *lm_inferior
- = gdb::checked_static_cast<const lm_info_svr4 *> (so.lm_info.get ());
+ auto &lm_inferior = get_lm_info_svr4 (so);
/* This is inspired by the svr4_same, by finding the svr4_so object
in the map, and then double checking if the lm_info is considered
the same. */
if (namespace_solibs.count (so.original_name) > 0
- && namespace_solibs[so.original_name]->l_addr_inferior
- == lm_inferior->l_addr_inferior)
+ && (namespace_solibs[so.original_name]->l_addr_inferior
+ == lm_inferior.l_addr_inferior))
{
ns_solibs.push_back (&so);
/* Remove the SO from the map, so that we don't end up
diff --git a/gdb/solib-svr4.h b/gdb/solib-svr4.h
index 7235fd9..7b38ff4 100644
--- a/gdb/solib-svr4.h
+++ b/gdb/solib-svr4.h
@@ -34,6 +34,10 @@ struct svr4_so;
struct lm_info_svr4 final : public lm_info
{
+ explicit lm_info_svr4 (CORE_ADDR debug_base)
+ : debug_base (debug_base)
+ {}
+
/* Amount by which addresses in the binary should be relocated to
match the inferior. The direct inferior value is L_ADDR_INFERIOR.
When prelinking is involved and the prelink base address changes,
@@ -49,6 +53,18 @@ struct lm_info_svr4 final : public lm_info
/* Values read in from inferior's fields of the same name. */
CORE_ADDR l_ld = 0, l_next = 0, l_prev = 0, l_name = 0;
+
+ /* The address of the dynamic linker structure (r_debug) this solib comes
+ from. This identifies which namespace this library is in.
+
+ This field can be 0 in the following situations:
+
+ - we receive the libraries through XML from an old gdbserver that
+ doesn't include the "lmid" field
+ - the default debug base is not yet known
+
+ In other cases, this field should have a sensible value. */
+ CORE_ADDR debug_base;
};
using lm_info_svr4_up = std::unique_ptr<lm_info_svr4>;
@@ -78,6 +94,8 @@ enum probe_action
struct svr4_solib_ops : public solib_ops
{
+ using solib_ops::solib_ops;
+
void relocate_section_addresses (solib &so, target_section *) const override;
void clear_so (const solib &so) const override;
void clear_solib (program_space *pspace) const override;
@@ -94,6 +112,9 @@ struct svr4_solib_ops : public solib_ops
int find_solib_ns (const solib &so) const override;
int num_active_namespaces () const override;
std::vector<const solib *> get_solibs_in_ns (int nsid) const override;
+ void iterate_over_objfiles_in_search_order
+ (iterate_over_objfiles_in_search_order_cb_ftype cb,
+ objfile *current_objfile) const override;
/* Return the appropriate link map offsets table for the architecture. */
virtual link_map_offsets *fetch_link_map_offsets () const = 0;
@@ -116,8 +137,9 @@ private:
CORE_ADDR find_r_ldsomap (svr4_info *info) const;
owning_intrusive_list<solib> default_sos (svr4_info *info) const;
int read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm,
- std::vector<svr4_so> &sos, int ignore_first) const;
- lm_info_svr4_up read_lm_info (CORE_ADDR lm_addr) const;
+ CORE_ADDR debug_base, std::vector<svr4_so> &sos,
+ int ignore_first) const;
+ lm_info_svr4_up read_lm_info (CORE_ADDR lm_addr, CORE_ADDR debug_base) const;
int has_lm_dynamic_from_link_map () const;
CORE_ADDR lm_addr_check (const solib &so, bfd *abfd) const;
CORE_ADDR read_r_next (CORE_ADDR debug_base) const;
@@ -131,12 +153,18 @@ private:
int update_incremental (svr4_info *info, CORE_ADDR debug_base,
CORE_ADDR lm) const;
bool update_event_breakpoint (breakpoint *b) const;
+
+ /* Return the base address of the dynamic linker structure for the default
+ namespace. */
+ CORE_ADDR default_debug_base (svr4_info *info, bool *changed = nullptr) const;
};
/* solib_ops for ILP32 SVR4 systems. */
struct ilp32_svr4_solib_ops : public svr4_solib_ops
{
+ using svr4_solib_ops::svr4_solib_ops;
+
link_map_offsets *fetch_link_map_offsets () const override;
};
@@ -192,11 +220,11 @@ extern CORE_ADDR svr4_fetch_objfile_link_map (struct objfile *objfile);
/* Return a new solib_ops for ILP32 SVR4 systems. */
-extern solib_ops_up make_svr4_ilp32_solib_ops ();
+extern solib_ops_up make_svr4_ilp32_solib_ops (program_space *pspace);
/* Return a new solib_ops for LP64 SVR4 systems. */
-extern solib_ops_up make_svr4_lp64_solib_ops ();
+extern solib_ops_up make_svr4_lp64_solib_ops (program_space *pspace);
/* For the MUSL C library, given link map address LM_ADDR, return the
corresponding TLS module id, or 0 if not found. */
diff --git a/gdb/solib-target.c b/gdb/solib-target.c
index 770028d..2ae25a8 100644
--- a/gdb/solib-target.c
+++ b/gdb/solib-target.c
@@ -29,10 +29,6 @@
/* Private data for each loaded library. */
struct lm_info_target final : public lm_info
{
- /* The library's name. The name is normally kept in the struct
- solib; it is only here during XML parsing. */
- std::string name;
-
/* The target can either specify segment bases or section bases, not
both. */
@@ -51,9 +47,18 @@ struct lm_info_target final : public lm_info
using lm_info_target_up = std::unique_ptr<lm_info_target>;
+/* Type used to convey the information about one target library while parsing
+ the XML. */
+
+struct target_library
+{
+ std::string name;
+ lm_info_target_up info;
+};
+
#if !defined(HAVE_LIBEXPAT)
-static std::vector<lm_info_target_up>
+static std::vector<target_library>
solib_target_parse_libraries (const char *library)
{
static int have_warned;
@@ -80,17 +85,17 @@ library_list_start_segment (struct gdb_xml_parser *parser,
void *user_data,
std::vector<gdb_xml_value> &attributes)
{
- auto *list = (std::vector<lm_info_target_up> *) user_data;
- lm_info_target *last = list->back ().get ();
+ const auto list = static_cast<std::vector<target_library> *> (user_data);
+ target_library &last = list->back ();
ULONGEST *address_p
= (ULONGEST *) xml_find_attribute (attributes, "address")->value.get ();
CORE_ADDR address = (CORE_ADDR) *address_p;
- if (!last->section_bases.empty ())
+ if (!last.info->section_bases.empty ())
gdb_xml_error (parser,
_("Library list with both segments and sections"));
- last->segment_bases.push_back (address);
+ last.info->segment_bases.push_back (address);
}
static void
@@ -99,17 +104,17 @@ library_list_start_section (struct gdb_xml_parser *parser,
void *user_data,
std::vector<gdb_xml_value> &attributes)
{
- auto *list = (std::vector<lm_info_target_up> *) user_data;
- lm_info_target *last = list->back ().get ();
+ const auto list = static_cast<std::vector<target_library> *> (user_data);
+ target_library &last = list->back ();
ULONGEST *address_p
= (ULONGEST *) xml_find_attribute (attributes, "address")->value.get ();
CORE_ADDR address = (CORE_ADDR) *address_p;
- if (!last->segment_bases.empty ())
+ if (!last.info->segment_bases.empty ())
gdb_xml_error (parser,
_("Library list with both segments and sections"));
- last->section_bases.push_back (address);
+ last.info->section_bases.push_back (address);
}
/* Handle the start of a <library> element. */
@@ -120,12 +125,12 @@ library_list_start_library (struct gdb_xml_parser *parser,
void *user_data,
std::vector<gdb_xml_value> &attributes)
{
- auto *list = (std::vector<lm_info_target_up> *) user_data;
- lm_info_target *item = new lm_info_target;
- item->name
+ const auto list = static_cast<std::vector<target_library> *> (user_data);
+ std::string name
= (const char *) xml_find_attribute (attributes, "name")->value.get ();
- list->emplace_back (item);
+ list->emplace_back (target_library { std::move (name),
+ std::make_unique<lm_info_target> () });
}
static void
@@ -133,10 +138,10 @@ library_list_end_library (struct gdb_xml_parser *parser,
const struct gdb_xml_element *element,
void *user_data, const char *body_text)
{
- auto *list = (std::vector<lm_info_target_up> *) user_data;
- lm_info_target *lm_info = list->back ().get ();
+ const auto list = static_cast<std::vector<target_library> *> (user_data);
+ target_library &last = list->back ();
- if (lm_info->segment_bases.empty () && lm_info->section_bases.empty ())
+ if (last.info->segment_bases.empty () && last.info->section_bases.empty ())
gdb_xml_error (parser, _("No segment or section bases defined"));
}
@@ -209,10 +214,10 @@ static const struct gdb_xml_element library_list_elements[] = {
{ NULL, NULL, NULL, GDB_XML_EF_NONE, NULL, NULL }
};
-static std::vector<lm_info_target_up>
+static std::vector<target_library>
solib_target_parse_libraries (const char *library)
{
- std::vector<lm_info_target_up> result;
+ std::vector<target_library> result;
if (gdb_xml_parse_quick (_("target library list"), "library-list.dtd",
library_list_elements, library, &result) == 0)
@@ -239,19 +244,13 @@ target_solib_ops::current_sos () const
return {};
/* Parse the list. */
- std::vector<lm_info_target_up> library_list
+ std::vector<target_library> library_list
= solib_target_parse_libraries (library_document->data ());
/* Build a struct solib for each entry on the list. */
- for (lm_info_target_up &info : library_list)
- {
- auto &new_solib = sos.emplace_back (*this);
-
- /* We don't need a copy of the name in INFO anymore. */
- new_solib.name = std::move (info->name);
- new_solib.original_name = new_solib.name;
- new_solib.lm_info = std::move (info);
- }
+ for (auto &library : library_list)
+ sos.emplace_back (std::move (library.info), library.name, library.name,
+ *this);
return sos;
}
@@ -389,7 +388,7 @@ target_solib_ops::in_dynsym_resolve_code (CORE_ADDR pc) const
/* See solib-target.h. */
solib_ops_up
-make_target_solib_ops ()
+make_target_solib_ops (program_space *pspace)
{
- return std::make_unique<target_solib_ops> ();
+ return std::make_unique<target_solib_ops> (pspace);
}
diff --git a/gdb/solib-target.h b/gdb/solib-target.h
index 89ae2bc..4b8f2d6 100644
--- a/gdb/solib-target.h
+++ b/gdb/solib-target.h
@@ -26,6 +26,8 @@
struct target_solib_ops : solib_ops
{
+ using solib_ops::solib_ops;
+
void relocate_section_addresses (solib &so, target_section *) const override;
owning_intrusive_list<solib> current_sos () const override;
bool in_dynsym_resolve_code (CORE_ADDR pc) const override;
@@ -33,6 +35,6 @@ struct target_solib_ops : solib_ops
/* Return a new solib_ops for systems fetching solibs from the target. */
-solib_ops_up make_target_solib_ops ();
+solib_ops_up make_target_solib_ops (program_space *pspace);
#endif /* GDB_SOLIB_TARGET_H */
diff --git a/gdb/solib.c b/gdb/solib.c
index 3ec2032..9a2ef12 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -473,6 +473,18 @@ solib_ops::bfd_open (const char *pathname) const
return solib_bfd_open (pathname);
}
+/* See solib.h. */
+
+void
+solib_ops::iterate_over_objfiles_in_search_order
+ (iterate_over_objfiles_in_search_order_cb_ftype cb,
+ objfile *current_objfile) const
+{
+ for (objfile *objfile : m_pspace->objfiles ())
+ if (cb (objfile))
+ return;
+}
+
/* Given a pointer to one of the shared objects in our list of mapped
objects, use the recorded name to open a bfd descriptor for the
object, build a section table, relocate all the section addresses
@@ -633,15 +645,12 @@ solib_read_symbols (solib &so, symfile_add_flags flags)
/* Have we already loaded this shared object? */
so.objfile = nullptr;
for (objfile *objfile : current_program_space->objfiles ())
- {
- if (filename_cmp (objfile_name (objfile), so.name.c_str ())
- == 0
- && objfile->addr_low == so.addr_low)
- {
- so.objfile = objfile;
- break;
- }
- }
+ if (objfile->addr_low == so.addr_low)
+ {
+ so.objfile = objfile;
+ break;
+ }
+
if (so.objfile == NULL)
{
section_addr_info sap
@@ -1045,7 +1054,7 @@ print_solib_list_table (std::vector<const solib *> solib_list,
uiout->table_header (addr_width - 1, ui_left, "from", "From");
uiout->table_header (addr_width - 1, ui_left, "to", "To");
if (print_namespace)
- uiout->table_header (5, ui_left, "namespace", "NS");
+ uiout->table_header (9, ui_left, "namespace", "Linker NS");
uiout->table_header (12 - 1, ui_left, "syms-read", "Syms Read");
uiout->table_header (0, ui_noalign, "name", "Shared Object Library");
@@ -1073,7 +1082,7 @@ print_solib_list_table (std::vector<const solib *> solib_list,
{
try
{
- uiout->field_fmt ("namespace", "[[%d]]", ops->find_solib_ns (*so));
+ uiout->field_fmt ("namespace", "%d", ops->find_solib_ns (*so));
}
catch (const gdb_exception_error &er)
{
@@ -1171,7 +1180,7 @@ info_linker_namespace_command (const char *pattern, int from_tty)
if (pattern == nullptr || pattern[0] == '\0')
{
- uiout->message (_("There are %d linker namespaces loaded\n"),
+ uiout->message (_("There are %d linker namespaces loaded.\n"),
ops->num_active_namespaces ());
int printed = 0;
@@ -1208,27 +1217,26 @@ info_linker_namespace_command (const char *pattern, int from_tty)
(std::make_pair (ns, ops->get_solibs_in_ns (ns)));
}
- bool ns_separator = false;
-
for (const auto &[ns, solibs_to_print] : all_solibs_to_print)
{
- if (ns_separator)
- uiout->message ("\n\n");
- else
- ns_separator = true;
+ uiout->message ("\n");
if (solibs_to_print.size () == 0)
{
- uiout->message (_("Linker namespace [[%d]] is not active.\n"), ns);
+ uiout->message (_("Linker namespace %d is not active.\n"), ns);
/* If we got here, a specific namespace was requested, so there
will only be one vector. We can leave early. */
break;
}
- uiout->message
- (_("There are %zu libraries loaded in linker namespace [[%d]]\n"),
- solibs_to_print.size (), ns);
- uiout->message
- (_("Displaying libraries for linker namespace [[%d]]:\n"), ns);
+
+ if (solibs_to_print.size () == 1)
+ uiout->message
+ (_("1 library loaded in linker namespace %d:\n"), ns);
+ else
+ uiout->message
+ (_("%zu libraries loaded in linker namespace %d:\n"),
+ solibs_to_print.size (), ns);
+
print_solib_list_table (solibs_to_print, false);
}
@@ -1805,6 +1813,18 @@ remove_user_added_objfile (struct objfile *objfile)
}
}
+/* See solib.h. */
+
+int
+solib_linker_namespace_count (program_space *pspace)
+{
+ if (const auto ops = pspace->solib_ops (); ops != nullptr
+ && ops->supports_namespaces ())
+ return ops->num_active_namespaces ();
+
+ return 0;
+}
+
/* Implementation of the linker_namespace convenience variable.
This returns the GDB internal identifier of the linker namespace,
@@ -1840,6 +1860,23 @@ static const struct internalvar_funcs linker_namespace_funcs =
nullptr,
};
+static value *
+linker_namespace_count_make_value (gdbarch *gdbarch, internalvar *var,
+ void *ignore)
+{
+ return value_from_longest
+ (builtin_type (gdbarch)->builtin_int,
+ solib_linker_namespace_count (current_program_space));
+}
+
+/* Implementation of `$_linker_namespace_count' variable. */
+
+static const struct internalvar_funcs linker_namespace_count_funcs =
+{
+ linker_namespace_count_make_value,
+ nullptr,
+};
+
INIT_GDB_FILE (solib)
{
gdb::observers::free_objfile.attach (remove_user_added_objfile, "solib");
@@ -1854,7 +1891,8 @@ INIT_GDB_FILE (solib)
for consistency. */
create_internalvar_type_lazy ("_linker_namespace",
&linker_namespace_funcs, nullptr);
- set_internalvar_integer (lookup_internalvar ("_active_linker_namespaces"), 1);
+ create_internalvar_type_lazy ("_linker_namespace_count",
+ &linker_namespace_count_funcs, nullptr);
add_com (
"sharedlibrary", class_files, sharedlibrary_command,
diff --git a/gdb/solib.h b/gdb/solib.h
index b9465e1..85ea667 100644
--- a/gdb/solib.h
+++ b/gdb/solib.h
@@ -61,7 +61,13 @@ struct solib : intrusive_list_node<solib>
/* Constructor
OPS is the solib_ops implementation providing this solib. */
- explicit solib (const solib_ops &ops) : m_ops (&ops) {}
+ explicit solib (lm_info_up lm_info, std::string original_name,
+ std::string name, const solib_ops &ops)
+ : lm_info (std::move (lm_info)),
+ original_name (std::move (original_name)),
+ name (std::move (name)),
+ m_ops (&ops)
+ {}
/* Return the solib_ops implementation providing this solib. */
const solib_ops &ops () const
@@ -131,8 +137,18 @@ private:
/* A unique pointer to an solib. */
using solib_up = std::unique_ptr<solib>;
+/* Callback type for the 'iterate_over_objfiles_in_search_order'
+ methods. */
+
+using iterate_over_objfiles_in_search_order_cb_ftype
+ = gdb::function_view<bool (objfile *)>;
+
struct solib_ops
{
+ explicit solib_ops (program_space *pspace)
+ : m_pspace (pspace)
+ {}
+
virtual ~solib_ops () = default;
/* Adjust the section binding addresses by the base address at
@@ -259,6 +275,22 @@ struct solib_ops
The supports_namespaces method must return true for this to be called. */
virtual std::vector<const solib *> get_solibs_in_ns (int ns) const
{ gdb_assert_not_reached ("namespaces not supported"); }
+
+ /* Iterate over all objfiles of the program space in the order that makes the
+ most sense for the architecture to make global symbol searches.
+
+ CB is a callback function passed an objfile to be searched. The iteration
+ stops if this function returns true.
+
+ If not nullptr, CURRENT_OBJFILE corresponds to the objfile being inspected
+ when the symbol search was requested. */
+ virtual void iterate_over_objfiles_in_search_order
+ (iterate_over_objfiles_in_search_order_cb_ftype cb,
+ objfile *current_objfile) const;
+
+protected:
+ /* The program space for which this solib_ops was created. */
+ program_space *m_pspace;
};
/* A unique pointer to an solib_ops. */
@@ -373,4 +405,8 @@ extern void update_solib_breakpoints (void);
extern void handle_solib_event (void);
+/* Calculate the number of linker namespaces active in PSPACE. */
+
+extern int solib_linker_namespace_count (program_space *pspace);
+
#endif /* GDB_SOLIB_H */
diff --git a/gdb/source.c b/gdb/source.c
index 0fd370b..99dffa8 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -774,9 +774,9 @@ prepare_path_for_appending (const char *path)
If FILENAME_OPENED is non-null, set it to a newly allocated string naming
the actual file opened (this string will always start with a "/"). We
- have to take special pains to avoid doubling the "/" between the directory
- and the file, sigh! Emacs gets confuzzed by this when we print the
- source file name!!!
+ have to ensure that we avoid doubling the "/" between the directory and the
+ file, because Emacs has special treatment of double slashes.
+ See "(emacs) Minibuffer File".
If OPTS has OPF_RETURN_REALPATH set return FILENAME_OPENED resolved by
gdb_realpath. Even without OPF_RETURN_REALPATH this function still returns
@@ -1312,14 +1312,12 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
int nlines = stopline - line;
struct ui_out *uiout = current_uiout;
- /* Regardless of whether we can open the file, set current_source_symtab. */
+ /* Regardless of whether we can open the file, we'll want to set
+ current_source_symtab, but not if throw an error, or return without
+ printing any source lines. */
current_source_location *loc
= get_source_location (current_program_space);
- loc->set (s, line);
- first_line_listed = line;
- last_line_listed = line;
-
/* If printing of source lines is disabled, just print file and line
number. */
if (uiout->test_flags (ui_source_list) && source_open)
@@ -1380,6 +1378,10 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
uiout->text ("\n");
}
+ loc->set (s, line);
+ first_line_listed = line;
+ last_line_listed = line;
+
return;
}
@@ -1399,12 +1401,9 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
}
const char *iter = lines.c_str ();
- int new_lineno = loc->line ();
- while (nlines-- > 0 && *iter != '\0')
+ int new_lineno = line;
+ for (; nlines-- > 0 && *iter != '\0'; ++new_lineno)
{
- char buf[20];
-
- last_line_listed = loc->line ();
if (flags & PRINT_SOURCE_LINES_FILENAME)
{
uiout->message ("%ps",
@@ -1415,7 +1414,6 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
uiout->message ("%ps\t", styled_string (line_number_style.style (),
pulongest (new_lineno)));
- ++new_lineno;
while (*iter != '\0')
{
@@ -1457,6 +1455,8 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
}
else if (*iter > 0 && *iter < 040)
{
+ char buf[20];
+
xsnprintf (buf, sizeof (buf), "^%c", *iter + 0100);
uiout->text (buf);
++iter;
@@ -1470,7 +1470,11 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
uiout->text ("\n");
}
- loc->set (loc->symtab (), new_lineno);
+ /* As NEW_LINENO was incremented after displaying the last source line,
+ the last line shown was the one before NEW_LINENO. */
+ first_line_listed = line;
+ last_line_listed = new_lineno - 1;
+ loc->set (s, new_lineno);
}
diff --git a/gdb/sparc-sol2-tdep.c b/gdb/sparc-sol2-tdep.c
index 337b929..8de7439 100644
--- a/gdb/sparc-sol2-tdep.c
+++ b/gdb/sparc-sol2-tdep.c
@@ -214,7 +214,7 @@ sparc32_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
tdep->plt_entry_size = 12;
/* Solaris has kernel-assisted single-stepping support. */
- set_gdbarch_software_single_step (gdbarch, NULL);
+ set_gdbarch_get_next_pcs (gdbarch, NULL);
frame_unwind_append_unwinder (gdbarch, &sparc32_sol2_sigtramp_frame_unwind);
}
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index 4a12516..914a568 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -1874,7 +1874,7 @@ sparc32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_frame_args_skip (gdbarch, 8);
- set_gdbarch_software_single_step (gdbarch, sparc_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, sparc_software_single_step);
set_gdbarch_write_pc (gdbarch, sparc_write_pc);
set_gdbarch_dummy_id (gdbarch, sparc_dummy_id);
diff --git a/gdb/sparc64-sol2-tdep.c b/gdb/sparc64-sol2-tdep.c
index 6d091f5..cb3ba6b 100644
--- a/gdb/sparc64-sol2-tdep.c
+++ b/gdb/sparc64-sol2-tdep.c
@@ -221,7 +221,7 @@ sparc64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
tdep->plt_entry_size = 16;
/* Solaris has kernel-assisted single-stepping support. */
- set_gdbarch_software_single_step (gdbarch, NULL);
+ set_gdbarch_get_next_pcs (gdbarch, NULL);
}
INIT_GDB_FILE (sparc64_sol2_tdep)
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 6ee61e0..733fc9e 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -46,7 +46,6 @@
#include "c-lang.h"
#include "cp-abi.h"
#include "cp-support.h"
-#include <ctype.h>
#include "block.h"
#include "filenames.h"
@@ -472,7 +471,7 @@ patch_block_stabs (struct pending *symbols, struct pending_stabs *stabs,
a N_GSYM stab for it, but no regular (C_EXT) symbol. */
sym = new (&objfile->objfile_obstack) symbol;
sym->set_domain (VAR_DOMAIN);
- sym->set_aclass_index (LOC_OPTIMIZED_OUT);
+ sym->set_loc_class_index (LOC_OPTIMIZED_OUT);
sym->set_linkage_name
(obstack_strndup (&objfile->objfile_obstack, name, pp - name));
pp += 2;
@@ -3067,7 +3066,7 @@ process_reference (const char **string)
p = *string + 1;
/* Read number as reference id. */
- while (*p && isdigit (*p))
+ while (*p && c_isdigit (*p))
{
refnum = refnum * 10 + *p - '0';
p++;
@@ -3123,7 +3122,7 @@ static const struct symbol_register_ops stab_register_funcs = {
stab_reg_to_regnum
};
-/* The "aclass" indices for computed symbols. */
+/* The "loc_class" indices for computed symbols. */
static int stab_register_index;
static int stab_regparm_index;
@@ -3251,7 +3250,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
deftypes we know how to handle is a local. */
if (!strchr ("cfFGpPrStTvVXCR", *p))
#else
- if (isdigit (*p) || *p == '(' || *p == '-')
+ if (c_isdigit (*p) || *p == '(' || *p == '-')
#endif
deftype = 'l';
else
@@ -3268,7 +3267,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
(where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
if (*p != '=')
{
- sym->set_aclass_index (LOC_CONST);
+ sym->set_loc_class_index (LOC_CONST);
sym->set_type (error_type (&p, objfile));
sym->set_domain (VAR_DOMAIN);
add_symbol_to_list (sym, get_file_symbols ());
@@ -3291,7 +3290,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
sym->set_type (dbl_type);
sym->set_value_bytes (dbl_valu);
- sym->set_aclass_index (LOC_CONST_BYTES);
+ sym->set_loc_class_index (LOC_CONST_BYTES);
}
break;
case 'i':
@@ -3305,7 +3304,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
sym->set_type (builtin_type (objfile)->builtin_long);
sym->set_value_longest (atoi (p));
- sym->set_aclass_index (LOC_CONST);
+ sym->set_loc_class_index (LOC_CONST);
}
break;
@@ -3313,7 +3312,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
{
sym->set_type (builtin_type (objfile)->builtin_char);
sym->set_value_longest (atoi (p));
- sym->set_aclass_index (LOC_CONST);
+ sym->set_loc_class_index (LOC_CONST);
}
break;
@@ -3327,7 +3326,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
if (quote != '\'' && quote != '"')
{
- sym->set_aclass_index (LOC_CONST);
+ sym->set_loc_class_index (LOC_CONST);
sym->set_type (error_type (&p, objfile));
sym->set_domain (VAR_DOMAIN);
add_symbol_to_list (sym, get_file_symbols ());
@@ -3352,7 +3351,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
}
if (*p != quote)
{
- sym->set_aclass_index (LOC_CONST);
+ sym->set_loc_class_index (LOC_CONST);
sym->set_type (error_type (&p, objfile));
sym->set_domain (VAR_DOMAIN);
add_symbol_to_list (sym, get_file_symbols ());
@@ -3375,7 +3374,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
p++;
sym->set_value_bytes (string_value);
- sym->set_aclass_index (LOC_CONST_BYTES);
+ sym->set_loc_class_index (LOC_CONST_BYTES);
}
break;
@@ -3385,7 +3384,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
e.g. "b:c=e6,0" for "const b = blob1"
(where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
{
- sym->set_aclass_index (LOC_CONST);
+ sym->set_loc_class_index (LOC_CONST);
sym->set_type (read_type (&p, objfile));
if (*p != ',')
@@ -3406,7 +3405,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
break;
default:
{
- sym->set_aclass_index (LOC_CONST);
+ sym->set_loc_class_index (LOC_CONST);
sym->set_type (error_type (&p, objfile));
}
}
@@ -3417,7 +3416,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
case 'C':
/* The name of a caught exception. */
sym->set_type (read_type (&p, objfile));
- sym->set_aclass_index (LOC_LABEL);
+ sym->set_loc_class_index (LOC_LABEL);
sym->set_domain (VAR_DOMAIN);
sym->set_value_address (valu);
add_symbol_to_list (sym, get_local_symbols ());
@@ -3426,7 +3425,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
case 'f':
/* A static function definition. */
sym->set_type (read_type (&p, objfile));
- sym->set_aclass_index (LOC_BLOCK);
+ sym->set_loc_class_index (LOC_BLOCK);
sym->set_domain (FUNCTION_DOMAIN);
add_symbol_to_list (sym, get_file_symbols ());
/* fall into process_function_types. */
@@ -3497,7 +3496,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
case 'F':
/* A global function definition. */
sym->set_type (read_type (&p, objfile));
- sym->set_aclass_index (LOC_BLOCK);
+ sym->set_loc_class_index (LOC_BLOCK);
sym->set_domain (FUNCTION_DOMAIN);
add_symbol_to_list (sym, get_global_symbols ());
goto process_function_types;
@@ -3508,7 +3507,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
corresponding linker definition to find the value.
These definitions appear at the end of the namelist. */
sym->set_type (read_type (&p, objfile));
- sym->set_aclass_index (LOC_STATIC);
+ sym->set_loc_class_index (LOC_STATIC);
sym->set_domain (VAR_DOMAIN);
/* Don't add symbol references to global_sym_chain.
Symbol references don't have valid names and won't match up with
@@ -3529,7 +3528,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
case 's':
case 'l':
sym->set_type (read_type (&p, objfile));
- sym->set_aclass_index (LOC_LOCAL);
+ sym->set_loc_class_index (LOC_LOCAL);
sym->set_value_longest (valu);
sym->set_domain (VAR_DOMAIN);
add_symbol_to_list (sym, get_local_symbols ());
@@ -3549,7 +3548,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
else
sym->set_type (read_type (&p, objfile));
- sym->set_aclass_index (LOC_ARG);
+ sym->set_loc_class_index (LOC_ARG);
sym->set_value_longest (valu);
sym->set_domain (VAR_DOMAIN);
sym->set_is_argument (1);
@@ -3598,7 +3597,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
case 'R':
/* Parameter which is in a register. */
sym->set_type (read_type (&p, objfile));
- sym->set_aclass_index (stab_register_index);
+ sym->set_loc_class_index (stab_register_index);
sym->set_is_argument (1);
sym->set_value_longest (valu);
sym->set_domain (VAR_DOMAIN);
@@ -3608,7 +3607,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
case 'r':
/* Register variable (either global or local). */
sym->set_type (read_type (&p, objfile));
- sym->set_aclass_index (stab_register_index);
+ sym->set_loc_class_index (stab_register_index);
sym->set_value_longest (valu);
sym->set_domain (VAR_DOMAIN);
if (within_function)
@@ -3640,12 +3639,12 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
struct symbol *prev_sym;
prev_sym = local_symbols->symbol[local_symbols->nsyms - 1];
- if ((prev_sym->aclass () == LOC_REF_ARG
- || prev_sym->aclass () == LOC_ARG)
+ if ((prev_sym->loc_class () == LOC_REF_ARG
+ || prev_sym->loc_class () == LOC_ARG)
&& strcmp (prev_sym->linkage_name (),
sym->linkage_name ()) == 0)
{
- prev_sym->set_aclass_index (stab_register_index);
+ prev_sym->set_loc_class_index (stab_register_index);
/* Use the type from the LOC_REGISTER; that is the type
that is actually in that register. */
prev_sym->set_type (sym->type ());
@@ -3663,7 +3662,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
case 'S':
/* Static symbol at top level of file. */
sym->set_type (read_type (&p, objfile));
- sym->set_aclass_index (LOC_STATIC);
+ sym->set_loc_class_index (LOC_STATIC);
sym->set_value_address (valu);
sym->set_domain (VAR_DOMAIN);
add_symbol_to_list (sym, get_file_symbols ());
@@ -3694,7 +3693,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
if (nameless)
return NULL;
- sym->set_aclass_index (LOC_TYPEDEF);
+ sym->set_loc_class_index (LOC_TYPEDEF);
sym->set_value_longest (valu);
sym->set_domain (TYPE_DOMAIN);
/* C++ vagaries: we may have a type which is derived from
@@ -3771,7 +3770,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
struct symbol *struct_sym = new (&objfile->objfile_obstack) symbol;
*struct_sym = *sym;
- struct_sym->set_aclass_index (LOC_TYPEDEF);
+ struct_sym->set_loc_class_index (LOC_TYPEDEF);
struct_sym->set_value_longest (valu);
struct_sym->set_domain (STRUCT_DOMAIN);
if (sym->type ()->name () == 0)
@@ -3798,7 +3797,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
if (nameless)
return NULL;
- sym->set_aclass_index (LOC_TYPEDEF);
+ sym->set_loc_class_index (LOC_TYPEDEF);
sym->set_value_longest (valu);
sym->set_domain (STRUCT_DOMAIN);
if (sym->type ()->name () == 0)
@@ -3813,7 +3812,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
struct symbol *typedef_sym = new (&objfile->objfile_obstack) symbol;
*typedef_sym = *sym;
- typedef_sym->set_aclass_index (LOC_TYPEDEF);
+ typedef_sym->set_loc_class_index (LOC_TYPEDEF);
typedef_sym->set_value_longest (valu);
typedef_sym->set_domain (TYPE_DOMAIN);
if (sym->type ()->name () == 0)
@@ -3827,7 +3826,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
case 'V':
/* Static symbol of local scope. */
sym->set_type (read_type (&p, objfile));
- sym->set_aclass_index (LOC_STATIC);
+ sym->set_loc_class_index (LOC_STATIC);
sym->set_value_address (valu);
sym->set_domain (VAR_DOMAIN);
add_symbol_to_list (sym, get_local_symbols ());
@@ -3836,7 +3835,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
case 'v':
/* Reference parameter */
sym->set_type (read_type (&p, objfile));
- sym->set_aclass_index (LOC_REF_ARG);
+ sym->set_loc_class_index (LOC_REF_ARG);
sym->set_is_argument (1);
sym->set_value_longest (valu);
sym->set_domain (VAR_DOMAIN);
@@ -3846,7 +3845,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
case 'a':
/* Reference parameter which is in a register. */
sym->set_type (read_type (&p, objfile));
- sym->set_aclass_index (stab_regparm_index);
+ sym->set_loc_class_index (stab_regparm_index);
sym->set_is_argument (1);
sym->set_value_longest (valu);
sym->set_domain (VAR_DOMAIN);
@@ -3859,7 +3858,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
that Pascal uses it too, but when I tried it Pascal used
"x:3" (local symbol) instead. */
sym->set_type (read_type (&p, objfile));
- sym->set_aclass_index (LOC_LOCAL);
+ sym->set_loc_class_index (LOC_LOCAL);
sym->set_value_longest (valu);
sym->set_domain (VAR_DOMAIN);
add_symbol_to_list (sym, get_local_symbols ());
@@ -3867,7 +3866,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
default:
sym->set_type (error_type (&p, objfile));
- sym->set_aclass_index (LOC_CONST);
+ sym->set_loc_class_index (LOC_CONST);
sym->set_value_longest (0);
sym->set_domain (VAR_DOMAIN);
add_symbol_to_list (sym, get_file_symbols ());
@@ -3883,12 +3882,12 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
{
/* We have to convert LOC_REGISTER to LOC_REGPARM_ADDR (for
variables passed in a register). */
- if (sym->aclass () == LOC_REGISTER)
- sym->set_aclass_index (LOC_REGPARM_ADDR);
+ if (sym->loc_class () == LOC_REGISTER)
+ sym->set_loc_class_index (LOC_REGPARM_ADDR);
/* Likewise for converting LOC_ARG to LOC_REF_ARG (for the 7th
and subsequent arguments on SPARC, for example). */
- else if (sym->aclass () == LOC_ARG)
- sym->set_aclass_index (LOC_REF_ARG);
+ else if (sym->loc_class () == LOC_ARG)
+ sym->set_loc_class_index (LOC_REF_ARG);
}
return sym;
@@ -4139,7 +4138,7 @@ again:
{
struct symbol *sym = ppt->symbol[i];
- if (sym->aclass () == LOC_TYPEDEF
+ if (sym->loc_class () == LOC_TYPEDEF
&& sym->domain () == STRUCT_DOMAIN
&& (sym->type ()->code () == code)
&& strcmp (sym->linkage_name (), type_name) == 0)
@@ -4340,7 +4339,7 @@ again:
break;
case '@':
- if (isdigit (**pp) || **pp == '(' || **pp == '-')
+ if (c_isdigit (**pp) || **pp == '(' || **pp == '-')
{ /* Member (class & variable) type */
/* FIXME -- we should be doing smash_to_XXX types here. */
@@ -4431,8 +4430,9 @@ again:
if (args == NULL)
return error_type (pp, objfile);
type = dbx_alloc_type (typenums, objfile);
- smash_to_method_type (type, domain, return_type, args,
- nargs, varargs);
+ smash_to_method_type (type, domain, return_type,
+ gdb::make_array_view (args, nargs),
+ varargs);
}
break;
@@ -6059,7 +6059,7 @@ read_enum_type (const char **pp, struct type *type,
sym->set_linkage_name (name);
sym->set_language (get_current_subfile ()->language,
&objfile->objfile_obstack);
- sym->set_aclass_index (LOC_CONST);
+ sym->set_loc_class_index (LOC_CONST);
sym->set_domain (VAR_DOMAIN);
sym->set_value_longest (n);
if (n < 0)
@@ -6726,7 +6726,7 @@ common_block_end (struct objfile *objfile)
sym = new (&objfile->objfile_obstack) symbol;
/* Note: common_block_name already saved on objfile_obstack. */
sym->set_linkage_name (common_block_name);
- sym->set_aclass_index (LOC_BLOCK);
+ sym->set_loc_class_index (LOC_BLOCK);
/* Now we copy all the symbols which have been defined since the BCOMM. */
@@ -6934,7 +6934,7 @@ cleanup_undefined_types_1 (void)
{
struct symbol *sym = ppt->symbol[i];
- if (sym->aclass () == LOC_TYPEDEF
+ if (sym->loc_class () == LOC_TYPEDEF
&& sym->domain () == STRUCT_DOMAIN
&& (sym->type ()->code () == (*type)->code ())
&& ((*type)->instance_flags ()
@@ -7044,7 +7044,7 @@ scan_file_globals (struct objfile *objfile)
the same symbol if there are multiple references. */
if (sym)
{
- if (sym->aclass () == LOC_BLOCK)
+ if (sym->loc_class () == LOC_BLOCK)
fix_common_block
(sym, msymbol->value_address (resolve_objfile),
msymbol->section_index ());
@@ -7090,8 +7090,8 @@ scan_file_globals (struct objfile *objfile)
prev->set_value_address (0);
/* Complain about unresolved common block symbols. */
- if (prev->aclass () == LOC_STATIC)
- prev->set_aclass_index (LOC_UNRESOLVED);
+ if (prev->loc_class () == LOC_STATIC)
+ prev->set_loc_class_index (LOC_UNRESOLVED);
else
complaint (_("%s: common block `%s' from "
"global_sym_chain unresolved"),
diff --git a/gdb/stack.c b/gdb/stack.c
index e633566..add1c54 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -758,7 +758,7 @@ print_frame_args (const frame_print_options &fp_opts,
break;
}
- switch (sym->aclass ())
+ switch (sym->loc_class ())
{
case LOC_ARG:
case LOC_REF_ARG:
@@ -813,7 +813,7 @@ print_frame_args (const frame_print_options &fp_opts,
nsym = lookup_symbol_search_name (sym->search_name (),
b, SEARCH_VAR_DOMAIN).symbol;
gdb_assert (nsym != NULL);
- if (nsym->aclass () == LOC_REGISTER
+ if (nsym->loc_class () == LOC_REGISTER
&& !nsym->is_argument ())
{
/* There is a LOC_ARG/LOC_REGISTER pair. This means
@@ -1165,10 +1165,10 @@ do_print_frame_info (struct ui_out *uiout, const frame_print_options &fp_opts,
if (set_current_sal)
{
- CORE_ADDR pc;
+ std::optional<CORE_ADDR> pc;
- if (get_frame_pc_if_available (frame, &pc))
- last_displayed_symtab_info.set (sal.pspace, pc, sal.symtab, sal.line);
+ if ((pc = get_frame_pc_if_available (frame)))
+ last_displayed_symtab_info.set (sal.pspace, *pc, sal.symtab, sal.line);
else
last_displayed_symtab_info.invalidate ();
}
@@ -1325,16 +1325,15 @@ print_frame (struct ui_out *uiout,
enum language funlang = language_unknown;
struct value_print_options opts;
struct symbol *func;
- CORE_ADDR pc = 0;
- int pc_p;
+ std::optional <CORE_ADDR> pc;
- pc_p = get_frame_pc_if_available (frame, &pc);
+ pc = get_frame_pc_if_available (frame);
gdb::unique_xmalloc_ptr<char> funname
= find_frame_funname (frame, &funlang, &func);
annotate_frame_begin (print_level ? frame_relative_level (frame) : 0,
- gdbarch, pc);
+ gdbarch, pc.value_or (0));
{
ui_out_emit_tuple tuple_emitter (uiout, "frame");
@@ -1352,8 +1351,8 @@ print_frame (struct ui_out *uiout,
|| print_what == LOC_AND_ADDRESS)
{
annotate_frame_address ();
- if (pc_p)
- print_pc (uiout, gdbarch, frame, pc);
+ if (pc.has_value ())
+ print_pc (uiout, gdbarch, frame, *pc);
else
uiout->field_string ("addr", "<unavailable>",
metadata_style.style ());
@@ -1422,7 +1421,7 @@ print_frame (struct ui_out *uiout,
}
if (print_what != SHORT_LOCATION
- && pc_p && (funname == NULL || sal.symtab == NULL))
+ && pc.has_value () && (funname == NULL || sal.symtab == NULL))
{
const char *lib
= solib_name_from_address (get_frame_program_space (frame),
@@ -1481,8 +1480,7 @@ info_frame_command_core (const frame_info_ptr &fi, bool selected_frame_p)
enum language funlang = language_unknown;
const char *pc_regname;
struct gdbarch *gdbarch;
- CORE_ADDR frame_pc;
- int frame_pc_p;
+ std::optional<CORE_ADDR> frame_pc;
/* Initialize it to avoid "may be used uninitialized" warning. */
CORE_ADDR caller_pc = 0;
int caller_pc_p = 0;
@@ -1503,7 +1501,7 @@ info_frame_command_core (const frame_info_ptr &fi, bool selected_frame_p)
get_frame_pc(). */
pc_regname = "pc";
- frame_pc_p = get_frame_pc_if_available (fi, &frame_pc);
+ frame_pc = get_frame_pc_if_available (fi);
func = get_frame_function (fi);
symtab_and_line sal = find_frame_sal (fi);
s = sal.symtab;
@@ -1525,9 +1523,9 @@ info_frame_command_core (const frame_info_ptr &fi, bool selected_frame_p)
funname = func_only.get ();
}
}
- else if (frame_pc_p)
+ else if (frame_pc.has_value ())
{
- bound_minimal_symbol msymbol = lookup_minimal_symbol_by_pc (frame_pc);
+ bound_minimal_symbol msymbol = lookup_minimal_symbol_by_pc (*frame_pc);
if (msymbol.minsym != NULL)
{
funname = msymbol.minsym->print_name ();
@@ -1548,7 +1546,7 @@ info_frame_command_core (const frame_info_ptr &fi, bool selected_frame_p)
gdb_puts (paddress (gdbarch, get_frame_base (fi)));
gdb_printf (":\n");
gdb_printf (" %s = ", pc_regname);
- if (frame_pc_p)
+ if (frame_pc.has_value ())
gdb_puts (paddress (gdbarch, get_frame_pc (fi)));
else
fputs_styled ("<unavailable>", metadata_style.style (), gdb_stdout);
@@ -2218,7 +2216,7 @@ iterate_over_block_locals (const struct block *b,
{
for (struct symbol *sym : block_iterator_range (b))
{
- switch (sym->aclass ())
+ switch (sym->loc_class ())
{
case LOC_CONST:
case LOC_CONST_BYTES:
@@ -2337,9 +2335,9 @@ print_frame_local_vars (const frame_info_ptr &frame,
{
struct print_variable_and_value_data cb_data;
const struct block *block;
- CORE_ADDR pc;
+ std::optional<CORE_ADDR> pc;
- if (!get_frame_pc_if_available (frame, &pc))
+ if (!(pc = get_frame_pc_if_available (frame)))
{
if (!quiet)
gdb_printf (stream,
@@ -2499,11 +2497,11 @@ print_frame_arg_vars (const frame_info_ptr &frame,
{
struct print_variable_and_value_data cb_data;
struct symbol *func;
- CORE_ADDR pc;
+ std::optional<CORE_ADDR> pc;
std::optional<compiled_regex> preg;
std::optional<compiled_regex> treg;
- if (!get_frame_pc_if_available (frame, &pc))
+ if (!(pc = get_frame_pc_if_available (frame)))
{
if (!quiet)
gdb_printf (stream,
@@ -3066,7 +3064,7 @@ frame_apply_level_cmd_completer (struct cmd_list_element *ignore,
/* Check if we're past a valid LEVEL already. */
if (levels.finished ()
- && cmd > text && !isspace (cmd[-1]))
+ && cmd > text && !c_isspace (cmd[-1]))
return;
/* We're past LEVELs, advance word point. */
@@ -3100,7 +3098,7 @@ frame_apply_cmd_completer (struct cmd_list_element *ignore,
return;
/* Check if we're past a valid COUNT already. */
- if (cmd > text && !isspace (cmd[-1]))
+ if (cmd > text && !c_isspace (cmd[-1]))
return;
/* We're past COUNT, advance word point. */
diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
index 3b692e2..6c15bce 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -39,7 +39,6 @@
#include "expop.h"
#include "gdbsupport/unordered_map.h"
-#include <ctype.h>
/* The name of the SystemTap section where we will find information about
the probes. */
@@ -575,14 +574,14 @@ stap_is_integer_prefix (struct gdbarch *gdbarch, const char *s,
if (r != NULL)
*r = "";
- return isdigit (*s) > 0;
+ return c_isdigit (*s) > 0;
}
for (p = t; *p != NULL; ++p)
{
size_t len = strlen (*p);
- if ((len == 0 && isdigit (*s))
+ if ((len == 0 && c_isdigit (*s))
|| (len > 0 && strncasecmp (s, *p, len) == 0))
{
/* Integers may or may not have a prefix. The "len == 0"
@@ -732,7 +731,7 @@ stap_parse_register_operand (struct stap_parse_info *p)
struct type *long_type = builtin_type (gdbarch)->builtin_long;
operation_up disp_op;
- if (isdigit (*p->arg))
+ if (c_isdigit (*p->arg))
{
/* The value of the displacement. */
long displacement;
@@ -767,14 +766,14 @@ stap_parse_register_operand (struct stap_parse_info *p)
start = p->arg;
/* We assume the register name is composed by letters and numbers. */
- while (isalnum (*p->arg))
+ while (c_isalnum (*p->arg))
++p->arg;
std::string regname (start, p->arg - start);
/* We only add the GDB's register prefix/suffix if we are dealing with
a numeric register. */
- if (isdigit (*start))
+ if (c_isdigit (*start))
{
if (gdb_reg_prefix != NULL)
regname = gdb_reg_prefix + regname;
@@ -921,7 +920,7 @@ stap_parse_single_operand (struct stap_parse_info *p)
if (p->inside_paren_p)
tmp = skip_spaces (tmp);
- while (isdigit (*tmp))
+ while (c_isdigit (*tmp))
{
/* We skip the digit here because we are only interested in
knowing what kind of unary operation this is. The digit
@@ -959,7 +958,7 @@ stap_parse_single_operand (struct stap_parse_info *p)
(std::move (result)));
}
}
- else if (isdigit (*p->arg))
+ else if (c_isdigit (*p->arg))
{
/* A temporary variable, needed for lookahead. */
const char *tmp = p->arg;
@@ -1042,7 +1041,7 @@ stap_parse_argument_conditionally (struct stap_parse_info *p)
expr::operation_up result;
if (*p->arg == '-' || *p->arg == '~' || *p->arg == '+' || *p->arg == '!'
- || isdigit (*p->arg)
+ || c_isdigit (*p->arg)
|| gdbarch_stap_is_single_operand (p->gdbarch, p->arg))
result = stap_parse_single_operand (p);
else if (*p->arg == '(')
@@ -1111,7 +1110,7 @@ stap_parse_argument_1 (struct stap_parse_info *p,
This loop shall continue until we run out of characters in the input,
or until we find a close-parenthesis, which means that we've reached
the end of a sub-expression. */
- while (*p->arg != '\0' && *p->arg != ')' && !isspace (*p->arg))
+ while (*p->arg != '\0' && *p->arg != ')' && !c_isspace (*p->arg))
{
const char *tmp_exp_buf;
enum exp_opcode opcode;
@@ -1270,8 +1269,8 @@ stap_probe::parse_arguments (struct gdbarch *gdbarch)
Where `N' can be [+,-][1,2,4,8]. This is not mandatory, so
we check it here. If we don't find it, go to the next
state. */
- if ((cur[0] == '-' && isdigit (cur[1]) && cur[2] == '@')
- || (isdigit (cur[0]) && cur[1] == '@'))
+ if ((cur[0] == '-' && c_isdigit (cur[1]) && cur[2] == '@')
+ || (c_isdigit (cur[0]) && cur[1] == '@'))
{
if (*cur == '-')
{
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index a5ff21e..705d8f7 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -193,7 +193,7 @@ objfile::map_symtabs_matching_filename
{
/* The callback to iterate_over_some_symtabs returns false to keep
going and true to continue, so we have to invert the result
- here, for expand_symtabs_matching. */
+ here, for search. */
bool result = !iterate_over_some_symtabs (name, real_path,
this->compunit_symtabs,
last_made,
@@ -204,14 +204,10 @@ objfile::map_symtabs_matching_filename
for (const auto &iter : qf)
{
- if (!iter->expand_symtabs_matching (this,
- match_one_filename,
- nullptr,
- nullptr,
- on_expansion,
- (SEARCH_GLOBAL_BLOCK
- | SEARCH_STATIC_BLOCK),
- SEARCH_ALL_DOMAINS))
+ if (!iter->search (this, match_one_filename, nullptr, nullptr,
+ on_expansion,
+ SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
+ SEARCH_ALL_DOMAINS))
{
retval = false;
break;
@@ -267,15 +263,11 @@ objfile::lookup_symbol (block_enum kind, const lookup_name_info &name,
for (const auto &iter : qf)
{
- if (!iter->expand_symtabs_matching (this,
- nullptr,
- &name,
- nullptr,
- search_one_symtab,
- kind == GLOBAL_BLOCK
- ? SEARCH_GLOBAL_BLOCK
- : SEARCH_STATIC_BLOCK,
- domain))
+ if (!iter->search (this, nullptr, &name, nullptr, search_one_symtab,
+ kind == GLOBAL_BLOCK
+ ? SEARCH_GLOBAL_BLOCK
+ : SEARCH_STATIC_BLOCK,
+ domain))
break;
}
@@ -311,28 +303,6 @@ objfile::dump ()
}
void
-objfile::expand_symtabs_for_function (const char *func_name)
-{
- if (debug_symfile)
- gdb_printf (gdb_stdlog,
- "qf->expand_symtabs_for_function (%s, \"%s\")\n",
- objfile_debug_name (this), func_name);
-
- lookup_name_info base_lookup (func_name, symbol_name_match_type::FULL);
- lookup_name_info lookup_name = base_lookup.make_ignore_params ();
-
- for (const auto &iter : qf)
- iter->expand_symtabs_matching (this,
- nullptr,
- &lookup_name,
- nullptr,
- nullptr,
- (SEARCH_GLOBAL_BLOCK
- | SEARCH_STATIC_BLOCK),
- SEARCH_FUNCTION_DOMAIN);
-}
-
-void
objfile::expand_all_symtabs ()
{
if (debug_symfile)
@@ -358,43 +328,35 @@ objfile::expand_symtabs_with_fullname (const char *fullname)
};
for (const auto &iter : qf)
- iter->expand_symtabs_matching (this,
- file_matcher,
- nullptr,
- nullptr,
- nullptr,
- (SEARCH_GLOBAL_BLOCK
- | SEARCH_STATIC_BLOCK),
- SEARCH_ALL_DOMAINS);
+ iter->search (this, file_matcher, nullptr, nullptr, nullptr,
+ SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
+ SEARCH_ALL_DOMAINS);
}
bool
-objfile::expand_symtabs_matching
- (expand_symtabs_file_matcher file_matcher,
- const lookup_name_info *lookup_name,
- expand_symtabs_symbol_matcher symbol_matcher,
- expand_symtabs_expansion_listener expansion_notify,
- block_search_flags search_flags,
- domain_search_flags domain,
- expand_symtabs_lang_matcher lang_matcher)
-{
- /* This invariant is documented in quick-functions.h. */
+objfile::search (search_symtabs_file_matcher file_matcher,
+ const lookup_name_info *lookup_name,
+ search_symtabs_symbol_matcher symbol_matcher,
+ search_symtabs_expansion_listener listener,
+ block_search_flags search_flags,
+ domain_search_flags domain,
+ search_symtabs_lang_matcher lang_matcher)
+{
+ /* This invariant is documented in quick-symbol.h. */
gdb_assert (lookup_name != nullptr || symbol_matcher == nullptr);
if (debug_symfile)
gdb_printf (gdb_stdlog,
- "qf->expand_symtabs_matching (%s, %s, %s, %s, %s)\n",
+ "qf->search (%s, %s, %s, %s, %s)\n",
objfile_debug_name (this),
host_address_to_string (&file_matcher),
host_address_to_string (&symbol_matcher),
- host_address_to_string (&expansion_notify),
+ host_address_to_string (&listener),
domain_name (domain).c_str ());
for (const auto &iter : qf)
- if (!iter->expand_symtabs_matching (this, file_matcher, lookup_name,
- symbol_matcher, expansion_notify,
- search_flags, domain,
- lang_matcher))
+ if (!iter->search (this, file_matcher, lookup_name, symbol_matcher,
+ listener, search_flags, domain, lang_matcher))
return false;
return true;
}
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 0e47f50..98cb637 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -58,7 +58,6 @@
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
-#include <ctype.h>
#include <chrono>
#include <algorithm>
@@ -835,9 +834,9 @@ init_entry_point_info (struct objfile *objfile)
= gdbarch_addr_bits_remove (objfile->arch (), entry_point);
found = 0;
- for (obj_section *osect : objfile->sections ())
+ for (obj_section &osect : objfile->sections ())
{
- struct bfd_section *sect = osect->the_bfd_section;
+ struct bfd_section *sect = osect.the_bfd_section;
if (entry_point >= bfd_section_vma (sect)
&& entry_point < (bfd_section_vma (sect)
@@ -2748,7 +2747,7 @@ set_ext_lang_command (const char *args,
error (_("'%s': Filename extension must begin with '.'"), ext_args.c_str ());
/* Find end of first arg. */
- while (*end != '\0' && !isspace (*end))
+ while (*end != '\0' && !c_isspace (*end))
end++;
if (*end == '\0')
@@ -3007,9 +3006,9 @@ static void
overlay_invalidate_all (program_space *pspace)
{
for (objfile *objfile : pspace->objfiles ())
- for (obj_section *sect : objfile->sections ())
- if (section_is_overlay (sect))
- sect->ovly_mapped = -1;
+ for (obj_section &sect : objfile->sections ())
+ if (section_is_overlay (&sect))
+ sect.ovly_mapped = -1;
}
/* Function: section_is_mapped (SECTION)
@@ -3183,18 +3182,18 @@ find_pc_overlay (CORE_ADDR pc)
if (overlay_debugging)
{
for (objfile *objfile : current_program_space->objfiles ())
- for (obj_section *osect : objfile->sections ())
- if (section_is_overlay (osect))
+ for (obj_section &osect : objfile->sections ())
+ if (section_is_overlay (&osect))
{
- if (pc_in_mapped_range (pc, osect))
+ if (pc_in_mapped_range (pc, &osect))
{
- if (section_is_mapped (osect))
- return osect;
+ if (section_is_mapped (&osect))
+ return &osect;
else
- best_match = osect;
+ best_match = &osect;
}
- else if (pc_in_unmapped_range (pc, osect))
- best_match = osect;
+ else if (pc_in_unmapped_range (pc, &osect))
+ best_match = &osect;
}
}
return best_match;
@@ -3210,9 +3209,9 @@ find_pc_mapped_section (CORE_ADDR pc)
if (overlay_debugging)
{
for (objfile *objfile : current_program_space->objfiles ())
- for (obj_section *osect : objfile->sections ())
- if (pc_in_mapped_range (pc, osect) && section_is_mapped (osect))
- return osect;
+ for (obj_section &osect : objfile->sections ())
+ if (pc_in_mapped_range (pc, &osect) && section_is_mapped (&osect))
+ return &osect;
}
return NULL;
@@ -3229,18 +3228,18 @@ list_overlays_command (const char *args, int from_tty)
if (overlay_debugging)
{
for (objfile *objfile : current_program_space->objfiles ())
- for (obj_section *osect : objfile->sections ())
- if (section_is_mapped (osect))
+ for (obj_section &osect : objfile->sections ())
+ if (section_is_mapped (&osect))
{
struct gdbarch *gdbarch = objfile->arch ();
const char *name;
bfd_vma lma, vma;
int size;
- vma = bfd_section_vma (osect->the_bfd_section);
- lma = bfd_section_lma (osect->the_bfd_section);
- size = bfd_section_size (osect->the_bfd_section);
- name = bfd_section_name (osect->the_bfd_section);
+ vma = bfd_section_vma (osect.the_bfd_section);
+ lma = bfd_section_lma (osect.the_bfd_section);
+ size = bfd_section_size (osect.the_bfd_section);
+ name = bfd_section_name (osect.the_bfd_section);
gdb_printf ("Section %s, loaded at ", name);
gdb_puts (paddress (gdbarch, lma));
@@ -3275,27 +3274,27 @@ map_overlay_command (const char *args, int from_tty)
/* First, find a section matching the user supplied argument. */
for (objfile *obj_file : current_program_space->objfiles ())
- for (obj_section *sec : obj_file->sections ())
- if (!strcmp (bfd_section_name (sec->the_bfd_section), args))
+ for (obj_section &sec : obj_file->sections ())
+ if (!strcmp (bfd_section_name (sec.the_bfd_section), args))
{
/* Now, check to see if the section is an overlay. */
- if (!section_is_overlay (sec))
+ if (!section_is_overlay (&sec))
continue; /* not an overlay section */
/* Mark the overlay as "mapped". */
- sec->ovly_mapped = 1;
+ sec.ovly_mapped = 1;
/* Next, make a pass and unmap any sections that are
overlapped by this new section: */
for (objfile *objfile2 : current_program_space->objfiles ())
- for (obj_section *sec2 : objfile2->sections ())
- if (sec2->ovly_mapped && sec != sec2 && sections_overlap (sec,
- sec2))
+ for (obj_section &sec2 : objfile2->sections ())
+ if (sec2.ovly_mapped && &sec != &sec2 && sections_overlap (&sec,
+ &sec2))
{
if (info_verbose)
gdb_printf (_("Note: section %s unmapped by overlap\n"),
- bfd_section_name (sec2->the_bfd_section));
- sec2->ovly_mapped = 0; /* sec2 overlaps sec: unmap sec2. */
+ bfd_section_name (sec2.the_bfd_section));
+ sec2.ovly_mapped = 0; /* sec2 overlaps sec: unmap sec2. */
}
return;
}
@@ -3319,12 +3318,12 @@ unmap_overlay_command (const char *args, int from_tty)
/* First, find a section matching the user supplied argument. */
for (objfile *objfile : current_program_space->objfiles ())
- for (obj_section *sec : objfile->sections ())
- if (!strcmp (bfd_section_name (sec->the_bfd_section), args))
+ for (obj_section &sec : objfile->sections ())
+ if (!strcmp (bfd_section_name (sec.the_bfd_section), args))
{
- if (!sec->ovly_mapped)
+ if (!sec.ovly_mapped)
error (_("Section %s is not mapped"), args);
- sec->ovly_mapped = 0;
+ sec.ovly_mapped = 0;
return;
}
error (_("No overlay section called %s"), args);
@@ -3578,17 +3577,17 @@ simple_overlay_update (struct obj_section *osect)
/* Now may as well update all sections, even if only one was requested. */
for (objfile *objfile : current_program_space->objfiles ())
- for (obj_section *sect : objfile->sections ())
- if (section_is_overlay (sect))
+ for (obj_section &sect : objfile->sections ())
+ if (section_is_overlay (&sect))
{
int i;
- asection *bsect = sect->the_bfd_section;
+ asection *bsect = sect.the_bfd_section;
for (i = 0; i < cache_novlys; i++)
if (cache_ovly_table[i][VMA] == bfd_section_vma (bsect)
&& cache_ovly_table[i][LMA] == bfd_section_lma (bsect))
{ /* obj_section matches i'th entry in ovly_table. */
- sect->ovly_mapped = cache_ovly_table[i][MAPPED];
+ sect.ovly_mapped = cache_ovly_table[i][MAPPED];
break; /* finished with inner for loop: break out. */
}
}
@@ -3756,31 +3755,6 @@ symfile_free_objfile (struct objfile *objfile)
objfile->pspace ()->remove_target_sections (objfile);
}
-/* Wrapper around the quick_symbol_functions expand_symtabs_matching "method".
- Expand all symtabs that match the specified criteria.
- See quick_symbol_functions.expand_symtabs_matching for details. */
-
-bool
-expand_symtabs_matching (expand_symtabs_file_matcher file_matcher,
- const lookup_name_info &lookup_name,
- expand_symtabs_symbol_matcher symbol_matcher,
- expand_symtabs_expansion_listener expansion_notify,
- block_search_flags search_flags,
- domain_search_flags domain,
- expand_symtabs_lang_matcher lang_matcher)
-{
- for (objfile *objfile : current_program_space->objfiles ())
- if (!objfile->expand_symtabs_matching (file_matcher,
- &lookup_name,
- symbol_matcher,
- expansion_notify,
- search_flags,
- domain,
- lang_matcher))
- return false;
- return true;
-}
-
/* Wrapper around the quick_symbol_functions map_symbol_filenames "method".
Map function FUN over every file.
See quick_symbol_functions.map_symbol_filenames for details. */
diff --git a/gdb/symfile.h b/gdb/symfile.h
index ee9bc11..06509a6 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -345,15 +345,6 @@ symfile_segment_data_up get_symfile_segment_data (bfd *abfd);
extern scoped_restore_tmpl<int> increment_reading_symtab (void);
-bool expand_symtabs_matching
- (expand_symtabs_file_matcher file_matcher,
- const lookup_name_info &lookup_name,
- expand_symtabs_symbol_matcher symbol_matcher,
- expand_symtabs_expansion_listener expansion_notify,
- block_search_flags search_flags,
- domain_search_flags kind,
- expand_symtabs_lang_matcher lang_matcher = nullptr);
-
void map_symbol_filenames (symbol_filename_listener fun, bool need_fullname);
/* Target-agnostic function to load the sections of an executable into memory.
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 0cb6a1b..e43fafa 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -537,7 +537,7 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
}
else
{
- if (symbol->aclass () == LOC_TYPEDEF)
+ if (symbol->loc_class () == LOC_TYPEDEF)
gdb_printf (outfile, "typedef ");
if (symbol->type ())
{
@@ -552,7 +552,7 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
else
gdb_printf (outfile, "%s ", symbol->print_name ());
- switch (symbol->aclass ())
+ switch (symbol->loc_class ())
{
case LOC_CONST:
gdb_printf (outfile, "const %s (%s)",
@@ -646,7 +646,7 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
default:
gdb_printf (outfile, "botched symbol class %x",
- symbol->aclass ());
+ symbol->loc_class ());
break;
}
}
@@ -918,7 +918,7 @@ maintenance_expand_symtabs (const char *args, int from_tty)
for (struct program_space *pspace : program_spaces)
for (objfile *objfile : pspace->objfiles ())
- objfile->expand_symtabs_matching
+ objfile->search
([&] (const char *filename, bool basenames)
{
/* KISS: Only apply the regexp to the complete file name. */
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 302f4eb..896b81d 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -56,7 +56,6 @@
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
-#include <ctype.h>
#include "cp-abi.h"
#include "cp-support.h"
#include "observable.h"
@@ -123,41 +122,6 @@ struct main_info
static const registry<program_space>::key<main_info> main_progspace_key;
-/* Symbol lookup is not reentrant (though this is not an intrinsic
- restriction). Keep track of whether a symbol lookup is active, to be able
- to detect reentrancy. */
-static bool in_symbol_lookup;
-
-/* Struct to mark that a symbol lookup is active for the duration of its
- lifetime. */
-
-struct enter_symbol_lookup
-{
- enter_symbol_lookup ()
- {
- /* Ensure that the current language has been set. Normally the
- language is set lazily. However, when performing a symbol lookup,
- this could result in a recursive call into the lookup code in some
- cases. Set it now to ensure that this does not happen. */
- get_current_language ();
-
- /* Detect symbol lookup reentrance. */
- gdb_assert (!in_symbol_lookup);
-
- in_symbol_lookup = true;
- }
-
- ~enter_symbol_lookup ()
- {
- /* Sanity check. */
- gdb_assert (in_symbol_lookup);
-
- in_symbol_lookup = false;
- }
-
- DISABLE_COPY_AND_ASSIGN (enter_symbol_lookup);
-};
-
/* The default symbol cache size.
There is no extra cpu cost for large N (except when flushing the cache,
which is rare). The value here is just a first attempt. A better default
@@ -1780,7 +1744,7 @@ fixup_symbol_section (struct symbol *sym, struct objfile *objfile)
index without doing the check that is done by the wrapper macros
like SECT_OFF_TEXT. */
int fallback;
- switch (sym->aclass ())
+ switch (sym->loc_class ())
{
case LOC_STATIC:
fallback = objfile->sect_index_data;
@@ -1846,18 +1810,18 @@ fixup_symbol_section (struct symbol *sym, struct objfile *objfile)
this reason, we still attempt a lookup by name prior to doing
a search of the section table. */
- for (obj_section *s : objfile->sections ())
+ for (obj_section &s : objfile->sections ())
{
- if ((bfd_section_flags (s->the_bfd_section) & SEC_ALLOC) == 0)
+ if ((bfd_section_flags (s.the_bfd_section) & SEC_ALLOC) == 0)
continue;
- int idx = s - objfile->sections_start;
+ int idx = &s - objfile->sections_start;
CORE_ADDR offset = objfile->section_offsets[idx];
if (fallback == -1)
fallback = idx;
- if (s->addr () - offset <= addr && addr < s->endaddr () - offset)
+ if (s.addr () - offset <= addr && addr < s.endaddr () - offset)
{
sym->set_section_index (idx);
return;
@@ -2286,8 +2250,6 @@ lookup_symbol_in_block (const char *name, symbol_name_match_type match_type,
const struct block *block,
const domain_search_flags domain)
{
- enter_symbol_lookup tmp;
-
struct symbol *sym;
if (symbol_lookup_debug)
@@ -2323,8 +2285,6 @@ lookup_global_symbol_from_objfile (struct objfile *main_objfile,
const char *name,
const domain_search_flags domain)
{
- enter_symbol_lookup tmp;
-
gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK);
for (objfile *objfile : main_objfile->separate_debug_objfiles ())
@@ -2357,44 +2317,26 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile,
block_index == GLOBAL_BLOCK ? "GLOBAL_BLOCK" : "STATIC_BLOCK",
name, domain_name (domain).c_str ());
- struct block_symbol other;
- other.symbol = NULL;
+ lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
+ best_symbol_tracker accum;
for (compunit_symtab *cust : objfile->compunits ())
{
const struct blockvector *bv;
const struct block *block;
- struct block_symbol result;
bv = cust->blockvector ();
block = bv->block (block_index);
- result.symbol = block_lookup_symbol_primary (block, name, domain);
- result.block = block;
- if (result.symbol == NULL)
- continue;
- if (best_symbol (result.symbol, domain))
- {
- other = result;
- break;
- }
- if (result.symbol->matches (domain))
- {
- struct symbol *better
- = better_symbol (other.symbol, result.symbol, domain);
- if (better != other.symbol)
- {
- other.symbol = better;
- other.block = block;
- }
- }
+ if (accum.search (cust, block, lookup_name, domain))
+ break;
}
- if (other.symbol != NULL)
+ if (accum.currently_best.symbol != nullptr)
{
symbol_lookup_debug_printf_v
("lookup_symbol_in_objfile_symtabs (...) = %s (block %s)",
- host_address_to_string (other.symbol),
- host_address_to_string (other.block));
- return other;
+ host_address_to_string (accum.currently_best.symbol),
+ host_address_to_string (accum.currently_best.block));
+ return accum.currently_best;
}
symbol_lookup_debug_printf_v
@@ -2468,11 +2410,6 @@ lookup_symbol_via_quick_fns (struct objfile *objfile,
enum block_enum block_index, const char *name,
const domain_search_flags domain)
{
- struct compunit_symtab *cust;
- const struct blockvector *bv;
- const struct block *block;
- struct block_symbol result;
-
symbol_lookup_debug_printf_v
("lookup_symbol_via_quick_fns (%s, %s, %s, %s)",
objfile_debug_name (objfile),
@@ -2480,27 +2417,36 @@ lookup_symbol_via_quick_fns (struct objfile *objfile,
name, domain_name (domain).c_str ());
lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
- cust = objfile->lookup_symbol (block_index, lookup_name, domain);
- if (cust == NULL)
+ best_symbol_tracker accum;
+ auto searcher = [&] (compunit_symtab *symtab)
+ {
+ const struct blockvector *bv = symtab->blockvector ();
+ const struct block *block = bv->block (block_index);
+ /* If the accumulator finds a best symbol, end the search by
+ returning false; otherwise keep going by returning true. */
+ return !accum.search (symtab, block, lookup_name, domain);
+ };
+
+ objfile->search (nullptr, &lookup_name, nullptr, searcher,
+ block_index == GLOBAL_BLOCK
+ ? SEARCH_GLOBAL_BLOCK
+ : SEARCH_STATIC_BLOCK,
+ domain);
+ if (accum.best_symtab == nullptr)
{
symbol_lookup_debug_printf_v
("lookup_symbol_via_quick_fns (...) = NULL");
return {};
}
-
- bv = cust->blockvector ();
- block = bv->block (block_index);
- result.symbol = block_lookup_symbol (block, lookup_name, domain);
- if (result.symbol == NULL)
- error_in_psymtab_expansion (block_index, name, cust);
+ if (accum.currently_best.symbol == nullptr)
+ error_in_psymtab_expansion (block_index, name, accum.best_symtab);
symbol_lookup_debug_printf_v
("lookup_symbol_via_quick_fns (...) = %s (block %s)",
- host_address_to_string (result.symbol),
- host_address_to_string (block));
+ host_address_to_string (accum.currently_best.symbol),
+ host_address_to_string (accum.currently_best.block));
- result.block = block;
- return result;
+ return accum.currently_best;
}
/* See language.h. */
@@ -2600,24 +2546,12 @@ lookup_symbol_in_objfile (struct objfile *objfile, enum block_enum block_index,
? "GLOBAL_BLOCK" : "STATIC_BLOCK",
name, domain_name (domain).c_str ());
- result = lookup_symbol_in_objfile_symtabs (objfile, block_index,
- name, domain);
- if (result.symbol != NULL)
- {
- symbol_lookup_debug_printf
- ("lookup_symbol_in_objfile (...) = %s (in symtabs)",
- host_address_to_string (result.symbol));
- return result;
- }
-
result = lookup_symbol_via_quick_fns (objfile, block_index,
name, domain);
- symbol_lookup_debug_printf ("lookup_symbol_in_objfile (...) = %s%s",
+ symbol_lookup_debug_printf ("lookup_symbol_in_objfile (...) = %s",
result.symbol != NULL
? host_address_to_string (result.symbol)
- : "NULL",
- result.symbol != NULL ? " (via quick fns)"
- : "");
+ : "NULL");
return result;
}
@@ -2650,13 +2584,10 @@ lookup_global_or_static_symbol (const char *name,
return result;
}
- enter_symbol_lookup tmp;
-
/* Do a global search (of global blocks, heh). */
if (result.symbol == NULL)
- gdbarch_iterate_over_objfiles_in_search_order
- (objfile != NULL ? objfile->arch () : current_inferior ()->arch (),
- [&result, block_index, name, domain] (struct objfile *objfile_iter)
+ current_program_space->iterate_over_objfiles_in_search_order
+ ([&result, block_index, name, domain] (struct objfile *objfile_iter)
{
result = lookup_symbol_in_objfile (objfile_iter, block_index,
name, domain);
@@ -2768,35 +2699,6 @@ basic_lookup_transparent_type_quick (struct objfile *objfile,
return sym->type ();
}
-/* Subroutine of basic_lookup_transparent_type to simplify it.
- Look up the non-opaque definition of NAME in BLOCK_INDEX of OBJFILE.
- BLOCK_INDEX is either GLOBAL_BLOCK or STATIC_BLOCK. */
-
-static struct type *
-basic_lookup_transparent_type_1 (struct objfile *objfile,
- enum block_enum block_index,
- domain_search_flags flags,
- const lookup_name_info &name)
-{
- const struct blockvector *bv;
- const struct block *block;
- const struct symbol *sym;
-
- for (compunit_symtab *cust : objfile->compunits ())
- {
- bv = cust->blockvector ();
- block = bv->block (block_index);
- sym = block_find_symbol (block, name, flags, nullptr);
- if (sym != nullptr)
- {
- gdb_assert (!TYPE_IS_OPAQUE (sym->type ()));
- return sym->type ();
- }
- }
-
- return NULL;
-}
-
/* The standard implementation of lookup_transparent_type. This code
was modeled on lookup_symbol -- the parts not relevant to looking
up types were just left out. In particular it's assumed here that
@@ -2810,19 +2712,7 @@ basic_lookup_transparent_type (const char *name, domain_search_flags flags)
lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
- /* Now search all the global symbols. Do the symtab's first, then
- check the psymtab's. If a psymtab indicates the existence
- of the desired name as a global, then do psymtab-to-symtab
- conversion on the fly and return the found symbol. */
-
- for (objfile *objfile : current_program_space->objfiles ())
- {
- t = basic_lookup_transparent_type_1 (objfile, GLOBAL_BLOCK,
- flags, lookup_name);
- if (t)
- return t;
- }
-
+ /* Search all the global symbols. */
for (objfile *objfile : current_program_space->objfiles ())
{
t = basic_lookup_transparent_type_quick (objfile, GLOBAL_BLOCK,
@@ -2831,21 +2721,8 @@ basic_lookup_transparent_type (const char *name, domain_search_flags flags)
return t;
}
- /* Now search the static file-level symbols.
- Not strictly correct, but more useful than an error.
- Do the symtab's first, then
- check the psymtab's. If a psymtab indicates the existence
- of the desired name as a file-level static, then do psymtab-to-symtab
- conversion on the fly and return the found symbol. */
-
- for (objfile *objfile : current_program_space->objfiles ())
- {
- t = basic_lookup_transparent_type_1 (objfile, STATIC_BLOCK,
- flags, lookup_name);
- if (t)
- return t;
- }
-
+ /* Now search the static file-level symbols. Not strictly correct,
+ but more useful than an error. */
for (objfile *objfile : current_program_space->objfiles ())
{
t = basic_lookup_transparent_type_quick (objfile, STATIC_BLOCK,
@@ -3038,7 +2915,7 @@ find_symbol_at_address (CORE_ADDR address)
for (struct symbol *sym : block_iterator_range (b))
{
- if (sym->aclass () == LOC_STATIC
+ if (sym->loc_class () == LOC_STATIC
&& sym->value_address () == addr)
return sym;
}
@@ -4310,7 +4187,7 @@ find_function_alias_target (bound_minimal_symbol msymbol)
symbol *sym = find_pc_function (func_addr);
if (sym != NULL
- && sym->aclass () == LOC_BLOCK
+ && sym->loc_class () == LOC_BLOCK
&& sym->value_block ()->entry_pc () == func_addr)
return sym;
@@ -4333,7 +4210,7 @@ operator_chars (const char *p, const char **end)
/* Don't get faked out by `operator' being part of a longer
identifier. */
- if (isalpha (*p) || *p == '_' || *p == '$' || *p == '\0')
+ if (c_isalpha (*p) || *p == '_' || *p == '$' || *p == '\0')
return *end;
/* Allow some whitespace between `operator' and the operator symbol. */
@@ -4342,11 +4219,11 @@ operator_chars (const char *p, const char **end)
/* Recognize 'operator TYPENAME'. */
- if (isalpha (*p) || *p == '_' || *p == '$')
+ if (c_isalpha (*p) || *p == '_' || *p == '$')
{
const char *q = p + 1;
- while (isalnum (*q) || *q == '_' || *q == '$')
+ while (c_isalnum (*q) || *q == '_' || *q == '$')
q++;
*end = q;
return p;
@@ -4902,11 +4779,11 @@ global_symbol_searcher::expand_symtabs
{
return file_matches (filename, m_filenames, basenames);
};
- expand_symtabs_file_matcher file_matcher = nullptr;
+ search_symtabs_file_matcher file_matcher = nullptr;
if (!m_filenames.empty ())
file_matcher = do_file_match;
- objfile->expand_symtabs_matching
+ objfile->search
(file_matcher,
&lookup_name_info::match_any (),
[&] (const char *symname)
@@ -5021,12 +4898,12 @@ global_symbol_searcher::add_matching_symbols
if ((kind & SEARCH_VAR_DOMAIN) != 0)
{
- if (sym->aclass () == LOC_UNRESOLVED
+ if (sym->loc_class () == LOC_UNRESOLVED
/* LOC_CONST can be used for more than
just enums, e.g., c++ static const
members. We only want to skip enums
here. */
- || (sym->aclass () == LOC_CONST
+ || (sym->loc_class () == LOC_CONST
&& (sym->type ()->code () == TYPE_CODE_ENUM)))
continue;
}
@@ -5120,7 +4997,7 @@ global_symbol_searcher::search () const
int fix = -1; /* -1 means ok; otherwise number of
spaces needed. */
- if (isalpha (*opname) || *opname == '_' || *opname == '$')
+ if (c_isalpha (*opname) || *opname == '_' || *opname == '$')
{
/* There should 1 space between 'operator' and 'TYPENAME'. */
if (opname[-1] != ' ' || opname[-2] == ' ')
@@ -5234,7 +5111,7 @@ symbol_to_info_string (struct symbol *sym, int block)
string_file tmp_stream;
type_print (sym->type (),
- (sym->aclass () == LOC_TYPEDEF
+ (sym->loc_class () == LOC_TYPEDEF
? "" : sym->print_name ()),
&tmp_stream, 0);
@@ -5602,7 +5479,7 @@ rbreak_command (const char *regexp, int from_tty)
if (colon && *(colon + 1) != ':')
{
int colon_index = colon - regexp;
- while (colon_index > 0 && isspace (regexp[colon_index - 1]))
+ while (colon_index > 0 && c_isspace (regexp[colon_index - 1]))
--colon_index;
file_name = make_unique_xstrndup (regexp, colon_index);
@@ -5753,7 +5630,7 @@ completion_list_add_symbol (completion_tracker &tracker,
the msymbol name and removes the msymbol name from the completion
tracker. */
if (sym->language () == language_cplus
- && sym->aclass () == LOC_BLOCK)
+ && sym->loc_class () == LOC_BLOCK)
{
/* The call to canonicalize returns the empty string if the input
string is already in canonical form, thanks to this we don't
@@ -5854,7 +5731,7 @@ language_search_unquoted_string (const char *text, const char *p)
{
for (; p > text; --p)
{
- if (isalnum (p[-1]) || p[-1] == '_' || p[-1] == '\0')
+ if (c_isalnum (p[-1]) || p[-1] == '_' || p[-1] == '\0')
continue;
else
{
@@ -5874,7 +5751,7 @@ language_search_unquoted_string (const char *text, const char *p)
Unfortunately we have to find it now to decide. */
while (t > text)
- if (isalnum (t[-1]) || t[-1] == '_' ||
+ if (c_isalnum (t[-1]) || t[-1] == '_' ||
t[-1] == ' ' || t[-1] == ':' ||
t[-1] == '(' || t[-1] == ')')
--t;
@@ -5898,7 +5775,7 @@ completion_list_add_fields (completion_tracker &tracker,
const lookup_name_info &lookup_name,
const char *text, const char *word)
{
- if (sym->aclass () == LOC_TYPEDEF)
+ if (sym->loc_class () == LOC_TYPEDEF)
{
struct type *t = sym->type ();
enum type_code c = t->code ();
@@ -5950,7 +5827,7 @@ symbol_is_function_or_method (minimal_symbol *msymbol)
bound_minimal_symbol
find_gnu_ifunc (const symbol *sym)
{
- if (sym->aclass () != LOC_BLOCK)
+ if (sym->loc_class () != LOC_BLOCK)
return {};
lookup_name_info lookup_name (sym->search_name (),
@@ -6082,7 +5959,7 @@ default_collect_symbol_completion_matches_break_on
which are in symbols. */
while (p > text)
{
- if (isalnum (p[-1]) || p[-1] == '_' || p[-1] == '\0'
+ if (c_isalnum (p[-1]) || p[-1] == '_' || p[-1] == '\0'
|| p[-1] == ':' || strchr (break_on, p[-1]) != NULL)
--p;
else
@@ -6122,25 +5999,20 @@ default_collect_symbol_completion_matches_break_on
/* Add completions for all currently loaded symbol tables. */
for (objfile *objfile : current_program_space->objfiles ())
{
- for (compunit_symtab *cust : objfile->compunits ())
- add_symtab_completions (cust, tracker, mode, lookup_name,
- sym_text, word, code);
- }
-
- /* Look through the partial symtabs for all symbols which begin by
- matching SYM_TEXT. Expand all CUs that you find to the list. */
- expand_symtabs_matching (NULL,
- lookup_name,
- NULL,
- [&] (compunit_symtab *symtab) /* expansion notify */
- {
- add_symtab_completions (symtab,
- tracker, mode, lookup_name,
- sym_text, word, code);
- return true;
- },
- SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
- SEARCH_ALL_DOMAINS);
+ /* Look through the partial symtabs for all symbols which begin by
+ matching SYM_TEXT. Expand all CUs that you find to the list. */
+ objfile->search
+ (nullptr, &lookup_name, nullptr,
+ [&] (compunit_symtab *symtab)
+ {
+ add_symtab_completions (symtab,
+ tracker, mode, lookup_name,
+ sym_text, word, code);
+ return true;
+ },
+ SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
+ SEARCH_ALL_DOMAINS);
+ }
/* Search upwards from currently selected frame (so that we can
complete on local vars). Also catch fields of types defined in
@@ -6575,9 +6447,8 @@ find_main_name (void)
/* Try to find language for main in psymtabs. */
bool symbol_found_p = false;
- gdbarch_iterate_over_objfiles_in_search_order
- (current_inferior ()->arch (),
- [&symbol_found_p, pspace] (objfile *obj)
+ current_program_space->iterate_over_objfiles_in_search_order
+ ([&symbol_found_p, pspace] (objfile *obj)
{
language lang
= obj->lookup_global_symbol_language ("main",
@@ -6629,13 +6500,13 @@ main_language (void)
/* The next index to hand out in response to a registration request. */
-static int next_aclass_value = LOC_FINAL_VALUE;
+static int next_loc_class_value = LOC_FINAL_VALUE;
-/* The maximum number of "aclass" registrations we support. This is
+/* The maximum number of "loc_class" registrations we support. This is
constant for convenience. */
#define MAX_SYMBOL_IMPLS (LOC_FINAL_VALUE + 11)
-/* The objects representing the various "aclass" values. The elements
+/* The objects representing the various "loc_class" values. The elements
from 0 up to LOC_FINAL_VALUE-1 represent themselves, and subsequent
elements are those registered at gdb initialization time. */
@@ -6648,22 +6519,22 @@ gdb::array_view<const struct symbol_impl> symbol_impls (symbol_impl);
/* Make sure we saved enough room in struct symbol. */
-static_assert (MAX_SYMBOL_IMPLS <= (1 << SYMBOL_ACLASS_BITS));
+static_assert (MAX_SYMBOL_IMPLS <= (1 << SYMBOL_LOC_CLASS_BITS));
-/* Register a computed symbol type. ACLASS must be LOC_COMPUTED. OPS
+/* Register a computed symbol type. LOC_CLASS must be LOC_COMPUTED. OPS
is the ops vector associated with this index. This returns the new
- index, which should be used as the aclass_index field for symbols
+ index, which should be used as the loc_class_index field for symbols
of this type. */
int
-register_symbol_computed_impl (enum address_class aclass,
+register_symbol_computed_impl (location_class loc_class,
const struct symbol_computed_ops *ops)
{
- int result = next_aclass_value++;
+ int result = next_loc_class_value++;
- gdb_assert (aclass == LOC_COMPUTED);
+ gdb_assert (loc_class == LOC_COMPUTED);
gdb_assert (result < MAX_SYMBOL_IMPLS);
- symbol_impl[result].aclass = aclass;
+ symbol_impl[result].loc_class = loc_class;
symbol_impl[result].ops_computed = ops;
/* Sanity check OPS. */
@@ -6676,20 +6547,20 @@ register_symbol_computed_impl (enum address_class aclass,
return result;
}
-/* Register a function with frame base type. ACLASS must be LOC_BLOCK.
+/* Register a function with frame base type. LOC_CLASS must be LOC_BLOCK.
OPS is the ops vector associated with this index. This returns the
- new index, which should be used as the aclass_index field for symbols
+ new index, which should be used as the loc_class_index field for symbols
of this type. */
int
-register_symbol_block_impl (enum address_class aclass,
+register_symbol_block_impl (location_class loc_class,
const struct symbol_block_ops *ops)
{
- int result = next_aclass_value++;
+ int result = next_loc_class_value++;
- gdb_assert (aclass == LOC_BLOCK);
+ gdb_assert (loc_class == LOC_BLOCK);
gdb_assert (result < MAX_SYMBOL_IMPLS);
- symbol_impl[result].aclass = aclass;
+ symbol_impl[result].loc_class = loc_class;
symbol_impl[result].ops_block = ops;
/* Sanity check OPS. */
@@ -6700,35 +6571,33 @@ register_symbol_block_impl (enum address_class aclass,
return result;
}
-/* Register a register symbol type. ACLASS must be LOC_REGISTER or
+/* Register a register symbol type. LOC_CLASS must be LOC_REGISTER or
LOC_REGPARM_ADDR. OPS is the register ops vector associated with
this index. This returns the new index, which should be used as
- the aclass_index field for symbols of this type. */
+ the loc_class_index field for symbols of this type. */
int
-register_symbol_register_impl (enum address_class aclass,
+register_symbol_register_impl (location_class loc_class,
const struct symbol_register_ops *ops)
{
- int result = next_aclass_value++;
+ int result = next_loc_class_value++;
- gdb_assert (aclass == LOC_REGISTER || aclass == LOC_REGPARM_ADDR);
+ gdb_assert (loc_class == LOC_REGISTER || loc_class == LOC_REGPARM_ADDR);
gdb_assert (result < MAX_SYMBOL_IMPLS);
- symbol_impl[result].aclass = aclass;
+ symbol_impl[result].loc_class = loc_class;
symbol_impl[result].ops_register = ops;
return result;
}
/* Initialize elements of 'symbol_impl' for the constants in enum
- address_class. */
+ location_class. */
static void
initialize_ordinary_address_classes (void)
{
- int i;
-
- for (i = 0; i < LOC_FINAL_VALUE; ++i)
- symbol_impl[i].aclass = (enum address_class) i;
+ for (int i = 0; i < LOC_FINAL_VALUE; ++i)
+ symbol_impl[i].loc_class = static_cast<location_class> (i);
}
@@ -6776,7 +6645,7 @@ CORE_ADDR
symbol::get_maybe_copied_address () const
{
gdb_assert (this->maybe_copied);
- gdb_assert (this->aclass () == LOC_STATIC);
+ gdb_assert (this->loc_class () == LOC_STATIC);
const char *linkage_name = this->linkage_name ();
bound_minimal_symbol minsym
diff --git a/gdb/symtab.h b/gdb/symtab.h
index a711953..09a361d 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -145,7 +145,7 @@ private:
std::string m_encoded_name;
/* The decoded lookup name. This is formed by calling ada_decode
- with both 'operators' and 'wide' set to false. */
+ with 'translate' set to false. */
std::string m_decoded_name;
/* Whether the user-provided lookup name was Ada encoded. If so,
@@ -967,9 +967,9 @@ to_scripting_domain (domain_search_flags val)
Throws an exception if VAL is not one of the allowable values. */
extern domain_search_flags from_scripting_domain (int val);
-/* An address-class says where to find the value of a symbol. */
+/* A location class says where to find the value of a symbol. */
-enum address_class
+enum location_class
{
/* Not used; catches errors. */
@@ -1078,14 +1078,14 @@ enum address_class
LOC_FINAL_VALUE
};
-/* The number of bits needed for values in enum address_class, with some
+/* The number of bits needed for values in enum location_class, with some
padding for reasonable growth, and room for run-time registered address
classes. See symtab.c:MAX_SYMBOL_IMPLS.
This is a #define so that we can have a assertion elsewhere to
verify that we have reserved enough space for synthetic address
classes. */
-#define SYMBOL_ACLASS_BITS 5
-static_assert (LOC_FINAL_VALUE <= (1 << SYMBOL_ACLASS_BITS));
+#define SYMBOL_LOC_CLASS_BITS 5
+static_assert (LOC_FINAL_VALUE <= (1 << SYMBOL_LOC_CLASS_BITS));
/* The methods needed to implement LOC_COMPUTED. These methods can
use the symbol's .aux_value for additional per-symbol information.
@@ -1202,7 +1202,7 @@ struct symbol_register_ops
struct symbol_impl
{
- enum address_class aclass;
+ location_class loc_class;
/* Used with LOC_COMPUTED. */
const struct symbol_computed_ops *ops_computed;
@@ -1238,7 +1238,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack<symbol>
symbol ()
/* Class-initialization of bitfields is only allowed in C++20. */
: m_domain (UNDEF_DOMAIN),
- m_aclass_index (0),
+ m_loc_class_index (0),
m_is_objfile_owned (1),
m_is_argument (0),
m_is_inlined (0),
@@ -1262,14 +1262,14 @@ struct symbol : public general_symbol_info, public allocate_on_obstack<symbol>
symbol (const symbol &) = default;
symbol &operator= (const symbol &) = default;
- void set_aclass_index (unsigned int aclass_index)
+ void set_loc_class_index (unsigned int loc_class_index)
{
- m_aclass_index = aclass_index;
+ m_loc_class_index = loc_class_index;
}
const symbol_impl &impl () const
{
- return symbol_impls[this->m_aclass_index];
+ return symbol_impls[this->m_loc_class_index];
}
const symbol_block_ops *block_ops () const
@@ -1287,9 +1287,9 @@ struct symbol : public general_symbol_info, public allocate_on_obstack<symbol>
return this->impl ().ops_register;
}
- address_class aclass () const
+ location_class loc_class () const
{
- return this->impl ().aclass;
+ return this->impl ().loc_class;
}
/* Return true if this symbol's domain matches FLAGS. */
@@ -1480,11 +1480,11 @@ struct symbol : public general_symbol_info, public allocate_on_obstack<symbol>
ENUM_BITFIELD(domain_enum) m_domain : SYMBOL_DOMAIN_BITS;
- /* Address class. This holds an index into the 'symbol_impls'
- table. The actual enum address_class value is stored there,
+ /* Location class. This holds an index into the 'symbol_impls'
+ table. The actual location_class value is stored there,
alongside any per-class ops vectors. */
- unsigned int m_aclass_index : SYMBOL_ACLASS_BITS;
+ unsigned int m_loc_class_index : SYMBOL_LOC_CLASS_BITS;
/* If non-zero then symbol is objfile-owned, use owner.symtab.
Otherwise symbol is arch-owned, use owner.arch. */
@@ -1575,13 +1575,13 @@ symbol::value_block () const
return m_value.block;
}
-extern int register_symbol_computed_impl (enum address_class,
+extern int register_symbol_computed_impl (location_class,
const struct symbol_computed_ops *);
-extern int register_symbol_block_impl (enum address_class aclass,
+extern int register_symbol_block_impl (location_class loc_class,
const struct symbol_block_ops *ops);
-extern int register_symbol_register_impl (enum address_class,
+extern int register_symbol_register_impl (location_class,
const struct symbol_register_ops *);
/* An instance of this type is used to represent a C++ template
diff --git a/gdb/syscalls/riscv-linux.xml b/gdb/syscalls/riscv-linux.xml
new file mode 100644
index 0000000..3578c3f
--- /dev/null
+++ b/gdb/syscalls/riscv-linux.xml
@@ -0,0 +1,340 @@
+<?xml version="1.0"?>
+<!DOCTYPE syscalls_info SYSTEM "gdb-syscalls.dtd">
+<!-- Copyright (C) 2025 Free Software Foundation, Inc.
+
+ Copying and distribution of this file, with or without modification,
+ are permitted in any medium without royalty provided the copyright
+ notice and this notice are preserved. -->
+<!-- This file was generated using the following file:
+
+ <sys/syscall.h>
+
+ The file mentioned above belongs to the Linux Kernel. -->
+<syscalls_info>
+ <syscall name="io_setup" number="0" groups="memory"/>
+ <syscall name="io_destroy" number="1" groups="memory"/>
+ <syscall name="io_submit" number="2"/>
+ <syscall name="io_cancel" number="3"/>
+ <syscall name="io_getevents" number="4"/>
+ <syscall name="setxattr" number="5" groups="file"/>
+ <syscall name="lsetxattr" number="6" groups="file"/>
+ <syscall name="fsetxattr" number="7" groups="descriptor"/>
+ <syscall name="getxattr" number="8" groups="file"/>
+ <syscall name="lgetxattr" number="9" groups="file"/>
+ <syscall name="fgetxattr" number="10" groups="descriptor"/>
+ <syscall name="listxattr" number="11" groups="file"/>
+ <syscall name="llistxattr" number="12" groups="file"/>
+ <syscall name="flistxattr" number="13" groups="descriptor"/>
+ <syscall name="removexattr" number="14" groups="file"/>
+ <syscall name="lremovexattr" number="15" groups="file"/>
+ <syscall name="fremovexattr" number="16" groups="descriptor"/>
+ <syscall name="getcwd" number="17" groups="file"/>
+ <syscall name="lookup_dcookie" number="18"/>
+ <syscall name="eventfd2" number="19" groups="descriptor"/>
+ <syscall name="epoll_create1" number="20" groups="descriptor"/>
+ <syscall name="epoll_ctl" number="21" groups="descriptor"/>
+ <syscall name="epoll_pwait" number="22" groups="descriptor"/>
+ <syscall name="dup" number="23" groups="descriptor"/>
+ <syscall name="dup3" number="24" groups="descriptor"/>
+ <syscall name="fcntl" number="25" groups="descriptor"/>
+ <syscall name="inotify_init1" number="26" groups="descriptor"/>
+ <syscall name="inotify_add_watch" number="27" groups="descriptor,file"/>
+ <syscall name="inotify_rm_watch" number="28" groups="descriptor"/>
+ <syscall name="ioctl" number="29" groups="descriptor"/>
+ <syscall name="ioprio_set" number="30"/>
+ <syscall name="ioprio_get" number="31"/>
+ <syscall name="flock" number="32" groups="descriptor"/>
+ <syscall name="mknodat" number="33" groups="descriptor,file"/>
+ <syscall name="mkdirat" number="34" groups="descriptor,file"/>
+ <syscall name="unlinkat" number="35" groups="descriptor,file"/>
+ <syscall name="symlinkat" number="36" groups="descriptor,file"/>
+ <syscall name="linkat" number="37" groups="descriptor,file"/>
+ <syscall name="umount2" number="39" groups="file"/>
+ <syscall name="mount" number="40" groups="file"/>
+ <syscall name="pivot_root" number="41" groups="file"/>
+ <syscall name="nfsservctl" number="42"/>
+ <syscall name="statfs" number="43" groups="file"/>
+ <syscall name="fstatfs" number="44" groups="descriptor"/>
+ <syscall name="truncate" number="45" groups="file"/>
+ <syscall name="ftruncate" number="46" groups="descriptor"/>
+ <syscall name="fallocate" number="47" groups="descriptor"/>
+ <syscall name="faccessat" number="48" groups="descriptor,file"/>
+ <syscall name="chdir" number="49" groups="file"/>
+ <syscall name="fchdir" number="50" groups="descriptor"/>
+ <syscall name="chroot" number="51" groups="file"/>
+ <syscall name="fchmod" number="52" groups="descriptor"/>
+ <syscall name="fchmodat" number="53" groups="descriptor,file"/>
+ <syscall name="fchownat" number="54" groups="descriptor,file"/>
+ <syscall name="fchown" number="55" groups="descriptor"/>
+ <syscall name="openat" number="56" groups="descriptor,file"/>
+ <syscall name="close" number="57" groups="descriptor"/>
+ <syscall name="vhangup" number="58"/>
+ <syscall name="pipe2" number="59" groups="descriptor"/>
+ <syscall name="quotactl" number="60" groups="file"/>
+ <syscall name="getdents64" number="61" groups="descriptor"/>
+ <syscall name="lseek" number="62" groups="descriptor"/>
+ <syscall name="read" number="63" groups="descriptor"/>
+ <syscall name="write" number="64" groups="descriptor"/>
+ <syscall name="readv" number="65" groups="descriptor"/>
+ <syscall name="writev" number="66" groups="descriptor"/>
+ <syscall name="pread64" number="67" groups="descriptor"/>
+ <syscall name="pwrite64" number="68" groups="descriptor"/>
+ <syscall name="preadv" number="69" groups="descriptor"/>
+ <syscall name="pwritev" number="70" groups="descriptor"/>
+ <syscall name="sendfile" number="71" groups="descriptor,network"/>
+ <syscall name="pselect6" number="72" groups="descriptor"/>
+ <syscall name="ppoll" number="73" groups="descriptor"/>
+ <syscall name="signalfd4" number="74" groups="descriptor,signal"/>
+ <syscall name="vmsplice" number="75" groups="descriptor"/>
+ <syscall name="splice" number="76" groups="descriptor"/>
+ <syscall name="tee" number="77" groups="descriptor"/>
+ <syscall name="readlinkat" number="78" groups="descriptor,file"/>
+ <syscall name="newfstatat" number="79" groups="descriptor,file"/>
+ <syscall name="fstat" number="80" groups="descriptor"/>
+ <syscall name="sync" number="81"/>
+ <syscall name="fsync" number="82" groups="descriptor"/>
+ <syscall name="fdatasync" number="83" groups="descriptor"/>
+ <syscall name="sync_file_range" number="84" groups="descriptor"/>
+ <syscall name="timerfd_create" number="85" groups="descriptor"/>
+ <syscall name="timerfd_settime" number="86" groups="descriptor"/>
+ <syscall name="timerfd_gettime" number="87" groups="descriptor"/>
+ <syscall name="utimensat" number="88" groups="descriptor,file"/>
+ <syscall name="acct" number="89" groups="file"/>
+ <syscall name="capget" number="90"/>
+ <syscall name="capset" number="91"/>
+ <syscall name="personality" number="92"/>
+ <syscall name="exit" number="93" groups="process"/>
+ <syscall name="exit_group" number="94" groups="process"/>
+ <syscall name="waitid" number="95" groups="process"/>
+ <syscall name="set_tid_address" number="96"/>
+ <syscall name="unshare" number="97"/>
+ <syscall name="futex" number="98"/>
+ <syscall name="set_robust_list" number="99"/>
+ <syscall name="get_robust_list" number="100"/>
+ <syscall name="nanosleep" number="101"/>
+ <syscall name="getitimer" number="102"/>
+ <syscall name="setitimer" number="103"/>
+ <syscall name="kexec_load" number="104"/>
+ <syscall name="init_module" number="105"/>
+ <syscall name="delete_module" number="106"/>
+ <syscall name="timer_create" number="107"/>
+ <syscall name="timer_gettime" number="108"/>
+ <syscall name="timer_getoverrun" number="109"/>
+ <syscall name="timer_settime" number="110"/>
+ <syscall name="timer_delete" number="111"/>
+ <syscall name="clock_settime" number="112"/>
+ <syscall name="clock_gettime" number="113"/>
+ <syscall name="clock_getres" number="114"/>
+ <syscall name="clock_nanosleep" number="115"/>
+ <syscall name="syslog" number="116"/>
+ <syscall name="ptrace" number="117"/>
+ <syscall name="sched_setparam" number="118"/>
+ <syscall name="sched_setscheduler" number="119"/>
+ <syscall name="sched_getscheduler" number="120"/>
+ <syscall name="sched_getparam" number="121"/>
+ <syscall name="sched_setaffinity" number="122"/>
+ <syscall name="sched_getaffinity" number="123"/>
+ <syscall name="sched_yield" number="124"/>
+ <syscall name="sched_get_priority_max" number="125"/>
+ <syscall name="sched_get_priority_min" number="126"/>
+ <syscall name="sched_rr_get_interval" number="127"/>
+ <syscall name="restart_syscall" number="128"/>
+ <syscall name="kill" number="129" groups="signal,process"/>
+ <syscall name="tkill" number="130" groups="signal,process"/>
+ <syscall name="tgkill" number="131" groups="signal,process"/>
+ <syscall name="sigaltstack" number="132" groups="signal"/>
+ <syscall name="rt_sigsuspend" number="133" groups="signal"/>
+ <syscall name="rt_sigaction" number="134" groups="signal"/>
+ <syscall name="rt_sigprocmask" number="135" groups="signal"/>
+ <syscall name="rt_sigpending" number="136" groups="signal"/>
+ <syscall name="rt_sigtimedwait" number="137" groups="signal"/>
+ <syscall name="rt_sigqueueinfo" number="138" groups="signal,process"/>
+ <syscall name="rt_sigreturn" number="139" groups="signal"/>
+ <syscall name="setpriority" number="140"/>
+ <syscall name="getpriority" number="141"/>
+ <syscall name="reboot" number="142"/>
+ <syscall name="setregid" number="143"/>
+ <syscall name="setgid" number="144"/>
+ <syscall name="setreuid" number="145"/>
+ <syscall name="setuid" number="146"/>
+ <syscall name="setresuid" number="147"/>
+ <syscall name="getresuid" number="148"/>
+ <syscall name="setresgid" number="149"/>
+ <syscall name="getresgid" number="150"/>
+ <syscall name="setfsuid" number="151"/>
+ <syscall name="setfsgid" number="152"/>
+ <syscall name="times" number="153"/>
+ <syscall name="setpgid" number="154"/>
+ <syscall name="getpgid" number="155"/>
+ <syscall name="getsid" number="156"/>
+ <syscall name="setsid" number="157"/>
+ <syscall name="getgroups" number="158"/>
+ <syscall name="setgroups" number="159"/>
+ <syscall name="uname" number="160"/>
+ <syscall name="sethostname" number="161"/>
+ <syscall name="setdomainname" number="162"/>
+ <syscall name="getrlimit" number="163"/>
+ <syscall name="setrlimit" number="164"/>
+ <syscall name="getrusage" number="165"/>
+ <syscall name="umask" number="166"/>
+ <syscall name="prctl" number="167"/>
+ <syscall name="getcpu" number="168"/>
+ <syscall name="gettimeofday" number="169"/>
+ <syscall name="settimeofday" number="170"/>
+ <syscall name="adjtimex" number="171"/>
+ <syscall name="getpid" number="172"/>
+ <syscall name="getppid" number="173"/>
+ <syscall name="getuid" number="174"/>
+ <syscall name="geteuid" number="175"/>
+ <syscall name="getgid" number="176"/>
+ <syscall name="getegid" number="177"/>
+ <syscall name="gettid" number="178"/>
+ <syscall name="sysinfo" number="179"/>
+ <syscall name="mq_open" number="180" groups="descriptor"/>
+ <syscall name="mq_unlink" number="181"/>
+ <syscall name="mq_timedsend" number="182" groups="descriptor"/>
+ <syscall name="mq_timedreceive" number="183" groups="descriptor"/>
+ <syscall name="mq_notify" number="184" groups="descriptor"/>
+ <syscall name="mq_getsetattr" number="185" groups="descriptor"/>
+ <syscall name="msgget" number="186" groups="ipc"/>
+ <syscall name="msgctl" number="187" groups="ipc"/>
+ <syscall name="msgrcv" number="188" groups="ipc"/>
+ <syscall name="msgsnd" number="189" groups="ipc"/>
+ <syscall name="semget" number="190" groups="ipc"/>
+ <syscall name="semctl" number="191" groups="ipc"/>
+ <syscall name="semtimedop" number="192" groups="ipc"/>
+ <syscall name="semop" number="193" groups="ipc"/>
+ <syscall name="shmget" number="194" groups="ipc"/>
+ <syscall name="shmctl" number="195" groups="ipc"/>
+ <syscall name="shmat" number="196" groups="ipc,memory"/>
+ <syscall name="shmdt" number="197" groups="ipc,memory"/>
+ <syscall name="socket" number="198" groups="network"/>
+ <syscall name="socketpair" number="199" groups="network"/>
+ <syscall name="bind" number="200" groups="network"/>
+ <syscall name="listen" number="201" groups="network"/>
+ <syscall name="accept" number="202" groups="network"/>
+ <syscall name="connect" number="203" groups="network"/>
+ <syscall name="getsockname" number="204" groups="network"/>
+ <syscall name="getpeername" number="205" groups="network"/>
+ <syscall name="sendto" number="206" groups="network"/>
+ <syscall name="recvfrom" number="207" groups="network"/>
+ <syscall name="setsockopt" number="208" groups="network"/>
+ <syscall name="getsockopt" number="209" groups="network"/>
+ <syscall name="shutdown" number="210" groups="network"/>
+ <syscall name="sendmsg" number="211" groups="network"/>
+ <syscall name="recvmsg" number="212" groups="network"/>
+ <syscall name="readahead" number="213" groups="descriptor"/>
+ <syscall name="brk" number="214" groups="memory"/>
+ <syscall name="munmap" number="215" groups="memory"/>
+ <syscall name="mremap" number="216" groups="memory"/>
+ <syscall name="add_key" number="217"/>
+ <syscall name="request_key" number="218"/>
+ <syscall name="keyctl" number="219"/>
+ <syscall name="clone" number="220" groups="process"/>
+ <syscall name="execve" number="221" groups="file,process"/>
+ <syscall name="mmap" number="222" groups="descriptor,memory"/>
+ <syscall name="fadvise64" number="223" groups="descriptor"/>
+ <syscall name="swapon" number="224" groups="file"/>
+ <syscall name="swapoff" number="225" groups="file"/>
+ <syscall name="mprotect" number="226" groups="memory"/>
+ <syscall name="msync" number="227" groups="memory"/>
+ <syscall name="mlock" number="228" groups="memory"/>
+ <syscall name="munlock" number="229" groups="memory"/>
+ <syscall name="mlockall" number="230" groups="memory"/>
+ <syscall name="munlockall" number="231" groups="memory"/>
+ <syscall name="mincore" number="232" groups="memory"/>
+ <syscall name="madvise" number="233" groups="memory"/>
+ <syscall name="remap_file_pages" number="234" groups="memory"/>
+ <syscall name="mbind" number="235" groups="memory"/>
+ <syscall name="get_mempolicy" number="236" groups="memory"/>
+ <syscall name="set_mempolicy" number="237" groups="memory"/>
+ <syscall name="migrate_pages" number="238" groups="memory"/>
+ <syscall name="move_pages" number="239" groups="memory"/>
+ <syscall name="rt_tgsigqueueinfo" number="240" groups="process,signal"/>
+ <syscall name="perf_event_open" number="241" groups="descriptor"/>
+ <syscall name="accept4" number="242" groups="network"/>
+ <syscall name="recvmmsg" number="243" groups="network"/>
+ <syscall name="riscv_hwprobe" number="258"/>
+ <syscall name="riscv_flush_icache" number="259" groups="memory"/>
+ <syscall name="wait4" number="260" groups="process"/>
+ <syscall name="prlimit64" number="261"/>
+ <syscall name="fanotify_init" number="262" groups="descriptor"/>
+ <syscall name="fanotify_mark" number="263" groups="descriptor,file"/>
+ <syscall name="name_to_handle_at" number="264" groups="descriptor,file"/>
+ <syscall name="open_by_handle_at" number="265" groups="descriptor"/>
+ <syscall name="clock_adjtime" number="266"/>
+ <syscall name="syncfs" number="267" groups="descriptor"/>
+ <syscall name="setns" number="268" groups="descriptor"/>
+ <syscall name="sendmmsg" number="269" groups="network"/>
+ <syscall name="process_vm_readv" number="270"/>
+ <syscall name="process_vm_writev" number="271"/>
+ <syscall name="kcmp" number="272"/>
+ <syscall name="finit_module" number="273" groups="descriptor"/>
+ <syscall name="sched_setattr" number="274"/>
+ <syscall name="sched_getattr" number="275"/>
+ <syscall name="renameat2" number="276" groups="descriptor,file"/>
+ <syscall name="seccomp" number="277"/>
+ <syscall name="getrandom" number="278"/>
+ <syscall name="memfd_create" number="279" groups="descriptor"/>
+ <syscall name="bpf" number="280" groups="descriptor"/>
+ <syscall name="execveat" number="281" groups="descriptor,file,process"/>
+ <syscall name="userfaultfd" number="282" groups="descriptor"/>
+ <syscall name="membarrier" number="283"/>
+ <syscall name="mlock2" number="284" groups="memory"/>
+ <syscall name="copy_file_range" number="285" groups="descriptor"/>
+ <syscall name="preadv2" number="286" groups="descriptor"/>
+ <syscall name="pwritev2" number="287" groups="descriptor"/>
+ <syscall name="pkey_mprotect" number="288" groups="memory"/>
+ <syscall name="pkey_alloc" number="289"/>
+ <syscall name="pkey_free" number="290"/>
+ <syscall name="statx" number="291" groups="descriptor,file"/>
+ <syscall name="io_pgetevents" number="292"/>
+ <syscall name="rseq" number="293"/>
+ <syscall name="kexec_file_load" number="294" groups="descriptor"/>
+ <syscall name="pidfd_send_signal" number="424" groups="descriptor,signal,process"/>
+ <syscall name="io_uring_setup" number="425" groups="descriptor"/>
+ <syscall name="io_uring_enter" number="426" groups="descriptor,signal"/>
+ <syscall name="io_uring_register" number="427" groups="descriptor,memory"/>
+ <syscall name="open_tree" number="428" groups="descriptor,file"/>
+ <syscall name="move_mount" number="429" groups="descriptor,file"/>
+ <syscall name="fsopen" number="430" groups="descriptor"/>
+ <syscall name="fsconfig" number="431" groups="descriptor,file"/>
+ <syscall name="fsmount" number="432" groups="descriptor"/>
+ <syscall name="fspick" number="433" groups="descriptor,file"/>
+ <syscall name="pidfd_open" number="434" groups="descriptor"/>
+ <syscall name="clone3" number="435" groups="process"/>
+ <syscall name="close_range" number="436"/>
+ <syscall name="openat2" number="437" groups="descriptor,file"/>
+ <syscall name="pidfd_getfd" number="438" groups="descriptor"/>
+ <syscall name="faccessat2" number="439" groups="descriptor,file"/>
+ <syscall name="process_madvise" number="440" groups="descriptor"/>
+ <syscall name="epoll_pwait2" number="441" groups="descriptor"/>
+ <syscall name="mount_setattr" number="442" groups="descriptor,file"/>
+ <syscall name="quotactl_fd" number="443" groups="descriptor"/>
+ <syscall name="landlock_create_ruleset" number="444" groups="descriptor"/>
+ <syscall name="landlock_add_rule" number="445" groups="descriptor"/>
+ <syscall name="landlock_restrict_self" number="446" groups="descriptor"/>
+ <syscall name="memfd_secret" number="447" groups="descriptor"/>
+ <syscall name="process_mrelease" number="448" groups="descriptor"/>
+ <syscall name="futex_waitv" number="449"/>
+ <syscall name="set_mempolicy_home_node" number="450" groups="memory"/>
+ <syscall name="cachestat" number="451" groups="descriptor"/>
+ <syscall name="fchmodat2" number="452" groups="descriptor,file"/>
+ <syscall name="map_shadow_stack" number="453" groups="memory"/>
+ <syscall name="futex_wake" number="454"/>
+ <syscall name="futex_wait" number="455"/>
+ <syscall name="futex_requeue" number="456"/>
+ <syscall name="statmount" number="457"/>
+ <syscall name="listmount" number="458"/>
+ <syscall name="lsm_get_self_attr" number="459"/>
+ <syscall name="lsm_set_self_attr" number="460"/>
+ <syscall name="lsm_list_modules" number="461"/>
+ <syscall name="mseal" number="462" groups="memory"/>
+ <syscall name="setxattrat" number="463" groups="descriptor,file"/>
+ <syscall name="getxattrat" number="464" groups="descriptor,file"/>
+ <syscall name="listxattrat" number="465" groups="descriptor,file"/>
+ <syscall name="removexattrat" number="466" groups="descriptor,file"/>
+ <syscall name="open_tree_attr" number="467" groups="descriptor,file"/>
+ <syscall name="file_getattr" number="468" groups="descriptor,file"/>
+ <syscall name="file_setattr" number="469" groups="descriptor,file"/>
+</syscalls_info>
diff --git a/gdb/syscalls/riscv-linux.xml.in b/gdb/syscalls/riscv-linux.xml.in
new file mode 100644
index 0000000..17b2b0a
--- /dev/null
+++ b/gdb/syscalls/riscv-linux.xml.in
@@ -0,0 +1,344 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2025 Free Software Foundation, Inc.
+
+ Copying and distribution of this file, with or without modification,
+ are permitted in any medium without royalty provided the copyright
+ notice and this notice are preserved. -->
+
+<!DOCTYPE feature SYSTEM "gdb-syscalls.dtd">
+
+<!-- This file was generated using the following file:
+
+ <sys/syscall.h>
+
+ The file mentioned above belongs to the Linux Kernel. -->
+
+
+<syscalls_info>
+ <syscall name="io_setup" number="0"/>
+ <syscall name="io_destroy" number="1"/>
+ <syscall name="io_submit" number="2"/>
+ <syscall name="io_cancel" number="3"/>
+ <syscall name="io_getevents" number="4"/>
+ <syscall name="setxattr" number="5"/>
+ <syscall name="lsetxattr" number="6"/>
+ <syscall name="fsetxattr" number="7"/>
+ <syscall name="getxattr" number="8"/>
+ <syscall name="lgetxattr" number="9"/>
+ <syscall name="fgetxattr" number="10"/>
+ <syscall name="listxattr" number="11"/>
+ <syscall name="llistxattr" number="12"/>
+ <syscall name="flistxattr" number="13"/>
+ <syscall name="removexattr" number="14"/>
+ <syscall name="lremovexattr" number="15"/>
+ <syscall name="fremovexattr" number="16"/>
+ <syscall name="getcwd" number="17"/>
+ <syscall name="lookup_dcookie" number="18"/>
+ <syscall name="eventfd2" number="19"/>
+ <syscall name="epoll_create1" number="20"/>
+ <syscall name="epoll_ctl" number="21"/>
+ <syscall name="epoll_pwait" number="22"/>
+ <syscall name="dup" number="23"/>
+ <syscall name="dup3" number="24"/>
+ <syscall name="fcntl" number="25"/>
+ <syscall name="inotify_init1" number="26"/>
+ <syscall name="inotify_add_watch" number="27"/>
+ <syscall name="inotify_rm_watch" number="28"/>
+ <syscall name="ioctl" number="29"/>
+ <syscall name="ioprio_set" number="30"/>
+ <syscall name="ioprio_get" number="31"/>
+ <syscall name="flock" number="32"/>
+ <syscall name="mknodat" number="33"/>
+ <syscall name="mkdirat" number="34"/>
+ <syscall name="unlinkat" number="35"/>
+ <syscall name="symlinkat" number="36"/>
+ <syscall name="linkat" number="37"/>
+ <syscall name="umount2" number="39"/>
+ <syscall name="mount" number="40"/>
+ <syscall name="pivot_root" number="41"/>
+ <syscall name="nfsservctl" number="42"/>
+ <syscall name="statfs" number="43"/>
+ <syscall name="fstatfs" number="44"/>
+ <syscall name="truncate" number="45"/>
+ <syscall name="ftruncate" number="46"/>
+ <syscall name="fallocate" number="47"/>
+ <syscall name="faccessat" number="48"/>
+ <syscall name="chdir" number="49"/>
+ <syscall name="fchdir" number="50"/>
+ <syscall name="chroot" number="51"/>
+ <syscall name="fchmod" number="52"/>
+ <syscall name="fchmodat" number="53"/>
+ <syscall name="fchownat" number="54"/>
+ <syscall name="fchown" number="55"/>
+ <syscall name="openat" number="56"/>
+ <syscall name="close" number="57"/>
+ <syscall name="vhangup" number="58"/>
+ <syscall name="pipe2" number="59"/>
+ <syscall name="quotactl" number="60"/>
+ <syscall name="getdents64" number="61"/>
+ <syscall name="lseek" number="62"/>
+ <syscall name="read" number="63"/>
+ <syscall name="write" number="64"/>
+ <syscall name="readv" number="65"/>
+ <syscall name="writev" number="66"/>
+ <syscall name="pread64" number="67"/>
+ <syscall name="pwrite64" number="68"/>
+ <syscall name="preadv" number="69"/>
+ <syscall name="pwritev" number="70"/>
+ <syscall name="sendfile" number="71"/>
+ <syscall name="pselect6" number="72"/>
+ <syscall name="ppoll" number="73"/>
+ <syscall name="signalfd4" number="74"/>
+ <syscall name="vmsplice" number="75"/>
+ <syscall name="splice" number="76"/>
+ <syscall name="tee" number="77"/>
+ <syscall name="readlinkat" number="78"/>
+ <syscall name="newfstatat" number="79"/>
+ <syscall name="fstat" number="80"/>
+ <syscall name="sync" number="81"/>
+ <syscall name="fsync" number="82"/>
+ <syscall name="fdatasync" number="83"/>
+ <syscall name="sync_file_range" number="84"/>
+ <syscall name="timerfd_create" number="85"/>
+ <syscall name="timerfd_settime" number="86"/>
+ <syscall name="timerfd_gettime" number="87"/>
+ <syscall name="utimensat" number="88"/>
+ <syscall name="acct" number="89"/>
+ <syscall name="capget" number="90"/>
+ <syscall name="capset" number="91"/>
+ <syscall name="personality" number="92"/>
+ <syscall name="exit" number="93"/>
+ <syscall name="exit_group" number="94"/>
+ <syscall name="waitid" number="95"/>
+ <syscall name="set_tid_address" number="96"/>
+ <syscall name="unshare" number="97"/>
+ <syscall name="futex" number="98"/>
+ <syscall name="set_robust_list" number="99"/>
+ <syscall name="get_robust_list" number="100"/>
+ <syscall name="nanosleep" number="101"/>
+ <syscall name="getitimer" number="102"/>
+ <syscall name="setitimer" number="103"/>
+ <syscall name="kexec_load" number="104"/>
+ <syscall name="init_module" number="105"/>
+ <syscall name="delete_module" number="106"/>
+ <syscall name="timer_create" number="107"/>
+ <syscall name="timer_gettime" number="108"/>
+ <syscall name="timer_getoverrun" number="109"/>
+ <syscall name="timer_settime" number="110"/>
+ <syscall name="timer_delete" number="111"/>
+ <syscall name="clock_settime" number="112"/>
+ <syscall name="clock_gettime" number="113"/>
+ <syscall name="clock_getres" number="114"/>
+ <syscall name="clock_nanosleep" number="115"/>
+ <syscall name="syslog" number="116"/>
+ <syscall name="ptrace" number="117"/>
+ <syscall name="sched_setparam" number="118"/>
+ <syscall name="sched_setscheduler" number="119"/>
+ <syscall name="sched_getscheduler" number="120"/>
+ <syscall name="sched_getparam" number="121"/>
+ <syscall name="sched_setaffinity" number="122"/>
+ <syscall name="sched_getaffinity" number="123"/>
+ <syscall name="sched_yield" number="124"/>
+ <syscall name="sched_get_priority_max" number="125"/>
+ <syscall name="sched_get_priority_min" number="126"/>
+ <syscall name="sched_rr_get_interval" number="127"/>
+ <syscall name="restart_syscall" number="128"/>
+ <syscall name="kill" number="129"/>
+ <syscall name="tkill" number="130"/>
+ <syscall name="tgkill" number="131"/>
+ <syscall name="sigaltstack" number="132"/>
+ <syscall name="rt_sigsuspend" number="133"/>
+ <syscall name="rt_sigaction" number="134"/>
+ <syscall name="rt_sigprocmask" number="135"/>
+ <syscall name="rt_sigpending" number="136"/>
+ <syscall name="rt_sigtimedwait" number="137"/>
+ <syscall name="rt_sigqueueinfo" number="138"/>
+ <syscall name="rt_sigreturn" number="139"/>
+ <syscall name="setpriority" number="140"/>
+ <syscall name="getpriority" number="141"/>
+ <syscall name="reboot" number="142"/>
+ <syscall name="setregid" number="143"/>
+ <syscall name="setgid" number="144"/>
+ <syscall name="setreuid" number="145"/>
+ <syscall name="setuid" number="146"/>
+ <syscall name="setresuid" number="147"/>
+ <syscall name="getresuid" number="148"/>
+ <syscall name="setresgid" number="149"/>
+ <syscall name="getresgid" number="150"/>
+ <syscall name="setfsuid" number="151"/>
+ <syscall name="setfsgid" number="152"/>
+ <syscall name="times" number="153"/>
+ <syscall name="setpgid" number="154"/>
+ <syscall name="getpgid" number="155"/>
+ <syscall name="getsid" number="156"/>
+ <syscall name="setsid" number="157"/>
+ <syscall name="getgroups" number="158"/>
+ <syscall name="setgroups" number="159"/>
+ <syscall name="uname" number="160"/>
+ <syscall name="sethostname" number="161"/>
+ <syscall name="setdomainname" number="162"/>
+ <syscall name="getrlimit" number="163"/>
+ <syscall name="setrlimit" number="164"/>
+ <syscall name="getrusage" number="165"/>
+ <syscall name="umask" number="166"/>
+ <syscall name="prctl" number="167"/>
+ <syscall name="getcpu" number="168"/>
+ <syscall name="gettimeofday" number="169"/>
+ <syscall name="settimeofday" number="170"/>
+ <syscall name="adjtimex" number="171"/>
+ <syscall name="getpid" number="172"/>
+ <syscall name="getppid" number="173"/>
+ <syscall name="getuid" number="174"/>
+ <syscall name="geteuid" number="175"/>
+ <syscall name="getgid" number="176"/>
+ <syscall name="getegid" number="177"/>
+ <syscall name="gettid" number="178"/>
+ <syscall name="sysinfo" number="179"/>
+ <syscall name="mq_open" number="180"/>
+ <syscall name="mq_unlink" number="181"/>
+ <syscall name="mq_timedsend" number="182"/>
+ <syscall name="mq_timedreceive" number="183"/>
+ <syscall name="mq_notify" number="184"/>
+ <syscall name="mq_getsetattr" number="185"/>
+ <syscall name="msgget" number="186"/>
+ <syscall name="msgctl" number="187"/>
+ <syscall name="msgrcv" number="188"/>
+ <syscall name="msgsnd" number="189"/>
+ <syscall name="semget" number="190"/>
+ <syscall name="semctl" number="191"/>
+ <syscall name="semtimedop" number="192"/>
+ <syscall name="semop" number="193"/>
+ <syscall name="shmget" number="194"/>
+ <syscall name="shmctl" number="195"/>
+ <syscall name="shmat" number="196"/>
+ <syscall name="shmdt" number="197"/>
+ <syscall name="socket" number="198"/>
+ <syscall name="socketpair" number="199"/>
+ <syscall name="bind" number="200"/>
+ <syscall name="listen" number="201"/>
+ <syscall name="accept" number="202"/>
+ <syscall name="connect" number="203"/>
+ <syscall name="getsockname" number="204"/>
+ <syscall name="getpeername" number="205"/>
+ <syscall name="sendto" number="206"/>
+ <syscall name="recvfrom" number="207"/>
+ <syscall name="setsockopt" number="208"/>
+ <syscall name="getsockopt" number="209"/>
+ <syscall name="shutdown" number="210"/>
+ <syscall name="sendmsg" number="211"/>
+ <syscall name="recvmsg" number="212"/>
+ <syscall name="readahead" number="213"/>
+ <syscall name="brk" number="214"/>
+ <syscall name="munmap" number="215"/>
+ <syscall name="mremap" number="216"/>
+ <syscall name="add_key" number="217"/>
+ <syscall name="request_key" number="218"/>
+ <syscall name="keyctl" number="219"/>
+ <syscall name="clone" number="220"/>
+ <syscall name="execve" number="221"/>
+ <syscall name="mmap" number="222"/>
+ <syscall name="fadvise64" number="223"/>
+ <syscall name="swapon" number="224"/>
+ <syscall name="swapoff" number="225"/>
+ <syscall name="mprotect" number="226"/>
+ <syscall name="msync" number="227"/>
+ <syscall name="mlock" number="228"/>
+ <syscall name="munlock" number="229"/>
+ <syscall name="mlockall" number="230"/>
+ <syscall name="munlockall" number="231"/>
+ <syscall name="mincore" number="232"/>
+ <syscall name="madvise" number="233"/>
+ <syscall name="remap_file_pages" number="234"/>
+ <syscall name="mbind" number="235"/>
+ <syscall name="get_mempolicy" number="236"/>
+ <syscall name="set_mempolicy" number="237"/>
+ <syscall name="migrate_pages" number="238"/>
+ <syscall name="move_pages" number="239"/>
+ <syscall name="rt_tgsigqueueinfo" number="240"/>
+ <syscall name="perf_event_open" number="241"/>
+ <syscall name="accept4" number="242"/>
+ <syscall name="recvmmsg" number="243"/>
+ <syscall name="riscv_hwprobe" number="258"/>
+ <syscall name="riscv_flush_icache" number="259"/>
+ <syscall name="wait4" number="260"/>
+ <syscall name="prlimit64" number="261"/>
+ <syscall name="fanotify_init" number="262"/>
+ <syscall name="fanotify_mark" number="263"/>
+ <syscall name="name_to_handle_at" number="264"/>
+ <syscall name="open_by_handle_at" number="265"/>
+ <syscall name="clock_adjtime" number="266"/>
+ <syscall name="syncfs" number="267"/>
+ <syscall name="setns" number="268"/>
+ <syscall name="sendmmsg" number="269"/>
+ <syscall name="process_vm_readv" number="270"/>
+ <syscall name="process_vm_writev" number="271"/>
+ <syscall name="kcmp" number="272"/>
+ <syscall name="finit_module" number="273"/>
+ <syscall name="sched_setattr" number="274"/>
+ <syscall name="sched_getattr" number="275"/>
+ <syscall name="renameat2" number="276"/>
+ <syscall name="seccomp" number="277"/>
+ <syscall name="getrandom" number="278"/>
+ <syscall name="memfd_create" number="279"/>
+ <syscall name="bpf" number="280"/>
+ <syscall name="execveat" number="281"/>
+ <syscall name="userfaultfd" number="282"/>
+ <syscall name="membarrier" number="283"/>
+ <syscall name="mlock2" number="284"/>
+ <syscall name="copy_file_range" number="285"/>
+ <syscall name="preadv2" number="286"/>
+ <syscall name="pwritev2" number="287"/>
+ <syscall name="pkey_mprotect" number="288"/>
+ <syscall name="pkey_alloc" number="289"/>
+ <syscall name="pkey_free" number="290"/>
+ <syscall name="statx" number="291"/>
+ <syscall name="io_pgetevents" number="292"/>
+ <syscall name="rseq" number="293"/>
+ <syscall name="kexec_file_load" number="294"/>
+ <syscall name="pidfd_send_signal" number="424"/>
+ <syscall name="io_uring_setup" number="425"/>
+ <syscall name="io_uring_enter" number="426"/>
+ <syscall name="io_uring_register" number="427"/>
+ <syscall name="open_tree" number="428"/>
+ <syscall name="move_mount" number="429"/>
+ <syscall name="fsopen" number="430"/>
+ <syscall name="fsconfig" number="431"/>
+ <syscall name="fsmount" number="432"/>
+ <syscall name="fspick" number="433"/>
+ <syscall name="pidfd_open" number="434"/>
+ <syscall name="clone3" number="435"/>
+ <syscall name="close_range" number="436"/>
+ <syscall name="openat2" number="437"/>
+ <syscall name="pidfd_getfd" number="438"/>
+ <syscall name="faccessat2" number="439"/>
+ <syscall name="process_madvise" number="440"/>
+ <syscall name="epoll_pwait2" number="441"/>
+ <syscall name="mount_setattr" number="442"/>
+ <syscall name="quotactl_fd" number="443"/>
+ <syscall name="landlock_create_ruleset" number="444"/>
+ <syscall name="landlock_add_rule" number="445"/>
+ <syscall name="landlock_restrict_self" number="446"/>
+ <syscall name="memfd_secret" number="447"/>
+ <syscall name="process_mrelease" number="448"/>
+ <syscall name="futex_waitv" number="449"/>
+ <syscall name="set_mempolicy_home_node" number="450"/>
+ <syscall name="cachestat" number="451"/>
+ <syscall name="fchmodat2" number="452"/>
+ <syscall name="map_shadow_stack" number="453"/>
+ <syscall name="futex_wake" number="454"/>
+ <syscall name="futex_wait" number="455"/>
+ <syscall name="futex_requeue" number="456"/>
+ <syscall name="statmount" number="457"/>
+ <syscall name="listmount" number="458"/>
+ <syscall name="lsm_get_self_attr" number="459"/>
+ <syscall name="lsm_set_self_attr" number="460"/>
+ <syscall name="lsm_list_modules" number="461"/>
+ <syscall name="mseal" number="462"/>
+ <syscall name="setxattrat" number="463"/>
+ <syscall name="getxattrat" number="464"/>
+ <syscall name="listxattrat" number="465"/>
+ <syscall name="removexattrat" number="466"/>
+ <syscall name="open_tree_attr" number="467"/>
+ <syscall name="file_getattr" number="468"/>
+ <syscall name="file_setattr" number="469"/>
+</syscalls_info>
diff --git a/gdb/syscalls/update-linux-from-src.sh b/gdb/syscalls/update-linux-from-src.sh
index ea06c13..26c38f6 100755
--- a/gdb/syscalls/update-linux-from-src.sh
+++ b/gdb/syscalls/update-linux-from-src.sh
@@ -325,6 +325,11 @@ regen ()
gen_from_kernel_headers "$f" arm64
return
;;
+ riscv-linux.xml.in)
+ # No syscall.tbl.
+ gen_from_kernel_headers "$f" riscv
+ return
+ ;;
arm-linux.xml.in)
t="arch/arm/tools/syscall.tbl"
h="arch/arm/include/uapi/asm/unistd.h"
diff --git a/gdb/syscalls/update-linux.sh b/gdb/syscalls/update-linux.sh
index 107ce05..cbc8a9d 100755
--- a/gdb/syscalls/update-linux.sh
+++ b/gdb/syscalls/update-linux.sh
@@ -40,6 +40,9 @@ case "$f" in
*aarch64-linux.xml.in)
startyear=2015
;;
+ *riscv-linux.xml.in)
+ startyear=2025
+ ;;
esac
year=$(date +%Y)
diff --git a/gdb/tclint.toml b/gdb/tclint.toml
new file mode 100644
index 0000000..47c3ce4
--- /dev/null
+++ b/gdb/tclint.toml
@@ -0,0 +1,55 @@
+# Copyright 2025 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/>.
+
+# Configuration file for tclint ( https://github.com/nmoroze/tclint ).
+
+exclude = [
+# TODO:
+"gdb/testsuite/boards",
+"gdb/testsuite/config",
+"gdb/testsuite/lib",
+"gdb/testsuite/gdb.arch",
+"gdb/testsuite/gdb.base",
+"gdb/testsuite/gdb.cp",
+"gdb/testsuite/gdb.dwarf2",
+"gdb/testsuite/gdb.mi",
+"gdb/testsuite/gdb.trace",
+# IGNORE (document reason in trailing comment):
+"gdb/testsuite/gdb.stabs", # To be removed.
+]
+
+# A maximum line length of 80 is current policy, but it hasn't been too
+# strictly enforced. It's the most frequent and least harmful violation.
+# Ignore this for now.
+ignore = ["line-length"]
+
+extensions = ["exp", "tcl"]
+
+[style]
+# Used by tclfmt. Doesn't support the mixed TAB and spaces style we use. See
+# this tclint issue ( https://github.com/nmoroze/tclint/issues/109 ).
+indent = 4
+
+# Used by both tclint and tclfmt. Current policy is 80.
+line-length = 80
+
+# Used by tclfmt.
+max-blank-lines = 1
+
+# Used by tclfmt. False conflicts with emacs tcl mode.
+indent-namespace-eval = true
+
+# Used by tclfmt.
+spaces-in-braces = false
diff --git a/gdb/terminal.h b/gdb/terminal.h
index 720fd4a..87a1aee 100644
--- a/gdb/terminal.h
+++ b/gdb/terminal.h
@@ -58,4 +58,10 @@ public:
private:
serial_ttystate m_ttystate;
};
+
+#ifdef USE_WIN32API
+/* Set translation mode of stdout/stderr to binary. */
+extern void set_output_translation_mode_binary ();
+#endif
+
#endif /* GDB_TERMINAL_H */
diff --git a/gdb/testsuite/boards/native-extended-gdbserver.exp b/gdb/testsuite/boards/native-extended-gdbserver.exp
index 3299e31..22d8782 100644
--- a/gdb/testsuite/boards/native-extended-gdbserver.exp
+++ b/gdb/testsuite/boards/native-extended-gdbserver.exp
@@ -58,7 +58,7 @@ proc mi_gdb_start { args } {
global gdbserver_reconnect_p
# Spawn GDB.
- set res [eval extended_gdbserver_mi_gdb_start $args]
+ set res [extended_gdbserver_mi_gdb_start {*}$args]
if { $res } {
return $res
}
diff --git a/gdb/testsuite/gdb.ada/array_bounds.exp b/gdb/testsuite/gdb.ada/array_bounds.exp
index 3675c9f..ab50da7 100644
--- a/gdb/testsuite/gdb.ada/array_bounds.exp
+++ b/gdb/testsuite/gdb.ada/array_bounds.exp
@@ -28,7 +28,7 @@ clean_restart ${testfile}
set bp_location [gdb_get_line_number "START" ${testdir}/bar.adb]
if {![runto "bar.adb:$bp_location"]} {
return
-}
+}
gdb_test "print itable'first" \
"= 2"
diff --git a/gdb/testsuite/gdb.ada/array_long_idx.exp b/gdb/testsuite/gdb.ada/array_long_idx.exp
new file mode 100644
index 0000000..13a4d3d
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/array_long_idx.exp
@@ -0,0 +1,36 @@
+# Copyright 2025 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 that long array index types work.
+
+load_lib "ada.exp"
+
+require allow_ada_tests
+
+standard_ada_testfile main
+
+if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} {
+ return
+}
+
+clean_restart ${testfile}
+
+set bp_location [gdb_get_line_number STOP ${testdir}/main.adb]
+if {![runto "main.adb:$bp_location"]} {
+ return
+}
+
+gdb_test "print some_regular_access.all" \
+ [string_to_regexp " = (-2147483648 => (-9223372036854775808 => 1, 2, 3), (-9223372036854775808 => 4, 5, 6))"]
diff --git a/gdb/testsuite/gdb.ada/array_long_idx/main.adb b/gdb/testsuite/gdb.ada/array_long_idx/main.adb
new file mode 100644
index 0000000..6c4971f
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/array_long_idx/main.adb
@@ -0,0 +1,31 @@
+-- Copyright 2025 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 Pck; use Pck;
+
+procedure Main is
+
+ type Shorter_Integer is range -2147483648 .. 2147483647;
+ type Longer_Integer is range -9223372036854775808 .. 9223372036854775807;
+ type My_Array is array (Shorter_Integer range <>,
+ Longer_Integer range <>) of Integer;
+
+ type My_Reg_Acc is access all My_Array;
+
+ Some_Regular_Access : My_Reg_Acc := new My_Array'((1, 2, 3), (4, 5, 6));
+
+begin
+ Do_Nothing (Some_Regular_Access'Address); -- STOP
+end Main;
diff --git a/gdb/testsuite/gdb.ada/array_long_idx/pck.adb b/gdb/testsuite/gdb.ada/array_long_idx/pck.adb
new file mode 100644
index 0000000..54ddf5c
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/array_long_idx/pck.adb
@@ -0,0 +1,21 @@
+-- Copyright 2012-2025 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/>.
+
+package body Pck is
+ procedure Do_Nothing (A : System.Address) is
+ begin
+ null;
+ end Do_Nothing;
+end Pck;
diff --git a/gdb/testsuite/gdb.ada/array_long_idx/pck.ads b/gdb/testsuite/gdb.ada/array_long_idx/pck.ads
new file mode 100644
index 0000000..db7c0a8
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/array_long_idx/pck.ads
@@ -0,0 +1,19 @@
+-- Copyright 2012-2025 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 System;
+package Pck is
+ procedure Do_Nothing (A : System.Address);
+end Pck;
diff --git a/gdb/testsuite/gdb.ada/array_of_variant.exp b/gdb/testsuite/gdb.ada/array_of_variant.exp
index 7b35bb0..84239a7 100644
--- a/gdb/testsuite/gdb.ada/array_of_variant.exp
+++ b/gdb/testsuite/gdb.ada/array_of_variant.exp
@@ -24,7 +24,7 @@ set old_gcc [gnat_version_compare < 8]
proc gdb_test_with_xfail { cmd re re_xfail msg } {
global scenario old_gcc
- set have_xfail [expr $old_gcc && [string equal "$scenario" "minimal"]]
+ set have_xfail [expr {$old_gcc && [string equal "$scenario" "minimal"]}]
gdb_test_multiple $cmd $msg {
-re -wrap $re {
diff --git a/gdb/testsuite/gdb.ada/arrayidx.exp b/gdb/testsuite/gdb.ada/arrayidx.exp
index 9481d28..b29a2a7 100644
--- a/gdb/testsuite/gdb.ada/arrayidx.exp
+++ b/gdb/testsuite/gdb.ada/arrayidx.exp
@@ -34,7 +34,7 @@ runto "p.adb:$bp_location"
gdb_test_no_output "set print array-indexes off"
-if $old_gcc {
+if {$old_gcc} {
setup_xfail "*-*-*"
}
gdb_test "print one_two_three" \
@@ -57,21 +57,21 @@ gdb_test "print p_one_two_three" \
"= \\(false, true, true\\)" \
"print p_one_two_three, indexes off"
-if $old_gcc {
+if {$old_gcc} {
setup_xfail "*-*-*"
}
gdb_test "print few_reps" \
"= \\(1, 2, 3, 3, 3, 3, 3, 4, 5\\)" \
"print few_reps, indexes off"
-if $old_gcc {
+if {$old_gcc} {
setup_xfail "*-*-*"
}
gdb_test "print many_reps" \
"= \\(1, 2, 3 <repeats 12 times>, 4, 5\\)" \
"print many_reps, indexes off"
-if $old_gcc {
+if {$old_gcc} {
setup_xfail "*-*-*"
}
gdb_test "print empty" \
@@ -82,7 +82,7 @@ gdb_test "print empty" \
gdb_test_no_output "set print array-indexes on"
-if $old_gcc {
+if {$old_gcc} {
setup_xfail "*-*-*"
}
gdb_test "print one_two_three" \
@@ -100,19 +100,19 @@ gdb_test "print u_one_two_three" \
gdb_test "print p_one_two_three" \
"= \\(one => false, two => true, three => true\\)"
-if $old_gcc {
+if {$old_gcc} {
setup_xfail "*-*-*"
}
gdb_test "print few_reps" \
"= \\(1 => 1, 2 => 2, 3 => 3, 4 => 3, 5 => 3, 6 => 3, 7 => 3, 8 => 4, 9 => 5\\)"
-if $old_gcc {
+if {$old_gcc} {
setup_xfail "*-*-*"
}
gdb_test "print many_reps" \
"= \\(1 => 1, 2 => 2, 3 => 3 <repeats 12 times>, 15 => 4, 16 => 5\\)"
-if $old_gcc {
+if {$old_gcc} {
setup_xfail "*-*-*"
}
gdb_test "print empty" \
diff --git a/gdb/testsuite/gdb.ada/call_pn.exp b/gdb/testsuite/gdb.ada/call_pn.exp
index 7e01523..4d9c26e 100644
--- a/gdb/testsuite/gdb.ada/call_pn.exp
+++ b/gdb/testsuite/gdb.ada/call_pn.exp
@@ -38,7 +38,7 @@ if {![runto "foo.adb:$bp_location"]} {
gdb_test_no_output {maint expand-symtabs "\(pck\|foo\)\.adb"}
set gcc_major_version [gcc_major_version]
-set have_xfail [expr $gcc_major_version >= 8 && $gcc_major_version <= 9]
+set have_xfail [expr {$gcc_major_version >= 8 && $gcc_major_version <= 9}]
# The xfail is for PR gcc/94469, which occurs with target board
# unix/-flto/-O0/-flto-partition=none/-ffat-lto-objects and gcc-8 and later.
diff --git a/gdb/testsuite/gdb.ada/complete.exp b/gdb/testsuite/gdb.ada/complete.exp
index c8fcc47..18548c7 100644
--- a/gdb/testsuite/gdb.ada/complete.exp
+++ b/gdb/testsuite/gdb.ada/complete.exp
@@ -164,7 +164,7 @@ test_gdb_complete "external_ident" \
[multi_line "p external_identical_one" \
"p external_identical_two" ]
-# Complete on the name of package.
+# Complete on the name of package.
test_gdb_complete "pck" \
[multi_line_with_optional \
"(p pck)?" \
diff --git a/gdb/testsuite/gdb.ada/exec_changed.exp b/gdb/testsuite/gdb.ada/exec_changed.exp
index c52757e..31add11 100644
--- a/gdb/testsuite/gdb.ada/exec_changed.exp
+++ b/gdb/testsuite/gdb.ada/exec_changed.exp
@@ -84,7 +84,7 @@ if { [gdb_start_cmd] < 0 } {
# Try again, this time with just changing the file time of first.
-clean_restart "${binfile}$EXEEXT"
+clean_restart "${::testfile}$EXEEXT"
# Ensure we don't accidentally use the main symbol cache.
gdb_test_no_output "mt set symbol-cache-size 0"
diff --git a/gdb/testsuite/gdb.ada/extended-access.c b/gdb/testsuite/gdb.ada/extended-access.c
new file mode 100644
index 0000000..9a1b299
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/extended-access.c
@@ -0,0 +1,38 @@
+/* This test program is part of GDB, the GNU debugger.
+
+ Copyright 2025 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 array_data[] = { 23, 24, 25, 26, 27 };
+
+struct bounds
+{
+ int LB0;
+ int UB0;
+};
+
+struct extended_access_ptr
+{
+ int (*P_ARRAY)[];
+ struct bounds BOUNDS;
+};
+
+struct extended_access_ptr the_array = { &array_data, { 93, 97 } };
+
+int
+main (void)
+{
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.ada/extended-access.exp b/gdb/testsuite/gdb.ada/extended-access.exp
new file mode 100644
index 0000000..7c02ad7
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/extended-access.exp
@@ -0,0 +1,29 @@
+# Copyright 2025 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/>.
+
+require allow_ada_tests
+
+standard_testfile
+
+if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile}]} {
+ return
+}
+
+# The test case is written in C, because it was easy to make the
+# required type there without requiring a new version of GNAT.
+gdb_test_no_output "set lang ada"
+
+gdb_test "print the_array.all" \
+ [string_to_regexp " = (93 => 23, 24, 25, 26, 27)"]
diff --git a/gdb/testsuite/gdb.ada/file-then-restart.exp b/gdb/testsuite/gdb.ada/file-then-restart.exp
index faa9962..6e8e058 100644
--- a/gdb/testsuite/gdb.ada/file-then-restart.exp
+++ b/gdb/testsuite/gdb.ada/file-then-restart.exp
@@ -36,7 +36,7 @@ if {[gdb_compile_ada "${srcfile2}" "${binfile2}" executable {debug}] != ""} {
}
foreach_with_prefix scenario {kill no-kill} {
- clean_restart $binfile
+ clean_restart $::testfile
# Start the program, we should land in the program main procedure
if {[gdb_start_cmd] < 0} {
diff --git a/gdb/testsuite/gdb.ada/finish-var-size.exp b/gdb/testsuite/gdb.ada/finish-var-size.exp
index ae30086..6365c95 100644
--- a/gdb/testsuite/gdb.ada/finish-var-size.exp
+++ b/gdb/testsuite/gdb.ada/finish-var-size.exp
@@ -24,7 +24,7 @@ standard_ada_testfile p
set opts {}
lappend opts debug
-if { [have_fvar_tracking] } {
+if { [ada_fvar_tracking] } {
lappend opts additional_flags=-fvar-tracking
}
diff --git a/gdb/testsuite/gdb.ada/formatted_ref.exp b/gdb/testsuite/gdb.ada/formatted_ref.exp
index c63f847..d473554 100644
--- a/gdb/testsuite/gdb.ada/formatted_ref.exp
+++ b/gdb/testsuite/gdb.ada/formatted_ref.exp
@@ -16,8 +16,8 @@
# Author: P. N. Hilfinger, AdaCore Inc.
# Note: This test is essentially a transcription of gdb.cp/formatted-ref.exp,
-# and is thus much more wordy than it needs to be. There are fewer
-# tests because only a few parameter types in Ada are required to be
+# and is thus much more wordy than it needs to be. There are fewer
+# tests because only a few parameter types in Ada are required to be
# passed by reference, and there is no equivalent of &(&x) for reference
# values.
# This also tests that some other arithmetic operations on references
@@ -54,7 +54,7 @@ proc test_p_x { var val addr } {
gdb_test_multiple "$test" $test {
-re "\\$\[0-9\]+ = [string_to_regexp $val].*$gdb_prompt $" {
pass $test
- }
+ }
-re "\\$\[0-9\]+ = $addr.*$gdb_prompt $" {
fail "$test (prints just address)"
}
diff --git a/gdb/testsuite/gdb.ada/frame_args.exp b/gdb/testsuite/gdb.ada/frame_args.exp
index 4ffc3d1..e6cf868 100644
--- a/gdb/testsuite/gdb.ada/frame_args.exp
+++ b/gdb/testsuite/gdb.ada/frame_args.exp
@@ -32,7 +32,7 @@ set sp "\[ \t\]*"
if {![runto break_me]} {
return
-}
+}
# First, print all the arrays without indexes
diff --git a/gdb/testsuite/gdb.ada/fun_in_declare.exp b/gdb/testsuite/gdb.ada/fun_in_declare.exp
index 9ababcf..a5f6f63 100644
--- a/gdb/testsuite/gdb.ada/fun_in_declare.exp
+++ b/gdb/testsuite/gdb.ada/fun_in_declare.exp
@@ -27,7 +27,7 @@ clean_restart ${testfile}
if {![runto_main]} {
return
-}
+}
# Some variables used to simplify the maintenance of some of
# the regular expressions below.
diff --git a/gdb/testsuite/gdb.ada/huge.exp b/gdb/testsuite/gdb.ada/huge.exp
index 9a86804..fa94fa0 100644
--- a/gdb/testsuite/gdb.ada/huge.exp
+++ b/gdb/testsuite/gdb.ada/huge.exp
@@ -34,7 +34,7 @@ set opts {}
lappend opts debug
set compilation_succeeded 0
-for { set size $max } { $size >= $min } { set size [expr $size / 2] } {
+for { set size $max } { $size >= $min } { set size [expr {$size / 2}] } {
set try_opts [concat $opts [list additional_flags=-gnateDCRASHGDB=$size]]
# Use gdb_compile_ada_1 to prevent failed compilations from producing a
# FAIL.
diff --git a/gdb/testsuite/gdb.ada/import.exp b/gdb/testsuite/gdb.ada/import.exp
index ab3a1c9..51ce7fa 100644
--- a/gdb/testsuite/gdb.ada/import.exp
+++ b/gdb/testsuite/gdb.ada/import.exp
@@ -54,6 +54,9 @@ gdb_test "print pkg.imported_var_ada" " = 42"
gdb_test "print pkg.exported_var_ada" " = 99"
gdb_test "print exported_var_ada" " = 99"
+gdb_breakpoint "local_imported_func" message
+gdb_test "print copy" " = 42"
+
# This passes with gcc 10 but fails with gcc 9. With gcc 9, we have:
# <1><1659>: Abbrev Number: 4 (DW_TAG_subprogram)
# <165a> DW_AT_external : 1
@@ -76,19 +79,16 @@ gdb_test "print exported_var_ada" " = 99"
# The fact that things start to work when adding the DW_AT_declaration is
# consistent with what is described in commit ff9baa5f1c5, so xfail this
# (without pinpointing it to a specific gcc PR or commit).
-if { [gcc_major_version] < 10 } {
- setup_xfail *-*-*
-}
-gdb_breakpoint "pkg.imported_func_ada" message
-gdb_breakpoint "imported_func" message
-if { [gcc_major_version] < 10 } {
- setup_xfail *-*-*
+foreach func {"pkg.imported_func_ada" "imported_func"} {
+ clean_restart $testfile
+ if { [gcc_major_version] < 10 } {
+ setup_xfail *-*-*
+ }
+ gdb_breakpoint $func message
}
-gdb_breakpoint "imported_func_ada" message
-gdb_breakpoint "local_imported_func" message
-gdb_breakpoint "pkg.exported_func_ada" message
-gdb_breakpoint "exported_func_ada" message
-gdb_breakpoint "exported_func" message
-
-gdb_test "print copy" " = 42"
+foreach func {"imported_func_ada" "pkg.exported_func_ada" \
+ "exported_func_ada" "exported_func"} {
+ clean_restart $testfile
+ gdb_breakpoint $func message
+}
diff --git a/gdb/testsuite/gdb.ada/limited-length.exp b/gdb/testsuite/gdb.ada/limited-length.exp
index 7172c37..a5001fa 100644
--- a/gdb/testsuite/gdb.ada/limited-length.exp
+++ b/gdb/testsuite/gdb.ada/limited-length.exp
@@ -70,7 +70,7 @@ with_test_prefix "with standard max-value size" {
# Set the max-value-size so we can only print 33 elements.
set elements 33
set elem_size [get_valueof "/d" "(Large_1d_Array(1)'Size + 7) / 8" "*unknown*"]
-gdb_test_no_output "set max-value-size [expr $elem_size * $elements]"
+gdb_test_no_output "set max-value-size [expr {$elem_size * $elements}]"
with_test_prefix "with reduced max-value size" {
# GNAT historically named this type, but as the array type is
diff --git a/gdb/testsuite/gdb.ada/mi_catch_assert.exp b/gdb/testsuite/gdb.ada/mi_catch_assert.exp
index 1b4609a..c3dbfca 100644
--- a/gdb/testsuite/gdb.ada/mi_catch_assert.exp
+++ b/gdb/testsuite/gdb.ada/mi_catch_assert.exp
@@ -26,7 +26,7 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
###################################################
# 2. Try catching conditionnal failed assertion. #
diff --git a/gdb/testsuite/gdb.ada/mi_catch_ex.exp b/gdb/testsuite/gdb.ada/mi_catch_ex.exp
index da3d340..0837028 100644
--- a/gdb/testsuite/gdb.ada/mi_catch_ex.exp
+++ b/gdb/testsuite/gdb.ada/mi_catch_ex.exp
@@ -30,7 +30,7 @@ set any_nb "\[0-9\]+"
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
####################################
# 1. Try catching all exceptions. #
diff --git a/gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp b/gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp
index 00e8f6e..0c50f59 100644
--- a/gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp
+++ b/gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp
@@ -26,7 +26,7 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
#############################################
# 1. Try catching all exceptions handlers. #
diff --git a/gdb/testsuite/gdb.ada/mi_dyn_arr.exp b/gdb/testsuite/gdb.ada/mi_dyn_arr.exp
index c0e9f7f..b01f3e9 100644
--- a/gdb/testsuite/gdb.ada/mi_dyn_arr.exp
+++ b/gdb/testsuite/gdb.ada/mi_dyn_arr.exp
@@ -26,7 +26,7 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" }
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
if {[mi_runto_main] < 0} {
return 0
diff --git a/gdb/testsuite/gdb.ada/mi_ex_cond.exp b/gdb/testsuite/gdb.ada/mi_ex_cond.exp
index 53ace22..43caf76 100644
--- a/gdb/testsuite/gdb.ada/mi_ex_cond.exp
+++ b/gdb/testsuite/gdb.ada/mi_ex_cond.exp
@@ -30,7 +30,7 @@ set any_nb "\[0-9\]+"
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.ada/mi_exc_info.exp b/gdb/testsuite/gdb.ada/mi_exc_info.exp
index b9d0072..a95fb23 100644
--- a/gdb/testsuite/gdb.ada/mi_exc_info.exp
+++ b/gdb/testsuite/gdb.ada/mi_exc_info.exp
@@ -26,7 +26,7 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" }
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
if {[mi_runto_main] < 0} {
return 0
diff --git a/gdb/testsuite/gdb.ada/mi_interface.exp b/gdb/testsuite/gdb.ada/mi_interface.exp
index 630353d..f25adf0 100644
--- a/gdb/testsuite/gdb.ada/mi_interface.exp
+++ b/gdb/testsuite/gdb.ada/mi_interface.exp
@@ -28,7 +28,7 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
if {[mi_runto_main] < 0} {
return 0
diff --git a/gdb/testsuite/gdb.ada/mi_prot.exp b/gdb/testsuite/gdb.ada/mi_prot.exp
index 7f68ca8..4edc93b 100644
--- a/gdb/testsuite/gdb.ada/mi_prot.exp
+++ b/gdb/testsuite/gdb.ada/mi_prot.exp
@@ -28,7 +28,7 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable \
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
if {[mi_runto_main] < 0} {
return 0
diff --git a/gdb/testsuite/gdb.ada/mi_ref_changeable.exp b/gdb/testsuite/gdb.ada/mi_ref_changeable.exp
index 315e2b3..c69f615 100644
--- a/gdb/testsuite/gdb.ada/mi_ref_changeable.exp
+++ b/gdb/testsuite/gdb.ada/mi_ref_changeable.exp
@@ -26,7 +26,7 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug]] != "" }
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
if {[mi_runto_main] < 0} {
return 0
diff --git a/gdb/testsuite/gdb.ada/mi_string_access.exp b/gdb/testsuite/gdb.ada/mi_string_access.exp
index 25c0490..e29e17d 100644
--- a/gdb/testsuite/gdb.ada/mi_string_access.exp
+++ b/gdb/testsuite/gdb.ada/mi_string_access.exp
@@ -29,7 +29,7 @@ foreach_gnat_encoding scenario flags {all minimal} {
return -1
}
- mi_clean_restart $binfile-$scenario
+ mi_clean_restart $::testfile-$scenario
if {[mi_runto_main] < 0} {
return 0
diff --git a/gdb/testsuite/gdb.ada/mi_task_arg.exp b/gdb/testsuite/gdb.ada/mi_task_arg.exp
index 018e3bc..6c222ff 100644
--- a/gdb/testsuite/gdb.ada/mi_task_arg.exp
+++ b/gdb/testsuite/gdb.ada/mi_task_arg.exp
@@ -26,7 +26,7 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.ada/mi_task_info.exp b/gdb/testsuite/gdb.ada/mi_task_info.exp
index aa05a02..9895cfe 100644
--- a/gdb/testsuite/gdb.ada/mi_task_info.exp
+++ b/gdb/testsuite/gdb.ada/mi_task_info.exp
@@ -26,7 +26,7 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.ada/mi_var_access.exp b/gdb/testsuite/gdb.ada/mi_var_access.exp
index 9bfaeff..b595780 100644
--- a/gdb/testsuite/gdb.ada/mi_var_access.exp
+++ b/gdb/testsuite/gdb.ada/mi_var_access.exp
@@ -26,7 +26,7 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable debug] != "" } {
return -1
}
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
if {[mi_runto_main] < 0} {
return 0
diff --git a/gdb/testsuite/gdb.ada/mi_var_array.exp b/gdb/testsuite/gdb.ada/mi_var_array.exp
index a04673c..0ba90e7 100644
--- a/gdb/testsuite/gdb.ada/mi_var_array.exp
+++ b/gdb/testsuite/gdb.ada/mi_var_array.exp
@@ -29,7 +29,7 @@ foreach_gnat_encoding scenario flags {none all minimal} {
return -1
}
- mi_clean_restart $binfile-$scenario
+ mi_clean_restart $::testfile-$scenario
if {[mi_runto_main] < 0} {
return 0
diff --git a/gdb/testsuite/gdb.ada/mi_var_union.exp b/gdb/testsuite/gdb.ada/mi_var_union.exp
index 99882cf..b198800 100644
--- a/gdb/testsuite/gdb.ada/mi_var_union.exp
+++ b/gdb/testsuite/gdb.ada/mi_var_union.exp
@@ -31,7 +31,7 @@ foreach_gnat_encoding scenario flags {none all minimal} {
return -1
}
- mi_clean_restart $binfile-$scenario
+ mi_clean_restart $::testfile-$scenario
if {[mi_runto_main] < 0} {
return 0
diff --git a/gdb/testsuite/gdb.ada/mi_variant.exp b/gdb/testsuite/gdb.ada/mi_variant.exp
index 4c71f16..18693ce 100644
--- a/gdb/testsuite/gdb.ada/mi_variant.exp
+++ b/gdb/testsuite/gdb.ada/mi_variant.exp
@@ -30,7 +30,7 @@ foreach_gnat_encoding scenario flags {none all minimal} {
return -1
}
- mi_clean_restart $binfile-$scenario
+ mi_clean_restart $::testfile-$scenario
if {[mi_runto_main] < 0} {
return 0
diff --git a/gdb/testsuite/gdb.ada/mod_from_name.exp b/gdb/testsuite/gdb.ada/mod_from_name.exp
index 6384f39..e97eb5a 100644
--- a/gdb/testsuite/gdb.ada/mod_from_name.exp
+++ b/gdb/testsuite/gdb.ada/mod_from_name.exp
@@ -31,7 +31,7 @@ foreach_gnat_encoding scenario flags {all minimal} {
set bp_location [gdb_get_line_number "START" ${testdir}/foo.adb]
if {![runto "foo.adb:$bp_location"]} {
return
- }
+ }
# GNAT 9 and 10 are known to fail.
if {$scenario == "minimal"
diff --git a/gdb/testsuite/gdb.ada/null_array.exp b/gdb/testsuite/gdb.ada/null_array.exp
index 82c1923..851a0a6 100644
--- a/gdb/testsuite/gdb.ada/null_array.exp
+++ b/gdb/testsuite/gdb.ada/null_array.exp
@@ -30,7 +30,7 @@ runto "foo.adb:$bp_location"
if {[gnat_version_compare <= {4 4}]} {
# Ada array bounds are missing in older GCCs.
- setup_xfail *-*-*
+ setup_xfail *-*-*
}
gdb_test "print my_table" \
"= \\(\\)"
diff --git a/gdb/testsuite/gdb.ada/ref_param.exp b/gdb/testsuite/gdb.ada/ref_param.exp
index d1d8960..1ae1d97 100644
--- a/gdb/testsuite/gdb.ada/ref_param.exp
+++ b/gdb/testsuite/gdb.ada/ref_param.exp
@@ -27,7 +27,7 @@ clean_restart ${testfile}
if {![runto pck.adb:20]} {
return
-}
+}
gdb_test_no_output "set print frame-arguments all"
diff --git a/gdb/testsuite/gdb.ada/return-small-char-array.exp b/gdb/testsuite/gdb.ada/return-small-char-array.exp
new file mode 100644
index 0000000..75c781e
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/return-small-char-array.exp
@@ -0,0 +1,40 @@
+# Copyright 2025 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 proc
+
+if { [gdb_compile_ada $srcfile $binfile executable debug] != "" } {
+ return -1
+}
+
+clean_restart $testfile
+
+set bp_location [gdb_get_line_number "STOP" $testdir/proc.adb]
+runto "proc.adb:$bp_location"
+
+gdb_test "print Value.Name(My_Value)" \
+ { = "abcd"}
+
+# Step into the function.
+gdb_test "step 2" \
+ "return Of_Value;"
+
+# and finish.
+gdb_test "finish" \
+ { = "abcd"}
diff --git a/gdb/testsuite/gdb.ada/return-small-char-array/proc.adb b/gdb/testsuite/gdb.ada/return-small-char-array/proc.adb
new file mode 100644
index 0000000..b18d9fe
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/return-small-char-array/proc.adb
@@ -0,0 +1,22 @@
+-- Copyright 2025 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 Value;
+procedure Proc is
+ My_Value : Value.T := "abcd";
+begin
+ null; -- STOP
+ My_Value := Value.Name(My_Value);
+end;
diff --git a/gdb/testsuite/gdb.ada/return-small-char-array/value.adb b/gdb/testsuite/gdb.ada/return-small-char-array/value.adb
new file mode 100644
index 0000000..2dd9faa
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/return-small-char-array/value.adb
@@ -0,0 +1,21 @@
+-- Copyright 2025 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/>.
+
+package body Value is
+ function Name (Of_Value : T) return T is
+ begin
+ return Of_Value;
+ end Name;
+end Value;
diff --git a/gdb/testsuite/gdb.ada/return-small-char-array/value.ads b/gdb/testsuite/gdb.ada/return-small-char-array/value.ads
new file mode 100644
index 0000000..16b171e
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/return-small-char-array/value.ads
@@ -0,0 +1,20 @@
+-- Copyright 2025 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/>.
+
+package Value is
+ type T is new String (1 .. 4);
+
+ function Name (Of_Value : T) return T;
+end;
diff --git a/gdb/testsuite/gdb.ada/scalar_storage.exp b/gdb/testsuite/gdb.ada/scalar_storage.exp
index 52a85cd..a380541 100644
--- a/gdb/testsuite/gdb.ada/scalar_storage.exp
+++ b/gdb/testsuite/gdb.ada/scalar_storage.exp
@@ -48,7 +48,7 @@ if {![runto "storage.adb:$bp_location"]} {
set re "value => 126, another_value => 12, color => green"
# This requires a compiler fix that is in GCC 14.
-set have_xfail [expr ![gnat_version_compare >= 14]]
+set have_xfail [expr {![gnat_version_compare >= 14]}]
set re_color "(red|green|blue|$decimal)"
set re_xfail \
"value => $decimal, another_value => $decimal, color => $re_color"
diff --git a/gdb/testsuite/gdb.ada/taft_type.exp b/gdb/testsuite/gdb.ada/taft_type.exp
index ac7b258..875718f 100644
--- a/gdb/testsuite/gdb.ada/taft_type.exp
+++ b/gdb/testsuite/gdb.ada/taft_type.exp
@@ -28,7 +28,7 @@ clean_restart ${testfile}
set bp_location [gdb_get_line_number "START" ${testdir}/p.adb]
if {![runto "p.adb:$bp_location"]} {
return
-}
+}
gdb_test "print w.e.all" \
"= \\(month => 8, year => 1974\\)"
diff --git a/gdb/testsuite/gdb.ada/unchecked_union.exp b/gdb/testsuite/gdb.ada/unchecked_union.exp
index 89c0593..5d29e28b 100644
--- a/gdb/testsuite/gdb.ada/unchecked_union.exp
+++ b/gdb/testsuite/gdb.ada/unchecked_union.exp
@@ -26,7 +26,7 @@ proc multi_line_string {str} {
foreach line [split $str \n] {
lappend result [string_to_regexp $line]
}
- return [eval multi_line $result]
+ return [multi_line {*}$result]
}
set inner_string { case ? is
diff --git a/gdb/testsuite/gdb.ada/var_arr_typedef/pack.adb b/gdb/testsuite/gdb.ada/var_arr_typedef/pack.adb
index 2f9114a..80cfac1 100644
--- a/gdb/testsuite/gdb.ada/var_arr_typedef/pack.adb
+++ b/gdb/testsuite/gdb.ada/var_arr_typedef/pack.adb
@@ -20,6 +20,6 @@ package body Pack is
return I;
end Identity;
- procedure Do_Nothing (A : Array_Type) is null;
+ procedure Do_Nothing (A : System.Address) is null;
end Pack;
diff --git a/gdb/testsuite/gdb.ada/var_arr_typedef/pack.ads b/gdb/testsuite/gdb.ada/var_arr_typedef/pack.ads
index 2ceb071..353ec48 100644
--- a/gdb/testsuite/gdb.ada/var_arr_typedef/pack.ads
+++ b/gdb/testsuite/gdb.ada/var_arr_typedef/pack.ads
@@ -13,6 +13,8 @@
-- 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 System; use System;
+
package Pack is
type Rec_Type is record
I : Integer;
@@ -23,7 +25,7 @@ package Pack is
type Array_Type is array (Positive range <>) of Vec_Type;
- procedure Do_Nothing (A : Array_Type);
+ procedure Do_Nothing (A : System.Address);
function Identity (I : Integer) return Integer;
end Pack;
diff --git a/gdb/testsuite/gdb.ada/var_arr_typedef/var_arr_typedef.adb b/gdb/testsuite/gdb.ada/var_arr_typedef/var_arr_typedef.adb
index 4a7f4cb..86609a8 100644
--- a/gdb/testsuite/gdb.ada/var_arr_typedef/var_arr_typedef.adb
+++ b/gdb/testsuite/gdb.ada/var_arr_typedef/var_arr_typedef.adb
@@ -24,5 +24,5 @@ procedure Var_Arr_Typedef is
A : constant Array_Type (1 .. Identity (4)) := (VA, VA, VB, VB);
begin
- Do_Nothing (A); -- BREAK
+ Do_Nothing (A'Address); -- BREAK
end Var_Arr_Typedef;
diff --git a/gdb/testsuite/gdb.ada/verylong.exp b/gdb/testsuite/gdb.ada/verylong.exp
index e695ddd..de5fd04 100644
--- a/gdb/testsuite/gdb.ada/verylong.exp
+++ b/gdb/testsuite/gdb.ada/verylong.exp
@@ -44,10 +44,10 @@ gdb_test_multiple "ptype Long_Long_Long_Integer" "" {
require {expr $lll_int_size == 8 || $lll_int_size == 16}
gdb_test "print x" " = $max"
-gdb_test "print x / 2" " = [expr $max / 2]"
-gdb_test "print (x / 4) * 2" " = [expr ($max / 4) * 2]"
+gdb_test "print x / 2" " = [expr {$max / 2}]"
+gdb_test "print (x / 4) * 2" " = [expr {($max / 4) * 2}]"
gdb_test "print x - x" " = 0"
-gdb_test "print x - 99 + 1" " = [expr $max - 99 + 1]"
+gdb_test "print x - 99 + 1" " = [expr {$max - 99 + 1}]"
gdb_test "print -x" " = -$max"
gdb_test "print +x" " = $max"
diff --git a/gdb/testsuite/gdb.ada/whatis_array_val.exp b/gdb/testsuite/gdb.ada/whatis_array_val.exp
index 2ccac34..becc9b8 100644
--- a/gdb/testsuite/gdb.ada/whatis_array_val.exp
+++ b/gdb/testsuite/gdb.ada/whatis_array_val.exp
@@ -28,7 +28,7 @@ clean_restart ${testfile}
set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb]
if {![runto "foo.adb:$bp_location"]} {
return
-}
+}
# Accept "foo." prefix for older versions of GNAT.
gdb_test "whatis full" \
diff --git a/gdb/testsuite/gdb.arch/aarch64-frameptr-vecreg-unwind.c b/gdb/testsuite/gdb.arch/aarch64-frameptr-vecreg-unwind.c
new file mode 100644
index 0000000..44ed3e8
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-frameptr-vecreg-unwind.c
@@ -0,0 +1,62 @@
+/* Copyright 2025 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/>. */
+
+volatile void dummy () {}
+
+long test_function(void)
+{
+ __asm__ volatile (
+ /* Zero d0 (64-bit vector register part of v0). */
+ "movi d0, #0\n\t"
+
+ /* Move the frame pointer (x29) to d0 using fmov. */
+ "fmov d0, x29\n\t"
+
+ /* Describe CFI: Frame pointer is now in d0. */
+ ".cfi_register x29, d0\n\t"
+
+ /* Clobber list: Specify all modified registers. */
+ : /* No output operands. */
+ : /* No input operands. */
+ : "d0"
+ );
+
+ dummy (); /* break-here */
+
+ __asm__ volatile (
+ /* Restore the frame pointer (x29) from d0 using fmov. */
+ "fmov x29, d0\n\t"
+
+ /* Describe CFI: Frame pointer is restored. */
+ ".cfi_restore x29\n\t"
+
+ /* Clobber list: Specify all modified registers. */
+ : /* No output operands. */
+ : /* No input operands. */
+ : "x29", "d0"
+ );
+
+ return 0;
+}
+
+int
+main ()
+{
+ long result = test_function ();
+ dummy ();
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/aarch64-frameptr-vecreg-unwind.exp b/gdb/testsuite/gdb.arch/aarch64-frameptr-vecreg-unwind.exp
new file mode 100644
index 0000000..2d710bc
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-frameptr-vecreg-unwind.exp
@@ -0,0 +1,33 @@
+# Copyright 2025 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/>.
+
+require is_aarch64_target
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" ${testfile} \
+ "${srcfile}" {debug}] } {
+ return -1
+}
+
+if {![runto_main]} {
+ return
+}
+
+gdb_breakpoint [gdb_get_line_number "break-here"]
+gdb_continue_to_breakpoint "break-here"
+gdb_test "with confirm off --return -1" "result = test_function \\(\\);"
+gdb_test "step" "dummy \\(\\);"
+gdb_test "print result" "= -1"
diff --git a/gdb/testsuite/gdb.arch/aarch64-gcs-core.c b/gdb/testsuite/gdb.arch/aarch64-gcs-core.c
new file mode 100644
index 0000000..f3362cb
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-gcs-core.c
@@ -0,0 +1,123 @@
+/* This test program is part of GDB, the GNU debugger.
+
+ Copyright 2025 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 <stdlib.h>
+#include <sys/auxv.h>
+#include <linux/prctl.h>
+#include <sys/syscall.h>
+
+/* Feature check for Guarded Control Stack. */
+#ifndef HWCAP_GCS
+#define HWCAP_GCS (1ULL << 32)
+#endif
+
+#ifndef PR_GET_SHADOW_STACK_STATUS
+#define PR_GET_SHADOW_STACK_STATUS 74
+#define PR_SET_SHADOW_STACK_STATUS 75
+#define PR_SHADOW_STACK_ENABLE (1UL << 0)
+#endif
+
+/* We need to use a macro to call prctl because after GCS is enabled, it's not
+ possible to return from the function which enabled it. This is because the
+ return address of the calling function isn't on the GCS. */
+#define my_syscall2(num, arg1, arg2) \
+ ({ \
+ register long _num __asm__("x8") = (num); \
+ register long _arg1 __asm__("x0") = (long)(arg1); \
+ register long _arg2 __asm__("x1") = (long)(arg2); \
+ register long _arg3 __asm__("x2") = 0; \
+ register long _arg4 __asm__("x3") = 0; \
+ register long _arg5 __asm__("x4") = 0; \
+ \
+ __asm__ volatile ("svc #0\n" \
+ : "=r"(_arg1) \
+ : "r"(_arg1), "r"(_arg2), "r"(_arg3), "r"(_arg4), \
+ "r"(_arg5), "r"(_num) \
+ : "memory", "cc"); \
+ _arg1; \
+ })
+
+#define get_gcspr(void) \
+ ({ \
+ unsigned long *gcspr; \
+ \
+ /* Get GCSPR_EL0. */ \
+ asm volatile ("mrs %0, S3_3_C2_C5_1" : "=r"(gcspr) : : "cc"); \
+ \
+ gcspr; \
+ })
+
+/* Corrupt the return address to see if GDB will report a SIGSEGV with the
+ expected $_siginfo.si_code. */
+static void __attribute__ ((noinline))
+function (unsigned long *gcspr)
+{
+ /* x30 holds the return address. */
+ register long x30 __asm__("x30") __attribute__ ((unused));
+
+ /* Print GCSPR to stdout so that the testcase can capture it. */
+ printf ("%p\n", get_gcspr ());
+ fflush (stdout);
+
+ /* Cause a GCS exception. */
+ x30 = 0xbadc0ffee;
+ __asm__ volatile ("ret\n");
+}
+
+int
+main (void)
+{
+ if (!(getauxval (AT_HWCAP) & HWCAP_GCS))
+ {
+ fprintf (stderr, "GCS support not found in AT_HWCAP\n");
+ return EXIT_FAILURE;
+ }
+
+ /* Force shadow stacks on, our tests *should* be fine with or
+ without libc support and with or without this having ended
+ up tagged for GCS and enabled by the dynamic linker. We
+ can't use the libc prctl() function since we can't return
+ from enabling the stack. Also lock GCS if not already
+ locked so we can test behaviour when it's locked. */
+ unsigned long gcs_mode;
+ int ret = my_syscall2 (__NR_prctl, PR_GET_SHADOW_STACK_STATUS, &gcs_mode);
+ if (ret)
+ {
+ fprintf (stderr, "Failed to read GCS state: %d\n", ret);
+ return EXIT_FAILURE;
+ }
+
+ if (!(gcs_mode & PR_SHADOW_STACK_ENABLE))
+ {
+ gcs_mode = PR_SHADOW_STACK_ENABLE;
+ ret = my_syscall2 (__NR_prctl, PR_SET_SHADOW_STACK_STATUS, gcs_mode);
+ if (ret)
+ {
+ fprintf (stderr, "Failed to configure GCS: %d\n", ret);
+ return EXIT_FAILURE;
+ }
+ }
+
+ unsigned long *gcspr = get_gcspr ();
+
+ /* Pass gscpr to function just so it's used for something. */
+ function (gcspr); /* Break here. */
+
+ /* Avoid returning, in case libc doesn't understand GCS. */
+ exit (EXIT_SUCCESS);
+}
diff --git a/gdb/testsuite/gdb.arch/aarch64-gcs-core.exp b/gdb/testsuite/gdb.arch/aarch64-gcs-core.exp
new file mode 100644
index 0000000..9c4b7d5
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-gcs-core.exp
@@ -0,0 +1,116 @@
+# Copyright 2025 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 reading and writing the core dump of a binary that uses a Guarded
+# Control Stack.
+
+require allow_aarch64_gcs_tests
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
+ return
+}
+
+set linespec ${srcfile}:[gdb_get_line_number "Break here"]
+
+if ![runto $linespec] {
+ return
+}
+
+# Obtain an OS-generated core file. Save test program output to
+# ${binfile}.out.
+set core_filename [core_find $binfile {} {} "${binfile}.out"]
+set core_generated [expr {$core_filename != ""}]
+
+# Make sure GDB can read the given core file correctly.
+proc check_core_file {core_filename saved_gcspr} {
+ global decimal hex
+
+ # Load the core file.
+ if [gdb_test "core $core_filename" \
+ [multi_line \
+ "Core was generated by .*\\." \
+ "Program terminated with signal SIGSEGV, Segmentation fault" \
+ "Guarded Control Stack error\\." \
+ "#0 function \\(gcspr=$hex\\) at .*aarch64-gcs-core.c:$decimal" \
+ "$decimal.*__asm__ volatile \\(\"ret\\\\n\"\\);"] \
+ "load core file"] {
+ return -1
+ }
+
+ # Check the value of GCSPR in the core file.
+ gdb_test "print/x \$gcspr" "\\$\[0-9\]+ = $saved_gcspr" \
+ "gcspr contents from core file"
+}
+
+if {!$core_generated} {
+ untested "unable to create or find corefile"
+}
+
+if {$core_generated} {
+ clean_restart
+ gdb_load $binfile
+
+ with_test_prefix "OS corefile" {
+ # Read GCSPR value from saved output of the test program.
+ set out_id [open ${binfile}.out "r"]
+ set gcspr_in_core [gets $out_id]
+ close $out_id
+
+ check_core_file $core_filename $gcspr_in_core
+ }
+}
+
+if ![gcore_cmd_available] {
+ unsupported "target does not support gcore command."
+ return
+}
+
+clean_restart
+gdb_load $binfile
+
+if ![runto $linespec] {
+ return
+}
+
+# Continue until a crash. The line with the hex number is optional because
+# it's printed by the test program, and doesn't appear in the Expect buffer
+# when testing a remote target.
+gdb_test "continue" \
+ [multi_line \
+ "Continuing\\." \
+ "($hex\r\n)?" \
+ "Program received signal SIGSEGV, Segmentation fault" \
+ "Guarded Control Stack error\\." \
+ "function \\(gcspr=$hex\\) at .*aarch64-gcs-core.c:$decimal" \
+ {.*__asm__ volatile \("ret\\n"\);}] \
+ "continue to SIGSEGV"
+
+set gcspr_in_gcore [get_valueof "/x" "\$gcspr" "*unknown*"]
+
+# Generate the gcore core file.
+set gcore_filename [standard_output_file "${testfile}.gcore"]
+set gcore_generated [gdb_gcore_cmd "$gcore_filename" "generate gcore file"]
+
+gdb_assert { $gcore_generated } "gcore corefile created"
+if {$gcore_generated} {
+ clean_restart
+ gdb_load $binfile
+
+ with_test_prefix "gcore corefile" {
+ check_core_file $gcore_filename $gcspr_in_gcore
+ }
+}
diff --git a/gdb/testsuite/gdb.arch/aarch64-gcs-disp-step.c b/gdb/testsuite/gdb.arch/aarch64-gcs-disp-step.c
new file mode 100644
index 0000000..754fda1
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-gcs-disp-step.c
@@ -0,0 +1,140 @@
+/* This test program is part of GDB, the GNU debugger.
+
+ Copyright 2025 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 <stdlib.h>
+#include <sys/auxv.h>
+#include <sys/syscall.h>
+#include <linux/prctl.h>
+
+/* Feature check for Guarded Control Stack. */
+#ifndef HWCAP_GCS
+#define HWCAP_GCS (1ULL << 32)
+#endif
+
+#ifndef PR_GET_SHADOW_STACK_STATUS
+#define PR_GET_SHADOW_STACK_STATUS 74
+#define PR_SET_SHADOW_STACK_STATUS 75
+#define PR_SHADOW_STACK_ENABLE (1UL << 0)
+#endif
+
+/* We need to use a macro to call prctl because after GCS is enabled, it's not
+ possible to return from the function which enabled it. This is because the
+ return address of the calling function isn't on the GCS. */
+#define my_syscall2(num, arg1, arg2) \
+ ({ \
+ register long _num __asm__("x8") = (num); \
+ register long _arg1 __asm__("x0") = (long)(arg1); \
+ register long _arg2 __asm__("x1") = (long)(arg2); \
+ register long _arg3 __asm__("x2") = 0; \
+ register long _arg4 __asm__("x3") = 0; \
+ register long _arg5 __asm__("x4") = 0; \
+ \
+ __asm__ volatile("svc #0\n" \
+ : "=r"(_arg1) \
+ : "r"(_arg1), "r"(_arg2), "r"(_arg3), "r"(_arg4), \
+ "r"(_arg5), "r"(_num) \
+ : "memory", "cc"); \
+ _arg1; \
+ })
+
+#define get_gcspr(void) \
+ ({ \
+ unsigned long *gcspr; \
+ \
+ /* Get GCSPR_EL0. */ \
+ asm volatile("mrs %0, S3_3_C2_C5_1" : "=r"(gcspr) : : "cc"); \
+ \
+ gcspr; \
+ })
+
+static int __attribute__ ((noinline))
+function2 (void)
+{
+ return EXIT_SUCCESS;
+}
+
+/* Put branch and link instructions being tested into their own functions so
+ that the program returns one level up in the stack after the displaced
+ stepped instruction. This tests that GDB doesn't leave the GCS out of sync
+ with the regular stack. */
+
+static int __attribute__ ((noinline))
+function_bl (void)
+{
+ register int x0 __asm__("x0");
+
+ __asm__ ("bl function2\n"
+ : "=r"(x0)
+ :
+ : "x30");
+
+ return x0;
+}
+
+static int __attribute__ ((noinline))
+function_blr (void)
+{
+ register int x0 __asm__("x0");
+
+ __asm__ ("blr %1\n"
+ : "=r"(x0)
+ : "r"(&function2)
+ : "x30");
+
+ return x0;
+}
+
+int
+main (void)
+{
+ if (!(getauxval (AT_HWCAP) & HWCAP_GCS))
+ {
+ fprintf (stderr, "GCS support not found in AT_HWCAP\n");
+ return EXIT_FAILURE;
+ }
+
+ /* Force shadow stacks on, our tests *should* be fine with or
+ without libc support and with or without this having ended
+ up tagged for GCS and enabled by the dynamic linker. We
+ can't use the libc prctl() function since we can't return
+ from enabling the stack. */
+ unsigned long gcs_mode;
+ int ret = my_syscall2 (__NR_prctl, PR_GET_SHADOW_STACK_STATUS, &gcs_mode);
+ if (ret)
+ {
+ fprintf (stderr, "Failed to read GCS state: %d\n", ret);
+ return EXIT_FAILURE;
+ }
+
+ if (!(gcs_mode & PR_SHADOW_STACK_ENABLE))
+ {
+ gcs_mode = PR_SHADOW_STACK_ENABLE;
+ ret = my_syscall2 (__NR_prctl, PR_SET_SHADOW_STACK_STATUS, gcs_mode);
+ if (ret)
+ {
+ fprintf (stderr, "Failed to configure GCS: %d\n", ret);
+ return EXIT_FAILURE;
+ }
+ }
+
+ int ret1 = function_bl ();
+ int ret2 = function_blr ();
+
+ /* Avoid returning, in case libc doesn't understand GCS. */
+ exit (ret1 + ret2);
+}
diff --git a/gdb/testsuite/gdb.arch/aarch64-gcs-disp-step.exp b/gdb/testsuite/gdb.arch/aarch64-gcs-disp-step.exp
new file mode 100644
index 0000000..2359d96
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-gcs-disp-step.exp
@@ -0,0 +1,86 @@
+# Copyright 2025 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 displaced stepping in a program that uses a Guarded Control Stack.
+
+require allow_aarch64_gcs_tests
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
+ return
+}
+
+if ![runto_main] {
+ return
+}
+
+gdb_test_no_output "set breakpoint auto-hw off"
+gdb_test_no_output "set displaced-stepping on"
+
+# Get address of the branch and link instructions of interest.
+set addr_bl 0
+set test "get address of bl instruction"
+gdb_test_multiple "disassemble function_bl" $test -lbl {
+ -re "\r\n\\s+($hex) <\\+${decimal}>:\\s+bl\\s+${hex} <function2>(?=\r\n)" {
+ set addr_bl $expect_out(1,string)
+ exp_continue
+ }
+ -re -wrap "" {
+ gdb_assert { $addr_bl != 0 } $test
+ }
+}
+
+set addr_blr 0
+set test "get address of blr instruction"
+gdb_test_multiple "disassemble function_blr" $test -lbl {
+ -re "\r\n\\s+($hex) <\\+${decimal}>:\\s+blr\\s+x${decimal}(?=\r\n)" {
+ set addr_blr $expect_out(1,string)
+ exp_continue
+ }
+ -re -wrap "" {
+ gdb_assert { $addr_blr != 0 } $test
+ }
+}
+
+if { $addr_bl == 0 || $addr_blr == 0 } {
+ return
+}
+
+gdb_test "break *$addr_bl" \
+ "Breakpoint $decimal at $hex: file .*aarch64-gcs-disp-step.c, line ${decimal}." \
+ "set breakpoint at bl instruction"
+
+gdb_test "break *$addr_blr" \
+ "Breakpoint $decimal at $hex: file .*aarch64-gcs-disp-step.c, line ${decimal}." \
+ "set breakpoint at blr instruction"
+
+gdb_test "continue" \
+ [multi_line \
+ {Continuing\.} \
+ "" \
+ "Breakpoint $decimal, function_bl \\(\\) at .*aarch64-gcs-disp-step.c:${decimal}(?: \\\[GCS error\\\])?" \
+ {[^\r\n]+"bl function2\\n"}] \
+ "continue to breakpoint at bl"
+
+gdb_test "continue" \
+ [multi_line \
+ {Continuing\.} \
+ "" \
+ "Breakpoint $decimal, $hex in function_blr \\(\\) at .*aarch64-gcs-disp-step.c:${decimal}(?: \\\[GCS error\\\])?" \
+ {[^\r\n]+"blr %1\\n"}] \
+ "continue to breakpoint at blr"
+
+gdb_continue_to_end
diff --git a/gdb/testsuite/gdb.arch/aarch64-gcs-return.c b/gdb/testsuite/gdb.arch/aarch64-gcs-return.c
new file mode 100644
index 0000000..c062fea
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-gcs-return.c
@@ -0,0 +1,105 @@
+/* This test program is part of GDB, the GNU debugger.
+
+ Copyright 2025 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 <stdlib.h>
+#include <sys/auxv.h>
+#include <sys/syscall.h>
+#include <linux/prctl.h>
+
+/* Feature check for Guarded Control Stack. */
+#ifndef HWCAP_GCS
+#define HWCAP_GCS (1ULL << 32)
+#endif
+
+#ifndef PR_GET_SHADOW_STACK_STATUS
+#define PR_GET_SHADOW_STACK_STATUS 74
+#define PR_SET_SHADOW_STACK_STATUS 75
+#define PR_SHADOW_STACK_ENABLE (1UL << 0)
+#endif
+
+/* We need to use a macro to call prctl because after GCS is enabled, it's not
+ possible to return from the function which enabled it. This is because the
+ return address of the calling function isn't on the GCS. */
+#define my_syscall2(num, arg1, arg2) \
+ ({ \
+ register long _num __asm__("x8") = (num); \
+ register long _arg1 __asm__("x0") = (long)(arg1); \
+ register long _arg2 __asm__("x1") = (long)(arg2); \
+ register long _arg3 __asm__("x2") = 0; \
+ register long _arg4 __asm__("x3") = 0; \
+ register long _arg5 __asm__("x4") = 0; \
+ \
+ __asm__ volatile("svc #0\n" \
+ : "=r"(_arg1) \
+ : "r"(_arg1), "r"(_arg2), "r"(_arg3), "r"(_arg4), \
+ "r"(_arg5), "r"(_num) \
+ : "memory", "cc"); \
+ _arg1; \
+ })
+
+static int __attribute__ ((noinline))
+call2 ()
+{
+ return 42; /* Break call2. */
+}
+
+static int __attribute__ ((noinline))
+call1 ()
+{
+ return call2 (); /* Break call1. */
+}
+
+int
+main ()
+{
+ if (!(getauxval (AT_HWCAP) & HWCAP_GCS))
+ {
+ fprintf (stderr, "GCS support not found in AT_HWCAP\n");
+ return EXIT_FAILURE;
+ }
+
+ /* Force shadow stacks on, our tests *should* be fine with or
+ without libc support and with or without this having ended
+ up tagged for GCS and enabled by the dynamic linker. We
+ can't use the libc prctl() function since we can't return
+ from enabling the stack. Also lock GCS if not already
+ locked so we can test behaviour when it's locked. */
+ unsigned long gcs_mode;
+ int ret = my_syscall2 (__NR_prctl, PR_GET_SHADOW_STACK_STATUS, &gcs_mode);
+ if (ret)
+ {
+ fprintf (stderr, "Failed to read GCS state: %d\n", ret);
+ return EXIT_FAILURE;
+ }
+
+ if (!(gcs_mode & PR_SHADOW_STACK_ENABLE))
+ {
+ gcs_mode = PR_SHADOW_STACK_ENABLE;
+ ret = my_syscall2 (__NR_prctl, PR_SET_SHADOW_STACK_STATUS, gcs_mode);
+ if (ret)
+ {
+ fprintf (stderr, "Failed to configure GCS: %d\n", ret);
+ return EXIT_FAILURE;
+ }
+ }
+
+ call1 (); /* Break begin. */
+
+ /* Avoid returning, in case libc doesn't understand GCS. */
+ exit (EXIT_SUCCESS);
+}
diff --git a/gdb/testsuite/gdb.arch/aarch64-gcs-return.exp b/gdb/testsuite/gdb.arch/aarch64-gcs-return.exp
new file mode 100644
index 0000000..6f695da
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-gcs-return.exp
@@ -0,0 +1,132 @@
+# Copyright 2025 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 the GDB return command in a program that uses a Guarded Control Stack.
+# Based on the return tests in gdb.arch/amd64-shadow-stack-cmds.exp.
+# Note that potential GCS violations often only occur after resuming normal
+# execution. Therefore, it is important to test normal program
+# completion after testing the return command.
+
+require allow_aarch64_gcs_tests
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
+ return
+}
+
+set begin_line [gdb_get_line_number "Break begin"]
+set call1_line [gdb_get_line_number "Break call1"]
+set call2_line [gdb_get_line_number "Break call2"]
+
+if ![runto ${begin_line}] {
+ return
+}
+
+proc restart_and_run_infcall_call2 {} {
+ global binfile call2_line
+ clean_restart
+ gdb_load $binfile
+ if ![runto_main] {
+ return
+ }
+ set inside_infcall_str "The program being debugged stopped while in a function called from GDB"
+ gdb_breakpoint ${call2_line}
+ gdb_continue_to_breakpoint "Break call2" ".*Break call2.*"
+ gdb_test "call (int) call2()" \
+ "Breakpoint \[0-9\]*, call2.*$inside_infcall_str.*"
+}
+
+with_test_prefix "test inferior call and continue" {
+ gdb_breakpoint ${call1_line}
+ gdb_continue_to_breakpoint "Break call1" ".*Break call1.*"
+
+ gdb_test "call (int) call2()" "= 42"
+
+ gdb_continue_to_end
+}
+
+with_test_prefix "test return inside an inferior call" {
+ restart_and_run_infcall_call2
+
+ gdb_test "return" "\#0.*call2.*" \
+ "Test GCS return inside an inferior call" \
+ "Make.*return now\\? \\(y or n\\) " "y"
+
+ gdb_continue_to_end
+}
+
+with_test_prefix "test return 'above' an inferior call" {
+ restart_and_run_infcall_call2
+
+ gdb_test "frame 2" "call2 ().*" "move to frame 'above' inferior call"
+
+ gdb_test "return" "\#0.*call1.*" \
+ "Test GCS return 'above' an inferior call" \
+ "Make.*return now\\? \\(y or n\\) " "y"
+
+ gdb_continue_to_end
+}
+
+clean_restart
+gdb_load $binfile
+if ![runto ${begin_line}] {
+ return
+}
+
+# Extract GCS pointer inside main, call1 and call2 function.
+gdb_breakpoint ${call1_line}
+gdb_breakpoint ${call2_line}
+set gcspr_main [get_valueof /x "\$gcspr" 0 "get value of gcspr in main"]
+gdb_continue_to_breakpoint "Break call1" ".*Break call1.*"
+set gcspr_call1 [get_valueof /x "\$gcspr" 0 "get value of gcspr in call1"]
+gdb_continue_to_breakpoint "Break call2" ".*Break call2.*"
+set gcspr_call2 [get_valueof /x "\$gcspr" 0 "get value of gcspr in call2"]
+
+with_test_prefix "test frame level update" {
+ gdb_test "up" "call1.*" "move to frame 1"
+ gdb_test "print /x \$gcspr" "= $gcspr_call1" "check gcspr of frame 1"
+ gdb_test "up" "main.*" "move to frame 2"
+ gdb_test "print /x \$gcspr" "= $gcspr_main" "check gcspr of frame 2"
+ gdb_test "frame 0" "call2.*" "move to frame 0"
+ gdb_test "print /x \$gcspr" "= $gcspr_call2" "check gcspr of frame 0"
+}
+
+with_test_prefix "test return from current frame" {
+ gdb_test "return (int) 1" "#0.*call1.*" \
+ "Test GCS return from current frame" \
+ "Make.*return now\\? \\(y or n\\) " "y"
+
+ gdb_continue_to_end
+}
+
+clean_restart
+gdb_load $binfile
+if ![runto_main] {
+ return
+}
+
+with_test_prefix "test return from past frame" {
+ gdb_breakpoint ${call2_line}
+ gdb_continue_to_breakpoint "Break call2" ".*Break call2.*"
+
+ gdb_test "frame 1" ".*in call1.*"
+
+ gdb_test "return (int) 1" "#0.*main.*" \
+ "Test GCS return from past frame" \
+ "Make.*return now\\? \\(y or n\\) " "y"
+
+ gdb_continue_to_end
+}
diff --git a/gdb/testsuite/gdb.arch/aarch64-gcs-tdesc-without-linux.xml b/gdb/testsuite/gdb.arch/aarch64-gcs-tdesc-without-linux.xml
new file mode 100644
index 0000000..056ab58
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-gcs-tdesc-without-linux.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0"?>
+<!DOCTYPE target SYSTEM "gdb-target.dtd">
+<target>
+ <architecture>aarch64</architecture>
+ <feature name="org.gnu.gdb.aarch64.core">
+ <flags id="cpsr_flags" size="4">
+ <field name="SP" start="0" end="0" type="bool"/>
+ <field name="EL" start="2" end="3" type="uint32"/>
+ <field name="nRW" start="4" end="4" type="bool"/>
+ <field name="F" start="6" end="6" type="bool"/>
+ <field name="I" start="7" end="7" type="bool"/>
+ <field name="A" start="8" end="8" type="bool"/>
+ <field name="D" start="9" end="9" type="bool"/>
+ <field name="BTYPE" start="10" end="11" type="uint32"/>
+ <field name="SSBS" start="12" end="12" type="bool"/>
+ <field name="IL" start="20" end="20" type="bool"/>
+ <field name="SS" start="21" end="21" type="bool"/>
+ <field name="PAN" start="22" end="22" type="bool"/>
+ <field name="UAO" start="23" end="23" type="bool"/>
+ <field name="DIT" start="24" end="24" type="bool"/>
+ <field name="TCO" start="25" end="25" type="bool"/>
+ <field name="V" start="28" end="28" type="bool"/>
+ <field name="C" start="29" end="29" type="bool"/>
+ <field name="Z" start="30" end="30" type="bool"/>
+ <field name="N" start="31" end="31" type="bool"/>
+ </flags>
+ <reg name="x0" bitsize="64" type="int" regnum="0"/>
+ <reg name="x1" bitsize="64" type="int" regnum="1"/>
+ <reg name="x2" bitsize="64" type="int" regnum="2"/>
+ <reg name="x3" bitsize="64" type="int" regnum="3"/>
+ <reg name="x4" bitsize="64" type="int" regnum="4"/>
+ <reg name="x5" bitsize="64" type="int" regnum="5"/>
+ <reg name="x6" bitsize="64" type="int" regnum="6"/>
+ <reg name="x7" bitsize="64" type="int" regnum="7"/>
+ <reg name="x8" bitsize="64" type="int" regnum="8"/>
+ <reg name="x9" bitsize="64" type="int" regnum="9"/>
+ <reg name="x10" bitsize="64" type="int" regnum="10"/>
+ <reg name="x11" bitsize="64" type="int" regnum="11"/>
+ <reg name="x12" bitsize="64" type="int" regnum="12"/>
+ <reg name="x13" bitsize="64" type="int" regnum="13"/>
+ <reg name="x14" bitsize="64" type="int" regnum="14"/>
+ <reg name="x15" bitsize="64" type="int" regnum="15"/>
+ <reg name="x16" bitsize="64" type="int" regnum="16"/>
+ <reg name="x17" bitsize="64" type="int" regnum="17"/>
+ <reg name="x18" bitsize="64" type="int" regnum="18"/>
+ <reg name="x19" bitsize="64" type="int" regnum="19"/>
+ <reg name="x20" bitsize="64" type="int" regnum="20"/>
+ <reg name="x21" bitsize="64" type="int" regnum="21"/>
+ <reg name="x22" bitsize="64" type="int" regnum="22"/>
+ <reg name="x23" bitsize="64" type="int" regnum="23"/>
+ <reg name="x24" bitsize="64" type="int" regnum="24"/>
+ <reg name="x25" bitsize="64" type="int" regnum="25"/>
+ <reg name="x26" bitsize="64" type="int" regnum="26"/>
+ <reg name="x27" bitsize="64" type="int" regnum="27"/>
+ <reg name="x28" bitsize="64" type="int" regnum="28"/>
+ <reg name="x29" bitsize="64" type="int" regnum="29"/>
+ <reg name="x30" bitsize="64" type="int" regnum="30"/>
+ <reg name="sp" bitsize="64" type="data_ptr" regnum="31"/>
+ <reg name="pc" bitsize="64" type="code_ptr" regnum="32"/>
+ <reg name="cpsr" bitsize="32" type="cpsr_flags" regnum="33"/>
+ </feature>
+ <feature name="org.gnu.gdb.aarch64.gcs">
+ <reg name="gcspr" bitsize="64" type="data_ptr" regnum="90" group="system"/>
+ </feature>
+</target>
diff --git a/gdb/testsuite/gdb.arch/aarch64-gcs-wrong-tdesc.c b/gdb/testsuite/gdb.arch/aarch64-gcs-wrong-tdesc.c
new file mode 100644
index 0000000..10cf749
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-gcs-wrong-tdesc.c
@@ -0,0 +1,26 @@
+/* This test program is part of GDB, the GNU debugger.
+
+ Copyright 2025 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>
+
+int
+main (void)
+{
+ printf ("Hello, world!\n");
+
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/aarch64-gcs-wrong-tdesc.exp b/gdb/testsuite/gdb.arch/aarch64-gcs-wrong-tdesc.exp
new file mode 100644
index 0000000..f0508cd
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-gcs-wrong-tdesc.exp
@@ -0,0 +1,48 @@
+# Copyright 2025 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 that GDB complains when given a target description with the GCS feature
+# but not the GCS Linux feature.
+
+require allow_aarch64_gcs_tests
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
+ return
+}
+
+set xml_path "${srcdir}/${subdir}/aarch64-gcs-tdesc-without-linux.xml"
+
+gdb_test "set tdesc filename ${xml_path}" \
+ "warning: Incomplete GCS support in the target: missing Linux part. GCS feature disabled." \
+ "warn about incomplete GCS support"
+
+# We can't test a debugging session on a remote target because with the
+# wrong tdesc, GDB expects a g packet reply with the wrong size.
+if {[gdb_protocol_is_remote]} {
+ return
+}
+
+if ![runto_main] {
+ return
+}
+
+gdb_test "print \$gcspr" " = <unavailable>" "GCSPR is unavailable"
+
+# Now check that we can continue the debugging session normally.
+gdb_test "next"
+
+gdb_continue_to_end
diff --git a/gdb/testsuite/gdb.arch/aarch64-gcs.c b/gdb/testsuite/gdb.arch/aarch64-gcs.c
new file mode 100644
index 0000000..9eb2e9e
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-gcs.c
@@ -0,0 +1,180 @@
+/* This test program is part of GDB, the GNU debugger.
+
+ Copyright 2025 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 <stdlib.h>
+#include <signal.h>
+#include <sys/auxv.h>
+#include <sys/syscall.h>
+#include <linux/prctl.h>
+
+/* Feature check for Guarded Control Stack. */
+#ifndef HWCAP_GCS
+#define HWCAP_GCS (1ULL << 32)
+#endif
+
+#ifndef PR_GET_SHADOW_STACK_STATUS
+#define PR_GET_SHADOW_STACK_STATUS 74
+#define PR_SET_SHADOW_STACK_STATUS 75
+#define PR_SHADOW_STACK_ENABLE (1UL << 0)
+#endif
+
+/* We need to use a macro to call prctl because after GCS is enabled, it's not
+ possible to return from the function which enabled it. This is because the
+ return address of the calling function isn't on the GCS. */
+#define my_syscall2(num, arg1, arg2) \
+ ({ \
+ register long _num __asm__("x8") = (num); \
+ register long _arg1 __asm__("x0") = (long)(arg1); \
+ register long _arg2 __asm__("x1") = (long)(arg2); \
+ register long _arg3 __asm__("x2") = 0; \
+ register long _arg4 __asm__("x3") = 0; \
+ register long _arg5 __asm__("x4") = 0; \
+ \
+ __asm__ volatile ("svc #0\n" \
+ : "=r"(_arg1) \
+ : "r"(_arg1), "r"(_arg2), "r"(_arg3), "r"(_arg4), \
+ "r"(_arg5), "r"(_num) \
+ : "memory", "cc"); \
+ _arg1; \
+ })
+
+#define get_gcspr(void) \
+ ({ \
+ unsigned long *gcspr; \
+ \
+ /* Get GCSPR_EL0. */ \
+ asm volatile ("mrs %0, S3_3_C2_C5_1" : "=r"(gcspr) : : "cc"); \
+ \
+ gcspr; \
+ })
+
+static unsigned long *handler_gcspr = 0;
+
+static void
+handler (int sig)
+{
+ handler_gcspr = get_gcspr ();
+}
+
+static int __attribute__ ((unused))
+called_from_gdb (int val)
+{
+ return val + 1;
+}
+
+/* Corrupt the return address to see if GDB will report a SIGSEGV with the
+ expected $_siginfo.si_code. */
+static void __attribute__ ((noinline))
+normal_function2 (void)
+{
+ /* x30 holds the return address. */
+ register unsigned long x30 __asm__("x30") __attribute__ ((unused));
+
+ /* Cause a GCS exception. */
+ x30 = 0xbadc0ffee;
+ /* Use explicit ret so that we can verify that a SIGSEGV was generated
+ exactly on the return instruction. */
+ __asm__ volatile ("ret\n");
+}
+
+static inline void __attribute__ ((__always_inline__))
+inline_function2 (void)
+{
+ normal_function2 ();
+}
+
+static void __attribute__ ((noinline))
+normal_function1 (void)
+{
+ inline_function2 ();
+}
+
+/* First in a sequence of inline and normal functions, to test GDB
+ backtrace. */
+static inline void __attribute__ ((__always_inline__))
+inline_function1 (void)
+{
+ normal_function1 ();
+}
+
+/* Trivial function, just so that GDB can test return with wrong GCSPR. */
+static void __attribute__ ((noinline))
+normal_function0 (void)
+{
+ /* Use explicit ret so that we can verify that a SIGSEGV was generated
+ exactly on the return instruction. */
+ __asm__ volatile ("ret\n");
+}
+
+int
+main (void)
+{
+ if (!(getauxval (AT_HWCAP) & HWCAP_GCS))
+ {
+ fprintf (stderr, "GCS support not found in AT_HWCAP\n");
+ return EXIT_FAILURE;
+ }
+
+ /* Force shadow stacks on, our tests *should* be fine with or
+ without libc support and with or without this having ended
+ up tagged for GCS and enabled by the dynamic linker. We
+ can't use the libc prctl() function since we can't return
+ from enabling the stack. Also lock GCS if not already
+ locked so we can test behaviour when it's locked. */
+ unsigned long gcs_mode;
+ int ret = my_syscall2 (__NR_prctl, PR_GET_SHADOW_STACK_STATUS, &gcs_mode);
+ if (ret)
+ {
+ fprintf (stderr, "Failed to read GCS state: %d\n", ret);
+ return EXIT_FAILURE;
+ }
+
+ if (!(gcs_mode & PR_SHADOW_STACK_ENABLE))
+ {
+ gcs_mode = PR_SHADOW_STACK_ENABLE;
+ ret = my_syscall2 (__NR_prctl, PR_SET_SHADOW_STACK_STATUS, gcs_mode);
+ if (ret)
+ {
+ fprintf (stderr, "Failed to configure GCS: %d\n", ret);
+ return EXIT_FAILURE;
+ }
+ }
+
+ /* Regular function call. */
+ normal_function0 ();
+
+ /* This is used by GDB. */
+ __attribute__((unused)) unsigned long *gcspr = get_gcspr ();
+
+ struct sigaction act = { 0 };
+
+ act.sa_handler = &handler; /* Break here. */
+ if (sigaction (SIGUSR1, &act, NULL) == -1)
+ {
+ perror ("sigaction");
+ exit (EXIT_FAILURE);
+ }
+
+ raise (SIGUSR1);
+
+/* Call sequence of inline and normal functions, to test GDB backtrace. */
+ inline_function1 ();
+
+ /* Avoid returning, in case libc doesn't understand GCS. */
+ exit (EXIT_SUCCESS);
+}
diff --git a/gdb/testsuite/gdb.arch/aarch64-gcs.exp b/gdb/testsuite/gdb.arch/aarch64-gcs.exp
new file mode 100644
index 0000000..b09e010
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-gcs.exp
@@ -0,0 +1,99 @@
+# Copyright 2025 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 a binary that uses a Guarded Control Stack.
+
+require allow_aarch64_gcs_tests
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
+ return
+}
+
+set linespec ${srcfile}:[gdb_get_line_number "Break here"]
+
+if ![runto ${linespec}] {
+ return
+}
+
+gdb_test "print \$gcs_features_enabled" \
+ [string_to_regexp { = [ PR_SHADOW_STACK_ENABLE ]}] \
+ "GCS is enabled"
+
+gdb_test "print \$gcspr" ". = \\(void \\*\\) $hex" "GDB knows about gcspr"
+gdb_test "print \$gcspr == gcspr" ". = 1" "GDB has the correct gcspr value"
+gdb_test_no_output "set \$gcspr_in_main = \$gcspr" \
+ "save gcspr value in main for later"
+
+# If the inferior function call fails, we don't want the tests following it
+# to be affected.
+gdb_test_no_output "set unwindonsignal on"
+gdb_test "print called_from_gdb (41)" ". = 42" "call inferior function"
+
+gdb_test "break handler" "Breakpoint \[0-9\]+ .*aarch64-gcs.c, line \[0-9\]+\\."
+gdb_test "handle SIGUSR1 nostop" \
+ ".*\r\nSIGUSR1\\s+No\\s+Yes\\s+Yes\\s+User defined signal 1" \
+ "let the inferior receive SIGUSR1 uninterrupted"
+gdb_test "continue" \
+ ".*\r\nBreakpoint \[0-9\]+, handler \\(sig=10\\) at .*aarch64-gcs.c.*handler_gcspr = get_gcspr \\(\\);" \
+ "continue to signal handler"
+
+gdb_test_no_output "set \$gcspr_in_handler = \$gcspr" \
+ "save gcspr value in handler for later"
+# Select the frame above the <signal handler called> frame, which makes GDB
+# unwind the gcspr from the signal frame GCS context.
+gdb_test "frame 2" "#2 ($hex in )?\\S+ \\(.*\\) (at|from) \\S+.*" \
+ "reached frame 2"
+gdb_test "print \$gcspr" ". = \\(void \\*\\) $hex" "gcspr in frame level 2"
+gdb_test "print \$gcspr == \$gcspr_in_handler + 8" ". = 1" \
+ "gcspr unwound from signal context is correct"
+
+gdb_test "continue" \
+ [multi_line \
+ "Continuing\\." \
+ "" \
+ "Program received signal SIGSEGV, Segmentation fault" \
+ "Guarded Control Stack error\\." \
+ "normal_function2 \\(\\) at .*aarch64-gcs.c:$decimal" \
+ "${decimal}\\s+__asm__ volatile \\(\"ret\\\\n\"\\);"] \
+ "continue to SIGSEGV"
+
+gdb_test "print \$_siginfo.si_code" ". = 10" \
+ "test value of si_code when GCS SIGSEGV happens"
+# The GCS grows down, and there are two real frames until main.
+gdb_test "print \$gcspr == \$gcspr_in_main - 16" ". = 1" \
+ "test value of gcspr when GCS SIGSEGV happens"
+
+# Test writing to GCSPR.
+clean_restart
+gdb_load $binfile
+if ![runto normal_function0] {
+ return
+}
+
+gdb_test_no_output "set \$gcspr = 0xbadc0ffee" "set bogus gcspr value"
+# Continue to make sure that the value was actually written to the register.
+# The SIGSEGV isn't a GCS error because the problem isn't that the GCS entry
+# doesn't match the return address, but rather that that GCSPR is pointing
+# to an invalid address.
+gdb_test "continue" \
+ [multi_line \
+ "Continuing\\." \
+ "" \
+ "Program received signal SIGSEGV, Segmentation fault\\." \
+ "normal_function0 \\(\\) at .*aarch64-gcs.c:$decimal" \
+ "${decimal}\\s+__asm__ volatile \\(\"ret\\\\n\"\\);"] \
+ "continue after bad gcspr"
diff --git a/gdb/testsuite/gdb.arch/aarch64-mte-core.exp b/gdb/testsuite/gdb.arch/aarch64-mte-core.exp
index fdaa061..7da836e 100644
--- a/gdb/testsuite/gdb.arch/aarch64-mte-core.exp
+++ b/gdb/testsuite/gdb.arch/aarch64-mte-core.exp
@@ -145,7 +145,8 @@ proc test_mode { mode } {
# both correctly.
if {$gcore_generated} {
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
with_test_prefix "gcore corefile" {
test_mte_core_file $gcore_filename $mode
}
@@ -154,7 +155,8 @@ proc test_mode { mode } {
}
if {$core_generated} {
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
with_test_prefix "native corefile" {
test_mte_core_file $core_filename $mode
}
diff --git a/gdb/testsuite/gdb.arch/aarch64-pseudo-unwind.exp b/gdb/testsuite/gdb.arch/aarch64-pseudo-unwind.exp
index 7ce1fdf..e835ddf 100644
--- a/gdb/testsuite/gdb.arch/aarch64-pseudo-unwind.exp
+++ b/gdb/testsuite/gdb.arch/aarch64-pseudo-unwind.exp
@@ -29,7 +29,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
return -1
}
-clean_restart ${binfile}
+clean_restart $testfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl b/gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl
index 44d0808..64cfd54 100644
--- a/gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl
+++ b/gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl
@@ -91,7 +91,8 @@ proc generate_sme_core_files { executable binfile id state vl svl} {
# and the native one generated by the Linux Kernel. Make sure GDB can read
# both correctly.
if {$gcore_generated} {
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
gdb_test_no_output "set print repeats 1" \
"adjust repeat count post-crash gcore"
@@ -103,7 +104,8 @@ proc generate_sme_core_files { executable binfile id state vl svl} {
}
if {$core_generated} {
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
gdb_test_no_output "set print repeats 1" \
"adjust repeat count post-crash native core"
diff --git a/gdb/testsuite/gdb.arch/alpha-step.exp b/gdb/testsuite/gdb.arch/alpha-step.exp
index e41bd97..bdbfeec 100644
--- a/gdb/testsuite/gdb.arch/alpha-step.exp
+++ b/gdb/testsuite/gdb.arch/alpha-step.exp
@@ -25,7 +25,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {}] !
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
proc test_stepi {function } {
# Restart the program from scratch. If GDB got confused during one
diff --git a/gdb/testsuite/gdb.arch/altivec-abi.exp b/gdb/testsuite/gdb.arch/altivec-abi.exp
index 12f523b..fb5367d 100644
--- a/gdb/testsuite/gdb.arch/altivec-abi.exp
+++ b/gdb/testsuite/gdb.arch/altivec-abi.exp
@@ -47,7 +47,8 @@ proc altivec_abi_tests { extra_flags force_abi } {
}
}
- clean_restart $binfile
+ clean_restart
+ gdb_load $::binfile
# Run to `main' where we begin our tests.
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.arch/amd64-byte.exp b/gdb/testsuite/gdb.arch/amd64-byte.exp
index ac70672..d084303 100644
--- a/gdb/testsuite/gdb.arch/amd64-byte.exp
+++ b/gdb/testsuite/gdb.arch/amd64-byte.exp
@@ -27,7 +27,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list
return
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.arch/amd64-dword.exp b/gdb/testsuite/gdb.arch/amd64-dword.exp
index e8a527d..cd3d76b 100644
--- a/gdb/testsuite/gdb.arch/amd64-dword.exp
+++ b/gdb/testsuite/gdb.arch/amd64-dword.exp
@@ -27,7 +27,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list
return
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis-no-cfi.S b/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis-no-cfi.S
new file mode 100644
index 0000000..39cf3e6
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis-no-cfi.S
@@ -0,0 +1,117 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2025 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 compiled from gdb.arch/amd64-extended-prologue-analysis.c
+ using gcc 11.4.0 with flags: -g0 -O1 -S -fno-omit-frame-pointer
+ -fno-asynchronous-unwind-tables. */
+
+ .file "amd64-extended-prologue-analysis.c"
+ .text
+ .globl bar
+ .type bar, @function
+bar:
+ endbr64
+ leal (%rdi,%rdi), %eax
+ ret
+ .size bar, .-bar
+ .globl foo
+ .type foo, @function
+foo:
+ endbr64
+ pushq %rbp
+ movq %rsp, %rbp
+ pushq %r15
+ pushq %r14
+ pushq %r13
+ pushq %r12
+ pushq %rbx
+ subq $280, %rsp
+ movl %edi, %ebx
+ movl %esi, %r14d
+ movl %edx, %r13d
+ movl %ecx, %r12d
+ movq %fs:40, %rax
+ movq %rax, -56(%rbp)
+ xorl %eax, %eax
+.L3:
+ leal (%rbx,%rax), %ecx
+ movslq %eax, %rdx
+ movb %cl, -320(%rbp,%rdx)
+ addl $1, %eax
+ cmpl $256, %eax
+ jne .L3
+ movl %ebx, %edi
+ call bar
+ movl %eax, %r15d
+ movl %r14d, %edi
+ call bar
+ leal (%r15,%rax), %r14d
+ movl %r13d, %edi
+ call bar
+ addl %eax, %r14d
+ movl %r12d, %edi
+ call bar
+ addl %r14d, %eax
+ addl %ebx, %eax
+ movq -56(%rbp), %rdx
+ subq %fs:40, %rdx
+ jne .L7
+ addq $280, %rsp
+ popq %rbx
+ popq %r12
+ popq %r13
+ popq %r14
+ popq %r15
+ popq %rbp
+ ret
+.L7:
+ call __stack_chk_fail@PLT
+ .size foo, .-foo
+ .globl main
+ .type main, @function
+main:
+ endbr64
+ pushq %rbp
+ movq %rsp, %rbp
+ subq $16, %rsp
+ leal (%rdi,%rdi), %ecx
+ leal 2(%rdi), %edx
+ leal 1(%rdi), %esi
+ call foo
+ movl %eax, -4(%rbp)
+ movl -4(%rbp), %eax
+ leave
+ ret
+ .size main, .-main
+ .ident "GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
+ .section .note.GNU-stack,"",@progbits
+ .section .note.gnu.property,"a"
+ .align 8
+ .long 1f - 0f
+ .long 4f - 1f
+ .long 5
+0:
+ .string "GNU"
+1:
+ .align 8
+ .long 0xc0000002
+ .long 3f - 2f
+2:
+ .long 0x3
+3:
+ .align 8
+4:
diff --git a/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis-offset.S b/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis-offset.S
new file mode 100644
index 0000000..ea001b3
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis-offset.S
@@ -0,0 +1,112 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2025 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 compiled from gdb.arch/amd64-extended-prologue-analysis.c
+ using gcc 11.4.0 with flags: -g0 -O1 -S -fomit-frame-pointer
+ -fno-asynchronous-unwind-tables. */
+
+ .file "amd64-extended-prologue-analysis.c"
+ .text
+ .globl bar
+ .type bar, @function
+bar:
+ endbr64
+ leal (%rdi,%rdi), %eax
+ ret
+ .size bar, .-bar
+ .globl foo
+ .type foo, @function
+foo:
+ endbr64
+ pushq %r14
+ pushq %r13
+ pushq %r12
+ pushq %rbp
+ pushq %rbx
+ subq $272, %rsp
+ movl %edi, %ebx
+ movl %esi, %r13d
+ movl %edx, %r12d
+ movl %ecx, %ebp
+ movq %fs:40, %rax
+ movq %rax, 264(%rsp)
+ xorl %eax, %eax
+.L3:
+ leal (%rbx,%rax), %ecx
+ movslq %eax, %rdx
+ movb %cl, (%rsp,%rdx)
+ addl $1, %eax
+ cmpl $256, %eax
+ jne .L3
+ movl %ebx, %edi
+ call bar
+ movl %eax, %r14d
+ movl %r13d, %edi
+ call bar
+ leal (%r14,%rax), %r13d
+ movl %r12d, %edi
+ call bar
+ addl %eax, %r13d
+ movl %ebp, %edi
+ call bar
+ addl %r13d, %eax
+ addl %ebx, %eax
+ movq 264(%rsp), %rdx
+ subq %fs:40, %rdx
+ jne .L7
+ addq $272, %rsp
+ popq %rbx
+ popq %rbp
+ popq %r12
+ popq %r13
+ popq %r14
+ ret
+.L7:
+ call __stack_chk_fail@PLT
+ .size foo, .-foo
+ .globl main
+ .type main, @function
+main:
+ endbr64
+ subq $24, %rsp
+ leal (%rdi,%rdi), %ecx
+ leal 2(%rdi), %edx
+ leal 1(%rdi), %esi
+ call foo
+ movl %eax, 12(%rsp)
+ movl 12(%rsp), %eax
+ addq $24, %rsp
+ ret
+ .size main, .-main
+ .ident "GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
+ .section .note.GNU-stack,"",@progbits
+ .section .note.gnu.property,"a"
+ .align 8
+ .long 1f - 0f
+ .long 4f - 1f
+ .long 5
+0:
+ .string "GNU"
+1:
+ .align 8
+ .long 0xc0000002
+ .long 3f - 2f
+2:
+ .long 0x3
+3:
+ .align 8
+4:
diff --git a/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis.S b/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis.S
new file mode 100644
index 0000000..691eee0
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis.S
@@ -0,0 +1,143 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2025 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 compiled from gdb.arch/amd64-extended-prologue-analysis.c
+ using gcc 11.4.0 with flags: -g0 -O1 -S -fno-omit-frame-pointer. */
+
+ .file "amd64-extended-prologue-analysis.c"
+ .text
+ .globl bar
+ .type bar, @function
+bar:
+.LFB0:
+ .cfi_startproc
+ endbr64
+ leal (%rdi,%rdi), %eax
+ ret
+ .cfi_endproc
+.LFE0:
+ .size bar, .-bar
+ .globl foo
+ .type foo, @function
+foo:
+.LFB1:
+ .cfi_startproc
+ endbr64
+ pushq %rbp
+ .cfi_def_cfa_offset 16
+ .cfi_offset 6, -16
+ movq %rsp, %rbp
+ .cfi_def_cfa_register 6
+ pushq %r15
+ pushq %r14
+ pushq %r13
+ pushq %r12
+ pushq %rbx
+ subq $280, %rsp
+ .cfi_offset 15, -24
+ .cfi_offset 14, -32
+ .cfi_offset 13, -40
+ .cfi_offset 12, -48
+ .cfi_offset 3, -56
+ movl %edi, %ebx
+ movl %esi, %r14d
+ movl %edx, %r13d
+ movl %ecx, %r12d
+ movq %fs:40, %rax
+ movq %rax, -56(%rbp)
+ xorl %eax, %eax
+.L3:
+ leal (%rbx,%rax), %ecx
+ movslq %eax, %rdx
+ movb %cl, -320(%rbp,%rdx)
+ addl $1, %eax
+ cmpl $256, %eax
+ jne .L3
+ movl %ebx, %edi
+ call bar
+ movl %eax, %r15d
+ movl %r14d, %edi
+ call bar
+ leal (%r15,%rax), %r14d
+ movl %r13d, %edi
+ call bar
+ addl %eax, %r14d
+ movl %r12d, %edi
+ call bar
+ addl %r14d, %eax
+ addl %ebx, %eax
+ movq -56(%rbp), %rdx
+ subq %fs:40, %rdx
+ jne .L7
+ addq $280, %rsp
+ popq %rbx
+ popq %r12
+ popq %r13
+ popq %r14
+ popq %r15
+ popq %rbp
+ .cfi_remember_state
+ .cfi_def_cfa 7, 8
+ ret
+.L7:
+ .cfi_restore_state
+ call __stack_chk_fail@PLT
+ .cfi_endproc
+.LFE1:
+ .size foo, .-foo
+ .globl main
+ .type main, @function
+main:
+.LFB2:
+ .cfi_startproc
+ endbr64
+ pushq %rbp
+ .cfi_def_cfa_offset 16
+ .cfi_offset 6, -16
+ movq %rsp, %rbp
+ .cfi_def_cfa_register 6
+ subq $16, %rsp
+ leal (%rdi,%rdi), %ecx
+ leal 2(%rdi), %edx
+ leal 1(%rdi), %esi
+ call foo
+ movl %eax, -4(%rbp)
+ movl -4(%rbp), %eax
+ leave
+ .cfi_def_cfa 7, 8
+ ret
+ .cfi_endproc
+.LFE2:
+ .size main, .-main
+ .ident "GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
+ .section .note.GNU-stack,"",@progbits
+ .section .note.gnu.property,"a"
+ .align 8
+ .long 1f - 0f
+ .long 4f - 1f
+ .long 5
+0:
+ .string "GNU"
+1:
+ .align 8
+ .long 0xc0000002
+ .long 3f - 2f
+2:
+ .long 0x3
+3:
+ .align 8
+4:
diff --git a/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis.c b/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis.c
new file mode 100644
index 0000000..707b4fb
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis.c
@@ -0,0 +1,56 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2025 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 __attribute__ ((noinline))
+bar (int x)
+{
+ return x + x;
+}
+
+/* This function should generate a prologue in shape of:
+ push %rbp
+ .cfi_def_cfa_offset 16
+ .cfi_offset %rbp, -16
+ mov %rsp, %rbp
+ .cfi_def_cfa_register %rbp
+ push %reg1
+ push %reg2
+ sub $XXX, %rsp
+ .cfi_offset %reg2, 32
+ .cfi_offset %reg1, 24
+
+ So to be able to unwind a register, GDB needs to skip prologue past
+ register pushes and stack allocation (to access .cfi directives). */
+int __attribute__ ((noinline))
+foo (int a, int b, int c, int d)
+{
+ /* "volatile" alone isn't enough for clang to not optimize it out and
+ allocate space on the stack. */
+ volatile char s[256];
+ for (int i = 0; i < 256; i++)
+ s[i] = (char) (a + i);
+
+ a += bar (a) + bar (b) + bar (c) + bar (d);
+ return a;
+}
+
+int
+main (int argc, char **argv)
+{
+ volatile int a = foo (argc, argc + 1, argc + 2, argc * 2);
+ return a;
+}
diff --git a/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis.exp b/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis.exp
new file mode 100644
index 0000000..356afc7
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis.exp
@@ -0,0 +1,208 @@
+# Copyright 2025 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 test verifies that when placing a breakpoint on a function with a frame
+# pointer, instructions that push callee-saved registers and stack allocation
+# in the prologue are skipped, without debug info. When stopped on such
+# breakpoint, the pushed registers should be able to be immediately unwound.
+# With debug info present, GDB would try to use prologue-end markers found in
+# the line table to determine where the prologue ends.
+#
+# It is also tested both with and without .eh_frame's .cfi directives - with
+# them, GDB can only unwind a register once stopped after .cfi directive for
+# that register's push.
+
+require is_x86_64_m64_target
+standard_testfile .c -no-cfi.S .S -offset.S
+
+proc test_run {} {
+ gdb_breakpoint "foo"
+ gdb_continue_to_breakpoint "Continue to foo"
+
+ gdb_test "backtrace" "#0\[^\r\n\]+in foo\[^s\]+#1\[^\r\n\]+in main\[^s\]+" \
+ "Verify backtrace output in foo"
+
+ set main_r12 [get_integer_valueof "\$r12" "null"]
+ gdb_assert { $main_r12 ne "null" }
+
+ set foo_r12 [expr "$main_r12 + 2"]
+ gdb_test "print \$r12=$foo_r12" "$foo_r12" "Set foo's %r12=$foo_r12"
+ gdb_test "up" ".*main.*" "Go up a frame from foo"
+ gdb_test "print \$r12" "$main_r12" "foo's %r12 unwound"
+ gdb_test "down" ".*foo.*" "Go back down a frame to foo"
+ gdb_test "print \$r12" "$foo_r12" "foo's %r12 unwound back"
+}
+
+proc offset_test_run {} {
+ gdb_breakpoint "*foo"
+ gdb_continue_to_breakpoint "Continue to entry of foo"
+
+ set old_reg_val [get_integer_valueof "\$r12" "null"]
+ gdb_assert { $old_reg_val ne "null" }
+
+ set new_reg_val [expr "$old_reg_val + 3"]
+ gdb_test "print \$r14=$new_reg_val" "$new_reg_val" "Set %r14=$new_reg_val"
+ gdb_test "print \$r13=$new_reg_val" "$new_reg_val" "Set %r13=$new_reg_val"
+ gdb_test "print \$r12=$new_reg_val" "$new_reg_val" "Set %r12=$new_reg_val"
+
+ set addr_past_prologue "null"
+ gdb_test_multiple "disassemble" "Disassemble foo" -lbl {
+ -re "\r\n\\s*($::hex) <\\+($::decimal)>:\\s*mov.*(?=\r\n)" {
+ set addr_past_prologue $expect_out(1,string)
+ exp_continue
+ }
+
+ -re -wrap "" {
+ gdb_assert { $addr_past_prologue ne "null" } $gdb_test_name
+ }
+ }
+
+ gdb_assert { $addr_past_prologue ne "null" }
+
+ gdb_breakpoint "*$addr_past_prologue"
+ gdb_continue_to_breakpoint "Continue past foo's prologue"
+
+ gdb_test "up" ".*main.*" "Go up a frame from foo"
+ gdb_test "print \$r14" "$new_reg_val" "Verify %r14 value"
+ gdb_test "print \$r13" "$new_reg_val" "Verify %r13 value"
+ gdb_test "print \$r12" "$new_reg_val" "Verify %r12 value"
+}
+
+# Tests are done for two versions (not counting with and w/o .cfi):
+# - binary compiled from C source, which verifies we actually test against
+# the code that compilers produce and we expect
+# - binary compiled from ASM source, which verifies that we properly analyze
+# prologue sequences even when compiler introduces a sudden change in how
+# it generates assembly
+#
+# With those 2 versions, we can easily distinguish GDB breaking analyzer and
+# compilers behaving differently, if there ever is an impactful change in how
+# they generate prologues.
+with_test_prefix "w/o .cfi directives" {
+ with_test_prefix "compiler gen" {
+ # -fno-asynchronous-unwind-tables is needed to get rid of .cfi
+ # directives in .eh_frame section.
+ if { [gdb_can_simple_compile fno-asynchronous-unwind-tables \
+ { void foo () { } } object -fno-asynchronous-unwind-tables] == 0 } {
+ unsupported \
+ "compiler doesn't support -fno-asynchronous-unwind-tables flag"
+ } else {
+ # For at least gcc 11.4/clang 14.0.0 and later, -O1 makes them more
+ # eager to use registers in the prologue.
+ #
+ # At least gcc 11.4 and later by default does not generate full
+ # debug info, "nodebug" is there for other compilers.
+ if { [prepare_for_testing "failed to prepare" "$testfile-no-cfi-C" \
+ $srcfile { optimize=-O1 nodebug
+ additional_flags=-fno-asynchronous-unwind-tables
+ additional_flags=-fno-omit-frame-pointer}] } {
+ return
+ }
+
+ if { ![runto_main] } {
+ untested "unable to run to main"
+ return
+ }
+
+ test_run
+ }
+ }
+
+ with_test_prefix "ASM source" {
+ if { [prepare_for_testing "failed to prepare" "$testfile-no-cfi-S" \
+ $srcfile2 nodebug ] } {
+ return
+ }
+
+ if { ![runto_main] } {
+ untested "unable to run to main"
+ return
+ }
+
+ test_run
+ }
+}
+
+with_test_prefix "with .cfi directives" {
+ with_test_prefix "compiler gen" {
+ if { [prepare_for_testing "failed to prepare" "$testfile-cfi-C" \
+ $srcfile { optimize=-O1
+ nodebug additional_flags=-fno-omit-frame-pointer}] } {
+ return
+ }
+
+ if { ![runto_main] } {
+ untested "unable to run to main"
+ return
+ }
+
+ test_run
+ }
+
+ with_test_prefix "ASM source" {
+ if { [prepare_for_testing "failed to prepare" "$testfile-cfi-S" \
+ $srcfile3 nodebug ] } {
+ return
+ }
+
+ if { ![runto_main] } {
+ untested "unable to run to main"
+ return
+ }
+
+ test_run
+ }
+}
+
+# This section exists to verify that we properly assign offsets for functions
+# w/o a frame pointer, for registers when they're pushed. If they were assigned
+# in a wrong way, we might end up unwinding improper register values.
+with_test_prefix "offset initialization" {
+ with_test_prefix "compiler gen" {
+ if { [gdb_can_simple_compile fno-asynchronous-unwind-tables \
+ { void foo () { } } object -fno-asynchronous-unwind-tables] == 0 } {
+ unsupported \
+ "compiler doesn't support -fno-asynchronous-unwind-tables flag"
+ } else {
+ if { [prepare_for_testing "failed to prepare" "$testfile-offset-C" \
+ $srcfile { optimize=-O1 nodebug
+ additional_flags=-fno-asynchronous-unwind-tables
+ additional_flags=-fomit-frame-pointer}] } {
+ return
+ }
+
+ if { ![runto_main] } {
+ untested "unable to run to main"
+ return
+ }
+
+ offset_test_run
+ }
+ }
+
+ with_test_prefix "ASM source" {
+ if { [prepare_for_testing "failed to prepare" "$testfile-offset-S" \
+ $srcfile4 nodebug ] } {
+ return
+ }
+
+ if { ![runto_main] } {
+ untested "unable to run to main"
+ return
+ }
+
+ offset_test_run
+ }
+}
diff --git a/gdb/testsuite/gdb.arch/amd64-frameptr-vecreg-unwind.c b/gdb/testsuite/gdb.arch/amd64-frameptr-vecreg-unwind.c
new file mode 100644
index 0000000..1b79a65
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-frameptr-vecreg-unwind.c
@@ -0,0 +1,63 @@
+/* Copyright 2025 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/>. */
+
+volatile void dummy () {}
+
+long test_function(void)
+{
+ __asm__ volatile (
+ /* Clear xmm0. */
+ "vxorps %%xmm0, %%xmm0, %%xmm0\n\t"
+
+ /* Move the frame pointer (rbp) to xmm0. */
+ "movq %%rbp, %%xmm0\n\t"
+
+ /* CFI: Frame pointer is in xmm0. */
+ ".cfi_register %%rbp, %%xmm0\n\t"
+
+ /* Clobber list: Specify all modified registers */
+ : // No output operands
+ : // No input operands
+ : "xmm0"
+ );
+
+ dummy (); /* break-here */
+
+ /* Pseudo-epilogue: Restore rbp from xmm0. */
+ __asm__ volatile (
+ /* Restore rbp. */
+ "movq %%xmm0, %%rbp\n\t"
+
+ /* Describe CFI: Frame pointer is restored. */
+ ".cfi_restore %%rbp\n\t"
+
+ /* Clobber list: Specify all modified registers */
+ : /* No output operands. */
+ : /* No input operands. */
+ : /* Despite clobbering rbp, gcc doesn't let us list it here. */
+ );
+
+ return 0;
+}
+
+int
+main ()
+{
+ long result = test_function ();
+ dummy ();
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/amd64-frameptr-vecreg-unwind.exp b/gdb/testsuite/gdb.arch/amd64-frameptr-vecreg-unwind.exp
new file mode 100644
index 0000000..3c0b319
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-frameptr-vecreg-unwind.exp
@@ -0,0 +1,40 @@
+# Copyright 2025 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 test verifies that we can read and write the value of a pseudo register
+# in unwound frames. For the test, we choose one raw register, rbx, and one
+# pseudo register that is backed by rbx, ebx. We have two frames (the inner one,
+# #0 and the outer one, #1) that each set a value for rbx. We verify that we
+# can read both rbx and ebx correctly for each frame, and that when we write to
+# ebx, rbx for that frame is correctly updated.
+
+require is_x86_64_m64_target
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" ${testfile} \
+ "${srcfile}" {debug}] } {
+ return -1
+}
+
+if {![runto_main]} {
+ return
+}
+
+gdb_breakpoint [gdb_get_line_number "break-here"]
+gdb_continue_to_breakpoint "break-here"
+gdb_test "with confirm off --return -1" "result = test_function \\(\\);"
+gdb_test "step" "dummy \\(\\);"
+gdb_test "print result" "= -1"
diff --git a/gdb/testsuite/gdb.arch/amd64-init-x87-values.exp b/gdb/testsuite/gdb.arch/amd64-init-x87-values.exp
index 11004fa..5bbadaf 100644
--- a/gdb/testsuite/gdb.arch/amd64-init-x87-values.exp
+++ b/gdb/testsuite/gdb.arch/amd64-init-x87-values.exp
@@ -24,7 +24,7 @@ standard_testfile .S
set options [list debug \
additional_flags=-static \
- additional_flags=-nostartfiles]
+ ldflags=-nostartfiles]
if { [build_executable "failed to prepare" ${testfile} ${srcfile} $options] } {
return -1
}
@@ -40,7 +40,7 @@ if { [build_executable "failed to prepare" ${testfile} ${srcfile} $options] } {
proc_with_prefix check_x87_regs_around_init {} {
global binfile
- clean_restart ${binfile}
+ clean_restart ${::testfile}
# Get things started.
if {![runto_main]} {
@@ -115,7 +115,7 @@ proc_with_prefix check_x87_regs_around_init {} {
proc_with_prefix check_setting_mxcsr_before_enable {} {
global binfile gdb_prompt
- clean_restart ${binfile}
+ clean_restart ${::testfile}
if {![runto_main]} {
return 0
@@ -149,7 +149,7 @@ proc_with_prefix check_setting_mxcsr_before_enable {} {
proc_with_prefix check_setting_x87_regs_before_enable {} {
global binfile
- clean_restart ${binfile}
+ clean_restart ${::testfile}
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp b/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp
index 03ecba6..451c84b 100644
--- a/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp
+++ b/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp
@@ -45,7 +45,7 @@ gdb_test "bt" "^#0 +breakpt *\\(\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in func5\[^\
gdb_test "bt" "^#0 +breakpt *\\(\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in func5\[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in func4\[^\r\n\]*\r\n#3 +0x\[0-9a-f\]+ in func3\[^\r\n\]*\r\nBacktrace stopped: Cannot access memory at address 0x\[0-9a-f\]+" \
"second backtrace, with error message"
-clean_restart ${binfile}
+clean_restart ${::testfile}
if ![runto breakpt] {
return -1
@@ -59,7 +59,7 @@ gdb_test "interpreter-exec mi \"-stack-info-depth\"" \
"\\^done,depth=\"4\"" \
"check mi -stack-info-depth command, second time"
-clean_restart ${binfile}
+clean_restart ${::testfile}
if ![runto breakpt] {
return -1
diff --git a/gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp b/gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp
index 134dfda..b715ecf 100644
--- a/gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp
+++ b/gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp
@@ -49,7 +49,7 @@ gdb_test "bt no-filters" "^#0 +$hex in func2 \\(\\)\r\nBacktrace stopped: Cannot
gdb_test "bt no-filters" "^#0 +$hex in func2 \\(\\)\r\nBacktrace stopped: Cannot access memory at address 0x\[0-9a-f\]+" \
"second backtrace, with error message"
-clean_restart ${binfile}
+clean_restart ${::testfile}
if ![runto breakpt] {
return -1
@@ -63,7 +63,7 @@ gdb_test "interpreter-exec mi \"-stack-info-depth\"" \
"\\^done,depth=\"1\"" \
"check mi -stack-info-depth command, second time"
-clean_restart ${binfile}
+clean_restart ${::testfile}
if ![runto breakpt] {
return -1
diff --git a/gdb/testsuite/gdb.arch/amd64-prologue-skip.exp b/gdb/testsuite/gdb.arch/amd64-prologue-skip.exp
index 04f3266..c96c0c7 100644
--- a/gdb/testsuite/gdb.arch/amd64-prologue-skip.exp
+++ b/gdb/testsuite/gdb.arch/amd64-prologue-skip.exp
@@ -14,7 +14,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
standard_testfile .S
-set binfile ${binfile}.o
+set testfile $testfile.o
+set binfile [standard_output_file $testfile]
require is_x86_64_m64_target
@@ -23,7 +24,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {debug}]
return
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_test "break *pushrbp" " at 0x1: file .*"
gdb_test "break pushrbp" " at 0x1: file .*"
diff --git a/gdb/testsuite/gdb.arch/amd64-prologue-xmm.exp b/gdb/testsuite/gdb.arch/amd64-prologue-xmm.exp
index 7c16238..8447973 100644
--- a/gdb/testsuite/gdb.arch/amd64-prologue-xmm.exp
+++ b/gdb/testsuite/gdb.arch/amd64-prologue-xmm.exp
@@ -28,7 +28,7 @@ if [info exists COMPILE] {
require is_x86_64_m64_target
}
-if {[prepare_for_testing "failed to prepare" ${binfile} $srcfile $opts]} {
+if {[prepare_for_testing "failed to prepare" ${testfile} $srcfile $opts]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/amd64-pseudo-unwind.exp b/gdb/testsuite/gdb.arch/amd64-pseudo-unwind.exp
index 6333311..49721dd 100644
--- a/gdb/testsuite/gdb.arch/amd64-pseudo-unwind.exp
+++ b/gdb/testsuite/gdb.arch/amd64-pseudo-unwind.exp
@@ -32,7 +32,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.arch/amd64-shadow-stack-cmds.exp b/gdb/testsuite/gdb.arch/amd64-shadow-stack-cmds.exp
new file mode 100644
index 0000000..0ae172d
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-shadow-stack-cmds.exp
@@ -0,0 +1,143 @@
+# Copyright 2024-2025 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 shadow stack enabling for frame level update, the return and the
+# call commands.
+# As potential CET violations often only occur after resuming normal
+# execution, test normal program continuation after each return or call
+# commands.
+
+require allow_ssp_tests
+
+standard_testfile amd64-shadow-stack.c
+
+# Restart GDB an run until breakpoint in call2.
+
+proc restart_and_run_infcall_call2 {} {
+ global binfile
+ clean_restart ${::testfile}
+ if { ![runto_main] } {
+ return -1
+ }
+ set inside_infcall_str "The program being debugged stopped while in a function called from GDB"
+ gdb_breakpoint [ gdb_get_line_number "break call2" ]
+ gdb_continue_to_breakpoint "break call2" ".*break call2.*"
+ gdb_test "call (int) call2()" \
+ "Breakpoint \[0-9\]*, call2.*$inside_infcall_str.*"
+}
+
+save_vars { ::env(GLIBC_TUNABLES) } {
+
+ append_environment GLIBC_TUNABLES "glibc.cpu.hwcaps" "SHSTK"
+
+ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
+ {debug additional_flags="-fcf-protection=return"}] } {
+ return -1
+ }
+
+ clean_restart ${::testfile}
+ if { ![runto_main] } {
+ return -1
+ }
+
+ with_test_prefix "test inferior call and continue" {
+ gdb_breakpoint [ gdb_get_line_number "break call1" ]
+ gdb_continue_to_breakpoint "break call1" ".*break call1.*"
+
+ gdb_test "call (int) call2()" "= 42"
+
+ gdb_continue_to_end
+ }
+
+ with_test_prefix "test return inside an inferior call" {
+ restart_and_run_infcall_call2
+
+ gdb_test "return" "\#0.*call2.*" \
+ "Test shadow stack return inside an inferior call" \
+ "Make.*return now\\? \\(y or n\\) " "y"
+
+ gdb_continue_to_end
+ }
+
+ with_test_prefix "test return 'above' an inferior call" {
+ restart_and_run_infcall_call2
+
+ gdb_test "frame 2" "call2 ().*" "move to frame 'above' inferior call"
+
+ gdb_test "return" "\#0.*call1.*" \
+ "Test shadow stack return 'above' an inferior call" \
+ "Make.*return now\\? \\(y or n\\) " "y"
+
+ gdb_continue_to_end
+ }
+
+ clean_restart ${::testfile}
+ if { ![runto_main] } {
+ return -1
+ }
+
+ set call1_line [ gdb_get_line_number "break call1" ]
+ set call2_line [ gdb_get_line_number "break call2" ]
+
+ # Extract shadow stack pointer inside main, call1 and call2 function.
+ gdb_breakpoint $call1_line
+ gdb_breakpoint $call2_line
+ set ssp_main [get_valueof /x "\$pl3_ssp" 0 "get value of ssp in main"]
+ gdb_continue_to_breakpoint "break call1" ".*break call1.*"
+ set ssp_call1 [get_valueof /x "\$pl3_ssp" 0 "get value of ssp in call1"]
+ gdb_continue_to_breakpoint "break call2" ".*break call2.*"
+ set ssp_call2 [get_valueof /x "\$pl3_ssp" 0 "get value of ssp in call2"]
+
+ with_test_prefix "test frame level update" {
+ gdb_test "up" "call1.*" "move to frame 1"
+ gdb_test "print /x \$pl3_ssp" "= $ssp_call1" "check pl3_ssp of frame 1"
+ gdb_test "up" "main.*" "move to frame 2"
+ gdb_test "print /x \$pl3_ssp" "= $ssp_main" "check pl3_ssp of frame 2"
+ gdb_test "frame 0" "call2.*" "move to frame 0"
+ gdb_test "print /x \$pl3_ssp" "= $ssp_call2" "check pl3_ssp of frame 0"
+ }
+
+ with_test_prefix "test return from current frame" {
+ gdb_test "return (int) 1" "#0.*call1.*" \
+ "Test shadow stack return from current frame" \
+ "Make.*return now\\? \\(y or n\\) " "y"
+
+ # Potential CET violations often only occur after resuming normal execution.
+ # Therefore, it is important to test normal program continuation after
+ # testing the return command.
+ gdb_continue_to_end
+ }
+
+ clean_restart ${::testfile}
+ if { ![runto_main] } {
+ return -1
+ }
+
+ with_test_prefix "test return from past frame" {
+ gdb_breakpoint $call2_line
+ gdb_continue_to_breakpoint "break call2" ".*break call2.*"
+
+ gdb_test "frame 1" ".*in call1.*"
+
+ gdb_test "return (int) 1" "#0.*main.*" \
+ "Test shadow stack return from past frame" \
+ "Make.*return now\\? \\(y or n\\) " "y"
+
+ # Potential CET violations often only occur after resuming normal execution.
+ # Therefore, it is important to test normal program continuation after
+ # testing the return command.
+ gdb_continue_to_end
+ }
+}
diff --git a/gdb/testsuite/gdb.arch/amd64-shadow-stack-corefile.c b/gdb/testsuite/gdb.arch/amd64-shadow-stack-corefile.c
new file mode 100644
index 0000000..5e84793
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-shadow-stack-corefile.c
@@ -0,0 +1,46 @@
+/* This test program is part of GDB, the GNU debugger.
+
+ Copyright 2025 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>
+
+/* Call the return instruction before function epilogue to trigger a
+ control-flow exception. */
+void
+function ()
+{
+ unsigned long ssp;
+ #ifndef __ILP32__
+ asm volatile ("xor %0, %0; rdsspq %0" : "=r" (ssp));
+ #else
+ asm volatile ("xor %0, %0; rdsspd %0" : "=r" (ssp));
+ #endif
+
+ /* Print ssp to stdout so that the testcase can capture it. */
+ printf ("%p\n", (void *) ssp);
+ fflush (stdout);
+
+ /* Manually cause a control-flow exception by executing a return
+ instruction before function epilogue, so the address atop the stack
+ is not the return instruction. */
+ __asm__ volatile ("ret\n");
+}
+
+int
+main (void)
+{
+ function (); /* Break here. */
+}
diff --git a/gdb/testsuite/gdb.arch/amd64-shadow-stack-corefile.exp b/gdb/testsuite/gdb.arch/amd64-shadow-stack-corefile.exp
new file mode 100644
index 0000000..039f528
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-shadow-stack-corefile.exp
@@ -0,0 +1,119 @@
+# Copyright 2024-2025 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 the shadow stack pointer note in core dumps.
+# Based on the corefile tests in gdb.arch/aarch64-gcs-core.exp.
+
+require allow_ssp_tests
+
+standard_testfile
+
+# Make sure GDB can read the given core file correctly.
+
+proc check_core_file {core_filename saved_pl3_ssp} {
+ global decimal
+
+ # Load the core file.
+ if [gdb_test "core $core_filename" \
+ [multi_line \
+ "Core was generated by .*\\." \
+ "Program terminated with signal SIGSEGV, Segmentation fault.*" \
+ "#0 function \\(\\) at .*amd64-shadow-stack-corefile.c:$decimal" \
+ "$decimal.*__asm__ volatile \\(\"ret\\\\n\"\\);"] \
+ "load core file"] {
+ return
+ }
+
+ # Check the value of ssp in the core file.
+ gdb_test "print/x \$pl3_ssp" "\\$\[0-9\]+ = $saved_pl3_ssp" \
+ "pl3_ssp contents from core file $saved_pl3_ssp"
+}
+
+save_vars { ::env(GLIBC_TUNABLES) } {
+
+ append_environment GLIBC_TUNABLES "glibc.cpu.hwcaps" "SHSTK"
+
+ if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
+ {debug additional_flags="-fcf-protection=return"}] } {
+ return
+ }
+
+ set linespec ${srcfile}:[gdb_get_line_number "Break here"]
+
+ if ![runto $linespec] {
+ return
+ }
+
+ # Obtain an OS-generated core file. Save test program output to
+ # ${binfile}.out.
+ set core_filename [core_find $binfile {} {} "${binfile}.out"]
+ set core_generated [expr {$core_filename != ""}]
+
+ if {!$core_generated} {
+ untested "unable to create or find corefile"
+ }
+
+ # Load the core file and check the value of the shadow stack pointer.
+ if {$core_generated} {
+ clean_restart $::testfile
+
+ with_test_prefix "OS corefile" {
+ # Read ssp value from saved output of the test program.
+ set out_id [open ${binfile}.out "r"]
+ set ssp_in_gcore [gets $out_id]
+ close $out_id
+ check_core_file $core_filename $ssp_in_gcore
+ }
+ }
+
+ if ![gcore_cmd_available] {
+ unsupported "target does not support gcore command."
+ return
+ }
+
+ clean_restart $::testfile
+
+ if ![runto $linespec] {
+ return
+ }
+
+ # Continue until a crash. The line with the hex number is optional because
+ # it's printed by the test program, and doesn't appear in the Expect buffer
+ # when testing a remote target.
+
+ gdb_test "continue" \
+ [multi_line \
+ "Continuing\\." \
+ "($hex\r\n)?" \
+ "Program received signal SIGSEGV, Segmentation fault.*" \
+ "function \\(\\) at .*amd64-shadow-stack-corefile.c:$decimal" \
+ {.*__asm__ volatile \("ret\\n"\);}] \
+ "continue to SIGSEGV"
+
+ set ssp_in_gcore [get_valueof "/x" "\$pl3_ssp" "*unknown*"]
+
+ # Generate the gcore core file.
+ set gcore_filename [standard_output_file "${testfile}.gcore"]
+ set gcore_generated [gdb_gcore_cmd "$gcore_filename" "generate gcore file"]
+
+ gdb_assert { $gcore_generated } "gcore corefile created"
+ if { $gcore_generated } {
+ clean_restart $::testfile
+
+ with_test_prefix "gcore corefile" {
+ check_core_file $gcore_filename $ssp_in_gcore
+ }
+ }
+}
diff --git a/gdb/testsuite/gdb.arch/amd64-shadow-stack-disp-step.exp b/gdb/testsuite/gdb.arch/amd64-shadow-stack-disp-step.exp
new file mode 100644
index 0000000..e4efa00
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-shadow-stack-disp-step.exp
@@ -0,0 +1,84 @@
+# Copyright 2025 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 continue from call instructions with shadow stack and displaced
+# stepping being enabled.
+
+require allow_ssp_tests support_displaced_stepping
+
+standard_testfile amd64-shadow-stack.c
+
+save_vars { ::env(GLIBC_TUNABLES) } {
+
+ append_environment GLIBC_TUNABLES "glibc.cpu.hwcaps" "SHSTK"
+
+ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
+ additional_flags="-fcf-protection=return"] } {
+ return
+ }
+
+ # Enable displaced stepping.
+ gdb_test_no_output "set displaced-stepping on"
+ gdb_test "show displaced-stepping" ".* displaced stepping .* is on.*"
+
+ if { ![runto_main] } {
+ return
+ }
+
+ # Get the address of the call to the call1 function.
+ set call1_addr -1
+ gdb_test_multiple "disassemble main" "" {
+ -re -wrap "($hex) <\\+($decimal)>:\\s*call\\s*0x.*<call1>.*" {
+ set call1_addr $expect_out(1,string)
+ pass $gdb_test_name
+ }
+ }
+
+ if { $call1_addr == -1 } {
+ return
+ }
+
+ # Get the address of the call to the call2 function.
+ set call2_addr -1
+ gdb_test_multiple "disassemble call1" "" {
+ -re -wrap "($hex) <\\+($decimal)>:\\s*call\\s*0x.*<call2>.*" {
+ set call2_addr $expect_out(1,string)
+ pass $gdb_test_name
+ }
+ }
+
+ if { $call2_addr == -1 } {
+ return
+ }
+
+ gdb_test "break *$call1_addr" \
+ "Breakpoint $decimal at $hex.*" \
+ "break at the address of the call1 instruction"
+
+ gdb_test "break *$call2_addr" \
+ "Breakpoint $decimal at $hex.*" \
+ "break at the address of the call2 instruction"
+
+ gdb_test "continue" \
+ "Breakpoint $decimal, $call1_addr in main ().*" \
+ "continue until call1 instruction"
+
+ # Test continue from breakpoint at call1 and call2 instructions.
+ gdb_test "continue" \
+ "Breakpoint $decimal, $call2_addr in call1 ().*" \
+ "continue from call1 instruction"
+
+ gdb_continue_to_end "continue from call2 instruction"
+}
diff --git a/gdb/testsuite/gdb.arch/amd64-shadow-stack.c b/gdb/testsuite/gdb.arch/amd64-shadow-stack.c
new file mode 100644
index 0000000..4a1ca1e
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-shadow-stack.c
@@ -0,0 +1,40 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2024-2025 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/>. */
+
+static int
+call2 ()
+{
+ return 42; /* break call2. */
+}
+
+static int
+call1 ()
+{
+ return call2 (); /* break call1. */
+}
+
+int
+main ()
+{
+ /* Depending on instruction generation we might end up in the call
+ instruction of call1 function after "runto_main". Avoid this by
+ adding a nop instruction, to simplify the testing in
+ amd64-shadow-stack-disp-step.exp. */
+ asm ("nop");
+ call1 (); /* break main. */
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/amd64-shadow-stack.exp b/gdb/testsuite/gdb.arch/amd64-shadow-stack.exp
new file mode 100644
index 0000000..e9f6fa6
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-shadow-stack.exp
@@ -0,0 +1,71 @@
+# Copyright 2024-2025 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 accessing the shadow stack pointer register.
+
+require allow_ssp_tests
+
+standard_testfile
+
+# Write PL3_SSP register with invalid shadow stack pointer value.
+proc write_invalid_ssp {} {
+ gdb_test "print /x \$pl3_ssp = 0x12345678" "= 0x12345678" "set pl3_ssp value"
+ gdb_test "print /x \$pl3_ssp" "= 0x12345678" "read pl3_ssp value after setting"
+}
+
+save_vars { ::env(GLIBC_TUNABLES) } {
+
+ append_environment GLIBC_TUNABLES "glibc.cpu.hwcaps" "SHSTK"
+
+ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
+ additional_flags="-fcf-protection=return"] } {
+ return
+ }
+
+ if {![runto_main]} {
+ return
+ }
+
+ with_test_prefix "invalid ssp" {
+ write_invalid_ssp
+
+ # Continue until SIGSEV to test that the value is written back to HW.
+ gdb_test "continue" \
+ [multi_line \
+ "Continuing\\." \
+ "" \
+ "Program received signal SIGSEGV, Segmentation fault\\." \
+ "$hex in main \\(\\)"] \
+ "continue to SIGSEGV"
+ }
+
+ clean_restart ${::testfile}
+ if { ![runto_main] } {
+ return
+ }
+
+ with_test_prefix "restore original ssp" {
+ # Read PL3_SSP register.
+ set ssp_main [get_hexadecimal_valueof "\$pl3_ssp" "read pl3_ssp value"]
+
+ write_invalid_ssp
+
+ # Restore original value.
+ gdb_test "print /x \$pl3_ssp = $ssp_main" "= $ssp_main" "restore original value"
+
+ # Now we should not see a SIGSEV, since the original value is restored.
+ gdb_continue_to_end
+ }
+}
diff --git a/gdb/testsuite/gdb.arch/amd64-word.exp b/gdb/testsuite/gdb.arch/amd64-word.exp
index d5dfb02..8a6b28d 100644
--- a/gdb/testsuite/gdb.arch/amd64-word.exp
+++ b/gdb/testsuite/gdb.arch/amd64-word.exp
@@ -27,7 +27,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list
return
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.arch/arm-pseudo-unwind-legacy.exp b/gdb/testsuite/gdb.arch/arm-pseudo-unwind-legacy.exp
index 892cfba..9cbf71d 100644
--- a/gdb/testsuite/gdb.arch/arm-pseudo-unwind-legacy.exp
+++ b/gdb/testsuite/gdb.arch/arm-pseudo-unwind-legacy.exp
@@ -34,7 +34,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
return -1
}
-clean_restart ${binfile}
+clean_restart $testfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.arch/arm-pseudo-unwind.exp b/gdb/testsuite/gdb.arch/arm-pseudo-unwind.exp
index c474a99..4cbb12e 100644
--- a/gdb/testsuite/gdb.arch/arm-pseudo-unwind.exp
+++ b/gdb/testsuite/gdb.arch/arm-pseudo-unwind.exp
@@ -29,7 +29,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
return -1
}
-clean_restart ${binfile}
+clean_restart $testfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.arch/arm-pthread_cond_timedwait-bt.exp b/gdb/testsuite/gdb.arch/arm-pthread_cond_timedwait-bt.exp
index 15c4050..32f085a 100644
--- a/gdb/testsuite/gdb.arch/arm-pthread_cond_timedwait-bt.exp
+++ b/gdb/testsuite/gdb.arch/arm-pthread_cond_timedwait-bt.exp
@@ -33,7 +33,7 @@ if { [build_executable "failed to prepare" ${testfile} ${srcfile} \
save_vars { GDBFLAGS } {
append GDBFLAGS " --readnever"
- if { [clean_restart ${binfile}] == -1 } {
+ if { [clean_restart $testfile] == -1 } {
return -1
}
}
diff --git a/gdb/testsuite/gdb.arch/e500-prologue.exp b/gdb/testsuite/gdb.arch/e500-prologue.exp
index e8f3ebd..b1eb865 100644
--- a/gdb/testsuite/gdb.arch/e500-prologue.exp
+++ b/gdb/testsuite/gdb.arch/e500-prologue.exp
@@ -27,7 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {}] !
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
# Insert a breakpoint in FUNCTION and verifies that the breakpoint was
# inserted at the expected location. EXPECTED_LOCATION should be an
diff --git a/gdb/testsuite/gdb.arch/e500-regs.exp b/gdb/testsuite/gdb.arch/e500-regs.exp
index 543ce63..6d69ccc 100644
--- a/gdb/testsuite/gdb.arch/e500-regs.exp
+++ b/gdb/testsuite/gdb.arch/e500-regs.exp
@@ -136,7 +136,8 @@ gdb_expect_list "info vector" ".*$gdb_prompt $" {
# We must restart everything, because we have set important registers to
# some unusual values.
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
if {![runto_main]} {
return 0
}
diff --git a/gdb/testsuite/gdb.arch/gdb1291.exp b/gdb/testsuite/gdb.arch/gdb1291.exp
index ad3b8f9..9f460c8 100644
--- a/gdb/testsuite/gdb.arch/gdb1291.exp
+++ b/gdb/testsuite/gdb.arch/gdb1291.exp
@@ -33,7 +33,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ""] !
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
#
# Run to `main' where we begin our tests.
diff --git a/gdb/testsuite/gdb.arch/gdb1431.exp b/gdb/testsuite/gdb.arch/gdb1431.exp
index 34bc8d6..bc65d26 100644
--- a/gdb/testsuite/gdb.arch/gdb1431.exp
+++ b/gdb/testsuite/gdb.arch/gdb1431.exp
@@ -35,7 +35,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ""] !
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
#
# Run to `main' where we begin our tests.
diff --git a/gdb/testsuite/gdb.arch/gdb1558.exp b/gdb/testsuite/gdb.arch/gdb1558.exp
index f690468..3de5723 100644
--- a/gdb/testsuite/gdb.arch/gdb1558.exp
+++ b/gdb/testsuite/gdb.arch/gdb1558.exp
@@ -32,7 +32,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {"add
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
gdb_test "b -q main" "Breakpoint 1.*" "set breakpoint at main"
gdb_test "b -q sub1" "Breakpoint 2.*" "set breakpoint at sub1"
diff --git a/gdb/testsuite/gdb.arch/i386-avx.exp b/gdb/testsuite/gdb.arch/i386-avx.exp
index 8f07a3d..ba41a8c 100644
--- a/gdb/testsuite/gdb.arch/i386-avx.exp
+++ b/gdb/testsuite/gdb.arch/i386-avx.exp
@@ -42,7 +42,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
return
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return 0
@@ -93,7 +93,7 @@ with_test_prefix "force-disable xml descriptions" {
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"set remote target-features-packet off\""
- clean_restart ${binfile}
+ clean_restart ${::testfile}
}
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.arch/i386-bp_permanent.exp b/gdb/testsuite/gdb.arch/i386-bp_permanent.exp
index 1d3713f..6eb9ee6 100644
--- a/gdb/testsuite/gdb.arch/i386-bp_permanent.exp
+++ b/gdb/testsuite/gdb.arch/i386-bp_permanent.exp
@@ -33,7 +33,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list
}
-clean_restart $binfile
+clean_restart $::testfile
#
# Run to `main' where we begin our tests.
diff --git a/gdb/testsuite/gdb.arch/i386-byte.exp b/gdb/testsuite/gdb.arch/i386-byte.exp
index dcbcb40..1eff977 100644
--- a/gdb/testsuite/gdb.arch/i386-byte.exp
+++ b/gdb/testsuite/gdb.arch/i386-byte.exp
@@ -28,7 +28,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list
return
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.arch/i386-dr3-watch.exp b/gdb/testsuite/gdb.arch/i386-dr3-watch.exp
index 4fe2608..11b4773 100644
--- a/gdb/testsuite/gdb.arch/i386-dr3-watch.exp
+++ b/gdb/testsuite/gdb.arch/i386-dr3-watch.exp
@@ -23,7 +23,7 @@ require {is_any_target "i?86-*-*" "x86_64-*-*"}
standard_testfile
-if [prepare_for_testing "failed to prepare" ${binfile} ${srcfile} {debug $additional_flags}] {
+if [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug $additional_flags}] {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/i386-gnu-cfi.exp b/gdb/testsuite/gdb.arch/i386-gnu-cfi.exp
index b51f034..c446fae 100644
--- a/gdb/testsuite/gdb.arch/i386-gnu-cfi.exp
+++ b/gdb/testsuite/gdb.arch/i386-gnu-cfi.exp
@@ -40,7 +40,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfilec} ${srcdir}/${subdir}/${srcfile
# Get things started.
-clean_restart $binfile
+clean_restart $::testfile
# We should stop in abort(3).
diff --git a/gdb/testsuite/gdb.arch/i386-permbkpt.exp b/gdb/testsuite/gdb.arch/i386-permbkpt.exp
index b979d6e..1118cb4 100644
--- a/gdb/testsuite/gdb.arch/i386-permbkpt.exp
+++ b/gdb/testsuite/gdb.arch/i386-permbkpt.exp
@@ -30,7 +30,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_test "break -q main" "" "first permanent break"
gdb_test "break -q main" "" "second permanent break"
diff --git a/gdb/testsuite/gdb.arch/i386-prologue-skip-cf-protection.exp b/gdb/testsuite/gdb.arch/i386-prologue-skip-cf-protection.exp
index 06285ce..b289b84 100644
--- a/gdb/testsuite/gdb.arch/i386-prologue-skip-cf-protection.exp
+++ b/gdb/testsuite/gdb.arch/i386-prologue-skip-cf-protection.exp
@@ -58,7 +58,7 @@ with_test_prefix "skip-cf-protection" {
return
}
- clean_restart ${binfile}
+ clean_restart ${::testfile}
test_run
}
diff --git a/gdb/testsuite/gdb.arch/i386-prologue.exp b/gdb/testsuite/gdb.arch/i386-prologue.exp
index 72246f4..bfab6d1 100644
--- a/gdb/testsuite/gdb.arch/i386-prologue.exp
+++ b/gdb/testsuite/gdb.arch/i386-prologue.exp
@@ -53,7 +53,7 @@ proc skip_breakpoint { msg } {
}
-clean_restart $binfile
+clean_restart $::testfile
#
# Run to `main' where we begin our tests.
diff --git a/gdb/testsuite/gdb.arch/i386-signal.exp b/gdb/testsuite/gdb.arch/i386-signal.exp
index 30f212b..80d1827 100644
--- a/gdb/testsuite/gdb.arch/i386-signal.exp
+++ b/gdb/testsuite/gdb.arch/i386-signal.exp
@@ -30,7 +30,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
return -1
}
-clean_restart $binfile
+clean_restart $::testfile
runto func
gdb_test "backtrace 10" \
diff --git a/gdb/testsuite/gdb.arch/i386-size-overlap.exp b/gdb/testsuite/gdb.arch/i386-size-overlap.exp
index ca8383d..db88673 100644
--- a/gdb/testsuite/gdb.arch/i386-size-overlap.exp
+++ b/gdb/testsuite/gdb.arch/i386-size-overlap.exp
@@ -30,7 +30,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
return -1
}
-clean_restart $binfile
+clean_restart $::testfile
# We use gdb_run_cmd so this stands a chance to work for remote
# targets too.
diff --git a/gdb/testsuite/gdb.arch/i386-size.exp b/gdb/testsuite/gdb.arch/i386-size.exp
index b08182f..997e629 100644
--- a/gdb/testsuite/gdb.arch/i386-size.exp
+++ b/gdb/testsuite/gdb.arch/i386-size.exp
@@ -35,7 +35,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
return -1
}
-clean_restart $binfile
+clean_restart $::testfile
# We use gdb_run_cmd so this stands a chance to work for remote
# targets too.
diff --git a/gdb/testsuite/gdb.arch/i386-sse.exp b/gdb/testsuite/gdb.arch/i386-sse.exp
index f0aa5ec..154f5ea 100644
--- a/gdb/testsuite/gdb.arch/i386-sse.exp
+++ b/gdb/testsuite/gdb.arch/i386-sse.exp
@@ -40,7 +40,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
return
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.arch/i386-unwind.exp b/gdb/testsuite/gdb.arch/i386-unwind.exp
index 99acfe9..76f0a78 100644
--- a/gdb/testsuite/gdb.arch/i386-unwind.exp
+++ b/gdb/testsuite/gdb.arch/i386-unwind.exp
@@ -33,7 +33,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list
return -1
}
-clean_restart $binfile
+clean_restart $::testfile
# Testcase for backtrace/1435.
diff --git a/gdb/testsuite/gdb.arch/i386-word.exp b/gdb/testsuite/gdb.arch/i386-word.exp
index 0da49c0..ed02d27 100644
--- a/gdb/testsuite/gdb.arch/i386-word.exp
+++ b/gdb/testsuite/gdb.arch/i386-word.exp
@@ -28,7 +28,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list
return
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.arch/ia64-breakpoint-shadow.exp b/gdb/testsuite/gdb.arch/ia64-breakpoint-shadow.exp
index 8e8ed9b..d6fd14c 100644
--- a/gdb/testsuite/gdb.arch/ia64-breakpoint-shadow.exp
+++ b/gdb/testsuite/gdb.arch/ia64-breakpoint-shadow.exp
@@ -23,7 +23,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
# We need to start the inferior to place the breakpoints in the memory at all.
if ![runto_main] {
diff --git a/gdb/testsuite/gdb.arch/mips-fpregset-core.exp b/gdb/testsuite/gdb.arch/mips-fpregset-core.exp
index aa55ede..d67cef2 100644
--- a/gdb/testsuite/gdb.arch/mips-fpregset-core.exp
+++ b/gdb/testsuite/gdb.arch/mips-fpregset-core.exp
@@ -79,7 +79,8 @@ set core_supported [expr {$corefile != ""}]
# Generate a core file with "gcore".
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
runto break_here
@@ -116,7 +117,8 @@ proc mips_fpregset_core_test { supported corefile } {
upvar host_triplet host_triplet
upvar binfile binfile
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
set test "load core file"
if { $supported } {
diff --git a/gdb/testsuite/gdb.arch/mips-octeon-bbit.exp b/gdb/testsuite/gdb.arch/mips-octeon-bbit.exp
index 3fb6f9c..f43127d 100644
--- a/gdb/testsuite/gdb.arch/mips-octeon-bbit.exp
+++ b/gdb/testsuite/gdb.arch/mips-octeon-bbit.exp
@@ -86,7 +86,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
pass "compilation"
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
# Native needs run.
runto_main
diff --git a/gdb/testsuite/gdb.arch/pa-nullify.exp b/gdb/testsuite/gdb.arch/pa-nullify.exp
index 87afe7a..ad246ca 100644
--- a/gdb/testsuite/gdb.arch/pa-nullify.exp
+++ b/gdb/testsuite/gdb.arch/pa-nullify.exp
@@ -40,7 +40,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {}] !
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
# In the first test, we do a "step" on a function whose last instruction
# contains a branch-with-nullify. The instruction in the delay slot belongs
diff --git a/gdb/testsuite/gdb.arch/powerpc-aix-prologue.exp b/gdb/testsuite/gdb.arch/powerpc-aix-prologue.exp
index 13e3fd3..f95bddf 100644
--- a/gdb/testsuite/gdb.arch/powerpc-aix-prologue.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-aix-prologue.exp
@@ -28,7 +28,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {}] !
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
# Insert a breakpoint in FUNCTION and verifies that the breakpoint was
# inserted at the expected location. EXPECTED_LOCATION should be an
diff --git a/gdb/testsuite/gdb.arch/powerpc-altivec.exp b/gdb/testsuite/gdb.arch/powerpc-altivec.exp
index 987da07..bc8ff7a 100644
--- a/gdb/testsuite/gdb.arch/powerpc-altivec.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-altivec.exp
@@ -27,7 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}]
return -1
}
-clean_restart ${objfile}
+clean_restart
+gdb_load $objfile
# Disassemble the function.
set func ""
diff --git a/gdb/testsuite/gdb.arch/powerpc-altivec2.exp b/gdb/testsuite/gdb.arch/powerpc-altivec2.exp
index 3bf7c57..6fddd34 100644
--- a/gdb/testsuite/gdb.arch/powerpc-altivec2.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-altivec2.exp
@@ -27,7 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}]
return -1
}
-clean_restart ${objfile}
+clean_restart
+gdb_load $objfile
# Disassemble the function.
set func ""
diff --git a/gdb/testsuite/gdb.arch/powerpc-altivec3.exp b/gdb/testsuite/gdb.arch/powerpc-altivec3.exp
index ff1d79a..7b1d0c3 100644
--- a/gdb/testsuite/gdb.arch/powerpc-altivec3.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-altivec3.exp
@@ -27,7 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}]
return -1
}
-clean_restart ${objfile}
+clean_restart
+gdb_load $objfile
# Disassemble the function.
set func ""
diff --git a/gdb/testsuite/gdb.arch/powerpc-d128-regs.exp b/gdb/testsuite/gdb.arch/powerpc-d128-regs.exp
index 42fc51e..cb5a371 100644
--- a/gdb/testsuite/gdb.arch/powerpc-d128-regs.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-d128-regs.exp
@@ -29,7 +29,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {qui
return -1
}
-clean_restart $binfile
+clean_restart $::testfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.arch/powerpc-fpscr-gcore.exp b/gdb/testsuite/gdb.arch/powerpc-fpscr-gcore.exp
index a7614fa..13163d2 100644
--- a/gdb/testsuite/gdb.arch/powerpc-fpscr-gcore.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-fpscr-gcore.exp
@@ -34,7 +34,7 @@ if {[build_executable "compile" $binfile $gen_src] == -1} {
return -1
}
-clean_restart $binfile
+clean_restart $testfile
if {![runto_main]} {
return -1
diff --git a/gdb/testsuite/gdb.arch/powerpc-htm-regs.exp b/gdb/testsuite/gdb.arch/powerpc-htm-regs.exp
index 6fcb69f..5e2923f 100644
--- a/gdb/testsuite/gdb.arch/powerpc-htm-regs.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-htm-regs.exp
@@ -82,7 +82,8 @@ with_test_prefix "check htm support" {
return
}
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
# Displaced-stepping a tbegin. causes problems,
# so we make the breakpoint temporary.
@@ -131,7 +132,7 @@ if {[build_executable "compile" $binfile $srcfile {debug}] == -1} {
return
}
-clean_restart $binfile
+clean_restart $testfile
gdb_breakpoint [gdb_get_line_number "first marker"] temporary
diff --git a/gdb/testsuite/gdb.arch/powerpc-power10.exp b/gdb/testsuite/gdb.arch/powerpc-power10.exp
index 1bb7174..124baaf 100644
--- a/gdb/testsuite/gdb.arch/powerpc-power10.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-power10.exp
@@ -27,7 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}]
return -1
}
-clean_restart ${objfile}
+clean_restart
+gdb_load $objfile
# Disassemble the function.
set func ""
diff --git a/gdb/testsuite/gdb.arch/powerpc-power7.exp b/gdb/testsuite/gdb.arch/powerpc-power7.exp
index f33405d..8885a91 100644
--- a/gdb/testsuite/gdb.arch/powerpc-power7.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-power7.exp
@@ -27,7 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}]
return -1
}
-clean_restart ${objfile}
+clean_restart
+gdb_load $objfile
# Disassemble the function.
set func ""
diff --git a/gdb/testsuite/gdb.arch/powerpc-power8.exp b/gdb/testsuite/gdb.arch/powerpc-power8.exp
index ab69b0f..f740ae8 100644
--- a/gdb/testsuite/gdb.arch/powerpc-power8.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-power8.exp
@@ -27,7 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}]
return -1
}
-clean_restart ${objfile}
+clean_restart
+gdb_load $objfile
# Disassemble the function.
set func ""
diff --git a/gdb/testsuite/gdb.arch/powerpc-power9.exp b/gdb/testsuite/gdb.arch/powerpc-power9.exp
index b1bfa9d..8dcf536 100644
--- a/gdb/testsuite/gdb.arch/powerpc-power9.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-power9.exp
@@ -27,7 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}]
return -1
}
-clean_restart ${objfile}
+clean_restart
+gdb_load $objfile
# Disassemble the function.
set func ""
diff --git a/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp b/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp
index ef6bb9d..1b4c608 100644
--- a/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp
@@ -66,7 +66,7 @@ proc ppr_dscr_available {} {
}
with_test_prefix "check PPR/DSCR access" {
- clean_restart $binfile
+ clean_restart $::testfile
if ![runto_main] {
return
@@ -86,7 +86,7 @@ with_test_prefix "check PPR/DSCR access" {
}
# Now do the actual test
-clean_restart $binfile
+clean_restart $::testfile
if ![runto_main] {
return
diff --git a/gdb/testsuite/gdb.arch/powerpc-prologue-frame.exp b/gdb/testsuite/gdb.arch/powerpc-prologue-frame.exp
index 3c79039..156a70e 100644
--- a/gdb/testsuite/gdb.arch/powerpc-prologue-frame.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-prologue-frame.exp
@@ -26,7 +26,7 @@ if {[gdb_compile \
}
-clean_restart ${binfile}
+clean_restart $testfile
if ![runto bar] {
untested "could not run to bar"
diff --git a/gdb/testsuite/gdb.arch/powerpc-prologue.exp b/gdb/testsuite/gdb.arch/powerpc-prologue.exp
index 4e697c1..44877a1 100644
--- a/gdb/testsuite/gdb.arch/powerpc-prologue.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-prologue.exp
@@ -31,7 +31,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {}] !
}
-clean_restart $binfile
+clean_restart $testfile
#
# Run to `main' where we begin our tests.
diff --git a/gdb/testsuite/gdb.arch/powerpc-tar.exp b/gdb/testsuite/gdb.arch/powerpc-tar.exp
index b44d554..a060ec8 100644
--- a/gdb/testsuite/gdb.arch/powerpc-tar.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-tar.exp
@@ -68,7 +68,7 @@ proc tar_available {} {
# Do one pass to check if TAR is usable, system
# software can prevent it from being used.
with_test_prefix "check TAR access" {
- clean_restart $binfile
+ clean_restart $::testfile
if ![runto_main] {
return
@@ -84,7 +84,7 @@ with_test_prefix "check TAR access" {
}
# Now do the actual test
-clean_restart $binfile
+clean_restart $::testfile
if ![runto_main] {
return
diff --git a/gdb/testsuite/gdb.arch/powerpc-vector-regs.exp b/gdb/testsuite/gdb.arch/powerpc-vector-regs.exp
index 9e9162e..4537646 100644
--- a/gdb/testsuite/gdb.arch/powerpc-vector-regs.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-vector-regs.exp
@@ -30,7 +30,7 @@ if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable {debug}]
}
# Check if our test binary can actually run on this processor.
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_run_cmd
@@ -44,7 +44,7 @@ gdb_test_multiple "" "wait for exit" {
}
# Run the actual test.
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_breakpoint [gdb_get_line_number "marker"]
diff --git a/gdb/testsuite/gdb.arch/powerpc-vsx-gcore.exp b/gdb/testsuite/gdb.arch/powerpc-vsx-gcore.exp
index be1f93a..db568c6 100644
--- a/gdb/testsuite/gdb.arch/powerpc-vsx-gcore.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-vsx-gcore.exp
@@ -34,7 +34,7 @@ if {[build_executable "compile" $binfile $gen_src] == -1} {
return -1
}
-clean_restart $binfile
+clean_restart $testfile
if {![runto_main]} {
return -1
diff --git a/gdb/testsuite/gdb.arch/powerpc-vsx.exp b/gdb/testsuite/gdb.arch/powerpc-vsx.exp
index a6832e6..73a0fdc 100644
--- a/gdb/testsuite/gdb.arch/powerpc-vsx.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-vsx.exp
@@ -27,7 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}]
return -1
}
-clean_restart ${objfile}
+clean_restart
+gdb_load $objfile
# Disassemble the function.
set func ""
diff --git a/gdb/testsuite/gdb.arch/powerpc-vsx2.exp b/gdb/testsuite/gdb.arch/powerpc-vsx2.exp
index d5cb18e..dfee7a3 100644
--- a/gdb/testsuite/gdb.arch/powerpc-vsx2.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-vsx2.exp
@@ -27,7 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}]
return -1
}
-clean_restart ${objfile}
+clean_restart
+gdb_load $objfile
# Disassemble the function.
set func ""
diff --git a/gdb/testsuite/gdb.arch/powerpc-vsx3.exp b/gdb/testsuite/gdb.arch/powerpc-vsx3.exp
index bd54eaf..fd725f9 100644
--- a/gdb/testsuite/gdb.arch/powerpc-vsx3.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-vsx3.exp
@@ -27,7 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}]
return -1
}
-clean_restart ${objfile}
+clean_restart
+gdb_load $objfile
# Disassemble the function.
set func ""
diff --git a/gdb/testsuite/gdb.arch/ppc-dfp.exp b/gdb/testsuite/gdb.arch/ppc-dfp.exp
index d7a8312..20145ae 100644
--- a/gdb/testsuite/gdb.arch/ppc-dfp.exp
+++ b/gdb/testsuite/gdb.arch/ppc-dfp.exp
@@ -31,7 +31,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {quie
return -1
}
-clean_restart $binfile
+clean_restart $::testfile
gdb_breakpoint [gdb_get_line_number "Set DFP rounding mode."]
diff --git a/gdb/testsuite/gdb.arch/ppc-fp.exp b/gdb/testsuite/gdb.arch/ppc-fp.exp
index 4733296..c8342bb 100644
--- a/gdb/testsuite/gdb.arch/ppc-fp.exp
+++ b/gdb/testsuite/gdb.arch/ppc-fp.exp
@@ -31,7 +31,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {quie
return -1
}
-clean_restart $binfile
+clean_restart $::testfile
gdb_breakpoint [gdb_get_line_number "Invalid operation."]
gdb_breakpoint [gdb_get_line_number "Division by zero."]
diff --git a/gdb/testsuite/gdb.arch/ppc-longdouble.exp b/gdb/testsuite/gdb.arch/ppc-longdouble.exp
index f3603f1..739e36f 100644
--- a/gdb/testsuite/gdb.arch/ppc-longdouble.exp
+++ b/gdb/testsuite/gdb.arch/ppc-longdouble.exp
@@ -28,7 +28,7 @@ proc do_test { name {opts {}} } {
return
}
- clean_restart ${binfile}.${name}
+ clean_restart ${::testfile}.${name}
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.arch/pr25124.exp b/gdb/testsuite/gdb.arch/pr25124.exp
index 4c43716..4e7c114 100644
--- a/gdb/testsuite/gdb.arch/pr25124.exp
+++ b/gdb/testsuite/gdb.arch/pr25124.exp
@@ -25,7 +25,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug
return -1
}
-clean_restart $binfile
+clean_restart $testfile
# Check if the disassemble ouput is correct.
gdb_test "x /i main+8" \
diff --git a/gdb/testsuite/gdb.arch/sparc-sysstep.exp b/gdb/testsuite/gdb.arch/sparc-sysstep.exp
index 40de862..4dfc514 100644
--- a/gdb/testsuite/gdb.arch/sparc-sysstep.exp
+++ b/gdb/testsuite/gdb.arch/sparc-sysstep.exp
@@ -28,7 +28,7 @@ set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
set opts {}
-if {[prepare_for_testing "failed to prepare" ${binfile} $srcfile {additional_flags=-g}]} {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {additional_flags=-g}]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/thumb-prologue.exp b/gdb/testsuite/gdb.arch/thumb-prologue.exp
index 112c111..2ee82fb 100644
--- a/gdb/testsuite/gdb.arch/thumb-prologue.exp
+++ b/gdb/testsuite/gdb.arch/thumb-prologue.exp
@@ -27,7 +27,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {"add
}
-clean_restart $binfile
+clean_restart $testfile
#
# Run to `main' where we begin our tests.
diff --git a/gdb/testsuite/gdb.arch/thumb2-it.exp b/gdb/testsuite/gdb.arch/thumb2-it.exp
index 49031e1..e6ef06d 100644
--- a/gdb/testsuite/gdb.arch/thumb2-it.exp
+++ b/gdb/testsuite/gdb.arch/thumb2-it.exp
@@ -24,7 +24,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug
return -1
}
-clean_restart $binfile
+clean_restart $testfile
if {![runto_main]} {
return -1
diff --git a/gdb/testsuite/gdb.arch/vsx-regs.exp b/gdb/testsuite/gdb.arch/vsx-regs.exp
index 645207f..df74ef3 100644
--- a/gdb/testsuite/gdb.arch/vsx-regs.exp
+++ b/gdb/testsuite/gdb.arch/vsx-regs.exp
@@ -184,7 +184,8 @@ if {!$core_supported} {
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
set core_loaded [gdb_core_cmd "$corefile" "re-load generated corefile"]
if { $core_loaded == -1 } {
diff --git a/gdb/testsuite/gdb.asm/asm-source.exp b/gdb/testsuite/gdb.asm/asm-source.exp
index e3655b1..eb96c19 100644
--- a/gdb/testsuite/gdb.asm/asm-source.exp
+++ b/gdb/testsuite/gdb.asm/asm-source.exp
@@ -1,5 +1,5 @@
# Copyright 1998-2025 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
@@ -184,7 +184,7 @@ if {[istarget "*-*-openbsd*"]} {
# built with different defaults. So no matter what we do, we lose. We may as
# well get out of this test sooner rather than later.
set dest [target_info name]
-if [board_info $dest exists multilib_flags] {
+if {[board_info $dest exists multilib_flags]} {
set multilib_flags [board_info $dest multilib_flags]
if { "${multilib_flags}" != "" } {
untested "failed to compile"
@@ -269,16 +269,16 @@ if { [istarget "m6811-*-*"] || [istarget "m6812-*-*"] } {
}
# Collect some line numbers.
-set line_enter [expr [gdb_get_line_number "main enter" "asmsrc1.s"] + 1]
-set line_main [expr [gdb_get_line_number "main start" "asmsrc1.s"] + 1]
-set line_call_foo2 [expr [gdb_get_line_number "call foo2" "asmsrc1.s"] + 1]
-set line_search_comment [expr [gdb_get_line_number "search" "asmsrc1.s"] + 1]
-set line_foo3 [expr [gdb_get_line_number "foo3 start" "asmsrc1.s"] + 1]
-set line_main_exit [expr [gdb_get_line_number "main exit" "asmsrc1.s"] + 1]
-set line_foo2 [expr [gdb_get_line_number "foo2 start" "asmsrc2.s"] + 1]
-set line_call_foo3 [expr [gdb_get_line_number "call foo3" "asmsrc2.s"] + 1]
-set line_call_foo3_again [expr $line_call_foo3 + 1]
-set line_foo2_leave [expr [gdb_get_line_number "foo2 leave" "asmsrc2.s"] + 1]
+set line_enter [expr {[gdb_get_line_number "main enter" "asmsrc1.s"] + 1}]
+set line_main [expr {[gdb_get_line_number "main start" "asmsrc1.s"] + 1}]
+set line_call_foo2 [expr {[gdb_get_line_number "call foo2" "asmsrc1.s"] + 1}]
+set line_search_comment [expr {[gdb_get_line_number "search" "asmsrc1.s"] + 1}]
+set line_foo3 [expr {[gdb_get_line_number "foo3 start" "asmsrc1.s"] + 1}]
+set line_main_exit [expr {[gdb_get_line_number "main exit" "asmsrc1.s"] + 1}]
+set line_foo2 [expr {[gdb_get_line_number "foo2 start" "asmsrc2.s"] + 1}]
+set line_call_foo3 [expr {[gdb_get_line_number "call foo3" "asmsrc2.s"] + 1}]
+set line_call_foo3_again [expr {$line_call_foo3 + 1}]
+set line_foo2_leave [expr {[gdb_get_line_number "foo2 leave" "asmsrc2.s"] + 1}]
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
@@ -346,7 +346,7 @@ gdb_test "f" ".*asmsrc2\[.\]s:$line_foo2.*" "f in foo2"
# `next' one insn (or macro) to set up our stackframe (for the following bt).
gdb_test "n" "$line_call_foo3\[ \]*.*foo3" "n in foo2"
-# See if a simple `bt' prints the right source files and
+# See if a simple `bt' prints the right source files and
# doesn't fall off the stack.
gdb_test "bt 10" \
@@ -405,7 +405,7 @@ gdb_test_multiple "info sources" "info sources" {
set seen_asmsrc_2 1
exp_continue
}
- -re ", " {
+ -re ", " {
exp_continue
}
-re "$gdb_prompt $" {
@@ -416,7 +416,7 @@ gdb_test_multiple "info sources" "info sources" {
}
}
}
-
+
# Try 'info line'
gdb_test "info line" \
diff --git a/gdb/testsuite/gdb.base/a2-run.exp b/gdb/testsuite/gdb.base/a2-run.exp
index 4e95e56..966e12a 100644
--- a/gdb/testsuite/gdb.base/a2-run.exp
+++ b/gdb/testsuite/gdb.base/a2-run.exp
@@ -18,6 +18,8 @@
# Can't do this test without stdio support.
require {!gdb_skip_stdio_test "a2run.exp"}
+set have_startup_shell [have_startup_shell]
+
#
# test running programs
#
@@ -166,9 +168,8 @@ gdb_run_cmd
setup_xfail "arm-*-coff"
gdb_test_stdio "" "720" "" "run \"$testfile\" again after setting args"
-# GOAL: Test that shell is being used with "run". For remote debugging
-# targets, there is no guarantee that a "shell" (whatever that is) is used.
-if {![is_remote target]} {
+# GOAL: Test that shell is being used with "run".
+if { $have_startup_shell == 1 } {
gdb_test_stdio "run `echo 8`" \
"40320" "" "run \"$testfile\" with shell"
}
diff --git a/gdb/testsuite/gdb.base/access-mem-running.exp b/gdb/testsuite/gdb.base/access-mem-running.exp
index ecff427..280e89b 100644
--- a/gdb/testsuite/gdb.base/access-mem-running.exp
+++ b/gdb/testsuite/gdb.base/access-mem-running.exp
@@ -32,7 +32,8 @@ proc test { non_stop } {
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"set non-stop $non_stop\""
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
}
if ![runto_main] {
diff --git a/gdb/testsuite/gdb.base/annota1.exp b/gdb/testsuite/gdb.base/annota1.exp
index 06dbec2..744d825 100644
--- a/gdb/testsuite/gdb.base/annota1.exp
+++ b/gdb/testsuite/gdb.base/annota1.exp
@@ -533,7 +533,8 @@ proc thread_test {} {
if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] == "" } {
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
if {![runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.base/annotate-symlink.exp b/gdb/testsuite/gdb.base/annotate-symlink.exp
index f7f6f18..a5d431e 100644
--- a/gdb/testsuite/gdb.base/annotate-symlink.exp
+++ b/gdb/testsuite/gdb.base/annotate-symlink.exp
@@ -20,7 +20,7 @@ standard_testfile realname-expand.c realname-expand-real.c
require {!is_remote host}
set srcdirabs [file join [pwd] $srcdir]
-set srcfilelink [standard_output_file realname-expand-link.c]
+set srcfilelink [build_standard_output_file realname-expand-link.c]
remote_exec build "ln -sf ${srcdirabs}/${subdir}/${srcfile2} $srcfilelink"
diff --git a/gdb/testsuite/gdb.base/args.exp b/gdb/testsuite/gdb.base/args.exp
index 33952e4..3930059 100644
--- a/gdb/testsuite/gdb.base/args.exp
+++ b/gdb/testsuite/gdb.base/args.exp
@@ -21,6 +21,7 @@ require {!target_info exists noargs}
# This test requires starting new inferior processes, skip it if the target
# board is a stub.
require !use_gdb_stub
+require {expr [have_startup_shell] != -1}
standard_testfile
@@ -29,74 +30,187 @@ if {[build_executable $testfile.exp $testfile $srcfile] == -1} {
return -1
}
-# NAME is the name to use for the tests and ARGLIST is the list of
-# arguments that are passed to GDB when it is started.
+# Assuming a running GDB. Check the status of the single inferior
+# argument feature. When this feature is on GDB passes inferior
+# arguments as a single combined string. When this feature is off GDB
+# will split the inferior arguments into multiple separate strings.
#
-# The optional RE_LIST is the list of patterns to check the arguments
-# against, these patterns should match ARGLIST. If the arguments are
-# expected to show up unmodified in the test output then RE_LIST can
-# be dropped, and this proc will reuse ARGLIST.
-
-proc args_test { name arglist {re_list {}} } {
-
- # If RE_LIST is not supplied then we can reuse ARGLIST, this
- # implies that the arguments will appear unmodified in the test
- # output.
- if {[llength $re_list] == 0} {
- set re_list $arglist
+# Return true when arguments are being split, or false when a single
+# combined string is being sent.
+
+proc is_argument_splitting_on {} {
+ set arg_splitting true
+
+ gdb_test_multiple "show remote single-inferior-argument-feature-packet" "" {
+ -re -wrap "Support for the 'single-inferior-argument-feature' packet on the current remote target is \"(on|off)\"\\.(.*)" {
+ set value $expect_out(1,string)
+ pass $gdb_test_name
+ if { $value eq "on" } {
+ set arg_splitting false
+ }
+ }
+ -re -wrap "Support for the 'single-inferior-argument-feature' packet on the current remote target is \"auto\", currently (enabled|disabled)\\.(.*)" {
+ set value $expect_out(1,string)
+ pass $gdb_test_name
+ if { $value eq "enabled" } {
+ set arg_splitting false
+ }
+ }
}
- foreach_with_prefix startup_with_shell { on off } {
- save_vars { ::GDBFLAGS } {
- set ::GDBFLAGS "$::GDBFLAGS --args $::binfile $arglist"
-
- clean_restart $::binfile
-
- gdb_test_no_output "set startup-with-shell ${startup_with_shell}" \
- "set startup-with-shell for $name"
+ return $arg_splitting
+}
- runto_main
- gdb_breakpoint [gdb_get_line_number "set breakpoint here"]
- gdb_continue_to_breakpoint "breakpoint for $name"
+# NAME is the name to use for the tests and ARGLIST is the list of
+# arguments that are passed to GDB when it is started.
+#
+# The optional RE_ESC_LIST is the list of patterns to check the
+# inferior arguments against when GDB is started using --args. If
+# RE_ESC_LIST is not given then ARGLIST is reused, this implies that
+# the inferior arguments appear unchanged in the test output.
+#
+# The optional RE_NO_ESC_LIST is the list of patterns to check the
+# inferior arguments against when GDB is started using
+# --no-escape-args. If RE_NO_ESC_LIST is not given then RE_ESC_LIST
+# is reused, this implies that there's no difference between the test
+# output when the arguments are escaped or not.
+
+proc args_test { name arglist {re_esc_list {}} {re_no_esc_list {}} } {
+
+ # If either of the two regexp lists are not specificed then we can
+ # use an earlier argument value instead.
+ #
+ # For the first regexp list, if this is missing then we use the
+ # argument list, this assumes that the arguments will appear
+ # unmodified in the output.
+ if {[llength $re_esc_list] == 0} {
+ set re_esc_list $arglist
+ }
- set expected_len [expr 1 + [llength $re_list]]
- gdb_test "print argc" "\\\$$::decimal = $expected_len" "argc for $name"
+ # If the second regexp list is missing then we reuse the first
+ # regexp list. This assumes there's no difference between escaped
+ # and unescaped arguments in the output.
+ if {[llength $re_no_esc_list] == 0} {
+ set re_no_esc_list $re_esc_list
+ }
- set i 1
- foreach arg $re_list {
- gdb_test "print argv\[$i\]" "\\\$$::decimal = $::hex \"$arg\"" \
- "argv\[$i\] for $name"
- set i [expr $i + 1]
+ foreach_with_prefix startup_with_shell { on off } {
+ foreach_with_prefix arg_flag { args no-escape-args } {
+ save_vars { ::GDBFLAGS } {
+ set ::GDBFLAGS "$::GDBFLAGS --${arg_flag} $::binfile $arglist"
+
+ clean_restart $::testfile
+
+ gdb_test_no_output \
+ "set startup-with-shell ${startup_with_shell}" \
+ "set startup-with-shell for $name"
+
+ runto_main
+ gdb_breakpoint [gdb_get_line_number "set breakpoint here"]
+ gdb_continue_to_breakpoint "breakpoint for $name"
+
+ if { $arg_flag eq "args" || $startup_with_shell eq "off" } {
+ set re_list $re_esc_list
+ } else {
+ set re_list $re_no_esc_list
+ }
+
+ set expected_len [expr 1 + [llength $re_list]]
+ gdb_test "print argc" \
+ "\\\$$::decimal = $expected_len" "argc for $name"
+
+ set i 1
+ foreach arg $re_list {
+ if { $arg eq "\n" } {
+ set arg {\\n}
+ } elseif { $arg eq "\"" } {
+ set arg {\\\"}
+ }
+
+ # If we are starting with a shell, we're not escaping
+ # special shell characters in arguments passed to GDB,
+ # we're using a remote target, and the arguments contain
+ # a shell variable (indicated with a '$'), then this
+ # test will currently fail if we are splitting the
+ # arguments.
+ if { $startup_with_shell eq "on"
+ && $arg_flag eq "no-escape-args"
+ && [gdb_protocol_is_remote]
+ && [string first "\$" $arglist] != -1
+ && [is_argument_splitting_on] } {
+ setup_xfail "*-*-*" gdb/28392
+ }
+
+ gdb_test "print argv\[$i\]" \
+ "\\\$$::decimal = $::hex \"$arg\"" \
+ "argv\[$i\] for $name"
+ set i [expr $i + 1]
+ }
}
}
}
}
-# Test that the --args are processed correctly.
+# Run all the tests.
+proc run_all_tests {} {
+ # Test that the --args are processed correctly.
+
+ args_test basic {{1} {3}}
-args_test basic {{1} {3}}
+ # Test that the --args are processed correctly even if one of them is
+ # empty.
-# Test that the --args are processed correctly even if one of them is
-# empty.
+ args_test "one empty" {{1} {} {3}}
-args_test "one empty" {{1} {} {3}}
+ # Try with 2 empty args.
-# Try with 2 empty args.
+ args_test "two empty" {{1} {} {} 3}
-args_test "two empty" {{1} {} {} 3}
+ # Try with arguments containing literal single quotes.
-# Try with arguments containing literal single quotes.
+ args_test "one empty with single quotes" {{1} {''} {3}}
-args_test "one empty with single quotes" {{1} {''} {3}}
+ args_test "two empty with single quotes" {{1} {''} {''} {3}}
-args_test "two empty with single quotes" {{1} {''} {''} {3}}
+ # Try with arguments containing literal newlines.
-# Try with arguments containing literal newlines.
+ args_test "one newline" {{1} "\n" {3}} {1 \\\\n 3}
-args_test "one newline" {{1} "\n" {3}} {1 \\\\n 3}
+ args_test "two newlines" {{1} "\n" "\n" {3}} {1 \\\\n \\\\n 3}
-args_test "two newlines" {{1} "\n" "\n" {3}} {1 \\\\n \\\\n 3}
+ args_test "lone single quote" {{1} \' {3}}
-args_test "lone single quote" {{1} \' {3}}
+ args_test "lone double quote" {{1} \" {3}} {1 \\\\\" 3}
-args_test "lone double quote" {{1} \" {3}} {1 \\\\\" 3}
+ save_vars { ::env(TEST) } {
+ set ::env(TEST) "ABCD"
+ args_test "shell variable" {{$TEST}} {\\$TEST} {{ABCD}}
+ }
+
+ # At one point we had a bug where, if the last inferior argument,
+ # appearing after --args, looked like an option GDB might be able
+ # to process, e.g. started with a dash, then GDB would try to
+ # process it. This would leave GDB in a broken state, and so GDB
+ # would fail to start. A example of a failing GDB command line:
+ # $ gdb --args /bin/ls --all
+ foreach_with_prefix flag { args no-escape-args } {
+ args_test "with trailing GDB flag" [list "--${flag}"]
+ }
+ args_test "with trailing GDB option and value" [list "--ex" "start"]
+ args_test "with trailing double dash option" [list "--foo"]
+ args_test "with trailing single dash option" [list "-foo"]
+}
+
+run_all_tests
+
+# For extended-remote targets, disable the packet which passes
+# inferior arguments as a single string. This changes how the vRun
+# (extended-remote only) packet works.
+if {[target_info gdb_protocol] == "extended-remote"} {
+ with_test_prefix "single-inferior-arg disabled" {
+ save_vars { GDBFLAGS } {
+ append GDBFLAGS " -ex \"set remote single-inferior-argument-feature-packet off\""
+ run_all_tests
+ }
+ }
+}
diff --git a/gdb/testsuite/gdb.base/arrayidx.exp b/gdb/testsuite/gdb.base/arrayidx.exp
index 4fc221f..757ce92 100644
--- a/gdb/testsuite/gdb.base/arrayidx.exp
+++ b/gdb/testsuite/gdb.base/arrayidx.exp
@@ -24,7 +24,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debu
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.base/assign.exp b/gdb/testsuite/gdb.base/assign.exp
index a69655d..aaee796 100644
--- a/gdb/testsuite/gdb.base/assign.exp
+++ b/gdb/testsuite/gdb.base/assign.exp
@@ -33,7 +33,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
#
diff --git a/gdb/testsuite/gdb.base/attach-fail-twice.exp b/gdb/testsuite/gdb.base/attach-fail-twice.exp
index 529002d..5e5d73f 100644
--- a/gdb/testsuite/gdb.base/attach-fail-twice.exp
+++ b/gdb/testsuite/gdb.base/attach-fail-twice.exp
@@ -77,7 +77,8 @@ proc test_good_attach {test} {
}
proc_with_prefix test {} {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
# GDB used to have a bug on Windows where failing to attach once
# made a subsequent "attach" or "run" hang. So it's important for
diff --git a/gdb/testsuite/gdb.base/attach-non-pgrp-leader.exp b/gdb/testsuite/gdb.base/attach-non-pgrp-leader.exp
index 2ce092d..c43a11c 100644
--- a/gdb/testsuite/gdb.base/attach-non-pgrp-leader.exp
+++ b/gdb/testsuite/gdb.base/attach-non-pgrp-leader.exp
@@ -36,7 +36,8 @@ proc do_test {} {
# Attach to the parent, run it to a known point, extract the
# child's PID, and detach.
with_test_prefix "parent" {
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
gdb_test "attach $parent_pid" \
"Attaching to program.*, process $parent_pid.*" \
@@ -56,7 +57,8 @@ proc do_test {} {
# Start over, and attach to the child this time.
with_test_prefix "child" {
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
gdb_test "attach $child_pid" \
"Attaching to program.*, process $child_pid.*" \
diff --git a/gdb/testsuite/gdb.base/attach-twice.exp b/gdb/testsuite/gdb.base/attach-twice.exp
index 3d74298..63205e2 100644
--- a/gdb/testsuite/gdb.base/attach-twice.exp
+++ b/gdb/testsuite/gdb.base/attach-twice.exp
@@ -45,6 +45,6 @@ gdb_test_multiple "attach $testpid" $test {
}
if {$parentpid != 0} {
- eval exec kill -9 $parentpid
+ exec kill -9 $parentpid
}
kill_wait_spawned_process $test_spawn_id
diff --git a/gdb/testsuite/gdb.base/attach-wait-input.exp b/gdb/testsuite/gdb.base/attach-wait-input.exp
index 84c9bab..47e3d25 100644
--- a/gdb/testsuite/gdb.base/attach-wait-input.exp
+++ b/gdb/testsuite/gdb.base/attach-wait-input.exp
@@ -43,7 +43,8 @@ proc start_program {binfile} {
global gdb_prompt
global decimal
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
if {![runto setup_done]} {
return 0
diff --git a/gdb/testsuite/gdb.base/attach.c b/gdb/testsuite/gdb.base/attach.c
index b3c5498..5133dd0 100644
--- a/gdb/testsuite/gdb.base/attach.c
+++ b/gdb/testsuite/gdb.base/attach.c
@@ -5,7 +5,7 @@
exit unless/until gdb sets the variable to non-zero.)
*/
#include <stdio.h>
-#include <unistd.h>
+#include "gdb_watchdog.h"
int bidule = 0;
volatile int should_exit = 0;
@@ -14,7 +14,7 @@ int main ()
{
int local_i = 0;
- alarm (60);
+ gdb_watchdog (60);
while (! should_exit)
{
diff --git a/gdb/testsuite/gdb.base/attach.exp b/gdb/testsuite/gdb.base/attach.exp
index 0d1550a..d0a29f2 100644
--- a/gdb/testsuite/gdb.base/attach.exp
+++ b/gdb/testsuite/gdb.base/attach.exp
@@ -56,7 +56,8 @@ proc_with_prefix do_attach_failure_tests {} {
global escapedbinfile
global srcfile
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
# Figure out a regular expression that will match the sysroot,
# noting that the default sysroot is "target:", and also noting
@@ -215,7 +216,8 @@ proc_with_prefix do_attach_tests {} {
global timeout
global decimal
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
# Figure out a regular expression that will match the sysroot,
# noting that the default sysroot is "target:", and also noting
@@ -519,7 +521,8 @@ proc_with_prefix do_attach_exec_mismatch_handling_tests {} {
global binfile2
global binfile3
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
# Start two programs that can be attached to.
# The first program contains a 'int bidule' variable, the second a 'float bidule'.
diff --git a/gdb/testsuite/gdb.base/auxv.exp b/gdb/testsuite/gdb.base/auxv.exp
index 090d9ba..38efa45 100644
--- a/gdb/testsuite/gdb.base/auxv.exp
+++ b/gdb/testsuite/gdb.base/auxv.exp
@@ -41,7 +41,8 @@ set core_works [expr [isnative] && ! [is_remote target]]
# Run GDB on the test program up to where it will dump core.
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
gdb_test_no_output "set print sevenbit-strings"
gdb_test_no_output "set width 0"
diff --git a/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug.exp b/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug.exp
index fce6d67..652e8c1 100644
--- a/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug.exp
+++ b/gdb/testsuite/gdb.base/backtrace-through-cu-nodebug.exp
@@ -52,9 +52,10 @@ proc prepare_test {has_cfi} {
return false
}
- clean_restart "$binfile-${extension}"
+ clean_restart
+ gdb_load $binfile-$extension
- if ![runto callback] then {
+ if { ![runto callback] } {
fail "has_cfi=$has_cfi: Can't run to callback"
return false
}
diff --git a/gdb/testsuite/gdb.base/backtrace.exp b/gdb/testsuite/gdb.base/backtrace.exp
index 35784b4..3020666 100644
--- a/gdb/testsuite/gdb.base/backtrace.exp
+++ b/gdb/testsuite/gdb.base/backtrace.exp
@@ -17,11 +17,7 @@
standard_testfile
-set flags {}
-lappend flags debug
-lappend_include_file flags $srcdir/lib/attributes.h
-
-if { [prepare_for_testing "failed to prepare" $testfile $srcfile $flags] } {
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
return -1
}
diff --git a/gdb/testsuite/gdb.base/basic-edit-cmd.exp b/gdb/testsuite/gdb.base/basic-edit-cmd.exp
index 8a23c9b..7ad8ab9 100644
--- a/gdb/testsuite/gdb.base/basic-edit-cmd.exp
+++ b/gdb/testsuite/gdb.base/basic-edit-cmd.exp
@@ -68,7 +68,8 @@ save_vars { env(EDITOR) } {
"try edit when no symbol file is loaded"
# Now start with a test binary.
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
with_test_prefix "before starting inferior" {
diff --git a/gdb/testsuite/gdb.base/bfp-test.exp b/gdb/testsuite/gdb.base/bfp-test.exp
index 7781fe1..53d274f 100644
--- a/gdb/testsuite/gdb.base/bfp-test.exp
+++ b/gdb/testsuite/gdb.base/bfp-test.exp
@@ -23,7 +23,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debu
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.exp b/gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.exp
index 18e20e0..2e2a8e6 100644
--- a/gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.exp
+++ b/gdb/testsuite/gdb.base/bg-exec-sigint-bp-cond.exp
@@ -34,7 +34,8 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug]} {
# AFTER_KILL_COND is appended to the breakpoint condition, after "kill
# -SIGINT $gdb_pid".
proc test { {after_kill_cond ""} } {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.base/bg-execution-repeat.exp b/gdb/testsuite/gdb.base/bg-execution-repeat.exp
index d5580fb..e7bdf49 100644
--- a/gdb/testsuite/gdb.base/bg-execution-repeat.exp
+++ b/gdb/testsuite/gdb.base/bg-execution-repeat.exp
@@ -33,7 +33,8 @@ proc test {continue_cmd} {
global binfile
global linenum
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
if ![runto_main] {
return
diff --git a/gdb/testsuite/gdb.base/bigcore.exp b/gdb/testsuite/gdb.base/bigcore.exp
index 7727e48..f917eb8 100644
--- a/gdb/testsuite/gdb.base/bigcore.exp
+++ b/gdb/testsuite/gdb.base/bigcore.exp
@@ -117,7 +117,8 @@ proc test {dumper} {
# Run GDB on the bigcore program up-to where it will dump core.
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
gdb_test_no_output "set print sevenbit-strings"
gdb_test_no_output "set width 0"
diff --git a/gdb/testsuite/gdb.base/bitfields2.exp b/gdb/testsuite/gdb.base/bitfields2.exp
index a99660a..3e981dd 100644
--- a/gdb/testsuite/gdb.base/bitfields2.exp
+++ b/gdb/testsuite/gdb.base/bitfields2.exp
@@ -233,7 +233,8 @@ proc bitfield_set {} {
}
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
gdb_test_no_output "set print sevenbit-strings"
runto_main
diff --git a/gdb/testsuite/gdb.base/bp-cmds-continue-ctrl-c.exp b/gdb/testsuite/gdb.base/bp-cmds-continue-ctrl-c.exp
index 4fc8f06..648992c 100644
--- a/gdb/testsuite/gdb.base/bp-cmds-continue-ctrl-c.exp
+++ b/gdb/testsuite/gdb.base/bp-cmds-continue-ctrl-c.exp
@@ -118,7 +118,8 @@ proc do_test {} {
# "attach".
with_test_prefix "run" {
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
if {![runto_main]} {
return -1
@@ -129,7 +130,8 @@ with_test_prefix "run" {
with_test_prefix "attach" {
if {[can_spawn_for_attach]} {
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
set test_spawn_id [spawn_wait_for_attach $binfile]
set testpid [spawn_id_get_pid $test_spawn_id]
diff --git a/gdb/testsuite/gdb.base/bp-cond-failure.exp b/gdb/testsuite/gdb.base/bp-cond-failure.exp
index 4d03e7b..f33092b 100644
--- a/gdb/testsuite/gdb.base/bp-cond-failure.exp
+++ b/gdb/testsuite/gdb.base/bp-cond-failure.exp
@@ -26,7 +26,7 @@
standard_testfile
-if { [prepare_for_testing "failed to prepare" ${binfile} "${srcfile}" \
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
{debug c++}] == -1 } {
return
}
@@ -45,7 +45,8 @@ if { [is_address_zero_readable] } {
}
proc run_test { cond_eval access_type bpexpr nloc } {
- clean_restart ${::binfile}
+ clean_restart
+ gdb_load $::binfile
if { ![runto_main] } {
return -1
diff --git a/gdb/testsuite/gdb.base/bp-disabled-by-cond.exp b/gdb/testsuite/gdb.base/bp-disabled-by-cond.exp
index f0bdd16..371b9e7 100644
--- a/gdb/testsuite/gdb.base/bp-disabled-by-cond.exp
+++ b/gdb/testsuite/gdb.base/bp-disabled-by-cond.exp
@@ -52,7 +52,8 @@ set exit_bp_line [gdb_get_line_number "BP before exit" $srcfile]
# Restart the inferior, which should unload the shared library, GDB
# should mark the b/p as disabled due to its condition again.
proc run_test { hit_cond } {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.base/bp-permanent.exp b/gdb/testsuite/gdb.base/bp-permanent.exp
index c6c6269..3ae5efe 100644
--- a/gdb/testsuite/gdb.base/bp-permanent.exp
+++ b/gdb/testsuite/gdb.base/bp-permanent.exp
@@ -42,7 +42,8 @@ proc test {always_inserted sw_watchpoint} {
global gdb_prompt
global srcfile binfile
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
if {![runto_main]} {
return -1
diff --git a/gdb/testsuite/gdb.base/break-fun-addr.exp b/gdb/testsuite/gdb.base/break-fun-addr.exp
index 9f5325a..ba6e32e 100644
--- a/gdb/testsuite/gdb.base/break-fun-addr.exp
+++ b/gdb/testsuite/gdb.base/break-fun-addr.exp
@@ -44,7 +44,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile1}" executable {d
# on the first instruction of function "main" ("*main"), then
# run to that breakpoint.
-clean_restart ${binfile1}
+clean_restart
+gdb_load $binfile1
with_test_prefix "${testfile1}" {
diff --git a/gdb/testsuite/gdb.base/break-idempotent.exp b/gdb/testsuite/gdb.base/break-idempotent.exp
index ed23b64..3b32c89 100644
--- a/gdb/testsuite/gdb.base/break-idempotent.exp
+++ b/gdb/testsuite/gdb.base/break-idempotent.exp
@@ -161,7 +161,7 @@ foreach_with_prefix pie { "nopie" "pie" } {
set binfile [standard_output_file $testfile-$pie]
- if {[prepare_for_testing "failed to prepare" $binfile $srcfile $opts]} {
+ if {[prepare_for_testing "failed to prepare" $testfile-$pie $srcfile $opts]} {
continue
}
diff --git a/gdb/testsuite/gdb.base/break-interp.exp b/gdb/testsuite/gdb.base/break-interp.exp
index 649cc86..038c3ea 100644
--- a/gdb/testsuite/gdb.base/break-interp.exp
+++ b/gdb/testsuite/gdb.base/break-interp.exp
@@ -78,7 +78,8 @@ gdb_test_multiple $test $test {
}
set interp_system [section_get [standard_output_file $binfile_test] .interp]
-clean_restart $interp_system
+clean_restart
+gdb_load $interp_system
set dl_main_found 0
gdb_test_multiple "info addr dl_main" "" {
-re -wrap "Symbol \"dl_main\" is a function at address $hex\\." {
@@ -218,6 +219,7 @@ proc test_core {file displacement} {
set corefile [core_find $file {} "segv"]
if {$corefile == ""} {
+ untested "unable to create or find corefile"
return
}
diff --git a/gdb/testsuite/gdb.base/bt-on-fatal-signal.exp b/gdb/testsuite/gdb.base/bt-on-fatal-signal.exp
index 06402dc..63428a1 100644
--- a/gdb/testsuite/gdb.base/bt-on-fatal-signal.exp
+++ b/gdb/testsuite/gdb.base/bt-on-fatal-signal.exp
@@ -61,7 +61,8 @@ foreach test_data {{SEGV "Segmentation fault"} \
# Restart GDB.
save_vars { GDB } {
set GDB [gdb_no_core]
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
}
# Capture the pid of GDB.
diff --git a/gdb/testsuite/gdb.base/bt-selected-frame.exp b/gdb/testsuite/gdb.base/bt-selected-frame.exp
index 68f5ed4..bbe2a5a 100644
--- a/gdb/testsuite/gdb.base/bt-selected-frame.exp
+++ b/gdb/testsuite/gdb.base/bt-selected-frame.exp
@@ -24,7 +24,8 @@ if { [build_executable "failed to prepare" $testfile $srcfile debug] } {
proc check_selected_frame_after_bt { bt_cmd stack_pattern } {
global binfile
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
with_test_prefix $bt_cmd {
diff --git a/gdb/testsuite/gdb.base/call-rt-st.exp b/gdb/testsuite/gdb.base/call-rt-st.exp
index 244eba8..511e209 100644
--- a/gdb/testsuite/gdb.base/call-rt-st.exp
+++ b/gdb/testsuite/gdb.base/call-rt-st.exp
@@ -39,7 +39,8 @@ set allow_float_test [allow_float_test]
# Start with a fresh gdb.
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
gdb_test_no_output "set print sevenbit-strings"
gdb_test_no_output "set print address off"
gdb_test_no_output "set width 0"
diff --git a/gdb/testsuite/gdb.base/call-sc.exp b/gdb/testsuite/gdb.base/call-sc.exp
index 4d0fccc..f67670d 100644
--- a/gdb/testsuite/gdb.base/call-sc.exp
+++ b/gdb/testsuite/gdb.base/call-sc.exp
@@ -46,7 +46,7 @@ proc start_scalars_test { type } {
set testfile "call-sc-${type}"
set binfile [standard_output_file ${testfile}]
- if { [prepare_for_testing "failed to prepare" $binfile $srcfile $flags] } {
+ if { [prepare_for_testing "failed to prepare" $testfile $srcfile $flags] } {
return -1
}
diff --git a/gdb/testsuite/gdb.base/call-signal-resume.exp b/gdb/testsuite/gdb.base/call-signal-resume.exp
index 10a2928..a74b8af 100644
--- a/gdb/testsuite/gdb.base/call-signal-resume.exp
+++ b/gdb/testsuite/gdb.base/call-signal-resume.exp
@@ -47,7 +47,8 @@ proc get_dummy_frame_number { } {
# Start with a fresh gdb.
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
if { ![runto_main] } {
return 0
diff --git a/gdb/testsuite/gdb.base/callexit.exp b/gdb/testsuite/gdb.base/callexit.exp
index c250c67..e0ce899 100644
--- a/gdb/testsuite/gdb.base/callexit.exp
+++ b/gdb/testsuite/gdb.base/callexit.exp
@@ -27,7 +27,8 @@ require {!target_info exists gdb,cannot_call_functions}
# Start with a fresh gdb.
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
if { ![runto_main] } {
return 0
diff --git a/gdb/testsuite/gdb.base/catch-syscall.exp b/gdb/testsuite/gdb.base/catch-syscall.exp
index f3ddef5..9c5839c 100644
--- a/gdb/testsuite/gdb.base/catch-syscall.exp
+++ b/gdb/testsuite/gdb.base/catch-syscall.exp
@@ -630,7 +630,8 @@ proc test_catch_syscall_multi_arch {} {
test_catch_syscall_multi_arch_1 $arch1 $arch2 $syscall1_name \
$syscall2_name $syscall_number
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
}
proc do_syscall_tests_without_xml {} {
@@ -801,18 +802,21 @@ fill_all_syscalls_numbers
# Execute the tests, using XML support
gdb_exit
if { [allow_xml_test] } {
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
do_syscall_tests
# Now, we have to see if GDB displays a warning when we
# don't set the data-directory but try to use catch syscall
# anyway. For that, we must restart GDB first.
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
test_catch_syscall_fail_nodatadir
}
# Restart gdb
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
# Execute the tests, without XML support. In this case, GDB will
# only display syscall numbers, and not syscall names.
diff --git a/gdb/testsuite/gdb.base/checkpoint.exp b/gdb/testsuite/gdb.base/checkpoint.exp
index 89b36f5..55eba5d 100644
--- a/gdb/testsuite/gdb.base/checkpoint.exp
+++ b/gdb/testsuite/gdb.base/checkpoint.exp
@@ -290,7 +290,8 @@ gdb_test "restart 10" "has no checkpoints" "no more checkpoint 10"
# Now let's try setting a large number of checkpoints (>600)
#
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
runto_main
gdb_breakpoint $break1_loc
@@ -356,7 +357,8 @@ gdb_test "kill" "" "kill all one with many checkpoints" \
#
with_test_prefix "delete checkpoint 0" {
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
runto_main
gdb_test "checkpoint" "Checkpoint 1: fork returned pid $decimal\\."
diff --git a/gdb/testsuite/gdb.base/chng-syms.exp b/gdb/testsuite/gdb.base/chng-syms.exp
index a561689..dbc523d 100644
--- a/gdb/testsuite/gdb.base/chng-syms.exp
+++ b/gdb/testsuite/gdb.base/chng-syms.exp
@@ -36,7 +36,8 @@ proc expect_to_stop_here { ident } {
gdb_test "" "Breakpoint \[0-9\]*, stop_here .*" "running to stop_here $ident"
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
gdb_test "break stop_here if (var1 == 42)" \
"Breakpoint.*at.* file .*$srcfile, line.*" \
diff --git a/gdb/testsuite/gdb.base/clear_non_user_bp.exp b/gdb/testsuite/gdb.base/clear_non_user_bp.exp
index f078b97..c016d07 100644
--- a/gdb/testsuite/gdb.base/clear_non_user_bp.exp
+++ b/gdb/testsuite/gdb.base/clear_non_user_bp.exp
@@ -47,7 +47,8 @@ if { [gdb_compile "${srcdir}/${subdir}/main.c" "${binfile}" executable {debug}]
}
# Start with a fresh gdb.
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.base/cli-suppress-notification.exp b/gdb/testsuite/gdb.base/cli-suppress-notification.exp
index 19f9c55..6880d98 100644
--- a/gdb/testsuite/gdb.base/cli-suppress-notification.exp
+++ b/gdb/testsuite/gdb.base/cli-suppress-notification.exp
@@ -17,7 +17,7 @@
standard_testfile
-if {[prepare_for_testing "failed to prepare" ${binfile} ${srcfile}]} {
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
return
}
diff --git a/gdb/testsuite/gdb.base/code-expr.exp b/gdb/testsuite/gdb.base/code-expr.exp
index 4288617..8af2ee6 100644
--- a/gdb/testsuite/gdb.base/code-expr.exp
+++ b/gdb/testsuite/gdb.base/code-expr.exp
@@ -29,7 +29,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
gdb_test_no_output "set print sevenbit-strings"
gdb_test_no_output "set print address off"
diff --git a/gdb/testsuite/gdb.base/color-prompt.exp b/gdb/testsuite/gdb.base/color-prompt.exp
new file mode 100644
index 0000000..c037185
--- /dev/null
+++ b/gdb/testsuite/gdb.base/color-prompt.exp
@@ -0,0 +1,29 @@
+# Copyright 2025 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 using a prompt with color in CLI.
+
+# Using tuiterm requires setting TERM on host.
+require {!is_remote host}
+
+# We use a tuiterm, which allows us to determine cursor position.
+tuiterm_env
+Term::clean_restart 8 80
+
+# We start with an empty screen, to generate a visible prompt.
+Term::gen_prompt
+
+set tui 0
+source $srcdir/$subdir/../gdb.tui/color-prompt.exp.tcl
diff --git a/gdb/testsuite/gdb.base/cond-expr.exp b/gdb/testsuite/gdb.base/cond-expr.exp
index e60fd16..2080937 100644
--- a/gdb/testsuite/gdb.base/cond-expr.exp
+++ b/gdb/testsuite/gdb.base/cond-expr.exp
@@ -39,7 +39,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.base/condbreak-bad.exp b/gdb/testsuite/gdb.base/condbreak-bad.exp
index 7aff409..19c16dc 100644
--- a/gdb/testsuite/gdb.base/condbreak-bad.exp
+++ b/gdb/testsuite/gdb.base/condbreak-bad.exp
@@ -17,7 +17,7 @@
standard_testfile
-if {[prepare_for_testing "failed to prepare" ${binfile} ${srcfile}]} {
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
return
}
diff --git a/gdb/testsuite/gdb.base/condbreak-multi-context.exp b/gdb/testsuite/gdb.base/condbreak-multi-context.exp
index dce162b..b4ea0f1 100644
--- a/gdb/testsuite/gdb.base/condbreak-multi-context.exp
+++ b/gdb/testsuite/gdb.base/condbreak-multi-context.exp
@@ -53,7 +53,8 @@ proc find_location_contexts { } {
global loc_name loc_index fill
global decimal hex gdb_prompt binfile
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
if {![runto_main]} {
return
@@ -130,7 +131,8 @@ proc check_bp_locations {bpnum states cond {msg ""}} {
proc_with_prefix scenario_1 { start_before } {
global warning decimal fill bkptno_num_re binfile
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
if { $start_before } {
if {![runto_main temporary]} {
@@ -242,7 +244,8 @@ proc setup_bps { bpnum1_name bpnum2_name } {
proc_with_prefix scenario_2 { start_before } {
global binfile bkptno_num_re
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
if { $start_before } {
if {![runto_main temporary]} {
@@ -290,7 +293,8 @@ proc_with_prefix scenario_2 { start_before } {
proc_with_prefix scenario_3 { start_before } {
global binfile bkptno_num_re loc_index warning
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
if { $start_before } {
if {![runto_main temporary]} {
@@ -367,7 +371,8 @@ proc_with_prefix scenario_3 { start_before } {
proc_with_prefix scenario_4 { start_before } {
global binfile bkptno_num_re loc_index warning
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
if { $start_before } {
if {![runto_main temporary]} {
diff --git a/gdb/testsuite/gdb.base/consecutive.exp b/gdb/testsuite/gdb.base/consecutive.exp
index e73b3c3..fa58a8f 100644
--- a/gdb/testsuite/gdb.base/consecutive.exp
+++ b/gdb/testsuite/gdb.base/consecutive.exp
@@ -54,7 +54,7 @@ gdb_test "break \*$bp_addr" "Breakpoint $decimal at $bp_addr: file .*" \
gdb_test_multiple "step" "stopped at bp, 2nd instr" {
-re -wrap "Breakpoint $decimal, ($hex) in foo.*" {
set stop_addr $expect_out(1,string)
- if {[eval expr "$bp_addr == $stop_addr"]} {
+ if {$bp_addr == $stop_addr} {
pass "stopped at bp, 2nd instr"
} else {
fail "stopped at bp, 2nd instr (wrong address)"
@@ -65,7 +65,7 @@ gdb_test_multiple "step" "stopped at bp, 2nd instr" {
set stop_addr_is_stmt [hex_in_list $stop_addr $is_stmt]
if {!$stop_addr_is_stmt} {
fail "stopped at bp, 2nd instr (missing hex prefix)"
- } elseif {[eval expr "$bp_addr == $stop_addr"]} {
+ } elseif {$bp_addr == $stop_addr} {
pass "stopped at bp, 2nd instr"
} else {
fail "stopped at bp, 2nd instr (wrong address)"
diff --git a/gdb/testsuite/gdb.base/constvars.exp b/gdb/testsuite/gdb.base/constvars.exp
index 8f55945..dcc8d1b 100644
--- a/gdb/testsuite/gdb.base/constvars.exp
+++ b/gdb/testsuite/gdb.base/constvars.exp
@@ -34,7 +34,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
#
diff --git a/gdb/testsuite/gdb.base/continue-after-aborted-step-over.exp b/gdb/testsuite/gdb.base/continue-after-aborted-step-over.exp
index 4764d72..8ba1f61 100644
--- a/gdb/testsuite/gdb.base/continue-after-aborted-step-over.exp
+++ b/gdb/testsuite/gdb.base/continue-after-aborted-step-over.exp
@@ -45,7 +45,8 @@ proc do_test {displaced breakpoint_always_inserted} {
global gdb_prompt decimal
global srcfile binfile
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
gdb_test_no_output "set displaced-stepping $displaced"
gdb_test_no_output "set breakpoint always-inserted $breakpoint_always_inserted"
diff --git a/gdb/testsuite/gdb.base/corefile-exec-context.exp b/gdb/testsuite/gdb.base/corefile-exec-context.exp
index 7c9647c..23fd964 100644
--- a/gdb/testsuite/gdb.base/corefile-exec-context.exp
+++ b/gdb/testsuite/gdb.base/corefile-exec-context.exp
@@ -51,7 +51,8 @@ remote_exec build "mv $corefile $corefile_1"
# Load the core file and confirm that the full executable name is
# seen.
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
set saw_generated_line false
gdb_test_multiple "core-file $corefile_1" "load core file no args" {
-re "^Core was generated by `[string_to_regexp $binfile]'\\.\r\n" {
@@ -80,7 +81,8 @@ remote_exec build "mv $corefile $corefile_2"
# Load the core file and confirm that the full executable name and
# argument list are seen.
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
set saw_generated_line false
gdb_test_multiple "core-file $corefile_2" "load core file with args" {
-re "^Core was generated by `[string_to_regexp $binfile] $args'\\.\r\n" {
@@ -155,7 +157,8 @@ remote_exec build "mv $corefile $corefile_3"
# Restart, load the core file, and check the environment variable
# shows up.
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
# Check for environment variable VAR_NAME in the environment, its
# value should be VAR_VALUE.
diff --git a/gdb/testsuite/gdb.base/corefile-shmem-zero-id.exp b/gdb/testsuite/gdb.base/corefile-shmem-zero-id.exp
index 57c665e..94ab454 100644
--- a/gdb/testsuite/gdb.base/corefile-shmem-zero-id.exp
+++ b/gdb/testsuite/gdb.base/corefile-shmem-zero-id.exp
@@ -93,7 +93,8 @@ save_vars { env(LD_PRELOAD) env(ASAN_OPTIONS) } {
# LD_PRELOAD.
append_environment_default ASAN_OPTIONS verify_asan_link_order 0
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
# Start GDB with the modified environment, this means that, when
# using remote targets, gdbserver will also use the preload
@@ -186,7 +187,8 @@ with_timeout_factor 3 {
# Restart GDB. This time we are _not_ using the preload library. We
# no longer need it as we are only analysing the core file now.
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
# Load the core file.
gdb_test "core-file $corefile" \
diff --git a/gdb/testsuite/gdb.base/corefile.exp b/gdb/testsuite/gdb.base/corefile.exp
index da1fdf3..c34dfb5 100644
--- a/gdb/testsuite/gdb.base/corefile.exp
+++ b/gdb/testsuite/gdb.base/corefile.exp
@@ -31,6 +31,7 @@ if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
# mmapped data in core file" test.
set corefile [core_find $binfile {}]
if {$corefile == ""} {
+ untested "unable to create or find corefile"
return 0
}
@@ -96,7 +97,8 @@ foreach_with_prefix coreopt {--core= -core= "-c "} {
# Now restart normally.
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
# Test basic corefile recognition via core-file command.
@@ -200,7 +202,8 @@ set coremmap_data_backup_filename \
remote_exec host "mv ${coremmap_data_filename} \
${coremmap_data_backup_filename}"
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
# Load the core file and check we get a warning about the
# coremmap.data file being missing.
@@ -229,7 +232,8 @@ remote_exec host "mv ${coremmap_data_backup_filename} \
# Test that we can unload the core with the "detach" command.
proc_with_prefix corefile_detach {} {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
gdb_test "core-file $::corefile" "Core was generated by .*" "load core"
gdb_test "detach" "No core file now\\." "detach core"
@@ -251,7 +255,8 @@ proc corefile_test_run {} {
return
}
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
gdb_test "core-file $corefile" "Core was generated by .*" "run: load core again"
set re "Local core dump file:"
diff --git a/gdb/testsuite/gdb.base/corefile2.exp b/gdb/testsuite/gdb.base/corefile2.exp
index 392705b..3975460 100644
--- a/gdb/testsuite/gdb.base/corefile2.exp
+++ b/gdb/testsuite/gdb.base/corefile2.exp
@@ -40,6 +40,7 @@ if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
set corefile [core_find $binfile {}]
if {$corefile == ""} {
+ untested "unable to create or find corefile"
return 0
}
@@ -170,7 +171,8 @@ with_test_prefix "renamed binfile" {
# Restart and run to the abort call.
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
if {![runto_main]} {
return
@@ -194,7 +196,8 @@ if {!$core_supported} {
gdb_test_no_output "maint print core-file-backed-mappings" \
"maint print core-file-backed-mapping with no core file"
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
set core_loaded [gdb_core_cmd "$corefile" "re-load generated corefile"]
if { $core_loaded == -1 } {
diff --git a/gdb/testsuite/gdb.base/corefile3.exp b/gdb/testsuite/gdb.base/corefile3.exp
index 57b2300..4528509 100644
--- a/gdb/testsuite/gdb.base/corefile3.exp
+++ b/gdb/testsuite/gdb.base/corefile3.exp
@@ -34,6 +34,7 @@ if {[build_executable $testfile.exp $testfile $srcfile] == -1} {
set corefile [core_find $binfile {}]
if {$corefile == ""} {
+ untested "unable to create or find corefile"
return
}
@@ -46,7 +47,8 @@ set backup_filename \
[standard_output_file coredir.[getpid]/coremmap.data.backup]
remote_exec host "mv ${data_filename} ${backup_filename}"
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
# Load the core file. The 'coremap.data' file cannot be found by GDB,
# but all the mappings for that file are r/w and should be present in
diff --git a/gdb/testsuite/gdb.base/ctf-ptype.exp b/gdb/testsuite/gdb.base/ctf-ptype.exp
index 3f9023f..6d55cb2 100644
--- a/gdb/testsuite/gdb.base/ctf-ptype.exp
+++ b/gdb/testsuite/gdb.base/ctf-ptype.exp
@@ -234,11 +234,10 @@ proc ptype_maybe_prototyped { id prototyped plain { overprototyped "NO-MATCH" }
# Turn the arguments, which are literal strings, into
# regular expressions by quoting any special characters they contain.
foreach var { prototyped plain overprototyped } {
- eval "set val \$$var"
- regsub -all "\[\]\[*()\]" $val "\\\\&" val
+ set val [string_to_regexp [set $var]]
regsub -all "short int" $val "short( int)?" val
regsub -all "long int" $val "long( int)?" val
- eval "set $var \$val"
+ set $var $val
}
gdb_test_multiple "ptype $id" "ptype $id" {
diff --git a/gdb/testsuite/gdb.base/cvexpr.exp b/gdb/testsuite/gdb.base/cvexpr.exp
index 3e527db..e2f8c35 100644
--- a/gdb/testsuite/gdb.base/cvexpr.exp
+++ b/gdb/testsuite/gdb.base/cvexpr.exp
@@ -517,7 +517,7 @@ foreach testspec $specs {
# These tests don't rely on the debug format.
with_test_prefix nodebug {
- if { [prepare_for_testing "failed to prepare" $binfile $srcfile {nodebug}] } {
+ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {nodebug}] } {
return 0
}
diff --git a/gdb/testsuite/gdb.base/default-args.exp b/gdb/testsuite/gdb.base/default-args.exp
index efc4205..ae417ed 100644
--- a/gdb/testsuite/gdb.base/default-args.exp
+++ b/gdb/testsuite/gdb.base/default-args.exp
@@ -25,7 +25,8 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug]} {
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
# Basic/core tests using user-visible commands.
with_test_prefix "basics" {
diff --git a/gdb/testsuite/gdb.base/default.exp b/gdb/testsuite/gdb.base/default.exp
index 01e3cc1..b5e64c2 100644
--- a/gdb/testsuite/gdb.base/default.exp
+++ b/gdb/testsuite/gdb.base/default.exp
@@ -759,7 +759,6 @@ set show_conv_list \
{$_probe_arg10 = <error: No frame selected>} \
{$_probe_arg11 = <error: No frame selected>} \
{$_cimag = <internal function _cimag>} \
- {$_colorsupport = "monochrome"} \
{$_creal = <internal function _creal>} \
{$_isvoid = <internal function _isvoid>} \
{$_shell = <internal function _shell>} \
@@ -767,11 +766,9 @@ set show_conv_list \
{$_gdb_maint_setting = <internal function _gdb_maint_setting>} \
{$_gdb_setting_str = <internal function _gdb_setting_str>} \
{$_gdb_setting = <internal function _gdb_setting>} \
- {$_gdb_major = 17} \
- {$_gdb_minor = 1} \
{$_shell_exitsignal = void} \
{$_shell_exitcode = 0} \
- {$_active_linker_namespaces = 1} \
+ {$_linker_namespace_count = 0} \
{$_linker_namespace = <error: No registers.>}\
}
if [allow_python_tests] {
@@ -788,10 +785,52 @@ if [allow_python_tests] {
{$_any_caller_matches = <internal function _any_caller_matches>} \
}
}
-gdb_test_list_exact "show convenience" "show convenience" \
- "\[^\r\n\]+\[\r\n\]+" \
- "\[^\r\n\]+" \
- $show_conv_list
+
+set lines [gdb_get_lines_no_pass "show convenience"]
+set matches 0
+set all_found 1
+foreach s $show_conv_list {
+ if { ![regexp (^|\r\n)[string_to_regexp $s](\r\n|$) $lines] } {
+ verbose -log "didn't match: '$s'"
+ set all_found 0
+ break
+ }
+ incr matches
+}
+
+set re_var [string_to_regexp {$_colorsupport}]
+if { [is_remote host] } {
+ set re_val {[^\r\n]+}
+} else {
+ set re_val [string_to_regexp {"monochrome"}]
+}
+if { [regexp "$re_var = $re_val" $lines] } {
+ incr matches
+} else {
+ set all_found 0
+}
+
+set re_vars \
+ [list \
+ [string_to_regexp {$_gdb_major}] \
+ [string_to_regexp {$_gdb_minor}]]
+foreach re_var $re_vars {
+ if { [regexp "$re_var = $decimal" $lines] } {
+ incr matches
+ } else {
+ set all_found 0
+ }
+}
+
+if { [regexp [string_to_regexp {$_tlb = void}] $lines] } {
+ incr matches
+} else {
+ # Convenience variable _tlb is added only if support for windows targets
+ # is enabled. Don't complain if it's missing.
+}
+
+gdb_assert { $all_found && $matches == [count_newlines $lines] } \
+ "show convenience"
#test show directories
gdb_test "show directories" "Source directories searched: .cdir\[:;\].cwd"
diff --git a/gdb/testsuite/gdb.base/detach-sysroot-target.exp b/gdb/testsuite/gdb.base/detach-sysroot-target.exp
index 4248c86..c7466c0 100644
--- a/gdb/testsuite/gdb.base/detach-sysroot-target.exp
+++ b/gdb/testsuite/gdb.base/detach-sysroot-target.exp
@@ -22,7 +22,7 @@
standard_testfile
-if {[prepare_for_testing "failed to prepare" ${binfile} ${srcfile}]} {
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
return
}
diff --git a/gdb/testsuite/gdb.base/detach-while-running.exp b/gdb/testsuite/gdb.base/detach-while-running.exp
index 60943f3..34c2adc 100644
--- a/gdb/testsuite/gdb.base/detach-while-running.exp
+++ b/gdb/testsuite/gdb.base/detach-while-running.exp
@@ -45,7 +45,8 @@ proc test {} {
if {$is_remote} {
append ::GDBFLAGS " -ex \"maint set target-non-stop on\""
}
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
}
set test_spawn_id [spawn_wait_for_attach $binfile]
diff --git a/gdb/testsuite/gdb.base/detach.exp b/gdb/testsuite/gdb.base/detach.exp
index f9f67a8..c8d4350 100644
--- a/gdb/testsuite/gdb.base/detach.exp
+++ b/gdb/testsuite/gdb.base/detach.exp
@@ -42,7 +42,8 @@ proc do_detach_tests {} {
gdb_test "detach" "Detaching from program: .*$escapedbinfile, .*" "detach, $pass"
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
global pass
set pass "one"
diff --git a/gdb/testsuite/gdb.base/dfp-test.exp b/gdb/testsuite/gdb.base/dfp-test.exp
index 2a6c377..11f75da 100644
--- a/gdb/testsuite/gdb.base/dfp-test.exp
+++ b/gdb/testsuite/gdb.base/dfp-test.exp
@@ -28,7 +28,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {quie
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.base/display.exp b/gdb/testsuite/gdb.base/display.exp
index 7aed6d5..2fb6e07 100644
--- a/gdb/testsuite/gdb.base/display.exp
+++ b/gdb/testsuite/gdb.base/display.exp
@@ -52,7 +52,8 @@ if !$use_gdb_stub {
gdb_test "kill" ".*" "kill again"
gdb_test "detach" ".*" "detach again"
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
}
# Ok, on to real life
diff --git a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
index 4d3e8eb..f3bdfb0 100644
--- a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
+++ b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp
@@ -38,16 +38,80 @@ if { [build_executable "failed to build" $testfile $srcfile \
return
}
+# Return a list of shared libraries extract from the "info sharedlibrary"
+# command. Each item in the list is itself a list with the following items:
+#
+# - "from" address
+# - "to" address
+# - namespace ID
+# - name (file path)
+
+proc get_info_shared {} {
+ set from_re "($::hex)\\s+"
+ set to_re "($::hex)\\s+"
+ set ns_re "(?:($::decimal)\\s+)?"
+ set syms_read_re "(Yes( \\(\\*\\))?|No)\\s+"
+ set name_re "(\[^\r\n\]+)"
+ set libs {}
+
+ gdb_test_multiple "info sharedlibrary" "" {
+ -re {From\s+To\s+(Linker NS\s+)?Syms Read\s+Shared Object Library\r\n} {
+ exp_continue
+ }
+
+ -re "^${from_re}${to_re}${ns_re}${syms_read_re}${name_re}\r\n" {
+ set from $expect_out(1,string)
+ set to $expect_out(2,string)
+ set ns $expect_out(3,string)
+ set name $expect_out(4,string)
+
+ lappend libs [list $from $to $ns $name]
+ exp_continue
+ }
+
+ -re {^\(\*\): Shared library is missing debugging information\.\r\n} {
+ exp_continue
+ }
+
+ -re "^$::gdb_prompt " {
+ pass $gdb_test_name
+ }
+ }
+
+ return $libs
+}
+
+# Verify that "info sharedlibrary" does not contain duplicate entries.
+
+proc check_no_duplicates {} {
+ with_test_prefix "check no duplicates" {
+ set libs [get_info_shared]
+ array set seen {}
+ set seen_duplicate 0
+
+ foreach lib $libs {
+ if {[info exists seen($lib)]} {
+ verbose -log "already seen: $lib"
+ set seen_duplicate 1
+ }
+
+ set seen($lib) 1
+ }
+
+ gdb_assert {!$seen_duplicate} "no duplicates"
+ }
+}
+
# Run the command "info sharedlibrary" and get the first namespace
# for the so
proc get_first_so_ns {} {
set ns -1
set lib_regexp [string_to_regexp ${::binfile_lib}]
gdb_test_multiple "info sharedlibrary $::so_name" "get SO namespace" -lbl {
- -re "\r\nFrom\\s+To\\s+\(NS\\s+\)?Syms\\s+Read\\s+Shared Object Library(?=\r\n)" {
+ -re "\r\nFrom\\s+To\\s+\(Linker NS\\s+\)?Syms\\s+Read\\s+Shared Object Library(?=\r\n)" {
exp_continue
}
- -re "\r\n$::hex\\s+$::hex\\s+\\\[\\\[($::decimal)\\\]\\\]\\s+\[^\r\n]+${lib_regexp}(?=\r\n)" {
+ -re "\r\n$::hex\\s+$::hex\\s+($::decimal)\\s+\[^\r\n]+${lib_regexp}(?=\r\n)" {
if {$ns == -1} {
set ns $expect_out(1,string)
}
@@ -62,7 +126,8 @@ proc get_first_so_ns {} {
# Run the tests relating to the command "info sharedlibrary", to
# verify that the namespace ID is consistent.
proc test_info_shared {} {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
if { ![runto_main] } {
return
@@ -78,9 +143,11 @@ proc test_info_shared {} {
# Next, test that we *do* print a namespace column after loading SOs.
gdb_test "info sharedlibrary" \
- "From\\s+To\\s+NS\\s+Syms\\s+Read\\s+Shared Object Library.*" \
+ "From\\s+To\\s+Linker NS\\s+Syms\\s+Read\\s+Shared Object Library.*" \
"after loading everything"
+ check_no_duplicates
+
gdb_assert {[get_first_so_ns] == 1} "before closing any library"
gdb_test "next" ".*second dlclose.*" "close first library"
@@ -107,11 +174,14 @@ proc test_info_shared {} {
# Run all tests related to the linkage namespaces convenience
# variables, _active_namespaces and _current_namespaces.
+# Also tests that the namespace ID is only printed at the correct
+# times.
proc_with_prefix test_conv_vars {} {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
- gdb_test "print \$_active_linker_namespaces" "1" \
- "1 namespace before starting inferior"
+ gdb_test "print \$_linker_namespace_count" "0" \
+ "0 namespace before starting inferior"
gdb_test "print \$_linker_namespace" "No registers." \
"No current namespace before starting inferior"
@@ -119,7 +189,7 @@ proc_with_prefix test_conv_vars {} {
return
}
- gdb_test "print \$_active_linker_namespaces" "1" \
+ gdb_test "print \$_linker_namespace_count" "1" \
"Before activating namespaces"
gdb_test "print \$_linker_namespace" ".* = 0" \
"Still in the default namespace"
@@ -141,17 +211,18 @@ proc_with_prefix test_conv_vars {} {
"print namespace of selected frame"
gdb_continue_to_breakpoint "first dlclose"
- gdb_test "print \$_active_linker_namespaces" "4" "all SOs loaded"
+ gdb_test "print \$_linker_namespace_count" "4" "all SOs loaded"
gdb_test "next" ".*second dlclose.*" "close one SO"
- gdb_test "print \$_active_linker_namespaces" "3" "one SOs unloaded"
+ gdb_test "print \$_linker_namespace_count" "3" "one SOs unloaded"
gdb_test "next" ".*third dlclose.*" "close another SO"
- gdb_test "print \$_active_linker_namespaces" "2" "two SOs unloaded"
+ gdb_test "print \$_linker_namespace_count" "2" "two SOs unloaded"
# Restarting GDB so that we can test setting a breakpoint
# using the convenience variable, while a proper bp syntax
# isn't implemented for namespaces
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
if {![runto_main]} {
return
}
@@ -167,7 +238,8 @@ proc_with_prefix test_conv_vars {} {
# Run several tests relating to the command "info namespaces".
proc test_info_linker_namespaces {} {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
# Check that "info linker-namespaces" while the inferior is not running
# doesn't crash.
@@ -186,50 +258,44 @@ proc test_info_linker_namespaces {} {
# First, test printing a single namespace, and ensure all of
# them are correct, using both syntaxes.
- set found_all_libs false
- gdb_test_multiple "info linker-namespaces \[\[0\]\]" "print namespace 0" -lbl {
- -re "^\r\nThere are ($::decimal) libraries loaded in linker namespace \\\[\\\[0\\\]\\\]" {
- # Some systems may add libc and libm to every loaded namespace,
- # others may load only one or neither, because the SO doesn't
- # actually use either library. The best we can do is check if
- # we found the dynamic linker, and up to 2 more libraries.
- set libs $expect_out(1,string)
- set found_all_libs [expr $libs - 1 <= 2]
- exp_continue
- }
- -re "^\r\n$::gdb_prompt $" {
- gdb_assert $found_all_libs "the correct number of libraries was reported"
- }
- -re "(^\r\n)?\[^\r\n\]+(?=\r\n)" {
- exp_continue
+ set n_libraries 999
+
+ gdb_test_multiple "info linker-namespaces \[\[0\]\]" "print namespace 0" {
+ -re -wrap "($::decimal) librar(?:y|ies) loaded in linker namespace 0:.*" {
+ set n_libraries $expect_out(1,string)
}
}
+
+ # Some systems may add libc and libm to every loaded namespace,
+ # others may load only one or neither, because the SO doesn't
+ # actually use either library. The best we can do is check if
+ # we found the dynamic linker, and up to 2 more libraries.
+ gdb_assert {$n_libraries <= 3} "the correct number of libraries was reported"
+
+ set binfile_lib_re [string_to_regexp $::binfile_lib]
+
foreach_with_prefix ns {1 2 3} {
set found_test_so false
- set found_all_libs false
- gdb_test_multiple "info linker-namespaces $ns" "print namespace $ns" -lbl {
- -re "^\r\nThere are ($::decimal) libraries loaded in linker namespace \\\[\\\[$ns\\\]\\\]" {
- set libs $expect_out(1,string)
- # Some systems may add libc and libm to every loaded namespace,
- # others may load only one or neither, because the SO doesn't
- # actually use either library. The best we can do is check if
- # we found the dynamic linker, the test SO, and maybe up to 2
- # more libraries.
- set found_all_libs [expr $libs - 2 <= 2]
+ set n_libraries 999
+
+ gdb_test_multiple "info linker-namespaces $ns" "print namespace $ns" {
+ -re ".*($::decimal) librar(?:y|ies) loaded in linker namespace $ns:\r\n" {
+ set n_libraries $expect_out(1,string)
exp_continue
}
- -re "^\r\n\[^\r\n\]+${::binfile_lib}\[^\r\n\]*(?=\r\n)" {
+
+ -re -wrap "${binfile_lib_re}.*" {
set found_test_so true
- exp_continue
- }
- -re "^\r\n$::gdb_prompt $" {
- gdb_assert $found_test_so "this testfle's SO was reported"
- gdb_assert $found_all_libs "the correct number of libraries was reported"
- }
- -re "(^\r\n)?\[^\r\n\]+(?=\r\n)" {
- exp_continue
}
}
+
+ # Some systems may add libc and libm to every loaded namespace,
+ # others may load only one or neither, because the SO doesn't
+ # actually use either library. The best we can do is check if
+ # we found the dynamic linker, the test SO, and maybe up to 2
+ # more libraries.
+ gdb_assert {$n_libraries <= 4} "the correct number of libraries was reported"
+ gdb_assert {$found_test_so} "this testfile's SO was reported"
}
# These patterns are simpler, and purposefully glob multiple lines.
@@ -237,14 +303,15 @@ proc test_info_linker_namespaces {} {
# without worrying about the libraries printed, since that was tested
# above.
gdb_test "info linker-namespaces" \
- [multi_line "There are 4 linker namespaces loaded" \
- "There are $::decimal libraries loaded in linker namespace ..0.." \
+ [multi_line "There are 4 linker namespaces loaded\\." \
+ "" \
+ "$::decimal librar(y|ies) loaded in linker namespace 0:" \
".*" \
- "There are $::decimal libraries loaded in linker namespace ..1.." \
+ "$::decimal librar(y|ies) loaded in linker namespace 1:" \
".*" \
- "There are $::decimal libraries loaded in linker namespace ..2.." \
+ "$::decimal librar(y|ies) loaded in linker namespace 2:" \
".*" \
- "There are $::decimal libraries loaded in linker namespace ..3.." \
+ "$::decimal librar(y|ies) loaded in linker namespace 3:" \
".*" ] "print namespaces with no argument"
}
diff --git a/gdb/testsuite/gdb.base/dlmopen.exp b/gdb/testsuite/gdb.base/dlmopen.exp
index da17002..c4eb7cd 100644
--- a/gdb/testsuite/gdb.base/dlmopen.exp
+++ b/gdb/testsuite/gdb.base/dlmopen.exp
@@ -95,9 +95,19 @@ if { $dyln_name eq "" } {
return
}
+# If the dynamic linker path contains a symlink, some instances show the real
+# path instead of the original path. Accept both.
+lassign [remote_exec target realpath "$dyln_name"] realpath_ret dyln_realpath_name
+
+if { $realpath_ret == 0 } {
+ set dyln_realpath_name [string trim $dyln_realpath_name]
+} else {
+ set dyln_realpath_name "not-a-valid-path"
+}
+
# Return true if FILENAME is the dynamic linker. Otherwise return false.
proc is_dyln { filename } {
- return [expr {$filename eq $::dyln_name}]
+ return [expr {$filename eq $::dyln_name || $filename eq $::dyln_realpath_name}]
}
# Check that 'info shared' show NUM occurrences of DSO.
@@ -106,7 +116,7 @@ proc check_dso_count { dso num } {
set count 0
gdb_test_multiple "info shared" "info shared" {
- -re "$hex $hex \(\[\[$::decimal\]\]\\s+\)\?Yes \[^\r\n\]*$dso\r\n" {
+ -re "$hex $hex \($::decimal\\s+\)\?Yes \[^\r\n\]*$dso\r\n" {
# use longer form so debug remote does not interfere
set count [expr $count + 1]
exp_continue
@@ -173,7 +183,8 @@ proc test_dlmopen {} {
# Setup for calling 'test_dlmopen', this is the version of the test
# that doesn't use 'attach'.
proc test_dlmopen_no_attach {} {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
if { ![runto_main] } {
return
@@ -198,7 +209,8 @@ proc test_dlmopen_with_attach {} {
return
}
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
# Start the test program.
set test_spawn_id [spawn_wait_for_attach $::binfile]
@@ -233,7 +245,7 @@ proc get_dyld_info {} {
set dyld_count 0
set dyld_start_addr ""
gdb_test_multiple "info sharedlibrary" "" {
- -re "From\\s+To\\s+\(NS\\s+\)?Syms\\s+Read\\s+Shared Object Library\r\n" {
+ -re "From\\s+To\\s+\(Linker NS\\s+\)?Syms\\s+Read\\s+Shared Object Library\r\n" {
exp_continue
}
-re "^($::hex)\\s+$::hex\\s+\(\#$::decimal\\s+\)?\[^/\]+(/\[^\r\n\]+)\r\n" {
@@ -288,7 +300,8 @@ proc_with_prefix test_solib_unmap_events { } {
return
}
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
if { ![runto_main] } {
return
@@ -358,15 +371,19 @@ proc_with_prefix test_solib_unmap_events { } {
# dynamic linker as pending when some instances of the library were
# unloaded, despite there really only being one copy of the dynamic
# linker actually loaded into the inferior's address space.
- gdb_test_multiple "info breakpoints $bpnum" "check b/p status" {
- -re -wrap "$bpnum\\s+breakpoint\\s+keep\\s+y\\s+<PENDING>\\s+\\*$::hex\\s*\r\n\\s+stop only if \\(0\\)" {
- fail $gdb_test_name
- }
-
- -re -wrap "$bpnum\\s+breakpoint\\s+keep\\s+y\\s+$::hex\\s*\[^\r\n\]+\r\n\\s+stop only if \\(0\\)" {
- pass $gdb_test_name
- }
- }
+ set hs {[^\r\n]}
+ set re_pass \
+ [multi_line \
+ "" \
+ [join \
+ [list \
+ "$bpnum" "breakpoint" "keep" "y" "$::hex$hs+"] \
+ {\s+}] \
+ [string cat \
+ {\s+} \
+ [string_to_regexp "stop only if (0)"] \
+ ([string_to_regexp " (target evals)"])?]]
+ gdb_test "info breakpoints $bpnum" $re_pass "check b/p status"
# With all the dlclose calls now complete, we should be back to a
# single copy of the dynamic linker.
@@ -379,7 +396,8 @@ proc_with_prefix test_solib_unmap_events { } {
# Check that we can 'next' over the dlclose calls without GDB giving any
# warnings or errors.
proc_with_prefix test_next_over_dlclose {} {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
if { ![runto_main] } {
return
diff --git a/gdb/testsuite/gdb.base/dprintf-bp-same-addr.exp b/gdb/testsuite/gdb.base/dprintf-bp-same-addr.exp
index 649784b..11a8310 100644
--- a/gdb/testsuite/gdb.base/dprintf-bp-same-addr.exp
+++ b/gdb/testsuite/gdb.base/dprintf-bp-same-addr.exp
@@ -28,7 +28,8 @@ proc test { style } {
global gdb_prompt binfile dp_location
with_test_prefix "$style" {
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
if ![runto_main] {
return -1
diff --git a/gdb/testsuite/gdb.base/dprintf-detach.exp b/gdb/testsuite/gdb.base/dprintf-detach.exp
index dc3384b..431037c 100644
--- a/gdb/testsuite/gdb.base/dprintf-detach.exp
+++ b/gdb/testsuite/gdb.base/dprintf-detach.exp
@@ -37,7 +37,8 @@ proc dprintf_detach_test { breakpoint_always_inserted dprintf_style disconnected
with_test_prefix "$test_prefix" {
# Start with a clean gdb
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
gdb_test_no_output "set breakpoint always-inserted ${breakpoint_always_inserted}"
gdb_test_no_output "set dprintf-style ${dprintf_style}"
@@ -68,7 +69,8 @@ proc dprintf_detach_test { breakpoint_always_inserted dprintf_style disconnected
gdb_exit
# Check that the process still exists by attaching a new gdb to it.
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
set test "re-attach to inferior"
set is_gdbserver [target_is_gdbserver]
diff --git a/gdb/testsuite/gdb.base/dprintf-execution-x-script.exp b/gdb/testsuite/gdb.base/dprintf-execution-x-script.exp
index 06be468..65de2d5 100644
--- a/gdb/testsuite/gdb.base/dprintf-execution-x-script.exp
+++ b/gdb/testsuite/gdb.base/dprintf-execution-x-script.exp
@@ -93,7 +93,8 @@ do_test "" $test
# Restart GDB and 'source' the script; this will (still) run the program
# due to the 'run' command in the script.
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
do_test "source $x_file" "load and run script using source command"
# This should leave us at the gdb prompt; Run program again using
diff --git a/gdb/testsuite/gdb.base/dprintf-pending.exp b/gdb/testsuite/gdb.base/dprintf-pending.exp
index 9242a84..f28e969 100644
--- a/gdb/testsuite/gdb.base/dprintf-pending.exp
+++ b/gdb/testsuite/gdb.base/dprintf-pending.exp
@@ -60,7 +60,8 @@ with_test_prefix "without symbols" {
gdb_test "" ".*x=3.*x=4.*x=3.*" "run to resolved dprintf"
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
gdb_load_shlib $lib_sl
#
diff --git a/gdb/testsuite/gdb.base/dprintf.exp b/gdb/testsuite/gdb.base/dprintf.exp
index 0135b86..262ccc1 100644
--- a/gdb/testsuite/gdb.base/dprintf.exp
+++ b/gdb/testsuite/gdb.base/dprintf.exp
@@ -74,7 +74,8 @@ proc restart {} {
global binfile
global bp_location1 dp_location1
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
if ![runto_main] {
return -1
diff --git a/gdb/testsuite/gdb.base/dso2dso.exp b/gdb/testsuite/gdb.base/dso2dso.exp
index 24d4203..3b00f6d 100644
--- a/gdb/testsuite/gdb.base/dso2dso.exp
+++ b/gdb/testsuite/gdb.base/dso2dso.exp
@@ -54,7 +54,8 @@ if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable \
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
gdb_load_shlib $binfile_libdso2
gdb_load_shlib $binfile_libdso1
diff --git a/gdb/testsuite/gdb.base/dtrace-probe.exp b/gdb/testsuite/gdb.base/dtrace-probe.exp
index 32a72cc..5d4b9df 100644
--- a/gdb/testsuite/gdb.base/dtrace-probe.exp
+++ b/gdb/testsuite/gdb.base/dtrace-probe.exp
@@ -27,7 +27,8 @@ proc dtrace_test {} {
return -1
}
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
if ![runto_main] {
return -1
@@ -63,8 +64,8 @@ proc dtrace_test {} {
# Since test:progress-counter is disabled we can run to the second
# instance of the test:two-locations probe.
- runto "-probe-dtrace test:two-locations"]
- runto "-probe-dtrace test:two-locations"]
+ runto "-probe-dtrace test:two-locations"
+ runto "-probe-dtrace test:two-locations"
# Go back to the breakpoint on main() and enable the
# test:progress-counter probe. Set a breakpoint on it and see
diff --git a/gdb/testsuite/gdb.base/dump.c b/gdb/testsuite/gdb.base/dump.c
index bdcafbf..14b66b1 100644
--- a/gdb/testsuite/gdb.base/dump.c
+++ b/gdb/testsuite/gdb.base/dump.c
@@ -35,7 +35,7 @@ main()
for (i = 0; i < ARRSIZE; i++)
intarray[i] = i+1;
- intstruct.a = 12 * 1;
+ intstruct.a = (12 * 1) << 16;
intstruct.b = 12 * 2;
intstruct.c = 12 * 3;
intstruct.d = 12 * 4;
diff --git a/gdb/testsuite/gdb.base/dump.exp b/gdb/testsuite/gdb.base/dump.exp
index a55e5b0..64d897b 100644
--- a/gdb/testsuite/gdb.base/dump.exp
+++ b/gdb/testsuite/gdb.base/dump.exp
@@ -46,7 +46,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ${op
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
gdb_test "dump mem /dev/null 0x10 0x20" "Cannot access memory at address 0x10" \
"inaccessible memory is reported"
@@ -107,14 +108,7 @@ set endian [get_endianness]
# Now generate some dump files.
proc make_dump_file { command msg } {
- global gdb_prompt
-
- gdb_test_multiple "${command}" "$msg" {
- -re ".*\[Ee\]rror.*$gdb_prompt $" { fail $msg }
- -re ".*\[Ww\]arning.*$gdb_prompt $" { fail $msg }
- -re ".*\[Uu\]ndefined .*$gdb_prompt $" { fail $msg }
- -re ".*$gdb_prompt $" { pass $msg }
- }
+ gdb_test_no_output "${command}" "$msg"
}
make_dump_file "dump val [set intarr1.bin] intarray" \
diff --git a/gdb/testsuite/gdb.base/duplicate-bp.exp b/gdb/testsuite/gdb.base/duplicate-bp.exp
index b1003f2..da5834b 100644
--- a/gdb/testsuite/gdb.base/duplicate-bp.exp
+++ b/gdb/testsuite/gdb.base/duplicate-bp.exp
@@ -24,7 +24,8 @@ proc test_setup { count } {
global srcfile
global binfile
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.base/eh_return.exp b/gdb/testsuite/gdb.base/eh_return.exp
index 5a4f524..703f9e9 100644
--- a/gdb/testsuite/gdb.base/eh_return.exp
+++ b/gdb/testsuite/gdb.base/eh_return.exp
@@ -71,7 +71,8 @@ if { $address == -1 } {
return 0
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
gdb_assert [gdb_breakpoint "*$address" no-message] "set breakpoint on address"
diff --git a/gdb/testsuite/gdb.base/ending-run.exp b/gdb/testsuite/gdb.base/ending-run.exp
index 022ac28..0b5eadf 100644
--- a/gdb/testsuite/gdb.base/ending-run.exp
+++ b/gdb/testsuite/gdb.base/ending-run.exp
@@ -224,7 +224,7 @@ set program_in_exit 0
if {!$use_gdb_stub
&& (! [target_info exists use_cygmon] || ! [target_info use_cygmon])} {
global program_exited
- if {[eval expr $program_exited == 0]} {
+ if {$program_exited == 0} {
gdb_test_multiple "n" "step to end of run" {
-re "$inferior_exited_re normally.*$gdb_prompt $" {
# If we actually have debug info for the start function,
diff --git a/gdb/testsuite/gdb.base/errno.exp b/gdb/testsuite/gdb.base/errno.exp
index ff18214..ea1ff70 100644
--- a/gdb/testsuite/gdb.base/errno.exp
+++ b/gdb/testsuite/gdb.base/errno.exp
@@ -45,7 +45,8 @@
standard_testfile
proc do_tests {{do_xfail_cast 0} {do_xfail 0} {do_xfail_core_test 0}} {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
if ![runto_main] {
return
}
@@ -176,7 +177,8 @@ proc do_tests {{do_xfail_cast 0} {do_xfail 0} {do_xfail_core_test 0}} {
return
}
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
set core_loaded [gdb_core_cmd $corefile "load corefile"]
if { $core_loaded == -1 } {
diff --git a/gdb/testsuite/gdb.base/eval-skip.exp b/gdb/testsuite/gdb.base/eval-skip.exp
index 82c5fe0..b4c856e 100644
--- a/gdb/testsuite/gdb.base/eval-skip.exp
+++ b/gdb/testsuite/gdb.base/eval-skip.exp
@@ -39,7 +39,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.base/exe-lock.exp b/gdb/testsuite/gdb.base/exe-lock.exp
index 40a470f..2e375b4 100644
--- a/gdb/testsuite/gdb.base/exe-lock.exp
+++ b/gdb/testsuite/gdb.base/exe-lock.exp
@@ -27,7 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debu
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
# Sanity-check: Verify that the executable exists. This is just to
# make sure that, when we verify later that the file does not exist,
diff --git a/gdb/testsuite/gdb.base/exec-invalid-sysroot.exp b/gdb/testsuite/gdb.base/exec-invalid-sysroot.exp
index 7ab446e..99f5e7d 100644
--- a/gdb/testsuite/gdb.base/exec-invalid-sysroot.exp
+++ b/gdb/testsuite/gdb.base/exec-invalid-sysroot.exp
@@ -69,5 +69,6 @@ proc do_exec_sysroot_test {} {
}
# Start with a fresh gdb
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
do_exec_sysroot_test
diff --git a/gdb/testsuite/gdb.base/execl-update-breakpoints.exp b/gdb/testsuite/gdb.base/execl-update-breakpoints.exp
index 27bd042..cd49df1 100644
--- a/gdb/testsuite/gdb.base/execl-update-breakpoints.exp
+++ b/gdb/testsuite/gdb.base/execl-update-breakpoints.exp
@@ -41,7 +41,8 @@ if { [gdb_compile $objfile $exec1 executable {debug text_segment=0x1000000}] !=
# First check whether the address of "main" in exec1 is readable in
# exec2. If it is, then skip the test as unsupported.
-clean_restart ${exec1}
+clean_restart
+gdb_load $exec1
if {![runto_main]} {
return -1
}
@@ -55,7 +56,8 @@ gdb_test_multiple "p/x &main" $test {
}
}
-clean_restart ${exec2}
+clean_restart
+gdb_load $exec2
if {![runto_main]} {
return -1
}
@@ -84,7 +86,8 @@ proc test { always_inserted } {
global exec1
global gdb_prompt
- clean_restart ${exec1}
+ clean_restart
+ gdb_load $exec1
gdb_test_no_output "set breakpoint always-inserted $always_inserted"
diff --git a/gdb/testsuite/gdb.base/exprs.exp b/gdb/testsuite/gdb.base/exprs.exp
index f703c18..ee0c198 100644
--- a/gdb/testsuite/gdb.base/exprs.exp
+++ b/gdb/testsuite/gdb.base/exprs.exp
@@ -26,7 +26,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
#
# set it up at a breakpoint so we can play with the variable values
@@ -285,11 +286,14 @@ gdb_test "print v_short + " \
gdb_test "print v_short =}{= 3" \
"A syntax error in expression, near `\\}\\{= 3'\\."
+set hs {[^\r\n]}
+set re_debug [string cat $hs* {[Ss]hift} $hs*]
+
gdb_test_no_output "set debug parse 1"
set saw_start 0
set saw_val 0
gdb_test_multiple "print 23" "print with debugging" -lbl {
- -re "\r\nStarting parse(?=\r\n)" {
+ -re "\r\n${re_debug}(?=\r\n)" {
set saw_start 1
exp_continue
}
diff --git a/gdb/testsuite/gdb.base/fileio.c b/gdb/testsuite/gdb.base/fileio.c
index 0f20151..4ba5ab0 100644
--- a/gdb/testsuite/gdb.base/fileio.c
+++ b/gdb/testsuite/gdb.base/fileio.c
@@ -73,6 +73,10 @@ static const char *strerrno (int err);
#define STRING "Hello World"
+#define STRINGIFY(s) STRINGIFY_(s)
+#define STRINGIFY_(s) #s
+#define OUTDIR STRINGIFY (OUTDIR_)
+
static void stop (void) {}
/* A NULL string. We pass this to stat below instead of a NULL
diff --git a/gdb/testsuite/gdb.base/fileio.exp b/gdb/testsuite/gdb.base/fileio.exp
index 6996d6d..a6b4c23 100644
--- a/gdb/testsuite/gdb.base/fileio.exp
+++ b/gdb/testsuite/gdb.base/fileio.exp
@@ -27,7 +27,7 @@ if {[is_remote host]} {
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
executable \
- [list debug "additional_flags=-DOUTDIR=\"$outdir/\""]] != "" } {
+ [list debug additional_flags=[quote_for_host -DOUTDIR_=$outdir/]]] != "" } {
untested "failed to compile"
return -1
}
@@ -41,7 +41,8 @@ system "rm -rf [standard_output_file *.fileio.test]"
set oldtimeout $timeout
set timeout [expr "$timeout + 60"]
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
gdb_test_no_output "set print sevenbit-strings"
gdb_test_no_output "set print address off"
gdb_test_no_output "set width 0"
diff --git a/gdb/testsuite/gdb.base/find.exp b/gdb/testsuite/gdb.base/find.exp
index ae68686..3b2dfb0 100644
--- a/gdb/testsuite/gdb.base/find.exp
+++ b/gdb/testsuite/gdb.base/find.exp
@@ -22,7 +22,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
gdb_test "break $srcfile:stop_here" \
"Breakpoint.*at.* file .*$srcfile, line.*" \
diff --git a/gdb/testsuite/gdb.base/fixsection.exp b/gdb/testsuite/gdb.base/fixsection.exp
index 9a5c996..3056851 100644
--- a/gdb/testsuite/gdb.base/fixsection.exp
+++ b/gdb/testsuite/gdb.base/fixsection.exp
@@ -32,7 +32,8 @@ if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
gdb_load_shlib ${lib_sl}
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.base/float128.exp b/gdb/testsuite/gdb.base/float128.exp
index 95b83af..b8d3a6c 100644
--- a/gdb/testsuite/gdb.base/float128.exp
+++ b/gdb/testsuite/gdb.base/float128.exp
@@ -30,7 +30,8 @@ if { [do_compile] != "" && [do_compile {-mfloat128}] != "" } {
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.base/floatn.exp b/gdb/testsuite/gdb.base/floatn.exp
index 7138d04..1b39ed8 100644
--- a/gdb/testsuite/gdb.base/floatn.exp
+++ b/gdb/testsuite/gdb.base/floatn.exp
@@ -30,7 +30,8 @@ if { [do_compile] != "" && [do_compile {-mfloat128}] != "" } {
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.base/foll-exec.exp.tcl b/gdb/testsuite/gdb.base/foll-exec.exp.tcl
index 8f96a55..64bcea8 100644
--- a/gdb/testsuite/gdb.base/foll-exec.exp.tcl
+++ b/gdb/testsuite/gdb.base/foll-exec.exp.tcl
@@ -68,7 +68,8 @@ proc do_exec_tests { execer_lang execee_lang } {
}
# Now we can start running the tests.
- clean_restart $execer_binfile
+ clean_restart
+ gdb_load $execer_binfile
# Start the program running, and stop at main.
if {![runto_main]} {
@@ -93,7 +94,8 @@ proc do_exec_tests { execer_lang execee_lang } {
return
}
- clean_restart $execer_binfile
+ clean_restart
+ gdb_load $execer_binfile
# Start the program running, and stop at main.
#
@@ -182,7 +184,8 @@ proc do_exec_tests { execer_lang execee_lang } {
# Explicitly kill this program, or a subsequent rerun actually runs
# the exec'd program, not the original program...
- clean_restart $execer_binfile
+ clean_restart
+ gdb_load $execer_binfile
# Start the program running, and stop at main.
#
@@ -250,7 +253,8 @@ proc do_exec_tests { execer_lang execee_lang } {
# Explicitly kill this program, or a subsequent rerun actually runs
# the exec'd program, not the original program...
- clean_restart $execer_binfile
+ clean_restart
+ gdb_load $execer_binfile
# Start the program running, and stop at main.
#
@@ -317,7 +321,8 @@ proc do_exec_tests { execer_lang execee_lang } {
# Explicitly kill this program, or a subsequent rerun actually runs
# the exec'd program, not the original program...
- clean_restart $execer_binfile
+ clean_restart
+ gdb_load $execer_binfile
# Start the program running, and stop at main.
#
@@ -378,7 +383,8 @@ proc do_exec_tests { execer_lang execee_lang } {
# Explicitly kill this program, or a subsequent rerun actually runs
# the exec'd program, not the original program...
- clean_restart $execer_binfile
+ clean_restart
+ gdb_load $execer_binfile
# Start the program running, and stop at main.
#
diff --git a/gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen.exp b/gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen.exp
index 2d47d5d..cb49ef6 100644
--- a/gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen.exp
+++ b/gdb/testsuite/gdb.base/fork-no-detach-follow-child-dlopen.exp
@@ -41,7 +41,8 @@ if { [build_executable "failed to prepare" ${testfile} ${srcfile} $opts] } {
}
proc do_test {} {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
gdb_locate_shlib $::shlib_path
gdb_test_no_output "set follow-fork-mode child"
gdb_test_no_output "set detach-on-fork off"
diff --git a/gdb/testsuite/gdb.base/fork-print-inferior-events.exp b/gdb/testsuite/gdb.base/fork-print-inferior-events.exp
index 19ace00..c24a9bc 100644
--- a/gdb/testsuite/gdb.base/fork-print-inferior-events.exp
+++ b/gdb/testsuite/gdb.base/fork-print-inferior-events.exp
@@ -73,7 +73,8 @@ set i 0
foreach_with_prefix print_inferior_events { "on" "off" } {
foreach_with_prefix follow_fork_mode { "child" "parent" } {
foreach_with_prefix detach_on_fork { "on" "off" } {
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
gdb_test_no_output "set print inferior-events $print_inferior_events"
gdb_test_no_output "set follow-fork-mode $follow_fork_mode"
gdb_test_no_output "set detach-on-fork $detach_on_fork"
diff --git a/gdb/testsuite/gdb.base/frame-args.exp b/gdb/testsuite/gdb.base/frame-args.exp
index 31e4d15..0daa3aa 100644
--- a/gdb/testsuite/gdb.base/frame-args.exp
+++ b/gdb/testsuite/gdb.base/frame-args.exp
@@ -19,7 +19,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debu
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
if {![runto break_me]} {
return
diff --git a/gdb/testsuite/gdb.base/frame-info-consistent.exp b/gdb/testsuite/gdb.base/frame-info-consistent.exp
index 67bcd18..b594047 100644
--- a/gdb/testsuite/gdb.base/frame-info-consistent.exp
+++ b/gdb/testsuite/gdb.base/frame-info-consistent.exp
@@ -97,7 +97,8 @@ proc compare_frames {frames} {
proc test {enable} {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
gdb_test_no_output "maint frame-unwinder $enable DEBUGINFO"
diff --git a/gdb/testsuite/gdb.base/frame-view.exp b/gdb/testsuite/gdb.base/frame-view.exp
index fa00c35..34ac668 100644
--- a/gdb/testsuite/gdb.base/frame-view.exp
+++ b/gdb/testsuite/gdb.base/frame-view.exp
@@ -28,7 +28,8 @@ if { [build_executable "failed to prepare" \
# "select-frame view".
proc test_select_frame_view { with_pretty_printer } {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
if { $with_pretty_printer } {
require allow_python_tests
diff --git a/gdb/testsuite/gdb.base/fullname.exp b/gdb/testsuite/gdb.base/fullname.exp
index 430d0c4..ec90179 100644
--- a/gdb/testsuite/gdb.base/fullname.exp
+++ b/gdb/testsuite/gdb.base/fullname.exp
@@ -45,7 +45,8 @@ set line [gdb_get_line_number "set breakpoint 1 here"]
# Initialize GDB after getting the line number, to make sure
# symbols aren't loaded.
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
set msg "set breakpoint by full path before loading symbols - built absolute"
if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
@@ -65,12 +66,13 @@ if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}]
}
# Build the test executable using a relative path.
-if { [gdb_compile [relative_filename [pwd] [standard_output_file tmp-${srcfile}]] \
+if { [gdb_compile [relative_filename [pwd] [build_standard_output_file tmp-${srcfile}]] \
"${binfile}" executable {debug}] != "" } {
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
set msg "set breakpoint by full path before loading symbols - built relative"
if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
@@ -99,7 +101,8 @@ with_cwd [standard_output_file {}] {
}
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
set msg "set breakpoint by full path before loading symbols - built other"
if { [gdb_breakpoint [standard_output_file tmp-${srcfile}]:${line} {no-message}] != 0 } {
diff --git a/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp b/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp
index 0fb79c7..5a6bfe6 100644
--- a/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp
+++ b/gdb/testsuite/gdb.base/gcore-buffer-overflow.exp
@@ -29,7 +29,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
# Start with a fresh gdb.
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
gdb_test_no_output "set args ${pattern}" \
"set buffer exceeding arguments"
diff --git a/gdb/testsuite/gdb.base/gcore-memory-usage.exp b/gdb/testsuite/gdb.base/gcore-memory-usage.exp
index bd041f2..14b03a0 100644
--- a/gdb/testsuite/gdb.base/gcore-memory-usage.exp
+++ b/gdb/testsuite/gdb.base/gcore-memory-usage.exp
@@ -47,8 +47,10 @@ proc get_mem_usage {pid prefix} {
# This proc restarts GDB, runs the inferior with the desired
# amount of memory, then checks how much memory is necessary
# to run the gcore command. It will return -1 if the gcore
-# command fails, 0 otherwise.
-proc run_test {megs} {
+# command fails, otherwise the amount of memory used by GDB
+# to generate that gcore. MAX_MEM is the maximum amount of
+# memory GDB is allowed to use, in megabytes.
+proc run_test {megs max_mem} {
with_test_prefix "$megs Mb" {
clean_restart $::testfile
@@ -74,23 +76,24 @@ proc run_test {megs} {
set diff_k [expr $mem_after - $mem_before]
set diff [expr $diff_k/1024]
verbose -log "The gcore command used $diff Mb ($diff_k Kb)"
- # The original plan was to compare to a multiple of MEGS
- # but since the requirements don't seem to go up as the
- # inferior allocated more memory, we instead just hardcode
- # 2 megs, since sometimes 1 is used.
- gdb_assert {$diff < 2} "gdb did not use too much memory"
+ gdb_assert {$diff <= $max_mem} "gdb did not use too much memory"
gdb_test_no_output "set spin=0" "Allow program to exit"
}
- return 0
+ return $diff
}
# If we couldn't create the first corefile, there's no point
-# in running the second part of the test.
-if {[run_test 4] != 0} {
+# in running the second part of the test. The maximum amount
+# of memory allowed is the same as the memory used by the
+# inferior.
+set mem_limit [run_test 4 4]
+if {$mem_limit < 0} {
return
}
# Surprisingly enough, the larger inferior doesn't seem to use
# any extra memory, it usually uses less memory. Which is good,
# it means our memory requirements aren't growing with the inferior.
-run_test 64
+# This test ensures that it remains true that a larger inferior will
+# not grow the memory requirements.
+run_test 64 $mem_limit
diff --git a/gdb/testsuite/gdb.base/gcore-relro-pie.exp b/gdb/testsuite/gdb.base/gcore-relro-pie.exp
index 361fdb6..641caf1 100644
--- a/gdb/testsuite/gdb.base/gcore-relro-pie.exp
+++ b/gdb/testsuite/gdb.base/gcore-relro-pie.exp
@@ -38,7 +38,8 @@ if [run_on_host "strip" "$strip_program" "-g -o ${stripped_binfile} $binfile"] {
set perm [file attributes ${binfile} -permissions]
file attributes ${stripped_binfile} -permissions $perm
-clean_restart ${stripped_binfile}
+clean_restart
+gdb_load $stripped_binfile
# The binary is stripped of debug info, but not minsyms.
if ![runto break_here] {
@@ -51,7 +52,8 @@ if {![gdb_gcore_cmd $gcorefile "save a corefile"]} {
# Now restart gdb with the unstripped binary and load the corefile.
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
gdb_test "core ${gcorefile}" \
"Core was generated by .*" "re-load generated corefile"
diff --git a/gdb/testsuite/gdb.base/gcore-relro.exp b/gdb/testsuite/gdb.base/gcore-relro.exp
index 0090c37..2bbd064 100644
--- a/gdb/testsuite/gdb.base/gcore-relro.exp
+++ b/gdb/testsuite/gdb.base/gcore-relro.exp
@@ -34,7 +34,8 @@ set objfile [standard_output_file ${testfile}.o]
}
with_test_prefix "first session" {
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
gdb_load_shlib ${binfile_lib}
if ![runto lib] {
@@ -49,7 +50,8 @@ with_test_prefix "first session" {
# Now restart gdb and load the corefile.
with_test_prefix "second session" {
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
gdb_load_shlib ${binfile_lib}
gdb_test "core ${gcorefile}" "Core was generated by .*" \
diff --git a/gdb/testsuite/gdb.base/gcore-tls-pie.exp b/gdb/testsuite/gdb.base/gcore-tls-pie.exp
index c508b78..a8f7366 100644
--- a/gdb/testsuite/gdb.base/gcore-tls-pie.exp
+++ b/gdb/testsuite/gdb.base/gcore-tls-pie.exp
@@ -42,7 +42,8 @@ if [run_on_host "strip" "$strip_program" "-g -o ${stripped_binfile} $binfile"] {
set perm [file attributes ${binfile} -permissions]
file attributes ${stripped_binfile} -permissions $perm
-clean_restart ${stripped_binfile}
+clean_restart
+gdb_load $stripped_binfile
# The binary is stripped of debug info, but not minsyms.
if ![runto break_here] {
@@ -55,7 +56,8 @@ if {![gdb_gcore_cmd $gcorefile "save a corefile"]} {
# Now restart gdb with the unstripped binary and load the corefile.
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
gdb_test "core ${gcorefile}" \
"Core was generated by .*" "re-load generated corefile"
diff --git a/gdb/testsuite/gdb.base/gcore.exp b/gdb/testsuite/gdb.base/gcore.exp
index 0a9f099..c8a4c11 100644
--- a/gdb/testsuite/gdb.base/gcore.exp
+++ b/gdb/testsuite/gdb.base/gcore.exp
@@ -58,7 +58,8 @@ if {!$core_supported} {
}
# Now restart gdb and load the corefile.
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
set core_loaded [gdb_core_cmd "$corefile" "re-load generated corefile"]
if { $core_loaded == -1 } {
diff --git a/gdb/testsuite/gdb.base/gcorebg.exp b/gdb/testsuite/gdb.base/gcorebg.exp
index 3e79702..fd9f06e 100644
--- a/gdb/testsuite/gdb.base/gcorebg.exp
+++ b/gdb/testsuite/gdb.base/gcorebg.exp
@@ -46,10 +46,10 @@ proc test_body { detached } {
global binfile
global GCORE
global corefile
- global GDB_DATA_DIRECTORY
+ global GDB GDB_DATA_DIRECTORY
# We can't use gdb_test_multiple here because GDB is not started.
- set gcore_cmd $GCORE
+ set gcore_cmd "$GCORE -g $GDB"
if {$GDB_DATA_DIRECTORY ne ""} {
set gcore_cmd "$gcore_cmd -d '$GDB_DATA_DIRECTORY'"
}
diff --git a/gdb/testsuite/gdb.base/gdb-index-err.exp b/gdb/testsuite/gdb.base/gdb-index-err.exp
index 973248a..b353836 100644
--- a/gdb/testsuite/gdb.base/gdb-index-err.exp
+++ b/gdb/testsuite/gdb.base/gdb-index-err.exp
@@ -90,13 +90,15 @@ foreach_with_prefix flag { "" "-dwarf-5" } {
}
# Add the index section to the executable.
- clean_restart ${binfile}.${extension}
+ clean_restart
+ gdb_load $binfile.$extension
gdb_assert {[ensure_gdb_index ${binfile}.${extension} ${flag}] == 1} \
"add index to executable"
# Reload the executable (which now has an index), and try to
# generate and index from it. This will fail.
- clean_restart ${binfile}.${extension}
+ clean_restart
+ gdb_load $binfile.$extension
gdb_test "save gdb-index ${flag} $already_indexed_dir" \
"Error while writing index for `[string_to_regexp $binfile.$extension]': Cannot use an index to create the index" \
"try to generate an index from a binary with an index"
diff --git a/gdb/testsuite/gdb.base/gdb1250.exp b/gdb/testsuite/gdb.base/gdb1250.exp
index 4e83c8c..2cabbf0 100644
--- a/gdb/testsuite/gdb.base/gdb1250.exp
+++ b/gdb/testsuite/gdb.base/gdb1250.exp
@@ -29,7 +29,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
if {![runto abort {allow-pending}]} {
return
diff --git a/gdb/testsuite/gdb.base/gdb1555.exp b/gdb/testsuite/gdb.base/gdb1555.exp
index 648abd7..ab12a28 100644
--- a/gdb/testsuite/gdb.base/gdb1555.exp
+++ b/gdb/testsuite/gdb.base/gdb1555.exp
@@ -34,7 +34,8 @@ if { [gdb_compile_shlib $libsrc $libobj {debug}] != ""
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
gdb_load_shlib $libobj
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.base/gdbindex-stabs.exp b/gdb/testsuite/gdb.base/gdbindex-stabs.exp
index 506ad11..9becaa1 100644
--- a/gdb/testsuite/gdb.base/gdbindex-stabs.exp
+++ b/gdb/testsuite/gdb.base/gdbindex-stabs.exp
@@ -28,7 +28,8 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile_stabs}" ${objfile_stabs} object
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
# FAIL was: No line number known for stabs_function.
gdb_test "list stabs_function" " marker-here .*"
diff --git a/gdb/testsuite/gdb.base/gdbinit-history.exp b/gdb/testsuite/gdb.base/gdbinit-history.exp
index 48aae6b..11a4a23 100644
--- a/gdb/testsuite/gdb.base/gdbinit-history.exp
+++ b/gdb/testsuite/gdb.base/gdbinit-history.exp
@@ -141,7 +141,7 @@ proc check_history { hist } {
if { [llength $hist_lines] == 1 } {
set pattern [lindex $hist_lines 0]
} else {
- set pattern [eval multi_line $hist_lines]
+ set pattern [multi_line {*}$hist_lines]
}
# Check the history.
diff --git a/gdb/testsuite/gdb.base/global-var-nested-by-dso.exp b/gdb/testsuite/gdb.base/global-var-nested-by-dso.exp
index 92d6c62..480396a 100644
--- a/gdb/testsuite/gdb.base/global-var-nested-by-dso.exp
+++ b/gdb/testsuite/gdb.base/global-var-nested-by-dso.exp
@@ -42,7 +42,8 @@ if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable \
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
gdb_load_shlib $binfile_lib1
gdb_load_shlib $binfile_lib2
diff --git a/gdb/testsuite/gdb.base/gnu-ifunc.exp b/gdb/testsuite/gdb.base/gnu-ifunc.exp
index c7afbe5..f134a0f 100644
--- a/gdb/testsuite/gdb.base/gnu-ifunc.exp
+++ b/gdb/testsuite/gdb.base/gnu-ifunc.exp
@@ -96,7 +96,8 @@ proc_with_prefix set-break {resolver_attr resolver_debug final_debug} {
set suffix [make_binsuffix $resolver_attr $resolver_debug $final_debug]
set lib_so [standard_output_file ${libfile}-$suffix.so]
- clean_restart $binfile-$suffix
+ clean_restart
+ gdb_load $binfile-$suffix
gdb_load_shlib ${lib_so}
if {![runto_main]} {
@@ -185,6 +186,11 @@ proc_with_prefix set-break {resolver_attr resolver_debug final_debug} {
# other two locations.
gdb_test "info breakpoints" "$location\r\n.*$location\r\n$location"
}
+
+ # At one point a bug existed such that GDB would trigger an assert
+ # while restarting the inferior with ifunc breakpoints set.
+ gdb_run_cmd
+ gdb_test "" "Breakpoint $::decimal,.*final \\(\[^\r\n\]*\\).*" "restart, run until breakpoint"
}
# Misc GNU ifunc tests. For the description of RESOLVER_ATTR,
@@ -218,7 +224,8 @@ proc misc_tests {resolver_attr resolver_debug final_debug} {
# Start with a fresh gdb.
- clean_restart $binfile-$suffix
+ clean_restart
+ gdb_load $binfile-$suffix
gdb_load_shlib ${lib_so}
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.base/gnu_vector.exp b/gdb/testsuite/gdb.base/gnu_vector.exp
index ac0bff3..62c2003 100644
--- a/gdb/testsuite/gdb.base/gnu_vector.exp
+++ b/gdb/testsuite/gdb.base/gnu_vector.exp
@@ -40,7 +40,8 @@ if { [do_compile {-mcpu=native}] != ""
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
if { ![runto_main] } {
return -1
diff --git a/gdb/testsuite/gdb.base/hashline1.exp b/gdb/testsuite/gdb.base/hashline1.exp
index 9af144b..8e815ae 100644
--- a/gdb/testsuite/gdb.base/hashline1.exp
+++ b/gdb/testsuite/gdb.base/hashline1.exp
@@ -37,7 +37,8 @@ if { [gdb_compile $compile_name "${binfile}" executable {debug}] != "" } {
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
set bp_location [gdb_get_line_number "set breakpoint here" $new_srcfile]
diff --git a/gdb/testsuite/gdb.base/hashline2.exp b/gdb/testsuite/gdb.base/hashline2.exp
index 740f511..f12b4d1 100644
--- a/gdb/testsuite/gdb.base/hashline2.exp
+++ b/gdb/testsuite/gdb.base/hashline2.exp
@@ -34,7 +34,8 @@ if { [gdb_compile $new_srcfile "${binfile}" executable {debug}] != "" } {
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
set bp_location [gdb_get_line_number "set breakpoint here" ${new_srcfile}]
diff --git a/gdb/testsuite/gdb.base/hashline3.exp b/gdb/testsuite/gdb.base/hashline3.exp
index 2575c28..508f7c9 100644
--- a/gdb/testsuite/gdb.base/hashline3.exp
+++ b/gdb/testsuite/gdb.base/hashline3.exp
@@ -35,7 +35,8 @@ if { [gdb_compile $new_srcfile "${binfile}" executable {debug}] != "" } {
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
set bp_location [gdb_get_line_number "set breakpoint here" $new_srcfile]
diff --git a/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported.exp b/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported.exp
index 8598345..9355ce0 100644
--- a/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported.exp
+++ b/gdb/testsuite/gdb.base/hbreak-in-shr-unsupported.exp
@@ -34,7 +34,8 @@ if { [gdb_compile_shlib ${srcdir}/${subdir}/${lib_src} ${lib_so} $lib_opts] != "
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
gdb_load_shlib $lib_so
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.base/hook-stop.exp b/gdb/testsuite/gdb.base/hook-stop.exp
index a7b6ccd..1c774ce 100644
--- a/gdb/testsuite/gdb.base/hook-stop.exp
+++ b/gdb/testsuite/gdb.base/hook-stop.exp
@@ -37,7 +37,8 @@ proc define_hook_stop {commands} {
proc setup {commands} {
global srcfile binfile
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
if {![runto_main]} {
return -code return
diff --git a/gdb/testsuite/gdb.base/huge.exp b/gdb/testsuite/gdb.base/huge.exp
index f75b620..cb12964 100644
--- a/gdb/testsuite/gdb.base/huge.exp
+++ b/gdb/testsuite/gdb.base/huge.exp
@@ -42,7 +42,8 @@ for { set size $max } { $size >= $min } { set size [expr $size / 2] } {
require {expr $compilation_succeeded}
# Start with a fresh gdb.
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
save_vars { timeout } {
set timeout 30
diff --git a/gdb/testsuite/gdb.base/infcall-exec.exp b/gdb/testsuite/gdb.base/infcall-exec.exp
index 33cc5b6..b819284 100644
--- a/gdb/testsuite/gdb.base/infcall-exec.exp
+++ b/gdb/testsuite/gdb.base/infcall-exec.exp
@@ -36,7 +36,8 @@ if { [is_remote target] } {
set binfile2 [gdb_remote_download target $binfile2]
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
if {![runto_main]} {
return -1
diff --git a/gdb/testsuite/gdb.base/infcall-failure-2.exp b/gdb/testsuite/gdb.base/infcall-failure-2.exp
new file mode 100644
index 0000000..2a7d784
--- /dev/null
+++ b/gdb/testsuite/gdb.base/infcall-failure-2.exp
@@ -0,0 +1,37 @@
+# Copyright 2025 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/>.
+
+standard_testfile infcall-failure.c
+
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile] == -1 } {
+ return
+}
+
+if { ![runto_main] } {
+ return
+}
+
+if { ![gdb_breakpoint "*0x1" message] } {
+ return
+}
+
+gdb_test "p foo ()" \
+ [multi_line \
+ [string_to_regexp "Command aborted."] \
+ ".*" ]
+
+# Check that gdb is still responsive. Regression test for PR gdb/33068.
+gdb_test "p 1 + 1" \
+ " = 2"
diff --git a/gdb/testsuite/gdb.base/infcall-failure.exp b/gdb/testsuite/gdb.base/infcall-failure.exp
index e7aeac1..594cb2b 100644
--- a/gdb/testsuite/gdb.base/infcall-failure.exp
+++ b/gdb/testsuite/gdb.base/infcall-failure.exp
@@ -39,7 +39,8 @@ proc start_gdb_and_runto_main { target_async target_non_stop } {
append ::GDBFLAGS \
" -ex \"maintenance set target-async ${target_async}\""
- clean_restart ${::binfile}
+ clean_restart
+ gdb_load $::binfile
}
if { ![runto_main] } {
diff --git a/gdb/testsuite/gdb.base/infcall-nested-structs.exp.tcl b/gdb/testsuite/gdb.base/infcall-nested-structs.exp.tcl
index 3a11d7f..6c95934 100644
--- a/gdb/testsuite/gdb.base/infcall-nested-structs.exp.tcl
+++ b/gdb/testsuite/gdb.base/infcall-nested-structs.exp.tcl
@@ -81,7 +81,8 @@ proc start_nested_structs_test { lang types } {
}
# Start with a fresh gdb.
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
# Make certain that the output is consistent
gdb_test_no_output "set print sevenbit-strings"
@@ -91,7 +92,7 @@ proc start_nested_structs_test { lang types } {
gdb_test_no_output "set print elements 300"
# Advance to main
- if { ![runto_main] } then {
+ if { ![runto_main] } {
return 0
}
diff --git a/gdb/testsuite/gdb.base/infcall-timeout.exp b/gdb/testsuite/gdb.base/infcall-timeout.exp
index aa7dbc3..621a7b9 100644
--- a/gdb/testsuite/gdb.base/infcall-timeout.exp
+++ b/gdb/testsuite/gdb.base/infcall-timeout.exp
@@ -41,7 +41,8 @@ proc run_test { target_async target_non_stop non_stop unwind } {
append ::GDBFLAGS \
" -ex \"maintenance set target-async ${target_async}\""
- clean_restart ${::binfile}
+ clean_restart
+ gdb_load $::binfile
}
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.base/inferior-args.exp b/gdb/testsuite/gdb.base/inferior-args.exp
index 9406c78..6b92c08 100644
--- a/gdb/testsuite/gdb.base/inferior-args.exp
+++ b/gdb/testsuite/gdb.base/inferior-args.exp
@@ -17,6 +17,7 @@
# This does not work on boards that don't support inferior arguments.
require {!target_info exists noargs}
+require {expr [have_startup_shell] != -1}
standard_testfile .c
@@ -42,7 +43,8 @@ proc do_test { method startup_with_shell inferior_args expected_results \
stub_suitable } {
global binfile hex
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
gdb_test_no_output "set startup-with-shell $startup_with_shell"
@@ -168,8 +170,7 @@ lappend test_desc_list [list "test one" \
# the rest of this mess in order to avoid TCL escaping the quote for
# me. It's super important that what we send to GDB is '"' not '\"'.
set item [list "test two" false]
-set cmd [format "lappend item \{ '%c' '\\%c' \}" 34 34]
-eval $cmd
+lappend item [format { '%c' '\%c' } 34 34]
set bs "\\\\"
lappend item [list "$hex \"$bs\"\"" "$hex \"$bs$bs$bs\"\""]
lappend test_desc_list $item
@@ -211,14 +212,31 @@ lappend test_desc_list [list "test four" \
[list "$hex \"'\"" \
"$hex \"\\\\\"\""]]
-foreach desc $test_desc_list {
- lassign $desc name stub_suitable args re_list
- with_test_prefix $name {
- foreach_with_prefix set_method { "start" "starti" "run" "set args" } {
- foreach_with_prefix startup_with_shell { on off } {
- do_test $set_method $startup_with_shell $args $re_list \
- $stub_suitable
+# Run all tests in the global TEST_DESC_LIST.
+proc run_all_tests {} {
+ foreach desc $::test_desc_list {
+ lassign $desc name stub_suitable args re_list
+ with_test_prefix $name {
+ foreach_with_prefix set_method { "start" "starti" "run" "set args" } {
+ foreach_with_prefix startup_with_shell { on off } {
+ do_test $set_method $startup_with_shell $args $re_list \
+ $stub_suitable
+ }
}
}
}
}
+
+run_all_tests
+
+# For extended-remote targets, disable the packet which passes
+# inferior arguments as a single string. This changes how the vRun
+# (extended-remote only) packet works.
+if {[target_info gdb_protocol] == "extended-remote"} {
+ with_test_prefix "single-inferior-arg disabled" {
+ save_vars { GDBFLAGS } {
+ append GDBFLAGS " -ex \"set remote single-inferior-argument-feature-packet off\""
+ run_all_tests
+ }
+ }
+}
diff --git a/gdb/testsuite/gdb.base/inferior-died.exp b/gdb/testsuite/gdb.base/inferior-died.exp
index 764a88d..9ba3a4c 100644
--- a/gdb/testsuite/gdb.base/inferior-died.exp
+++ b/gdb/testsuite/gdb.base/inferior-died.exp
@@ -25,7 +25,8 @@ if { [build_executable "failed to build" ${testfile} ${testfile}.c] } {
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"set non-stop on\""
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
}
gdb_test_no_output "set detach-on-fork off"
diff --git a/gdb/testsuite/gdb.base/info-proc.exp b/gdb/testsuite/gdb.base/info-proc.exp
index 8dff6a5..adc8894 100644
--- a/gdb/testsuite/gdb.base/info-proc.exp
+++ b/gdb/testsuite/gdb.base/info-proc.exp
@@ -63,7 +63,8 @@ if {[istarget "*-*-linux*"]} {
}
set gcorefile [standard_output_file $testfile.gcore]
if {[gdb_gcore_cmd $gcorefile "save a core file"]} {
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
gdb_test "core $gcorefile" "Core was generated by.*" \
"core [file tail $gcorefile]"
diff --git a/gdb/testsuite/gdb.base/info-program.exp b/gdb/testsuite/gdb.base/info-program.exp
index 5a47e1e..da24880 100644
--- a/gdb/testsuite/gdb.base/info-program.exp
+++ b/gdb/testsuite/gdb.base/info-program.exp
@@ -35,7 +35,8 @@ standard_testfile
proc do_test { threads non-stop } {
save_vars { ::GDBFLAGS } {
append ::GDBFLAGS " -ex \"set non-stop ${non-stop}\""
- clean_restart $::binfile-$threads
+ clean_restart
+ gdb_load $::binfile-$threads
}
gdb_test "info program" \
diff --git a/gdb/testsuite/gdb.base/info-types.exp.tcl b/gdb/testsuite/gdb.base/info-types.exp.tcl
index f75bb36..c05837b 100644
--- a/gdb/testsuite/gdb.base/info-types.exp.tcl
+++ b/gdb/testsuite/gdb.base/info-types.exp.tcl
@@ -33,7 +33,7 @@ proc run_test { lang } {
return -1
}
- if ![runto_main] then {
+ if { ![runto_main] } {
return 0
}
diff --git a/gdb/testsuite/gdb.base/info_sources_2.exp b/gdb/testsuite/gdb.base/info_sources_2.exp
index c469049..09e9972 100644
--- a/gdb/testsuite/gdb.base/info_sources_2.exp
+++ b/gdb/testsuite/gdb.base/info_sources_2.exp
@@ -35,7 +35,8 @@ if {[gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable \
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
set solib_name [gdb_load_shlib $solib_name]
@@ -72,13 +73,18 @@ proc run_info_sources { extra_args args } {
set objfile_name ""
set source_files {}
set files {}
+ # Note below we sanitize paths so we can compare against the
+ # host_file_normalize'd paths later. Note we sanitize, but
+ # don't normalize here, as the latter would turn a relative
+ # path into an absolute path, and this testcase wants to make
+ # sure that GDB prints the absolute path.
gdb_test_multiple $cmd "" {
-re "${command_regex}\r\n" {
exp_continue
}
-re "^(\[^\r\n\]+):\r\n" {
- set objfile_name $expect_out(1,string)
+ set objfile_name [host_file_sanitize $expect_out(1,string)]
if { $is_remote_target } {
set objfile_name [file tail $objfile_name]
}
@@ -101,7 +107,7 @@ proc run_info_sources { extra_args args } {
}
-re "^(\[^,\r\n\]+), " {
- set f $expect_out(1,string)
+ set f [host_file_sanitize $expect_out(1,string)]
lappend files $f
exp_continue
}
@@ -111,7 +117,7 @@ proc run_info_sources { extra_args args } {
return
}
- set f $expect_out(1,string)
+ set f [host_file_sanitize $expect_out(1,string)]
lappend files $f
set info_sources($objfile_name) $files
set $objfile_name ""
@@ -133,7 +139,7 @@ proc run_info_sources { extra_args args } {
}
# Figure out the path for SOURCEFILE that we're looking for.
- set sourcepath [file normalize ${srcdir}/${subdir}/${sourcefile}]
+ set sourcepath [host_file_normalize ${srcdir}/${subdir}/${sourcefile}]
if { $is_remote_target } {
set objfile [file tail $objfile]
@@ -156,32 +162,34 @@ proc run_info_sources { extra_args args } {
# The actual tests.
+set host_binfile [host_file_normalize $binfile$EXEEXT]
+
run_info_sources "" \
- ${binfile} ${srcfile} \
- ${binfile} ${testfile}-header.h \
+ ${host_binfile} ${srcfile} \
+ ${host_binfile} ${testfile}-header.h \
${solib_name} ${srcfile2} \
${solib_name} ${testfile}-header.h
run_info_sources "-basename info_sources_2" \
- ${binfile} ${srcfile} \
- ${binfile} ${testfile}-header.h \
+ ${host_binfile} ${srcfile} \
+ ${host_binfile} ${testfile}-header.h \
${solib_name} ${srcfile2} \
${solib_name} ${testfile}-header.h
run_info_sources "-basename \\.c" \
- ${binfile} ${srcfile} \
- ${binfile} !${testfile}-header.h \
+ ${host_binfile} ${srcfile} \
+ ${host_binfile} !${testfile}-header.h \
${solib_name} ${srcfile2} \
${solib_name} !${testfile}-header.h
run_info_sources "-basename -- -test\\.c" \
- ${binfile} ${srcfile} \
- ${binfile} !${testfile}-header.h \
+ ${host_binfile} ${srcfile} \
+ ${host_binfile} !${testfile}-header.h \
${solib_name} !${srcfile2} \
${solib_name} !${testfile}-header.h
run_info_sources "-basename -- -lib\\.c" \
- ${binfile} !${srcfile} \
- ${binfile} !${testfile}-header.h \
+ ${host_binfile} !${srcfile} \
+ ${host_binfile} !${testfile}-header.h \
${solib_name} ${srcfile2} \
${solib_name} !${testfile}-header.h
diff --git a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.py b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.py
index bc4a673..4ab7257 100644
--- a/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.py
+++ b/gdb/testsuite/gdb.base/inline-frame-cycle-unwind.py
@@ -65,6 +65,10 @@ class TestUnwinder(Unwinder):
for reg in pending_frame.architecture().registers("general"):
val = pending_frame.read_register(reg)
+ # Having unavailable registers leads to a fall back to the standard
+ # unwinders. Don't add unavailable registers to avoid this.
+ if str(val) == "<unavailable>":
+ continue
unwinder.add_saved_register(reg, val)
return unwinder
diff --git a/gdb/testsuite/gdb.base/internal-string-values.exp b/gdb/testsuite/gdb.base/internal-string-values.exp
index aa68bc9..c1afa18 100644
--- a/gdb/testsuite/gdb.base/internal-string-values.exp
+++ b/gdb/testsuite/gdb.base/internal-string-values.exp
@@ -250,7 +250,8 @@ proc_with_prefix test_internal_var { } {
return
}
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
if {![runto_main]} {
fail "could not run to main"
diff --git a/gdb/testsuite/gdb.base/interrupt-daemon-attach.exp b/gdb/testsuite/gdb.base/interrupt-daemon-attach.exp
index 3c46f5d..a42fc12 100644
--- a/gdb/testsuite/gdb.base/interrupt-daemon-attach.exp
+++ b/gdb/testsuite/gdb.base/interrupt-daemon-attach.exp
@@ -36,7 +36,8 @@ proc do_test {} {
# Attach to the parent, run it to a known point, extract the
# child's PID, and detach.
with_test_prefix "parent" {
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
gdb_test "attach $parent_pid" \
"Attaching to program.*, process $parent_pid.*" \
@@ -60,7 +61,8 @@ proc do_test {} {
with_test_prefix "child" {
global gdb_prompt
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
gdb_test "attach $child_pid" \
"Attaching to program.*, process $child_pid.*" \
diff --git a/gdb/testsuite/gdb.base/interrupt-daemon.exp b/gdb/testsuite/gdb.base/interrupt-daemon.exp
index 8b8c61d..b909437 100644
--- a/gdb/testsuite/gdb.base/interrupt-daemon.exp
+++ b/gdb/testsuite/gdb.base/interrupt-daemon.exp
@@ -30,7 +30,8 @@ proc do_test {} {
global binfile
global gdb_prompt
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
gdb_test "set follow-fork-mode child" ".*"
diff --git a/gdb/testsuite/gdb.base/jit-bfd-name.exp b/gdb/testsuite/gdb.base/jit-bfd-name.exp
index 219929b..756a38b 100644
--- a/gdb/testsuite/gdb.base/jit-bfd-name.exp
+++ b/gdb/testsuite/gdb.base/jit-bfd-name.exp
@@ -46,7 +46,8 @@ if { [compile_jit_main ${main_srcfile} ${main_binfile} {}] != 0 } {
return
}
-clean_restart $::main_binfile
+clean_restart
+gdb_load $::main_binfile
if { ![runto_main] } {
return
}
diff --git a/gdb/testsuite/gdb.base/jit-elf-fork.exp b/gdb/testsuite/gdb.base/jit-elf-fork.exp
index c1fa428..92e7dc6 100644
--- a/gdb/testsuite/gdb.base/jit-elf-fork.exp
+++ b/gdb/testsuite/gdb.base/jit-elf-fork.exp
@@ -54,7 +54,8 @@ if { [compile_jit_main ${main_srcfile} ${main_binfile} {}] != 0 } {
# that the callers can continue execution until there.
proc do_setup { detach-on-fork follow-fork-mode } {
- clean_restart ${::main_binfile}
+ clean_restart
+ gdb_load $::main_binfile
gdb_test_no_output "set detach-on-fork ${detach-on-fork}"
gdb_test_no_output "set follow-fork-mode ${follow-fork-mode}"
diff --git a/gdb/testsuite/gdb.base/jit-elf-so.exp b/gdb/testsuite/gdb.base/jit-elf-so.exp
index c227748..8f16bdb 100644
--- a/gdb/testsuite/gdb.base/jit-elf-so.exp
+++ b/gdb/testsuite/gdb.base/jit-elf-so.exp
@@ -73,7 +73,8 @@ proc one_jit_test {solib_binfiles_target match_str} {
global main_loader_binfile main_loader_srcfile
global main_solib_binfile main_solib_binfile_target main_solib_srcfile
- clean_restart $main_loader_binfile
+ clean_restart
+ gdb_load $main_loader_binfile
gdb_locate_shlib $main_solib_binfile
# This is just to help debugging when things fail
diff --git a/gdb/testsuite/gdb.base/jit-elf.exp b/gdb/testsuite/gdb.base/jit-elf.exp
index a519565..2dc67a5 100644
--- a/gdb/testsuite/gdb.base/jit-elf.exp
+++ b/gdb/testsuite/gdb.base/jit-elf.exp
@@ -48,7 +48,8 @@ proc clean_reattach {} {
gdb_test_no_output "set var wait_for_gdb = 1"
gdb_test "detach" "Detaching from .*"
- clean_restart ${main_binfile}
+ clean_restart
+ gdb_load $main_binfile
if { ![gdb_attach $testpid \
-pattern "main.*at .*$::main_basename.c:.*"] } {
@@ -84,7 +85,8 @@ proc one_jit_test {jit_solibs_target match_str reattach} {
global test_verbose
global main_binfile main_srcfile
- clean_restart ${main_binfile}
+ clean_restart
+ gdb_load $main_binfile
# This is just to help debugging when things fail
if {$test_verbose > 0} {
diff --git a/gdb/testsuite/gdb.base/jit-reader-exec.exp b/gdb/testsuite/gdb.base/jit-reader-exec.exp
index ef6148b..e70f104 100644
--- a/gdb/testsuite/gdb.base/jit-reader-exec.exp
+++ b/gdb/testsuite/gdb.base/jit-reader-exec.exp
@@ -43,7 +43,8 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.base/jit-reader-simple.exp b/gdb/testsuite/gdb.base/jit-reader-simple.exp
index 77705eb..f577dba 100644
--- a/gdb/testsuite/gdb.base/jit-reader-simple.exp
+++ b/gdb/testsuite/gdb.base/jit-reader-simple.exp
@@ -103,9 +103,11 @@ proc jit_test_reread {standalone change_addr} {
with_test_prefix "initial run" {
if {$standalone} {
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
} else {
- clean_restart $binfile_dl
+ clean_restart
+ gdb_load $binfile_dl
}
runto_main
@@ -175,7 +177,8 @@ foreach standalone {1 0} {
# see JIT breakpoints defined for both.
with_test_prefix "two JITers" {
- clean_restart $binfile_dl2
+ clean_restart
+ gdb_load $binfile_dl2
if {![runto_main]} {
return -1
diff --git a/gdb/testsuite/gdb.base/jit-reader.exp b/gdb/testsuite/gdb.base/jit-reader.exp
index 4462ab4..cd844ca 100644
--- a/gdb/testsuite/gdb.base/jit-reader.exp
+++ b/gdb/testsuite/gdb.base/jit-reader.exp
@@ -102,7 +102,8 @@ proc jit_reader_test {} {
set any "\[^\r\n\]*"
- clean_restart $jit_host_bin
+ clean_restart
+ gdb_load $jit_host_bin
gdb_load_shlib $jit_reader_bin
if {$test_verbose > 0} {
diff --git a/gdb/testsuite/gdb.base/kill-during-detach.exp b/gdb/testsuite/gdb.base/kill-during-detach.exp
index e164234..290606a 100644
--- a/gdb/testsuite/gdb.base/kill-during-detach.exp
+++ b/gdb/testsuite/gdb.base/kill-during-detach.exp
@@ -76,7 +76,8 @@ set checkpoint_line [gdb_get_line_number "Checkpoint here"]
proc run_test { exit_p checkpoint_p } {
save_vars { ::GDBFLAGS } {
append ::GDBFLAGS " -ex \"set non-stop on\""
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
}
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.base/killed-outside.exp b/gdb/testsuite/gdb.base/killed-outside.exp
index 919584d..2b367e4 100644
--- a/gdb/testsuite/gdb.base/killed-outside.exp
+++ b/gdb/testsuite/gdb.base/killed-outside.exp
@@ -46,7 +46,8 @@ proc test {cmds_after_kill} {
global gdb_prompt
global decimal
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
if ![runto done] {
return
diff --git a/gdb/testsuite/gdb.base/langs.exp b/gdb/testsuite/gdb.base/langs.exp
index b84b7d6..aa8d8e0 100644
--- a/gdb/testsuite/gdb.base/langs.exp
+++ b/gdb/testsuite/gdb.base/langs.exp
@@ -93,7 +93,8 @@ if {[runto csub]} {
gdb_continue_to_end "first session"
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
# Try exercising the "minimal" language a bit...
diff --git a/gdb/testsuite/gdb.base/large-frame.exp b/gdb/testsuite/gdb.base/large-frame.exp
index 0418b5b..f0d7af6 100644
--- a/gdb/testsuite/gdb.base/large-frame.exp
+++ b/gdb/testsuite/gdb.base/large-frame.exp
@@ -28,12 +28,12 @@ if { [is_remote host] } {
# the test.
proc run_test { opt_level } {
- global srcfile srcfile2 binfile hex
+ global srcfile srcfile2 hex
standard_testfile large-frame-1.c large-frame-2.c
if {[prepare_for_testing_full "failed to prepare" \
- [list ${binfile}-${opt_level} debug \
+ [list $::testfile-$opt_level debug \
$srcfile [list debug] \
$srcfile2 [list nodebug optimize=-$opt_level]]]} {
return
diff --git a/gdb/testsuite/gdb.base/libsegfault.exp b/gdb/testsuite/gdb.base/libsegfault.exp
index eab12ff..a3883e1 100644
--- a/gdb/testsuite/gdb.base/libsegfault.exp
+++ b/gdb/testsuite/gdb.base/libsegfault.exp
@@ -24,6 +24,15 @@
# the local machine.
require {!is_remote host}
+# On Cygwin, the testcase would somehow end up trying to preload
+# libSegFault.so into the Expect process, which would fail and crash
+# it. Since libSegFault.so is a glibc feature that doesn't exist on
+# Cygwin, just skip testing there.
+require {!expr {[isbuild "*-*-cygwin*"] && [ishost "*-*-cygwin*"]}}
+# Same when testing MinGW with MSYS2, as MSYS2 is really a Cygwin
+# fork.
+require {!expr {[isbuild "*-*-mingw*"] && [ishost "*-*-mingw*"]}}
+
# Spawn GDB with LIB preloaded with LD_PRELOAD. CMDLINE_OPTS are
# command line options passed to GDB.
diff --git a/gdb/testsuite/gdb.base/lineinc.exp b/gdb/testsuite/gdb.base/lineinc.exp
index cfd2ba7..2382fa5 100644
--- a/gdb/testsuite/gdb.base/lineinc.exp
+++ b/gdb/testsuite/gdb.base/lineinc.exp
@@ -86,7 +86,8 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" ${binfile} executable \
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
# Any command that causes GDB to read the debugging info for the
# lineinc.c compilation unit will do here.
diff --git a/gdb/testsuite/gdb.base/list-missing-source.exp b/gdb/testsuite/gdb.base/list-missing-source.exp
index 7807206..196a1f2 100644
--- a/gdb/testsuite/gdb.base/list-missing-source.exp
+++ b/gdb/testsuite/gdb.base/list-missing-source.exp
@@ -43,7 +43,8 @@ if { [gdb_compile "${srcfile}" "${binfile}" \
remote_file host delete $srcfile
# Now start GDB, run to main and try to list the source.
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp
index d005ceb..bdbb52b 100644
--- a/gdb/testsuite/gdb.base/list.exp
+++ b/gdb/testsuite/gdb.base/list.exp
@@ -385,7 +385,8 @@ proc test_only_end {} {
proc test_list_invalid_args {} {
global binfile
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
gdb_test "list -INVALID" \
"invalid explicit location argument, \"-INVALID\"" \
"first use of \"list -INVALID\""
@@ -393,7 +394,8 @@ proc test_list_invalid_args {} {
"invalid explicit location argument, \"-INVALID\"" \
"second use of \"list -INVALID\""
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
gdb_test "list +INVALID" "Function \"\\+INVALID\" not defined." \
"first use of \"list +INVALID\""
gdb_test "list +INVALID" "Function \"\\+INVALID\" not defined." \
@@ -499,7 +501,8 @@ proc test_list {command listsize1 listsize2 linerange1 linerange2} {
with_test_prefix "$command after stop: $listsize1, $listsize2" {
global binfile
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
if {![runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.base/logical.exp b/gdb/testsuite/gdb.base/logical.exp
index 31007e8..b00d6d5 100644
--- a/gdb/testsuite/gdb.base/logical.exp
+++ b/gdb/testsuite/gdb.base/logical.exp
@@ -32,7 +32,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
#
diff --git a/gdb/testsuite/gdb.base/long_long.exp b/gdb/testsuite/gdb.base/long_long.exp
index 38ba03e..4fbb757 100644
--- a/gdb/testsuite/gdb.base/long_long.exp
+++ b/gdb/testsuite/gdb.base/long_long.exp
@@ -30,7 +30,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [con
# use this to debug:
#log_user 1
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
if {![runto known_types]} {
return
diff --git a/gdb/testsuite/gdb.base/longjmp.exp b/gdb/testsuite/gdb.base/longjmp.exp
index caf0d5c..99552e6 100644
--- a/gdb/testsuite/gdb.base/longjmp.exp
+++ b/gdb/testsuite/gdb.base/longjmp.exp
@@ -26,7 +26,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
}
proc do_test { with_probes } {
- clean_restart ${::binfile}
+ clean_restart
+ gdb_load $::binfile
if { !$with_probes } {
gdb_test "maint ignore-probes libc ^longjmp$"
diff --git a/gdb/testsuite/gdb.base/macro-source-path.exp b/gdb/testsuite/gdb.base/macro-source-path.exp
index 47ad789..9c84227 100644
--- a/gdb/testsuite/gdb.base/macro-source-path.exp
+++ b/gdb/testsuite/gdb.base/macro-source-path.exp
@@ -33,7 +33,7 @@ require {!is_remote host}
# Set the current working directory to $out/cwd, so that we can test compiling
# using relative paths.
-set out_dir [standard_output_file ""]
+set out_dir [build_standard_output_file ""]
file mkdir $out_dir/cwd
file mkdir $out_dir/other
file copy -force $srcdir/$subdir/$srcfile $out_dir/cwd
@@ -53,7 +53,8 @@ proc test { src name } {
return
}
- clean_restart $binfile
+ clean_restart
+ gdb_load [host_file_normalize $binfile]
if { ![runto_main] } {
return
diff --git a/gdb/testsuite/gdb.base/macscp.exp b/gdb/testsuite/gdb.base/macscp.exp
index 0b5f863..63f1356 100644
--- a/gdb/testsuite/gdb.base/macscp.exp
+++ b/gdb/testsuite/gdb.base/macscp.exp
@@ -29,7 +29,8 @@ if {[gdb_compile "${srcdir}/${subdir}/macscp1.c" "${objfile}" \
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
# Ask GDB to show the current definition of MACRO, and return a list
diff --git a/gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.exp b/gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.exp
index 80f2d01..91d0379 100644
--- a/gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.exp
+++ b/gdb/testsuite/gdb.base/maint-info-inline-frames-and-blocks.exp
@@ -201,7 +201,8 @@ gdb_test "maint info blocks" [make_blocks_result normal_func \
inline_func_a inline_func_b] \
"maint info blocks using stored \$pc, inferior still running"
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
# Use the recorded $pc value to check inline frames when the inferior
# is not executing.
diff --git a/gdb/testsuite/gdb.base/maint-test-remote-args.exp b/gdb/testsuite/gdb.base/maint-test-remote-args.exp
new file mode 100644
index 0000000..6cd3006
--- /dev/null
+++ b/gdb/testsuite/gdb.base/maint-test-remote-args.exp
@@ -0,0 +1,40 @@
+# Copyright 2024-2025 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 the 'maint test-remote-args' command.
+#
+# We do minimal testing in here. If you are thinking of adding a new
+# test here then you are most likely adding the test in the wrong
+# place. Remote argument testing is checked in the following test
+# scripts: gdb.base/args.exp, gdb.base/inferior-args.exp,
+# gdb.base/startup-with-shell.exp, and gdb.python/py-inferior.exp.
+# The test gdb.gdb/unittest.exp also runs 'maint selftest
+# remote-args', which are the remote argument self tests.
+#
+# If you have a new test for an argument that was being passed
+# incorrectly, then add the test to one of those scripts.
+#
+# This file is ONLY for validating that the 'maint test-remote-args'
+# command itself is working.
+
+gdb_start
+
+gdb_test "maint test-remote-args a b c" \
+ [multi_line \
+ "Input \\(a b c\\)" \
+ " \\(a\\)" \
+ " \\(b\\)" \
+ " \\(c\\)" \
+ "Output \\(a b c\\)"]
diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp
index 7936e53..3d49b36 100644
--- a/gdb/testsuite/gdb.base/maint.exp
+++ b/gdb/testsuite/gdb.base/maint.exp
@@ -72,7 +72,8 @@ with_test_prefix "warnings" {
foreach cmd {"per-command" "per-command time"} {
with_test_prefix $cmd {
# GDB only warns once, so restart between commands.
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
gdb_test "mt set $cmd on" "$maybe_per_command_warning"
gdb_test "mt set $cmd off" "command started"
gdb_test_no_output "mt set $cmd on" \
diff --git a/gdb/testsuite/gdb.base/many-headers.exp b/gdb/testsuite/gdb.base/many-headers.exp
index f46b980..5e022da 100644
--- a/gdb/testsuite/gdb.base/many-headers.exp
+++ b/gdb/testsuite/gdb.base/many-headers.exp
@@ -33,6 +33,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug]} {
# Generate core file.
set corefile [core_find $binfile]
if {$corefile == ""} {
+ untested "unable to create or find corefile"
return 0
}
diff --git a/gdb/testsuite/gdb.base/max-depth.exp.tcl b/gdb/testsuite/gdb.base/max-depth.exp.tcl
index fcec47b..22bf180 100644
--- a/gdb/testsuite/gdb.base/max-depth.exp.tcl
+++ b/gdb/testsuite/gdb.base/max-depth.exp.tcl
@@ -30,12 +30,12 @@ proc compile_and_run_tests { lang } {
lappend flags "additional_flags=-std=c++11"
}
- if { [prepare_for_testing "failed to prepare" "${binfile}" "${srcfile}" "${flags}"] } {
+ if { [prepare_for_testing "failed to prepare" $testfile $srcfile $flags] } {
return 0
}
# Advance to main.
- if { ![runto_main] } then {
+ if { ![runto_main] } {
return 0
}
diff --git a/gdb/testsuite/gdb.base/memops-watchpoint.exp b/gdb/testsuite/gdb.base/memops-watchpoint.exp
index eba54c1..1a8d6d9 100644
--- a/gdb/testsuite/gdb.base/memops-watchpoint.exp
+++ b/gdb/testsuite/gdb.base/memops-watchpoint.exp
@@ -44,118 +44,63 @@ gdb_test "watch -location c\[28\]" \
# This is to allow the tests to work if there's a properly named symbol for
# the function, even if there's no libc debug info.
-set saw_watch_trigger 0
-set saw_function 0
-set is_supported 1
-set message "continue until memset watchpoint hits"
-set watch_trigger \
+# ARRAY_RE is the array whose modification is caught by the
+# watchpoint. SOURCE_FUNCTION is the function that modifies the
+# array, as written in the source of the test program. FUNCTION_RE
+# matches the name of the symbol that actually implements
+# SOURCE_FUNCTION (e.g., memcpy may be implemented with memmove, so we
+# may want to expect both). OLD_VALUE_RE and NEW_VALUE_RE match the
+# old/new values when the watchpoint triggers.
+
+proc continue_to_watchpoint {array_re source_function function_re
+ old_value_re new_value_re} {
+ set thread_prefix_re "(?:Thread $::decimal \[^\r\n\]*hit )?"
+
+ set saw_watch_trigger 0
+ set saw_function 0
+ set is_supported 1
+ set watch_trigger_re \
[multi_line \
"Continuing\\." \
"" \
- "(Hardware w|W)atchpoint ${decimal}: -location a\\\[28\\\]" \
+ "${thread_prefix_re}(Hardware w|W)atchpoint ${::decimal}: -location ${array_re}\\\[28\\\]" \
"" \
- "Old value = 104 'h'" \
- "New value = 0 '\\\\000'"]
-gdb_test_multiple "continue" $message {
- -re $watch_trigger {
- set saw_watch_trigger 1
- exp_continue
- }
- -re ".*memset.* \\(\\) at .*:$decimal\r\n" {
- set saw_function 1
- exp_continue
- }
- -re ".*memset.* \\(\\) from .*libc\[^\r\n\]+\r\n" {
- set saw_function 1
- exp_continue
- }
- -re "in \\?\\? \\(\\) from .*libc\[^\r\n\]+\r\n" {
- set is_supported 0
- unsupported "symbol for memset not found"
- exp_continue
- }
- -re "$gdb_prompt $" {
- if { $is_supported } {
- setup_kfail breakpoints/31665 arm*-*-linux*
- gdb_assert { $saw_watch_trigger && $saw_function } $message
+ "Old value = ${old_value_re}" \
+ "New value = ${new_value_re}"]
+ gdb_test_multiple "continue" \
+ "continue until $source_function watchpoint hits" {
+ -re $watch_trigger_re {
+ set saw_watch_trigger 1
+ exp_continue
+ }
+ -re "${function_re}.* \\(\\) at \[^\r\n\]+:${::decimal}(?=\r\n)" {
+ set saw_function 1
+ exp_continue
+ }
+ -re "${function_re}.* \\(\\) from \[^\r\n\]+(?=\r\n)" {
+ set saw_function 1
+ exp_continue
+ }
+ -re "in \\?\\? \\(\\) from \[^\r\n\]+(?=\r\n)" {
+ set is_supported 0
+ unsupported "symbol for ${source_function} not found"
+ exp_continue
+ }
+ -re -wrap "" {
+ if { $is_supported } {
+ setup_kfail breakpoints/31665 arm*-*-linux*
+ gdb_assert { $saw_watch_trigger && $saw_function } \
+ $gdb_test_name
+ }
}
}
}
+# Note: Some architectures use memmove for memset.
+continue_to_watchpoint "a" "memset" "(memset|memmove)" "104 'h'" "0 '\\\\000'"
+
# Note: Some architectures use memmove for memcpy.
-set saw_watch_trigger 0
-set saw_function 0
-set is_supported 1
-set message "continue until memcpy watchpoint hits"
-set watch_trigger \
- [multi_line \
- "Continuing\\." \
- "" \
- "(Hardware w|W)atchpoint ${decimal}: -location b\\\[28\\\]" \
- "" \
- "Old value = 101 'e'" \
- "New value = 114 'r'"]
-gdb_test_multiple "continue" $message {
- -re $watch_trigger {
- set saw_watch_trigger 1
- exp_continue
- }
- -re ".*(memcpy|memmove).* \\(\\) at .*:$decimal\r\n" {
- set saw_function 1
- exp_continue
- }
- -re ".*(memcpy|memmove).* \\(\\) from .*libc\[^\r\n\]+\r\n" {
- set saw_function 1
- exp_continue
- }
- -re "in \\?\\? \\(\\) from .*libc\[^\r\n\]+\r\n" {
- set is_supported 0
- unsupported "symbol for memcpy not found"
- exp_continue
- }
- -re "$gdb_prompt $" {
- if { $is_supported } {
- setup_kfail breakpoints/31665 arm*-*-linux*
- gdb_assert { $saw_watch_trigger && $saw_function } $message
- }
- }
-}
+continue_to_watchpoint "b" "memcpy" "(memcpy|memmove)" "101 'e'" "114 'r'"
# Note: Some architectures use memcpy for memmove.
-set saw_watch_trigger 0
-set saw_function 0
-set is_supported 1
-set message "continue until memmove watchpoint hits"
-set watch_trigger \
- [multi_line \
- "Continuing\\." \
- "" \
- "(Hardware w|W)atchpoint ${decimal}: -location c\\\[28\\\]" \
- "" \
- "Old value = 100 'd'" \
- "New value = 114 'r'"]
-gdb_test_multiple "continue" $message {
- -re $watch_trigger {
- set saw_watch_trigger 1
- exp_continue
- }
- -re ".*(memcpy|memmove).* \\(\\) at .*:$decimal\r\n" {
- set saw_function 1
- exp_continue
- }
- -re ".*(memcpy|memmove).* \\(\\) from .*libc\[^\r\n\]+\r\n" {
- set saw_function 1
- exp_continue
- }
- -re "in \\?\\? \\(\\) from .*libc\[^\r\n\]+\r\n" {
- set is_supported 0
- unsupported "symbol for memmove not found"
- exp_continue
- }
- -re "$gdb_prompt $" {
- if { $is_supported } {
- setup_kfail breakpoints/31665 arm*-*-linux*
- gdb_assert { $saw_watch_trigger && $saw_function } $message
- }
- }
-}
+continue_to_watchpoint "c" "memmove" "(memcpy|memmove)" "100 'd'" "114 'r'"
diff --git a/gdb/testsuite/gdb.base/miscexprs.exp b/gdb/testsuite/gdb.base/miscexprs.exp
index 86196fa..f723d75 100644
--- a/gdb/testsuite/gdb.base/miscexprs.exp
+++ b/gdb/testsuite/gdb.base/miscexprs.exp
@@ -44,7 +44,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [lis
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
#
diff --git a/gdb/testsuite/gdb.base/msym-bp-shl.exp b/gdb/testsuite/gdb.base/msym-bp-shl.exp
index b154ce6..41dc818 100644
--- a/gdb/testsuite/gdb.base/msym-bp-shl.exp
+++ b/gdb/testsuite/gdb.base/msym-bp-shl.exp
@@ -55,7 +55,8 @@ proc test {debug} {
return
}
- clean_restart $bin
+ clean_restart
+ gdb_load $bin
gdb_load_shlib $lib
# Should find two locations: the static foo in the
diff --git a/gdb/testsuite/gdb.base/multi-forks.exp b/gdb/testsuite/gdb.base/multi-forks.exp
index 3facccb..5d2d220 100644
--- a/gdb/testsuite/gdb.base/multi-forks.exp
+++ b/gdb/testsuite/gdb.base/multi-forks.exp
@@ -28,7 +28,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $fla
# Start with a fresh gdb
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
global gdb_prompt
@@ -103,7 +104,8 @@ proc continue_to_exit_bp_loc {} {
# parent's branch.
foreach mode { "child" "parent" } {
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
runto_main
gdb_test_no_output "set follow-fork $mode"
@@ -135,7 +137,8 @@ foreach mode { "child" "parent" } {
# Start with a fresh gdb
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
runto_main
gdb_breakpoint $exit_bp_loc
diff --git a/gdb/testsuite/gdb.base/nodebug.exp b/gdb/testsuite/gdb.base/nodebug.exp
index 2d0a5a9..b839317 100644
--- a/gdb/testsuite/gdb.base/nodebug.exp
+++ b/gdb/testsuite/gdb.base/nodebug.exp
@@ -33,7 +33,8 @@ if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != "
# Start with a fresh gdb.
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
# Run to FUNC and unload symbols from system shared libraries, to
# avoid conflicts with the minsyms in the program. E.g.,
diff --git a/gdb/testsuite/gdb.base/nofield.exp b/gdb/testsuite/gdb.base/nofield.exp
index 2e88725..31d0234 100644
--- a/gdb/testsuite/gdb.base/nofield.exp
+++ b/gdb/testsuite/gdb.base/nofield.exp
@@ -23,7 +23,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debu
set eol "\r\n"
set sp "\[ \t\]*"
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
gdb_test "ptype struct not_empty" \
"type = struct not_empty {$eol${sp}void \\*e;$eol${sp}void \\*u;$eol}"
diff --git a/gdb/testsuite/gdb.base/nostdlib.exp b/gdb/testsuite/gdb.base/nostdlib.exp
index ecf09a8..8dcefcf 100644
--- a/gdb/testsuite/gdb.base/nostdlib.exp
+++ b/gdb/testsuite/gdb.base/nostdlib.exp
@@ -49,7 +49,8 @@ foreach_with_prefix pie { "nopie" "pie" } {
return -1
}
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
gdb_breakpoint "*marker"
diff --git a/gdb/testsuite/gdb.base/options.exp b/gdb/testsuite/gdb.base/options.exp
index a0947e2..8ac9f4e 100644
--- a/gdb/testsuite/gdb.base/options.exp
+++ b/gdb/testsuite/gdb.base/options.exp
@@ -205,7 +205,8 @@ proc_with_prefix test-print {{prefix ""}} {
}
global binfile
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
if ![runto_main] {
return
@@ -317,7 +318,8 @@ proc_with_prefix test-backtrace {} {
"backtrace no-filters"
global binfile
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
if ![runto_main] {
return
diff --git a/gdb/testsuite/gdb.base/paginate-after-ctrl-c-running.exp b/gdb/testsuite/gdb.base/paginate-after-ctrl-c-running.exp
index a831050..d60a0ea 100644
--- a/gdb/testsuite/gdb.base/paginate-after-ctrl-c-running.exp
+++ b/gdb/testsuite/gdb.base/paginate-after-ctrl-c-running.exp
@@ -31,7 +31,8 @@ proc test_ctrlc_while_target_running_does_not_paginate {} {
set testline [gdb_get_line_number "after sleep"]
with_test_prefix "ctrlc target running" {
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.base/paginate-bg-execution.exp b/gdb/testsuite/gdb.base/paginate-bg-execution.exp
index dfd7823..40f98fc 100644
--- a/gdb/testsuite/gdb.base/paginate-bg-execution.exp
+++ b/gdb/testsuite/gdb.base/paginate-bg-execution.exp
@@ -30,7 +30,8 @@ proc test_bg_execution_pagination_return {} {
global decimal
with_test_prefix "paginate" {
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.base/paginate-inferior-exit.exp b/gdb/testsuite/gdb.base/paginate-inferior-exit.exp
index 76176e2..6cc992b 100644
--- a/gdb/testsuite/gdb.base/paginate-inferior-exit.exp
+++ b/gdb/testsuite/gdb.base/paginate-inferior-exit.exp
@@ -29,7 +29,8 @@ proc test_paginate_inferior_exited {} {
global inferior_exited_re
with_test_prefix "paginate" {
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.base/patch.exp b/gdb/testsuite/gdb.base/patch.exp
index 69e5581..f6abc59 100644
--- a/gdb/testsuite/gdb.base/patch.exp
+++ b/gdb/testsuite/gdb.base/patch.exp
@@ -34,7 +34,8 @@ with_test_prefix "exec" {
gdb_test "p extern_global = 2" " = 2" "modify value"
gdb_test "p extern_global" " = 2" "value modified"
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
gdb_test "p extern_global" " = 2" "value modified persisted"
}
@@ -43,7 +44,8 @@ with_test_prefix "exec" {
# Generate a core file.
with_test_prefix "gcore" {
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.base/pc-not-saved.exp b/gdb/testsuite/gdb.base/pc-not-saved.exp
index 16e11bc..e761e93 100644
--- a/gdb/testsuite/gdb.base/pc-not-saved.exp
+++ b/gdb/testsuite/gdb.base/pc-not-saved.exp
@@ -60,7 +60,8 @@ gdb_assert { ![string equal $pc unknown] } \
"check we read the frame's PC"
# Restart and load the Python unwinder script.
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
gdb_test_no_output "source ${remote_python_file}" "load python file"
# Tell the Python unwinder to use the frame-id we cached above.
diff --git a/gdb/testsuite/gdb.base/pie-fork.exp b/gdb/testsuite/gdb.base/pie-fork.exp
index 86407b4..9d232c8 100644
--- a/gdb/testsuite/gdb.base/pie-fork.exp
+++ b/gdb/testsuite/gdb.base/pie-fork.exp
@@ -29,7 +29,8 @@ if [build_executable "failed to prepare" $testfile $srcfile $opts] {
proc setup_test {detach_on_fork {follow_fork_mode "parent"}} {
global binfile
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
if ![runto_main] {
return
diff --git a/gdb/testsuite/gdb.base/pointers.exp b/gdb/testsuite/gdb.base/pointers.exp
index ab02181..4d4d58e 100644
--- a/gdb/testsuite/gdb.base/pointers.exp
+++ b/gdb/testsuite/gdb.base/pointers.exp
@@ -32,7 +32,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
#
diff --git a/gdb/testsuite/gdb.base/pr11022.exp b/gdb/testsuite/gdb.base/pr11022.exp
index e7bfba0..70a7d8b 100644
--- a/gdb/testsuite/gdb.base/pr11022.exp
+++ b/gdb/testsuite/gdb.base/pr11022.exp
@@ -24,7 +24,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
# Start with a fresh gdb.
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.base/print-symbol-loading.exp b/gdb/testsuite/gdb.base/print-symbol-loading.exp
index c9e2480..91e818b 100644
--- a/gdb/testsuite/gdb.base/print-symbol-loading.exp
+++ b/gdb/testsuite/gdb.base/print-symbol-loading.exp
@@ -35,7 +35,8 @@ if { [gdb_compile ${objfile} ${binfile} executable $opts] != "" } {
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
gdb_load_shlib ${binfile_lib}
if ![runto lib] {
@@ -94,7 +95,8 @@ proc test_load_shlib { print_symbol_loading } {
global binfile
global gdb_prompt
with_test_prefix "shlib ${print_symbol_loading}" {
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
if ![runto_main] {
return -1
}
diff --git a/gdb/testsuite/gdb.base/prologue.exp b/gdb/testsuite/gdb.base/prologue.exp
index 0d3902d..736e779 100644
--- a/gdb/testsuite/gdb.base/prologue.exp
+++ b/gdb/testsuite/gdb.base/prologue.exp
@@ -23,7 +23,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.base/ptr-typedef.exp b/gdb/testsuite/gdb.base/ptr-typedef.exp
index 53d03cc..8bffb26 100644
--- a/gdb/testsuite/gdb.base/ptr-typedef.exp
+++ b/gdb/testsuite/gdb.base/ptr-typedef.exp
@@ -22,7 +22,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
# Get things started.
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
if ![runto marker1] {
untested "couldn't run to marker1"
diff --git a/gdb/testsuite/gdb.base/ptype.exp b/gdb/testsuite/gdb.base/ptype.exp
index 6971f4c..04d2d2b 100644
--- a/gdb/testsuite/gdb.base/ptype.exp
+++ b/gdb/testsuite/gdb.base/ptype.exp
@@ -528,11 +528,10 @@ proc ptype_maybe_prototyped { id prototyped plain { overprototyped "NO-MATCH" }
# Turn the arguments, which are literal strings, into
# regular expressions by quoting any special characters they contain.
foreach var { prototyped plain overprototyped } {
- eval "set val \$$var"
- regsub -all "\[\]\[*()\]" $val "\\\\&" val
+ set val [string_to_regexp [set $var]]
regsub -all "short int" $val "short( int)?" val
regsub -all "long int" $val "long( int)?" val
- eval "set $var \$val"
+ set $var $val
}
gdb_test_multiple "ptype $id" "ptype $id" {
diff --git a/gdb/testsuite/gdb.base/quit-live.exp b/gdb/testsuite/gdb.base/quit-live.exp
index a95c980..46579d4 100644
--- a/gdb/testsuite/gdb.base/quit-live.exp
+++ b/gdb/testsuite/gdb.base/quit-live.exp
@@ -95,7 +95,8 @@ proc quit_with_live_inferior {appear_how extra_inferior quit_how} {
set test_spawn_id ""
if {$appear_how != "attach-nofile"} {
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
} else {
clean_restart
}
diff --git a/gdb/testsuite/gdb.base/random-signal.exp b/gdb/testsuite/gdb.base/random-signal.exp
index bb5b482..16f9467 100644
--- a/gdb/testsuite/gdb.base/random-signal.exp
+++ b/gdb/testsuite/gdb.base/random-signal.exp
@@ -49,7 +49,8 @@ proc do_test {} {
# while gdb is processing the internal software watchtpoint
# single-step. With remote debugging, the ctrl-c reaches GDB first.
with_test_prefix "run" {
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
if {![runto_main]} {
return -1
@@ -62,7 +63,8 @@ with_test_prefix "run" {
# reaches GDB first. Test that as well.
with_test_prefix "attach" {
if {[can_spawn_for_attach]} {
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
set test_spawn_id [spawn_wait_for_attach $binfile]
set testpid [spawn_id_get_pid $test_spawn_id]
diff --git a/gdb/testsuite/gdb.base/readline-ask.exp b/gdb/testsuite/gdb.base/readline-ask.exp
index 3f98e13..0fdfc76 100644
--- a/gdb/testsuite/gdb.base/readline-ask.exp
+++ b/gdb/testsuite/gdb.base/readline-ask.exp
@@ -13,6 +13,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+require {!is_remote host}
+
standard_testfile .c
set inputrc ${srcdir}/${subdir}/${testfile}.inputrc
@@ -25,7 +27,8 @@ setenv TERM dumb
# INPUTRC gets reset for the next testfile.
setenv INPUTRC $inputrc
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
if { ![readline_is_used] } {
unsupported "completion doesn't work when readline isn't used."
diff --git a/gdb/testsuite/gdb.base/readline-commands-eof.exp b/gdb/testsuite/gdb.base/readline-commands-eof.exp
index 021e40f..d55dd1d 100644
--- a/gdb/testsuite/gdb.base/readline-commands-eof.exp
+++ b/gdb/testsuite/gdb.base/readline-commands-eof.exp
@@ -43,7 +43,8 @@ if { ![readline_supports_eof_flag] } {
# arrived. If it is then GDB will start displaying extra blank lines
# after each line of input.
proc run_test {} {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
gdb_breakpoint main
diff --git a/gdb/testsuite/gdb.base/readline.exp b/gdb/testsuite/gdb.base/readline.exp
index 198d686..9b87790 100644
--- a/gdb/testsuite/gdb.base/readline.exp
+++ b/gdb/testsuite/gdb.base/readline.exp
@@ -21,6 +21,8 @@
# Tests for readline operations.
#
+require {!is_remote host}
+
# This function is used to test operate-and-get-next.
# NAME is the name of the test.
# ARGS is a list of alternating commands and expected results.
diff --git a/gdb/testsuite/gdb.base/readnever.exp b/gdb/testsuite/gdb.base/readnever.exp
index 6dfd576..891adf5 100644
--- a/gdb/testsuite/gdb.base/readnever.exp
+++ b/gdb/testsuite/gdb.base/readnever.exp
@@ -26,7 +26,7 @@ if { [build_executable "failed to build" $testfile $srcfile { debug }] == -1 } {
save_vars { GDBFLAGS } {
append GDBFLAGS " --readnever"
- if { [clean_restart ${binfile}] == -1 } {
+ if { [clean_restart $testfile] == -1 } {
return -1
}
}
diff --git a/gdb/testsuite/gdb.base/relativedebug.exp b/gdb/testsuite/gdb.base/relativedebug.exp
index d713771..2465ffd 100644
--- a/gdb/testsuite/gdb.base/relativedebug.exp
+++ b/gdb/testsuite/gdb.base/relativedebug.exp
@@ -24,7 +24,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
# Get things started.
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
runto_main
diff --git a/gdb/testsuite/gdb.base/remote-exec-file.exp b/gdb/testsuite/gdb.base/remote-exec-file.exp
index b735281..baaf039 100644
--- a/gdb/testsuite/gdb.base/remote-exec-file.exp
+++ b/gdb/testsuite/gdb.base/remote-exec-file.exp
@@ -37,10 +37,13 @@ with_test_prefix "set inf 2" {
with_test_prefix "show inf 1" {
gdb_test "inferior 1" "Switching to inferior 1.*"
- gdb_test "show remote exec-file" "prog1"
+ gdb_test "show remote exec-file" \
+ "The remote exec-file is \"prog1\"\\."
+
}
with_test_prefix "show inf 2" {
gdb_test "inferior 2" "Switching to inferior 2.*"
- gdb_test "show remote exec-file" "prog2"
+ gdb_test "show remote exec-file" \
+ "The remote exec-file is \"prog2\"\\."
}
diff --git a/gdb/testsuite/gdb.base/remote.exp b/gdb/testsuite/gdb.base/remote.exp
index 9917faf..c1d6a99 100644
--- a/gdb/testsuite/gdb.base/remote.exp
+++ b/gdb/testsuite/gdb.base/remote.exp
@@ -164,7 +164,8 @@ gdb_load_timed $binfile "limit" 0
# Get the size of random_data table (defaults to 48K).
set sizeof_random_data [get_sizeof "random_data" 48*1024]
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
#
# Part THREE: Check the upload behavior.
diff --git a/gdb/testsuite/gdb.base/reread.exp b/gdb/testsuite/gdb.base/reread.exp
index 7e7d2c8..6c71f40 100644
--- a/gdb/testsuite/gdb.base/reread.exp
+++ b/gdb/testsuite/gdb.base/reread.exp
@@ -106,7 +106,8 @@ foreach_with_prefix opts { "" "pie" } {
gdb_rename_execfile ${binfile1} ${binfile}
# Restart GDB entirely.
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
# Set a breakpoint on foo and run to it.
gdb_test "break foo" \
diff --git a/gdb/testsuite/gdb.base/reset-catchpoint-cond.exp b/gdb/testsuite/gdb.base/reset-catchpoint-cond.exp
index 062dc63..852576a 100644
--- a/gdb/testsuite/gdb.base/reset-catchpoint-cond.exp
+++ b/gdb/testsuite/gdb.base/reset-catchpoint-cond.exp
@@ -75,7 +75,8 @@ proc run_test { mode } {
return
}
- clean_restart $exec_name
+ clean_restart
+ gdb_load $exec_name
gdb_load_shlib $::libfile
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.base/restore.exp b/gdb/testsuite/gdb.base/restore.exp
index 9724032..5448fb4 100644
--- a/gdb/testsuite/gdb.base/restore.exp
+++ b/gdb/testsuite/gdb.base/restore.exp
@@ -96,7 +96,8 @@ restore_tests
set timeout $prev_timeout
# Test PR cli/23785
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
if { ![runto_main] } {
return -1
}
diff --git a/gdb/testsuite/gdb.base/return2.exp b/gdb/testsuite/gdb.base/return2.exp
index b657c11..e90a60b 100644
--- a/gdb/testsuite/gdb.base/return2.exp
+++ b/gdb/testsuite/gdb.base/return2.exp
@@ -103,7 +103,8 @@ proc return2_tests { } {
# Start with a fresh gdb.
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
set timeout 30
return2_tests
diff --git a/gdb/testsuite/gdb.base/rtld-step.exp b/gdb/testsuite/gdb.base/rtld-step.exp
index 242cd47..d1e240b 100644
--- a/gdb/testsuite/gdb.base/rtld-step.exp
+++ b/gdb/testsuite/gdb.base/rtld-step.exp
@@ -114,7 +114,8 @@ if { [gdb_compile ${srcfile_main} ${binfile_main} executable $main_flags] != ""
return -1
}
-clean_restart ${binfile_main}
+clean_restart
+gdb_load $binfile_main
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.base/run-attach-while-running.exp b/gdb/testsuite/gdb.base/run-attach-while-running.exp
index ae1388d..7b40a5f 100644
--- a/gdb/testsuite/gdb.base/run-attach-while-running.exp
+++ b/gdb/testsuite/gdb.base/run-attach-while-running.exp
@@ -60,7 +60,8 @@ proc_with_prefix test { non-stop threaded run-or-attach } {
set ::GDBFLAGS "$::GDBFLAGS -ex \"maint set target-non-stop on\""
}
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
}
if { ![runto_main] } {
diff --git a/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp b/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp
index eaee010..2c75d06 100644
--- a/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp
+++ b/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp
@@ -56,7 +56,8 @@ proc do_test { action1 action2 } {
save_vars { ::GDBFLAGS } {
append ::GDBFLAGS " -ex \"maintenance set target-non-stop on\""
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
}
# Ensure we are at least after the getpid call, should we need it.
diff --git a/gdb/testsuite/gdb.base/run-fail-twice.exp b/gdb/testsuite/gdb.base/run-fail-twice.exp
index af8c61b..07cbdda 100644
--- a/gdb/testsuite/gdb.base/run-fail-twice.exp
+++ b/gdb/testsuite/gdb.base/run-fail-twice.exp
@@ -43,7 +43,8 @@ proc test_run {testname} {
proc_with_prefix test {} {
global gdb_prompt binfile
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
gdb_test_no_output "set confirm off"
diff --git a/gdb/testsuite/gdb.base/savedregs.exp b/gdb/testsuite/gdb.base/savedregs.exp
index 2c44566..d71d872 100644
--- a/gdb/testsuite/gdb.base/savedregs.exp
+++ b/gdb/testsuite/gdb.base/savedregs.exp
@@ -35,7 +35,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
}
# get things started
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
# Advance to main
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.base/sep.exp b/gdb/testsuite/gdb.base/sep.exp
index 5a1e077..6abf356 100644
--- a/gdb/testsuite/gdb.base/sep.exp
+++ b/gdb/testsuite/gdb.base/sep.exp
@@ -26,7 +26,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
set location [gdb_get_line_number "say_hello" "sep-proc.c"]
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
# Try to display the source code inside a file which is included by
# another source file. The purpose of this test is to verify that
@@ -45,7 +46,8 @@ gdb_test "list sep-proc.c:$location" \
# Try the same, but this time with a breakpoint. We need to exit
# GDB to make sure that we havn't loaded the full symbols yet when
# we test the breakpoint insertion.
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
set test "breakpoint inside included file"
gdb_test_multiple "break sep-proc.c:$location" "$test" {
diff --git a/gdb/testsuite/gdb.base/sepsymtab.exp b/gdb/testsuite/gdb.base/sepsymtab.exp
index f5e8705..ed7a7a2 100644
--- a/gdb/testsuite/gdb.base/sepsymtab.exp
+++ b/gdb/testsuite/gdb.base/sepsymtab.exp
@@ -31,7 +31,8 @@ if [gdb_gnu_strip_debug $binfile no-main] {
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
set command "info sym main"
set command_regex [string_to_regexp $command]
diff --git a/gdb/testsuite/gdb.base/set-cwd.exp b/gdb/testsuite/gdb.base/set-cwd.exp
index 72a2632..73a200f 100644
--- a/gdb/testsuite/gdb.base/set-cwd.exp
+++ b/gdb/testsuite/gdb.base/set-cwd.exp
@@ -184,7 +184,9 @@ proc_with_prefix test_cwd_reset { } {
}
test_cd_into_dir
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
test_tilde_expansion
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
test_cwd_reset
diff --git a/gdb/testsuite/gdb.base/set-inferior-tty.exp b/gdb/testsuite/gdb.base/set-inferior-tty.exp
index 64ec57b..c9b0a96 100644
--- a/gdb/testsuite/gdb.base/set-inferior-tty.exp
+++ b/gdb/testsuite/gdb.base/set-inferior-tty.exp
@@ -24,7 +24,8 @@ if {[build_executable $testfile.exp $testfile ${srcfile} ${compile_options}] ==
proc test_set_inferior_tty { command } {
global binfile
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
gdb_test_no_output "$command hello" "set inferior-tty to hello"
gdb_test "show inferior-tty" \
diff --git a/gdb/testsuite/gdb.base/setshow.exp b/gdb/testsuite/gdb.base/setshow.exp
index 79ff913..0e38a9d 100644
--- a/gdb/testsuite/gdb.base/setshow.exp
+++ b/gdb/testsuite/gdb.base/setshow.exp
@@ -29,7 +29,8 @@ if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable {debug}]
proc_with_prefix test_setshow_annotate {} {
# Start with a fresh gdb
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
if {![runto_main]} {
return
@@ -78,7 +79,8 @@ proc_with_prefix test_setshow_annotate {} {
}
proc_with_prefix test_setshow_args {} {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.base/settings.exp b/gdb/testsuite/gdb.base/settings.exp
index 5e7cc24..d83023b 100644
--- a/gdb/testsuite/gdb.base/settings.exp
+++ b/gdb/testsuite/gdb.base/settings.exp
@@ -531,7 +531,8 @@ proc test-string {variant} {
global srcfile binfile
# Load symbols for the completion test below.
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
# Use these variables to make sure we don't call the wrong command
# by mistake.
diff --git a/gdb/testsuite/gdb.base/share-env-with-gdbserver.exp b/gdb/testsuite/gdb.base/share-env-with-gdbserver.exp
index 920f435..aa4b300 100644
--- a/gdb/testsuite/gdb.base/share-env-with-gdbserver.exp
+++ b/gdb/testsuite/gdb.base/share-env-with-gdbserver.exp
@@ -91,7 +91,8 @@ proc do_prepare_inferior { } {
proc do_test { var_value { var_name "" } { var_name_match "" } { var_value_match "" } } {
global binfile test_var_name
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
if { $var_name == "" } {
set var_name $test_var_name
@@ -146,7 +147,8 @@ with_test_prefix "strange named var" {
proc test_set_unset_vars { } {
global binfile
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
with_test_prefix "set 3 environment variables" {
# Set some environment variables
@@ -205,7 +207,8 @@ with_test_prefix "test set/unset of vars" {
proc test_unset { } {
global hex decimal binfile gdb_prompt
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
do_prepare_inferior
@@ -234,7 +237,8 @@ proc test_unset { } {
}
with_test_prefix "set-then-unset" {
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
# Test if setting and then unsetting $HOME works.
gdb_test_no_output "set environment HOME = test" "set HOME as test"
diff --git a/gdb/testsuite/gdb.base/shlib-call.exp b/gdb/testsuite/gdb.base/shlib-call.exp
index 6a5f6d8..d3ff1c3 100644
--- a/gdb/testsuite/gdb.base/shlib-call.exp
+++ b/gdb/testsuite/gdb.base/shlib-call.exp
@@ -59,7 +59,8 @@ if { [gdb_compile_shlib ${lib1src} ${lib1} $lib_opts] != ""
# Start with a fresh gdb.
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
gdb_load_shlib $lib1
gdb_load_shlib $lib2
@@ -161,7 +162,8 @@ gdb_test "step" "mainshr1 \\(g=4\\) at.*return 2.g;" \
# Start with a fresh gdb.
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
# PR's 16495, 18213
# test that we can re-set breakpoints in shared libraries
diff --git a/gdb/testsuite/gdb.base/shlib-unload.exp b/gdb/testsuite/gdb.base/shlib-unload.exp
index 9d47416..0e1369e 100644
--- a/gdb/testsuite/gdb.base/shlib-unload.exp
+++ b/gdb/testsuite/gdb.base/shlib-unload.exp
@@ -69,7 +69,8 @@ proc_with_prefix test_bp_modified_events {} {
return
}
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
if {![runto_main]} {
return
@@ -114,7 +115,8 @@ proc_with_prefix test_bp_modified_events {} {
# Check that GDB disables dprintf breakpoints within a shared library
# when the shared library is unloaded.
proc_with_prefix test_dprintf_after_unload {} {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
if {![runto_main]} {
return
@@ -143,7 +145,8 @@ proc_with_prefix test_dprintf_after_unload {} {
# inferior. We should not get an error about re-setting the dprintf
# breakpoint.
proc_with_prefix test_dprintf_with_rerun {} {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
if {![runto_main]} {
return
@@ -238,7 +241,8 @@ proc_with_prefix test_silent_nosharedlib {} {
}
foreach_with_prefix type { breakpoint dprintf } {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.base/shreloc.exp b/gdb/testsuite/gdb.base/shreloc.exp
index 8ab64a8..2bd79af 100644
--- a/gdb/testsuite/gdb.base/shreloc.exp
+++ b/gdb/testsuite/gdb.base/shreloc.exp
@@ -65,7 +65,8 @@ if { [gdb_compile_shlib $lib1src $lib1_sl $lib_opts] != ""} {
# Start with a fresh gdb.
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
gdb_load_shlib $lib1_sl
gdb_load_shlib $lib2_sl
diff --git a/gdb/testsuite/gdb.base/sigaltstack.exp b/gdb/testsuite/gdb.base/sigaltstack.exp
index 978ddeb..47013a0 100644
--- a/gdb/testsuite/gdb.base/sigaltstack.exp
+++ b/gdb/testsuite/gdb.base/sigaltstack.exp
@@ -33,7 +33,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
}
# get things started
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
# Pass all the alarms straight through (but verbosely)
gdb_test "handle SIGALRM print pass nostop"
diff --git a/gdb/testsuite/gdb.base/sigchld.exp b/gdb/testsuite/gdb.base/sigchld.exp
index 51d41c3..4011241 100644
--- a/gdb/testsuite/gdb.base/sigchld.exp
+++ b/gdb/testsuite/gdb.base/sigchld.exp
@@ -24,7 +24,8 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
runto_main
diff --git a/gdb/testsuite/gdb.base/siginfo-obj.exp b/gdb/testsuite/gdb.base/siginfo-obj.exp
index d63febb..52f7140 100644
--- a/gdb/testsuite/gdb.base/siginfo-obj.exp
+++ b/gdb/testsuite/gdb.base/siginfo-obj.exp
@@ -118,7 +118,8 @@ with_test_prefix "validate modified siginfo fields" {
# Test siginfo preservation in core files.
if {$gcore_created} {
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
gdb_test "core $gcorefile" "Core was generated by.*" \
"core [file tail $gcorefile]"
diff --git a/gdb/testsuite/gdb.base/siginfo-thread.exp b/gdb/testsuite/gdb.base/siginfo-thread.exp
index bf0d58c..270b4e1 100644
--- a/gdb/testsuite/gdb.base/siginfo-thread.exp
+++ b/gdb/testsuite/gdb.base/siginfo-thread.exp
@@ -27,7 +27,8 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" \
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
# Advance to main
if {![runto_main]} {
@@ -92,7 +93,8 @@ gdb_test "p \$_siginfo.si_signo == $ssi_signo" " = 0" \
# Test siginfo preservation in core files.
if {$gcore_created} {
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
gdb_test "core $gcorefile" "Core was generated by.*" \
"core [file tail $gcorefile]"
diff --git a/gdb/testsuite/gdb.base/signals-state-child.exp b/gdb/testsuite/gdb.base/signals-state-child.exp
index 608951f..00ad7f5 100644
--- a/gdb/testsuite/gdb.base/signals-state-child.exp
+++ b/gdb/testsuite/gdb.base/signals-state-child.exp
@@ -97,7 +97,8 @@ remote_close target
# Now run the program through gdb, and dump its initial signal actions
# and mask in "gdb.txt".
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
if {![runto_main]} {
return -1
diff --git a/gdb/testsuite/gdb.base/signals.exp b/gdb/testsuite/gdb.base/signals.exp
index d311361..5ff1e38 100644
--- a/gdb/testsuite/gdb.base/signals.exp
+++ b/gdb/testsuite/gdb.base/signals.exp
@@ -58,7 +58,8 @@ proc test_handle_all_print {} {
}
test_handle_all_print
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
if {[runto_main]} {
diff --git a/gdb/testsuite/gdb.base/signull.exp b/gdb/testsuite/gdb.base/signull.exp
index 478e471..9ad772f 100644
--- a/gdb/testsuite/gdb.base/signull.exp
+++ b/gdb/testsuite/gdb.base/signull.exp
@@ -37,7 +37,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debu
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
#
# Run to `main' where we begin our tests.
diff --git a/gdb/testsuite/gdb.base/sigrepeat.exp b/gdb/testsuite/gdb.base/sigrepeat.exp
index 9afa346..8fa92af 100644
--- a/gdb/testsuite/gdb.base/sigrepeat.exp
+++ b/gdb/testsuite/gdb.base/sigrepeat.exp
@@ -30,7 +30,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
}
# get things started
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
# Advance to main
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.base/sigstep.exp b/gdb/testsuite/gdb.base/sigstep.exp
index b49105c..2df5dd0 100644
--- a/gdb/testsuite/gdb.base/sigstep.exp
+++ b/gdb/testsuite/gdb.base/sigstep.exp
@@ -40,7 +40,8 @@ set other_handler_location [gdb_get_line_number "other handler location"]
proc restart {} {
global binfile
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
gdb_test "display/i \$pc"
diff --git a/gdb/testsuite/gdb.base/skip.exp b/gdb/testsuite/gdb.base/skip.exp
index 016e5eb..0c84cf9 100644
--- a/gdb/testsuite/gdb.base/skip.exp
+++ b/gdb/testsuite/gdb.base/skip.exp
@@ -309,7 +309,8 @@ with_test_prefix "step using -fi + -fu" {
with_test_prefix "skip delete completion" {
global binfile
- clean_restart "${binfile}"
+ clean_restart
+ gdb_load $binfile
if ![runto_main] {
return
}
diff --git a/gdb/testsuite/gdb.base/so-impl-ld.exp b/gdb/testsuite/gdb.base/so-impl-ld.exp
index d5c4143..1e309e5 100644
--- a/gdb/testsuite/gdb.base/so-impl-ld.exp
+++ b/gdb/testsuite/gdb.base/so-impl-ld.exp
@@ -33,7 +33,8 @@ if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
# Start with a fresh gdb
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
gdb_load_shlib $lib_sl
# This program implicitly loads SOM shared libraries.
diff --git a/gdb/testsuite/gdb.base/solib-abort.exp b/gdb/testsuite/gdb.base/solib-abort.exp
index 2f6d636..ab162a9 100644
--- a/gdb/testsuite/gdb.base/solib-abort.exp
+++ b/gdb/testsuite/gdb.base/solib-abort.exp
@@ -38,7 +38,8 @@ if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != ""
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.base/solib-disc.exp b/gdb/testsuite/gdb.base/solib-disc.exp
index ba7dcce..880f632 100644
--- a/gdb/testsuite/gdb.base/solib-disc.exp
+++ b/gdb/testsuite/gdb.base/solib-disc.exp
@@ -44,7 +44,8 @@ if { [gdb_compile_shlib $libsrc $libobj {debug}] != ""
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
gdb_load_shlib $libobj
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.base/solib-symbol.exp b/gdb/testsuite/gdb.base/solib-symbol.exp
index f3ca612..4d3494c 100644
--- a/gdb/testsuite/gdb.base/solib-symbol.exp
+++ b/gdb/testsuite/gdb.base/solib-symbol.exp
@@ -34,7 +34,8 @@ if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != ""
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
gdb_load_shlib $binfile_lib
# Set a breakpoint in the binary.
diff --git a/gdb/testsuite/gdb.base/solib-weak.exp b/gdb/testsuite/gdb.base/solib-weak.exp
index 2d75a91..511ef37 100644
--- a/gdb/testsuite/gdb.base/solib-weak.exp
+++ b/gdb/testsuite/gdb.base/solib-weak.exp
@@ -84,7 +84,8 @@ proc do_test { lib1opts lib2opts lib1first } {
}
with_test_prefix $testopts {
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
gdb_load_shlib $lib1
gdb_load_shlib $lib2
diff --git a/gdb/testsuite/gdb.base/source-dir.exp b/gdb/testsuite/gdb.base/source-dir.exp
index b2bf78c..e07a117 100644
--- a/gdb/testsuite/gdb.base/source-dir.exp
+++ b/gdb/testsuite/gdb.base/source-dir.exp
@@ -62,7 +62,7 @@ proc test_truncated_comp_dir {} {
# /some/path/to/gdb/build/testsuite/
# We are going to copy the source file out of the source tree into
# a location like this:
- # /some/path/to/gdb/build/testsuite/output/gdb.base/soure-dir/
+ # /some/path/to/gdb/build/testsuite/output/gdb.base/source-dir/
#
# We will then switch to this directory and compile the source
# file, however, we will ask GCC to remove this prefix from the
@@ -87,11 +87,12 @@ proc test_truncated_comp_dir {} {
return
}
- set working_dir [standard_output_file ""]
+ set working_dir [build_standard_output_file ""]
with_cwd $working_dir {
- set strip_dir [file normalize "${working_dir}/../.."]
+ set strip_dir [build_file_normalize "${working_dir}/../.."]
+ set h_strip_dir [host_file_normalize $strip_dir]
- set new_srcfile [standard_output_file ${srcfile}]
+ set new_srcfile [build_standard_output_file ${srcfile}]
set fd [open "$new_srcfile" w]
puts $fd "int
main ()
@@ -100,8 +101,17 @@ proc test_truncated_comp_dir {} {
}"
close $fd
+ # We ask GCC to remove both the build and host views of the
+ # path, because we don't know which one GCC uses. E.g., we're
+ # testing on MSYS2 with an MSYS2 cross-compiler that targets
+ # MinGW, then the path GCC uses is a Unix path. If OTOH we're
+ # testing on MSYS2 with a native Windows compiler, then the
+ # path GCC uses is a Windows path.
set options \
- "debug additional_flags=-fdebug-prefix-map=${strip_dir}="
+ [list \
+ "debug" \
+ "additional_flags=-fdebug-prefix-map=${strip_dir}=" \
+ "additional_flags=-fdebug-prefix-map=${h_strip_dir}="]
if { [gdb_compile "${srcfile}" "${binfile}" \
executable ${options}] != "" } {
untested "failed to compile"
@@ -109,7 +119,8 @@ proc test_truncated_comp_dir {} {
}
}
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
if { [ishost *-*-mingw*] } {
gdb_test_no_output "set directories \$cdir;\$cwd"
@@ -133,9 +144,9 @@ proc test_truncated_comp_dir {} {
"Does not include preprocessor macro info." ] \
"info source before setting directory search list"
- gdb_test "dir $strip_dir" \
+ gdb_test "dir $h_strip_dir" \
[search_dir_list [list \
- "$strip_dir" \
+ "$h_strip_dir" \
"\\\$cdir" \
"\\\$cwd"]] \
"setup source path search directory"
@@ -146,17 +157,23 @@ proc test_truncated_comp_dir {} {
"4\[ \t\]+return 0;" \
"5\[ \t\]+\\}" ]
- gdb_test "info source" \
- [multi_line \
- "Current source file is ${srcfile}" \
- "Compilation directory is \[^\n\r\]+" \
- "Located in ${new_srcfile}" \
- "Contains 5 lines." \
- "Source language is c." \
- "Producer is \[^\n\r\]+" \
- "\[^\n\r\]+" \
- "\[^\n\r\]+" ] \
- "info source after setting directory search list"
+ set re [multi_line \
+ "Current source file is ${srcfile}" \
+ "Compilation directory is \[^\n\r\]+" \
+ "Located in (\[^\n\r\]+)" \
+ "Contains 5 lines." \
+ "Source language is c." \
+ "Producer is \[^\n\r\]+" \
+ "\[^\n\r\]+" \
+ "\[^\n\r\]+"]
+ set test "info source after setting directory search list"
+ gdb_test_multiple "info source" $test {
+ -re -wrap "$re" {
+ set host_new_srcfile [host_file_normalize $new_srcfile]
+ set host_location [host_file_sanitize $expect_out(1,string)]
+ gdb_assert {$host_new_srcfile eq $host_location} $gdb_test_name
+ }
+ }
}
proc test_change_search_directory_with_empty_dirname {} {
diff --git a/gdb/testsuite/gdb.base/source-search.c b/gdb/testsuite/gdb.base/source-search.c
new file mode 100644
index 0000000..2320c5c
--- /dev/null
+++ b/gdb/testsuite/gdb.base/source-search.c
@@ -0,0 +1,127 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2025 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)
+{
+ /* Line 21 */
+ /* Line 22 */
+ /* Line 23 */
+ /* Line 24 */
+ /* Line 25 */
+ /* Line 26 */
+ /* Line 27 */
+ /* Line 28 */
+ /* Line 29 */
+ /* Line 30 */
+ /* Line 31 */
+ /* Line 32 */
+ /* Line 33 */
+ /* Line 34 */
+ /* Line 35 */
+ /* Line 36 */
+ /* Line 37 */
+ /* Line 38 */
+ /* Line 39 */
+ /* Line 40 */
+ /* Line 41 */
+ /* Line 42 */
+ /* Line 43 */
+ /* Line 44 */
+ /* Line 45 */
+ /* Line 46 */
+ /* Line 47 */
+ /* Line 48 */
+ /* Line 49 */
+ /* Line 50 */
+ /* Line 51 */
+ /* Line 52 */
+ /* Line 53 */
+ /* Line 54 */
+ /* Line 55 */
+ /* Line 56 */
+ /* Line 57 */
+ /* Line 58 */
+ /* Line 59 */
+ /* Line 60 */
+ /* Line 61 */
+ /* Line 62 */
+ /* Line 63 */
+ /* Line 64 */
+ /* Line 65 */
+ /* Line 66 */
+ /* Line 67 */
+ /* Line 68 */
+ /* Line 69 */
+ /* Line 70 */
+ /* Line 71 */
+ /* Line 72 */
+ /* Line 73 */
+ /* Line 74 */
+ /* Line 75 */
+ /* Line 76 */
+ /* Line 77 */
+ /* Line 78 */
+ /* Line 79 */
+ /* Line 80 */
+ /* Line 81 */
+ /* Line 82 */
+ /* Line 83 */
+ /* Line 84 */
+ /* Line 85 */
+ /* Line 86 */
+ /* Line 87 */
+ /* Line 88 */
+ /* Line 89 */
+ /* Line 90 */
+ /* Line 91 */
+ /* Line 92 */
+ /* Line 93 */
+ /* Line 94 */
+ /* Line 95 */
+ /* Line 96 */
+ /* Line 97 */
+ /* Line 98 */
+ /* Line 99 */
+ /* Line 100 */
+ /* Line 101 */
+ /* Line 102 */
+ /* Line 103 */
+ /* Line 104 */
+ /* Line 105 */
+ /* Line 106 */
+ /* Line 107 */
+ /* Line 108 */
+ /* Line 109 */
+ /* Line 110 */
+ /* Line 111 */
+ /* Line 112 */
+ /* Line 113 */
+ /* Line 114 */
+ /* Line 115 */
+ /* Line 116 */
+ /* Line 117 */
+ /* Line 118 */
+ /* Line 119 */
+ /* Line 120 */
+ /* Line 121 */
+ /* Line 122 */
+ /* Line 123 */
+ /* Line 124 */
+ /* Line 125 */
+ return 0;
+} /* Last line. */
diff --git a/gdb/testsuite/gdb.base/source-search.exp b/gdb/testsuite/gdb.base/source-search.exp
new file mode 100644
index 0000000..559c500
--- /dev/null
+++ b/gdb/testsuite/gdb.base/source-search.exp
@@ -0,0 +1,106 @@
+# Copyright 2025 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 'forward-search' and 'reverse-search' commands. This test
+# relies on some hard-coded line numbers relating to the source file.
+# We could switch to using gdb_get_line_number, but it doesn't feel
+# like that would add much value; just don't change the source file.
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
+ return
+}
+
+gdb_test "forward-search This testcase is part" \
+ "1\\s+/\\* This testcase is part of GDB, the GNU debugger\\." \
+ "search for first line of the file"
+
+gdb_test "forward-search This testcase is part" \
+ "Expression not found" \
+ "repeated search doesn't find the same first line"
+
+# The 'reverse-search' command starts searching from the line before
+# the last line displayed. So in this case, the reverse search starts
+# from line 0, i.e. nothing is searched.
+gdb_test "reverse-search This testcase is part" \
+ "Expression not found" \
+ "reverse search doesn't find the first line either"
+
+# List some source lines, and then perform some forward-searches. The
+# searches start from the first line after the last line displayed.
+gdb_test "list 20" ".*" \
+ "list source code ahead of a forward-search"
+gdb_test "forward-search Line 2" \
+ "25\\s+/\\* Line 25 \\*/" \
+ "first forward-search after a list"
+gdb_test "forward-search Line 2" \
+ "26\\s+/\\* Line 26 \\*/" \
+ "second forward-search after a list"
+gdb_test "forward-search Line 2" \
+ "27\\s+/\\* Line 27 \\*/" \
+ "third forward-search after a list"
+
+# Now reverse-search from where we got too.
+gdb_test "reverse-search Line 2" \
+ "26\\s+/\\* Line 26 \\*/" \
+ "first reverse-search for 'Line 2'"
+gdb_test "reverse-search Line 2" \
+ "25\\s+/\\* Line 25 \\*/" \
+ "second reverse-search for 'Line 2'"
+gdb_test "reverse-search Line 2" \
+ "24\\s+/\\* Line 24 \\*/" \
+ "third reverse-search for 'Line 2'"
+
+# List some source lines, and then perform a reverse-search. The
+# search starts frm the first line before the last line displayed.
+gdb_test "list 20" ".*" \
+ "list source code ahead of a reverse-search"
+gdb_test "reverse-search Line 2" \
+ "23\\s+/\\* Line 23 \\*/" \
+ "reverse-search after a list"
+
+# List the last lines of the file, then reverse search for the last
+# line. As reverse-search starts on the line before the last line
+# displayed, this will fail to find the last line.
+gdb_test "list 127"
+gdb_test "reverse-search Last line" \
+ "Expression not found" \
+ "reverse search for the last line fails"
+
+# List some lines from the middle of the file. Then try an invalid
+# 'list' command. Finally, check searches pick up from the middle of
+# the file where the first 'list' successfully completed.
+foreach_with_prefix search_direction { forward reverse } {
+ foreach_with_prefix bad_list { out-of-range backwards } {
+ gdb_test "list 50"
+
+ if { $bad_list eq "out-of-range" } {
+ gdb_test "list 1000" \
+ "Line number 995 out of range; \[^\r\n\]+ has 127 lines\\."
+ } else {
+ gdb_test_no_output "list 60,50"
+ }
+
+ if { $search_direction eq "forward" } {
+ set line 55
+ } else {
+ set line 53
+ }
+
+ gdb_test "${search_direction}-search Line" \
+ "$line\\s+/\\* Line $line \\*/"
+ }
+}
diff --git a/gdb/testsuite/gdb.base/stack-checking.exp b/gdb/testsuite/gdb.base/stack-checking.exp
index 5e55b43..15fc677 100644
--- a/gdb/testsuite/gdb.base/stack-checking.exp
+++ b/gdb/testsuite/gdb.base/stack-checking.exp
@@ -21,7 +21,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [con
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.base/startup-with-shell.exp b/gdb/testsuite/gdb.base/startup-with-shell.exp
index 80dfdf3..a6ebb57 100644
--- a/gdb/testsuite/gdb.base/startup-with-shell.exp
+++ b/gdb/testsuite/gdb.base/startup-with-shell.exp
@@ -22,6 +22,8 @@ require !use_gdb_stub
# (via dejagnu) yet.
require {!is_remote target}
+require {expr [have_startup_shell] != -1}
+
standard_testfile
if { [build_executable "failed to prepare" $testfile $srcfile debug] } {
@@ -40,7 +42,8 @@ run_on_host \
proc initial_setup_simple { startup_with_shell run_args } {
global hex decimal binfile unique_file
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
gdb_test_no_output "set startup-with-shell $startup_with_shell"
gdb_test_no_output "set print characters unlimited"
@@ -91,73 +94,97 @@ proc run_test_same { args re testname } {
run_test $args $re $re $testname
}
-# The regexp to match a single '\' character.
-set bs "\\\\"
-
-# Are we using 'remote' or 'extended-remote' protocol?
-set is_remote_p [gdb_protocol_is_remote]
-
-## Run the actual tests
-
-run_test "$unique_file_dir/*.unique-extension" \
- "\"$unique_file\"" \
- "\"$unique_file_dir/\\\*\.unique-extension\"" \
- "arg is glob" \
- $is_remote_p
-
-run_test_same "$unique_file_dir/\\*.unique-extension" \
- "\"$unique_file_dir/\\\*\.unique-extension\"" \
- "arg is escaped glob"
-
-save_vars { env(TEST) } {
- set env(TEST) "1234"
- run_test "\$TEST" \
- "\"1234\"" \
- "\"\\\$TEST\"" \
- "arg is shell variable" \
- $is_remote_p
+# Run the actual tests
+proc run_all_tests { { is_remote_with_split_args false } } {
+ # The regexp to match a single '\' character.
+ set bs "\\\\"
+
+ run_test "$::unique_file_dir/*.unique-extension" \
+ "\"$::unique_file\"" \
+ "\"$::unique_file_dir/\\\*\.unique-extension\"" \
+ "arg is glob" \
+ $is_remote_with_split_args
+
+ run_test_same "$::unique_file_dir/\\*.unique-extension" \
+ "\"$::unique_file_dir/\\\*\.unique-extension\"" \
+ "arg is escaped glob"
+
+ save_vars { ::env(TEST) } {
+ set ::env(TEST) "1234"
+ run_test "\$TEST" \
+ "\"1234\"" \
+ "\"\\\$TEST\"" \
+ "arg is shell variable" \
+ $is_remote_with_split_args
+
+ run_test_same "\\\$TEST" \
+ "\"\\\$TEST\"" \
+ "arg is escaped shell variable"
+ }
- run_test_same "\\\$TEST" \
- "\"\\\$TEST\"" \
- "arg is escaped shell variable"
+ run_test "\$(echo foo)" \
+ "\"foo\"" \
+ "\"\\\$\\(echo\"" \
+ "arg is parameter expansion, command execution" \
+ $is_remote_with_split_args
+
+ run_test "\$((2 + 3))" \
+ "\"5\"" \
+ "\"\\\$\\(\\(2\"" \
+ "arg is parameter expansion, expression evaluation" \
+ $is_remote_with_split_args
+
+ run_test_same "\"\\a\"" \
+ "\"${bs}${bs}a\"" \
+ "retain backslash in double quote arg"
+
+ run_test_same "'\\a'" \
+ "\"${bs}${bs}a\"" \
+ "retain backslash in single quote arg"
+
+ run_test_same "\"\\\$\"" \
+ "\"\\\$\"" \
+ "'\$' can be escaped in double quote arg"
+
+ run_test_same "'\\\$'" \
+ "\"${bs}${bs}\\\$\"" \
+ "'\$' is not escaped in single quote arg"
+
+ run_test_same "\"\\`\"" \
+ "\"\\`\"" \
+ "'`' can be escaped in double quote arg"
+
+ run_test_same "'\\`'" \
+ "\"${bs}${bs}`\"" \
+ "'`' is not escaped in single quote arg"
+
+ run_test_same "\"\\\"\"" \
+ "\"${bs}\"\"" \
+ "'\"' can be escaped in double quote arg"
+
+ run_test_same "'\\\"'" \
+ "\"${bs}${bs}${bs}\"\"" \
+ "'\"' is not escaped in single quote arg"
+
+ run_test_same "\"\\\\\"" \
+ "\"${bs}${bs}\"" \
+ "'\\' can be escaped in double quote arg"
+
+ run_test_same "'\\\\'" \
+ "\"${bs}${bs}${bs}${bs}\"" \
+ "'\\' is not escaped in single quote arg"
}
-run_test_same "\"\\a\"" \
- "\"${bs}${bs}a\"" \
- "retain backslash in double quote arg"
-
-run_test_same "'\\a'" \
- "\"${bs}${bs}a\"" \
- "retain backslash in single quote arg"
-
-run_test_same "\"\\\$\"" \
- "\"\\\$\"" \
- "'\$' can be escaped in double quote arg"
+run_all_tests
-run_test_same "'\\\$'" \
- "\"${bs}${bs}\\\$\"" \
- "'\$' is not escaped in single quote arg"
-
-run_test_same "\"\\`\"" \
- "\"\\`\"" \
- "'`' can be escaped in double quote arg"
-
-run_test_same "'\\`'" \
- "\"${bs}${bs}`\"" \
- "'`' is not escaped in single quote arg"
-
-run_test_same "\"\\\"\"" \
- "\"${bs}\"\"" \
- "'\"' can be escaped in double quote arg"
-
-run_test_same "'\\\"'" \
- "\"${bs}${bs}${bs}\"\"" \
- "'\"' is not escaped in single quote arg"
-
-run_test_same "\"\\\\\"" \
- "\"${bs}${bs}\"" \
- "'\\' can be escaped in double quote arg"
-
-run_test_same "'\\\\'" \
- "\"${bs}${bs}${bs}${bs}\"" \
- "'\\' is not escaped in single quote arg"
+# For extended-remote targets, disable the packet which passes
+# inferior arguments as a single string. This changes how the vRun
+# (extended-remote only) packet works.
+if {[target_info gdb_protocol] == "extended-remote"} {
+ with_test_prefix "single-inferior-arg disabled" {
+ save_vars { GDBFLAGS } {
+ append GDBFLAGS " -ex \"set remote single-inferior-argument-feature-packet off\""
+ run_all_tests true
+ }
+ }
+}
diff --git a/gdb/testsuite/gdb.base/step-over-no-symbols.exp b/gdb/testsuite/gdb.base/step-over-no-symbols.exp
index 2eb8efe..1a91986 100644
--- a/gdb/testsuite/gdb.base/step-over-no-symbols.exp
+++ b/gdb/testsuite/gdb.base/step-over-no-symbols.exp
@@ -47,7 +47,8 @@ proc test_step_over { displaced } {
global hex
global binfile
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
if ![runto_main] {
return -1
diff --git a/gdb/testsuite/gdb.base/step-sw-breakpoint-adjust-pc.exp b/gdb/testsuite/gdb.base/step-sw-breakpoint-adjust-pc.exp
index 2dc67ea..2dde3bb 100644
--- a/gdb/testsuite/gdb.base/step-sw-breakpoint-adjust-pc.exp
+++ b/gdb/testsuite/gdb.base/step-sw-breakpoint-adjust-pc.exp
@@ -36,7 +36,8 @@ proc test {non_stop displaced always_inserted} {
save_vars { GDBFLAGS } {
set GDBFLAGS "$GDBFLAGS -ex \"set non-stop $non_stop\""
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
}
gdb_test_no_output "set displaced-stepping $displaced"
diff --git a/gdb/testsuite/gdb.base/step-test.exp b/gdb/testsuite/gdb.base/step-test.exp
index 28eccf7..39833a3 100644
--- a/gdb/testsuite/gdb.base/step-test.exp
+++ b/gdb/testsuite/gdb.base/step-test.exp
@@ -24,7 +24,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debu
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.base/structs.exp b/gdb/testsuite/gdb.base/structs.exp
index 31a45b5..fa7f786 100644
--- a/gdb/testsuite/gdb.base/structs.exp
+++ b/gdb/testsuite/gdb.base/structs.exp
@@ -56,7 +56,7 @@ proc start_structs_test { types } {
}
set binfile [standard_output_file ${testfile}]
- if { [prepare_for_testing "failed to prepare" $binfile $srcfile $flags] } {
+ if { [prepare_for_testing "failed to prepare" $testfile $srcfile $flags] } {
return -1
}
diff --git a/gdb/testsuite/gdb.base/structs2.exp b/gdb/testsuite/gdb.base/structs2.exp
index 8ccd50d..f377022 100644
--- a/gdb/testsuite/gdb.base/structs2.exp
+++ b/gdb/testsuite/gdb.base/structs2.exp
@@ -15,7 +15,7 @@
standard_testfile .c
-if { [prepare_for_testing "failed to prepare" $binfile $srcfile {debug}] } {
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug}] } {
return -1
}
diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp
index a6c18d3..92b5085 100644
--- a/gdb/testsuite/gdb.base/style.exp
+++ b/gdb/testsuite/gdb.base/style.exp
@@ -13,6 +13,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+require {!is_remote host}
+
load_lib gdb-python.exp
# Test CLI output styling.
@@ -48,7 +50,7 @@ proc clean_restart_and_disable { prefix args } {
global currently_disabled_style
with_test_prefix "$prefix" {
- eval "clean_restart $args"
+ clean_restart {*}$args
if { $currently_disabled_style != "" } {
set st $currently_disabled_style
@@ -75,7 +77,7 @@ proc run_style_tests { } {
# Restart GDB with the correct TERM variable setting, this
# means that GDB will enable styling.
- clean_restart_and_disable "restart 1" ${binfile}
+ clean_restart_and_disable "restart 1" $::testfile
set readnow [readnow]
@@ -356,7 +358,7 @@ proc test_disable_disassembler_styling { } {
# Restart GDB with the correct TERM variable setting, this
# means that GDB will enable styling.
- clean_restart_and_disable "restart 3" $::binfile
+ clean_restart_and_disable "restart 3" $::testfile
set styled_hex [limited_style $::hex address]
set main [limited_style main function]
@@ -471,7 +473,7 @@ proc test_disassembler_error_handling { } {
# Restart GDB with the correct TERM variable setting, this
# means that GDB will enable styling.
- clean_restart_and_disable "restart 4" $::binfile
+ clean_restart_and_disable "restart 4" $::testfile
# Disable use of libopcodes for styling. As this function is
# only called when Python Pygments module is available, we
@@ -883,7 +885,8 @@ proc previous_line_is_ok { str } {
# prompt, the previous line disables styling as expected.
proc test_pagination_prompt_styling {} {
with_ansi_styling_terminal {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
}
if {![runto_main]} {
@@ -979,7 +982,8 @@ proc test_pagination_prompt_styling {} {
# default style once the logging file has finished.
proc test_pagination_continue_styling_1 { length } {
with_ansi_styling_terminal {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
}
set filename [string repeat "ax" $length]
@@ -1034,7 +1038,8 @@ proc test_pagination_continue_styling { } {
# Check to see if the Python styling of disassembler output is
# expected or not, this styling requires Python support in GDB, and
# the Python pygments module to be available.
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
if {[allow_python_tests] && [gdb_py_module_available "pygments"]} {
set python_disassembly_styling true
} else {
diff --git a/gdb/testsuite/gdb.base/sym-file.exp b/gdb/testsuite/gdb.base/sym-file.exp
index 8197c0e..13febda 100644
--- a/gdb/testsuite/gdb.base/sym-file.exp
+++ b/gdb/testsuite/gdb.base/sym-file.exp
@@ -61,7 +61,8 @@ if {[gdb_compile_shlib $libsrc $lib_so {debug}] != ""} {
return
}
-if {[prepare_for_testing "failed to prepare" $binfile "$srcfile $srcfile2" $exec_opts]} {
+if { [prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2" \
+ $exec_opts] } {
return
}
@@ -70,7 +71,8 @@ gdb_load_shlib ${lib_so}
proc do_test { remove_expr } {
global lib_basename lib_syms srcfile srcfile3
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.base/symtab-search-order.exp b/gdb/testsuite/gdb.base/symtab-search-order.exp
index cf0d507..34b1db0 100644
--- a/gdb/testsuite/gdb.base/symtab-search-order.exp
+++ b/gdb/testsuite/gdb.base/symtab-search-order.exp
@@ -33,7 +33,8 @@ if { [gdb_compile_shlib $lib1src $lib1 $lib_opts] != ""
# Start with a fresh gdb.
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
gdb_load_shlib $lib1
if ![runto_main] {
diff --git a/gdb/testsuite/gdb.base/testenv.exp b/gdb/testsuite/gdb.base/testenv.exp
index beb59d2..59cd33c 100644
--- a/gdb/testsuite/gdb.base/testenv.exp
+++ b/gdb/testsuite/gdb.base/testenv.exp
@@ -27,7 +27,7 @@ standard_testfile .c
# Compile binary
# and start with a fresh gdb
-if { [prepare_for_testing "failed to prepare" ${binfile} ${srcfile}] } {
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
return -1
}
@@ -90,7 +90,8 @@ proc find_env {varname} {
proc_with_prefix test_set_unset_env {} {
global binfile
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
# First test with no TEST_GDB_VAR.
with_test_prefix "test1" {
@@ -151,7 +152,8 @@ proc_with_prefix test_inherit_env_var {} {
save_vars {env(TEST_GDB_GLOBAL)} {
set env(TEST_GDB_GLOBAL) "Global environment value"
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
gdb_breakpoint $bp_line
diff --git a/gdb/testsuite/gdb.base/tls-common.exp.tcl b/gdb/testsuite/gdb.base/tls-common.exp.tcl
index 7aa7f46..fc212a9 100644
--- a/gdb/testsuite/gdb.base/tls-common.exp.tcl
+++ b/gdb/testsuite/gdb.base/tls-common.exp.tcl
@@ -1,4 +1,4 @@
-# Copyright 2024 Free Software Foundation, Inc.
+# Copyright 2024-2025 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
diff --git a/gdb/testsuite/gdb.base/tls-dlobj-lib.c b/gdb/testsuite/gdb.base/tls-dlobj-lib.c
index c69bab7..e82a064 100644
--- a/gdb/testsuite/gdb.base/tls-dlobj-lib.c
+++ b/gdb/testsuite/gdb.base/tls-dlobj-lib.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2024 Free Software Foundation, Inc.
+ Copyright 2024-2025 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
diff --git a/gdb/testsuite/gdb.base/tls-dlobj.c b/gdb/testsuite/gdb.base/tls-dlobj.c
index 322bdda..a93f4a7 100644
--- a/gdb/testsuite/gdb.base/tls-dlobj.c
+++ b/gdb/testsuite/gdb.base/tls-dlobj.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2024 Free Software Foundation, Inc.
+ Copyright 2024-2025 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
diff --git a/gdb/testsuite/gdb.base/tls-dlobj.exp b/gdb/testsuite/gdb.base/tls-dlobj.exp
index 02f2ff8..1509ec8 100644
--- a/gdb/testsuite/gdb.base/tls-dlobj.exp
+++ b/gdb/testsuite/gdb.base/tls-dlobj.exp
@@ -1,4 +1,4 @@
-# Copyright 2024 Free Software Foundation, Inc.
+# Copyright 2024-2025 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
@@ -56,7 +56,8 @@ proc gdb_test_with_xfail { cmd re cond} {
}
proc do_tests {force_internal_tls} {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
if ![runto_main] {
return
}
@@ -288,7 +289,8 @@ proc do_tests {force_internal_tls} {
return
}
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
set core_loaded [gdb_core_cmd $corefile "load corefile"]
if { $core_loaded == -1 } {
diff --git a/gdb/testsuite/gdb.base/tls-multiobj.c b/gdb/testsuite/gdb.base/tls-multiobj.c
index 10e67da..dd4aadb 100644
--- a/gdb/testsuite/gdb.base/tls-multiobj.c
+++ b/gdb/testsuite/gdb.base/tls-multiobj.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2024 Free Software Foundation, Inc.
+ Copyright 2024-2025 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
diff --git a/gdb/testsuite/gdb.base/tls-multiobj.exp b/gdb/testsuite/gdb.base/tls-multiobj.exp
index 97acb33..eb3721e 100644
--- a/gdb/testsuite/gdb.base/tls-multiobj.exp
+++ b/gdb/testsuite/gdb.base/tls-multiobj.exp
@@ -1,4 +1,4 @@
-# Copyright 2024 Free Software Foundation, Inc.
+# Copyright 2024-2025 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
@@ -26,7 +26,8 @@ set lib2obj [standard_output_file "${testfile}2-lib.so"]
set lib3obj [standard_output_file "${testfile}3-lib.so"]
proc do_tests {force_internal_tls {do_kfail_tls_access 0}} {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
if ![runto_main] {
return
}
@@ -128,7 +129,8 @@ proc do_tests {force_internal_tls {do_kfail_tls_access 0}} {
return
}
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
set core_loaded [gdb_core_cmd $corefile "load corefile"]
if { $core_loaded == -1 } {
diff --git a/gdb/testsuite/gdb.base/tls-multiobj1.c b/gdb/testsuite/gdb.base/tls-multiobj1.c
index 86e7222..6207173 100644
--- a/gdb/testsuite/gdb.base/tls-multiobj1.c
+++ b/gdb/testsuite/gdb.base/tls-multiobj1.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2024 Free Software Foundation, Inc.
+ Copyright 2024-2025 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
diff --git a/gdb/testsuite/gdb.base/tls-multiobj2.c b/gdb/testsuite/gdb.base/tls-multiobj2.c
index cea0709..9ff8b67 100644
--- a/gdb/testsuite/gdb.base/tls-multiobj2.c
+++ b/gdb/testsuite/gdb.base/tls-multiobj2.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2024 Free Software Foundation, Inc.
+ Copyright 2024-2025 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
diff --git a/gdb/testsuite/gdb.base/tls-multiobj3.c b/gdb/testsuite/gdb.base/tls-multiobj3.c
index bb0f239..3594eba0 100644
--- a/gdb/testsuite/gdb.base/tls-multiobj3.c
+++ b/gdb/testsuite/gdb.base/tls-multiobj3.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2024 Free Software Foundation, Inc.
+ Copyright 2024-2025 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
diff --git a/gdb/testsuite/gdb.base/tls-nothreads.c b/gdb/testsuite/gdb.base/tls-nothreads.c
index b3aaa33..cac20f8 100644
--- a/gdb/testsuite/gdb.base/tls-nothreads.c
+++ b/gdb/testsuite/gdb.base/tls-nothreads.c
@@ -1,6 +1,6 @@
/* This testcase is part of GDB, the GNU debugger.
- Copyright 2024 Free Software Foundation, Inc.
+ Copyright 2024-2025 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
diff --git a/gdb/testsuite/gdb.base/tls-nothreads.exp b/gdb/testsuite/gdb.base/tls-nothreads.exp
index 92a5cd9..c7b1476 100644
--- a/gdb/testsuite/gdb.base/tls-nothreads.exp
+++ b/gdb/testsuite/gdb.base/tls-nothreads.exp
@@ -1,4 +1,4 @@
-# Copyright 2024 Free Software Foundation, Inc.
+# Copyright 2024-2025 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
@@ -18,7 +18,8 @@ source $srcdir/$subdir/tls-common.exp.tcl
standard_testfile
proc do_tests {force_internal_tls {do_kfail_tls_access 0}} {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
if ![runto_main] {
return
}
@@ -105,7 +106,8 @@ proc do_tests {force_internal_tls {do_kfail_tls_access 0}} {
set objcopy [gdb_find_objcopy]
set cmd "$objcopy --strip-debug ${::binfile} $binfile_stripped"
if ![catch "exec $cmd" cmd_output] {
- clean_restart $binfile_stripped
+ clean_restart
+ gdb_load $binfile_stripped
if ![runto_main] {
return
}
@@ -155,7 +157,8 @@ proc do_tests {force_internal_tls {do_kfail_tls_access 0}} {
return
}
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
set core_loaded [gdb_core_cmd $corefile "load corefile"]
if { $core_loaded == -1 } {
diff --git a/gdb/testsuite/gdb.base/twice.exp b/gdb/testsuite/gdb.base/twice.exp
index 6f49c46..995cd4d 100644
--- a/gdb/testsuite/gdb.base/twice.exp
+++ b/gdb/testsuite/gdb.base/twice.exp
@@ -32,7 +32,8 @@ if { [gdb_compile $local_srcfile "${binfile}" executable $options] != "" } {
# Start with a fresh gdb.
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
if {[runto_main]} {
# Test that GDB can still detect whether we have line numbers
diff --git a/gdb/testsuite/gdb.base/type-opaque.exp b/gdb/testsuite/gdb.base/type-opaque.exp
index da060b9..f5d8582 100644
--- a/gdb/testsuite/gdb.base/type-opaque.exp
+++ b/gdb/testsuite/gdb.base/type-opaque.exp
@@ -32,7 +32,8 @@ if { [gdb_compile_shlib $libsrc $libobj {debug}] != ""
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
gdb_load_shlib ${libobj}
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.base/unload.exp b/gdb/testsuite/gdb.base/unload.exp
index 0761f27..b2d848d 100644
--- a/gdb/testsuite/gdb.base/unload.exp
+++ b/gdb/testsuite/gdb.base/unload.exp
@@ -50,7 +50,8 @@ if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
gdb_load_shlib $lib_sl
gdb_load_shlib $lib_sl2
diff --git a/gdb/testsuite/gdb.base/until-trailing-insns.exp b/gdb/testsuite/gdb.base/until-trailing-insns.exp
index a3701f2..cc28adc 100644
--- a/gdb/testsuite/gdb.base/until-trailing-insns.exp
+++ b/gdb/testsuite/gdb.base/until-trailing-insns.exp
@@ -100,16 +100,16 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name until-trailing-isns.c}
- {stmt_list $L DW_FORM_sec_offset}
- {low_pc 0 addr}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name until-trailing-isns.c
+ DW_AT_stmt_list $L DW_FORM_sec_offset
+ DW_AT_low_pc 0 addr
} {
subprogram {
- {external 1 flag}
- {name main}
- {low_pc $main_start addr}
- {high_pc $main_len DW_FORM_data4}
+ DW_AT_external 1 flag
+ DW_AT_name main
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc $main_len DW_FORM_data4
}
}
}
diff --git a/gdb/testsuite/gdb.base/varargs.exp b/gdb/testsuite/gdb.base/varargs.exp
index a34a578..534971c 100644
--- a/gdb/testsuite/gdb.base/varargs.exp
+++ b/gdb/testsuite/gdb.base/varargs.exp
@@ -49,7 +49,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
# Start with a fresh gdb.
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
gdb_test_no_output "set print sevenbit-strings"
gdb_test_no_output "set print address off"
gdb_test_no_output "set width 0"
diff --git a/gdb/testsuite/gdb.base/watch_thread_num.exp b/gdb/testsuite/gdb.base/watch_thread_num.exp
index 4a5c1c2..e1b54c0 100644
--- a/gdb/testsuite/gdb.base/watch_thread_num.exp
+++ b/gdb/testsuite/gdb.base/watch_thread_num.exp
@@ -31,7 +31,8 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.base/watchpoint-hw-attach.exp b/gdb/testsuite/gdb.base/watchpoint-hw-attach.exp
index fa63edb..afdb82e 100644
--- a/gdb/testsuite/gdb.base/watchpoint-hw-attach.exp
+++ b/gdb/testsuite/gdb.base/watchpoint-hw-attach.exp
@@ -35,7 +35,8 @@ gdb_test "detach" "Detaching from program: .*, process $testpid\r\n\\\[Inferior
# A clean restart is needed to force the hardware watchpoint setup
# logic to run post attach rather than post inferior launch.
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
gdb_test "attach $testpid" "Attaching to program: .*, process $testpid.*" "attach twice"
diff --git a/gdb/testsuite/gdb.base/watchpoint-running.exp b/gdb/testsuite/gdb.base/watchpoint-running.exp
index 1a5f9c3..04c4c52 100644
--- a/gdb/testsuite/gdb.base/watchpoint-running.exp
+++ b/gdb/testsuite/gdb.base/watchpoint-running.exp
@@ -43,7 +43,8 @@ proc test {stop_mode hw} {
# default.
append ::GDBFLAGS " -ex \"maint set target-non-stop on\""
}
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
}
gdb_test_no_output "set can-use-hw-watchpoints $hw"
diff --git a/gdb/testsuite/gdb.base/watchpoint-solib.exp b/gdb/testsuite/gdb.base/watchpoint-solib.exp
index 28b8d08..7f58a83 100644
--- a/gdb/testsuite/gdb.base/watchpoint-solib.exp
+++ b/gdb/testsuite/gdb.base/watchpoint-solib.exp
@@ -49,7 +49,8 @@ if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
gdb_load_shlib $lib_sl
runto_main
diff --git a/gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.exp b/gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.exp
index 2bedcaa..163ec3b 100644
--- a/gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.exp
+++ b/gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.exp
@@ -129,7 +129,8 @@ proc test {always_inserted} {
with_test_prefix "always-inserted $always_inserted" {
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.base/watchpoint-unaligned.c b/gdb/testsuite/gdb.base/watchpoint-unaligned.c
index d3c1349..ca2fa45 100644
--- a/gdb/testsuite/gdb.base/watchpoint-unaligned.c
+++ b/gdb/testsuite/gdb.base/watchpoint-unaligned.c
@@ -18,6 +18,8 @@
#include <stdint.h>
#include <assert.h>
+static volatile int volatile_dummy;
+
static int again;
static volatile struct
@@ -53,6 +55,40 @@ write_size8twice (void)
data.u.size8twice[offset] = first;
data.u.size8twice[offset + 1] = second;
#endif
+
+ /* Setting a breakpoint on an instruction after an instruction triggering a
+ watchpoint makes it ambiguous which one will be reported.
+ Insert a dummy instruction in between to make sure the watchpoint gets
+ reported. */
+ volatile_dummy = 1;
+
+ return; /* write_size8twice_return */
+}
+
+static void
+read_size8twice (void)
+{
+ static uint64_t volatile first;
+ static uint64_t volatile second;
+
+#ifdef __aarch64__
+ volatile void *p = &data.u.size8twice[offset];
+ asm volatile ("ldp %0, %1, [%2]"
+ : "=r" (first), "=r" (second) /* output */
+ : "r" (p) /* input */
+ : /* clobber */);
+#else
+ first = data.u.size8twice[offset];
+ second = data.u.size8twice[offset + 1];
+#endif
+
+ /* Setting a breakpoint on an instruction after an instruction triggering a
+ watchpoint makes it ambiguous which one will be reported.
+ Insert a dummy instruction inbetween to make sure the watchpoint gets
+ reported. */
+ volatile_dummy = 1;
+
+ return; /* read_size8twice_return */
}
int
@@ -63,6 +99,7 @@ main (void)
assert (sizeof (data) == 8 + 3 * 8);
write_size8twice ();
+ read_size8twice ();
while (size)
{
diff --git a/gdb/testsuite/gdb.base/watchpoint-unaligned.exp b/gdb/testsuite/gdb.base/watchpoint-unaligned.exp
index 9220402..85b1eb7 100644
--- a/gdb/testsuite/gdb.base/watchpoint-unaligned.exp
+++ b/gdb/testsuite/gdb.base/watchpoint-unaligned.exp
@@ -151,6 +151,63 @@ foreach_with_prefix wpcount {4 7} {
gdb_assert $got_hit $test
}
+proc size8twice { function cmd offset index } {
+ clean_restart $::testfile
+
+ if { ![runto $function] } {
+ return -1
+ }
+
+ # Set offset in the inferior.
+ gdb_test_no_output "set var offset = $offset"
+
+ # Set a breakpoint.
+ set bp_src_string "${function}_return"
+ set bp_loc [gdb_get_line_number $bp_src_string]
+ gdb_breakpoint $bp_loc \
+ "Breakpoint $::decimal at $::hex" "$bp_src_string"
+
+ # Set a hardware watchpoint.
+ set watch_index [expr $offset + $index]
+ set test "$cmd data.u.size8twice\[$watch_index\]"
+ set wpnum 0
+ gdb_test_multiple $test "" {
+ -re -wrap "Hardware (read )?watchpoint ($::decimal): .*" {
+ set wpnum $expect_out(2,string)
+ pass $gdb_test_name
+ }
+ -re -wrap "Watchpoint ($::decimal): .*" {
+ if {[istarget "arm*-*-*"]} {
+ untested $gdb_test_name
+ } else {
+ fail $gdb_test_name
+ }
+ }
+ }
+
+ if { ! $wpnum } {
+ # No hardware watchpoint, we're done.
+ return 0
+ }
+
+ # Try to trigger the hardware watchpoint.
+ set got_hit 0
+ gdb_test_multiple "continue" "" {
+ -re -wrap "\r\nCould not insert hardware watchpoint .*" {
+ }
+ -re -wrap "Hardware (read )?watchpoint $wpnum:.*(New value|Value) = .*" {
+ set got_hit 1
+ send_gdb "continue\n"
+ exp_continue
+ }
+ -re -wrap " $bp_src_string .*" {
+ }
+ }
+ gdb_assert { $got_hit }
+
+ return $got_hit
+}
+
# We've got an array with 3 8-byte elements. Do a store of 16 bytes,
# to:
# - elements 0 and 1 (offset == 0), and
@@ -158,49 +215,21 @@ foreach_with_prefix wpcount {4 7} {
# For each case, check setting a watchpoint at:
# - the first written element (index == 0), and
# - the second element (index == 1).
-foreach_with_prefix offset { 0 1 } {
- foreach_with_prefix index { 0 1 } {
-
- clean_restart $binfile
-
- if ![runto_main] {
- return -1
- }
-
- gdb_test_no_output "set var offset = $offset"
- gdb_breakpoint [gdb_get_line_number "final_return"] \
- "Breakpoint $decimal at $hex" "final_return"
- set watch_index [expr $offset + $index]
- set test "watch data.u.size8twice\[$watch_index\]"
- set wpnum 0
- gdb_test_multiple $test $test {
- -re "Hardware watchpoint (\[0-9\]+): .*\r\n$gdb_prompt $" {
- set wpnum $expect_out(1,string)
- pass $gdb_test_name
- }
- -re "Watchpoint (\[0-9\]+): .*\r\n$gdb_prompt $" {
- if {[istarget "arm*-*-*"]} {
- untested $gdb_test_name
- } else {
- fail $gdb_test_name
- }
+foreach_with_prefix fun { write_size8twice read_size8twice } {
+ if { $fun == "write_size8twice" } {
+ set cmd "watch"
+ } else {
+ set cmd "rwatch"
+ }
+ foreach_with_prefix offset { 0 1 } {
+ foreach_with_prefix index { 0 1 } {
+ set res [size8twice $fun $cmd $offset $index]
+ if { $res != 1 } {
+ break
}
}
- if {$wpnum} {
- set test "continue"
- set got_hit 0
- gdb_test_multiple $test $test {
- -re "\r\nCould not insert hardware watchpoint .*\r\n$gdb_prompt $" {
- }
- -re "Hardware watchpoint $wpnum:.*New value = .*\r\n$gdb_prompt $" {
- set got_hit 1
- send_gdb "continue\n"
- exp_continue
- }
- -re " final_return .*\r\n$gdb_prompt $" {
- }
- }
- gdb_assert $got_hit "size8twice write"
+ if { $res != 1 } {
+ break
}
}
}
diff --git a/gdb/testsuite/gdb.base/watchpoints.exp b/gdb/testsuite/gdb.base/watchpoints.exp
index 37baa5e..d8e4d63 100644
--- a/gdb/testsuite/gdb.base/watchpoints.exp
+++ b/gdb/testsuite/gdb.base/watchpoints.exp
@@ -53,7 +53,8 @@ with_test_prefix "before inferior start" {
# This will turn hardware watchpoints back on and delete the watchpoint
# we just created.
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
# Disable hardware watchpoints if necessary.
if {!$allow_hw_watchpoint_tests_p} {
diff --git a/gdb/testsuite/gdb.base/with-mf.exp b/gdb/testsuite/gdb.base/with-mf.exp
index 564d5d7..3ac5e1d 100644
--- a/gdb/testsuite/gdb.base/with-mf.exp
+++ b/gdb/testsuite/gdb.base/with-mf.exp
@@ -29,7 +29,8 @@ if { [ensure_gdb_index $binfile] == -1 } {
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
gdb_test "with language ada -- print g_s" \
" = \\(a => 1, b => 2, c => 3\\)"
diff --git a/gdb/testsuite/gdb.base/with.exp b/gdb/testsuite/gdb.base/with.exp
index a9b4a6c..d766e5d 100644
--- a/gdb/testsuite/gdb.base/with.exp
+++ b/gdb/testsuite/gdb.base/with.exp
@@ -25,7 +25,8 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug]} {
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
# Test "maint with". VALUES is a list of values. A nested "with" is
# performed with each combination of pair of values from this list.
@@ -178,7 +179,8 @@ with_test_prefix "user-defined" {
# Check repeating.
with_test_prefix "repeat" {
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
# "with" with no command reinvokes the previous command.
gdb_test "with language ada" \
@@ -209,7 +211,8 @@ with_test_prefix "repeat" {
# Basic run control.
with_test_prefix "run control" {
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
if ![runto_main] {
return
diff --git a/gdb/testsuite/gdb.btrace/buffer-size.exp b/gdb/testsuite/gdb.btrace/buffer-size.exp
index 3a54baa..16958ae 100644
--- a/gdb/testsuite/gdb.btrace/buffer-size.exp
+++ b/gdb/testsuite/gdb.btrace/buffer-size.exp
@@ -20,11 +20,11 @@
require allow_btrace_tests
standard_testfile record_goto.c
-if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/data.exp b/gdb/testsuite/gdb.btrace/data.exp
index d42d017..4245157 100644
--- a/gdb/testsuite/gdb.btrace/data.exp
+++ b/gdb/testsuite/gdb.btrace/data.exp
@@ -20,11 +20,11 @@
require allow_btrace_tests
standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/delta.exp b/gdb/testsuite/gdb.btrace/delta.exp
index 0807c58..64e965d 100644
--- a/gdb/testsuite/gdb.btrace/delta.exp
+++ b/gdb/testsuite/gdb.btrace/delta.exp
@@ -20,11 +20,11 @@
require allow_btrace_tests
standard_testfile record_goto.c
-if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/dlopen.exp b/gdb/testsuite/gdb.btrace/dlopen.exp
index 092f4b0..1383bd9 100644
--- a/gdb/testsuite/gdb.btrace/dlopen.exp
+++ b/gdb/testsuite/gdb.btrace/dlopen.exp
@@ -33,7 +33,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/enable-new-thread.exp b/gdb/testsuite/gdb.btrace/enable-new-thread.exp
index ee7c023..ab73d45 100644
--- a/gdb/testsuite/gdb.btrace/enable-new-thread.exp
+++ b/gdb/testsuite/gdb.btrace/enable-new-thread.exp
@@ -20,11 +20,11 @@
require allow_btrace_tests
standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/enable-running.exp b/gdb/testsuite/gdb.btrace/enable-running.exp
index 1daa005..92ae566 100644
--- a/gdb/testsuite/gdb.btrace/enable-running.exp
+++ b/gdb/testsuite/gdb.btrace/enable-running.exp
@@ -29,7 +29,7 @@ save_vars { GDBFLAGS } {
clean_restart $testfile
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/enable.exp b/gdb/testsuite/gdb.btrace/enable.exp
index ad62733..cc48cc2 100644
--- a/gdb/testsuite/gdb.btrace/enable.exp
+++ b/gdb/testsuite/gdb.btrace/enable.exp
@@ -35,11 +35,11 @@ gdb_test "record instruction-history" "No recording is currently active\\..*" "r
gdb_test "info record" "No recording is currently active\\." "info record without target"
standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile {} {debug}] {
+if {[prepare_for_testing "failed to prepare" $testfile {} {debug}]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
@@ -78,20 +78,20 @@ gdb_exit
load_lib gdbserver-support.exp
require allow_gdbserver_tests
clean_restart $testfile
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
# make sure record-btrace can be enabled after re-run
clean_restart $testfile
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
gdb_test_no_output "record btrace" "enable after restart"
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
gdb_test_no_output "record btrace" "enable after re-run"
diff --git a/gdb/testsuite/gdb.btrace/exception.exp b/gdb/testsuite/gdb.btrace/exception.exp
index 67e9fbd..61a4bd9 100755
--- a/gdb/testsuite/gdb.btrace/exception.exp
+++ b/gdb/testsuite/gdb.btrace/exception.exp
@@ -22,12 +22,12 @@ require allow_btrace_tests
# We expect a specific function call history. This gets messed up with
# PIE on 32-bit.
standard_testfile exception.cc
-if [prepare_for_testing "failed to prepare" $testfile $srcfile \
- {nopie c++ debug}] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile \
+ {nopie c++ debug}]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/function_call_history.exp b/gdb/testsuite/gdb.btrace/function_call_history.exp
index e233936..325099a 100644
--- a/gdb/testsuite/gdb.btrace/function_call_history.exp
+++ b/gdb/testsuite/gdb.btrace/function_call_history.exp
@@ -22,11 +22,11 @@ require allow_btrace_tests
# We expect a specific function call history. This gets messed up with
# PIE on 32-bit.
standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile {} {nopie debug}] {
+if {[prepare_for_testing "failed to prepare" $testfile {} {nopie debug}]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
@@ -226,7 +226,7 @@ gdb_test "record function-call-history /c 21, +11" [multi_line \
] "indented"
# make sure we can handle incomplete trace with respect to indentation
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
# navigate to the fib in line 24 above
diff --git a/gdb/testsuite/gdb.btrace/gcore.exp b/gdb/testsuite/gdb.btrace/gcore.exp
index b9e96d4..6d7ba5c 100644
--- a/gdb/testsuite/gdb.btrace/gcore.exp
+++ b/gdb/testsuite/gdb.btrace/gcore.exp
@@ -20,11 +20,11 @@
require allow_btrace_tests
standard_testfile record_goto.c
-if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/instruction_history.exp b/gdb/testsuite/gdb.btrace/instruction_history.exp
index 4e20194..fb68b33 100644
--- a/gdb/testsuite/gdb.btrace/instruction_history.exp
+++ b/gdb/testsuite/gdb.btrace/instruction_history.exp
@@ -20,11 +20,11 @@
require allow_btrace_tests
standard_testfile .c .S
-if [prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2" {debug}] {
+if {[prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2" {debug}]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/multi-inferior.exp b/gdb/testsuite/gdb.btrace/multi-inferior.exp
index d87a941..fc75233 100644
--- a/gdb/testsuite/gdb.btrace/multi-inferior.exp
+++ b/gdb/testsuite/gdb.btrace/multi-inferior.exp
@@ -29,14 +29,14 @@ require allow_multi_inferior_tests
require !use_gdb_stub
standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile {} {debug}] {
+if {[prepare_for_testing "failed to prepare" $testfile {} {debug}]} {
return -1
}
set host_binfile [gdb_remote_download host $binfile]
with_test_prefix "inferior 1" {
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
}
@@ -46,7 +46,7 @@ with_test_prefix "inferior 2" {
"add second inferior"
gdb_test "inferior 2" "Switching to inferior 2.*"
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
@@ -65,7 +65,7 @@ with_test_prefix "inferior 3" {
"add third inferior"
gdb_test "inferior 3" "Switching to inferior 3.*"
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/multi-thread-step.exp b/gdb/testsuite/gdb.btrace/multi-thread-step.exp
index 9f4c6c0..7a769b5 100644
--- a/gdb/testsuite/gdb.btrace/multi-thread-step.exp
+++ b/gdb/testsuite/gdb.btrace/multi-thread-step.exp
@@ -26,7 +26,7 @@ if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" "$binfile" executable {debu
}
clean_restart $testfile
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/nohist.exp b/gdb/testsuite/gdb.btrace/nohist.exp
index f573ed3..220a380 100644
--- a/gdb/testsuite/gdb.btrace/nohist.exp
+++ b/gdb/testsuite/gdb.btrace/nohist.exp
@@ -20,11 +20,11 @@
require allow_btrace_tests
standard_testfile record_goto.c
-if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/non-stop.exp b/gdb/testsuite/gdb.btrace/non-stop.exp
index 856985c..bc5ebdb 100644
--- a/gdb/testsuite/gdb.btrace/non-stop.exp
+++ b/gdb/testsuite/gdb.btrace/non-stop.exp
@@ -28,7 +28,7 @@ save_vars { GDBFLAGS } {
clean_restart $testfile
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/ptwrite.exp b/gdb/testsuite/gdb.btrace/ptwrite.exp
index 0c2bb7c..5207488 100644
--- a/gdb/testsuite/gdb.btrace/ptwrite.exp
+++ b/gdb/testsuite/gdb.btrace/ptwrite.exp
@@ -21,7 +21,7 @@ require allow_btrace_ptw_tests allow_python_tests
set opts {}
-if [info exists COMPILE] {
+if {[info exists COMPILE]} {
# make check RUNTESTFLAGS="gdb.btrace/ptwrite.exp COMPILE=1"
standard_testfile ptwrite.c
lappend opts debug additional_flags=-mptwrite
@@ -36,7 +36,7 @@ if [info exists COMPILE] {
return -1
}
-if [prepare_for_testing "failed to prepare" $testfile $srcfile $opts] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile $opts]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/reconnect.exp b/gdb/testsuite/gdb.btrace/reconnect.exp
index 15a0bca..44a9121 100644
--- a/gdb/testsuite/gdb.btrace/reconnect.exp
+++ b/gdb/testsuite/gdb.btrace/reconnect.exp
@@ -23,7 +23,7 @@ require allow_btrace_tests
require allow_gdbserver_tests
standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/record_goto-step.exp b/gdb/testsuite/gdb.btrace/record_goto-step.exp
index 10307a7..d881cf7 100644
--- a/gdb/testsuite/gdb.btrace/record_goto-step.exp
+++ b/gdb/testsuite/gdb.btrace/record_goto-step.exp
@@ -20,11 +20,11 @@
require allow_btrace_tests
standard_testfile record_goto.c
-if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/record_goto.exp b/gdb/testsuite/gdb.btrace/record_goto.exp
index b1b3c09..f7dbe10 100644
--- a/gdb/testsuite/gdb.btrace/record_goto.exp
+++ b/gdb/testsuite/gdb.btrace/record_goto.exp
@@ -28,7 +28,7 @@ require allow_btrace_tests
# Luckily, they are similar enough that a single test script can handle
# both.
set opts {}
-if [info exists COMPILE] {
+if {[info exists COMPILE]} {
# make check RUNTESTFLAGS="gdb.btrace/record_goto.exp COMPILE=1"
standard_testfile record_goto.c
lappend opts debug
@@ -43,11 +43,11 @@ if [info exists COMPILE] {
return -1
}
-if [prepare_for_testing "failed to prepare" $testfile $srcfile $opts] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile $opts]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/rn-dl-bind.exp b/gdb/testsuite/gdb.btrace/rn-dl-bind.exp
index 6592b74c..22ce8e5 100644
--- a/gdb/testsuite/gdb.btrace/rn-dl-bind.exp
+++ b/gdb/testsuite/gdb.btrace/rn-dl-bind.exp
@@ -24,12 +24,12 @@
require allow_btrace_tests
standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile $srcfile \
- {debug ldflags=-Wl,-z,lazy}] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile \
+ {debug ldflags=-Wl,-z,lazy}]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/segv.exp b/gdb/testsuite/gdb.btrace/segv.exp
index 628c155..509bcf1 100644
--- a/gdb/testsuite/gdb.btrace/segv.exp
+++ b/gdb/testsuite/gdb.btrace/segv.exp
@@ -20,10 +20,10 @@
require allow_btrace_tests
standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/step.exp b/gdb/testsuite/gdb.btrace/step.exp
index 7852d65..e96714a 100644
--- a/gdb/testsuite/gdb.btrace/step.exp
+++ b/gdb/testsuite/gdb.btrace/step.exp
@@ -20,11 +20,11 @@
require allow_btrace_tests
standard_testfile record_goto.c
-if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/stepi.exp b/gdb/testsuite/gdb.btrace/stepi.exp
index 3684bef..a37d144 100644
--- a/gdb/testsuite/gdb.btrace/stepi.exp
+++ b/gdb/testsuite/gdb.btrace/stepi.exp
@@ -26,7 +26,7 @@ require allow_btrace_tests
#
# Luckily, they are similar enough that a single test script can handle
# both.
-if [info exists COMPILE] {
+if {[info exists COMPILE]} {
# make check RUNTESTFLAGS="gdb.btrace/stepi.exp COMPILE=1"
standard_testfile record_goto.c
lappend opts debug
@@ -41,11 +41,11 @@ if [info exists COMPILE] {
return -1
}
-if [prepare_for_testing "failed to prepare" $testfile $srcfile {}] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {}]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/tailcall-only.exp b/gdb/testsuite/gdb.btrace/tailcall-only.exp
index c4f032a..5010d16 100644
--- a/gdb/testsuite/gdb.btrace/tailcall-only.exp
+++ b/gdb/testsuite/gdb.btrace/tailcall-only.exp
@@ -30,7 +30,7 @@ require allow_btrace_tests
# Luckily, they are similar enough that a single test script can handle
# both.
set opts {}
-if [info exists COMPILE] {
+if {[info exists COMPILE]} {
# make check RUNTESTFLAGS="gdb.btrace/tailcall-only.exp COMPILE=1"
standard_testfile tailcall-only.c
lappend opts debug optimize=-O2
@@ -45,11 +45,11 @@ if [info exists COMPILE] {
return -1
}
-if [prepare_for_testing "failed to prepare" $testfile $srcfile $opts] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile $opts]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/tailcall.exp b/gdb/testsuite/gdb.btrace/tailcall.exp
index 50d0a8b..d4d445c 100644
--- a/gdb/testsuite/gdb.btrace/tailcall.exp
+++ b/gdb/testsuite/gdb.btrace/tailcall.exp
@@ -27,7 +27,7 @@ require allow_btrace_tests
# Luckily, they are similar enough that a single test script can handle
# both.
set opts {}
-if [info exists COMPILE] {
+if {[info exists COMPILE]} {
# make check RUNTESTFLAGS="gdb.btrace/tailcall.exp COMPILE=1"
standard_testfile tailcall.c
lappend opts debug optimize=-O2
@@ -42,10 +42,10 @@ if [info exists COMPILE] {
return -1
}
-if [prepare_for_testing "failed to prepare" $testfile $srcfile $opts] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile $opts]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/tsx.exp b/gdb/testsuite/gdb.btrace/tsx.exp
index 168319b..6da3fa7 100644
--- a/gdb/testsuite/gdb.btrace/tsx.exp
+++ b/gdb/testsuite/gdb.btrace/tsx.exp
@@ -18,11 +18,11 @@
require allow_btrace_pt_tests allow_tsx_tests
standard_testfile .c x86-tsx.S
-if [prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2" {debug}] {
+if {[prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2" {debug}]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/unknown_functions.exp b/gdb/testsuite/gdb.btrace/unknown_functions.exp
index 61aed6f..0696d8b 100644
--- a/gdb/testsuite/gdb.btrace/unknown_functions.exp
+++ b/gdb/testsuite/gdb.btrace/unknown_functions.exp
@@ -25,12 +25,12 @@ standard_testfile
# PIE on 32-bit.
#
# Also discard local symbols.
-if [prepare_for_testing "failed to prepare" $testfile $srcfile \
- {ldflags=-Wl,-x nopie}] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile \
+ {ldflags=-Wl,-x nopie}]} {
return -1
}
-if ![runto test] {
+if {![runto test]} {
return -1
}
diff --git a/gdb/testsuite/gdb.btrace/vdso.exp b/gdb/testsuite/gdb.btrace/vdso.exp
index 1e19f99..0484da1 100644
--- a/gdb/testsuite/gdb.btrace/vdso.exp
+++ b/gdb/testsuite/gdb.btrace/vdso.exp
@@ -23,11 +23,11 @@
require allow_btrace_tests
standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile $srcfile] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.compile/compile-cplus-print.exp b/gdb/testsuite/gdb.compile/compile-cplus-print.exp
index d89bf61..e4e2782 100644
--- a/gdb/testsuite/gdb.compile/compile-cplus-print.exp
+++ b/gdb/testsuite/gdb.compile/compile-cplus-print.exp
@@ -22,7 +22,7 @@ require is_c_compiler_gcc
require allow_compile_tests
set options {}
-if [test_compiler_info gcc*] {
+if {[test_compiler_info gcc*]} {
lappend options additional_flags=-g3
lappend options additional_flags=-std=gnu++11
lappend options c++
@@ -30,13 +30,14 @@ if [test_compiler_info gcc*] {
set srcfilesoptions [list ${srcfile} ${options}]
-if { [eval build_executable_from_specs ${testfile}.exp $testfile {$options} ${srcfilesoptions}] } {
+if { [build_executable_from_specs $testfile.exp $testfile $options \
+ {*}$srcfilesoptions] } {
return -1
}
clean_restart ${testfile}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.compile/compile-cplus.exp b/gdb/testsuite/gdb.compile/compile-cplus.exp
index a0f5cf0..66ac76f 100644
--- a/gdb/testsuite/gdb.compile/compile-cplus.exp
+++ b/gdb/testsuite/gdb.compile/compile-cplus.exp
@@ -39,7 +39,9 @@ if { $srcfile3 != "" } {
}
set srcfile4options "nodebug c++"
lappend srcfilesoptions $srcfile4 $srcfile4options
-if { [eval build_executable_from_specs ${testfile}.exp $testfile {$options} ${srcfilesoptions}] } {
+
+if { [build_executable_from_specs $testfile.exp $testfile $options \
+ {*}$srcfilesoptions] } {
return -1
}
@@ -52,7 +54,7 @@ clean_restart ${testfile}
gdb_test_no_output "set language c++" \
"Set language to C++"
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.compile/compile-ifunc.exp b/gdb/testsuite/gdb.compile/compile-ifunc.exp
index 068dce5..72c1142 100644
--- a/gdb/testsuite/gdb.compile/compile-ifunc.exp
+++ b/gdb/testsuite/gdb.compile/compile-ifunc.exp
@@ -24,7 +24,7 @@ standard_testfile
require is_c_compiler_gcc
set flags ""
-if [test_compiler_info gcc*] {
+if {[test_compiler_info gcc*]} {
set flags additional_flags=-Wno-attribute-alias
}
diff --git a/gdb/testsuite/gdb.compile/compile-ops.exp b/gdb/testsuite/gdb.compile/compile-ops.exp
index 410d5a4..c41c91e 100644
--- a/gdb/testsuite/gdb.compile/compile-ops.exp
+++ b/gdb/testsuite/gdb.compile/compile-ops.exp
@@ -375,36 +375,36 @@ Dwarf::assemble $asm_file {
declare_labels int_label
compile_unit {
- {name file1.txt}
- {language @DW_LANG_C}
- {low_pc $func_start addr}
- {high_pc $func_end addr}
+ DW_AT_name file1.txt
+ DW_AT_language @DW_LANG_C
+ DW_AT_low_pc $func_start addr
+ DW_AT_high_pc $func_end addr
} {
global program
int_label: base_type {
- {name int}
- {byte_size 4 sdata}
- {encoding @DW_ATE_signed}
+ DW_AT_name int
+ DW_AT_byte_size 4 sdata
+ DW_AT_encoding @DW_ATE_signed
}
subprogram {
- {external 1 flag}
- {name func}
- {low_pc $func_start addr}
- {high_pc $func_end addr}
+ DW_AT_external 1 flag
+ DW_AT_name func
+ DW_AT_low_pc $func_start addr
+ DW_AT_high_pc $func_end addr
} {
formal_parameter {
- {name param}
- {variable_parameter 1 flag}
- {type :$int_label}
- {location $program SPECIAL_expr}
+ DW_AT_name param
+ DW_AT_variable_parameter 1 flag
+ DW_AT_type :$int_label
+ DW_AT_location $program SPECIAL_expr
}
formal_parameter {
- {name optimized_out}
- {variable_parameter 1 flag}
- {type :$int_label}
+ DW_AT_name optimized_out
+ DW_AT_variable_parameter 1 flag
+ DW_AT_type :$int_label
}
}
}
@@ -416,7 +416,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
return -1
}
-if ![runto func] {
+if {![runto func]} {
return -1
}
diff --git a/gdb/testsuite/gdb.compile/compile-print.exp b/gdb/testsuite/gdb.compile/compile-print.exp
index 4c90a71..2d3ad2f 100644
--- a/gdb/testsuite/gdb.compile/compile-print.exp
+++ b/gdb/testsuite/gdb.compile/compile-print.exp
@@ -25,7 +25,7 @@ if { [prepare_for_testing "failed to prepare" "$testfile"] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.compile/compile-setjmp.exp b/gdb/testsuite/gdb.compile/compile-setjmp.exp
index 73f6b8b..048d0a4 100644
--- a/gdb/testsuite/gdb.compile/compile-setjmp.exp
+++ b/gdb/testsuite/gdb.compile/compile-setjmp.exp
@@ -25,7 +25,7 @@ if { [prepare_for_testing "failed to prepare" $testfile] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.compile/compile-tls.exp b/gdb/testsuite/gdb.compile/compile-tls.exp
index aaa8e03..e7db1da 100644
--- a/gdb/testsuite/gdb.compile/compile-tls.exp
+++ b/gdb/testsuite/gdb.compile/compile-tls.exp
@@ -26,7 +26,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return 0
}
diff --git a/gdb/testsuite/gdb.compile/compile.exp b/gdb/testsuite/gdb.compile/compile.exp
index ff20b2e..66ac182 100644
--- a/gdb/testsuite/gdb.compile/compile.exp
+++ b/gdb/testsuite/gdb.compile/compile.exp
@@ -32,7 +32,8 @@ if { $srcfile3 != "" } {
lappend srcfilesoptions $srcfile3 ${options}
}
lappend srcfilesoptions $srcfile4 "nodebug"
-if { [eval build_executable_from_specs ${testfile}.exp $testfile {$options} ${srcfilesoptions}] } {
+if { [build_executable_from_specs $testfile.exp $testfile $options \
+ {*}$srcfilesoptions] } {
return -1
}
@@ -53,7 +54,7 @@ gdb_test "compile file -r ${srcdir}/${subdir}/${testfile}-mod.c" \
"The program must be running for the compile command to work.*" \
"test compile file command without running inferior"
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
@@ -378,8 +379,9 @@ if { $srcfile3 != "" } {
require allow_shlib_tests
-set libbin [standard_output_file ${testfile}-shlib.so]
-set binfile [standard_output_file ${testfile}-shlib]
+set testfile $testfile-shlib
+set libbin [standard_output_file $testfile.so]
+set binfile [standard_output_file $testfile]
if { [gdb_compile_shlib ${srcdir}/${subdir}/${srcfile2} $libbin {debug}] != ""
|| [gdb_compile ${srcdir}/${subdir}/${srcfile} $binfile executable \
@@ -387,10 +389,10 @@ if { [gdb_compile_shlib ${srcdir}/${subdir}/${srcfile2} $libbin {debug}] != ""
return -1
}
-clean_restart $binfile
+clean_restart $testfile
gdb_load_shlib $libbin
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.cp/call-c.exp b/gdb/testsuite/gdb.cp/call-c.exp
index f99d171..6d240c8 100644
--- a/gdb/testsuite/gdb.cp/call-c.exp
+++ b/gdb/testsuite/gdb.cp/call-c.exp
@@ -27,7 +27,7 @@ if {[gdb_compile "$srcdir/$subdir/${srcfile2}" "${objfilec}" object {debug}] !=
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
runto_main
diff --git a/gdb/testsuite/gdb.cp/call-method-register.exp b/gdb/testsuite/gdb.cp/call-method-register.exp
index dfd3ce0..b736312 100644
--- a/gdb/testsuite/gdb.cp/call-method-register.exp
+++ b/gdb/testsuite/gdb.cp/call-method-register.exp
@@ -45,59 +45,59 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {DW_AT_language @DW_LANG_C_plus_plus}
- {DW_AT_name $::srcfile}
- {DW_AT_comp_dir /tmp}
+ DW_AT_language @DW_LANG_C_plus_plus
+ DW_AT_name $::srcfile
+ DW_AT_comp_dir /tmp
} {
declare_labels int_type_label struct_type_label \
struct_ptr_type_label
set ptr_size [get_sizeof "void *" 96]
DW_TAG_subprogram {
- {name main}
- {low_pc $main_start addr}
- {high_pc $main_length data8}
- {DW_AT_type :$int_type_label}
+ DW_AT_name main
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc $main_length data8
+ DW_AT_type :$int_type_label
}
int_type_label: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name int}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int
}
struct_type_label: DW_TAG_structure_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_name small}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_name small
} {
member {
- {name xxx}
- {type :$int_type_label}
- {data_member_location 0 data1}
+ DW_AT_name xxx
+ DW_AT_type :$int_type_label
+ DW_AT_data_member_location 0 data1
}
subprogram {
- {name yyy}
- {type :$int_type_label}
+ DW_AT_name yyy
+ DW_AT_type :$int_type_label
} {
formal_parameter {
- {type :$struct_ptr_type_label}
- {artificial 1 flag_present}
+ DW_AT_type :$struct_ptr_type_label
+ DW_AT_artificial 1 flag_present
}
}
}
struct_ptr_type_label: DW_TAG_pointer_type {
- {DW_AT_byte_size $ptr_size DW_FORM_data1}
- {type :$struct_type_label}
+ DW_AT_byte_size $ptr_size DW_FORM_data1
+ DW_AT_type :$struct_type_label
}
DW_TAG_variable {
- {DW_AT_name global_var}
- {DW_AT_type :$struct_type_label}
- {DW_AT_location {
+ DW_AT_name global_var
+ DW_AT_type :$struct_type_label
+ DW_AT_location {
DW_OP_reg0
- } SPECIAL_expr}
- {external 1 flag}
+ } SPECIAL_expr
+ DW_AT_external 1 flag
}
}
}
diff --git a/gdb/testsuite/gdb.cp/eval-reference-type.cc b/gdb/testsuite/gdb.cp/eval-reference-type.cc
new file mode 100644
index 0000000..b177cbf
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/eval-reference-type.cc
@@ -0,0 +1,36 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2025 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 that expression evaluation does not return an error if one of
+ the operands is of reference type. */
+
+struct
+{
+ int &get ()
+ {
+ return x;
+ };
+
+ int x = 1;
+} v_struct;
+
+int
+main (void)
+{
+ v_struct.get () = 2;
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.cp/eval-reference-type.exp b/gdb/testsuite/gdb.cp/eval-reference-type.exp
new file mode 100644
index 0000000..4c7b3b7
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/eval-reference-type.exp
@@ -0,0 +1,46 @@
+# Copyright 2025 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/>.
+
+standard_testfile .cc
+
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
+ return
+}
+
+runto_main
+
+# Test for reference type.
+gdb_test "print v_struct.get () == 1 && v_struct.get () == 2" \
+ " = false"
+gdb_test "print v_struct.get () == 1 || v_struct.get () == 2" \
+ " = true"
+
+# Test for correct type resolution using 'ptype'.
+gdb_test "ptype v_struct.get ()" \
+ "type = int &"
+gdb_test "ptype v_struct.get () == 1" \
+ "type = bool"
+gdb_test "ptype v_struct.get () + 1" \
+ "type = int"
+gdb_test "ptype v_struct.get () && 1" \
+ "type = bool"
+gdb_test "ptype v_struct.get () || 1" \
+ "type = bool"
+gdb_test "ptype !v_struct.get ()" \
+ "type = bool"
+gdb_test "ptype v_struct.get () ? 2 : 3" \
+ "type = int"
+gdb_test "ptype v_struct.get () | 1" \
+ "type = int"
diff --git a/gdb/testsuite/gdb.cp/gdb2384.exp b/gdb/testsuite/gdb.cp/gdb2384.exp
index 204bdeb..a53ec3a 100644
--- a/gdb/testsuite/gdb.cp/gdb2384.exp
+++ b/gdb/testsuite/gdb.cp/gdb2384.exp
@@ -35,7 +35,7 @@ if { [gdb_compile_shlib $srcdir/$subdir/$srcfile2 $sofile {debug c++}] != ""
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_load_shlib ${sofile}
diff --git a/gdb/testsuite/gdb.cp/incomplete-type-overload.exp b/gdb/testsuite/gdb.cp/incomplete-type-overload.exp
index aa51fd9..aa582e0 100644
--- a/gdb/testsuite/gdb.cp/incomplete-type-overload.exp
+++ b/gdb/testsuite/gdb.cp/incomplete-type-overload.exp
@@ -57,105 +57,109 @@ Dwarf::assemble ${asm_file} {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C_plus_plus}
- {name $srcfile}
- {stmt_list $L DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C_plus_plus
+ DW_AT_name $srcfile
+ DW_AT_stmt_list $L DW_FORM_sec_offset
} {
declare_labels int_label base_label complete_label incomplete_label
declare_labels ptr_base_label ptr_inc_label ptr_comp_label ptr_int_label
int_label: DW_TAG_base_type {
- {DW_AT_byte_size $int_size DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name "int"}
+ DW_AT_byte_size $int_size DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name "int"
}
base_label: DW_TAG_class_type {
- {DW_AT_byte_size $struct_base_size DW_FORM_sdata}
- {DW_AT_name "base"}
+ DW_AT_byte_size $struct_base_size DW_FORM_sdata
+ DW_AT_name "base"
} {
DW_TAG_member {
- {DW_AT_name "member"}
- {DW_AT_type :$int_label}
- {DW_AT_data_member_location 0 DW_FORM_sdata}
+ DW_AT_name "member"
+ DW_AT_type :$int_label
+ DW_AT_data_member_location 0 DW_FORM_sdata
}
}
complete_label: DW_TAG_class_type {
- {DW_AT_byte_size $struct_complete_size DW_FORM_sdata}
- {DW_AT_name "complete"}
+ DW_AT_byte_size $struct_complete_size DW_FORM_sdata
+ DW_AT_name "complete"
} {
DW_TAG_inheritance {
- {DW_AT_type :$base_label}
- {DW_AT_data_member_location 0 DW_FORM_sdata}
- {DW_AT_accessibility 1 DW_FORM_data1}
+ DW_AT_type :$base_label
+ DW_AT_data_member_location 0 DW_FORM_sdata
+ DW_AT_accessibility 1 DW_FORM_data1
}
}
incomplete_label: DW_TAG_class_type {
- {DW_AT_name "incomplete"}
- {DW_AT_declaration 1 DW_FORM_flag_present}
+ DW_AT_name "incomplete"
+ DW_AT_declaration 1 DW_FORM_flag_present
}
ptr_base_label: DW_TAG_pointer_type {
- {DW_AT_byte_size $addr_size DW_FORM_udata}
- {DW_AT_type :$base_label}
+ DW_AT_byte_size $addr_size DW_FORM_udata
+ DW_AT_type :$base_label
}
ptr_inc_label: DW_TAG_pointer_type {
- {DW_AT_byte_size $addr_size DW_FORM_udata}
- {DW_AT_type :$incomplete_label}
+ DW_AT_byte_size $addr_size DW_FORM_udata
+ DW_AT_type :$incomplete_label
}
ptr_comp_label: DW_TAG_pointer_type {
- {DW_AT_byte_size $addr_size DW_FORM_udata}
- {DW_AT_type :$complete_label}
+ DW_AT_byte_size $addr_size DW_FORM_udata
+ DW_AT_type :$complete_label
}
ptr_int_label: DW_TAG_pointer_type {
- {DW_AT_byte_size $addr_size DW_FORM_udata}
- {DW_AT_type :$int_label}
+ DW_AT_byte_size $addr_size DW_FORM_udata
+ DW_AT_type :$int_label
}
DW_TAG_variable {
- {DW_AT_name "comp"}
- {DW_AT_type :$complete_label}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "comp"]} SPECIAL_expr}
- {DW_AT_external 1 DW_FORM_flag}
+ DW_AT_name "comp"
+ DW_AT_type :$complete_label
+ DW_AT_location [subst {DW_OP_addr [gdb_target_symbol "comp"]}] \
+ SPECIAL_expr
+ DW_AT_external 1 DW_FORM_flag
}
DW_TAG_variable {
- {DW_AT_name "cp"}
- {DW_AT_type :$ptr_comp_label}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "cp"]} SPECIAL_expr}
- {DW_AT_external 1 DW_FORM_flag}
+ DW_AT_name "cp"
+ DW_AT_type :$ptr_comp_label
+ DW_AT_location [subst {DW_OP_addr [gdb_target_symbol "cp"]}] \
+ SPECIAL_expr
+ DW_AT_external 1 DW_FORM_flag
}
DW_TAG_variable {
- {DW_AT_name "inc"}
- {DW_AT_type :$ptr_inc_label}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "inc"]} SPECIAL_expr}
- {DW_AT_external 1 DW_FORM_flag}
+ DW_AT_name "inc"
+ DW_AT_type :$ptr_inc_label
+ DW_AT_location [subst {DW_OP_addr [gdb_target_symbol "inc"]}] \
+ SPECIAL_expr
+ DW_AT_external 1 DW_FORM_flag
}
DW_TAG_variable {
- {DW_AT_name "ip"}
- {DW_AT_type :$ptr_int_label}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "ip"]} SPECIAL_expr}
- {DW_AT_external 1 DW_FORM_flag}
+ DW_AT_name "ip"
+ DW_AT_type :$ptr_int_label
+ DW_AT_location [subst {DW_OP_addr [gdb_target_symbol "ip"]}] \
+ SPECIAL_expr
+ DW_AT_external 1 DW_FORM_flag
}
DW_TAG_subprogram {
- {MACRO_AT_func {"main"}}
- {DW_AT_external 1 flag}
+ MACRO_AT_func {"main"}
+ DW_AT_external 1 flag
}
DW_TAG_subprogram {
- {MACRO_AT_func {"foo"}}
- {DW_AT_type :$int_label}
- {DW_AT_external 1 flag}
+ MACRO_AT_func {"foo"}
+ DW_AT_type :$int_label
+ DW_AT_external 1 flag
} { formal_parameter {
- {DW_AT_name "b"}
- {DW_AT_type :$ptr_base_label}
+ DW_AT_name "b"
+ DW_AT_type :$ptr_base_label
}
}
}
diff --git a/gdb/testsuite/gdb.cp/infcall-nodebug.exp.tcl b/gdb/testsuite/gdb.cp/infcall-nodebug.exp.tcl
index 0a7bc76..764d31d 100644
--- a/gdb/testsuite/gdb.cp/infcall-nodebug.exp.tcl
+++ b/gdb/testsuite/gdb.cp/infcall-nodebug.exp.tcl
@@ -71,9 +71,9 @@ proc build_and_run_test { lang symbols } {
# Startup and run to main.
- clean_restart $binfile
+ clean_restart $::testfile
- if ![runto_main] then {
+ if { ![runto_main] } {
return
}
diff --git a/gdb/testsuite/gdb.cp/method-ref-return.cc b/gdb/testsuite/gdb.cp/method-ref-return.cc
new file mode 100644
index 0000000..4169bfe
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/method-ref-return.cc
@@ -0,0 +1,42 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2025 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 that we can access class method/data member via reference. */
+
+struct foo
+{
+ foo () : m_a (42) {}
+ int get_a () const { return m_a; }
+ int m_a;
+};
+
+struct bar
+{
+ bar () : m_foo () {}
+ const foo &get_foo () const { return m_foo; }
+ foo m_foo;
+};
+
+int
+main (int argc, char *argv[])
+{
+ bar b;
+ const foo &ref = b.get_foo ();
+ int ret = ref.m_a; // breakpoint here
+ ret += ref.get_a ();
+ return ret;
+} \ No newline at end of file
diff --git a/gdb/testsuite/gdb.cp/method-ref-return.exp b/gdb/testsuite/gdb.cp/method-ref-return.exp
new file mode 100644
index 0000000..1ac5ac9
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/method-ref-return.exp
@@ -0,0 +1,70 @@
+# Copyright 2025 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 calling methods and accessing members via reference.
+
+require allow_cplus_tests
+
+standard_testfile .cc
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
+ return -1
+}
+
+if {![runto_main]} {
+ return -1
+}
+
+# Set a breakpoint after the bar object is created and the reference is obtained.
+gdb_breakpoint [gdb_get_line_number "breakpoint here"]
+gdb_continue_to_breakpoint "after reference assignment"
+
+# Test that we can call the method through reference and get the expected result.
+gdb_test_multiple "print b.get_foo()" "print method call returning reference" {
+ -re "\\$\[0-9\]+ = \\(const foo &\\) @$hex: \\{m_a = 42\\}\r\n$gdb_prompt $" {
+ pass $gdb_test_name
+ }
+ -re "Could not validate memory tag: Value can't be converted to integer\\." {
+ fail "$gdb_test_name"
+ }
+}
+
+# Test accessing the member through the reference.
+gdb_test "print b.get_foo ().m_a" \
+ "\\$\[0-9\]+ = 42" \
+ "print member access through reference"
+
+# Test calling method on the referenced object.
+gdb_test "print b.get_foo ().get_a()" \
+ "\\$\[0-9\]+ = 42" \
+ "print method call on referenced object"
+
+# Test that the stored reference works correctly.
+gdb_test_multiple "print ref" "print stored reference" {
+ -re "\\$\[0-9\]+ = \\(const foo &\\) @$hex: \\{m_a = 42\\}\r\n$gdb_prompt $" {
+ pass $gdb_test_name
+ }
+ -re "Could not validate memory tag: Value can't be converted to integer\\." {
+ fail "$gdb_test_name"
+ }
+}
+
+gdb_test "print ref.m_a" \
+ "\\$\[0-9\]+ = 42" \
+ "print member through stored reference"
+
+gdb_test "print ref.get_a()" \
+ "\\$\[0-9\]+ = 42" \
+ "print method call through stored reference" \ No newline at end of file
diff --git a/gdb/testsuite/gdb.cp/nsalias.exp b/gdb/testsuite/gdb.cp/nsalias.exp
index a145410..7ad2da8 100644
--- a/gdb/testsuite/gdb.cp/nsalias.exp
+++ b/gdb/testsuite/gdb.cp/nsalias.exp
@@ -56,111 +56,113 @@ standard_testfile .cc nsalias-dw.S
set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu {} {
- compile_unit {{language @DW_LANG_C_plus_plus}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C_plus_plus
+ } {
declare_labels int_label outer_label inner_label innermost_label
declare_labels im_foo_label i_foo_label o_foo_label
declare_labels OuterInner_label oi1_label oi2_label
int_label: base_type {
- {name int}
- {encoding @DW_ATE_signed}
- {byte_size 4 DW_FORM_sdata}
+ DW_AT_name int
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 4 DW_FORM_sdata
}
outer_label: DW_TAG_namespace {
- {name outer}
+ DW_AT_name outer
} {
inner_label: DW_TAG_namespace {
- {name inner}
+ DW_AT_name inner
} {
innermost_label: DW_TAG_namespace {
- {name innermost}
+ DW_AT_name innermost
} {
DW_TAG_variable {
- {name x}
- {type :$int_label}
- {const_value 2 DW_FORM_data1}
+ DW_AT_name x
+ DW_AT_type :$int_label
+ DW_AT_const_value 2 DW_FORM_data1
}
im_foo_label: DW_TAG_subprogram {
- {name foo}
- {external 1 flag_present}
- {declaration 1 flag_present}
+ DW_AT_name foo
+ DW_AT_external 1 flag_present
+ DW_AT_declaration 1 flag_present
}
}
imported_declaration {
- {name Innermost}
- {import :$innermost_label}
+ DW_AT_name Innermost
+ DW_AT_import :$innermost_label
}
DW_TAG_variable {
- {name x}
- {type :$int_label}
- {const_value 1 DW_FORM_data1}
+ DW_AT_name x
+ DW_AT_type :$int_label
+ DW_AT_const_value 1 DW_FORM_data1
}
i_foo_label: subprogram {
- {name foo}
- {external 1 flag_present}
- {declaration 1 flag_present}
+ DW_AT_name foo
+ DW_AT_external 1 flag_present
+ DW_AT_declaration 1 flag_present
}
}
OuterInner_label: imported_declaration {
- {name Inner}
- {import :$inner_label}
+ DW_AT_name Inner
+ DW_AT_import :$inner_label
}
DW_TAG_variable {
- {name x}
- {type :$int_label}
- {const_value 0 DW_FORM_data1}
+ DW_AT_name x
+ DW_AT_type :$int_label
+ DW_AT_const_value 0 DW_FORM_data1
}
o_foo_label: subprogram {
- {name foo}
- {external 1 flag_present}
- {declaration 1 flag_present}
+ DW_AT_name foo
+ DW_AT_external 1 flag_present
+ DW_AT_declaration 1 flag_present
}
}
imported_declaration {
- {name Outer}
- {import :$outer_label}
+ DW_AT_name Outer
+ DW_AT_import :$outer_label
}
oi1_label: imported_declaration {
- {name oi1}
- {import :$OuterInner_label}
+ DW_AT_name oi1
+ DW_AT_import :$OuterInner_label
}
oi2_label: imported_declaration {
- {name oi2}
- {import :$oi1_label}
+ DW_AT_name oi2
+ DW_AT_import :$oi1_label
}
imported_declaration {
- {name oi3}
- {import :$oi2_label}
+ DW_AT_name oi3
+ DW_AT_import :$oi2_label
}
subprogram {
- {specification :$im_foo_label}
- {low_pc 0x4 DW_FORM_addr}
- {high_pc 0x7 DW_FORM_addr}
+ DW_AT_specification :$im_foo_label
+ DW_AT_low_pc 0x4 DW_FORM_addr
+ DW_AT_high_pc 0x7 DW_FORM_addr
}
subprogram {
- {specification :$i_foo_label}
- {low_pc 0x8 DW_FORM_addr}
- {high_pc 0xb DW_FORM_addr}
+ DW_AT_specification :$i_foo_label
+ DW_AT_low_pc 0x8 DW_FORM_addr
+ DW_AT_high_pc 0xb DW_FORM_addr
}
subprogram {
- {specification :$o_foo_label}
- {low_pc 0xc DW_FORM_addr}
- {high_pc 0xf DW_FORM_addr}
+ DW_AT_specification :$o_foo_label
+ DW_AT_low_pc 0xc DW_FORM_addr
+ DW_AT_high_pc 0xf DW_FORM_addr
}
}
}
@@ -253,19 +255,19 @@ set imports {
declare_labels n0_label
n0_label: DW_TAG_namespace {
- {name n0}
+ DW_AT_name n0
} {
DW_TAG_variable {
- {name x}
- {type :$int_label}
- {const_value 3 DW_FORM_data1}
+ DW_AT_name x
+ DW_AT_type :$int_label
+ DW_AT_const_value 3 DW_FORM_data1
}
}
declare_labels n0_import
n0_import: imported_declaration {
- {name N0}
- {import :$n0_label}
+ DW_AT_name N0
+ DW_AT_import :$n0_label
}
}
@@ -273,8 +275,8 @@ for {set i 1} {$i <= 100} {incr i} {
append imports [format "
declare_labels n%d_import
n%d_import: imported_declaration {
- {name N%d}
- {import :\$n%d_import}
+ DW_AT_name N%d
+ DW_AT_import :\$n%d_import
}" $i $i $i [expr {$i - 1}]]
}
@@ -283,13 +285,15 @@ standard_testfile .cc nsalias-r-dw.S
set asm_file [standard_output_file $srcfile2]
set the_dwarf [format {
cu {} {
- compile_unit {{language @DW_LANG_C_plus_plus}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C_plus_plus
+ } {
declare_labels int_label n0_label
int_label: base_type {
- {name int}
- {encoding @DW_ATE_signed}
- {byte_size 4 DW_FORM_sdata}
+ DW_AT_name int
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 4 DW_FORM_sdata
}
%s
diff --git a/gdb/testsuite/gdb.cp/pr10728.exp b/gdb/testsuite/gdb.cp/pr10728.exp
index 0525ac1..8201e24 100644
--- a/gdb/testsuite/gdb.cp/pr10728.exp
+++ b/gdb/testsuite/gdb.cp/pr10728.exp
@@ -42,7 +42,7 @@ if { [gdb_compile "${tfx}.o ${tfy}.o" ${binfile} executable {debug c++}] != ""
return -1
}
-clean_restart $binfile
+clean_restart $::testfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.cp/print-global-stub.exp b/gdb/testsuite/gdb.cp/print-global-stub.exp
index 139e8b1..d847c00 100644
--- a/gdb/testsuite/gdb.cp/print-global-stub.exp
+++ b/gdb/testsuite/gdb.cp/print-global-stub.exp
@@ -19,14 +19,15 @@
require allow_cplus_tests
standard_testfile .cc
-set objfile [standard_output_file ${testfile}.o]
+set testfile $testfile.o
+set binfile [standard_output_file $testfile]
-if { [gdb_compile $srcdir/$subdir/$srcfile $objfile object \
+if { [gdb_compile $srcdir/$subdir/$srcfile $binfile object \
{c++ debug}] != "" } {
untested "failed to compile"
return -1
}
-clean_restart $objfile
+clean_restart $testfile
gdb_test "print s" " = <incomplete type>"
diff --git a/gdb/testsuite/gdb.cp/psmang.exp b/gdb/testsuite/gdb.cp/psmang.exp
index acc7b3b..67bc9cd9 100644
--- a/gdb/testsuite/gdb.cp/psmang.exp
+++ b/gdb/testsuite/gdb.cp/psmang.exp
@@ -190,6 +190,6 @@ gdb_test "break s::method1" "Breakpoint .* at .*: file .*psmang1.cc.*"
# We have to exit and restart GDB here, to make sure that all the
# compilation units are psymtabs again.
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_test "break s::method2" "Breakpoint .* at .*: file .*psmang2.cc.*"
diff --git a/gdb/testsuite/gdb.cp/ref-params.exp b/gdb/testsuite/gdb.cp/ref-params.exp
index 97a56ab..4f2cbb5 100644
--- a/gdb/testsuite/gdb.cp/ref-params.exp
+++ b/gdb/testsuite/gdb.cp/ref-params.exp
@@ -32,7 +32,7 @@ proc gdb_start_again { text } {
global binfile
global srcfile
- clean_restart $binfile
+ clean_restart $::testfile
runto ${srcfile}:[gdb_get_line_number $text]
}
diff --git a/gdb/testsuite/gdb.cp/rvalue-ref-params.exp b/gdb/testsuite/gdb.cp/rvalue-ref-params.exp
index 8a5e66f..267dbc7 100644
--- a/gdb/testsuite/gdb.cp/rvalue-ref-params.exp
+++ b/gdb/testsuite/gdb.cp/rvalue-ref-params.exp
@@ -30,7 +30,7 @@ proc gdb_start_again {text prefix} {
global srcfile
with_test_prefix $prefix {
- clean_restart $binfile
+ clean_restart $::testfile
runto ${srcfile}:[gdb_get_line_number $text]
}
diff --git a/gdb/testsuite/gdb.ctf/cross-tu-cyclic.exp b/gdb/testsuite/gdb.ctf/cross-tu-cyclic.exp
index 922729f..2a0e999 100644
--- a/gdb/testsuite/gdb.ctf/cross-tu-cyclic.exp
+++ b/gdb/testsuite/gdb.ctf/cross-tu-cyclic.exp
@@ -37,6 +37,6 @@ gdb_test_no_output "set always-read-ctf on"
gdb_load $binfile
# Same thing with struct and union.
-gdb_test "ptype struct A" "type = struct A \{\[\r\n\]+\[ \t\]+struct B \\*foo;\[\r\n\]+\}.*" "ptype structure A"
-gdb_test "ptype struct B" "type = struct B \{\[\r\n\]+\[ \t\]+struct B \\*next;\[\r\n\]+\}.*" "ptype structure B"
+gdb_test "ptype struct A" "type = struct A \{\[\r\n\]+\[ \t\]+long a;\[\r\n\]+\[ \t\]+struct B \\*foo;\[\r\n\]+\}.*" "ptype structure A"
+gdb_test "ptype struct B" "type = struct B \{\[\r\n\]+\[ \t\]+int foo;\[\r\n\]+\[ \t\]+struct A \\*bar;\[\r\n\]+\}.*" "ptype structure B"
gdb_test "ptype struct C" "type = struct C \{\[\r\n\]+\[ \t\]+struct B \\*foo;\[\r\n\]+\[ \t\]+int b;\[\r\n\]+\}.*" "ptype structure C"
diff --git a/gdb/testsuite/gdb.ctf/funcreturn.exp b/gdb/testsuite/gdb.ctf/funcreturn.exp
index 4d13531..55ee969 100644
--- a/gdb/testsuite/gdb.ctf/funcreturn.exp
+++ b/gdb/testsuite/gdb.ctf/funcreturn.exp
@@ -15,7 +15,7 @@
require allow_ctf_tests
-if [target_info exists no_long_long] {
+if {[target_info exists no_long_long]} {
set exec_opts [list debug additional_flags=-DNO_LONG_LONG]
} else {
set exec_opts [list debug]
@@ -91,7 +91,7 @@ gdb_test "print v_unsigned_long_func" \
"$decimal = \{unsigned long|long \\(\\)\} 0x\[0-9a-z\]+ <v_unsigned_long_func>.*" \
"print unsigned long function"
-if ![target_info exists no_long_long] {
+if {![target_info exists no_long_long]} {
gdb_test "print v_long_long_func" \
"$decimal = \{long long \\(\\)\} 0x\[0-9a-z\]+ <v_long_long_func>.*" \
"print long long function"
@@ -164,7 +164,7 @@ gdb_test "whatis v_unsigned_long_func" \
"type = (unsigned (int|long|long int)|long unsigned int) \\($void\\)" \
"whatis unsigned long function"
-if ![target_info exists no_long_long] {
+if {![target_info exists no_long_long]} {
gdb_test "whatis v_long_long_func" \
"type = long long(| int) \\($void\\)" \
"whatis long long function"
diff --git a/gdb/testsuite/gdb.dap/attach-fail.exp b/gdb/testsuite/gdb.dap/attach-fail.exp
new file mode 100644
index 0000000..8992f62
--- /dev/null
+++ b/gdb/testsuite/gdb.dap/attach-fail.exp
@@ -0,0 +1,32 @@
+# Copyright 2025 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 "attach" failure in DAP.
+
+require can_spawn_for_attach allow_dap_tests
+
+load_lib dap-support.exp
+
+# Passing an empty remote name here will guarantee a failure without
+# trying to find a real remote.
+set id [dap_target_remote {""}]
+
+dap_check_request_and_response "configurationDone" configurationDone
+
+set resp [lindex [dap_read_response attach $id] 0]
+gdb_assert {[dict get $resp success] == "false"} \
+ "attach failed"
+
+dap_shutdown
diff --git a/gdb/testsuite/gdb.dap/bt-nodebug.exp b/gdb/testsuite/gdb.dap/bt-nodebug.exp
index 3053f8c..8188a98 100644
--- a/gdb/testsuite/gdb.dap/bt-nodebug.exp
+++ b/gdb/testsuite/gdb.dap/bt-nodebug.exp
@@ -71,6 +71,7 @@ gdb_assert {[dict exists [lindex $breakpoints 0] instructionReference]} \
# slipped in that caused this to be incorrect, so we test both parts
# here; to test whether a string was given, we have to reach into the
# TON form.
+# tclint-disable-next-line command-args
set list_form [namespace eval ton::2list $last_ton]
set ref [namespace eval ton::2list {
get $list_form body breakpoints 0 instructionReference
diff --git a/gdb/testsuite/gdb.dap/catch-exception.exp b/gdb/testsuite/gdb.dap/catch-exception.exp
index ced2cc5..0e8c27a 100644
--- a/gdb/testsuite/gdb.dap/catch-exception.exp
+++ b/gdb/testsuite/gdb.dap/catch-exception.exp
@@ -35,7 +35,7 @@ set obj [dap_check_request_and_response "set exception catchpoints" \
setExceptionBreakpoints \
{o filters [a [s nosuchfilter] [s assert]] \
filterOptions [a [o filterId [s exception] \
- condition [s "Global_Var = 23"]]]}]
+ condition [s program_error]]]}]
set bps [dict get [lindex $obj 0] body breakpoints]
# We should get three responses, because we requested three
@@ -77,6 +77,20 @@ dap_wait_for_event_and_check "stopped at first raise" stopped \
"body reason" breakpoint \
"body hitBreakpointIds" 2
+set found_line -1
+set line [gdb_get_line_number "EXPECTED" $testdir/prog.adb]
+set bt [lindex [dap_check_request_and_response "backtrace" stackTrace \
+ {o threadId [i 1]}] \
+ 0]
+foreach frame [dict get $bt body stackFrames] {
+ if {[dict exists $frame source path]
+ && [file tail [dict get $frame source path]] == "prog.adb"} {
+ set found_line [dict get $frame line]
+ }
+}
+
+gdb_assert {$found_line == $line} "stopped at correct raise"
+
dap_check_request_and_response "continue to assert" continue \
{o threadId [i 1]}
dap_wait_for_event_and_check "stopped at assert" stopped \
diff --git a/gdb/testsuite/gdb.dap/catch-exception/prog.adb b/gdb/testsuite/gdb.dap/catch-exception/prog.adb
index ed60272..7a5a31d 100644
--- a/gdb/testsuite/gdb.dap/catch-exception/prog.adb
+++ b/gdb/testsuite/gdb.dap/catch-exception/prog.adb
@@ -19,15 +19,14 @@ procedure Prog is
begin
begin
- raise Program_Error;
+ raise Constraint_Error;
exception
when others =>
null;
end;
begin
- Global_Var := 23;
- raise Program_Error;
+ raise Program_Error; -- EXPECTED
exception
when others =>
null;
diff --git a/gdb/testsuite/gdb.dap/eof.exp b/gdb/testsuite/gdb.dap/eof.exp
index 4752347..5c709ed 100644
--- a/gdb/testsuite/gdb.dap/eof.exp
+++ b/gdb/testsuite/gdb.dap/eof.exp
@@ -30,8 +30,10 @@ if {[dap_initialize] == ""} {
return
}
-catch "close -i $gdb_spawn_id"
-catch "wait -i $gdb_spawn_id"
+# Expect support is missing ( https://github.com/nmoroze/tclint/issues/118 ).
+# tclint-disable-next-line command-args
+catch {close -i $gdb_spawn_id}
+catch {wait -i $gdb_spawn_id}
unset gdb_spawn_id
dap_check_log_file
diff --git a/gdb/testsuite/gdb.dap/scopes.c b/gdb/testsuite/gdb.dap/scopes.c
index d8929f1..2a1d76c 100644
--- a/gdb/testsuite/gdb.dap/scopes.c
+++ b/gdb/testsuite/gdb.dap/scopes.c
@@ -27,6 +27,8 @@ int main ()
static int scalar = 23;
+ void *ptr = (void *) &scalar;
+
{
const char *inner = "inner block";
diff --git a/gdb/testsuite/gdb.dap/scopes.exp b/gdb/testsuite/gdb.dap/scopes.exp
index 59d344b..52efa68 100644
--- a/gdb/testsuite/gdb.dap/scopes.exp
+++ b/gdb/testsuite/gdb.dap/scopes.exp
@@ -70,7 +70,8 @@ lassign $scopes scope reg_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] == 3} "three vars in scope"
+set count [dict get $scope namedVariables]
+gdb_assert {$count == 4} "four vars in scope"
gdb_assert {[dict get $reg_scope name] == "Registers"} \
"second scope is registers"
@@ -89,8 +90,8 @@ set refs1 [lindex [dap_check_request_and_response "fetch variables 0,1" \
set refs2 [lindex [dap_check_request_and_response "fetch variables 2" \
"variables" \
[format {o variablesReference [i %d] \
- start [i 2] count [i 1]} \
- $num]] \
+ start [i 2] count [i %d]} \
+ $num [expr {$count - 2}]]] \
0]
set vars [concat [dict get $refs1 body variables] \
@@ -115,6 +116,10 @@ foreach var $vars {
"scalar" {
gdb_assert {[dict get $var value] == 23} "check value of scalar"
}
+ "ptr" {
+ gdb_assert {[dict get $var memoryReference] != ""} \
+ "check memoryReference of ptr"
+ }
default {
fail "unknown variable $name"
}
@@ -128,11 +133,38 @@ set refs [lindex [dap_check_request_and_response "fetch contents of dei" \
set deivals [dict get $refs body variables]
gdb_assert {[llength $deivals] == 2} "dei has two members"
+# Request more children than exist. See PR dap/33228.
+set seq [dap_send_request variables \
+ [format {o variablesReference [i %d] count [i 100]} $dei_ref]]
+lassign [dap_read_response variables $seq] response ignore
+gdb_assert {[dict get $response success] == "false"} \
+ "variables with invalid count"
+
set num [dict get $reg_scope variablesReference]
-# The request succeeding is sufficient.
-set val [dap_check_request_and_response "fetch first register" \
+lassign [dap_check_request_and_response "fetch all registers" \
"variables" \
- [format {o variablesReference [i %d] count [i 1]} $num]]
+ [format {o variablesReference [i %d] count [i %d]} $num\
+ [dict get $reg_scope namedVariables]]] \
+ val events
+
+# If any register has children, try to fetch those as well. This is a
+# regression test for part of PR dap/33228.
+foreach var [dict get $val body variables] {
+ set regvar [dict get $var variablesReference]
+ if {$regvar > 0} {
+ # If variablesReference is non-zero, then there must be either
+ # named or indexed children.
+ if {[dict exists $var namedVariables]} {
+ set n [dict get $var namedVariables]
+ } else {
+ set n [dict get $var indexedVariables]
+ }
+
+ dap_check_request_and_response "fetch register children for $regvar" \
+ "variables" \
+ [format {o variablesReference [i %d] count [i %d]} $regvar $n]
+ }
+}
set num [dict get $scope variablesReference]
set refs [lindex [dap_check_request_and_response "set variable scalar" \
diff --git a/gdb/testsuite/gdb.debuginfod/corefile-mapped-file.exp b/gdb/testsuite/gdb.debuginfod/corefile-mapped-file.exp
index dac4e6c..c85cfb1 100644
--- a/gdb/testsuite/gdb.debuginfod/corefile-mapped-file.exp
+++ b/gdb/testsuite/gdb.debuginfod/corefile-mapped-file.exp
@@ -69,14 +69,15 @@ standard_testfile -1.c -2.c -3.c
# shared library, then use GDB to figure out the offset of the
# variable 'library_ptr' within the library.
set library_filename [standard_output_file "libfoo.so"]
-set binfile2 [standard_output_file "library_loader"]
+set testfile2 "library_loader"
+set binfile2 [standard_output_file $testfile2]
if {[prepare_for_testing_full "build exec which loads the shared library" \
[list $library_filename \
{ debug shlib build-id \
additional_flags=-DPOINTER_VALUE=0x12345678 } \
$srcfile2 {}] \
- [list $binfile2 [list debug shlib=$library_filename ] \
+ [list $testfile2 [list debug shlib=$library_filename ] \
$srcfile { debug }]] != 0} {
return
}
@@ -160,7 +161,7 @@ if { $ptr_expected_value eq "" } {
# Load this executable within GDB and confirm that we can use the
# offset we calculated previously to view the value of 'library_ptr'.
set opts [list debug additional_flags=-DSHLIB_FILENAME=\"$library_filename\"]
-if {[prepare_for_testing "prepare second executable" $binfile \
+if {[prepare_for_testing "prepare second executable" $testfile \
$srcfile3 $opts] != 0} {
return
}
@@ -174,7 +175,7 @@ gdb_continue_to_breakpoint "run to breakpoint"
set library_base_address \
[get_hexadecimal_valueof "library_base_address" "unknown"]
-set ptr_address [format 0x%x [expr $library_base_address + $ptr_offset]]
+set ptr_address [format 0x%x [expr {$library_base_address + $ptr_offset}]]
set ptr_value [read_ptr_value]
gdb_assert { $ptr_value == $ptr_expected_value } \
@@ -268,13 +269,13 @@ proc load_core_file { testname { line_re "" } } {
# And now restart GDB, load the core-file and check that the library shows as
# being mapped in, and that we can still read the library_ptr value from
# memory.
-clean_restart $binfile
+clean_restart $::testfile
load_core_file "load core file"
set library_base_address [get_hexadecimal_valueof "library_base_address" \
"unknown" "get library_base_address in core-file"]
-set ptr_address [format 0x%x [expr $library_base_address + $ptr_offset]]
+set ptr_address [format 0x%x [expr {$library_base_address + $ptr_offset}]]
set ptr_value [read_ptr_value]
gdb_assert { $ptr_value == $ptr_expected_value } \
@@ -287,7 +288,7 @@ gdb_assert { $ptr_value == $ptr_expected_value } \
set library_backup_filename [standard_output_file "libfoo.so.backup"]
remote_exec build "mv \"$library_filename\" \"$library_backup_filename\""
-clean_restart $binfile
+clean_restart $::testfile
load_core_file "load corefile with library file missing" \
"warning: Can't open file [string_to_regexp $library_filename] during file-backed mapping note processing"
@@ -309,7 +310,7 @@ set build_id_filename \
remote_exec build "mkdir -p [file dirname $build_id_filename]"
remote_exec build "ln -sf $library_backup_filename $build_id_filename"
-clean_restart $binfile
+clean_restart $::testfile
gdb_test_no_output "set debug-file-directory $debugdir" \
"set debug-file-directory"
@@ -331,7 +332,7 @@ if {[build_executable "build second version of shared library" \
return
}
-clean_restart $binfile
+clean_restart $::testfile
load_core_file "load corefile with wrong library in place" \
"warning: File [string_to_regexp $library_filename] doesn't match build-id from core-file during file-backed mapping processing"
diff --git a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
index 4b3894e..292be70 100644
--- a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
+++ b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp
@@ -56,7 +56,7 @@ proc write_just_debugaltlink {filename dwzname buildid} {
# Only the DWARF reader checks .gnu_debugaltlink, so make sure
# there is a bit of DWARF in here.
cu {} {
- compile_unit {{language @DW_LANG_C}} {
+ compile_unit {DW_AT_language @DW_LANG_C} {
}
}
}
@@ -76,17 +76,19 @@ proc write_dwarf_file {filename buildid {value 99}} {
build_id $buildid
cu {} {
- compile_unit {{language @DW_LANG_C}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C
+ } {
int_label2: base_type {
- {name int}
- {byte_size 4 sdata}
- {encoding @DW_ATE_signed}
+ DW_AT_name int
+ DW_AT_byte_size 4 sdata
+ DW_AT_encoding @DW_ATE_signed
}
constant {
- {name the_int}
- {type :$int_label2}
- {const_value $value data1}
+ DW_AT_name the_int
+ DW_AT_type :$int_label2
+ DW_AT_const_value $value data1
}
}
}
@@ -107,7 +109,7 @@ proc_with_prefix no_url { } {
setenv DEBUGINFOD_URLS ""
# Test that GDB cannot find source without debuginfod.
- clean_restart $binfile
+ clean_restart $::testfile
gdb_test_no_output "set substitute-path $outputdir /dev/null" \
"set substitute-path"
gdb_test "list" ".*No such file or directory.*"
@@ -126,7 +128,7 @@ proc_with_prefix no_url { } {
file rename -force $debuginfo $debugdir
# Test that GDB cannot find symbols without debuginfod.
- clean_restart $binfile
+ clean_restart $::testfile
gdb_test "file" ".*No symbol file.*"
set buildid "01234567890abcdef0123456"
@@ -157,7 +159,7 @@ proc_with_prefix no_url { } {
# Generate a core file and test that GDB cannot find the
# executable.
- clean_restart ${binfile}2
+ clean_restart ${::testfile}2
if ![runto_main] {
return -1
}
diff --git a/gdb/testsuite/gdb.debuginfod/solib-with-soname.exp b/gdb/testsuite/gdb.debuginfod/solib-with-soname.exp
index 1008e46..67d9237 100644
--- a/gdb/testsuite/gdb.debuginfod/solib-with-soname.exp
+++ b/gdb/testsuite/gdb.debuginfod/solib-with-soname.exp
@@ -132,7 +132,7 @@ if {$corefile eq ""} {
proc load_exec_and_core_file { expect_warning expect_download testname \
{debugdir ""} } {
with_test_prefix $testname {
- clean_restart $::binfile
+ clean_restart $::testfile
if { $debugdir ne "" } {
gdb_test_no_output "set debug-file-directory $debugdir" \
diff --git a/gdb/testsuite/gdb.disasm/am33.exp b/gdb/testsuite/gdb.disasm/am33.exp
index b5ae981..7515da1 100644
--- a/gdb/testsuite/gdb.disasm/am33.exp
+++ b/gdb/testsuite/gdb.disasm/am33.exp
@@ -795,7 +795,7 @@ proc dsp_autoincrement_tests { } {
}
}
-clean_restart $binfile
+clean_restart $::testfile
call_tests
movm_tests
diff --git a/gdb/testsuite/gdb.disasm/basics.exp b/gdb/testsuite/gdb.disasm/basics.exp
index e54dced..9be9945 100644
--- a/gdb/testsuite/gdb.disasm/basics.exp
+++ b/gdb/testsuite/gdb.disasm/basics.exp
@@ -22,7 +22,7 @@ if { [prepare_for_testing "failed to prepare" $testfile ${srcfile}] == -1 } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.disasm/hppa.exp b/gdb/testsuite/gdb.disasm/hppa.exp
index e330809..10b5cb5 100644
--- a/gdb/testsuite/gdb.disasm/hppa.exp
+++ b/gdb/testsuite/gdb.disasm/hppa.exp
@@ -23,7 +23,7 @@ set srcfile ${srcdir}/${subdir}/${testfile}.s
set binfile ${objdir}/${subdir}/${testfile}
set comp_output [gdb_compile "${srcfile}" "${binfile}" executable ""]
if { $comp_output != "" } {
- if [ regexp "Opcode not defined - DIAG" $comp_output] {
+ if {[regexp "Opcode not defined - DIAG" $comp_output]} {
warning "HP assembler in use--skipping disasm tests"
return
} else {
@@ -686,7 +686,7 @@ proc all_integer_computational_tests { } {
}
}
- set subi_insns [list {subi} {subio} {comiclr} ]
+ set subi_insns [list {subi} {subio} {comiclr}]
foreach i $subi_insns {
send_gdb "x/16i $i"; send_gdb "_tests\n"
@@ -746,7 +746,7 @@ proc all_integer_computational_tests { } {
timeout { fail "(timeout) "shd tests" }
}
- set extract_insns1 [list {extru} {extrs} {zdep} {dep} ]
+ set extract_insns1 [list {extru} {extrs} {zdep} {dep}]
foreach i $extract_insns1 {
send_gdb "x/8i $i"; send_gdb "_tests\n"
@@ -766,7 +766,7 @@ proc all_integer_computational_tests { } {
}
}
- set extract_insns2 [list {vextru} {vextrs} {zvdep} {vdep} ]
+ set extract_insns2 [list {vextru} {vextrs} {zvdep} {vdep}]
foreach i $extract_insns2 {
send_gdb "x/8i $i"; send_gdb "_tests\n"
@@ -786,7 +786,7 @@ proc all_integer_computational_tests { } {
}
}
- set extract_insns3 [list {vdepi} {zvdepi} ]
+ set extract_insns3 [list {vdepi} {zvdepi}]
foreach i $extract_insns3 {
send_gdb "x/8i $i"; send_gdb "_tests\n"
@@ -806,7 +806,7 @@ proc all_integer_computational_tests { } {
}
}
- set extract_insns4 [list {depi} {zdepi} ]
+ set extract_insns4 [list {depi} {zdepi}]
foreach i $extract_insns4 {
send_gdb "x/8i $i"; send_gdb "_tests\n"
@@ -1365,7 +1365,7 @@ proc fmemLRbug_tests { } {
}
}
-clean_restart $binfile
+clean_restart $::testfile
all_integer_memory_tests
all_immediate_tests
diff --git a/gdb/testsuite/gdb.disasm/mn10300.exp b/gdb/testsuite/gdb.disasm/mn10300.exp
index 55ce96c..74e7c7c 100644
--- a/gdb/testsuite/gdb.disasm/mn10300.exp
+++ b/gdb/testsuite/gdb.disasm/mn10300.exp
@@ -529,7 +529,7 @@ proc sub_tests { } {
}
}
-clean_restart $binfile
+clean_restart $::testfile
add_tests
bcc_tests
diff --git a/gdb/testsuite/gdb.disasm/sh3.exp b/gdb/testsuite/gdb.disasm/sh3.exp
index 09b27a0..fc591a7 100644
--- a/gdb/testsuite/gdb.disasm/sh3.exp
+++ b/gdb/testsuite/gdb.disasm/sh3.exp
@@ -100,7 +100,7 @@ proc all_fp_misc_tests { } {
}
}
-clean_restart $binfile
+clean_restart $::testfile
all_fp_move_and_load_tests
all_fp_arithmetic_tests
diff --git a/gdb/testsuite/gdb.dlang/circular.exp b/gdb/testsuite/gdb.dlang/circular.exp
index e318945..cc79062 100644
--- a/gdb/testsuite/gdb.dlang/circular.exp
+++ b/gdb/testsuite/gdb.dlang/circular.exp
@@ -27,98 +27,98 @@ set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_D}
+ DW_AT_language @DW_LANG_D
} {
declare_labels circular1_label circular2_label circular3_label
declare_labels circular4_label circular5_label
circular1_label: module {
- {name circular1}
+ DW_AT_name circular1
} {
imported_module {
- {import :$circular2_label}
+ DW_AT_import :$circular2_label
}
imported_module {
- {import :$circular3_label}
+ DW_AT_import :$circular3_label
}
imported_module {
- {import :$circular4_label}
+ DW_AT_import :$circular4_label
}
imported_module {
- {import :$circular5_label}
+ DW_AT_import :$circular5_label
}
subprogram {
- {external 1 flag_present}
- {MACRO_AT_func {found}}
+ DW_AT_external 1 flag_present
+ MACRO_AT_func {found}
}
}
circular2_label: module {
- {name circular2}
+ DW_AT_name circular2
} {
imported_module {
- {import :$circular1_label}
+ DW_AT_import :$circular1_label
}
imported_module {
- {import :$circular3_label}
+ DW_AT_import :$circular3_label
}
imported_module {
- {import :$circular4_label}
+ DW_AT_import :$circular4_label
}
imported_module {
- {import :$circular5_label}
+ DW_AT_import :$circular5_label
}
}
circular3_label: module {
- {name circular3}
+ DW_AT_name circular3
} {
imported_module {
- {import :$circular1_label}
+ DW_AT_import :$circular1_label
}
imported_module {
- {import :$circular2_label}
+ DW_AT_import :$circular2_label
}
imported_module {
- {import :$circular4_label}
+ DW_AT_import :$circular4_label
}
imported_module {
- {import :$circular5_label}
+ DW_AT_import :$circular5_label
}
}
circular4_label: module {
- {name circular4}
+ DW_AT_name circular4
} {
imported_module {
- {import :$circular1_label}
+ DW_AT_import :$circular1_label
}
imported_module {
- {import :$circular2_label}
+ DW_AT_import :$circular2_label
}
imported_module {
- {import :$circular3_label}
+ DW_AT_import :$circular3_label
}
imported_module {
- {import :$circular5_label}
+ DW_AT_import :$circular5_label
}
}
circular5_label: module {
- {name circular5}
+ DW_AT_name circular5
} {
imported_module {
- {import :$circular1_label}
+ DW_AT_import :$circular1_label
}
imported_module {
- {import :$circular2_label}
+ DW_AT_import :$circular2_label
}
imported_module {
- {import :$circular3_label}
+ DW_AT_import :$circular3_label
}
imported_module {
- {import :$circular4_label}
+ DW_AT_import :$circular4_label
}
}
}
diff --git a/gdb/testsuite/gdb.dlang/demangle.exp b/gdb/testsuite/gdb.dlang/demangle.exp
index 75c2f79..4181513 100644
--- a/gdb/testsuite/gdb.dlang/demangle.exp
+++ b/gdb/testsuite/gdb.dlang/demangle.exp
@@ -197,7 +197,7 @@ proc test_d_demangling {} {
clean_restart
-if [set_lang_d] {
+if {[set_lang_d]} {
gdb_test_no_output "set width 0"
test_d_demangling
diff --git a/gdb/testsuite/gdb.dlang/dlang-start-2.exp b/gdb/testsuite/gdb.dlang/dlang-start-2.exp
index 403dcfd..b5c0542 100644
--- a/gdb/testsuite/gdb.dlang/dlang-start-2.exp
+++ b/gdb/testsuite/gdb.dlang/dlang-start-2.exp
@@ -40,24 +40,24 @@ Dwarf::assemble $asm_file {
cu { label cu_start } {
compile_unit {
- {language @DW_LANG_D}
+ DW_AT_language @DW_LANG_D
} {
module {
- {name dmain}
+ DW_AT_name dmain
}
subprogram {
- {name "D main" }
- {MIPS_linkage_name "_Dmain"}
- {low_pc $dmain_start DW_FORM_addr}
- {high_pc "$dmain_start + $dmain_length" DW_FORM_addr}
- {external 1 flag_present}
+ DW_AT_name "D main"
+ DW_AT_MIPS_linkage_name "_Dmain"
+ DW_AT_low_pc $dmain_start DW_FORM_addr
+ DW_AT_high_pc "$dmain_start + $dmain_length" DW_FORM_addr
+ DW_AT_external 1 flag_present
}
subprogram {
- {name "dmain._d_cmain!().main" }
- {MIPS_linkage_name "main"}
- {low_pc $main_start DW_FORM_addr}
- {high_pc "$main_start + $main_length" DW_FORM_addr}
- {external 1 flag_present}
+ DW_AT_name "dmain._d_cmain!().main"
+ DW_AT_MIPS_linkage_name "main"
+ DW_AT_low_pc $main_start DW_FORM_addr
+ DW_AT_high_pc "$main_start + $main_length" DW_FORM_addr
+ DW_AT_external 1 flag_present
}
}
}
diff --git a/gdb/testsuite/gdb.dlang/expression.exp b/gdb/testsuite/gdb.dlang/expression.exp
index 0d22cee..6e611ed 100644
--- a/gdb/testsuite/gdb.dlang/expression.exp
+++ b/gdb/testsuite/gdb.dlang/expression.exp
@@ -129,7 +129,7 @@ proc test_d_expressions {} {
clean_restart
-if [set_lang_d] {
+if {[set_lang_d]} {
test_d_integer_literals
test_d_float_literals
test_d_expressions
diff --git a/gdb/testsuite/gdb.dlang/primitive-types.exp b/gdb/testsuite/gdb.dlang/primitive-types.exp
index 8e74520..9e6e8fa 100644
--- a/gdb/testsuite/gdb.dlang/primitive-types.exp
+++ b/gdb/testsuite/gdb.dlang/primitive-types.exp
@@ -51,7 +51,7 @@ proc test_builtin_d_types_accepted {} {
clean_restart
-if [set_lang_d] {
+if {[set_lang_d]} {
test_builtin_d_types_accepted
} else {
warning "D type tests suppressed."
diff --git a/gdb/testsuite/gdb.dlang/properties.exp b/gdb/testsuite/gdb.dlang/properties.exp
index 0fe18a5..d0266f8 100644
--- a/gdb/testsuite/gdb.dlang/properties.exp
+++ b/gdb/testsuite/gdb.dlang/properties.exp
@@ -82,7 +82,7 @@ proc test_d_typeof {} {
clean_restart
-if [set_lang_d] {
+if {[set_lang_d]} {
test_d_sizeof
test_d_typeof
} else {
diff --git a/gdb/testsuite/gdb.dlang/watch-loc.exp b/gdb/testsuite/gdb.dlang/watch-loc.exp
index ec50e91..7cfc539 100644
--- a/gdb/testsuite/gdb.dlang/watch-loc.exp
+++ b/gdb/testsuite/gdb.dlang/watch-loc.exp
@@ -33,30 +33,30 @@ Dwarf::assemble $asm_file {
cu { label cu_start } {
compile_unit {
- {language @DW_LANG_D}
+ DW_AT_language @DW_LANG_D
} {
declare_labels watch_module_label watch_struct_label
watch_module_label: module {
- {name watch}
+ DW_AT_name watch
} {
watch_struct_label: structure_type {
- {name tstruct}
- {byte_size 1 data1}
+ DW_AT_name tstruct
+ DW_AT_byte_size 1 data1
}
tag_variable {
- {name my_data}
- {type :$watch_struct_label}
- {location {
+ DW_AT_name my_data
+ DW_AT_type :$watch_struct_label
+ DW_AT_location [subst {
addr [gdb_target_symbol my_data]
- } SPECIAL_expr}
- {external 1 flag}
+ }] SPECIAL_expr
+ DW_AT_external 1 flag
}
subprogram {
- {MACRO_AT_func { "_Dmain" }}
- {external 1 flag_present}
+ MACRO_AT_func { "_Dmain" }
+ DW_AT_external 1 flag_present
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/DW_OP_piece_with_DW_OP_GNU_uninit.exp b/gdb/testsuite/gdb.dwarf2/DW_OP_piece_with_DW_OP_GNU_uninit.exp
index 6735207..291bc83 100644
--- a/gdb/testsuite/gdb.dwarf2/DW_OP_piece_with_DW_OP_GNU_uninit.exp
+++ b/gdb/testsuite/gdb.dwarf2/DW_OP_piece_with_DW_OP_GNU_uninit.exp
@@ -35,37 +35,37 @@ Dwarf::assemble $asm_file {
declare_labels i64_type i32_type
i64_type: base_type {
- {name "int64_t"}
- {encoding @DW_ATE_signed}
- {byte_size 8 DW_FORM_sdata}
+ DW_AT_name "int64_t"
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 8 DW_FORM_sdata
}
i32_type: base_type {
- {name "int32_t"}
- {encoding @DW_ATE_signed}
- {byte_size 4 DW_FORM_sdata}
+ DW_AT_name "int32_t"
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 4 DW_FORM_sdata
}
DW_TAG_variable {
- {name i64_var}
- {type :$i64_type}
- {location {
+ DW_AT_name i64_var
+ DW_AT_type :$i64_type
+ DW_AT_location [subst {
DW_OP_constu $::c64
DW_OP_stack_value
DW_OP_GNU_uninit
DW_OP_piece 8
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
DW_TAG_variable {
- {name i32_var}
- {type :$i32_type}
- {location {
+ DW_AT_name i32_var
+ DW_AT_type :$i32_type
+ DW_AT_location [subst {
DW_OP_constu $::c32
DW_OP_stack_value
DW_OP_GNU_uninit
DW_OP_piece 4
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/ada-array-bound.exp b/gdb/testsuite/gdb.dwarf2/ada-array-bound.exp
index f48df7b..779ce00 100644
--- a/gdb/testsuite/gdb.dwarf2/ada-array-bound.exp
+++ b/gdb/testsuite/gdb.dwarf2/ada-array-bound.exp
@@ -31,49 +31,50 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_Ada95}
- {DW_AT_name $srcfile}
+ DW_AT_language @DW_LANG_Ada95
+ DW_AT_name $srcfile
} {
declare_labels byte array disc struct
byte: DW_TAG_base_type {
- {DW_AT_byte_size 1 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_unsigned}
- {DW_AT_name byte}
+ DW_AT_byte_size 1 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_unsigned
+ DW_AT_name byte
}
array: DW_TAG_array_type {
- {DW_AT_name array_type}
- {DW_AT_type :$byte}
+ DW_AT_name array_type
+ DW_AT_type :$byte
} {
DW_TAG_subrange_type {
- {DW_AT_type :$byte}
- {DW_AT_upper_bound :$disc}
+ DW_AT_type :$byte
+ DW_AT_upper_bound :$disc
}
}
struct: DW_TAG_structure_type {
- {DW_AT_name discriminated}
- {DW_AT_byte_size 4 DW_FORM_sdata}
+ DW_AT_name discriminated
+ DW_AT_byte_size 4 DW_FORM_sdata
} {
disc: DW_TAG_member {
- {DW_AT_name disc}
- {DW_AT_type :$byte}
- {DW_AT_data_member_location 0 DW_FORM_sdata}
+ DW_AT_name disc
+ DW_AT_type :$byte
+ DW_AT_data_member_location 0 DW_FORM_sdata
}
DW_TAG_member {
- {DW_AT_name nums}
- {DW_AT_type :$array}
- {DW_AT_data_member_location 1 DW_FORM_sdata}
+ DW_AT_name nums
+ DW_AT_type :$array
+ DW_AT_data_member_location 1 DW_FORM_sdata
}
}
DW_TAG_variable {
- {DW_AT_name "value"}
- {DW_AT_type :$struct}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "our_data"]}
- SPECIAL_expr}
+ DW_AT_name "value"
+ DW_AT_type :$struct
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location \
+ [subst {DW_OP_addr [gdb_target_symbol "our_data"]}] \
+ SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/ada-cold-name.exp b/gdb/testsuite/gdb.dwarf2/ada-cold-name.exp
index c5758c2..3520319 100644
--- a/gdb/testsuite/gdb.dwarf2/ada-cold-name.exp
+++ b/gdb/testsuite/gdb.dwarf2/ada-cold-name.exp
@@ -30,28 +30,28 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_Ada95}
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir /tmp}
+ DW_AT_language @DW_LANG_Ada95
+ DW_AT_name $srcfile
+ DW_AT_comp_dir /tmp
} {
declare_labels b_l
b_l: DW_TAG_base_type {
- {DW_AT_byte_size 1 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name bool}
+ DW_AT_byte_size 1 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name bool
}
DW_TAG_subprogram {
- {name pck__xtra__function.cold}
- {MACRO_AT_range {first}}
- {type :$b_l}
+ DW_AT_name pck__xtra__function.cold
+ MACRO_AT_range {first}
+ DW_AT_type :$b_l
}
DW_TAG_subprogram {
- {name pck__xtra__function}
- {MACRO_AT_range {second}}
- {type :$b_l}
+ DW_AT_name pck__xtra__function
+ MACRO_AT_range {second}
+ DW_AT_type :$b_l
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/ada-linkage-name.exp b/gdb/testsuite/gdb.dwarf2/ada-linkage-name.exp
index 9f2061c..915f47e 100644
--- a/gdb/testsuite/gdb.dwarf2/ada-linkage-name.exp
+++ b/gdb/testsuite/gdb.dwarf2/ada-linkage-name.exp
@@ -31,31 +31,31 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_Ada95}
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir /tmp}
+ DW_AT_language @DW_LANG_Ada95
+ DW_AT_name $srcfile
+ DW_AT_comp_dir /tmp
} {
declare_labels b_l
b_l: DW_TAG_base_type {
- {DW_AT_byte_size 1 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name bool}
+ DW_AT_byte_size 1 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name bool
}
# Here the name comes first and the linkage name second.
DW_TAG_subprogram {
- {name system__namefirst}
- {linkage_name __gnat_namefirst}
- {MACRO_AT_range {first}}
- {type :$b_l}
+ DW_AT_name system__namefirst
+ DW_AT_linkage_name __gnat_namefirst
+ MACRO_AT_range {first}
+ DW_AT_type :$b_l
}
# Here the linkage name comes first and the name second.
DW_TAG_subprogram {
- {linkage_name __gnat_namesecond}
- {name system__namesecond}
- {MACRO_AT_range {second}}
- {type :$b_l}
+ DW_AT_linkage_name __gnat_namesecond
+ DW_AT_name system__namesecond
+ MACRO_AT_range {second}
+ DW_AT_type :$b_l
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/ada-thick-pointer.exp b/gdb/testsuite/gdb.dwarf2/ada-thick-pointer.exp
index 5032252..0efb8cb 100644
--- a/gdb/testsuite/gdb.dwarf2/ada-thick-pointer.exp
+++ b/gdb/testsuite/gdb.dwarf2/ada-thick-pointer.exp
@@ -31,53 +31,53 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_Ada95}
- {DW_AT_name $srcfile}
+ DW_AT_language @DW_LANG_Ada95
+ DW_AT_name $srcfile
} {
declare_labels integer array array_pointer bounds_pointer
integer: DW_TAG_base_type {
- {DW_AT_byte_size 8 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
+ DW_AT_byte_size 8 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
}
array: DW_TAG_array_type {
- {DW_AT_name array_type}
- {DW_AT_type :$integer}
+ DW_AT_name array_type
+ DW_AT_type :$integer
} {
DW_TAG_subrange_type {
- {DW_AT_type :$integer}
- {DW_AT_lower_bound 1 DW_FORM_data1}
- {DW_AT_upper_bound 7 DW_FORM_data1}
+ DW_AT_type :$integer
+ DW_AT_lower_bound 1 DW_FORM_data1
+ DW_AT_upper_bound 7 DW_FORM_data1
}
}
array_pointer: DW_TAG_pointer_type {
- {DW_AT_type :$array}
- {DW_AT_byte_size 8 DW_FORM_sdata}
+ DW_AT_type :$array
+ DW_AT_byte_size 8 DW_FORM_sdata
}
# This isn't exactly what GNAT emits, but it doesn't
# matter.
bounds_pointer: DW_TAG_pointer_type {
- {DW_AT_type :$integer}
- {DW_AT_byte_size 8 DW_FORM_sdata}
+ DW_AT_type :$integer
+ DW_AT_byte_size 8 DW_FORM_sdata
}
DW_TAG_structure_type {
- {DW_AT_name thick_pointer_type}
- {DW_AT_byte_size 8 DW_FORM_sdata}
+ DW_AT_name thick_pointer_type
+ DW_AT_byte_size 8 DW_FORM_sdata
} {
DW_TAG_member {
- {DW_AT_name P_ARRAY}
- {DW_AT_type :$array_pointer}
- {DW_AT_data_member_location 0 DW_FORM_sdata}
+ DW_AT_name P_ARRAY
+ DW_AT_type :$array_pointer
+ DW_AT_data_member_location 0 DW_FORM_sdata
}
DW_TAG_member {
- {DW_AT_name P_BOUNDS}
- {DW_AT_type :$bounds_pointer}
- {DW_AT_data_member_location 8 DW_FORM_sdata}
+ DW_AT_name P_BOUNDS
+ DW_AT_type :$bounds_pointer
+ DW_AT_data_member_location 8 DW_FORM_sdata
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp b/gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp
index e1a76bf..a754426 100644
--- a/gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp
+++ b/gdb/testsuite/gdb.dwarf2/ada-valprint-error.exp
@@ -35,10 +35,10 @@ if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu {} {
- DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_Ada95}
- {DW_AT_name fd.adb}
- {DW_AT_comp_dir /tmp}
+ DW_TAG_compile_unit {
+ DW_AT_language @DW_LANG_Ada95
+ DW_AT_name fd.adb
+ DW_AT_comp_dir /tmp
} {
declare_labels array_elt_label integer_label array_label \
typedef_label ref_type_label
@@ -48,8 +48,8 @@ Dwarf::assemble $asm_file {
# A structure with no size attribute, to mimick structures
# in Ada that have a dynamic size...
array_elt_label: structure_type {
- {name fd__Tints_doubledC}
- {artificial 1 DW_FORM_flag_present}
+ DW_AT_name fd__Tints_doubledC
+ DW_AT_artificial 1 DW_FORM_flag_present
}
# ... and a corresponding XVZ variable, supposed to be there
@@ -58,44 +58,44 @@ Dwarf::assemble $asm_file {
# it has been optimized out (which the compiler can do,
# even if it at the expense of debuggability).
DW_TAG_variable {
- {name fd__Tints_doubledC___XVZ}
- {DW_AT_type :$integer_label}
- {artificial 1 DW_FORM_flag_present}
+ DW_AT_name fd__Tints_doubledC___XVZ
+ DW_AT_type :$integer_label
+ DW_AT_artificial 1 DW_FORM_flag_present
}
integer_label: DW_TAG_base_type {
- {DW_AT_byte_size $int_size DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
+ DW_AT_byte_size $int_size DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
}
array_label: DW_TAG_array_type {
- {DW_AT_name fd__ints_doubled}
- {DW_AT_type :$array_elt_label}
+ DW_AT_name fd__ints_doubled
+ DW_AT_type :$array_elt_label
} {
DW_TAG_subrange_type {
- {DW_AT_type :$integer_label}
- {DW_AT_upper_bound 2 DW_FORM_data1}
+ DW_AT_type :$integer_label
+ DW_AT_upper_bound 2 DW_FORM_data1
}
}
typedef_label: DW_TAG_typedef {
- {DW_AT_name fd__ints_doubled}
- {DW_AT_type :$array_label}
+ DW_AT_name fd__ints_doubled
+ DW_AT_type :$array_label
}
ref_type_label: DW_TAG_reference_type {
- {DW_AT_byte_size $ptr_size DW_FORM_sdata}
- {DW_AT_type :$typedef_label}
+ DW_AT_byte_size $ptr_size DW_FORM_sdata
+ DW_AT_type :$typedef_label
}
DW_TAG_variable {
- {name fd__global}
- {DW_AT_type :$ref_type_label}
- {DW_AT_location {
- DW_OP_addr [gdb_target_symbol fd__global]
- } SPECIAL_expr}
- {external 1 flag}
+ DW_AT_name fd__global
+ DW_AT_type :$ref_type_label
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol fd__global]
+ }] SPECIAL_expr
+ DW_AT_external 1 flag
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/arr-opt-out.exp b/gdb/testsuite/gdb.dwarf2/arr-opt-out.exp
index 6bbfef2..d3ccec8 100644
--- a/gdb/testsuite/gdb.dwarf2/arr-opt-out.exp
+++ b/gdb/testsuite/gdb.dwarf2/arr-opt-out.exp
@@ -29,51 +29,51 @@ set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_Ada95}
- {DW_AT_name foo.adb}
- {DW_AT_comp_dir /tmp}
+ DW_AT_language @DW_LANG_Ada95
+ DW_AT_name foo.adb
+ DW_AT_comp_dir /tmp
} {
declare_labels integer_label array_label \
low_bound_label high_bound_label
integer_label: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
}
# Note that the bounds don't have a location -- they are
# optimized out. This mimics what it is seen sometimes in
# the wild with optimized Ada code.
low_bound_label: DW_TAG_variable {
- {DW_AT_name pck__table___L}
- {DW_AT_type :$integer_label}
- {DW_AT_declaration 1 flag}
+ DW_AT_name pck__table___L
+ DW_AT_type :$integer_label
+ DW_AT_declaration 1 flag
}
high_bound_label: DW_TAG_variable {
- {DW_AT_name pck__table___U}
- {DW_AT_type :$integer_label}
- {DW_AT_declaration 1 flag}
+ DW_AT_name pck__table___U
+ DW_AT_type :$integer_label
+ DW_AT_declaration 1 flag
}
array_label: DW_TAG_array_type {
- {DW_AT_name pck__table}
- {DW_AT_type :$integer_label}
+ DW_AT_name pck__table
+ DW_AT_type :$integer_label
} {
DW_TAG_subrange_type {
- {DW_AT_type :$integer_label}
- {DW_AT_lower_bound :$low_bound_label}
- {DW_AT_upper_bound :$high_bound_label}
+ DW_AT_type :$integer_label
+ DW_AT_lower_bound :$low_bound_label
+ DW_AT_upper_bound :$high_bound_label
}
}
DW_TAG_variable {
- {DW_AT_name the_table}
- {DW_AT_type :$array_label}
- {DW_AT_location {
+ DW_AT_name the_table
+ DW_AT_type :$array_label
+ DW_AT_location [subst {
DW_OP_addr [gdb_target_symbol global_array]
- } SPECIAL_expr}
- {DW_AT_external 1 flag}
+ }] SPECIAL_expr
+ DW_AT_external 1 flag
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/arr-stride.exp b/gdb/testsuite/gdb.dwarf2/arr-stride.exp
index be0fdf3..bad1ffe 100644
--- a/gdb/testsuite/gdb.dwarf2/arr-stride.exp
+++ b/gdb/testsuite/gdb.dwarf2/arr-stride.exp
@@ -24,86 +24,86 @@ set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_Ada95}
- {DW_AT_name foo.adb}
- {DW_AT_comp_dir /tmp}
+ DW_AT_language @DW_LANG_Ada95
+ DW_AT_name foo.adb
+ DW_AT_comp_dir /tmp
} {
declare_labels integer_label array_elt_label array_label \
big_array_label struct_label
integer_label: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
}
array_elt_label: DW_TAG_subrange_type {
- {DW_AT_lower_bound 0xe0 DW_FORM_data1}
- {DW_AT_upper_bound 0x1f DW_FORM_data1}
- {DW_AT_name pck__item}
- {DW_AT_type :$integer_label}
+ DW_AT_lower_bound 0xe0 DW_FORM_data1
+ DW_AT_upper_bound 0x1f DW_FORM_data1
+ DW_AT_name pck__item
+ DW_AT_type :$integer_label
}
DW_TAG_typedef {
- {DW_AT_name pck__table}
- {DW_AT_type :$array_label}
+ DW_AT_name pck__table
+ DW_AT_type :$array_label
}
array_label: DW_TAG_array_type {
- {DW_AT_name pck__table}
- {DW_AT_bit_stride 6 DW_FORM_data1}
- {DW_AT_type :$array_elt_label}
+ DW_AT_name pck__table
+ DW_AT_bit_stride 6 DW_FORM_data1
+ DW_AT_type :$array_elt_label
} {
DW_TAG_subrange_type {
- {DW_AT_type :$integer_label}
- {DW_AT_lower_bound 0 DW_FORM_data1}
- {DW_AT_upper_bound 4 DW_FORM_data1}
+ DW_AT_type :$integer_label
+ DW_AT_lower_bound 0 DW_FORM_data1
+ DW_AT_upper_bound 4 DW_FORM_data1
}
}
DW_TAG_typedef {
- {DW_AT_name pck__big_table}
- {DW_AT_type :$big_array_label}
+ DW_AT_name pck__big_table
+ DW_AT_type :$big_array_label
}
big_array_label: DW_TAG_array_type {
- {DW_AT_name pck__big_table}
- {DW_AT_byte_stride 1 DW_FORM_data1}
- {DW_AT_type :$array_elt_label}
+ DW_AT_name pck__big_table
+ DW_AT_byte_stride 1 DW_FORM_data1
+ DW_AT_type :$array_elt_label
} {
DW_TAG_subrange_type {
- {DW_AT_type :$integer_label}
- {DW_AT_lower_bound 0 DW_FORM_data1}
- {DW_AT_upper_bound 4 DW_FORM_data1}
+ DW_AT_type :$integer_label
+ DW_AT_lower_bound 0 DW_FORM_data1
+ DW_AT_upper_bound 4 DW_FORM_data1
}
}
struct_label: DW_TAG_structure_type {
- {name struct_type}
- {byte_size 16 DW_FORM_sdata}
+ DW_AT_name struct_type
+ DW_AT_byte_size 16 DW_FORM_sdata
} {
member {
- {name intfield}
- {type :$integer_label}
- {data_member_location 0 DW_FORM_sdata}
+ DW_AT_name intfield
+ DW_AT_type :$integer_label
+ DW_AT_data_member_location 0 DW_FORM_sdata
}
member {
- {name arrayfield}
- {type :$array_label}
- {data_member_location 4 DW_FORM_sdata}
+ DW_AT_name arrayfield
+ DW_AT_type :$array_label
+ DW_AT_data_member_location 4 DW_FORM_sdata
}
}
DW_TAG_variable {
- {name the_struct}
- {external 1 DW_FORM_flag}
- {location {
+ DW_AT_name the_struct
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location {
DW_OP_const1u 1
DW_OP_stack_value
DW_OP_piece 4
DW_OP_piece 12
- } SPECIAL_expr}
- {type :$struct_label}
+ } SPECIAL_expr
+ DW_AT_type :$struct_label
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/arr-subrange.exp b/gdb/testsuite/gdb.dwarf2/arr-subrange.exp
index 05fe778..24d4600 100644
--- a/gdb/testsuite/gdb.dwarf2/arr-subrange.exp
+++ b/gdb/testsuite/gdb.dwarf2/arr-subrange.exp
@@ -23,52 +23,52 @@ standard_testfile main.c -dw.S
set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu {} {
- DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_Ada95}
- {DW_AT_name foo.adb}
- {DW_AT_comp_dir /tmp}
- {MACRO_AT_range {main}}
- } {
+ DW_TAG_compile_unit {
+ DW_AT_language @DW_LANG_Ada95
+ DW_AT_name foo.adb
+ DW_AT_comp_dir /tmp
+ MACRO_AT_range {main}
+ } {
declare_labels boolean_label typedef_label array_label enum_label
- boolean_label: DW_TAG_base_type {
- {DW_AT_byte_size 1 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_boolean}
- {DW_AT_name boolean}
- }
+ boolean_label: DW_TAG_base_type {
+ DW_AT_byte_size 1 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_boolean
+ DW_AT_name boolean
+ }
- typedef_label: DW_TAG_typedef {
- {DW_AT_name pck__table}
- {DW_AT_type :$array_label}
- }
+ typedef_label: DW_TAG_typedef {
+ DW_AT_name pck__table
+ DW_AT_type :$array_label
+ }
array_label: DW_TAG_array_type {
- {DW_AT_name pck__table}
- {DW_AT_type :$boolean_label}
+ DW_AT_name pck__table
+ DW_AT_type :$boolean_label
} {
DW_TAG_subrange_type {
- {DW_AT_type :$enum_label}
- {DW_AT_lower_bound 0 DW_FORM_data1}
- {DW_AT_upper_bound 128 DW_FORM_data1}
+ DW_AT_type :$enum_label
+ DW_AT_lower_bound 0 DW_FORM_data1
+ DW_AT_upper_bound 128 DW_FORM_data1
}
}
enum_label: DW_TAG_enumeration_type {
- {DW_AT_name pck__enum_t}
- {DW_AT_byte_size 1 DW_FORM_sdata}
- } {
- DW_TAG_enumerator {
- {DW_AT_name pck__enum_000}
- {DW_AT_const_value 0 DW_FORM_sdata}
- }
- DW_TAG_enumerator {
- {DW_AT_name pck__enum_001}
- {DW_AT_const_value 1 DW_FORM_sdata}
- }
- DW_TAG_enumerator {
- {DW_AT_name pck__enum_128}
- {DW_AT_const_value 128 DW_FORM_sdata}
- }
+ DW_AT_name pck__enum_t
+ DW_AT_byte_size 1 DW_FORM_sdata
+ } {
+ DW_TAG_enumerator {
+ DW_AT_name pck__enum_000
+ DW_AT_const_value 0 DW_FORM_sdata
+ }
+ DW_TAG_enumerator {
+ DW_AT_name pck__enum_001
+ DW_AT_const_value 1 DW_FORM_sdata
+ }
+ DW_TAG_enumerator {
+ DW_AT_name pck__enum_128
+ DW_AT_const_value 128 DW_FORM_sdata
+ }
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/assign-variable-value-to-register.exp b/gdb/testsuite/gdb.dwarf2/assign-variable-value-to-register.exp
index 64a86ec..1ebd622 100644
--- a/gdb/testsuite/gdb.dwarf2/assign-variable-value-to-register.exp
+++ b/gdb/testsuite/gdb.dwarf2/assign-variable-value-to-register.exp
@@ -36,29 +36,29 @@ Dwarf::assemble $dwarf_file {
declare_labels int_label float_label
int_label: DW_TAG_base_type {
- { DW_AT_name int }
- { DW_AT_byte_size 4 DW_FORM_udata }
- { DW_AT_encoding @DW_ATE_signed }
+ DW_AT_name int
+ DW_AT_byte_size 4 DW_FORM_udata
+ DW_AT_encoding @DW_ATE_signed
}
float_label: DW_TAG_base_type {
- { DW_AT_name float }
- { DW_AT_byte_size 4 DW_FORM_udata }
- { DW_AT_encoding @DW_ATE_float }
+ DW_AT_name float
+ DW_AT_byte_size 4 DW_FORM_udata
+ DW_AT_encoding @DW_ATE_float
}
DW_TAG_subprogram {
- { DW_AT_name main }
- { DW_AT_low_pc $main_start DW_FORM_addr }
- { DW_AT_high_pc $main_end DW_FORM_addr }
- { DW_AT_type :$int_label }
+ DW_AT_name main
+ DW_AT_low_pc $main_start DW_FORM_addr
+ DW_AT_high_pc $main_end DW_FORM_addr
+ DW_AT_type :$int_label
} {
DW_TAG_variable {
- { DW_AT_name foo }
- { DW_AT_type :$float_label }
- { DW_AT_location {
+ DW_AT_name foo
+ DW_AT_type :$float_label
+ DW_AT_location [subst {
DW_OP_regx $::st0_dwarf_regnum
- } SPECIAL_expr }
+ }] SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/atomic-type.exp b/gdb/testsuite/gdb.dwarf2/atomic-type.exp
index 2e6d903..022b63c 100644
--- a/gdb/testsuite/gdb.dwarf2/atomic-type.exp
+++ b/gdb/testsuite/gdb.dwarf2/atomic-type.exp
@@ -27,54 +27,54 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C11}
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir /tmp}
- } {
+ DW_AT_language @DW_LANG_C11
+ DW_AT_name $srcfile
+ DW_AT_comp_dir /tmp
+ } {
declare_labels i_l c_l c_c_l ac_c_l pac_c_l vpac_c_l avpac_c_l
- i_l: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name int}
- }
-
- c_l: DW_TAG_base_type {
- {DW_AT_byte_size 2 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_unsigned}
- {DW_AT_name char}
- }
-
- c_c_l: DW_TAG_const_type {
- {DW_AT_type :$c_l}
- }
-
- ac_c_l: DW_TAG_atomic_type {
- {DW_AT_type :$c_c_l}
- }
-
- pac_c_l: DW_TAG_pointer_type {
- {DW_AT_byte_size 8 DW_FORM_sdata}
- {DW_AT_type :$ac_c_l}
- }
-
- vpac_c_l: DW_TAG_volatile_type {
- {DW_AT_type :$pac_c_l}
- }
-
- avpac_c_l: DW_TAG_atomic_type {
- {DW_AT_type :$vpac_c_l}
- }
-
- DW_TAG_subprogram {
- {MACRO_AT_func {f}}
- {type :$i_l}
- } {
- DW_TAG_formal_parameter {
- {type :$avpac_c_l}
- {name x}
- }
- }
+ i_l: DW_TAG_base_type {
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int
+ }
+
+ c_l: DW_TAG_base_type {
+ DW_AT_byte_size 2 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_unsigned
+ DW_AT_name char
+ }
+
+ c_c_l: DW_TAG_const_type {
+ DW_AT_type :$c_l
+ }
+
+ ac_c_l: DW_TAG_atomic_type {
+ DW_AT_type :$c_c_l
+ }
+
+ pac_c_l: DW_TAG_pointer_type {
+ DW_AT_byte_size 8 DW_FORM_sdata
+ DW_AT_type :$ac_c_l
+ }
+
+ vpac_c_l: DW_TAG_volatile_type {
+ DW_AT_type :$pac_c_l
+ }
+
+ avpac_c_l: DW_TAG_atomic_type {
+ DW_AT_type :$vpac_c_l
+ }
+
+ DW_TAG_subprogram {
+ MACRO_AT_func {f}
+ DW_AT_type :$i_l
+ } {
+ DW_TAG_formal_parameter {
+ DW_AT_type :$avpac_c_l
+ DW_AT_name x
+ }
+ }
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/backward-spec-inter-cu.exp b/gdb/testsuite/gdb.dwarf2/backward-spec-inter-cu.exp
index b62f928..0cd26e8 100644
--- a/gdb/testsuite/gdb.dwarf2/backward-spec-inter-cu.exp
+++ b/gdb/testsuite/gdb.dwarf2/backward-spec-inter-cu.exp
@@ -20,6 +20,7 @@ load_lib dwarf.exp
# This test can only be run on targets which support DWARF-2 and use gas.
require dwarf2_support
+require !readnow
standard_testfile main.c -debug.S
@@ -32,23 +33,23 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C_plus_plus}
+ DW_AT_language @DW_LANG_C_plus_plus
} {
declare_labels myint
myint: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name myint}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name myint
}
DW_TAG_namespace {
- {DW_AT_name ns}
+ DW_AT_name ns
} {
spec: DW_TAG_variable {
- {DW_AT_name v}
- {DW_AT_type :$myint}
- {DW_AT_declaration 1 DW_FORM_flag_present}
+ DW_AT_name v
+ DW_AT_type :$myint
+ DW_AT_declaration 1 DW_FORM_flag_present
}
}
}
@@ -56,17 +57,17 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C_plus_plus}
+ DW_AT_language @DW_LANG_C_plus_plus
} {
# The new indexer has special code to compute the full
# name of an object that uses a specification that appears
# later in the DWARF.
DW_TAG_variable {
- {DW_AT_specification %$spec}
- {DW_AT_location {
+ DW_AT_specification %$spec
+ DW_AT_location {
DW_OP_const1u 23
DW_OP_stack_value
- } SPECIAL_expr}
+ } SPECIAL_expr
}
}
}
@@ -98,6 +99,11 @@ foreach_with_prefix worker_threads $worker_threads_list {
gdb_load $binfile
+ set index [have_index $binfile]
+ if { ![string eq $index ""] } {
+ return
+ }
+
gdb_test "pipe maint print objfiles | grep ns::v" \
"$ws+qualified:$ws+ns::v" \
"v has parent ns"
diff --git a/gdb/testsuite/gdb.dwarf2/bad-regnum.exp b/gdb/testsuite/gdb.dwarf2/bad-regnum.exp
index b443f82..eea13af 100644
--- a/gdb/testsuite/gdb.dwarf2/bad-regnum.exp
+++ b/gdb/testsuite/gdb.dwarf2/bad-regnum.exp
@@ -27,34 +27,34 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C}
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir /tmp}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name $srcfile
+ DW_AT_comp_dir /tmp
} {
declare_labels integer_label
integer_label: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
}
DW_TAG_variable {
- {DW_AT_name foo1}
- {DW_AT_type :$integer_label}
- {DW_AT_location {
+ DW_AT_name foo1
+ DW_AT_type :$integer_label
+ DW_AT_location {
DW_OP_regx 2147483647
- } SPECIAL_expr}
- {external 1 flag}
+ } SPECIAL_expr
+ DW_AT_external 1 flag
}
DW_TAG_variable {
- {DW_AT_name foo2}
- {DW_AT_type :$integer_label}
- {DW_AT_location {
+ DW_AT_name foo2
+ DW_AT_type :$integer_label
+ DW_AT_location {
DW_OP_regx -1
- } SPECIAL_expr}
- {external 1 flag}
+ } SPECIAL_expr
+ DW_AT_external 1 flag
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/bitfield-parent-optimized-out.exp b/gdb/testsuite/gdb.dwarf2/bitfield-parent-optimized-out.exp
index d2eb9bf..82eaed7 100644
--- a/gdb/testsuite/gdb.dwarf2/bitfield-parent-optimized-out.exp
+++ b/gdb/testsuite/gdb.dwarf2/bitfield-parent-optimized-out.exp
@@ -32,37 +32,37 @@ Dwarf::assemble $asm_file {
declare_labels struct_label var_label int_label
int_label: base_type {
- {byte_size 4 sdata}
- {encoding @DW_ATE_signed}
- {name int}
+ DW_AT_byte_size 4 sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int
}
struct_label: structure_type {
- {name S}
- {byte_size 8 DW_FORM_sdata}
+ DW_AT_name S
+ DW_AT_byte_size 8 DW_FORM_sdata
} {
member {
- {name bitfield}
- {type :$int_label}
- {bit_size 12 DW_FORM_sdata}
- {bit_offset 20 DW_FORM_sdata}
+ DW_AT_name bitfield
+ DW_AT_type :$int_label
+ DW_AT_bit_size 12 DW_FORM_sdata
+ DW_AT_bit_offset 20 DW_FORM_sdata
}
member {
- {name intfield}
- {type :$int_label}
- {data_member_location 4 DW_FORM_sdata}
+ DW_AT_name intfield
+ DW_AT_type :$int_label
+ DW_AT_data_member_location 4 DW_FORM_sdata
}
}
subprogram {
- {MACRO_AT_func { main }}
- {type :$int_label}
- {external 1 flag}
+ MACRO_AT_func { main }
+ DW_AT_type :$int_label
+ DW_AT_external 1 flag
} {
var_label: DW_TAG_variable {
- {name var}
- {location {} DW_FORM_block1}
- {type :$struct_label}
+ DW_AT_name var
+ DW_AT_location {} DW_FORM_block1
+ DW_AT_type :$struct_label
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/calling-convention.exp b/gdb/testsuite/gdb.dwarf2/calling-convention.exp
index 3cced7d..d3426b9 100644
--- a/gdb/testsuite/gdb.dwarf2/calling-convention.exp
+++ b/gdb/testsuite/gdb.dwarf2/calling-convention.exp
@@ -42,26 +42,26 @@ set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name "calling-convention"}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name "calling-convention"
} {
declare_labels int_label
int_label: base_type {
- {byte_size [get_sizeof "int" 4] sdata}
- {encoding @DW_ATE_signed}
- {name "int"}
+ DW_AT_byte_size [get_sizeof "int" 4] sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name "int"
}
subprogram {
- {MACRO_AT_func { foo }}
- {type :$int_label}
- {calling_convention @DW_CC_nocall}
+ MACRO_AT_func { foo }
+ DW_AT_type :$int_label
+ DW_AT_calling_convention @DW_CC_nocall
}
subprogram {
- {MACRO_AT_func { main }}
- {type :$int_label}
+ MACRO_AT_func { main }
+ DW_AT_type :$int_label
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/clang-cli-macro.exp b/gdb/testsuite/gdb.dwarf2/clang-cli-macro.exp
index b856c5b..d73a3a1 100644
--- a/gdb/testsuite/gdb.dwarf2/clang-cli-macro.exp
+++ b/gdb/testsuite/gdb.dwarf2/clang-cli-macro.exp
@@ -37,22 +37,22 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_producer "clang version 15.0.0"}
- {DW_AT_language @DW_LANG_C11}
- {DW_AT_name $::srcfile}
- {DW_AT_macros $cu_macros DW_FORM_sec_offset}
- {DW_AT_stmt_list $L DW_FORM_sec_offset}
+ DW_AT_producer "clang version 15.0.0"
+ DW_AT_language @DW_LANG_C11
+ DW_AT_name $::srcfile
+ DW_AT_macros $cu_macros 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_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}
+ MACRO_AT_func {main}
+ DW_AT_type :$int_type
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/clztest.exp b/gdb/testsuite/gdb.dwarf2/clztest.exp
index 7a74e02..93c2ced 100644
--- a/gdb/testsuite/gdb.dwarf2/clztest.exp
+++ b/gdb/testsuite/gdb.dwarf2/clztest.exp
@@ -61,7 +61,7 @@ proc scan_gdb_tests {} {
continue
}
- eval $test_cmd
+ {*}$test_cmd
}
close $fd
}
diff --git a/gdb/testsuite/gdb.dwarf2/comp-unit-lang.exp b/gdb/testsuite/gdb.dwarf2/comp-unit-lang.exp
index 9b18d9a..f4d9195 100644
--- a/gdb/testsuite/gdb.dwarf2/comp-unit-lang.exp
+++ b/gdb/testsuite/gdb.dwarf2/comp-unit-lang.exp
@@ -41,13 +41,13 @@ proc do_test {cu_lang gdb_lang} {
# both 32- and 64-bit machines.
cu { addr_size 4 } {
compile_unit {
- {name file1.txt}
- {language @$cu_lang}
- {MACRO_AT_range {func}}
+ DW_AT_name file1.txt
+ DW_AT_language @$cu_lang
+ MACRO_AT_range {func}
} {
subprogram {
- {external 1 flag}
- {MACRO_AT_func {func}}
+ DW_AT_external 1 flag
+ MACRO_AT_func {func}
} {
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/corrupt.exp b/gdb/testsuite/gdb.dwarf2/corrupt.exp
index b9f242c..a68b7e3 100644
--- a/gdb/testsuite/gdb.dwarf2/corrupt.exp
+++ b/gdb/testsuite/gdb.dwarf2/corrupt.exp
@@ -36,31 +36,31 @@ Dwarf::assemble $asm_file {
declare_labels int_label
int_label: base_type {
- {byte_size 4 sdata}
- {name "int"}
+ DW_AT_byte_size 4 sdata
+ DW_AT_name "int"
}
enumeration_type {
- {name "ENUM"}
- {byte_size 4 sdata}
+ DW_AT_name "ENUM"
+ DW_AT_byte_size 4 sdata
} {
enumerator {
- {name "A"}
- {const_value 0 sdata}
+ DW_AT_name "A"
+ DW_AT_const_value 0 sdata
}
enumerator {
- {name "B"}
- {const_value 1 sdata}
- {sibling 12345678 DW_FORM_ref4}
+ DW_AT_name "B"
+ DW_AT_const_value 1 sdata
+ DW_AT_sibling 12345678 DW_FORM_ref4
} {
base_type {
- {byte_size 1 sdata}
- {name "char"}
+ DW_AT_byte_size 1 sdata
+ DW_AT_name "char"
}
}
array_type {
- {type :$int_label}
- {sibling 12345678 DW_FORM_ref4}
+ DW_AT_type :$int_label
+ DW_AT_sibling 12345678 DW_FORM_ref4
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/count.exp b/gdb/testsuite/gdb.dwarf2/count.exp
index a8b216d..4d2ec31 100644
--- a/gdb/testsuite/gdb.dwarf2/count.exp
+++ b/gdb/testsuite/gdb.dwarf2/count.exp
@@ -25,100 +25,101 @@ standard_testfile main.c .S
set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu {} {
- compile_unit {{language @DW_LANG_C99}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C99
+ } {
declare_labels char_label \
array_size_type_label long_unsigned_int_label \
array_label array_label2 static_array_label \
vla_length_label vla_array_label
char_label: base_type {
- {name char}
- {encoding @DW_ATE_signed}
- {byte_size 1 DW_FORM_sdata}
+ DW_AT_name char
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 1 DW_FORM_sdata
}
array_size_type_label: base_type {
- {byte_size 8 DW_FORM_sdata}
- {encoding @DW_ATE_unsigned}
- {name __ARRAY_SIZE_TYPE__}
+ DW_AT_byte_size 8 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_unsigned
+ DW_AT_name __ARRAY_SIZE_TYPE__
}
long_unsigned_int_label: base_type {
- {byte_size 8 DW_FORM_sdata}
- {encoding @DW_ATE_unsigned}
- {name "long unsigned int"}
+ DW_AT_byte_size 8 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_unsigned
+ DW_AT_name "long unsigned int"
}
array_label: array_type {
- {type :$char_label}
+ DW_AT_type :$char_label
} {
subrange_type {
- {count {DW_OP_lit5} SPECIAL_expr}
- {type :$char_label}
+ DW_AT_count {DW_OP_lit5} SPECIAL_expr
+ DW_AT_type :$char_label
}
}
array_label2: array_type {
- {type :$char_label}
+ DW_AT_type :$char_label
} {
subrange_type {
- {count {DW_OP_lit1} SPECIAL_expr}
- {type :$char_label}
+ DW_AT_count {DW_OP_lit1} SPECIAL_expr
+ DW_AT_type :$char_label
}
}
static_array_label: array_type {
- {type :$char_label}
+ DW_AT_type :$char_label
} {
subrange_type {
- {count 5 DW_FORM_sdata}
- {type :$char_label}
+ DW_AT_count 5 DW_FORM_sdata
+ DW_AT_type :$char_label
}
}
vla_length_label:
DW_TAG_variable {
- {location
- {
- lit6
- stack_value
- } SPECIAL_expr}
- {name "__vla_array_length"}
- {type :$long_unsigned_int_label}
- {artificial 1 DW_FORM_flag_present}
+ DW_AT_location {
+ lit6
+ stack_value
+ } SPECIAL_expr
+ DW_AT_name "__vla_array_length"
+ DW_AT_type :$long_unsigned_int_label
+ DW_AT_artificial 1 DW_FORM_flag_present
}
vla_array_label: array_type {
- {type :$char_label}
+ DW_AT_type :$char_label
} {
subrange_type {
- {type :$array_size_type_label}
- {count :$vla_length_label}
+ DW_AT_type :$array_size_type_label
+ DW_AT_count :$vla_length_label
}
}
DW_TAG_variable {
- {name array2}
- {type :$array_label2}
- {const_value 65 DW_FORM_udata}
+ DW_AT_name array2
+ DW_AT_type :$array_label2
+ DW_AT_const_value 65 DW_FORM_udata
}
DW_TAG_variable {
- {name array}
- {type :$array_label}
- {const_value hello DW_FORM_block1}
+ DW_AT_name array
+ DW_AT_type :$array_label
+ DW_AT_const_value hello DW_FORM_block1
}
DW_TAG_variable {
- {name static_array}
- {type :$static_array_label}
- {const_value world DW_FORM_block1}
+ DW_AT_name static_array
+ DW_AT_type :$static_array_label
+ DW_AT_const_value world DW_FORM_block1
}
DW_TAG_variable {
- {name vla_array}
- {type :$vla_array_label}
- {const_value saluton DW_FORM_block1}
+ DW_AT_name vla_array
+ DW_AT_type :$vla_array_label
+ DW_AT_const_value saluton DW_FORM_block1
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/cpp-linkage-name.exp b/gdb/testsuite/gdb.dwarf2/cpp-linkage-name.exp
index 7442399..a21e980 100644
--- a/gdb/testsuite/gdb.dwarf2/cpp-linkage-name.exp
+++ b/gdb/testsuite/gdb.dwarf2/cpp-linkage-name.exp
@@ -32,49 +32,49 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C_plus_plus}
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir /tmp}
+ DW_AT_language @DW_LANG_C_plus_plus
+ DW_AT_name $srcfile
+ DW_AT_comp_dir /tmp
} {
declare_labels a_l b_l
a_l: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name int}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int
}
# To expose the bug that existed at one point this
# structure must have a linkage name, but no name, and the
# linkage name is something that doesn't demangle.
b_l: DW_TAG_structure_type {
- {DW_AT_byte_size 8 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_linkage_name <anon>}
+ DW_AT_byte_size 8 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_linkage_name <anon>
} {
member {
- {name x}
- {type :$a_l}
- {data_member_location 0 data1}
+ DW_AT_name x
+ DW_AT_type :$a_l
+ DW_AT_data_member_location 0 data1
}
member {
- {name y}
- {type :$a_l}
- {data_member_location 0 data1}
+ DW_AT_name y
+ DW_AT_type :$a_l
+ DW_AT_data_member_location 0 data1
}
}
DW_TAG_subprogram {
- {MACRO_AT_func {main}}
- {type :$a_l}
+ MACRO_AT_func {main}
+ DW_AT_type :$a_l
}
DW_TAG_variable {
- {type :$b_l}
- {external 1 flag}
- {DW_AT_name global_var}
- {DW_AT_location {
+ DW_AT_type :$b_l
+ DW_AT_external 1 flag
+ DW_AT_name global_var
+ DW_AT_location [subst {
DW_OP_addr [gdb_target_symbol global_var]
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/cu-empty-name.exp b/gdb/testsuite/gdb.dwarf2/cu-empty-name.exp
index 6bed9e5..6ee55a6 100644
--- a/gdb/testsuite/gdb.dwarf2/cu-empty-name.exp
+++ b/gdb/testsuite/gdb.dwarf2/cu-empty-name.exp
@@ -27,10 +27,10 @@ set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_producer "Tsetsuite"}
- {DW_AT_language @DW_LANG_C}
- {DW_AT_name ""}
- {DW_AT_comp_dir /tmp}
+ DW_AT_producer "Tsetsuite"
+ DW_AT_language @DW_LANG_C
+ DW_AT_name ""
+ DW_AT_comp_dir /tmp
} {
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/cu-no-addrs.exp b/gdb/testsuite/gdb.dwarf2/cu-no-addrs.exp
index 7f36878..796f935 100644
--- a/gdb/testsuite/gdb.dwarf2/cu-no-addrs.exp
+++ b/gdb/testsuite/gdb.dwarf2/cu-no-addrs.exp
@@ -35,13 +35,13 @@ Dwarf::assemble $asm_file {
# The PC range here is intentionally empty -- this was the
# trigger for the bug.
compile_unit {
- {language @DW_LANG_C}
- {DW_AT_low_pc $main_start DW_FORM_addr}
- {DW_AT_high_pc $main_start DW_FORM_addr}
+ DW_AT_language @DW_LANG_C
+ DW_AT_low_pc $main_start DW_FORM_addr
+ DW_AT_high_pc $main_start DW_FORM_addr
} {
DW_TAG_subprogram {
- {DW_AT_name "main"}
- {DW_AT_low_pc $main_start DW_FORM_addr}
+ DW_AT_name "main"
+ DW_AT_low_pc $main_start DW_FORM_addr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/data-loc.exp b/gdb/testsuite/gdb.dwarf2/data-loc.exp
index 20500cb..94b9e09 100644
--- a/gdb/testsuite/gdb.dwarf2/data-loc.exp
+++ b/gdb/testsuite/gdb.dwarf2/data-loc.exp
@@ -34,83 +34,83 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu {} {
- DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_Ada95}
- {DW_AT_name foo.adb}
- {DW_AT_comp_dir /tmp}
- } {
- declare_labels integer_label array_label array_ptr_label
+ DW_TAG_compile_unit {
+ DW_AT_language @DW_LANG_Ada95
+ DW_AT_name foo.adb
+ DW_AT_comp_dir /tmp
+ } {
+ declare_labels integer_label array_label array_ptr_label
set int_size [get_sizeof "int" 4]
set voidp_size [get_sizeof "void *" 96]
- integer_label: DW_TAG_base_type {
- {DW_AT_byte_size $int_size DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
- }
+ integer_label: DW_TAG_base_type {
+ DW_AT_byte_size $int_size DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
+ }
array_label: DW_TAG_array_type {
- {DW_AT_name foo__array_type}
- {DW_AT_type :$integer_label}
- {DW_AT_data_location {
- DW_OP_push_object_address
- DW_OP_deref
- } SPECIAL_expr}
- {external 1 flag}
+ DW_AT_name foo__array_type
+ DW_AT_type :$integer_label
+ DW_AT_data_location {
+ DW_OP_push_object_address
+ DW_OP_deref
+ } SPECIAL_expr
+ DW_AT_external 1 flag
} {
DW_TAG_subrange_type {
- {DW_AT_type :$integer_label}
- {DW_AT_lower_bound {
- DW_OP_push_object_address
- DW_OP_plus_uconst $voidp_size
- DW_OP_deref
- DW_OP_deref_size $int_size
- } SPECIAL_expr}
- {DW_AT_upper_bound {
- DW_OP_push_object_address
- DW_OP_plus_uconst $voidp_size
- DW_OP_deref
- DW_OP_plus_uconst $int_size
- DW_OP_deref_size $int_size
- } SPECIAL_expr}
+ DW_AT_type :$integer_label
+ DW_AT_lower_bound [subst {
+ DW_OP_push_object_address
+ DW_OP_plus_uconst $voidp_size
+ DW_OP_deref
+ DW_OP_deref_size $int_size
+ }] SPECIAL_expr
+ DW_AT_upper_bound [subst {
+ DW_OP_push_object_address
+ DW_OP_plus_uconst $voidp_size
+ DW_OP_deref
+ DW_OP_plus_uconst $int_size
+ DW_OP_deref_size $int_size
+ }] SPECIAL_expr
}
}
- array_ptr_label: DW_TAG_typedef {
- {DW_AT_name foo__array_type}
- {DW_AT_type :$array_label}
- }
- DW_TAG_variable {
- {DW_AT_name foo__three}
- {DW_AT_type :$array_label}
- {DW_AT_location {
- DW_OP_addr [gdb_target_symbol table_1]
- } SPECIAL_expr}
- {external 1 flag}
- }
- DW_TAG_variable {
- {DW_AT_name foo__three_tdef}
- {DW_AT_type :$array_ptr_label}
- {DW_AT_location {
- DW_OP_addr [gdb_target_symbol table_1]
- } SPECIAL_expr}
- {external 1 flag}
- }
- DW_TAG_variable {
- {DW_AT_name foo__five}
- {DW_AT_type :$array_label}
- {DW_AT_location {
- DW_OP_addr [gdb_target_symbol table_2]
- } SPECIAL_expr}
- {external 1 flag}
- }
- DW_TAG_variable {
- {DW_AT_name foo__five_tdef}
- {DW_AT_type :$array_ptr_label}
- {DW_AT_location {
- DW_OP_addr [gdb_target_symbol table_2]
- } SPECIAL_expr}
- {external 1 flag}
- }
+ array_ptr_label: DW_TAG_typedef {
+ DW_AT_name foo__array_type
+ DW_AT_type :$array_label
+ }
+ DW_TAG_variable {
+ DW_AT_name foo__three
+ DW_AT_type :$array_label
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol table_1]
+ }] SPECIAL_expr
+ DW_AT_external 1 flag
+ }
+ DW_TAG_variable {
+ DW_AT_name foo__three_tdef
+ DW_AT_type :$array_ptr_label
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol table_1]
+ }] SPECIAL_expr
+ DW_AT_external 1 flag
+ }
+ DW_TAG_variable {
+ DW_AT_name foo__five
+ DW_AT_type :$array_label
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol table_2]
+ }] SPECIAL_expr
+ DW_AT_external 1 flag
+ }
+ DW_TAG_variable {
+ DW_AT_name foo__five_tdef
+ DW_AT_type :$array_ptr_label
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol table_2]
+ }] SPECIAL_expr
+ DW_AT_external 1 flag
+ }
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/debug-aranges-duplicate-offset-warning.exp b/gdb/testsuite/gdb.dwarf2/debug-aranges-duplicate-offset-warning.exp
index ac9c774..9ac9d94 100644
--- a/gdb/testsuite/gdb.dwarf2/debug-aranges-duplicate-offset-warning.exp
+++ b/gdb/testsuite/gdb.dwarf2/debug-aranges-duplicate-offset-warning.exp
@@ -31,20 +31,20 @@ Dwarf::assemble $asm_file {
cu { label cu_label } {
compile_unit {
- {language @DW_LANG_C}
- {name $srcfile}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name $srcfile
} {
subprogram {
- {external 1 flag}
- {name main}
- {low_pc $main_start addr}
- {high_pc $main_len DW_FORM_data4}
+ DW_AT_external 1 flag
+ DW_AT_name main
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc $main_len DW_FORM_data4
}
subprogram {
- {external 1 flag}
- {name frame2}
- {low_pc $frame2_start addr}
- {high_pc $frame2_len DW_FORM_data4}
+ DW_AT_external 1 flag
+ DW_AT_name frame2
+ DW_AT_low_pc $frame2_start addr
+ DW_AT_high_pc $frame2_len DW_FORM_data4
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/debug-names-bad-cu-index.exp b/gdb/testsuite/gdb.dwarf2/debug-names-bad-cu-index.exp
index c758db7..016478f 100644
--- a/gdb/testsuite/gdb.dwarf2/debug-names-bad-cu-index.exp
+++ b/gdb/testsuite/gdb.dwarf2/debug-names-bad-cu-index.exp
@@ -21,7 +21,7 @@ require dwarf2_support
standard_testfile _start.c debug-names.S
set func_info_vars \
- [get_func_info _start [list debug additional_flags=-nostartfiles]]
+ [get_func_info _start [list debug ldflags=-nostartfiles]]
# Create the DWARF.
set asm_file [standard_output_file $srcfile2]
@@ -35,11 +35,13 @@ Dwarf::assemble {
}
cu { label cu_label } {
- compile_unit {{language @DW_LANG_C}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C
+ } {
subprogram {
- {DW_AT_name _start}
- {DW_AT_low_pc $_start_start DW_FORM_addr}
- {DW_AT_high_pc $_start_end DW_FORM_addr}
+ DW_AT_name _start
+ DW_AT_low_pc $_start_start DW_FORM_addr
+ DW_AT_high_pc $_start_end DW_FORM_addr
}
}
}
@@ -49,18 +51,18 @@ Dwarf::assemble {
declare_labels int_type
structure_type {
- {name struct_with_int_member}
- {byte_size 4 sdata}
+ DW_AT_name struct_with_int_member
+ DW_AT_byte_size 4 sdata
} {
member {
- {name member}
- {type :$int_type}
+ DW_AT_name member
+ DW_AT_type :$int_type
}
}
int_type: base_type {
- {name int}
- {encoding @DW_ATE_signed}
- {byte_size 4 sdata}
+ DW_AT_name int
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 4 sdata
}
}
}
@@ -74,7 +76,7 @@ Dwarf::assemble {
}
if {[build_executable ${testfile}.exp $testfile "${asm_file} ${srcfile}" \
- [list additional_flags=-nostartfiles]] == -1} {
+ [list ldflags=-nostartfiles]] == -1} {
return -1
}
diff --git a/gdb/testsuite/gdb.dwarf2/debug-names-duplicate-cu.exp b/gdb/testsuite/gdb.dwarf2/debug-names-duplicate-cu.exp
index 44d623b..28f2157 100644
--- a/gdb/testsuite/gdb.dwarf2/debug-names-duplicate-cu.exp
+++ b/gdb/testsuite/gdb.dwarf2/debug-names-duplicate-cu.exp
@@ -21,7 +21,7 @@ require dwarf2_support
standard_testfile _start.c debug-names.S
set func_info_vars \
- [get_func_info _start [list debug additional_flags=-nostartfiles]]
+ [get_func_info _start [list debug ldflags=-nostartfiles]]
# Create the DWARF.
set asm_file [standard_output_file $srcfile2]
@@ -35,16 +35,18 @@ Dwarf::assemble {
}
cu { label cu_label } {
- compile_unit {{language @DW_LANG_C}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C
+ } {
subprogram {
- {DW_AT_name _start}
- {DW_AT_low_pc $_start_start DW_FORM_addr}
- {DW_AT_high_pc $_start_end DW_FORM_addr}
+ DW_AT_name _start
+ DW_AT_low_pc $_start_start DW_FORM_addr
+ DW_AT_high_pc $_start_end DW_FORM_addr
}
base_type {
- {name int}
- {byte_size 4 sdata}
- {encoding @DW_ATE_signed}
+ DW_AT_name int
+ DW_AT_byte_size 4 sdata
+ DW_AT_encoding @DW_ATE_signed
}
}
}
@@ -58,7 +60,7 @@ Dwarf::assemble {
}
if [prepare_for_testing "failed to prepare" $testfile "${asm_file} ${srcfile}" \
- [list additional_flags=-nostartfiles]] {
+ [list ldflags=-nostartfiles]] {
return -1
}
diff --git a/gdb/testsuite/gdb.dwarf2/debug-names-missing-cu.exp b/gdb/testsuite/gdb.dwarf2/debug-names-missing-cu.exp
index d7d4fb8..77db144 100644
--- a/gdb/testsuite/gdb.dwarf2/debug-names-missing-cu.exp
+++ b/gdb/testsuite/gdb.dwarf2/debug-names-missing-cu.exp
@@ -18,10 +18,14 @@ load_lib dwarf.exp
# This test can only be run on targets which support DWARF-2 and use gas.
require dwarf2_support
+# This test checks that no CU is initially expanded, which is negated
+# by readnow.
+require !readnow
+
standard_testfile _start.c debug-names.S
set func_info_vars \
- [get_func_info _start [list debug additional_flags=-nostartfiles]]
+ [get_func_info _start [list debug ldflags=-nostartfiles]]
# Create the DWARF.
set asm_file [standard_output_file $srcfile2]
@@ -35,16 +39,18 @@ Dwarf::assemble {
}
cu { label cu_label } {
- compile_unit {{language @DW_LANG_C}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C
+ } {
subprogram {
- {DW_AT_name _start}
- {DW_AT_low_pc $_start_start DW_FORM_addr}
- {DW_AT_high_pc $_start_end DW_FORM_addr}
+ DW_AT_name _start
+ DW_AT_low_pc $_start_start DW_FORM_addr
+ DW_AT_high_pc $_start_end DW_FORM_addr
}
base_type {
- {name int}
- {byte_size 4 sdata}
- {encoding @DW_ATE_signed}
+ DW_AT_name int
+ DW_AT_byte_size 4 sdata
+ DW_AT_encoding @DW_ATE_signed
}
}
}
@@ -61,7 +67,7 @@ Dwarf::assemble {
}
if [prepare_for_testing "failed to prepare" $testfile "${asm_file} ${srcfile}" \
- [list additional_flags=-nostartfiles]] {
+ [list ldflags=-nostartfiles]] {
return -1
}
diff --git a/gdb/testsuite/gdb.dwarf2/debug-names-tu.exp.tcl b/gdb/testsuite/gdb.dwarf2/debug-names-tu.exp.tcl
index 60d1d0d..4de96ff 100644
--- a/gdb/testsuite/gdb.dwarf2/debug-names-tu.exp.tcl
+++ b/gdb/testsuite/gdb.dwarf2/debug-names-tu.exp.tcl
@@ -18,10 +18,14 @@ load_lib dwarf.exp
# This test can only be run on targets which support DWARF-2 and use gas.
require dwarf2_support
+# When using readnow, the index isn't used, which invalidates this
+# test.
+require !readnow
+
standard_testfile _start.c debug-names.S
set func_info_vars \
- [get_func_info _start [list debug additional_flags=-nostartfiles]]
+ [get_func_info _start [list debug ldflags=-nostartfiles]]
# Create the DWARF.
set asm_file [standard_output_file $srcfile2]
@@ -36,32 +40,36 @@ Dwarf::assemble {
}
cu { label cu_label version $dwarf_version } {
- compile_unit {{language @DW_LANG_C}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C
+ } {
subprogram {
- {DW_AT_name _start}
- {DW_AT_low_pc $_start_start DW_FORM_addr}
- {DW_AT_high_pc $_start_end DW_FORM_addr}
+ DW_AT_name _start
+ DW_AT_low_pc $_start_start DW_FORM_addr
+ DW_AT_high_pc $_start_end DW_FORM_addr
}
}
}
tu { label tu_label version $dwarf_version } 0x8ece66f4224fddb3 "" {
- type_unit {{language @DW_LANG_C}} {
+ type_unit {
+ DW_AT_language @DW_LANG_C
+ } {
declare_labels int_type
structure_type {
- {name struct_with_int_member}
- {byte_size 4 sdata}
+ DW_AT_name struct_with_int_member
+ DW_AT_byte_size 4 sdata
} {
member {
- {name member}
- {type :$int_type}
+ DW_AT_name member
+ DW_AT_type :$int_type
}
}
int_type: base_type {
- {name int}
- {encoding @DW_ATE_signed}
- {byte_size 4 sdata}
+ DW_AT_name int
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 4 sdata
}
}
}
@@ -76,7 +84,7 @@ Dwarf::assemble {
}
if [prepare_for_testing "failed to prepare" $testfile "${asm_file} ${srcfile}" \
- [list additional_flags=-nostartfiles]] {
+ [list ldflags=-nostartfiles]] {
return -1
}
diff --git a/gdb/testsuite/gdb.dwarf2/debug-names.exp b/gdb/testsuite/gdb.dwarf2/debug-names.exp
index 67a4f49..7f63af2 100644
--- a/gdb/testsuite/gdb.dwarf2/debug-names.exp
+++ b/gdb/testsuite/gdb.dwarf2/debug-names.exp
@@ -21,7 +21,7 @@ require dwarf2_support
standard_testfile _start.c debug-names.S
set func_info_vars \
- [get_func_info _start [list debug additional_flags=-nostartfiles]]
+ [get_func_info _start [list debug ldflags=-nostartfiles]]
# Create the DWARF.
set asm_file [standard_output_file $srcfile2]
@@ -35,16 +35,18 @@ Dwarf::assemble {
}
cu { label cu_label } {
- compile_unit {{language @DW_LANG_C}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C
+ } {
subprogram {
- {DW_AT_name _start}
- {DW_AT_low_pc $_start_start DW_FORM_addr}
- {DW_AT_high_pc $_start_end DW_FORM_addr}
+ DW_AT_name _start
+ DW_AT_low_pc $_start_start DW_FORM_addr
+ DW_AT_high_pc $_start_end DW_FORM_addr
}
base_type {
- {name int}
- {byte_size 4 sdata}
- {encoding @DW_ATE_signed}
+ DW_AT_name int
+ DW_AT_byte_size 4 sdata
+ DW_AT_encoding @DW_ATE_signed
}
}
}
@@ -57,7 +59,7 @@ Dwarf::assemble {
}
if [prepare_for_testing "failed to prepare" $testfile "${asm_file} ${srcfile}" \
- [list additional_flags=-nostartfiles]] {
+ [list ldflags=-nostartfiles]] {
return -1
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw-form-ref-addr-with-type-units.exp b/gdb/testsuite/gdb.dwarf2/dw-form-ref-addr-with-type-units.exp
index 6253629..396fd94 100644
--- a/gdb/testsuite/gdb.dwarf2/dw-form-ref-addr-with-type-units.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw-form-ref-addr-with-type-units.exp
@@ -42,8 +42,8 @@ Dwarf::assemble $asm_file {
compile_unit {
} {
subprogram {
- {MACRO_AT_func {main}}
- {type %$int_type}
+ MACRO_AT_func {main}
+ DW_AT_type %$int_type
}
}
}
@@ -61,9 +61,9 @@ Dwarf::assemble $asm_file {
compile_unit {
} {
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_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int
}
}
}
@@ -79,19 +79,19 @@ Dwarf::assemble $asm_file {
declare_labels dummy_int_type
the_type_i: structure_type {
- {name s}
- {byte_size 4 sdata}
+ DW_AT_name s
+ DW_AT_byte_size 4 sdata
} {
- member {
- {name i}
- {type :$dummy_int_type}
- }
+ member {
+ DW_AT_name i
+ DW_AT_type :$dummy_int_type
+ }
}
dummy_int_type: base_type {
- {name int}
- {encoding @DW_ATE_signed}
- {byte_size 4 sdata}
+ DW_AT_name int
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 4 sdata
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp.tcl b/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp.tcl
index bc5a654..0e5cee2 100644
--- a/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp.tcl
+++ b/gdb/testsuite/gdb.dwarf2/dw-form-strx.exp.tcl
@@ -32,23 +32,23 @@ Dwarf::assemble $asm_file {
version 5
} {
DW_TAG_compile_unit {
- {DW_AT_str_offsets_base $base_offset_cu1 sec_offset}
+ DW_AT_str_offsets_base $base_offset_cu1 sec_offset
} {
declare_labels int4_type
int4_type: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name $::int_str_idx DW_FORM_strx_id}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name $::int_str_idx DW_FORM_strx_id
}
DW_TAG_variable {
- {DW_AT_name global_var}
- {DW_AT_type :$int4_type}
- {DW_AT_location {
+ DW_AT_name global_var
+ DW_AT_type :$int4_type
+ DW_AT_location {
DW_OP_const1u 12
DW_OP_stack_value
- } SPECIAL_expr}
+ } SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-align.exp b/gdb/testsuite/gdb.dwarf2/dw2-align.exp
index 4d43816..dfb11af8 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-align.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-align.exp
@@ -27,39 +27,39 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C_plus_plus}
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir /tmp}
- } {
+ DW_AT_language @DW_LANG_C_plus_plus
+ DW_AT_name $srcfile
+ DW_AT_comp_dir /tmp
+ } {
declare_labels itype ptype
- itype: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name int_4096}
- {DW_AT_alignment 4096 DW_FORM_sdata}
- }
+ itype: DW_TAG_base_type {
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int_4096
+ DW_AT_alignment 4096 DW_FORM_sdata
+ }
- ptype: DW_TAG_pointer_type {
- {DW_AT_byte_size 8 DW_FORM_sdata}
- {DW_AT_type :$itype}
- {DW_AT_alignment 4096 DW_FORM_sdata}
- }
+ ptype: DW_TAG_pointer_type {
+ DW_AT_byte_size 8 DW_FORM_sdata
+ DW_AT_type :$itype
+ DW_AT_alignment 4096 DW_FORM_sdata
+ }
- DW_TAG_typedef {
- {DW_AT_name ptr_4096}
- {DW_AT_type :$ptype}
- }
+ DW_TAG_typedef {
+ DW_AT_name ptr_4096
+ DW_AT_type :$ptype
+ }
DW_TAG_structure_type {
- {DW_AT_name "struct_4096"}
- {DW_AT_byte_size 4096 DW_FORM_sdata}
- {DW_AT_alignment 4096 DW_FORM_udata}
+ DW_AT_name "struct_4096"
+ DW_AT_byte_size 4096 DW_FORM_sdata
+ DW_AT_alignment 4096 DW_FORM_udata
} {
member {
- {name a}
- {type :$itype}
- {data_member_location 0 data1}
+ DW_AT_name a
+ DW_AT_type :$itype
+ DW_AT_data_member_location 0 data1
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-aranges.exp b/gdb/testsuite/gdb.dwarf2/dw2-aranges.exp
index 8d941ba..928edf0 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-aranges.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-aranges.exp
@@ -25,14 +25,17 @@ set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu { label cu_start } {
- compile_unit {{language @DW_LANG_C}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C
+ } {
}
}
aranges { addr_zero true } cu_start {
}
}
-if { [prepare_for_testing "failed to prepare" $binfile [list $asm_file $srcfile ]] } {
+if { [prepare_for_testing "failed to prepare" $testfile \
+ [list $asm_file $srcfile ]] } {
return -1
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bad-abstract-origin.exp b/gdb/testsuite/gdb.dwarf2/dw2-bad-abstract-origin.exp
index 9c1f424..0ee06b0 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-bad-abstract-origin.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-bad-abstract-origin.exp
@@ -93,75 +93,75 @@ proc run_test { dwarf_version } {
cu { version $dwarf_version } {
compile_unit {
- {producer "GNU C 14.1.0"}
- {language @DW_LANG_C}
- {name $::srcfile}
- {comp_dir /tmp}
- {stmt_list $lines_table DW_FORM_sec_offset}
- {low_pc 0 addr}
+ DW_AT_producer "GNU C 14.1.0"
+ DW_AT_language @DW_LANG_C
+ DW_AT_name $::srcfile
+ DW_AT_comp_dir /tmp
+ DW_AT_stmt_list $lines_table DW_FORM_sec_offset
+ DW_AT_low_pc 0 addr
} {
int_label: base_type {
- {name "int"}
- {byte_size 4 sdata}
- {encoding @DW_ATE_signed}
+ DW_AT_name "int"
+ DW_AT_byte_size 4 sdata
+ DW_AT_encoding @DW_ATE_signed
}
foo_func: subprogram {
- {name foo}
- {inline @DW_INL_declared_inlined}
- {decl_file 1 data1}
- {decl_line $::func_a_decl_line data1}
+ DW_AT_name foo
+ DW_AT_inline @DW_INL_declared_inlined
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line $::func_a_decl_line data1
} {
foo_block: lexical_block {
} {
value_label: DW_TAG_variable {
- {name value}
- {type :$int_label}
+ DW_AT_name value
+ DW_AT_type :$int_label
}
}
}
subprogram {
- {abstract_origin %$foo_func}
- {low_pc func_a_0 addr}
- {high_pc func_a_6 addr}
- {external 1 flag}
+ DW_AT_abstract_origin %$foo_func
+ DW_AT_low_pc func_a_0 addr
+ DW_AT_high_pc func_a_6 addr
+ DW_AT_external 1 flag
} {
bad_block: lexical_block {
- {abstract_origin %$foo_block}
- {ranges $block_ranges DW_FORM_sec_offset}
+ DW_AT_abstract_origin %$foo_block
+ DW_AT_ranges $block_ranges DW_FORM_sec_offset
} {
DW_TAG_variable {
- {abstract_origin %$value_label}
- {DW_AT_location {
+ DW_AT_abstract_origin %$value_label
+ DW_AT_location {
DW_OP_const1u 23
DW_OP_stack_value
- } SPECIAL_expr}
+ } SPECIAL_expr
}
}
}
subprogram {
- {name baz}
- {low_pc func_b_0 addr}
- {high_pc func_b_5 addr}
- {external 1 flag}
+ DW_AT_name baz
+ DW_AT_low_pc func_b_0 addr
+ DW_AT_high_pc func_b_5 addr
+ DW_AT_external 1 flag
} {
inlined_subroutine {
- {abstract_origin %$foo_func}
- {call_file 1 data1}
- {call_line $::call_line data1}
- {low_pc func_b_1 addr}
- {high_pc func_b_4 addr}
+ DW_AT_abstract_origin %$foo_func
+ DW_AT_call_file 1 data1
+ DW_AT_call_line $::call_line data1
+ DW_AT_low_pc func_b_1 addr
+ DW_AT_high_pc func_b_4 addr
} {
lexical_block {
- {abstract_origin %$bad_block}
- {low_pc func_b_2 addr}
- {high_pc func_b_3 addr}
+ DW_AT_abstract_origin %$bad_block
+ DW_AT_low_pc func_b_2 addr
+ DW_AT_high_pc func_b_3 addr
} {
DW_TAG_variable {
- {abstract_origin %$value_label}
- {DW_AT_location {
+ DW_AT_abstract_origin %$value_label
+ DW_AT_location {
DW_OP_const1u 99
DW_OP_stack_value
- } SPECIAL_expr}
+ } SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp b/gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp
index fa9d000..a0ae498 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp
@@ -54,56 +54,56 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C}
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir ${srcdir}/${subdir}}
- {stmt_list $L1 DW_FORM_sec_offset}
- {ranges ${ranges_label_1} DW_FORM_sec_offset}
- {DW_AT_low_pc 0 addr}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name $srcfile
+ DW_AT_comp_dir ${srcdir}/${subdir}
+ DW_AT_stmt_list $L1 DW_FORM_sec_offset
+ DW_AT_ranges ${ranges_label_1} DW_FORM_sec_offset
+ DW_AT_low_pc 0 addr
} {
declare_labels integer_label
DW_TAG_subprogram {
- {name main}
- {low_pc $main_start addr}
- {high_pc $main_length data8}
- {DW_AT_type :$integer_label}
- {DW_AT_decl_file 1 data1}
- {DW_AT_decl_line 10 data1}
+ DW_AT_name main
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc $main_length data8
+ DW_AT_type :$integer_label
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line 10 data1
}
integer_label: DW_TAG_base_type {
- {DW_AT_byte_size $int_size DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
+ DW_AT_byte_size $int_size DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
}
}
}
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C}
- {DW_AT_name $srcfile2}
- {DW_AT_comp_dir ${srcdir}/${subdir}}
- {stmt_list $L2 DW_FORM_sec_offset}
- {ranges ${ranges_label_2} DW_FORM_sec_offset}
- {DW_AT_low_pc 0 addr}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name $srcfile2
+ DW_AT_comp_dir ${srcdir}/${subdir}
+ DW_AT_stmt_list $L2 DW_FORM_sec_offset
+ DW_AT_ranges ${ranges_label_2} DW_FORM_sec_offset
+ DW_AT_low_pc 0 addr
} {
declare_labels integer_label
DW_TAG_subprogram {
- {name some_func}
- {low_pc some_func addr}
- {high_pc some_func_end addr}
- {DW_AT_type :$integer_label}
- {DW_AT_decl_file 2 data1}
- {DW_AT_decl_line 5 data1}
+ DW_AT_name some_func
+ DW_AT_low_pc some_func addr
+ DW_AT_high_pc some_func_end addr
+ DW_AT_type :$integer_label
+ DW_AT_decl_file 2 data1
+ DW_AT_decl_line 5 data1
}
integer_label: DW_TAG_base_type {
- {DW_AT_byte_size $int_size DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
+ DW_AT_byte_size $int_size DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
}
}
}
@@ -170,7 +170,7 @@ if { [build_executable ${testfile}.exp ${testfile} \
proc run_test { goto_main } {
global binfile decimal hex
- clean_restart ${binfile}
+ clean_restart ${::testfile}
if { $goto_main } {
if ![runto_main] {
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bad-mips-linkage-name.exp b/gdb/testsuite/gdb.dwarf2/dw2-bad-mips-linkage-name.exp
index f2534cb..ad65842 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-bad-mips-linkage-name.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-bad-mips-linkage-name.exp
@@ -28,27 +28,26 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C_plus_plus}
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir /tmp}
-
- } {
+ DW_AT_language @DW_LANG_C_plus_plus
+ DW_AT_name $srcfile
+ DW_AT_comp_dir /tmp
+ } {
declare_labels b_l
b_l: DW_TAG_base_type {
- {DW_AT_byte_size 1 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name bool}
+ DW_AT_byte_size 1 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name bool
}
- DW_TAG_subprogram {
- {MACRO_AT_func {f}}
- {type :$b_l}
- {DW_AT_MIPS_linkage_name _Z1fv}
+ DW_TAG_subprogram {
+ MACRO_AT_func {f}
+ DW_AT_type :$b_l
+ DW_AT_MIPS_linkage_name _Z1fv
}
- DW_TAG_subprogram {
- {MACRO_AT_func {g}}
- {type :$b_l}
- {DW_AT_MIPS_linkage_name 42 DW_FORM_data1}
+ DW_TAG_subprogram {
+ MACRO_AT_func {g}
+ DW_AT_type :$b_l
+ DW_AT_MIPS_linkage_name 42 DW_FORM_data1
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bad-unresolved.exp b/gdb/testsuite/gdb.dwarf2/dw2-bad-unresolved.exp
index fd2c899..dba8d5e 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-bad-unresolved.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-bad-unresolved.exp
@@ -30,21 +30,21 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C}
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir /tmp}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name $srcfile
+ DW_AT_comp_dir /tmp
} {
declare_labels b_l
b_l: DW_TAG_base_type {
- {DW_AT_byte_size 1 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name bool}
+ DW_AT_byte_size 1 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name bool
}
DW_TAG_variable {
- {name var}
- {type :$b_l}
- {external 1 flag}
+ DW_AT_name var
+ DW_AT_type :$b_l
+ DW_AT_external 1 flag
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bfloat16.exp b/gdb/testsuite/gdb.dwarf2/dw2-bfloat16.exp
index c611ad2..b8f96a1 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-bfloat16.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-bfloat16.exp
@@ -32,35 +32,35 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C}
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir /tmp}
- } {
+ DW_AT_language @DW_LANG_C
+ DW_AT_name $srcfile
+ DW_AT_comp_dir /tmp
+ } {
declare_labels bf16_type fp16_type \
bf16_var fp16_var
- bf16_type: DW_TAG_base_type {
- {DW_AT_name __bf16}
- {encoding @DW_ATE_float}
- {DW_AT_byte_size 2 DW_FORM_sdata}
- }
+ bf16_type: DW_TAG_base_type {
+ DW_AT_name __bf16
+ DW_AT_encoding @DW_ATE_float
+ DW_AT_byte_size 2 DW_FORM_sdata
+ }
- fp16_type: DW_TAG_base_type {
- {DW_AT_name __fp16}
- {encoding @DW_ATE_float}
- {DW_AT_byte_size 2 DW_FORM_sdata}
- }
+ fp16_type: DW_TAG_base_type {
+ DW_AT_name __fp16
+ DW_AT_encoding @DW_ATE_float
+ DW_AT_byte_size 2 DW_FORM_sdata
+ }
bf16_var: DW_TAG_variable {
- {DW_AT_name "bf16_1"}
- {DW_AT_type :${bf16_type}}
- {DW_AT_const_value 0x4049 DW_FORM_sdata}
+ DW_AT_name "bf16_1"
+ DW_AT_type :${bf16_type}
+ DW_AT_const_value 0x4049 DW_FORM_sdata
}
fp16_var: DW_TAG_variable {
- {DW_AT_name "fp16_1"}
- {DW_AT_type :${fp16_type}}
- {DW_AT_const_value 0x4248 DW_FORM_sdata}
+ DW_AT_name "fp16_1"
+ DW_AT_type :${fp16_type}
+ DW_AT_const_value 0x4248 DW_FORM_sdata
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-complex-parts.exp b/gdb/testsuite/gdb.dwarf2/dw2-complex-parts.exp
index 34746f2..509924a 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-complex-parts.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-complex-parts.exp
@@ -52,14 +52,14 @@ Dwarf::assemble $asm_file {
declare_labels int_type
int_type: DW_TAG_base_type {
- {DW_AT_byte_size $::int_size DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name int}
+ DW_AT_byte_size $::int_size DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int
}
DW_TAG_subprogram {
- {MACRO_AT_func {main}}
- {type :$int_type}
+ MACRO_AT_func {main}
+ DW_AT_type :$int_type
}
# GCC complex float.
@@ -67,36 +67,36 @@ Dwarf::assemble $asm_file {
declare_labels cf_type cd_type cld_type
cf_type: DW_TAG_base_type {
- {DW_AT_byte_size [expr 2 * $::float_size] DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_complex_float}
- {DW_AT_name "complex float"}
+ DW_AT_byte_size [expr 2 * $::float_size] DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_complex_float
+ DW_AT_name "complex float"
}
cd_type: DW_TAG_base_type {
- {DW_AT_byte_size [expr 2 * $::double_size] DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_complex_float}
- {DW_AT_name "complex double"}
+ DW_AT_byte_size [expr 2 * $::double_size] DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_complex_float
+ DW_AT_name "complex double"
}
cld_type: DW_TAG_base_type {
- {DW_AT_byte_size [expr 2 * $::long_double_size] DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_complex_float}
- {DW_AT_name "complex long double"}
+ DW_AT_byte_size [expr 2 * $::long_double_size] DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_complex_float
+ DW_AT_name "complex long double"
}
DW_TAG_variable {
- {name var_complex_float}
- {DW_AT_type :$cf_type}
+ DW_AT_name var_complex_float
+ DW_AT_type :$cf_type
}
DW_TAG_variable {
- {name var_complex_double}
- {DW_AT_type :$cd_type}
+ DW_AT_name var_complex_double
+ DW_AT_type :$cd_type
}
DW_TAG_variable {
- {name var_complex_long_double}
- {DW_AT_type :$cld_type}
+ DW_AT_name var_complex_long_double
+ DW_AT_type :$cld_type
}
# GCC complex int.
@@ -105,14 +105,14 @@ Dwarf::assemble $asm_file {
declare_labels ci_type
ci_type: DW_TAG_base_type {
- {DW_AT_byte_size [expr 2 * $::int_size] DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_lo_user}
- {DW_AT_name "complex int"}
+ DW_AT_byte_size [expr 2 * $::int_size] DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_lo_user
+ DW_AT_name "complex int"
}
DW_TAG_variable {
- {name var_complex_int}
- {DW_AT_type :$ci_type}
+ DW_AT_name var_complex_int
+ DW_AT_type :$ci_type
}
# Clang complex float.
@@ -122,36 +122,36 @@ Dwarf::assemble $asm_file {
declare_labels clang_cf_type clang_cd_type clang_cld_type
clang_cf_type: DW_TAG_base_type {
- {DW_AT_byte_size [expr 2 * $::float_size] DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_complex_float}
- {DW_AT_name "complex"}
+ DW_AT_byte_size [expr 2 * $::float_size] DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_complex_float
+ DW_AT_name "complex"
}
DW_TAG_variable {
- {name var_complex_clang_float}
- {DW_AT_type :$clang_cf_type}
+ DW_AT_name var_complex_clang_float
+ DW_AT_type :$clang_cf_type
}
clang_cd_type: DW_TAG_base_type {
- {DW_AT_byte_size [expr 2 * $::double_size] DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_complex_float}
- {DW_AT_name "complex"}
+ DW_AT_byte_size [expr 2 * $::double_size] DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_complex_float
+ DW_AT_name "complex"
}
DW_TAG_variable {
- {name var_complex_clang_double}
- {DW_AT_type :$clang_cd_type}
+ DW_AT_name var_complex_clang_double
+ DW_AT_type :$clang_cd_type
}
clang_cld_type: DW_TAG_base_type {
- {DW_AT_byte_size [expr 2 * $::long_double_size] DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_complex_float}
- {DW_AT_name "complex"}
+ DW_AT_byte_size [expr 2 * $::long_double_size] DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_complex_float
+ DW_AT_name "complex"
}
DW_TAG_variable {
- {name var_complex_clang_long_double}
- {DW_AT_type :$clang_cld_type}
+ DW_AT_name var_complex_clang_long_double
+ DW_AT_type :$clang_cld_type
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-disasm-over-non-stmt.exp b/gdb/testsuite/gdb.dwarf2/dw2-disasm-over-non-stmt.exp
index cec1017..ddbab26 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-disasm-over-non-stmt.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-disasm-over-non-stmt.exp
@@ -43,15 +43,15 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {producer "gcc" }
- {language @DW_LANG_C}
- {name ${srcfile3}}
- {low_pc 0 addr}
- {stmt_list ${lines_label} DW_FORM_sec_offset}
+ DW_AT_producer "gcc"
+ DW_AT_language @DW_LANG_C
+ DW_AT_name ${srcfile3}
+ DW_AT_low_pc 0 addr
+ DW_AT_stmt_list ${lines_label} DW_FORM_sec_offset
} {
subprogram {
- {external 1 flag}
- {MACRO_AT_func {main}}
+ DW_AT_external 1 flag
+ MACRO_AT_func {main}
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-empty-file-name.exp b/gdb/testsuite/gdb.dwarf2/dw2-empty-file-name.exp
index 85b6f8b..2a32433 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-empty-file-name.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-empty-file-name.exp
@@ -33,13 +33,13 @@ Dwarf::assemble $asm_file {
cu { version 5 } {
compile_unit {
- {language @DW_LANG_C}
- {name $srcfile}
- {stmt_list $Llines DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name $srcfile
+ DW_AT_stmt_list $Llines DW_FORM_sec_offset
} {
subprogram {
- {external 1 flag}
- {MACRO_AT_func {main}}
+ DW_AT_external 1 flag
+ MACRO_AT_func {main}
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-entry-pc.exp b/gdb/testsuite/gdb.dwarf2/dw2-entry-pc.exp
index e795040..1a0eeba 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-entry-pc.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-entry-pc.exp
@@ -159,20 +159,20 @@ proc_with_prefix use_low_high_bounds_without_entry_pc { dwarf_vesion } {
cu { version $::dwarf_version } {
compile_unit {
- {producer "gcc"}
- {language @DW_LANG_C}
- {name ${srcfile}}
- {comp_dir /tmp}
- {stmt_list $lines_table DW_FORM_sec_offset}
+ DW_AT_producer "gcc"
+ DW_AT_language @DW_LANG_C
+ DW_AT_name ${srcfile}
+ DW_AT_comp_dir /tmp
+ DW_AT_stmt_list $lines_table DW_FORM_sec_offset
} {
subprogram {
- {name foo}
- {decl_file 1 data1}
- {decl_line $::foo_decl_line data1}
- {decl_column 1 data1}
- {low_pc $::foo_start addr}
- {high_pc $::foo_len $::ptr_type}
- {external 1 flag}
+ DW_AT_name foo
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line $::foo_decl_line data1
+ DW_AT_decl_column 1 data1
+ DW_AT_low_pc $::foo_start addr
+ DW_AT_high_pc $::foo_len $::ptr_type
+ DW_AT_external 1 flag
}
}
}
@@ -202,21 +202,21 @@ proc_with_prefix use_low_high_bounds_with_entry_pc { dwarf_version } {
cu { version $::dwarf_version } {
compile_unit {
- {producer "gcc"}
- {language @DW_LANG_C}
- {name ${srcfile}}
- {comp_dir /tmp}
- {stmt_list $lines_table DW_FORM_sec_offset}
+ DW_AT_producer "gcc"
+ DW_AT_language @DW_LANG_C
+ DW_AT_name ${srcfile}
+ DW_AT_comp_dir /tmp
+ DW_AT_stmt_list $lines_table DW_FORM_sec_offset
} {
subprogram {
- {name foo}
- {decl_file 1 data1}
- {decl_line $::foo_decl_line data1}
- {decl_column 1 data1}
- {low_pc $::foo_start addr}
- {high_pc $::foo_len $::ptr_type}
- {external 1 flag}
- {entry_pc foo_middle addr}
+ DW_AT_name foo
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line $::foo_decl_line data1
+ DW_AT_decl_column 1 data1
+ DW_AT_low_pc $::foo_start addr
+ DW_AT_high_pc $::foo_len $::ptr_type
+ DW_AT_external 1 flag
+ DW_AT_entry_pc foo_middle addr
}
}
}
@@ -248,21 +248,21 @@ proc_with_prefix use_low_high_bounds_with_entry_offset { dwarf_version } {
cu { version $::dwarf_version } {
compile_unit {
- {producer "gcc"}
- {language @DW_LANG_C}
- {name ${srcfile}}
- {comp_dir /tmp}
- {stmt_list $lines_table DW_FORM_sec_offset}
+ DW_AT_producer "gcc"
+ DW_AT_language @DW_LANG_C
+ DW_AT_name ${srcfile}
+ DW_AT_comp_dir /tmp
+ DW_AT_stmt_list $lines_table DW_FORM_sec_offset
} {
subprogram {
- {name foo}
- {decl_file 1 data1}
- {decl_line $::foo_decl_line data1}
- {decl_column 1 data1}
- {low_pc $::foo_start addr}
- {high_pc $::foo_len $::ptr_type}
- {external 1 flag}
- {entry_pc $foo_offset data4}
+ DW_AT_name foo
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line $::foo_decl_line data1
+ DW_AT_decl_column 1 data1
+ DW_AT_low_pc $::foo_start addr
+ DW_AT_high_pc $::foo_len $::ptr_type
+ DW_AT_external 1 flag
+ DW_AT_entry_pc $foo_offset data4
}
}
}
@@ -293,20 +293,20 @@ proc_with_prefix use_ranges_without_entry_pc { dwarf_version } {
cu { version $::dwarf_version } {
compile_unit {
- {producer "gcc"}
- {language @DW_LANG_C}
- {name ${srcfile}}
- {comp_dir /tmp}
- {stmt_list $lines_table DW_FORM_sec_offset}
- {low_pc 0 addr}
+ DW_AT_producer "gcc"
+ DW_AT_language @DW_LANG_C
+ DW_AT_name ${srcfile}
+ DW_AT_comp_dir /tmp
+ DW_AT_stmt_list $lines_table DW_FORM_sec_offset
+ DW_AT_low_pc 0 addr
} {
subprogram {
- {name foo}
- {decl_file 1 data1}
- {decl_line $::foo_decl_line data1}
- {decl_column 1 data1}
- {external 1 flag}
- {ranges ${ranges_label} DW_FORM_sec_offset}
+ DW_AT_name foo
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line $::foo_decl_line data1
+ DW_AT_decl_column 1 data1
+ DW_AT_external 1 flag
+ DW_AT_ranges ${ranges_label} DW_FORM_sec_offset
}
}
}
@@ -357,21 +357,21 @@ proc_with_prefix use_ranges_with_entry_pc { dwarf_version } {
cu { version $::dwarf_version } {
compile_unit {
- {producer "gcc"}
- {language @DW_LANG_C}
- {name ${srcfile}}
- {comp_dir /tmp}
- {stmt_list $lines_table DW_FORM_sec_offset}
- {low_pc 0 addr}
+ DW_AT_producer "gcc"
+ DW_AT_language @DW_LANG_C
+ DW_AT_name ${srcfile}
+ DW_AT_comp_dir /tmp
+ DW_AT_stmt_list $lines_table DW_FORM_sec_offset
+ DW_AT_low_pc 0 addr
} {
subprogram {
- {name foo}
- {decl_file 1 data1}
- {decl_line $::foo_decl_line data1}
- {decl_column 1 data1}
- {external 1 flag}
- {ranges ${ranges_label} DW_FORM_sec_offset}
- {entry_pc foo_middle addr}
+ DW_AT_name foo
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line $::foo_decl_line data1
+ DW_AT_decl_column 1 data1
+ DW_AT_external 1 flag
+ DW_AT_ranges ${ranges_label} DW_FORM_sec_offset
+ DW_AT_entry_pc foo_middle addr
}
}
}
@@ -424,21 +424,21 @@ proc_with_prefix use_ranges_with_entry_offset { dwarf_version } {
cu { version $::dwarf_version } {
compile_unit {
- {producer "gcc"}
- {language @DW_LANG_C}
- {name ${srcfile}}
- {comp_dir /tmp}
- {stmt_list $lines_table DW_FORM_sec_offset}
- {low_pc 0 addr}
+ DW_AT_producer "gcc"
+ DW_AT_language @DW_LANG_C
+ DW_AT_name ${srcfile}
+ DW_AT_comp_dir /tmp
+ DW_AT_stmt_list $lines_table DW_FORM_sec_offset
+ DW_AT_low_pc 0 addr
} {
subprogram {
- {name foo}
- {decl_file 1 data1}
- {decl_line $::foo_decl_line data1}
- {decl_column 1 data1}
- {external 1 flag}
- {ranges ${ranges_label} DW_FORM_sec_offset}
- {entry_pc $foo_offset data4}
+ DW_AT_name foo
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line $::foo_decl_line data1
+ DW_AT_decl_column 1 data1
+ DW_AT_external 1 flag
+ DW_AT_ranges ${ranges_label} DW_FORM_sec_offset
+ DW_AT_entry_pc $foo_offset data4
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-entry-points.c b/gdb/testsuite/gdb.dwarf2/dw2-entry-points.c
index ccfb150..258ebfa 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-entry-points.c
+++ b/gdb/testsuite/gdb.dwarf2/dw2-entry-points.c
@@ -33,11 +33,28 @@ bar_helper (void)
asm ("foobar_entry_label: .globl foobar_entry_label");
}
+__attribute__ ((noinline))
+void
+barso_helper (void)
+{
+ asm ("barso_helper_label: .globl barso_helper_label");
+ I++;
+ J++;
+ asm ("fooso_entry_label: .globl fooso_entry_label");
+ J++;
+ K++;
+ asm ("foobarso_entry_label: .globl foobarso_entry_label");
+}
+
int
main (void)
{
asm ("main_label: .globl main_label");
bar_helper ();
+ I = 0;
+ J = 0;
+ K = 0;
+ barso_helper ();
return 0;
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-entry-points.exp b/gdb/testsuite/gdb.dwarf2/dw2-entry-points.exp
index bd22560..97194d5 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-entry-points.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-entry-points.exp
@@ -36,6 +36,7 @@ Dwarf::assemble $asm_file {
get_func_info main
get_func_info bar_helper
+ get_func_info barso_helper
set int_size [get_sizeof "int" 4]
@@ -50,69 +51,69 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_Fortran90}
- {name dw2-entry-points.f90}
- {comp_dir /tmp}
+ DW_AT_language @DW_LANG_Fortran90
+ DW_AT_name dw2-entry-points.f90
+ DW_AT_comp_dir /tmp
} {
int_label: base_type {
- {name "int"}
- {byte_size $int_size sdata}
- {encoding @DW_ATE_signed}
+ DW_AT_name "int"
+ DW_AT_byte_size $int_size sdata
+ DW_AT_encoding @DW_ATE_signed
}
subprogram {
- {name prog}
- {decl_file 1 data1}
- {decl_line $prog_line data1}
- {low_pc $main_start addr}
- {high_pc "$main_start + $main_len" addr}
- {external 1 flag}
- {main_subprogram 1 flag}
+ DW_AT_name prog
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line $prog_line data1
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc "$main_start + $main_len" addr
+ DW_AT_external 1 flag
+ DW_AT_main_subprogram 1 flag
}
subprogram {
- {name bar}
- {decl_file 1 data1}
- {decl_line $bar_line data1}
- {external 1 flag}
- {low_pc $bar_helper_start addr}
- {high_pc "$bar_helper_start + $bar_helper_len" addr}
+ DW_AT_name bar
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line $bar_line data1
+ DW_AT_external 1 flag
+ DW_AT_low_pc $bar_helper_start addr
+ DW_AT_high_pc "$bar_helper_start + $bar_helper_len" addr
} {
formal_parameter {
- {name I}
- {type :$int_label}
- {location {addr $global_I} SPECIAL_expr}
+ DW_AT_name I
+ DW_AT_type :$int_label
+ DW_AT_location [subst {addr $global_I}] SPECIAL_expr
}
formal_parameter {
- {name J}
- {type :$int_label}
- {location {addr $global_J} SPECIAL_expr}
+ DW_AT_name J
+ DW_AT_type :$int_label
+ DW_AT_location [subst {addr $global_J}] SPECIAL_expr
}
entry_point {
- {name foo}
- {decl_file 1 data1}
- {decl_line $foo_line data1}
- {low_pc foo_entry_label addr}
+ DW_AT_name foo
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line $foo_line data1
+ DW_AT_low_pc foo_entry_label addr
} {
formal_parameter {
- {name J}
- {type :$int_label}
- {location {addr $global_J} SPECIAL_expr}
+ DW_AT_name J
+ DW_AT_type :$int_label
+ DW_AT_location [subst {addr $global_J}] SPECIAL_expr
}
formal_parameter {
- {name K}
- {type :$int_label}
- {location {addr $global_K} SPECIAL_expr}
+ DW_AT_name K
+ DW_AT_type :$int_label
+ DW_AT_location [subst {addr $global_K}] SPECIAL_expr
}
}
entry_point {
- {name foobar}
- {decl_file 1 data1}
- {decl_line $foobar_line data1}
- {low_pc foobar_entry_label addr}
+ DW_AT_name foobar
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line $foobar_line data1
+ DW_AT_low_pc foobar_entry_label addr
} {
formal_parameter {
- {name J}
- {type :$int_label}
- {location {addr $global_J} SPECIAL_expr}
+ DW_AT_name J
+ DW_AT_type :$int_label
+ DW_AT_location [subst {addr $global_J}] SPECIAL_expr
}
}
}
@@ -121,48 +122,48 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_Fortran90}
- {name dw2-entry-points-2.f90}
- {comp_dir /tmp}
+ DW_AT_language @DW_LANG_Fortran90
+ DW_AT_name dw2-entry-points-2.f90
+ DW_AT_comp_dir /tmp
} {
int2_label: base_type {
- {name "int"}
- {byte_size $int_size sdata}
- {encoding @DW_ATE_signed}
+ DW_AT_name "int"
+ DW_AT_byte_size $int_size sdata
+ DW_AT_encoding @DW_ATE_signed
}
subprogram {
- {name barso}
- {decl_file 1 data1}
- {decl_line $bar_line data1}
- {external 1 flag}
- {low_pc $bar_helper_start addr}
- {high_pc "$bar_helper_start + $bar_helper_len" addr}
+ DW_AT_name barso
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line $bar_line data1
+ DW_AT_external 1 flag
+ DW_AT_low_pc $barso_helper_start addr
+ DW_AT_high_pc "$barso_helper_start + $barso_helper_len" addr
} {
formal_parameter {
- {name I}
- {type :$int2_label}
- {location {addr $global_I} SPECIAL_expr}
+ DW_AT_name I
+ DW_AT_type :$int2_label
+ DW_AT_location [subst {addr $global_I}] SPECIAL_expr
}
formal_parameter {
- {name J}
- {type :$int2_label}
- {location {addr $global_J} SPECIAL_expr}
+ DW_AT_name J
+ DW_AT_type :$int2_label
+ DW_AT_location [subst {addr $global_J}] SPECIAL_expr
}
entry_point {
- {name fooso}
- {decl_file 1 data1}
- {decl_line $foo_line data1}
- {low_pc foo_entry_label addr}
+ DW_AT_name fooso
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line $foo_line data1
+ DW_AT_low_pc fooso_entry_label addr
} {
formal_parameter {
- {name J}
- {type :$int2_label}
- {location {addr $global_J} SPECIAL_expr}
+ DW_AT_name J
+ DW_AT_type :$int2_label
+ DW_AT_location [subst {addr $global_J}] SPECIAL_expr
}
formal_parameter {
- {name K}
- {type :$int2_label}
- {location {addr $global_K} SPECIAL_expr}
+ DW_AT_name K
+ DW_AT_type :$int2_label
+ DW_AT_location [subst {addr $global_K}] SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-entry-value-2.exp b/gdb/testsuite/gdb.dwarf2/dw2-entry-value-2.exp
index 55ecf9c..7dd859c 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-entry-value-2.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-entry-value-2.exp
@@ -45,47 +45,47 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_name $srcfile}
+ DW_AT_name $srcfile
} {
declare_labels integer
integer: DW_TAG_base_type {
- {DW_AT_byte_size 8 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
+ DW_AT_byte_size 8 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
}
DW_TAG_subprogram {
- { DW_AT_name main }
- { DW_AT_low_pc $main_start DW_FORM_addr }
- { DW_AT_high_pc $main_end DW_FORM_addr }
+ DW_AT_name main
+ DW_AT_low_pc $main_start DW_FORM_addr
+ DW_AT_high_pc $main_end DW_FORM_addr
} {
DW_TAG_variable {
- { DW_AT_name argc }
- { DW_AT_type :$integer }
- { DW_AT_location {
+ DW_AT_name argc
+ DW_AT_type :$integer
+ DW_AT_location [subst {
DW_OP_entry_value {
DW_OP_regx $::dwarf_regnum
}
- } SPECIAL_expr }
+ }] SPECIAL_expr
}
}
DW_TAG_subprogram {
- { DW_AT_name bar }
- { DW_AT_low_pc $bar_start DW_FORM_addr }
- { DW_AT_high_pc $bar_end DW_FORM_addr }
+ DW_AT_name bar
+ DW_AT_low_pc $bar_start DW_FORM_addr
+ DW_AT_high_pc $bar_end DW_FORM_addr
} {
DW_TAG_variable {
- { DW_AT_name foo }
- { DW_AT_type :$integer }
- { DW_AT_location {
+ DW_AT_name foo
+ DW_AT_type :$integer
+ DW_AT_location [subst {
DW_OP_entry_value {
DW_OP_bregx $::dwarf_regnum 0
DW_OP_deref_size 4
}
DW_OP_stack_value
- } SPECIAL_expr }
+ }] SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp.tcl b/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp.tcl
index 954a252..7e60b6e 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp.tcl
+++ b/gdb/testsuite/gdb.dwarf2/dw2-epilogue-begin.exp.tcl
@@ -56,42 +56,42 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name dw2-prologue-end.c}
- {stmt_list ${lines_label} DW_FORM_sec_offset}
- {producer "clang version 17.0.1"}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name dw2-prologue-end.c
+ DW_AT_stmt_list ${lines_label} DW_FORM_sec_offset
+ DW_AT_producer "clang version 17.0.1"
} {
declare_labels char_label
char_label: base_type {
- {name char}
- {encoding @DW_ATE_signed}
- {byte_size 1 DW_FORM_sdata}
+ DW_AT_name char
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 1 DW_FORM_sdata
}
subprogram {
- {external 1 flag}
- {name trivial}
- {low_pc $trivial_start addr}
- {high_pc "$trivial_start + $trivial_len" addr}
+ DW_AT_external 1 flag
+ DW_AT_name trivial
+ DW_AT_low_pc $trivial_start addr
+ DW_AT_high_pc "$trivial_start + $trivial_len" addr
}
subprogram {
- {external 1 flag}
- {name watch}
- {low_pc $watch_start addr}
- {high_pc "$watch_start + $watch_len" addr}
+ DW_AT_external 1 flag
+ DW_AT_name watch
+ DW_AT_low_pc $watch_start addr
+ DW_AT_high_pc "$watch_start + $watch_len" addr
} {
DW_TAG_variable {
- {name local}
- {type :$char_label}
- {DW_AT_location {DW_OP_reg0} SPECIAL_expr}
+ DW_AT_name local
+ DW_AT_type :$char_label
+ DW_AT_location {DW_OP_reg0} SPECIAL_expr
}
}
subprogram {
- {external 1 flag}
- {name main}
- {low_pc $main_start addr}
- {high_pc "$main_start + $main_len" addr}
+ DW_AT_external 1 flag
+ DW_AT_name main
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc "$main_start + $main_len" addr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-fixed-point.exp b/gdb/testsuite/gdb.dwarf2/dw2-fixed-point.exp
index a8ade90..7666089 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-fixed-point.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-fixed-point.exp
@@ -23,91 +23,91 @@ standard_testfile dw2-fixed-point.c dw2-fixed-point-dw.S
set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu {} {
- DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_Ada95}
- {DW_AT_name pck.ads}
- {DW_AT_comp_dir /tmp}
- } {
- declare_labels fp1_base_type fp2_base_type fp3_small \
- fp3_base_type fp1_range_type
-
- fp1_base_type: DW_TAG_base_type {
- {DW_AT_byte_size 1 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed_fixed}
- {DW_AT_name pck__fp1_type}
- {DW_AT_binary_scale -4 DW_FORM_sdata}
- }
-
- DW_TAG_variable {
- {DW_AT_name pck__fp1_var}
- {DW_AT_type :$fp1_base_type}
- {DW_AT_location {
- DW_OP_addr [gdb_target_symbol pck__fp1_var]
- } SPECIAL_expr}
- {external 1 flag}
- }
-
- DW_TAG_variable {
- {DW_AT_name pck__fp1_var2}
- {DW_AT_type :$fp1_base_type}
- {DW_AT_location {
- DW_OP_addr [gdb_target_symbol pck__fp1_var2]
- } SPECIAL_expr}
- {external 1 flag}
- }
-
- fp2_base_type: DW_TAG_base_type {
- {DW_AT_byte_size 1 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed_fixed}
- {DW_AT_name pck__fp2_type}
- {DW_AT_decimal_scale -2 DW_FORM_sdata}
- }
-
- DW_TAG_variable {
- {DW_AT_name pck__fp2_var}
- {DW_AT_type :$fp2_base_type}
- {DW_AT_location {
- DW_OP_addr [gdb_target_symbol pck__fp2_var]
- } SPECIAL_expr}
- {external 1 flag}
- }
-
- fp3_small: DW_TAG_constant {
- {DW_AT_GNU_numerator 1 DW_FORM_data1}
- {DW_AT_GNU_denominator 30 DW_FORM_sdata}
- }
-
- fp3_base_type: DW_TAG_base_type {
- {DW_AT_byte_size 1 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed_fixed}
- {DW_AT_name pck__fp3_type}
- {DW_AT_small :$fp3_small}
- }
-
- DW_TAG_variable {
- {DW_AT_name pck__fp3_var}
- {DW_AT_type :$fp3_base_type}
- {DW_AT_location {
- DW_OP_addr [gdb_target_symbol pck__fp3_var]
- } SPECIAL_expr}
- {external 1 flag}
- }
-
- fp1_range_type: DW_TAG_subrange_type {
- {DW_AT_lower_bound 0xf0 DW_FORM_data1}
- {DW_AT_upper_bound 0x10 DW_FORM_data1}
- {DW_AT_name foo__fp1_range_type}
- {DW_AT_type :$fp1_base_type}
- }
-
- DW_TAG_variable {
- {DW_AT_name pck__fp1_range_var}
- {DW_AT_type :$fp1_range_type}
- {DW_AT_location {
- DW_OP_addr [gdb_target_symbol pck__fp1_range_var]
- } SPECIAL_expr}
- {external 1 flag}
- }
+ DW_TAG_compile_unit {
+ DW_AT_language @DW_LANG_Ada95
+ DW_AT_name pck.ads
+ DW_AT_comp_dir /tmp
+ } {
+ declare_labels fp1_base_type fp2_base_type fp3_small \
+ fp3_base_type fp1_range_type
+
+ fp1_base_type: DW_TAG_base_type {
+ DW_AT_byte_size 1 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed_fixed
+ DW_AT_name pck__fp1_type
+ DW_AT_binary_scale -4 DW_FORM_sdata
+ }
+
+ DW_TAG_variable {
+ DW_AT_name pck__fp1_var
+ DW_AT_type :$fp1_base_type
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol pck__fp1_var]
+ }] SPECIAL_expr
+ DW_AT_external 1 flag
+ }
+
+ DW_TAG_variable {
+ DW_AT_name pck__fp1_var2
+ DW_AT_type :$fp1_base_type
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol pck__fp1_var2]
+ }] SPECIAL_expr
+ DW_AT_external 1 flag
+ }
+
+ fp2_base_type: DW_TAG_base_type {
+ DW_AT_byte_size 1 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed_fixed
+ DW_AT_name pck__fp2_type
+ DW_AT_decimal_scale -2 DW_FORM_sdata
+ }
+
+ DW_TAG_variable {
+ DW_AT_name pck__fp2_var
+ DW_AT_type :$fp2_base_type
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol pck__fp2_var]
+ }] SPECIAL_expr
+ DW_AT_external 1 flag
+ }
+
+ fp3_small: DW_TAG_constant {
+ DW_AT_GNU_numerator 1 DW_FORM_data1
+ DW_AT_GNU_denominator 30 DW_FORM_sdata
+ }
+
+ fp3_base_type: DW_TAG_base_type {
+ DW_AT_byte_size 1 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed_fixed
+ DW_AT_name pck__fp3_type
+ DW_AT_small :$fp3_small
+ }
+
+ DW_TAG_variable {
+ DW_AT_name pck__fp3_var
+ DW_AT_type :$fp3_base_type
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol pck__fp3_var]
+ }] SPECIAL_expr
+ DW_AT_external 1 flag
+ }
+
+ fp1_range_type: DW_TAG_subrange_type {
+ DW_AT_lower_bound 0xf0 DW_FORM_data1
+ DW_AT_upper_bound 0x10 DW_FORM_data1
+ DW_AT_name foo__fp1_range_type
+ DW_AT_type :$fp1_base_type
+ }
+
+ DW_TAG_variable {
+ DW_AT_name pck__fp1_range_var
+ DW_AT_type :$fp1_range_type
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol pck__fp1_range_var]
+ }] SPECIAL_expr
+ DW_AT_external 1 flag
+ }
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-gas-workaround.exp b/gdb/testsuite/gdb.dwarf2/dw2-gas-workaround.exp
index 25a73a6..6611bf3 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-gas-workaround.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-gas-workaround.exp
@@ -20,7 +20,7 @@ load_lib dwarf.exp
# This test can only be run on targets which support DWARF-2 and use gas.
require dwarf2_support
-standard_testfile dw2-lines.c -dw2.S
+standard_testfile dw2-lines.c -dw2.S -dw2-one-diridx.S
with_shared_gdb {
set func_info_vars [get_func_info bar]
@@ -33,49 +33,61 @@ proc line_for { l } {
return [expr $line + 1]
}
-set asm_file [standard_output_file $srcfile2]
-Dwarf::assemble $asm_file {
- declare_labels Llines
- global srcdir subdir srcfile objdir
- global func_info_vars
- foreach var $func_info_vars {
- global $var
- }
+# A helper proc to create the DWARF assembly for the test.
+# If ONE_DIRIDX is true, then the directory table will be limited
+# to one entry.
+proc create_dwarf_assembly {source_file one_diridx} {
+ set asm_file [standard_output_file $source_file]
+ Dwarf::assemble $asm_file {
+ declare_labels Llines
+ global srcdir subdir srcfile objdir
+ global func_info_vars
+ upvar one_diridx one_diridx
+ foreach var $func_info_vars {
+ global $var
+ }
- cu { version 5 } {
- compile_unit {
- {language @DW_LANG_Mips_Assembler}
- {name $srcfile}
- {comp_dir $objdir}
- {stmt_list $Llines DW_FORM_sec_offset}
- {producer "GNU AS 2.35.2"}
- } {
- subprogram {
- {external 1 flag}
- {name bar}
- {low_pc $bar_start addr}
- {high_pc "$bar_start + $bar_len" addr}
+ cu { version 5 } {
+ compile_unit {
+ DW_AT_language @DW_LANG_Mips_Assembler
+ DW_AT_name $srcfile
+ DW_AT_comp_dir $objdir
+ DW_AT_stmt_list $Llines DW_FORM_sec_offset
+ DW_AT_producer "GNU AS 2.35.2"
+ } {
+ subprogram {
+ DW_AT_external 1 flag
+ DW_AT_name bar
+ DW_AT_low_pc $bar_start addr
+ DW_AT_high_pc "$bar_start + $bar_len" addr
+ }
}
}
- }
- lines [list version 5] Llines {
- set diridx1 [include_dir "${srcdir}/${subdir}"]
- set diridx2 [include_dir "${srcdir}/${subdir}"]
- file_name "$srcfile" $diridx1
- file_name "$srcfile" $diridx2
-
- program {
- DW_LNE_set_address bar_label
- line [line_for bar_label]
- DW_LNS_copy
+ lines [list version 5] Llines {
+ set diridx1 [include_dir "${srcdir}/${subdir}"]
+ file_name "$srcfile" $diridx1
+ if {!$one_diridx} {
+ set diridx2 [include_dir "${srcdir}/${subdir}"]
+ file_name "$srcfile" $diridx2
+ } else {
+ file_name "$srcfile" $diridx1
+ }
+ program {
+ DW_LNE_set_address bar_label
+ line [line_for bar_label]
+ DW_LNS_copy
- DW_LNE_set_address $bar_end
- DW_LNE_end_sequence
+ DW_LNE_set_address $bar_end
+ DW_LNE_end_sequence
+ }
}
}
+
+ return $asm_file
}
+set asm_file [create_dwarf_assembly $srcfile2 false]
if { [prepare_for_testing "failed to prepare" ${testfile} \
[list $srcfile $asm_file] {nodebug}] } {
return -1
@@ -90,3 +102,13 @@ gdb_test_multiple "ptype bar" "" {
pass $gdb_test_name
}
}
+
+# Test whether gdb crashes in the case where the number of
+# directory indexes is only one.
+set asm_file [create_dwarf_assembly $srcfile3 true]
+if {[prepare_for_testing "failed to prepare" ${testfile}-one-diridx \
+ [list $srcfile $asm_file] {nodebug}] } {
+ return -1
+}
+
+gdb_test "ptype bar" ".*" "do not crash with only one directory table entry"
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-ifort-parameter.exp b/gdb/testsuite/gdb.dwarf2/dw2-ifort-parameter.exp
index 309f9d8..ef48038 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-ifort-parameter.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-ifort-parameter.exp
@@ -29,28 +29,28 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {name file1.txt}
- {language @DW_LANG_C}
- {MACRO_AT_range { func }}
+ DW_AT_name file1.txt
+ DW_AT_language @DW_LANG_C
+ MACRO_AT_range { func }
} {
int_label: base_type {
- {name int}
- {byte_size 4 sdata}
- {encoding @DW_ATE_signed}
+ DW_AT_name int
+ DW_AT_byte_size 4 sdata
+ DW_AT_encoding @DW_ATE_signed
}
subprogram {
- {external 1 flag}
- {MACRO_AT_func { func }}
+ DW_AT_external 1 flag
+ MACRO_AT_func { func }
} {
formal_parameter {
- {name param}
- {variable_parameter 1 flag}
- {type :$int_label}
- {location {
+ DW_AT_name param
+ DW_AT_variable_parameter 1 flag
+ DW_AT_type :$int_label
+ DW_AT_location [subst {
addr [gdb_target_symbol ptr]
deref
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-1.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-1.exp
index 2781cf3..ecf0614 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-1.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-1.exp
@@ -78,29 +78,29 @@ proc do_test { start_label func_name tag } {
cu {} {
compile_unit {
- {producer "gcc" }
- {language @DW_LANG_C}
- {name ${srcfile3}}
- {low_pc 0 addr}
- {stmt_list ${lines_label} DW_FORM_sec_offset}
+ DW_AT_producer "gcc"
+ DW_AT_language @DW_LANG_C
+ DW_AT_name ${srcfile3}
+ DW_AT_low_pc 0 addr
+ DW_AT_stmt_list ${lines_label} DW_FORM_sec_offset
} {
callee_subprog_label: subprogram {
- {external 1 flag}
- {name callee}
- {inline 3 data1}
+ DW_AT_external 1 flag
+ DW_AT_name callee
+ DW_AT_inline 3 data1
}
subprogram {
- {external 1 flag}
- {name main}
- {low_pc $main_start addr}
- {high_pc "$main_start + $main_len" addr}
+ DW_AT_external 1 flag
+ DW_AT_name main
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc "$main_start + $main_len" addr
} {
inlined_subroutine {
- {abstract_origin %$callee_subprog_label}
- {low_pc $start_label addr}
- {high_pc line_label_6 addr}
- {call_file 1 data1}
- {call_line 18 data1}
+ DW_AT_abstract_origin %$callee_subprog_label
+ DW_AT_low_pc $start_label addr
+ DW_AT_high_pc line_label_6 addr
+ DW_AT_call_file 1 data1
+ DW_AT_call_line 18 data1
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-2.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-2.exp
index 2004dfb..3d08ac0 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-2.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-2.exp
@@ -68,29 +68,29 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {producer "gcc" }
- {language @DW_LANG_C}
- {name ${srcfile3}}
- {low_pc 0 addr}
- {stmt_list ${lines_label} DW_FORM_sec_offset}
+ DW_AT_producer "gcc"
+ DW_AT_language @DW_LANG_C
+ DW_AT_name ${srcfile3}
+ DW_AT_low_pc 0 addr
+ DW_AT_stmt_list ${lines_label} DW_FORM_sec_offset
} {
callee_subprog_label: subprogram {
- {external 1 flag}
- {name callee}
- {inline 3 data1}
+ DW_AT_external 1 flag
+ DW_AT_name callee
+ DW_AT_inline 3 data1
}
subprogram {
- {external 1 flag}
- {name main}
- {low_pc $main_start addr}
- {high_pc "$main_start + $main_len" addr}
+ DW_AT_external 1 flag
+ DW_AT_name main
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc "$main_start + $main_len" addr
} {
inlined_subroutine {
- {abstract_origin %$callee_subprog_label}
- {low_pc line_label_3 addr}
- {high_pc line_label_5 addr}
- {call_file 1 data1}
- {call_line 18 data1}
+ DW_AT_abstract_origin %$callee_subprog_label
+ DW_AT_low_pc line_label_3 addr
+ DW_AT_high_pc line_label_5 addr
+ DW_AT_call_file 1 data1
+ DW_AT_call_line 18 data1
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-3.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-3.exp
index f7d220c..ad914b9 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-header-3.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-header-3.exp
@@ -57,29 +57,29 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {producer "gcc" }
- {language @DW_LANG_C}
- {name ${srcfile3}}
- {low_pc 0 addr}
- {stmt_list ${lines_label} DW_FORM_sec_offset}
+ DW_AT_producer "gcc"
+ DW_AT_language @DW_LANG_C
+ DW_AT_name ${srcfile3}
+ DW_AT_low_pc 0 addr
+ DW_AT_stmt_list ${lines_label} DW_FORM_sec_offset
} {
callee_subprog_label: subprogram {
- {external 1 flag}
- {name callee}
- {inline 3 data1}
+ DW_AT_external 1 flag
+ DW_AT_name callee
+ DW_AT_inline 3 data1
}
subprogram {
- {external 1 flag}
- {name main}
- {low_pc $main_start addr}
- {high_pc "$main_start + $main_len" addr}
+ DW_AT_external 1 flag
+ DW_AT_name main
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc "$main_start + $main_len" addr
} {
inlined_subroutine {
- {abstract_origin %$callee_subprog_label}
- {low_pc line_label_3 addr}
- {high_pc line_label_5 addr}
- {call_file 1 data1}
- {call_line 18 data1}
+ DW_AT_abstract_origin %$callee_subprog_label
+ DW_AT_low_pc line_label_3 addr
+ DW_AT_high_pc line_label_5 addr
+ DW_AT_call_file 1 data1
+ DW_AT_call_line 18 data1
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-many-frames.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-many-frames.exp
index 795f1e0..e8668e0 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-many-frames.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-many-frames.exp
@@ -58,116 +58,116 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name dw2-inline-stepping.c}
- {low_pc 0 addr}
- {stmt_list ${lines_label} DW_FORM_sec_offset}
- {ranges ${ranges_label} DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name dw2-inline-stepping.c
+ DW_AT_low_pc 0 addr
+ DW_AT_stmt_list ${lines_label} DW_FORM_sec_offset
+ DW_AT_ranges ${ranges_label} DW_FORM_sec_offset
} {
subprogram {
- {external 1 flag}
- {name ddd}
- {low_pc $ddd_start addr}
- {high_pc "$ddd_start + $ddd_len" addr}
+ DW_AT_external 1 flag
+ DW_AT_name ddd
+ DW_AT_low_pc $ddd_start addr
+ DW_AT_high_pc "$ddd_start + $ddd_len" addr
}
subprogram {
- {external 1 flag}
- {name eee}
- {low_pc $eee_start addr}
- {high_pc "$eee_start + $eee_len" addr}
+ DW_AT_external 1 flag
+ DW_AT_name eee
+ DW_AT_low_pc $eee_start addr
+ DW_AT_high_pc "$eee_start + $eee_len" addr
}
subprogram {
- {external 1 flag}
- {name jjj}
- {low_pc $jjj_start addr}
- {high_pc "$jjj_start + $jjj_len" addr}
+ DW_AT_external 1 flag
+ DW_AT_name jjj
+ DW_AT_low_pc $jjj_start addr
+ DW_AT_high_pc "$jjj_start + $jjj_len" addr
}
subprogram {
- {external 1 flag}
- {name kkk}
- {low_pc $kkk_start addr}
- {high_pc "$kkk_start + $kkk_len" addr}
+ DW_AT_external 1 flag
+ DW_AT_name kkk
+ DW_AT_low_pc $kkk_start addr
+ DW_AT_high_pc "$kkk_start + $kkk_len" addr
}
aaa_label: subprogram {
- {name aaa}
- {inline 3 data1}
+ DW_AT_name aaa
+ DW_AT_inline 3 data1
}
bbb_label: subprogram {
- {name bbb}
- {inline 3 data1}
+ DW_AT_name bbb
+ DW_AT_inline 3 data1
}
ccc_label: subprogram {
- {name ccc}
- {inline 3 data1}
+ DW_AT_name ccc
+ DW_AT_inline 3 data1
}
ggg_label: subprogram {
- {name ggg}
- {inline 3 data1}
+ DW_AT_name ggg
+ DW_AT_inline 3 data1
}
hhh_label: subprogram {
- {name hhh}
- {inline 3 data1}
+ DW_AT_name hhh
+ DW_AT_inline 3 data1
}
iii_label: subprogram {
- {name iii}
- {inline 3 data1}
+ DW_AT_name iii
+ DW_AT_inline 3 data1
}
subprogram {
- {external 1 flag}
- {name main}
- {low_pc $main_start addr}
- {high_pc "$main_start + $main_len" addr}
+ DW_AT_external 1 flag
+ DW_AT_name main
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc "$main_start + $main_len" addr
} {
inlined_subroutine {
- {abstract_origin %$aaa_label}
- {low_pc main_label2 addr}
- {high_pc main_label3 addr}
- {call_file 1 data1}
- {call_line $call_in_main data1}
+ DW_AT_abstract_origin %$aaa_label
+ DW_AT_low_pc main_label2 addr
+ DW_AT_high_pc main_label3 addr
+ DW_AT_call_file 1 data1
+ DW_AT_call_line $call_in_main data1
} {
inlined_subroutine {
- {abstract_origin %$bbb_label}
- {low_pc main_label2 addr}
- {high_pc main_label3 addr}
- {call_file 1 data1}
- {call_line $call_in_aaa data1}
+ DW_AT_abstract_origin %$bbb_label
+ DW_AT_low_pc main_label2 addr
+ DW_AT_high_pc main_label3 addr
+ DW_AT_call_file 1 data1
+ DW_AT_call_line $call_in_aaa data1
} {
inlined_subroutine {
- {abstract_origin %$ccc_label}
- {low_pc main_label2 addr}
- {high_pc main_label3 addr}
- {call_file 1 data1}
- {call_line $call_in_bbb data1}
+ DW_AT_abstract_origin %$ccc_label
+ DW_AT_low_pc main_label2 addr
+ DW_AT_high_pc main_label3 addr
+ DW_AT_call_file 1 data1
+ DW_AT_call_line $call_in_bbb data1
}
}
}
}
subprogram {
- {external 1 flag}
- {name fff}
- {low_pc $fff_start addr}
- {high_pc "$fff_start + $fff_len" addr}
+ DW_AT_external 1 flag
+ DW_AT_name fff
+ DW_AT_low_pc $fff_start addr
+ DW_AT_high_pc "$fff_start + $fff_len" addr
} {
inlined_subroutine {
- {abstract_origin %$ggg_label}
- {low_pc fff_label addr}
- {high_pc main_label2 addr}
- {call_file 1 data1}
- {call_line $call_in_fff data1}
+ DW_AT_abstract_origin %$ggg_label
+ DW_AT_low_pc fff_label addr
+ DW_AT_high_pc main_label2 addr
+ DW_AT_call_file 1 data1
+ DW_AT_call_line $call_in_fff data1
} {
inlined_subroutine {
- {abstract_origin %$hhh_label}
- {low_pc fff_label addr}
- {high_pc fff_label2 addr}
- {call_file 1 data1}
- {call_line $call_in_ggg data1}
+ DW_AT_abstract_origin %$hhh_label
+ DW_AT_low_pc fff_label addr
+ DW_AT_high_pc fff_label2 addr
+ DW_AT_call_file 1 data1
+ DW_AT_call_line $call_in_ggg data1
} {
inlined_subroutine {
- {abstract_origin %$iii_label}
- {low_pc fff_label addr}
- {high_pc fff_label2 addr}
- {call_file 1 data1}
- {call_line $call_in_hhh data1}
+ DW_AT_abstract_origin %$iii_label
+ DW_AT_low_pc fff_label addr
+ DW_AT_high_pc fff_label2 addr
+ DW_AT_call_file 1 data1
+ DW_AT_call_line $call_in_hhh data1
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp
index 12812dd..a4309d4 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-small-func.exp
@@ -47,29 +47,29 @@ Dwarf::assemble $asm_file {
# time of writing this, GCC for x86-64 doesn't make use of
# skip_prologue_using_sal, while clang does.
compile_unit {
- {producer "clang xxxx" }
- {language @DW_LANG_C}
- {name ${srcfile3}}
- {low_pc 0 addr}
- {stmt_list ${lines_label} DW_FORM_sec_offset}
+ DW_AT_producer "clang xxxx"
+ DW_AT_language @DW_LANG_C
+ DW_AT_name ${srcfile3}
+ DW_AT_low_pc 0 addr
+ DW_AT_stmt_list ${lines_label} DW_FORM_sec_offset
} {
callee_subprog_label: subprogram {
- {external 1 flag}
- {name callee}
- {inline 3 data1}
+ DW_AT_external 1 flag
+ DW_AT_name callee
+ DW_AT_inline 3 data1
}
subprogram {
- {external 1 flag}
- {name main}
- {low_pc $main_start addr}
- {high_pc "$main_start + $main_len" addr}
+ DW_AT_external 1 flag
+ DW_AT_name main
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc "$main_start + $main_len" addr
} {
inlined_subroutine {
- {abstract_origin %$callee_subprog_label}
- {low_pc line_label_1 addr}
- {high_pc line_label_2 addr}
- {call_file 1 data1}
- {call_line 21 data1}
+ DW_AT_abstract_origin %$callee_subprog_label
+ DW_AT_low_pc line_label_1 addr
+ DW_AT_high_pc line_label_2 addr
+ DW_AT_call_file 1 data1
+ DW_AT_call_line 21 data1
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-stepping.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-stepping.exp
index 840d813..a544616 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-stepping.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-stepping.exp
@@ -49,34 +49,34 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name dw2-inline-stepping.c}
- {low_pc 0 addr}
- {stmt_list ${lines_label} DW_FORM_sec_offset}
- {ranges ${ranges_label} DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name dw2-inline-stepping.c
+ DW_AT_low_pc 0 addr
+ DW_AT_stmt_list ${lines_label} DW_FORM_sec_offset
+ DW_AT_ranges ${ranges_label} DW_FORM_sec_offset
} {
subprogram {
- {external 1 flag}
- {name bar}
- {low_pc $bar_start addr}
- {high_pc "$bar_start + $bar_len" addr}
+ DW_AT_external 1 flag
+ DW_AT_name bar
+ DW_AT_low_pc $bar_start addr
+ DW_AT_high_pc "$bar_start + $bar_len" addr
}
foo_prog: subprogram {
- {name foo}
- {inline 3 data1}
+ DW_AT_name foo
+ DW_AT_inline 3 data1
}
subprogram {
- {external 1 flag}
- {name main}
- {low_pc $main_start addr}
- {high_pc "$main_start + $main_len" addr}
+ DW_AT_external 1 flag
+ DW_AT_name main
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc "$main_start + $main_len" addr
} {
inlined_subroutine {
- {abstract_origin %$foo_prog}
- {low_pc main_label2 addr}
- {high_pc main_label3 addr}
- {call_file 1 data1}
- {call_line $call_line data1}
+ DW_AT_abstract_origin %$foo_prog
+ DW_AT_low_pc main_label2 addr
+ DW_AT_high_pc main_label3 addr
+ DW_AT_call_file 1 data1
+ DW_AT_call_line $call_line data1
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp b/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
index 320aa34..2674c17 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inline-with-lexical-scope.exp
@@ -43,59 +43,59 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C99}
- {name $srcfile}
- {low_pc $main_start addr}
- {high_pc "$main_start + $main_len" addr}
- {stmt_list ${lines_label} DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C99
+ DW_AT_name $srcfile
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc "$main_start + $main_len" addr
+ DW_AT_stmt_list ${lines_label} DW_FORM_sec_offset
} {
int_label: base_type {
- {name "int"}
- {byte_size 4 sdata}
- {encoding @DW_ATE_signed}
+ DW_AT_name "int"
+ DW_AT_byte_size 4 sdata
+ DW_AT_encoding @DW_ATE_signed
}
func_label: subprogram {
- {name func}
- {inline @DW_INL_declared_inlined}
+ DW_AT_name func
+ DW_AT_inline @DW_INL_declared_inlined
} {
num_label: DW_TAG_variable {
- {name num}
- {type :$int_label}
+ DW_AT_name num
+ DW_AT_type :$int_label
}
lexical_block {
} {
value_label: DW_TAG_variable {
- {name value}
- {type :$int_label}
+ DW_AT_name value
+ DW_AT_type :$int_label
}
}
}
subprogram {
- {name main}
- {external 1 flag}
- {low_pc $main_start addr}
- {high_pc "$main_start + $main_len" addr}
+ DW_AT_name main
+ DW_AT_external 1 flag
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc "$main_start + $main_len" addr
} {
inlined_subroutine {
- {abstract_origin %$func_label}
- {low_pc main_label addr}
- {high_pc main_label2 addr}
- {call_file 1 data1}
- {call_line $func_call data1}
+ DW_AT_abstract_origin %$func_label
+ DW_AT_low_pc main_label addr
+ DW_AT_high_pc main_label2 addr
+ DW_AT_call_file 1 data1
+ DW_AT_call_line $func_call data1
} {
DW_TAG_variable {
- {abstract_origin %$num_label}
- {location {addr $global_num_addr} SPECIAL_expr}
+ DW_AT_abstract_origin %$num_label
+ DW_AT_location [subst {addr $global_num_addr}] SPECIAL_expr
}
lexical_block {
- {low_pc scope_label1 addr}
- {high_pc scope_label2 addr}
+ DW_AT_low_pc scope_label1 addr
+ DW_AT_high_pc scope_label2 addr
} {
DW_TAG_variable {
- {abstract_origin %$value_label}
- {location {addr $global_value_addr} SPECIAL_expr}
+ DW_AT_abstract_origin %$value_label
+ DW_AT_location [subst {addr $global_value_addr}] SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inter-cu-error-2.exp b/gdb/testsuite/gdb.dwarf2/dw2-inter-cu-error-2.exp
index e65d1b9..8e99cb4 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inter-cu-error-2.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inter-cu-error-2.exp
@@ -29,10 +29,12 @@ Dwarf::assemble $asm_file {
declare_labels label1
cu {} {
- compile_unit {{language @DW_LANG_C}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C
+ } {
subprogram {
- {MACRO_AT_range { main }}
- {DW_AT_specification %$label1}
+ MACRO_AT_range { main }
+ DW_AT_specification %$label1
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inter-cu-error.exp b/gdb/testsuite/gdb.dwarf2/dw2-inter-cu-error.exp
index bfdd1a7..ded5f10 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inter-cu-error.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inter-cu-error.exp
@@ -26,16 +26,20 @@ Dwarf::assemble $asm_file {
declare_labels label1
cu {} {
- compile_unit {{language @DW_LANG_C}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C
+ } {
subprogram {
- {MACRO_AT_range { main }}
- {DW_AT_specification %$label1}
+ MACRO_AT_range { main }
+ DW_AT_specification %$label1
}
}
}
cu {} {
- compile_unit {{language @DW_LANG_C}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C
+ } {
label1:
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inter-cu-forth-and-back.exp b/gdb/testsuite/gdb.dwarf2/dw2-inter-cu-forth-and-back.exp
index 3e91a51..0ae6004 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inter-cu-forth-and-back.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inter-cu-forth-and-back.exp
@@ -30,22 +30,26 @@ Dwarf::assemble $asm_file {
declare_labels label1 label2
cu {} {
- compile_unit {{language @DW_LANG_C}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C
+ } {
subprogram {
- {MACRO_AT_range { main }}
- {DW_AT_specification %$label1}
+ MACRO_AT_range { main }
+ DW_AT_specification %$label1
}
label2: subprogram {
- {DW_AT_name main}
+ DW_AT_name main
}
}
}
cu {} {
- compile_unit {{language @DW_LANG_C}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C
+ } {
label1: subprogram {
- {DW_AT_specification %$label2}
+ DW_AT_specification %$label2
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inter-cu-symbol.exp b/gdb/testsuite/gdb.dwarf2/dw2-inter-cu-symbol.exp
index dba8b83..fc72cf7 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-inter-cu-symbol.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inter-cu-symbol.exp
@@ -27,36 +27,36 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {stmt_list $L1 DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C
+ DW_AT_stmt_list $L1 DW_FORM_sec_offset
} {
tag_variable {
- {name var1}
- {abstract_origin %$var_label}
- {const_value 1 DW_FORM_sdata}
+ DW_AT_name var1
+ DW_AT_abstract_origin %$var_label
+ DW_AT_const_value 1 DW_FORM_sdata
}
subprogram {
- {external 1 flag}
- {MACRO_AT_func {main}}
+ DW_AT_external 1 flag
+ MACRO_AT_func {main}
}
int_label: base_type {
- {byte_size 4 udata}
- {encoding @DW_ATE_signed}
- {name int}
+ DW_AT_byte_size 4 udata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int
}
}
}
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {stmt_list $L2 DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C
+ DW_AT_stmt_list $L2 DW_FORM_sec_offset
} {
var_label: tag_variable {
- {name "var1"}
- {type %$int_label}
- {decl_file 1}
- {decl_line 1}
+ DW_AT_name "var1"
+ DW_AT_type %$int_label
+ DW_AT_decl_file 1
+ DW_AT_decl_line 1
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.exp b/gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.exp
index 49091f7..77bac52 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.exp
@@ -42,16 +42,16 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name dw2-is-stmt.c}
- {low_pc 0 addr}
- {stmt_list ${lines_label} DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name dw2-is-stmt.c
+ DW_AT_low_pc 0 addr
+ DW_AT_stmt_list ${lines_label} DW_FORM_sec_offset
} {
subprogram {
- {external 1 flag}
- {name main}
- {low_pc $main_start addr}
- {high_pc "$main_start + $main_len" addr}
+ DW_AT_external 1 flag
+ DW_AT_name main
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc "$main_start + $main_len" addr
} {}
}
}
@@ -179,7 +179,7 @@ foreach entry $locs {
# through. This is checking that the is-stmt marked lines are
# displayed differently (without addresses) to addresses that are
# mid-way through a line, or not marked as is-stmt.
-clean_restart $binfile
+clean_restart $::testfile
runto_main
foreach entry $locs {
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-is-stmt.exp b/gdb/testsuite/gdb.dwarf2/dw2-is-stmt.exp
index 65d9559..1b9ccaa 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-is-stmt.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-is-stmt.exp
@@ -42,16 +42,16 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name dw2-is-stmt.c}
- {low_pc 0 addr}
- {stmt_list ${lines_label} DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name dw2-is-stmt.c
+ DW_AT_low_pc 0 addr
+ DW_AT_stmt_list ${lines_label} DW_FORM_sec_offset
} {
subprogram {
- {external 1 flag}
- {name main}
- {low_pc $main_start addr}
- {high_pc "$main_start + $main_len" addr}
+ DW_AT_external 1 flag
+ DW_AT_name main
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc "$main_start + $main_len" addr
} {}
}
}
@@ -116,7 +116,7 @@ gdb_test "step" "/\\* main end \\*/" \
# Restart the test. This time, stop at a location we know is marked
# as a statement.
-clean_restart ${binfile}
+clean_restart ${::testfile}
runto_main
gdb_breakpoint "*line_label_3"
@@ -129,7 +129,7 @@ gdb_test "step" "/\\* main end \\*/" \
# Restart the test, this time, step through line by line, ensure we
# only stop at the places where is-stmt is true.
-clean_restart ${binfile}
+clean_restart ${::testfile}
runto_main
# Get the values of the labels where we expect to stop.
@@ -161,7 +161,7 @@ with_test_prefix "step to line_label_5" {
# Now restart the test, and place a breakpoint by line number. GDB
# should select the location that is marked as is-stmt.
-clean_restart ${binfile}
+clean_restart ${::testfile}
runto_main
set linum [gdb_get_line_number "main, set var to 0"]
gdb_breakpoint "$srcfile:$linum"
@@ -171,7 +171,7 @@ gdb_assert { $ll3 == $pc } "check initial \$pc"
# Restart the test again, this time we will test stepping by
# instruction.
-clean_restart ${binfile}
+clean_restart ${::testfile}
runto_main
# We will be at line_label_1 at this point - we already tested this
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-lexical-block-bare.exp b/gdb/testsuite/gdb.dwarf2/dw2-lexical-block-bare.exp
index ae7f97e..a973a11 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-lexical-block-bare.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-lexical-block-bare.exp
@@ -24,29 +24,29 @@ set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {MACRO_AT_range {main}}
+ MACRO_AT_range {main}
} {
declare_labels integer_label
integer_label: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
}
DW_TAG_subprogram {
- {MACRO_AT_func {main}}
- {DW_AT_external 1 flag}
+ MACRO_AT_func {main}
+ DW_AT_external 1 flag
} {
DW_TAG_lexical_block {
} {
DW_TAG_variable {
- {DW_AT_name testvar}
- {DW_AT_type :$integer_label}
- {DW_AT_external 1 flag}
- {DW_AT_location {
+ DW_AT_name testvar
+ DW_AT_type :$integer_label
+ DW_AT_external 1 flag
+ DW_AT_location [subst {
DW_OP_addr [gdb_target_symbol main]
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-line-number-zero.exp b/gdb/testsuite/gdb.dwarf2/dw2-line-number-zero.exp
index d46f003..144e62e 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-line-number-zero.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-line-number-zero.exp
@@ -32,21 +32,21 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name dw2-line-number-zero.c}
- {stmt_list $Llines DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name dw2-line-number-zero.c
+ DW_AT_stmt_list $Llines DW_FORM_sec_offset
} {
subprogram {
- {external 1 flag}
- {MACRO_AT_func {main}}
+ DW_AT_external 1 flag
+ MACRO_AT_func {main}
}
subprogram {
- {external 1 flag}
- {MACRO_AT_func {bar1}}
+ DW_AT_external 1 flag
+ MACRO_AT_func {bar1}
}
subprogram {
- {external 1 flag}
- {MACRO_AT_func {bar2}}
+ DW_AT_external 1 flag
+ MACRO_AT_func {bar2}
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-lines.exp b/gdb/testsuite/gdb.dwarf2/dw2-lines.exp
index 16ca54e7..6eacf0b 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-lines.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-lines.exp
@@ -59,21 +59,21 @@ proc test_1 { _cv _cdw64 _lv _ldw64 {_string_form ""}} {
cu { version $cv is_64 $cdw64 } {
compile_unit {
- {language @DW_LANG_C}
- {name $srcfile}
- {stmt_list $Llines DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name $srcfile
+ DW_AT_stmt_list $Llines DW_FORM_sec_offset
} {
subprogram {
- {external 1 flag}
- {name main}
- {low_pc $main_start addr}
- {high_pc "$main_start + $main_len" addr}
+ DW_AT_external 1 flag
+ DW_AT_name main
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc "$main_start + $main_len" addr
}
subprogram {
- {external 1 flag}
- {name bar}
- {low_pc $bar_start addr}
- {high_pc "$bar_start + $bar_len" addr}
+ DW_AT_external 1 flag
+ DW_AT_name bar
+ DW_AT_low_pc $bar_start addr
+ DW_AT_high_pc "$bar_start + $bar_len" addr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-linkage-name-trust.exp b/gdb/testsuite/gdb.dwarf2/dw2-linkage-name-trust.exp
index 01eab48..7627e8e 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-linkage-name-trust.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-linkage-name-trust.exp
@@ -27,7 +27,7 @@ standard_testfile .S
set executable ${testfile}
if {[prepare_for_testing_full "failed to prepare" \
- [list $testfile c++ $testfile-main.cc {c++ debug} \
+ [list $testfile c++ $testfile-main.cc {c++ nodebug} \
$srcfile {}]]} {
return -1
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-main-no-line-number.exp b/gdb/testsuite/gdb.dwarf2/dw2-main-no-line-number.exp
index 309875a..e05e4c9 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-main-no-line-number.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-main-no-line-number.exp
@@ -33,12 +33,12 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name $srcfile}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name $srcfile
} {
subprogram {
- {external 1 flag}
- {MACRO_AT_func {main}}
+ DW_AT_external 1 flag
+ MACRO_AT_func {main}
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-missing-cu-tag.exp b/gdb/testsuite/gdb.dwarf2/dw2-missing-cu-tag.exp
index 44b1726..998b614 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-missing-cu-tag.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-missing-cu-tag.exp
@@ -31,8 +31,8 @@ Dwarf::assemble $asm_file {
# We should have either one of DW_TAG_compile_unit,
# DW_TAG_partial_unit, or DW_TAG_type_unit here.
subprogram {
- {external 1 flag}
- {MACRO_AT_func {main}}
+ DW_AT_external 1 flag
+ MACRO_AT_func {main}
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-multiple-debug-info.exp b/gdb/testsuite/gdb.dwarf2/dw2-multiple-debug-info.exp
index a8fa524..0092969 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-multiple-debug-info.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-multiple-debug-info.exp
@@ -31,6 +31,6 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" "$binfile" object \
return -1
}
-clean_restart $binfile
+clean_restart $::testfile
gdb_test "ptype a" "type = class sp1::A .*"
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-namespaceless-anonymous.exp b/gdb/testsuite/gdb.dwarf2/dw2-namespaceless-anonymous.exp
index d930801..ebbe6c0 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-namespaceless-anonymous.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-namespaceless-anonymous.exp
@@ -27,26 +27,26 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C_plus_plus}
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir /tmp}
+ DW_AT_language @DW_LANG_C_plus_plus
+ DW_AT_name $srcfile
+ DW_AT_comp_dir /tmp
} {
declare_labels myint
myint: DW_TAG_base_type {
- {DW_AT_byte_size 1 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name myint}
+ DW_AT_byte_size 1 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name myint
}
DW_TAG_namespace {} {
DW_TAG_variable {
- {DW_AT_name v}
- {DW_AT_linkage_name _ZN12_GLOBAL__N_11vE}
- {DW_AT_location {
+ DW_AT_name v
+ DW_AT_linkage_name _ZN12_GLOBAL__N_11vE
+ DW_AT_location [subst {
DW_OP_addr [gdb_target_symbol _ZN12_GLOBAL__N_11vE]
- } SPECIAL_expr}
- {DW_AT_type :$myint}
+ }] SPECIAL_expr
+ DW_AT_type :$myint
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-noloc.exp b/gdb/testsuite/gdb.dwarf2/dw2-noloc.exp
index 86ea143..526f88a 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-noloc.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-noloc.exp
@@ -28,167 +28,167 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name $srcfile}
- {stmt_list ${lines_label} DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name $srcfile
+ DW_AT_stmt_list ${lines_label} DW_FORM_sec_offset
} {
declare_labels integer_label
set int_size [get_sizeof "int" 4]
integer_label: DW_TAG_base_type {
- {DW_AT_byte_size $int_size DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name int}
+ DW_AT_byte_size $int_size DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int
}
DW_TAG_subprogram {
- {external 1 flag}
- {name main}
- {low_pc $main_start addr}
- {high_pc "$main_start + $main_len" addr}
+ DW_AT_external 1 flag
+ DW_AT_name main
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc "$main_start + $main_len" addr
}
DW_TAG_variable {
- {DW_AT_name file_locno_resolvable}
- {DW_AT_type :$integer_label}
+ DW_AT_name file_locno_resolvable
+ DW_AT_type :$integer_label
}
DW_TAG_variable {
- {DW_AT_name file_locno_unresolvable}
- {DW_AT_type :$integer_label}
+ DW_AT_name file_locno_unresolvable
+ DW_AT_type :$integer_label
}
DW_TAG_variable {
- {DW_AT_name file_locempty_resolvable}
- {DW_AT_type :$integer_label}
- {DW_AT_location {} DW_FORM_block1}
+ DW_AT_name file_locempty_resolvable
+ DW_AT_type :$integer_label
+ DW_AT_location {} DW_FORM_block1
}
DW_TAG_variable {
- {DW_AT_name file_locempty_unresolvable}
- {DW_AT_type :$integer_label}
- {DW_AT_location {} DW_FORM_block1}
+ DW_AT_name file_locempty_unresolvable
+ DW_AT_type :$integer_label
+ DW_AT_location {} DW_FORM_block1
}
DW_TAG_variable {
- {DW_AT_name file_locaddr_resolvable}
- {DW_AT_type :$integer_label}
- {DW_AT_location {
+ DW_AT_name file_locaddr_resolvable
+ DW_AT_type :$integer_label
+ DW_AT_location [subst {
DW_OP_addr [gdb_target_symbol file_locaddr_resolvable]
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
DW_TAG_variable {
- {DW_AT_name file_locaddr_unresolvable}
- {DW_AT_type :$integer_label}
- {DW_AT_location {
+ DW_AT_name file_locaddr_unresolvable
+ DW_AT_type :$integer_label
+ DW_AT_location [subst {
DW_OP_addr [gdb_target_symbol file_locaddr_resolvable]
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
DW_TAG_variable {
- {DW_AT_name file_extern_locno_resolvable}
- {DW_AT_type :$integer_label}
- {DW_AT_external 1 flag}
+ DW_AT_name file_extern_locno_resolvable
+ DW_AT_type :$integer_label
+ DW_AT_external 1 flag
}
DW_TAG_variable {
- {DW_AT_name file_extern_locno_unresolvable}
- {DW_AT_type :$integer_label}
- {DW_AT_external 1 flag}
+ DW_AT_name file_extern_locno_unresolvable
+ DW_AT_type :$integer_label
+ DW_AT_external 1 flag
}
DW_TAG_variable {
- {DW_AT_name file_extern_locempty_resolvable}
- {DW_AT_type :$integer_label}
- {DW_AT_external 1 flag}
- {DW_AT_location {} DW_FORM_block1}
+ DW_AT_name file_extern_locempty_resolvable
+ DW_AT_type :$integer_label
+ DW_AT_external 1 flag
+ DW_AT_location {} DW_FORM_block1
}
DW_TAG_variable {
- {DW_AT_name file_extern_locempty_unresolvable}
- {DW_AT_type :$integer_label}
- {DW_AT_external 1 flag}
- {DW_AT_location {} DW_FORM_block1}
+ DW_AT_name file_extern_locempty_unresolvable
+ DW_AT_type :$integer_label
+ DW_AT_external 1 flag
+ DW_AT_location {} DW_FORM_block1
}
DW_TAG_variable {
- {DW_AT_name file_extern_locaddr_resolvable}
- {DW_AT_type :$integer_label}
- {DW_AT_external 1 flag}
- {DW_AT_location {
+ DW_AT_name file_extern_locaddr_resolvable
+ DW_AT_type :$integer_label
+ DW_AT_external 1 flag
+ DW_AT_location [subst {
DW_OP_addr [gdb_target_symbol file_extern_locaddr_resolvable]
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
DW_TAG_variable {
- {DW_AT_name file_extern_locaddr_unresolvable}
- {DW_AT_type :$integer_label}
- {DW_AT_external 1 flag}
- {DW_AT_location {
+ DW_AT_name file_extern_locaddr_unresolvable
+ DW_AT_type :$integer_label
+ DW_AT_external 1 flag
+ DW_AT_location [subst {
DW_OP_addr [gdb_target_symbol file_extern_locaddr_resolvable]
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
DW_TAG_variable {
- {DW_AT_name main_local_locno_resolvable}
- {DW_AT_type :$integer_label}
+ DW_AT_name main_local_locno_resolvable
+ DW_AT_type :$integer_label
}
DW_TAG_variable {
- {DW_AT_name main_local_locno_unresolvable}
- {DW_AT_type :$integer_label}
+ DW_AT_name main_local_locno_unresolvable
+ DW_AT_type :$integer_label
}
DW_TAG_variable {
- {DW_AT_name main_local_locempty_resolvable}
- {DW_AT_type :$integer_label}
- {DW_AT_location {} DW_FORM_block1}
+ DW_AT_name main_local_locempty_resolvable
+ DW_AT_type :$integer_label
+ DW_AT_location {} DW_FORM_block1
}
DW_TAG_variable {
- {DW_AT_name main_local_locempty_unresolvable}
- {DW_AT_type :$integer_label}
- {DW_AT_location {} DW_FORM_block1}
+ DW_AT_name main_local_locempty_unresolvable
+ DW_AT_type :$integer_label
+ DW_AT_location {} DW_FORM_block1
}
DW_TAG_variable {
- {DW_AT_name main_local_locaddr_resolvable}
- {DW_AT_type :$integer_label}
- {DW_AT_location {
+ DW_AT_name main_local_locaddr_resolvable
+ DW_AT_type :$integer_label
+ DW_AT_location [subst {
DW_OP_addr [gdb_target_symbol main_local_locaddr_resolvable]
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
DW_TAG_variable {
- {DW_AT_name main_local_locaddr_unresolvable}
- {DW_AT_type :$integer_label}
- {DW_AT_location {
+ DW_AT_name main_local_locaddr_unresolvable
+ DW_AT_type :$integer_label
+ DW_AT_location [subst {
DW_OP_addr [gdb_target_symbol main_local_locaddr_resolvable]
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
DW_TAG_variable {
- {DW_AT_name main_extern_locno_resolvable}
- {DW_AT_type :$integer_label}
- {DW_AT_external 1 flag}
+ DW_AT_name main_extern_locno_resolvable
+ DW_AT_type :$integer_label
+ DW_AT_external 1 flag
}
DW_TAG_variable {
- {DW_AT_name main_extern_locno_unresolvable}
- {DW_AT_type :$integer_label}
- {DW_AT_external 1 flag}
+ DW_AT_name main_extern_locno_unresolvable
+ DW_AT_type :$integer_label
+ DW_AT_external 1 flag
}
DW_TAG_variable {
- {DW_AT_name main_extern_locempty_resolvable}
- {DW_AT_type :$integer_label}
- {DW_AT_external 1 flag}
- {DW_AT_location {} DW_FORM_block1}
+ DW_AT_name main_extern_locempty_resolvable
+ DW_AT_type :$integer_label
+ DW_AT_external 1 flag
+ DW_AT_location {} DW_FORM_block1
}
DW_TAG_variable {
- {DW_AT_name main_extern_locempty_unresolvable}
- {DW_AT_type :$integer_label}
- {DW_AT_external 1 flag}
- {DW_AT_location {} DW_FORM_block1}
+ DW_AT_name main_extern_locempty_unresolvable
+ DW_AT_type :$integer_label
+ DW_AT_external 1 flag
+ DW_AT_location {} DW_FORM_block1
}
DW_TAG_variable {
- {DW_AT_name main_extern_locaddr_resolvable}
- {DW_AT_type :$integer_label}
- {DW_AT_external 1 flag}
- {DW_AT_location {
+ DW_AT_name main_extern_locaddr_resolvable
+ DW_AT_type :$integer_label
+ DW_AT_external 1 flag
+ DW_AT_location [subst {
DW_OP_addr [gdb_target_symbol main_extern_locaddr_resolvable]
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
DW_TAG_variable {
- {DW_AT_name main_extern_locaddr_unresolvable}
- {DW_AT_type :$integer_label}
- {DW_AT_external 1 flag}
- {DW_AT_location {
+ DW_AT_name main_extern_locaddr_unresolvable
+ DW_AT_type :$integer_label
+ DW_AT_external 1 flag
+ DW_AT_location [subst {
DW_OP_addr [gdb_target_symbol main_extern_locaddr_resolvable]
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp b/gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp
index 486a4e8..866df3a 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp
@@ -46,74 +46,74 @@ proc build_test_program {} {
cu { addr_size 4 } {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C99}
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir /tmp}
+ DW_AT_language @DW_LANG_C99
+ DW_AT_name $srcfile
+ DW_AT_comp_dir /tmp
} {
declare_labels int_label struct_label pointer_label \
array_label
int_label: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
}
array_label: DW_TAG_array_type {
- {DW_AT_name foo__array_type}
- {DW_AT_type :$int_label}
+ DW_AT_name foo__array_type
+ DW_AT_type :$int_label
} {
DW_TAG_subrange_type {
- {DW_AT_type :$int_label}
- {DW_AT_lower_bound 0 DW_FORM_data1}
- {DW_AT_upper_bound 127 DW_FORM_data1}
+ DW_AT_type :$int_label
+ DW_AT_lower_bound 0 DW_FORM_data1
+ DW_AT_upper_bound 127 DW_FORM_data1
}
}
struct_label: DW_TAG_structure_type {
- {DW_AT_name "foo"}
- {DW_AT_byte_size 12 DW_FORM_sdata}
+ DW_AT_name "foo"
+ DW_AT_byte_size 12 DW_FORM_sdata
} {
member {
- {name a}
- {type :$int_label}
- {data_member_location 0 data1}
+ DW_AT_name a
+ DW_AT_type :$int_label
+ DW_AT_data_member_location 0 data1
}
member {
- {name x}
- {type :$array_label}
- {data_member_location 4 data1}
+ DW_AT_name x
+ DW_AT_type :$array_label
+ DW_AT_data_member_location 4 data1
}
member {
- {name y}
- {type :$pointer_label}
- {data_member_location 8 data1}
+ DW_AT_name y
+ DW_AT_type :$pointer_label
+ DW_AT_data_member_location 8 data1
}
}
pointer_label: DW_TAG_pointer_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_type :$struct_label}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_type :$struct_label
}
DW_TAG_subprogram {
- {DW_AT_name func01}
- {DW_AT_type :$int_label}
- {external 1 flag}
- {MACRO_AT_func {func01}}
+ DW_AT_name func01
+ DW_AT_type :$int_label
+ DW_AT_external 1 flag
+ MACRO_AT_func {func01}
} {
DW_TAG_variable {
- {DW_AT_name ptr}
- {DW_AT_type :$pointer_label}
- {DW_AT_location {} DW_FORM_block1}
+ DW_AT_name ptr
+ DW_AT_type :$pointer_label
+ DW_AT_location {} DW_FORM_block1
}
}
DW_TAG_subprogram {
- {DW_AT_name main}
- {DW_AT_type :$int_label}
- {external 1 flag}
- {MACRO_AT_func {main}}
+ DW_AT_name main
+ DW_AT_type :$int_label
+ DW_AT_external 1 flag
+ MACRO_AT_func {main}
} {
}
}
@@ -134,7 +134,7 @@ set re_address_class "@\[^\r\n\]+"
proc do_console_test {} {
global binfile
- clean_restart $binfile
+ clean_restart $::testfile
with_test_prefix "console" {
gdb_test_no_output "set print object on"
@@ -173,7 +173,7 @@ proc do_mi_test {} {
global binfile
with_test_prefix "mi" {
- if {[mi_clean_restart $binfile]} {
+ if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-out-of-range-end-of-seq.exp b/gdb/testsuite/gdb.dwarf2/dw2-out-of-range-end-of-seq.exp
index 79c03c7..70db471 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-out-of-range-end-of-seq.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-out-of-range-end-of-seq.exp
@@ -39,15 +39,15 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name $srcfile}
- {stmt_list $Llines DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name $srcfile
+ DW_AT_stmt_list $Llines DW_FORM_sec_offset
} {
subprogram {
- {external 1 flag}
- {name main}
- {low_pc $main_start}
- {high_pc $main_end addr}
+ DW_AT_external 1 flag
+ DW_AT_name main
+ DW_AT_low_pc $main_start
+ DW_AT_high_pc $main_end addr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp b/gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp
index eea17b0..cf94c71 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-prologue-end-2.exp
@@ -30,21 +30,21 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name dw2-prologue-end.c}
- {stmt_list ${lines_label} DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name dw2-prologue-end.c
+ DW_AT_stmt_list ${lines_label} DW_FORM_sec_offset
} {
subprogram {
- {external 1 flag}
- {name foo}
- {low_pc foo_label addr}
- {high_pc foo_end addr}
+ DW_AT_external 1 flag
+ DW_AT_name foo
+ DW_AT_low_pc foo_label addr
+ DW_AT_high_pc foo_end addr
}
subprogram {
- {external 1 flag}
- {name bar}
- {low_pc bar_label addr}
- {high_pc bar_end addr}
+ DW_AT_external 1 flag
+ DW_AT_name bar
+ DW_AT_low_pc bar_label addr
+ DW_AT_high_pc bar_end addr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-prologue-end.exp b/gdb/testsuite/gdb.dwarf2/dw2-prologue-end.exp
index 23d8c26..8e66abe 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-prologue-end.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-prologue-end.exp
@@ -32,15 +32,15 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name dw2-prologue-end.c}
- {stmt_list ${lines_label} DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name dw2-prologue-end.c
+ DW_AT_stmt_list ${lines_label} DW_FORM_sec_offset
} {
subprogram {
- {external 1 flag}
- {name main}
- {low_pc $main_start addr}
- {high_pc "$main_start + $main_len" addr}
+ DW_AT_external 1 flag
+ DW_AT_name main
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc "$main_start + $main_len" addr
}
}
}
@@ -91,7 +91,7 @@ set prologue_end_line [gdb_get_line_number "main assign o"]
gdb_test "frame" ".*main \\\(\\\) at \[^\r\n\]*:$prologue_end_line\r\n.*"
with_test_prefix "ignore-prologue-end" {
- clean_restart $binfile
+ clean_restart $::testfile
gdb_test_no_output "maintenance set ignore-prologue-end-flag on"
if ![runto_main] {
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp b/gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp
index e63bbc3..9e39f6b 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp
@@ -45,22 +45,22 @@ Dwarf::assemble $asm_file {
# .debug_ranges data then the test achieves its objective.
cu { label cu_label } {
compile_unit {
- {language @DW_LANG_C}
- {name dw-ranges-base.c}
- {stmt_list $L DW_FORM_sec_offset}
- {ranges ${ranges_label} DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name dw-ranges-base.c
+ DW_AT_stmt_list $L DW_FORM_sec_offset
+ DW_AT_ranges ${ranges_label} DW_FORM_sec_offset
} {
subprogram {
- {external 1 flag}
- {name main}
+ DW_AT_external 1 flag
+ DW_AT_name main
}
subprogram {
- {external 1 flag}
- {name frame2}
+ DW_AT_external 1 flag
+ DW_AT_name frame2
}
subprogram {
- {external 1 flag}
- {name frame3}
+ DW_AT_external 1 flag
+ DW_AT_name frame3
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-ranges-func.exp b/gdb/testsuite/gdb.dwarf2/dw2-ranges-func.exp
index 9fea8a8..56aab60 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-ranges-func.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-ranges-func.exp
@@ -70,49 +70,49 @@ proc do_test {suffix} {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name dw-ranges-func2.c}
- {stmt_list $L DW_FORM_sec_offset}
- {low_pc 0 addr}
- {ranges ${cu_ranges_label} DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name dw-ranges-func2.c
+ DW_AT_stmt_list $L DW_FORM_sec_offset
+ DW_AT_low_pc 0 addr
+ DW_AT_ranges ${cu_ranges_label} DW_FORM_sec_offset
} {
integer_label: DW_TAG_base_type {
- {DW_AT_byte_size $int_size DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
+ DW_AT_byte_size $int_size DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
}
volatile_label: DW_TAG_volatile_type {
- {type :$integer_label}
+ DW_AT_type :$integer_label
}
DW_TAG_variable {
- {name e}
- {external 1 flag}
- {type :$volatile_label}
- {location {addr $e_var} SPECIAL_expr}
+ DW_AT_name e
+ DW_AT_external 1 flag
+ DW_AT_type :$volatile_label
+ DW_AT_location [subst {addr $e_var}] SPECIAL_expr
}
subprogram {
- {external 1 flag}
- {name main}
- {DW_AT_type :$integer_label}
- {low_pc $main_start addr}
- {high_pc $main_len DW_FORM_data4}
+ DW_AT_external 1 flag
+ DW_AT_name main
+ DW_AT_type :$integer_label
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc $main_len DW_FORM_data4
}
subprogram {
- {external 1 flag}
- {name foo}
- {ranges ${func_ranges_label} DW_FORM_sec_offset}
+ DW_AT_external 1 flag
+ DW_AT_name foo
+ DW_AT_ranges ${func_ranges_label} DW_FORM_sec_offset
}
subprogram {
- {external 1 flag}
- {name bar}
- {low_pc $bar_start addr}
- {high_pc $bar_len DW_FORM_data4}
+ DW_AT_external 1 flag
+ DW_AT_name bar
+ DW_AT_low_pc $bar_start addr
+ DW_AT_high_pc $bar_len DW_FORM_data4
}
subprogram {
- {external 1 flag}
- {name baz}
- {low_pc $baz_start addr}
- {high_pc $baz_len DW_FORM_data4}
+ DW_AT_external 1 flag
+ DW_AT_name baz
+ DW_AT_low_pc $baz_start addr
+ DW_AT_high_pc $baz_len DW_FORM_data4
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-ranges-overlap.exp b/gdb/testsuite/gdb.dwarf2/dw2-ranges-overlap.exp
index 8e7d51e..75c874e 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-ranges-overlap.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-ranges-overlap.exp
@@ -44,13 +44,13 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C_plus_plus}
- {name $srcfile}
- {ranges ${ranges_label} DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C_plus_plus
+ DW_AT_name $srcfile
+ DW_AT_ranges ${ranges_label} DW_FORM_sec_offset
} {
subprogram {
- {external 1 flag}
- {name quux}
+ DW_AT_external 1 flag
+ DW_AT_name quux
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-ranges-psym-warning.exp b/gdb/testsuite/gdb.dwarf2/dw2-ranges-psym-warning.exp
index 6120878..fa1e03b 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-ranges-psym-warning.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-ranges-psym-warning.exp
@@ -61,31 +61,31 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name dw-ranges-psym.c}
- {low_pc 0 addr}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name dw-ranges-psym.c
+ DW_AT_low_pc 0 addr
} {
integer_label: DW_TAG_base_type {
- {DW_AT_byte_size $int_size DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
+ DW_AT_byte_size $int_size DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
}
subprogram {
- {external 1 flag}
- {name foo}
- {ranges ${func_ranges_label} DW_FORM_sec_offset}
+ DW_AT_external 1 flag
+ DW_AT_name foo
+ DW_AT_ranges ${func_ranges_label} DW_FORM_sec_offset
}
subprogram {
- {external 1 flag}
- {name bar}
- {low_pc $bar_start addr}
- {high_pc $bar_len DW_FORM_data4}
+ DW_AT_external 1 flag
+ DW_AT_name bar
+ DW_AT_low_pc $bar_start addr
+ DW_AT_high_pc $bar_len DW_FORM_data4
}
subprogram {
- {external 1 flag}
- {name baz}
- {low_pc $baz_start addr}
- {high_pc $baz_len DW_FORM_data4}
+ DW_AT_external 1 flag
+ DW_AT_name baz
+ DW_AT_low_pc $baz_start addr
+ DW_AT_high_pc $baz_len DW_FORM_data4
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-ranges-psym.exp b/gdb/testsuite/gdb.dwarf2/dw2-ranges-psym.exp
index e8c9890..6440722 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-ranges-psym.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-ranges-psym.exp
@@ -63,35 +63,35 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name dw-ranges-psym.c}
- {low_pc 0 addr}
- {ranges ${cu_ranges_label} DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name dw-ranges-psym.c
+ DW_AT_low_pc 0 addr
+ DW_AT_ranges ${cu_ranges_label} DW_FORM_sec_offset
} {
integer_label: DW_TAG_base_type {
- {DW_AT_byte_size $int_size DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
+ DW_AT_byte_size $int_size DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
}
volatile_label: DW_TAG_volatile_type {
- {type :$integer_label}
+ DW_AT_type :$integer_label
}
subprogram {
- {external 1 flag}
- {name someothername}
- {ranges ${func_ranges_label} DW_FORM_sec_offset}
+ DW_AT_external 1 flag
+ DW_AT_name someothername
+ DW_AT_ranges ${func_ranges_label} DW_FORM_sec_offset
}
subprogram {
- {external 1 flag}
- {name bar}
- {low_pc $bar_start addr}
- {high_pc $bar_len DW_FORM_data4}
+ DW_AT_external 1 flag
+ DW_AT_name bar
+ DW_AT_low_pc $bar_start addr
+ DW_AT_high_pc $bar_len DW_FORM_data4
}
subprogram {
- {external 1 flag}
- {name baz}
- {low_pc $baz_start addr}
- {high_pc $baz_len DW_FORM_data4}
+ DW_AT_external 1 flag
+ DW_AT_name baz
+ DW_AT_low_pc $baz_start addr
+ DW_AT_high_pc $baz_len DW_FORM_data4
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-regno-invalid.exp b/gdb/testsuite/gdb.dwarf2/dw2-regno-invalid.exp
index 5f3c324..7cfeb58 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-regno-invalid.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-regno-invalid.exp
@@ -27,27 +27,27 @@ set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {MACRO_AT_range {main}}
+ MACRO_AT_range {main}
} {
declare_labels integer_label
integer_label: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
}
DW_TAG_subprogram {
- {DW_AT_external 1 flag}
- {MACRO_AT_func {main}}
+ DW_AT_external 1 flag
+ MACRO_AT_func {main}
} {
DW_TAG_variable {
- {DW_AT_name bregx}
- {DW_AT_type :$integer_label}
- {DW_AT_external 1 flag}
- {DW_AT_location {
+ DW_AT_name bregx
+ DW_AT_type :$integer_label
+ DW_AT_external 1 flag
+ DW_AT_location {
DW_OP_bregx 0xffffffff 0
- } SPECIAL_expr}
+ } SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-skipped-line-entries.exp b/gdb/testsuite/gdb.dwarf2/dw2-skipped-line-entries.exp
index 2c2b5ff..1d86c61 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-skipped-line-entries.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-skipped-line-entries.exp
@@ -40,14 +40,14 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name $::srcfile}
- {low_pc 0 addr}
- {stmt_list ${lines_label} DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name $::srcfile
+ DW_AT_low_pc 0 addr
+ DW_AT_stmt_list ${lines_label} DW_FORM_sec_offset
} {
subprogram {
- {external 1 flag}
- {MACRO_AT_func {main}}
+ DW_AT_external 1 flag
+ MACRO_AT_func {main}
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-step-between-different-inline-functions.exp b/gdb/testsuite/gdb.dwarf2/dw2-step-between-different-inline-functions.exp
index a2f36cf..1eb1e38 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-step-between-different-inline-functions.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-step-between-different-inline-functions.exp
@@ -79,48 +79,48 @@ Dwarf::assemble $asm_file {
cu { version 4 } {
compile_unit {
- {producer "gcc"}
- {language @DW_LANG_C}
- {name ${srcfile}}
- {comp_dir /tmp}
- {stmt_list $lines_table DW_FORM_sec_offset}
- {low_pc 0 addr}
+ DW_AT_producer "gcc"
+ DW_AT_language @DW_LANG_C
+ DW_AT_name ${srcfile}
+ DW_AT_comp_dir /tmp
+ DW_AT_stmt_list $lines_table DW_FORM_sec_offset
+ DW_AT_low_pc 0 addr
} {
bar_label: subprogram {
- {external 1 flag}
- {name bar}
- {decl_file 1 data1}
- {decl_line $bar_decl_line data1}
- {decl_column 1 data1}
- {inline 3 data1}
+ DW_AT_external 1 flag
+ DW_AT_name bar
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line $bar_decl_line data1
+ DW_AT_decl_column 1 data1
+ DW_AT_inline 3 data1
}
baz_label: subprogram {
- {external 1 flag}
- {name baz}
- {decl_file 1 data1}
- {decl_line $baz_decl_line data1}
- {decl_column 1 data1}
- {inline 3 data1}
+ DW_AT_external 1 flag
+ DW_AT_name baz
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line $baz_decl_line data1
+ DW_AT_decl_column 1 data1
+ DW_AT_inline 3 data1
}
subprogram {
- {name foo}
- {decl_file 1 data1}
- {decl_line $foo_decl_line data1}
- {decl_column 1 data1}
- {ranges ${ranges_label_foo} DW_FORM_sec_offset}
- {external 1 flag}
+ DW_AT_name foo
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line $foo_decl_line data1
+ DW_AT_decl_column 1 data1
+ DW_AT_ranges ${ranges_label_foo} DW_FORM_sec_offset
+ DW_AT_external 1 flag
} {
inlined_subroutine {
- {abstract_origin %$bar_label}
- {call_file 1 data1}
- {call_line $foo_src_2 data1}
- {ranges ${ranges_label_bar} DW_FORM_sec_offset}
+ DW_AT_abstract_origin %$bar_label
+ DW_AT_call_file 1 data1
+ DW_AT_call_line $foo_src_2 data1
+ DW_AT_ranges ${ranges_label_bar} DW_FORM_sec_offset
}
inlined_subroutine {
- {abstract_origin %$baz_label}
- {call_file 1 data1}
- {call_line $foo_src_3 data1}
- {ranges ${ranges_label_baz} DW_FORM_sec_offset}
+ DW_AT_abstract_origin %$baz_label
+ DW_AT_call_file 1 data1
+ DW_AT_call_line $foo_src_3 data1
+ DW_AT_ranges ${ranges_label_baz} DW_FORM_sec_offset
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-step-between-inline-func-blocks.exp b/gdb/testsuite/gdb.dwarf2/dw2-step-between-inline-func-blocks.exp
index ea8c7d3..1a76c58 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-step-between-inline-func-blocks.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-step-between-inline-func-blocks.exp
@@ -71,34 +71,34 @@ Dwarf::assemble $asm_file {
cu { version 4 } {
compile_unit {
- {producer "gcc"}
- {language @DW_LANG_C}
- {name ${srcfile}}
- {comp_dir /tmp}
- {stmt_list $lines_table DW_FORM_sec_offset}
- {low_pc 0 addr}
+ DW_AT_producer "gcc"
+ DW_AT_language @DW_LANG_C
+ DW_AT_name ${srcfile}
+ DW_AT_comp_dir /tmp
+ DW_AT_stmt_list $lines_table DW_FORM_sec_offset
+ DW_AT_low_pc 0 addr
} {
bar_label: subprogram {
- {external 1 flag}
- {name bar}
- {decl_file 1 data1}
- {decl_line $bar_decl_line data1}
- {decl_column 1 data1}
- {inline 3 data1}
+ DW_AT_external 1 flag
+ DW_AT_name bar
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line $bar_decl_line data1
+ DW_AT_decl_column 1 data1
+ DW_AT_inline 3 data1
}
subprogram {
- {name foo}
- {decl_file 1 data1}
- {decl_line $foo_decl_line data1}
- {decl_column 1 data1}
- {ranges ${ranges_label_foo} DW_FORM_sec_offset}
- {external 1 flag}
+ DW_AT_name foo
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line $foo_decl_line data1
+ DW_AT_decl_column 1 data1
+ DW_AT_ranges ${ranges_label_foo} DW_FORM_sec_offset
+ DW_AT_external 1 flag
} {
inlined_subroutine {
- {abstract_origin %$bar_label}
- {call_file 1 data1}
- {call_line $foo_src_3 data1}
- {ranges ${ranges_label_bar} DW_FORM_sec_offset}
+ DW_AT_abstract_origin %$bar_label
+ DW_AT_call_file 1 data1
+ DW_AT_call_line $foo_src_3 data1
+ DW_AT_ranges ${ranges_label_bar} DW_FORM_sec_offset
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-step-out-of-function-no-stmt.exp b/gdb/testsuite/gdb.dwarf2/dw2-step-out-of-function-no-stmt.exp
index a2d197b..3eaaa52 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-step-out-of-function-no-stmt.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-step-out-of-function-no-stmt.exp
@@ -50,17 +50,17 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name $srcfile}
- {stmt_list $Llines DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name $srcfile
+ DW_AT_stmt_list $Llines DW_FORM_sec_offset
} {
subprogram {
- {external 1 flag}
- {MACRO_AT_func {main}}
+ DW_AT_external 1 flag
+ MACRO_AT_func {main}
}
subprogram {
- {external 1 flag}
- {MACRO_AT_func {bar}}
+ DW_AT_external 1 flag
+ MACRO_AT_func {bar}
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes-lookup.exp b/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes-lookup.exp
index aaa32ae..ccee277 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes-lookup.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes-lookup.exp
@@ -54,23 +54,23 @@ Dwarf::assemble $asm_file {
cu {} {
partial_label: partial_unit {
- {stmt_list ${lines_label} DW_FORM_sec_offset}
+ DW_AT_stmt_list ${lines_label} DW_FORM_sec_offset
} {
DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name myint}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name myint
}
}
}
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {DW_AT_name bla.c}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name bla.c
} {
imported_unit {
- {import $partial_label ref_addr}
+ DW_AT_import $partial_label ref_addr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes.exp b/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes.exp
index fce4346..3e34c3c 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes.exp
@@ -38,11 +38,11 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {stmt_list ${lines_label} DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C
+ DW_AT_stmt_list ${lines_label} DW_FORM_sec_offset
} {
imported_unit {
- {import $partial_label ref_addr}
+ DW_AT_import $partial_label ref_addr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-unexpected-entry-pc.exp b/gdb/testsuite/gdb.dwarf2/dw2-unexpected-entry-pc.exp
index d8b738d..fb257f0 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-unexpected-entry-pc.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-unexpected-entry-pc.exp
@@ -102,32 +102,32 @@ proc run_test { entry_label dwarf_version with_line_table } {
cu { version $dwarf_version } {
compile_unit {
- {producer "gcc"}
- {language @DW_LANG_C}
- {name $::srcfile}
- {comp_dir /tmp}
- {stmt_list $lines_table DW_FORM_sec_offset}
- {low_pc 0 addr}
+ DW_AT_producer "gcc"
+ DW_AT_language @DW_LANG_C
+ DW_AT_name $::srcfile
+ DW_AT_comp_dir /tmp
+ DW_AT_stmt_list $lines_table DW_FORM_sec_offset
+ DW_AT_low_pc 0 addr
} {
inline_func: subprogram {
- {name bar}
- {inline @DW_INL_declared_inlined}
+ DW_AT_name bar
+ DW_AT_inline @DW_INL_declared_inlined
}
subprogram {
- {name foo}
- {decl_file 1 data1}
- {decl_line $::foo_decl_line data1}
- {decl_column 1 data1}
- {low_pc $::foo_start addr}
- {high_pc $::foo_len $::ptr_type}
- {external 1 flag}
+ DW_AT_name foo
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line $::foo_decl_line data1
+ DW_AT_decl_column 1 data1
+ DW_AT_low_pc $::foo_start addr
+ DW_AT_high_pc $::foo_len $::ptr_type
+ DW_AT_external 1 flag
} {
inlined_subroutine {
- {abstract_origin %$inline_func}
- {call_file 1 data1}
- {call_line $::bar_call_line data1}
- {entry_pc $entry_label addr}
- {ranges ${ranges_label} DW_FORM_sec_offset}
+ DW_AT_abstract_origin %$inline_func
+ DW_AT_call_file 1 data1
+ DW_AT_call_line $::bar_call_line data1
+ DW_AT_entry_pc $entry_label addr
+ DW_AT_ranges ${ranges_label} DW_FORM_sec_offset
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.exp b/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.exp
index 0822c98..fece767 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.exp
@@ -51,41 +51,41 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_Mips_Assembler}
+ DW_AT_language @DW_LANG_Mips_Assembler
} {
unspecified_type_label: unspecified_type {}
DW_TAG_subprogram {
- {name foo}
- {low_pc $foo_start addr}
- {high_pc $foo_end addr}
- {type :$unspecified_type_label}
+ DW_AT_name foo
+ DW_AT_low_pc $foo_start addr
+ DW_AT_high_pc $foo_end addr
+ DW_AT_type :$unspecified_type_label
}
}
}
cu {} {
compile_unit {
- {language @DW_LANG_Mips_Assembler}
- {producer "GNU AS 2.39.0"}
+ DW_AT_language @DW_LANG_Mips_Assembler
+ DW_AT_producer "GNU AS 2.39.0"
} {
DW_TAG_subprogram {
- {name bar}
- {low_pc $bar_start addr}
- {high_pc $bar_end addr}
+ DW_AT_name bar
+ DW_AT_low_pc $bar_start addr
+ DW_AT_high_pc $bar_end addr
}
}
}
cu { version 2 } {
compile_unit {
- {language @DW_LANG_Mips_Assembler}
- {producer "GNU AS 2.40.0"}
+ DW_AT_language @DW_LANG_Mips_Assembler
+ DW_AT_producer "GNU AS 2.40.0"
} {
DW_TAG_subprogram {
- {name foo2}
- {low_pc $foo2_start addr}
- {high_pc $foo2_end addr}
+ DW_AT_name foo2
+ DW_AT_low_pc $foo2_start addr
+ DW_AT_high_pc $foo2_end addr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-unusual-field-names.exp b/gdb/testsuite/gdb.dwarf2/dw2-unusual-field-names.exp
index 0a306dd..6632a86 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-unusual-field-names.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-unusual-field-names.exp
@@ -59,49 +59,49 @@ proc run_test { field_name } {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C}
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir /tmp}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name $srcfile
+ DW_AT_comp_dir /tmp
} {
declare_labels itype ptype stype
itype: DW_TAG_base_type {
- {DW_AT_byte_size $int_size DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name int}
+ DW_AT_byte_size $int_size DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int
}
stype: DW_TAG_structure_type {
- {DW_AT_name "foo"}
- {DW_AT_byte_size $int_size DW_FORM_sdata}
+ DW_AT_name "foo"
+ DW_AT_byte_size $int_size DW_FORM_sdata
} {
member {
- {name $field_name}
- {type :$itype}
- {data_member_location 0 data1}
+ DW_AT_name $field_name
+ DW_AT_type :$itype
+ DW_AT_data_member_location 0 data1
}
}
ptype: DW_TAG_pointer_type {
- {DW_AT_type :$stype}
+ DW_AT_type :$stype
}
DW_TAG_variable {
- {DW_AT_name obj}
- {DW_AT_type :$stype}
- {DW_AT_location {
+ DW_AT_name obj
+ DW_AT_type :$stype
+ DW_AT_location [subst {
DW_OP_addr [gdb_target_symbol obj]
- } SPECIAL_expr}
- {external 1 flag}
+ }] SPECIAL_expr
+ DW_AT_external 1 flag
}
DW_TAG_variable {
- {DW_AT_name ptr}
- {DW_AT_type :$ptype}
- {DW_AT_location {
+ DW_AT_name ptr
+ DW_AT_type :$ptype
+ DW_AT_location [subst {
DW_OP_addr [gdb_target_symbol ptr]
- } SPECIAL_expr}
- {external 1 flag}
+ }] SPECIAL_expr
+ DW_AT_external 1 flag
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp b/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp
index e46cbe5..6d8d9b1 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp
@@ -34,51 +34,51 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name ${srcfile}}
- } {
+ DW_AT_language @DW_LANG_C
+ DW_AT_name ${srcfile}
+ } {
declare_labels int4_type struct_type
int4_type: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
}
struct_type: DW_TAG_structure_type {
- {DW_AT_name "foo_t" DW_FORM_strp}
- {DW_AT_byte_size 12 DW_FORM_sdata}
+ DW_AT_name "foo_t" DW_FORM_strp
+ DW_AT_byte_size 12 DW_FORM_sdata
} {
member {
- {name "aa" DW_FORM_strp}
- {type :$int4_type}
- {data_member_location 0 data1}
+ DW_AT_name "aa" DW_FORM_strp
+ DW_AT_type :$int4_type
+ DW_AT_data_member_location 0 data1
}
member {
- {name "bb" DW_FORM_strp}
- {type :$int4_type}
- {data_member_location 4 data1}
+ DW_AT_name "bb" DW_FORM_strp
+ DW_AT_type :$int4_type
+ DW_AT_data_member_location 4 data1
}
member {
- {name "cc" DW_FORM_strp}
- {type :$int4_type}
- {data_member_location 8 data1}
+ DW_AT_name "cc" DW_FORM_strp
+ DW_AT_type :$int4_type
+ DW_AT_data_member_location 8 data1
}
}
DW_TAG_variable {
- {DW_AT_name global_var DW_FORM_strp}
- {DW_AT_type :$struct_type}
- {DW_AT_location {
+ DW_AT_name global_var DW_FORM_strp
+ DW_AT_type :$struct_type
+ DW_AT_location [subst {
DW_OP_addr [gdb_target_symbol global_var]
- } SPECIAL_expr}
- {external 1 flag}
+ }] SPECIAL_expr
+ DW_AT_external 1 flag
}
subprogram {
- {external 1 flag}
- {name main DW_FORM_strp}
- {MACRO_AT_range {main}}
+ DW_AT_external 1 flag
+ DW_AT_name main DW_FORM_strp
+ MACRO_AT_range {main}
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-var-zero-addr.exp b/gdb/testsuite/gdb.dwarf2/dw2-var-zero-addr.exp
index f021f42..c6234d5 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-var-zero-addr.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-var-zero-addr.exp
@@ -34,7 +34,7 @@ test
save_vars { GDBFLAGS } {
set GDBFLAGS "$GDBFLAGS --readnow"
- clean_restart ${binfile}
+ clean_restart ${::testfile}
}
with_test_prefix "readnow" {
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-vendor-extended-opcode.exp b/gdb/testsuite/gdb.dwarf2/dw2-vendor-extended-opcode.exp
index 3e4ffc4..6432c9d 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-vendor-extended-opcode.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-vendor-extended-opcode.exp
@@ -34,13 +34,13 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name dw2-vendor-extended-opcode.c}
- {stmt_list $Llines DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name dw2-vendor-extended-opcode.c
+ DW_AT_stmt_list $Llines DW_FORM_sec_offset
} {
subprogram {
- {external 1 flag}
- {MACRO_AT_func {main}}
+ DW_AT_external 1 flag
+ MACRO_AT_func {main}
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-weird-type-len.exp b/gdb/testsuite/gdb.dwarf2/dw2-weird-type-len.exp
index 0c76c87..35eaa16 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-weird-type-len.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-weird-type-len.exp
@@ -35,52 +35,52 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C}
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir /tmp}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name $srcfile
+ DW_AT_comp_dir /tmp
} {
declare_labels integer_label foo_t_label bar_t_label
foo_t_label: DW_TAG_structure_type {
- {name foo_t}
- {byte_size 3 DW_FORM_sdata}
+ DW_AT_name foo_t
+ DW_AT_byte_size 3 DW_FORM_sdata
} {
member {
- {name field}
- {type :$integer_label}
- {data_member_location 0 DW_FORM_sdata}
+ DW_AT_name field
+ DW_AT_type :$integer_label
+ DW_AT_data_member_location 0 DW_FORM_sdata
}
}
integer_label: DW_TAG_base_type {
- {DW_AT_byte_size 3 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
+ DW_AT_byte_size 3 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
}
bar_t_label: DW_TAG_structure_type {
- {name bar_t}
- {byte_size 3 DW_FORM_sdata}
+ DW_AT_name bar_t
+ DW_AT_byte_size 3 DW_FORM_sdata
} {
member {
- {name f}
- {type :$foo_t_label}
- {data_member_location 0 DW_FORM_sdata}
+ DW_AT_name f
+ DW_AT_type :$foo_t_label
+ DW_AT_data_member_location 0 DW_FORM_sdata
}
}
DW_TAG_subprogram {
- {name main}
- {low_pc $main_start addr}
- {high_pc $main_len data8}
- {DW_AT_type :$integer_label}
+ DW_AT_name main
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc $main_len data8
+ DW_AT_type :$integer_label
}
DW_TAG_subprogram {
- {name get_bar}
- {low_pc $get_bar_start addr}
- {high_pc $get_bar_len data8}
- {DW_AT_type :$bar_t_label}
+ DW_AT_name get_bar
+ DW_AT_low_pc $get_bar_start addr
+ DW_AT_high_pc $get_bar_len data8
+ DW_AT_type :$bar_t_label
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-wrong-mangled-name.exp b/gdb/testsuite/gdb.dwarf2/dw2-wrong-mangled-name.exp
index 33b1515..f892d70 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-wrong-mangled-name.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-wrong-mangled-name.exp
@@ -33,20 +33,20 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C_plus_plus}
- {name $srcfile}
+ DW_AT_language @DW_LANG_C_plus_plus
+ DW_AT_name $srcfile
} {
subprogram {
- {MACRO_AT_range {func_demangled_test}}
- {linkage_name "_FUNC_WRONG_MANGLED__"}
- {name "func_demangled_test"}
- {external 1 flag}
+ MACRO_AT_range {func_demangled_test}
+ DW_AT_linkage_name "_FUNC_WRONG_MANGLED__"
+ DW_AT_name "func_demangled_test"
+ DW_AT_external 1 flag
}
subprogram {
- {MACRO_AT_range {main}}
- {external 1 flag}
- {name main}
- {main_subprogram 1 flag}
+ MACRO_AT_range {main}
+ DW_AT_external 1 flag
+ DW_AT_name main
+ DW_AT_main_subprogram 1 flag
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp b/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp
index 221bf7b..d5faf6f 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp
@@ -26,7 +26,8 @@ standard_testfile .c -shlib.c -dw.S
# Test for presence of complaint, with the lib relocated.
proc_with_prefix test_relocated { exec_path lib_path complaint_re readnow_p } {
- clean_restart $exec_path
+ clean_restart
+ gdb_load $exec_path
gdb_load_shlib $lib_path
if { ![runto_main] } {
@@ -95,13 +96,13 @@ foreach_with_prefix ranges_sect {ranges rnglists} {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name $srcfile2}
- {ranges ${ranges_label} DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name $srcfile2
+ DW_AT_ranges ${ranges_label} DW_FORM_sec_offset
} {
subprogram {
- {external 1 flag}
- {name foo}
+ DW_AT_external 1 flag
+ DW_AT_name foo
}
}
}
@@ -122,13 +123,13 @@ foreach_with_prefix ranges_sect {ranges rnglists} {
version 5
} {
compile_unit {
- {language @DW_LANG_C}
- {name $srcfile2}
- {ranges ${rnglists_label} DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name $srcfile2
+ DW_AT_ranges ${rnglists_label} DW_FORM_sec_offset
} {
subprogram {
- {external 1 flag}
- {name foo}
+ DW_AT_external 1 flag
+ DW_AT_name foo
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dwz-unused-pu.exp b/gdb/testsuite/gdb.dwarf2/dwz-unused-pu.exp
index b7dc275..d9daedf 100644
--- a/gdb/testsuite/gdb.dwarf2/dwz-unused-pu.exp
+++ b/gdb/testsuite/gdb.dwarf2/dwz-unused-pu.exp
@@ -28,9 +28,11 @@ Dwarf::assemble $asm_file {
declare_labels partial_label int_label int_label2
cu {} {
- compile_unit {{language @DW_LANG_C}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C
+ } {
subprogram {
- {MACRO_AT_func { main }}
+ MACRO_AT_func { main }
}
}
}
@@ -38,15 +40,15 @@ Dwarf::assemble $asm_file {
cu {} {
partial_unit {} {
int_label: base_type {
- {name int}
- {byte_size 4 sdata}
- {encoding @DW_ATE_signed}
+ DW_AT_name int
+ DW_AT_byte_size 4 sdata
+ DW_AT_encoding @DW_ATE_signed
}
constant {
- {name the_int}
- {type :$int_label}
- {const_value 99 data1}
+ DW_AT_name the_int
+ DW_AT_type :$int_label
+ DW_AT_const_value 99 data1
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dwz.exp b/gdb/testsuite/gdb.dwarf2/dwz.exp
index 1d214c1..ebccea6 100644
--- a/gdb/testsuite/gdb.dwarf2/dwz.exp
+++ b/gdb/testsuite/gdb.dwarf2/dwz.exp
@@ -28,49 +28,53 @@ Dwarf::assemble $asm_file {
cu {} {
partial_label: partial_unit {} {
subprogram {
- {MACRO_AT_func { main }}
+ MACRO_AT_func { main }
}
}
}
cu {} {
- compile_unit {{language @DW_LANG_C}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C
+ } {
int_label2: base_type {
- {name int}
- {byte_size 4 sdata}
- {encoding @DW_ATE_signed}
+ DW_AT_name int
+ DW_AT_byte_size 4 sdata
+ DW_AT_encoding @DW_ATE_signed
}
constant {
- {name the_int}
- {type :$int_label2}
- {const_value 99 data1}
+ DW_AT_name the_int
+ DW_AT_type :$int_label2
+ DW_AT_const_value 99 data1
}
constant {
- {name other_int}
- {type :$int_label2}
- {const_value 99 data1}
+ DW_AT_name other_int
+ DW_AT_type :$int_label2
+ DW_AT_const_value 99 data1
}
}
}
cu {} {
- compile_unit {{language @DW_LANG_C}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C
+ } {
imported_unit {
- {import $partial_label ref_addr}
+ DW_AT_import $partial_label ref_addr
}
int_label: base_type {
- {name int}
- {byte_size 4 sdata}
- {encoding @DW_ATE_signed}
+ DW_AT_name int
+ DW_AT_byte_size 4 sdata
+ DW_AT_encoding @DW_ATE_signed
}
constant {
- {name the_int}
- {type :$int_label}
- {const_value 23 data1}
+ DW_AT_name the_int
+ DW_AT_type :$int_label
+ DW_AT_const_value 23 data1
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dwzbuildid.tcl b/gdb/testsuite/gdb.dwarf2/dwzbuildid.tcl
index a9077eb..1aa889a 100644
--- a/gdb/testsuite/gdb.dwarf2/dwzbuildid.tcl
+++ b/gdb/testsuite/gdb.dwarf2/dwzbuildid.tcl
@@ -51,7 +51,9 @@ proc write_just_debugaltlink {filename dwzname buildid} {
# Only the DWARF reader checks .gnu_debugaltlink, so make sure
# there is a bit of DWARF in here.
cu { label cu_start } {
- compile_unit {{language @DW_LANG_C}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C
+ } {
}
}
aranges {} cu_start {
@@ -77,17 +79,19 @@ proc write_dwarf_file {filename buildid {value 99}} {
}
cu { label cu_start } {
- compile_unit {{language @DW_LANG_C}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C
+ } {
int_label2: base_type {
- {name int}
- {byte_size 4 sdata}
- {encoding @DW_ATE_signed}
+ DW_AT_name int
+ DW_AT_byte_size 4 sdata
+ DW_AT_encoding @DW_ATE_signed
}
constant {
- {name the_int}
- {type :$int_label2}
- {const_value $value data1}
+ DW_AT_name the_int
+ DW_AT_type :$int_label2
+ DW_AT_const_value $value data1
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dwznolink.exp b/gdb/testsuite/gdb.dwarf2/dwznolink.exp
index 0c486ea..b568055 100644
--- a/gdb/testsuite/gdb.dwarf2/dwznolink.exp
+++ b/gdb/testsuite/gdb.dwarf2/dwznolink.exp
@@ -30,11 +30,13 @@ set asm_file [standard_output_file $srcfile2]
# one point, this caused gdb crashes.
Dwarf::assemble $asm_file {
cu {} {
- compile_unit {{language @DW_LANG_C}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C
+ } {
constant {
- {name 0 DW_FORM_GNU_strp_alt}
- {type 97 DW_FORM_GNU_ref_alt}
- {const_value 99 data1}
+ DW_AT_name 0 DW_FORM_GNU_strp_alt
+ DW_AT_type 97 DW_FORM_GNU_ref_alt
+ DW_AT_const_value 99 data1
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dyn-type-unallocated.exp b/gdb/testsuite/gdb.dwarf2/dyn-type-unallocated.exp
index 09af96c..e4248d0 100644
--- a/gdb/testsuite/gdb.dwarf2/dyn-type-unallocated.exp
+++ b/gdb/testsuite/gdb.dwarf2/dyn-type-unallocated.exp
@@ -66,57 +66,57 @@ Dwarf::assemble $asm_file {
global srcfile
compile_unit {
- {producer "gcc" }
- {language @DW_LANG_Fortran90}
- {name ${srcfile}}
- {low_pc 0 addr}
- } {
+ DW_AT_producer "gcc"
+ DW_AT_language @DW_LANG_Fortran90
+ DW_AT_name ${srcfile}
+ DW_AT_low_pc 0 addr
+ } {
declare_labels array_type_label integer_type_label
- integer_type_label: DW_TAG_base_type {
- {DW_AT_byte_size $int_size DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
- }
+ integer_type_label: DW_TAG_base_type {
+ DW_AT_byte_size $int_size DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
+ }
array_type_label: DW_TAG_array_type {
- {DW_AT_type :$integer_type_label}
- {DW_AT_data_location {
+ DW_AT_type :$integer_type_label
+ DW_AT_data_location {
DW_OP_push_object_address
DW_OP_deref
- } SPECIAL_expr}
- {DW_AT_allocated {
+ } SPECIAL_expr
+ DW_AT_allocated {
DW_OP_lit0
- } SPECIAL_expr}
+ } SPECIAL_expr
} {
DW_TAG_subrange_type {
- {DW_AT_type :$integer_type_label}
- {DW_AT_lower_bound {
+ DW_AT_type :$integer_type_label
+ DW_AT_lower_bound {
DW_OP_skip -3
- } SPECIAL_expr}
- {DW_AT_upper_bound {
+ } SPECIAL_expr
+ DW_AT_upper_bound {
DW_OP_skip -3
- } SPECIAL_expr}
- {DW_AT_byte_stride {
+ } SPECIAL_expr
+ DW_AT_byte_stride {
DW_OP_skip -3
- } SPECIAL_expr}
+ } SPECIAL_expr
}
}
DW_TAG_variable {
- {DW_AT_location {
- DW_OP_addr [gdb_target_symbol dyn_object]
- } SPECIAL_expr}
- {name "dyn_object"}
- {type :$array_type_label}
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol dyn_object]
+ }] SPECIAL_expr
+ DW_AT_name "dyn_object"
+ DW_AT_type :$array_type_label
}
subprogram {
- {external 1 flag}
- {DW_AT_name main}
- {DW_AT_low_pc $main_start DW_FORM_addr}
- {DW_AT_high_pc $main_end DW_FORM_addr}
+ DW_AT_external 1 flag
+ DW_AT_name main
+ DW_AT_low_pc $main_start DW_FORM_addr
+ DW_AT_high_pc $main_end DW_FORM_addr
}
- }
+ }
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dynamic-bit-offset.exp b/gdb/testsuite/gdb.dwarf2/dynamic-bit-offset.exp
index f4e02da..a5cf54d 100644
--- a/gdb/testsuite/gdb.dwarf2/dynamic-bit-offset.exp
+++ b/gdb/testsuite/gdb.dwarf2/dynamic-bit-offset.exp
@@ -32,35 +32,35 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_Ada95}
- {DW_AT_name $srcfile}
+ DW_AT_language @DW_LANG_Ada95
+ DW_AT_name $srcfile
} {
declare_labels byte array struct
byte: DW_TAG_base_type {
- {DW_AT_byte_size 1 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_unsigned}
- {DW_AT_name byte}
+ DW_AT_byte_size 1 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_unsigned
+ DW_AT_name byte
}
array: DW_TAG_array_type {
- {DW_AT_name array_type}
- {DW_AT_type :$byte}
+ DW_AT_name array_type
+ DW_AT_type :$byte
} {
DW_TAG_subrange_type {
- {DW_AT_type :$byte}
- {DW_AT_upper_bound 3 DW_FORM_sdata}
+ DW_AT_type :$byte
+ DW_AT_upper_bound 3 DW_FORM_sdata
}
}
struct: DW_TAG_structure_type {
- {DW_AT_name discriminated}
- {DW_AT_byte_size 4 DW_FORM_sdata}
+ DW_AT_name discriminated
+ DW_AT_byte_size 4 DW_FORM_sdata
} {
DW_TAG_member {
- {DW_AT_name disc}
- {DW_AT_type :$byte}
- {DW_AT_data_member_location 0 DW_FORM_sdata}
+ DW_AT_name disc
+ DW_AT_type :$byte
+ DW_AT_data_member_location 0 DW_FORM_sdata
}
# We know this is always at offset 1 but use an
@@ -68,18 +68,19 @@ Dwarf::assemble $asm_file {
# DWARF extension. See
# https://dwarfstd.org/issues/250501.1.html.
DW_TAG_member {
- {DW_AT_name nums}
- {DW_AT_type :$array}
- {DW_AT_data_bit_offset {DW_OP_lit8} SPECIAL_expr}
+ DW_AT_name nums
+ DW_AT_type :$array
+ DW_AT_data_bit_offset {DW_OP_lit8} SPECIAL_expr
}
}
DW_TAG_variable {
- {DW_AT_name "value"}
- {DW_AT_type :$struct}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "our_data"]}
- SPECIAL_expr}
+ DW_AT_name "value"
+ DW_AT_type :$struct
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "our_data"]
+ }] SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/dynarr-ptr.exp b/gdb/testsuite/gdb.dwarf2/dynarr-ptr.exp
index 1e06212..331cfc2 100644
--- a/gdb/testsuite/gdb.dwarf2/dynarr-ptr.exp
+++ b/gdb/testsuite/gdb.dwarf2/dynarr-ptr.exp
@@ -34,83 +34,83 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu {} {
- DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_Ada95}
- {DW_AT_name foo.adb}
- {DW_AT_comp_dir /tmp}
- } {
- declare_labels integer_label array_label array_ptr_label \
- array_typedef_label
- set ptr_size [get_sizeof "void *" 96]
+ DW_TAG_compile_unit {
+ DW_AT_language @DW_LANG_Ada95
+ DW_AT_name foo.adb
+ DW_AT_comp_dir /tmp
+ } {
+ declare_labels integer_label array_label array_ptr_label \
+ array_typedef_label
+ set ptr_size [get_sizeof "void *" 96]
set int_size [get_sizeof "int" 4]
- integer_label: DW_TAG_base_type {
- {DW_AT_byte_size $int_size DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
- }
+ integer_label: DW_TAG_base_type {
+ DW_AT_byte_size $int_size DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
+ }
array_label: DW_TAG_array_type {
- {DW_AT_name foo__array_type}
- {DW_AT_type :$integer_label}
- {external 1 flag}
+ DW_AT_name foo__array_type
+ DW_AT_type :$integer_label
+ DW_AT_external 1 flag
} {
DW_TAG_subrange_type {
- {DW_AT_type :$integer_label}
- {DW_AT_lower_bound {
- DW_OP_push_object_address
- DW_OP_const1u [expr {2 * $int_size}]
- DW_OP_minus
- DW_OP_deref_size $int_size
- } SPECIAL_expr}
- {DW_AT_upper_bound {
- DW_OP_push_object_address
+ DW_AT_type :$integer_label
+ DW_AT_lower_bound [subst {
+ DW_OP_push_object_address
+ DW_OP_const1u [expr {2 * $int_size}]
+ DW_OP_minus
+ DW_OP_deref_size $int_size
+ }] SPECIAL_expr
+ DW_AT_upper_bound [subst {
+ DW_OP_push_object_address
DW_OP_const1u $int_size
- DW_OP_minus
- DW_OP_deref_size $int_size
- } SPECIAL_expr}
+ DW_OP_minus
+ DW_OP_deref_size $int_size
+ }] SPECIAL_expr
}
}
- array_ptr_label: DW_TAG_pointer_type {
- {DW_AT_byte_size $ptr_size DW_FORM_data1}
- {DW_AT_type :$array_label}
- }
- array_typedef_label: DW_TAG_typedef {
- {DW_AT_name "foo__array_ptr"}
- {DW_AT_type :$array_ptr_label}
- }
- DW_TAG_variable {
- {DW_AT_name foo__three_ptr}
- {DW_AT_type :$array_ptr_label}
- {DW_AT_location {
- DW_OP_addr [gdb_target_symbol table_1_ptr]
- } SPECIAL_expr}
- {external 1 flag}
- }
- DW_TAG_variable {
- {DW_AT_name foo__three_ptr_tdef}
- {DW_AT_type :$array_typedef_label}
- {DW_AT_location {
- DW_OP_addr [gdb_target_symbol table_1_ptr]
- } SPECIAL_expr}
- {external 1 flag}
- }
- DW_TAG_variable {
- {DW_AT_name foo__five_ptr}
- {DW_AT_type :$array_ptr_label}
- {DW_AT_location {
- DW_OP_addr [gdb_target_symbol table_2_ptr]
- } SPECIAL_expr}
- {external 1 flag}
- }
- DW_TAG_variable {
- {DW_AT_name foo__five_ptr_tdef}
- {DW_AT_type :$array_typedef_label}
- {DW_AT_location {
- DW_OP_addr [gdb_target_symbol table_2_ptr]
- } SPECIAL_expr}
- {external 1 flag}
- }
+ array_ptr_label: DW_TAG_pointer_type {
+ DW_AT_byte_size $ptr_size DW_FORM_data1
+ DW_AT_type :$array_label
+ }
+ array_typedef_label: DW_TAG_typedef {
+ DW_AT_name "foo__array_ptr"
+ DW_AT_type :$array_ptr_label
+ }
+ DW_TAG_variable {
+ DW_AT_name foo__three_ptr
+ DW_AT_type :$array_ptr_label
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol table_1_ptr]
+ }] SPECIAL_expr
+ DW_AT_external 1 flag
+ }
+ DW_TAG_variable {
+ DW_AT_name foo__three_ptr_tdef
+ DW_AT_type :$array_typedef_label
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol table_1_ptr]
+ }] SPECIAL_expr
+ DW_AT_external 1 flag
+ }
+ DW_TAG_variable {
+ DW_AT_name foo__five_ptr
+ DW_AT_type :$array_ptr_label
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol table_2_ptr]
+ }] SPECIAL_expr
+ DW_AT_external 1 flag
+ }
+ DW_TAG_variable {
+ DW_AT_name foo__five_ptr_tdef
+ DW_AT_type :$array_typedef_label
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol table_2_ptr]
+ }] SPECIAL_expr
+ DW_AT_external 1 flag
+ }
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/enqueued-cu-base-addr.exp b/gdb/testsuite/gdb.dwarf2/enqueued-cu-base-addr.exp
index 621b2e7..96287dd 100644
--- a/gdb/testsuite/gdb.dwarf2/enqueued-cu-base-addr.exp
+++ b/gdb/testsuite/gdb.dwarf2/enqueued-cu-base-addr.exp
@@ -37,28 +37,28 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C_plus_plus}
- {name "cu1"}
+ DW_AT_language @DW_LANG_C_plus_plus
+ DW_AT_name "cu1"
} {
DW_TAG_variable {
- {name foo}
- {type %$int_label}
- {const_value 1 DW_FORM_sdata}
+ DW_AT_name foo
+ DW_AT_type %$int_label
+ DW_AT_const_value 1 DW_FORM_sdata
}
}
}
cu {} {
compile_unit {
- {language @DW_LANG_C_plus_plus}
- {name "cu2"}
- {ranges ${ranges_label} sec_offset}
- {low_pc {[lindex $main_func 0]}}
+ DW_AT_language @DW_LANG_C_plus_plus
+ DW_AT_name "cu2"
+ DW_AT_ranges ${ranges_label} sec_offset
+ DW_AT_low_pc [lindex $main_func 0]
} {
int_label: base_type {
- {byte_size 4 udata}
- {encoding @DW_ATE_signed}
- {name int}
+ DW_AT_byte_size 4 udata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/entry-value-typedef.exp b/gdb/testsuite/gdb.dwarf2/entry-value-typedef.exp
index 44d58a8..f84f0f3 100644
--- a/gdb/testsuite/gdb.dwarf2/entry-value-typedef.exp
+++ b/gdb/testsuite/gdb.dwarf2/entry-value-typedef.exp
@@ -31,7 +31,7 @@ if {[gdb_compile "$srcdir/$subdir/$srcfile" "$binfile" executable {c++}] != ""}
return
}
-clean_restart $binfile
+clean_restart $::testfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.dwarf2/enum-type.exp b/gdb/testsuite/gdb.dwarf2/enum-type.exp
index 121a350..f077c0a 100644
--- a/gdb/testsuite/gdb.dwarf2/enum-type.exp
+++ b/gdb/testsuite/gdb.dwarf2/enum-type.exp
@@ -26,41 +26,41 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C}
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir /tmp}
- } {
+ DW_AT_language @DW_LANG_C
+ DW_AT_name $srcfile
+ DW_AT_comp_dir /tmp
+ } {
declare_labels integer_label uinteger_label
- integer_label: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name int}
- }
+ integer_label: DW_TAG_base_type {
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int
+ }
- uinteger_label: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_unsigned}
- {DW_AT_name {unsigned int}}
- }
+ uinteger_label: DW_TAG_base_type {
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_unsigned
+ DW_AT_name {unsigned int}
+ }
DW_TAG_enumeration_type {
- {DW_AT_name E}
- {DW_AT_type :$integer_label}
+ DW_AT_name E
+ DW_AT_type :$integer_label
} {
DW_TAG_enumerator {
- {DW_AT_name ONE}
- {DW_AT_const_value 1 DW_FORM_sdata}
+ DW_AT_name ONE
+ DW_AT_const_value 1 DW_FORM_sdata
}
}
DW_TAG_enumeration_type {
- {DW_AT_name EU}
- {DW_AT_type :$uinteger_label}
+ DW_AT_name EU
+ DW_AT_type :$uinteger_label
} {
DW_TAG_enumerator {
- {DW_AT_name TWO}
- {DW_AT_const_value 2 DW_FORM_sdata}
+ DW_AT_name TWO
+ DW_AT_const_value 2 DW_FORM_sdata
}
}
}
@@ -68,34 +68,34 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C_plus_plus}
- {DW_AT_name tmp.c}
- {DW_AT_comp_dir /tmp}
+ DW_AT_language @DW_LANG_C_plus_plus
+ DW_AT_name tmp.c
+ DW_AT_comp_dir /tmp
} {
declare_labels integer_label forward
integer_label: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name int}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int
}
DW_TAG_enumeration_type {
- {DW_AT_specification :$forward}
+ DW_AT_specification :$forward
} {
DW_TAG_enumerator {
- {DW_AT_name val1}
- {DW_AT_const_value 1 DW_FORM_sdata}
+ DW_AT_name val1
+ DW_AT_const_value 1 DW_FORM_sdata
}
}
DW_TAG_namespace {
- {DW_AT_name ns}
+ DW_AT_name ns
} {
forward: DW_TAG_enumeration_type {
- {DW_AT_name e}
- {DW_AT_type :$integer_label}
- {DW_AT_declaration 1 flag}
+ DW_AT_name e
+ DW_AT_type :$integer_label
+ DW_AT_declaration 1 flag
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/fission-absolute-dwo.exp b/gdb/testsuite/gdb.dwarf2/fission-absolute-dwo.exp
index 4f354cd..640d4d2 100644
--- a/gdb/testsuite/gdb.dwarf2/fission-absolute-dwo.exp
+++ b/gdb/testsuite/gdb.dwarf2/fission-absolute-dwo.exp
@@ -40,53 +40,53 @@ Dwarf::assemble $asm_file {
set debug_addr_lbl [debug_addr_label]
compile_unit {
- {language @DW_LANG_C}
- {name ${srcfile}}
- {DW_AT_comp_dir ${objdir}}
- {DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8}
- } {
+ DW_AT_language @DW_LANG_C
+ DW_AT_name ${srcfile}
+ DW_AT_comp_dir ${objdir}
+ DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8
+ } {
declare_labels int4_type struct_type
int4_type: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
}
struct_type: DW_TAG_structure_type {
- {DW_AT_name "foo_t"}
- {DW_AT_byte_size 12 DW_FORM_sdata}
+ DW_AT_name "foo_t"
+ DW_AT_byte_size 12 DW_FORM_sdata
} {
member {
- {name "aa"}
- {type :$int4_type}
- {data_member_location 0 data1}
+ DW_AT_name "aa"
+ DW_AT_type :$int4_type
+ DW_AT_data_member_location 0 data1
}
member {
- {name "bb"}
- {type :$int4_type}
- {data_member_location 4 data1}
+ DW_AT_name "bb"
+ DW_AT_type :$int4_type
+ DW_AT_data_member_location 4 data1
}
member {
- {name "cc"}
- {type :$int4_type}
- {data_member_location 8 data1}
+ DW_AT_name "cc"
+ DW_AT_type :$int4_type
+ DW_AT_data_member_location 8 data1
}
}
DW_TAG_variable {
- {DW_AT_name global_var}
- {DW_AT_type :$struct_type}
- {DW_AT_location {
+ DW_AT_name global_var
+ DW_AT_type :$struct_type
+ DW_AT_location [subst {
DW_OP_GNU_addr_index [gdb_target_symbol global_var]
- } SPECIAL_expr}
- {external 1 flag}
+ }] SPECIAL_expr
+ DW_AT_external 1 flag
}
subprogram {
- {external 1 flag}
- {DW_AT_name main DW_FORM_string}
- {MACRO_AT_func {main}}
+ DW_AT_external 1 flag
+ DW_AT_name main DW_FORM_string
+ MACRO_AT_func {main}
}
}
}
@@ -94,11 +94,11 @@ Dwarf::assemble $asm_file {
# The information that will remain in the .o file.
cu {} {
compile_unit {
- {DW_AT_GNU_dwo_name ${binfile}.dwo DW_FORM_strp}
- {DW_AT_comp_dir ${objdir}}
- {DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8}
- {DW_AT_GNU_addr_base $debug_addr_lbl}
- } {
+ DW_AT_GNU_dwo_name ${binfile}.dwo DW_FORM_strp
+ DW_AT_comp_dir ${objdir}
+ DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8
+ DW_AT_GNU_addr_base $debug_addr_lbl
+ } {
# Nothing.
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/fission-base.exp b/gdb/testsuite/gdb.dwarf2/fission-base.exp
index 4d18ea0..9f70f30 100644
--- a/gdb/testsuite/gdb.dwarf2/fission-base.exp
+++ b/gdb/testsuite/gdb.dwarf2/fission-base.exp
@@ -35,7 +35,7 @@ if [build_executable_and_dwo_files "$testfile.exp" "${binfile}" {nodebug} \
return -1
}
-clean_restart $binfile
+clean_restart $::testfile
if ![runto_main] {
return -1
diff --git a/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp b/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp
index 4f5867c..5f778e6 100644
--- a/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp
+++ b/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp
@@ -32,7 +32,7 @@ Dwarf::assemble $main_asm_file {
dwo_id 0xF00D
} {
compile_unit {
- {DW_AT_dwo_name ${::gdb_test_file_name}.dwo DW_FORM_strp}
+ DW_AT_dwo_name ${::gdb_test_file_name}.dwo DW_FORM_strp
} {}
}
}
@@ -50,18 +50,18 @@ Dwarf::assemble $dwo_asm_file {
declare_labels int4_type
int4_type: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name 0 DW_FORM_strx_id}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name 0 DW_FORM_strx_id
}
DW_TAG_variable {
- {DW_AT_name global_var}
- {DW_AT_type :$int4_type}
- {DW_AT_location {
+ DW_AT_name global_var
+ DW_AT_type :$int4_type
+ DW_AT_location {
DW_OP_const1u 12
DW_OP_stack_value
- } SPECIAL_expr}
+ } SPECIAL_expr
}
}
}
@@ -83,6 +83,6 @@ if { [is_remote host] } {
gdb_remote_download host $dwo_file
}
-clean_restart $binfile
+clean_restart $::testfile
gdb_test "ptype global_var" "type = int"
diff --git a/gdb/testsuite/gdb.dwarf2/fission-loclists-pie.exp b/gdb/testsuite/gdb.dwarf2/fission-loclists-pie.exp
index 5be2e8e..aa54718 100644
--- a/gdb/testsuite/gdb.dwarf2/fission-loclists-pie.exp
+++ b/gdb/testsuite/gdb.dwarf2/fission-loclists-pie.exp
@@ -40,7 +40,7 @@ if [build_executable_and_dwo_files "$testfile.exp" "${binfile}" \
return -1
}
-clean_restart $binfile
+clean_restart $::testfile
if ![runto_main] {
return -1
diff --git a/gdb/testsuite/gdb.dwarf2/fission-loclists.exp b/gdb/testsuite/gdb.dwarf2/fission-loclists.exp
index 95c1fac..59cd10b 100644
--- a/gdb/testsuite/gdb.dwarf2/fission-loclists.exp
+++ b/gdb/testsuite/gdb.dwarf2/fission-loclists.exp
@@ -35,7 +35,7 @@ if [build_executable_and_dwo_files "$testfile.exp" "${binfile}" {nodebug} \
return -1
}
-clean_restart $binfile
+clean_restart $::testfile
if ![runto_main] {
return -1
diff --git a/gdb/testsuite/gdb.dwarf2/fission-mix.exp b/gdb/testsuite/gdb.dwarf2/fission-mix.exp
index e4741c3..e6a430c 100644
--- a/gdb/testsuite/gdb.dwarf2/fission-mix.exp
+++ b/gdb/testsuite/gdb.dwarf2/fission-mix.exp
@@ -35,7 +35,7 @@ if {[gdb_compile "$objfile $objfile2" $binfile executable {debug}] != "" } {
return -1
}
-clean_restart $binfile
+clean_restart $::testfile
gdb_test "break -q main" "Breakpoint .*"
diff --git a/gdb/testsuite/gdb.dwarf2/fission-multi-cu.exp b/gdb/testsuite/gdb.dwarf2/fission-multi-cu.exp
index 44e72d6..ff498c9 100644
--- a/gdb/testsuite/gdb.dwarf2/fission-multi-cu.exp
+++ b/gdb/testsuite/gdb.dwarf2/fission-multi-cu.exp
@@ -51,29 +51,29 @@ Dwarf::assemble $asm_file_1 {
set debug_addr_lbl [debug_addr_label]
compile_unit {
- {language @DW_LANG_C}
- {name ${srcfile}}
- {DW_AT_comp_dir ${objdir}}
- {DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8}
- } {
+ DW_AT_language @DW_LANG_C
+ DW_AT_name ${srcfile}
+ DW_AT_comp_dir ${objdir}
+ DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8
+ } {
int4_type: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name int}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int
}
subprogram {
- {external 1 flag}
- {DW_AT_name func DW_FORM_string}
- {MACRO_AT_func {func}}
- {DW_AT_type :$int4_type}
+ DW_AT_external 1 flag
+ DW_AT_name func DW_FORM_string
+ MACRO_AT_func {func}
+ DW_AT_type :$int4_type
} {
DW_TAG_formal_parameter {
- {DW_AT_name arg}
- {DW_AT_type :$int4_type}
- {DW_AT_location {
+ DW_AT_name arg
+ DW_AT_type :$int4_type
+ DW_AT_location [subst {
DW_OP_GNU_addr_index [gdb_target_symbol global_param]
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
}
}
@@ -100,12 +100,12 @@ Dwarf::assemble $asm_file_1 {
# The information that will remain in the .o file.
cu {} {
compile_unit {
- {DW_AT_GNU_dwo_name ${binfile}-1-dw.dwo DW_FORM_strp}
- {DW_AT_comp_dir ${objdir}}
- {DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8}
- {DW_AT_GNU_addr_base $debug_addr_lbl}
- {stmt_list $lines_table DW_FORM_sec_offset}
- } {
+ DW_AT_GNU_dwo_name ${binfile}-1-dw.dwo DW_FORM_strp
+ DW_AT_comp_dir ${objdir}
+ DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8
+ DW_AT_GNU_addr_base $debug_addr_lbl
+ DW_AT_stmt_list $lines_table DW_FORM_sec_offset
+ } {
# Nothing.
}
}
@@ -131,24 +131,24 @@ Dwarf::assemble $asm_file_2 {
set debug_addr_lbl [debug_addr_label]
compile_unit {
- {language @DW_LANG_C}
- {name ${srcfile}}
- {DW_AT_comp_dir ${objdir}}
- {DW_AT_GNU_dwo_id 0x4567 DW_FORM_data8}
- } {
+ DW_AT_language @DW_LANG_C
+ DW_AT_name ${srcfile}
+ DW_AT_comp_dir ${objdir}
+ DW_AT_GNU_dwo_id 0x4567 DW_FORM_data8
+ } {
int4_type: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name int}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int
}
subprogram {
- {external 1 flag}
- {DW_AT_name main DW_FORM_string}
- {MACRO_AT_func {main}}
- {DW_AT_type :$int4_type}
- {DW_AT_decl_file 1 data1}
- {DW_AT_decl_line 29 data1}
+ DW_AT_external 1 flag
+ DW_AT_name main DW_FORM_string
+ MACRO_AT_func {main}
+ DW_AT_type :$int4_type
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line 29 data1
}
}
}
@@ -182,12 +182,12 @@ Dwarf::assemble $asm_file_2 {
# The information that will remain in the .o file.
cu {} {
compile_unit {
- {DW_AT_GNU_dwo_name ${binfile}-2-dw.dwo DW_FORM_strp}
- {DW_AT_comp_dir ${objdir}}
- {DW_AT_GNU_dwo_id 0x4567 DW_FORM_data8}
- {DW_AT_GNU_addr_base $debug_addr_lbl}
- {stmt_list $lines_table DW_FORM_sec_offset}
- } {
+ DW_AT_GNU_dwo_name ${binfile}-2-dw.dwo DW_FORM_strp
+ DW_AT_comp_dir ${objdir}
+ DW_AT_GNU_dwo_id 0x4567 DW_FORM_data8
+ DW_AT_GNU_addr_base $debug_addr_lbl
+ DW_AT_stmt_list $lines_table DW_FORM_sec_offset
+ } {
# Nothing.
}
}
@@ -203,7 +203,7 @@ if [build_executable_and_dwo_files "$testfile.exp" "${binfile}" {nodebug} \
return -1
}
-clean_restart $binfile
+clean_restart $::testfile
if ![runto_main] {
return -1
diff --git a/gdb/testsuite/gdb.dwarf2/fission-relative-dwo.exp b/gdb/testsuite/gdb.dwarf2/fission-relative-dwo.exp
index 5590156..e605aef 100644
--- a/gdb/testsuite/gdb.dwarf2/fission-relative-dwo.exp
+++ b/gdb/testsuite/gdb.dwarf2/fission-relative-dwo.exp
@@ -37,53 +37,53 @@ Dwarf::assemble $asm_file {
set debug_addr_base [debug_addr_label]
compile_unit {
- {language @DW_LANG_C}
- {name ${srcfile}}
- {DW_AT_comp_dir .}
- {DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8}
- } {
+ DW_AT_language @DW_LANG_C
+ DW_AT_name ${srcfile}
+ DW_AT_comp_dir .
+ DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8
+ } {
declare_labels int4_type struct_type
int4_type: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
}
struct_type: DW_TAG_structure_type {
- {DW_AT_name "foo_t"}
- {DW_AT_byte_size 12 DW_FORM_sdata}
+ DW_AT_name "foo_t"
+ DW_AT_byte_size 12 DW_FORM_sdata
} {
member {
- {name "aa"}
- {type :$int4_type}
- {data_member_location 0 data1}
+ DW_AT_name "aa"
+ DW_AT_type :$int4_type
+ DW_AT_data_member_location 0 data1
}
member {
- {name "bb"}
- {type :$int4_type}
- {data_member_location 4 data1}
+ DW_AT_name "bb"
+ DW_AT_type :$int4_type
+ DW_AT_data_member_location 4 data1
}
member {
- {name "cc"}
- {type :$int4_type}
- {data_member_location 8 data1}
+ DW_AT_name "cc"
+ DW_AT_type :$int4_type
+ DW_AT_data_member_location 8 data1
}
}
DW_TAG_variable {
- {DW_AT_name global_var}
- {DW_AT_type :$struct_type}
- {DW_AT_location {
+ DW_AT_name global_var
+ DW_AT_type :$struct_type
+ DW_AT_location [subst {
DW_OP_GNU_addr_index [gdb_target_symbol global_var]
- } SPECIAL_expr}
- {external 1 flag}
+ }] SPECIAL_expr
+ DW_AT_external 1 flag
}
subprogram {
- {external 1 flag}
- {DW_AT_name main DW_FORM_string}
- {MACRO_AT_func {main}}
+ DW_AT_external 1 flag
+ DW_AT_name main DW_FORM_string
+ MACRO_AT_func {main}
}
}
}
@@ -91,11 +91,11 @@ Dwarf::assemble $asm_file {
# The information that will remain in the .o file.
cu {} {
compile_unit {
- {DW_AT_GNU_dwo_name ${gdb_test_file_name}.dwo DW_FORM_strp}
- {DW_AT_comp_dir .}
- {DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8}
- {DW_AT_GNU_addr_base $debug_addr_base}
- } {
+ DW_AT_GNU_dwo_name ${gdb_test_file_name}.dwo DW_FORM_strp
+ DW_AT_comp_dir .
+ DW_AT_GNU_dwo_id 0x1234 DW_FORM_data8
+ DW_AT_GNU_addr_base $debug_addr_base
+ } {
# Nothing.
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/fission-reread.exp b/gdb/testsuite/gdb.dwarf2/fission-reread.exp
index 6821747..238afb1 100644
--- a/gdb/testsuite/gdb.dwarf2/fission-reread.exp
+++ b/gdb/testsuite/gdb.dwarf2/fission-reread.exp
@@ -62,7 +62,7 @@ pass "$testfile - unload"
remote_file target delete $dwo
save_vars { GDBFLAGS } {
append GDBFLAGS " -iex \"maint set dwarf synchronous on\""
- clean_restart $binfile
+ clean_restart $::testfile
}
set output_dir [standard_output_file ""]
set cmd "save gdb-index"
diff --git a/gdb/testsuite/gdb.dwarf2/fission-with-type-unit.exp b/gdb/testsuite/gdb.dwarf2/fission-with-type-unit.exp
index 0a02f7c..58cda29 100644
--- a/gdb/testsuite/gdb.dwarf2/fission-with-type-unit.exp
+++ b/gdb/testsuite/gdb.dwarf2/fission-with-type-unit.exp
@@ -33,7 +33,7 @@ Dwarf::assemble $main_asm_file {
dwo_id 0xF00D
} {
compile_unit {
- {DW_AT_dwo_name ${::gdb_test_file_name}.dwo DW_FORM_strp}
+ DW_AT_dwo_name ${::gdb_test_file_name}.dwo DW_FORM_strp
} {}
}
}
@@ -46,9 +46,9 @@ Dwarf::assemble $dwo_asm_file {
} 0xCAFE "the_type" {
type_unit {} {
the_type: base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name int}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int
}
}
}
@@ -62,18 +62,18 @@ Dwarf::assemble $dwo_asm_file {
declare_labels int4_type
int4_type: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name int}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int
}
DW_TAG_variable {
- {DW_AT_name global_var}
- {DW_AT_type :$int4_type}
- {DW_AT_location {
+ DW_AT_name global_var
+ DW_AT_type :$int4_type
+ DW_AT_location {
DW_OP_const1u 12
DW_OP_stack_value
- } SPECIAL_expr}
+ } SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/formdata16.exp b/gdb/testsuite/gdb.dwarf2/formdata16.exp
index 70c7cc4..c08183e 100644
--- a/gdb/testsuite/gdb.dwarf2/formdata16.exp
+++ b/gdb/testsuite/gdb.dwarf2/formdata16.exp
@@ -50,33 +50,33 @@ Dwarf::assemble $asm_file {
declare_labels int_label sint_label
int_label: DW_TAG_base_type {
- {DW_AT_byte_size 16 DW_FORM_udata}
- {DW_AT_encoding @DW_ATE_unsigned}
- {DW_AT_name "__uint128"}
+ DW_AT_byte_size 16 DW_FORM_udata
+ DW_AT_encoding @DW_ATE_unsigned
+ DW_AT_name "__uint128"
}
sint_label: DW_TAG_base_type {
- {DW_AT_byte_size 16 DW_FORM_udata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name "__int128"}
+ DW_AT_byte_size 16 DW_FORM_udata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name "__int128"
}
DW_TAG_variable {
- {name xxx}
- {type :$int_label}
- {const_value $pair DW_FORM_data16}
+ DW_AT_name xxx
+ DW_AT_type :$int_label
+ DW_AT_const_value $pair DW_FORM_data16
}
DW_TAG_variable {
- {name yyy}
- {type :$int_label}
- {const_value $pair2 DW_FORM_data16}
+ DW_AT_name yyy
+ DW_AT_type :$int_label
+ DW_AT_const_value $pair2 DW_FORM_data16
}
DW_TAG_variable {
- {name sss}
- {type :$sint_label}
- {const_value $negative DW_FORM_data16}
+ DW_AT_name sss
+ DW_AT_type :$sint_label
+ DW_AT_const_value $negative DW_FORM_data16
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/fortran-var-string.exp b/gdb/testsuite/gdb.dwarf2/fortran-var-string.exp
index e4a1270..b751900 100644
--- a/gdb/testsuite/gdb.dwarf2/fortran-var-string.exp
+++ b/gdb/testsuite/gdb.dwarf2/fortran-var-string.exp
@@ -40,92 +40,92 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_Fortran90}
- {DW_AT_name fortran-var-string.f90}
- {DW_AT_comp_dir /tmp}
- } {
+ DW_AT_language @DW_LANG_Fortran90
+ DW_AT_name fortran-var-string.f90
+ DW_AT_comp_dir /tmp
+ } {
declare_labels integer_label string_label array_lb_label \
array_ub_label
DW_TAG_subprogram {
- {name main}
- {low_pc $main_helper_start addr}
- {high_pc $main_helper_len data8}
- {DW_AT_type :$integer_label}
- {DW_AT_decl_file 1 data1}
- {DW_AT_decl_line 1 data1}
+ DW_AT_name main
+ DW_AT_low_pc $main_helper_start addr
+ DW_AT_high_pc $main_helper_len data8
+ DW_AT_type :$integer_label
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line 1 data1
}
DW_TAG_subprogram {
- {name test_1_func}
- {low_pc $main_start addr}
- {high_pc $main_len data8}
- {DW_AT_type :$integer_label}
- {DW_AT_decl_file 1 data1}
- {DW_AT_decl_line 2 data1}
+ DW_AT_name test_1_func
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc $main_len data8
+ DW_AT_type :$integer_label
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line 2 data1
} {
formal_parameter {
- {name arg1}
- {type :$string_label}
+ DW_AT_name arg1
+ DW_AT_type :$string_label
}
}
DW_TAG_subprogram {
- {name test_2_func}
- {low_pc $main_start addr}
- {high_pc $main_len data8}
- {DW_AT_type :$integer_label}
- {DW_AT_decl_file 1 data1}
- {DW_AT_decl_line 3 data1}
+ DW_AT_name test_2_func
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc $main_len data8
+ DW_AT_type :$integer_label
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line 3 data1
} {
formal_parameter {
- {name arg1}
- {type :$array_ub_label}
+ DW_AT_name arg1
+ DW_AT_type :$array_ub_label
}
}
DW_TAG_subprogram {
- {name test_3_func}
- {low_pc $main_start addr}
- {high_pc $main_len data8}
- {DW_AT_type :$integer_label}
- {DW_AT_decl_file 1 data1}
- {DW_AT_decl_line 4 data1}
+ DW_AT_name test_3_func
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc $main_len data8
+ DW_AT_type :$integer_label
+ DW_AT_decl_file 1 data1
+ DW_AT_decl_line 4 data1
} {
formal_parameter {
- {name arg1}
- {type :$array_lb_label}
+ DW_AT_name arg1
+ DW_AT_type :$array_lb_label
}
}
integer_label: DW_TAG_base_type {
- {DW_AT_byte_size $int_size DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
+ DW_AT_byte_size $int_size DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
}
string_label: DW_TAG_string_type {
- {DW_AT_byte_size $int_size DW_FORM_sdata}
- {DW_AT_name .str.arg}
- {DW_AT_string_length {} DW_FORM_block1}
+ DW_AT_byte_size $int_size DW_FORM_sdata
+ DW_AT_name .str.arg
+ DW_AT_string_length {} DW_FORM_block1
}
array_lb_label: DW_TAG_array_type {
- {DW_AT_ordering 1 data1}
- {DW_AT_type :$integer_label}
+ DW_AT_ordering 1 data1
+ DW_AT_type :$integer_label
} {
DW_TAG_subrange_type {
- {DW_AT_lower_bound {} DW_FORM_block1}
- {DW_AT_upper_bound 10 DW_FORM_data1}
+ DW_AT_lower_bound {} DW_FORM_block1
+ DW_AT_upper_bound 10 DW_FORM_data1
}
}
array_ub_label: DW_TAG_array_type {
- {DW_AT_ordering 1 data1}
- {DW_AT_type :$integer_label}
+ DW_AT_ordering 1 data1
+ DW_AT_type :$integer_label
} {
DW_TAG_subrange_type {
- {DW_AT_upper_bound {} DW_FORM_block1}
+ DW_AT_upper_bound {} DW_FORM_block1
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/forward-spec-inter-cu.exp b/gdb/testsuite/gdb.dwarf2/forward-spec-inter-cu.exp
index e92e582..7d55f73 100644
--- a/gdb/testsuite/gdb.dwarf2/forward-spec-inter-cu.exp
+++ b/gdb/testsuite/gdb.dwarf2/forward-spec-inter-cu.exp
@@ -20,6 +20,7 @@ load_lib dwarf.exp
# This test can only be run on targets which support DWARF-2 and use gas.
require dwarf2_support
+require !readnow
standard_testfile main.c -debug.S
@@ -32,40 +33,40 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C_plus_plus}
+ DW_AT_language @DW_LANG_C_plus_plus
} {
# The new indexer has special code to compute the full
# name of an object that uses a specification that appears
# later in the DWARF.
DW_TAG_variable {
- {DW_AT_specification %$spec}
- {DW_AT_location {
+ DW_AT_specification %$spec
+ DW_AT_location {
DW_OP_const1u 23
DW_OP_stack_value
- } SPECIAL_expr}
+ } SPECIAL_expr
}
}
}
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C_plus_plus}
+ DW_AT_language @DW_LANG_C_plus_plus
} {
declare_labels myint
myint: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name myint}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name myint
}
DW_TAG_namespace {
- {DW_AT_name ns}
+ DW_AT_name ns
} {
spec: DW_TAG_variable {
- {DW_AT_name v}
- {DW_AT_type :$myint}
- {DW_AT_declaration 1 DW_FORM_flag_present}
+ DW_AT_name v
+ DW_AT_type :$myint
+ DW_AT_declaration 1 DW_FORM_flag_present
}
}
}
@@ -98,6 +99,11 @@ foreach_with_prefix worker_threads $worker_threads_list {
gdb_load $binfile
+ set index [have_index $binfile]
+ if { ![string eq $index ""] } {
+ return
+ }
+
gdb_test "pipe maint print objfiles | grep ns::v" \
"$ws+qualified:$ws+ns::v" \
"v has parent ns"
diff --git a/gdb/testsuite/gdb.dwarf2/forward-spec.exp b/gdb/testsuite/gdb.dwarf2/forward-spec.exp
index 6c38be8..e534da2 100644
--- a/gdb/testsuite/gdb.dwarf2/forward-spec.exp
+++ b/gdb/testsuite/gdb.dwarf2/forward-spec.exp
@@ -32,9 +32,9 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C_plus_plus}
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir /tmp}
+ DW_AT_language @DW_LANG_C_plus_plus
+ DW_AT_name $srcfile
+ DW_AT_comp_dir /tmp
} {
declare_labels spec myint
@@ -43,26 +43,26 @@ Dwarf::assemble $asm_file {
# name of an object that uses a specification that appears
# later in the DWARF.
DW_TAG_variable {
- {DW_AT_specification :$spec}
- {DW_AT_location {
+ DW_AT_specification :$spec
+ DW_AT_location {
DW_OP_const1u 23
DW_OP_stack_value
- } SPECIAL_expr}
+ } SPECIAL_expr
}
myint: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name myint}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name myint
}
DW_TAG_namespace {
- {DW_AT_name ns}
+ DW_AT_name ns
} {
spec: DW_TAG_variable {
- {DW_AT_name v}
- {DW_AT_type :$myint}
- {DW_AT_declaration 1 DW_FORM_flag_present}
+ DW_AT_name v
+ DW_AT_type :$myint
+ DW_AT_declaration 1 DW_FORM_flag_present
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp b/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp
index ef7cf92..ad19ce7 100644
--- a/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp
+++ b/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp
@@ -46,44 +46,44 @@ Dwarf::assemble $dwarf_asm {
cu { label cu_label addr_size 4 } {
DW_TAG_compile_unit {
- {DW_AT_name $srcfile}
- {DW_AT_stmt_list $stmt_list DW_FORM_sec_offset}
- {DW_AT_language @DW_LANG_C99}
- {DW_AT_low_pc __cu_low_pc DW_FORM_addr}
- {DW_AT_high_pc __cu_high_pc DW_FORM_addr}
+ DW_AT_name $srcfile
+ DW_AT_stmt_list $stmt_list DW_FORM_sec_offset
+ DW_AT_language @DW_LANG_C99
+ DW_AT_low_pc __cu_low_pc DW_FORM_addr
+ DW_AT_high_pc __cu_high_pc DW_FORM_addr
} {
DW_TAG_subprogram {
- {DW_AT_name "_start"}
- {DW_AT_low_pc __start_low_pc DW_FORM_addr}
- {DW_AT_high_pc __start_high_pc DW_FORM_addr}
+ DW_AT_name "_start"
+ DW_AT_low_pc __start_low_pc DW_FORM_addr
+ DW_AT_high_pc __start_high_pc DW_FORM_addr
} {
DW_TAG_inlined_subroutine {
- {DW_AT_abstract_origin :$foo_subprogram}
- {DW_AT_low_pc __foo_low_pc DW_FORM_addr}
- {DW_AT_high_pc __foo_high_pc DW_FORM_addr}
- {DW_AT_call_file 1 DW_FORM_data1}
- {DW_AT_call_line 13 DW_FORM_data1}
+ DW_AT_abstract_origin :$foo_subprogram
+ DW_AT_low_pc __foo_low_pc DW_FORM_addr
+ DW_AT_high_pc __foo_high_pc DW_FORM_addr
+ DW_AT_call_file 1 DW_FORM_data1
+ DW_AT_call_line 13 DW_FORM_data1
} {
DW_TAG_inlined_subroutine {
- {DW_AT_abstract_origin :$bar_subprogram}
- {DW_AT_low_pc __bar_low_pc DW_FORM_addr}
- {DW_AT_high_pc __bar_high_pc DW_FORM_addr}
- {DW_AT_call_file 1 DW_FORM_data1}
- {DW_AT_call_line 7 DW_FORM_data1}
+ DW_AT_abstract_origin :$bar_subprogram
+ DW_AT_low_pc __bar_low_pc DW_FORM_addr
+ DW_AT_high_pc __bar_high_pc DW_FORM_addr
+ DW_AT_call_file 1 DW_FORM_data1
+ DW_AT_call_line 7 DW_FORM_data1
}
}
}
foo_subprogram: DW_TAG_subprogram {
- {DW_AT_name "foo"}
- {DW_AT_prototyped 1 DW_FORM_flag_present}
- {DW_AT_inline 0x1 DW_FORM_data1}
+ DW_AT_name "foo"
+ DW_AT_prototyped 1 DW_FORM_flag_present
+ DW_AT_inline 0x1 DW_FORM_data1
}
bar_subprogram: DW_TAG_subprogram {
- {DW_AT_name "bar"}
- {DW_AT_prototyped 1 DW_FORM_flag_present}
- {DW_AT_inline 0x1 DW_FORM_data1}
+ DW_AT_name "bar"
+ DW_AT_prototyped 1 DW_FORM_flag_present
+ DW_AT_inline 0x1 DW_FORM_data1
}
}
}
@@ -106,7 +106,7 @@ if { [build_executable ${testfile}.exp ${testfile} "$srcfile $dwarf_asm" \
return
}
-clean_restart $binfile
+clean_restart $::testfile
if { [gdb_starti_cmd] != 0 } {
fail "failed to run to first instruction"
diff --git a/gdb/testsuite/gdb.dwarf2/gdb-add-index-symlink.exp b/gdb/testsuite/gdb.dwarf2/gdb-add-index-symlink.exp
index cd05925..9233637 100644
--- a/gdb/testsuite/gdb.dwarf2/gdb-add-index-symlink.exp
+++ b/gdb/testsuite/gdb.dwarf2/gdb-add-index-symlink.exp
@@ -56,7 +56,8 @@ if { [ensure_gdb_index $symlink] == -1 } {
# Ok, we have a copy of $binfile with an index.
# Restart gdb and verify the index was used.
-clean_restart $symlink
+clean_restart
+gdb_load $symlink
gdb_test "mt print objfiles ${testfile}" \
"(gdb_index|debug_names).*" \
"index used"
diff --git a/gdb/testsuite/gdb.dwarf2/gdb-add-index.exp b/gdb/testsuite/gdb.dwarf2/gdb-add-index.exp
index 3285d1c..0fbd3a2 100644
--- a/gdb/testsuite/gdb.dwarf2/gdb-add-index.exp
+++ b/gdb/testsuite/gdb.dwarf2/gdb-add-index.exp
@@ -33,7 +33,7 @@ if { [ensure_gdb_index $binfile] == -1 } {
# Ok, we have a copy of $binfile with an index.
# Restart gdb and verify the index was used.
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_test "mt print objfiles ${testfile}" \
"(gdb_index|debug_names).*" \
"index used"
diff --git a/gdb/testsuite/gdb.dwarf2/gdb-index-tilde.exp b/gdb/testsuite/gdb.dwarf2/gdb-index-tilde.exp
index c0d5225..a8c5c39 100644
--- a/gdb/testsuite/gdb.dwarf2/gdb-index-tilde.exp
+++ b/gdb/testsuite/gdb.dwarf2/gdb-index-tilde.exp
@@ -47,7 +47,7 @@ if { [prepare_for_testing "failed to prepare" "${testfile}" ${srcfile}] } {
}
# Start GDB and load in the executable.
-clean_restart ${binfile}
+clean_restart ${::testfile}
# If the executable was built with an index, or lacks the debug
# information required to create an index, then we'll not be able to
diff --git a/gdb/testsuite/gdb.dwarf2/gdb-index-types-dwarf5.exp b/gdb/testsuite/gdb.dwarf2/gdb-index-types-dwarf5.exp
index d6f5e48..a47d73a 100644
--- a/gdb/testsuite/gdb.dwarf2/gdb-index-types-dwarf5.exp
+++ b/gdb/testsuite/gdb.dwarf2/gdb-index-types-dwarf5.exp
@@ -13,6 +13,10 @@
# 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 test checks that .gdb_index is in use, which isn't the case
+# with readnow.
+require !readnow
+
standard_testfile
set flags {}
@@ -29,7 +33,7 @@ if { [ensure_gdb_index $binfile] != 1 } {
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
# Verify that .gdb_index section is not ignored.
set index [have_index $binfile]
diff --git a/gdb/testsuite/gdb.dwarf2/gdb-index.exp b/gdb/testsuite/gdb.dwarf2/gdb-index.exp
index ebeb62b..f7c3337 100644
--- a/gdb/testsuite/gdb.dwarf2/gdb-index.exp
+++ b/gdb/testsuite/gdb.dwarf2/gdb-index.exp
@@ -98,20 +98,24 @@ set test "check if index present"
set filter "gdb_index|debug_names|Psymtabs|Cooked"
set cmd "pipe mt print objfiles ${testfile} | grep -E \"$filter\""
set cmd_re [string_to_regexp $cmd]
+set testfile_with_index bla
gdb_test_multiple $cmd $test {
-re ^$cmd_re {
exp_continue
}
-re "gdb_index.*${gdb_prompt} $" {
- set binfile_with_index $binfile
+ set testfile_with_index $testfile
+ set binfile_with_index [standard_output_file $testfile_with_index]
set host_binfile_with_index [gdb_remote_download host $binfile]
}
-re "debug_names.*${gdb_prompt} $" {
- set binfile_with_index $binfile
+ set testfile_with_index $testfile
+ set binfile_with_index [standard_output_file $testfile_with_index]
set host_binfile_with_index [gdb_remote_download host $binfile]
}
-re "(Psymtabs|Cooked).*${gdb_prompt} $" {
lassign [local_add_gdb_index $binfile] binfile_with_index host_binfile_with_index
+ set testfile_with_index [file tail $binfile_with_index]
if { ${binfile_with_index} == "" } {
return -1
}
@@ -124,7 +128,7 @@ gdb_test_multiple $cmd $test {
# Ok, we have a copy of $binfile with an index.
# Restart gdb and verify the index was used.
-clean_restart ${binfile_with_index}
+clean_restart $testfile_with_index
gdb_test "mt print objfiles ${testfile}" \
"(gdb_index|debug_names).*" \
"index used"
diff --git a/gdb/testsuite/gdb.dwarf2/implptr-64bit.exp b/gdb/testsuite/gdb.dwarf2/implptr-64bit.exp
index c4496f1..be3a648 100644
--- a/gdb/testsuite/gdb.dwarf2/implptr-64bit.exp
+++ b/gdb/testsuite/gdb.dwarf2/implptr-64bit.exp
@@ -39,54 +39,54 @@ proc test_1 { name dwarf_version offset_size addr_size ref_addr_size two_cu } {
is_64 $is_64
} {
compile_unit {
- { producer "GNU C 4.4.3" }
- { language @DW_LANG_C89 }
- { name 1.c }
+ DW_AT_producer "GNU C 4.4.3"
+ DW_AT_language @DW_LANG_C89
+ DW_AT_name 1.c
} {
declare_labels struct_label variable_label int_label pointer_label
int_label: base_type {
- { byte_size 4 DW_FORM_sdata }
- { DW_AT_encoding @DW_ATE_signed }
- { name int }
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int
}
struct_label: structure_type {
- { name s }
- { byte_size 4 sdata }
+ DW_AT_name s
+ DW_AT_byte_size 4 sdata
} {
member {
- { name f }
- { type :$int_label }
- { data_member_location 0 data1 }
+ DW_AT_name f
+ DW_AT_type :$int_label
+ DW_AT_data_member_location 0 data1
}
}
pointer_label: pointer_type {
- { byte_size $Dwarf::_cu_addr_size sdata }
- { type :$struct_label }
+ DW_AT_byte_size $Dwarf::_cu_addr_size sdata
+ DW_AT_type :$struct_label
}
variable_label: DW_TAG_variable {
- { name v }
- { location {
+ DW_AT_name v
+ DW_AT_location {
DW_OP_implicit_value 0x1 0x1 0x1 0x1
- } SPECIAL_expr}
- { type :$struct_label "DW_FORM_ref$ref_addr_size" }
+ } SPECIAL_expr
+ DW_AT_type :$struct_label "DW_FORM_ref$ref_addr_size"
}
if { !$two_cu } {
subprogram {
- {MACRO_AT_func {main}}
- { type :$int_label }
- { external 1 flag }
+ MACRO_AT_func {main}
+ DW_AT_type :$int_label
+ DW_AT_external 1 flag
} {
DW_TAG_variable {
- { name p }
- { location {
+ DW_AT_name p
+ DW_AT_location [subst {
GNU_implicit_pointer $variable_label 0
- } SPECIAL_expr }
- { type :$pointer_label "DW_FORM_ref$ref_addr_size" }
+ }] SPECIAL_expr
+ DW_AT_type :$pointer_label "DW_FORM_ref$ref_addr_size"
}
}
}
@@ -100,21 +100,21 @@ proc test_1 { name dwarf_version offset_size addr_size ref_addr_size two_cu } {
is_64 $is_64
} {
compile_unit {
- { producer "GNU C 4.4.3" }
- { language @DW_LANG_C89 }
- { name 1.c }
+ DW_AT_producer "GNU C 4.4.3"
+ DW_AT_language @DW_LANG_C89
+ DW_AT_name 1.c
} {
subprogram {
- { MACRO_AT_func {main} }
- { type %$int_label }
- { external 1 flag }
+ MACRO_AT_func {main}
+ DW_AT_type %$int_label
+ DW_AT_external 1 flag
} {
DW_TAG_variable {
- { name p }
- { location {
+ DW_AT_name p
+ DW_AT_location [subst {
GNU_implicit_pointer $variable_label 0
- } SPECIAL_expr }
- { type %$pointer_label }
+ }] SPECIAL_expr
+ DW_AT_type %$pointer_label
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/implptr-optimized-out.exp b/gdb/testsuite/gdb.dwarf2/implptr-optimized-out.exp
index 79fcf61..7feb983 100644
--- a/gdb/testsuite/gdb.dwarf2/implptr-optimized-out.exp
+++ b/gdb/testsuite/gdb.dwarf2/implptr-optimized-out.exp
@@ -25,51 +25,51 @@ set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu { version 3 addr_size 4 } {
compile_unit {
- {producer "GNU C 4.4.3"}
- {language @DW_LANG_C89}
- {name 1.c}
+ DW_AT_producer "GNU C 4.4.3"
+ DW_AT_language @DW_LANG_C89
+ DW_AT_name 1.c
} {
declare_labels int_label struct_label pointer_label variable_label
int_label: base_type {
- {byte_size 4 sdata}
- {encoding @DW_ATE_signed}
- {name int}
+ DW_AT_byte_size 4 sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int
}
struct_label: structure_type {
- {name s}
- {byte_size 4 sdata}
+ DW_AT_name s
+ DW_AT_byte_size 4 sdata
} {
member {
- {name f}
- {type :$int_label}
- {data_member_location 0 data1}
+ DW_AT_name f
+ DW_AT_type :$int_label
+ DW_AT_data_member_location 0 data1
}
}
subprogram {
- {MACRO_AT_func { main }}
- {type :$int_label}
- {external 1 flag}
+ MACRO_AT_func { main }
+ DW_AT_type :$int_label
+ DW_AT_external 1 flag
} {
pointer_label: pointer_type {
- {byte_size 4 sdata}
- {type :$struct_label}
+ DW_AT_byte_size 4 sdata
+ DW_AT_type :$struct_label
}
variable_label: DW_TAG_variable {
- {name v}
- {location {} DW_FORM_block1}
- {type :$struct_label}
+ DW_AT_name v
+ DW_AT_location {} DW_FORM_block1
+ DW_AT_type :$struct_label
}
DW_TAG_variable {
- {name p}
- {location {
+ DW_AT_name p
+ DW_AT_location [subst {
GNU_implicit_pointer $variable_label 0
- } SPECIAL_expr}
- {type :$pointer_label}
+ }] SPECIAL_expr
+ DW_AT_type :$pointer_label
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/implptrconst.exp b/gdb/testsuite/gdb.dwarf2/implptrconst.exp
index f3d47a2..8e735ca 100644
--- a/gdb/testsuite/gdb.dwarf2/implptrconst.exp
+++ b/gdb/testsuite/gdb.dwarf2/implptrconst.exp
@@ -33,51 +33,51 @@ Dwarf::assemble $asm_file {
declare_labels var_label ptr_label
byte_label: base_type {
- {name byte}
- {encoding @DW_ATE_signed}
- {byte_size 1 DW_FORM_sdata}
+ DW_AT_name byte
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 1 DW_FORM_sdata
}
size_type_label: base_type {
- {name sizetype}
- {encoding @DW_ATE_unsigned}
- {byte_size 4 DW_FORM_sdata}
+ DW_AT_name sizetype
+ DW_AT_encoding @DW_ATE_unsigned
+ DW_AT_byte_size 4 DW_FORM_sdata
}
array_label: array_type {
- {type :$byte_label}
+ DW_AT_type :$byte_label
} {
subrange_type {
- {type :$size_type_label}
- {upper_bound 7 DW_FORM_data1}
+ DW_AT_type :$size_type_label
+ DW_AT_upper_bound 7 DW_FORM_data1
}
}
var_label: DW_TAG_variable {
- {name b}
- {type :$array_label}
- {const_value rstuvwxy DW_FORM_block1}
+ DW_AT_name b
+ DW_AT_type :$array_label
+ DW_AT_const_value rstuvwxy DW_FORM_block1
}
ptr_label: pointer_type {
- {byte_size 4 DW_FORM_sdata}
- {type :$byte_label}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_type :$byte_label
}
DW_TAG_variable {
- {name c}
- {type :$ptr_label}
- {location {
+ DW_AT_name c
+ DW_AT_type :$ptr_label
+ DW_AT_location [subst {
GNU_implicit_pointer $var_label 0
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
DW_TAG_variable {
- {name d}
- {type :$ptr_label}
- {location {
+ DW_AT_name d
+ DW_AT_type :$ptr_label
+ DW_AT_location [subst {
GNU_implicit_pointer $var_label 2
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/implptrpiece.exp b/gdb/testsuite/gdb.dwarf2/implptrpiece.exp
index 9654483..58c5e66 100644
--- a/gdb/testsuite/gdb.dwarf2/implptrpiece.exp
+++ b/gdb/testsuite/gdb.dwarf2/implptrpiece.exp
@@ -36,48 +36,48 @@ Dwarf::assemble $asm_file {
declare_labels var_label
struct_label: structure_type {
- {name S}
- {byte_size 4 DW_FORM_sdata}
+ DW_AT_name S
+ DW_AT_byte_size 4 DW_FORM_sdata
} {
member {
- {name a}
- {type :$short_type_label}
- {data_member_location 0 DW_FORM_sdata}
+ DW_AT_name a
+ DW_AT_type :$short_type_label
+ DW_AT_data_member_location 0 DW_FORM_sdata
}
member {
- {name b}
- {type :$char_type_label}
- {data_member_location 2 DW_FORM_sdata}
+ DW_AT_name b
+ DW_AT_type :$char_type_label
+ DW_AT_data_member_location 2 DW_FORM_sdata
}
member {
- {name c}
- {type :$char_type_label}
- {data_member_location 3 DW_FORM_sdata}
+ DW_AT_name c
+ DW_AT_type :$char_type_label
+ DW_AT_data_member_location 3 DW_FORM_sdata
}
}
short_type_label: base_type {
- {name "short int"}
- {encoding @DW_ATE_signed}
- {byte_size 2 DW_FORM_sdata}
+ DW_AT_name "short int"
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 2 DW_FORM_sdata
}
char_type_label: base_type {
- {name "signed char"}
- {encoding @DW_ATE_signed}
- {byte_size 1 DW_FORM_sdata}
+ DW_AT_name "signed char"
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 1 DW_FORM_sdata
}
# See comment above to understand the pointer size.
ptr_label: pointer_type {
- {byte_size 2 DW_FORM_sdata}
- {type :$char_type_label}
+ DW_AT_byte_size 2 DW_FORM_sdata
+ DW_AT_type :$char_type_label
}
var_label: DW_TAG_variable {
- {name s}
- {type :$struct_label}
- {location {
+ DW_AT_name s
+ DW_AT_type :$struct_label
+ DW_AT_location {
const2u 0x5678
stack_value
piece 2
@@ -87,15 +87,15 @@ Dwarf::assemble $asm_file {
const1u 3
stack_value
piece 1
- } SPECIAL_expr}
+ } SPECIAL_expr
}
DW_TAG_variable {
- {name p}
- {type :$ptr_label}
- {location {
+ DW_AT_name p
+ DW_AT_type :$ptr_label
+ DW_AT_location [subst {
GNU_implicit_pointer $var_label 2
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/implref-array.exp b/gdb/testsuite/gdb.dwarf2/implref-array.exp
index 4f7bb4b..1236537 100644
--- a/gdb/testsuite/gdb.dwarf2/implref-array.exp
+++ b/gdb/testsuite/gdb.dwarf2/implref-array.exp
@@ -51,7 +51,7 @@ Dwarf::assemble ${asm_file} {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C_plus_plus}
+ DW_AT_language @DW_LANG_C_plus_plus
} {
declare_labels int_label sizetype_label array_label variable_label ref_label
set int_size [get_sizeof "int" -1]
@@ -61,48 +61,52 @@ Dwarf::assemble ${asm_file} {
set addr_size [get_sizeof "void *" -1]
int_label: DW_TAG_base_type {
- {DW_AT_byte_size ${int_size} DW_FORM_udata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name "int"}
+ DW_AT_byte_size ${int_size} DW_FORM_udata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name "int"
}
sizetype_label: DW_TAG_base_type {
- {DW_AT_byte_size ${int_size} DW_FORM_udata}
- {DW_AT_encoding @DW_ATE_unsigned}
- {DW_AT_name "sizetype"}
+ DW_AT_byte_size ${int_size} DW_FORM_udata
+ DW_AT_encoding @DW_ATE_unsigned
+ DW_AT_name "sizetype"
}
array_label: DW_TAG_array_type {
- {DW_AT_type :${int_label}}
+ DW_AT_type :${int_label}
} {
DW_TAG_subrange_type {
- {DW_AT_type :${sizetype_label}}
- {DW_AT_lower_bound 0 DW_FORM_udata}
- {DW_AT_upper_bound ${upper_bound} DW_FORM_udata}
+ DW_AT_type :${sizetype_label}
+ DW_AT_lower_bound 0 DW_FORM_udata
+ DW_AT_upper_bound ${upper_bound} DW_FORM_udata
}
}
ref_label: DW_TAG_reference_type {
- {DW_AT_byte_size ${addr_size} DW_FORM_udata}
- {DW_AT_type :${array_label}}
+ DW_AT_byte_size ${addr_size} DW_FORM_udata
+ DW_AT_type :${array_label}
}
variable_label: DW_TAG_variable {
- {DW_AT_name "array"}
- {DW_AT_type :${array_label}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "array"]} SPECIAL_expr}
+ DW_AT_name "array"
+ DW_AT_type :${array_label}
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "array"]
+ }] SPECIAL_expr
}
DW_TAG_subprogram {
- {MACRO_AT_func { "main" }}
- {DW_AT_type :${int_label}}
- {DW_AT_external 1 DW_FORM_flag}
+ MACRO_AT_func { "main" }
+ DW_AT_type :${int_label}
+ DW_AT_external 1 DW_FORM_flag
} {
DW_TAG_variable {
- {DW_AT_name "ref"}
- {DW_AT_type :${ref_label}}
- {DW_AT_location {DW_OP_GNU_implicit_pointer ${variable_label} 0} SPECIAL_expr}
+ DW_AT_name "ref"
+ DW_AT_type :${ref_label}
+ DW_AT_location [subst {
+ DW_OP_GNU_implicit_pointer ${variable_label} 0
+ }] SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/implref-const.exp b/gdb/testsuite/gdb.dwarf2/implref-const.exp
index 57ccfcd..ec19eed 100644
--- a/gdb/testsuite/gdb.dwarf2/implref-const.exp
+++ b/gdb/testsuite/gdb.dwarf2/implref-const.exp
@@ -45,7 +45,7 @@ if [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] {
Dwarf::assemble ${asm_file} {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C_plus_plus}
+ DW_AT_language @DW_LANG_C_plus_plus
} {
declare_labels int_label const_label variable_label ref_label
set int_size [get_sizeof "int" -1]
@@ -55,35 +55,37 @@ Dwarf::assemble ${asm_file} {
set var_value 42
int_label: DW_TAG_base_type {
- {DW_AT_byte_size ${int_size} DW_FORM_udata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name "int"}
+ DW_AT_byte_size ${int_size} DW_FORM_udata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name "int"
}
ref_label: DW_TAG_reference_type {
- {DW_AT_byte_size ${addr_size} DW_FORM_udata}
- {DW_AT_type :${int_label}}
+ DW_AT_byte_size ${addr_size} DW_FORM_udata
+ DW_AT_type :${int_label}
}
const_label: DW_TAG_const_type {
- {DW_AT_type :${ref_label}}
+ DW_AT_type :${ref_label}
}
DW_TAG_subprogram {
- {MACRO_AT_func { "main" }}
- {DW_AT_type :${int_label}}
- {DW_AT_external 1 DW_FORM_flag}
+ MACRO_AT_func { "main" }
+ DW_AT_type :${int_label}
+ DW_AT_external 1 DW_FORM_flag
} {
variable_label: DW_TAG_variable {
- {DW_AT_name "var"}
- {DW_AT_type :${int_label}}
- {DW_AT_const_value ${var_value} DW_FORM_udata}
+ DW_AT_name "var"
+ DW_AT_type :${int_label}
+ DW_AT_const_value ${var_value} DW_FORM_udata
}
DW_TAG_variable {
- {DW_AT_name "ref"}
- {DW_AT_type :${const_label}}
- {DW_AT_location {DW_OP_GNU_implicit_pointer ${variable_label} 0} SPECIAL_expr}
+ DW_AT_name "ref"
+ DW_AT_type :${const_label}
+ DW_AT_location [subst {
+ DW_OP_GNU_implicit_pointer ${variable_label} 0
+ }] SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/implref-global.exp b/gdb/testsuite/gdb.dwarf2/implref-global.exp
index 5d9e679..cb885ef 100644
--- a/gdb/testsuite/gdb.dwarf2/implref-global.exp
+++ b/gdb/testsuite/gdb.dwarf2/implref-global.exp
@@ -47,7 +47,7 @@ if [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] {
Dwarf::assemble ${asm_file} {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C_plus_plus}
+ DW_AT_language @DW_LANG_C_plus_plus
} {
declare_labels int_label variable_label ref_label
set int_size [get_sizeof "int" -1]
@@ -56,32 +56,36 @@ Dwarf::assemble ${asm_file} {
set addr_size [get_sizeof "void *" -1]
int_label: DW_TAG_base_type {
- {DW_AT_byte_size ${int_size} DW_FORM_udata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name "int"}
+ DW_AT_byte_size ${int_size} DW_FORM_udata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name "int"
}
ref_label: DW_TAG_reference_type {
- {DW_AT_byte_size ${addr_size} DW_FORM_udata}
- {DW_AT_type :${int_label}}
+ DW_AT_byte_size ${addr_size} DW_FORM_udata
+ DW_AT_type :${int_label}
}
variable_label: DW_TAG_variable {
- {DW_AT_name "global_var"}
- {DW_AT_type :${int_label}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "global_var"]} SPECIAL_expr}
+ DW_AT_name "global_var"
+ DW_AT_type :${int_label}
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "global_var"]
+ }] SPECIAL_expr
}
DW_TAG_subprogram {
- {MACRO_AT_func { "main" }}
- {DW_AT_type :${int_label}}
- {DW_AT_external 1 DW_FORM_flag}
+ MACRO_AT_func { "main" }
+ DW_AT_type :${int_label}
+ DW_AT_external 1 DW_FORM_flag
} {
DW_TAG_variable {
- {DW_AT_name "ref"}
- {DW_AT_type :${ref_label}}
- {DW_AT_location {DW_OP_GNU_implicit_pointer ${variable_label} 0} SPECIAL_expr}
+ DW_AT_name "ref"
+ DW_AT_type :${ref_label}
+ DW_AT_location [subst {
+ DW_OP_GNU_implicit_pointer ${variable_label} 0
+ }] SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/implref-struct.exp b/gdb/testsuite/gdb.dwarf2/implref-struct.exp
index 1add485..9dc3b1b 100644
--- a/gdb/testsuite/gdb.dwarf2/implref-struct.exp
+++ b/gdb/testsuite/gdb.dwarf2/implref-struct.exp
@@ -47,7 +47,7 @@ if [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug c++}]
Dwarf::assemble ${asm_file} {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C_plus_plus}
+ DW_AT_language @DW_LANG_C_plus_plus
} {
declare_labels int_label struct_label variable_label ref_label
set int_size [get_sizeof "int" -1]
@@ -61,62 +61,68 @@ Dwarf::assemble ${asm_file} {
set c_offset 8
int_label: DW_TAG_base_type {
- {DW_AT_byte_size ${int_size} DW_FORM_udata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name "int"}
+ DW_AT_byte_size ${int_size} DW_FORM_udata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name "int"
}
struct_label: DW_TAG_structure_type {
- {DW_AT_name "S"}
- {DW_AT_byte_size ${S_size} DW_FORM_udata}
+ DW_AT_name "S"
+ DW_AT_byte_size ${S_size} DW_FORM_udata
} {
DW_TAG_member {
- {DW_AT_name "a"}
- {DW_AT_type :${int_label}}
- {DW_AT_data_member_location 0 DW_FORM_udata}
+ DW_AT_name "a"
+ DW_AT_type :${int_label}
+ DW_AT_data_member_location 0 DW_FORM_udata
}
DW_TAG_member {
- {DW_AT_name "b"}
- {DW_AT_type :${int_label}}
- {DW_AT_data_member_location ${b_offset} DW_FORM_udata}
+ DW_AT_name "b"
+ DW_AT_type :${int_label}
+ DW_AT_data_member_location ${b_offset} DW_FORM_udata
}
DW_TAG_member {
- {DW_AT_name "c"}
- {DW_AT_type :${int_label}}
- {DW_AT_data_member_location ${c_offset} DW_FORM_udata}
+ DW_AT_name "c"
+ DW_AT_type :${int_label}
+ DW_AT_data_member_location ${c_offset} DW_FORM_udata
}
}
ref_label: DW_TAG_reference_type {
- {DW_AT_byte_size ${addr_size} DW_FORM_udata}
- {DW_AT_type :${struct_label}}
+ DW_AT_byte_size ${addr_size} DW_FORM_udata
+ DW_AT_type :${struct_label}
}
variable_label: DW_TAG_variable {
- {DW_AT_name "s1"}
- {DW_AT_type :${struct_label}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "s1"]} SPECIAL_expr}
+ DW_AT_name "s1"
+ DW_AT_type :${struct_label}
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "s1"]
+ }] SPECIAL_expr
}
DW_TAG_variable {
- {DW_AT_name "s2"}
- {DW_AT_type :${struct_label}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "s2"]} SPECIAL_expr}
+ DW_AT_name "s2"
+ DW_AT_type :${struct_label}
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "s2"]
+ }] SPECIAL_expr
}
DW_TAG_subprogram {
- {MACRO_AT_func { "main" }}
- {DW_AT_type :${int_label}}
- {DW_AT_external 1 DW_FORM_flag}
+ MACRO_AT_func { "main" }
+ DW_AT_type :${int_label}
+ DW_AT_external 1 DW_FORM_flag
} {
DW_TAG_variable {
- {DW_AT_name "ref"}
- {DW_AT_type :${ref_label}}
- {DW_AT_location {DW_OP_GNU_implicit_pointer ${variable_label} 0} SPECIAL_expr}
+ DW_AT_name "ref"
+ DW_AT_type :${ref_label}
+ DW_AT_location [subst {
+ DW_OP_GNU_implicit_pointer ${variable_label} 0
+ }] SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/imported-unit-abstract-const-value.exp b/gdb/testsuite/gdb.dwarf2/imported-unit-abstract-const-value.exp
index 2517a2a..7141d6b 100644
--- a/gdb/testsuite/gdb.dwarf2/imported-unit-abstract-const-value.exp
+++ b/gdb/testsuite/gdb.dwarf2/imported-unit-abstract-const-value.exp
@@ -40,40 +40,40 @@ Dwarf::assemble $asm_file {
cu {} {
cu_label: partial_unit {
- {language @DW_LANG_C}
- {name "imported_unit.c"}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name "imported_unit.c"
} {
int_label: base_type {
- {byte_size $int_size sdata}
- {encoding @DW_ATE_signed}
- {name int}
+ DW_AT_byte_size $int_size sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int
}
aaa_label: DW_TAG_variable {
- {name aaa}
- {type :$int_label}
- {const_value 1 DW_FORM_sdata}
+ DW_AT_name aaa
+ DW_AT_type :$int_label
+ DW_AT_const_value 1 DW_FORM_sdata
}
main_label: subprogram {
- {name main}
- {type :$int_label}
- {external 1 flag}
+ DW_AT_name main
+ DW_AT_type :$int_label
+ DW_AT_external 1 flag
}
}
}
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name "<artificial>"}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name "<artificial>"
} {
DW_TAG_variable {
- {abstract_origin %$aaa_label}
+ DW_AT_abstract_origin %$aaa_label
}
subprogram {
- {abstract_origin %$main_label}
- {MACRO_AT_range {main}}
+ DW_AT_abstract_origin %$main_label
+ MACRO_AT_range {main}
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/imported-unit-bp.exp.tcl b/gdb/testsuite/gdb.dwarf2/imported-unit-bp.exp.tcl
index 65c3466..de1195a 100644
--- a/gdb/testsuite/gdb.dwarf2/imported-unit-bp.exp.tcl
+++ b/gdb/testsuite/gdb.dwarf2/imported-unit-bp.exp.tcl
@@ -38,34 +38,34 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @$lang}
- {name "<artificial>"}
+ DW_AT_language @$lang
+ DW_AT_name "<artificial>"
} {
imported_unit {
- {import %$cu_label}
+ DW_AT_import %$cu_label
}
}
}
cu {} {
cu_label: compile_unit {
- {producer "gcc"}
- {language @$lang}
- {name ${srcfile}}
- {comp_dir "/tmp"}
- {low_pc 0 addr}
- {stmt_list ${lines_label} DW_FORM_sec_offset}
+ DW_AT_producer "gcc"
+ DW_AT_language @$lang
+ DW_AT_name ${srcfile}
+ DW_AT_comp_dir "/tmp"
+ DW_AT_low_pc 0 addr
+ DW_AT_stmt_list ${lines_label} DW_FORM_sec_offset
} {
callee_subprog_label: subprogram {
- {external 1 flag}
- {name callee}
- {inline 3 data1}
+ DW_AT_external 1 flag
+ DW_AT_name callee
+ DW_AT_inline 3 data1
}
subprogram {
- {external 1 flag}
- {name func}
- {low_pc $func_start addr}
- {high_pc "$func_start + $func_len" addr}
+ DW_AT_external 1 flag
+ DW_AT_name func
+ DW_AT_low_pc $func_start addr
+ DW_AT_high_pc "$func_start + $func_len" addr
} {
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/imported-unit-c.exp b/gdb/testsuite/gdb.dwarf2/imported-unit-c.exp
index 521ccc3..4ccda52 100644
--- a/gdb/testsuite/gdb.dwarf2/imported-unit-c.exp
+++ b/gdb/testsuite/gdb.dwarf2/imported-unit-c.exp
@@ -22,52 +22,52 @@ Dwarf::assemble $asm_file {
# imported CU 1: inty unsigned
cu {} {
cu_label: compile_unit {
- {language @DW_LANG_C}
- {name "<artificial>"}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name "<artificial>"
} {
int_label: base_type {
- {byte_size $int_size sdata}
- {encoding @DW_ATE_unsigned}
- {name {unsigned int}}
+ DW_AT_byte_size $int_size sdata
+ DW_AT_encoding @DW_ATE_unsigned
+ DW_AT_name {unsigned int}
+ }
+ DW_TAG_typedef {
+ DW_AT_name inty
+ DW_AT_type :$int_label
}
- DW_TAG_typedef {
- {DW_AT_name inty}
- {DW_AT_type :$int_label}
- }
}
}
# imported CU 2: inty signed
cu {} {
cu2_label: compile_unit {
- {language @DW_LANG_C}
- {name "<artificial>"}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name "<artificial>"
} {
int2_label: base_type {
- {byte_size $int_size sdata}
- {encoding @DW_ATE_signed}
- {name {int}}
+ DW_AT_byte_size $int_size sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name {int}
+ }
+ DW_TAG_typedef {
+ DW_AT_name inty
+ DW_AT_type :$int2_label
}
- DW_TAG_typedef {
- {DW_AT_name inty}
- {DW_AT_type :$int2_label}
- }
}
}
# main CU
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name "<artificial>"}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name "<artificial>"
} {
imported_unit {
- {import %$cu2_label}
+ DW_AT_import %$cu2_label
}
subprogram {
- {MACRO_AT_func {main}}
- {external 1 flag}
+ MACRO_AT_func {main}
+ DW_AT_external 1 flag
}
}
}
@@ -75,16 +75,16 @@ Dwarf::assemble $asm_file {
# foo CU
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name "<artificial>"}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name "<artificial>"
} {
imported_unit {
- {import %$cu_label}
+ DW_AT_import %$cu_label
}
subprogram {
- {MACRO_AT_func {foo}}
- {external 1 flag}
+ MACRO_AT_func {foo}
+ DW_AT_external 1 flag
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/imported-unit-runto-main.exp b/gdb/testsuite/gdb.dwarf2/imported-unit-runto-main.exp
index c4bacb1..12dc69e 100644
--- a/gdb/testsuite/gdb.dwarf2/imported-unit-runto-main.exp
+++ b/gdb/testsuite/gdb.dwarf2/imported-unit-runto-main.exp
@@ -37,31 +37,31 @@ Dwarf::assemble $asm_file {
cu {} {
cu_label: partial_unit {
- {language @DW_LANG_C}
- {name "imported_unit.c"}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name "imported_unit.c"
} {
int_label: base_type {
- {byte_size $int_size sdata}
- {encoding @DW_ATE_signed}
- {name int}
+ DW_AT_byte_size $int_size sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int
}
main_label: subprogram {
- {name main}
- {type :$int_label}
- {external 1 flag}
+ DW_AT_name main
+ DW_AT_type :$int_label
+ DW_AT_external 1 flag
}
}
}
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name "<artificial>"}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name "<artificial>"
} {
subprogram {
- {abstract_origin %$main_label}
- {MACRO_AT_range {main}}
+ DW_AT_abstract_origin %$main_label
+ MACRO_AT_range {main}
}
}
}
@@ -77,6 +77,6 @@ if { [ensure_gdb_index $binfile] == -1 } {
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
runto main
diff --git a/gdb/testsuite/gdb.dwarf2/imported-unit.exp b/gdb/testsuite/gdb.dwarf2/imported-unit.exp
index e5df67e..2c17f2d 100644
--- a/gdb/testsuite/gdb.dwarf2/imported-unit.exp
+++ b/gdb/testsuite/gdb.dwarf2/imported-unit.exp
@@ -52,27 +52,27 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C_plus_plus}
- {name "<artificial>"}
+ DW_AT_language @DW_LANG_C_plus_plus
+ DW_AT_name "<artificial>"
} {
imported_unit {
- {import %$cu_label}
+ DW_AT_import %$cu_label
}
subprogram {
- {abstract_origin %$main_label}
- {MACRO_AT_range {main}}
+ DW_AT_abstract_origin %$main_label
+ MACRO_AT_range {main}
} {
subprogram {
- {abstract_origin %$doit_label}
- {MACRO_AT_range {doit}}
+ DW_AT_abstract_origin %$doit_label
+ MACRO_AT_range {doit}
} {
formal_parameter {
- {abstract_origin %$doit_self_label}
+ DW_AT_abstract_origin %$doit_self_label
}
}
DW_TAG_variable {
- {abstract_origin %$foo_label}
- {location 4 data1}
+ DW_AT_abstract_origin %$foo_label
+ DW_AT_location 4 data1
}
}
}
@@ -80,43 +80,43 @@ Dwarf::assemble $asm_file {
cu {} {
cu_label: compile_unit {
- {language @DW_LANG_C_plus_plus}
- {name "imported_unit.c"}
+ DW_AT_language @DW_LANG_C_plus_plus
+ DW_AT_name "imported_unit.c"
} {
int_label: base_type {
- {byte_size $int_size sdata}
- {encoding @DW_ATE_signed}
- {name int}
+ DW_AT_byte_size $int_size sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int
}
main_label: subprogram {
- {name main}
- {type :$int_label}
- {external 1 flag}
+ DW_AT_name main
+ DW_AT_type :$int_label
+ DW_AT_external 1 flag
} {
Foo_label: class_type {
- {name Foo}
- {byte_size 1 sdata}
+ DW_AT_name Foo
+ DW_AT_byte_size 1 sdata
} {
doit_label: subprogram {
- {name doit}
- {type :$int_label}
- {accessibility 1 DW_FORM_data1}
+ DW_AT_name doit
+ DW_AT_type :$int_label
+ DW_AT_accessibility 1 DW_FORM_data1
} {
doit_self_label: formal_parameter {
- {name this}
- {artificial 1 DW_FORM_flag_present}
- {type :$Foo_pointer_type}
+ DW_AT_name this
+ DW_AT_artificial 1 DW_FORM_flag_present
+ DW_AT_type :$Foo_pointer_type
}
}
Foo_pointer_type: pointer_type {
- {byte_size $addr_size sdata}
- {type :$Foo_label}
+ DW_AT_byte_size $addr_size sdata
+ DW_AT_type :$Foo_label
}
}
foo_label: DW_TAG_variable {
- {name foo}
- {type :$Foo_label}
+ DW_AT_name foo
+ DW_AT_type :$Foo_label
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/info-locals-optimized-out.exp b/gdb/testsuite/gdb.dwarf2/info-locals-optimized-out.exp
index 76e20b6..59c9669 100644
--- a/gdb/testsuite/gdb.dwarf2/info-locals-optimized-out.exp
+++ b/gdb/testsuite/gdb.dwarf2/info-locals-optimized-out.exp
@@ -32,31 +32,31 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir /tmp}
+ DW_AT_name $srcfile
+ DW_AT_comp_dir /tmp
} {
declare_labels int_type_label
# int
int_type_label: base_type {
- {name "int"}
- {encoding @DW_ATE_signed}
- {byte_size 4 DW_FORM_sdata}
+ DW_AT_name "int"
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 4 DW_FORM_sdata
}
DW_TAG_subprogram {
- {MACRO_AT_func { main }}
- {DW_AT_external 1 flag}
+ MACRO_AT_func { main }
+ DW_AT_external 1 flag
} {
# A variable completely optimized out.
DW_TAG_variable {
- {name "opt_out"}
- {type :$int_type_label}
+ DW_AT_name "opt_out"
+ DW_AT_type :$int_type_label
}
DW_TAG_variable {
- {name const_bytes}
- {type :$int_type_label}
- {const_value "\x01\x01\x01\x01" DW_FORM_block1}
+ DW_AT_name const_bytes
+ DW_AT_type :$int_type_label
+ DW_AT_const_value "\x01\x01\x01\x01" DW_FORM_block1
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/inlined_subroutine-inheritance.exp b/gdb/testsuite/gdb.dwarf2/inlined_subroutine-inheritance.exp
index b26650c..7236662 100644
--- a/gdb/testsuite/gdb.dwarf2/inlined_subroutine-inheritance.exp
+++ b/gdb/testsuite/gdb.dwarf2/inlined_subroutine-inheritance.exp
@@ -38,21 +38,21 @@ Dwarf::assemble $asm_file {
cu {} {
Db: compile_unit {
- {language @DW_LANG_C99}
- {name "<artificial>"}
+ DW_AT_language @DW_LANG_C99
+ DW_AT_name "<artificial>"
} {
D72f8: subprogram {
- {abstract_origin %$D272519}
- {low_pc 0xb9e20 addr}
- {high_pc 0x1f5 data4}
+ DW_AT_abstract_origin %$D272519
+ DW_AT_low_pc 0xb9e20 addr
+ DW_AT_high_pc 0x1f5 data4
} {
D736e: inlined_subroutine {
- {abstract_origin %$D26b227}
- {low_pc 0xb9efc addr}
- {high_pc 0xc data4}
+ DW_AT_abstract_origin %$D26b227
+ DW_AT_low_pc 0xb9efc addr
+ DW_AT_high_pc 0xc data4
} {
formal_parameter {
- {abstract_origin %$D274c42}
+ DW_AT_abstract_origin %$D274c42
}
}
}
@@ -61,53 +61,53 @@ Dwarf::assemble $asm_file {
cu {} {
D266465: compile_unit {
- {language @DW_LANG_C99}
+ DW_AT_language @DW_LANG_C99
} {
D266477: typedef {
- {name "size_t"}
- {type :$D266483}
+ DW_AT_name "size_t"
+ DW_AT_type :$D266483
}
D266483: base_type {
- {byte_size 8 sdata}
- {encoding @DW_ATE_unsigned}
+ DW_AT_byte_size 8 sdata
+ DW_AT_encoding @DW_ATE_unsigned
}
D266496: pointer_type {
- {byte_size 8 sdata}
+ DW_AT_byte_size 8 sdata
}
D266498: restrict_type {
- {type :$D266496}
+ DW_AT_type :$D266496
}
D266ad3: pointer_type {
- {byte_size 8 sdata}
- {type :$D266ade}
+ DW_AT_byte_size 8 sdata
+ DW_AT_type :$D266ade
}
D266ad9: restrict_type {
- {type :$D266ad3}
+ DW_AT_type :$D266ad3
}
D266ade: const_type {}
D26b227: subprogram {
- {external 1 flag}
- {name "memcpy"}
- {type :$D266496}
+ DW_AT_external 1 flag
+ DW_AT_name "memcpy"
+ DW_AT_type :$D266496
} {
D26b237: formal_parameter {
- {name "__dest"}
- {type :$D266498}
+ DW_AT_name "__dest"
+ DW_AT_type :$D266498
}
formal_parameter {
- {name "__src"}
- {type :$D266ad9}
+ DW_AT_name "__src"
+ DW_AT_type :$D266ad9
}
formal_parameter {
- {name "__len"}
- {type :$D266477}
+ DW_AT_name "__len"
+ DW_AT_type :$D266477
}
}
}
@@ -115,85 +115,85 @@ Dwarf::assemble $asm_file {
cu {} {
D26d8b1: compile_unit {
- {language @DW_LANG_C99}
+ DW_AT_language @DW_LANG_C99
} {
D26d8c3: typedef {
- {name "size_t"}
- {type :$D26d8cf}
+ DW_AT_name "size_t"
+ DW_AT_type :$D26d8cf
}
D26d8cf: base_type {
- {byte_size 8 sdata}
- {encoding @DW_ATE_unsigned}
- {name "long unsigned int"}
+ DW_AT_byte_size 8 sdata
+ DW_AT_encoding @DW_ATE_unsigned
+ DW_AT_name "long unsigned int"
}
D26d944: pointer_type {
- {byte_size 8 sdata}
+ DW_AT_byte_size 8 sdata
}
D26d946: restrict_type {
- {type :$D26d944}
+ DW_AT_type :$D26d944
}
D26e103: structure_type {
- {name "__object"}
- {byte_size 12 sdata}
+ DW_AT_name "__object"
+ DW_AT_byte_size 12 sdata
} {
member {
- {name "__ob_next"}
- {type :$D26e145}
- {data_member_location 0 sdata}
+ DW_AT_name "__ob_next"
+ DW_AT_type :$D26e145
+ DW_AT_data_member_location 0 sdata
}
}
D26e145: pointer_type {
- {byte_size 8 sdata}
- {type :$D26e103}
+ DW_AT_byte_size 8 sdata
+ DW_AT_type :$D26e103
}
D26e415: typedef {
- {name "PyObject"}
- {type :$D26e103}
+ DW_AT_name "PyObject"
+ DW_AT_type :$D26e103
}
D26e48c: pointer_type {
- {byte_size 8 sdata}
- {type :$D26e415}
+ DW_AT_byte_size 8 sdata
+ DW_AT_type :$D26e415
}
D26df00: pointer_type {
- {byte_size 8 sdata}
- {type :$D26df0b}
+ DW_AT_byte_size 8 sdata
+ DW_AT_type :$D26df0b
}
D26df06: restrict_type {
- {type :$D26df00}
+ DW_AT_type :$D26df00
}
D26df0b: const_type {}
D272519: subprogram {
- {name "bytes_repeat"}
- {type :$D26e48c}
+ DW_AT_name "bytes_repeat"
+ DW_AT_type :$D26e48c
}
D274c1a: subprogram {
- {external 1 flag}
- {name "memcpy"}
- {type :$D26d944}
+ DW_AT_external 1 flag
+ DW_AT_name "memcpy"
+ DW_AT_type :$D26d944
} {
formal_parameter {
- {name "__dest"}
- {type :$D26d946}
+ DW_AT_name "__dest"
+ DW_AT_type :$D26d946
}
formal_parameter {
- {name "__src"}
- {type :$D26df06}
+ DW_AT_name "__src"
+ DW_AT_type :$D26df06
}
D274c42: formal_parameter {
- {name "__len"}
- {type :$D26d8c3}
+ DW_AT_name "__len"
+ DW_AT_type :$D26d8c3
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/intbits.exp b/gdb/testsuite/gdb.dwarf2/intbits.exp
index ff1d69a..ec77c2d 100644
--- a/gdb/testsuite/gdb.dwarf2/intbits.exp
+++ b/gdb/testsuite/gdb.dwarf2/intbits.exp
@@ -33,153 +33,162 @@ if [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] {
Dwarf::assemble ${asm_file} {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C_plus_plus}
+ DW_AT_language @DW_LANG_C_plus_plus
} {
declare_labels i7_type u1_type u17_type u31_type \
u31_1_type u32_0_type u0_0_type be30_1_type just_bit_type
i7_type: DW_TAG_base_type {
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_endianity @DW_END_little}
- {DW_AT_name "i7"}
- {DW_AT_byte_size 2 DW_FORM_udata}
- {DW_AT_bit_size 7 DW_FORM_implicit_const}
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_endianity @DW_END_little
+ DW_AT_name "i7"
+ DW_AT_byte_size 2 DW_FORM_udata
+ DW_AT_bit_size 7 DW_FORM_implicit_const
}
DW_TAG_variable {
- {DW_AT_name "v_i16_m1"}
- {DW_AT_type :${i7_type}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "i16_m1"]}
- SPECIAL_expr}
+ DW_AT_name "v_i16_m1"
+ DW_AT_type :${i7_type}
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "i16_m1"]
+ }] SPECIAL_expr
}
u1_type: DW_TAG_base_type {
- {DW_AT_encoding @DW_ATE_boolean}
- {DW_AT_endianity @DW_END_little}
- {DW_AT_name "u1"}
- {DW_AT_byte_size 2 DW_FORM_udata}
- {DW_AT_bit_size 1 DW_FORM_udata}
- {DW_AT_data_bit_offset 2 DW_FORM_udata}
+ DW_AT_encoding @DW_ATE_boolean
+ DW_AT_endianity @DW_END_little
+ DW_AT_name "u1"
+ DW_AT_byte_size 2 DW_FORM_udata
+ DW_AT_bit_size 1 DW_FORM_udata
+ DW_AT_data_bit_offset 2 DW_FORM_udata
}
DW_TAG_variable {
- {DW_AT_name "v_u16_1"}
- {DW_AT_type :${u1_type}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "u16_1"]}
- SPECIAL_expr}
+ DW_AT_name "v_u16_1"
+ DW_AT_type :${u1_type}
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "u16_1"]
+ }] SPECIAL_expr
}
u17_type: DW_TAG_base_type {
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_endianity @DW_END_little}
- {DW_AT_name "u17"}
- {DW_AT_byte_size 4 DW_FORM_udata}
- {DW_AT_bit_size 17 DW_FORM_udata}
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_endianity @DW_END_little
+ DW_AT_name "u17"
+ DW_AT_byte_size 4 DW_FORM_udata
+ DW_AT_bit_size 17 DW_FORM_udata
}
DW_TAG_variable {
- {DW_AT_name "v_u32_m2"}
- {DW_AT_type :${u17_type}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "u32_m2"]}
- SPECIAL_expr}
+ DW_AT_name "v_u32_m2"
+ DW_AT_type :${u17_type}
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "u32_m2"]
+ }] SPECIAL_expr
}
u31_type: DW_TAG_base_type {
- {DW_AT_encoding @DW_ATE_unsigned}
- {DW_AT_endianity @DW_END_little}
- {DW_AT_name "u31"}
- {DW_AT_byte_size 4 DW_FORM_udata}
- {DW_AT_bit_size 31 DW_FORM_udata}
+ DW_AT_encoding @DW_ATE_unsigned
+ DW_AT_endianity @DW_END_little
+ DW_AT_name "u31"
+ DW_AT_byte_size 4 DW_FORM_udata
+ DW_AT_bit_size 31 DW_FORM_udata
}
DW_TAG_variable {
- {DW_AT_name "v_u32_1"}
- {DW_AT_type :${u31_type}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "u32_1"]}
- SPECIAL_expr}
+ DW_AT_name "v_u32_1"
+ DW_AT_type :${u31_type}
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "u32_1"]
+ }] SPECIAL_expr
}
u31_1_type: DW_TAG_base_type {
- {DW_AT_encoding @DW_ATE_unsigned}
- {DW_AT_endianity @DW_END_little}
- {DW_AT_name "u31_1"}
- {DW_AT_byte_size 4 DW_FORM_udata}
- {DW_AT_bit_size 31 DW_FORM_udata}
- {DW_AT_data_bit_offset 1 DW_FORM_udata}
+ DW_AT_encoding @DW_ATE_unsigned
+ DW_AT_endianity @DW_END_little
+ DW_AT_name "u31_1"
+ DW_AT_byte_size 4 DW_FORM_udata
+ DW_AT_bit_size 31 DW_FORM_udata
+ DW_AT_data_bit_offset 1 DW_FORM_udata
}
DW_TAG_variable {
- {DW_AT_name "v_u32_1_off"}
- {DW_AT_type :${u31_1_type}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "u32_1_off"]}
- SPECIAL_expr}
+ DW_AT_name "v_u32_1_off"
+ DW_AT_type :${u31_1_type}
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "u32_1_off"]
+ }] SPECIAL_expr
}
be30_1_type: DW_TAG_base_type {
- {DW_AT_encoding @DW_ATE_unsigned}
- {DW_AT_endianity @DW_END_big}
- {DW_AT_name "be30_1"}
- {DW_AT_byte_size 4 DW_FORM_udata}
- {DW_AT_bit_size 30 DW_FORM_udata}
- {DW_AT_data_bit_offset 1 DW_FORM_udata}
+ DW_AT_encoding @DW_ATE_unsigned
+ DW_AT_endianity @DW_END_big
+ DW_AT_name "be30_1"
+ DW_AT_byte_size 4 DW_FORM_udata
+ DW_AT_bit_size 30 DW_FORM_udata
+ DW_AT_data_bit_offset 1 DW_FORM_udata
}
DW_TAG_variable {
- {DW_AT_name "v_be30_1_off"}
- {DW_AT_type :${be30_1_type}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "be30_1_off"]}
- SPECIAL_expr}
+ DW_AT_name "v_be30_1_off"
+ DW_AT_type :${be30_1_type}
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "be30_1_off"]
+ }] SPECIAL_expr
}
u32_0_type: DW_TAG_base_type {
- {DW_AT_encoding @DW_ATE_unsigned}
- {DW_AT_endianity @DW_END_little}
- {DW_AT_name "u32_0"}
- {DW_AT_byte_size 4 DW_FORM_udata}
- {DW_AT_bit_size 0 DW_FORM_udata}
+ DW_AT_encoding @DW_ATE_unsigned
+ DW_AT_endianity @DW_END_little
+ DW_AT_name "u32_0"
+ DW_AT_byte_size 4 DW_FORM_udata
+ DW_AT_bit_size 0 DW_FORM_udata
}
DW_TAG_variable {
- {DW_AT_name "v_u32_0"}
- {DW_AT_type :${u32_0_type}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "u32_0"]}
- SPECIAL_expr}
+ DW_AT_name "v_u32_0"
+ DW_AT_type :${u32_0_type}
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "u32_0"]
+ }] SPECIAL_expr
}
u0_0_type: DW_TAG_base_type {
- {DW_AT_encoding @DW_ATE_unsigned}
- {DW_AT_endianity @DW_END_little}
- {DW_AT_name "u0_0"}
- {DW_AT_byte_size 0 DW_FORM_udata}
+ DW_AT_encoding @DW_ATE_unsigned
+ DW_AT_endianity @DW_END_little
+ DW_AT_name "u0_0"
+ DW_AT_byte_size 0 DW_FORM_udata
}
DW_TAG_variable {
- {DW_AT_name "v_u0_0"}
- {DW_AT_type :${u0_0_type}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "u32_0"]}
- SPECIAL_expr}
+ DW_AT_name "v_u0_0"
+ DW_AT_type :${u0_0_type}
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "u32_0"]
+ }] SPECIAL_expr
}
just_bit_type: DW_TAG_base_type {
- {DW_AT_encoding @DW_ATE_unsigned}
- {DW_AT_name "just_bit_type"}
- {DW_AT_bit_size 3 DW_FORM_udata}
+ DW_AT_encoding @DW_ATE_unsigned
+ DW_AT_name "just_bit_type"
+ DW_AT_bit_size 3 DW_FORM_udata
}
DW_TAG_variable {
- {DW_AT_name "v_just_bit"}
- {DW_AT_type :${just_bit_type}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "just_bit_0"]}
- SPECIAL_expr}
+ DW_AT_name "v_just_bit"
+ DW_AT_type :${just_bit_type}
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "just_bit_0"]
+ }] SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/loc-sec-offset.exp b/gdb/testsuite/gdb.dwarf2/loc-sec-offset.exp
index 6e10b6c..fb4bf3a 100644
--- a/gdb/testsuite/gdb.dwarf2/loc-sec-offset.exp
+++ b/gdb/testsuite/gdb.dwarf2/loc-sec-offset.exp
@@ -53,27 +53,27 @@ foreach_with_prefix is_64 {false true} {
DW_TAG_compile_unit {
} {
int_type1: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_data1}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name "int"}
+ DW_AT_byte_size 4 DW_FORM_data1
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name "int"
}
DW_TAG_variable {
- {DW_AT_name "foo"}
- {DW_AT_location $foo_location_list DW_FORM_sec_offset}
- {DW_AT_type :$int_type1}
+ DW_AT_name "foo"
+ DW_AT_location $foo_location_list DW_FORM_sec_offset
+ DW_AT_type :$int_type1
}
DW_TAG_subprogram {
- {DW_AT_name "func1"}
- {DW_AT_low_pc $func1_addr}
- {DW_AT_high_pc $func1_len DW_FORM_udata}
+ DW_AT_name "func1"
+ DW_AT_low_pc $func1_addr
+ DW_AT_high_pc $func1_len DW_FORM_udata
}
DW_TAG_subprogram {
- {DW_AT_name "func2"}
- {DW_AT_low_pc $func2_addr}
- {DW_AT_high_pc $func2_len DW_FORM_udata}
+ DW_AT_name "func2"
+ DW_AT_low_pc $func2_addr
+ DW_AT_high_pc $func2_len DW_FORM_udata
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp
index ea871d6..2a8b457 100644
--- a/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp
+++ b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp
@@ -154,38 +154,38 @@ Dwarf::assemble ${asm_file} {
cu { label cu_label } {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C_plus_plus}
- {name ${::srcfile}}
- {stmt_list $L DW_FORM_sec_offset}
+ DW_AT_language @DW_LANG_C_plus_plus
+ DW_AT_name ${::srcfile}
+ DW_AT_stmt_list $L DW_FORM_sec_offset
} {
declare_labels int_label class_A_label class_B_label \
B_ptr_label
int_label: DW_TAG_base_type {
- {DW_AT_byte_size ${::long_size} DW_FORM_udata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name "int"}
+ DW_AT_byte_size ${::long_size} DW_FORM_udata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name "int"
}
class_A_label: DW_TAG_class_type {
- {DW_AT_name "A"}
- {DW_AT_byte_size ${::struct_A_size} DW_FORM_sdata}
+ DW_AT_name "A"
+ DW_AT_byte_size ${::struct_A_size} DW_FORM_sdata
} {
DW_TAG_member {
- {DW_AT_name "a"}
- {DW_AT_type :$int_label}
- {DW_AT_data_member_location ${::A_a} DW_FORM_udata}
+ DW_AT_name "a"
+ DW_AT_type :$int_label
+ DW_AT_data_member_location ${::A_a} DW_FORM_udata
}
DW_TAG_member {
- {DW_AT_name "x"}
- {DW_AT_type :$int_label}
- {DW_AT_data_member_location ${::A_x} DW_FORM_udata}
+ DW_AT_name "x"
+ DW_AT_type :$int_label
+ DW_AT_data_member_location ${::A_x} DW_FORM_udata
}
}
class_B_label: DW_TAG_class_type {
- {DW_AT_name "B"}
- {DW_AT_byte_size ${::struct_B_size} DW_FORM_sdata}
+ DW_AT_name "B"
+ DW_AT_byte_size ${::struct_B_size} DW_FORM_sdata
} {
# While there are easier / better ways to specify an
# offset used by DW_AT_data_member_location than that
@@ -201,45 +201,47 @@ Dwarf::assemble ${asm_file} {
# by decode_locdesc(); this is why those opcodes were
# chosen.
DW_TAG_inheritance {
- {DW_AT_type :$class_A_label}
- {DW_AT_data_member_location {
+ DW_AT_type :$class_A_label
+ DW_AT_data_member_location [subst {
DW_OP_constu ${::B_a}
DW_OP_plus
DW_OP_pick 0
- DW_OP_drop} SPECIAL_expr}
- {DW_AT_accessibility 1 DW_FORM_data1}
+ DW_OP_drop}] SPECIAL_expr
+ DW_AT_accessibility 1 DW_FORM_data1
}
DW_TAG_member {
- {DW_AT_name "b"}
- {DW_AT_type :$int_label}
- {DW_AT_data_member_location ${::B_b} DW_FORM_udata}
+ DW_AT_name "b"
+ DW_AT_type :$int_label
+ DW_AT_data_member_location ${::B_b} DW_FORM_udata
}
DW_TAG_member {
- {DW_AT_name "x2"}
- {DW_AT_type :$int_label}
- {DW_AT_data_member_location ${::B_x2} DW_FORM_udata}
+ DW_AT_name "x2"
+ DW_AT_type :$int_label
+ DW_AT_data_member_location ${::B_x2} DW_FORM_udata
}
}
B_ptr_label: DW_TAG_pointer_type {
- {DW_AT_type :$class_B_label}
- {DW_AT_byte_size ${::addr_size} DW_FORM_sdata}
+ DW_AT_type :$class_B_label
+ DW_AT_byte_size ${::addr_size} DW_FORM_sdata
}
DW_TAG_variable {
- {DW_AT_name "g_A"}
- {DW_AT_type :$class_A_label}
- {DW_AT_external 1 flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "g_A"]} \
- SPECIAL_expr}
+ DW_AT_name "g_A"
+ DW_AT_type :$class_A_label
+ DW_AT_external 1 flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "g_A"]
+ }] SPECIAL_expr
}
DW_TAG_variable {
- {DW_AT_name "g_B"}
- {DW_AT_type :$class_B_label}
- {DW_AT_external 1 flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "g_B"]} \
- SPECIAL_expr}
+ DW_AT_name "g_B"
+ DW_AT_type :$class_B_label
+ DW_AT_external 1 flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "g_B"]
+ }] SPECIAL_expr
}
# We can't use MACRO_AT for the definitions of foo and bar
@@ -247,23 +249,23 @@ Dwarf::assemble ${asm_file} {
# flags. Therefore, we list the name, low_pc, and high_pc
# explicitly.
DW_TAG_subprogram {
- {DW_AT_name foo}
- {DW_AT_low_pc $foo_start DW_FORM_addr}
- {DW_AT_high_pc $foo_end DW_FORM_addr}
- {DW_AT_type :${B_ptr_label}}
- {DW_AT_external 1 flag}
+ DW_AT_name foo
+ DW_AT_low_pc $foo_start DW_FORM_addr
+ DW_AT_high_pc $foo_end DW_FORM_addr
+ DW_AT_type :${B_ptr_label}
+ DW_AT_external 1 flag
}
DW_TAG_subprogram {
- {DW_AT_name bar}
- {DW_AT_low_pc $bar_start DW_FORM_addr}
- {DW_AT_high_pc $bar_end DW_FORM_addr}
- {DW_AT_type :${B_ptr_label}}
- {DW_AT_external 1 flag}
+ DW_AT_name bar
+ DW_AT_low_pc $bar_start DW_FORM_addr
+ DW_AT_high_pc $bar_end DW_FORM_addr
+ DW_AT_type :${B_ptr_label}
+ DW_AT_external 1 flag
} {
DW_TAG_formal_parameter {
- {DW_AT_name v}
- {DW_AT_type :${B_ptr_label}}
+ DW_AT_name v
+ DW_AT_type :${B_ptr_label}
}
}
}
@@ -330,7 +332,7 @@ if {[gdb_compile_shlib [list $libsrc $asm_file] $lib_so \
### Second GDB session.
with_test_prefix "second session" {
- clean_restart $binfile
+ clean_restart $::testfile
# Again, do whatever is necessary to make sure that the shared library is
# loaded for remote targets.
diff --git a/gdb/testsuite/gdb.dwarf2/loclists-multiple-cus.exp b/gdb/testsuite/gdb.dwarf2/loclists-multiple-cus.exp
index b0c9d7d..021129d 100644
--- a/gdb/testsuite/gdb.dwarf2/loclists-multiple-cus.exp
+++ b/gdb/testsuite/gdb.dwarf2/loclists-multiple-cus.exp
@@ -57,30 +57,30 @@ foreach_with_prefix is_64 {false true} {
declare_labels int_type
DW_TAG_compile_unit {
- {DW_AT_loclists_base cu_table DW_FORM_sec_offset}
+ DW_AT_loclists_base cu_table DW_FORM_sec_offset
} {
int_type: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_data1}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name "int"}
+ DW_AT_byte_size 4 DW_FORM_data1
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name "int"
}
DW_TAG_variable {
- {DW_AT_name "foo"}
- {DW_AT_location 1 DW_FORM_loclistx}
- {DW_AT_type :$int_type}
+ DW_AT_name "foo"
+ DW_AT_location 1 DW_FORM_loclistx
+ DW_AT_type :$int_type
}
DW_TAG_subprogram {
- {DW_AT_name "func1"}
- {DW_AT_low_pc $func1_addr}
- {DW_AT_high_pc $func1_len DW_FORM_udata}
+ DW_AT_name "func1"
+ DW_AT_low_pc $func1_addr
+ DW_AT_high_pc $func1_len DW_FORM_udata
}
DW_TAG_subprogram {
- {DW_AT_name "func2"}
- {DW_AT_low_pc $func2_addr}
- {DW_AT_high_pc $func2_len DW_FORM_udata}
+ DW_AT_name "func2"
+ DW_AT_low_pc $func2_addr
+ DW_AT_high_pc $func2_len DW_FORM_udata
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/loclists-sec-offset.exp b/gdb/testsuite/gdb.dwarf2/loclists-sec-offset.exp
index 38512cd..e39ca19 100644
--- a/gdb/testsuite/gdb.dwarf2/loclists-sec-offset.exp
+++ b/gdb/testsuite/gdb.dwarf2/loclists-sec-offset.exp
@@ -66,27 +66,27 @@ foreach_with_prefix is_64 {false true} {
DW_TAG_compile_unit {
} {
int_type1: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_data1}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name "int"}
+ DW_AT_byte_size 4 DW_FORM_data1
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name "int"
}
DW_TAG_variable {
- {DW_AT_name "foo"}
- {DW_AT_location $foo_location_list DW_FORM_sec_offset}
- {DW_AT_type :$int_type1}
+ DW_AT_name "foo"
+ DW_AT_location $foo_location_list DW_FORM_sec_offset
+ DW_AT_type :$int_type1
}
DW_TAG_subprogram {
- {DW_AT_name "func1"}
- {DW_AT_low_pc $func1_addr}
- {DW_AT_high_pc $func1_len DW_FORM_udata}
+ DW_AT_name "func1"
+ DW_AT_low_pc $func1_addr
+ DW_AT_high_pc $func1_len DW_FORM_udata
}
DW_TAG_subprogram {
- {DW_AT_name "func2"}
- {DW_AT_low_pc $func2_addr}
- {DW_AT_high_pc $func2_len DW_FORM_udata}
+ DW_AT_name "func2"
+ DW_AT_low_pc $func2_addr
+ DW_AT_high_pc $func2_len DW_FORM_udata
}
}
}
@@ -100,30 +100,30 @@ foreach_with_prefix is_64 {false true} {
is_64 $is_64
} {
DW_TAG_compile_unit {
- {DW_AT_loclists_base cu2_table DW_FORM_sec_offset}
+ DW_AT_loclists_base cu2_table DW_FORM_sec_offset
} {
int_type2: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_data1}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name "int"}
+ DW_AT_byte_size 4 DW_FORM_data1
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name "int"
}
DW_TAG_variable {
- {DW_AT_name "bar"}
- {DW_AT_location $bar_location_list DW_FORM_sec_offset}
- {DW_AT_type :$int_type2}
+ DW_AT_name "bar"
+ DW_AT_location $bar_location_list DW_FORM_sec_offset
+ DW_AT_type :$int_type2
}
DW_TAG_subprogram {
- {DW_AT_name "func3"}
- {DW_AT_low_pc $func3_addr}
- {DW_AT_high_pc $func3_len DW_FORM_udata}
+ DW_AT_name "func3"
+ DW_AT_low_pc $func3_addr
+ DW_AT_high_pc $func3_len DW_FORM_udata
}
DW_TAG_subprogram {
- {DW_AT_name "func4"}
- {DW_AT_low_pc $func4_addr}
- {DW_AT_high_pc $func4_len DW_FORM_udata}
+ DW_AT_name "func4"
+ DW_AT_low_pc $func4_addr
+ DW_AT_high_pc $func4_len DW_FORM_udata
}
}
}
@@ -138,27 +138,27 @@ foreach_with_prefix is_64 {false true} {
DW_TAG_compile_unit {
} {
int_type3: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_data1}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name "int"}
+ DW_AT_byte_size 4 DW_FORM_data1
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name "int"
}
DW_TAG_variable {
- {DW_AT_name "baz"}
- {DW_AT_location $baz_location_list DW_FORM_sec_offset}
- {DW_AT_type :$int_type3}
+ DW_AT_name "baz"
+ DW_AT_location $baz_location_list DW_FORM_sec_offset
+ DW_AT_type :$int_type3
}
DW_TAG_subprogram {
- {DW_AT_name "func5"}
- {DW_AT_low_pc $func5_addr}
- {DW_AT_high_pc $func5_len DW_FORM_udata}
+ DW_AT_name "func5"
+ DW_AT_low_pc $func5_addr
+ DW_AT_high_pc $func5_len DW_FORM_udata
}
DW_TAG_subprogram {
- {DW_AT_name "func6"}
- {DW_AT_low_pc $func6_addr}
- {DW_AT_high_pc $func6_len DW_FORM_udata}
+ DW_AT_name "func6"
+ DW_AT_low_pc $func6_addr
+ DW_AT_high_pc $func6_len DW_FORM_udata
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/loclists-start-end.exp b/gdb/testsuite/gdb.dwarf2/loclists-start-end.exp
index 2569896..876a8b2 100644
--- a/gdb/testsuite/gdb.dwarf2/loclists-start-end.exp
+++ b/gdb/testsuite/gdb.dwarf2/loclists-start-end.exp
@@ -48,30 +48,30 @@ foreach_with_prefix is_64 {false true} {
declare_labels int_type
DW_TAG_compile_unit {
- {DW_AT_loclists_base cu_table DW_FORM_sec_offset}
+ DW_AT_loclists_base cu_table DW_FORM_sec_offset
} {
int_type: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_data1}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name "int"}
+ DW_AT_byte_size 4 DW_FORM_data1
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name "int"
}
DW_TAG_variable {
- {DW_AT_name "foo"}
- {DW_AT_location 1 DW_FORM_loclistx}
- {DW_AT_type :$int_type}
+ DW_AT_name "foo"
+ DW_AT_location 1 DW_FORM_loclistx
+ DW_AT_type :$int_type
}
DW_TAG_subprogram {
- {DW_AT_name "func1"}
- {DW_AT_low_pc $func1_addr}
- {DW_AT_high_pc $func1_len DW_FORM_udata}
+ DW_AT_name "func1"
+ DW_AT_low_pc $func1_addr
+ DW_AT_high_pc $func1_len DW_FORM_udata
}
DW_TAG_subprogram {
- {DW_AT_name "func2"}
- {DW_AT_low_pc $func2_addr}
- {DW_AT_high_pc $func2_len DW_FORM_udata}
+ DW_AT_name "func2"
+ DW_AT_low_pc $func2_addr
+ DW_AT_high_pc $func2_len DW_FORM_udata
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/macro-complaints.exp b/gdb/testsuite/gdb.dwarf2/macro-complaints.exp
index 7b0b27a..17e18c0 100644
--- a/gdb/testsuite/gdb.dwarf2/macro-complaints.exp
+++ b/gdb/testsuite/gdb.dwarf2/macro-complaints.exp
@@ -36,20 +36,20 @@ Dwarf::assemble $asm_file {
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}
+ 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_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}
+ MACRO_AT_func {main}
+ DW_AT_type :$int_type
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/macro-source-path-clang14-dw4.exp b/gdb/testsuite/gdb.dwarf2/macro-source-path-clang14-dw4.exp
index c0c2635..d4407d7 100644
--- a/gdb/testsuite/gdb.dwarf2/macro-source-path-clang14-dw4.exp
+++ b/gdb/testsuite/gdb.dwarf2/macro-source-path-clang14-dw4.exp
@@ -18,6 +18,10 @@
# Generate binaries imitating different ways source file paths can be passed to
# compilers. Test printing macros from those binaries.
+load_lib dwarf.exp
+
+require dwarf2_support
+
# The do_test proc comes from macro-source-path.exp.tcl.
source $srcdir/$subdir/macro-source-path.exp.tcl
diff --git a/gdb/testsuite/gdb.dwarf2/macro-source-path-clang14-dw5.exp b/gdb/testsuite/gdb.dwarf2/macro-source-path-clang14-dw5.exp
index 0b3239e..23a40ba 100644
--- a/gdb/testsuite/gdb.dwarf2/macro-source-path-clang14-dw5.exp
+++ b/gdb/testsuite/gdb.dwarf2/macro-source-path-clang14-dw5.exp
@@ -18,6 +18,10 @@
# Generate binaries imitating different ways source file paths can be passed to
# compilers. Test printing macros from those binaries.
+load_lib dwarf.exp
+
+require dwarf2_support
+
# The do_test proc comes from macro-source-path.exp.tcl.
source $srcdir/$subdir/macro-source-path.exp.tcl
diff --git a/gdb/testsuite/gdb.dwarf2/macro-source-path-gcc11-ld234-dw5.exp b/gdb/testsuite/gdb.dwarf2/macro-source-path-gcc11-ld234-dw5.exp
index 940f997..99f7857 100644
--- a/gdb/testsuite/gdb.dwarf2/macro-source-path-gcc11-ld234-dw5.exp
+++ b/gdb/testsuite/gdb.dwarf2/macro-source-path-gcc11-ld234-dw5.exp
@@ -18,6 +18,10 @@
# Generate binaries imitating different ways source file paths can be passed to
# compilers. Test printing macros from those binaries.
+load_lib dwarf.exp
+
+require dwarf2_support
+
# The do_test proc comes from macro-source-path.exp.tcl.
source $srcdir/$subdir/macro-source-path.exp.tcl
diff --git a/gdb/testsuite/gdb.dwarf2/macro-source-path-gcc11-ld238-dw4.exp b/gdb/testsuite/gdb.dwarf2/macro-source-path-gcc11-ld238-dw4.exp
index dea0308..569b409 100644
--- a/gdb/testsuite/gdb.dwarf2/macro-source-path-gcc11-ld238-dw4.exp
+++ b/gdb/testsuite/gdb.dwarf2/macro-source-path-gcc11-ld238-dw4.exp
@@ -18,6 +18,10 @@
# Generate binaries imitating different ways source file paths can be passed to
# compilers. Test printing macros from those binaries.
+load_lib dwarf.exp
+
+require dwarf2_support
+
# The do_test proc comes from macro-source-path.exp.tcl.
source $srcdir/$subdir/macro-source-path.exp.tcl
diff --git a/gdb/testsuite/gdb.dwarf2/macro-source-path-gcc11-ld238-dw5.exp b/gdb/testsuite/gdb.dwarf2/macro-source-path-gcc11-ld238-dw5.exp
index 98a278e..0517d29 100644
--- a/gdb/testsuite/gdb.dwarf2/macro-source-path-gcc11-ld238-dw5.exp
+++ b/gdb/testsuite/gdb.dwarf2/macro-source-path-gcc11-ld238-dw5.exp
@@ -18,6 +18,10 @@
# Generate binaries imitating different ways source file paths can be passed to
# compilers. Test printing macros from those binaries.
+load_lib dwarf.exp
+
+require dwarf2_support
+
# The do_test proc comes from macro-source-path.exp.tcl.
source $srcdir/$subdir/macro-source-path.exp.tcl
diff --git a/gdb/testsuite/gdb.dwarf2/macro-source-path.exp.tcl b/gdb/testsuite/gdb.dwarf2/macro-source-path.exp.tcl
index ecaf685..b71d55d 100644
--- a/gdb/testsuite/gdb.dwarf2/macro-source-path.exp.tcl
+++ b/gdb/testsuite/gdb.dwarf2/macro-source-path.exp.tcl
@@ -21,10 +21,6 @@
# The entry points for this test are in the various
# gdb.dwarf2/macro-source-path-*.exp files.
-load_lib dwarf.exp
-
-require dwarf2_support
-
standard_testfile macro-source-path.c
lassign [function_range main $srcdir/$subdir/$srcfile] \
@@ -68,24 +64,24 @@ proc do_test { test_name lines_version DW_AT_name main_file_idx directories
cu {} {
DW_TAG_compile_unit {
- {DW_AT_producer "My C Compiler"}
- {DW_AT_language @DW_LANG_C11}
- {DW_AT_name $::DW_AT_name}
- {DW_AT_comp_dir $comp_dir}
- {DW_AT_stmt_list $Llines DW_FORM_sec_offset}
- {DW_AT_macros $cu_macros DW_FORM_sec_offset}
+ DW_AT_producer "My C Compiler"
+ DW_AT_language @DW_LANG_C11
+ DW_AT_name $::DW_AT_name
+ DW_AT_comp_dir $comp_dir
+ DW_AT_stmt_list $Llines DW_FORM_sec_offset
+ DW_AT_macros $cu_macros 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_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}
+ MACRO_AT_func {main}
+ DW_AT_type :$int_type
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/main-subprogram.exp b/gdb/testsuite/gdb.dwarf2/main-subprogram.exp
index 467cf20..0200316 100644
--- a/gdb/testsuite/gdb.dwarf2/main-subprogram.exp
+++ b/gdb/testsuite/gdb.dwarf2/main-subprogram.exp
@@ -31,22 +31,22 @@ Dwarf::assemble $asm_file {
# so choose a language that isn't C and that gdb is unlikely
# to implement.
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_PLI}
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir /tmp}
- } {
+ DW_AT_language @DW_LANG_PLI
+ DW_AT_name $srcfile
+ DW_AT_comp_dir /tmp
+ } {
declare_labels type
- type: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name 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 {mymain}}
- {type :$type}
- {DW_AT_main_subprogram 1 flag}
+ MACRO_AT_func {mymain}
+ DW_AT_type :$type
+ DW_AT_main_subprogram 1 flag
} {
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/mega-enum.exp b/gdb/testsuite/gdb.dwarf2/mega-enum.exp
index 7482edb..7817fbf 100644
--- a/gdb/testsuite/gdb.dwarf2/mega-enum.exp
+++ b/gdb/testsuite/gdb.dwarf2/mega-enum.exp
@@ -26,21 +26,21 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C}
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir /tmp}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name $srcfile
+ DW_AT_comp_dir /tmp
} {
declare_labels integer_label
integer_label: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name int}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int
}
DW_TAG_enumeration_type {
- {DW_AT_name mega_enum}
- {DW_AT_type :$integer_label}
+ DW_AT_name mega_enum
+ DW_AT_type :$integer_label
} {
# In the past gdb used a 'short' for the field count.
# But this fails if there are too many fields. If the
@@ -48,8 +48,8 @@ Dwarf::assemble $asm_file {
# so use a number that's just big enough.
for {set i 0} {$i < 65538} {incr i} {
DW_TAG_enumerator {
- {DW_AT_name DEI_$i}
- {DW_AT_const_value $i DW_FORM_sdata}
+ DW_AT_name DEI_$i
+ DW_AT_const_value $i DW_FORM_sdata
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/method-ptr.exp b/gdb/testsuite/gdb.dwarf2/method-ptr.exp
index 867527c..828166f 100644
--- a/gdb/testsuite/gdb.dwarf2/method-ptr.exp
+++ b/gdb/testsuite/gdb.dwarf2/method-ptr.exp
@@ -28,48 +28,50 @@ Dwarf::assemble $asm_file {
declare_labels ptr_label subr_label memptr_label
cu {} {
- compile_unit {{language @DW_LANG_C_plus_plus}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C_plus_plus
+ } {
int_label: base_type {
- {name int}
- {encoding @DW_ATE_signed}
- {byte_size 4 DW_FORM_sdata}
+ DW_AT_name int
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 4 DW_FORM_sdata
}
float_label: base_type {
- {name float}
- {encoding @DW_ATE_float}
- {byte_size 4 DW_FORM_sdata}
+ DW_AT_name float
+ DW_AT_encoding @DW_ATE_float
+ DW_AT_byte_size 4 DW_FORM_sdata
}
struct_label: structure_type {
- {name S}
- {byte_size 1 DW_FORM_sdata}
+ DW_AT_name S
+ DW_AT_byte_size 1 DW_FORM_sdata
}
ptr_label: pointer_type {
- {type :$struct_label}
+ DW_AT_type :$struct_label
}
subr_label: subroutine_type {
- {type :$int_label}
+ DW_AT_type :$int_label
} {
formal_parameter {
- {type :$ptr_label}
- {artificial 1 DW_FORM_flag_present}
+ DW_AT_type :$ptr_label
+ DW_AT_artificial 1 DW_FORM_flag_present
}
formal_parameter {
- {type :$float_label}
+ DW_AT_type :$float_label
}
}
memptr_label: ptr_to_member_type {
- {type :$subr_label}
- {containing_type :$struct_label}
+ DW_AT_type :$subr_label
+ DW_AT_containing_type :$struct_label
}
typedef {
- {name the_typedef}
- {type :$memptr_label}
+ DW_AT_name the_typedef
+ DW_AT_type :$memptr_label
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/missing-line-table.exp b/gdb/testsuite/gdb.dwarf2/missing-line-table.exp
index 835686e..977a016 100644
--- a/gdb/testsuite/gdb.dwarf2/missing-line-table.exp
+++ b/gdb/testsuite/gdb.dwarf2/missing-line-table.exp
@@ -38,19 +38,19 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name missing-line-table.c}
- {stmt_list $Llines DW_FORM_sec_offset}
- {DW_AT_low_pc $::foo_start DW_FORM_addr}
- {DW_AT_high_pc $::main_end DW_FORM_addr}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name missing-line-table.c
+ DW_AT_stmt_list $Llines DW_FORM_sec_offset
+ DW_AT_low_pc $::foo_start DW_FORM_addr
+ DW_AT_high_pc $::main_end DW_FORM_addr
} {
subprogram {
- {external 1 flag}
- {MACRO_AT_func {main}}
+ DW_AT_external 1 flag
+ MACRO_AT_func {main}
}
subprogram {
- {external 1 flag}
- {MACRO_AT_func {foo}}
+ DW_AT_external 1 flag
+ MACRO_AT_func {foo}
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/missing-sig-type.exp b/gdb/testsuite/gdb.dwarf2/missing-sig-type.exp
index 947f024..a3eaae9 100644
--- a/gdb/testsuite/gdb.dwarf2/missing-sig-type.exp
+++ b/gdb/testsuite/gdb.dwarf2/missing-sig-type.exp
@@ -30,8 +30,8 @@ Dwarf::assemble $asm_file {
# This signature is intentionally wrong.
typedef_label: typedef {
- {name foo}
- {type 0xee22334455667788 ref_sig8 }
+ DW_AT_name foo
+ DW_AT_type 0xee22334455667788 ref_sig8
}
}
}
@@ -39,9 +39,9 @@ Dwarf::assemble $asm_file {
tu {} 0x1122334455667788 the_type {
type_unit {} {
the_type: base_type {
- {name int}
- {encoding @DW_ATE_signed}
- {byte_size 4 sdata}
+ DW_AT_name int
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 4 sdata
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/missing-type-name-for-templates.exp b/gdb/testsuite/gdb.dwarf2/missing-type-name-for-templates.exp
index 108c9c7..ee6992b 100644
--- a/gdb/testsuite/gdb.dwarf2/missing-type-name-for-templates.exp
+++ b/gdb/testsuite/gdb.dwarf2/missing-type-name-for-templates.exp
@@ -40,112 +40,112 @@ set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C_plus_plus}
+ DW_AT_language @DW_LANG_C_plus_plus
} {
declare_labels int float template_var1 template_var2 template_var3
int: DW_TAG_base_type {
- {DW_AT_name "int"}
- {DW_AT_byte_size 4 DW_FORM_data1}
- {DW_AT_encoding @DW_ATE_signed}
+ DW_AT_name "int"
+ DW_AT_byte_size 4 DW_FORM_data1
+ DW_AT_encoding @DW_ATE_signed
}
float: base_type {
- {DW_AT_name float}
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_float}
+ DW_AT_name float
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_float
}
DW_TAG_subprogram {
- {DW_AT_name "main"}
- {DW_AT_low_pc $::main_start DW_FORM_addr}
- {DW_AT_high_pc $::main_end DW_FORM_addr}
- {DW_AT_type :$int}
- {DW_AT_external 1 DW_FORM_flag}
+ DW_AT_name "main"
+ DW_AT_low_pc $::main_start DW_FORM_addr
+ DW_AT_high_pc $::main_end DW_FORM_addr
+ DW_AT_type :$int
+ DW_AT_external 1 DW_FORM_flag
} {
DW_TAG_variable {
- {DW_AT_name "var1"}
- {DW_AT_type :$template_var1}
+ DW_AT_name "var1"
+ DW_AT_type :$template_var1
}
DW_TAG_variable {
- {DW_AT_name "var2"}
- {DW_AT_type :$template_var2}
+ DW_AT_name "var2"
+ DW_AT_type :$template_var2
}
DW_TAG_variable {
- {DW_AT_name "var3"}
- {DW_AT_type :$template_var3}
+ DW_AT_name "var3"
+ DW_AT_type :$template_var3
}
}
# A variable whose type is a template instantiation with two
# template parameters, one unnamed.
template_var1: DW_TAG_structure_type {
- {DW_AT_name "template_var1<int, float>"}
+ DW_AT_name "template_var1<int, float>"
} {
DW_TAG_member {
- {DW_AT_name "me"}
- {DW_AT_type :$int}
+ DW_AT_name "me"
+ DW_AT_type :$int
}
DW_TAG_member {
- {DW_AT_name "me2"}
- {DW_AT_type :$float}
+ DW_AT_name "me2"
+ DW_AT_type :$float
}
DW_TAG_template_type_param {
- {DW_AT_type :$int}
+ DW_AT_type :$int
}
DW_TAG_template_type_param {
- {DW_AT_name "second"}
- {DW_AT_type :$float}
+ DW_AT_name "second"
+ DW_AT_type :$float
}
}
# A variable whose type is a template instantiation with two
# template parameters, both unnamed.
template_var2: DW_TAG_class_type {
- {DW_AT_name "template_var2<int, float>"}
+ DW_AT_name "template_var2<int, float>"
} {
DW_TAG_member {
- {DW_AT_name "me"}
- {DW_AT_type :$int}
+ DW_AT_name "me"
+ DW_AT_type :$int
}
DW_TAG_member {
- {DW_AT_name "me2"}
- {DW_AT_type :$float}
+ DW_AT_name "me2"
+ DW_AT_type :$float
}
DW_TAG_template_type_param {
- {DW_AT_type :$int}
+ DW_AT_type :$int
}
DW_TAG_template_type_param {
- {DW_AT_type :$float}
+ DW_AT_type :$float
}
}
# A variable whose type is a template instantiation with four
# template arguments, two types, two values, all unnamed.
template_var3: DW_TAG_structure_type {
- {DW_AT_name "template_var3<0, int, 11, float>"}
+ DW_AT_name "template_var3<0, int, 11, float>"
} {
DW_TAG_member {
- {DW_AT_name "me"}
- {DW_AT_type :$int}
+ DW_AT_name "me"
+ DW_AT_type :$int
}
DW_TAG_member {
- {DW_AT_name "me2"}
- {DW_AT_type :$float}
+ DW_AT_name "me2"
+ DW_AT_type :$float
}
DW_TAG_template_value_param {
- {DW_AT_type :$int}
- {DW_AT_const_value 0 DW_FORM_sdata}
+ DW_AT_type :$int
+ DW_AT_const_value 0 DW_FORM_sdata
}
DW_TAG_template_type_param {
- {DW_AT_type :$int}
+ DW_AT_type :$int
}
DW_TAG_template_value_param {
- {DW_AT_type :$int}
- {DW_AT_const_value 11 DW_FORM_sdata}
+ DW_AT_type :$int
+ DW_AT_const_value 11 DW_FORM_sdata
}
DW_TAG_template_type_param {
- {DW_AT_type :$float}
+ DW_AT_type :$float
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/missing-type-name.exp b/gdb/testsuite/gdb.dwarf2/missing-type-name.exp
index 91997f7..68a5552 100644
--- a/gdb/testsuite/gdb.dwarf2/missing-type-name.exp
+++ b/gdb/testsuite/gdb.dwarf2/missing-type-name.exp
@@ -44,48 +44,52 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_producer "GNU C 8.1"}
- {DW_AT_language @DW_LANG_C}
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir /tmp}
- } {
+ DW_AT_producer "GNU C 8.1"
+ DW_AT_language @DW_LANG_C
+ DW_AT_name $srcfile
+ DW_AT_comp_dir /tmp
+ } {
declare_labels main_type int_type ptr_type
main_type: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
}
int_type: DW_TAG_base_type {
- {DW_AT_byte_size 0 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
+ DW_AT_byte_size 0 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
}
ptr_type: DW_TAG_pointer_type {
- {DW_AT_type :$int_type}
+ DW_AT_type :$int_type
}
- DW_TAG_subprogram {
- {MACRO_AT_func func}
- {type :$int_type}
+ DW_TAG_subprogram {
+ MACRO_AT_func func
+ DW_AT_type :$int_type
}
- DW_TAG_subprogram {
- {MACRO_AT_func main}
- {type :$main_type}
+ DW_TAG_subprogram {
+ MACRO_AT_func main
+ DW_AT_type :$main_type
}
DW_TAG_variable {
- {DW_AT_name "var_a"}
- {DW_AT_type :$main_type}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_a"]} SPECIAL_expr}
+ DW_AT_name "var_a"
+ DW_AT_type :$main_type
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "var_a"]
+ }] SPECIAL_expr
}
DW_TAG_variable {
- {DW_AT_name "var_ptr"}
- {DW_AT_type :$ptr_type}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_ptr"]} SPECIAL_expr}
+ DW_AT_name "var_ptr"
+ DW_AT_type :$ptr_type
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "var_ptr"]
+ }] SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/multidictionary.exp b/gdb/testsuite/gdb.dwarf2/multidictionary.exp
index 3458f7c..4fdf985 100644
--- a/gdb/testsuite/gdb.dwarf2/multidictionary.exp
+++ b/gdb/testsuite/gdb.dwarf2/multidictionary.exp
@@ -35,40 +35,40 @@ Dwarf::assemble $asm_file {
cu {} {
D45d9: compile_unit {
- {language @DW_LANG_C_plus_plus}
- {name "SerialPortUtils.cpp"}
+ DW_AT_language @DW_LANG_C_plus_plus
+ DW_AT_name "SerialPortUtils.cpp"
} {
D5079: base_type {
- {byte_size 1 sdata}
- {encoding @DW_ATE_unsigned}
- {name "char"}
+ DW_AT_byte_size 1 sdata
+ DW_AT_encoding @DW_ATE_unsigned
+ DW_AT_name "char"
}
D5080: const_type {
- {type :$D5079}
+ DW_AT_type :$D5079
}
D50a9: pointer_type {
- {byte_size 4 sdata}
- {type :$D5080}
+ DW_AT_byte_size 4 sdata
+ DW_AT_type :$D5080
}
D50af: const_type {
- {type :$D50a9}
+ DW_AT_type :$D50a9
}
D5ab2: subprogram {
- {external 1 flag}
- {linkage_name "_Z18SerialSyncWriteStrPKc"}
+ DW_AT_external 1 flag
+ DW_AT_linkage_name "_Z18SerialSyncWriteStrPKc"
} {
D5ac2: formal_parameter {
- {name "msg"}
- {type :$D50af}
+ DW_AT_name "msg"
+ DW_AT_type :$D50af
}
D5ace: lexical_block {} {
D5acf: DW_TAG_variable {
- {name "p"}
- {type :$D50a9}
+ DW_AT_name "p"
+ DW_AT_type :$D50a9
}
}
}
@@ -77,34 +77,34 @@ Dwarf::assemble $asm_file {
cu {} {
D2135f: compile_unit {
- {language @DW_LANG_C_plus_plus}
- {name "Main.cpp"}
+ DW_AT_language @DW_LANG_C_plus_plus
+ DW_AT_name "Main.cpp"
} {
D2216a: base_type {
- {byte_size 1 sdata}
- {encoding @DW_ATE_unsigned_char}
- {name "char"}
+ DW_AT_byte_size 1 sdata
+ DW_AT_encoding @DW_ATE_unsigned_char
+ DW_AT_name "char"
}
D22171: const_type {
- {type :$D2216a}
+ DW_AT_type :$D2216a
}
D226c4: pointer_type {
- {byte_size 4 sdata}
- {type :$D22171}
+ DW_AT_byte_size 4 sdata
+ DW_AT_type :$D22171
}
D226ca: const_type {
- {type :$D226c4}
+ DW_AT_type :$D226c4
}
D245da: subprogram {
- {name "PrintPanicMsg"}
+ DW_AT_name "PrintPanicMsg"
} {
D245e6: formal_parameter {
- {name "msg"}
- {type :$D226ca}
+ DW_AT_name "msg"
+ DW_AT_type :$D226ca
}
}
}
@@ -112,28 +112,28 @@ Dwarf::assemble $asm_file {
cu {} {
D41c21: compile_unit {
- {language @DW_LANG_C99}
- {name "<artificial>"}
+ DW_AT_language @DW_LANG_C99
+ DW_AT_name "<artificial>"
} {
- D42025: subprogram {
- {abstract_origin %$D245da}
- {low_pc 0x80b60 addr}
- {high_pc 0x6c data4}
- } {
+ D42025: subprogram {
+ DW_AT_abstract_origin %$D245da
+ DW_AT_low_pc 0x80b60 addr
+ DW_AT_high_pc 0x6c data4
+ } {
D42038: formal_parameter {
- {abstract_origin %$D245e6}
+ DW_AT_abstract_origin %$D245e6
}
D42045: inlined_subroutine {
- {abstract_origin %$D5ab2}
- {low_pc 0x8060 addr}
- {high_pc 0xc data4}
- } {
- D420b5: formal_parameter {
- {abstract_origin %$D5ac2}
- }
- }
- }
+ DW_AT_abstract_origin %$D5ab2
+ DW_AT_low_pc 0x8060 addr
+ DW_AT_high_pc 0xc data4
+ } {
+ D420b5: formal_parameter {
+ DW_AT_abstract_origin %$D5ac2
+ }
+ }
+ }
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/nameless-enum.exp b/gdb/testsuite/gdb.dwarf2/nameless-enum.exp
index 1610b7c..6d42fb7 100644
--- a/gdb/testsuite/gdb.dwarf2/nameless-enum.exp
+++ b/gdb/testsuite/gdb.dwarf2/nameless-enum.exp
@@ -27,25 +27,25 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_D}
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir /tmp}
+ DW_AT_language @DW_LANG_D
+ DW_AT_name $srcfile
+ DW_AT_comp_dir /tmp
} {
declare_labels integer_label
integer_label: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name int}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int
}
DW_TAG_enumeration_type {
- {DW_AT_type :$integer_label}
- {DW_AT_enum_class 1 DW_FORM_flag}
+ DW_AT_type :$integer_label
+ DW_AT_enum_class 1 DW_FORM_flag
} {
DW_TAG_enumerator {
- {DW_AT_name VALUE}
- {DW_AT_const_value 17 DW_FORM_sdata}
+ DW_AT_name VALUE
+ DW_AT_const_value 17 DW_FORM_sdata
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/negative-data-member-location.exp b/gdb/testsuite/gdb.dwarf2/negative-data-member-location.exp
index 365204f..48f272e 100644
--- a/gdb/testsuite/gdb.dwarf2/negative-data-member-location.exp
+++ b/gdb/testsuite/gdb.dwarf2/negative-data-member-location.exp
@@ -31,33 +31,35 @@ set asm_file [standard_output_file ${srcfile2}]
Dwarf::assemble ${asm_file} {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C99}
- {DW_AT_producer "GNU C++17 11.1.0 -mtune=generic -march=x86-64 -g3 -O0"}
- {name ${::srcfile}}
+ DW_AT_language @DW_LANG_C99
+ DW_AT_producer "GNU C++17 11.1.0 -mtune=generic -march=x86-64 -g3 -O0"
+ DW_AT_name ${::srcfile}
} {
declare_labels int_label struct_label
int_label: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_udata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name "int"}
+ DW_AT_byte_size 4 DW_FORM_udata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name "int"
}
struct_label: DW_TAG_structure_type {
- {DW_AT_name "the_struct"}
- {DW_AT_byte_size 4 DW_FORM_udata}
+ DW_AT_name "the_struct"
+ DW_AT_byte_size 4 DW_FORM_udata
} {
DW_TAG_member {
- {DW_AT_name "field"}
- {DW_AT_type :$int_label}
- {DW_AT_data_member_location -1 DW_FORM_sdata}
+ DW_AT_name "field"
+ DW_AT_type :$int_label
+ DW_AT_data_member_location -1 DW_FORM_sdata
}
}
DW_TAG_variable {
- {DW_AT_name "s"}
- {DW_AT_type :$struct_label}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "s"]} SPECIAL_expr}
+ DW_AT_name "s"
+ DW_AT_type :$struct_label
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "s"]
+ }] SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/nonvar-access.exp b/gdb/testsuite/gdb.dwarf2/nonvar-access.exp
index 4aef19a..93c3dea 100644
--- a/gdb/testsuite/gdb.dwarf2/nonvar-access.exp
+++ b/gdb/testsuite/gdb.dwarf2/nonvar-access.exp
@@ -31,165 +31,165 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {DW_AT_name $srcfile}
+ DW_AT_name $srcfile
} {
declare_labels int_type_label char_type_label \
struct_s_label struct_t_label array_a9_label \
char_ptr_label implicit_a_label stack_b_label
int_type_label: base_type {
- {name "int"}
- {encoding @DW_ATE_signed}
- {byte_size 4 DW_FORM_sdata}
+ DW_AT_name "int"
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 4 DW_FORM_sdata
}
char_type_label: base_type {
- {name "char"}
- {encoding @DW_ATE_unsigned}
- {byte_size 1 DW_FORM_sdata}
+ DW_AT_name "char"
+ DW_AT_encoding @DW_ATE_unsigned
+ DW_AT_byte_size 1 DW_FORM_sdata
}
char_ptr_label: pointer_type {
- {type :$char_type_label}
+ DW_AT_type :$char_type_label
}
struct_s_label: structure_type {
- {name s}
- {byte_size 4 DW_FORM_sdata}
+ DW_AT_name s
+ DW_AT_byte_size 4 DW_FORM_sdata
} {
member {
- {name a}
- {type :$int_type_label}
- {data_member_location 0 DW_FORM_udata}
- {bit_size 8 DW_FORM_udata}
+ DW_AT_name a
+ DW_AT_type :$int_type_label
+ DW_AT_data_member_location 0 DW_FORM_udata
+ DW_AT_bit_size 8 DW_FORM_udata
}
member {
- {name b}
- {type :$int_type_label}
- {data_bit_offset 8 DW_FORM_udata}
- {bit_size 24 DW_FORM_udata}
+ DW_AT_name b
+ DW_AT_type :$int_type_label
+ DW_AT_data_bit_offset 8 DW_FORM_udata
+ DW_AT_bit_size 24 DW_FORM_udata
}
}
struct_t_label: structure_type {
- {name t}
- {byte_size 4 DW_FORM_sdata}
+ DW_AT_name t
+ DW_AT_byte_size 4 DW_FORM_sdata
} {
member {
- {name a}
- {type :$int_type_label}
- {data_member_location 0 DW_FORM_udata}
- {bit_size 9 DW_FORM_udata}
+ DW_AT_name a
+ DW_AT_type :$int_type_label
+ DW_AT_data_member_location 0 DW_FORM_udata
+ DW_AT_bit_size 9 DW_FORM_udata
}
member {
- {name b}
- {type :$int_type_label}
- {data_bit_offset 9 DW_FORM_udata}
- {bit_size 23 DW_FORM_udata}
+ DW_AT_name b
+ DW_AT_type :$int_type_label
+ DW_AT_data_bit_offset 9 DW_FORM_udata
+ DW_AT_bit_size 23 DW_FORM_udata
}
}
array_a9_label: array_type {
- {type :$char_type_label}
+ DW_AT_type :$char_type_label
} {
subrange_type {
- {type :$int_type_label}
- {upper_bound 8 DW_FORM_udata}
+ DW_AT_type :$int_type_label
+ DW_AT_upper_bound 8 DW_FORM_udata
}
}
DW_TAG_subprogram {
- {MACRO_AT_func {main}}
- {DW_AT_external 1 flag}
+ MACRO_AT_func {main}
+ DW_AT_external 1 flag
} {
# Simple variable without location.
DW_TAG_variable {
- {name undef_int}
- {type :$int_type_label}
+ DW_AT_name undef_int
+ DW_AT_type :$int_type_label
}
# Struct variable without location.
DW_TAG_variable {
- {name undef_s}
- {type :$struct_s_label}
+ DW_AT_name undef_s
+ DW_AT_type :$struct_s_label
}
# Composite location: byte-aligned pieces.
DW_TAG_variable {
- {name def_s}
- {type :$struct_s_label}
- {location {
+ DW_AT_name def_s
+ DW_AT_type :$struct_s_label
+ DW_AT_location {
const1u 0
stack_value
bit_piece 8 0
const1s -1
stack_value
bit_piece 24 0
- } SPECIAL_expr}
+ } SPECIAL_expr
}
# Composite location: non-byte-aligned pieces.
DW_TAG_variable {
- {name def_t}
- {type :$struct_t_label}
- {location {
+ DW_AT_name def_t
+ DW_AT_type :$struct_t_label
+ DW_AT_location {
const2s -184
stack_value
bit_piece 9 0
const4u 1752286
stack_value
bit_piece 23 0
- } SPECIAL_expr}
+ } SPECIAL_expr
}
# Composite location with some empty pieces.
DW_TAG_variable {
- {name part_def_a}
- {type :$array_a9_label}
- {location {
+ DW_AT_name part_def_a
+ DW_AT_type :$array_a9_label
+ DW_AT_location {
piece 3
const4u 0xf1927314
stack_value
piece 4
piece 2
- } SPECIAL_expr}
+ } SPECIAL_expr
}
# Implicit location: immediate value.
DW_TAG_variable {
- {name def_implicit_s}
- {type :$struct_s_label}
- {location {
+ DW_AT_name def_implicit_s
+ DW_AT_type :$struct_s_label
+ DW_AT_location {
implicit_value 0x12 0x34 0x56 0x78
- } SPECIAL_expr}
+ } SPECIAL_expr
}
# Implicit location: immediate value for whole array, with
# excess bytes.
implicit_a_label: DW_TAG_variable {
- {name def_implicit_a}
- {type :$array_a9_label}
- {location {
+ DW_AT_name def_implicit_a
+ DW_AT_type :$array_a9_label
+ DW_AT_location {
implicit_value 0x1 0x12 0x23 0x34 0x45 \
0x56 0x67 0x78 0x89 0x9a 0xab
- } SPECIAL_expr}
+ } SPECIAL_expr
}
# Implicit pointer into immediate value.
DW_TAG_variable {
- {name implicit_a_ptr}
- {type :$char_ptr_label}
- {location {
+ DW_AT_name implicit_a_ptr
+ DW_AT_type :$char_ptr_label
+ DW_AT_location [subst {
implicit_pointer $implicit_a_label 5
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
# Stack-value location.
stack_b_label: DW_TAG_variable {
- {name def_stack_b}
- {type :$struct_t_label}
- {location {
+ DW_AT_name def_stack_b
+ DW_AT_type :$struct_t_label
+ DW_AT_location {
const4u 0x1a2b3c4d
stack_value
- } SPECIAL_expr}
+ } SPECIAL_expr
}
# Implicit pointer into stack value.
DW_TAG_variable {
- {name implicit_b_ptr}
- {type :$char_ptr_label}
- {location {
+ DW_AT_name implicit_b_ptr
+ DW_AT_type :$char_ptr_label
+ DW_AT_location [subst {
implicit_pointer $stack_b_label 1
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/nostaticblock.exp b/gdb/testsuite/gdb.dwarf2/nostaticblock.exp
index 2cc8338..0d5943c 100644
--- a/gdb/testsuite/gdb.dwarf2/nostaticblock.exp
+++ b/gdb/testsuite/gdb.dwarf2/nostaticblock.exp
@@ -26,8 +26,8 @@ set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {low_pc 0x104320 DW_FORM_addr}
- {high_pc 0x1045ed DW_FORM_addr}
+ DW_AT_low_pc 0x104320 DW_FORM_addr
+ DW_AT_high_pc 0x1045ed DW_FORM_addr
} {
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/opaque-type-lookup.exp b/gdb/testsuite/gdb.dwarf2/opaque-type-lookup.exp
index 757212b..b4d275c 100644
--- a/gdb/testsuite/gdb.dwarf2/opaque-type-lookup.exp
+++ b/gdb/testsuite/gdb.dwarf2/opaque-type-lookup.exp
@@ -44,37 +44,37 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name opaque_before}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name opaque_before
} {
imported_unit {
- {import $partial_unit_with_opaque ref_addr}
+ DW_AT_import $partial_unit_with_opaque ref_addr
}
imported_unit {
- {import $partial_unit_defining_a ref_addr}
+ DW_AT_import $partial_unit_defining_a ref_addr
}
}
}
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name opaque_after}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name opaque_after
} {
imported_unit {
- {import $partial_unit_defining_b ref_addr}
+ DW_AT_import $partial_unit_defining_b ref_addr
}
imported_unit {
- {import $partial_unit_with_opaque ref_addr}
+ DW_AT_import $partial_unit_with_opaque ref_addr
}
}
}
cu {} {
partial_unit_with_opaque: partial_unit {
- {name "partial_unit_with_opaque"}
+ DW_AT_name "partial_unit_with_opaque"
} {
# Normally gdb doesn't add opaque types to the symbol table
# but there are times when it will, and in order to exercise
@@ -82,89 +82,89 @@ Dwarf::assemble $asm_file {
# By giving it a size of 1 we achieve this.
opaque_struct_a_label: structure_type {
- {name struct_a}
- {declaration 1 flag}
- {byte_size 1 DW_FORM_sdata}
+ DW_AT_name struct_a
+ DW_AT_declaration 1 flag
+ DW_AT_byte_size 1 DW_FORM_sdata
}
opaque_struct_b_label: structure_type {
- {name struct_b}
- {declaration 1 flag}
- {byte_size 1 DW_FORM_sdata}
+ DW_AT_name struct_b
+ DW_AT_declaration 1 flag
+ DW_AT_byte_size 1 DW_FORM_sdata
}
DW_TAG_variable {
- {name variable_a}
- {type :$opaque_struct_a_label}
- {external 1 flag}
- {declaration 1 flag}
+ DW_AT_name variable_a
+ DW_AT_type :$opaque_struct_a_label
+ DW_AT_external 1 flag
+ DW_AT_declaration 1 flag
}
DW_TAG_variable {
- {name variable_b}
- {type :$opaque_struct_b_label}
- {external 1 flag}
- {declaration 1 flag}
+ DW_AT_name variable_b
+ DW_AT_type :$opaque_struct_b_label
+ DW_AT_external 1 flag
+ DW_AT_declaration 1 flag
}
}
}
cu {} {
partial_unit_defining_a: partial_unit {
- {name "partial_unit_defining_a"}
+ DW_AT_name "partial_unit_defining_a"
} {
char_type1_label: base_type {
- {name "signed char"}
- {encoding @DW_ATE_signed}
- {byte_size 1 DW_FORM_sdata}
+ DW_AT_name "signed char"
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 1 DW_FORM_sdata
}
struct_a_label: structure_type {
- {name struct_a}
- {byte_size 1 DW_FORM_sdata}
+ DW_AT_name struct_a
+ DW_AT_byte_size 1 DW_FORM_sdata
} {
member {
- {name xyz}
- {type :$char_type1_label}
- {data_member_location 0 DW_FORM_sdata}
+ DW_AT_name xyz
+ DW_AT_type :$char_type1_label
+ DW_AT_data_member_location 0 DW_FORM_sdata
}
}
DW_TAG_variable {
- {name variable_a}
- {type :$struct_a_label}
- {external 1 flag}
- {linkage_name variable_a}
+ DW_AT_name variable_a
+ DW_AT_type :$struct_a_label
+ DW_AT_external 1 flag
+ DW_AT_linkage_name variable_a
}
}
}
cu {} {
partial_unit_defining_b: partial_unit {
- {name "partial_unit_defining_b"}
+ DW_AT_name "partial_unit_defining_b"
} {
char_type2_label: base_type {
- {name "signed char"}
- {encoding @DW_ATE_signed}
- {byte_size 1 DW_FORM_sdata}
+ DW_AT_name "signed char"
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 1 DW_FORM_sdata
}
struct_b_label: structure_type {
- {name struct_b}
- {byte_size 1 DW_FORM_sdata}
+ DW_AT_name struct_b
+ DW_AT_byte_size 1 DW_FORM_sdata
} {
member {
- {name xyz}
- {type :$char_type2_label}
- {data_member_location 0 DW_FORM_sdata}
+ DW_AT_name xyz
+ DW_AT_type :$char_type2_label
+ DW_AT_data_member_location 0 DW_FORM_sdata
}
}
DW_TAG_variable {
- {name variable_b}
- {type :$struct_b_label}
- {external 1 flag}
- {linkage_name variable_b}
+ DW_AT_name variable_b
+ DW_AT_type :$struct_b_label
+ DW_AT_external 1 flag
+ DW_AT_linkage_name variable_b
}
}
}
@@ -173,11 +173,11 @@ Dwarf::assemble $asm_file {
# so keep this separate.
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name main}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name main
} {
subprogram {
- {MACRO_AT_func { main }}
+ MACRO_AT_func { main }
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/opt-out-not-implptr.exp b/gdb/testsuite/gdb.dwarf2/opt-out-not-implptr.exp
index e5334f2..8c60d03 100644
--- a/gdb/testsuite/gdb.dwarf2/opt-out-not-implptr.exp
+++ b/gdb/testsuite/gdb.dwarf2/opt-out-not-implptr.exp
@@ -30,57 +30,57 @@ Dwarf::assemble $asm_file {
declare_labels i64_type i32_type i64_array i32_array
i64_type: base_type {
- {name "int64_t"}
- {encoding @DW_ATE_signed}
- {byte_size 8 DW_FORM_sdata}
+ DW_AT_name "int64_t"
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 8 DW_FORM_sdata
}
i32_type: base_type {
- {name "int32_t"}
- {encoding @DW_ATE_signed}
- {byte_size 4 DW_FORM_sdata}
+ DW_AT_name "int32_t"
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 4 DW_FORM_sdata
}
i64_array: DW_TAG_array_type {
- {DW_AT_name array_type}
- {DW_AT_type :$i64_type}
+ DW_AT_name array_type
+ DW_AT_type :$i64_type
} {
DW_TAG_subrange_type {
- {DW_AT_type :$i64_type}
- {DW_AT_lower_bound 0 DW_FORM_data1}
- {DW_AT_upper_bound 3 DW_FORM_data1}
+ DW_AT_type :$i64_type
+ DW_AT_lower_bound 0 DW_FORM_data1
+ DW_AT_upper_bound 3 DW_FORM_data1
}
}
i32_array: DW_TAG_array_type {
- {DW_AT_name array_type}
- {DW_AT_type :$i32_type}
+ DW_AT_name array_type
+ DW_AT_type :$i32_type
} {
DW_TAG_subrange_type {
- {DW_AT_type :$i32_type}
- {DW_AT_lower_bound 0 DW_FORM_data1}
- {DW_AT_upper_bound 3 DW_FORM_data1}
+ DW_AT_type :$i32_type
+ DW_AT_lower_bound 0 DW_FORM_data1
+ DW_AT_upper_bound 3 DW_FORM_data1
}
}
DW_TAG_variable {
- {name i64_noptr}
- {type :$i64_array}
- {location {
+ DW_AT_name i64_noptr
+ DW_AT_type :$i64_array
+ DW_AT_location [subst {
DW_OP_constu $::c64
DW_OP_stack_value
DW_OP_piece 8
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
DW_TAG_variable {
- {name i32_noptr}
- {type :$i32_array}
- {location {
+ DW_AT_name i32_noptr
+ DW_AT_type :$i32_array
+ DW_AT_location [subst {
DW_OP_constu $::c32
DW_OP_stack_value
DW_OP_piece 4
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/rnglists-multiple-cus.exp b/gdb/testsuite/gdb.dwarf2/rnglists-multiple-cus.exp
index 0545b35..d6cb4c1 100644
--- a/gdb/testsuite/gdb.dwarf2/rnglists-multiple-cus.exp
+++ b/gdb/testsuite/gdb.dwarf2/rnglists-multiple-cus.exp
@@ -49,14 +49,14 @@ foreach_with_prefix is_64 {false true} {
is_64 $is_64
} {
DW_TAG_compile_unit {
- {DW_AT_ranges 1 DW_FORM_rnglistx}
- {DW_AT_rnglists_base cu_table DW_FORM_sec_offset}
+ DW_AT_ranges 1 DW_FORM_rnglistx
+ DW_AT_rnglists_base cu_table DW_FORM_sec_offset
} {
# This tests a DW_AT_ranges attribute of form DW_FORM_rnglistx on a
# function, which was buggy at some point.
DW_TAG_subprogram {
- {DW_AT_name "foo"}
- {DW_AT_ranges 2 DW_FORM_rnglistx}
+ DW_AT_name "foo"
+ DW_AT_ranges 2 DW_FORM_rnglistx
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/rnglists-sec-offset.exp b/gdb/testsuite/gdb.dwarf2/rnglists-sec-offset.exp
index 7c65dcd..5b12ae4 100644
--- a/gdb/testsuite/gdb.dwarf2/rnglists-sec-offset.exp
+++ b/gdb/testsuite/gdb.dwarf2/rnglists-sec-offset.exp
@@ -43,11 +43,11 @@ foreach_with_prefix is_64 {false true} {
is_64 $is_64
} {
DW_TAG_compile_unit {
- {DW_AT_ranges $cu1_range_list DW_FORM_sec_offset}
+ DW_AT_ranges $cu1_range_list DW_FORM_sec_offset
} {
DW_TAG_subprogram {
- {DW_AT_name "foo"}
- {DW_AT_ranges $foo_range_list DW_FORM_sec_offset}
+ DW_AT_name "foo"
+ DW_AT_ranges $foo_range_list DW_FORM_sec_offset
}
}
}
@@ -61,12 +61,12 @@ foreach_with_prefix is_64 {false true} {
is_64 $is_64
} {
DW_TAG_compile_unit {
- {DW_AT_ranges $cu2_range_list DW_FORM_sec_offset}
- {DW_AT_rnglists_base cu2_table DW_FORM_sec_offset}
+ DW_AT_ranges $cu2_range_list DW_FORM_sec_offset
+ DW_AT_rnglists_base cu2_table DW_FORM_sec_offset
} {
DW_TAG_subprogram {
- {DW_AT_name "bar"}
- {DW_AT_ranges $bar_range_list DW_FORM_sec_offset}
+ DW_AT_name "bar"
+ DW_AT_ranges $bar_range_list DW_FORM_sec_offset
}
}
}
@@ -79,11 +79,11 @@ foreach_with_prefix is_64 {false true} {
is_64 $is_64
} {
DW_TAG_compile_unit {
- {DW_AT_ranges $cu3_range_list DW_FORM_sec_offset}
+ DW_AT_ranges $cu3_range_list DW_FORM_sec_offset
} {
DW_TAG_subprogram {
- {DW_AT_name "baz"}
- {DW_AT_ranges $baz_range_list DW_FORM_sec_offset}
+ DW_AT_name "baz"
+ DW_AT_ranges $baz_range_list DW_FORM_sec_offset
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/rust-enum.exp b/gdb/testsuite/gdb.dwarf2/rust-enum.exp
index 89d4a16..87e710e 100644
--- a/gdb/testsuite/gdb.dwarf2/rust-enum.exp
+++ b/gdb/testsuite/gdb.dwarf2/rust-enum.exp
@@ -30,64 +30,64 @@ Dwarf::assemble $asm_file {
cu { addr_size 4 } {
compile_unit {
- {name file1.txt}
- {language @DW_LANG_Rust}
+ DW_AT_name file1.txt
+ DW_AT_language @DW_LANG_Rust
} {
uinteger_label: DW_TAG_base_type {
- {DW_AT_byte_size 1 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_unsigned}
- {DW_AT_name {unsigned integer}}
+ DW_AT_byte_size 1 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_unsigned
+ DW_AT_name {unsigned integer}
}
one_label: structure_type {
- {name One}
- {byte_size 1 DW_FORM_sdata}
+ DW_AT_name One
+ DW_AT_byte_size 1 DW_FORM_sdata
} {
member {
- {name __0}
- {type :$uinteger_label}
- {data_member_location 0 data1}
+ DW_AT_name __0
+ DW_AT_type :$uinteger_label
+ DW_AT_data_member_location 0 data1
}
}
two_label: structure_type {
- {name Two}
- {byte_size 1 DW_FORM_sdata}
+ DW_AT_name Two
+ DW_AT_byte_size 1 DW_FORM_sdata
} {
member {
- {name __0}
- {type :$uinteger_label}
- {data_member_location 0 data1}
+ DW_AT_name __0
+ DW_AT_type :$uinteger_label
+ DW_AT_data_member_location 0 data1
}
}
simple_label: structure_type {
- {name Simple}
- {byte_size 2 DW_FORM_sdata}
+ DW_AT_name Simple
+ DW_AT_byte_size 2 DW_FORM_sdata
} {
variant_part {
- {discr :$discr_1_label DW_FORM_ref4}
+ DW_AT_discr :$discr_1_label DW_FORM_ref4
} {
discr_1_label: member {
- {type :$uinteger_label}
- {data_member_location 0 data1}
- {artificial 1 DW_FORM_flag_present}
+ DW_AT_type :$uinteger_label
+ DW_AT_data_member_location 0 data1
+ DW_AT_artificial 1 DW_FORM_flag_present
}
variant {
- {discr_value 65 udata}
+ DW_AT_discr_value 65 udata
} {
member {
- {type :$one_label}
- {data_member_location 1 data1}
+ DW_AT_type :$one_label
+ DW_AT_data_member_location 1 data1
}
}
variant {
} {
member {
- {type :$two_label}
- {data_member_location 1 data1}
+ DW_AT_type :$two_label
+ DW_AT_data_member_location 1 data1
}
}
}
@@ -96,14 +96,14 @@ Dwarf::assemble $asm_file {
# In PR rust/31005, a constant Rust enum value could not
# be correctly resolved.
DW_TAG_variable {
- {name constant_variable}
- {const_value 0x4141 udata}
- {type :$simple_label}
+ DW_AT_name constant_variable
+ DW_AT_const_value 0x4141 udata
+ DW_AT_type :$simple_label
}
DW_TAG_variable {
- {name constant_variable2}
- {const_value "AA" DW_FORM_block1}
- {type :$simple_label}
+ DW_AT_name constant_variable2
+ DW_AT_const_value "AA" DW_FORM_block1
+ DW_AT_type :$simple_label
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/self-spec.exp b/gdb/testsuite/gdb.dwarf2/self-spec.exp
index 2136623..3d6c853 100644
--- a/gdb/testsuite/gdb.dwarf2/self-spec.exp
+++ b/gdb/testsuite/gdb.dwarf2/self-spec.exp
@@ -26,12 +26,14 @@ standard_testfile main.c .S
set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu {} {
- compile_unit {{language @DW_LANG_C_plus_plus}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C_plus_plus
+ } {
# Check handling of self-referencing DIE.
declare_labels c1
c1: class_type {
- {name class1}
- {specification :$c1}
+ DW_AT_name class1
+ DW_AT_specification :$c1
}
# Check handling of self-referencing child DIE. Regression test
@@ -39,11 +41,11 @@ Dwarf::assemble $asm_file {
declare_labels f1 abstract_f1 f1_l
abstract_f1: subprogram {}
f1: subprogram {
- {MACRO_AT_func {main}}
- {abstract_origin :$abstract_f1}
+ MACRO_AT_func {main}
+ DW_AT_abstract_origin :$abstract_f1
} {
f1_l: label {
- {abstract_origin :$f1_l}
+ DW_AT_abstract_origin :$f1_l
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/short-build-id.exp b/gdb/testsuite/gdb.dwarf2/short-build-id.exp
index 51c6cef..439b2b2 100644
--- a/gdb/testsuite/gdb.dwarf2/short-build-id.exp
+++ b/gdb/testsuite/gdb.dwarf2/short-build-id.exp
@@ -50,17 +50,19 @@ proc run_test { buildid } {
build_id $buildid
cu { label cu_start } {
- compile_unit {{language @DW_LANG_C}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C
+ } {
int_label2: base_type {
- {name int}
- {byte_size 4 sdata}
- {encoding @DW_ATE_signed}
+ DW_AT_name int
+ DW_AT_byte_size 4 sdata
+ DW_AT_encoding @DW_ATE_signed
}
constant {
- {name the_int}
- {type :$int_label2}
- {const_value 99 data1}
+ DW_AT_name the_int
+ DW_AT_type :$int_label2
+ DW_AT_const_value 99 data1
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/shortpiece.exp b/gdb/testsuite/gdb.dwarf2/shortpiece.exp
index c9bf490..64d5b55 100644
--- a/gdb/testsuite/gdb.dwarf2/shortpiece.exp
+++ b/gdb/testsuite/gdb.dwarf2/shortpiece.exp
@@ -30,90 +30,90 @@ Dwarf::assemble $asm_file {
declare_labels int_label ushort_label struct_label struct_label_2
int_label: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_udata}
- {DW_AT_encoding @DW_ATE_unsigned}
- {DW_AT_name "myint"}
+ DW_AT_byte_size 4 DW_FORM_udata
+ DW_AT_encoding @DW_ATE_unsigned
+ DW_AT_name "myint"
}
ushort_label: DW_TAG_base_type {
- {DW_AT_byte_size 2 DW_FORM_udata}
- {DW_AT_encoding @DW_ATE_unsigned}
- {DW_AT_name "myushort"}
+ DW_AT_byte_size 2 DW_FORM_udata
+ DW_AT_encoding @DW_ATE_unsigned
+ DW_AT_name "myushort"
}
struct_label: DW_TAG_structure_type {
- {DW_AT_name "S"}
- {DW_AT_byte_size 8 DW_FORM_udata}
+ DW_AT_name "S"
+ DW_AT_byte_size 8 DW_FORM_udata
} {
DW_TAG_member {
- {DW_AT_name "a"}
- {DW_AT_type :${int_label}}
- {DW_AT_data_member_location 0 DW_FORM_udata}
+ DW_AT_name "a"
+ DW_AT_type :${int_label}
+ DW_AT_data_member_location 0 DW_FORM_udata
}
DW_TAG_member {
- {DW_AT_name "b"}
- {DW_AT_type :${ushort_label}}
- {DW_AT_data_member_location 4 DW_FORM_udata}
+ DW_AT_name "b"
+ DW_AT_type :${ushort_label}
+ DW_AT_data_member_location 4 DW_FORM_udata
}
}
struct_label_2: DW_TAG_structure_type {
- {DW_AT_name "S_2"}
- {DW_AT_byte_size 6 DW_FORM_udata}
+ DW_AT_name "S_2"
+ DW_AT_byte_size 6 DW_FORM_udata
} {
DW_TAG_member {
- {DW_AT_name "a"}
- {DW_AT_type :${int_label}}
- {DW_AT_data_member_location 0 DW_FORM_udata}
+ DW_AT_name "a"
+ DW_AT_type :${int_label}
+ DW_AT_data_member_location 0 DW_FORM_udata
}
DW_TAG_member {
- {DW_AT_name "b"}
- {DW_AT_type :${ushort_label}}
- {DW_AT_data_member_location 4 DW_FORM_udata}
+ DW_AT_name "b"
+ DW_AT_type :${ushort_label}
+ DW_AT_data_member_location 4 DW_FORM_udata
}
}
DW_TAG_variable {
- {DW_AT_name "s1"}
- {DW_AT_type :${struct_label}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {
+ DW_AT_name "s1"
+ DW_AT_type :${struct_label}
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location {
DW_OP_constu 1
DW_OP_stack_value
DW_OP_piece 4
DW_OP_constu 0
DW_OP_stack_value
DW_OP_piece 2
- } SPECIAL_expr}
+ } SPECIAL_expr
}
DW_TAG_variable {
- {DW_AT_name "s2"}
- {DW_AT_type :${struct_label}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {
+ DW_AT_name "s2"
+ DW_AT_type :${struct_label}
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location {
DW_OP_constu 1
DW_OP_stack_value
DW_OP_piece 4
DW_OP_constu 0
DW_OP_stack_value
DW_OP_piece 8
- } SPECIAL_expr}
+ } SPECIAL_expr
}
DW_TAG_variable {
- {DW_AT_name "s3"}
- {DW_AT_type :${struct_label_2}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {
+ DW_AT_name "s3"
+ DW_AT_type :${struct_label_2}
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location {
DW_OP_constu 0
DW_OP_stack_value
DW_OP_piece 4
DW_OP_constu 1
DW_OP_stack_value
DW_OP_piece 2
- } SPECIAL_expr}
+ } SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/static-optimized-out.exp b/gdb/testsuite/gdb.dwarf2/static-optimized-out.exp
index 6be8283..8b139fa 100644
--- a/gdb/testsuite/gdb.dwarf2/static-optimized-out.exp
+++ b/gdb/testsuite/gdb.dwarf2/static-optimized-out.exp
@@ -28,21 +28,19 @@ set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {
- language @DW_LANG_C
- }
+ DW_AT_language @DW_LANG_C
} {
declare_labels integer_label
integer_label: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
}
DW_TAG_variable {
- {name var}
- {type :$integer_label}
+ DW_AT_name var
+ DW_AT_type :$integer_label
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/staticvirtual.exp b/gdb/testsuite/gdb.dwarf2/staticvirtual.exp
index e04c500..9fa1a2b 100644
--- a/gdb/testsuite/gdb.dwarf2/staticvirtual.exp
+++ b/gdb/testsuite/gdb.dwarf2/staticvirtual.exp
@@ -25,18 +25,20 @@ standard_testfile main.c -dw.S
set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu {} {
- compile_unit {{language @DW_LANG_C_plus_plus}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C_plus_plus
+ } {
structure_type {
- {name S}
- {byte_size 1 DW_FORM_sdata}
+ DW_AT_name S
+ DW_AT_byte_size 1 DW_FORM_sdata
} {
subprogram {
- {low_pc 0x1000 addr}
- {high_pc 0x2000 addr}
- {name ~S}
- {external 1 flag}
- {virtuality @DW_VIRTUALITY_virtual}
- {vtable_elem_location {const1u 1} SPECIAL_expr}
+ DW_AT_low_pc 0x1000 addr
+ DW_AT_high_pc 0x2000 addr
+ DW_AT_name ~S
+ DW_AT_external 1 flag
+ DW_AT_virtuality @DW_VIRTUALITY_virtual
+ DW_AT_vtable_elem_location {const1u 1} SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/struct-decl.exp b/gdb/testsuite/gdb.dwarf2/struct-decl.exp
index e389216..bc857a7 100644
--- a/gdb/testsuite/gdb.dwarf2/struct-decl.exp
+++ b/gdb/testsuite/gdb.dwarf2/struct-decl.exp
@@ -30,9 +30,9 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C_plus_plus}
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir /tmp}
+ DW_AT_language @DW_LANG_C_plus_plus
+ DW_AT_name $srcfile
+ DW_AT_comp_dir /tmp
} {
declare_labels origin
@@ -42,14 +42,14 @@ Dwarf::assemble $asm_file {
# which meant that if a method referred back to them via a
# specification, it would get the wrong name.
DW_TAG_structure_type {
- {DW_AT_byte_size 8 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name the_type}
- {DW_AT_declaration 1 DW_FORM_flag_present}
+ DW_AT_byte_size 8 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name the_type
+ DW_AT_declaration 1 DW_FORM_flag_present
} {
origin: DW_TAG_subprogram {
- {DW_AT_name "method"}
- {DW_AT_declaration 1 DW_FORM_flag_present}
+ DW_AT_name "method"
+ DW_AT_declaration 1 DW_FORM_flag_present
}
}
@@ -57,8 +57,8 @@ Dwarf::assemble $asm_file {
# range that is valid in the program, so we use the main
# function's range.
DW_TAG_subprogram {
- {DW_AT_specification :$origin}
- {MACRO_AT_range main}
+ DW_AT_specification :$origin
+ MACRO_AT_range main
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/struct-with-sig-2.exp b/gdb/testsuite/gdb.dwarf2/struct-with-sig-2.exp
index 02a492d..a527263 100644
--- a/gdb/testsuite/gdb.dwarf2/struct-with-sig-2.exp
+++ b/gdb/testsuite/gdb.dwarf2/struct-with-sig-2.exp
@@ -34,18 +34,18 @@ Dwarf::assemble $asm_file {
declare_labels int_type
the_type_i: structure_type {
- {name s}
- {byte_size 4 sdata}
+ DW_AT_name s
+ DW_AT_byte_size 4 sdata
} {
member {
- {name i}
- {type :$int_type}
+ DW_AT_name i
+ DW_AT_type :$int_type
}
}
int_type: base_type {
- {name int}
- {encoding @DW_ATE_signed}
- {byte_size 4 sdata}
+ DW_AT_name int
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 4 sdata
}
}
}
@@ -55,18 +55,18 @@ Dwarf::assemble $asm_file {
declare_labels int_type
the_type_j: structure_type {
- {name s}
- {byte_size 4 sdata}
+ DW_AT_name s
+ DW_AT_byte_size 4 sdata
} {
member {
- {name j}
- {type :$int_type}
+ DW_AT_name j
+ DW_AT_type :$int_type
}
}
int_type: base_type {
- {name int}
- {encoding @DW_ATE_signed}
- {byte_size 4 sdata}
+ DW_AT_name int
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 4 sdata
}
}
}
@@ -88,32 +88,32 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {DW_AT_language @DW_LANG_C}
- {DW_AT_name main.c}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name main.c
} {
structure_type {
- {name s}
- {signature 0x0000000000000001 ref_sig8}
- {declaration 1 flag}
+ DW_AT_name s
+ DW_AT_signature 0x0000000000000001 ref_sig8
+ DW_AT_declaration 1 flag
}
DW_TAG_subprogram {
- {MACRO_AT_func {main}}
+ MACRO_AT_func {main}
}
}
}
cu {} {
compile_unit {
- {DW_AT_language @DW_LANG_C}
- {DW_AT_name foo.c}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name foo.c
} {
structure_type {
- {name s}
- {signature 0x0000000000000002 ref_sig8}
- {declaration 1 flag}
+ DW_AT_name s
+ DW_AT_signature 0x0000000000000002 ref_sig8
+ DW_AT_declaration 1 flag
}
DW_TAG_subprogram {
- {MACRO_AT_func {foo}}
+ MACRO_AT_func {foo}
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/struct-with-sig.exp b/gdb/testsuite/gdb.dwarf2/struct-with-sig.exp
index 9861327..7e15999 100644
--- a/gdb/testsuite/gdb.dwarf2/struct-with-sig.exp
+++ b/gdb/testsuite/gdb.dwarf2/struct-with-sig.exp
@@ -24,32 +24,32 @@ set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {DW_AT_language @DW_LANG_C}
- {DW_AT_name main.c}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name main.c
} {
structure_type {
- {name s}
- {signature 0x0000000000000001 ref_sig8}
- {declaration 1 flag}
+ DW_AT_name s
+ DW_AT_signature 0x0000000000000001 ref_sig8
+ DW_AT_declaration 1 flag
}
DW_TAG_subprogram {
- {MACRO_AT_func {main}}
+ MACRO_AT_func {main}
}
}
}
cu {} {
compile_unit {
- {DW_AT_language @DW_LANG_C}
- {DW_AT_name foo.c}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name foo.c
} {
structure_type {
- {name s}
- {signature 0x0000000000000002 ref_sig8}
- {declaration 1 flag}
+ DW_AT_name s
+ DW_AT_signature 0x0000000000000002 ref_sig8
+ DW_AT_declaration 1 flag
}
DW_TAG_subprogram {
- {MACRO_AT_func {foo}}
+ MACRO_AT_func {foo}
}
}
}
@@ -59,18 +59,18 @@ Dwarf::assemble $asm_file {
declare_labels int_type
the_type_i: structure_type {
- {name s}
- {byte_size 4 sdata}
+ DW_AT_name s
+ DW_AT_byte_size 4 sdata
} {
member {
- {name i}
- {type :$int_type}
+ DW_AT_name i
+ DW_AT_type :$int_type
}
}
int_type: base_type {
- {name int}
- {encoding @DW_ATE_signed}
- {byte_size 4 sdata}
+ DW_AT_name int
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 4 sdata
}
}
}
@@ -80,18 +80,18 @@ Dwarf::assemble $asm_file {
declare_labels int_type
the_type_j: structure_type {
- {name s}
- {byte_size 4 sdata}
+ DW_AT_name s
+ DW_AT_byte_size 4 sdata
} {
member {
- {name j}
- {type :$int_type}
+ DW_AT_name j
+ DW_AT_type :$int_type
}
}
int_type: base_type {
- {name int}
- {encoding @DW_ATE_signed}
- {byte_size 4 sdata}
+ DW_AT_name int
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 4 sdata
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/subrange-enum.exp b/gdb/testsuite/gdb.dwarf2/subrange-enum.exp
index 9df5774..339cb49 100644
--- a/gdb/testsuite/gdb.dwarf2/subrange-enum.exp
+++ b/gdb/testsuite/gdb.dwarf2/subrange-enum.exp
@@ -26,43 +26,45 @@ standard_testfile main.c -dw.S
set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu {} {
- compile_unit {{language @DW_LANG_C}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C
+ } {
declare_labels integer_label enum_label subrange_label
- integer_label: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
- }
+ integer_label: DW_TAG_base_type {
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
+ }
enum_label: DW_TAG_enumeration_type {
- {DW_AT_name E}
- {DW_AT_type :$integer_label}
+ DW_AT_name E
+ DW_AT_type :$integer_label
} {
DW_TAG_enumerator {
- {DW_AT_name ONE}
- {DW_AT_const_value 1 DW_FORM_sdata}
+ DW_AT_name ONE
+ DW_AT_const_value 1 DW_FORM_sdata
}
DW_TAG_enumerator {
- {DW_AT_name TWO}
- {DW_AT_const_value 2 DW_FORM_sdata}
+ DW_AT_name TWO
+ DW_AT_const_value 2 DW_FORM_sdata
}
DW_TAG_enumerator {
- {DW_AT_name THREE}
- {DW_AT_const_value 3 DW_FORM_sdata}
+ DW_AT_name THREE
+ DW_AT_const_value 3 DW_FORM_sdata
}
}
subrange_label: DW_TAG_subrange_type {
- {lower_bound 1 DW_FORM_sdata}
- {upper_bound 2 DW_FORM_sdata}
- {type :$enum_label}
+ DW_AT_lower_bound 1 DW_FORM_sdata
+ DW_AT_upper_bound 2 DW_FORM_sdata
+ DW_AT_type :$enum_label
}
DW_TAG_variable {
- {name rangeval}
- {type :$subrange_label}
- {const_value 2 DW_FORM_udata}
+ DW_AT_name rangeval
+ DW_AT_type :$subrange_label
+ DW_AT_const_value 2 DW_FORM_udata
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/subrange.exp b/gdb/testsuite/gdb.dwarf2/subrange.exp
index 2cc7472..3e0326f 100644
--- a/gdb/testsuite/gdb.dwarf2/subrange.exp
+++ b/gdb/testsuite/gdb.dwarf2/subrange.exp
@@ -25,35 +25,37 @@ standard_testfile method-ptr.cc -dw.S
set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu {} {
- compile_unit {{language @DW_LANG_Pascal83}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_Pascal83
+ } {
declare_labels byte_label typedef_label array_label
# A subrange's underlying type that is a typedef.
byte_label: base_type {
- {name byte}
- {encoding @DW_ATE_unsigned}
- {byte_size 1 DW_FORM_sdata}
+ DW_AT_name byte
+ DW_AT_encoding @DW_ATE_unsigned
+ DW_AT_byte_size 1 DW_FORM_sdata
}
typedef_label: typedef {
- {name byte_typedef}
- {type :$byte_label}
+ DW_AT_name byte_typedef
+ DW_AT_type :$byte_label
}
array_label: array_type {
- {type :$byte_label}
+ DW_AT_type :$byte_label
} {
subrange_type {
- {lower_bound 0 DW_FORM_sdata}
- {upper_bound 191 DW_FORM_sdata}
- {byte_stride 2 DW_FORM_sdata}
- {type :$typedef_label}
+ DW_AT_lower_bound 0 DW_FORM_sdata
+ DW_AT_upper_bound 191 DW_FORM_sdata
+ DW_AT_byte_stride 2 DW_FORM_sdata
+ DW_AT_type :$typedef_label
}
}
typedef {
- {name TByteArray}
- {type :$array_label}
+ DW_AT_name TByteArray
+ DW_AT_type :$array_label
}
# This subrange's underlying type is signed, but the bounds are
@@ -61,21 +63,21 @@ Dwarf::assemble $asm_file {
declare_labels signed_byte_label subrange_with_buggy_negative_bounds_label
signed_byte_label: base_type {
- {name signed_byte}
- {encoding @DW_ATE_signed}
- {byte_size 1 DW_FORM_sdata}
+ DW_AT_name signed_byte
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 1 DW_FORM_sdata
}
# The bounds mean -16 to -12.
subrange_with_buggy_negative_bounds_label: subrange_type {
- {lower_bound 0xf0 DW_FORM_udata}
- {upper_bound 0xf4 DW_FORM_udata}
- {type :$signed_byte_label}
+ DW_AT_lower_bound 0xf0 DW_FORM_udata
+ DW_AT_upper_bound 0xf4 DW_FORM_udata
+ DW_AT_type :$signed_byte_label
}
DW_TAG_variable {
- {name subrange_with_buggy_negative_bounds_variable}
- {type :$subrange_with_buggy_negative_bounds_label}
+ DW_AT_name subrange_with_buggy_negative_bounds_variable
+ DW_AT_type :$subrange_with_buggy_negative_bounds_label
}
# This subrange's base type is 16-bytes long (although the bounds fit in
@@ -83,19 +85,19 @@ Dwarf::assemble $asm_file {
declare_labels a_16_byte_integer_label a_16_byte_subrange_label
a_16_byte_integer_label: base_type {
- {byte_size 16 udata}
- {encoding @DW_ATE_signed}
+ DW_AT_byte_size 16 udata
+ DW_AT_encoding @DW_ATE_signed
}
a_16_byte_subrange_label: subrange_type {
- {lower_bound -9223372036854775808 DW_FORM_sdata}
- {upper_bound 9223372036854775807 DW_FORM_sdata}
- {type :$a_16_byte_integer_label}
+ DW_AT_lower_bound -9223372036854775808 DW_FORM_sdata
+ DW_AT_upper_bound 9223372036854775807 DW_FORM_sdata
+ DW_AT_type :$a_16_byte_integer_label
}
DW_TAG_variable {
- {name a_16_byte_subrange_variable}
- {type :$a_16_byte_subrange_label}
+ DW_AT_name a_16_byte_subrange_variable
+ DW_AT_type :$a_16_byte_subrange_label
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/symbol_needs_eval_fail.exp b/gdb/testsuite/gdb.dwarf2/symbol_needs_eval_fail.exp
index e69d9b4..6efd458 100644
--- a/gdb/testsuite/gdb.dwarf2/symbol_needs_eval_fail.exp
+++ b/gdb/testsuite/gdb.dwarf2/symbol_needs_eval_fail.exp
@@ -63,23 +63,23 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_name symbol_needs_eval.c}
- {DW_AT_comp_dir /tmp}
+ DW_AT_name symbol_needs_eval.c
+ DW_AT_comp_dir /tmp
} {
declare_labels int_type_label
# define int type
int_type_label: DW_TAG_base_type {
- {DW_AT_name "int"}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_byte_size $int_size DW_FORM_sdata}
+ DW_AT_name "int"
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size $int_size DW_FORM_sdata
}
# define artificial variable a
DW_TAG_variable {
- {DW_AT_name a}
- {DW_AT_type :$int_type_label}
- {DW_AT_location {
+ DW_AT_name a
+ DW_AT_type :$int_type_label
+ DW_AT_location [subst {
DW_OP_addr $exec_mask_var
DW_OP_deref_size $int_size
@@ -91,8 +91,8 @@ Dwarf::assemble $asm_file {
DW_OP_skip 3
DW_OP_bregx $dwarf_regnum 0
DW_OP_stack_value
- } SPECIAL_expr}
- {external 1 flag}
+ }] SPECIAL_expr
+ DW_AT_external 1 flag
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/symbol_needs_eval_timeout.exp b/gdb/testsuite/gdb.dwarf2/symbol_needs_eval_timeout.exp
index a6773d5..61a40eb 100644
--- a/gdb/testsuite/gdb.dwarf2/symbol_needs_eval_timeout.exp
+++ b/gdb/testsuite/gdb.dwarf2/symbol_needs_eval_timeout.exp
@@ -63,40 +63,40 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_name symbol_needs_eval.c}
- {DW_AT_comp_dir /tmp}
+ DW_AT_name symbol_needs_eval.c
+ DW_AT_comp_dir /tmp
} {
declare_labels int_type_label
# define int type
int_type_label: DW_TAG_base_type {
- {DW_AT_name "int"}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_byte_size $int_size DW_FORM_sdata}
+ DW_AT_name "int"
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size $int_size DW_FORM_sdata
}
# add info for variable exec_mask
DW_TAG_variable {
- {DW_AT_name exec_mask}
- {DW_AT_type :$int_type_label}
- {DW_AT_location {
+ DW_AT_name exec_mask
+ DW_AT_type :$int_type_label
+ DW_AT_location [subst {
DW_OP_addr $exec_mask_var
- } SPECIAL_expr}
- {external 1 flag}
+ }] SPECIAL_expr
+ DW_AT_external 1 flag
}
# add info for subprogram main
DW_TAG_subprogram {
- {MACRO_AT_func { main }}
- {DW_AT_frame_base {
+ MACRO_AT_func { main }
+ DW_AT_frame_base [subst {
DW_OP_regx $dwarf_regnum
- } SPECIAL_expr}
+ }] SPECIAL_expr
} {
# define artificial variable a
DW_TAG_variable {
- {DW_AT_name a}
- {DW_AT_type :$int_type_label}
- {DW_AT_location {
+ DW_AT_name a
+ DW_AT_type :$int_type_label
+ DW_AT_location [subst {
DW_OP_lit1
DW_OP_addr $exec_mask_var
DW_OP_deref_size $int_size
@@ -112,8 +112,8 @@ Dwarf::assemble $asm_file {
# conditional jump to DW_OP_drop
DW_OP_bra -9
DW_OP_stack_value
- } SPECIAL_expr}
- {external 1 flag}
+ }] SPECIAL_expr
+ DW_AT_external 1 flag
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/symtab-producer.exp b/gdb/testsuite/gdb.dwarf2/symtab-producer.exp
index 1734a77..2826ba7 100644
--- a/gdb/testsuite/gdb.dwarf2/symtab-producer.exp
+++ b/gdb/testsuite/gdb.dwarf2/symtab-producer.exp
@@ -26,46 +26,46 @@ set asm_file [standard_output_file $srcfile2]
Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_producer "ACME Compiler Company"}
- {DW_AT_language @DW_LANG_C}
- {DW_AT_name symtab-producer-dw.c}
- {DW_AT_comp_dir /tmp}
+ DW_AT_producer "ACME Compiler Company"
+ DW_AT_language @DW_LANG_C
+ DW_AT_name symtab-producer-dw.c
+ DW_AT_comp_dir /tmp
} {
declare_labels integer_label
integer_label: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
}
DW_TAG_variable {
- {DW_AT_name with_producer}
- {DW_AT_type :$integer_label}
- {DW_AT_external 1 flag}
- {DW_AT_const_value 42 DW_FORM_sdata}
+ DW_AT_name with_producer
+ DW_AT_type :$integer_label
+ DW_AT_external 1 flag
+ DW_AT_const_value 42 DW_FORM_sdata
}
}
}
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C}
- {DW_AT_name symtab-producer2-dw.c}
- {DW_AT_comp_dir /tmp}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name symtab-producer2-dw.c
+ DW_AT_comp_dir /tmp
} {
declare_labels integer_label
integer_label: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name integer}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name integer
}
DW_TAG_variable {
- {DW_AT_name without_producer}
- {DW_AT_type :$integer_label}
- {DW_AT_external 1 flag}
- {DW_AT_const_value 43 DW_FORM_sdata}
+ DW_AT_name without_producer
+ DW_AT_type :$integer_label
+ DW_AT_external 1 flag
+ DW_AT_const_value 43 DW_FORM_sdata
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/template-specification-full-name.exp b/gdb/testsuite/gdb.dwarf2/template-specification-full-name.exp
index 60b49a5..52d9b32 100644
--- a/gdb/testsuite/gdb.dwarf2/template-specification-full-name.exp
+++ b/gdb/testsuite/gdb.dwarf2/template-specification-full-name.exp
@@ -35,19 +35,19 @@ Dwarf::assemble $asm_file {
cu { label cu_start } {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C_plus_plus}
+ DW_AT_language @DW_LANG_C_plus_plus
} {
declare_labels templated_subprogram int
int: DW_TAG_base_type {
- {DW_AT_name "int"}
- {DW_AT_byte_size 4 DW_FORM_data1}
- {DW_AT_encoding @DW_ATE_signed}
+ DW_AT_name "int"
+ DW_AT_byte_size 4 DW_FORM_data1
+ DW_AT_encoding @DW_ATE_signed
}
# The templated subprogram.
templated_subprogram: DW_TAG_subprogram {
- {DW_AT_name "apply"}
+ DW_AT_name "apply"
}
# The template specialization.
@@ -55,12 +55,12 @@ Dwarf::assemble $asm_file {
# The low and high PC are phony: we just need an address range that
# is valid in the program, so we use the main function's range.
DW_TAG_subprogram {
- {DW_AT_specification :$templated_subprogram}
- {MACRO_AT_range main}
+ DW_AT_specification :$templated_subprogram
+ MACRO_AT_range main
} {
DW_TAG_template_type_param {
- {DW_AT_name "T"}
- {DW_AT_type :$int DW_FORM_ref4}
+ DW_AT_name "T"
+ DW_AT_type :$int DW_FORM_ref4
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/typeddwarf.exp b/gdb/testsuite/gdb.dwarf2/typeddwarf.exp
index 1135709..b80ce97 100644
--- a/gdb/testsuite/gdb.dwarf2/typeddwarf.exp
+++ b/gdb/testsuite/gdb.dwarf2/typeddwarf.exp
@@ -78,7 +78,7 @@ proc scan_gdb_tests {} {
continue
}
- eval $test_cmd
+ {*}$test_cmd
}
close $fd
}
diff --git a/gdb/testsuite/gdb.dwarf2/typedef-void-finish.exp b/gdb/testsuite/gdb.dwarf2/typedef-void-finish.exp
index e59286d..a96c1ac 100644
--- a/gdb/testsuite/gdb.dwarf2/typedef-void-finish.exp
+++ b/gdb/testsuite/gdb.dwarf2/typedef-void-finish.exp
@@ -31,29 +31,29 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_producer "GNU C 8.1"}
- {DW_AT_language @DW_LANG_C}
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir /tmp}
- } {
+ DW_AT_producer "GNU C 8.1"
+ DW_AT_language @DW_LANG_C
+ DW_AT_name $srcfile
+ DW_AT_comp_dir /tmp
+ } {
declare_labels main_type void_typedef
main_type: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
}
void_typedef: DW_TAG_typedef {
- {name foo}
+ DW_AT_name foo
}
- DW_TAG_subprogram {
- {MACRO_AT_func {func}}
- {type :$void_typedef}
+ DW_TAG_subprogram {
+ MACRO_AT_func {func}
+ DW_AT_type :$void_typedef
}
- DW_TAG_subprogram {
- {MACRO_AT_func {main}}
- {type :$main_type}
+ DW_TAG_subprogram {
+ MACRO_AT_func {main}
+ DW_AT_type :$main_type
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/utf-rust.exp b/gdb/testsuite/gdb.dwarf2/utf-rust.exp
index 3380f8d..9ab9bf5 100644
--- a/gdb/testsuite/gdb.dwarf2/utf-rust.exp
+++ b/gdb/testsuite/gdb.dwarf2/utf-rust.exp
@@ -34,19 +34,19 @@ Dwarf::assemble $asm_file {
# both 32- and 64-bit machines.
cu { addr_size 4 } {
compile_unit {
- {name file1.txt}
- {language @DW_LANG_Rust}
+ DW_AT_name file1.txt
+ DW_AT_language @DW_LANG_Rust
} {
- char_label: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_UTF}
- {DW_AT_name char}
- }
+ char_label: DW_TAG_base_type {
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_UTF
+ DW_AT_name char
+ }
DW_TAG_variable {
- {name cvalue}
- {type :$char_label}
- {const_value 97 DW_FORM_udata}
+ DW_AT_name cvalue
+ DW_AT_type :$char_label
+ DW_AT_const_value 97 DW_FORM_udata
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/var-access.exp b/gdb/testsuite/gdb.dwarf2/var-access.exp
index 347d276..6889cc2 100644
--- a/gdb/testsuite/gdb.dwarf2/var-access.exp
+++ b/gdb/testsuite/gdb.dwarf2/var-access.exp
@@ -54,8 +54,8 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir /tmp}
+ DW_AT_name $srcfile
+ DW_AT_comp_dir /tmp
} {
declare_labels char_type_label
declare_labels int_type_label short_type_label
@@ -64,131 +64,131 @@ Dwarf::assemble $asm_file {
# char
char_type_label: base_type {
- {name "char"}
- {encoding @DW_ATE_unsigned_char}
- {byte_size 1 DW_FORM_sdata}
+ DW_AT_name "char"
+ DW_AT_encoding @DW_ATE_unsigned_char
+ DW_AT_byte_size 1 DW_FORM_sdata
}
# int
int_type_label: base_type {
- {name "int"}
- {encoding @DW_ATE_signed}
- {byte_size 4 DW_FORM_sdata}
+ DW_AT_name "int"
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 4 DW_FORM_sdata
}
# char [8]
array_a8_label: array_type {
- {type :$char_type_label}
+ DW_AT_type :$char_type_label
} {
subrange_type {
- {type :$int_type_label}
- {upper_bound 7 DW_FORM_udata}
+ DW_AT_type :$int_type_label
+ DW_AT_upper_bound 7 DW_FORM_udata
}
}
# struct s { char a, b, c, d; };
struct_s_label: structure_type {
- {name "s"}
- {byte_size 4 DW_FORM_sdata}
+ DW_AT_name "s"
+ DW_AT_byte_size 4 DW_FORM_sdata
} {
member {
- {name "a"}
- {type :$char_type_label}
- {data_member_location 0 DW_FORM_udata}
+ DW_AT_name "a"
+ DW_AT_type :$char_type_label
+ DW_AT_data_member_location 0 DW_FORM_udata
}
member {
- {name "b"}
- {type :$char_type_label}
- {data_member_location 1 DW_FORM_udata}
+ DW_AT_name "b"
+ DW_AT_type :$char_type_label
+ DW_AT_data_member_location 1 DW_FORM_udata
}
member {
- {name "c"}
- {type :$char_type_label}
- {data_member_location 2 DW_FORM_udata}
+ DW_AT_name "c"
+ DW_AT_type :$char_type_label
+ DW_AT_data_member_location 2 DW_FORM_udata
}
member {
- {name "d"}
- {type :$char_type_label}
- {data_member_location 3 DW_FORM_udata}
+ DW_AT_name "d"
+ DW_AT_type :$char_type_label
+ DW_AT_data_member_location 3 DW_FORM_udata
}
}
# struct t { int u, x:9, y:13, z:10; };
struct_t_label: structure_type {
- {name "t"}
- {byte_size 8 DW_FORM_sdata}
+ DW_AT_name "t"
+ DW_AT_byte_size 8 DW_FORM_sdata
} {
member {
- {name "u"}
- {type :$int_type_label}
+ DW_AT_name "u"
+ DW_AT_type :$int_type_label
}
member {
- {name "x"}
- {type :$int_type_label}
- {data_member_location 4 DW_FORM_udata}
- {bit_size 9 DW_FORM_udata}
+ DW_AT_name "x"
+ DW_AT_type :$int_type_label
+ DW_AT_data_member_location 4 DW_FORM_udata
+ DW_AT_bit_size 9 DW_FORM_udata
}
member {
- {name "y"}
- {type :$int_type_label}
- {data_bit_offset 41 DW_FORM_udata}
- {bit_size 13 DW_FORM_udata}
+ DW_AT_name "y"
+ DW_AT_type :$int_type_label
+ DW_AT_data_bit_offset 41 DW_FORM_udata
+ DW_AT_bit_size 13 DW_FORM_udata
}
member {
- {name "z"}
- {type :$int_type_label}
- {data_bit_offset 54 DW_FORM_udata}
- {bit_size 10 DW_FORM_udata}
+ DW_AT_name "z"
+ DW_AT_type :$int_type_label
+ DW_AT_data_bit_offset 54 DW_FORM_udata
+ DW_AT_bit_size 10 DW_FORM_udata
}
}
# struct st { struct s s; struct t t; };
struct_st_label: structure_type {
- {name "st"}
- {byte_size 12 DW_FORM_udata}
+ DW_AT_name "st"
+ DW_AT_byte_size 12 DW_FORM_udata
} {
member {
- {name "s"}
- {type :$struct_s_label}
+ DW_AT_name "s"
+ DW_AT_type :$struct_s_label
}
member {
- {name "t"}
- {type :$struct_t_label}
- {data_member_location 4 DW_FORM_udata}
+ DW_AT_name "t"
+ DW_AT_type :$struct_t_label
+ DW_AT_data_member_location 4 DW_FORM_udata
}
}
DW_TAG_subprogram {
- {MACRO_AT_func { main }}
- {DW_AT_external 1 flag}
+ MACRO_AT_func { main }
+ DW_AT_external 1 flag
} {
# Simple memory location.
DW_TAG_variable {
- {name "a"}
- {type :$array_a8_label}
- {location {
+ DW_AT_name "a"
+ DW_AT_type :$array_a8_label
+ DW_AT_location [subst {
addr $buf_var
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
# Memory pieces: two bytes from &buf[2], and two bytes
# from &buf[0].
DW_TAG_variable {
- {name "s1"}
- {type :$struct_s_label}
- {location {
+ DW_AT_name "s1"
+ DW_AT_type :$struct_s_label
+ DW_AT_location [subst {
addr $buf_var
plus_uconst 2
piece 2
addr $buf_var
piece 2
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
# Register- and memory pieces: one byte each from r0,
# &buf[4], r1, and &buf[5].
DW_TAG_variable {
- {name "s2"}
- {type :$struct_s_label}
- {location {
+ DW_AT_name "s2"
+ DW_AT_type :$struct_s_label
+ DW_AT_location [subst {
regx [lindex $dwarf_regnum 0]
piece 1
addr "$buf_var + 4"
@@ -197,41 +197,41 @@ Dwarf::assemble $asm_file {
piece 1
addr "$buf_var + 5"
piece 1
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
# Memory pieces for bitfield access: 8 bytes optimized
# out, 3 bytes from &buf[3], and 1 byte from &buf[1].
DW_TAG_variable {
- {name "st1"}
- {type :$struct_st_label}
- {location {
+ DW_AT_name "st1"
+ DW_AT_type :$struct_st_label
+ DW_AT_location [subst {
piece 8
addr "$buf_var + 3"
piece 3
addr "$buf_var + 1"
piece 1
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
# Register pieces for bitfield access: 4 bytes optimized
# out, 3 bytes from r0, and 1 byte from r1.
DW_TAG_variable {
- {name "t2"}
- {type :$struct_t_label}
- {location {
+ DW_AT_name "t2"
+ DW_AT_type :$struct_t_label
+ DW_AT_location [subst {
piece 4
regx [lindex $dwarf_regnum 0]
piece 3
regx [lindex $dwarf_regnum 1]
piece 1
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
# One piece per bitfield, using piece offsets: 32 bits of
# an implicit value, 9 bits of a stack value, 13 bits of
# r0, and 10 bits of buf.
DW_TAG_variable {
- {name "t3"}
- {type :$struct_t_label}
- {location {
+ DW_AT_name "t3"
+ DW_AT_type :$struct_t_label
+ DW_AT_location [subst {
implicit_value 0x12 0x34 0x56 0x78 0x9a
bit_piece 32 4
const2s -280
@@ -241,7 +241,7 @@ Dwarf::assemble $asm_file {
bit_piece 13 14
addr $buf_var
bit_piece 10 42
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/variant.exp b/gdb/testsuite/gdb.dwarf2/variant.exp
index ce504f2..93abcbd 100644
--- a/gdb/testsuite/gdb.dwarf2/variant.exp
+++ b/gdb/testsuite/gdb.dwarf2/variant.exp
@@ -36,125 +36,125 @@ Dwarf::assemble $asm_file {
# both 32- and 64-bit machines.
cu { addr_size 4 } {
compile_unit {
- {name file1.txt}
- {language @DW_LANG_Rust}
+ DW_AT_name file1.txt
+ DW_AT_language @DW_LANG_Rust
} {
- uinteger_label: DW_TAG_base_type {
- {DW_AT_byte_size 4 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_unsigned}
- {DW_AT_name {unsigned integer}}
- }
-
- int8_label: DW_TAG_base_type {
- {DW_AT_byte_size 1 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name i8}
- }
+ uinteger_label: DW_TAG_base_type {
+ DW_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_unsigned
+ DW_AT_name {unsigned integer}
+ }
+
+ int8_label: DW_TAG_base_type {
+ DW_AT_byte_size 1 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name i8
+ }
float_label: base_type {
- {name float}
- {encoding @DW_ATE_float}
- {byte_size 4 DW_FORM_sdata}
+ DW_AT_name float
+ DW_AT_encoding @DW_ATE_float
+ DW_AT_byte_size 4 DW_FORM_sdata
}
one_label: structure_type {
- {name One}
- {byte_size 4 DW_FORM_sdata}
+ DW_AT_name One
+ DW_AT_byte_size 4 DW_FORM_sdata
} {
member {
- {name __0}
- {type :$uinteger_label}
- {data_member_location 0 data1}
+ DW_AT_name __0
+ DW_AT_type :$uinteger_label
+ DW_AT_data_member_location 0 data1
}
}
two_label: structure_type {
- {name Two}
- {byte_size 4 DW_FORM_sdata}
+ DW_AT_name Two
+ DW_AT_byte_size 4 DW_FORM_sdata
} {
member {
- {name __0}
- {type :$float_label}
- {data_member_location 0 data1}
+ DW_AT_name __0
+ DW_AT_type :$float_label
+ DW_AT_data_member_location 0 data1
}
}
structure_type {
- {name Simple}
- {byte_size 8 DW_FORM_sdata}
+ DW_AT_name Simple
+ DW_AT_byte_size 8 DW_FORM_sdata
} {
variant_part {
- {discr :$discr_1_label DW_FORM_ref4}
+ DW_AT_discr :$discr_1_label DW_FORM_ref4
} {
discr_1_label: member {
- {type :$uinteger_label}
- {data_member_location 0 data1}
- {artificial 1 DW_FORM_flag_present}
+ DW_AT_type :$uinteger_label
+ DW_AT_data_member_location 0 data1
+ DW_AT_artificial 1 DW_FORM_flag_present
}
variant {
- {discr_value 23 udata}
+ DW_AT_discr_value 23 udata
} {
member {
- {type :$one_label}
- {data_member_location 4 data1}
+ DW_AT_type :$one_label
+ DW_AT_data_member_location 4 data1
}
}
variant {
- {discr_value 1 udata}
+ DW_AT_discr_value 1 udata
} {
member {
- {type :$two_label}
- {data_member_location 4 data1}
+ DW_AT_type :$two_label
+ DW_AT_data_member_location 4 data1
}
}
}
}
structure_type {
- {name Defaulted}
- {byte_size 8 DW_FORM_sdata}
+ DW_AT_name Defaulted
+ DW_AT_byte_size 8 DW_FORM_sdata
} {
variant_part {
- {discr :$discr_2_label DW_FORM_ref4}
+ DW_AT_discr :$discr_2_label DW_FORM_ref4
} {
discr_2_label: member {
- {type :$uinteger_label}
- {data_member_location 0 data1}
- {artificial 1 DW_FORM_flag_present}
+ DW_AT_type :$uinteger_label
+ DW_AT_data_member_location 0 data1
+ DW_AT_artificial 1 DW_FORM_flag_present
}
variant {
} {
member {
- {type :$one_label}
- {data_member_location 4 data1}
+ DW_AT_type :$one_label
+ DW_AT_data_member_location 4 data1
}
}
variant {
- {discr_value 1 udata}
+ DW_AT_discr_value 1 udata
} {
member {
- {type :$two_label}
- {data_member_location 4 data1}
+ DW_AT_type :$two_label
+ DW_AT_data_member_location 4 data1
}
}
}
}
structure_type {
- {name Univariant}
- {byte_size 8 DW_FORM_sdata}
+ DW_AT_name Univariant
+ DW_AT_byte_size 8 DW_FORM_sdata
} {
variant_part {
} {
variant {
} {
member {
- {type :$one_label}
- {data_member_location 4 data1}
+ DW_AT_type :$one_label
+ DW_AT_data_member_location 4 data1
}
}
}
@@ -163,24 +163,24 @@ Dwarf::assemble $asm_file {
# Rust won't emit a negative discriminant like this, but
# we want to test the code path anyway.
structure_type {
- {name Negative}
- {byte_size 8 DW_FORM_sdata}
+ DW_AT_name Negative
+ DW_AT_byte_size 8 DW_FORM_sdata
} {
variant_part {
- {discr :$discr_3_label DW_FORM_ref4}
+ DW_AT_discr :$discr_3_label DW_FORM_ref4
} {
discr_3_label: member {
- {type :$int8_label}
- {data_member_location 0 data1}
- {artificial 1 DW_FORM_flag_present}
+ DW_AT_type :$int8_label
+ DW_AT_data_member_location 0 data1
+ DW_AT_artificial 1 DW_FORM_flag_present
}
variant {
- {discr_value -1 sdata}
+ DW_AT_discr_value -1 sdata
} {
member {
- {type :$one_label}
- {data_member_location 4 data1}
+ DW_AT_type :$one_label
+ DW_AT_data_member_location 4 data1
}
}
@@ -190,8 +190,8 @@ Dwarf::assemble $asm_file {
variant {
} {
member {
- {type :$two_label}
- {data_member_location 4 data1}
+ DW_AT_type :$two_label
+ DW_AT_data_member_location 4 data1
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/varval.exp b/gdb/testsuite/gdb.dwarf2/varval.exp
index 6846ecb..8f132bb 100644
--- a/gdb/testsuite/gdb.dwarf2/varval.exp
+++ b/gdb/testsuite/gdb.dwarf2/varval.exp
@@ -50,7 +50,7 @@ proc setup_exec { arg_bad } {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_language @DW_LANG_C_plus_plus}
+ DW_AT_language @DW_LANG_C_plus_plus
} {
declare_labels int_label ptr_label struct_label var_a_label \
var_b_label var_c_label var_p_label var_bad_label \
@@ -61,179 +61,193 @@ proc setup_exec { arg_bad } {
int_label: DW_TAG_base_type {
- {DW_AT_byte_size ${int_size} DW_FORM_udata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name "int"}
+ DW_AT_byte_size ${int_size} DW_FORM_udata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name "int"
}
ptr_label: DW_TAG_pointer_type {
- {DW_AT_type :$int_label}
+ DW_AT_type :$int_label
}
var_a_label: DW_TAG_variable {
- {DW_AT_name "var_a"}
- {DW_AT_type :${int_label}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_a"]} SPECIAL_expr}
+ DW_AT_name "var_a"
+ DW_AT_type :${int_label}
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "var_a"]
+ }] SPECIAL_expr
}
var_a_abstract_label: DW_TAG_variable {
- {DW_AT_type :${int_label}}
- {DW_AT_external 1 DW_FORM_flag}
+ DW_AT_type :${int_label}
+ DW_AT_external 1 DW_FORM_flag
}
var_b_label: DW_TAG_variable {
- {DW_AT_name "var_b"}
- {DW_AT_type :${int_label}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_b"]} SPECIAL_expr}
+ DW_AT_name "var_b"
+ DW_AT_type :${int_label}
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "var_b"]
+ }] SPECIAL_expr
}
var_c_label: DW_TAG_variable {
- {DW_AT_name "var_c"}
- {DW_AT_type :${int_label}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_const_value 53 DW_FORM_sdata}
+ DW_AT_name "var_c"
+ DW_AT_type :${int_label}
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_const_value 53 DW_FORM_sdata
}
var_p_label: DW_TAG_variable {
- {DW_AT_name "var_p"}
- {DW_AT_type :${ptr_label}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_p"]} SPECIAL_expr}
+ DW_AT_name "var_p"
+ DW_AT_type :${ptr_label}
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "var_p"]
+ }] SPECIAL_expr
}
if { $bad } {
var_bad_label: DW_TAG_variable {
- {DW_AT_name "var_bad"}
- {DW_AT_type :${int_label}}
- {DW_AT_external 1 DW_FORM_flag}
+ DW_AT_name "var_bad"
+ DW_AT_type :${int_label}
+ DW_AT_external 1 DW_FORM_flag
}
}
struct_label: DW_TAG_structure_type {
- {DW_AT_byte_size 8*$int_size DW_FORM_sdata}
+ DW_AT_byte_size 8*$int_size DW_FORM_sdata
} {
DW_TAG_member {
- {DW_AT_name "a"}
- {DW_AT_type :$int_label}
- {DW_AT_data_member_location 0*$int_size DW_FORM_udata}
+ DW_AT_name "a"
+ DW_AT_type :$int_label
+ DW_AT_data_member_location 0*$int_size DW_FORM_udata
}
DW_TAG_member {
- {DW_AT_name "b"}
- {DW_AT_type :$int_label}
- {DW_AT_data_member_location 1*$int_size DW_FORM_udata}
+ DW_AT_name "b"
+ DW_AT_type :$int_label
+ DW_AT_data_member_location 1*$int_size DW_FORM_udata
}
DW_TAG_member {
- {DW_AT_name "c"}
- {DW_AT_type :$int_label}
- {DW_AT_data_member_location 2*$int_size DW_FORM_udata}
+ DW_AT_name "c"
+ DW_AT_type :$int_label
+ DW_AT_data_member_location 2*$int_size DW_FORM_udata
}
DW_TAG_member {
- {DW_AT_name "d"}
- {DW_AT_type :$int_label}
- {DW_AT_data_member_location 3*$int_size DW_FORM_udata}
+ DW_AT_name "d"
+ DW_AT_type :$int_label
+ DW_AT_data_member_location 3*$int_size DW_FORM_udata
}
DW_TAG_member {
- {DW_AT_name "e"}
- {DW_AT_type :$int_label}
- {DW_AT_data_member_location 4*$int_size DW_FORM_udata}
+ DW_AT_name "e"
+ DW_AT_type :$int_label
+ DW_AT_data_member_location 4*$int_size DW_FORM_udata
}
DW_TAG_member {
- {DW_AT_name "f"}
- {DW_AT_type :$int_label}
- {DW_AT_data_member_location 5*$int_size DW_FORM_udata}
+ DW_AT_name "f"
+ DW_AT_type :$int_label
+ DW_AT_data_member_location 5*$int_size DW_FORM_udata
}
DW_TAG_member {
- {DW_AT_name "g"}
- {DW_AT_type :$int_label}
- {DW_AT_data_member_location 6*$int_size DW_FORM_udata}
+ DW_AT_name "g"
+ DW_AT_type :$int_label
+ DW_AT_data_member_location 6*$int_size DW_FORM_udata
}
DW_TAG_member {
- {DW_AT_name "h"}
- {DW_AT_type :$int_label}
- {DW_AT_data_member_location 7*$int_size DW_FORM_udata}
+ DW_AT_name "h"
+ DW_AT_type :$int_label
+ DW_AT_data_member_location 7*$int_size DW_FORM_udata
}
}
var_s_label: DW_TAG_variable {
- {DW_AT_name "var_s"}
- {DW_AT_type :${struct_label}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_s"]} SPECIAL_expr}
+ DW_AT_name "var_s"
+ DW_AT_type :${struct_label}
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "var_s"]
+ }] SPECIAL_expr
}
var_untyped_label: DW_TAG_variable {
- {DW_AT_name "var_untyped"}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_b"]} SPECIAL_expr}
+ DW_AT_name "var_untyped"
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "var_b"]
+ }] SPECIAL_expr
}
int_array_label: DW_TAG_array_type {
- {DW_AT_type :${int_label}}
+ DW_AT_type :${int_label}
} {
DW_TAG_subrange_type {}
}
varval3_decl_label: DW_TAG_variable {
- {DW_AT_name "varval3"}
- {DW_AT_type :${int_array_label}}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_declaration 1 DW_FORM_flag}
+ DW_AT_name "varval3"
+ DW_AT_type :${int_array_label}
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_declaration 1 DW_FORM_flag
}
int_array_of_1_label: DW_TAG_array_type {
- {DW_AT_type :${int_label}}
+ DW_AT_type :${int_label}
} {
DW_TAG_subrange_type {
- {DW_AT_type :$int_label}
- {DW_AT_upper_bound 0 DW_FORM_data1}
+ DW_AT_type :$int_label
+ DW_AT_upper_bound 0 DW_FORM_data1
}
}
varval3_def_label: DW_TAG_variable {
- {DW_AT_name "varval3"}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_type :${int_array_of_1_label}}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_a"]} SPECIAL_expr}
+ DW_AT_name "varval3"
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_type :${int_array_of_1_label}
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "var_a"]
+ }] SPECIAL_expr
}
DW_TAG_subprogram {
- {MACRO_AT_func { "main" }}
- {DW_AT_type :${int_label}}
- {DW_AT_external 1 DW_FORM_flag}
+ MACRO_AT_func { "main" }
+ DW_AT_type :${int_label}
+ DW_AT_external 1 DW_FORM_flag
} {
varval_label: DW_TAG_variable {
- {DW_AT_name "varval"}
- {DW_AT_type :${int_label}}
- {DW_AT_location {
+ DW_AT_name "varval"
+ DW_AT_type :${int_label}
+ DW_AT_location [subst {
DW_OP_GNU_variable_value ${var_a_label}
DW_OP_const1s 0
DW_OP_or
DW_OP_stack_value
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
varval2_label: DW_TAG_variable {
- {DW_AT_name "varval2"}
- {DW_AT_type :${int_label}}
- {DW_AT_location {
+ DW_AT_name "varval2"
+ DW_AT_type :${int_label}
+ DW_AT_location [subst {
DW_OP_GNU_variable_value ${var_a_abstract_label}
DW_OP_stack_value
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
var_a_concrete_label: DW_TAG_variable {
- {DW_AT_abstract_origin :${var_a_abstract_label}}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_a"]} SPECIAL_expr}
+ DW_AT_abstract_origin :${var_a_abstract_label}
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "var_a"]
+ }] SPECIAL_expr
}
DW_TAG_variable {
- {DW_AT_name "constval"}
- {DW_AT_type :${int_label}}
- {DW_AT_location {
+ DW_AT_name "constval"
+ DW_AT_type :${int_label}
+ DW_AT_location [subst {
DW_OP_GNU_variable_value ${var_c_label}
DW_OP_stack_value
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
DW_TAG_variable {
- {DW_AT_name "mixedval"}
- {DW_AT_type :${int_label}}
- {DW_AT_location {
+ DW_AT_name "mixedval"
+ DW_AT_type :${int_label}
+ DW_AT_location [subst {
DW_OP_GNU_variable_value ${var_c_label}
DW_OP_GNU_variable_value ${var_b_label}
DW_OP_div
@@ -244,55 +258,55 @@ proc setup_exec { arg_bad } {
DW_OP_GNU_variable_value ${varval_label}
DW_OP_minus
DW_OP_stack_value
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
DW_TAG_variable {
- {DW_AT_name "pointerval"}
- {DW_AT_type :${ptr_label}}
- {DW_AT_location {
+ DW_AT_name "pointerval"
+ DW_AT_type :${ptr_label}
+ DW_AT_location [subst {
DW_OP_GNU_variable_value ${var_p_label}
DW_OP_stack_value
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
if { $bad } {
DW_TAG_variable {
- {DW_AT_name "badval"}
- {DW_AT_type :${int_label}}
- {DW_AT_location {
+ DW_AT_name "badval"
+ DW_AT_type :${int_label}
+ DW_AT_location [subst {
DW_OP_GNU_variable_value ${var_bad_label}
DW_OP_stack_value
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
}
DW_TAG_variable {
- {DW_AT_name "structval"}
- {DW_AT_type :${struct_label}}
- {DW_AT_location {
+ DW_AT_name "structval"
+ DW_AT_type :${struct_label}
+ DW_AT_location [subst {
DW_OP_GNU_variable_value ${var_s_label}
DW_OP_stack_value
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
DW_TAG_variable {
- {DW_AT_name "untypedval"}
- {DW_AT_location {
+ DW_AT_name "untypedval"
+ DW_AT_location [subst {
DW_OP_GNU_variable_value ${var_untyped_label}
DW_OP_stack_value
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
if { $bad } {
DW_TAG_variable {
- {DW_AT_name "bad_die_val1"}
- {DW_AT_location {
+ DW_AT_name "bad_die_val1"
+ DW_AT_location {
DW_OP_GNU_variable_value 0xabcdef11
DW_OP_stack_value
- } SPECIAL_expr}
+ } SPECIAL_expr
}
DW_TAG_variable {
- {DW_AT_name "bad_die_val2"}
- {DW_AT_location {
+ DW_AT_name "bad_die_val2"
+ DW_AT_location [subst {
DW_OP_GNU_variable_value ${ptr_label}+1
DW_OP_stack_value
- } SPECIAL_expr}
+ }] SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.dwarf2/void-type.exp b/gdb/testsuite/gdb.dwarf2/void-type.exp
index 64bebe1..10f5738 100644
--- a/gdb/testsuite/gdb.dwarf2/void-type.exp
+++ b/gdb/testsuite/gdb.dwarf2/void-type.exp
@@ -38,50 +38,54 @@ Dwarf::assemble $asm_file {
cu {} {
DW_TAG_compile_unit {
- {DW_AT_producer "Intel(R) C Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.5.212 Build 20150212"}
- {DW_AT_language @DW_LANG_C}
- {DW_AT_name $srcfile}
- {DW_AT_comp_dir /tmp}
- } {
+ DW_AT_producer "Intel(R) C Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.5.212 Build 20150212"
+ DW_AT_language @DW_LANG_C
+ DW_AT_name $srcfile
+ DW_AT_comp_dir /tmp
+ } {
declare_labels int_type void_type ptr_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_AT_byte_size 4 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name int
}
void_type: DW_TAG_base_type {
- {DW_AT_byte_size 0 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name void}
+ DW_AT_byte_size 0 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name void
}
ptr_type: DW_TAG_pointer_type {
- {DW_AT_type :$void_type}
+ DW_AT_type :$void_type
}
- DW_TAG_subprogram {
- {MACRO_AT_func {func}}
- {type :$void_type}
+ DW_TAG_subprogram {
+ MACRO_AT_func {func}
+ DW_AT_type :$void_type
}
- DW_TAG_subprogram {
- {MACRO_AT_func {main}}
- {type :$int_type}
+ DW_TAG_subprogram {
+ MACRO_AT_func {main}
+ DW_AT_type :$int_type
}
DW_TAG_variable {
- {DW_AT_name "var_a"}
- {DW_AT_type :$int_type}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_a"]} SPECIAL_expr}
+ DW_AT_name "var_a"
+ DW_AT_type :$int_type
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "var_a"]
+ }] SPECIAL_expr
}
DW_TAG_variable {
- {DW_AT_name "var_ptr"}
- {DW_AT_type :$ptr_type}
- {DW_AT_external 1 DW_FORM_flag}
- {DW_AT_location {DW_OP_addr [gdb_target_symbol "var_ptr"]} SPECIAL_expr}
+ DW_AT_name "var_ptr"
+ DW_AT_type :$ptr_type
+ DW_AT_external 1 DW_FORM_flag
+ DW_AT_location [subst {
+ DW_OP_addr [gdb_target_symbol "var_ptr"]
+ }] SPECIAL_expr
}
}
}
diff --git a/gdb/testsuite/gdb.fortran/allocated.exp b/gdb/testsuite/gdb.fortran/allocated.exp
index a000b6e..7cf1367 100644
--- a/gdb/testsuite/gdb.fortran/allocated.exp
+++ b/gdb/testsuite/gdb.fortran/allocated.exp
@@ -25,7 +25,7 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/array-bounds.exp b/gdb/testsuite/gdb.fortran/array-bounds.exp
index fb8ee86..9efd95f 100644
--- a/gdb/testsuite/gdb.fortran/array-bounds.exp
+++ b/gdb/testsuite/gdb.fortran/array-bounds.exp
@@ -34,8 +34,8 @@ if {![fortran_runto_main]} {
# GCC outputs incorrect range debug info for -m32, gcc PR debug/54934.
set expect_xfail \
[expr \
- [test_compiler_info {gfortran-*} f90] \
- && [is_ilp32_target]]
+ {[test_compiler_info {gfortran-*} f90]
+ && [is_ilp32_target]}]
set re_ok [string_to_regexp (4294967296:4294967297)]
set re_xfail [string_to_regexp (0:1)]
diff --git a/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp b/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp
index 8c19c85..72c7c5e 100644
--- a/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp
+++ b/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp
@@ -25,7 +25,7 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
@@ -53,7 +53,7 @@ gdb_test_multiple $cmd $cmd {
# slice.
for { set j 1 } { $j < 6 } { incr j } {
for { set i 1 } { $i < 6 } { incr i } {
- set val [expr ((($i - 1) * 2) + (($j - 1) * 20)) + 1]
+ set val [expr {((($i - 1) * 2) + (($j - 1) * 20)) + 1}]
gdb_test "print ${varname} ($i,$j)" " = $val"
}
}
@@ -106,7 +106,7 @@ gdb_test "print str (26:1:-2)" " = 'zxvtrpnljhfdb'"
# existing value in memory.
gdb_test_no_output "set fortran repack-array-slices on"
set element_size [get_integer_valueof "sizeof (array (1,1))" "unknown"]
-set slice_size [expr $element_size * 4]
+set slice_size [expr {$element_size * 4}]
gdb_test_no_output "set max-value-size $slice_size"
gdb_test "print array (1:2, 1:2)" "= \\(\\(1, 2\\) \\(11, 12\\)\\)"
gdb_test "print array (2:3, 2:3)" "= \\(\\(12, 13\\) \\(22, 23\\)\\)"
diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp b/gdb/testsuite/gdb.fortran/array-slices.exp
index b1e3dad..7d4f96e 100644
--- a/gdb/testsuite/gdb.fortran/array-slices.exp
+++ b/gdb/testsuite/gdb.fortran/array-slices.exp
@@ -56,9 +56,9 @@ proc array_slice_to_var { slice_str } {
proc run_test { repack } {
global binfile gdb_prompt
- clean_restart ${binfile}
+ clean_restart ${::testfile}
- if ![fortran_runto_main] {
+ if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/associated.exp b/gdb/testsuite/gdb.fortran/associated.exp
index c900ce7..9297220 100644
--- a/gdb/testsuite/gdb.fortran/associated.exp
+++ b/gdb/testsuite/gdb.fortran/associated.exp
@@ -25,7 +25,7 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/assumedrank.exp b/gdb/testsuite/gdb.fortran/assumedrank.exp
index 159608f..45e8c09 100644
--- a/gdb/testsuite/gdb.fortran/assumedrank.exp
+++ b/gdb/testsuite/gdb.fortran/assumedrank.exp
@@ -32,7 +32,7 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
untested "could not run to main"
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/call-no-debug.exp b/gdb/testsuite/gdb.fortran/call-no-debug.exp
index 1b158c4..96ccdd7 100644
--- a/gdb/testsuite/gdb.fortran/call-no-debug.exp
+++ b/gdb/testsuite/gdb.fortran/call-no-debug.exp
@@ -22,7 +22,7 @@ standard_testfile call-no-debug-prog.f90 call-no-debug-func.f90
load_lib fortran.exp
if {[prepare_for_testing_full "failed to prepare" \
- [list ${binfile} [list debug f90] \
+ [list $testfile [list debug f90] \
$srcfile [list debug f90] \
$srcfile2 [list nodebug f90]]]} {
return -1
@@ -67,7 +67,7 @@ proc find_mangled_name { name } {
set some_func [find_mangled_name "some_func"]
set string_func [find_mangled_name "string_func"]
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/charset.exp b/gdb/testsuite/gdb.fortran/charset.exp
index 0f5ee3d..cd117d4 100644
--- a/gdb/testsuite/gdb.fortran/charset.exp
+++ b/gdb/testsuite/gdb.fortran/charset.exp
@@ -30,7 +30,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug addi
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.fortran/class-allocatable-array.exp b/gdb/testsuite/gdb.fortran/class-allocatable-array.exp
index 241cc83..d860b2c 100644
--- a/gdb/testsuite/gdb.fortran/class-allocatable-array.exp
+++ b/gdb/testsuite/gdb.fortran/class-allocatable-array.exp
@@ -26,7 +26,7 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/common-block.exp b/gdb/testsuite/gdb.fortran/common-block.exp
index 6f3e55d..f27f3ad 100644
--- a/gdb/testsuite/gdb.fortran/common-block.exp
+++ b/gdb/testsuite/gdb.fortran/common-block.exp
@@ -4,12 +4,12 @@
# 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/>.
diff --git a/gdb/testsuite/gdb.fortran/completion.exp b/gdb/testsuite/gdb.fortran/completion.exp
index 0961207..5038251 100644
--- a/gdb/testsuite/gdb.fortran/completion.exp
+++ b/gdb/testsuite/gdb.fortran/completion.exp
@@ -26,7 +26,7 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/debug-expr.exp b/gdb/testsuite/gdb.fortran/debug-expr.exp
index 6e84b24..d872ad6 100644
--- a/gdb/testsuite/gdb.fortran/debug-expr.exp
+++ b/gdb/testsuite/gdb.fortran/debug-expr.exp
@@ -28,7 +28,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/empty-string.exp b/gdb/testsuite/gdb.fortran/empty-string.exp
index 531af45..17ee5e5 100644
--- a/gdb/testsuite/gdb.fortran/empty-string.exp
+++ b/gdb/testsuite/gdb.fortran/empty-string.exp
@@ -24,7 +24,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/exprs.exp b/gdb/testsuite/gdb.fortran/exprs.exp
index 72efb56..323a2ab 100644
--- a/gdb/testsuite/gdb.fortran/exprs.exp
+++ b/gdb/testsuite/gdb.fortran/exprs.exp
@@ -232,7 +232,7 @@ proc test_arithmetic_expressions {} {
gdb_test "p 6.0 / 3.0" " = 2" "real divided by real"
# Test exponentiation with various operands
-
+
gdb_test "p 2 ** 3" " = 8" "int powered by int"
gdb_test "p 2 ** 2 ** 3" " = 256" "combined exponentiation expression"
gdb_test "p (2 ** 2) ** 3" " = 64" "combined exponentiation expression in specified order"
diff --git a/gdb/testsuite/gdb.fortran/huge.exp b/gdb/testsuite/gdb.fortran/huge.exp
index 35bc6c8..f7c50d7 100644
--- a/gdb/testsuite/gdb.fortran/huge.exp
+++ b/gdb/testsuite/gdb.fortran/huge.exp
@@ -27,7 +27,7 @@ load_lib fortran.exp
standard_testfile .F90
-set max [expr 2 * 1024 * 1024]
+set max [expr {2 * 1024 * 1024}]
set min 16
set opts {}
@@ -35,7 +35,7 @@ lappend opts debug
lappend opts f90
set compilation_succeeded 0
-for { set size [expr $max] } { $size >= $min } { set size [expr $size / 2] } {
+for { set size [expr {$max}] } { $size >= $min } { set size [expr {$size / 2}] } {
set try_opts [concat $opts [list additional_flags=-DCRASH_GDB=$size]]
with_test_prefix CRASH_GDB=$size {
if { [build_executable $testfile.exp $testfile $srcfile $try_opts] == -1 } {
@@ -49,7 +49,7 @@ for { set size [expr $max] } { $size >= $min } { set size [expr $size / 2] } {
require {expr $compilation_succeeded}
# Start with a fresh gdb.
-clean_restart ${binfile}
+clean_restart ${::testfile}
save_vars { timeout } {
set timeout 30
@@ -92,6 +92,6 @@ save_vars { timeout } {
unsupported $test
} else {
# At 112 passes with and without the fix, so use 111.
- gdb_assert {$space_used < [expr 111 * 4 * $size] } $test
+ gdb_assert {$space_used < [expr {111 * 4 * $size}] } $test
}
}
diff --git a/gdb/testsuite/gdb.fortran/info-main.exp b/gdb/testsuite/gdb.fortran/info-main.exp
index 4178886..6cdfd15 100644
--- a/gdb/testsuite/gdb.fortran/info-main.exp
+++ b/gdb/testsuite/gdb.fortran/info-main.exp
@@ -29,7 +29,7 @@ save_vars { GDBFLAGS } {
gdb_test "info main" "simple" "info main prior to start"
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
untested "could not run to main"
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/intrinsic-precedence.exp b/gdb/testsuite/gdb.fortran/intrinsic-precedence.exp
index 02f5ff3..93f1da9 100644
--- a/gdb/testsuite/gdb.fortran/intrinsic-precedence.exp
+++ b/gdb/testsuite/gdb.fortran/intrinsic-precedence.exp
@@ -33,7 +33,7 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/intvar-array.exp b/gdb/testsuite/gdb.fortran/intvar-array.exp
index 68b674c..52314ed 100644
--- a/gdb/testsuite/gdb.fortran/intvar-array.exp
+++ b/gdb/testsuite/gdb.fortran/intvar-array.exp
@@ -25,7 +25,7 @@ if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/intvar-dynamic-types.exp b/gdb/testsuite/gdb.fortran/intvar-dynamic-types.exp
index b28bf5c..201f020 100644
--- a/gdb/testsuite/gdb.fortran/intvar-dynamic-types.exp
+++ b/gdb/testsuite/gdb.fortran/intvar-dynamic-types.exp
@@ -24,7 +24,7 @@ if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/lbound-ubound.exp b/gdb/testsuite/gdb.fortran/lbound-ubound.exp
index f8e256c..143c5be 100644
--- a/gdb/testsuite/gdb.fortran/lbound-ubound.exp
+++ b/gdb/testsuite/gdb.fortran/lbound-ubound.exp
@@ -25,7 +25,7 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
@@ -160,7 +160,7 @@ while { $test_count < 500 } {
# Finally, check that asking for a dimension above the valid
# range gives the expected error.
- set bad_dim [expr $upper_dim + 1]
+ set bad_dim [expr {$upper_dim + 1}]
gdb_test "p lbound ($array_name, $bad_dim)" \
"LBOUND dimension must be from 1 to $upper_dim" \
"check error message for lbound of dim = $bad_dim"
diff --git a/gdb/testsuite/gdb.fortran/library-module.exp b/gdb/testsuite/gdb.fortran/library-module.exp
index ec35ef1..07867ee 100644
--- a/gdb/testsuite/gdb.fortran/library-module.exp
+++ b/gdb/testsuite/gdb.fortran/library-module.exp
@@ -17,7 +17,7 @@ load_lib fortran.exp
require allow_fortran_tests
-standard_testfile library-module-main.f90
+standard_testfile library-module-main.f90
set srclibfile ${testfile}-lib.f90
set libfile [standard_output_file ${testfile}-lib.so]
diff --git a/gdb/testsuite/gdb.fortran/limited-length.exp b/gdb/testsuite/gdb.fortran/limited-length.exp
index 38c5286..9c65d48 100644
--- a/gdb/testsuite/gdb.fortran/limited-length.exp
+++ b/gdb/testsuite/gdb.fortran/limited-length.exp
@@ -80,7 +80,7 @@ with_test_prefix "with standard max-value size" {
# Set the max-value-size so we can only print 50 elements.
set elements 50
set elem_size [get_valueof "/d" "sizeof(large_1d_array(1))" "*unknown*"]
-gdb_test_no_output "set max-value-size [expr $elem_size * $elements]"
+gdb_test_no_output "set max-value-size [expr {$elem_size * $elements}]"
with_test_prefix "with reduced max-value size" {
gdb_test "print large_4d_array" \
diff --git a/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp b/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp
index ac8f742..e3b9fb5 100644
--- a/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp
+++ b/gdb/testsuite/gdb.fortran/mixed-lang-stack.exp
@@ -28,7 +28,7 @@ require allow_fortran_tests
standard_testfile mixed-lang-stack.c mixed-lang-stack.cpp mixed-lang-stack.f90
if {[prepare_for_testing_full "failed to prepare" \
- [list ${binfile} {debug f90 additional_flags=-lstdc++} \
+ [list $testfile {debug f90 additional_flags=-lstdc++} \
$srcfile {debug} \
$srcfile2 {debug c++ additional_flags=-std=c++11} \
$srcfile3 {debug f90}]]} {
@@ -43,9 +43,9 @@ proc run_tests { lang } {
with_test_prefix "lang=${lang}" {
global binfile hex have_index
- clean_restart ${binfile}
+ clean_restart ${::testfile}
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/module.exp b/gdb/testsuite/gdb.fortran/module.exp
index 30988a2..2496f66 100644
--- a/gdb/testsuite/gdb.fortran/module.exp
+++ b/gdb/testsuite/gdb.fortran/module.exp
@@ -25,7 +25,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}] }
# Test automatic language detection before the inferior starts. It tests the
# effect of expected:
-# (gdb) show language
+# (gdb) show language
# The current source language is "auto; currently fortran".
gdb_test "p modmany::var_i" " = 14" "stopped language detection"
@@ -131,6 +131,6 @@ gdb_test "show language" {The current source language is "(auto; currently )?for
# gcc-4.4.2: The main program is always $fmain in .symtab so "runto" above
# works. But DWARF DW_TAG_subprogram contains the name specified by
# the "program" Fortran statement.
-if [gdb_breakpoint "module"] {
+if {[gdb_breakpoint "module"]} {
pass "setting breakpoint at module"
}
diff --git a/gdb/testsuite/gdb.fortran/multi-dim.exp b/gdb/testsuite/gdb.fortran/multi-dim.exp
index efd225a..0a719fe 100644
--- a/gdb/testsuite/gdb.fortran/multi-dim.exp
+++ b/gdb/testsuite/gdb.fortran/multi-dim.exp
@@ -25,7 +25,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug f90}
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.fortran/namelist.exp b/gdb/testsuite/gdb.fortran/namelist.exp
index 10846cf..fce6314 100644
--- a/gdb/testsuite/gdb.fortran/namelist.exp
+++ b/gdb/testsuite/gdb.fortran/namelist.exp
@@ -38,8 +38,8 @@ gdb_continue_to_breakpoint "Display namelist"
# DW_TAG_namelist is supported starting gcc 4.9.
set supported [expr \
- [test_compiler_info {gfortran-*} f90] \
- && [gcc_major_version {gfortran-*} f90] >= 4.9]
+ {[test_compiler_info {gfortran-*} f90]
+ && [gcc_major_version {gfortran-*} f90] >= 4.9}]
if { $supported } {
gdb_test "ptype nml" \
"type = Type nml\r\n *$int :: a\r\n *$int :: b\r\n *End Type nml"
diff --git a/gdb/testsuite/gdb.fortran/nested-funcs.exp b/gdb/testsuite/gdb.fortran/nested-funcs.exp
index 63917c5..c92a8c1 100755
--- a/gdb/testsuite/gdb.fortran/nested-funcs.exp
+++ b/gdb/testsuite/gdb.fortran/nested-funcs.exp
@@ -14,7 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This testcase is supposed to test DWARF static link which is usually
-# used together with nested functions.
+# used together with nested functions.
require allow_fortran_tests
diff --git a/gdb/testsuite/gdb.fortran/oop_extend_type.exp b/gdb/testsuite/gdb.fortran/oop_extend_type.exp
index f2e64e9..9f443d9 100755
--- a/gdb/testsuite/gdb.fortran/oop_extend_type.exp
+++ b/gdb/testsuite/gdb.fortran/oop_extend_type.exp
@@ -23,7 +23,7 @@ if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
perror "could not run to main"
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/pointer-to-pointer.exp b/gdb/testsuite/gdb.fortran/pointer-to-pointer.exp
index 9920616..47ca74a 100644
--- a/gdb/testsuite/gdb.fortran/pointer-to-pointer.exp
+++ b/gdb/testsuite/gdb.fortran/pointer-to-pointer.exp
@@ -25,7 +25,7 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/print_type.exp b/gdb/testsuite/gdb.fortran/print_type.exp
index c08f501..6d2457f 100755
--- a/gdb/testsuite/gdb.fortran/print_type.exp
+++ b/gdb/testsuite/gdb.fortran/print_type.exp
@@ -26,7 +26,7 @@ if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/rank.exp b/gdb/testsuite/gdb.fortran/rank.exp
index c61ae98..e998ead 100644
--- a/gdb/testsuite/gdb.fortran/rank.exp
+++ b/gdb/testsuite/gdb.fortran/rank.exp
@@ -25,7 +25,7 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/shape.exp b/gdb/testsuite/gdb.fortran/shape.exp
index e525bf7..7a6bc9b 100644
--- a/gdb/testsuite/gdb.fortran/shape.exp
+++ b/gdb/testsuite/gdb.fortran/shape.exp
@@ -25,7 +25,7 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/short-circuit-argument-list.exp b/gdb/testsuite/gdb.fortran/short-circuit-argument-list.exp
index bca971d..ab0411a 100644
--- a/gdb/testsuite/gdb.fortran/short-circuit-argument-list.exp
+++ b/gdb/testsuite/gdb.fortran/short-circuit-argument-list.exp
@@ -48,12 +48,12 @@ reset_called_flags
# a(x,y) .OR./.AND. a(a,b) correctly.
foreach_with_prefix truth_table_index {1 2 3 4} {
gdb_test "p truth_table($truth_table_index, 1) .OR. truth_table($truth_table_index, 2)" \
- "[expr $truth_table_index > 1 ? \".TRUE.\" : \".FALSE.\"]"
+ "[expr {$truth_table_index > 1 ? ".TRUE." : ".FALSE."}]"
}
foreach_with_prefix truth_table_index {1 2 3 4} {
gdb_test "p truth_table($truth_table_index, 1) .AND. truth_table($truth_table_index, 2)" \
- "[expr $truth_table_index > 3 ? \".TRUE.\" : \".FALSE.\"]"
+ "[expr {$truth_table_index > 3 ? ".TRUE." : ".FALSE."}]"
}
# Vary number of function arguments to skip.
@@ -78,14 +78,14 @@ with_test_prefix "nested call not skipped" {
gdb_test "p function_one_arg(.FALSE. .OR. function_no_arg())" \
" = .TRUE."
gdb_test "p calls" \
- " = \\\( function_no_arg_called = [expr $prime + 1], function_no_arg_false_called = $prime, function_one_arg_called = [expr $prime + 1], function_two_arg_called = $prime, function_array_called = $prime \\\)"
+ " = \\\( function_no_arg_called = [expr {$prime + 1}], function_no_arg_false_called = $prime, function_one_arg_called = [expr {$prime + 1}], function_two_arg_called = $prime, function_array_called = $prime \\\)"
}
with_test_prefix "nested call skipped" {
gdb_test "p function_one_arg(.TRUE. .OR. function_no_arg())" \
" = .TRUE."
gdb_test "p calls" \
- " = \\\( function_no_arg_called = [expr $prime + 1], function_no_arg_false_called = $prime, function_one_arg_called = [expr $prime + 2], function_two_arg_called = $prime, function_array_called = $prime \\\)"
+ " = \\\( function_no_arg_called = [expr {$prime + 1}], function_no_arg_false_called = $prime, function_one_arg_called = [expr {$prime + 2}], function_two_arg_called = $prime, function_array_called = $prime \\\)"
}
# Vary number of components in the expression to skip.
diff --git a/gdb/testsuite/gdb.fortran/size.exp b/gdb/testsuite/gdb.fortran/size.exp
index dd6340f..5bc7db2 100644
--- a/gdb/testsuite/gdb.fortran/size.exp
+++ b/gdb/testsuite/gdb.fortran/size.exp
@@ -25,7 +25,7 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/sizeof.exp b/gdb/testsuite/gdb.fortran/sizeof.exp
index aa22107..c0a9fd3 100644
--- a/gdb/testsuite/gdb.fortran/sizeof.exp
+++ b/gdb/testsuite/gdb.fortran/sizeof.exp
@@ -25,7 +25,7 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/types.exp b/gdb/testsuite/gdb.fortran/types.exp
index c444228..03bc2ce 100644
--- a/gdb/testsuite/gdb.fortran/types.exp
+++ b/gdb/testsuite/gdb.fortran/types.exp
@@ -25,7 +25,7 @@ proc test_integer_literal_types_accepted {} {
# Test various decimal values.
# Should be integer*4 probably.
- gdb_test "pt 123" "type = int"
+ gdb_test "pt 123" "type = int"
}
proc test_character_literal_types_accepted {} {
diff --git a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
index 8d9fc25..b766e1d 100644
--- a/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
+++ b/gdb/testsuite/gdb.fortran/vla-alloc-assoc.exp
@@ -23,7 +23,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/vla-array.exp b/gdb/testsuite/gdb.fortran/vla-array.exp
index 092a19a..7c2d48d 100644
--- a/gdb/testsuite/gdb.fortran/vla-array.exp
+++ b/gdb/testsuite/gdb.fortran/vla-array.exp
@@ -23,7 +23,7 @@ if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
untested "could not run to main"
return -1
}
@@ -34,12 +34,12 @@ gdb_continue_to_breakpoint "arr_vla1-print"
# GFortran emits DW_TAG_structure_type for strings and it has only
# DW_AT_declaration tag. This results in <incomplete type> in gdb.
-if [test_compiler_info "gfortran*" f90] { setup_xfail *-*-* gcc/101826 }
+if {[test_compiler_info "gfortran*" f90]} { setup_xfail *-*-* gcc/101826 }
gdb_test "print arr_vla1" \
" = \\\('vlaaryvlaary', 'vlaaryvlaary', 'vlaaryvlaary', 'vlaaryvlaary', 'vlaaryvlaary'\\\)" \
"print vla string array"
-if [test_compiler_info "gfortran*" f90] { setup_xfail *-*-* gcc/101826 }
+if {[test_compiler_info "gfortran*" f90]} { setup_xfail *-*-* gcc/101826 }
gdb_test "ptype arr_vla1" \
"type = character\\*12 \\(5\\)" \
"print variable length string array type"
diff --git a/gdb/testsuite/gdb.fortran/vla-datatypes.exp b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
index a4ea89d..6f2bb3a 100644
--- a/gdb/testsuite/gdb.fortran/vla-datatypes.exp
+++ b/gdb/testsuite/gdb.fortran/vla-datatypes.exp
@@ -26,7 +26,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
# check that all fortran standard datatypes will be
# handled correctly when using as VLA's
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/vla-history.exp b/gdb/testsuite/gdb.fortran/vla-history.exp
index d51ded4..6dcc31c 100644
--- a/gdb/testsuite/gdb.fortran/vla-history.exp
+++ b/gdb/testsuite/gdb.fortran/vla-history.exp
@@ -23,7 +23,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
index 1a4efc7..9f63e60 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptr-info.exp
@@ -23,7 +23,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
index 7d95787..6809d8c 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptype-sub.exp
@@ -23,7 +23,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/vla-ptype.exp b/gdb/testsuite/gdb.fortran/vla-ptype.exp
index ca75afc..4c72d62 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptype.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptype.exp
@@ -23,7 +23,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
index da9eaa1..ede677f 100644
--- a/gdb/testsuite/gdb.fortran/vla-sizeof.exp
+++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
@@ -23,7 +23,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
index f33231a..7cd9cd8 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
@@ -23,7 +23,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
index 01d717e..ef40dff 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub-finish.exp
@@ -23,7 +23,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub.exp b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
index e3103bd..566125e 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub.exp
@@ -23,7 +23,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp
index fc2864b..687b14c 100644
--- a/gdb/testsuite/gdb.fortran/vla-value.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value.exp
@@ -23,7 +23,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.fortran/whatis_type.exp b/gdb/testsuite/gdb.fortran/whatis_type.exp
index 8cbddc1..8891eac 100644
--- a/gdb/testsuite/gdb.fortran/whatis_type.exp
+++ b/gdb/testsuite/gdb.fortran/whatis_type.exp
@@ -23,7 +23,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
return -1
}
-if ![fortran_runto_main] {
+if {![fortran_runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.gdb/index-file.exp b/gdb/testsuite/gdb.gdb/index-file.exp
index 2252b79..5229446 100644
--- a/gdb/testsuite/gdb.gdb/index-file.exp
+++ b/gdb/testsuite/gdb.gdb/index-file.exp
@@ -30,9 +30,17 @@ if { $filename eq "" } {
return -1
}
+# If FILENAME is a libtool wrapper, then we need to get the path of the real
+# executable.
+set filename [selftest_libtool_get_real_gdb_executable $filename]
+if { $filename eq "" } {
+ return -1
+}
+
with_timeout_factor $timeout_factor {
# Start GDB, load FILENAME.
- clean_restart $filename
+ clean_restart
+ gdb_load $filename
}
# Record how many worker threads GDB is using.
@@ -99,7 +107,7 @@ proc check_symbol_table_usage { filename } {
_ _ _ symbol_table_offset shortcut_offset
# The length of the symbol hash table (in entries).
- set len [expr ($shortcut_offset - $symbol_table_offset) / 8]
+ set len [expr {($shortcut_offset - $symbol_table_offset) / 8}]
# Now walk the hash table and count how many entries are in use.
set offset $symbol_table_offset
@@ -119,7 +127,7 @@ proc check_symbol_table_usage { filename } {
close $fp
# Calculate how full the cache is.
- set pct [expr (100 * double($count)) / $len]
+ set pct [expr {(100 * double($count)) / $len}]
# Write our results out to the gdb.log.
verbose -log "Hash table size: $len"
@@ -145,7 +153,7 @@ if { $worker_threads > 1 } {
clean_restart
# Adjust the number of threads to use.
- set reduced_threads [expr $worker_threads / 2]
+ set reduced_threads [expr {$worker_threads / 2}]
gdb_test_no_output "maint set worker-threads $reduced_threads"
with_timeout_factor $timeout_factor {
diff --git a/gdb/testsuite/gdb.gdb/python-helper.exp b/gdb/testsuite/gdb.gdb/python-helper.exp
index 8126740..33243c9 100644
--- a/gdb/testsuite/gdb.gdb/python-helper.exp
+++ b/gdb/testsuite/gdb.gdb/python-helper.exp
@@ -291,4 +291,4 @@ proc test_python_helper {} {
}
# Use the self-test framework to run the test.
-do_self_tests captured_main test_python_helper
+do_self_tests test_python_helper
diff --git a/gdb/testsuite/gdb.gdb/selftest.exp b/gdb/testsuite/gdb.gdb/selftest.exp
index 1cf9265..7fa320e 100644
--- a/gdb/testsuite/gdb.gdb/selftest.exp
+++ b/gdb/testsuite/gdb.gdb/selftest.exp
@@ -56,7 +56,7 @@ proc test_with_self { } {
}
# start the "xgdb" process
- if [target_info exists gdb,noinferiorio] {
+ if {[target_info exists gdb,noinferiorio]} {
# With no way to interact with the inferior GDB, all we can do
# is let it run.
send_gdb "continue\n"
@@ -98,7 +98,7 @@ proc test_with_self { } {
}
# kill the xgdb process
- if ![target_info exists gdb,nointerrupts] {
+ if {![target_info exists gdb,nointerrupts]} {
set description "send ^C to child process"
send_gdb "\003"
# "Thread 1" is displayed iff Guile support is linked in.
@@ -147,7 +147,7 @@ proc test_with_self { } {
# Switch back to the GDB thread if Guile support is linked in.
# "signal SIGINT" could also switch the current thread.
gdb_test "thread 1" {\[Switching to thread 1 .*\].*}
-
+
# get a stack trace
#
# This fails on some linux systems for unknown reasons. On the
@@ -167,5 +167,5 @@ proc test_with_self { } {
save_vars { INTERNAL_GDBFLAGS } {
set INTERNAL_GDBFLAGS [string map {"-q" ""} $INTERNAL_GDBFLAGS]
- do_self_tests captured_main test_with_self
+ do_self_tests test_with_self
}
diff --git a/gdb/testsuite/gdb.gdb/unittest.exp b/gdb/testsuite/gdb.gdb/unittest.exp
index 795a32b..38955ca 100644
--- a/gdb/testsuite/gdb.gdb/unittest.exp
+++ b/gdb/testsuite/gdb.gdb/unittest.exp
@@ -63,7 +63,7 @@ proc run_selftests { binfile } {
gdb_exit
gdb_start
} else {
- clean_restart ${binfile}
+ clean_restart ${::testfile}
}
if { [is_remote host] } {
diff --git a/gdb/testsuite/gdb.go/basic-types.exp b/gdb/testsuite/gdb.go/basic-types.exp
index 3d4bfd5..53ce4fa 100644
--- a/gdb/testsuite/gdb.go/basic-types.exp
+++ b/gdb/testsuite/gdb.go/basic-types.exp
@@ -25,7 +25,7 @@ require allow_go_tests
proc test_integer_literal_types_accepted {} {
# Test various decimal values.
- gdb_test "pt 123" "type = int"
+ gdb_test "pt 123" "type = int"
gdb_test "pt void(42)" "type = void"
gdb_test "pt byte(42)" "type = uint8"
@@ -102,7 +102,7 @@ proc test_complex_literal_types_accepted {} {
clean_restart
-if [set_lang_go] {
+if {[set_lang_go]} {
test_integer_literal_types_accepted
test_logical_literal_types_accepted
test_character_literal_types_accepted
diff --git a/gdb/testsuite/gdb.go/integers.exp b/gdb/testsuite/gdb.go/integers.exp
index d58c771..50ea9a8 100644
--- a/gdb/testsuite/gdb.go/integers.exp
+++ b/gdb/testsuite/gdb.go/integers.exp
@@ -44,9 +44,9 @@ gdb_test "print i" ".* = 0" "print i before assigned to 1"
gdb_test "next" "i = 1" "next to 'i = 1' line"
gdb_test "next" "j = 2" "next to 'j = 2' line"
-# At that point,
+# At that point,
# i should be equal to 1
-gdb_test "print i" " = 1"
+gdb_test "print i" " = 1"
# but j should still be equal to zero
gdb_test "print j" " = 0" "test j value before assignment"
diff --git a/gdb/testsuite/gdb.go/package.exp b/gdb/testsuite/gdb.go/package.exp
index c30b8c0..180b48a 100644
--- a/gdb/testsuite/gdb.go/package.exp
+++ b/gdb/testsuite/gdb.go/package.exp
@@ -27,7 +27,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${testfile}2.go" "${binfile}2.o" object
untested "failed to compile"
return -1
}
-
+
if { [gdb_compile "${srcdir}/${subdir}/${testfile}1.go ${binfile}2.o" "${binfile}" executable "debug go libdir=[standard_output_file {}]"] != "" } {
untested "failed to compile"
return -1
diff --git a/gdb/testsuite/gdb.go/print.exp b/gdb/testsuite/gdb.go/print.exp
index 85cb6a1..a02b746 100644
--- a/gdb/testsuite/gdb.go/print.exp
+++ b/gdb/testsuite/gdb.go/print.exp
@@ -58,7 +58,7 @@ proc test_float_rejected {} {
clean_restart
-if [set_lang_go] {
+if {[set_lang_go]} {
test_float_accepted
test_float_rejected
} else {
diff --git a/gdb/testsuite/gdb.guile/scm-arch.exp b/gdb/testsuite/gdb.guile/scm-arch.exp
index bd64c4b..752c2d8 100644
--- a/gdb/testsuite/gdb.guile/scm-arch.exp
+++ b/gdb/testsuite/gdb.guile/scm-arch.exp
@@ -23,7 +23,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return
}
-if ![gdb_guile_runto_main] {
+if {![gdb_guile_runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.guile/scm-block.exp b/gdb/testsuite/gdb.guile/scm-block.exp
index 266e714..65e2275 100644
--- a/gdb/testsuite/gdb.guile/scm-block.exp
+++ b/gdb/testsuite/gdb.guile/scm-block.exp
@@ -26,7 +26,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return -1
}
-if ![gdb_guile_runto_main] {
+if {![gdb_guile_runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.guile/scm-breakpoint.exp b/gdb/testsuite/gdb.guile/scm-breakpoint.exp
index 8694530..3b90d99 100644
--- a/gdb/testsuite/gdb.guile/scm-breakpoint.exp
+++ b/gdb/testsuite/gdb.guile/scm-breakpoint.exp
@@ -32,7 +32,7 @@ proc_with_prefix test_bkpt_basic { } {
# Start with a fresh gdb.
clean_restart ${testfile}
- if ![gdb_guile_runto_main] {
+ if {![gdb_guile_runto_main]} {
return
}
@@ -65,7 +65,7 @@ proc_with_prefix test_bkpt_basic { } {
"scm-breakpoint\.c:${mult_line}*" \
"check multiply breakpoint location"
- # Check hit and ignore counts.
+ # Check hit and ignore counts.
gdb_test "guile (print (breakpoint-hit-count mult-bkpt))" \
"= 1" "check multiply breakpoint hit count"
gdb_scm_test_silent_cmd "guile (set-breakpoint-ignore-count! mult-bkpt 4)" \
@@ -105,7 +105,7 @@ proc_with_prefix test_bkpt_deletion { } {
# Start with a fresh gdb.
clean_restart ${testfile}
- if ![gdb_guile_runto_main] {
+ if {![gdb_guile_runto_main]} {
return
}
@@ -141,7 +141,7 @@ proc_with_prefix test_bkpt_cond_and_cmds { } {
# Start with a fresh gdb.
clean_restart ${testfile}
- if ![gdb_guile_runto_main] {
+ if {![gdb_guile_runto_main]} {
return
}
@@ -188,7 +188,7 @@ proc_with_prefix test_bkpt_invisible { } {
# Start with a fresh gdb.
clean_restart ${testfile}
- if ![gdb_guile_runto_main] {
+ if {![gdb_guile_runto_main]} {
return
}
@@ -238,10 +238,10 @@ proc_with_prefix test_watchpoints { } {
clean_restart ${testfile}
# Disable hardware watchpoints if necessary.
- if [target_info exists gdb,no_hardware_watchpoints] {
+ if {[target_info exists gdb,no_hardware_watchpoints]} {
gdb_test_no_output "set can-use-hw-watchpoints 0" ""
}
- if ![gdb_guile_runto_main] {
+ if {![gdb_guile_runto_main]} {
return
}
@@ -273,10 +273,10 @@ proc_with_prefix test_bkpt_internal { } {
clean_restart ${testfile}
# Disable hardware watchpoints if necessary.
- if [target_info exists gdb,no_hardware_watchpoints] {
+ if {[target_info exists gdb,no_hardware_watchpoints]} {
gdb_test_no_output "set can-use-hw-watchpoints 0" ""
}
- if ![gdb_guile_runto_main] {
+ if {![gdb_guile_runto_main]} {
return
}
@@ -304,10 +304,10 @@ proc_with_prefix test_bkpt_eval_funcs { } {
clean_restart ${testfile}
# Disable hardware watchpoints if necessary.
- if [target_info exists gdb,no_hardware_watchpoints] {
+ if {[target_info exists gdb,no_hardware_watchpoints]} {
gdb_test_no_output "set can-use-hw-watchpoints 0" ""
}
- if ![gdb_guile_runto_main] {
+ if {![gdb_guile_runto_main]} {
return
}
@@ -451,7 +451,7 @@ proc_with_prefix test_bkpt_registration {} {
# Start with a fresh gdb.
clean_restart ${testfile}
- if ![gdb_guile_runto_main] {
+ if {![gdb_guile_runto_main]} {
return
}
@@ -490,7 +490,7 @@ proc_with_prefix test_bkpt_temporary { } {
# Start with a fresh gdb.
clean_restart ${testfile}
- if ![gdb_guile_runto_main] {
+ if {![gdb_guile_runto_main]} {
return 0
}
delete_breakpoints
@@ -556,7 +556,7 @@ proc_with_prefix test_catchpoints {} {
# Start with a fresh gdb.
clean_restart ${testfile}
- if ![gdb_guile_runto_main] {
+ if {![gdb_guile_runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.guile/scm-cmd.exp b/gdb/testsuite/gdb.guile/scm-cmd.exp
index 3709cb1..36abb00 100644
--- a/gdb/testsuite/gdb.guile/scm-cmd.exp
+++ b/gdb/testsuite/gdb.guile/scm-cmd.exp
@@ -26,7 +26,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return
}
-if ![gdb_guile_runto_main] {
+if {![gdb_guile_runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.guile/scm-color.exp b/gdb/testsuite/gdb.guile/scm-color.exp
index 578f712..4c6a9c2 100644
--- a/gdb/testsuite/gdb.guile/scm-color.exp
+++ b/gdb/testsuite/gdb.guile/scm-color.exp
@@ -19,6 +19,7 @@
load_lib gdb-guile.exp
require allow_guile_tests
+require {!is_remote host}
# Start GDB with styling support.
with_ansi_styling_terminal {
diff --git a/gdb/testsuite/gdb.guile/scm-disasm.exp b/gdb/testsuite/gdb.guile/scm-disasm.exp
index 5541a60..bd551ad 100644
--- a/gdb/testsuite/gdb.guile/scm-disasm.exp
+++ b/gdb/testsuite/gdb.guile/scm-disasm.exp
@@ -23,7 +23,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return
}
-if ![gdb_guile_runto_main] {
+if {![gdb_guile_runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.guile/scm-equal.exp b/gdb/testsuite/gdb.guile/scm-equal.exp
index 0450d62..2a87139 100644
--- a/gdb/testsuite/gdb.guile/scm-equal.exp
+++ b/gdb/testsuite/gdb.guile/scm-equal.exp
@@ -26,7 +26,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return
}
-if ![gdb_guile_runto_main] {
+if {![gdb_guile_runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.guile/scm-frame-args.exp b/gdb/testsuite/gdb.guile/scm-frame-args.exp
index c519087..9c1e831 100644
--- a/gdb/testsuite/gdb.guile/scm-frame-args.exp
+++ b/gdb/testsuite/gdb.guile/scm-frame-args.exp
@@ -23,7 +23,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return
}
-if ![gdb_guile_runto_main] {
+if {![gdb_guile_runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.guile/scm-frame-inline.exp b/gdb/testsuite/gdb.guile/scm-frame-inline.exp
index a2fe11d..02884f7 100644
--- a/gdb/testsuite/gdb.guile/scm-frame-inline.exp
+++ b/gdb/testsuite/gdb.guile/scm-frame-inline.exp
@@ -23,7 +23,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return
}
-if ![runto_main] {
+if {![runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.guile/scm-frame.exp b/gdb/testsuite/gdb.guile/scm-frame.exp
index 9a27c42..821567e 100644
--- a/gdb/testsuite/gdb.guile/scm-frame.exp
+++ b/gdb/testsuite/gdb.guile/scm-frame.exp
@@ -28,7 +28,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
# The following tests require execution.
-if ![gdb_guile_runto_main] {
+if {![gdb_guile_runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.guile/scm-iterator.exp b/gdb/testsuite/gdb.guile/scm-iterator.exp
index 43d776b..188b5ef 100644
--- a/gdb/testsuite/gdb.guile/scm-iterator.exp
+++ b/gdb/testsuite/gdb.guile/scm-iterator.exp
@@ -26,7 +26,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return -1
}
-if ![gdb_guile_runto_main] {
+if {![gdb_guile_runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.guile/scm-lazy-string.exp b/gdb/testsuite/gdb.guile/scm-lazy-string.exp
index c5d09ae..eaee001 100644
--- a/gdb/testsuite/gdb.guile/scm-lazy-string.exp
+++ b/gdb/testsuite/gdb.guile/scm-lazy-string.exp
@@ -31,7 +31,7 @@ if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
# The following tests require execution.
-if ![gdb_guile_runto_main] {
+if {![gdb_guile_runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.guile/scm-math.exp b/gdb/testsuite/gdb.guile/scm-math.exp
index 8b21909..17b54d1 100644
--- a/gdb/testsuite/gdb.guile/scm-math.exp
+++ b/gdb/testsuite/gdb.guile/scm-math.exp
@@ -167,21 +167,21 @@ proc test_value_numeric_ops {} {
# TCL 8.5 required here. Use lookup table instead?
proc get_max_int { size } {
- return [expr "(1 << ($size - 1)) - 1"]
+ return [expr {(1 << ($size - 1)) - 1}]
}
# Return the min signed int of size SIZE.
# TCL 8.5 required here. Use lookup table instead?
proc get_min_int { size } {
- return [expr "-(1 << ($size - 1))"]
+ return [expr {-(1 << ($size - 1))}]
}
# Return the max unsigned int of size SIZE.
# TCL 8.5 required here. Use lookup table instead?
proc get_max_uint { size } {
- return [expr "(1 << $size) - 1"]
+ return [expr {(1 << $size) - 1}]
}
# Helper routine for test_value_numeric_ranges.
@@ -252,7 +252,7 @@ proc test_value_numeric_ranges {} {
proc test_make_pointer_value { size } {
set max [get_max_uint $size]
- set max_hex [string repeat "f" [expr "$size / 4"]]
+ set max_hex [string repeat "f" [expr {$size / 4}]]
gdb_test "gu (print (make-value $max #:type void-pointer-type))" \
"= 0x$max_hex" "test make-value void* max"
@@ -337,7 +337,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c}]} {
return
}
-if ![gdb_guile_runto_main] {
+if {![gdb_guile_runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.guile/scm-objfile-script.exp b/gdb/testsuite/gdb.guile/scm-objfile-script.exp
index b6d9369..88cd18c 100644
--- a/gdb/testsuite/gdb.guile/scm-objfile-script.exp
+++ b/gdb/testsuite/gdb.guile/scm-objfile-script.exp
@@ -41,7 +41,7 @@ gdb_load ${binfile}
# Verify gdb loaded the script.
gdb_test "info auto-load guile-scripts" "Yes.*/${testfile}-gdb.scm.*"
-if ![gdb_guile_runto_main] {
+if {![gdb_guile_runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.guile/scm-objfile.exp b/gdb/testsuite/gdb.guile/scm-objfile.exp
index e0018c4..09256df 100644
--- a/gdb/testsuite/gdb.guile/scm-objfile.exp
+++ b/gdb/testsuite/gdb.guile/scm-objfile.exp
@@ -26,7 +26,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return
}
-if ![gdb_guile_runto_main] {
+if {![gdb_guile_runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.guile/scm-parameter.exp b/gdb/testsuite/gdb.guile/scm-parameter.exp
index e35428a..5483b81 100644
--- a/gdb/testsuite/gdb.guile/scm-parameter.exp
+++ b/gdb/testsuite/gdb.guile/scm-parameter.exp
@@ -26,7 +26,7 @@ gdb_install_guile_utils
gdb_install_guile_module
proc scm_param_test_maybe_no_output { command pattern args } {
- if [string length $pattern] {
+ if {[string length $pattern]} {
gdb_test $command $pattern $args
} else {
gdb_test_no_output $command $args
@@ -39,7 +39,8 @@ if { [is_remote host] } {
gdb_test "guile (print (parameter-value \"directories\"))" \
"\\\$cdir.\\\$cwd"
} else {
- set escaped_directory [string_to_regexp "$srcdir/$subdir"]
+ set directory [host_file_normalize "$::srcdir/$::subdir"]
+ set escaped_directory [string_to_regexp $directory]
gdb_test "guile (print (parameter-value \"directories\"))" \
"$escaped_directory.\\\$cdir.\\\$cwd"
}
@@ -109,7 +110,7 @@ with_test_prefix "test-enum-param" {
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 "set print test-enum-param three" "Undefined item: \"three\".*" "set invalid enum parameter"
+ gdb_test "set print test-enum-param three" "Undefined item: \"three\".*" "set invalid enum parameter"
}
# Test integer parameters.
@@ -305,7 +306,7 @@ with_test_prefix "test-file-param" {
gdb_test_no_output "set test-file-param bar.txt"
gdb_test "show test-file-param" "The name of the file is bar.txt." "show new value"
gdb_test "guile (print (parameter-value test-file-param))" "bar.txt" " new parameter value"
- gdb_test "set test-file-param" "Argument required.*"
+ gdb_test "set test-file-param" "Argument required.*"
}
# Test a parameter that is not documented.
@@ -565,47 +566,50 @@ rename scm_param_test_maybe_no_output ""
# Test a color parameter.
-with_ansi_styling_terminal {
- # This enables 256 colors support and disables colors approximation.
- setenv TERM xterm-256color
- setenv COLORTERM truecolor
-
- # Start with a fresh gdb.
- gdb_exit
- gdb_start
- gdb_reinitialize_dir $srcdir/$subdir
-
- gdb_install_guile_utils
- gdb_install_guile_module
-
- # We use "." here instead of ":" so that this works on win32 too.
- set escaped_directory [string_to_regexp "$srcdir/$subdir"]
-
- gdb_test_multiline "color gdb parameter" \
- "guile" "" \
- "(define test-color-param" "" \
- " (make-parameter \"print test-color-param\"" "" \
- " #:command-class COMMAND_DATA" "" \
- " #:parameter-type PARAM_COLOR" "" \
- " #:doc \"When set, test param does something useful. When disabled, does nothing.\"" "" \
- " #:show-doc \"Show the state of the test-color-param.\"" "" \
- " #:set-doc \"Set the state of the test-color-param.\"" "" \
- " #:show-func (lambda (self value)" "" \
- " (format #f \"The state of the test-color-param is ~a.\" value))" "" \
- " #:initial-value (make-color \"green\")))" "" \
- "(register-parameter! test-color-param)" "" \
- "end"
-
- with_test_prefix "test-color-param" {
- with_test_prefix "initial-value" {
- gdb_test "guile (print (parameter-value test-color-param))" "= #<gdb:color green COLORSPACE_ANSI_8COLOR>" "color parameter value (green)"
- gdb_test "show print test-color-param" "The state of the test-color-param is green." "show initial value"
- gdb_test_no_output "set print test-color-param 255"
- }
- with_test_prefix "new-value" {
- gdb_test "show print test-color-param" "The state of the test-color-param is 255." "show new value"
- gdb_test "guile (print (parameter-value test-color-param))" "= #<gdb:color 255 COLORSPACE_XTERM_256COLOR>" "color parameter value (255)"
- gdb_test "set print test-color-param 256" "integer 256 out of range.*" "set invalid color parameter"
+if { ![is_remote host] } {
+ with_ansi_styling_terminal {
+
+ # This enables 256 colors support and disables colors approximation.
+ setenv TERM xterm-256color
+ setenv COLORTERM truecolor
+
+ # Start with a fresh gdb.
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+
+ gdb_install_guile_utils
+ gdb_install_guile_module
+
+ # We use "." here instead of ":" so that this works on win32 too.
+ set escaped_directory [string_to_regexp "$srcdir/$subdir"]
+
+ gdb_test_multiline "color gdb parameter" \
+ "guile" "" \
+ "(define test-color-param" "" \
+ " (make-parameter \"print test-color-param\"" "" \
+ " #:command-class COMMAND_DATA" "" \
+ " #:parameter-type PARAM_COLOR" "" \
+ " #:doc \"When set, test param does something useful. When disabled, does nothing.\"" "" \
+ " #:show-doc \"Show the state of the test-color-param.\"" "" \
+ " #:set-doc \"Set the state of the test-color-param.\"" "" \
+ " #:show-func (lambda (self value)" "" \
+ " (format #f \"The state of the test-color-param is ~a.\" value))" "" \
+ " #:initial-value (make-color \"green\")))" "" \
+ "(register-parameter! test-color-param)" "" \
+ "end"
+
+ with_test_prefix "test-color-param" {
+ with_test_prefix "initial-value" {
+ gdb_test "guile (print (parameter-value test-color-param))" "= #<gdb:color green COLORSPACE_ANSI_8COLOR>" "color parameter value (green)"
+ gdb_test "show print test-color-param" "The state of the test-color-param is green." "show initial value"
+ gdb_test_no_output "set print test-color-param 255"
+ }
+ with_test_prefix "new-value" {
+ gdb_test "show print test-color-param" "The state of the test-color-param is 255." "show new value"
+ gdb_test "guile (print (parameter-value test-color-param))" "= #<gdb:color 255 COLORSPACE_XTERM_256COLOR>" "color parameter value (255)"
+ gdb_test "set print test-color-param 256" "integer 256 out of range.*" "set invalid color parameter"
+ }
}
}
}
diff --git a/gdb/testsuite/gdb.guile/scm-ports.exp b/gdb/testsuite/gdb.guile/scm-ports.exp
index c67ebd2..a0af289 100644
--- a/gdb/testsuite/gdb.guile/scm-ports.exp
+++ b/gdb/testsuite/gdb.guile/scm-ports.exp
@@ -26,7 +26,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return
}
-if ![gdb_guile_runto_main] {
+if {![gdb_guile_runto_main]} {
return
}
@@ -84,7 +84,7 @@ foreach variation $port_variations {
# Test read/write of memory ports.
proc test_mem_port_rw { buffered } {
- if $buffered {
+ if {$buffered} {
set mode "r+"
} else {
set mode "r+0"
@@ -115,7 +115,7 @@ proc test_mem_port_rw { buffered } {
"define new-value"
gdb_test "guile (print (put-bytevector rw-mem-port (make-bytevector 1 new-value)))" \
"= #<unspecified>"
- if $buffered {
+ if {$buffered} {
# Value shouldn't be in memory yet.
gdb_test "guile (print (value=? (parse-and-eval \"*(char*) \$sp\") byte-at-sp))" \
"= #t" \
diff --git a/gdb/testsuite/gdb.guile/scm-pretty-print.exp b/gdb/testsuite/gdb.guile/scm-pretty-print.exp
index 09717a9..62fb8e2 100644
--- a/gdb/testsuite/gdb.guile/scm-pretty-print.exp
+++ b/gdb/testsuite/gdb.guile/scm-pretty-print.exp
@@ -33,9 +33,10 @@ proc run_lang_tests {exefile lang} {
set nl "\[\r\n\]+"
# Start with a fresh gdb.
- clean_restart $exefile
+ clean_restart
+ gdb_load $exefile
- if ![gdb_guile_runto_main] {
+ if {![gdb_guile_runto_main]} {
return
}
@@ -114,9 +115,9 @@ run_lang_tests "${binfile}-cxx" "c++"
# Run various other tests.
-clean_restart $binfile
+clean_restart $::testfile
-if ![gdb_guile_runto_main] {
+if {![gdb_guile_runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.guile/scm-section-script.exp b/gdb/testsuite/gdb.guile/scm-section-script.exp
index 4c0238d..3a68adc 100644
--- a/gdb/testsuite/gdb.guile/scm-section-script.exp
+++ b/gdb/testsuite/gdb.guile/scm-section-script.exp
@@ -94,7 +94,7 @@ gdb_test "info auto-load guile-scripts ${testfile}" "Yes.*${testfile}.scm.*"
gdb_test "info auto-load guile-scripts no-script-matches-this" \
"No auto-load scripts matching no-script-matches-this."
-if ![gdb_guile_runto_main] {
+if {![gdb_guile_runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.guile/scm-symbol.exp b/gdb/testsuite/gdb.guile/scm-symbol.exp
index b6ebffd..2ddd3f0 100644
--- a/gdb/testsuite/gdb.guile/scm-symbol.exp
+++ b/gdb/testsuite/gdb.guile/scm-symbol.exp
@@ -54,7 +54,7 @@ gdb_test "guile (print (symbol-value qq-var))" \
gdb_test "guile (print (symbol-needs-frame? qq-var))" \
"= #f" "print whether qq needs a frame"
-if ![gdb_guile_runto_main] {
+if {![gdb_guile_runto_main]} {
return
}
@@ -141,9 +141,9 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}-cxx" executable "
return -1
}
-clean_restart ${binfile}-cxx
+clean_restart ${::testfile}-cxx
-if ![gdb_guile_runto_main] {
+if {![gdb_guile_runto_main]} {
return
}
@@ -172,7 +172,7 @@ gdb_test "guile (print (= (symbol-addr-class cplusfunc) SYMBOL_LOC_BLOCK))" "= #
# test as it unloads the object file in GDB.
# Start with a fresh gdb.
clean_restart ${testfile}
-if ![gdb_guile_runto_main] {
+if {![gdb_guile_runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.guile/scm-symtab.exp b/gdb/testsuite/gdb.guile/scm-symtab.exp
index 621bbbe..c19b460 100644
--- a/gdb/testsuite/gdb.guile/scm-symtab.exp
+++ b/gdb/testsuite/gdb.guile/scm-symtab.exp
@@ -27,7 +27,7 @@ if {[prepare_for_testing "failed to prepare" $testfile \
return
}
-if ![gdb_guile_runto_main] {
+if {![gdb_guile_runto_main]} {
return
}
@@ -143,7 +143,7 @@ clean_restart ${testfile}
# Test find-pc-line.
# The following tests require execution.
-if ![gdb_guile_runto_main] {
+if {![gdb_guile_runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.guile/scm-type.exp b/gdb/testsuite/gdb.guile/scm-type.exp
index 1167dd1..d974c86 100644
--- a/gdb/testsuite/gdb.guile/scm-type.exp
+++ b/gdb/testsuite/gdb.guile/scm-type.exp
@@ -38,13 +38,14 @@ proc build_inferior {exefile lang} {
proc restart_gdb {exefile} {
global srcdir subdir
- clean_restart $exefile
+ clean_restart
+ gdb_load $exefile
if { ![allow_guile_tests] } {
return 0
}
- if ![gdb_guile_runto_main] {
+ if {![gdb_guile_runto_main]} {
return 0
}
gdb_scm_test_silent_cmd "guile (use-modules (gdb iterator))" \
@@ -274,7 +275,7 @@ proc test_range {} {
if { [build_inferior "${binfile}" "c"] < 0 } {
return
}
-if ![restart_gdb "${binfile}"] {
+if {![restart_gdb "${binfile}"]} {
return
}
@@ -290,7 +291,7 @@ with_test_prefix "lang_c" {
if { [build_inferior "${binfile}-cxx" "c++"] < 0 } {
return
}
-if ![restart_gdb "${binfile}-cxx"] {
+if {![restart_gdb "${binfile}-cxx"]} {
return
}
diff --git a/gdb/testsuite/gdb.guile/scm-value-cc.exp b/gdb/testsuite/gdb.guile/scm-value-cc.exp
index 202f01e..f65be25 100644
--- a/gdb/testsuite/gdb.guile/scm-value-cc.exp
+++ b/gdb/testsuite/gdb.guile/scm-value-cc.exp
@@ -26,7 +26,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
return
}
-if ![gdb_guile_runto_main] {
+if {![gdb_guile_runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.guile/scm-value.exp b/gdb/testsuite/gdb.guile/scm-value.exp
index 1567b13..ea77d8f 100644
--- a/gdb/testsuite/gdb.guile/scm-value.exp
+++ b/gdb/testsuite/gdb.guile/scm-value.exp
@@ -309,9 +309,10 @@ proc test_value_after_death {} {
proc test_subscript_regression {exefile lang} {
# Start with a fresh gdb.
- clean_restart ${exefile}
+ clean_restart
+ gdb_load ${exefile}
- if ![gdb_guile_runto_main ] {
+ if {![gdb_guile_runto_main ]} {
return
}
@@ -427,7 +428,7 @@ if { [build_inferior "${binfile}" "c"] < 0 } {
}
# Start with a fresh gdb.
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_install_guile_utils
gdb_install_guile_module
@@ -437,7 +438,7 @@ test_value_hash
# The following tests require execution.
-if ![gdb_guile_runto_main] {
+if {![gdb_guile_runto_main]} {
return
}
@@ -446,7 +447,7 @@ test_inferior_function_call
test_strings
test_value_after_death
-# Test either C or C++ values.
+# Test either C or C++ values.
test_subscript_regression "${binfile}" "c"
diff --git a/gdb/testsuite/gdb.guile/types-module.exp b/gdb/testsuite/gdb.guile/types-module.exp
index c9d7067..e8412cc 100644
--- a/gdb/testsuite/gdb.guile/types-module.exp
+++ b/gdb/testsuite/gdb.guile/types-module.exp
@@ -30,7 +30,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $flags] } {
return -1
}
-if ![gdb_guile_runto_main] {
+if {![gdb_guile_runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.linespec/cp-replace-typedefs-ns-template.exp b/gdb/testsuite/gdb.linespec/cp-replace-typedefs-ns-template.exp
index 77757fc..db6ed69 100644
--- a/gdb/testsuite/gdb.linespec/cp-replace-typedefs-ns-template.exp
+++ b/gdb/testsuite/gdb.linespec/cp-replace-typedefs-ns-template.exp
@@ -93,7 +93,7 @@ foreach loc {
"NS1::NS2::AliasTempl<int>::static_method<int>(NS1::NS2::object*)"
"NS1::NS2::AliasTempl<int>::static_method<int>(NS1::NS2::object_p)"
} {
- if [test_compiler_info gcc*] {
+ if {[test_compiler_info gcc*]} {
# While Clang emits "AliasTempl<int>" (etc.) typedefs, GCC
# emits "AliasTempl" typedefs with no template parameter info.
setup_xfail gcc/95437 *-*-*
@@ -104,7 +104,7 @@ foreach loc {
# instead of succeeding with e.g., "AliasTempl<int>" preserved in
# the location text. If that ever happens, we'll need to update
# these tests.
- if [test_compiler_info gcc*] {
+ if {[test_compiler_info gcc*]} {
check_setting_bp_fails "b $loc"
}
}
diff --git a/gdb/testsuite/gdb.linespec/cpcompletion.exp b/gdb/testsuite/gdb.linespec/cpcompletion.exp
index 6c1c551..2f1cc84 100644
--- a/gdb/testsuite/gdb.linespec/cpcompletion.exp
+++ b/gdb/testsuite/gdb.linespec/cpcompletion.exp
@@ -779,7 +779,7 @@ proc test_makem_1 {arglist_list expected_list} {
send_log "expecting $expected_list\n"
# Do list equality via canonical strings.
- if {[expr {[list {*}$expected_list] eq [list {*}$result]}]} {
+ if {[string eq $expected_list eq $result]} {
pass "makem unit test: $arglist"
} else {
fail "makem unit test: $arglist"
diff --git a/gdb/testsuite/gdb.linespec/explicit.exp b/gdb/testsuite/gdb.linespec/explicit.exp
index 12eaa51..b859b44 100644
--- a/gdb/testsuite/gdb.linespec/explicit.exp
+++ b/gdb/testsuite/gdb.linespec/explicit.exp
@@ -608,7 +608,7 @@ namespace eval $testfile {
}
# Test interaction of condition command and explicit linespec conditons.
- clean_restart [standard_output_file $exefile]
+ clean_restart $exefile
set tst "condition_command overrides explicit linespec condition"
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.linespec/keywords.exp b/gdb/testsuite/gdb.linespec/keywords.exp
index 42a9228..b1df13a 100644
--- a/gdb/testsuite/gdb.linespec/keywords.exp
+++ b/gdb/testsuite/gdb.linespec/keywords.exp
@@ -22,7 +22,7 @@ if {[prepare_for_testing "failed to prepare" $exefile $srcfile {debug}]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return 0
}
diff --git a/gdb/testsuite/gdb.linespec/line-breakpoint-outside-function.exp b/gdb/testsuite/gdb.linespec/line-breakpoint-outside-function.exp
index 012be6b..120ee6c 100644
--- a/gdb/testsuite/gdb.linespec/line-breakpoint-outside-function.exp
+++ b/gdb/testsuite/gdb.linespec/line-breakpoint-outside-function.exp
@@ -32,7 +32,7 @@ if {[build_executable "failed to prepare" ${testfile} ${srcfile} $opts]} {
}
proc do_test {} {
- clean_restart $::binfile
+ clean_restart $::testfile
# To make things easier, just so we don't have to deal with the question.
gdb_test_no_output "set breakpoint pending on"
diff --git a/gdb/testsuite/gdb.linespec/ls-errs.exp b/gdb/testsuite/gdb.linespec/ls-errs.exp
index 303fd9f..56f9467 100644
--- a/gdb/testsuite/gdb.linespec/ls-errs.exp
+++ b/gdb/testsuite/gdb.linespec/ls-errs.exp
@@ -22,7 +22,7 @@ proc do_test {lang} {
standard_testfile
set exefile $testfile
- if [info exists compiler_info] {
+ if {[info exists compiler_info]} {
# Unsetting compiler_info allows us to switch compilers
# used by prepare_for_testing.
unset compiler_info
@@ -89,9 +89,8 @@ proc do_test {lang} {
proc test_break {linespec msg_id args} {
global error_messages
- gdb_test "break $linespec" [string_to_regexp \
- [eval format \$error_messages($msg_id) \
- $args]] \
+ gdb_test "break $linespec" \
+ [string_to_regexp [format $error_messages($msg_id) {*}$args]] \
"'break $linespec'"
}
diff --git a/gdb/testsuite/gdb.linespec/macro-relative.exp b/gdb/testsuite/gdb.linespec/macro-relative.exp
index 94ab16a..c076e02 100644
--- a/gdb/testsuite/gdb.linespec/macro-relative.exp
+++ b/gdb/testsuite/gdb.linespec/macro-relative.exp
@@ -41,7 +41,7 @@ clean_restart ${testfile}
# Test macros respect DW_AT_comp_dir.
# "list header_two_func" does not set exactly the one line we want.
-if ![runto header_two_func] {
+if {![runto header_two_func]} {
return -1
}
diff --git a/gdb/testsuite/gdb.linespec/skip-two.exp b/gdb/testsuite/gdb.linespec/skip-two.exp
index 6e3ab30..cfd91da 100644
--- a/gdb/testsuite/gdb.linespec/skip-two.exp
+++ b/gdb/testsuite/gdb.linespec/skip-two.exp
@@ -31,7 +31,7 @@ if {[prepare_for_testing "failed to prepare" $execfile \
gdb_test "skip function dupname" \
{Function dupname will be skipped when stepping\.}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
@@ -63,7 +63,7 @@ gdb_test_no_output "skip delete 1"
gdb_test "skip file thefile.cc" \
{File thefile\.cc will be skipped when stepping\.}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.linespec/thread.exp b/gdb/testsuite/gdb.linespec/thread.exp
index d2f7b25..f5cdf8b 100644
--- a/gdb/testsuite/gdb.linespec/thread.exp
+++ b/gdb/testsuite/gdb.linespec/thread.exp
@@ -23,7 +23,7 @@ if {[prepare_for_testing "failed to prepare" $exefile $srcfile {debug}]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return 0
}
diff --git a/gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp b/gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp
index 3fd9b81..0565681 100644
--- a/gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp
+++ b/gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp
@@ -42,7 +42,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" $objsfile object {}] != ""
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
@@ -54,7 +54,7 @@ if [mi_runto func_nofb_marker] {
}
# GDB could have crashed.
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/gdb2549.exp b/gdb/testsuite/gdb.mi/gdb2549.exp
index 796c1fa..5aabc3b 100644
--- a/gdb/testsuite/gdb.mi/gdb2549.exp
+++ b/gdb/testsuite/gdb.mi/gdb2549.exp
@@ -94,7 +94,7 @@ proc register_tests { } {
register_test 666 t $binary
}
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
register_tests_no_exec
diff --git a/gdb/testsuite/gdb.mi/gdb669.exp b/gdb/testsuite/gdb.mi/gdb669.exp
index 086d3c1..da1db64 100644
--- a/gdb/testsuite/gdb.mi/gdb669.exp
+++ b/gdb/testsuite/gdb.mi/gdb669.exp
@@ -30,7 +30,7 @@ if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $option
return -1
}
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
mi_runto_main
check_mi_and_console_threads "at main"
diff --git a/gdb/testsuite/gdb.mi/gdb701.exp b/gdb/testsuite/gdb.mi/gdb701.exp
index 587481c..9ef6fb7 100644
--- a/gdb/testsuite/gdb.mi/gdb701.exp
+++ b/gdb/testsuite/gdb.mi/gdb701.exp
@@ -35,7 +35,7 @@ if {[gdb_compile $srcdir/$subdir/$srcfile $binfile executable debug] != ""} {
# If it doesn't, Bad Things Happen(TM).
# Run to main
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
mi_runto_main
# Step over "foo = 0"
diff --git a/gdb/testsuite/gdb.mi/gdb792.exp b/gdb/testsuite/gdb.mi/gdb792.exp
index f894eea..64f218a 100644
--- a/gdb/testsuite/gdb.mi/gdb792.exp
+++ b/gdb/testsuite/gdb.mi/gdb792.exp
@@ -28,7 +28,7 @@ if {[gdb_compile $srcdir/$subdir/$srcfile $binfile executable {debug c++}] != ""
return -1
}
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
mi_runto_main
diff --git a/gdb/testsuite/gdb.mi/interrupt-thread-group.exp b/gdb/testsuite/gdb.mi/interrupt-thread-group.exp
index 869fb1c..5f9e49e 100644
--- a/gdb/testsuite/gdb.mi/interrupt-thread-group.exp
+++ b/gdb/testsuite/gdb.mi/interrupt-thread-group.exp
@@ -30,7 +30,7 @@ if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile \
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"set non-stop on\" -ex \"set mi-async\""
- mi_clean_restart $binfile
+ mi_clean_restart $::testfile
}
mi_detect_async
diff --git a/gdb/testsuite/gdb.mi/mi-add-inferior.exp b/gdb/testsuite/gdb.mi/mi-add-inferior.exp
index d110e68..8c4926f 100644
--- a/gdb/testsuite/gdb.mi/mi-add-inferior.exp
+++ b/gdb/testsuite/gdb.mi/mi-add-inferior.exp
@@ -26,7 +26,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
return -1
}
-mi_clean_restart ${binfile}
+mi_clean_restart ${::testfile}
# Start execution to establish a connection.
mi_runto_main
diff --git a/gdb/testsuite/gdb.mi/mi-async-run.exp b/gdb/testsuite/gdb.mi/mi-async-run.exp
index 8352803..3df8769 100644
--- a/gdb/testsuite/gdb.mi/mi-async-run.exp
+++ b/gdb/testsuite/gdb.mi/mi-async-run.exp
@@ -35,7 +35,7 @@ proc test_async_run {} {
set GDBFLAGS [concat $GDBFLAGS " -ex \"set mi-async on\""]
- if {[mi_clean_restart $binfile]} {
+ if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-async.exp b/gdb/testsuite/gdb.mi/mi-async.exp
index 09db7f9..1c4e06c 100644
--- a/gdb/testsuite/gdb.mi/mi-async.exp
+++ b/gdb/testsuite/gdb.mi/mi-async.exp
@@ -42,7 +42,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
save_vars { GDBFLAGS } {
set GDBFLAGS [concat $GDBFLAGS " -ex \"set mi-async on\""]
- if {[mi_clean_restart $binfile]} {
+ if {[mi_clean_restart $::testfile]} {
return
}
}
diff --git a/gdb/testsuite/gdb.mi/mi-break-qualified.exp b/gdb/testsuite/gdb.mi/mi-break-qualified.exp
index b5e5e78..9adc2d9 100644
--- a/gdb/testsuite/gdb.mi/mi-break-qualified.exp
+++ b/gdb/testsuite/gdb.mi/mi-break-qualified.exp
@@ -93,7 +93,7 @@ proc test_break_qualified {} {
"delete temp breakpoints"
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-break.exp b/gdb/testsuite/gdb.mi/mi-break.exp
index bb982c3..cb7c14b 100644
--- a/gdb/testsuite/gdb.mi/mi-break.exp
+++ b/gdb/testsuite/gdb.mi/mi-break.exp
@@ -346,7 +346,7 @@ proc_with_prefix test_forced_conditions {} {
set loc [mi_make_breakpoint_loc -enabled "N"]
set args [list -cond "bad" -locations "\\\[$loc\\\]"]
- set bp [eval mi_make_breakpoint_multi $args]
+ set bp [mi_make_breakpoint_multi {*}$args]
mi_gdb_test "-break-insert -c bad --force-condition callme" \
"${warning}\\^done,$bp" \
@@ -398,7 +398,7 @@ proc test_break {mi_mode} {
} else {
set start_ops ""
}
- if [mi_clean_restart $binfile $start_ops ] {
+ if [mi_clean_restart $::testfile $start_ops ] {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp b/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp
index 9cb91de..46561e4 100644
--- a/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp
+++ b/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp
@@ -48,7 +48,7 @@ proc test_insert_delete_modify { } {
global lib_sl1 lib_sl2
global binfile
- mi_clean_restart $binfile
+ mi_clean_restart $::testfile
mi_load_shlibs $lib_sl1 $lib_sl2
@@ -184,7 +184,7 @@ proc test_pending_resolved { } {
global lib_sl1 lib_sl2
global mi_gdb_prompt
- if {[mi_clean_restart $binfile]} {
+ if {[mi_clean_restart $::testfile]} {
return
}
mi_load_shlibs $lib_sl1 $lib_sl2
@@ -279,7 +279,7 @@ proc test_auto_disable { } {
global lib_sl1 lib_sl2
global binfile
- mi_clean_restart $binfile
+ mi_clean_restart $::testfile
mi_load_shlibs $lib_sl1 $lib_sl2
diff --git a/gdb/testsuite/gdb.mi/mi-breakpoint-multiple-locations.exp b/gdb/testsuite/gdb.mi/mi-breakpoint-multiple-locations.exp
index cbf9f57..7995846 100644
--- a/gdb/testsuite/gdb.mi/mi-breakpoint-multiple-locations.exp
+++ b/gdb/testsuite/gdb.mi/mi-breakpoint-multiple-locations.exp
@@ -56,7 +56,7 @@ proc do_test { mi_version use_fix_flag expect_fixed_output } {
global MIFLAGS decimal binfile
set MIFLAGS "-i=mi${mi_version}"
- mi_clean_restart $binfile
+ mi_clean_restart $::testfile
mi_runto_main
diff --git a/gdb/testsuite/gdb.mi/mi-breakpoint-script.exp b/gdb/testsuite/gdb.mi/mi-breakpoint-script.exp
index af514e8..ce30d44 100644
--- a/gdb/testsuite/gdb.mi/mi-breakpoint-script.exp
+++ b/gdb/testsuite/gdb.mi/mi-breakpoint-script.exp
@@ -51,7 +51,7 @@ proc do_test { mi_version use_fix_flag expect_fixed_output } {
save_vars { ::MIFLAGS } {
set ::MIFLAGS "-i=mi${mi_version}"
- mi_clean_restart $::binfile
+ mi_clean_restart $::testfile
}
if $use_fix_flag {
diff --git a/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.exp b/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.exp
index 9053b18..ec023e6 100644
--- a/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.exp
+++ b/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.exp
@@ -27,7 +27,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
if {[mi_runto_main] < 0} {
return -1
}
@@ -46,7 +46,7 @@ proc restart_for_test {} {
global srcdir subdir binfile srcfile
global main_lineno
- if {[mi_clean_restart $binfile]} {
+ if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-catch-load.exp b/gdb/testsuite/gdb.mi/mi-catch-load.exp
index a9a5fdc..3c36cc9 100644
--- a/gdb/testsuite/gdb.mi/mi-catch-load.exp
+++ b/gdb/testsuite/gdb.mi/mi-catch-load.exp
@@ -36,7 +36,7 @@ gdb_download_shlib $binfile2
# test -catch-load
with_test_prefix "catch-load" {
- mi_clean_restart $binfile
+ mi_clean_restart $::testfile
mi_locate_shlib $binfile2
mi_runto_main
@@ -63,7 +63,7 @@ with_test_prefix "catch-load" {
# test -catch-unload
with_test_prefix "catch-unload" {
- mi_clean_restart $binfile
+ mi_clean_restart $::testfile
mi_locate_shlib $binfile2
mi_runto_main
diff --git a/gdb/testsuite/gdb.mi/mi-cli.exp b/gdb/testsuite/gdb.mi/mi-cli.exp
index a3ff7eb..b59a5ed 100644
--- a/gdb/testsuite/gdb.mi/mi-cli.exp
+++ b/gdb/testsuite/gdb.mi/mi-cli.exp
@@ -29,7 +29,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
mi_gdb_test "-interpreter-exec" \
{\^error,msg="-interpreter-exec: Usage: -interpreter-exec interp command"} \
diff --git a/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp b/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp
index 5587b76..24d12c1 100644
--- a/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp
+++ b/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp
@@ -31,7 +31,7 @@ proc test_command_param_changed { } {
global binfile
with_test_prefix "cmd param" {
- mi_clean_restart $binfile
+ mi_clean_restart $::testfile
mi_runto_main
if { $scheduler_locking_supported } {
diff --git a/gdb/testsuite/gdb.mi/mi-cmd-user-context.exp b/gdb/testsuite/gdb.mi/mi-cmd-user-context.exp
index 806ed4c..324de5a 100644
--- a/gdb/testsuite/gdb.mi/mi-cmd-user-context.exp
+++ b/gdb/testsuite/gdb.mi/mi-cmd-user-context.exp
@@ -29,7 +29,7 @@ set main_break_line [gdb_get_line_number "main break line"]
set any "\[^\r\n\]*"
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
mi_create_breakpoint "$srcfile:$main_break_line" "set breakpoint in main"
mi_run_cmd
mi_expect_stop "breakpoint-hit" "main" "" $srcfile $main_break_line \
diff --git a/gdb/testsuite/gdb.mi/mi-complete.exp b/gdb/testsuite/gdb.mi/mi-complete.exp
index 22acda3..ad29b3f 100644
--- a/gdb/testsuite/gdb.mi/mi-complete.exp
+++ b/gdb/testsuite/gdb.mi/mi-complete.exp
@@ -26,7 +26,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debu
return -1
}
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
# Don't run to main to avoid increasing the search scope to include
# debug info of shared libraries like glibc, libgcc, etc.
diff --git a/gdb/testsuite/gdb.mi/mi-condbreak-call-thr-state.exp b/gdb/testsuite/gdb.mi/mi-condbreak-call-thr-state.exp
index 02d02b2..7708a6d 100644
--- a/gdb/testsuite/gdb.mi/mi-condbreak-call-thr-state.exp
+++ b/gdb/testsuite/gdb.mi/mi-condbreak-call-thr-state.exp
@@ -59,7 +59,7 @@ proc test { variant } {
return -1
}
- if {[mi_clean_restart $binfile]} {
+ if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-condbreak-fail.exp b/gdb/testsuite/gdb.mi/mi-condbreak-fail.exp
index 43b1e2f..5bd8993 100644
--- a/gdb/testsuite/gdb.mi/mi-condbreak-fail.exp
+++ b/gdb/testsuite/gdb.mi/mi-condbreak-fail.exp
@@ -35,7 +35,7 @@ if [build_executable ${testfile}.exp ${binfile} ${srcfile}] {
proc run_test { unwind_on_signal } {
- if {[mi_clean_restart $::binfile]} {
+ if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-condbreak-throw.exp b/gdb/testsuite/gdb.mi/mi-condbreak-throw.exp
index 0a89a8a..b4960a8 100644
--- a/gdb/testsuite/gdb.mi/mi-condbreak-throw.exp
+++ b/gdb/testsuite/gdb.mi/mi-condbreak-throw.exp
@@ -38,7 +38,7 @@ if [build_executable ${testfile}.exp ${binfile} ${srcfile} {debug c++}] {
proc run_test { unwind_on_exception } {
- if {[mi_clean_restart $::binfile]} {
+ if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-console.exp b/gdb/testsuite/gdb.mi/mi-console.exp
index efb1ea9..861ef42 100644
--- a/gdb/testsuite/gdb.mi/mi-console.exp
+++ b/gdb/testsuite/gdb.mi/mi-console.exp
@@ -53,7 +53,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-corefile.exp b/gdb/testsuite/gdb.mi/mi-corefile.exp
index 3f0e720..b491486 100644
--- a/gdb/testsuite/gdb.mi/mi-corefile.exp
+++ b/gdb/testsuite/gdb.mi/mi-corefile.exp
@@ -29,6 +29,7 @@ if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
set corefile [core_find $binfile {}]
if {$corefile == ""} {
+ untested "unable to create or find corefile"
return 0
}
diff --git a/gdb/testsuite/gdb.mi/mi-detach.exp b/gdb/testsuite/gdb.mi/mi-detach.exp
index ff983c1..b485a9b 100644
--- a/gdb/testsuite/gdb.mi/mi-detach.exp
+++ b/gdb/testsuite/gdb.mi/mi-detach.exp
@@ -25,7 +25,7 @@ if {[build_executable $testfile.exp $testfile $srcfile {debug}] == -1} {
return -1
}
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
mi_runto_main
mi_gdb_test "-target-detach" "=thread-exited,id=\"1\".*=thread-group-exited,id=\"i1\".*" "detach"
diff --git a/gdb/testsuite/gdb.mi/mi-disassemble.exp b/gdb/testsuite/gdb.mi/mi-disassemble.exp
index 15ead33..90f79e3 100644
--- a/gdb/testsuite/gdb.mi/mi-disassemble.exp
+++ b/gdb/testsuite/gdb.mi/mi-disassemble.exp
@@ -345,7 +345,7 @@ proc test_disassembly_opcode_format {} {
"data-disassemble checking the opcodes bytes format"
}
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
mi_runto_main
test_disassembly_only
test_disassembly_with_opcodes
diff --git a/gdb/testsuite/gdb.mi/mi-dlmopen.exp b/gdb/testsuite/gdb.mi/mi-dlmopen.exp
index c0208eb..0e1d0bc 100644
--- a/gdb/testsuite/gdb.mi/mi-dlmopen.exp
+++ b/gdb/testsuite/gdb.mi/mi-dlmopen.exp
@@ -65,9 +65,19 @@ if { $dyln_name eq "" } {
set bp_main [gdb_get_line_number "bp.main" $srcfile]
set bp_loaded [gdb_get_line_number "bp.loaded" $srcfile]
+# If the dynamic linker path contains a symlink, some instances show the real
+# path instead of the original path. Accept both.
+lassign [remote_exec target realpath "$dyln_name"] realpath_ret dyln_realpath_name
+
+if { $realpath_ret == 0 } {
+ set dyln_realpath_name [string trim $dyln_realpath_name]
+} else {
+ set dyln_realpath_name "not-a-valid-path"
+}
+
# Return true if FILENAME is the dynamic linker. Otherwise return false.
proc is_dyln { filename } {
- return [expr {$filename eq $::dyln_name}]
+ return [expr {$filename eq $::dyln_name || $filename eq $::dyln_realpath_name}]
}
# Run 'info sharedlibrary' and count the number of mappings that look
@@ -81,7 +91,7 @@ proc get_dyld_info {} {
set dyld_count 0
set dyld_start_addr ""
gdb_test_multiple "info sharedlibrary" "" {
- -re "~\"From\\s+To(\\s+NS)?\\s+Syms\\s+Read\\s+Shared Object Library\\\\n\"\r\n" {
+ -re "~\"From\\s+To(\\s+Linker NS)?\\s+Syms\\s+Read\\s+Shared Object Library\\\\n\"\r\n" {
exp_continue
}
-re "^~\"($::hex)\\s+${::hex}(\\s+$::decimal)?\\s+\[^/\]+(/\[^\r\n\]+)\\\\n\"\r\n" {
@@ -122,7 +132,7 @@ proc get_dyld_info {} {
# number of unload events for the libraries created for this test, and
# additionally, check for dynamic linker unload events.
proc check_solib_unload_events {} {
- mi_clean_restart $::binfile
+ mi_clean_restart $::testfile
if {[mi_runto_main] == -1} {
return
diff --git a/gdb/testsuite/gdb.mi/mi-dprintf-modified.exp b/gdb/testsuite/gdb.mi/mi-dprintf-modified.exp
index c3e1bdf..0584a86 100644
--- a/gdb/testsuite/gdb.mi/mi-dprintf-modified.exp
+++ b/gdb/testsuite/gdb.mi/mi-dprintf-modified.exp
@@ -52,7 +52,7 @@ if { [build_executable "build exec" $binfile $srcfile $opts] == -1} {
set bp_line [gdb_get_line_number "Break here" $srcfile]
# Start the inferior.
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
mi_runto_main
# Place a breakpoint at the dlopen() line.
diff --git a/gdb/testsuite/gdb.mi/mi-dprintf-pending.exp b/gdb/testsuite/gdb.mi/mi-dprintf-pending.exp
index 2df9ad4..3685e42 100644
--- a/gdb/testsuite/gdb.mi/mi-dprintf-pending.exp
+++ b/gdb/testsuite/gdb.mi/mi-dprintf-pending.exp
@@ -39,7 +39,7 @@ if {[gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != ""}
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-dprintf.exp b/gdb/testsuite/gdb.mi/mi-dprintf.exp
index 5d448e4..9d0b95a 100644
--- a/gdb/testsuite/gdb.mi/mi-dprintf.exp
+++ b/gdb/testsuite/gdb.mi/mi-dprintf.exp
@@ -31,7 +31,7 @@ if {[build_executable $testfile.exp $testfile $srcfile $flags] == -1} {
set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
set dp_location1 [gdb_get_line_number "set dprintf 1 here"]
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
mi_runto_main
set i 0
diff --git a/gdb/testsuite/gdb.mi/mi-eval.exp b/gdb/testsuite/gdb.mi/mi-eval.exp
index 27c27f5..2b21895 100644
--- a/gdb/testsuite/gdb.mi/mi-eval.exp
+++ b/gdb/testsuite/gdb.mi/mi-eval.exp
@@ -32,7 +32,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-exec-run.exp b/gdb/testsuite/gdb.mi/mi-exec-run.exp
index a7a61b8..43406cf 100644
--- a/gdb/testsuite/gdb.mi/mi-exec-run.exp
+++ b/gdb/testsuite/gdb.mi/mi-exec-run.exp
@@ -30,6 +30,8 @@ set MIFLAGS "-i=mi"
# cannot use it, then there is no point in running this testcase.
require !use_gdb_stub
+set have_startup_shell [have_startup_shell]
+
standard_testfile mi-start.c
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
@@ -172,6 +174,9 @@ remote_exec target "chmod \"a-x\" $binfile.nox"
foreach_with_prefix inferior-tty {"main" "separate"} {
foreach_with_prefix mi {"main" "separate"} {
foreach_with_prefix force-fail {0 1} {
+ if { ${force-fail} && $have_startup_shell == -1 } {
+ continue
+ }
test ${inferior-tty} ${mi} ${force-fail}
}
}
diff --git a/gdb/testsuite/gdb.mi/mi-exit-code.exp b/gdb/testsuite/gdb.mi/mi-exit-code.exp
index 344d565..af2c6bd 100644
--- a/gdb/testsuite/gdb.mi/mi-exit-code.exp
+++ b/gdb/testsuite/gdb.mi/mi-exit-code.exp
@@ -36,7 +36,7 @@ proc test_list_thread_groups { } {
"122\\^done,groups=\\\[\{id=\"i1\",type=\"process\"\}\]" \
"-list-thread-groups before run shows no exit-code"
- mi_clean_restart $binfile
+ mi_clean_restart $::testfile
with_test_prefix "first run" {
mi_runto_main
diff --git a/gdb/testsuite/gdb.mi/mi-fill-memory.exp b/gdb/testsuite/gdb.mi/mi-fill-memory.exp
index 0afc258..ab7e03a 100644
--- a/gdb/testsuite/gdb.mi/mi-fill-memory.exp
+++ b/gdb/testsuite/gdb.mi/mi-fill-memory.exp
@@ -27,7 +27,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}.c" "${binfile}" executable {d
return -1
}
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
mi_runto_main
mi_next_to "main" "" "mi-read-memory.c" "20" "next at main"
diff --git a/gdb/testsuite/gdb.mi/mi-fortran-modules.exp b/gdb/testsuite/gdb.mi/mi-fortran-modules.exp
index 8886702..48391bc 100644
--- a/gdb/testsuite/gdb.mi/mi-fortran-modules.exp
+++ b/gdb/testsuite/gdb.mi/mi-fortran-modules.exp
@@ -28,7 +28,7 @@ if {[build_executable "failed to prepare" ${testfile} \
return -1
}
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
mi_runto_main
diff --git a/gdb/testsuite/gdb.mi/mi-frame-regs.exp b/gdb/testsuite/gdb.mi/mi-frame-regs.exp
index f31e4a1..990abd5 100644
--- a/gdb/testsuite/gdb.mi/mi-frame-regs.exp
+++ b/gdb/testsuite/gdb.mi/mi-frame-regs.exp
@@ -62,7 +62,7 @@ proc_with_prefix do_floating_varobj_test {} {
global hex
global expect_out
- if {[mi_clean_restart $binfile]} {
+ if {[mi_clean_restart $::testfile]} {
fail "couldn't start gdb"
return
}
@@ -113,7 +113,7 @@ proc_with_prefix do_fixed_varobj_test {} {
global srcfile binfile
global hex
- if {[mi_clean_restart $binfile] != 0} {
+ if {[mi_clean_restart $::testfile] != 0} {
fail "couldn't start gdb"
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-fullname-deleted.exp b/gdb/testsuite/gdb.mi/mi-fullname-deleted.exp
index 130b5bf..6c1dbec 100644
--- a/gdb/testsuite/gdb.mi/mi-fullname-deleted.exp
+++ b/gdb/testsuite/gdb.mi/mi-fullname-deleted.exp
@@ -58,7 +58,7 @@ if { [gdb_compile "$srcfileabs" "${binfile}" executable {debug}] != "" } {
file delete -- $srcfileabs
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-info-os.exp b/gdb/testsuite/gdb.mi/mi-info-os.exp
index 5d8d3ff..c70dac6 100644
--- a/gdb/testsuite/gdb.mi/mi-info-os.exp
+++ b/gdb/testsuite/gdb.mi/mi-info-os.exp
@@ -32,7 +32,7 @@ if [build_executable "Failed to build $testfile" $testfile $srcfile \
return -1;
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-info-sources.exp b/gdb/testsuite/gdb.mi/mi-info-sources.exp
index f44fc29..80ca596 100644
--- a/gdb/testsuite/gdb.mi/mi-info-sources.exp
+++ b/gdb/testsuite/gdb.mi/mi-info-sources.exp
@@ -26,7 +26,7 @@ if {[build_executable $testfile.exp $testfile \
return -1
}
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
set readnow_p [mi_readnow]
diff --git a/gdb/testsuite/gdb.mi/mi-inheritance-syntax-error.exp b/gdb/testsuite/gdb.mi/mi-inheritance-syntax-error.exp
index 0ab2de2..3092b692 100644
--- a/gdb/testsuite/gdb.mi/mi-inheritance-syntax-error.exp
+++ b/gdb/testsuite/gdb.mi/mi-inheritance-syntax-error.exp
@@ -25,7 +25,7 @@ if {[gdb_compile $srcdir/$subdir/$srcfile $binfile executable {debug c++}] != ""
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-linespec-err-cp.exp b/gdb/testsuite/gdb.mi/mi-linespec-err-cp.exp
index 3314d5f..7eeb259 100644
--- a/gdb/testsuite/gdb.mi/mi-linespec-err-cp.exp
+++ b/gdb/testsuite/gdb.mi/mi-linespec-err-cp.exp
@@ -29,7 +29,7 @@ if {[build_executable "failed to prepare" $exefile $srcfile {debug c++}]} {
return -1
}
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
# Turn off the pending breakpoint queries.
mi_gdb_test "-interpreter-exec console \"set breakpoint pending off\"" \
diff --git a/gdb/testsuite/gdb.mi/mi-logging.exp b/gdb/testsuite/gdb.mi/mi-logging.exp
index de76e02..8235591 100644
--- a/gdb/testsuite/gdb.mi/mi-logging.exp
+++ b/gdb/testsuite/gdb.mi/mi-logging.exp
@@ -24,7 +24,7 @@ if [build_executable $testfile.exp $testfile $srcfile $opts] {
return -1
}
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
if {[mi_runto_main] < 0} {
return -1
diff --git a/gdb/testsuite/gdb.mi/mi-memory-changed.exp b/gdb/testsuite/gdb.mi/mi-memory-changed.exp
index bc2b6c3..6d02c33 100644
--- a/gdb/testsuite/gdb.mi/mi-memory-changed.exp
+++ b/gdb/testsuite/gdb.mi/mi-memory-changed.exp
@@ -22,7 +22,7 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
load_lib mi-support.exp
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-nonstop-exit.exp b/gdb/testsuite/gdb.mi/mi-nonstop-exit.exp
index 599e460..4729033 100644
--- a/gdb/testsuite/gdb.mi/mi-nonstop-exit.exp
+++ b/gdb/testsuite/gdb.mi/mi-nonstop-exit.exp
@@ -30,7 +30,7 @@ if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $option
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"set non-stop on\""
- mi_clean_restart $binfile
+ mi_clean_restart $::testfile
}
mi_gdb_test "-gdb-set mi-async 1" ".*"
diff --git a/gdb/testsuite/gdb.mi/mi-nonstop.exp b/gdb/testsuite/gdb.mi/mi-nonstop.exp
index b8efef7..1ba37a3 100644
--- a/gdb/testsuite/gdb.mi/mi-nonstop.exp
+++ b/gdb/testsuite/gdb.mi/mi-nonstop.exp
@@ -41,7 +41,7 @@ if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $option
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"set non-stop on\""
- mi_clean_restart $binfile
+ mi_clean_restart $::testfile
}
mi_gdb_test "-gdb-set mi-async 1" ".*"
diff --git a/gdb/testsuite/gdb.mi/mi-ns-stale-regcache.exp b/gdb/testsuite/gdb.mi/mi-ns-stale-regcache.exp
index 20d9e45..20936f1 100644
--- a/gdb/testsuite/gdb.mi/mi-ns-stale-regcache.exp
+++ b/gdb/testsuite/gdb.mi/mi-ns-stale-regcache.exp
@@ -43,7 +43,7 @@ if {[gdb_compile "$srcdir/$subdir/$srcfile" \
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"set non-stop on\""
- mi_clean_restart $binfile
+ mi_clean_restart $::testfile
}
mi_gdb_test "-gdb-set mi-async 1" ".*"
diff --git a/gdb/testsuite/gdb.mi/mi-nsintrall.exp b/gdb/testsuite/gdb.mi/mi-nsintrall.exp
index 983c0fe..8c8aef8 100644
--- a/gdb/testsuite/gdb.mi/mi-nsintrall.exp
+++ b/gdb/testsuite/gdb.mi/mi-nsintrall.exp
@@ -30,7 +30,7 @@ if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $option
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"set non-stop on\""
- mi_clean_restart $binfile
+ mi_clean_restart $::testfile
}
mi_gdb_test "-gdb-set mi-async 1" ".*"
diff --git a/gdb/testsuite/gdb.mi/mi-nsmoribund.exp b/gdb/testsuite/gdb.mi/mi-nsmoribund.exp
index da43a93..2307c2e 100644
--- a/gdb/testsuite/gdb.mi/mi-nsmoribund.exp
+++ b/gdb/testsuite/gdb.mi/mi-nsmoribund.exp
@@ -30,7 +30,7 @@ if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $option
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"set non-stop on\""
- mi_clean_restart $binfile
+ mi_clean_restart $::testfile
}
mi_gdb_test "-gdb-set mi-async 1" ".*"
diff --git a/gdb/testsuite/gdb.mi/mi-nsthrexec.exp b/gdb/testsuite/gdb.mi/mi-nsthrexec.exp
index fd8aa54..1f9d1ae 100644
--- a/gdb/testsuite/gdb.mi/mi-nsthrexec.exp
+++ b/gdb/testsuite/gdb.mi/mi-nsthrexec.exp
@@ -35,7 +35,7 @@ if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $option
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"set non-stop on\""
- mi_clean_restart $binfile
+ mi_clean_restart $::testfile
}
mi_gdb_test "-gdb-set mi-async 1" ".*"
diff --git a/gdb/testsuite/gdb.mi/mi-pending.exp b/gdb/testsuite/gdb.mi/mi-pending.exp
index 49839cb..eb0719c 100644
--- a/gdb/testsuite/gdb.mi/mi-pending.exp
+++ b/gdb/testsuite/gdb.mi/mi-pending.exp
@@ -45,7 +45,7 @@ if { [gdb_compile_pthreads $srcdir/$subdir/$srcfile $binfile executable $exec_op
}
# Start with a fresh gdb.
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
mi_load_shlibs $lib_sl1
diff --git a/gdb/testsuite/gdb.mi/mi-pthreads.exp b/gdb/testsuite/gdb.mi/mi-pthreads.exp
index 93f0344..117b2de 100644
--- a/gdb/testsuite/gdb.mi/mi-pthreads.exp
+++ b/gdb/testsuite/gdb.mi/mi-pthreads.exp
@@ -63,7 +63,7 @@ if {[gdb_compile_pthreads "$srcdir/$subdir/$srcfile" $binfile executable $option
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-py-modify-bp.exp b/gdb/testsuite/gdb.mi/mi-py-modify-bp.exp
index 4193757..5175899 100644
--- a/gdb/testsuite/gdb.mi/mi-py-modify-bp.exp
+++ b/gdb/testsuite/gdb.mi/mi-py-modify-bp.exp
@@ -31,7 +31,7 @@ if {[build_executable $testfile.exp $testfile $srcfile] == -1} {
set remote_python_file [gdb_remote_download host \
${srcdir}/${subdir}/${testfile}.py]
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
mi_runto_main
# Delete all breakpoints, watchpoints, tracepoints, and catchpoints.
diff --git a/gdb/testsuite/gdb.mi/mi-read-memory.exp b/gdb/testsuite/gdb.mi/mi-read-memory.exp
index 8de8728..4469123 100644
--- a/gdb/testsuite/gdb.mi/mi-read-memory.exp
+++ b/gdb/testsuite/gdb.mi/mi-read-memory.exp
@@ -25,7 +25,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
mi_runto_main
mi_next_to "main" "" "mi-read-memory.c" "20" "next at main"
diff --git a/gdb/testsuite/gdb.mi/mi-record-changed.exp b/gdb/testsuite/gdb.mi/mi-record-changed.exp
index e37540b..986efd9 100644
--- a/gdb/testsuite/gdb.mi/mi-record-changed.exp
+++ b/gdb/testsuite/gdb.mi/mi-record-changed.exp
@@ -24,7 +24,7 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
load_lib mi-support.exp
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
mi_runto_main
diff --git a/gdb/testsuite/gdb.mi/mi-reg-undefined.exp b/gdb/testsuite/gdb.mi/mi-reg-undefined.exp
index c7e0564..ef102ce 100644
--- a/gdb/testsuite/gdb.mi/mi-reg-undefined.exp
+++ b/gdb/testsuite/gdb.mi/mi-reg-undefined.exp
@@ -29,7 +29,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-regs.exp b/gdb/testsuite/gdb.mi/mi-regs.exp
index 0bb305b..aae00a6 100644
--- a/gdb/testsuite/gdb.mi/mi-regs.exp
+++ b/gdb/testsuite/gdb.mi/mi-regs.exp
@@ -108,7 +108,7 @@ require {istarget "sparc-*-*"}
mi_clean_restart
sparc_register_tests_no_exec
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
mi_runto_main
sparc_register_tests
diff --git a/gdb/testsuite/gdb.mi/mi-return.exp b/gdb/testsuite/gdb.mi/mi-return.exp
index ba296d5..998a1ff 100644
--- a/gdb/testsuite/gdb.mi/mi-return.exp
+++ b/gdb/testsuite/gdb.mi/mi-return.exp
@@ -31,7 +31,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-reverse.exp b/gdb/testsuite/gdb.mi/mi-reverse.exp
index d039240..aa25255 100644
--- a/gdb/testsuite/gdb.mi/mi-reverse.exp
+++ b/gdb/testsuite/gdb.mi/mi-reverse.exp
@@ -39,7 +39,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
mi_runto_main
if [supports_process_record] {
diff --git a/gdb/testsuite/gdb.mi/mi-simplerun.exp b/gdb/testsuite/gdb.mi/mi-simplerun.exp
index e390f14..5ee7881 100644
--- a/gdb/testsuite/gdb.mi/mi-simplerun.exp
+++ b/gdb/testsuite/gdb.mi/mi-simplerun.exp
@@ -34,7 +34,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-solib.exp b/gdb/testsuite/gdb.mi/mi-solib.exp
index c66d4b0..8ddca8d 100644
--- a/gdb/testsuite/gdb.mi/mi-solib.exp
+++ b/gdb/testsuite/gdb.mi/mi-solib.exp
@@ -34,7 +34,7 @@ if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != ""
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-stack.exp b/gdb/testsuite/gdb.mi/mi-stack.exp
index a91b76e..89f58c8 100644
--- a/gdb/testsuite/gdb.mi/mi-stack.exp
+++ b/gdb/testsuite/gdb.mi/mi-stack.exp
@@ -32,7 +32,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-start.exp b/gdb/testsuite/gdb.mi/mi-start.exp
index 745e5c9..d384230 100644
--- a/gdb/testsuite/gdb.mi/mi-start.exp
+++ b/gdb/testsuite/gdb.mi/mi-start.exp
@@ -28,7 +28,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-stepi.exp b/gdb/testsuite/gdb.mi/mi-stepi.exp
index 8ba6399..7f53c8b 100644
--- a/gdb/testsuite/gdb.mi/mi-stepi.exp
+++ b/gdb/testsuite/gdb.mi/mi-stepi.exp
@@ -63,7 +63,7 @@ proc test_stepi_nexti {} {
}
}
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
mi_runto_main
test_stepi_nexti
diff --git a/gdb/testsuite/gdb.mi/mi-stepn.exp b/gdb/testsuite/gdb.mi/mi-stepn.exp
index 489564a..f11e9c0 100644
--- a/gdb/testsuite/gdb.mi/mi-stepn.exp
+++ b/gdb/testsuite/gdb.mi/mi-stepn.exp
@@ -26,7 +26,7 @@ if [build_executable ${testfile}.exp ${testfile} ${srcfile} $opts] {
return -1
}
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
if {[mi_runto_main] < 0} {
return -1
diff --git a/gdb/testsuite/gdb.mi/mi-sym-info.exp b/gdb/testsuite/gdb.mi/mi-sym-info.exp
index ef8dd86..6b0bf2d 100644
--- a/gdb/testsuite/gdb.mi/mi-sym-info.exp
+++ b/gdb/testsuite/gdb.mi/mi-sym-info.exp
@@ -33,7 +33,7 @@ if {[build_executable "failed to prepare" ${testfile} \
return -1
}
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
# Don't run to main to avoid increasing the search scope to include
# debug info of shared libraries like libc, libgcc, etc.
diff --git a/gdb/testsuite/gdb.mi/mi-syn-frame.exp b/gdb/testsuite/gdb.mi/mi-syn-frame.exp
index 633f317..b3ec377 100644
--- a/gdb/testsuite/gdb.mi/mi-syn-frame.exp
+++ b/gdb/testsuite/gdb.mi/mi-syn-frame.exp
@@ -29,7 +29,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
mi_runto_main
diff --git a/gdb/testsuite/gdb.mi/mi-thread-bp-deleted.exp b/gdb/testsuite/gdb.mi/mi-thread-bp-deleted.exp
index 2a734c8..976b68d 100644
--- a/gdb/testsuite/gdb.mi/mi-thread-bp-deleted.exp
+++ b/gdb/testsuite/gdb.mi/mi-thread-bp-deleted.exp
@@ -47,7 +47,7 @@ foreach_mi_ui_mode mode {
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"maint set target-non-stop on\""
append GDBFLAGS " -ex \"set mi-async on\""
- mi_clean_restart $binfile $start_ops
+ mi_clean_restart $::testfile $start_ops
}
mi_runto_main
diff --git a/gdb/testsuite/gdb.mi/mi-thread-specific-bp.exp b/gdb/testsuite/gdb.mi/mi-thread-specific-bp.exp
index 86d050a..81ff274 100644
--- a/gdb/testsuite/gdb.mi/mi-thread-specific-bp.exp
+++ b/gdb/testsuite/gdb.mi/mi-thread-specific-bp.exp
@@ -90,7 +90,7 @@ foreach_mi_ui_mode mode {
set start_ops ""
}
- if {[mi_clean_restart $binfile $start_ops]} {
+ if {[mi_clean_restart $::testfile $start_ops]} {
break
}
diff --git a/gdb/testsuite/gdb.mi/mi-threads-interrupt.exp b/gdb/testsuite/gdb.mi/mi-threads-interrupt.exp
index ff74e7b..8aab3b8 100644
--- a/gdb/testsuite/gdb.mi/mi-threads-interrupt.exp
+++ b/gdb/testsuite/gdb.mi/mi-threads-interrupt.exp
@@ -33,7 +33,7 @@ proc test_continue_interrupt { } {
global binfile
global async
- if {[mi_clean_restart $binfile]} {
+ if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-until.exp b/gdb/testsuite/gdb.mi/mi-until.exp
index ee50c4f..e8f24bc 100644
--- a/gdb/testsuite/gdb.mi/mi-until.exp
+++ b/gdb/testsuite/gdb.mi/mi-until.exp
@@ -31,7 +31,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-var-block.exp b/gdb/testsuite/gdb.mi/mi-var-block.exp
index bdba639..3914c3a 100644
--- a/gdb/testsuite/gdb.mi/mi-var-block.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-block.exp
@@ -29,7 +29,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-var-child-f.exp b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
index c424490..4856e3d 100644
--- a/gdb/testsuite/gdb.mi/mi-var-child-f.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
@@ -28,7 +28,7 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-var-child.exp b/gdb/testsuite/gdb.mi/mi-var-child.exp
index 89ce9dd..4a3ba07 100644
--- a/gdb/testsuite/gdb.mi/mi-var-child.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-child.exp
@@ -29,7 +29,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-var-cmd.exp b/gdb/testsuite/gdb.mi/mi-var-cmd.exp
index 8c8c306..9e7b14c 100644
--- a/gdb/testsuite/gdb.mi/mi-var-cmd.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-cmd.exp
@@ -29,7 +29,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-var-cp.exp b/gdb/testsuite/gdb.mi/mi-var-cp.exp
index c1d70f1..eee1007 100644
--- a/gdb/testsuite/gdb.mi/mi-var-cp.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-cp.exp
@@ -25,7 +25,7 @@ if {[gdb_compile $srcdir/$subdir/$srcfile $binfile executable {debug c++}] != ""
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-var-create-rtti.exp b/gdb/testsuite/gdb.mi/mi-var-create-rtti.exp
index ad6ce5c..517449c 100644
--- a/gdb/testsuite/gdb.mi/mi-var-create-rtti.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-create-rtti.exp
@@ -23,7 +23,7 @@ if [build_executable $testfile.exp $testfile $srcfile $opts] {
return -1
}
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
if {[mi_runto_main] < 0} {
return -1
diff --git a/gdb/testsuite/gdb.mi/mi-var-display.exp b/gdb/testsuite/gdb.mi/mi-var-display.exp
index 5535368..3ae593b 100644
--- a/gdb/testsuite/gdb.mi/mi-var-display.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-display.exp
@@ -29,7 +29,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-var-invalidate.exp b/gdb/testsuite/gdb.mi/mi-var-invalidate.exp
index c1c52f2..800c22f 100644
--- a/gdb/testsuite/gdb.mi/mi-var-invalidate.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-invalidate.exp
@@ -44,7 +44,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {d
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-var-list-children-invalid-grandchild.exp b/gdb/testsuite/gdb.mi/mi-var-list-children-invalid-grandchild.exp
index 0f20c50f..597e2e0 100644
--- a/gdb/testsuite/gdb.mi/mi-var-list-children-invalid-grandchild.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-list-children-invalid-grandchild.exp
@@ -26,7 +26,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-var-rtti.exp b/gdb/testsuite/gdb.mi/mi-var-rtti.exp
index fcf8404..c2768b6 100644
--- a/gdb/testsuite/gdb.mi/mi-var-rtti.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-rtti.exp
@@ -25,7 +25,7 @@ if [build_executable $testfile.exp $testfile $srcfile $opts] {
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-vla-c99.exp b/gdb/testsuite/gdb.mi/mi-vla-c99.exp
index ec12e6f..5f23d05 100644
--- a/gdb/testsuite/gdb.mi/mi-vla-c99.exp
+++ b/gdb/testsuite/gdb.mi/mi-vla-c99.exp
@@ -29,7 +29,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" \
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-vla-fortran.exp b/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
index 5077089..81e2d89 100644
--- a/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
+++ b/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
@@ -34,7 +34,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
# the type names can be printed differently.
set real [fortran_real4]
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi-watch-nonstop.exp b/gdb/testsuite/gdb.mi/mi-watch-nonstop.exp
index f9237c0..36d7410 100644
--- a/gdb/testsuite/gdb.mi/mi-watch-nonstop.exp
+++ b/gdb/testsuite/gdb.mi/mi-watch-nonstop.exp
@@ -38,7 +38,7 @@ if {[gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable {debug}] != "" }
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"set non-stop on\""
- mi_clean_restart $binfile
+ mi_clean_restart $::testfile
}
mi_gdb_test "-gdb-set mi-async 1" ".*"
diff --git a/gdb/testsuite/gdb.mi/mi-watch.exp b/gdb/testsuite/gdb.mi/mi-watch.exp
index e318a2b..43f2378 100644
--- a/gdb/testsuite/gdb.mi/mi-watch.exp
+++ b/gdb/testsuite/gdb.mi/mi-watch.exp
@@ -155,7 +155,7 @@ proc test_watchpoint_all {mi_mode type} {
} else {
set start_ops ""
}
- if [mi_clean_restart ${binfile} $start_ops] {
+ if [mi_clean_restart ${::testfile} $start_ops] {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp b/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
index c7e21e9..0d51dc5 100644
--- a/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
+++ b/gdb/testsuite/gdb.mi/mi2-amd64-entry-value.exp
@@ -31,7 +31,7 @@ if [build_executable ${testfile}.exp ${binfile} ${srcfile} $opts] {
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi2-cli-display.exp b/gdb/testsuite/gdb.mi/mi2-cli-display.exp
index 656c93e..993b87c 100644
--- a/gdb/testsuite/gdb.mi/mi2-cli-display.exp
+++ b/gdb/testsuite/gdb.mi/mi2-cli-display.exp
@@ -25,7 +25,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/mi2-var-child.exp b/gdb/testsuite/gdb.mi/mi2-var-child.exp
index 9bd9054..3618d5a 100644
--- a/gdb/testsuite/gdb.mi/mi2-var-child.exp
+++ b/gdb/testsuite/gdb.mi/mi2-var-child.exp
@@ -29,7 +29,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.mi/new-ui-mi-sync.exp b/gdb/testsuite/gdb.mi/new-ui-mi-sync.exp
index cb83329..7112248 100644
--- a/gdb/testsuite/gdb.mi/new-ui-mi-sync.exp
+++ b/gdb/testsuite/gdb.mi/new-ui-mi-sync.exp
@@ -102,7 +102,7 @@ proc do_test {sync_command} {
}
foreach_with_prefix sync-command {"run" "continue"} {
- if {[mi_clean_restart $binfile "separate-mi-tty"] != 0} {
+ if {[mi_clean_restart $::testfile "separate-mi-tty"] != 0} {
fail "could not start gdb"
break
}
diff --git a/gdb/testsuite/gdb.mi/pr11022.exp b/gdb/testsuite/gdb.mi/pr11022.exp
index ad8e3b2..1e01bf6 100644
--- a/gdb/testsuite/gdb.mi/pr11022.exp
+++ b/gdb/testsuite/gdb.mi/pr11022.exp
@@ -29,7 +29,7 @@ proc test_memory_changed_observer { mi_command } {
with_test_prefix "${mi_command}" {
global srcfile binfile
- mi_clean_restart $binfile
+ mi_clean_restart $::testfile
mi_runto_main
set line_number [gdb_get_line_number "break here"]
diff --git a/gdb/testsuite/gdb.mi/print-simple-values.exp b/gdb/testsuite/gdb.mi/print-simple-values.exp
index 1c56d68..23488e3 100644
--- a/gdb/testsuite/gdb.mi/print-simple-values.exp
+++ b/gdb/testsuite/gdb.mi/print-simple-values.exp
@@ -34,7 +34,7 @@ if [build_executable "failed to prepare" $testfile $srcfile $opts] {
return -1
}
-if [mi_clean_restart $binfile] {
+if [mi_clean_restart $::testfile] {
return
}
diff --git a/gdb/testsuite/gdb.mi/run-with-two-mi-uis.exp b/gdb/testsuite/gdb.mi/run-with-two-mi-uis.exp
index df370c9..c9e352d 100644
--- a/gdb/testsuite/gdb.mi/run-with-two-mi-uis.exp
+++ b/gdb/testsuite/gdb.mi/run-with-two-mi-uis.exp
@@ -29,7 +29,7 @@ if {[build_executable $testfile.exp $testfile ${srcfile} "debug"] == -1} {
# UI_TO_RUN is the UI that should issue the run command.
proc do_test { ui_to_run } {
- if {[mi_clean_restart $::binfile "separate-mi-tty"] != 0} {
+ if {[mi_clean_restart $::testfile "separate-mi-tty"] != 0} {
fail "could not start gdb"
return
}
diff --git a/gdb/testsuite/gdb.mi/user-selected-context-sync.exp b/gdb/testsuite/gdb.mi/user-selected-context-sync.exp
index f85e108..a0bf11f 100644
--- a/gdb/testsuite/gdb.mi/user-selected-context-sync.exp
+++ b/gdb/testsuite/gdb.mi/user-selected-context-sync.exp
@@ -1329,7 +1329,7 @@ foreach_with_prefix mode { "all-stop" "non-stop" } {
set GDBFLAGS [concat $GDBFLAGS " -ex \"set non-stop 1\""]
}
- if { [mi_clean_restart $binfile "separate-mi-tty"] != 0 } {
+ if { [mi_clean_restart $::testfile "separate-mi-tty"] != 0 } {
break
}
}
diff --git a/gdb/testsuite/gdb.multi/attach-no-multi-process.exp b/gdb/testsuite/gdb.multi/attach-no-multi-process.exp
index 502f309..2813fa9 100644
--- a/gdb/testsuite/gdb.multi/attach-no-multi-process.exp
+++ b/gdb/testsuite/gdb.multi/attach-no-multi-process.exp
@@ -44,7 +44,7 @@ proc test {target_non_stop} {
"${::GDBFLAGS} -ex \"set remote multiprocess-feature-packet off\""
set ::GDBFLAGS \
"${::GDBFLAGS} -ex \"maint set target-non-stop ${target_non_stop}\""
- clean_restart ${binfile}
+ clean_restart ${::testfile}
}
# Start the first inferior.
diff --git a/gdb/testsuite/gdb.multi/attach-while-running.exp b/gdb/testsuite/gdb.multi/attach-while-running.exp
index 723ebb2..4eb500e 100644
--- a/gdb/testsuite/gdb.multi/attach-while-running.exp
+++ b/gdb/testsuite/gdb.multi/attach-while-running.exp
@@ -46,7 +46,7 @@ if { [build_executable "failed to prepare" ${testfile} ${srcfile}] } {
proc do_test {} {
save_vars { ::GDBFLAGS } {
append ::GDBFLAGS " -ex \"maint set target-non-stop on\""
- clean_restart $::binfile
+ clean_restart $::testfile
}
gdb_test -no-prompt-anchor "run &"
diff --git a/gdb/testsuite/gdb.multi/gdb-settings.exp b/gdb/testsuite/gdb.multi/gdb-settings.exp
index b1acca0..97961f5 100644
--- a/gdb/testsuite/gdb.multi/gdb-settings.exp
+++ b/gdb/testsuite/gdb.multi/gdb-settings.exp
@@ -44,7 +44,7 @@ set run [expr {![use_gdb_stub]}]
set inferiors {1 2}
# Start all the inferiors.
-clean_restart $binfile
+clean_restart $::testfile
foreach_with_prefix inf $inferiors {
if { $inf > 1 } {
gdb_test "add-inferior -exec $binfile" "Added inferior 2.*" \
@@ -71,6 +71,7 @@ foreach_with_prefix inf $inferiors {
gdb_test_no_output "set args inf${inf}-args"
gdb_test_no_output "set cwd /inf${inf}-cwd"
gdb_test_no_output "set inferior-tty /inf${inf}-tty"
+ gdb_test_no_output "set remote exec-file /inf${inf}-remote-exec"
}
# Check settings are still correct for each inferior.
@@ -88,6 +89,9 @@ foreach_with_prefix inf $inferiors {
gdb_test "with inferior-tty tmp-value -- print 1" " = 1"
gdb_test "show inferior-tty" "/inf${inf}-tty.*"
+ gdb_test "with remote exec-file tmp-value -- print 1" " = 1"
+ gdb_test "show remote exec-file" "/inf${inf}-remote-exec.*"
+
# If the inferiors are running check $_gdb_setting_str and
# $_gdb_setting return the correct values.
if { $run } {
@@ -101,6 +105,11 @@ foreach_with_prefix inf $inferiors {
"\"/inf${inf}-tty\""
gdb_test {print $_gdb_setting("inferior-tty")} \
"\"/inf${inf}-tty\""
+
+ gdb_test {print $_gdb_setting_str("remote exec-file")} \
+ "\"/inf${inf}-remote-exec\""
+ gdb_test {print $_gdb_setting("remote exec-file")} \
+ "\"/inf${inf}-remote-exec\""
}
# Check the settings can be read from Python.
@@ -109,6 +118,8 @@ foreach_with_prefix inf $inferiors {
gdb_test "python print(gdb.parameter('cwd'))" "/inf${inf}-cwd"
gdb_test "python print(gdb.parameter('inferior-tty'))" \
"/inf${inf}-tty"
+ gdb_test "python print(gdb.parameter('remote exec-file'))" \
+ "/inf${inf}-remote-exec"
}
# Check the settings can be read from Guile.
@@ -119,5 +130,7 @@ foreach_with_prefix inf $inferiors {
"/inf${inf}-cwd"
gdb_test "guile (print (parameter-value \"inferior-tty\"))" \
"/inf${inf}-tty"
+ gdb_test "guile (print (parameter-value \"remote exec-file\"))" \
+ "/inf${inf}-remote-exec"
}
}
diff --git a/gdb/testsuite/gdb.multi/inferior-specific-bp.exp b/gdb/testsuite/gdb.multi/inferior-specific-bp.exp
index db09095..6d2fc9e 100644
--- a/gdb/testsuite/gdb.multi/inferior-specific-bp.exp
+++ b/gdb/testsuite/gdb.multi/inferior-specific-bp.exp
@@ -22,8 +22,10 @@ if {[use_gdb_stub]} {
}
set srcfile1 ${srcfile}
-set binfile1 ${binfile}-1
-set binfile2 ${binfile}-2
+set testfile1 $testfile-1
+set testfile2 $testfile-2
+set binfile1 [standard_output_file $testfile1]
+set binfile2 [standard_output_file $testfile2]
if {[build_executable ${testfile}.exp ${binfile1} "${srcfile1}"] != 0} {
return -1
@@ -34,7 +36,7 @@ if {[build_executable ${testfile}.exp ${binfile2} "${srcfile2}"] != 0} {
}
# Start the first inferior.
-clean_restart ${binfile1}
+clean_restart $testfile1
if {![runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.multi/interrupt-bg-exec.c b/gdb/testsuite/gdb.multi/interrupt-bg-exec.c
new file mode 100644
index 0000000..b5fa568
--- /dev/null
+++ b/gdb/testsuite/gdb.multi/interrupt-bg-exec.c
@@ -0,0 +1,47 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2025 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 <unistd.h>
+
+volatile int wait_for_gdb = 1;
+
+void
+breakpt (void)
+{
+ /* Nothing. */
+}
+
+void
+all_started (void)
+{
+ /* Nothing. */
+}
+
+int
+main (void)
+{
+ alarm (360);
+
+ all_started ();
+
+ while (wait_for_gdb)
+ sleep (1);
+
+ breakpt ();
+
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.multi/interrupt-bg-exec.exp b/gdb/testsuite/gdb.multi/interrupt-bg-exec.exp
new file mode 100644
index 0000000..065a112
--- /dev/null
+++ b/gdb/testsuite/gdb.multi/interrupt-bg-exec.exp
@@ -0,0 +1,143 @@
+# Copyright 2025 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/>.
+
+# In all-stop mode, set one inferior running in the background, then
+# continue a second inferior. When the second inferior hits a breakpoint,
+# both inferiors should be stopped.
+
+# This tests the use of native and remote targets. If we try to run
+# it with a board that forces native targets to become remote, then
+# this doesn't really make sense (for this test).
+require {string equal [target_info gdb_protocol] ""}
+
+source $srcdir/$subdir/multi-target.exp.tcl
+
+load_lib gdbserver-support.exp
+
+require allow_gdbserver_tests
+
+# This overrides the call in multi-target.exp.tcl.
+standard_testfile
+
+if { [build_executable "failed to build" $testfile $srcfile] } {
+ return
+}
+
+# Start two inferiors, TARGET_TYPE_1 and TARGET_TYPE_2 are strings, either
+# 'extended-remote' or 'native', and control the connection type of each
+# inferior.
+#
+# Set the first inferior running in the background, then continue theA
+# second inferior allowing it to hit a breakpoint.
+#
+# Once the breakpoint is hit, both inferiors should be stopped.
+proc run_test { target_type_1 target_type_2 } {
+ cleanup_gdbservers
+
+ clean_restart
+
+ gdb_test "disconnect" ".*"
+
+ gdb_test_no_output "set sysroot"
+
+ # multi-target depends on target running in non-stop mode. Force it
+ # on for remote targets, until this is the default.
+ gdb_test_no_output "maint set target-non-stop on"
+
+ # Run in all-stop mode.
+ gdb_test_no_output "set non-stop off"
+
+ if {![add_inferior 2 $target_type_1 $::binfile]} {
+ return 0
+ }
+
+ if {![add_inferior 3 $target_type_2 $::binfile]} {
+ return 0
+ }
+
+ # Check we see all the expected threads.
+ gdb_test "info threads" \
+ [multi_line \
+ "\\s+Id\\s+Target Id\\s+Frame\\s*" \
+ "\\s+2\\.1\\s+\[^\r\n\]+" \
+ "\\*\\s+3\\.1\\s+\[^\r\n\]+"] \
+ "check expected threads exist"
+
+ # The breakpoint will be set in both inferiors, but only inferior 3
+ # will hit it as 'wait_for_gdb' is cleared only in that inferior.
+ gdb_breakpoint breakpt
+ gdb_test "thread apply 3.1 set wait_for_gdb = 0"
+
+ # Let inferior 2 run in the background.
+ gdb_test "thread 2.1"
+ gdb_test -no-prompt-anchor "continue&"
+
+ # Run inferior 3 until it hits a breakpoint.
+ gdb_test "thread 3.1"
+ gdb_test "continue" \
+ [multi_line \
+ "Thread 3\\.1 \[^\r\n\]+ hit Breakpoint \[^\r\n\]+, breakpt \\(\\) \[^\r\n\]+" \
+ "$::decimal\\s+\[^\r\n\]+"] \
+ "continue to breakpt function"
+
+ # Check the state of all threads. None should be running.
+ set saw_inferior_2 false
+ set saw_inferior_3 false
+ gdb_test_multiple "info threads" "check threads after stop" {
+ -re "^info threads\r\n" {
+ exp_continue
+ }
+
+ -re "^\\s+Id\\s+Target Id\\s+Frame\\s*\r\n" {
+ exp_continue
+ }
+
+ -re "^\\s+2\\.1\\s+\[^\r\n\]+\\s+\\(running\\)\\s*\r\n" {
+ # Don't count this as seeing inferior 2 as the thread is
+ # incorrectly still marked as running. By not setting the
+ # SAW_INFERIOR_2 flag this test will now fail.
+ exp_continue
+ }
+
+ -re "^\\s+2\\.1\\s+\[^\r\n\]+\r\n" {
+ set saw_inferior_2 true
+ exp_continue
+ }
+
+ -re "^\\*\\s+3\\.1\\s+\[^\r\n\]+\r\n" {
+ set saw_inferior_3 true
+ exp_continue
+ }
+
+ -re "^$::gdb_prompt $" {
+ gdb_assert { $saw_inferior_2 && $saw_inferior_3 } \
+ $gdb_test_name
+ }
+
+ -re "^\[^\r\n\]*\r\n" {
+ exp_continue
+ }
+ }
+}
+
+set all_target_types { extended-remote native }
+
+foreach_with_prefix target_type_1 $all_target_types {
+ foreach_with_prefix target_type_2 $all_target_types {
+ run_test $target_type_1 $target_type_2
+ }
+}
+
+multi_target_cleanup
diff --git a/gdb/testsuite/gdb.multi/multi-arch-exec.exp b/gdb/testsuite/gdb.multi/multi-arch-exec.exp
index 69c6b13..435efc5 100644
--- a/gdb/testsuite/gdb.multi/multi-arch-exec.exp
+++ b/gdb/testsuite/gdb.multi/multi-arch-exec.exp
@@ -23,7 +23,7 @@ require !use_gdb_stub
# The 64-bit compile may succeed for i386-linux, but gdb won't be able
# to load the file.
-if [istarget "i?86-*linux*"] {
+if {[istarget "i?86-*linux*"]} {
return
}
@@ -69,9 +69,9 @@ proc append_arch2_options {options_var} {
}
}
- if [istarget "powerpc64*-*-*"] {
+ if {[istarget "powerpc64*-*-*"]} {
set march "-m64"
- } elseif [istarget "s390*-*-*"] {
+ } elseif {[istarget "s390*-*-*"]} {
set march "-m31"
} else {
set march "-m32"
diff --git a/gdb/testsuite/gdb.multi/multi-arch.exp b/gdb/testsuite/gdb.multi/multi-arch.exp
index 1d41ba5..b75009d 100644
--- a/gdb/testsuite/gdb.multi/multi-arch.exp
+++ b/gdb/testsuite/gdb.multi/multi-arch.exp
@@ -25,7 +25,7 @@ require !use_gdb_stub
# The 64-bit compile may succeed for i386-linux, but gdb won't be able
# to load the file.
-if [istarget "i?86-*linux*"] {
+if {[istarget "i?86-*linux*"]} {
return
}
@@ -41,7 +41,7 @@ set binfile2 [standard_output_file ${exec2}]
# Build two executables, one for each arch.
-if [istarget "s390*-*-*"] {
+if {[istarget "s390*-*-*"]} {
set march1 "-m64"
set march2 "-m31"
} elseif { [istarget "aarch64*-*-*"] } {
@@ -67,7 +67,7 @@ if { [build_executable "failed to prepare" ${exec1} "${srcfile1}" \
set options [list debug]
-if [istarget "aarch64*-*-*"] {
+if {[istarget "aarch64*-*-*"]} {
if {[arm_cc_for_target] != ""} {
lappend options "compiler=[arm_cc_for_target]"
} else {
diff --git a/gdb/testsuite/gdb.multi/multi-exit.exp b/gdb/testsuite/gdb.multi/multi-exit.exp
index 8393067..fcd7cd2 100644
--- a/gdb/testsuite/gdb.multi/multi-exit.exp
+++ b/gdb/testsuite/gdb.multi/multi-exit.exp
@@ -36,7 +36,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile]} {
# Hence, go with the all-stop-on-top-of-non-stop mode.
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"maint set target-non-stop on\""
- clean_restart ${binfile}
+ clean_restart ${::testfile}
}
# Start inferior NUM.
diff --git a/gdb/testsuite/gdb.multi/multi-kill.exp b/gdb/testsuite/gdb.multi/multi-kill.exp
index 7d66ab0..1473372 100644
--- a/gdb/testsuite/gdb.multi/multi-kill.exp
+++ b/gdb/testsuite/gdb.multi/multi-kill.exp
@@ -36,7 +36,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile {debug}]} {
# Hence, go with the all-stop-on-top-of-non-stop mode.
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"maint set target-non-stop on\""
- clean_restart ${binfile}
+ clean_restart ${::testfile}
}
# Wrap the entire test in a namespace to avoid contaminating other tests.
diff --git a/gdb/testsuite/gdb.multi/multi-re-run.exp b/gdb/testsuite/gdb.multi/multi-re-run.exp
index 4caadea..89d43a4 100644
--- a/gdb/testsuite/gdb.multi/multi-re-run.exp
+++ b/gdb/testsuite/gdb.multi/multi-re-run.exp
@@ -24,23 +24,23 @@ require allow_multi_inferior_tests
# Build two executables, with different symbols.
-set exec1 "multi-re-run-1"
+set testfile1 "multi-re-run-1"
set srcfile1 multi-re-run-1.c
-set binfile1 [standard_output_file ${exec1}]
+set binfile1 [standard_output_file $testfile1]
-set exec2 "multi-re-run-2"
+set testfile2 "multi-re-run-2"
set srcfile2 multi-re-run-2.c
-set binfile2 [standard_output_file ${exec2}]
+set binfile2 [standard_output_file $testfile2]
with_test_prefix "exec1" {
- if { [build_executable "failed to prepare" ${exec1} "${srcfile1}" \
+ if { [build_executable "failed to prepare" $testfile1 $srcfile1 \
[list pthreads debug]] } {
return -1
}
}
with_test_prefix "exec2" {
- if { [build_executable "failed to prepare" ${exec2} "${srcfile2}" \
+ if { [build_executable "failed to prepare" $testfile2 $srcfile2 \
[list pthreads debug]] } {
return -1
}
@@ -55,7 +55,7 @@ proc test_re_run {re_run_inf} {
global gdb_prompt
global last_loaded_file
- clean_restart ${binfile1}
+ clean_restart $::testfile1
delete_breakpoints
diff --git a/gdb/testsuite/gdb.multi/multi-target.exp.tcl b/gdb/testsuite/gdb.multi/multi-target.exp.tcl
index dc88ca4..1963db5 100644
--- a/gdb/testsuite/gdb.multi/multi-target.exp.tcl
+++ b/gdb/testsuite/gdb.multi/multi-target.exp.tcl
@@ -53,7 +53,7 @@ proc add_inferior {num target binfile {gcorefile ""}} {
return 0
}
}
- if ![runto "all_started"] then {
+ if { ![runto "all_started"] } {
return 0
}
delete_breakpoints
@@ -65,9 +65,9 @@ proc prepare_core {} {
global gcorefile gcore_created
global binfile
- clean_restart ${binfile}
+ clean_restart ${::testfile}
- if ![runto all_started] then {
+ if { ![runto all_started] } {
return -1
}
@@ -114,7 +114,7 @@ proc setup {non-stop {multi_process ""}} {
# Make GDB read files from the local file system, not through the
# remote targets, to speed things up.
set ::GDBFLAGS "${::GDBFLAGS} -ex \"set sysroot\""
- clean_restart ${binfile}
+ clean_restart ${::testfile}
}
# multi-target depends on target running in non-stop mode. Force
@@ -123,13 +123,13 @@ proc setup {non-stop {multi_process ""}} {
gdb_test_no_output "set non-stop ${non-stop}"
- if {${multi_process} ne ""} then {
+ if {${multi_process} ne ""} {
gdb_test \
"set remote multiprocess-feature-packet $multi_process" \
"Support for the 'multiprocess-feature' packet on future remote targets is set to \"${multi_process}\"."
}
- if ![runto all_started] then {
+ if { ![runto all_started] } {
return 0
}
@@ -184,7 +184,7 @@ proc multi_target_prepare {} {
return 0
}
- if { [prepare_for_testing "failed to prepare" ${binfile} "${srcfile}" \
+ if { [prepare_for_testing "failed to prepare" $::testfile $srcfile \
{debug pthreads}] } {
return 0
}
diff --git a/gdb/testsuite/gdb.multi/multi-term-settings.exp b/gdb/testsuite/gdb.multi/multi-term-settings.exp
index 38322be..2893d36 100644
--- a/gdb/testsuite/gdb.multi/multi-term-settings.exp
+++ b/gdb/testsuite/gdb.multi/multi-term-settings.exp
@@ -29,7 +29,7 @@ require allow_multi_inferior_tests
require can_spawn_for_attach
-if [build_executable "failed to prepare" $testfile $srcfile {debug}] {
+if {[build_executable "failed to prepare" $testfile $srcfile {debug}]} {
return -1
}
@@ -56,7 +56,7 @@ proc create_inferior {which_inf inf_how} {
# Run to main and delete breakpoints.
proc my_runto_main {} {
- if ![runto_main] {
+ if {![runto_main]} {
return 0
} else {
# Delete breakpoints otherwise GDB would try to step over
@@ -69,7 +69,7 @@ proc create_inferior {which_inf inf_how} {
}
if {$inf_how == "run"} {
- if [my_runto_main] {
+ if {[my_runto_main]} {
global inferior_spawn_id
return $inferior_spawn_id
}
@@ -80,7 +80,7 @@ proc create_inferior {which_inf inf_how} {
set inf_tty_name $spawn_out(slave,name)
gdb_test_no_output "tty $inf_tty_name" "tty TTY"
- if [my_runto_main] {
+ if {[my_runto_main]} {
return $inf_spawn_id
}
} elseif {$inf_how == "attach"} {
@@ -138,7 +138,7 @@ proc coretest {inf1_how inf2_how} {
global gdb_spawn_id
global decimal
- clean_restart $binfile
+ clean_restart $::testfile
with_test_prefix "inf1" {
set inf1_spawn_id [create_inferior 1 $inf1_how]
diff --git a/gdb/testsuite/gdb.multi/pending-bp-del-inferior.exp b/gdb/testsuite/gdb.multi/pending-bp-del-inferior.exp
index a7055d7..781937d 100644
--- a/gdb/testsuite/gdb.multi/pending-bp-del-inferior.exp
+++ b/gdb/testsuite/gdb.multi/pending-bp-del-inferior.exp
@@ -37,7 +37,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
#
# Return true after a successful setup, otherwise, return false.
proc test_setup {} {
- clean_restart $::binfile
+ clean_restart $::testfile
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.multi/pending-bp.exp b/gdb/testsuite/gdb.multi/pending-bp.exp
index 2458cd7..30a75b9 100644
--- a/gdb/testsuite/gdb.multi/pending-bp.exp
+++ b/gdb/testsuite/gdb.multi/pending-bp.exp
@@ -45,7 +45,7 @@ if { [build_executable "failed to prepare" $testfile $srcfile \
# '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}
+ clean_restart ${::testfile}
gdb_locate_shlib $::binfile_lib
diff --git a/gdb/testsuite/gdb.multi/remote-with-running-inferior.c b/gdb/testsuite/gdb.multi/remote-with-running-inferior.c
new file mode 100644
index 0000000..a610eda
--- /dev/null
+++ b/gdb/testsuite/gdb.multi/remote-with-running-inferior.c
@@ -0,0 +1,38 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2025 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 <unistd.h>
+
+int global_var = 123;
+
+void
+breakpt (void)
+{
+ /* Nothing. */
+}
+
+int
+main (void)
+{
+ for (int i = 0; i < 30; ++i)
+ {
+ sleep (1);
+ breakpt ();
+ }
+
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.multi/remote-with-running-inferior.exp b/gdb/testsuite/gdb.multi/remote-with-running-inferior.exp
new file mode 100644
index 0000000..43842ba
--- /dev/null
+++ b/gdb/testsuite/gdb.multi/remote-with-running-inferior.exp
@@ -0,0 +1,171 @@
+# This testcase is part of GDB, the GNU debugger.
+#
+# Copyright 2025 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/>.
+
+# Set an inferior running in the background (using "run&"), then
+# connect to gdbserver in a second inferior. When this test was added
+# there were two bugs in GDB. First, just connecting to gdbserver
+# while an inferior was running on a different connection type
+# (e.g. inferior 1 was native, and inferior 2 was gdbserver) would
+# trigger an assertion.
+#
+# Then, once the assertion was fixed, GDB would stop the thread from
+# the first inferior, but would fail to update it's state in GDB core,
+# this would leave the thread stopped, but GDB core thinking the
+# thread was running. Check this is fixed by looking at the 'info
+# threads' output after connecting to the remote target.
+
+# This tests the use of native and remote targets, and also depends on use
+# of the 'run' command. If we try to run it with a board that forces native
+# targets to become remote, then this test isn't going to work, especially
+# for 'remote' targets where 'run' is not supported.
+require {string equal [target_info gdb_protocol] ""}
+
+load_lib gdbserver-support.exp
+
+require allow_gdbserver_tests
+
+standard_testfile
+
+if { [build_executable "failed to build" $testfile $srcfile] } {
+ return
+}
+
+# Set non-stop mode based on NON_STOP. Start a native inferior running in
+# the background, then start a second, remote inferior. Based on the value
+# of NON_STOP we might expect the inferior thread to have been stopped.
+# Confirm inferior one is in the correct state, and that it can be
+# interrupted and/or resumed.
+proc run_test { target_non_stop non_stop } {
+ clean_restart $::testfile
+
+ # Setup non-stop settings.
+ gdb_test_no_output "maint set target-non-stop $target_non_stop"
+ gdb_test_no_output "set non-stop $non_stop"
+
+ # Start the first inferior running in the background.
+ gdb_test -no-prompt-anchor "run&" "Starting program: .*" "start background inferior"
+
+ # Add a second inferior.
+ gdb_test "add-inferior" "Added inferior 2.*"
+ gdb_test "inferior 2" "Switching to inferior 2.*"
+
+ # Setup the sysroot if possible. This will make connecting to
+ # gdbserver quicker.
+ if { ![is_remote host] && ![is_remote target] } {
+ gdb_test "set sysroot"
+ }
+
+ # Setup, and connect to, a remote target.
+ set target_exec [gdbserver_download_current_prog]
+ set res [gdbserver_start "" $target_exec]
+ set gdbserver_protocol [lindex $res 0]
+ set gdbserver_gdbport [lindex $res 1]
+ set res [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
+ gdb_assert {$res == 0} "connect to remote target"
+
+ # Check the info threads output. We're checking that we see the two
+ # threads we expect, that the correct thread (inferior two's thread)
+ # is current, and that none of the threads are running.
+ set state_inferior_1 ""
+ set state_inferior_2 ""
+ gdb_test_multiple "info threads" "" {
+ -re "^info threads\r\n" {
+ exp_continue
+ }
+
+ -re "^\\s+Id\\s+Target Id\\s+Frame\\s*\r\n" {
+ exp_continue
+ }
+
+ -re "^\\s+1\\.1\\s+\[^\r\n\]+\\(running\\)\r\n" {
+ set state_inferior_1 "running"
+ exp_continue
+ }
+
+ -re "^\\*\\s+2\\.1\\s+\[^\r\n\]+\\(running\\)\r\n" {
+ set state_inferior_2 "running"
+ exp_continue
+ }
+
+ -re "^\\s+1\\.1\\s+\[^\r\n\]+\r\n" {
+ set state_inferior_1 "stopped"
+ exp_continue
+ }
+
+ -re "^\\*\\s+2\\.1\\s+\[^\r\n\]+\r\n" {
+ set state_inferior_2 "stopped"
+ exp_continue
+ }
+
+ -re "^$::gdb_prompt $" {
+ if { $non_stop } {
+ gdb_assert { $state_inferior_1 == "running" \
+ && $state_inferior_2 == "stopped" } \
+ $gdb_test_name
+ } else {
+ gdb_assert { $state_inferior_1 == "stopped" \
+ && $state_inferior_2 == "stopped" } \
+ $gdb_test_name
+ }
+ }
+ }
+
+ # Allow inferior 2 to reach main. The confirms that inferior 2 can be
+ # set running again.
+ gdb_breakpoint main
+ gdb_continue_to_breakpoint "breakpoint in main"
+ gdb_test "bt 1" \
+ "#0\\s+main \\(\\) at\[^\r\n\]+" \
+ "check inferior 2 is in main"
+
+ # Switch to inferior 1 and allow it to continue. This is a
+ # critical part of the test. When the test was added a bug (in
+ # all-stop mode) would leave inferior 1 stopped, but GDB code
+ # would think the thread was running. As such. the thread
+ # couldn't be resumed again.
+ gdb_test "inferior 1" "Switching to inferior 1.*"
+
+ # In non-stop mode, thread 1.1 is correctly left running, so we
+ # need to stop it now.
+ if { $non_stop } {
+ gdb_test -no-prompt-anchor "interrupt"
+ gdb_test "p 1 + 1" " = 2" \
+ "simple print to resync output"
+ }
+
+ gdb_breakpoint breakpt
+ gdb_continue_to_breakpoint "continue to breakpoint in breakpt"
+ gdb_test "bt 1" \
+ [multi_line \
+ "#0\\s+breakpt \\(\\) at\[^\r\n\]+" \
+ "\\(More stack frames follow\\.\\.\\.\\)"] \
+ "check inferior 1 is in breakpt"
+
+ # Switch back to inferior 2. The testing infrastructure will try to
+ # use 'monitor exit' to close gdbserver. It helps if we are in the
+ # gdbserver inferior when the script finishes.
+ gdb_test "inferior 2" "Switching to inferior 2.*" \
+ "switch back to inferior 2"
+}
+
+# Multi-inferior support requires non-stop targets.
+foreach_with_prefix target_non_stop { auto on } {
+ # But it's OK if we're emulating all-stop mode on top of non-stop.
+ foreach_with_prefix non_stop { on off } {
+ run_test $target_non_stop $non_stop
+ }
+}
diff --git a/gdb/testsuite/gdb.multi/remove-inferiors.exp b/gdb/testsuite/gdb.multi/remove-inferiors.exp
index 586d958..52e6cb0 100644
--- a/gdb/testsuite/gdb.multi/remove-inferiors.exp
+++ b/gdb/testsuite/gdb.multi/remove-inferiors.exp
@@ -32,7 +32,7 @@ proc add_inferior { expected_num message } {
proc test_remove_inferiors { } {
global binfile
- clean_restart ${binfile}
+ clean_restart ${::testfile}
# Add another inferior and switch to it.
add_inferior 2 "add second inferior"
diff --git a/gdb/testsuite/gdb.multi/run-only-second-inf.exp b/gdb/testsuite/gdb.multi/run-only-second-inf.exp
index 7b6532c..3645962 100644
--- a/gdb/testsuite/gdb.multi/run-only-second-inf.exp
+++ b/gdb/testsuite/gdb.multi/run-only-second-inf.exp
@@ -31,7 +31,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile {debug}]} {
# So, start GDB with this setting.
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"maint set target-non-stop on\""
- clean_restart ${binfile}
+ clean_restart ${::testfile}
}
# Add and start the second inferior.
diff --git a/gdb/testsuite/gdb.multi/sched-multi-add-inferior.exp b/gdb/testsuite/gdb.multi/sched-multi-add-inferior.exp
new file mode 100644
index 0000000..9344c80
--- /dev/null
+++ b/gdb/testsuite/gdb.multi/sched-multi-add-inferior.exp
@@ -0,0 +1,109 @@
+# Copyright 2025 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/>.
+
+# Start multiple inferiors while schedule-multiple is on. Make use of
+# the multi-target.exp.tcl support library for the helper procs, but
+# don't use its 'setup' proc as that only turns on schedule-multiple
+# after starting all the inferiors, and that is too late for this test.
+#
+# The specific bug that this test guards against was that, when a
+# native target starts and runs upto a breakpoint, the thread would
+# have its last signal recorded as SIGTRAP.
+#
+# When starting a gdbserver inferior (with schedule-multiple on) the
+# native target would also be resumed.
+#
+# However, GDBs 'run' command was failing to clear out the old signal
+# state from the native inferior, and so GDB would deliver a SIGTRAP
+# to that inferior, killing it.
+
+source $srcdir/$subdir/multi-target.exp.tcl
+
+if {![multi_target_prepare]} {
+ return
+}
+
+# Some breakpoint locations.
+set line1 [gdb_get_line_number "set break 1 here"]
+set line2 [gdb_get_line_number "set break 2 here"]
+
+# Start two inferiors using TARGET_TYPE_1 and TARGET_TYPE_2 (either
+# 'extended-remote' or 'native'). Due to the way that inferior 1 is
+# special (existing once GDB starts up), we just use the existing
+# helper functions to create inferiors 2 and 3 using these types, and
+# we leave inferior 1 unused.
+proc run_test { target_type_1 target_type_2 } {
+ cleanup_gdbservers
+
+ clean_restart
+
+ gdb_test_no_output "set sysroot"
+
+ # The schedule-multiple setting relies on all targets running in
+ # non-stop mode. Force it on for remote targets, until this is
+ # the default.
+ gdb_test_no_output "maint set target-non-stop on"
+
+ # Run in all-stop mode.
+ gdb_test_no_output "set non-stop off"
+
+ # Turn on schedule-multiple before starting any inferiors.
+ gdb_test_no_output "set schedule-multiple on"
+
+ if {![add_inferior 2 $target_type_1 $::binfile]} {
+ return 0
+ }
+
+ if {![add_inferior 3 $target_type_2 $::binfile]} {
+ return 0
+ }
+
+ # Check we see all the expected threads.
+ gdb_test "info threads" \
+ [multi_line \
+ "\\s+Id\\s+Target Id\\s+Frame\\s*" \
+ "\\s+2\\.1\\s+\[^\r\n\]+" \
+ "\\s+2\\.2\\s+\[^\r\n\]+" \
+ "\\*\\s+3\\.1\\s+\[^\r\n\]+" \
+ "\\s+3\\.2\\s+\[^\r\n\]+"]
+
+ # Ensure that all inferiors can be set running again.
+ gdb_test "break ${::srcfile}:${::line1} thread 3.1"
+ gdb_test "break ${::srcfile}:${::line2} thread 2.1"
+ gdb_test "continue" \
+ [multi_line \
+ "Thread 3\\.1 \[^\r\n\]+, main \\(\[^\r\n\]+\\) at \[^\r\n\]+" \
+ "$::decimal\\s+function1 \\(\\); /\\* set break 1 here \\*/"] \
+ "continue to function1"
+
+ # Unblock thread 2.1 and continue again. This time, thread 2.1
+ # will hit a breakpoint.
+ gdb_test "thread apply 2.1 set wait_for_gdb = 0" ".*"
+ gdb_test "continue" \
+ [multi_line \
+ "Thread 2\\.1 \[^\r\n\]+, main \\(\[^\r\n\]+\\) at \[^\r\n\]+" \
+ "$::decimal\\s+function2 \\(\\); /\\* set break 2 here \\*/"] \
+ "continue to function2"
+}
+
+set all_target_types { extended-remote native }
+
+foreach_with_prefix target_type_1 $all_target_types {
+ foreach_with_prefix target_type_2 $all_target_types {
+ run_test $target_type_1 $target_type_2
+ }
+}
+
+multi_target_cleanup
diff --git a/gdb/testsuite/gdb.multi/start-inferior-specific.exp b/gdb/testsuite/gdb.multi/start-inferior-specific.exp
index 74f984c..39621f0 100644
--- a/gdb/testsuite/gdb.multi/start-inferior-specific.exp
+++ b/gdb/testsuite/gdb.multi/start-inferior-specific.exp
@@ -30,7 +30,8 @@ require allow_multi_inferior_tests
require !use_gdb_stub
set srcfile_other ${srcfile2}
-set binfile_other ${binfile}-other
+set testfile_other $testfile-other
+set binfile_other [standard_output_file $testfile_other]
if { [build_executable ${testfile}.exp ${binfile} "${srcfile}" {debug}] != 0 } {
return -1
@@ -48,7 +49,7 @@ proc do_test {} {
append ::GDBFLAGS " -ex \"maintenance set target-non-stop on\""
}
- clean_restart ${::binfile_other}
+ clean_restart $::testfile_other
}
gdb_test -no-prompt-anchor "run&" "Starting program: .*" "start background inferior"
diff --git a/gdb/testsuite/gdb.multi/watchpoint-multi-exit.exp b/gdb/testsuite/gdb.multi/watchpoint-multi-exit.exp
index 3446296..a149407 100644
--- a/gdb/testsuite/gdb.multi/watchpoint-multi-exit.exp
+++ b/gdb/testsuite/gdb.multi/watchpoint-multi-exit.exp
@@ -31,12 +31,12 @@ if {[build_executable "failed to build" $testfile $srcfile {debug}]} {
proc do_test {dispose} {
global binfile bkptno_numopt_re
- clean_restart $binfile
+ clean_restart $::testfile
gdb_test_no_output "set follow-fork child"
gdb_test_no_output "set detach-on-fork off"
- if ![runto "child_function"] {
+ if {![runto "child_function"]} {
return
}
diff --git a/gdb/testsuite/gdb.multi/watchpoint-multi.exp b/gdb/testsuite/gdb.multi/watchpoint-multi.exp
index b0c8731..501f0a6 100644
--- a/gdb/testsuite/gdb.multi/watchpoint-multi.exp
+++ b/gdb/testsuite/gdb.multi/watchpoint-multi.exp
@@ -38,7 +38,7 @@ gdb_test_no_output "set breakpoint always-inserted on"
# displaced-stepping is also needed as other GDB sometimes still removes the
# breakpoints, even with always-inserted on.
# Without the support this test just is not as thorough as it could be.
-if [support_displaced_stepping] {
+if {[support_displaced_stepping]} {
gdb_test_no_output "set displaced-stepping on"
}
diff --git a/gdb/testsuite/gdb.objc/basicclass.exp b/gdb/testsuite/gdb.objc/basicclass.exp
index 7f29aff..9e40c71 100644
--- a/gdb/testsuite/gdb.objc/basicclass.exp
+++ b/gdb/testsuite/gdb.objc/basicclass.exp
@@ -72,7 +72,7 @@ proc deduce_language_of_main {} {
proc do_objc_tests {} {
global binfile
- clean_restart $binfile
+ clean_restart $::testfile
deduce_language_of_main
}
diff --git a/gdb/testsuite/gdb.objc/nondebug.exp b/gdb/testsuite/gdb.objc/nondebug.exp
index dfdd9bc..9ca86ff 100644
--- a/gdb/testsuite/gdb.objc/nondebug.exp
+++ b/gdb/testsuite/gdb.objc/nondebug.exp
@@ -29,7 +29,7 @@ if {[gdb_compile_objc "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [
proc do_objc_tests {} {
global binfile
- clean_restart $binfile
+ clean_restart $::testfile
}
do_objc_tests
diff --git a/gdb/testsuite/gdb.objc/objcdecode.exp b/gdb/testsuite/gdb.objc/objcdecode.exp
index b7c38db..5414f0f 100644
--- a/gdb/testsuite/gdb.objc/objcdecode.exp
+++ b/gdb/testsuite/gdb.objc/objcdecode.exp
@@ -29,7 +29,7 @@ if {[gdb_compile_objc "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [
proc do_objc_tests {} {
global binfile
- clean_restart $binfile
+ clean_restart $::testfile
}
do_objc_tests
diff --git a/gdb/testsuite/gdb.objc/print.exp b/gdb/testsuite/gdb.objc/print.exp
index c18bf29..e3f4177 100644
--- a/gdb/testsuite/gdb.objc/print.exp
+++ b/gdb/testsuite/gdb.objc/print.exp
@@ -59,7 +59,7 @@ proc test_float_rejected {} {
clean_restart
-if [set_lang_objc] {
+if { [set_lang_objc] } {
test_float_accepted
test_float_rejected
} else {
diff --git a/gdb/testsuite/gdb.opencl/callfuncs.exp b/gdb/testsuite/gdb.opencl/callfuncs.exp
index 8ab8db7..6982461 100644
--- a/gdb/testsuite/gdb.opencl/callfuncs.exp
+++ b/gdb/testsuite/gdb.opencl/callfuncs.exp
@@ -21,8 +21,9 @@ load_lib opencl.exp
require allow_opencl_tests
-set testfile "callfuncs"
-set clprogram [remote_download target ${srcdir}/${subdir}/${testfile}.cl]
+standard_testfile .cl
+
+set clprogram [remote_download target $srcdir/$subdir/$srcfile]
# Compile the generic OpenCL host app
if { [gdb_compile_opencl_hostapp "${clprogram}" "${testfile}" "" ] != "" } {
@@ -30,7 +31,7 @@ if { [gdb_compile_opencl_hostapp "${clprogram}" "${testfile}" "" ] != "" } {
return -1
}
-clean_restart [standard_testfile $testfile]
+clean_restart $testfile
# Set breakpoint at the OpenCL kernel
gdb_test "tbreak testkernel" \
diff --git a/gdb/testsuite/gdb.opencl/vec_comps.exp b/gdb/testsuite/gdb.opencl/vec_comps.exp
index 3485a34..09c12ec 100644
--- a/gdb/testsuite/gdb.opencl/vec_comps.exp
+++ b/gdb/testsuite/gdb.opencl/vec_comps.exp
@@ -58,7 +58,7 @@ set have_cl_khr_fp16 [get_integer_valueof "have_cl_khr_fp16" 0]
# Sanity checks
proc check_basic { name type size } {
gdb_test "ptype ${name}" "type = ${type}16"
- gdb_test "p sizeof(${name})" " = [expr ${size} * 16]"
+ gdb_test "p sizeof(${name})" " = [expr {${size} * 16}]"
gdb_test "print/d ${name}" " = \\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15\\}"
}
@@ -227,40 +227,40 @@ proc check_type { name type alttype } {
}
proc check_sizeof { name size } {
- gdb_test "print sizeof (${name}.lo)" " = [expr $size * 8]"
- gdb_test "print sizeof (${name}.hi)" " = [expr $size * 8]"
- gdb_test "print sizeof (${name}.even)" " = [expr $size * 8]"
- gdb_test "print sizeof (${name}.odd)" " = [expr $size * 8]"
+ gdb_test "print sizeof (${name}.lo)" " = [expr {$size * 8}]"
+ gdb_test "print sizeof (${name}.hi)" " = [expr {$size * 8}]"
+ gdb_test "print sizeof (${name}.even)" " = [expr {$size * 8}]"
+ gdb_test "print sizeof (${name}.odd)" " = [expr {$size * 8}]"
- gdb_test "print sizeof (${name}.hi.even)" " = [expr $size * 4]"
- gdb_test "print sizeof (${name}.odd.odd.lo)" " = [expr $size * 2]"
+ gdb_test "print sizeof (${name}.hi.even)" " = [expr {$size * 4}]"
+ gdb_test "print sizeof (${name}.odd.odd.lo)" " = [expr {$size * 2}]"
gdb_test "print sizeof (${name}.even.hi.lo.odd)" " = $size"
gdb_test "print sizeof (${name}.x)" " = $size"
- gdb_test "print sizeof (${name}.xy)" " = [expr $size * 2]"
- gdb_test "print sizeof (${name}.xyz)" " = [expr $size * 4]"
- gdb_test "print sizeof (${name}.xyzw)" " = [expr $size * 4]"
+ gdb_test "print sizeof (${name}.xy)" " = [expr {$size * 2}]"
+ gdb_test "print sizeof (${name}.xyz)" " = [expr {$size * 4}]"
+ gdb_test "print sizeof (${name}.xyzw)" " = [expr {$size * 4}]"
gdb_test "print sizeof (${name}.xy.x)" " = $size"
- gdb_test "print sizeof (${name}.wzyx.yy)" " = [expr $size * 2]"
+ gdb_test "print sizeof (${name}.wzyx.yy)" " = [expr {$size * 2}]"
gdb_test "print sizeof (${name}.wzyx.yx.x)" " = $size"
gdb_test "print sizeof (${name}.xyzw.w)" " = $size"
gdb_test "print sizeof (${name}.s0)" " = $size"
- gdb_test "print sizeof (${name}.s01)" " = [expr $size * 2]"
- gdb_test "print sizeof (${name}.s012)" " = [expr $size * 4]"
- gdb_test "print sizeof (${name}.s0123)" " = [expr $size * 4]"
- gdb_test "print sizeof (${name}.s01234567)" " = [expr $size * 8]"
- gdb_test "print sizeof (${name}.s0123456789abcdef)" " = [expr $size * 16]"
-
- gdb_test "print sizeof (${name}.sfedcba98.S0246)" " = [expr $size * 4]"
- gdb_test "print sizeof (${name}.sfedcba98.S0246.s13)" " = [expr $size * 2]"
+ gdb_test "print sizeof (${name}.s01)" " = [expr {$size * 2}]"
+ gdb_test "print sizeof (${name}.s012)" " = [expr {$size * 4}]"
+ gdb_test "print sizeof (${name}.s0123)" " = [expr {$size * 4}]"
+ gdb_test "print sizeof (${name}.s01234567)" " = [expr {$size * 8}]"
+ gdb_test "print sizeof (${name}.s0123456789abcdef)" " = [expr {$size * 16}]"
+
+ gdb_test "print sizeof (${name}.sfedcba98.S0246)" " = [expr {$size * 4}]"
+ gdb_test "print sizeof (${name}.sfedcba98.S0246.s13)" " = [expr {$size * 2}]"
gdb_test "print sizeof (${name}.sfedcba98.S0246.s13.s0)" " = $size"
- gdb_test "print sizeof (${name}.s0123456789abcdef.s22)" " = [expr $size * 2]"
+ gdb_test "print sizeof (${name}.s0123456789abcdef.s22)" " = [expr {$size * 2}]"
- gdb_test "print sizeof (${name}.hi.s7654.wx)" " = [expr $size * 2]"
- gdb_test "print sizeof (${name}.s0123456789abcdef.even.lo)" " = [expr $size * 4]"
- gdb_test "print sizeof (${name}.odd.xyzw.s23)" " = [expr $size * 2]"
+ gdb_test "print sizeof (${name}.hi.s7654.wx)" " = [expr {$size * 2}]"
+ gdb_test "print sizeof (${name}.s0123456789abcdef.even.lo)" " = [expr {$size * 4}]"
+ gdb_test "print sizeof (${name}.odd.xyzw.s23)" " = [expr {$size * 2}]"
gdb_test "print sizeof (${name}.xyzw.hi.odd)" " = $size"
}
@@ -343,8 +343,8 @@ proc check_access { name } {
# lvalue tests
for {set i 0} {$i < 16} {incr i} {
- gdb_test_no_output "set variable ${name}.s[format "%x" $i] = [expr 15 - $i]"
- gdb_test "print/d ${name}.s[format "%x" $i]" " = [expr 15 - $i]"
+ gdb_test_no_output "set variable ${name}.s[format "%x" $i] = [expr {15 - $i}]"
+ gdb_test "print/d ${name}.s[format "%x" $i]" " = [expr {15 - $i}]"
}
gdb_test "print/d ${name}" " = \\{15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0\\}"
diff --git a/gdb/testsuite/gdb.opt/inline-break.exp b/gdb/testsuite/gdb.opt/inline-break.exp
index d83ff75..0805f69 100644
--- a/gdb/testsuite/gdb.opt/inline-break.exp
+++ b/gdb/testsuite/gdb.opt/inline-break.exp
@@ -209,7 +209,7 @@ foreach_with_prefix cmd [list "break" "tbreak"] {
# that we actually stop where we think we should.
for {set i 1} {$i < 4} {incr i} {
foreach inline {"not_inline" "inline"} {
- eval gdb_breakpoint "${inline}_func$i" $break_flags
+ gdb_breakpoint "${inline}_func$i" {*}$break_flags
}
}
@@ -247,7 +247,7 @@ foreach_with_prefix func {
"func_inline_caller"
"func_inline_callee"
} {
- clean_restart $binfile
+ clean_restart $::testfile
if {![runto_main]} {
continue
@@ -264,7 +264,7 @@ foreach_with_prefix func {
set line [gdb_get_line_number "break here"]
with_test_prefix "line number" {
- clean_restart $binfile
+ clean_restart $::testfile
if {![runto_main]} {
continue
@@ -288,7 +288,7 @@ with_test_prefix "line number" {
with_test_prefix "address" {
- clean_restart $binfile
+ clean_restart $::testfile
if {![runto_main]} {
continue
@@ -308,7 +308,7 @@ with_test_prefix "address" {
with_test_prefix "check alignment" {
- clean_restart $binfile
+ clean_restart $::testfile
if {![runto_main]} {
continue
diff --git a/gdb/testsuite/gdb.opt/inline-cmds.exp b/gdb/testsuite/gdb.opt/inline-cmds.exp
index eca897c..e80d6f7 100644
--- a/gdb/testsuite/gdb.opt/inline-cmds.exp
+++ b/gdb/testsuite/gdb.opt/inline-cmds.exp
@@ -241,7 +241,7 @@ gdb_test "step" ".*set breakpoint 2 here.*" "step into finish marker"
# Some architectures will have one or more instructions after
# the call instruction which still are part of the call sequence,
-# so it should be expected to return to the caller line after issue
+# so it should be expected to return to the caller line after issue
# a 'finish' command.
gdb_test_multiple "finish" "finish from marker to func1" {
-re -wrap "func1 \\(\\);" {
diff --git a/gdb/testsuite/gdb.opt/inline-entry.exp b/gdb/testsuite/gdb.opt/inline-entry.exp
index f185f10..0c6b0fb 100644
--- a/gdb/testsuite/gdb.opt/inline-entry.exp
+++ b/gdb/testsuite/gdb.opt/inline-entry.exp
@@ -43,11 +43,11 @@ if { [supports_statement_frontiers] } {
lappend options additional_flags=-gstatement-frontiers
}
-if { [prepare_for_testing "failed to prepare" $binfile $srcfile $options] } {
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile $options] } {
return
}
-if ![runto_main] {
+if { ![runto_main] } {
return
}
diff --git a/gdb/testsuite/gdb.opt/inline-small-func.exp b/gdb/testsuite/gdb.opt/inline-small-func.exp
index d77a10e..b04f957 100644
--- a/gdb/testsuite/gdb.opt/inline-small-func.exp
+++ b/gdb/testsuite/gdb.opt/inline-small-func.exp
@@ -41,7 +41,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
return -1
}
-if ![runto_main] {
+if { ![runto_main] } {
return -1
}
diff --git a/gdb/testsuite/gdb.opt/solib-intra-step.exp b/gdb/testsuite/gdb.opt/solib-intra-step.exp
index 4b7ab3a..9c6d6c5 100644
--- a/gdb/testsuite/gdb.opt/solib-intra-step.exp
+++ b/gdb/testsuite/gdb.opt/solib-intra-step.exp
@@ -34,7 +34,7 @@ if { [gdb_compile_shlib ${srcfile_lib} ${binfile_lib} $lib_flags] != ""
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_load_shlib $binfile_lib
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.pascal/floats.exp b/gdb/testsuite/gdb.pascal/floats.exp
index a0c37ad..926c0c3 100644
--- a/gdb/testsuite/gdb.pascal/floats.exp
+++ b/gdb/testsuite/gdb.pascal/floats.exp
@@ -48,9 +48,9 @@ gdb_test "next" "u := 78\\.3;" "next to 'u := 78.3' line"
gdb_test "next" "l := 1;" "next to 'l := 1' line"
gdb_test "next" "i := 1;" "next to 'i := 1' line"
-# At that point,
+# At that point,
# r should be equal to 1.25
-gdb_test "print r" " = 1\\.25"
+gdb_test "print r" " = 1\\.25"
# s should be equal to 2.2
gdb_test "print s" " = 2\\.(199.*|2|200.*)"
# t should be equal to -3.2
@@ -120,7 +120,7 @@ gdb_test "next" "s := sin\\(u\\);" "advance to 's := sin(u)' line"
gdb_test "print r" " = -1" "test cos(pi) is equal to -1"
gdb_test "next" "" "go past 's := sin(u)' line"
-set msg "Test sin(pi) is equal to 0"
+set msg "Test sin(pi) is equal to 0"
gdb_test_multiple "print s" $msg {
-re ".* = (0|-?\[0-9\]\\.\[0-9\]*\[eE\](-?\[0-9\]*))\[\r\n\]+$gdb_prompt $" {
diff --git a/gdb/testsuite/gdb.pascal/gdb11492.exp b/gdb/testsuite/gdb.pascal/gdb11492.exp
index e39f522..67764c5 100644
--- a/gdb/testsuite/gdb.pascal/gdb11492.exp
+++ b/gdb/testsuite/gdb.pascal/gdb11492.exp
@@ -37,9 +37,9 @@ if { [gdb_breakpoint ${srcfile}:${bp_location1}] } {
gdb_test "continue" ""
gdb_test "print integer_array" { = \{50, 51, 52, 53, 54, 55, 56, 57\}}
-gdb_test "print /s integer_array" " = '23456789'"
+gdb_test "print /s integer_array" " = '23456789'"
-gdb_test "print char_array" " = '23456789'"
+gdb_test "print char_array" " = '23456789'"
gdb_test "print /d char_array" { = \{50, 51, 52, 53, 54, 55, 56, 57\}}
gdb_test "print /x char_array" { = \{0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39\}}
# Use next two times to avoid GPC line numbering problem
diff --git a/gdb/testsuite/gdb.pascal/hello.exp b/gdb/testsuite/gdb.pascal/hello.exp
index 904f2a9..ac10280 100644
--- a/gdb/testsuite/gdb.pascal/hello.exp
+++ b/gdb/testsuite/gdb.pascal/hello.exp
@@ -46,7 +46,7 @@ gdb_test "print st" \
# This test also fails for gpc because the program
# stops after the string has been written
-# while it should stop before writing it
+# while it should stop before writing it
if { $pascal_compiler_is_gpc } {
setup_xfail *-*-*
}
diff --git a/gdb/testsuite/gdb.pascal/integers.exp b/gdb/testsuite/gdb.pascal/integers.exp
index c9974a1..12d15c8 100644
--- a/gdb/testsuite/gdb.pascal/integers.exp
+++ b/gdb/testsuite/gdb.pascal/integers.exp
@@ -43,9 +43,9 @@ gdb_test "print i" ".* = 0" "print i before assigned to 1"
gdb_test "next" "i := 1;" "next to 'i := 1' line"
gdb_test "next" "j := 2;" "next to 'j := 2' line"
-# At that point,
+# At that point,
# i should be equal to 1
-gdb_test "print i" " = 1"
+gdb_test "print i" " = 1"
# but j should still be equal to zero
if { $pascal_compiler_is_gpc } {
setup_xfail *-*-*
diff --git a/gdb/testsuite/gdb.pascal/print.exp b/gdb/testsuite/gdb.pascal/print.exp
index 98b0879..18dff4b 100644
--- a/gdb/testsuite/gdb.pascal/print.exp
+++ b/gdb/testsuite/gdb.pascal/print.exp
@@ -59,7 +59,7 @@ proc test_float_rejected {} {
clean_restart
-if [set_lang_pascal] {
+if { [set_lang_pascal] } {
test_float_accepted
test_float_rejected
} else {
diff --git a/gdb/testsuite/gdb.pascal/types.exp b/gdb/testsuite/gdb.pascal/types.exp
index c234c28..b4949f5 100644
--- a/gdb/testsuite/gdb.pascal/types.exp
+++ b/gdb/testsuite/gdb.pascal/types.exp
@@ -25,7 +25,7 @@ proc test_integer_literal_types_accepted {} {
# Test various decimal values.
# Should be integer*4 probably.
- gdb_test "pt 123" "type = int"
+ gdb_test "pt 123" "type = int"
}
proc test_character_literal_types_accepted {} {
global gdb_prompt
diff --git a/gdb/testsuite/gdb.perf/backtrace.exp b/gdb/testsuite/gdb.perf/backtrace.exp
index 9ec099f..aea1e01 100644
--- a/gdb/testsuite/gdb.perf/backtrace.exp
+++ b/gdb/testsuite/gdb.perf/backtrace.exp
@@ -28,7 +28,7 @@ set executable $testfile
set expfile $testfile.exp
# make check-perf RUNTESTFLAGS='backtrace.exp BACKTRACE_DEPTH=1024'
-if ![info exists BACKTRACE_DEPTH] {
+if {![info exists BACKTRACE_DEPTH]} {
set BACKTRACE_DEPTH 64
}
@@ -47,7 +47,7 @@ PerfTest::assemble {
} {
global binfile
- clean_restart $binfile
+ clean_restart $::testfile
if ![runto_main] {
return -1
diff --git a/gdb/testsuite/gdb.perf/gmonster1.exp b/gdb/testsuite/gdb.perf/gmonster1.exp
index f752062..8bb748d 100644
--- a/gdb/testsuite/gdb.perf/gmonster1.exp
+++ b/gdb/testsuite/gdb.perf/gmonster1.exp
@@ -38,7 +38,7 @@ load_lib gen-perf-test.exp
require allow_perf_tests
-if ![info exists MONSTER] {
+if {![info exists MONSTER]} {
set MONSTER "n"
}
diff --git a/gdb/testsuite/gdb.perf/gmonster2.exp b/gdb/testsuite/gdb.perf/gmonster2.exp
index ba4e46b..7049bce 100644
--- a/gdb/testsuite/gdb.perf/gmonster2.exp
+++ b/gdb/testsuite/gdb.perf/gmonster2.exp
@@ -38,7 +38,7 @@ load_lib gen-perf-test.exp
require allow_perf_tests
-if ![info exists MONSTER] {
+if {![info exists MONSTER]} {
set MONSTER "n"
}
diff --git a/gdb/testsuite/gdb.perf/single-step.exp b/gdb/testsuite/gdb.perf/single-step.exp
index 920cf9d..8ec32d1 100644
--- a/gdb/testsuite/gdb.perf/single-step.exp
+++ b/gdb/testsuite/gdb.perf/single-step.exp
@@ -26,7 +26,7 @@ set executable $testfile
set expfile $testfile.exp
# make check-perf RUNTESTFLAGS='single-step.exp SINGLE_STEP_COUNT=300'
-if ![info exists SINGLE_STEP_COUNT] {
+if {![info exists SINGLE_STEP_COUNT]} {
set SINGLE_STEP_COUNT 1000
}
@@ -39,7 +39,7 @@ PerfTest::assemble {
return 0
} {
global binfile
- clean_restart $binfile
+ clean_restart $::testfile
if ![runto_main] {
return -1
diff --git a/gdb/testsuite/gdb.perf/skip-command.exp b/gdb/testsuite/gdb.perf/skip-command.exp
index b82d318..e59cb07 100644
--- a/gdb/testsuite/gdb.perf/skip-command.exp
+++ b/gdb/testsuite/gdb.perf/skip-command.exp
@@ -33,10 +33,10 @@ set skip_func_file [standard_output_file $srcfile2]
set expfile $testfile.exp
# make check-perf RUNTESTFLAGS='skip-command.exp SKIP_STEP_COUNT=1000 ...'
-if ![info exists SKIP_STEP_COUNT] {
+if {![info exists SKIP_STEP_COUNT]} {
set SKIP_STEP_COUNT 1000
}
-if ![info exists SKIP_DIRECTIVE_COUNT] {
+if {![info exists SKIP_DIRECTIVE_COUNT]} {
set SKIP_DIRECTIVE_COUNT 1000
}
@@ -91,7 +91,7 @@ proc write_skip_func_source { file_name func_name_prefix nr_funcs } {
proc run_skip_bench { kind text } {
global SKIP_STEP_COUNT SKIP_DIRECTIVE_COUNT
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
@@ -120,7 +120,7 @@ PerfTest::assemble {
return 0
} {
global binfile
- clean_restart $binfile
+ clean_restart $::testfile
return 0
} {
global SKIP_STEP_COUNT SKIP_DIRECTIVE_COUNT
diff --git a/gdb/testsuite/gdb.perf/skip-prologue.exp b/gdb/testsuite/gdb.perf/skip-prologue.exp
index 50df93a..880a0f4 100644
--- a/gdb/testsuite/gdb.perf/skip-prologue.exp
+++ b/gdb/testsuite/gdb.perf/skip-prologue.exp
@@ -28,7 +28,7 @@ set executable $testfile
set expfile $testfile.exp
# make check-perf RUNTESTFLAGS='skip-prologue.exp SKIP_PROLOGUE_COUNT=500'
-if ![info exists SKIP_PROLOGUE_COUNT] {
+if {![info exists SKIP_PROLOGUE_COUNT]} {
set SKIP_PROLOGUE_COUNT 500
}
@@ -51,7 +51,7 @@ PerfTest::assemble {
global binfile
global gdb_prompt
- clean_restart $binfile
+ clean_restart $::testfile
if ![runto_main] {
return -1
diff --git a/gdb/testsuite/gdb.perf/solib.exp b/gdb/testsuite/gdb.perf/solib.exp
index 45f9330..e7870f6 100644
--- a/gdb/testsuite/gdb.perf/solib.exp
+++ b/gdb/testsuite/gdb.perf/solib.exp
@@ -31,7 +31,7 @@ set executable $testfile
set expfile $testfile.exp
# make check-perf RUNTESTFLAGS='solib.exp SOLIB_COUNT=1024'
-if ![info exists SOLIB_COUNT] {
+if {![info exists SOLIB_COUNT]} {
set SOLIB_COUNT 128
}
@@ -72,7 +72,7 @@ PerfTest::assemble {
} {
global binfile
- clean_restart $binfile
+ clean_restart $::testfile
if ![runto_main] {
return -1
diff --git a/gdb/testsuite/gdb.perf/template-breakpoints.exp b/gdb/testsuite/gdb.perf/template-breakpoints.exp
index 7d66e0f..e5d21b2 100644
--- a/gdb/testsuite/gdb.perf/template-breakpoints.exp
+++ b/gdb/testsuite/gdb.perf/template-breakpoints.exp
@@ -28,7 +28,7 @@ set executable $testfile
set expfile $testfile.exp
# make check-perf RUNTESTFLAGS='template-breakpoints.exp EXPANSION_DEPTH=40'
-if ![info exists EXPANSION_DEPTH] {
+if {![info exists EXPANSION_DEPTH]} {
set EXPANSION_DEPTH 40
}
@@ -47,7 +47,7 @@ PerfTest::assemble {
} {
global binfile
- clean_restart $binfile
+ clean_restart $::testfile
if ![runto_main] {
return -1
diff --git a/gdb/testsuite/gdb.python/make-visualizer.exp b/gdb/testsuite/gdb.python/make-visualizer.exp
new file mode 100644
index 0000000..5794bbd
--- /dev/null
+++ b/gdb/testsuite/gdb.python/make-visualizer.exp
@@ -0,0 +1,176 @@
+# Copyright (C) 2025 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 for gdb.printing.make_visualizer; specifically that the
+# optimized-out and synthetic pointer cases work properly.
+
+load_lib dwarf.exp
+load_lib gdb-python.exp
+
+require dwarf2_support
+require allow_python_tests
+
+# Use a simple plain-"main" source file.
+standard_testfile py-progspace.c -dw.S
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug}]} {
+ return
+}
+
+if {![runto_main]} {
+ return
+}
+
+# Get size to create fake DWARF for the test.
+set ptr_size [get_sizeof "void *" 96]
+
+set asm_file [standard_output_file ${srcfile2}]
+Dwarf::assemble $asm_file {
+ cu {} {
+ compile_unit {} {
+ declare_labels i32_type i32_array \
+ struct_label variable_label pointer_label
+
+ i32_type: DW_TAG_base_type {
+ DW_AT_name "int32_t"
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 4 DW_FORM_sdata
+ }
+
+ i32_array: DW_TAG_array_type {
+ DW_AT_name array_type
+ DW_AT_type :$i32_type
+ } {
+ DW_TAG_subrange_type {
+ DW_AT_type :$i32_type
+ DW_AT_lower_bound 0 DW_FORM_data1
+ DW_AT_upper_bound 3 DW_FORM_data1
+ }
+ }
+
+ # Used for testing optimized-out elements of an array.
+ DW_TAG_variable {
+ DW_AT_name i32_noptr
+ DW_AT_type :$i32_array
+ DW_AT_location {
+ DW_OP_constu 1779823878
+ DW_OP_stack_value
+ DW_OP_piece 4
+ } SPECIAL_expr
+ }
+
+ struct_label: DW_TAG_structure_type {
+ DW_AT_name i32_noptr
+ DW_AT_byte_size 4 DW_FORM_sdata
+ } {
+ DW_TAG_member {
+ DW_AT_name f
+ DW_AT_type :$i32_type
+ DW_AT_data_member_location 0 DW_FORM_data1
+ }
+ }
+
+ pointer_label: DW_TAG_pointer_type {
+ DW_AT_byte_size $::ptr_size DW_FORM_sdata
+ DW_AT_type :$struct_label
+ }
+
+ variable_label: DW_TAG_variable {
+ DW_AT_name v
+ DW_AT_location {
+ DW_OP_implicit_value 0x1 0x1 0x1 0x1
+ } SPECIAL_expr
+ DW_AT_type :$struct_label
+ }
+
+ # Used for testing synthetic pointers.
+ DW_TAG_variable {
+ DW_AT_name synthptr
+ DW_AT_location [subst {
+ GNU_implicit_pointer $variable_label 0
+ }] SPECIAL_expr
+ DW_AT_type :$pointer_label
+ }
+
+ # Optimized-out pointer.
+ DW_TAG_variable {
+ DW_AT_name optoutptr
+ DW_AT_location { } SPECIAL_expr
+ DW_AT_type :$pointer_label
+ }
+ }
+ }
+}
+
+if {[prepare_for_testing "failed to prepare" ${testfile} \
+ [list $srcfile $asm_file] {nodebug}]} {
+ return
+}
+
+# Need a frame to evaluate a synthetic pointer.
+if {![runto_main]} {
+ return
+}
+
+gdb_test_no_output "python import gdb"
+gdb_test_no_output "python import gdb.printing"
+
+gdb_test_no_output "python val = gdb.parse_and_eval('i32_noptr')" \
+ "fetch i32_noptr"
+gdb_test_no_output "python vz = gdb.printing.make_visualizer(val)" \
+ "create i32_noptr visualizer"
+gdb_test "python print(isinstance(vz, gdb.printing.NoOpArrayPrinter))" \
+ True \
+ "i32_noptr uses array printer"
+
+gdb_test_no_output "python vz1 = gdb.printing.make_visualizer(val\[0\])" \
+ "create visualizer for valid element"
+gdb_test "python print(isinstance(vz1, gdb.printing.NoOpScalarPrinter))" \
+ True \
+ "valid element uses scalar printer"
+gdb_test "python print(vz1.to_string())" \
+ 1779823878 \
+ "string form of valid element"
+
+gdb_test_no_output "python vz2 = gdb.printing.make_visualizer(val\[1\])" \
+ "create visualizer for optimized-out element"
+gdb_test "python print(isinstance(vz2, gdb.printing.NoOpScalarPrinter))" \
+ True \
+ "optimized-out element uses scalar printer"
+gdb_test "python print(vz2.to_string())" \
+ "<optimized out>" \
+ "string form of optimized-out element"
+
+gdb_test_no_output "python val2 = gdb.parse_and_eval('synthptr')" \
+ "fetch synthetic pointer"
+gdb_test_no_output "python vzv2 = gdb.printing.make_visualizer(val2)" \
+ "create synthetic pointer visualizer"
+gdb_test "python print(isinstance(vzv2, gdb.printing.NoOpPointerReferencePrinter))" \
+ True \
+ "synthetic pointer uses pointer printer"
+gdb_test "python print(vzv2.child(0)\[1\])" \
+ "{f = 16843009}" \
+ "child of synthetic pointer"
+
+gdb_test_no_output "python val3 = gdb.parse_and_eval('optoutptr')" \
+ "fetch optimized-out pointer"
+gdb_test_no_output "python vzv3 = gdb.printing.make_visualizer(val3)" \
+ "create optimized-out pointer visualizer"
+gdb_test "python print(isinstance(vzv3, gdb.printing.NoOpScalarPrinter))" \
+ True \
+ "optimized-out pointer uses scalar printer"
+gdb_test "python print(vzv3.to_string())" \
+ "<optimized out>" \
+ "string representation of optimized-out pointer"
diff --git a/gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp b/gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp
index dd6cb59..17b8afe 100644
--- a/gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp
+++ b/gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp
@@ -39,7 +39,7 @@ proc start_test { breakpoint_comment } {
# Start with a fresh gdb.
# This is important because the test can crash GDB.
- clean_restart ${binfile}
+ clean_restart ${::testfile}
if {![runto_main]} {
untested "couldn't run to breakpoint"
diff --git a/gdb/testsuite/gdb.python/py-arch-reg-groups.exp b/gdb/testsuite/gdb.python/py-arch-reg-groups.exp
index 855af27..2b0ac3e 100644
--- a/gdb/testsuite/gdb.python/py-arch-reg-groups.exp
+++ b/gdb/testsuite/gdb.python/py-arch-reg-groups.exp
@@ -23,7 +23,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.python/py-arch-reg-names.exp b/gdb/testsuite/gdb.python/py-arch-reg-names.exp
index 7093674..99fb8ce 100644
--- a/gdb/testsuite/gdb.python/py-arch-reg-names.exp
+++ b/gdb/testsuite/gdb.python/py-arch-reg-names.exp
@@ -23,7 +23,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.python/py-arch.exp b/gdb/testsuite/gdb.python/py-arch.exp
index 79e5939..531ae50 100644
--- a/gdb/testsuite/gdb.python/py-arch.exp
+++ b/gdb/testsuite/gdb.python/py-arch.exp
@@ -20,7 +20,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
@@ -78,7 +78,7 @@ foreach size {0 1 2 3 4 8 16} {
} else {
set sign_result [lindex $sign_data 1]
}
- set fullsize [expr 8 * $size]
+ set fullsize [expr {8 * $size}]
gdb_test_no_output "python t = arch.integer_type($fullsize$sign)" \
"get integer type for $size$sign"
gdb_test "python print(t.sizeof)" "$size" \
diff --git a/gdb/testsuite/gdb.python/py-as-string.exp b/gdb/testsuite/gdb.python/py-as-string.exp
index 05d55df..2ad179d 100644
--- a/gdb/testsuite/gdb.python/py-as-string.exp
+++ b/gdb/testsuite/gdb.python/py-as-string.exp
@@ -26,7 +26,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return 0
}
diff --git a/gdb/testsuite/gdb.python/py-auto-load-chaining.exp b/gdb/testsuite/gdb.python/py-auto-load-chaining.exp
index 451dca6..fbb95d9 100644
--- a/gdb/testsuite/gdb.python/py-auto-load-chaining.exp
+++ b/gdb/testsuite/gdb.python/py-auto-load-chaining.exp
@@ -49,7 +49,7 @@ if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile}]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.python/py-bp-locations.exp b/gdb/testsuite/gdb.python/py-bp-locations.exp
index 61e4e38..b09a401 100644
--- a/gdb/testsuite/gdb.python/py-bp-locations.exp
+++ b/gdb/testsuite/gdb.python/py-bp-locations.exp
@@ -27,7 +27,7 @@ save_vars { GDBFLAGS } {
clean_restart $testfile
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
@@ -79,7 +79,7 @@ gdb_test "python print(gdb.breakpoints()\[1\].locations\[0\])" \
"check repr of disabled breakpoint location"
gdb_continue_to_breakpoint "" ".*25.*"
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.python/py-breakpoint-create-fail.exp b/gdb/testsuite/gdb.python/py-breakpoint-create-fail.exp
index 391744e..4098a7a 100644
--- a/gdb/testsuite/gdb.python/py-breakpoint-create-fail.exp
+++ b/gdb/testsuite/gdb.python/py-breakpoint-create-fail.exp
@@ -27,7 +27,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
}
clean_restart "${testfile}"
-if ![runto_main] {
+if {![runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.python/py-caller-is.exp b/gdb/testsuite/gdb.python/py-caller-is.exp
index 8e54c3b..0fdb80e 100644
--- a/gdb/testsuite/gdb.python/py-caller-is.exp
+++ b/gdb/testsuite/gdb.python/py-caller-is.exp
@@ -26,7 +26,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return 0
}
diff --git a/gdb/testsuite/gdb.python/py-color-pagination.exp b/gdb/testsuite/gdb.python/py-color-pagination.exp
new file mode 100644
index 0000000..e7a9e4f
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-color-pagination.exp
@@ -0,0 +1,137 @@
+# Copyright (C) 2025 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 tests gdb.Color and how this
+# interacts with GDB's pagination system.
+
+load_lib gdb-python.exp
+
+require allow_python_tests
+require {!is_remote host}
+
+standard_testfile
+
+set pyfile [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py]
+
+set str "<[string repeat - 78]>"
+
+# These define all the default attributes for a style: background
+# color, intensity, italics, and underlined.
+set other_attr ";49;22;23;24;27"
+
+# These colors set the foreground color only. Everything else is the
+# default.
+set black "(?:\033\\\[30${other_attr}m)"
+set red "(?:\033\\\[31${other_attr}m)"
+set green "(?:\033\\\[32${other_attr}m)"
+set yellow "(?:\033\\\[33${other_attr}m)"
+set blue "(?:\033\\\[34${other_attr}m)"
+set magenta "(?:\033\\\[35${other_attr}m)"
+set cyan "(?:\033\\\[36${other_attr}m)"
+set white "(?:\033\\\[37${other_attr}m)"
+
+set any_color "(?:${black}|${red}|${green}|${yellow}|${blue}|${magenta}|${cyan}|${white})"
+
+# Run the command 'TYPE-fill MODE' which fills the screen with output and
+# triggers the pagination prompt. Check that styling is applied correctly
+# to the output.
+proc test_pagination { type mode } {
+
+ # Start with a fresh GDB, but enable color support.
+ with_ansi_styling_terminal {
+ clean_restart
+ }
+
+ gdb_test_no_output "source $::pyfile" "source the script"
+
+ gdb_test_no_output "set width 80"
+ gdb_test_no_output "set height 15"
+
+ set saw_bad_color_handling false
+ set expected_restore_color ""
+ set last_color ""
+ gdb_test_multiple "$type-fill $mode" "" {
+ -re "^$type-fill $mode\r\n" {
+ exp_continue
+ }
+
+ -re "^(${::any_color})(${::any_color})$::str" {
+ # After a continuation prompt GDB will restore the previous
+ # color, and then we immediately switch to a new color.
+ set restored_color $expect_out(1,string)
+ if { $restored_color ne $expected_restore_color } {
+ set saw_bad_color_handling true
+ }
+ set last_color $expect_out(2,string)
+ exp_continue
+ }
+
+ -re "^(${::any_color})$::str" {
+ # This pattern matches printing STR in all cases that are not
+ # immediately after a pagination prompt. In this case there is
+ # a single escape sequence to set the color.
+ set last_color $expect_out(1,string)
+ exp_continue
+ }
+
+ -re "^\033\\\[${::decimal}m$::str" {
+ # This catches the case where the color's escape sequence has
+ # not been converted back into a full style. This indicates
+ # something went wrong in the pager_file::puts function.
+ set saw_bad_color_handling true
+ exp_continue
+ }
+
+ -re "^\033\\\[m$::pagination_prompt$" {
+ # After a pagination prompt we expect GDB to restore the last
+ # color.
+ set expected_restore_color $last_color
+
+ # Send '\n' to view more output.
+ send_gdb "\n"
+ exp_continue
+ }
+
+ -re "^$::pagination_prompt$" {
+ # After a pagination prompt we expect GDB to restore the last
+ # color.
+ set expected_restore_color $last_color
+
+ # If we didn't see a color reset sequence before the pagination
+ # prompt, then the prompt will have been printed in the wrong
+ # color, this is a GDB bug.
+ set saw_bad_color_handling true
+
+ # Send '\n' to view more output.
+ send_gdb "\n"
+ exp_continue
+ }
+
+ -re "^\r\n" {
+ # The matches the newline sent to the continuation prompt.
+ exp_continue
+ }
+
+ -re "^\033\\\[m\r\n$::gdb_prompt $" {
+ gdb_assert { !$saw_bad_color_handling } $gdb_test_name
+ }
+ }
+}
+
+foreach_with_prefix type { color } {
+ foreach_with_prefix mode { write print } {
+ test_pagination $type $mode
+ }
+}
diff --git a/gdb/testsuite/gdb.python/py-color-pagination.py b/gdb/testsuite/gdb.python/py-color-pagination.py
new file mode 100644
index 0000000..efd501e
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-color-pagination.py
@@ -0,0 +1,46 @@
+# Copyright (C) 2025 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/>.
+
+import gdb
+
+basic_colors = ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"]
+
+
+def write(mode, text):
+ if mode == "write":
+ gdb.write(text)
+ else:
+ print(text, end="")
+
+
+class ColorTester(gdb.Command):
+ def __init__(self):
+ super().__init__("color-fill", gdb.COMMAND_USER)
+
+ def invoke(self, args, from_tty):
+ mode = args
+ str = "<" + "-" * 78 + ">"
+ for i in range(0, 20):
+ for color_name in basic_colors:
+ c = gdb.Color(color_name)
+ write(mode, c.escape_sequence(True))
+ write(mode, str)
+
+ default = gdb.Color("none")
+ write(mode, default.escape_sequence(True))
+ write(mode, "\n")
+
+
+ColorTester()
diff --git a/gdb/testsuite/gdb.python/py-color.exp b/gdb/testsuite/gdb.python/py-color.exp
index 2601cf3..08089e5 100644
--- a/gdb/testsuite/gdb.python/py-color.exp
+++ b/gdb/testsuite/gdb.python/py-color.exp
@@ -18,6 +18,7 @@
load_lib gdb-python.exp
require allow_python_tests
+require {!is_remote host}
# Start with a fresh GDB, but enable color support.
with_ansi_styling_terminal {
diff --git a/gdb/testsuite/gdb.python/py-disasm.exp.tcl b/gdb/testsuite/gdb.python/py-disasm.exp.tcl
index c5099ba..5f45747 100644
--- a/gdb/testsuite/gdb.python/py-disasm.exp.tcl
+++ b/gdb/testsuite/gdb.python/py-disasm.exp.tcl
@@ -24,14 +24,16 @@ standard_testfile py-disasm.c
if { $kind == "obj" } {
- set obj [standard_output_file ${gdb_test_file_name}.o]
+ set testfile $testfile.o
+ set binfile [standard_output_file $testfile]
- if { [gdb_compile "$srcdir/$subdir/$srcfile" $obj object "debug"] != "" } {
- untested "failed to compile object file [file tail $obj]"
+ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile object \
+ "debug"] != "" } {
+ untested "failed to compile object file $testfile"
return -1
}
- clean_restart $obj
+ clean_restart $testfile
} else {
diff --git a/gdb/testsuite/gdb.python/py-event-load.exp b/gdb/testsuite/gdb.python/py-event-load.exp
index a09a946..dbb225f 100644
--- a/gdb/testsuite/gdb.python/py-event-load.exp
+++ b/gdb/testsuite/gdb.python/py-event-load.exp
@@ -20,12 +20,6 @@ load_lib gdb-python.exp
require allow_shlib_tests allow_python_tests
-if {[get_compiler_info]} {
- warning "Could not get compiler info"
- untested "no compiler info"
- return -1
-}
-
standard_testfile .c
if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
executable {debug shlib_load}] != ""} {
diff --git a/gdb/testsuite/gdb.python/py-exec-file.exp b/gdb/testsuite/gdb.python/py-exec-file.exp
index b3418a5..139ce83 100644
--- a/gdb/testsuite/gdb.python/py-exec-file.exp
+++ b/gdb/testsuite/gdb.python/py-exec-file.exp
@@ -19,8 +19,10 @@ load_lib gdb-python.exp
standard_testfile
-set binfile1 ${binfile}-a
-set binfile2 ${binfile}-b
+set testfile1 $testfile-a
+set binfile1 [standard_output_file $testfile1]
+set testfile2 $testfile-b
+set binfile2 [standard_output_file $testfile2]
if {[build_executable "failed to prepare first executable" \
$binfile1 $srcfile]} {
@@ -176,7 +178,7 @@ with_test_prefix "using 'symbol-file' command" {
# Check the executable_changed event when the executable changes on disk.
with_test_prefix "exec changes on disk" {
- clean_restart $binfile1
+ clean_restart $::testfile1
setup_exec_change_handler
diff --git a/gdb/testsuite/gdb.python/py-explore-cc.exp b/gdb/testsuite/gdb.python/py-explore-cc.exp
index 0be7019..8c28d87 100644
--- a/gdb/testsuite/gdb.python/py-explore-cc.exp
+++ b/gdb/testsuite/gdb.python/py-explore-cc.exp
@@ -36,7 +36,7 @@ A = <Enter 0 to explore this base class of type 'A'>.*\
i = <Enter 1 to explore this field of type 'int'>.*\
c = <Enter 2 to explore this field of type 'char'>.*"
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.python/py-explore.exp b/gdb/testsuite/gdb.python/py-explore.exp
index a68c110..df0f465 100644
--- a/gdb/testsuite/gdb.python/py-explore.exp
+++ b/gdb/testsuite/gdb.python/py-explore.exp
@@ -47,7 +47,7 @@ proc array_description { value_name type } {
proc pointer_description { value_name type_name } {
set type_description "'$value_name' is a pointer to a value of type '$type_name'\.\[\r\n\]+"
- set prompt "Continue exploring it as a pointer to a single value \[\[\]y/n\[\]\]: "
+ set prompt "Continue exploring it as a pointer to a single value \[\[\]y/n\[\]\]: "
return "$type_description$prompt"
}
@@ -75,7 +75,7 @@ proc scalar_value { value_name value } {
set SS_fields [field_values {a = 10} {d = 100[.].*}]
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
@@ -125,7 +125,7 @@ gdb_test_multiple "explore darray_ref" "" {
}
}
}
- }
+ }
}
}
}
diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint.exp b/gdb/testsuite/gdb.python/py-finish-breakpoint.exp
index c7d31f0..bec22ee 100644
--- a/gdb/testsuite/gdb.python/py-finish-breakpoint.exp
+++ b/gdb/testsuite/gdb.python/py-finish-breakpoint.exp
@@ -112,7 +112,7 @@ with_test_prefix "return to inlined function" {
}
#
-# Test FinishBreakpoint with no debug symbol
+# Test FinishBreakpoint with no debug symbol
#
with_test_prefix "no debug symbol" {
@@ -140,7 +140,7 @@ with_test_prefix "no debug symbol" {
}
#
-# Test FinishBreakpoint in function returned by longjmp
+# Test FinishBreakpoint in function returned by longjmp
#
with_test_prefix "function returned by longjump" {
@@ -166,7 +166,7 @@ with_test_prefix "function returned by longjump" {
}
#
-# Test FinishBreakpoint in BP condition evaluation
+# Test FinishBreakpoint in BP condition evaluation
# (finish in dummy frame)
#
@@ -194,7 +194,7 @@ with_test_prefix "finish in dummy frame" {
}
#
-# Test FinishBreakpoint in BP condition evaluation
+# Test FinishBreakpoint in BP condition evaluation
# (finish in normal frame)
#
diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp b/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp
index 922426f..be81576 100644
--- a/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp
+++ b/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp
@@ -42,7 +42,7 @@ gdb_breakpoint [gdb_get_line_number "Break after exception 2"]
gdb_test "source $pyfile" ".*Python script imported.*" \
"import python scripts"
-
+
gdb_breakpoint "throw_exception_1"
#
diff --git a/gdb/testsuite/gdb.python/py-format-address.exp b/gdb/testsuite/gdb.python/py-format-address.exp
index 173297c..2946314 100644
--- a/gdb/testsuite/gdb.python/py-format-address.exp
+++ b/gdb/testsuite/gdb.python/py-format-address.exp
@@ -27,12 +27,14 @@ foreach func_name { foo bar } {
}
}
-set binary_foo [standard_output_file "${testfile}-foo"]
-set binary_bar [standard_output_file "${testfile}-bar"]
+set testfile_foo $testfile-foo
+set testfile_bar $testfile-bar
+set binary_foo [standard_output_file $testfile_foo]
+set binary_bar [standard_output_file $testfile_bar]
-clean_restart $binary_foo
+clean_restart $testfile_foo
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
@@ -51,7 +53,7 @@ gdb_test_multiple "info break 1" "" {
}
}
if { $next_addr == "UNKNOWN" || $next_addr == $main_addr } {
- set next_addr [format 0x%x [expr $main_addr + 1]]
+ set next_addr [format 0x%x [expr {$main_addr + 1}]]
}
verbose -log "main_addr: $main_addr"
diff --git a/gdb/testsuite/gdb.python/py-format-string.exp b/gdb/testsuite/gdb.python/py-format-string.exp
index 114a606..f34108d 100644
--- a/gdb/testsuite/gdb.python/py-format-string.exp
+++ b/gdb/testsuite/gdb.python/py-format-string.exp
@@ -47,7 +47,8 @@ proc build_inferior {exefile lang} {
proc prepare_gdb {exefile} {
global srcdir subdir srcfile testfile hex
- clean_restart $exefile
+ clean_restart
+ gdb_load $exefile
if {![runto_main]} {
return
@@ -109,7 +110,7 @@ proc get_cut_big_string { max } {
return "\"${whole_big_string}\""
}
- set cut_string [string range $whole_big_string 0 [expr $max - 1]]
+ set cut_string [string range $whole_big_string 0 [expr {$max - 1}]]
return "\"${cut_string}\"..."
}
@@ -1202,7 +1203,9 @@ with_test_prefix "format_string" {
set current_lang "c"
prepare_gdb "${binfile}"
test_all_common
- test_styling
+ if { ![is_remote host] } {
+ test_styling
+ }
}
}
}
diff --git a/gdb/testsuite/gdb.python/py-frame-args.exp b/gdb/testsuite/gdb.python/py-frame-args.exp
index 1dbd30e..12f1651 100644
--- a/gdb/testsuite/gdb.python/py-frame-args.exp
+++ b/gdb/testsuite/gdb.python/py-frame-args.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.python/py-framefilter-addr.exp b/gdb/testsuite/gdb.python/py-framefilter-addr.exp
index 14eebc2..27c1de3 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-addr.exp
+++ b/gdb/testsuite/gdb.python/py-framefilter-addr.exp
@@ -27,7 +27,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.python/py-framefilter-mi.exp b/gdb/testsuite/gdb.python/py-framefilter-mi.exp
index de04236..03e5f90 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-mi.exp
+++ b/gdb/testsuite/gdb.python/py-framefilter-mi.exp
@@ -28,7 +28,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.python/py-inferior.exp b/gdb/testsuite/gdb.python/py-inferior.exp
index 62af1a4..58632f0 100644
--- a/gdb/testsuite/gdb.python/py-inferior.exp
+++ b/gdb/testsuite/gdb.python/py-inferior.exp
@@ -318,7 +318,7 @@ with_test_prefix "large range" {
# For native targets, test a pattern straddling a chunk boundary.
-if [isnative] {
+if {[isnative]} {
with_test_prefix "straddling" {
gdb_test_no_output "set *(int32_t*) &search_buf\[${CHUNK_SIZE}-1\] = 0xfdb97531"
gdb_test_no_output "py pattern = pack('${python_pack_char}I', 0xfdb97531)"
diff --git a/gdb/testsuite/gdb.python/py-label-symbol-value.exp b/gdb/testsuite/gdb.python/py-label-symbol-value.exp
index ca534d4..07bc870 100644
--- a/gdb/testsuite/gdb.python/py-label-symbol-value.exp
+++ b/gdb/testsuite/gdb.python/py-label-symbol-value.exp
@@ -24,7 +24,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.python/py-lazy-string.exp b/gdb/testsuite/gdb.python/py-lazy-string.exp
index 7e7272e..a6fdd77 100644
--- a/gdb/testsuite/gdb.python/py-lazy-string.exp
+++ b/gdb/testsuite/gdb.python/py-lazy-string.exp
@@ -26,7 +26,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
return -1
}
-if ![runto_main ] {
+if {![runto_main ]} {
return -1
}
diff --git a/gdb/testsuite/gdb.python/py-linetable-empty.exp b/gdb/testsuite/gdb.python/py-linetable-empty.exp
index 1e737e1..f742d70 100644
--- a/gdb/testsuite/gdb.python/py-linetable-empty.exp
+++ b/gdb/testsuite/gdb.python/py-linetable-empty.exp
@@ -27,11 +27,11 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name py-linetable-empty.c}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name py-linetable-empty.c
} {
subprogram {
- {MACRO_AT_func {main}}
+ MACRO_AT_func {main}
}
}
}
@@ -42,7 +42,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.python/py-linetable.exp b/gdb/testsuite/gdb.python/py-linetable.exp
index d27d16e..453ee7a 100644
--- a/gdb/testsuite/gdb.python/py-linetable.exp
+++ b/gdb/testsuite/gdb.python/py-linetable.exp
@@ -18,7 +18,7 @@ require allow_python_tests
set opts {}
standard_testfile .S
-if [info exists COMPILE] {
+if {[info exists COMPILE]} {
# make check RUNTESTFLAGS="gdb.python/py-linetable.exp COMPILE=1"
standard_testfile
lappend opts debug optimize=-O2
@@ -30,7 +30,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.python/py-mi-events.exp b/gdb/testsuite/gdb.python/py-mi-events.exp
index ecdb74a..a15ba0b 100644
--- a/gdb/testsuite/gdb.python/py-mi-events.exp
+++ b/gdb/testsuite/gdb.python/py-mi-events.exp
@@ -39,7 +39,7 @@ mi_gdb_test "set auto-load safe-path ${remote_python_file}" \
{.*\^done} \
"set safe-path"
-if [is_remote host] {
+if {[is_remote host]} {
set filename ${testfile}
remote_download host ${binfile} ${filename}
} else {
diff --git a/gdb/testsuite/gdb.python/py-mi-objfile.exp b/gdb/testsuite/gdb.python/py-mi-objfile.exp
index 58ecbc5..c1edffe 100644
--- a/gdb/testsuite/gdb.python/py-mi-objfile.exp
+++ b/gdb/testsuite/gdb.python/py-mi-objfile.exp
@@ -33,7 +33,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
# gdb will find it.
set remote_python_file [gdb_remote_download host ${srcdir}/${subdir}/${pyfile}]
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
@@ -41,7 +41,7 @@ mi_gdb_test "set auto-load safe-path ${remote_python_file}" \
{.*\^done} \
"set safe-path"
-if [is_remote host] {
+if {[is_remote host]} {
set filename ${testfile}
remote_download host ${binfile} ${filename}
} else {
diff --git a/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp b/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp
index 07cd40f..7a9124b 100644
--- a/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp
+++ b/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp
@@ -29,7 +29,7 @@ if {[gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable {debug}] != "" }
return -1
}
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
set pyfile [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py]
mi_gdb_test "source ${pyfile}" \
diff --git a/gdb/testsuite/gdb.python/py-mi.exp b/gdb/testsuite/gdb.python/py-mi.exp
index 7f1dffc..28d63c1 100644
--- a/gdb/testsuite/gdb.python/py-mi.exp
+++ b/gdb/testsuite/gdb.python/py-mi.exp
@@ -26,7 +26,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-if {[mi_clean_restart $binfile]} {
+if {[mi_clean_restart $::testfile]} {
return
}
@@ -345,7 +345,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}-cxx" \
return -1
}
-if {[mi_clean_restart ${binfile}-cxx]} {
+if {[mi_clean_restart ${::testfile}-cxx]} {
return
}
diff --git a/gdb/testsuite/gdb.python/py-missing-objfile.exp b/gdb/testsuite/gdb.python/py-missing-objfile.exp
index 29bc555..ce4dc76 100644
--- a/gdb/testsuite/gdb.python/py-missing-objfile.exp
+++ b/gdb/testsuite/gdb.python/py-missing-objfile.exp
@@ -134,7 +134,7 @@ proc clean_restart_load_python {} {
# For sanity, lets check that we can load the specify the executable
# and then load the core-file the easy way.
with_test_prefix "initial sanity check" {
- clean_restart $binfile
+ clean_restart $::testfile
load_core_file
check_loaded_debug true true
}
diff --git a/gdb/testsuite/gdb.python/py-objfile-script.exp b/gdb/testsuite/gdb.python/py-objfile-script.exp
index 1a3d394..4e6f5b6 100644
--- a/gdb/testsuite/gdb.python/py-objfile-script.exp
+++ b/gdb/testsuite/gdb.python/py-objfile-script.exp
@@ -41,7 +41,7 @@ gdb_load ${binfile}
# Verify gdb loaded the script.
gdb_test "info auto-load python-scripts" "Yes.*${testfile}-gdb.py.*"
-if ![runto_main] {
+if {![runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp
index 8d11028..ce4e37a 100644
--- a/gdb/testsuite/gdb.python/py-objfile.exp
+++ b/gdb/testsuite/gdb.python/py-objfile.exp
@@ -68,7 +68,7 @@ gdb_test "python print (gdb.lookup_objfile (\"${testfile}\").lookup_static_symbo
"None" "lookup_static_symbol can handle nonexistent symbol"
set binfile_build_id [get_build_id $binfile]
-if [string compare $binfile_build_id ""] {
+if {[string compare $binfile_build_id ""]} {
verbose -log "binfile_build_id = $binfile_build_id"
gdb_test "python print (objfile.build_id)" "$binfile_build_id" \
"Get objfile build id"
@@ -119,7 +119,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile}2 ${srcfile} {nodebug l
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return 0
}
@@ -158,12 +158,13 @@ if { [get_python_valueof "sep_objfile.build_id" "None"] != "None" } {
# An objfile that was a symlink to a differently named file is still
# findable with its original name.
# On Windows we don't have proper symlinks, so skip this.
-if ![ishost *-*-mingw*] {
+if {![ishost *-*-mingw*]} {
set symlink_binary [standard_output_file "symlink-binary"]
remote_exec host "rm -f ${symlink_binary}"
remote_exec host "ln -sf ${testfile} ${symlink_binary}"
- if [remote_file host exists "${symlink_binary}"] {
- clean_restart "${symlink_binary}"
+ if {[remote_file host exists "${symlink_binary}"]} {
+ clean_restart
+ gdb_load "${symlink_binary}"
gdb_test "python print (gdb.lookup_objfile (\"${symlink_binary}\").filename)" \
"${testfile}" "gdb.lookup_objfile of symlinked binary"
}
diff --git a/gdb/testsuite/gdb.python/py-parameter.exp b/gdb/testsuite/gdb.python/py-parameter.exp
index 214c570..1d7f22b 100644
--- a/gdb/testsuite/gdb.python/py-parameter.exp
+++ b/gdb/testsuite/gdb.python/py-parameter.exp
@@ -24,7 +24,7 @@ require allow_python_tests
clean_restart
proc py_param_test_maybe_no_output { command pattern args } {
- if [string length $pattern] {
+ if {[string length $pattern]} {
gdb_test $command $pattern $args
} else {
gdb_test_no_output $command $args
@@ -38,13 +38,17 @@ proc_with_prefix test_directories { } {
# doesn't set search directories on remote host.
set directories ".*\\\$cdir.\\\$cwd"
} else {
- set escaped_directory [string_to_regexp "$::srcdir/$::subdir"]
+ set directory [host_file_normalize "$::srcdir/$::subdir"]
+ set escaped_directory [string_to_regexp $directory]
set directories "$escaped_directory.\\\$cdir.\\\$cwd"
}
gdb_test "python print (gdb.parameter ('directories'))" $directories
}
proc_with_prefix test_data_directory { } {
+ # Proc assumes local host.
+ require {!is_remote host}
+
clean_restart
# Check we can correctly read the data-directory parameter. First,
@@ -187,6 +191,8 @@ proc_with_prefix test_enum_parameter { } {
# Test an color parameter.
proc_with_prefix test_color_parameter { } {
+ require {!is_remote host}
+
global env
with_ansi_styling_terminal {
# This enables 256 colors support and disables colors approximation.
diff --git a/gdb/testsuite/gdb.python/py-pp-cast.exp b/gdb/testsuite/gdb.python/py-pp-cast.exp
index 7e20756..917547c 100644
--- a/gdb/testsuite/gdb.python/py-pp-cast.exp
+++ b/gdb/testsuite/gdb.python/py-pp-cast.exp
@@ -25,7 +25,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return -1
}
-if ![runto break_function] {
+if {![runto break_function]} {
return -1
}
diff --git a/gdb/testsuite/gdb.python/py-pp-integral.exp b/gdb/testsuite/gdb.python/py-pp-integral.exp
index 8111d75..45645f9 100644
--- a/gdb/testsuite/gdb.python/py-pp-integral.exp
+++ b/gdb/testsuite/gdb.python/py-pp-integral.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return -1
}
-if ![runto tick_tock] {
+if {![runto tick_tock]} {
return -1
}
diff --git a/gdb/testsuite/gdb.python/py-pp-maint.exp b/gdb/testsuite/gdb.python/py-pp-maint.exp
index 74d8e76..bd26b91 100644
--- a/gdb/testsuite/gdb.python/py-pp-maint.exp
+++ b/gdb/testsuite/gdb.python/py-pp-maint.exp
@@ -72,10 +72,10 @@ gdb_test "enable pretty-printer" \
"second enable of all pretty printers"
gdb_test "disable pretty-printer global lookup_function_lookup_test" \
- "1 printer disabled.*[expr $num_pp - 1] of $num_pp printers enabled"
+ "1 printer disabled.*[expr {$num_pp - 1}] of $num_pp printers enabled"
gdb_test "disable pretty-printer global pp-test;.*" \
- "[expr 5] printers disabled.*0 of $num_pp printers enabled"
+ "[expr {$num_pp - 1}] printers disabled.*0 of $num_pp printers enabled"
gdb_test "info pretty-printer global .*function" \
{.*function_lookup_test \[disabled\].*} \
@@ -101,10 +101,10 @@ gdb_test "enable pretty-printer global pp-test" \
"0 printers enabled.*1 of $num_pp printers enabled"
gdb_test "enable pretty-printer global pp-test;.*ss.*" \
- "2 printers enabled.*[expr $num_pp - 3] of $num_pp printers enabled"
+ "2 printers enabled.*[expr {$num_pp - 3}] of $num_pp printers enabled"
gdb_test "enable pretty-printer global pp-test;.*s.*" \
- "2 printers enabled.*[expr $num_pp - 1] of $num_pp printers enabled"
+ "2 printers enabled.*[expr {$num_pp - 1}] of $num_pp printers enabled"
gdb_test "enable pretty-printer global pp-test;.*" \
"1 printer enabled.*$num_pp of $num_pp printers enabled"
diff --git a/gdb/testsuite/gdb.python/py-pp-re-notag.exp b/gdb/testsuite/gdb.python/py-pp-re-notag.exp
index 8111d75..45645f9 100644
--- a/gdb/testsuite/gdb.python/py-pp-re-notag.exp
+++ b/gdb/testsuite/gdb.python/py-pp-re-notag.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return -1
}
-if ![runto tick_tock] {
+if {![runto tick_tock]} {
return -1
}
diff --git a/gdb/testsuite/gdb.python/py-pp-registration.exp b/gdb/testsuite/gdb.python/py-pp-registration.exp
index c5e7f9a..d0d1fda 100644
--- a/gdb/testsuite/gdb.python/py-pp-registration.exp
+++ b/gdb/testsuite/gdb.python/py-pp-registration.exp
@@ -29,7 +29,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
set remote_python_file [gdb_remote_download host \
${srcdir}/${subdir}/${testfile}.py]
-if ![runto_main ] {
+if {![runto_main ]} {
return -1
}
@@ -40,7 +40,7 @@ proc prepare_test { } {
clean_restart ${testfile}
set run_to_here [gdb_get_line_number {break to inspect} ${testfile}.c ]
- if ![runto ${testfile}.c:$run_to_here] {
+ if {![runto ${testfile}.c:$run_to_here]} {
return 0
}
@@ -63,7 +63,7 @@ proc test_printers { s_prefix } {
# Test registration with verbose off.
with_test_prefix "verbose off" {
- if ![prepare_test] {
+ if {![prepare_test]} {
return -1
}
@@ -78,7 +78,7 @@ with_test_prefix "verbose off" {
# Test registration with verbose on.
with_test_prefix "verbose on" {
- if ![prepare_test] {
+ if {![prepare_test]} {
return -1
}
@@ -95,7 +95,7 @@ with_test_prefix "verbose on" {
# Exercise the "replace" argument to register_pretty_printer.
with_test_prefix "replace" {
- if ![prepare_test] {
+ if {![prepare_test]} {
return -1
}
diff --git a/gdb/testsuite/gdb.python/py-prettyprint.exp b/gdb/testsuite/gdb.python/py-prettyprint.exp
index 0b5ca9a..be2cecd 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint.exp
+++ b/gdb/testsuite/gdb.python/py-prettyprint.exp
@@ -36,7 +36,8 @@ proc run_lang_tests {exefile lang} {
set nl "\[\r\n\]+"
# Start with a fresh gdb.
- clean_restart $exefile
+ clean_restart
+ gdb_load $exefile
if {![runto_main]} {
return
@@ -52,11 +53,11 @@ proc run_lang_tests {exefile lang} {
${srcdir}/${subdir}/${testfile}.py]
gdb_test_no_output "source ${remote_python_file}" "load python file"
-
+
gdb_test "print ss" " = a=< a=<1> b=<$hex>> b=< a=<2> b=<$hex>>"
gdb_test "print ssa\[1\]" " = a=< a=<5> b=<$hex>> b=< a=<6> b=<$hex>>"
gdb_test "print ssa" " = {a=< a=<3> b=<$hex>> b=< a=<4> b=<$hex>>, a=< a=<5> b=<$hex>> b=< a=<6> b=<$hex>>}"
-
+
gdb_test "print arraystruct" " = {$nl *y = 7, *$nl *x = { a=<23> b=<$hex>, a=<24> b=<$hex>} *$nl *}"
# Test that when a pretty-printer returns a gdb.Value in its to_string, we
@@ -192,7 +193,7 @@ with_test_prefix c++ {
# Run various other tests.
-clean_restart $binfile
+clean_restart $::testfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.python/py-progspace.exp b/gdb/testsuite/gdb.python/py-progspace.exp
index 1d271d4..822c079 100644
--- a/gdb/testsuite/gdb.python/py-progspace.exp
+++ b/gdb/testsuite/gdb.python/py-progspace.exp
@@ -76,7 +76,7 @@ gdb_test "python print (blk.end >= ${pc_val})" "True" \
"block end is after \$pc"
# Check what happens when we ask for a block of an invalid address.
-if ![is_address_zero_readable] {
+if {![is_address_zero_readable]} {
gdb_test "python print (gdb.current_progspace ().block_for_pc (0))" "None"
}
diff --git a/gdb/testsuite/gdb.python/py-read-memory-leak.exp b/gdb/testsuite/gdb.python/py-read-memory-leak.exp
index 9ae5eb8..0b663d7 100644
--- a/gdb/testsuite/gdb.python/py-read-memory-leak.exp
+++ b/gdb/testsuite/gdb.python/py-read-memory-leak.exp
@@ -26,7 +26,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.python/py-record-btrace.exp b/gdb/testsuite/gdb.python/py-record-btrace.exp
index aff7c6c..6dd3ae1 100644
--- a/gdb/testsuite/gdb.python/py-record-btrace.exp
+++ b/gdb/testsuite/gdb.python/py-record-btrace.exp
@@ -23,7 +23,7 @@ load_lib gdb-python.exp
standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile $srcfile] { return -1 }
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} { return -1 }
if {![runto_main]} {
return -1
diff --git a/gdb/testsuite/gdb.python/py-record-full.exp b/gdb/testsuite/gdb.python/py-record-full.exp
index 97d21ce..790e5b3 100644
--- a/gdb/testsuite/gdb.python/py-record-full.exp
+++ b/gdb/testsuite/gdb.python/py-record-full.exp
@@ -23,7 +23,7 @@ load_lib gdb-python.exp
standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile $srcfile] { return -1 }
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} { return -1 }
if {![runto_main]} {
return -1
diff --git a/gdb/testsuite/gdb.python/py-section-script.exp b/gdb/testsuite/gdb.python/py-section-script.exp
index cc4425c..9d4e48c 100644
--- a/gdb/testsuite/gdb.python/py-section-script.exp
+++ b/gdb/testsuite/gdb.python/py-section-script.exp
@@ -71,13 +71,13 @@ clean_restart
# Get the name of the binfile on the host; on a remote host this means
# stripping off any directory prefix.
-if [is_remote host] {
+if {[is_remote host]} {
set remote_binfile [file tail ${binfile}]
} else {
set remote_binfile ${binfile}
}
-if [ishost *-*-mingw*] {
+if {[ishost *-*-mingw*]} {
set remote_pathsep ";"
} else {
set remote_pathsep ":"
@@ -107,7 +107,7 @@ gdb_test "info auto-load python-scripts ${testfile}" "Yes.*${testfile}.py.*"
gdb_test "info auto-load python-scripts no-script-matches-this" \
"No auto-load scripts matching no-script-matches-this."
-if ![runto_main] {
+if {![runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.python/py-source-styling.exp b/gdb/testsuite/gdb.python/py-source-styling.exp
index 308053c..e030768 100644
--- a/gdb/testsuite/gdb.python/py-source-styling.exp
+++ b/gdb/testsuite/gdb.python/py-source-styling.exp
@@ -62,7 +62,7 @@ proc check_source_listing_styling { cmd expect_styled { testname "" } } {
# highlighting when GNU source highlight is not available (or is
# disabled, as is done in this test).
proc test_pygments_styling {} {
- clean_restart $::binfile
+ clean_restart $::testfile
# Remote host boards disable styling via GDB's command line. Turn
# it back on now.
@@ -75,7 +75,7 @@ proc test_pygments_styling {} {
return
}
- if ![runto_main] {
+ if {![runto_main]} {
return
}
@@ -91,7 +91,7 @@ proc test_pygments_styling {} {
# string, then set the correct host encoding, and try again. This
# time the conversion should succeed.
proc test_gdb_execute_non_utf8_source {} {
- clean_restart $::binfile
+ clean_restart $::testfile
# The default host charset is utf-8, the source code contains a
# non-utf-8 character, so this will fail.
@@ -117,7 +117,7 @@ proc test_gdb_execute_non_utf8_source {} {
# output to be returned via a string, and in other cases we ask for
# the output to be sent straight to stdout.
proc_with_prefix test_source_cache_style_tracking {} {
- clean_restart $::binfile
+ clean_restart $::testfile
# Remote host boards disable styling via GDB's command line. Turn
# it back on now.
diff --git a/gdb/testsuite/gdb.python/py-startup-opt.exp b/gdb/testsuite/gdb.python/py-startup-opt.exp
index 7410706..929c64d 100644
--- a/gdb/testsuite/gdb.python/py-startup-opt.exp
+++ b/gdb/testsuite/gdb.python/py-startup-opt.exp
@@ -17,6 +17,7 @@
# initialized.
require allow_python_tests
+require {!is_remote host}
# Return a list containing two directory paths for newly created home
# directories.
diff --git a/gdb/testsuite/gdb.python/py-strfns.exp b/gdb/testsuite/gdb.python/py-strfns.exp
index 2b5dff19..13b8d2e 100644
--- a/gdb/testsuite/gdb.python/py-strfns.exp
+++ b/gdb/testsuite/gdb.python/py-strfns.exp
@@ -26,7 +26,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return 0
}
diff --git a/gdb/testsuite/gdb.python/py-styled-execute.exp b/gdb/testsuite/gdb.python/py-styled-execute.exp
index 0b27c63..198dab5 100644
--- a/gdb/testsuite/gdb.python/py-styled-execute.exp
+++ b/gdb/testsuite/gdb.python/py-styled-execute.exp
@@ -17,6 +17,7 @@
# on the value of the third argument passed to gdb.execute.
require allow_python_tests
+require {!is_remote host}
load_lib gdb-python.exp
diff --git a/gdb/testsuite/gdb.python/py-sym-artificial.exp b/gdb/testsuite/gdb.python/py-sym-artificial.exp
index e26e9d2..831ebd2 100644
--- a/gdb/testsuite/gdb.python/py-sym-artificial.exp
+++ b/gdb/testsuite/gdb.python/py-sym-artificial.exp
@@ -27,21 +27,21 @@ set asm_file [standard_output_file ${srcfile2}]
Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name py-sym-artificial.c}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name py-sym-artificial.c
} {
declare_labels signed
signed: DW_TAG_base_type {
- {DW_AT_byte_size 1 DW_FORM_sdata}
- {DW_AT_encoding @DW_ATE_signed}
- {DW_AT_name bool}
+ DW_AT_byte_size 1 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_name bool
}
DW_TAG_variable {
- {name the_variable}
- {DW_AT_type :$signed}
- {artificial 1 DW_FORM_flag_present}
+ DW_AT_name the_variable
+ DW_AT_type :$signed
+ DW_AT_artificial 1 DW_FORM_flag_present
}
}
}
diff --git a/gdb/testsuite/gdb.python/py-symbol.exp b/gdb/testsuite/gdb.python/py-symbol.exp
index dfc435e..2029c28 100644
--- a/gdb/testsuite/gdb.python/py-symbol.exp
+++ b/gdb/testsuite/gdb.python/py-symbol.exp
@@ -44,7 +44,7 @@ if {!$readnow_p} {
}
# Restart so we don't have expanded symtabs after the previous test.
-clean_restart ${binfile}
+clean_restart ${::testfile}
# Test looking up a global symbol before we runto_main as this is the
# point where we don't have a current frame, and we don't want to
@@ -214,8 +214,10 @@ gdb_test "python print (t\[0\].symtab)" "${py_symbol_c}" "get symtab"
# C++ tests
# Recompile binary.
lappend opts c++
-if {[prepare_for_testing "failed to prepare" "${binfile}-cxx" \
- [list $srcfile $srcfile2] $opts]} {
+set testfile $testfile-cxx
+set binfile [standard_output_file $testfile]
+if { [prepare_for_testing "failed to prepare" $testfile \
+ [list $srcfile $srcfile2] $opts] } {
return -1
}
@@ -251,7 +253,7 @@ gdb_test "python print (cplusfunc.addr_class == gdb.SYMBOL_LOC_BLOCK)" "True" "t
# Test is_valid when the objfile is unloaded. This must be the last
# test as it unloads the object file in GDB.
# Start with a fresh gdb.
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return 0
}
diff --git a/gdb/testsuite/gdb.python/py-thread-exited.exp b/gdb/testsuite/gdb.python/py-thread-exited.exp
index dcacb11..0f47ce0 100644
--- a/gdb/testsuite/gdb.python/py-thread-exited.exp
+++ b/gdb/testsuite/gdb.python/py-thread-exited.exp
@@ -32,7 +32,7 @@ gdb_test_no_output "source ${pyfile}" "load python file"
gdb_test "test-events" "Event testers registered."
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.python/py-thread-exited.py b/gdb/testsuite/gdb.python/py-thread-exited.py
index ef5a244..f725bd5 100644
--- a/gdb/testsuite/gdb.python/py-thread-exited.py
+++ b/gdb/testsuite/gdb.python/py-thread-exited.py
@@ -26,6 +26,8 @@ def thread_exited_handler(event):
global threadOneExit, threadTwoExit, mainThreadExit
print("{}".format(event))
assert isinstance(event, gdb.ThreadExitedEvent)
+ # Also check the inheritance.
+ assert isinstance(event, gdb.ThreadEvent)
if threadOneExit == "":
threadOneExit = "event type: thread-exited. global num: {}".format(
event.inferior_thread.global_num
diff --git a/gdb/testsuite/gdb.python/py-thrhandle.exp b/gdb/testsuite/gdb.python/py-thrhandle.exp
index 343bf4b..a959044 100644
--- a/gdb/testsuite/gdb.python/py-thrhandle.exp
+++ b/gdb/testsuite/gdb.python/py-thrhandle.exp
@@ -29,7 +29,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
runto_main
diff --git a/gdb/testsuite/gdb.python/py-type.exp b/gdb/testsuite/gdb.python/py-type.exp
index 0bc4556..c32a5bd 100644
--- a/gdb/testsuite/gdb.python/py-type.exp
+++ b/gdb/testsuite/gdb.python/py-type.exp
@@ -33,8 +33,9 @@ proc build_inferior {exefile lang} {
}
# Restart GDB.
-proc restart_gdb {exefile} {
- clean_restart $exefile
+proc restart_gdb {exefile} {
+ clean_restart
+ gdb_load $exefile
if {![runto_main]} {
return
@@ -134,7 +135,7 @@ proc test_fields {lang} {
# Test conversion to bool on scalar types
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 "python ar = gdb.history (0)" "get value (ar) from history" 1
@@ -253,9 +254,9 @@ proc test_template {} {
|| [test_compiler_info {gcc-4-[0-4]-*}]} {
set have_older_gcc 1
}
- if $have_older_gcc { setup_xfail *-*-* }
+ if {$have_older_gcc} { setup_xfail *-*-* }
gdb_test "python print (ttype.template_argument(1))" "23"
- if $have_older_gcc { setup_xfail *-*-* }
+ if {$have_older_gcc} { setup_xfail *-*-* }
gdb_test "python print (isinstance(ttype.template_argument(1), gdb.Value))" \
"True"
diff --git a/gdb/testsuite/gdb.python/py-value-cc.exp b/gdb/testsuite/gdb.python/py-value-cc.exp
index 3d371bc..6d261fb 100644
--- a/gdb/testsuite/gdb.python/py-value-cc.exp
+++ b/gdb/testsuite/gdb.python/py-value-cc.exp
@@ -24,7 +24,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.python/py-value.c b/gdb/testsuite/gdb.python/py-value.c
index a822346..f6dbf55 100644
--- a/gdb/testsuite/gdb.python/py-value.c
+++ b/gdb/testsuite/gdb.python/py-value.c
@@ -19,6 +19,14 @@
#include <stdlib.h>
#include <string.h>
+int long_array[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
+ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
+ 40, 41, 42, 43, 44, 45, 46, 47, 48, 49
+};
+
struct s
{
int a;
@@ -60,6 +68,7 @@ struct Derived : public Base {
Base *base = new Derived ();
Derived derived;
Base &base_ref = derived;
+struct str pod;
void ptr_ref(int*& rptr_int)
{
diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp
index 93985a9..087c8c2 100644
--- a/gdb/testsuite/gdb.python/py-value.exp
+++ b/gdb/testsuite/gdb.python/py-value.exp
@@ -297,9 +297,9 @@ proc test_value_in_inferior {} {
gdb_test "print argc" " = $argc_value" "sanity check argc"
gdb_test "python print (argc_lazy.is_lazy)" "\r\nTrue" \
"python print (argc_lazy.is_lazy) the second time"
- gdb_test_no_output "set argc=[expr $argc_value + 1]" "change argc"
+ gdb_test_no_output "set argc=[expr {$argc_value + 1}]" "change argc"
gdb_test "python print (argc_notlazy)" "\r\n$argc_value"
- gdb_test "python print (argc_lazy)" "\r\n[expr $argc_value + 1]"
+ gdb_test "python print (argc_lazy)" "\r\n[expr {$argc_value + 1}]"
gdb_test "python print (argc_lazy.is_lazy)" "False"
# Test string fetches, both partial and whole.
@@ -431,7 +431,8 @@ proc test_value_after_death {} {
proc test_subscript_regression {exefile lang} {
# Start with a fresh gdb.
- clean_restart ${exefile}
+ clean_restart
+ gdb_load $exefile
if {![runto_main]} {
return
@@ -457,6 +458,8 @@ proc test_subscript_regression {exefile lang} {
"Derived \[*\]"
gdb_test "python print (gdb.parse_and_eval('base_ref').dynamic_type)" \
"Derived \[&\]"
+ gdb_test "python print (gdb.parse_and_eval('pod').dynamic_type)" \
+ "str"
# A static type case.
gdb_test "python print (gdb.parse_and_eval('5').dynamic_type)" \
"int"
@@ -595,7 +598,7 @@ proc test_value_from_buffer {} {
gdb_py_test_silent_cmd "python atpbig=tp.array(3)" "make bigger array type" 0
gdb_test "python vabig=gdb.Value(b,atpbig)" \
"ValueError.*: Size of type is larger than that of buffer object\..*" \
- "attempt to construct large value with small buffer"
+ "attempt to construct large value with small buffer"
gdb_test "python v=gdb.Value(2048,tp)" \
"TypeError.*: Object must support the python buffer protocol\..*" \
"attempt to construct value from buffer with non-buffer object"
@@ -680,6 +683,7 @@ proc_with_prefix test_value_bytes { } {
"python" "" \
"def check_value_bytes(var_name):" "" \
" val = gdb.parse_and_eval(var_name)" "" \
+ " assert not val.is_unavailable" "" \
" addr = val.address" "" \
" len = val.type.sizeof" "" \
" mem = gdb.selected_inferior().read_memory(addr, len)" "" \
@@ -762,13 +766,45 @@ proc test_assign {} {
"cannot assign to integer"
}
+# Test Value.is_unavailable
+proc test_unavailable {} {
+ set elem_size [get_valueof "/d" "sizeof(long_array\[0\])" "UNKNOWN" \
+ "get size of long_array element"]
+ set max [expr {$elem_size * 10}]
+
+ with_set "print elements" 5 {
+ with_max_value_size $max {
+ gdb_test "p long_array"
+
+ gdb_test_no_output "set print elements 15"
+
+ gdb_test_no_output "python v = gdb.history(0)"
+
+ gdb_test "python print(v.is_unavailable)" "^True" \
+ "overall object shows as unavailable"
+ for { set i 0 } { $i < 10 } { incr i } {
+ gdb_test "python print(v\[$i\].is_unavailable)" "^False" \
+ "array element $i is available"
+ gdb_test "python print(v\[$i\])" "^$i" \
+ "array element $i has correct value"
+ }
+ for { set i 10 } { $i < 15 } { incr i } {
+ gdb_test "python print(v\[$i\].is_unavailable)" "^True" \
+ "array element $i is unavailable"
+ gdb_test "python print(v\[$i\])" "^<unavailable>" \
+ "array element $i shows as unavailable"
+ }
+ }
+ }
+}
+
# Build C version of executable. C++ is built later.
if { [build_inferior "${binfile}" "c"] < 0 } {
return -1
}
# Start with a fresh gdb.
-clean_restart ${binfile}
+clean_restart ${::testfile}
test_history_count
test_value_creation
@@ -788,6 +824,7 @@ if {![runto_main]} {
return 0
}
+test_unavailable
test_value_in_inferior
test_value_from_buffer
test_value_sub_classes
@@ -797,7 +834,7 @@ test_assign
test_value_bytes
test_value_after_death
-# Test either C or C++ values.
+# Test either C or C++ values.
test_subscript_regression "${binfile}" "c"
@@ -809,3 +846,15 @@ if {[allow_cplus_tests]} {
test_subscript_regression "${binfile}-cxx" "c++"
}
}
+
+if {[allow_rust_tests]} {
+ gdb_test "set lang rust"
+
+ set cst 0x80000000000000000000000000000000
+ gdb_test "python print(int(gdb.parse_and_eval('${cst}u128')))" \
+ "170141183460469231731687303715884105728" \
+ "convert 128 bit unsigned constant to python int"
+ gdb_test "python print(int(gdb.parse_and_eval('${cst}i128')))" \
+ "-170141183460469231731687303715884105728" \
+ "convert 128 bit signed constant to python int"
+}
diff --git a/gdb/testsuite/gdb.python/py-varobj.exp b/gdb/testsuite/gdb.python/py-varobj.exp
index 7fb45f9..cf6a662 100644
--- a/gdb/testsuite/gdb.python/py-varobj.exp
+++ b/gdb/testsuite/gdb.python/py-varobj.exp
@@ -25,7 +25,7 @@ if {[gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable {debug}] != ""}
return -1
}
-mi_clean_restart $binfile
+mi_clean_restart $::testfile
set pyfile [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py]
mi_gdb_test "source ${pyfile}" \
diff --git a/gdb/testsuite/gdb.python/py-xmethods.exp b/gdb/testsuite/gdb.python/py-xmethods.exp
index 3dafe0e..5863ec5 100644
--- a/gdb/testsuite/gdb.python/py-xmethods.exp
+++ b/gdb/testsuite/gdb.python/py-xmethods.exp
@@ -26,7 +26,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
index 96977df..020fc66 100644
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -158,7 +158,7 @@ gdb_test_multiple "python print (\"\\n\" * $lines)" $test {
}
gdb_test "q" "Quit.*" "verify pagination beforehand: q"
-gdb_test "python if gdb.execute('python print (\"\\\\n\" * $lines)', to_string=True) == \"\\n\" * [expr $lines + 1]: print (\"yes\")" "yes" "gdb.execute does not page"
+gdb_test "python if gdb.execute('python print (\"\\\\n\" * $lines)', to_string=True) == \"\\n\" * [expr {$lines + 1}]: print (\"yes\")" "yes" "gdb.execute does not page"
set test "verify pagination afterwards"
gdb_test_multiple "python print (\"\\n\" * $lines)" $test {
@@ -288,7 +288,7 @@ gdb_test "python gdb.write(\"Foo\\n\")" "Foo" "test default write"
gdb_test "python gdb.write(\"Error stream\\n\", stream=gdb.STDERR)" "Error stream" "test stderr write"
gdb_test "python gdb.write(\"Normal stream\\n\", stream=gdb.STDOUT)" "Normal stream" "test stdout write"
-if ![gdb_debug_enabled] {
+if {![gdb_debug_enabled]} {
gdb_test "python gdb.write(\"Log stream\\n\", stream=gdb.STDLOG)" "Log stream" "test stdlog write"
}
diff --git a/gdb/testsuite/gdb.replay/connect.exp b/gdb/testsuite/gdb.replay/connect.exp
index 26b7aa3..b25c372 100644
--- a/gdb/testsuite/gdb.replay/connect.exp
+++ b/gdb/testsuite/gdb.replay/connect.exp
@@ -70,9 +70,8 @@ proc_with_prefix record_initial_logfile {} {
# Connect to gdbreply using the global REMOTELOG. Runs to a breakpoint
# in main.
proc_with_prefix replay_without_error {} {
- global binfile
global remotelog
- clean_restart $binfile
+ clean_restart $::testfile
# Make sure we're disconnected, in case we're testing with an
# extended-remote board, therefore already connected.
gdb_test "disconnect" ".*"
@@ -97,7 +96,6 @@ proc_with_prefix replay_without_error {} {
# copy of REMOTELOG. Attempt to connect to the remote and expect to see
# the error reported by GDB.
proc_with_prefix replay_with_mustreplyempty_error {} {
- global binfile
global remotelog
global testfile
set newline E.errtext
@@ -107,7 +105,7 @@ proc_with_prefix replay_with_mustreplyempty_error {} {
# the vMustReplayEmty packet to an error.
update_log $remotelog $output_file "vMustReplyEmpty" $newline
- clean_restart $binfile
+ clean_restart $::testfile
# Make sure we're disconnected, in case we're testing with an
# extended-remote board, therefore already connected.
gdb_test "disconnect" ".*"
diff --git a/gdb/testsuite/gdb.replay/missing-thread.c b/gdb/testsuite/gdb.replay/missing-thread.c
new file mode 100644
index 0000000..8edb240
--- /dev/null
+++ b/gdb/testsuite/gdb.replay/missing-thread.c
@@ -0,0 +1,61 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2025 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 <pthread.h>
+#include <assert.h>
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdbool.h>
+
+pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t g_condvar = PTHREAD_COND_INITIALIZER;
+
+void *
+worker_function (void *arg)
+{
+ printf ("In worker, about to notify\n");
+ pthread_cond_signal (&g_condvar);
+
+ while (true)
+ sleep(1);
+
+ return NULL;
+}
+
+int
+main()
+{
+ pthread_t my_thread;
+
+ int result = pthread_create (&my_thread, NULL, worker_function, NULL);
+ assert (result == 0);
+
+ pthread_mutex_lock (&g_mutex);
+ pthread_cond_wait (&g_condvar, &g_mutex);
+
+ printf ("In main, have been woken.\n");
+ pthread_mutex_unlock (&g_mutex);
+
+ result = pthread_kill (my_thread, SIGTRAP);
+ assert (result == 0);
+
+ result = pthread_join (my_thread, NULL);
+ assert (result == 0);
+
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.replay/missing-thread.exp b/gdb/testsuite/gdb.replay/missing-thread.exp
new file mode 100644
index 0000000..6ee2e4c
--- /dev/null
+++ b/gdb/testsuite/gdb.replay/missing-thread.exp
@@ -0,0 +1,237 @@
+# Copyright 2025 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 test confirms how GDB handles a badly behaving remote target. The
+# remote target reports a stop event (signal delivery), then, as GDB is
+# processing the stop it syncs the thread list with the remote.
+#
+# The badly behaving remote target was dropping the signaled thread from the
+# thread list at this point, that is, the thread appeared to exit before an
+# exit event had been sent to (and seen by) GDB.
+#
+# At one point this was causing an assertion failed. GDB would try to
+# process the signal stop event, and to do this would try to read some
+# registers. Reading registers requires a regcache, and GDB will only
+# create a regcache for a non-exited thread.
+
+load_lib gdbserver-support.exp
+load_lib gdbreplay-support.exp
+
+require allow_gdbserver_tests
+require has_gdbreplay
+
+standard_testfile
+
+if { [build_executable "failed to build exec" $testfile $srcfile {debug pthreads}] } {
+ return -1
+}
+
+# Start the inferior and record a remote log for our interaction with it.
+# All we do is start the inferior and wait for thread 2 to receive a signal.
+# Check that GDB correctly shows the signal as received. LOG_FILENAME is
+# where we should write the remote log.
+proc_with_prefix record_initial_logfile { log_filename } {
+ clean_restart $::testfile
+
+ # Make sure we're disconnected, in case we're testing with an
+ # extended-remote board, therefore already connected.
+ gdb_test "disconnect" ".*"
+
+ gdb_test_no_output "set sysroot" \
+ "setting sysroot before starting gdbserver"
+
+ # Start gdbserver like:
+ # gdbserver :PORT ....
+ set res [gdbserver_start "" $::binfile]
+ set gdbserver_protocol [lindex $res 0]
+ set gdbserver_gdbport [lindex $res 1]
+
+ gdb_test_no_output "set remotelogfile $log_filename" \
+ "setup remotelogfile"
+
+ # Connect to gdbserver.
+ if {![gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport] == 0} {
+ unsupported "$testfile (couldn't start gdbserver)"
+ return
+ }
+
+ gdb_breakpoint main
+ gdb_continue_to_breakpoint "continuing to main"
+
+ gdb_test "continue" \
+ "Thread $::decimal \[^\r\n\]+ received signal SIGTRAP, .*"
+
+ gdb_test "disconnect" ".*" \
+ "disconnect after seeing signal"
+}
+
+# Copy the remote log from IN_FILENAME to OUT_FILENAME, but modify one
+# particular line.
+#
+# The line to be modified is the last <threads>...</threads> line, this is
+# the reply from the remote that indicates the thread list. It is expected
+# that the thread list will contain two threads.
+#
+# When DROP_BOTH is true then both threads will be removed from the modified
+# line. Otherwise, only the second thread is removed.
+proc update_replay_log { in_filename out_filename drop_both } {
+ # Read IN_FILENAME into a list.
+ set fd [open $in_filename]
+ set data [read $fd]
+ close $fd
+ set lines [split $data "\n"]
+
+ # Find the last line in LINES that contains the <threads> list.
+ set idx -1
+ for { set i 0 } { $i < [llength $lines] } { incr i } {
+ if { [regexp "^r.*<threads>.*</threads>" [lindex $lines $i]] } {
+ set idx $i
+ }
+ }
+
+ # Modify the line by dropping the second thread. This does assume
+ # the thread order as seen in the <threads>...</threads> list, but
+ # this seems stable for now.
+ set line [lindex $lines $idx]
+ set fixed_log false
+ if {[regexp "^(r .*<threads>\\\\n)(<thread id.*/>\\\\n)(<thread id.*/>\\\\n)(</threads>.*)$" $line \
+ match part1 part2 part3 part4]} {
+ if { $drop_both } {
+ set line $part1$part4
+ } else {
+ set line $part1$part2$part4
+ }
+ set lines [lreplace $lines $idx $idx $line]
+ set fixed_log true
+ }
+
+ # Write all the lines to OUT_FILENAME
+ set fd [open $out_filename "w"]
+ foreach l $lines {
+ puts $fd $l
+ }
+ close $fd
+
+ # Did we manage to update the log file?
+ return $fixed_log
+}
+
+# Replay the test process using REMOTE_LOG as the logfile to replay. If
+# EXPECT_ERROR is true then after the final 'continue' we expect GDB to give
+# an error as the required thread is missing. When EXPECT_ERROR is false
+# then we expect the test to complete as normal. NON_STOP is eithe 'on' or
+# 'off' and indicates GDBs non-stop mode.
+proc_with_prefix replay_with_log { remote_log expect_error non_stop } {
+ clean_restart $::testfile
+
+ # Make sure we're disconnected, in case we're testing with an
+ # extended-remote board, therefore already connected.
+ gdb_test "disconnect" ".*"
+
+ gdb_test_no_output "set sysroot"
+
+ set res [gdbreplay_start $remote_log]
+ set gdbserver_protocol [lindex $res 0]
+ set gdbserver_gdbport [lindex $res 1]
+
+ # Connect to gdbserver.
+ if {![gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport] == 0} {
+ fail "couldn't connect to gdbreplay"
+ return
+ }
+
+ gdb_breakpoint main
+ gdb_continue_to_breakpoint "continuing to main"
+
+ if { $expect_error } {
+ set expected_output \
+ [list \
+ "\\\[Thread \[^\r\n\]+ exited\\\]" \
+ "warning: command aborted, Thread \[^\r\n\]+ unexpectedly exited after signal stop event"]
+
+ if { !$non_stop } {
+ lappend expected_output "\\\[Switching to Thread \[^\r\n\]+\\\]"
+ }
+
+ gdb_test "continue" [multi_line {*}$expected_output]
+ } else {
+ # This is the original behaviour, we see this when running
+ # with the unmodified log.
+ gdb_test "continue" \
+ "Thread ${::decimal}(?: \[^\r\n\]+)? received signal SIGTRAP, .*"
+ }
+
+ gdb_test "disconnect" ".*" \
+ "disconnect after seeing signal"
+}
+
+# Run the complete test cycle; generate an initial log file, modify the log
+# file, then check that GDB correctly handles replaying the modified log
+# file.
+#
+# NON_STOP is either 'on' or 'off' and indicates GDB's non-stop mode.
+proc run_test { non_stop } {
+ if { $non_stop } {
+ set suffix "-ns"
+ } else {
+ set suffix ""
+ }
+
+ # The replay log is placed in 'replay.log'.
+ set remote_log [standard_output_file replay${suffix}.log]
+ set missing_1_log [standard_output_file replay-missing-1${suffix}.log]
+ set missing_2_log [standard_output_file replay-missing-2${suffix}.log]
+
+ record_initial_logfile $remote_log
+
+ if { ![update_replay_log $remote_log $missing_1_log false] } {
+ fail "couldn't update remote replay log (drop 1 case)"
+ }
+
+ if { ![update_replay_log $remote_log $missing_2_log true] } {
+ fail "couldn't update remote replay log (drop 2 case)"
+ }
+
+ with_test_prefix "with unmodified log" {
+ # Replay with the unmodified log. This confirms that we can replay this
+ # scenario correctly.
+ replay_with_log $remote_log false $non_stop
+ }
+
+ with_test_prefix "missing 1 thread log" {
+ # Now replay with the modified log, this time the thread that receives
+ # the event should be missing from the thread list, GDB will give an
+ # error when the inferior stops.
+ replay_with_log $missing_1_log true $non_stop
+ }
+
+ with_test_prefix "missing 2 threads log" {
+ # When we drop both threads from the <threads> reply, GDB doesn't
+ # actually remove both threads from the inferior; an inferior must
+ # always have at least one thread. So in this case, as the primary
+ # thread is first, GDB drops this, then retains the second thread, which
+ # is the one we're stopping in, and so, we don't expect to see the error
+ # in this case.
+ replay_with_log $missing_2_log false $non_stop
+ }
+}
+
+# Run the test twice, with non-stop on and off.
+foreach_with_prefix non_stop { on off } {
+ save_vars { ::GDBFLAGS } {
+ append ::GDBFLAGS " -ex \"set non-stop $non_stop\""
+ run_test $non_stop
+ }
+}
diff --git a/gdb/testsuite/gdb.reverse/aarch64-mops.exp b/gdb/testsuite/gdb.reverse/aarch64-mops.exp
index 0f447a6..797a0c2 100644
--- a/gdb/testsuite/gdb.reverse/aarch64-mops.exp
+++ b/gdb/testsuite/gdb.reverse/aarch64-mops.exp
@@ -40,7 +40,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.reverse/amd64-tailcall-reverse.exp b/gdb/testsuite/gdb.reverse/amd64-tailcall-reverse.exp
index 56ebb92..b5878f0 100644
--- a/gdb/testsuite/gdb.reverse/amd64-tailcall-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/amd64-tailcall-reverse.exp
@@ -18,7 +18,7 @@ require supports_reverse
set opts {}
standard_testfile .S
-if [info exists COMPILE] {
+if {[info exists COMPILE]} {
# make check RUNTESTFLAGS="gdb.reverse/amd64-tailcall-reverse.exp COMPILE=1"
standard_testfile
lappend opts debug optimize=-O2
@@ -30,11 +30,11 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
-if [supports_process_record] {
+if {[supports_process_record]} {
gdb_test_no_output "record"
}
diff --git a/gdb/testsuite/gdb.reverse/break-reverse.exp b/gdb/testsuite/gdb.reverse/break-reverse.exp
index 02c38ac..6db7ce1 100644
--- a/gdb/testsuite/gdb.reverse/break-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/break-reverse.exp
@@ -31,7 +31,7 @@ set end_location [gdb_get_line_number "end of main" ]
runto_main
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
}
diff --git a/gdb/testsuite/gdb.reverse/consecutive-precsave.exp b/gdb/testsuite/gdb.reverse/consecutive-precsave.exp
index 2cb139d..3ccff48 100644
--- a/gdb/testsuite/gdb.reverse/consecutive-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/consecutive-precsave.exp
@@ -79,7 +79,7 @@ set testmsg "stopped at bp, 2nd instr"
gdb_test_multiple "step" $testmsg {
-re -wrap "Breakpoint $decimal, ($hex) in foo.*" {
set stop_addr $expect_out(1,string)
- if {[eval expr "$foo2_addr == $stop_addr"]} {
+ if {$foo2_addr == $stop_addr} {
pass "stopped at bp, 2nd instr"
} else {
fail "stopped at bp, 2nd instr (wrong address)"
@@ -90,7 +90,7 @@ gdb_test_multiple "step" $testmsg {
set stop_addr_is_stmt [hex_in_list $stop_addr $is_stmt]
if { ! $stop_addr_is_stmt } {
fail "stopped at bp, 2nd instr (missing hex prefix)"
- } elseif {[eval expr "$foo2_addr == $stop_addr"]} {
+ } elseif {$foo2_addr == $stop_addr} {
pass "stopped at bp, 2nd instr"
} else {
fail "stopped at bp, 2nd instr (wrong address)"
@@ -112,7 +112,7 @@ set test_msg "stopped at bp in reverse, 1st instr"
gdb_test_multiple "step" "$test_msg" {
-re "Breakpoint $decimal, ($hex) in foo.*$gdb_prompt $" {
set stop_addr $expect_out(1,string)
- if {[eval expr "$foo1_addr == $stop_addr"]} {
+ if {$foo1_addr == $stop_addr} {
pass "$test_msg"
} else {
fail "$test_msg (wrong address)"
diff --git a/gdb/testsuite/gdb.reverse/consecutive-reverse.exp b/gdb/testsuite/gdb.reverse/consecutive-reverse.exp
index 27f2b72..7434efb 100644
--- a/gdb/testsuite/gdb.reverse/consecutive-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/consecutive-reverse.exp
@@ -26,7 +26,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
runto_main
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
}
@@ -61,7 +61,7 @@ set testmsg "stopped at bp, 2nd instr"
gdb_test_multiple "step" $testmsg {
-re -wrap "Breakpoint $decimal, ($hex) in foo.*" {
set stop_addr $expect_out(1,string)
- if {[eval expr "$foo2_addr == $stop_addr"]} {
+ if {$foo2_addr == $stop_addr} {
pass "stopped at bp, 2nd instr"
} else {
fail "stopped at bp, 2nd instr (wrong address)"
@@ -72,7 +72,7 @@ gdb_test_multiple "step" $testmsg {
set stop_addr_is_stmt [hex_in_list $stop_addr $is_stmt]
if { ! $stop_addr_is_stmt } {
fail "stopped at bp, 2nd instr (missing hex prefix)"
- } elseif {[eval expr "$foo2_addr == $stop_addr"]} {
+ } elseif {$foo2_addr == $stop_addr} {
pass "stopped at bp, 2nd instr"
} else {
fail "stopped at bp, 2nd instr (wrong address)"
@@ -94,7 +94,7 @@ set test_msg "stopped at bp in reverse, 1st instr"
gdb_test_multiple "step" "$test_msg" {
-re "Breakpoint $decimal, ($hex) in foo.*$gdb_prompt $" {
set stop_addr $expect_out(1,string)
- if {[eval expr "$foo1_addr == $stop_addr"]} {
+ if {$foo1_addr == $stop_addr} {
pass "$test_msg"
} else {
fail "$test_msg (wrong address)"
diff --git a/gdb/testsuite/gdb.reverse/finish-precsave.exp b/gdb/testsuite/gdb.reverse/finish-precsave.exp
index 596b40d..2e76a46 100644
--- a/gdb/testsuite/gdb.reverse/finish-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/finish-precsave.exp
@@ -27,12 +27,12 @@ if { [prepare_for_testing "failed to prepare" "$testfile" $srcfile] } {
runto_main
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
}
-# Run until end, then save execution log.
+# Run until end, then save execution log.
set breakloc [gdb_get_line_number "end of main" "$srcfile"]
gdb_test "break $breakloc" \
diff --git a/gdb/testsuite/gdb.reverse/finish-reverse-bkpt.exp b/gdb/testsuite/gdb.reverse/finish-reverse-bkpt.exp
index 1e92252..586d236 100644
--- a/gdb/testsuite/gdb.reverse/finish-reverse-bkpt.exp
+++ b/gdb/testsuite/gdb.reverse/finish-reverse-bkpt.exp
@@ -52,7 +52,7 @@ if {![runto_main]} {
return 0
}
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
}
diff --git a/gdb/testsuite/gdb.reverse/finish-reverse-next.exp b/gdb/testsuite/gdb.reverse/finish-reverse-next.exp
index f744e9c..07ba30c 100644
--- a/gdb/testsuite/gdb.reverse/finish-reverse-next.exp
+++ b/gdb/testsuite/gdb.reverse/finish-reverse-next.exp
@@ -41,7 +41,7 @@
# test only verified the reverse-finish command for a normal call that used
# the LEP.
-if ![supports_reverse] {
+if {![supports_reverse]} {
return
}
@@ -53,7 +53,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
runto_main
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay.
gdb_test_no_output "record" "turn on process record for test1"
}
diff --git a/gdb/testsuite/gdb.reverse/finish-reverse.exp b/gdb/testsuite/gdb.reverse/finish-reverse.exp
index f90a79f..ff28bd8 100644
--- a/gdb/testsuite/gdb.reverse/finish-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/finish-reverse.exp
@@ -26,7 +26,7 @@ if { [prepare_for_testing "failed to prepare" "$testfile" $srcfile] } {
runto_main
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
}
diff --git a/gdb/testsuite/gdb.reverse/fstatat-reverse.exp b/gdb/testsuite/gdb.reverse/fstatat-reverse.exp
index 76bd8a2..db2f5dc 100644
--- a/gdb/testsuite/gdb.reverse/fstatat-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/fstatat-reverse.exp
@@ -29,7 +29,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
runto_main
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
}
diff --git a/gdb/testsuite/gdb.reverse/getrandom.exp b/gdb/testsuite/gdb.reverse/getrandom.exp
index 62640af..2756fa3 100644
--- a/gdb/testsuite/gdb.reverse/getrandom.exp
+++ b/gdb/testsuite/gdb.reverse/getrandom.exp
@@ -30,7 +30,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
runto_main
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
}
diff --git a/gdb/testsuite/gdb.reverse/getresuid-reverse.exp b/gdb/testsuite/gdb.reverse/getresuid-reverse.exp
index 5ff0f2b..37d070d 100644
--- a/gdb/testsuite/gdb.reverse/getresuid-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/getresuid-reverse.exp
@@ -29,7 +29,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
runto_main
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
}
diff --git a/gdb/testsuite/gdb.reverse/i386-avx-reverse.exp b/gdb/testsuite/gdb.reverse/i386-avx-reverse.exp
index fb04260..b3550e2 100644
--- a/gdb/testsuite/gdb.reverse/i386-avx-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/i386-avx-reverse.exp
@@ -109,7 +109,7 @@ proc record_full_function {function} {
gdb_breakpoint $end temporary
gdb_continue_to_breakpoint "start ${function}_test"
- if [supports_process_record] {
+ if {[supports_process_record]} {
# Activate process record/replay.
gdb_test_no_output "record" "${function}: turn on process record"
}
diff --git a/gdb/testsuite/gdb.reverse/i386-reverse.exp b/gdb/testsuite/gdb.reverse/i386-reverse.exp
index 8c22363..9aee9a4 100644
--- a/gdb/testsuite/gdb.reverse/i386-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/i386-reverse.exp
@@ -36,7 +36,7 @@ set end_of_inc_dec_tests [gdb_get_line_number " end inc_dec_tests "]
runto_main
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
}
diff --git a/gdb/testsuite/gdb.reverse/i386-sse-reverse.exp b/gdb/testsuite/gdb.reverse/i386-sse-reverse.exp
index 0c99480..aa4cfce 100644
--- a/gdb/testsuite/gdb.reverse/i386-sse-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/i386-sse-reverse.exp
@@ -43,7 +43,7 @@ set end_sse4_test [gdb_get_line_number " end sse4_test "]
runto_main
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
}
diff --git a/gdb/testsuite/gdb.reverse/i387-env-reverse.exp b/gdb/testsuite/gdb.reverse/i387-env-reverse.exp
index 4b6a3f7..f3350fc 100644
--- a/gdb/testsuite/gdb.reverse/i387-env-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/i387-env-reverse.exp
@@ -36,7 +36,7 @@ set location [gdb_get_line_number "END I387-FLOAT-REVERSE"]
gdb_test_no_output "record" "Turn on process record"
# This can take awhile.
set oldtimeout $timeout
-set timeout [expr $oldtimeout + 120]
+set timeout [expr {$oldtimeout + 120}]
gdb_test "until $location" ".*$srcfile:$location.*" \
"record to end of main"
set timeout $oldtimeout
diff --git a/gdb/testsuite/gdb.reverse/insn-reverse.exp b/gdb/testsuite/gdb.reverse/insn-reverse.exp
index 5b3a2cd..9e238f0 100644
--- a/gdb/testsuite/gdb.reverse/insn-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/insn-reverse.exp
@@ -106,7 +106,7 @@ proc test { func testcase_nr } {
}
# Registers contents after each backward single step.
- for {set i [expr $count - 1]} {$i >= 0} {incr i -1} {
+ for {set i [expr {$count - 1}]} {$i >= 0} {incr i -1} {
gdb_test -nopass "reverse-stepi"
set post_regs($i) [capture_command_output "info all-registers" ""]
}
diff --git a/gdb/testsuite/gdb.reverse/machinestate-precsave.exp b/gdb/testsuite/gdb.reverse/machinestate-precsave.exp
index 53b958d..94d9723 100644
--- a/gdb/testsuite/gdb.reverse/machinestate-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/machinestate-precsave.exp
@@ -13,7 +13,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/>.
-# This file is part of the GDB testsuite.
+# This file is part of the GDB testsuite.
# This test tests the restoration of various kinds of machine state
# to their original values with a process record log. We will execute
# the program forward while it changes various types of data, and
diff --git a/gdb/testsuite/gdb.reverse/machinestate.exp b/gdb/testsuite/gdb.reverse/machinestate.exp
index 9177029..7edf517 100644
--- a/gdb/testsuite/gdb.reverse/machinestate.exp
+++ b/gdb/testsuite/gdb.reverse/machinestate.exp
@@ -13,7 +13,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/>.
-# This file is part of the GDB testsuite.
+# This file is part of the GDB testsuite.
# This test tests the restoration of various kinds of machine state
# to their original values by reverse execution. We will execute
# the program forward while it changes various types of data, and
@@ -53,7 +53,7 @@ set endmain [gdb_get_line_number " end main " $srcfile]
runto_main
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
}
diff --git a/gdb/testsuite/gdb.reverse/maint-print-instruction.exp b/gdb/testsuite/gdb.reverse/maint-print-instruction.exp
index 6599345..151c117 100644
--- a/gdb/testsuite/gdb.reverse/maint-print-instruction.exp
+++ b/gdb/testsuite/gdb.reverse/maint-print-instruction.exp
@@ -23,7 +23,7 @@
# change is printed, since any instruction must have at least a change
# to the PC.
-if ![supports_reverse] {
+if {![supports_reverse]} {
return
}
@@ -52,7 +52,7 @@ if { ![runto_main] } {
#confirm that GDB doesn't go crazy if recording isn't enabled
test_print false "" "print before starting to record"
-if ![supports_process_record] {
+if {![supports_process_record]} {
# No point in testing the rest if we can't record anything
return
}
diff --git a/gdb/testsuite/gdb.reverse/map-to-same-line.exp b/gdb/testsuite/gdb.reverse/map-to-same-line.exp
index 410394c..e31eef0 100644
--- a/gdb/testsuite/gdb.reverse/map-to-same-line.exp
+++ b/gdb/testsuite/gdb.reverse/map-to-same-line.exp
@@ -48,16 +48,16 @@ Dwarf::assemble $asm_file {
cu {} {
compile_unit {
- {language @DW_LANG_C}
- {name map-to-same-line.c}
- {stmt_list $L DW_FORM_sec_offset}
- {low_pc 0 addr}
+ DW_AT_language @DW_LANG_C
+ DW_AT_name map-to-same-line.c
+ DW_AT_stmt_list $L DW_FORM_sec_offset
+ DW_AT_low_pc 0 addr
} {
subprogram {
- {external 1 flag}
- {name main}
- {low_pc $main_start addr}
- {high_pc $main_len DW_FORM_data4}
+ DW_AT_external 1 flag
+ DW_AT_name main
+ DW_AT_low_pc $main_start addr
+ DW_AT_high_pc $main_len DW_FORM_data4
}
}
}
diff --git a/gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.exp b/gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.exp
index 454808d..574ab5e 100644
--- a/gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.exp
+++ b/gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.exp
@@ -52,7 +52,7 @@ if {![runto_main]} {
return 0
}
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
}
diff --git a/gdb/testsuite/gdb.reverse/pipe-reverse.exp b/gdb/testsuite/gdb.reverse/pipe-reverse.exp
index eb4f8eb..93ba3d1 100644
--- a/gdb/testsuite/gdb.reverse/pipe-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/pipe-reverse.exp
@@ -29,7 +29,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
runto_main
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
}
diff --git a/gdb/testsuite/gdb.reverse/readv-reverse.exp b/gdb/testsuite/gdb.reverse/readv-reverse.exp
index 47149f2..4456340 100644
--- a/gdb/testsuite/gdb.reverse/readv-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/readv-reverse.exp
@@ -29,7 +29,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
runto_main
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
}
diff --git a/gdb/testsuite/gdb.reverse/recursion.exp b/gdb/testsuite/gdb.reverse/recursion.exp
index bfe1770..ca08930 100644
--- a/gdb/testsuite/gdb.reverse/recursion.exp
+++ b/gdb/testsuite/gdb.reverse/recursion.exp
@@ -26,7 +26,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
runto_main
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
}
diff --git a/gdb/testsuite/gdb.reverse/recvmsg-reverse.exp b/gdb/testsuite/gdb.reverse/recvmsg-reverse.exp
index 89cac87..af6f73f 100644
--- a/gdb/testsuite/gdb.reverse/recvmsg-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/recvmsg-reverse.exp
@@ -29,7 +29,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
runto_main
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
}
diff --git a/gdb/testsuite/gdb.reverse/s390-mvcle.exp b/gdb/testsuite/gdb.reverse/s390-mvcle.exp
index 36cd611..642be8f 100644
--- a/gdb/testsuite/gdb.reverse/s390-mvcle.exp
+++ b/gdb/testsuite/gdb.reverse/s390-mvcle.exp
@@ -27,7 +27,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
runto_main
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
}
diff --git a/gdb/testsuite/gdb.reverse/sigall-precsave.exp b/gdb/testsuite/gdb.reverse/sigall-precsave.exp
index 64869c5..552be4b 100644
--- a/gdb/testsuite/gdb.reverse/sigall-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/sigall-precsave.exp
@@ -134,20 +134,20 @@ proc test_one_sig_reverse {prevsig} {
} else {
xfail "$testmsg (handled)"
}
- }
+ }
}
}
-clean_restart $binfile
+clean_restart $::testfile
runto gen_ABRT
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
}
-# Run until end, then save execution log.
+# Run until end, then save execution log.
set breakloc [gdb_get_line_number "end of main" "$srcfile"]
gdb_test "break $breakloc" \
@@ -299,7 +299,7 @@ gdb_test "continue" \
"get signal TERM"
gdb_test "continue" "Breakpoint.*handle_TERM.*" "send signal TERM"
-gdb_test "continue" " end of main .*" "continue to sigall exit"
+gdb_test "continue" " end of main .*" "continue to sigall exit"
foreach sig [lreverse $signals] {
test_one_sig_reverse $sig
diff --git a/gdb/testsuite/gdb.reverse/sigall-reverse.exp b/gdb/testsuite/gdb.reverse/sigall-reverse.exp
index b72e098..f9259a1 100644
--- a/gdb/testsuite/gdb.reverse/sigall-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/sigall-reverse.exp
@@ -140,15 +140,15 @@ proc test_one_sig_reverse {prevsig} {
} else {
xfail "$testmsg (handled)"
}
- }
+ }
}
}
-clean_restart $binfile
+clean_restart $::testfile
runto gen_ABRT
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
}
diff --git a/gdb/testsuite/gdb.reverse/singlejmp-reverse.exp b/gdb/testsuite/gdb.reverse/singlejmp-reverse.exp
index 7c1cf0b..8b9cb20 100644
--- a/gdb/testsuite/gdb.reverse/singlejmp-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/singlejmp-reverse.exp
@@ -18,7 +18,7 @@ require supports_reverse
standard_testfile ".S" "${gdb_test_file_name}-nodebug.S"
set executable ${testfile}
-if [info exists COMPILE] {
+if {[info exists COMPILE]} {
# make check RUNTESTFLAGS="gdb.reverse/singlejmp-reverse.exp COMPILE=1"
if { [build_executable_from_specs ${testfile}.exp $executable {} \
${testfile}.c {debug optimize=-O2} \
@@ -36,11 +36,11 @@ if [info exists COMPILE] {
clean_restart $executable
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
-if [supports_process_record] {
+if {[supports_process_record]} {
gdb_test_no_output "record"
}
diff --git a/gdb/testsuite/gdb.reverse/solib-precsave.exp b/gdb/testsuite/gdb.reverse/solib-precsave.exp
index 82b08cd..0b93501 100644
--- a/gdb/testsuite/gdb.reverse/solib-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/solib-precsave.exp
@@ -52,7 +52,7 @@ if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable \
untested "failed to compile"
return -1
}
-
+
# Note: The test previously did "set debug-file-directory" to (try to)
# ensure the debug info for the dynamic loader and libc weren't found.
# This doesn't work if the debug info is in the .debug subdirectory.
@@ -60,7 +60,7 @@ if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable \
# and is no longer attempted. Instead, the test does not make assumptions
# about whether the debug info is present or not.
-clean_restart $binfile
+clean_restart $::testfile
gdb_load_shlib $library1
gdb_load_shlib $library2
diff --git a/gdb/testsuite/gdb.reverse/solib-reverse.exp b/gdb/testsuite/gdb.reverse/solib-reverse.exp
index b2ef9b0..8991177 100644
--- a/gdb/testsuite/gdb.reverse/solib-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/solib-reverse.exp
@@ -44,7 +44,7 @@ if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $exec_opt
untested "failed to compile"
return -1
}
-
+
# Note: The test previously did "set debug-file-directory" to (try to)
# ensure the debug info for the dynamic loader and libc weren't found.
# This doesn't work if the debug info is in the .debug subdirectory.
@@ -52,13 +52,13 @@ if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable $exec_opt
# and is no longer attempted. Instead, the test does not make assumptions
# about whether the debug info is present or not.
-clean_restart $binfile
+clean_restart $::testfile
gdb_load_shlib $library1
gdb_load_shlib $library2
runto_main
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
}
diff --git a/gdb/testsuite/gdb.reverse/step-precsave.exp b/gdb/testsuite/gdb.reverse/step-precsave.exp
index b49c21b..d152454 100644
--- a/gdb/testsuite/gdb.reverse/step-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/step-precsave.exp
@@ -69,7 +69,7 @@ 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}
+clean_restart ${::testfile}
gdb_test "record restore $precsave" \
"Restored records from core file .*" \
@@ -229,7 +229,7 @@ gdb_test_multiple "stepi" "$test_message" {
}
}
-re "ENTER CALLEE.*$gdb_prompt $" {
- send_gdb "stepi\n"
+ send_gdb "stepi\n"
exp_continue
}
-re "$pic_thunk_re.*$gdb_prompt $" {
diff --git a/gdb/testsuite/gdb.reverse/step-reverse.exp b/gdb/testsuite/gdb.reverse/step-reverse.exp
index 6ecf1cd..78a11bf 100644
--- a/gdb/testsuite/gdb.reverse/step-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/step-reverse.exp
@@ -30,7 +30,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
runto_main
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
}
@@ -191,7 +191,7 @@ gdb_test_multiple "stepi" "$test_message" {
}
}
-re "ENTER CALLEE.*$gdb_prompt $" {
- send_gdb "stepi\n"
+ send_gdb "stepi\n"
exp_continue
}
-re "$pic_thunk_re.*$gdb_prompt $" {
diff --git a/gdb/testsuite/gdb.reverse/until-precsave.exp b/gdb/testsuite/gdb.reverse/until-precsave.exp
index 1f25a3a..325e4a8 100644
--- a/gdb/testsuite/gdb.reverse/until-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/until-precsave.exp
@@ -13,7 +13,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/>. */
-# This file is part of the GDB testsuite. It tests 'until' and
+# This file is part of the GDB testsuite. It tests 'until' and
# 'advance' in precord logfile.
# This test suitable only for process record-replay
@@ -147,7 +147,7 @@ gdb_test "advance $bp_location19" \
"factorial .value=720.*${srcfile}:$bp_location19.*" \
"reverse-advance to final return of factorial"
-# Now do "until" across the recursive calls,
+# Now do "until" across the recursive calls,
# ending up in the same frame where we are now.
gdb_test "until $bp_location7" \
diff --git a/gdb/testsuite/gdb.reverse/until-reverse.exp b/gdb/testsuite/gdb.reverse/until-reverse.exp
index 240f6da..de138f5 100644
--- a/gdb/testsuite/gdb.reverse/until-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/until-reverse.exp
@@ -13,7 +13,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/>. */
-# This file is part of the GDB testsuite. It tests 'until' and
+# This file is part of the GDB testsuite. It tests 'until' and
# 'advance' in reverse debugging.
require supports_reverse
@@ -34,7 +34,7 @@ set bp_location21 [gdb_get_line_number "set breakpoint 21 here"]
runto_main
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
}
@@ -120,7 +120,7 @@ gdb_test "advance $bp_location19" \
"factorial .value=720.*${srcfile}:$bp_location19.*" \
"reverse-advance to final return of factorial"
-# Now do "until" across the recursive calls,
+# Now do "until" across the recursive calls,
# ending up in the same frame where we are now.
gdb_test "until $bp_location7" \
diff --git a/gdb/testsuite/gdb.reverse/waitpid-reverse.exp b/gdb/testsuite/gdb.reverse/waitpid-reverse.exp
index c1cb402..26c3c99 100644
--- a/gdb/testsuite/gdb.reverse/waitpid-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/waitpid-reverse.exp
@@ -31,7 +31,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
runto_main
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
}
diff --git a/gdb/testsuite/gdb.reverse/watch-reverse.exp b/gdb/testsuite/gdb.reverse/watch-reverse.exp
index 6a694be..567ae4a 100644
--- a/gdb/testsuite/gdb.reverse/watch-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/watch-reverse.exp
@@ -28,7 +28,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
runto_main
-if [supports_process_record] {
+if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
}
diff --git a/gdb/testsuite/gdb.rocm/code-object-load-while-breakpoint-hit.exp b/gdb/testsuite/gdb.rocm/code-object-load-while-breakpoint-hit.exp
index 3fe6a95..e994884 100644
--- a/gdb/testsuite/gdb.rocm/code-object-load-while-breakpoint-hit.exp
+++ b/gdb/testsuite/gdb.rocm/code-object-load-while-breakpoint-hit.exp
@@ -53,7 +53,8 @@ if { [gdb_compile $srcdir/$subdir/$srcfile \
proc do_test { } {
with_rocm_gpu_lock {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
gdb_test_no_output "set args $::hipmodule_path" "set args"
if { ![runto_main] } {
diff --git a/gdb/testsuite/gdb.rocm/displaced-stepping.exp b/gdb/testsuite/gdb.rocm/displaced-stepping.exp
index cd50fec..9e8abd4 100644
--- a/gdb/testsuite/gdb.rocm/displaced-stepping.exp
+++ b/gdb/testsuite/gdb.rocm/displaced-stepping.exp
@@ -28,7 +28,8 @@ if {[build_executable "failed to prepare" $testfile $srcfile {hip}]} {
}
proc do_test {} {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
with_rocm_gpu_lock {
if ![runto_main] {
diff --git a/gdb/testsuite/gdb.rocm/fork-exec-gpu-to-non-gpu.exp b/gdb/testsuite/gdb.rocm/fork-exec-gpu-to-non-gpu.exp
index 22d4b75..dfd1092 100644
--- a/gdb/testsuite/gdb.rocm/fork-exec-gpu-to-non-gpu.exp
+++ b/gdb/testsuite/gdb.rocm/fork-exec-gpu-to-non-gpu.exp
@@ -54,7 +54,8 @@ proc do_test { detach-on-fork follow-fork-mode fork_func } {
}
with_rocm_gpu_lock {
- clean_restart ${::binfile}-execer-${fork_func}
+ clean_restart
+ gdb_load ${::binfile}-execer-${fork_func}
gdb_test_no_output "set detach-on-fork ${detach-on-fork}"
gdb_test_no_output "set follow-fork-mode ${follow-fork-mode}"
diff --git a/gdb/testsuite/gdb.rocm/fork-exec-non-gpu-to-gpu.exp b/gdb/testsuite/gdb.rocm/fork-exec-non-gpu-to-gpu.exp
index 1386099..b14e2c7 100644
--- a/gdb/testsuite/gdb.rocm/fork-exec-non-gpu-to-gpu.exp
+++ b/gdb/testsuite/gdb.rocm/fork-exec-non-gpu-to-gpu.exp
@@ -53,7 +53,8 @@ proc do_test { detach-on-fork follow-fork-mode fork_func } {
}
with_rocm_gpu_lock {
- clean_restart ${::binfile}-execer-${fork_func}
+ clean_restart
+ gdb_load ${::binfile}-execer-${fork_func}
gdb_test_no_output "set detach-on-fork ${detach-on-fork}"
gdb_test_no_output "set follow-fork-mode ${follow-fork-mode}"
diff --git a/gdb/testsuite/gdb.rocm/mi-attach.cpp b/gdb/testsuite/gdb.rocm/mi-attach.cpp
index da7659d..441d460 100644
--- a/gdb/testsuite/gdb.rocm/mi-attach.cpp
+++ b/gdb/testsuite/gdb.rocm/mi-attach.cpp
@@ -15,8 +15,8 @@
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 <unistd.h>
#include <hip/hip_runtime.h>
+#include "gdb_watchdog.h"
__global__ void
kern ()
@@ -30,7 +30,7 @@ main ()
{
/* This program will run outside of GDB, make sure that if anything goes
wrong it eventually gets killed. */
- alarm (30);
+ gdb_watchdog (30);
kern<<<1, 1>>> ();
return hipDeviceSynchronize () != hipSuccess;
diff --git a/gdb/testsuite/gdb.rocm/multi-inferior-gpu.exp b/gdb/testsuite/gdb.rocm/multi-inferior-gpu.exp
index 4f55432..0ed11e8 100644
--- a/gdb/testsuite/gdb.rocm/multi-inferior-gpu.exp
+++ b/gdb/testsuite/gdb.rocm/multi-inferior-gpu.exp
@@ -28,7 +28,8 @@ if {[build_executable "failed to prepare" $testfile $srcfile {debug hip}]} {
}
proc do_test {} {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
gdb_test_no_output "set non-stop on"
gdb_test_no_output "set detach-on-fork off"
gdb_test_no_output "set follow-fork parent"
diff --git a/gdb/testsuite/gdb.rocm/precise-memory-exec.exp b/gdb/testsuite/gdb.rocm/precise-memory-exec.exp
index 506488c..76be078 100644
--- a/gdb/testsuite/gdb.rocm/precise-memory-exec.exp
+++ b/gdb/testsuite/gdb.rocm/precise-memory-exec.exp
@@ -29,7 +29,8 @@ if {[build_executable "failed to prepare $testfile" $testfile $srcfile {debug}]}
}
proc do_test { follow-exec-mode } {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
with_rocm_gpu_lock {
if ![runto_main] {
diff --git a/gdb/testsuite/gdb.rocm/precise-memory-multi-inferiors.exp b/gdb/testsuite/gdb.rocm/precise-memory-multi-inferiors.exp
index c7a78b8..058b085 100644
--- a/gdb/testsuite/gdb.rocm/precise-memory-multi-inferiors.exp
+++ b/gdb/testsuite/gdb.rocm/precise-memory-multi-inferiors.exp
@@ -30,7 +30,7 @@ proc test_per_inferior { } {
gdb_test "show amdgpu precise-memory" \
"AMDGPU precise memory access reporting is off \\(currently disabled\\)." \
"show initial value, inferior 1"
- if $::test_python {
+ if { $::test_python } {
gdb_test "python print(gdb.parameter(\"amdgpu precise-memory\"))" \
"False" \
"show initial value using Python, inferior 1"
@@ -40,7 +40,7 @@ proc test_per_inferior { } {
gdb_test "show amdgpu precise-memory" \
"AMDGPU precise memory access reporting is on \\(currently disabled\\)." \
"show new value, inferior 1"
- if $::test_python {
+ if { $::test_python } {
gdb_test "python print(gdb.parameter(\"amdgpu precise-memory\"))" \
"True" \
"show new value using Python, inferior 1"
@@ -52,7 +52,7 @@ proc test_per_inferior { } {
gdb_test "show amdgpu precise-memory" \
"AMDGPU precise memory access reporting is off \\(currently disabled\\)." \
"show initial value, inferior 2"
- if $::test_python {
+ if { $::test_python } {
gdb_test "python print(gdb.parameter(\"amdgpu precise-memory\"))" \
"False" \
"show initial value using Python, inferior 2"
diff --git a/gdb/testsuite/gdb.rocm/precise-memory-warning-sigsegv.exp b/gdb/testsuite/gdb.rocm/precise-memory-warning-sigsegv.exp
index f855719..da0a95a 100644
--- a/gdb/testsuite/gdb.rocm/precise-memory-warning-sigsegv.exp
+++ b/gdb/testsuite/gdb.rocm/precise-memory-warning-sigsegv.exp
@@ -29,7 +29,8 @@ if {[build_executable "failed to prepare" $testfile $srcfile {debug hip}]} {
}
proc do_test { } {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
with_rocm_gpu_lock {
if ![runto_main] {
diff --git a/gdb/testsuite/gdb.rocm/precise-memory.exp b/gdb/testsuite/gdb.rocm/precise-memory.exp
index 6711d80..8f00559 100644
--- a/gdb/testsuite/gdb.rocm/precise-memory.exp
+++ b/gdb/testsuite/gdb.rocm/precise-memory.exp
@@ -28,7 +28,8 @@ if {[build_executable "failed to prepare" $testfile $srcfile {debug hip}]} {
}
proc do_test { } {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
with_rocm_gpu_lock {
if ![runto_main] {
diff --git a/gdb/testsuite/gdb.rocm/simple.exp b/gdb/testsuite/gdb.rocm/simple.exp
index bc90a0a..8f6ff3e 100644
--- a/gdb/testsuite/gdb.rocm/simple.exp
+++ b/gdb/testsuite/gdb.rocm/simple.exp
@@ -27,7 +27,8 @@ if {[build_executable "failed to prepare" $testfile $srcfile {debug hip}]} {
}
proc do_test {} {
- clean_restart $::binfile
+ clean_restart
+ gdb_load $::binfile
with_rocm_gpu_lock {
if ![runto_main] {
diff --git a/gdb/testsuite/gdb.rust/modules.exp b/gdb/testsuite/gdb.rust/modules.exp
index 5b2e998..0874db3 100644
--- a/gdb/testsuite/gdb.rust/modules.exp
+++ b/gdb/testsuite/gdb.rust/modules.exp
@@ -34,7 +34,7 @@ if {![runto ${srcfile}:$line]} {
# https://github.com/rust-lang/rust/issues/33121
# gdb_test "call f2()" "lambda f2"
-if ![target_info exists gdb,noinferiorio] {
+if { ![target_info exists gdb,noinferiorio] } {
gdb_test_stdio "call f3()" "mod1::inner::innest::f3"
gdb_test_stdio "call self::f2()" "mod1::inner::innest::f2"
gdb_test_stdio "call self::super::f2()" "mod1::inner::f2"
diff --git a/gdb/testsuite/gdb.rust/traits.exp b/gdb/testsuite/gdb.rust/traits.exp
index e5ef015..82fc894 100644
--- a/gdb/testsuite/gdb.rust/traits.exp
+++ b/gdb/testsuite/gdb.rust/traits.exp
@@ -25,7 +25,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug rust}]} {
}
set readelf_program [gdb_find_readelf]
-set result [catch "exec $readelf_program --debug-dump=info $binfile" output]
+set result [catch {exec $readelf_program --debug-dump=info $binfile} output]
if {$result != 0} {
untested "could not read [file tail ${binfile}] with readelf"
return
diff --git a/gdb/testsuite/gdb.server/argument-errors.exp b/gdb/testsuite/gdb.server/argument-errors.exp
new file mode 100644
index 0000000..45037bf
--- /dev/null
+++ b/gdb/testsuite/gdb.server/argument-errors.exp
@@ -0,0 +1,81 @@
+# This testcase is part of GDB, the GNU debugger.
+#
+# Copyright 2025 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 gdbserver prints a suitable message when argument values are
+# missing.
+
+load_lib gdbserver-support.exp
+
+standard_testfile
+
+require allow_gdbserver_tests
+
+set gdbserver [find_gdbserver]
+if { $gdbserver == "" } {
+ unsupported "could not find gdbserver"
+ return
+}
+
+# Start gdbserver using CMD_ARGS and a non-existent program name. We
+# expect to see an error message matching ERROR_RE from gdbserver.
+proc test_argument_error { cmd_args error_re } {
+ # Fire off gdbserver. gdbserver should give an error because
+ # --debug-file is missing its argument.
+ set spawn_id [remote_spawn target "$::gdbserver $cmd_args non-existing-program"]
+
+ set saw_expected_error false
+ set test "check gdbserver error: $cmd_args"
+ expect {
+ -i $spawn_id
+ -re $error_re {
+ set saw_expected_error true
+ exp_continue
+ }
+ eof {
+ gdb_assert $saw_expected_error $test
+ wait
+ }
+ timeout {
+ fail "$test (timeout)"
+ }
+ }
+
+ # expect defaults to spawn_id in many places. Avoid confusing any
+ # following code.
+ unset spawn_id
+}
+
+# Check that an argument that expects a value will not use a port, or
+# another argument, as its value.
+foreach arg { --debug-format --debug-file } {
+ test_argument_error "$arg stdio" \
+ "Missing argument value for: $arg"
+ test_argument_error "$arg :54321" \
+ "Missing argument value for: $arg"
+ test_argument_error "$arg -" \
+ "Missing argument value for: $arg"
+ test_argument_error "$arg --once -" \
+ "Missing argument value for: $arg"
+}
+
+# Test unknown argument handling.
+test_argument_error "--unknown -" \
+ "Unknown argument: --unknown"
+test_argument_error "-unknown -" \
+ "Unknown argument: -unknown"
+test_argument_error "--unknown=blah -" \
+ "Unknown argument: --unknown"
diff --git a/gdb/testsuite/gdb.server/bkpt-other-inferior.exp b/gdb/testsuite/gdb.server/bkpt-other-inferior.exp
index 893bd72..453be14 100644
--- a/gdb/testsuite/gdb.server/bkpt-other-inferior.exp
+++ b/gdb/testsuite/gdb.server/bkpt-other-inferior.exp
@@ -23,7 +23,7 @@ standard_testfile server.c
require allow_gdbserver_tests
-if { [prepare_for_testing "failed to prepare" ${binfile} "${srcfile}" \
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
{debug pthreads}] } {
return
}
diff --git a/gdb/testsuite/gdb.server/connect-stopped-target.exp b/gdb/testsuite/gdb.server/connect-stopped-target.exp
index 021f063..603782c 100644
--- a/gdb/testsuite/gdb.server/connect-stopped-target.exp
+++ b/gdb/testsuite/gdb.server/connect-stopped-target.exp
@@ -34,7 +34,7 @@ proc do_test {nonstop} {
global gdb_prompt
global hex
- clean_restart $binfile
+ clean_restart $::testfile
# Make sure we're disconnected, in case we're testing with an
# extended-remote board, therefore already connected.
diff --git a/gdb/testsuite/gdb.server/connect-with-no-symbol-file.exp b/gdb/testsuite/gdb.server/connect-with-no-symbol-file.exp
index 4e5ee98..01d7e46 100644
--- a/gdb/testsuite/gdb.server/connect-with-no-symbol-file.exp
+++ b/gdb/testsuite/gdb.server/connect-with-no-symbol-file.exp
@@ -69,7 +69,7 @@ proc connect_no_symbol_file { sysroot action } {
} elseif { $action == "permission" } {
remote_exec target "chmod 000 $target_exec"
}
-
+
# Connect to GDBserver.
gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport
}
diff --git a/gdb/testsuite/gdb.server/connect-without-multi-process.exp b/gdb/testsuite/gdb.server/connect-without-multi-process.exp
index 1a7246c..f47e57e 100644
--- a/gdb/testsuite/gdb.server/connect-without-multi-process.exp
+++ b/gdb/testsuite/gdb.server/connect-without-multi-process.exp
@@ -38,7 +38,7 @@ proc do_test {multiprocess} {
set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\""
}
- clean_restart $binfile
+ clean_restart $::testfile
}
# Make sure we're disconnected, in case we're testing with an
diff --git a/gdb/testsuite/gdb.server/exit-multiple-threads.exp b/gdb/testsuite/gdb.server/exit-multiple-threads.exp
index 73e4c32..be29f9e 100644
--- a/gdb/testsuite/gdb.server/exit-multiple-threads.exp
+++ b/gdb/testsuite/gdb.server/exit-multiple-threads.exp
@@ -45,7 +45,8 @@ proc prepare_for_test { executable target_executable disable_multi_process } {
set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\""
}
- clean_restart ${executable}
+ clean_restart
+ gdb_load $executable
}
# Make sure we're disconnected, in case we're testing with an
@@ -69,7 +70,7 @@ proc prepare_for_test { executable target_executable disable_multi_process } {
set gdbserver_protocol [lindex $res 0]
set gdbserver_gdbport [lindex $res 1]
set res [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
- if ![gdb_assert {$res == 0} "connect"] {
+ if { ![gdb_assert {$res == 0} "connect"] } {
return
}
diff --git a/gdb/testsuite/gdb.server/ext-attach.exp b/gdb/testsuite/gdb.server/ext-attach.exp
index bda3ae9..6af2ede 100644
--- a/gdb/testsuite/gdb.server/ext-attach.exp
+++ b/gdb/testsuite/gdb.server/ext-attach.exp
@@ -45,7 +45,7 @@ proc run_test { target_async target_non_stop to_disable } {
set ::GDBFLAGS "$::GDBFLAGS -ex \"set sysroot\""
}
- clean_restart $::binfile
+ clean_restart $::testfile
}
# Make sure we're disconnected, in case we're testing with an
diff --git a/gdb/testsuite/gdb.server/ext-run.exp b/gdb/testsuite/gdb.server/ext-run.exp
index 2286454..f4ff546 100644
--- a/gdb/testsuite/gdb.server/ext-run.exp
+++ b/gdb/testsuite/gdb.server/ext-run.exp
@@ -37,7 +37,7 @@ save_vars { GDBFLAGS } {
set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\""
}
- clean_restart $binfile
+ clean_restart $::testfile
}
# Make sure we're disconnected, in case we're testing with an
diff --git a/gdb/testsuite/gdb.server/extended-remote-restart.exp b/gdb/testsuite/gdb.server/extended-remote-restart.exp
index df722a1..a5ba53c 100644
--- a/gdb/testsuite/gdb.server/extended-remote-restart.exp
+++ b/gdb/testsuite/gdb.server/extended-remote-restart.exp
@@ -58,7 +58,7 @@ proc test_reload { do_kill_p follow_child_p } {
global decimal
global binfile
- clean_restart ${binfile}
+ clean_restart ${::testfile}
if {![runto_main]} {
return 0
@@ -70,7 +70,7 @@ proc test_reload { do_kill_p follow_child_p } {
set live_inf_ptn "process $decimal"
set dead_inf_ptn "<null>"
- if ${follow_child_p} {
+ if { $follow_child_p } {
gdb_test_no_output "set follow-fork child"
set parent_prefix " "
set child_prefix "\\*"
diff --git a/gdb/testsuite/gdb.server/inferior-args.c b/gdb/testsuite/gdb.server/inferior-args.c
new file mode 100644
index 0000000..3bc3ff7
--- /dev/null
+++ b/gdb/testsuite/gdb.server/inferior-args.c
@@ -0,0 +1,27 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2023-2025 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>
+
+int
+main (int argc, char **argv)
+{
+ for (int i = 0; i < argc; i++)
+ printf ("[%d] %s\n", i, argv[i]);
+
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.server/inferior-args.exp b/gdb/testsuite/gdb.server/inferior-args.exp
new file mode 100644
index 0000000..18ac5a3
--- /dev/null
+++ b/gdb/testsuite/gdb.server/inferior-args.exp
@@ -0,0 +1,156 @@
+# Copyright 2023-2025 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 passing inferior arguments on the gdbserver command line. Tests the
+# flags --no-startup-with-shell and --no-escape-args that change how GDB
+# interprets the arguments being passed.
+
+# This test relies on starting gdbserver using the pipe syntax. Not sure
+# how well this will run if part of this test is being run elsewhere.
+require {!is_remote target} {!is_remote host}
+
+load_lib gdbserver-support.exp
+
+standard_testfile
+
+require allow_gdbserver_tests
+
+set gdbserver [find_gdbserver]
+if { $gdbserver == "" } {
+ unsupported "could not find gdbserver"
+ return
+}
+
+standard_testfile
+if {[build_executable "failed to prepare" $testfile $srcfile]} {
+ return -1
+}
+
+# EXTENDED_P is a boolean, when true gdbserver is started with --multi, and
+# GDB connects using extended-remote protocol. Otherwise, no --multi flag
+# is passed, and GDB connects with the remote protocol.
+#
+# WITH_SHELL_P is a boolean, when true gdbserver starts the inferior using a
+# shell, when false gdbserver is passed the --no-startup-with-shell command
+# line option, and should not start the inferior through a shell.
+#
+# ESCAPE_P is a boolean, when true gdbserver applies escapes to the inferior
+# arguments, when false gdbserver is passed the --no-escape-args command
+# line option, and should not apply escaping to the inferior arguments.
+#
+# ARGLIST is a list of inferior arguments to add to the gdbserver command
+# line.
+#
+# RE_LIST is a list of patterns to match, one for each of ARGLIST. Once the
+# inferior is started we check that each argument matches its corresponding
+# entry in RE_LIST.
+proc do_test_inner { extended_p with_shell_p escape_p arglist re_list } {
+
+ clean_restart ${::testfile}
+
+ gdb_test_no_output "set sysroot"
+
+ # Make sure we're disconnected, in case we're testing with an
+ # extended-remote board, therefore already connected.
+ gdb_test "disconnect" ".*"
+
+ if { $extended_p } {
+ set protocol "extended-remote"
+ } else {
+ set protocol "remote"
+ }
+
+ if { $escape_p } {
+ set esc_opt ""
+ } else {
+ set esc_opt "--no-escape-args"
+ }
+
+ if { $with_shell_p } {
+ set shell_opt ""
+ } else {
+ set shell_opt "--no-startup-with-shell"
+ }
+
+ gdb_test "target ${protocol} | ${::gdbserver} --once ${esc_opt} ${shell_opt} - ${::binfile} ${arglist}" \
+ ".*" \
+ "start gdbserver over stdin"
+
+ gdb_breakpoint main
+ gdb_continue_to_breakpoint main
+
+ set expected_len [expr {1 + [llength $re_list]}]
+ gdb_test "print argc" \
+ "\\\$$::decimal = $expected_len" "check argc"
+
+ set i 1
+ foreach arg $re_list {
+ gdb_test "print argv\[$i\]" \
+ "\\\$$::decimal = $::hex \"$arg\"" \
+ "check argv\[$i\]"
+ incr i
+ }
+}
+
+# Wrapper around do_test_inner. NAME is the name of this test, used to make
+# the test names unique. ARGLIST is the list of inferior arguments to add
+# to the gdbserver command line.
+#
+# The optional RE_ESC_LIST is a list of patterns to match against the
+# inferior arguments once the inferior is started, one pattern for each
+# argument. If RE_ESC_LIST is not given then ARGLIST is reused, which
+# implies the arguments appear unmodified in the test output.
+#
+# The optional RE_NO_ESC_LIST is a list of patterns to match against the
+# inferior arguments when gdbserver is started with --no-escape-args or
+# --no-startup-with-shell. There should be one pattern for each argument.
+# If RE_NO_ESC_LIST is not given then RE_ESC_LIST is reused, which implies
+# there's no difference in how the arguments are printed.
+proc args_test { name arglist {re_esc_list {}} {re_no_esc_list {}} } {
+ if {[llength $re_esc_list] == 0} {
+ set re_esc_list $arglist
+ }
+
+ if {[llength $re_no_esc_list] == 0} {
+ set re_no_esc_list $re_esc_list
+ }
+
+ foreach_with_prefix extended_p { yes no } {
+ foreach_with_prefix startup_with_shell { on off } {
+ foreach_with_prefix escape_p { yes no } {
+ if { $escape_p || !$startup_with_shell } {
+ set re_list $re_esc_list
+ } else {
+ set re_list $re_no_esc_list
+ }
+
+ with_test_prefix "$name" {
+ do_test_inner $extended_p $startup_with_shell \
+ $escape_p $arglist $re_list
+ }
+ }
+ }
+ }
+}
+
+args_test "basic" {a b c}
+args_test "one empty" {1 "" 3}
+args_test "two empty" {1 "" "" 3}
+args_test "one with single quotes" {1 "''" 3}
+args_test "lone double quote" {"1" \" 3} {1 \\\\\" 3}
+save_vars { env(TEST) } {
+ set env(TEST) "ABCD"
+ args_test "shell variable" {\$TEST} {\\$TEST} {ABCD}
+}
diff --git a/gdb/testsuite/gdb.server/monitor-exit-quit.exp b/gdb/testsuite/gdb.server/monitor-exit-quit.exp
index ce63560..74842a0 100644
--- a/gdb/testsuite/gdb.server/monitor-exit-quit.exp
+++ b/gdb/testsuite/gdb.server/monitor-exit-quit.exp
@@ -34,7 +34,7 @@ save_vars { GDBFLAGS } {
set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\""
}
- clean_restart $binfile
+ clean_restart $::testfile
}
# Make sure we're disconnected, in case we're testing with an
@@ -70,7 +70,7 @@ gdb_test_multiple "quit" "" {
# Cleanup, as in default_gdb_exit.
if { $do_cleanup } {
- if ![is_remote host] {
+ if { ![is_remote host] } {
remote_close host
}
unset gdb_spawn_id
diff --git a/gdb/testsuite/gdb.server/non-existing-program.exp b/gdb/testsuite/gdb.server/non-existing-program.exp
index 7119723..ec9c044 100644
--- a/gdb/testsuite/gdb.server/non-existing-program.exp
+++ b/gdb/testsuite/gdb.server/non-existing-program.exp
@@ -34,6 +34,8 @@ if { $gdbserver == "" } {
# to spawn the program before opening the connection.
set spawn_id [remote_spawn target "$gdbserver stdio non-existing-program"]
+set eol {[\r\n]}
+
set msg "gdbserver exits cleanly"
set saw_exiting 0
expect {
@@ -51,7 +53,7 @@ expect {
exp_continue
}
# This is what we get on Windows.
- -re "Error creating process\r\n\r\nExiting\r\n" {
+ -re "Error creating process.*$eol+Exiting$eol+" {
set saw_exiting 1
exp_continue
}
diff --git a/gdb/testsuite/gdb.server/reconnect-ctrl-c.exp b/gdb/testsuite/gdb.server/reconnect-ctrl-c.exp
index 83869a3..bcab2de 100644
--- a/gdb/testsuite/gdb.server/reconnect-ctrl-c.exp
+++ b/gdb/testsuite/gdb.server/reconnect-ctrl-c.exp
@@ -51,7 +51,7 @@ proc connect_continue_ctrl_c {} {
global gdbserver_protocol gdbserver_gdbport
set res [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
- if ![gdb_assert {$res == 0} "connect"] {
+ if { ![gdb_assert {$res == 0} "connect"] } {
return
}
diff --git a/gdb/testsuite/gdb.server/server-exec-info.exp b/gdb/testsuite/gdb.server/server-exec-info.exp
index fccf075..007290a 100644
--- a/gdb/testsuite/gdb.server/server-exec-info.exp
+++ b/gdb/testsuite/gdb.server/server-exec-info.exp
@@ -21,7 +21,7 @@ load_lib gdbserver-support.exp
require allow_gdbserver_tests allow_shlib_tests
standard_testfile server.c
-if [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] {
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return -1
}
diff --git a/gdb/testsuite/gdb.server/server-kill.exp b/gdb/testsuite/gdb.server/server-kill.exp
index 0a759ae..a9fcabb 100644
--- a/gdb/testsuite/gdb.server/server-kill.exp
+++ b/gdb/testsuite/gdb.server/server-kill.exp
@@ -43,7 +43,7 @@ proc prepare {} {
set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\""
}
- clean_restart $binfile
+ clean_restart $::testfile
}
# Make sure we're disconnected, in case we're testing with an
diff --git a/gdb/testsuite/gdb.server/server-pipe.exp b/gdb/testsuite/gdb.server/server-pipe.exp
index d786946..20ca0b0 100644
--- a/gdb/testsuite/gdb.server/server-pipe.exp
+++ b/gdb/testsuite/gdb.server/server-pipe.exp
@@ -50,7 +50,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug]} {
# the contents of the gdb.TargetConnection.details string.
proc do_test { target } {
global timeout
- clean_restart ${::binfile}
+ clean_restart ${::testfile}
# Make sure we're disconnected, in case we're testing with an
# extended-remote board, therefore already connected.
diff --git a/gdb/testsuite/gdb.server/server-run.exp b/gdb/testsuite/gdb.server/server-run.exp
index 6c9db98..53b3278 100644
--- a/gdb/testsuite/gdb.server/server-run.exp
+++ b/gdb/testsuite/gdb.server/server-run.exp
@@ -34,7 +34,7 @@ save_vars { GDBFLAGS } {
set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\""
}
- clean_restart $binfile
+ clean_restart $::testfile
}
# Make sure we're disconnected, in case we're testing with an
diff --git a/gdb/testsuite/gdb.server/stop-reply-no-thread-multi.exp b/gdb/testsuite/gdb.server/stop-reply-no-thread-multi.exp
index 42608c4..f1c68a5 100644
--- a/gdb/testsuite/gdb.server/stop-reply-no-thread-multi.exp
+++ b/gdb/testsuite/gdb.server/stop-reply-no-thread-multi.exp
@@ -54,7 +54,7 @@ proc run_test { target_non_stop disable_feature } {
set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\""
}
- clean_restart ${binfile}
+ clean_restart ${::testfile}
}
# Make sure we're disconnected, in case we're testing with an
@@ -78,7 +78,7 @@ proc run_test { target_non_stop disable_feature } {
"Support for the 'multiprocess-feature' packet on future remote targets is set to \"off\"."
set res [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
- if ![gdb_assert {$res == 0} "connect"] {
+ if { ![gdb_assert {$res == 0} "connect"] } {
return
}
diff --git a/gdb/testsuite/gdb.server/stop-reply-no-thread.exp b/gdb/testsuite/gdb.server/stop-reply-no-thread.exp
index 38402e8..aa77095 100644
--- a/gdb/testsuite/gdb.server/stop-reply-no-thread.exp
+++ b/gdb/testsuite/gdb.server/stop-reply-no-thread.exp
@@ -42,7 +42,7 @@ proc run_test { disable_feature target_nonstop } {
set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\""
}
- clean_restart ${binfile}
+ clean_restart ${::testfile}
}
# Make sure we're disconnected, in case we're testing with an
@@ -70,7 +70,7 @@ proc run_test { disable_feature target_nonstop } {
gdb_test_no_output "maint set target-non-stop ${target_nonstop}"
set res [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport]
- if ![gdb_assert {$res == 0} "connect"] {
+ if { ![gdb_assert {$res == 0} "connect"] } {
return
}
diff --git a/gdb/testsuite/gdb.testsuite/board-sanity.exp b/gdb/testsuite/gdb.testsuite/board-sanity.exp
index 9c80282..7b9a19e 100644
--- a/gdb/testsuite/gdb.testsuite/board-sanity.exp
+++ b/gdb/testsuite/gdb.testsuite/board-sanity.exp
@@ -44,7 +44,7 @@ proc test_remote { remote host_is_target } {
if { $host_is_target } {
set res [remote_file $other_remote exists $file]
gdb_assert { $res != $exists_ok } \
- "$other_remote copy does not exist"
+ "$other_remote copy does not exist"
}
}
@@ -80,7 +80,7 @@ proc test_remote { remote host_is_target } {
set build_file [remote_upload $remote $file]
gdb_assert { [string equal [file tail $build_file] $file] == 1 } \
"remote_upload returns valid value"
-
+
set res [remote_file $remote delete $file]
gdb_assert { [string equal $res $delete_ok] == 1 } \
"remove $remote copy"
@@ -92,7 +92,7 @@ proc test_remote { remote host_is_target } {
if { $host_is_target } {
set res [remote_file $other_remote exists $file]
gdb_assert { $res != $exists_ok } \
- "$other_remote copy does not exist"
+ "$other_remote copy does not exist"
}
set res [remote_file build exists $file]
diff --git a/gdb/testsuite/gdb.testsuite/gdb-caching-proc-consistency.exp b/gdb/testsuite/gdb.testsuite/gdb-caching-proc-consistency.exp
index 0957dbd..27f905e 100644
--- a/gdb/testsuite/gdb.testsuite/gdb-caching-proc-consistency.exp
+++ b/gdb/testsuite/gdb.testsuite/gdb-caching-proc-consistency.exp
@@ -63,8 +63,8 @@ proc test_file { file } {
set fp [open $file]
while { [gets $fp line] >= 0 } {
- if [regexp -- "^gdb_caching_proc \[ \t\]*(\[^ \t\]*)" $line \
- match procname] {
+ if { [regexp -- "^gdb_caching_proc \[ \t\]*(\[^ \t\]*)" $line \
+ match procname] } {
lappend procnames $procname
}
}
@@ -95,7 +95,8 @@ proc test_file { file } {
}
if { $setup_gdb } {
- clean_restart $obj
+ clean_restart
+ gdb_load $obj
}
test_proc $procname
@@ -113,7 +114,7 @@ if { ![gdb_simple_compile $me $src executable] } {
}
# Test gdb_caching_procs in gdb/testsuite/lib/*.exp
-set files [eval glob -types f $srcdir/lib/*.exp]
+set files [glob -types f $srcdir/lib/*.exp]
set files [lsort $files]
foreach file $files {
test_file $file
diff --git a/gdb/testsuite/gdb.testsuite/gdb-caching-proc.exp b/gdb/testsuite/gdb.testsuite/gdb-caching-proc.exp
index f9610af..6b46b1c 100644
--- a/gdb/testsuite/gdb.testsuite/gdb-caching-proc.exp
+++ b/gdb/testsuite/gdb.testsuite/gdb-caching-proc.exp
@@ -22,23 +22,32 @@ gdb_caching_proc gdb_testsuite_gdb_caching_proc_exp_arg { arg } {
return $arg
}
+gdb_caching_proc gdb_testsuite_gdb_caching_proc_exp_arg_nested { arg } {
+ incr ::count
+ return [gdb_testsuite_gdb_caching_proc_exp_arg $arg]
+}
+
+# List of "expected $::count after running expression" and
+# "expression".
set assertions {
- { [gdb_testsuite_gdb_caching_proc_exp_noarg] == 1 }
- { [gdb_testsuite_gdb_caching_proc_exp_arg 1] == 1 }
- { [gdb_testsuite_gdb_caching_proc_exp_arg "foo foo"] == "foo foo" }
+ 1 { [gdb_testsuite_gdb_caching_proc_exp_noarg] == 1 }
+ 1 { [gdb_testsuite_gdb_caching_proc_exp_arg 1] == 1 }
+ 1 { [gdb_testsuite_gdb_caching_proc_exp_arg "foo foo"] == "foo foo" }
+ 1 { [gdb_testsuite_gdb_caching_proc_exp_arg_nested "foo foo"] == "foo foo" }
+ 2 { [gdb_testsuite_gdb_caching_proc_exp_arg_nested "bar bar"] == "bar bar" }
}
set assertion_nr 0
-foreach assertion $assertions {
+foreach {expected_count assertion} $assertions {
with_test_prefix $assertion_nr {
set ::count 0
gdb_assert $assertion
- gdb_assert { $::count == 1 }
+ gdb_assert { $::count == $expected_count }
with_test_prefix cached {
gdb_assert $assertion
- gdb_assert { $::count == 1 }
+ gdb_assert { $::count == $expected_count }
}
}
incr assertion_nr
diff --git a/gdb/testsuite/gdb.testsuite/mount-point-map.exp b/gdb/testsuite/gdb.testsuite/mount-point-map.exp
new file mode 100644
index 0000000..9e462bb
--- /dev/null
+++ b/gdb/testsuite/gdb.testsuite/mount-point-map.exp
@@ -0,0 +1,49 @@
+# Copyright 2025 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/>.
+
+set unix_to_win {
+ /bin C:/msys64/usr/bin
+ /c C:
+ / C:/msys64
+}
+
+# Test that FROM is normalized to TO.
+
+proc test {from to} {
+ set got [host_file_normalize_mingw $from $::unix_to_win]
+ verbose -log "input: $from"
+ verbose -log "expected: $to"
+ verbose -log "got: $got"
+ gdb_assert {$got == $to} $from
+}
+
+# Drive letters always get a '/' suffix, other Windows file names do
+# not.
+test "/" "C:/msys64"
+test "/c" "C:/"
+test "/bin" "C:/msys64/usr/bin"
+
+# A file name that already starts with a drive letter.
+test "C:/msys64" "C:/msys64"
+
+# A subdir/subfile under each mount.
+test "/foo" "C:/msys64/foo"
+test "/c/foo" "C:/foo"
+test "/bin/foo" "C:/msys64/usr/bin/foo"
+
+# Test slash normalization.
+test "//" "C:/msys64"
+test "/c///foo//bar//" "C:/foo/bar"
+# We don't currently handle UNC paths.
+test "//server///" "C:/msys64/server"
diff --git a/gdb/testsuite/gdb.testsuite/with-override.exp b/gdb/testsuite/gdb.testsuite/with-override.exp
index 9180150..2a316f9 100644
--- a/gdb/testsuite/gdb.testsuite/with-override.exp
+++ b/gdb/testsuite/gdb.testsuite/with-override.exp
@@ -42,6 +42,10 @@ with_test_prefix no-args {
gdb_assert { [foo] == 2 }
}
}
+
+ with_test_prefix "foo1 again" {
+ gdb_assert { [foo] == 1 }
+ }
}
with_test_prefix after {
@@ -50,11 +54,11 @@ with_test_prefix no-args {
}
proc foo { {a 0} } {
- return [expr $a + 1]
+ return [expr {$a + 1}]
}
proc foo_plus_1 { {a 0} } {
- return [expr $a + 2]
+ return [expr {$a + 2}]
}
with_test_prefix default-arg {
diff --git a/gdb/testsuite/gdb.threads/access-mem-running-thread-exit.exp b/gdb/testsuite/gdb.threads/access-mem-running-thread-exit.exp
index fec31c3..64d2f53 100644
--- a/gdb/testsuite/gdb.threads/access-mem-running-thread-exit.exp
+++ b/gdb/testsuite/gdb.threads/access-mem-running-thread-exit.exp
@@ -51,10 +51,10 @@ proc test { non_stop } {
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"set non-stop $non_stop\""
- clean_restart ${binfile}
+ clean_restart ${::testfile}
}
- if ![runto setup_done] {
+ if {![runto setup_done]} {
return -1
}
@@ -101,7 +101,7 @@ proc test { non_stop } {
#
# Since it's reload_on_run targets that need special care,
# we default to reusing the connection on most targets.
- if [target_info exists gdb,do_reload_on_run] {
+ if {[target_info exists gdb,do_reload_on_run]} {
gdb_test "add-inferior -no-connection" "New inferior 2.*"
} else {
gdb_test "add-inferior" "New inferior 2.*"
@@ -110,7 +110,7 @@ proc test { non_stop } {
gdb_load $binfile
- if ![runto setup_done] {
+ if {![runto setup_done]} {
return -1
}
}
@@ -187,7 +187,7 @@ proc test { non_stop } {
}
foreach non_stop { "off" "on" } {
- set stop_mode [expr ($non_stop=="off")?"all-stop":"non-stop"]
+ set stop_mode [expr {($non_stop=="off")?"all-stop":"non-stop"}]
with_test_prefix "$stop_mode" {
test $non_stop
}
diff --git a/gdb/testsuite/gdb.threads/async.exp b/gdb/testsuite/gdb.threads/async.exp
index b1e562a..6347333 100644
--- a/gdb/testsuite/gdb.threads/async.exp
+++ b/gdb/testsuite/gdb.threads/async.exp
@@ -32,7 +32,7 @@ proc test_current_thread {expected_thr} {
global gdb_prompt
global binfile
- clean_restart $binfile
+ clean_restart $::testfile
if {![runto "all_started"]} {
return
diff --git a/gdb/testsuite/gdb.threads/attach-into-signal.exp b/gdb/testsuite/gdb.threads/attach-into-signal.exp
index 0629736..ca452c1 100644
--- a/gdb/testsuite/gdb.threads/attach-into-signal.exp
+++ b/gdb/testsuite/gdb.threads/attach-into-signal.exp
@@ -58,7 +58,7 @@ proc corefunc { threadtype executable } {
# nonthreaded:
pass $test
verbose -log "$test succeeded on the attempt # $attempt of $attempts"
- set passes [expr $passes + 1]
+ set passes [expr {$passes + 1}]
}
-re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" {
set ok 0
@@ -84,11 +84,11 @@ proc corefunc { threadtype executable } {
if { $ok == 0} {
# We just lack the luck, we should try it again.
- set attempt [expr $attempt + 1]
+ set attempt [expr {$attempt + 1}]
} else {
pass $test
verbose -log "$test succeeded on the attempt # $attempt of $attempts"
- set passes [expr $passes + 1]
+ set passes [expr {$passes + 1}]
}
}
}] != 0 } {
diff --git a/gdb/testsuite/gdb.threads/attach-non-stop.exp b/gdb/testsuite/gdb.threads/attach-non-stop.exp
index 9404edd..b8da5b1 100644
--- a/gdb/testsuite/gdb.threads/attach-non-stop.exp
+++ b/gdb/testsuite/gdb.threads/attach-non-stop.exp
@@ -37,7 +37,7 @@ proc test {target_non_stop non_stop cmd} {
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"maint set target-non-stop $target_non_stop\""
append GDBFLAGS " -ex \"set non-stop $non_stop\""
- clean_restart $binfile
+ clean_restart $::testfile
}
set test_spawn_id [spawn_wait_for_attach $binfile]
diff --git a/gdb/testsuite/gdb.threads/attach-stopped.exp b/gdb/testsuite/gdb.threads/attach-stopped.exp
index e628adf..0391914 100644
--- a/gdb/testsuite/gdb.threads/attach-stopped.exp
+++ b/gdb/testsuite/gdb.threads/attach-stopped.exp
@@ -40,13 +40,13 @@ proc corefunc { threadtype } {
set test_spawn_id [spawn_wait_for_attach $binfile]
set testpid [spawn_id_get_pid $test_spawn_id]
- # Stop the program
+ # Stop the program
remote_exec build "kill -s STOP ${testpid}"
- clean_restart $binfile
+ clean_restart $::testfile
# Verify that we can attach to the stopped process.
-
+
set test "$threadtype: attach2 to stopped, after setting file"
gdb_test_multiple "attach $testpid" "$test" {
-re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" {
diff --git a/gdb/testsuite/gdb.threads/bp_in_thread.exp b/gdb/testsuite/gdb.threads/bp_in_thread.exp
index c63f179..5180c18 100644
--- a/gdb/testsuite/gdb.threads/bp_in_thread.exp
+++ b/gdb/testsuite/gdb.threads/bp_in_thread.exp
@@ -24,7 +24,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
return -1
}
-clean_restart $binfile
+clean_restart $::testfile
runto_main
diff --git a/gdb/testsuite/gdb.threads/break-while-running.exp b/gdb/testsuite/gdb.threads/break-while-running.exp
index fbc2b59..c1e1051 100644
--- a/gdb/testsuite/gdb.threads/break-while-running.exp
+++ b/gdb/testsuite/gdb.threads/break-while-running.exp
@@ -39,12 +39,12 @@ proc test { update_thread_list always_inserted non_stop } {
global gdb_prompt
global decimal
- clean_restart $binfile
+ clean_restart $::testfile
gdb_test_no_output "set non-stop $non_stop"
gdb_test_no_output "set breakpoint always-inserted $always_inserted"
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
@@ -152,8 +152,8 @@ proc test { update_thread_list always_inserted non_stop } {
foreach update_thread_list { true false } {
foreach always_inserted { "off" "on" } {
foreach non_stop { "off" "on" } {
- set stop_mode [expr ($non_stop=="off")?"all-stop":"non-stop"]
- set update_list_mode [expr ($update_thread_list)?"w/ithr":"wo/ithr"]
+ set stop_mode [expr {($non_stop=="off")?"all-stop":"non-stop"}]
+ set update_list_mode [expr {($update_thread_list)?"w/ithr":"wo/ithr"}]
with_test_prefix "$update_list_mode: always-inserted $always_inserted: $stop_mode" {
test $update_thread_list $always_inserted $non_stop
}
diff --git a/gdb/testsuite/gdb.threads/check-libthread-db.exp b/gdb/testsuite/gdb.threads/check-libthread-db.exp
index b97ab49..6d63185 100644
--- a/gdb/testsuite/gdb.threads/check-libthread-db.exp
+++ b/gdb/testsuite/gdb.threads/check-libthread-db.exp
@@ -40,7 +40,7 @@ set initial_thread_re "($thread_re1|$thread_re2)"
with_test_prefix "user-initiated check" {
# User-initiated check with libthread_db not loaded.
- clean_restart ${binfile}
+ clean_restart ${::testfile}
gdb_test "maint show check-libthread-db" \
"Whether to check libthread_db at load time is off."
@@ -85,7 +85,7 @@ with_test_prefix "automated load-time check" {
# Automated load-time check with NPTL possibly uninitialized.
with_test_prefix "libpthread.so possibly not initialized" {
- clean_restart ${binfile}
+ clean_restart ${::testfile}
gdb_test_no_output "maint set check-libthread-db 1"
gdb_test_no_output "set debug libthread-db 1"
@@ -104,7 +104,7 @@ with_test_prefix "automated load-time check" {
# Automated load-time check with NPTL fully operational.
if { [can_spawn_for_attach] } {
with_test_prefix "libpthread.so fully initialized" {
- clean_restart ${binfile}
+ clean_restart ${::testfile}
gdb_test_no_output "maint set check-libthread-db 1"
gdb_test_no_output "set debug libthread-db 1"
diff --git a/gdb/testsuite/gdb.threads/clone-attach-detach.exp b/gdb/testsuite/gdb.threads/clone-attach-detach.exp
index 3da2c3e..b0f5e52 100644
--- a/gdb/testsuite/gdb.threads/clone-attach-detach.exp
+++ b/gdb/testsuite/gdb.threads/clone-attach-detach.exp
@@ -19,7 +19,7 @@
# clone as proxy for when libthread_db is not available.
# This only works on targets with the Linux kernel.
-if ![istarget *-*-linux*] {
+if {![istarget *-*-linux*]} {
return
}
@@ -27,7 +27,7 @@ require can_spawn_for_attach
standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile $srcfile {debug}] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug}]} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/clone-thread_db.exp b/gdb/testsuite/gdb.threads/clone-thread_db.exp
index 7ee233d..12349e2 100644
--- a/gdb/testsuite/gdb.threads/clone-thread_db.exp
+++ b/gdb/testsuite/gdb.threads/clone-thread_db.exp
@@ -16,17 +16,17 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This only works on targets with the Linux kernel.
-if ![istarget *-*-linux*] {
+if {![istarget *-*-linux*]} {
return
}
standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/continue-pending-after-query.exp b/gdb/testsuite/gdb.threads/continue-pending-after-query.exp
index 5069cd2..1da2e23 100644
--- a/gdb/testsuite/gdb.threads/continue-pending-after-query.exp
+++ b/gdb/testsuite/gdb.threads/continue-pending-after-query.exp
@@ -51,7 +51,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}
proc test {} {
global srcfile gdb_prompt
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/continue-pending-status.exp b/gdb/testsuite/gdb.threads/continue-pending-status.exp
index 9cde85a..447b683 100644
--- a/gdb/testsuite/gdb.threads/continue-pending-status.exp
+++ b/gdb/testsuite/gdb.threads/continue-pending-status.exp
@@ -21,11 +21,11 @@ require {!target_info exists gdb,nointerrupts}
standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/corethreads.exp b/gdb/testsuite/gdb.threads/corethreads.exp
index 3b50ae3..0011dc3 100644
--- a/gdb/testsuite/gdb.threads/corethreads.exp
+++ b/gdb/testsuite/gdb.threads/corethreads.exp
@@ -29,6 +29,7 @@ if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executa
set corefile [core_find $binfile]
if {$corefile == ""} {
+ untested "unable to create or find corefile"
return 0
}
diff --git a/gdb/testsuite/gdb.threads/create-fail.exp b/gdb/testsuite/gdb.threads/create-fail.exp
index 14f3f4b..5d633f9 100644
--- a/gdb/testsuite/gdb.threads/create-fail.exp
+++ b/gdb/testsuite/gdb.threads/create-fail.exp
@@ -33,7 +33,7 @@ for {set i 1} {$i <= $iterations} {incr i} {
clean_restart ${executable}
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/del-pending-thread-bp.exp b/gdb/testsuite/gdb.threads/del-pending-thread-bp.exp
index 1fbfc40..bdc519f 100644
--- a/gdb/testsuite/gdb.threads/del-pending-thread-bp.exp
+++ b/gdb/testsuite/gdb.threads/del-pending-thread-bp.exp
@@ -44,7 +44,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
gdb_locate_shlib $binfile_lib
-if ![runto_main] {
+if {![runto_main]} {
return 0
}
diff --git a/gdb/testsuite/gdb.threads/detach-step-over.exp b/gdb/testsuite/gdb.threads/detach-step-over.exp
index 8a1cb29..98b412c 100644
--- a/gdb/testsuite/gdb.threads/detach-step-over.exp
+++ b/gdb/testsuite/gdb.threads/detach-step-over.exp
@@ -66,7 +66,7 @@ proc start_gdb_for_test {condition_eval target_non_stop non_stop displaced} {
append ::GDBFLAGS " -ex \"set non-stop $non_stop\""
append ::GDBFLAGS " -ex \"set displaced $displaced\""
append ::GDBFLAGS " -ex \"set schedule-multiple on\""
- clean_restart $::binfile
+ clean_restart $::testfile
}
gdb_test_no_output "set breakpoint condition-evaluation $condition_eval"
@@ -229,7 +229,7 @@ proc_with_prefix test_detach_command {condition_eval target_non_stop non_stop di
set running_count 0
set interrupted 0
- set running_expected [expr ($::n_threads + 1) * 2]
+ set running_expected [expr {($::n_threads + 1) * 2}]
gdb_test_multiple "info threads" "threads running" {
-re "\\(running\\)" {
incr running_count
@@ -357,7 +357,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile $options] == -1}
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/execl.exp b/gdb/testsuite/gdb.threads/execl.exp
index 502d387..a42dce9 100644
--- a/gdb/testsuite/gdb.threads/execl.exp
+++ b/gdb/testsuite/gdb.threads/execl.exp
@@ -31,7 +31,7 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile1}" executable {deb
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if { [is_remote target] } {
gdb_remote_download target $binfile1
}
diff --git a/gdb/testsuite/gdb.threads/foll-fork-other-thread.exp b/gdb/testsuite/gdb.threads/foll-fork-other-thread.exp
index 8ab540c..29ec34c 100644
--- a/gdb/testsuite/gdb.threads/foll-fork-other-thread.exp
+++ b/gdb/testsuite/gdb.threads/foll-fork-other-thread.exp
@@ -46,7 +46,7 @@ proc do_test { fork_func follow target-non-stop non-stop displaced-stepping } {
save_vars { ::GDBFLAGS } {
append ::GDBFLAGS " -ex \"maintenance set target-non-stop ${target-non-stop}\""
append ::GDBFLAGS " -ex \"set non-stop ${non-stop}\""
- clean_restart ${::binfile}-${fork_func}
+ clean_restart ${::testfile}-${fork_func}
}
gdb_test_no_output "set displaced-stepping ${displaced-stepping}"
diff --git a/gdb/testsuite/gdb.threads/fork-child-threads.exp b/gdb/testsuite/gdb.threads/fork-child-threads.exp
index ba9dfc2..d1b413c 100644
--- a/gdb/testsuite/gdb.threads/fork-child-threads.exp
+++ b/gdb/testsuite/gdb.threads/fork-child-threads.exp
@@ -21,7 +21,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.threads/fork-plus-threads.exp b/gdb/testsuite/gdb.threads/fork-plus-threads.exp
index 4ce88d3..c41b164 100644
--- a/gdb/testsuite/gdb.threads/fork-plus-threads.exp
+++ b/gdb/testsuite/gdb.threads/fork-plus-threads.exp
@@ -76,7 +76,7 @@ proc do_test { detach-on-fork } {
set saw_cannot_remove_breakpoints 0
set saw_thread_stopped 0
- set expected_num_inferior_exits [expr ${detach-on-fork} == "off" ? 11 : 1]
+ set expected_num_inferior_exits [expr {${detach-on-fork} == "off" ? 11 : 1}]
# Flags indicating if we have see the exit for each inferior.
for {set i 1} {$i <= $expected_num_inferior_exits} {incr i} {
diff --git a/gdb/testsuite/gdb.threads/fork-thread-pending.exp b/gdb/testsuite/gdb.threads/fork-thread-pending.exp
index 538e1ca..e0e3625 100644
--- a/gdb/testsuite/gdb.threads/fork-thread-pending.exp
+++ b/gdb/testsuite/gdb.threads/fork-thread-pending.exp
@@ -21,7 +21,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return 0
@@ -75,7 +75,7 @@ gdb_test_multiple "info threads" "$test" {
# Start over, but this time, don't switch away from the fork event thread.
-clean_restart $binfile
+clean_restart $::testfile
if {![runto_main]} {
return 0
}
diff --git a/gdb/testsuite/gdb.threads/forking-threads-plus-breakpoint.exp b/gdb/testsuite/gdb.threads/forking-threads-plus-breakpoint.exp
index c668a65..d65fe83d 100644
--- a/gdb/testsuite/gdb.threads/forking-threads-plus-breakpoint.exp
+++ b/gdb/testsuite/gdb.threads/forking-threads-plus-breakpoint.exp
@@ -37,7 +37,7 @@ proc probe_displaced_stepping_support {} {
global binfile gdb_prompt
with_test_prefix "probe displaced-stepping support" {
- clean_restart $binfile
+ clean_restart $::testfile
gdb_test_no_output "set displaced on"
if {![runto_main]} {
@@ -76,7 +76,7 @@ proc do_test { cond_bp_target detach_on_fork displaced } {
save_vars { GDBFLAGS } {
set GDBFLAGS [concat $GDBFLAGS " -ex \"set non-stop on\""]
- clean_restart $binfile
+ clean_restart $::testfile
}
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.threads/gcore-thread.exp b/gdb/testsuite/gdb.threads/gcore-thread.exp
index 4e00f80..f32e9b4 100644
--- a/gdb/testsuite/gdb.threads/gcore-thread.exp
+++ b/gdb/testsuite/gdb.threads/gcore-thread.exp
@@ -123,7 +123,7 @@ proc load_core { filename } {
}
# FIXME: now what can we test about the thread state?
- # We do not know for certain that there should be at least
+ # We do not know for certain that there should be at least
# three threads, because who knows what kind of many-to-one
# mapping various OS's may do? Let's assume that there must
# be at least two threads:
diff --git a/gdb/testsuite/gdb.threads/hand-call-in-threads.exp b/gdb/testsuite/gdb.threads/hand-call-in-threads.exp
index d1be1d0..f9c9e87 100644
--- a/gdb/testsuite/gdb.threads/hand-call-in-threads.exp
+++ b/gdb/testsuite/gdb.threads/hand-call-in-threads.exp
@@ -44,7 +44,7 @@ proc get_dummy_frame_number { } {
return ""
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if { ![runto_main] } {
return 0
@@ -74,7 +74,7 @@ gdb_test "show scheduler-locking" ".* locking scheduler .* is \"on\"." "show sch
# stop without returning.
# Add one for the main thread.
-set total_nr_threads [expr $NR_THREADS + 1]
+set total_nr_threads [expr {$NR_THREADS + 1}]
# Thread numbering in gdb is origin-1, so begin numbering at 1.
for { set i 1 } { $i <= $total_nr_threads } { incr i } {
diff --git a/gdb/testsuite/gdb.threads/hand-call-new-thread.exp b/gdb/testsuite/gdb.threads/hand-call-new-thread.exp
index 6b859ff..479c2ff 100644
--- a/gdb/testsuite/gdb.threads/hand-call-new-thread.exp
+++ b/gdb/testsuite/gdb.threads/hand-call-new-thread.exp
@@ -18,11 +18,11 @@
standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.threads/ia64-sigill.exp b/gdb/testsuite/gdb.threads/ia64-sigill.exp
index ac6ff20..46954de 100644
--- a/gdb/testsuite/gdb.threads/ia64-sigill.exp
+++ b/gdb/testsuite/gdb.threads/ia64-sigill.exp
@@ -27,7 +27,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" ${binfile} executable
clean_restart $testfile
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/inf-thr-count.exp b/gdb/testsuite/gdb.threads/inf-thr-count.exp
index 61533ab..4508be2 100644
--- a/gdb/testsuite/gdb.threads/inf-thr-count.exp
+++ b/gdb/testsuite/gdb.threads/inf-thr-count.exp
@@ -44,10 +44,10 @@ if {[build_executable "failed to prepare" $testfile $srcfile \
# the inferior while it is running.
save_vars {GDBFLAGS} {
append GDBFLAGS { -ex "set non-stop on"}
- clean_restart $binfile
+ clean_restart $::testfile
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-other-thread-event.exp b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-other-thread-event.exp
index 62a183c..35a1fe5 100644
--- a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-other-thread-event.exp
+++ b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-other-thread-event.exp
@@ -53,7 +53,7 @@ proc start_gdb_and_runto_main { target_async target_non_stop } {
append ::GDBFLAGS \
" -ex \"maintenance set target-async ${target_async}\""
- clean_restart ${::binfile}
+ clean_restart ${::testfile}
}
if { ![runto_main] } {
diff --git a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp
index 0f068c6..ed98998 100644
--- a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp
+++ b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp
@@ -42,7 +42,7 @@ proc start_gdb_and_runto_main { target_async target_non_stop } {
append ::GDBFLAGS \
" -ex \"maintenance set target-async ${target_async}\""
- clean_restart ${::binfile}
+ clean_restart ${::testfile}
}
if { ![runto_main] } {
diff --git a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-single.exp b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-single.exp
index c404a7d..bc12fb4 100644
--- a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-single.exp
+++ b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-single.exp
@@ -38,7 +38,7 @@ proc start_gdb_and_runto_main { target_async target_non_stop } {
append ::GDBFLAGS \
" -ex \"maintenance set target-async ${target_async}\""
- clean_restart ${::binfile}
+ clean_restart ${::testfile}
}
if { ![runto_main] } {
diff --git a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-timeout.exp b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-timeout.exp
index 9dbaa4f..03c6959 100644
--- a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-timeout.exp
+++ b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-timeout.exp
@@ -52,7 +52,7 @@ proc run_test { target_async target_non_stop non_stop other_thread_bp unwind } {
append ::GDBFLAGS " -ex \"maint non-stop $non_stop\""
append ::GDBFLAGS " -ex \"maintenance set target-async ${target_async}\""
- clean_restart ${::binfile}
+ clean_restart ${::testfile}
}
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.threads/infcall-thread-announce.exp b/gdb/testsuite/gdb.threads/infcall-thread-announce.exp
index 68fd7b7..59a5bcf 100644
--- a/gdb/testsuite/gdb.threads/infcall-thread-announce.exp
+++ b/gdb/testsuite/gdb.threads/infcall-thread-announce.exp
@@ -23,7 +23,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/info-threads-cur-sal.exp b/gdb/testsuite/gdb.threads/info-threads-cur-sal.exp
index 2d57136..784caf9 100644
--- a/gdb/testsuite/gdb.threads/info-threads-cur-sal.exp
+++ b/gdb/testsuite/gdb.threads/info-threads-cur-sal.exp
@@ -25,7 +25,7 @@ if {[gdb_compile_pthreads \
clean_restart ${executable}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/info-threads-options.exp b/gdb/testsuite/gdb.threads/info-threads-options.exp
index 38e4e67..b322261 100644
--- a/gdb/testsuite/gdb.threads/info-threads-options.exp
+++ b/gdb/testsuite/gdb.threads/info-threads-options.exp
@@ -24,10 +24,10 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"set non-stop on\""
- clean_restart $binfile
+ clean_restart $::testfile
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp b/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp
index 05587eb..d3f328b 100644
--- a/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp
+++ b/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp
@@ -84,7 +84,7 @@ proc test_one_iteration {} {
exp_continue
}
-re "$gdb_prompt " {
- if ![gdb_assert $saw_continuing $test] {
+ if {![gdb_assert $saw_continuing $test]} {
return 1
}
}
@@ -101,7 +101,7 @@ proc test_one_iteration {} {
exp_continue
}
-re "$gdb_prompt " {
- if ![gdb_assert {$running_count == $NUM_THREADS} $test] {
+ if {![gdb_assert {$running_count == $NUM_THREADS} $test]} {
return 1
}
}
@@ -151,7 +151,7 @@ proc test_one_iteration {} {
exp_continue
}
-re "$gdb_prompt " {
- if ![gdb_assert {$running_count == 0} $test] {
+ if {![gdb_assert {$running_count == 0} $test]} {
return 1
}
}
@@ -169,12 +169,12 @@ proc testdriver {displaced} {
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"set non-stop on\""
- clean_restart $binfile
+ clean_restart $::testfile
}
gdb_test_no_output "set displaced-stepping $displaced"
- if ![runto all_started] {
+ if {![runto all_started]} {
return
}
set break_line [gdb_get_line_number "set breakpoint here"]
diff --git a/gdb/testsuite/gdb.threads/interrupted-hand-call.exp b/gdb/testsuite/gdb.threads/interrupted-hand-call.exp
index 3a2bc63..15c48b1 100644
--- a/gdb/testsuite/gdb.threads/interrupted-hand-call.exp
+++ b/gdb/testsuite/gdb.threads/interrupted-hand-call.exp
@@ -28,7 +28,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if { ![runto_main] } {
return 0
diff --git a/gdb/testsuite/gdb.threads/kill.exp b/gdb/testsuite/gdb.threads/kill.exp
index 3e6aa8b..72f829c 100644
--- a/gdb/testsuite/gdb.threads/kill.exp
+++ b/gdb/testsuite/gdb.threads/kill.exp
@@ -23,7 +23,7 @@ standard_testfile
proc test {threaded} {
global testfile srcfile decimal
- with_test_prefix [expr ($threaded)?"threaded":"non-threaded"] {
+ with_test_prefix [expr {($threaded)?"threaded":"non-threaded"}] {
set options {debug}
if {$threaded} {
diff --git a/gdb/testsuite/gdb.threads/killed.exp b/gdb/testsuite/gdb.threads/killed.exp
index b1cec80b0..635ffc8 100644
--- a/gdb/testsuite/gdb.threads/killed.exp
+++ b/gdb/testsuite/gdb.threads/killed.exp
@@ -29,7 +29,7 @@
# There is absolutely no warranty for GDB. Type "show warranty" for details.
# This GDB was configured as "i686-pc-linux-gnu"...
# (gdb) run
-# Starting program: /home/jimb/foo/play/killed
+# Starting program: /home/jimb/foo/play/killed
# [New Thread 1024 (LWP 6487)]
# [New Thread 2049 (LWP 6488)]
# [New Thread 1026 (LWP 6489)]
@@ -42,17 +42,17 @@
# Cannot find thread 2049: generic error
# (gdb) The program is running. Exit anyway? (y or n) y
# Cannot find thread 2049: generic error
-# (gdb)
+# (gdb)
# [7]+ Stopped $D6/gdb/gdb -nw killed
# $ kill %7
-#
+#
# [7]+ Stopped $D6/gdb/gdb -nw killed
# $ kill -9 %7
-#
+#
# [7]+ Stopped $D6/gdb/gdb -nw killed
-# $
+# $
# [7]+ Killed $D6/gdb/gdb -nw killed
-# $
+# $
standard_testfile
@@ -62,7 +62,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_run_cmd
gdb_test "" "" "run program to completion"
diff --git a/gdb/testsuite/gdb.threads/leader-exit-attach.exp b/gdb/testsuite/gdb.threads/leader-exit-attach.exp
index 641d6b5..2df4a18 100644
--- a/gdb/testsuite/gdb.threads/leader-exit-attach.exp
+++ b/gdb/testsuite/gdb.threads/leader-exit-attach.exp
@@ -31,7 +31,7 @@ set testpid [spawn_id_get_pid $test_spawn_id]
# Wait a bit for the leader thread to exit, before attaching.
sleep 2
-clean_restart ${binfile}
+clean_restart ${::testfile}
# Save this early as we may not be able to talk with GDBserver anymore
# when we need to check it.
diff --git a/gdb/testsuite/gdb.threads/leader-exit.exp b/gdb/testsuite/gdb.threads/leader-exit.exp
index 1bc017b..85039b8 100644
--- a/gdb/testsuite/gdb.threads/leader-exit.exp
+++ b/gdb/testsuite/gdb.threads/leader-exit.exp
@@ -26,7 +26,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
clean_restart ${executable}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/linux-dp.exp b/gdb/testsuite/gdb.threads/linux-dp.exp
index 1652f78..c0ef9c7 100644
--- a/gdb/testsuite/gdb.threads/linux-dp.exp
+++ b/gdb/testsuite/gdb.threads/linux-dp.exp
@@ -44,7 +44,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_test_no_output "set print sevenbit-strings"
runto_main
@@ -117,7 +117,7 @@ for {set i 0} {$i < 5} {incr i} {
} else {
fail "create philosopher: $i"
}
-
+
set threads_after {}
gdb_test_multiple "info threads" "info threads after: $i" {
-re "info threads\r\n" {
@@ -172,7 +172,7 @@ for {set i 1} {$i < $nthreads} {incr i} {
append info_threads_ptn "$i *Thread .*"
}
append info_threads_ptn "\[\r\n\]+$gdb_prompt $"
-set info_threads_manager_ptn "[expr $nthreads + 1] *Thread .*$info_threads_ptn"
+set info_threads_manager_ptn "[expr {$nthreads + 1}] *Thread .*$info_threads_ptn"
gdb_test_multiple "info threads" "info threads 2" {
-re "$info_threads_manager_ptn" {
@@ -241,7 +241,7 @@ for {set i 0} {$only_five > 0 && $i < 10} {incr i} {
-re ".*$gdb_prompt $" {
set only_five 0
}
- timeout {
+ timeout {
set only_five -1
}
}
@@ -331,7 +331,7 @@ set any_interesting 0
catch {unset seen}
array set seen {}
for {set i 1} {$i <= $nthreads} {incr i} {
- if [check_philosopher_stack $i seen] {
+ if {[check_philosopher_stack $i seen]} {
set any_interesting 1
}
}
diff --git a/gdb/testsuite/gdb.threads/local-watch-wrong-thread.exp b/gdb/testsuite/gdb.threads/local-watch-wrong-thread.exp
index 3006b83..a63f0be 100644
--- a/gdb/testsuite/gdb.threads/local-watch-wrong-thread.exp
+++ b/gdb/testsuite/gdb.threads/local-watch-wrong-thread.exp
@@ -28,7 +28,7 @@ if {[gdb_compile_pthreads \
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_test_no_output "set can-use-hw-watchpoints 1" ""
diff --git a/gdb/testsuite/gdb.threads/main-thread-exit-during-detach.exp b/gdb/testsuite/gdb.threads/main-thread-exit-during-detach.exp
index 20e7bc4..1ce0194 100644
--- a/gdb/testsuite/gdb.threads/main-thread-exit-during-detach.exp
+++ b/gdb/testsuite/gdb.threads/main-thread-exit-during-detach.exp
@@ -50,7 +50,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile \
proc run_test { spawn_inferior } {
save_vars { ::GDBFLAGS } {
append ::GDBFLAGS " -ex \"set non-stop on\""
- clean_restart $::binfile
+ clean_restart $::testfile
}
# Setup the inferior. When complete the main thread (#1) will
diff --git a/gdb/testsuite/gdb.threads/manythreads.exp b/gdb/testsuite/gdb.threads/manythreads.exp
index ae51c5a..0a09897 100644
--- a/gdb/testsuite/gdb.threads/manythreads.exp
+++ b/gdb/testsuite/gdb.threads/manythreads.exp
@@ -22,7 +22,7 @@ require {!target_info exists gdb,nointerrupts}
standard_testfile
set opts { debug }
-if [info exists DEBUG] {
+if {[info exists DEBUG]} {
# make check RUNTESTFLAGS='gdb.threads/manythreads.exp DEBUG=1'
lappend opts "additional_flags=-DDEBUG"
}
@@ -31,7 +31,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_test_no_output "set print sevenbit-strings"
runto_main
diff --git a/gdb/testsuite/gdb.threads/multi-create-ns-info-thr.exp b/gdb/testsuite/gdb.threads/multi-create-ns-info-thr.exp
index 1c3231c..c42c1a9 100644
--- a/gdb/testsuite/gdb.threads/multi-create-ns-info-thr.exp
+++ b/gdb/testsuite/gdb.threads/multi-create-ns-info-thr.exp
@@ -25,7 +25,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}
gdb_test_no_output "set pagination off"
gdb_test_no_output "set non-stop on"
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/multi-create.exp b/gdb/testsuite/gdb.threads/multi-create.exp
index 966d44d..cb86aac 100644
--- a/gdb/testsuite/gdb.threads/multi-create.exp
+++ b/gdb/testsuite/gdb.threads/multi-create.exp
@@ -21,7 +21,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
runto_main
# Run to the beginning of create_function several times. Make sure
diff --git a/gdb/testsuite/gdb.threads/multiple-step-overs.exp b/gdb/testsuite/gdb.threads/multiple-step-overs.exp
index 84eef1a..c3456c2 100644
--- a/gdb/testsuite/gdb.threads/multiple-step-overs.exp
+++ b/gdb/testsuite/gdb.threads/multiple-step-overs.exp
@@ -35,7 +35,7 @@ proc setup {} {
with_test_prefix "setup" {
clean_restart $executable
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/multiple-successive-infcall.exp b/gdb/testsuite/gdb.threads/multiple-successive-infcall.exp
index 1aa9253..2694ce5 100644
--- a/gdb/testsuite/gdb.threads/multiple-successive-infcall.exp
+++ b/gdb/testsuite/gdb.threads/multiple-successive-infcall.exp
@@ -23,7 +23,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
return -1
}
-clean_restart "${binfile}"
+clean_restart "${::testfile}"
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.threads/names.exp b/gdb/testsuite/gdb.threads/names.exp
index 6f38c4e..808fa24 100644
--- a/gdb/testsuite/gdb.threads/names.exp
+++ b/gdb/testsuite/gdb.threads/names.exp
@@ -20,11 +20,11 @@ require {!target_info exists gdb,no_thread_names}
standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}]} {
return -1
}
-if ![runto "all_threads_ready"] {
+if {![runto "all_threads_ready"]} {
return
}
diff --git a/gdb/testsuite/gdb.threads/next-bp-other-thread.exp b/gdb/testsuite/gdb.threads/next-bp-other-thread.exp
index cf8d687..293b100 100644
--- a/gdb/testsuite/gdb.threads/next-bp-other-thread.exp
+++ b/gdb/testsuite/gdb.threads/next-bp-other-thread.exp
@@ -28,9 +28,9 @@ if {[build_executable "failed to prepare" $testfile $srcfile \
# Test all "set scheduler-locking" variants.
foreach schedlock {"off" "step" "on" } {
with_test_prefix "schedlock=$schedlock" {
- clean_restart $binfile
+ clean_restart $::testfile
- if ![runto_main] {
+ if {![runto_main]} {
continue
}
diff --git a/gdb/testsuite/gdb.threads/next-fork-exec-other-thread.exp b/gdb/testsuite/gdb.threads/next-fork-exec-other-thread.exp
index 3a97127..82e85a6 100644
--- a/gdb/testsuite/gdb.threads/next-fork-exec-other-thread.exp
+++ b/gdb/testsuite/gdb.threads/next-fork-exec-other-thread.exp
@@ -67,7 +67,7 @@ proc do_test { fork_func target-non-stop non-stop displaced-stepping } {
save_vars { ::GDBFLAGS } {
append ::GDBFLAGS " -ex \"maintenance set target-non-stop ${target-non-stop}\""
append ::GDBFLAGS " -ex \"set non-stop ${non-stop}\""
- clean_restart ${::binfile}-${fork_func}
+ clean_restart ${::testfile}-${fork_func}
}
gdb_test_no_output "set displaced-stepping ${displaced-stepping}"
diff --git a/gdb/testsuite/gdb.threads/next-fork-other-thread.exp b/gdb/testsuite/gdb.threads/next-fork-other-thread.exp
index 1cd6685..9349091 100644
--- a/gdb/testsuite/gdb.threads/next-fork-other-thread.exp
+++ b/gdb/testsuite/gdb.threads/next-fork-other-thread.exp
@@ -58,7 +58,7 @@ proc do_test { fork_func target-non-stop non-stop displaced-stepping } {
save_vars { ::GDBFLAGS } {
append ::GDBFLAGS " -ex \"maintenance set target-non-stop ${target-non-stop}\""
append ::GDBFLAGS " -ex \"set non-stop ${non-stop}\""
- clean_restart ${::binfile}-${fork_func}
+ clean_restart ${::testfile}-${fork_func}
}
gdb_test_no_output "set displaced-stepping ${displaced-stepping}"
diff --git a/gdb/testsuite/gdb.threads/no-unwaited-for-left.exp b/gdb/testsuite/gdb.threads/no-unwaited-for-left.exp
index edeabaf..96b5433 100644
--- a/gdb/testsuite/gdb.threads/no-unwaited-for-left.exp
+++ b/gdb/testsuite/gdb.threads/no-unwaited-for-left.exp
@@ -25,7 +25,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
clean_restart ${executable}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp
index 846fe89..7d2956d 100644
--- a/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp
+++ b/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp
@@ -31,7 +31,7 @@ proc do_test { lock_sched nonstop } {
clean_restart ${executable}
}
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp
index 860b6b5..bb66644 100644
--- a/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp
+++ b/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp
@@ -33,7 +33,7 @@ proc do_test { lock_sched nonstop } {
clean_restart ${executable}
}
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp
index b50bfac..4490b30 100644
--- a/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp
+++ b/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp
@@ -34,7 +34,7 @@ proc do_test { lock_sched nonstop } {
clean_restart ${executable}
}
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp
index 9892d83..533e14f 100644
--- a/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp
+++ b/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp
@@ -33,7 +33,7 @@ proc do_test { lock_sched nonstop } {
clean_restart ${executable}
}
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/non-ldr-exit.exp b/gdb/testsuite/gdb.threads/non-ldr-exit.exp
index b09a37e..4dd1b79 100644
--- a/gdb/testsuite/gdb.threads/non-ldr-exit.exp
+++ b/gdb/testsuite/gdb.threads/non-ldr-exit.exp
@@ -22,7 +22,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/non-stop-fair-events.exp b/gdb/testsuite/gdb.threads/non-stop-fair-events.exp
index 5def610..788a7e8 100644
--- a/gdb/testsuite/gdb.threads/non-stop-fair-events.exp
+++ b/gdb/testsuite/gdb.threads/non-stop-fair-events.exp
@@ -28,7 +28,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile $options] == -1}
gdb_test_no_output "set non-stop on"
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/omp-par-scope.exp b/gdb/testsuite/gdb.threads/omp-par-scope.exp
index 27dbaf0..2a097f5 100644
--- a/gdb/testsuite/gdb.threads/omp-par-scope.exp
+++ b/gdb/testsuite/gdb.threads/omp-par-scope.exp
@@ -30,7 +30,7 @@ if { [test_compiler_info "clang*"] } {
set have_nested_function_support 0
set opts {openmp debug}
-if [support_nested_function_tests] {
+if {[support_nested_function_tests]} {
lappend opts "additional_flags=-DHAVE_NESTED_FUNCTION_SUPPORT"
set have_nested_function_support 1
}
@@ -191,7 +191,7 @@ with_test_prefix "multi_scope" {
# Nested functions in C are a GNU extension, so only do the nested function
# tests if compiling with -DHAVE_NESTED_FUNCTION_SUPPORT was successful.
-if $have_nested_function_support {
+if {$have_nested_function_support} {
with_test_prefix "nested_func" {
gdb_breakpoint [gdb_get_line_number "nested_func: tn="]
diff --git a/gdb/testsuite/gdb.threads/pending-fork-event-detach-ns.exp b/gdb/testsuite/gdb.threads/pending-fork-event-detach-ns.exp
index 29a011e..9cc4978 100644
--- a/gdb/testsuite/gdb.threads/pending-fork-event-detach-ns.exp
+++ b/gdb/testsuite/gdb.threads/pending-fork-event-detach-ns.exp
@@ -52,7 +52,7 @@ proc do_test { } {
save_vars { ::GDBFLAGS } {
append ::GDBFLAGS " -ex \"set non-stop on\""
- clean_restart $::binfile
+ clean_restart $::testfile
}
if { ![runto break_here_first] } {
diff --git a/gdb/testsuite/gdb.threads/pending-fork-event-detach.exp b/gdb/testsuite/gdb.threads/pending-fork-event-detach.exp
index e627241..fa86488 100644
--- a/gdb/testsuite/gdb.threads/pending-fork-event-detach.exp
+++ b/gdb/testsuite/gdb.threads/pending-fork-event-detach.exp
@@ -93,7 +93,8 @@ proc do_test { target-non-stop who_forks fork_function stop_mode } {
save_vars { ::GDBFLAGS } {
append ::GDBFLAGS " -ex \"maintenance set target-non-stop ${target-non-stop}\""
- clean_restart $this_binfile
+ clean_restart
+ gdb_load $this_binfile
}
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.threads/pending-step.exp b/gdb/testsuite/gdb.threads/pending-step.exp
index 1c2422e..d31f879 100644
--- a/gdb/testsuite/gdb.threads/pending-step.exp
+++ b/gdb/testsuite/gdb.threads/pending-step.exp
@@ -54,7 +54,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.threads/print-threads.exp b/gdb/testsuite/gdb.threads/print-threads.exp
index 51a14b2..a3fcba3 100644
--- a/gdb/testsuite/gdb.threads/print-threads.exp
+++ b/gdb/testsuite/gdb.threads/print-threads.exp
@@ -32,7 +32,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
# Now we can proceed with the real testing.
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_test_no_output "set print sevenbit-strings"
#gdb_test_no_output "set print address off"
@@ -50,13 +50,13 @@ proc test_all_threads { name kill } {
set j 0
gdb_test_multiple "continue" "all threads ran once" {
-re "Breakpoint \[0-9\]+, thread_function \\(arg=.*\\) at .*print-threads.c:\[0-9\]+.*$gdb_prompt" {
- set i [expr $i + 1]
+ set i [expr {$i + 1}]
pass "hit thread_function breakpoint, $i"
send_gdb "continue\n"
exp_continue
}
-re "Breakpoint \[0-9\]+, .* kill \\(.*\\) .*$gdb_prompt" {
- set j [expr $j + 1]
+ set j [expr {$j + 1}]
if { $kill == 1 } {
pass "hit kill breakpoint, $j"
} else {
@@ -96,7 +96,7 @@ 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_no_output "set var slow = 1"
# Extend the timeout for slower tests.
-set timeout [expr $oldtimeout + 120]
+set timeout [expr {$oldtimeout + 120}]
test_all_threads "slow" 0
set timeout $oldtimeout
@@ -105,6 +105,6 @@ gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*p
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]
+set timeout [expr {$oldtimeout + 120}]
test_all_threads "slow with kill breakpoint" 1
set timeout $oldtimeout
diff --git a/gdb/testsuite/gdb.threads/process-dies-while-detaching.exp b/gdb/testsuite/gdb.threads/process-dies-while-detaching.exp
index 776c08e..63ddfec 100644
--- a/gdb/testsuite/gdb.threads/process-dies-while-detaching.exp
+++ b/gdb/testsuite/gdb.threads/process-dies-while-detaching.exp
@@ -43,6 +43,7 @@
# threads are reaped. We test that as well.
standard_testfile
+set testfile_base $testfile
# Test that GDBserver exits.
@@ -187,7 +188,7 @@ proc do_detach {multi_process cmd child_exit} {
perror "unhandled command: $cmd"
}
} else {
- if $is_remote {
+ if {$is_remote} {
set extra "\r\nEnding remote debugging\."
} else {
set extra ""
@@ -214,9 +215,9 @@ proc test_detach {multi_process cmd} {
with_test_prefix "detach" {
global binfile
- clean_restart ${binfile}
+ clean_restart ${::testfile}
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
@@ -242,9 +243,9 @@ proc test_detach_watch {wp multi_process cmd} {
with_test_prefix "watchpoint:$wp" {
global binfile decimal
- clean_restart ${binfile}
+ clean_restart ${::testfile}
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
@@ -290,9 +291,9 @@ proc test_detach_killed_outside {multi_process cmd} {
with_test_prefix "killed outside" {
global binfile
- clean_restart ${binfile}
+ clean_restart ${::testfile}
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
@@ -334,14 +335,15 @@ proc do_test {multi_process cmd} {
return
}
- set binfile [standard_output_file ${testfile}-$multi_process-$cmd]
+ set testfile $::testfile_base-$multi_process-$cmd
+ set binfile [standard_output_file $testfile]
set options {debug pthreads}
if {$multi_process} {
lappend options "additional_flags=-DMULTIPROCESS"
}
if {[build_executable "failed to build" \
- $testfile-$multi_process-$cmd $srcfile $options] == -1} {
+ $testfile $srcfile $options] == -1} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/process-dies-while-handling-bp.exp b/gdb/testsuite/gdb.threads/process-dies-while-handling-bp.exp
index 26dc8cc..a990dc9 100644
--- a/gdb/testsuite/gdb.threads/process-dies-while-handling-bp.exp
+++ b/gdb/testsuite/gdb.threads/process-dies-while-handling-bp.exp
@@ -42,7 +42,7 @@ proc do_test { non_stop cond_bp_target } {
save_vars { GDBFLAGS } {
set GDBFLAGS [concat $GDBFLAGS " -ex \"set non-stop $non_stop\""]
- clean_restart $binfile
+ clean_restart $::testfile
}
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.threads/pthread_cond_wait.exp b/gdb/testsuite/gdb.threads/pthread_cond_wait.exp
index c1be1cd..e11b904 100644
--- a/gdb/testsuite/gdb.threads/pthread_cond_wait.exp
+++ b/gdb/testsuite/gdb.threads/pthread_cond_wait.exp
@@ -17,7 +17,7 @@
# bug-gdb@gnu.org
# This file verifies that GDB is able to compute a backtrace for a thread
-# being blocked on a call to pthread_cond_wait().
+# being blocked on a call to pthread_cond_wait().
standard_testfile
@@ -25,7 +25,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
runto_main
gdb_test "break break_me" \
@@ -36,7 +36,7 @@ gdb_test "continue" \
".*Breakpoint 2, break_me ().*" \
"run to break_me"
-#
+#
# Backtrace all threads, find the one running noreturn, and
# verify that we are able to get a sensible backtrace, including
# the frame for the pthread_cond_wait() call.
diff --git a/gdb/testsuite/gdb.threads/pthreads.exp b/gdb/testsuite/gdb.threads/pthreads.exp
index 0437e74..04ae91e2 100644
--- a/gdb/testsuite/gdb.threads/pthreads.exp
+++ b/gdb/testsuite/gdb.threads/pthreads.exp
@@ -34,7 +34,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_test_no_output "set print sevenbit-strings"
#gdb_test_no_output "set print address off"
diff --git a/gdb/testsuite/gdb.threads/queue-signal.exp b/gdb/testsuite/gdb.threads/queue-signal.exp
index f791ffa..6ab8bbb 100644
--- a/gdb/testsuite/gdb.threads/queue-signal.exp
+++ b/gdb/testsuite/gdb.threads/queue-signal.exp
@@ -20,9 +20,9 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
-if ![runto_main] {
+if {![runto_main]} {
return 0
}
diff --git a/gdb/testsuite/gdb.threads/schedlock-new-thread.exp b/gdb/testsuite/gdb.threads/schedlock-new-thread.exp
index c398137..0937e2a 100644
--- a/gdb/testsuite/gdb.threads/schedlock-new-thread.exp
+++ b/gdb/testsuite/gdb.threads/schedlock-new-thread.exp
@@ -18,7 +18,7 @@
standard_testfile .c
foreach_with_prefix schedlock {off on} {
- set sl [expr $schedlock == "on" ? 1 : 0]
+ set sl [expr {$schedlock == "on" ? 1 : 0}]
if { [build_executable "failed to prepare" $testfile-$sl \
$srcfile \
[list debug pthreads additional_flags=-DSCHEDLOCK=$sl]] \
@@ -30,8 +30,8 @@ foreach_with_prefix schedlock {off on} {
proc test {non-stop schedlock} {
save_vars ::GDBFLAGS {
append ::GDBFLAGS " -ex \"set non-stop ${non-stop}\""
- set sl [expr $schedlock == "on" ? 1 : 0]
- clean_restart $::binfile-$sl
+ set sl [expr {$schedlock == "on" ? 1 : 0}]
+ clean_restart $::testfile-$sl
}
set linenum1 [gdb_get_line_number "set break 1 here"]
diff --git a/gdb/testsuite/gdb.threads/schedlock-thread-exit.exp b/gdb/testsuite/gdb.threads/schedlock-thread-exit.exp
index 434b058..137f652 100644
--- a/gdb/testsuite/gdb.threads/schedlock-thread-exit.exp
+++ b/gdb/testsuite/gdb.threads/schedlock-thread-exit.exp
@@ -28,7 +28,7 @@ if { [build_executable "failed to prepare" ${testfile} ${srcfile} \
}
proc do_test { } {
- clean_restart $::binfile
+ clean_restart $::testfile
# One of the launched threads will report a stop on thread_func. Some
# others will also stop on thread_func and have a pending status.
diff --git a/gdb/testsuite/gdb.threads/schedlock.exp b/gdb/testsuite/gdb.threads/schedlock.exp
index 4e2b835..1257868 100644
--- a/gdb/testsuite/gdb.threads/schedlock.exp
+++ b/gdb/testsuite/gdb.threads/schedlock.exp
@@ -41,7 +41,7 @@ proc get_args { description } {
global NUM
set pattern "(\[0-9\]+)"
- for {set i 1} {[expr $i < $NUM]} {incr i} {
+ for {set i 1} {$i < $NUM} {incr i} {
append pattern ", (\[0-9\]+)"
}
@@ -51,7 +51,7 @@ proc get_args { description } {
pass $test
set result ""
- for {set i 1} {[expr $i <= $NUM]} {incr i} {
+ for {set i 1} {[expr {$i <= $NUM}]} {incr i} {
lappend result $expect_out($i,string)
}
return $result
@@ -122,7 +122,7 @@ proc my_continue { msg } {
proc step_ten_loops { cmd } {
global gdb_prompt
- for {set i 0} {[expr $i < 10]} {set i [expr $i + 1]} {
+ for {set i 0} {$i < 10} {incr i} {
set other_step 0
set test "$cmd to increment, $i"
gdb_test_multiple $cmd $test {
@@ -183,7 +183,7 @@ my_continue "initial"
set cont_args [get_args "after initial"]
set bad 0
-for {set i 0} {[expr $i < $NUM]} {set i [expr $i + 1]} {
+for {set i 0} {$i < $NUM} {incr i} {
if {[lindex $start_args $i] == [lindex $cont_args $i]} {
incr bad
}
@@ -233,7 +233,7 @@ proc check_result { cmd before_thread before_args locked } {
} else {
if {$i == $before_thread} {
if {$cmd == "continue"
- || [lindex $before_args $i] == [expr [lindex $after_args $i] - 10]} {
+ || [lindex $before_args $i] == [lindex $after_args $i] - 10} {
pass "$test"
} else {
fail "$test (wrong amount)"
diff --git a/gdb/testsuite/gdb.threads/siginfo-threads.exp b/gdb/testsuite/gdb.threads/siginfo-threads.exp
index ecc372d..253c4c0 100644
--- a/gdb/testsuite/gdb.threads/siginfo-threads.exp
+++ b/gdb/testsuite/gdb.threads/siginfo-threads.exp
@@ -25,7 +25,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" \
clean_restart $testfile
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/signal-command-handle-nopass.exp b/gdb/testsuite/gdb.threads/signal-command-handle-nopass.exp
index 2586800..6d344e3 100644
--- a/gdb/testsuite/gdb.threads/signal-command-handle-nopass.exp
+++ b/gdb/testsuite/gdb.threads/signal-command-handle-nopass.exp
@@ -35,7 +35,7 @@ proc test { step_over } {
global srcfile binfile tdlabel_re
with_test_prefix "step-over $step_over" {
- clean_restart ${binfile}
+ clean_restart ${::testfile}
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.threads/signal-command-multiple-signals-pending.exp b/gdb/testsuite/gdb.threads/signal-command-multiple-signals-pending.exp
index 73f88c1..acb018b 100644
--- a/gdb/testsuite/gdb.threads/signal-command-multiple-signals-pending.exp
+++ b/gdb/testsuite/gdb.threads/signal-command-multiple-signals-pending.exp
@@ -32,7 +32,7 @@ proc test { schedlock } {
global srcfile binfile tdlabel_re
with_test_prefix "schedlock $schedlock" {
- clean_restart ${binfile}
+ clean_restart ${::testfile}
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.threads/signal-delivered-right-thread.exp b/gdb/testsuite/gdb.threads/signal-delivered-right-thread.exp
index 7445cad..9de0908 100644
--- a/gdb/testsuite/gdb.threads/signal-delivered-right-thread.exp
+++ b/gdb/testsuite/gdb.threads/signal-delivered-right-thread.exp
@@ -29,7 +29,7 @@ proc test { command } {
global srcfile binfile tdlabel_re
with_test_prefix "$command" {
- clean_restart ${binfile}
+ clean_restart ${::testfile}
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.threads/signal-sigtrap.exp b/gdb/testsuite/gdb.threads/signal-sigtrap.exp
index 8154ddf..849d628 100644
--- a/gdb/testsuite/gdb.threads/signal-sigtrap.exp
+++ b/gdb/testsuite/gdb.threads/signal-sigtrap.exp
@@ -32,7 +32,7 @@ proc test { sigtrap_thread } {
global srcfile binfile tdlabel_re
with_test_prefix "sigtrap thread $sigtrap_thread" {
- clean_restart ${binfile}
+ clean_restart ${::testfile}
if {![runto "thread_function"]} {
return 0
diff --git a/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp b/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp
index e2f7581..b7a110d 100644
--- a/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp
+++ b/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp
@@ -51,7 +51,7 @@ proc get_value {var test} {
clean_restart $executable
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/sigstep-threads.exp b/gdb/testsuite/gdb.threads/sigstep-threads.exp
index 0580cd0..9aed9e3 100644
--- a/gdb/testsuite/gdb.threads/sigstep-threads.exp
+++ b/gdb/testsuite/gdb.threads/sigstep-threads.exp
@@ -23,7 +23,7 @@ if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executa
clean_restart $executable
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
@@ -65,7 +65,7 @@ for {set i 0} {$i < 100} {incr i} {
set step_at $now
}
}
- if $failed {
+ if {$failed} {
return
}
}
diff --git a/gdb/testsuite/gdb.threads/sigthread.exp b/gdb/testsuite/gdb.threads/sigthread.exp
index 9d2f9b5..dea8eb8 100644
--- a/gdb/testsuite/gdb.threads/sigthread.exp
+++ b/gdb/testsuite/gdb.threads/sigthread.exp
@@ -24,7 +24,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.threads/staticthreads.exp b/gdb/testsuite/gdb.threads/staticthreads.exp
index 0374666..44cc686 100644
--- a/gdb/testsuite/gdb.threads/staticthreads.exp
+++ b/gdb/testsuite/gdb.threads/staticthreads.exp
@@ -34,7 +34,7 @@ foreach_with_prefix have_tls { "-DHAVE_TLS" "" } {
}
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_test_no_output "set print sevenbit-strings"
@@ -51,7 +51,7 @@ gdb_test_multiple "continue" "$test" {
kfail gdb/1328 "$test"
}
}
-
+
# See if handle SIG32 helps (a little) with a static multi-threaded
# program.
@@ -59,7 +59,7 @@ gdb_test_multiple "continue" "$test" {
set sig "SIG32"
# SIGRTMIN is 37 on hppa-linux
-if [istarget hppa*-*-*] {
+if {[istarget hppa*-*-*]} {
set sig "SIG37"
}
@@ -94,11 +94,11 @@ gdb_test_multiple "quit" "$test" {
pass "$test"
}
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if { "$have_tls" != "" } {
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
gdb_breakpoint [gdb_get_line_number "tlsvar-is-set"]
diff --git a/gdb/testsuite/gdb.threads/step-N-all-progress.exp b/gdb/testsuite/gdb.threads/step-N-all-progress.exp
index c874d79..031e36a 100644
--- a/gdb/testsuite/gdb.threads/step-N-all-progress.exp
+++ b/gdb/testsuite/gdb.threads/step-N-all-progress.exp
@@ -31,7 +31,7 @@ proc test {non-stop target-non-stop} {
save_vars ::GDBFLAGS {
append ::GDBFLAGS " -ex \"maintenance set target-non-stop ${target-non-stop}\""
append ::GDBFLAGS " -ex \"set non-stop ${non-stop}\""
- clean_restart $::binfile
+ clean_restart $::testfile
}
if { ![runto_main] } {
diff --git a/gdb/testsuite/gdb.threads/step-bg-decr-pc-switch-thread.exp b/gdb/testsuite/gdb.threads/step-bg-decr-pc-switch-thread.exp
index 309c826..82861a9 100644
--- a/gdb/testsuite/gdb.threads/step-bg-decr-pc-switch-thread.exp
+++ b/gdb/testsuite/gdb.threads/step-bg-decr-pc-switch-thread.exp
@@ -34,7 +34,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return
}
@@ -55,7 +55,7 @@ gdb_test_no_output "next&" "next& over inf loop"
set test "switch to main thread"
gdb_test_multiple "thread 1" $test {
-re "Cannot execute this command while the target is running.*$gdb_prompt $" {
-
+
# With remote targets, we can't send any other remote packet
# until the target stops. Switching thread wants to ask the
# remote side whether the thread is alive.
diff --git a/gdb/testsuite/gdb.threads/step-over-exec.exp b/gdb/testsuite/gdb.threads/step-over-exec.exp
index 7c553f2..22b9a13 100644
--- a/gdb/testsuite/gdb.threads/step-over-exec.exp
+++ b/gdb/testsuite/gdb.threads/step-over-exec.exp
@@ -71,11 +71,12 @@ proc do_test { execr_thread different_text_segments displaced_stepping } {
return -1
}
- clean_restart ${execr_binfile}
+ clean_restart
+ gdb_load $execr_binfile
gdb_test_no_output "set displaced-stepping $displaced_stepping"
- if ![runto_main] {
+ if {![runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.threads/step-over-lands-on-breakpoint.exp b/gdb/testsuite/gdb.threads/step-over-lands-on-breakpoint.exp
index 65aa2f1..3a96e0e 100644
--- a/gdb/testsuite/gdb.threads/step-over-lands-on-breakpoint.exp
+++ b/gdb/testsuite/gdb.threads/step-over-lands-on-breakpoint.exp
@@ -32,7 +32,7 @@ proc do_test {displaced command} {
with_test_prefix "displaced=$displaced: $command" {
clean_restart $executable
- if ![runto_main] {
+ if {![runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.threads/step-over-thread-exit-while-stop-all-threads.exp b/gdb/testsuite/gdb.threads/step-over-thread-exit-while-stop-all-threads.exp
index cf10bdc..fdd2b27 100644
--- a/gdb/testsuite/gdb.threads/step-over-thread-exit-while-stop-all-threads.exp
+++ b/gdb/testsuite/gdb.threads/step-over-thread-exit-while-stop-all-threads.exp
@@ -29,7 +29,7 @@ if { [build_executable "failed to prepare" $testfile \
proc test {displaced-stepping target-non-stop} {
save_vars ::GDBFLAGS {
append ::GDBFLAGS " -ex \"maintenance set target-non-stop ${target-non-stop}\""
- clean_restart $::binfile
+ clean_restart $::testfile
}
gdb_test_no_output "set displaced-stepping ${displaced-stepping}"
diff --git a/gdb/testsuite/gdb.threads/step-over-thread-exit.exp b/gdb/testsuite/gdb.threads/step-over-thread-exit.exp
index 31037a7..8ed2b21 100644
--- a/gdb/testsuite/gdb.threads/step-over-thread-exit.exp
+++ b/gdb/testsuite/gdb.threads/step-over-thread-exit.exp
@@ -55,7 +55,7 @@ proc test {step_over_mode non-stop target-non-stop schedlock cmd ns_stop_all} {
save_vars ::GDBFLAGS {
append ::GDBFLAGS " -ex \"maintenance set target-non-stop ${target-non-stop}\""
append ::GDBFLAGS " -ex \"set non-stop ${non-stop}\""
- clean_restart $::binfile
+ clean_restart $::testfile
}
if { $step_over_mode == "none" } {
diff --git a/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.exp b/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.exp
index 9a028fe..0e99656 100644
--- a/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.exp
+++ b/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.exp
@@ -38,7 +38,7 @@ proc do_test { displaced with_bp } {
global gdb_prompt
global hex
- if ${with_bp} {
+ if {${with_bp}} {
set prefix "with thread-specific bp"
} else {
set prefix "no thread-specific bp"
@@ -49,7 +49,7 @@ proc do_test { displaced with_bp } {
with_test_prefix $command {
clean_restart $executable
- if ![runto_main] {
+ if {![runto_main]} {
continue
}
@@ -106,7 +106,7 @@ proc do_test { displaced with_bp } {
gdb_test "p watch_me = 0" " = 0" "clear watch_me"
gdb_test "watch watch_me" "Hardware watchpoint .*"
- if ${with_bp} {
+ if {${with_bp}} {
gdb_test "b *$after_address_triggers_watch thread 1" \
"Breakpoint .*" \
"set breakpoint specific to thread 1"
diff --git a/gdb/testsuite/gdb.threads/stepi-over-clone.exp b/gdb/testsuite/gdb.threads/stepi-over-clone.exp
index 5da123e..e0b14cb 100644
--- a/gdb/testsuite/gdb.threads/stepi-over-clone.exp
+++ b/gdb/testsuite/gdb.threads/stepi-over-clone.exp
@@ -58,8 +58,8 @@ gdb_test "continue" \
# Return true if INSN is a syscall instruction.
proc is_syscall_insn { insn } {
- if [istarget x86_64-*-* ] {
- return { $insn == "syscall" }
+ if {[istarget x86_64-*-* ]} {
+ return [string equal $insn "syscall"]
} else {
error "port me"
}
@@ -76,7 +76,7 @@ gdb_test_multiple "disassemble" "" {
-re "^(?:=>)?\\s+(${hex})\\s+<\\+${decimal}>:\\s+(\[^\r\n\]+)\r\n" {
set addr $expect_out(1,string)
set insn [string trim $expect_out(2,string)]
- if [is_syscall_insn $insn] {
+ if {[is_syscall_insn $insn]} {
verbose -log "Found a syscall at: $addr"
lappend syscall_addrs $addr
}
@@ -106,7 +106,7 @@ proc test {non_stop displaced third_thread} {
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"set non-stop $non_stop\""
append GDBFLAGS " -ex \"set displaced $displaced\""
- clean_restart $binfile
+ clean_restart $::testfile
}
runto_main
diff --git a/gdb/testsuite/gdb.threads/stepi-random-signal.exp b/gdb/testsuite/gdb.threads/stepi-random-signal.exp
index 8ac81e8..a2d7743 100644
--- a/gdb/testsuite/gdb.threads/stepi-random-signal.exp
+++ b/gdb/testsuite/gdb.threads/stepi-random-signal.exp
@@ -31,7 +31,7 @@ if { [gdb_compile_pthreads \
clean_restart $executable
# Start the second thread.
-if ![runto start] {
+if {![runto start]} {
return -1
}
diff --git a/gdb/testsuite/gdb.threads/switch-threads.exp b/gdb/testsuite/gdb.threads/switch-threads.exp
index d43603c..1f67a45 100644
--- a/gdb/testsuite/gdb.threads/switch-threads.exp
+++ b/gdb/testsuite/gdb.threads/switch-threads.exp
@@ -29,7 +29,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
runto_main
diff --git a/gdb/testsuite/gdb.threads/thread-bp-deleted.exp b/gdb/testsuite/gdb.threads/thread-bp-deleted.exp
index 8cabb70..19b5001 100644
--- a/gdb/testsuite/gdb.threads/thread-bp-deleted.exp
+++ b/gdb/testsuite/gdb.threads/thread-bp-deleted.exp
@@ -31,14 +31,15 @@ if {[build_executable "failed to prepare" $testfile $srcfile \
# We need to do things a little differently when using the remote protocol.
set is_remote \
- [expr [target_info exists gdb_protocol] \
- && ([string equal [target_info gdb_protocol] "remote"] \
- || [string equal [target_info gdb_protocol] "extended-remote"])]
+ [expr \
+ {[target_info exists gdb_protocol]
+ && ([string equal [target_info gdb_protocol] "remote"]
+ || [string equal [target_info gdb_protocol] "extended-remote"])}]
# This test requires background execution, which relies on non-stop mode.
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"maint set target-non-stop on\""
- clean_restart ${binfile}
+ clean_restart ${::testfile}
}
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.threads/thread-execl.exp b/gdb/testsuite/gdb.threads/thread-execl.exp
index 04ba518..d1c80df 100644
--- a/gdb/testsuite/gdb.threads/thread-execl.exp
+++ b/gdb/testsuite/gdb.threads/thread-execl.exp
@@ -35,13 +35,13 @@ proc do_test { schedlock } {
set prefix "schedlock $schedlock"
}
with_test_prefix "$prefix" {
- clean_restart ${binfile}
+ clean_restart ${::testfile}
if {$schedlock == "non-stop"} {
gdb_test_no_output "set non-stop 1"
}
- if ![runto_main] {
+ if {![runto_main]} {
return 0
}
diff --git a/gdb/testsuite/gdb.threads/thread-find.exp b/gdb/testsuite/gdb.threads/thread-find.exp
index 456f7d3..171b94b 100644
--- a/gdb/testsuite/gdb.threads/thread-find.exp
+++ b/gdb/testsuite/gdb.threads/thread-find.exp
@@ -21,7 +21,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_test_no_output "set print sevenbit-strings"
runto_main
diff --git a/gdb/testsuite/gdb.threads/thread-specific-bp.exp b/gdb/testsuite/gdb.threads/thread-specific-bp.exp
index c4858f2..8f48b61 100644
--- a/gdb/testsuite/gdb.threads/thread-specific-bp.exp
+++ b/gdb/testsuite/gdb.threads/thread-specific-bp.exp
@@ -118,7 +118,7 @@ proc check_thread_specific_breakpoint {non_stop} {
foreach_with_prefix non_stop {on off} {
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"set non-stop $non_stop\""
- clean_restart $binfile
+ clean_restart $::testfile
}
check_thread_specific_breakpoint $non_stop
diff --git a/gdb/testsuite/gdb.threads/thread-specific.exp b/gdb/testsuite/gdb.threads/thread-specific.exp
index bf9c63b..d1e6f4d 100644
--- a/gdb/testsuite/gdb.threads/thread-specific.exp
+++ b/gdb/testsuite/gdb.threads/thread-specific.exp
@@ -62,7 +62,7 @@ proc get_thread_list { } {
return $thr_list
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_test_no_output "set print sevenbit-strings"
gdb_test_no_output "set width 0"
diff --git a/gdb/testsuite/gdb.threads/thread-unwindonsignal.exp b/gdb/testsuite/gdb.threads/thread-unwindonsignal.exp
index 5f4ac1f..dc74714 100644
--- a/gdb/testsuite/gdb.threads/thread-unwindonsignal.exp
+++ b/gdb/testsuite/gdb.threads/thread-unwindonsignal.exp
@@ -28,7 +28,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if { ![runto_main] } {
return 0
diff --git a/gdb/testsuite/gdb.threads/thread_check.exp b/gdb/testsuite/gdb.threads/thread_check.exp
index ee5f35a..6378e8a 100644
--- a/gdb/testsuite/gdb.threads/thread_check.exp
+++ b/gdb/testsuite/gdb.threads/thread_check.exp
@@ -15,16 +15,16 @@
# This file was written by Manoj Iyer. (manjo@austin.ibm.com)
# Test break points and single step on thread functions.
-#
+#
# Test Purpose:
-# - Test that breakpoints, continue in a threaded application works.
+# - Test that breakpoints, continue in a threaded application works.
# On powerpc64-unknown-linux-gnu system, running kernel version
# 2.6.5-7.71-pseries64 this test is known to fail due to kernel bug
# in ptrace system call.
#
# Test Strategy:
# - thread_check.c creates 2 threads
-# - start gdb
+# - start gdb
# - create 2 breakpoints #1 main() #2 tf() (the thread function)
# - run gdb till #1 main() breakpoint is reached
# - continue to breakpoint #2 tf()
@@ -39,7 +39,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return 1
@@ -62,7 +62,7 @@ gdb_test "continue" \
".*Breakpoint 2,.*tf.*at.*$srcfile:.*" \
"continue to tf"
-#
+#
# backtrace from thread function.
#
gdb_test "backtrace" \
diff --git a/gdb/testsuite/gdb.threads/threadapply.exp b/gdb/testsuite/gdb.threads/threadapply.exp
index 9110617..de264b6 100644
--- a/gdb/testsuite/gdb.threads/threadapply.exp
+++ b/gdb/testsuite/gdb.threads/threadapply.exp
@@ -25,7 +25,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
#
# Run to `main' where we begin our tests.
@@ -60,7 +60,7 @@ gdb_test "thread apply all backthread" "Thread ..*\\\$\[0-9]+ = 0x14.*Thread ..*
# Go into the thread_function to check that a simple "thread apply"
# does not change the selected frame.
gdb_test "step" "thread_function.*" "step to the thread_function"
-gdb_test "up" ".*in main.*" "go up in the stack frame"
+gdb_test "up" ".*in main.*" "go up in the stack frame"
gdb_test "thread apply all print 1" "Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1" "run a simple print command on all threads"
gdb_test "down" "#0.*thread_function.*" "go down and check selected frame"
@@ -73,9 +73,9 @@ proc thr_apply_detach {thread_set} {
global binfile
global break_line
- clean_restart ${binfile}
+ clean_restart ${::testfile}
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
@@ -104,7 +104,7 @@ proc kill_and_remove_inferior {thread_set} {
# The test starts multiple inferiors, therefore non-extended
# remote is not supported.
- if [use_gdb_stub] {
+ if {[use_gdb_stub]} {
unsupported "using gdb stub"
return
}
@@ -112,7 +112,7 @@ proc kill_and_remove_inferior {thread_set} {
set any "\[^\r\n\]*"
set ws "\[ \t\]\+"
- clean_restart ${binfile}
+ clean_restart ${::testfile}
with_test_prefix "start inferior 1" {
runto_main
diff --git a/gdb/testsuite/gdb.threads/threadcrash.exp b/gdb/testsuite/gdb.threads/threadcrash.exp
index 15d2a20..d57f437 100644
--- a/gdb/testsuite/gdb.threads/threadcrash.exp
+++ b/gdb/testsuite/gdb.threads/threadcrash.exp
@@ -132,8 +132,9 @@ proc do_full_test {} {
set pthread_kill ".*"
}
- for {set i 0} {$i < $thread_count } {incr i} {
- set thread_num [expr [llength $test_list] - $i]
+ set loop_iterations [llength $test_list]
+ for {set i 0} {$i < $loop_iterations } {incr i} {
+ set thread_num [expr {$loop_iterations - $i}]
set type [lindex $test_list $i]
if { $type == 1 } {
@@ -237,7 +238,7 @@ proc_with_prefix test_corefile {} {
proc_with_prefix test_gcore {} {
- clean_restart "$::binfile"
+ clean_restart "$::testfile"
gdb_test "handle SIGUSR1 nostop print pass" \
".*SIGUSR1.*No.*Yes.*Yes.*User defined signal 1" \
@@ -270,12 +271,12 @@ proc_with_prefix test_gcore {} {
standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile $srcfile \
- {debug pthreads}] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile \
+ {debug pthreads}]} {
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_test_no_output "set backtrace limit unlimited"
diff --git a/gdb/testsuite/gdb.threads/threads-after-exec.exp b/gdb/testsuite/gdb.threads/threads-after-exec.exp
index db26315..a6a3fb7 100644
--- a/gdb/testsuite/gdb.threads/threads-after-exec.exp
+++ b/gdb/testsuite/gdb.threads/threads-after-exec.exp
@@ -19,11 +19,11 @@
standard_testfile .c
proc do_test { } {
- if [prepare_for_testing "failed to prepare" $::testfile $::srcfile {debug pthreads}] {
+ if {[prepare_for_testing "failed to prepare" $::testfile $::srcfile {debug pthreads}]} {
return -1
}
- if ![runto_main] {
+ if {![runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.threads/threxit-hop-specific.exp b/gdb/testsuite/gdb.threads/threxit-hop-specific.exp
index ce2df7c..b55e80c 100644
--- a/gdb/testsuite/gdb.threads/threxit-hop-specific.exp
+++ b/gdb/testsuite/gdb.threads/threxit-hop-specific.exp
@@ -23,7 +23,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
runto_main
diff --git a/gdb/testsuite/gdb.threads/tid-reuse.exp b/gdb/testsuite/gdb.threads/tid-reuse.exp
index 6762127..ca5edc1 100644
--- a/gdb/testsuite/gdb.threads/tid-reuse.exp
+++ b/gdb/testsuite/gdb.threads/tid-reuse.exp
@@ -22,7 +22,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile { debug pthreads
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
@@ -72,6 +72,6 @@ delete_breakpoints
gdb_breakpoint "after_reuse_time"
# Higher than what the test program sleeps before exiting.
-set timeout [expr $reuse_time * 2]
+set timeout [expr {$reuse_time * 2}]
gdb_continue_to_breakpoint "after_reuse_time"
diff --git a/gdb/testsuite/gdb.threads/tls-core.exp b/gdb/testsuite/gdb.threads/tls-core.exp
index 96b1c6a..587ae61 100644
--- a/gdb/testsuite/gdb.threads/tls-core.exp
+++ b/gdb/testsuite/gdb.threads/tls-core.exp
@@ -27,7 +27,7 @@ set core_supported [expr {$corefile != ""}]
# Generate a core file with "gcore".
-clean_restart ${binfile}
+clean_restart ${::testfile}
runto thread_proc
@@ -43,7 +43,7 @@ proc tls_core_test {supported corefile} {
upvar host_triplet host_triplet
upvar binfile binfile
- clean_restart ${binfile}
+ clean_restart ${::testfile}
set test "load core file"
if {$supported} {
diff --git a/gdb/testsuite/gdb.threads/tls-nodebug-pie.exp b/gdb/testsuite/gdb.threads/tls-nodebug-pie.exp
index 01abcfa..44c12f5 100644
--- a/gdb/testsuite/gdb.threads/tls-nodebug-pie.exp
+++ b/gdb/testsuite/gdb.threads/tls-nodebug-pie.exp
@@ -20,7 +20,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return 0
}
diff --git a/gdb/testsuite/gdb.threads/tls-nodebug.exp b/gdb/testsuite/gdb.threads/tls-nodebug.exp
index ebfa752..971f26c 100644
--- a/gdb/testsuite/gdb.threads/tls-nodebug.exp
+++ b/gdb/testsuite/gdb.threads/tls-nodebug.exp
@@ -26,7 +26,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return 0
}
diff --git a/gdb/testsuite/gdb.threads/tls-sepdebug.exp b/gdb/testsuite/gdb.threads/tls-sepdebug.exp
index 6f3c711..fb684c9 100644
--- a/gdb/testsuite/gdb.threads/tls-sepdebug.exp
+++ b/gdb/testsuite/gdb.threads/tls-sepdebug.exp
@@ -83,7 +83,7 @@ foreach library_path [list $absdir [relative_filename [pwd] $absdir]] \
gdb_load ${binmainfile}
- if ![runto_main] {
+ if {![runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.threads/tls-shared.exp b/gdb/testsuite/gdb.threads/tls-shared.exp
index 35596bc..66dd52f 100644
--- a/gdb/testsuite/gdb.threads/tls-shared.exp
+++ b/gdb/testsuite/gdb.threads/tls-shared.exp
@@ -29,7 +29,7 @@ if { [gdb_compile_shlib_pthreads ${srcdir}/${subdir}/${srcfile_lib} ${binfile_li
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_load_shlib ${binfile_lib}
if {![runto_main]} {
@@ -52,6 +52,6 @@ gdb_test "break $line_number" \
gdb_test "continue" \
"main .* at .*:.*return 0.*break here to check result.*" \
"continue to break"
-# This is more of a gcc/glibc test, really.
+# This is more of a gcc/glibc test, really.
#
gdb_test "print result" "3"
diff --git a/gdb/testsuite/gdb.threads/tls-so_extern.exp b/gdb/testsuite/gdb.threads/tls-so_extern.exp
index 3cef672..a0aa5f8 100644
--- a/gdb/testsuite/gdb.threads/tls-so_extern.exp
+++ b/gdb/testsuite/gdb.threads/tls-so_extern.exp
@@ -28,7 +28,7 @@ if { [gdb_compile_shlib_pthreads ${srcdir}/${subdir}/${srcfile_lib} ${binfile_li
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_load_shlib ${binfile_lib}
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.threads/tls-var.exp b/gdb/testsuite/gdb.threads/tls-var.exp
index de74bd9..8d8b82e 100644
--- a/gdb/testsuite/gdb.threads/tls-var.exp
+++ b/gdb/testsuite/gdb.threads/tls-var.exp
@@ -27,7 +27,7 @@ if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${objfile} object {debug}] != "
clean_restart ${executable}
-if ![runto_main] {
+if {![runto_main]} {
return 0
}
diff --git a/gdb/testsuite/gdb.threads/tls.exp b/gdb/testsuite/gdb.threads/tls.exp
index 73fada7..3dbc802 100644
--- a/gdb/testsuite/gdb.threads/tls.exp
+++ b/gdb/testsuite/gdb.threads/tls.exp
@@ -56,7 +56,7 @@ proc get_me_variable {tnum} {
fail "$tnum thread print me"
}
timeout {
- fail "$tnum thread print me (timeout)"
+ fail "$tnum thread print me (timeout)"
}
}
return ${value_of_me}
@@ -116,8 +116,8 @@ proc select_thread {thread} {
### Do a backtrace for the current thread, and check that the 'spin' routine
### is in it. This means we have one of the threads we created, rather
-### than the main thread. Record the thread in the spin_threads
-### array. Also remember the level of the 'spin' routine in the backtrace, for
+### than the main thread. Record the thread in the spin_threads
+### array. Also remember the level of the 'spin' routine in the backtrace, for
### later use.
proc check_thread_stack {number spin_threads spin_threads_level} {
global gdb_prompt
@@ -148,12 +148,12 @@ proc check_thread_stack {number spin_threads spin_threads_level} {
pass "backtrace of thread number $number not relevant"
}
timeout {
- fail "backtrace of thread number $number (timeout)"
+ fail "backtrace of thread number $number (timeout)"
}
}
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_test_multiple "print a_thread_local" "" {
-re -wrap "Cannot find thread-local variables on this target" {
@@ -169,7 +169,7 @@ if {![runto_main]} {
}
# Set a breakpoint at the "spin" routine to
-# test the thread local's value.
+# test the thread local's value.
#
gdb_test "b [gdb_get_line_number "here we know tls value"]" \
".*Breakpoint 2.*tls.*" "set breakpoint at all threads"
@@ -247,7 +247,7 @@ array set spin_threads_level {}
unset spin_threads_level
# For each thread check its backtrace to see if it is stopped at the
-# spin routine.
+# spin routine.
for {set i 1} {$i <= $no_of_threads} {incr i} {
check_thread_stack $i spin_threads spin_threads_level
}
@@ -268,7 +268,7 @@ foreach i [array names spin_threads] {
# any intermediate point in spin, too, but that is much less
# likely.
gdb_test "up $level" ".*spin.*sem_(wait|post).*" "thread $i up"
- check_thread_local $i
+ check_thread_local $i
}
}
@@ -278,7 +278,7 @@ if {$thrs_in_spin == 0} {
gdb_test "continue" ".*Breakpoint 4.*before exit.*" "threads exited"
-send_gdb "info thread\n"
+send_gdb "info thread\n"
gdb_expect {
-re ".* 1 *${tdlabel_re}.*2 *${tdlabel_re}.*$gdb_prompt $" {
fail "too many threads left at end"
diff --git a/gdb/testsuite/gdb.threads/vfork-follow-child-exec.exp b/gdb/testsuite/gdb.threads/vfork-follow-child-exec.exp
index 0b95a75..7c2b309 100644
--- a/gdb/testsuite/gdb.threads/vfork-follow-child-exec.exp
+++ b/gdb/testsuite/gdb.threads/vfork-follow-child-exec.exp
@@ -30,7 +30,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile {debug pthreads}]}
proc test_vfork {detach} {
global binfile
- clean_restart $binfile
+ clean_restart $::testfile
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.threads/vfork-follow-child-exit.exp b/gdb/testsuite/gdb.threads/vfork-follow-child-exit.exp
index ced52df..a5e7475 100644
--- a/gdb/testsuite/gdb.threads/vfork-follow-child-exit.exp
+++ b/gdb/testsuite/gdb.threads/vfork-follow-child-exit.exp
@@ -30,7 +30,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile {debug pthreads}]}
proc test_vfork {detach} {
global binfile
- clean_restart $binfile
+ clean_restart $::testfile
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.threads/vfork-multi-thread.exp b/gdb/testsuite/gdb.threads/vfork-multi-thread.exp
index 61811ae..fce974b 100644
--- a/gdb/testsuite/gdb.threads/vfork-multi-thread.exp
+++ b/gdb/testsuite/gdb.threads/vfork-multi-thread.exp
@@ -59,7 +59,7 @@ proc do_test { target-non-stop non-stop follow-fork-mode detach-on-fork schedule
save_vars { ::GDBFLAGS } {
append ::GDBFLAGS " -ex \"maintenance set target-non-stop ${target-non-stop}\""
append ::GDBFLAGS " -ex \"set non-stop ${non-stop}\""
- clean_restart ${::binfile}
+ clean_restart ${::testfile}
}
gdb_test_no_output "set follow-fork-mode ${follow-fork-mode}"
diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork.exp b/gdb/testsuite/gdb.threads/watchpoint-fork.exp
index 8e9b1c3..68fc99e 100644
--- a/gdb/testsuite/gdb.threads/watchpoint-fork.exp
+++ b/gdb/testsuite/gdb.threads/watchpoint-fork.exp
@@ -69,7 +69,7 @@ proc test {type symbol} {
# Testcase uses it for the `follow-fork-mode child' type.
gdb_test "handle SIGUSR1 nostop noprint pass" "No\[ \t\]+No\[ \t\]+Yes.*"
- if ![runto_main] {
+ if {![runto_main]} {
return
}
@@ -126,7 +126,7 @@ proc test {type symbol} {
# Testcase uses it for the `follow-fork-mode child' type.
gdb_test "handle SIGUSR1 nostop noprint pass" "No\[ \t\]+No\[ \t\]+Yes.*"
- if ![runto_main] {
+ if {![runto_main]} {
return
}
@@ -165,7 +165,7 @@ proc test {type symbol} {
test parent FOLLOW_PARENT
# Only GNU/Linux is known to support `set follow-fork-mode child'.
-if [istarget "*-*-linux*"] {
+if {[istarget "*-*-linux*"]} {
test child FOLLOW_CHILD
} else {
untested "${testfile}: child"
diff --git a/gdb/testsuite/gdb.threads/watchthreads-reorder.exp b/gdb/testsuite/gdb.threads/watchthreads-reorder.exp
index 5d98913..067986a 100644
--- a/gdb/testsuite/gdb.threads/watchthreads-reorder.exp
+++ b/gdb/testsuite/gdb.threads/watchthreads-reorder.exp
@@ -41,7 +41,7 @@ foreach reorder {0 1} { with_test_prefix "reorder$reorder" {
gdb_test "set can-use-hw-watchpoints 1"
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
@@ -72,7 +72,7 @@ foreach reorder {0 1} { with_test_prefix "reorder$reorder" {
"Hardware read watchpoint \[0-9\]+: thread\[12\]_rwatch\r\n\r\nValue = 0\r\n0x\[0-9a-f\]+ in thread\[12\]_func .*" \
"continue a"
- if $reorder {
+ if {$reorder} {
# GDB orders watchpoints by their addresses so inserting new variables
# with lower addresses will shift the former watchpoints to higher
# debug registers.
diff --git a/gdb/testsuite/gdb.threads/watchthreads.exp b/gdb/testsuite/gdb.threads/watchthreads.exp
index 49fc762..e2d629d 100644
--- a/gdb/testsuite/gdb.threads/watchthreads.exp
+++ b/gdb/testsuite/gdb.threads/watchthreads.exp
@@ -31,7 +31,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
return -1
}
-clean_restart $binfile
+clean_restart $::testfile
gdb_test_no_output "set can-use-hw-watchpoints 1" ""
#
@@ -67,11 +67,11 @@ for {set i 0} {$i < 30} {incr i} {
# At least one hardware watchpoint was hit. Check if both were.
set string $expect_out(1,string)
- if [regexp "Hardware watchpoint 2: args\\\[0\\\]\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = $args_0\[^\r\]*\r\[^\r\]*New value = [expr $args_0+1]\r" $string] {
+ if {[regexp "Hardware watchpoint 2: args\\\[0\\\]\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = $args_0\[^\r\]*\r\[^\r\]*New value = [expr {$args_0+1}]\r" $string]} {
incr args_0
incr test_flag_0
}
- if [regexp "Hardware watchpoint 3: args\\\[1\\\]\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = $args_1\[^\r\]*\r\[^\r\]*New value = [expr $args_1+1]\r" $string] {
+ if {[regexp "Hardware watchpoint 3: args\\\[1\\\]\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = $args_1\[^\r\]*\r\[^\r\]*New value = [expr {$args_1+1}]\r" $string]} {
incr args_1
incr test_flag_1
}
@@ -97,7 +97,7 @@ for {set i 0} {$i < 30} {incr i} {
}
}
- if [ regexp "$expected_loc" $string ] {
+ if {[ regexp "$expected_loc" $string ]} {
set test_flag 1
} else {
fail "threaded watch loop"
@@ -140,23 +140,23 @@ if { $test_flag == 1 } {
# Verify that we hit first watchpoint in main thread.
set message "first watchpoint on args\[0\] hit"
if { $args_0 > 0 } {
- pass $message
+ pass $message
} else {
- fail $message
+ fail $message
}
# Verify that we hit second watchpoint in main thread.
set message "first watchpoint on args\[1\] hit"
if { $args_1 > 0 } {
- pass $message
+ pass $message
} else {
- fail $message
+ fail $message
}
# Verify that we hit first watchpoint in child thread.
set message "watchpoint on args\[0\] hit in thread"
if { $args_0 > 1 } {
- pass $message
+ pass $message
} else {
fail $message
}
@@ -164,9 +164,9 @@ if { $args_0 > 1 } {
# Verify that we hit second watchpoint in child thread.
set message "watchpoint on args\[1\] hit in thread"
if { $args_1 > 1 } {
- pass $message
+ pass $message
} else {
- fail $message
+ fail $message
}
# Verify that all watchpoint hits are accounted for.
@@ -174,12 +174,12 @@ set message "combination of threaded watchpoints = 30"
if { [target_no_stopped_data] } {
# See above. If we allow two watchpoints to be hit at once, we
# may have more than 30 hits total.
- set result [expr $args_0 + $args_1 >= 30]
+ set result [expr {$args_0 + $args_1 >= 30}]
} else {
- set result [expr $args_0 + $args_1 == 30]
+ set result [expr {$args_0 + $args_1 == 30}]
}
if { $result } {
- pass $message
+ pass $message
} else {
- fail $message
+ fail $message
}
diff --git a/gdb/testsuite/gdb.threads/watchthreads2.exp b/gdb/testsuite/gdb.threads/watchthreads2.exp
index 2426be4..a31c1a7 100644
--- a/gdb/testsuite/gdb.threads/watchthreads2.exp
+++ b/gdb/testsuite/gdb.threads/watchthreads2.exp
@@ -31,7 +31,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_test_no_output "set can-use-hw-watchpoints 1" ""
@@ -89,7 +89,7 @@ set x_thread_loc "thread_function \\\(arg=.*\\\) at .*watchthreads.c:$x_inc_line
# X is incremented under a mutex, so we should get NR_THREADS * X_INCR_COUNT
# hits.
-set limit [expr $NR_THREADS*$X_INCR_COUNT]
+set limit [expr {$NR_THREADS*$X_INCR_COUNT}]
set x_count 0
set done 0
@@ -102,7 +102,7 @@ for {set i 0} {!$done && $i < $limit} {incr i} {
-re "(.*Hardware watchpoint.*)$gdb_prompt $" {
set string $expect_out(1,string)
- if [regexp "Hardware watchpoint 3: x\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = $x_count\[^\r\]*\r\[^\r\]*New value = [expr $x_count+1]\r" $string] {
+ if {[regexp "Hardware watchpoint 3: x\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = $x_count\[^\r\]*\r\[^\r\]*New value = [expr {$x_count+1}]\r" $string]} {
incr x_count
set test_flag 1
} else {
diff --git a/gdb/testsuite/gdb.threads/wp-replication.exp b/gdb/testsuite/gdb.threads/wp-replication.exp
index 68f5eb0..1b63d57 100644
--- a/gdb/testsuite/gdb.threads/wp-replication.exp
+++ b/gdb/testsuite/gdb.threads/wp-replication.exp
@@ -34,7 +34,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
# Force hardware watchpoints to be used.
gdb_test_no_output "set can-use-hw-watchpoints 1" ""
@@ -126,7 +126,7 @@ gdb_test_no_output "set var test_ready=1" \
"set var test_ready=1"
# Set the number of expected watchpoint triggers.
-set TRIGGERS [expr "$NR_THREADS * $hwatch_count * $NR_TRIGGERS_PER_THREAD"]
+set TRIGGERS [expr {$NR_THREADS * $hwatch_count * $NR_TRIGGERS_PER_THREAD}]
# Move the threads and hit the watchpoints TRIGGERS times.
for { set i 1 } { $i <= $TRIGGERS } { incr i } {
diff --git a/gdb/testsuite/gdb.trace/ax.exp b/gdb/testsuite/gdb.trace/ax.exp
index 3380cdf..cc40853 100644
--- a/gdb/testsuite/gdb.trace/ax.exp
+++ b/gdb/testsuite/gdb.trace/ax.exp
@@ -30,7 +30,7 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
return -1
}
-clean_restart $binfile
+clean_restart $testfile
runto_main
gdb_test "maint agent 12" ".*const8 12.*pop.*end.*"
diff --git a/gdb/testsuite/gdb.trace/basic-libipa.exp b/gdb/testsuite/gdb.trace/basic-libipa.exp
index e7612ac..27be96b 100644
--- a/gdb/testsuite/gdb.trace/basic-libipa.exp
+++ b/gdb/testsuite/gdb.trace/basic-libipa.exp
@@ -42,7 +42,7 @@ save_vars { env(ASAN_OPTIONS) } {
# LD_PRELOAD.
append_environment_default ASAN_OPTIONS verify_asan_link_order 0
- clean_restart $binfile
+ clean_restart $testfile
}
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.trace/entry-values.exp b/gdb/testsuite/gdb.trace/entry-values.exp
index f6bcf66..1d2e8e9 100644
--- a/gdb/testsuite/gdb.trace/entry-values.exp
+++ b/gdb/testsuite/gdb.trace/entry-values.exp
@@ -29,7 +29,7 @@ if {[gdb_compile [list ${binfile}1.o] \
return -1
}
-clean_restart ${binfile}1
+clean_restart ${testfile}1
set returned_from_foo ""
@@ -90,61 +90,63 @@ Dwarf::assemble $asm_file {
set bar_length [lindex $bar_result 1]
cu {} {
- compile_unit {{language @DW_LANG_C}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C
+ } {
int_label: base_type {
- {name int}
- {encoding @DW_ATE_signed}
- {byte_size 4 DW_FORM_sdata}
+ DW_AT_name int
+ DW_AT_encoding @DW_ATE_signed
+ DW_AT_byte_size 4 DW_FORM_sdata
}
foo_label: subprogram {
- {decl_file 0 udata}
- {MACRO_AT_func { foo }}
+ DW_AT_decl_file 0 udata
+ MACRO_AT_func { foo }
} {
formal_parameter {
- {type :$int_label}
- {name i}
- {location {DW_OP_reg0} SPECIAL_expr}
+ DW_AT_type :$int_label
+ DW_AT_name i
+ DW_AT_location {DW_OP_reg0} SPECIAL_expr
}
formal_parameter {
- {type :$int_label}
- {name j}
- {location {DW_OP_reg1} SPECIAL_expr}
+ DW_AT_type :$int_label
+ DW_AT_name j
+ DW_AT_location {DW_OP_reg1} SPECIAL_expr
}
}
subprogram {
- {name bar}
- {decl_file 0 udata}
- {low_pc $bar_start addr}
- {high_pc "$bar_start + $bar_length" addr}
- {GNU_all_call_sites 1 sdata}
+ DW_AT_name bar
+ DW_AT_decl_file 0 udata
+ DW_AT_low_pc $bar_start addr
+ DW_AT_high_pc "$bar_start + $bar_length" addr
+ DW_AT_GNU_all_call_sites 1 sdata
} {
formal_parameter {
- {type :$int_label}
- {name i}
+ DW_AT_type :$int_label
+ DW_AT_name i
}
GNU_call_site {
- {low_pc "$bar_start + $returned_from_foo" addr}
- {abstract_origin :$foo_label}
+ DW_AT_low_pc "$bar_start + $returned_from_foo" addr
+ DW_AT_abstract_origin :$foo_label
} {
# Faked entry values are reference to variables 'global1'
# and 'global2' and faked locations are register 0 and
# register 1.
GNU_call_site_parameter {
- {location {DW_OP_reg0} SPECIAL_expr}
- {GNU_call_site_value {
+ DW_AT_location {DW_OP_reg0} SPECIAL_expr
+ DW_AT_GNU_call_site_value {
addr global1
deref_size 4
- } SPECIAL_expr}
+ } SPECIAL_expr
}
GNU_call_site_parameter {
- {location {DW_OP_reg1} SPECIAL_expr}
- {GNU_call_site_value {
+ DW_AT_location {DW_OP_reg1} SPECIAL_expr
+ DW_AT_GNU_call_site_value {
addr global2
deref_size 4
- } SPECIAL_expr}
+ } SPECIAL_expr
}
}
}
@@ -193,7 +195,7 @@ gdb_test_sequence "bt" "bt, 2" {
# Restart GDB and trace.
-clean_restart $binfile
+clean_restart $testfile
load_lib "trace-support.exp"
diff --git a/gdb/testsuite/gdb.trace/ftrace-lock.exp b/gdb/testsuite/gdb.trace/ftrace-lock.exp
index 36a7566..8c9d4aa 100644
--- a/gdb/testsuite/gdb.trace/ftrace-lock.exp
+++ b/gdb/testsuite/gdb.trace/ftrace-lock.exp
@@ -32,7 +32,7 @@ set options [list debug pthreads [gdb_target_symbol_prefix_flags] \
additional_flags=-DNUM_THREADS=$NUM_THREADS]
with_test_prefix "runtime trace support check" {
- if { [prepare_for_testing "prepare for testing" ${binfile}-check \
+ if { [prepare_for_testing "prepare for testing" ${testfile}-check \
$srcfile $options] } {
return
}
@@ -55,7 +55,7 @@ set remote_libipa [gdb_load_shlib $libipa]
lappend options shlib=$libipa
if { [prepare_for_testing "prepare for testing with libipa" \
- $binfile $srcfile $options] } {
+ $testfile $srcfile $options] } {
return
}
diff --git a/gdb/testsuite/gdb.trace/mi-trace-frame-collected.exp b/gdb/testsuite/gdb.trace/mi-trace-frame-collected.exp
index dd0d785..9b4f053 100644
--- a/gdb/testsuite/gdb.trace/mi-trace-frame-collected.exp
+++ b/gdb/testsuite/gdb.trace/mi-trace-frame-collected.exp
@@ -37,7 +37,7 @@ gdb_exit
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-mi_clean_restart $binfile
+mi_clean_restart $testfile
mi_runto_main
mi_gdb_test "-break-insert end" \
diff --git a/gdb/testsuite/gdb.trace/mi-trace-unavailable.exp b/gdb/testsuite/gdb.trace/mi-trace-unavailable.exp
index dde6d8b..dd22046 100644
--- a/gdb/testsuite/gdb.trace/mi-trace-unavailable.exp
+++ b/gdb/testsuite/gdb.trace/mi-trace-unavailable.exp
@@ -35,7 +35,7 @@ gdb_exit
load_lib mi-support.exp
set MIFLAGS "-i=mi"
-mi_clean_restart $binfile
+mi_clean_restart $testfile
mi_runto_main
mi_gdb_test "-break-insert marker" \
diff --git a/gdb/testsuite/gdb.trace/mi-traceframe-changed.exp b/gdb/testsuite/gdb.trace/mi-traceframe-changed.exp
index 05c10ed..90a053c 100644
--- a/gdb/testsuite/gdb.trace/mi-traceframe-changed.exp
+++ b/gdb/testsuite/gdb.trace/mi-traceframe-changed.exp
@@ -45,11 +45,10 @@ remote_file target delete $tfile_basic
proc test_tfind_tfile { } {
with_test_prefix "tfile" {
- global binfile
global decimal
global tfile_basic
- mi_clean_restart $binfile
+ mi_clean_restart $::testfile
mi_gdb_test "-target-select tfile ${tfile_basic}" \
".*=breakpoint-created,bkpt=\{number=\"${decimal}\",type=\"tracepoint\",disp=\"keep\",enabled=\"y\",.*,func=\"write_basic_trace_file\".*\\^connected" \
@@ -92,8 +91,8 @@ if [generate_tracefile $binfile] {
# Change to a different test case in order to run it on target, and get
# several traceframes.
standard_testfile status-stop.c
-append testfile -1
-append binfile -1
+append testfile "-1"
+append binfile "-1"
set executable $testfile
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
@@ -120,9 +119,8 @@ gdb_exit
proc test_tfind_remote { } {
with_test_prefix "remote" {
global decimal
- global binfile
- mi_clean_restart $binfile
+ mi_clean_restart $::testfile
mi_runto_main
mi_gdb_test "-break-insert end" "\\^done.*" "break end"
diff --git a/gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp b/gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp
index 90654c0..99f7bf9 100644
--- a/gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp
+++ b/gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp
@@ -89,9 +89,7 @@ proc test_reconnect { } {
}
}
- global binfile
-
- if {[mi_clean_restart $binfile]} {
+ if {[mi_clean_restart $::testfile]} {
return
}
@@ -155,11 +153,10 @@ proc test_pending_resolved { } {
with_test_prefix "pending resolved" {
global decimal hex
global executable
- global binfile
global lib_sl1 lib_sl2
global mi_gdb_prompt
- if {[mi_clean_restart $binfile]} {
+ if {[mi_clean_restart $::testfile]} {
return
}
mi_load_shlibs $lib_sl1 $lib_sl2
diff --git a/gdb/testsuite/gdb.trace/mi-tsv-changed.exp b/gdb/testsuite/gdb.trace/mi-tsv-changed.exp
index f90d9a4..6f71e79 100644
--- a/gdb/testsuite/gdb.trace/mi-tsv-changed.exp
+++ b/gdb/testsuite/gdb.trace/mi-tsv-changed.exp
@@ -77,7 +77,7 @@ proc test_create_delete_modify_tsv { } {
}
gdb_exit
- if {[mi_clean_restart $binfile]} {
+ if {[mi_clean_restart $::testfile]} {
return
}
@@ -145,7 +145,7 @@ proc test_upload_tsv { } {
return 0
}
- clean_restart $testfile
+ clean_restart $::testfile
if {![runto_main]} {
return 0
}
@@ -175,8 +175,7 @@ proc test_upload_tsv { } {
}
}
- global binfile
- if {[mi_clean_restart $binfile]} {
+ if {[mi_clean_restart $::testfile]} {
return
}
diff --git a/gdb/testsuite/gdb.trace/packetlen.exp b/gdb/testsuite/gdb.trace/packetlen.exp
index cf9fcc4..52a34b9 100644
--- a/gdb/testsuite/gdb.trace/packetlen.exp
+++ b/gdb/testsuite/gdb.trace/packetlen.exp
@@ -25,7 +25,7 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
return -1
}
-clean_restart $binfile
+clean_restart $testfile
gdb_test "tstop" ".*" ""
gdb_test "tfind none" ".*" ""
runto_main
diff --git a/gdb/testsuite/gdb.trace/passc-dyn.exp b/gdb/testsuite/gdb.trace/passc-dyn.exp
index 0a67df1..b4ec45a 100644
--- a/gdb/testsuite/gdb.trace/passc-dyn.exp
+++ b/gdb/testsuite/gdb.trace/passc-dyn.exp
@@ -25,7 +25,7 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
return -1
}
-clean_restart $binfile
+clean_restart $testfile
runto_main
if {![gdb_target_supports_trace]} {
diff --git a/gdb/testsuite/gdb.trace/report.exp b/gdb/testsuite/gdb.trace/report.exp
index 45857a1..f2a04f7 100644
--- a/gdb/testsuite/gdb.trace/report.exp
+++ b/gdb/testsuite/gdb.trace/report.exp
@@ -24,7 +24,7 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
untested "failed to compile"
return -1
}
-clean_restart $binfile
+clean_restart $testfile
runto_main
if {![gdb_target_supports_trace]} {
diff --git a/gdb/testsuite/gdb.trace/tfile.exp b/gdb/testsuite/gdb.trace/tfile.exp
index 020f4d4..4d156f7 100644
--- a/gdb/testsuite/gdb.trace/tfile.exp
+++ b/gdb/testsuite/gdb.trace/tfile.exp
@@ -61,7 +61,7 @@ if {!$purely_local} {
remote_download host [remote_upload target tfile-error.tf] tfile-error.tf
}
-clean_restart $binfile
+clean_restart $testfile
# Program has presumably exited, now target a trace file it created.
@@ -121,7 +121,7 @@ gdb_test "info registers" "The program has no registers now\." \
# Now start afresh, using only a trace file.
-clean_restart $binfile
+clean_restart $testfile
gdb_test "target tfile $tfile_error" "Created tracepoint.*" \
"target tfile [file tail $tfile_error]"
diff --git a/gdb/testsuite/gdb.trace/tfind.exp b/gdb/testsuite/gdb.trace/tfind.exp
index ae73206..92386e4 100644
--- a/gdb/testsuite/gdb.trace/tfind.exp
+++ b/gdb/testsuite/gdb.trace/tfind.exp
@@ -27,7 +27,7 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" "$binfile" \
return -1
}
-clean_restart $binfile
+clean_restart $testfile
# 6.2 test help tstart
gdb_test "help tstart" \
diff --git a/gdb/testsuite/gdb.trace/trace-mt.exp b/gdb/testsuite/gdb.trace/trace-mt.exp
index 0c6e4e5..092dc6d 100644
--- a/gdb/testsuite/gdb.trace/trace-mt.exp
+++ b/gdb/testsuite/gdb.trace/trace-mt.exp
@@ -22,7 +22,7 @@ set additional_flags [gdb_target_symbol_prefix_flags]
require gdb_trace_common_supports_arch
with_test_prefix "runtime trace support check" {
- if { [prepare_for_testing "prepare for testing" ${binfile} $srcfile \
+ if { [prepare_for_testing "prepare for testing" $testfile $srcfile \
[list debug pthreads $additional_flags]] } {
return
}
@@ -37,13 +37,13 @@ with_test_prefix "runtime trace support check" {
}
}
-proc step_over_tracepoint { binfile trace_type } \
+proc step_over_tracepoint { testfile trace_type } \
{with_test_prefix "step over $trace_type" \
{
global hex
# Start with a fresh gdb.
- clean_restart $binfile
+ clean_restart $testfile
# Make sure inferior is running in all-stop mode.
gdb_test_no_output "set non-stop 0"
@@ -63,13 +63,13 @@ proc step_over_tracepoint { binfile trace_type } \
# Set breakpoint and tracepoint at the same address.
-proc break_trace_same_addr { binfile trace_type option } \
+proc break_trace_same_addr { testfile trace_type option } \
{with_test_prefix "$trace_type $option" \
{
global hex
# Start with a fresh gdb.
- clean_restart $binfile
+ clean_restart $testfile
if ![runto_main] {
return -1
}
@@ -96,10 +96,10 @@ proc break_trace_same_addr { binfile trace_type option } \
}}
foreach break_always_inserted { "on" "off" } {
- break_trace_same_addr $binfile "trace" ${break_always_inserted}
+ break_trace_same_addr $testfile "trace" ${break_always_inserted}
}
-step_over_tracepoint $binfile "trace"
+step_over_tracepoint $testfile "trace"
require allow_shlib_tests
@@ -108,8 +108,8 @@ set libipa [get_in_proc_agent]
set remote_libipa [gdb_load_shlib $libipa]
# Compile test case again with IPA.
-set binfile_ipa ${binfile}-ipa
-if { [prepare_for_testing "prepare for testing" $binfile_ipa $srcfile \
+set testfile_ipa $testfile-ipa
+if { [prepare_for_testing "prepare for testing" $testfile_ipa $srcfile \
[list debug pthreads $additional_flags shlib=$libipa]] } {
return
}
@@ -122,8 +122,8 @@ if { [gdb_test "info sharedlibrary" ".*${remote_libipa}.*" "IPA loaded"] != 0 }
untested "could not find IPA lib loaded"
} else {
foreach break_always_inserted { "on" "off" } {
- break_trace_same_addr $binfile_ipa "ftrace" ${break_always_inserted}
+ break_trace_same_addr $testfile_ipa "ftrace" ${break_always_inserted}
}
- step_over_tracepoint $binfile_ipa "ftrace"
+ step_over_tracepoint $testfile_ipa "ftrace"
}
diff --git a/gdb/testsuite/gdb.trace/tsv.exp b/gdb/testsuite/gdb.trace/tsv.exp
index 96c7c35..837633d 100644
--- a/gdb/testsuite/gdb.trace/tsv.exp
+++ b/gdb/testsuite/gdb.trace/tsv.exp
@@ -23,7 +23,7 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
return -1
}
-clean_restart $binfile
+clean_restart $testfile
# PR gdb/21352: Command tsave does not support -r argument
gdb_test "tsave -r" "Argument required \\\(file in which to save trace data\\\)\." \
@@ -193,7 +193,7 @@ gdb_test_multiple "target ctf ${tracefile}.ctf" "" {
}
# Restart.
-clean_restart ${binfile}
+clean_restart $testfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp b/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp
index 98207f0..3adf24a 100644
--- a/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp
+++ b/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp
@@ -32,165 +32,167 @@ Dwarf::assemble $asm_file {
declare_labels uchar_label struct_s_label foo_label struct_t_label bar_label
cu {} {
- compile_unit {{language @DW_LANG_C}} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C
+ } {
uchar_label: DW_TAG_base_type {
- {name "unsigned char"}
- {byte_size 1 DW_FORM_sdata}
- {encoding @DW_ATE_unsigned_char}
+ DW_AT_name "unsigned char"
+ DW_AT_byte_size 1 DW_FORM_sdata
+ DW_AT_encoding @DW_ATE_unsigned_char
}
struct_s_label: DW_TAG_structure_type {
- {name s}
- {byte_size 3 DW_FORM_sdata}
- {decl_file 0 DW_FORM_udata}
- {decl_line 1 DW_FORM_udata}
+ DW_AT_name s
+ DW_AT_byte_size 3 DW_FORM_sdata
+ DW_AT_decl_file 0 DW_FORM_udata
+ DW_AT_decl_line 1 DW_FORM_udata
} {
DW_TAG_member {
- {name a}
- {type :$uchar_label}
- {data_member_location {
+ DW_AT_name a
+ DW_AT_type :$uchar_label
+ DW_AT_data_member_location {
DW_OP_plus_uconst 0
- } SPECIAL_expr}
+ } SPECIAL_expr
}
DW_TAG_member {
- {name b}
- {type :$uchar_label}
- {data_member_location {
+ DW_AT_name b
+ DW_AT_type :$uchar_label
+ DW_AT_data_member_location {
DW_OP_plus_uconst 1
- } SPECIAL_expr}
+ } SPECIAL_expr
}
DW_TAG_member {
- {name c}
- {type :$uchar_label}
- {data_member_location {
+ DW_AT_name c
+ DW_AT_type :$uchar_label
+ DW_AT_data_member_location {
DW_OP_plus_uconst 2
- } SPECIAL_expr}
+ } SPECIAL_expr
}
}
struct_t_label: DW_TAG_structure_type {
- {name t}
- {byte_size 3 DW_FORM_sdata}
- {decl_file 0 DW_FORM_udata}
- {decl_line 1 DW_FORM_udata}
+ DW_AT_name t
+ DW_AT_byte_size 3 DW_FORM_sdata
+ DW_AT_decl_file 0 DW_FORM_udata
+ DW_AT_decl_line 1 DW_FORM_udata
} {
DW_TAG_member {
- {name a}
- {type :$uchar_label}
- {data_member_location {
+ DW_AT_name a
+ DW_AT_type :$uchar_label
+ DW_AT_data_member_location {
DW_OP_plus_uconst 0
- } SPECIAL_expr}
+ } SPECIAL_expr
}
DW_TAG_member {
- {name b}
- {type :$uchar_label}
- {byte_size 1 DW_FORM_sdata}
- {bit_size 1 DW_FORM_sdata}
- {bit_offset 7 DW_FORM_sdata}
- {data_member_location {
+ DW_AT_name b
+ DW_AT_type :$uchar_label
+ DW_AT_byte_size 1 DW_FORM_sdata
+ DW_AT_bit_size 1 DW_FORM_sdata
+ DW_AT_bit_offset 7 DW_FORM_sdata
+ DW_AT_data_member_location {
DW_OP_plus_uconst 1
- } SPECIAL_expr}
+ } SPECIAL_expr
}
DW_TAG_member {
- {name c}
- {type :$uchar_label}
- {byte_size 1 DW_FORM_sdata}
- {bit_size 1 DW_FORM_sdata}
- {bit_offset 6 DW_FORM_sdata}
- {data_member_location {
+ DW_AT_name c
+ DW_AT_type :$uchar_label
+ DW_AT_byte_size 1 DW_FORM_sdata
+ DW_AT_bit_size 1 DW_FORM_sdata
+ DW_AT_bit_offset 6 DW_FORM_sdata
+ DW_AT_data_member_location {
DW_OP_plus_uconst 1
- } SPECIAL_expr}
+ } SPECIAL_expr
}
DW_TAG_member {
- {name d}
- {type :$uchar_label}
- {byte_size 1 DW_FORM_sdata}
- {bit_size 1 DW_FORM_sdata}
- {bit_offset 5 DW_FORM_sdata}
- {data_member_location {
+ DW_AT_name d
+ DW_AT_type :$uchar_label
+ DW_AT_byte_size 1 DW_FORM_sdata
+ DW_AT_bit_size 1 DW_FORM_sdata
+ DW_AT_bit_offset 5 DW_FORM_sdata
+ DW_AT_data_member_location {
DW_OP_plus_uconst 1
- } SPECIAL_expr}
+ } SPECIAL_expr
}
DW_TAG_member {
- {name e}
- {type :$uchar_label}
- {byte_size 1 DW_FORM_sdata}
- {bit_size 1 DW_FORM_sdata}
- {bit_offset 4 DW_FORM_sdata}
- {data_member_location {
+ DW_AT_name e
+ DW_AT_type :$uchar_label
+ DW_AT_byte_size 1 DW_FORM_sdata
+ DW_AT_bit_size 1 DW_FORM_sdata
+ DW_AT_bit_offset 4 DW_FORM_sdata
+ DW_AT_data_member_location {
DW_OP_plus_uconst 1
- } SPECIAL_expr}
+ } SPECIAL_expr
}
DW_TAG_member {
- {name f}
- {type :$uchar_label}
- {byte_size 1 DW_FORM_sdata}
- {bit_size 1 DW_FORM_sdata}
- {bit_offset 3 DW_FORM_sdata}
- {data_member_location {
+ DW_AT_name f
+ DW_AT_type :$uchar_label
+ DW_AT_byte_size 1 DW_FORM_sdata
+ DW_AT_bit_size 1 DW_FORM_sdata
+ DW_AT_bit_offset 3 DW_FORM_sdata
+ DW_AT_data_member_location {
DW_OP_plus_uconst 1
- } SPECIAL_expr}
+ } SPECIAL_expr
}
DW_TAG_member {
- {name g}
- {type :$uchar_label}
- {byte_size 1 DW_FORM_sdata}
- {bit_size 1 DW_FORM_sdata}
- {bit_offset 2 DW_FORM_sdata}
- {data_member_location {
+ DW_AT_name g
+ DW_AT_type :$uchar_label
+ DW_AT_byte_size 1 DW_FORM_sdata
+ DW_AT_bit_size 1 DW_FORM_sdata
+ DW_AT_bit_offset 2 DW_FORM_sdata
+ DW_AT_data_member_location {
DW_OP_plus_uconst 1
- } SPECIAL_expr}
+ } SPECIAL_expr
}
DW_TAG_member {
- {name h}
- {type :$uchar_label}
- {byte_size 1 DW_FORM_sdata}
- {bit_size 1 DW_FORM_sdata}
- {bit_offset 1 DW_FORM_sdata}
- {data_member_location {
+ DW_AT_name h
+ DW_AT_type :$uchar_label
+ DW_AT_byte_size 1 DW_FORM_sdata
+ DW_AT_bit_size 1 DW_FORM_sdata
+ DW_AT_bit_offset 1 DW_FORM_sdata
+ DW_AT_data_member_location {
DW_OP_plus_uconst 1
- } SPECIAL_expr}
+ } SPECIAL_expr
}
DW_TAG_member {
- {name i}
- {type :$uchar_label}
- {byte_size 1 DW_FORM_sdata}
- {bit_size 1 DW_FORM_sdata}
- {bit_offset 0 DW_FORM_sdata}
- {data_member_location {
+ DW_AT_name i
+ DW_AT_type :$uchar_label
+ DW_AT_byte_size 1 DW_FORM_sdata
+ DW_AT_bit_size 1 DW_FORM_sdata
+ DW_AT_bit_offset 0 DW_FORM_sdata
+ DW_AT_data_member_location {
DW_OP_plus_uconst 1
- } SPECIAL_expr}
+ } SPECIAL_expr
}
DW_TAG_member {
- {name j}
- {type :$uchar_label}
- {data_member_location {
+ DW_AT_name j
+ DW_AT_type :$uchar_label
+ DW_AT_data_member_location {
DW_OP_plus_uconst 2
- } SPECIAL_expr}
+ } SPECIAL_expr
}
}
DW_TAG_subprogram {
- {name foo}
- {decl_file 0 udata}
- {low_pc foo_start_lbl addr}
- {high_pc foo_end_lbl addr}
+ DW_AT_name foo
+ DW_AT_decl_file 0 udata
+ DW_AT_low_pc foo_start_lbl addr
+ DW_AT_high_pc foo_end_lbl addr
} {
DW_TAG_formal_parameter {
- {type :$struct_s_label}
- {name x}
- {location {
+ DW_AT_type :$struct_s_label
+ DW_AT_name x
+ DW_AT_location {
DW_OP_lit0
DW_OP_stack_value
DW_OP_piece 2
DW_OP_reg0
DW_OP_piece 1
- } SPECIAL_expr}
+ } SPECIAL_expr
}
DW_TAG_formal_parameter {
- {type :$struct_s_label}
- {name y}
- {location {
+ DW_AT_type :$struct_s_label
+ DW_AT_name y
+ DW_AT_location {
DW_OP_lit0
DW_OP_stack_value
DW_OP_piece 1
@@ -199,32 +201,32 @@ Dwarf::assemble $asm_file {
DW_OP_lit0
DW_OP_stack_value
DW_OP_piece 1
- } SPECIAL_expr}
+ } SPECIAL_expr
}
DW_TAG_formal_parameter {
- {type :$struct_s_label}
- {name z}
- {location {
+ DW_AT_type :$struct_s_label
+ DW_AT_name z
+ DW_AT_location {
DW_OP_reg0
DW_OP_piece 1
DW_OP_lit0
DW_OP_stack_value
DW_OP_piece 2
- } SPECIAL_expr}
+ } SPECIAL_expr
}
}
DW_TAG_subprogram {
- {name bar}
- {decl_file 0 udata}
- {low_pc bar_start_lbl addr}
- {high_pc bar_end_lbl addr}
+ DW_AT_name bar
+ DW_AT_decl_file 0 udata
+ DW_AT_low_pc bar_start_lbl addr
+ DW_AT_high_pc bar_end_lbl addr
} {
DW_TAG_formal_parameter {
- {type :$struct_t_label}
- {name x}
- {location {
+ DW_AT_type :$struct_t_label
+ DW_AT_name x
+ DW_AT_location {
DW_OP_lit0
DW_OP_stack_value
DW_OP_piece 1
@@ -236,12 +238,12 @@ Dwarf::assemble $asm_file {
DW_OP_lit0
DW_OP_stack_value
DW_OP_piece 1
- } SPECIAL_expr}
+ } SPECIAL_expr
}
DW_TAG_formal_parameter {
- {type :$struct_t_label}
- {name y}
- {location {
+ DW_AT_type :$struct_t_label
+ DW_AT_name y
+ DW_AT_location {
DW_OP_lit0
DW_OP_stack_value
DW_OP_piece 1
@@ -256,12 +258,12 @@ Dwarf::assemble $asm_file {
DW_OP_lit0
DW_OP_stack_value
DW_OP_piece 1
- } SPECIAL_expr}
+ } SPECIAL_expr
}
DW_TAG_formal_parameter {
- {type :$struct_t_label}
- {name z}
- {location {
+ DW_AT_type :$struct_t_label
+ DW_AT_name z
+ DW_AT_location {
DW_OP_lit0
DW_OP_stack_value
DW_OP_piece 1
@@ -273,7 +275,7 @@ Dwarf::assemble $asm_file {
DW_OP_lit0
DW_OP_stack_value
DW_OP_piece 1
- } SPECIAL_expr}
+ } SPECIAL_expr
}
}
diff --git a/gdb/testsuite/gdb.trace/while-dyn.exp b/gdb/testsuite/gdb.trace/while-dyn.exp
index 53a8e54..3940ff6 100644
--- a/gdb/testsuite/gdb.trace/while-dyn.exp
+++ b/gdb/testsuite/gdb.trace/while-dyn.exp
@@ -26,7 +26,7 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
return -1
}
-clean_restart $binfile
+clean_restart $testfile
runto_main
if {![gdb_target_supports_trace]} {
diff --git a/gdb/testsuite/gdb.tui/basic.exp b/gdb/testsuite/gdb.tui/basic.exp
index 35c99bd..8ecc91a 100644
--- a/gdb/testsuite/gdb.tui/basic.exp
+++ b/gdb/testsuite/gdb.tui/basic.exp
@@ -112,5 +112,9 @@ set re_noattr "\[^<\]"
set status_window_line 15
set status [Term::get_line_with_attrs $status_window_line]
-gdb_assert { [regexp "^<reverse:1>$re_noattr*<reverse:0>$" $status] == 1} \
+verbose -log "status line: '$status'"
+
+# The status line uses standout, which may translate to different attributes
+# depending on the terminal settings. Just check for at least one attribute.
+gdb_assert { [regexp "^<.*>(exec|extended-r)" $status] == 1 } \
"status window: reverse"
diff --git a/gdb/testsuite/gdb.tui/color-prompt.exp b/gdb/testsuite/gdb.tui/color-prompt.exp
index a95b24a..af6e467 100644
--- a/gdb/testsuite/gdb.tui/color-prompt.exp
+++ b/gdb/testsuite/gdb.tui/color-prompt.exp
@@ -15,18 +15,16 @@
# Check using a prompt with color in TUI.
+require allow_tui_tests
+
tuiterm_env
Term::clean_restart 24 80
-# Set colored prompt.
if {![Term::enter_tui]} {
unsupported "TUI not supported"
return
}
-Term::command "set prompt \\033\[31m(gdb) \\033\[0m"
-
-set line [Term::get_line_with_attrs $Term::_cur_row]
-gdb_assert { [regexp "^<fg:red>$gdb_prompt <fg:default> *$" $line] } \
- "prompt with color"
+set tui 1
+source $srcdir/$subdir/color-prompt.exp.tcl
diff --git a/gdb/testsuite/gdb.tui/color-prompt.exp.tcl b/gdb/testsuite/gdb.tui/color-prompt.exp.tcl
new file mode 100644
index 0000000..e6f4d3b
--- /dev/null
+++ b/gdb/testsuite/gdb.tui/color-prompt.exp.tcl
@@ -0,0 +1,80 @@
+# Copyright 2025 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 using a prompt with color in TUI ($tui == 0) or CLI ($tui == 0).
+
+set csi [string cat {\033} "\["]
+set rl_prompt_start_ignore {\001}
+set rl_prompt_end_ignore {\002}
+
+foreach_with_prefix rl_prompt_start_end_ignore { 0 1 } {
+ set color_on [string cat $csi 31m]
+ set color_off [string cat $csi 0m]
+
+ if { $rl_prompt_start_end_ignore } {
+ set color_on \
+ [string cat \
+ $rl_prompt_start_ignore \
+ $color_on \
+ $rl_prompt_end_ignore]
+ set color_off \
+ [string cat \
+ $rl_prompt_start_ignore \
+ $color_off \
+ $rl_prompt_end_ignore]
+ }
+
+ # Set prompt with color.
+ set prompt "${color_on}(gdb) $color_off"
+ Term::command "set prompt $prompt"
+
+ # Check the color.
+ set line [Term::get_line_with_attrs $Term::_cur_row]
+ gdb_assert { [regexp "^<fg:red>$gdb_prompt <fg:default> *$" $line] } \
+ "prompt with color"
+
+ # Type a string.
+ set cmd "some long command"
+ send_gdb $cmd
+ Term::wait_for_line ^[string_to_regexp "(gdb) $cmd"] 23
+
+ # Send ^A, aka C-a, trigger beginning-of-line.
+ send_gdb "\001"
+ if { $tui || $rl_prompt_start_end_ignore } {
+ Term::wait_for_line ^[string_to_regexp "(gdb) $cmd"] 6
+ } else {
+ # Without the markers, readline may get the cursor position wrong, so
+ # match less strict.
+ Term::wait_for_line ^[string_to_regexp "(gdb) $cmd"]
+ }
+ Term::dump_screen
+
+ # Type something else to flush out the effect of the ^A.
+ set prefix "A"
+ send_gdb $prefix
+ if { $tui || $rl_prompt_start_end_ignore } {
+ Term::wait_for_line ^[string_to_regexp "(gdb) $prefix$cmd"] 7
+ } else {
+ # Without the markers, readline may get the cursor position wrong, so
+ # match less strict.
+ Term::wait_for_line [string_to_regexp "$prefix"]
+ }
+
+ # Abort command line editing, and regenerate prompt.
+ send_gdb "\003"
+
+ # Reset prompt to default prompt.
+ Term::command "set prompt (gdb) "
+}
diff --git a/gdb/testsuite/gdb.tui/compact-source.exp b/gdb/testsuite/gdb.tui/compact-source.exp
index b050159..31bc1dc 100644
--- a/gdb/testsuite/gdb.tui/compact-source.exp
+++ b/gdb/testsuite/gdb.tui/compact-source.exp
@@ -41,7 +41,7 @@ if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} {
return -1
}
-Term::clean_restart 24 80 $binfile
+Term::clean_restart 24 80 $testfile
gdb_test_no_output "maint set tui-left-margin-verbose on"
gdb_test_no_output "set tui compact-source on"
@@ -55,9 +55,9 @@ set re_border "\\|"
set max_line_nr_in_source_file [llength $src_list]
# Ensure there are more lines in the window than in the source file.
-set src_window_lines [expr $max_line_nr_in_source_file + 2]
+set src_window_lines [expr {$max_line_nr_in_source_file + 2}]
# Account for border size.
-set src_window_size [expr $src_window_lines + 2]
+set src_window_size [expr {$src_window_lines + 2}]
Term::command "wh src $src_window_size"
set re_left_margin "___4_"
@@ -65,6 +65,6 @@ set re_left_margin "___4_"
Term::check_contents "compact source format" \
"$re_border$re_left_margin$re_line_four *$re_border"
-set re_left_margin "___0*[expr $max_line_nr_in_source_file + 1]_"
+set re_left_margin "___0*[expr {$max_line_nr_in_source_file + 1}]_"
Term::check_contents_not "no surplus line number" \
"$re_border$re_left_margin *$re_border"
diff --git a/gdb/testsuite/gdb.tui/empty.exp b/gdb/testsuite/gdb.tui/empty.exp
index 33710ff..19196e8 100644
--- a/gdb/testsuite/gdb.tui/empty.exp
+++ b/gdb/testsuite/gdb.tui/empty.exp
@@ -65,7 +65,7 @@ set layouts {
proc check_boxes {boxes} {
set boxno 1
foreach box $boxes {
- eval Term::check_box [list "box $boxno"] $box
+ Term::check_box "box $boxno" {*}$box
incr boxno
}
}
diff --git a/gdb/testsuite/gdb.testsuite/lmap.exp b/gdb/testsuite/gdb.tui/gdb.sh
index da03722..0079a3f 100644..100755
--- a/gdb/testsuite/gdb.testsuite/lmap.exp
+++ b/gdb/testsuite/gdb.tui/gdb.sh
@@ -1,4 +1,7 @@
-# Copyright 2023-2025 Free Software Foundation, Inc.
+#!/bin/sh
+
+# Copyright 2025 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
@@ -12,9 +15,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-set one 1
-set l1 { $one 2 }
-set res1 [lmap item $l1 {expr $item + 1}]
-gdb_assert { [lindex $res1 0] == 2 }
-gdb_assert { [lindex $res1 1] == 3 }
-gdb_assert { $item == 2 }
+printf "foo\033(%%5"
+
+read
diff --git a/gdb/testsuite/gdb.tui/main-2.exp b/gdb/testsuite/gdb.tui/main-2.exp
index 71ad03b..2bc6b8d 100644
--- a/gdb/testsuite/gdb.tui/main-2.exp
+++ b/gdb/testsuite/gdb.tui/main-2.exp
@@ -26,7 +26,7 @@ if { [build_executable "failed to prepare" $testfile $srcfile ] == -1} {
return -1
}
-Term::clean_restart 24 80 $binfile
+Term::clean_restart 24 80 $testfile
if {![runto_main]} {
perror "test suppressed"
@@ -41,7 +41,7 @@ if {![Term::enter_tui]} {
set line " return 0;"
set nr [gdb_get_line_number $line]
-set screen_line [Term::get_string_with_attrs 6 1 79]
+set screen_line [Term::get_string_with_attrs 6 11 79]
verbose -log "screen line 6: '$screen_line'"
-gdb_assert { [regexp "$nr <reverse:1>$line<reverse:0>" $screen_line] } \
+gdb_assert { [regexp "<reverse:1>$line<reverse:0>" $screen_line] } \
"highlighted line in middle of source window"
diff --git a/gdb/testsuite/gdb.tui/main.exp b/gdb/testsuite/gdb.tui/main.exp
index d6960c7..e49da35 100644
--- a/gdb/testsuite/gdb.tui/main.exp
+++ b/gdb/testsuite/gdb.tui/main.exp
@@ -43,7 +43,10 @@ if {![Term::enter_tui]} {
}
send_gdb "file [standard_output_file $testfile]\n"
-gdb_assert { [Term::wait_for "Reading symbols from"] } "file command"
+# Matching the output is difficult because it may or may not wrap. Simply
+# match the resulting prompt.
+gdb_assert { [Term::wait_for ""] } "file command"
+
Term::check_contents "show main after file" \
[string_to_regexp "|___[format %06d $nr]_$line"]
diff --git a/gdb/testsuite/gdb.tui/new-layout.exp b/gdb/testsuite/gdb.tui/new-layout.exp
index f517997..6a4c68f 100644
--- a/gdb/testsuite/gdb.tui/new-layout.exp
+++ b/gdb/testsuite/gdb.tui/new-layout.exp
@@ -45,15 +45,12 @@ gdb_test "tui new-layout example src 1 src 1" \
gdb_test "tui new-layout example src 1" \
"New layout does not contain the \"cmd\" window"
-# Avoid unbalanced curly braces problems with tcl 8.5.
-if { [tcl_version_at_least 8 6] } {
- gdb_test "tui new-layout example src 1\}" \
- "Extra '\}' in layout specification"
- gdb_test "tui new-layout example {src 1} 1\}" \
- "Extra '\}' in layout specification"
- gdb_test "tui new-layout example \{src 1" \
- "Missing '\}' in layout specification"
-}
+gdb_test "tui new-layout example src 1\}" \
+ "Extra '\}' in layout specification"
+gdb_test "tui new-layout example {src 1} 1\}" \
+ "Extra '\}' in layout specification"
+gdb_test "tui new-layout example \{src 1" \
+ "Missing '\}' in layout specification"
# Each entry of this list describes a layout, and some associated
# tests. The items within each entry are:
@@ -84,7 +81,7 @@ set layouts \
proc check_boxes {boxes} {
set boxno 1
foreach box $boxes {
- eval Term::check_box [list "box $boxno"] $box
+ Term::check_box "box $boxno" {*}$box
incr boxno
}
}
@@ -150,4 +147,7 @@ Term::check_box "before cmd_only: src box in src layout" 0 0 80 15
Term::command "layout cmd_only"
Term::command "layout src"
+
+# Flush out and check the resulting src box.
+Term::command "print 1"
Term::check_box "after cmd_only: src box in src layout" 0 0 80 15
diff --git a/gdb/testsuite/gdb.tui/pr30056.exp b/gdb/testsuite/gdb.tui/pr30056.exp
index 3403033..3cf5e90 100644
--- a/gdb/testsuite/gdb.tui/pr30056.exp
+++ b/gdb/testsuite/gdb.tui/pr30056.exp
@@ -22,67 +22,72 @@ require {have_host_locale C.UTF-8}
tuiterm_env
+standard_testfile tui-long-line.c
+
+if { [build_executable "failed to prepare" $testfile $srcfile] == -1 } {
+ return
+}
+
save_vars { env(LC_ALL) } {
setenv LC_ALL C.UTF-8
# Start terminal.
- Term::clean_restart 24 80
-
- # Start TUI.
- if {![Term::enter_tui]} {
- unsupported "TUI not supported"
- return
- }
-
- # Send "^R", starting reverse-i-search.
- send_gdb "\022"
- Term::wait_for_region_contents 0 $Term::_cur_row $Term::_cols 1 \
- [string_to_regexp "(reverse-i-search)`': "]
-
- # Send "xyz".
- send_gdb "xyz"
- Term::wait_for_region_contents 0 $Term::_cur_row $Term::_cols 1 \
- [string_to_regexp "(failed reverse-i-search)`xyz': "]
-
- # Send arrow-right.
- send_gdb "\033\[C"
+ Term::clean_restart 24 80 $testfile
+}
- # We need to the arrow-right to be processed by readline, before we
- # send the following ^C. Waiting 1 ms seems to do that.
- after 1
+# Start TUI.
+if {![Term::enter_tui]} {
+ unsupported "TUI not supported"
+ return
+}
- # Send ^C.
+# Send "^R", starting reverse-i-search.
+send_gdb "\022"
+gdb_assert { [Term::wait_for_region_contents 0 $Term::_cur_row $Term::_cols 1 \
+ [string_to_regexp "(reverse-i-search)`': "]] } \
+ "reverse-i-search"
+
+# Send "xyz".
+send_gdb "xyz"
+gdb_assert { [Term::wait_for_region_contents 0 $Term::_cur_row $Term::_cols 1 \
+ [string_to_regexp "(failed reverse-i-search)`xyz': "]] } \
+ "xyz"
+
+# Send arrow-right.
+send_gdb "\033\[C"
+# Wait for arrow-right effect.
+gdb_assert { [Term::wait_for_region_contents 1 5 78 1 \
+ [string_to_regexp " ain (void)"]] } "arrow right"
+
+# Send ^C.
+send_gdb "\003"
+gdb_assert { [Term::wait_for "Quit"] } "Control-C"
+
+set test "Control-C aborts isearch"
+
+# Send "xyz", again.
+send_gdb "xyz"
+# Wait for xyx to appear.
+gdb_assert { [Term::wait_for_region_contents \
+ 0 $Term::_cur_row $Term::_cols 1 "xyz"] } \
+ "xyz, again"
+
+if { [Term::check_region_contents_p 0 $Term::_cur_row $Term::_cols 1 \
+ "^$gdb_prompt xyz"] } {
+ pass $test
+
+ # Send ^C to clear the command line.
send_gdb "\003"
- gdb_assert { [Term::wait_for "Quit"] } "Control-C"
-
- # Uncomment this to simulate that PR cli/30498 is fixed.
- #send_gdb "\007"
-
- set test "Control-C aborts isearch"
-
- # Send "xyz", again.
- send_gdb "xyz"
- # Wait for xyx to appear.
- Term::wait_for_region_contents 0 $Term::_cur_row $Term::_cols 1 "xyz"
-
- if { [Term::check_region_contents_p 0 $Term::_cur_row $Term::_cols 1 \
- "^$gdb_prompt xyz"] } {
- pass $test
-
- # Send ^C to clear the command line.
- send_gdb "\003"
- } else {
- # Sending ^C currently doesn't abort the i-search. PR cli/30498 is
- # open about this.
- kfail cli/30498 $test
-
- # At this point we don't have a responsive prompt. Send ^G to abort
- # the i-search.
- send_gdb "\007"
- }
-
- # We need a responsive prompt here, to deal with the "monitor exit"
- # that native-extended-gdbserver will send. Check that we have a
- # responsive prompt.
- Term::command "echo \\n"
+} else {
+ # Sending ^C currently doesn't abort the i-search.
+ fail $test
+
+ # At this point we don't have a responsive prompt. Send ^G to abort
+ # the i-search.
+ send_gdb "\007"
}
+
+# We need a responsive prompt here, to deal with the "monitor exit"
+# that native-extended-gdbserver will send. Check that we have a
+# responsive prompt.
+Term::command "echo \\n"
diff --git a/gdb/testsuite/gdb.tui/source-search.c b/gdb/testsuite/gdb.tui/source-search.c
new file mode 100644
index 0000000..2320c5c
--- /dev/null
+++ b/gdb/testsuite/gdb.tui/source-search.c
@@ -0,0 +1,127 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2025 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)
+{
+ /* Line 21 */
+ /* Line 22 */
+ /* Line 23 */
+ /* Line 24 */
+ /* Line 25 */
+ /* Line 26 */
+ /* Line 27 */
+ /* Line 28 */
+ /* Line 29 */
+ /* Line 30 */
+ /* Line 31 */
+ /* Line 32 */
+ /* Line 33 */
+ /* Line 34 */
+ /* Line 35 */
+ /* Line 36 */
+ /* Line 37 */
+ /* Line 38 */
+ /* Line 39 */
+ /* Line 40 */
+ /* Line 41 */
+ /* Line 42 */
+ /* Line 43 */
+ /* Line 44 */
+ /* Line 45 */
+ /* Line 46 */
+ /* Line 47 */
+ /* Line 48 */
+ /* Line 49 */
+ /* Line 50 */
+ /* Line 51 */
+ /* Line 52 */
+ /* Line 53 */
+ /* Line 54 */
+ /* Line 55 */
+ /* Line 56 */
+ /* Line 57 */
+ /* Line 58 */
+ /* Line 59 */
+ /* Line 60 */
+ /* Line 61 */
+ /* Line 62 */
+ /* Line 63 */
+ /* Line 64 */
+ /* Line 65 */
+ /* Line 66 */
+ /* Line 67 */
+ /* Line 68 */
+ /* Line 69 */
+ /* Line 70 */
+ /* Line 71 */
+ /* Line 72 */
+ /* Line 73 */
+ /* Line 74 */
+ /* Line 75 */
+ /* Line 76 */
+ /* Line 77 */
+ /* Line 78 */
+ /* Line 79 */
+ /* Line 80 */
+ /* Line 81 */
+ /* Line 82 */
+ /* Line 83 */
+ /* Line 84 */
+ /* Line 85 */
+ /* Line 86 */
+ /* Line 87 */
+ /* Line 88 */
+ /* Line 89 */
+ /* Line 90 */
+ /* Line 91 */
+ /* Line 92 */
+ /* Line 93 */
+ /* Line 94 */
+ /* Line 95 */
+ /* Line 96 */
+ /* Line 97 */
+ /* Line 98 */
+ /* Line 99 */
+ /* Line 100 */
+ /* Line 101 */
+ /* Line 102 */
+ /* Line 103 */
+ /* Line 104 */
+ /* Line 105 */
+ /* Line 106 */
+ /* Line 107 */
+ /* Line 108 */
+ /* Line 109 */
+ /* Line 110 */
+ /* Line 111 */
+ /* Line 112 */
+ /* Line 113 */
+ /* Line 114 */
+ /* Line 115 */
+ /* Line 116 */
+ /* Line 117 */
+ /* Line 118 */
+ /* Line 119 */
+ /* Line 120 */
+ /* Line 121 */
+ /* Line 122 */
+ /* Line 123 */
+ /* Line 124 */
+ /* Line 125 */
+ return 0;
+} /* Last line. */
diff --git a/gdb/testsuite/gdb.tui/source-search.exp b/gdb/testsuite/gdb.tui/source-search.exp
new file mode 100644
index 0000000..4fcdca3
--- /dev/null
+++ b/gdb/testsuite/gdb.tui/source-search.exp
@@ -0,0 +1,72 @@
+# Copyright 2025 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 forward-search and reverse-search within the TUI src window.
+
+tuiterm_env
+
+standard_testfile .c
+
+if {[build_executable "failed to build" ${testfile} ${srcfile}] == -1} {
+ return
+}
+
+Term::clean_restart 24 80 $testfile
+if {![Term::enter_tui]} {
+ unsupported "TUI not supported"
+ return
+}
+
+proc check_src_window { testname first_line } {
+ set last_line [expr {$first_line + 12}]
+ Term::check_box_contents $testname 0 0 80 15 \
+ "^\\s+${first_line}\\s+.*\\s+${last_line}\\s+/\\* Line ${last_line} \\*/\\s+$"
+
+}
+
+# Initialise the src window so that it is displaying known contents.
+# Check that the expected contents are displayed.
+Term::command "list 20"
+set first_line 15
+check_src_window "initial src contents" $first_line
+
+# Search forward. Searches are from the last line displayed, so this
+# will move the next source line onto the screen each time.
+for { set i 1 } { $i < 4 } { incr i } {
+ incr first_line
+ Term::command "forward-search Line"
+ check_src_window "src windows after forward-search $i" $first_line
+}
+
+# Reverse search. Like forward-search, but move backward through the
+# source.
+for { set i 1 } { $i < 3 } { incr i } {
+ incr first_line -1
+ Term::command "reverse-search Line"
+ check_src_window "src windows after reverse-search $i" $first_line
+}
+
+# Until there are no matching lines left.
+Term::command "reverse-search Line"
+gdb_assert {[regexp -- "^Expression not found\\s+$" [Term::get_line 22]]} \
+ "check start of source was reached"
+
+Term::command "forward-search Last line"
+Term::check_box_contents "forward-search to end of file" 0 0 80 15 \
+ "^\\s+122\\s+.*/\\* Last line\\. \\*/\\s+$"
+
+Term::command "reverse-search This testcase is part"
+Term::check_box_contents "reverse-search to start of file" 0 0 80 15 \
+ "^\\s+1\\s+.*\\s+13\\s+GNU General Public License for more details\\.\\s+$"
diff --git a/gdb/testsuite/gdb.tui/tui-disasm-long-lines.exp b/gdb/testsuite/gdb.tui/tui-disasm-long-lines.exp
index 35f990d..7a9841f 100644
--- a/gdb/testsuite/gdb.tui/tui-disasm-long-lines.exp
+++ b/gdb/testsuite/gdb.tui/tui-disasm-long-lines.exp
@@ -35,7 +35,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "$binfile" \
}
}
-Term::clean_restart 24 80 $binfile
+Term::clean_restart 24 80 $testfile
if {![Term::prepare_for_tui]} {
unsupported "TUI not supported"
return
diff --git a/gdb/testsuite/gdb.tui/tui-disasm-styling.exp b/gdb/testsuite/gdb.tui/tui-disasm-styling.exp
index 513d787..6859744 100644
--- a/gdb/testsuite/gdb.tui/tui-disasm-styling.exp
+++ b/gdb/testsuite/gdb.tui/tui-disasm-styling.exp
@@ -37,12 +37,15 @@ proc check_asm_output { expect_styled testname } {
$testname
}
-Term::clean_restart 24 80 $binfile
+Term::clean_restart 24 80 $testfile
if {![Term::enter_tui]} {
unsupported "TUI not supported"
return
}
+# Proc enter_tui switches off styling, re-enable it.
+Term::command "set style enabled on"
+
Term::command "layout asm"
Term::check_box "asm box" 0 0 80 15
diff --git a/gdb/testsuite/gdb.tui/tui-focus.exp b/gdb/testsuite/gdb.tui/tui-focus.exp
index 26e5060..50a3315 100644
--- a/gdb/testsuite/gdb.tui/tui-focus.exp
+++ b/gdb/testsuite/gdb.tui/tui-focus.exp
@@ -36,7 +36,7 @@ foreach spec {{src true} {cmd true} {status true} {regs false} \
lassign $spec window valid_p
with_test_prefix "window=$window" {
- Term::clean_restart 24 80 $binfile
+ Term::clean_restart 24 80 $testfile
if {![Term::prepare_for_tui]} {
unsupported "TUI not supported"
return
@@ -75,7 +75,7 @@ foreach spec {{src true} {cmd true} {status true} {regs false} \
# Use the Python TUI API to exercise some of the ambiguous window name
# handling parts of the 'focus' command.
-Term::clean_restart 24 80 $binfile
+Term::clean_restart 24 80 $testfile
if {[allow_python_tests]} {
# Create a very simple tui window.
gdb_py_test_silent_cmd \
diff --git a/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.S b/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.S
index 9d69236..6e36152 100644
--- a/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.S
+++ b/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.S
@@ -20,8 +20,11 @@ _start:
.rept 5
nop
.endr
+
+#ifndef __CYGWIN__
#ifdef __arm__
.section .note.GNU-stack,"",%progbits
#else
.section .note.GNU-stack,"",@progbits
#endif
+#endif
diff --git a/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp b/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp
index 51623e8..e21914b 100644
--- a/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp
+++ b/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp
@@ -20,9 +20,13 @@ tuiterm_env
standard_testfile tui-layout-asm-short-prog.S
-if {[build_executable "failed to prepare" ${testfile} ${srcfile} \
- {debug additional_flags=-nostdlib \
- additional_flags=-nostartfiles}] == -1} {
+set opts {}
+lappend opts debug
+lappend opts additional_flags=-static
+lappend opts additional_flags=-nostdlib
+lappend opts ldflags=-nostartfiles
+
+if { [build_executable "failed to prepare" $testfile $srcfile $opts] == -1 } {
return -1
}
@@ -53,7 +57,7 @@ gdb_assert { [string match "|___0x*" $first_line] } \
# Scroll forward a large amount, this should take us to the last
# instruction in the program.
-Term::command "+ 13"
+Term::command "+ 15"
Term::check_box_contents "check asm box contents again" 0 0 80 15 \
[multi_line \
"^___$hex\[^\r\n\]+" \
@@ -61,6 +65,6 @@ Term::check_box_contents "check asm box contents again" 0 0 80 15 \
# Now scroll backward again, we should return to the start of the
# program.
-Term::command "- 13"
+Term::command "- 15"
gdb_assert {[string eq "$first_line" [Term::get_line 1]]} \
"check first line is back"
diff --git a/gdb/testsuite/gdb.tui/tui-layout.exp b/gdb/testsuite/gdb.tui/tui-layout.exp
index 7bb0ea1..f604871 100644
--- a/gdb/testsuite/gdb.tui/tui-layout.exp
+++ b/gdb/testsuite/gdb.tui/tui-layout.exp
@@ -40,7 +40,7 @@ if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile}]} {
# happens to be in after a call to clean_restart.
proc test_layout_or_focus {layout_name terminal execution} {
- global binfile gdb_prompt
+ global gdb_prompt
set dumb_terminal [string equal $terminal "dumb"]
@@ -48,9 +48,9 @@ proc test_layout_or_focus {layout_name terminal execution} {
save_vars { env(TERM) } {
setenv TERM $terminal
if {$dumb_terminal} {
- clean_restart $binfile
+ clean_restart $::testfile
} else {
- Term::clean_restart 24 80 $binfile
+ Term::clean_restart 24 80 $::testfile
if {![Term::prepare_for_tui]} {
unsupported "TUI not supported"
return
diff --git a/gdb/testsuite/gdb.tui/tui-long-line.c b/gdb/testsuite/gdb.tui/tui-long-line.c
new file mode 100644
index 0000000..8f1d6eb
--- /dev/null
+++ b/gdb/testsuite/gdb.tui/tui-long-line.c
@@ -0,0 +1,24 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2025 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)
+{
+ /* This is a comment that is meant to be longer than the usual 80 characters width of a tuiterm. */
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.tui/tui-missing-src.exp b/gdb/testsuite/gdb.tui/tui-missing-src.exp
index f29ec8c..ae98775 100644
--- a/gdb/testsuite/gdb.tui/tui-missing-src.exp
+++ b/gdb/testsuite/gdb.tui/tui-missing-src.exp
@@ -27,6 +27,7 @@
# Check if start command is supported.
require !use_gdb_stub
+require allow_tui_tests
tuiterm_env
@@ -64,10 +65,8 @@ f2 (int x)
close $fd
# Step 3: Compile the source files.
-if { [gdb_compile "${srcfiles}" "${binfile}" \
- executable {debug additional_flags=-O0}] != "" } {
- untested "failed to compile"
- return -1
+if { [build_executable "failed to prepare" $testfile $srcfiles] == -1 } {
+ return
}
# Step 4: Remove the main.c file.
diff --git a/gdb/testsuite/gdb.tui/tui-mode-switch.exp b/gdb/testsuite/gdb.tui/tui-mode-switch.exp
new file mode 100644
index 0000000..c605962
--- /dev/null
+++ b/gdb/testsuite/gdb.tui/tui-mode-switch.exp
@@ -0,0 +1,57 @@
+require allow_tui_tests
+
+tuiterm_env
+
+if { [ishost *-*-*bsd*] } {
+ # We need support for alternate screen, and xterm doesn't have it.
+ set term xterm-clear
+} else {
+ set term xterm
+}
+
+Term::with_term $term {
+ Term::clean_restart 12 40
+}
+
+if {![Term::prepare_for_tui]} {
+ unsupported "TUI not supported"
+ return 0
+}
+
+# Generate prompt.
+Term::gen_prompt
+
+# Move to last line.
+for { set i 1 } { $i <= 11 } { incr i } {
+ send_gdb "\n"
+ Term::wait_for ""
+}
+
+# Type "foo".
+send_gdb "foo"
+set line { 0 11 40 1 }
+gdb_assert { [Term::wait_for_region_contents {*}$line "^$gdb_prompt foo"] } \
+ "type foo"
+
+# Enter TUI.
+send_gdb "\030\001"
+gdb_assert { [Term::wait_for ""] } "enter TUI"
+
+# Exit TUI.
+send_gdb "\030\001"
+gdb_assert { [Term::wait_for ""] } "exit TUI"
+
+# Type b.
+send_gdb "b"
+gdb_assert { [Term::wait_for_region_contents {*}$line "^$gdb_prompt b"] } \
+ "type b"
+
+# Check that we don't see "boo".
+gdb_assert { ![Term::check_region_contents_p {*}$line "^$gdb_prompt boo"] } \
+ "no boo"
+Term::dump_screen
+
+# We need an empty prompt here, to deal with the "monitor exit" that
+# native-extended-gdbserver will send. Send a backspace.
+send_gdb "\010"
+Term::wait_for ""
diff --git a/gdb/testsuite/gdb.tui/tuiterm-2.exp b/gdb/testsuite/gdb.tui/tuiterm-2.exp
index 5992271..9e3ddc7 100644
--- a/gdb/testsuite/gdb.tui/tuiterm-2.exp
+++ b/gdb/testsuite/gdb.tui/tuiterm-2.exp
@@ -106,6 +106,84 @@ with_override Term::accept_gdb_output test_accept_gdb_output {
}
gdb_assert { [Term::wait_for ""] }
}
+
+ with_test_prefix "Term::wait_for 2" {
+ Term::_setup 4 20
+ set send_cnt 0
+ set expect_send {}
+ set action_cnt 0
+ set actions {
+ {
+ Term::_move_cursor 0 0
+
+ Term::_insert "${::border}(gdb) "
+ set pos $Term::_cur_col
+
+ Term::_insert "foo"
+
+ Term::_move_cursor 19 0
+ Term::_insert "$::border"
+
+ Term::_move_cursor $pos 0
+ }
+ {
+ Term::_move_cursor 0 1
+
+ Term::_insert "${::border}(gdb) "
+ set pos $Term::_cur_col
+
+ Term::_move_cursor 19 1
+ Term::_insert "$::border"
+
+ Term::_move_cursor $pos 1
+ }
+ }
+
+ # Wait for a prompt.
+ gdb_assert { [Term::wait_for ""] }
+
+ # The first action sets the cursor after the prompt on the
+ # first line. The second action sets the cursor after the
+ # prompt on the second line. Check that wait_for returns
+ # after the second action, not the first.
+ gdb_assert { $Term::_cur_row == 1 }
+ }
}
}
}
+
+proc_with_prefix unrecognized_escape_sequence {} {
+ if { [spawn $::srcdir/$::subdir/gdb.sh] == 0 } {
+ unsupported "cannot spawn gdb.sh"
+ return
+ }
+ switch_gdb_spawn_id $spawn_id
+
+ Term::_setup 4 20
+
+ save_vars ::timeout {
+ set ::timeout 1
+
+ set line { 0 0 20 1 }
+
+ # Parse "foo".
+ gdb_assert { [Term::wait_for_region_contents \
+ {*}$line \
+ [string_to_regexp "foo"]] } \
+ "foo"
+
+ # Parse "\033(%5".
+ gdb_assert { ![Term::accept_gdb_output 0] } \
+ "fail to parse escape sequence"
+ gdb_assert { [Term::wait_for_region_contents \
+ {*}$line \
+ [string_to_regexp "^\[(%5"]] } \
+ "echoed escape sequence"
+ }
+ Term::dump_screen
+
+ close $spawn_id
+ clear_gdb_spawn_id
+}
+
+unrecognized_escape_sequence
diff --git a/gdb/testsuite/gdb.tui/tuiterm.exp b/gdb/testsuite/gdb.tui/tuiterm.exp
index 6cd65f3..a91643e 100644
--- a/gdb/testsuite/gdb.tui/tuiterm.exp
+++ b/gdb/testsuite/gdb.tui/tuiterm.exp
@@ -653,13 +653,21 @@ proc test_cursor_backward_tabulation { } {
}
proc test_repeat { } {
- Term::_move_cursor 2 1
- set Term::_last_char X
+ Term::_move_cursor 0 1
+
+ Term::_insert "xxX"
+ gdb_assert { $Term::_last_char == "X" }
+ check "insert" {
+ "abcdefgh"
+ "xxXlmnop"
+ "qrstuvwx"
+ "yz01234 "
+ } 3 1
- Term::_csi_b 3
+ Term::_csi_b 2
check "repeat" {
"abcdefgh"
- "ijXXXnop"
+ "xxXXXnop"
"qrstuvwx"
"yz01234 "
} 5 1
@@ -799,7 +807,7 @@ proc test_attrs {} {
proc run_one_test_small { test_proc_name } {
save_vars { env(TERM) stty_init } {
setup_small
- eval $test_proc_name
+ $test_proc_name
}
}
@@ -808,7 +816,7 @@ proc run_one_test_small { test_proc_name } {
proc run_one_test_large { test_proc_name } {
save_vars { env(TERM) stty_init } {
setup_large
- eval $test_proc_name
+ $test_proc_name
}
}
diff --git a/gdb/testsuite/gdb.tui/wrap-line.exp b/gdb/testsuite/gdb.tui/wrap-line.exp
index aa2b1c6..67ad36c 100644
--- a/gdb/testsuite/gdb.tui/wrap-line.exp
+++ b/gdb/testsuite/gdb.tui/wrap-line.exp
@@ -37,11 +37,11 @@ proc fill_line { width } {
# Take into account that the prompt also takes space.
set prefix [string length "(gdb) "]
- set start [expr $prefix + 1]
+ set start [expr {$prefix + 1}]
# Print chars.
for { set i $start } { $i <= $width } { incr i } {
- set c [expr $i % 10]
+ set c [expr {$i % 10}]
send_gdb $c
append res $c
}
@@ -59,7 +59,7 @@ proc test_wrap { wrap_width tui } {
set str [fill_line $wrap_width]
# Remaining space on line.
- set space [string repeat " " [expr $::cols - $wrap_width]]
+ set space [string repeat " " [expr {$::cols - $wrap_width}]]
# Now print the first char we expect to wrap.
send_gdb "W"
@@ -104,29 +104,35 @@ proc test_wrap_cli_tui { auto_detected_width } {
set re1 "Number of characters gdb thinks are in a line is ($::decimal)\\."
set re2 \
"Number of characters readline reports are in a line is ($::decimal)\\."
+ set re3 \
+ "Readline wrapping mode: (\[a-z\]+) \[\^\r\n]*"
set cmd "maint info screen"
set re \
[multi_line \
"^$re1" \
$re2 \
- ".*"]
+ ".*" \
+ $re3]
gdb_test_multiple $cmd "" {
-re -wrap $re {
set gdb_width $expect_out(1,string)
set readline_width $expect_out(2,string)
+ set wrapping_mode $expect_out(3,string)
pass $gdb_test_name
}
}
- gdb_assert { $gdb_width == $::cols } "width"
+ if { $wrapping_mode == "readline" } {
+ gdb_assert { $gdb_width == $::cols } "width"
- # TERM=ansi, so readline hides the last column.
- gdb_assert { $gdb_width == [expr $readline_width + 1] }
+ # TERM=ansi, so readline hides the last column.
+ gdb_assert { $gdb_width == [expr $readline_width + 1] }
- with_test_prefix cli {
- set wrap_width $readline_width
+ with_test_prefix cli {
+ set wrap_width $readline_width
- test_wrap $wrap_width 0
+ test_wrap $wrap_width 0
+ }
}
with_test_prefix tui {
@@ -172,7 +178,7 @@ with_test_prefix width-auto-detected {
set test "startup prompt"
gdb_test_multiple "" $test {
- -re "^$gdb_prompt $" {
+ -re "^(\033\\\[6n)?$gdb_prompt $" {
pass "$test"
}
}
diff --git a/gdb/testsuite/lib/ada.exp b/gdb/testsuite/lib/ada.exp
index 37bed85..50067eb 100644
--- a/gdb/testsuite/lib/ada.exp
+++ b/gdb/testsuite/lib/ada.exp
@@ -220,7 +220,8 @@ proc gnat_runtime_has_debug_info_1 { shared } {
return 0
}
- clean_restart $dst
+ clean_restart
+ gdb_load $dst
if { ! [runto "GNAT_Debug_Info_Test"] } {
return 0
diff --git a/gdb/testsuite/lib/cache.exp b/gdb/testsuite/lib/cache.exp
index 6ca3f18..4ebb825 100644
--- a/gdb/testsuite/lib/cache.exp
+++ b/gdb/testsuite/lib/cache.exp
@@ -24,26 +24,9 @@ proc ignore_pass { msg } {
# Call proc real_name and return the result, while ignoring calls to pass.
proc gdb_do_cache_wrap {real_name args} {
- if { [info procs save_pass] != "" } {
- return [uplevel 2 $real_name]
+ with_override pass ignore_pass {
+ return [uplevel 2 [list $real_name {*}$args]]
}
-
- rename pass save_pass
- rename ignore_pass pass
-
- set code [catch {uplevel 2 [list $real_name {*}$args]} result]
-
- rename pass ignore_pass
- rename save_pass pass
-
- if {$code == 1} {
- global errorInfo errorCode
- return -code error -errorinfo $errorInfo -errorcode $errorCode $result
- } elseif {$code > 1} {
- return -code $code $result
- }
-
- return $result
}
# Global written to by gdb_exit_called proc. Is set to true to
diff --git a/gdb/testsuite/lib/check-test-names.exp b/gdb/testsuite/lib/check-test-names.exp
index 049addd..d099ffc 100644
--- a/gdb/testsuite/lib/check-test-names.exp
+++ b/gdb/testsuite/lib/check-test-names.exp
@@ -146,7 +146,7 @@ namespace eval ::CheckTestNames {
# If ARGS is the empty list then we don't want to pass a single
# empty string as a parameter here.
- eval "CheckTestNames::log_summary $args"
+ CheckTestNames::log_summary {*}$args
if { [llength $args] == 0 } {
set which "count"
@@ -184,10 +184,10 @@ foreach nm {pass fail xfail kfail xpass kpass unresolved untested \
# Create new global log_summary to replace Dejagnu's.
proc log_summary { args } {
- eval "CheckTestNames::do_log_summary $args"
+ CheckTestNames::do_log_summary {*}$args
}
# Create new global reset_vars to replace Dejagnu's.
proc reset_vars {} {
- eval "CheckTestNames::do_reset_vars"
+ CheckTestNames::do_reset_vars
}
diff --git a/gdb/testsuite/lib/compile-support.exp b/gdb/testsuite/lib/compile-support.exp
index dd0b9a9..8472d8d 100644
--- a/gdb/testsuite/lib/compile-support.exp
+++ b/gdb/testsuite/lib/compile-support.exp
@@ -265,7 +265,7 @@ namespace eval ::CompileExpression {
if {[string match $cmd "print"]} {
if {!$is_explicit} {
- eval setup_failures_ $fail_print
+ setup_failures_ {*}$fail_print
return [compile_command_ "compile print $exp" $result $tst]
}
} else {
@@ -274,11 +274,11 @@ namespace eval ::CompileExpression {
} else {
set command "compile code $varName_ = $exp"
}
- eval setup_failures_ $fail_compile
+ setup_failures_ {*}$fail_compile
if {![compile_command_ $command "" $tst]} {
return 0
}
- eval setup_failures_ $fail_value
+ setup_failures_ {*}$fail_value
gdb_test "p $varName_" "= $result" "result of $tst"
}
return 1
@@ -292,11 +292,11 @@ namespace eval ::CompileExpression {
proc setup_failures_ {how args} {
switch -nocase $how {
xfail {
- eval setup_xfail $args
+ setup_xfail {*}$args
}
kfail {
- eval setup_kfail $args
+ setup_kfail {*}$args
}
default {
diff --git a/gdb/testsuite/lib/dap-support.exp b/gdb/testsuite/lib/dap-support.exp
index d61b1c4..5c078ca 100644
--- a/gdb/testsuite/lib/dap-support.exp
+++ b/gdb/testsuite/lib/dap-support.exp
@@ -117,6 +117,7 @@ proc dap_to_ton {obj} {
# Format the object OBJ, in TON format, as JSON and send it to gdb.
proc _dap_send_ton {obj} {
+ # tclint-disable-next-line command-args
set json [namespace eval ton::2json $obj]
# FIXME this is wrong for non-ASCII characters.
set len [string length $json]
@@ -170,7 +171,7 @@ proc _dap_read_json {} {
}
if {$seen_timeout} {
- error "timeout reading json header"
+ error "timeout reading json header"
}
if {$seen_eof} {
error "eof reading json header"
@@ -200,7 +201,7 @@ proc _dap_read_json {} {
}
if {$seen_timeout} {
- error "timeout reading json header"
+ error "timeout reading json header"
}
if {$seen_eof} {
error "eof reading json header"
@@ -211,6 +212,7 @@ proc _dap_read_json {} {
global last_ton
set last_ton [ton::json2ton $json]
+ # tclint-disable-next-line command-args
return [namespace eval ton::2dict $last_ton]
}
@@ -229,9 +231,9 @@ proc dap_read_response {cmd num} {
set d [_dap_read_json]
if {[dict get $d type] == "response"} {
if {[dict get $d request_seq] != $num} {
- error "saw wrong request_seq in $obj"
+ error "saw wrong request_seq in $d"
} elseif {[dict get $d command] != $cmd} {
- error "saw wrong command in $obj"
+ error "saw wrong command in $d"
} else {
return [list $d $result]
}
@@ -443,7 +445,7 @@ proc dap_search_output {name rx events} {
# key/value pairs given in ARGS. NAME is used as the test name.
proc dap_match_values {name d args} {
foreach {key value} $args {
- if {[eval dict get [list $d] $key] != $value} {
+ if {[dict get $d {*}$key] != $value} {
fail "$name (checking $key)"
return ""
}
@@ -494,7 +496,7 @@ proc dap_wait_for_event_and_check {name type args} {
set result [_dap_wait_for_event $type]
set event [lindex $result 0]
- eval dap_match_values [list $name $event] $args
+ dap_match_values $name $event {*}$args
return $result
}
diff --git a/gdb/testsuite/lib/debuginfod-support.exp b/gdb/testsuite/lib/debuginfod-support.exp
index 674888a..7a8baf4 100644
--- a/gdb/testsuite/lib/debuginfod-support.exp
+++ b/gdb/testsuite/lib/debuginfod-support.exp
@@ -37,7 +37,7 @@ proc allow_debuginfod_tests {} {
# (installed by ASan) exist on startup. That makes TCL's exec throw an
# error. This is dealt with by the --quiet in INTERNAL_GDBFLAGS.
if { [string first "with-debuginfod" \
- [eval exec $::GDB $::INTERNAL_GDBFLAGS \
+ [exec $::GDB {*}$::INTERNAL_GDBFLAGS \
--configuration]] == -1 } {
return false
}
diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index 3a182c2..911ec88 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -461,16 +461,13 @@ proc get_func_info { name {options {debug}} } {
#
# proc DW_TAG_mumble {{attrs {}} {children {}}} { ... }
#
-# ATTRS is an optional list of attributes.
-# It is run through 'subst' in the caller's context before processing.
+# ATTRS holds optional attributes. It is just Tcl code and is
+# evaluated in the caller's context. Each attribute is a proc of the
+# form:
#
-# Each attribute in the list has one of two forms:
-# 1. { NAME VALUE }
-# 2. { NAME VALUE FORM }
+# proc DW_AT_mumble {value {form {}}} { ... }
#
-# In each case, NAME is the attribute's name.
-# This can either be the full name, like 'DW_AT_name', or a shortened
-# name, like 'name'. These are fully equivalent.
+# Only the full name can be used here.
#
# Besides DWARF standard attributes, assembler supports 'macro' attribute
# which will be substituted by one or more standard or macro attributes.
@@ -522,8 +519,6 @@ namespace eval Dwarf {
# Constants from dwarf2.h.
variable _constants
- # DW_AT short names.
- variable _AT
# DW_FORM short names.
variable _FORM
# DW_OP short names.
@@ -594,7 +589,6 @@ namespace eval Dwarf {
proc _process_one_constant {name value} {
variable _constants
- variable _AT
variable _FORM
variable _OP
@@ -633,7 +627,8 @@ namespace eval Dwarf {
}
AT {
- set _AT($name2) $name
+ proc $name {value {form {}}} \
+ "_handle_DW_AT $name \$value \$form"
}
FORM {
@@ -917,11 +912,27 @@ namespace eval Dwarf {
return $name
}
- proc _handle_attribute { attr_name attr_value attr_form } {
+ # Implementation of all the DW_AT_* procs.
+ proc _handle_DW_AT {attr_name attr_value attr_form} {
variable _abbrev_section
variable _constants
variable _cu_version
+ if {$attr_form == ""} {
+ set attr_form [_guess_form $attr_value attr_value]
+ if { $attr_form eq "" } {
+ set attr_form [_default_form $attr_name]
+ }
+ if { $attr_form eq "" } {
+ error "No form for $attr_name $attr_value"
+ }
+ } elseif { [string index $attr_value 0] == ":" } {
+ # It is a label, get its value.
+ _guess_form $attr_value attr_value
+ }
+
+ set attr_form [_map_name $attr_form _FORM]
+
_handle_DW_FORM $attr_form $attr_value
_defer_output $_abbrev_section {
@@ -942,9 +953,8 @@ namespace eval Dwarf {
}
}
- # Handle macro attribute MACRO_AT_range.
-
- proc _handle_macro_at_range { attr_value } {
+ # Handle extension attribute MACRO_AT_range.
+ proc MACRO_AT_range { attr_value } {
variable _cu_is_fission
if {[llength $attr_value] != 1} {
@@ -961,19 +971,17 @@ namespace eval Dwarf {
set form DW_FORM_GNU_addr_index
}
- _handle_attribute DW_AT_low_pc [lindex $result 0] $form
- _handle_attribute DW_AT_high_pc \
- "[lindex $result 0] + [lindex $result 1]" $form
+ DW_AT_low_pc [lindex $result 0] $form
+ DW_AT_high_pc "[lindex $result 0] + [lindex $result 1]" $form
}
- # Handle macro attribute MACRO_AT_func.
-
- proc _handle_macro_at_func { attr_value } {
+ # Handle extension attribute MACRO_AT_func.
+ proc MACRO_AT_func { attr_value } {
if {[llength $attr_value] != 1} {
error "usage: MACRO_AT_func { func file }"
}
- _handle_attribute DW_AT_name [lindex $attr_value 0] DW_FORM_string
- _handle_macro_at_range $attr_value
+ DW_AT_name [lindex $attr_value 0] DW_FORM_string
+ MACRO_AT_range $attr_value
}
# Return the next available abbrev number in the current CU's abbrev
@@ -1003,47 +1011,7 @@ namespace eval Dwarf {
_op .uleb128 $my_abbrev "Abbrev ($tag_name)"
- foreach attr $attrs {
- set attr_name [_map_name [lindex $attr 0] _AT]
-
- # When the length of ATTR is greater than 2, the last
- # element of the list must be a form. The second through
- # the penultimate elements are joined together and
- # evaluated using subst. This allows constructs such as
- # [gdb_target_symbol foo] to be used.
-
- if {[llength $attr] > 2} {
- set attr_value [uplevel 2 [list subst [join [lrange $attr 1 end-1]]]]
- } else {
- set attr_value [uplevel 2 [list subst [lindex $attr 1]]]
- }
-
- if { [string equal "MACRO_AT_func" $attr_name] } {
- _handle_macro_at_func $attr_value
- } elseif { [string equal "MACRO_AT_range" $attr_name] } {
- _handle_macro_at_range $attr_value
- } else {
- if {[llength $attr] > 2} {
- set attr_form [uplevel 2 [list subst [lindex $attr end]]]
-
- if { [string index $attr_value 0] == ":" } {
- # It is a label, get its value.
- _guess_form $attr_value attr_value
- }
- } else {
- set attr_form [_guess_form $attr_value attr_value]
- if { $attr_form eq "" } {
- set attr_form [_default_form $attr_name]
- }
- if { $attr_form eq "" } {
- error "No form for $attr_name $attr_value"
- }
- }
- set attr_form [_map_name $attr_form _FORM]
-
- _handle_attribute $attr_name $attr_value $attr_form
- }
- }
+ uplevel 2 $attrs
_defer_output $_abbrev_section {
# Terminator.
@@ -1094,7 +1062,7 @@ namespace eval Dwarf {
if {![info exists _deferred_output($_defer)]} {
set _deferred_output($_defer) ""
- eval _section $section_spec
+ _section {*}$section_spec
}
uplevel $body
diff --git a/gdb/testsuite/lib/future.exp b/gdb/testsuite/lib/future.exp
index 161c31c..6643187 100644
--- a/gdb/testsuite/lib/future.exp
+++ b/gdb/testsuite/lib/future.exp
@@ -749,19 +749,6 @@ if { [array size use_gdb_compile] != 0 } {
rename gdb_default_target_compile ""
}
-
-# Provide 'lreverse' missing in Tcl before 7.5.
-
-if {[info procs lreverse] == ""} {
- proc lreverse { arg } {
- set retval {}
- while { [llength $retval] < [llength $arg] } {
- lappend retval [lindex $arg end-[llength $retval]]
- }
- return $retval
- }
-}
-
# Various ccache versions provide incorrect debug info such as ignoring
# different current directory, breaking GDB testsuite.
set env(CCACHE_DISABLE) 1
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 98691df..9497850 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -15,6 +15,8 @@
# This file was written by Fred Fish. (fnf@cygnus.com)
+package require Tcl 8.6.2
+
# Generic gdb subroutines that should work for any target. If these
# need to be modified for any target, it can be done with a variable
# or by passing arguments.
@@ -274,7 +276,7 @@ if ![info exists INTERNAL_GDBFLAGS] {
append INTERNAL_GDBFLAGS { -iex "set interactive-mode on"}
if { [ishost "*-*-mingw*"] } {
- append INTERNAL_GDBFLAGS { -iex "maint set console-translation-mode binary"}
+ append INTERNAL_GDBFLAGS { --binary-output}
}
}
@@ -356,7 +358,7 @@ proc default_gdb_version {} {
global inotify_pid
if {[info exists inotify_pid]} {
- eval exec kill $inotify_pid
+ exec kill $inotify_pid
}
set output [remote_exec host "$GDB $INTERNAL_GDBFLAGS --version"]
@@ -1678,76 +1680,9 @@ proc python_version_at_least { major minor } {
# Return 1 if tcl version used is at least MAJOR.MINOR.PATCHLEVEL.
proc tcl_version_at_least { major minor {patchlevel 0} } {
- global tcl_patchLevel
- regexp {^([0-9]+)\.([0-9]+)\.([0-9]+)$} \
- $tcl_patchLevel dummy \
- tcl_version_major tcl_version_minor tcl_version_patchlevel
- return \
- [version_compare \
- [list \
- $major \
- $minor \
- $patchlevel] \
- <= \
- [list \
- $tcl_version_major \
- $tcl_version_minor \
- $tcl_version_patchlevel]]
-}
-
-if { [tcl_version_at_least 8 5] == 0 } {
- # lrepeat was added in tcl 8.5. Only add if missing.
- proc lrepeat { n element } {
- if { [string is integer -strict $n] == 0 } {
- error "expected integer but got \"$n\""
- }
- if { $n < 0 } {
- error "bad count \"$n\": must be integer >= 0"
- }
- set res [list]
- for {set i 0} {$i < $n} {incr i} {
- lappend res $element
- }
- return $res
- }
-}
-
-if { [tcl_version_at_least 8 6] == 0 } {
- # lmap was added in tcl 8.6. Only add if missing.
-
- # Note that we only implement the simple variant for now.
- proc lmap { varname list body } {
- set res {}
- foreach val $list {
- uplevel 1 "set $varname $val"
- lappend res [uplevel 1 $body]
- }
-
- return $res
- }
-
- # ::tcl_platform(pathSeparator) was added in 8.6.
- switch $::tcl_platform(platform) {
- windows {
- set ::tcl_platform(pathSeparator) ;
- }
- default {
- set ::tcl_platform(pathSeparator) :
- }
- }
-}
-
-if { [tcl_version_at_least 8 6 2] == 0 } {
- # string cat was added in tcl 8.6.2. Only add if missing.
-
- rename string tcl_proc_string
-
- proc string { what args } {
- if { $what == "cat" } {
- return [join $args ""]
- }
- return [tcl_proc_string $what {*}$args]
- }
+ set current_version [package require Tcl]
+ set min_version "$major.$minor.$patchlevel"
+ return [expr {[package vcompare $current_version $min_version] >= 0}]
}
# gdb_test_no_output [-prompt PROMPT_REGEXP] [-nopass] COMMAND [MESSAGE]
@@ -2252,6 +2187,209 @@ proc gdb_assert { condition {message ""} } {
return $res
}
+# Comparison command for "lsort -command". Sorts two strings by
+# descending file name length.
+
+proc compare_length_desc {a b} {
+ expr {[string length $b] - [string length $a]}
+}
+
+# Fill in and return the global cache for Windows <=> Unix mount point
+# mappings, for Windows.
+#
+# Calling external processes on MSYS2/Cygwin is expensive so instead
+# of calling "cygpath -ua $FILENAME" or "cygpath -ma $FILENAME" for
+# every file name, we extract the Windows and Unix file names of each
+# mount point using the 'mount' command output, and cache the
+# mappings, for both directions.
+
+gdb_caching_proc get_mount_point_map {} {
+ array set win_to_unix {}
+ array set unix_to_win {}
+
+ # The 'mount' command provides all mappings. The general format
+ # is: 'WindowsFileName on UnixFileName type ...'
+ #
+ # For example:
+ # 'C:/msys64 on / type ntfs (binary,auto)'
+ # 'C: on /c type ntfs (binary,posix=0,user,noumount,auto)'
+ set mount_output [exec mount]
+
+ foreach line [split $mount_output \n] {
+ if {[regexp {^(.+) on (.+) type } $line -> win_filename unix_filename]} {
+ set win_to_unix($win_filename) $unix_filename
+ set unix_to_win($unix_filename) $win_filename
+ }
+ }
+
+ # Sort each mapping's keys by descending file name length,
+ # otherwise we wouldn't be able to look for '/foo' in '/' (for
+ # example).
+
+ set sorted_win {}
+ foreach k [lsort -command compare_length_desc [array names win_to_unix]] {
+ lappend sorted_win $k $win_to_unix($k)
+ }
+
+ set sorted_unix {}
+ foreach k [lsort -command compare_length_desc [array names unix_to_win]] {
+ lappend sorted_unix $k $unix_to_win($k)
+ }
+
+ # Return both sorted lists: {win => unix} {unix => win}
+ return [list $sorted_win $sorted_unix]
+}
+
+# Normalize backward slashes to forward slashes.
+
+proc normalize_slashes {filename} {
+ return [string map {\\ /} $filename]
+}
+
+# Sanitize a host file name, without making it absolute or resolving
+# symlinks. On native Windows, this normalizes slashes to forward
+# slashes, and makes sure that if the file name starts with a drive
+# letter, it is upper case. On other systems, it just returns the
+# file name unmodified.
+
+proc host_file_sanitize {filename} {
+ if {[ishost *-*-mingw*]} {
+ set filename [normalize_slashes $filename]
+
+ # If the file name starts with a drive letter, uppercase it.
+ if {[regexp {^([a-zA-Z]):(/.*)?} $filename -> drive rest]} {
+ set filename "[string toupper $drive]:$rest"
+ }
+ }
+
+ return $filename
+}
+
+# Normalize a file name for the build machine. If running native
+# Windows GDB, this converts a Windows file name to the corresponding
+# Unix filename, per the mount table. For example, this replaces
+# 'c:/foo' with '/c/foo' (on MSYS2) or '/cygdrive/c/foo' (on Cygwin).
+# On other systems, it just wraps "file normalize".
+
+proc build_file_normalize {filename} {
+ if {[ishost *-*-mingw*]} {
+ set filename [host_file_sanitize $filename]
+
+ # Handle Windows => Unix mount point conversion. We assume
+ # there are no symlinks to resolve, which is a reasonable
+ # assumption for native Windows testing.
+
+ # Get Windows => Unix map.
+ lassign [get_mount_point_map] win_to_unix _
+
+ foreach {win_filename unix_filename} $win_to_unix {
+ if {[string equal -length [string length $win_filename] \
+ $win_filename $filename]} {
+ set rest [string range $filename \
+ [string length $win_filename] end]
+ return "${unix_filename}$rest"
+ }
+ }
+ }
+
+ return [file normalize $filename]
+}
+
+# Normalize a file name for the host machine and native Windows GDB.
+# This converts a Unix file name to a Windows filename,
+# per the mount table. E.g., '/c/foo' (on MSYS2) or '/cygdrive/c/foo'
+# (on Cygwin) is converted to 'c:/foo'.
+
+proc host_file_normalize_mingw {filename unix_to_win} {
+ set filename [host_file_sanitize $filename]
+
+ # If the file name already starts with a drive letter (e.g.,
+ # C:/foo), we're done. Don't let it fallthrough to "file
+ # normalize", which would misinterpret it as a relative file
+ # name.
+ if {[regexp {^[A-Z]:/} $filename]} {
+ return $filename
+ }
+
+ # Collapse all repeated forward slashes.
+ set filename [regsub -all {//+} $filename {/}]
+
+ # Strip trailing slash, except for root.
+ if {$filename ne "/" && [string match */ $filename]} {
+ set filename [string range $filename 0 end-1]
+ }
+
+ foreach {unix_filename win_filename} $unix_to_win {
+ set mount_len [string length $unix_filename]
+ if {[string equal -length $mount_len $unix_filename $filename]} {
+ if {$unix_filename eq "/"} {
+ if {$filename eq "/"} {
+ return "$win_filename"
+ } else {
+ return "$win_filename$filename"
+ }
+ } elseif {[string length $filename] == $mount_len} {
+ # Like "cygpath -ma" if the file name resolves to a
+ # drive letter, append a slash, to make it unambiguous
+ # that we resolved to the root of the drive and not
+ # the drive's current directory.
+ if {[string match {[A-Za-z]:} $win_filename]} {
+ return "$win_filename/"
+ } else {
+ return "$win_filename"
+ }
+ } elseif {[string index $filename $mount_len] eq "/"} {
+ set rest [string range $filename $mount_len end]
+ return "$win_filename$rest"
+ }
+ }
+ }
+
+ return [file normalize $filename]
+}
+
+# Normalize a file name for the host machine. If running native
+# Windows GDB, this converts a Unix file name to a Windows filename,
+# per the mount table. E.g., '/c/foo' (on MSYS2) or '/cygdrive/c/foo'
+# (on Cygwin) is converted to 'c:/foo'.
+
+proc host_file_normalize {filename} {
+ if {[ishost *-*-mingw*]} {
+ # Get Unix => Windows map.
+ lassign [get_mount_point_map] _ unix_to_win
+ return [host_file_normalize_mingw $filename $unix_to_win]
+ }
+
+ return [file normalize $filename]
+}
+
+# Wrapper around "file join" that handles host-specific details.
+#
+# For Cygwin/MSYS2's Tcl, file names that start with a drive letter
+# are not considered absolute file names, thus 'file join "c:/" "d:/"'
+# returns "c:/d:". This procedure thus detects absolute Windows-style
+# file names, and treats them as absolute, bypassing "file join".
+
+proc host_file_join {args} {
+ if {[isbuild *-*-mingw*]} {
+ set result ""
+ foreach filename $args {
+ set filename [host_file_sanitize $filename]
+
+ # If the file name starts with drive letter and colon
+ # (e.g., "C:/"), treat it as absolute.
+ if {[regexp {^[A-Z]:/} $filename]} {
+ set result $filename
+ } else {
+ set result [file join $result $filename]
+ }
+ }
+ return $result
+ } else {
+ return [file join {*}$args]
+ }
+}
+
proc gdb_reinitialize_dir { subdir } {
global gdb_prompt
@@ -2266,7 +2404,8 @@ proc gdb_reinitialize_dir { subdir } {
}
gdb_expect 60 {
-re "Source directories searched.*$gdb_prompt $" {
- send_gdb "dir $subdir\n"
+ set dir [host_file_normalize $subdir]
+ send_gdb "dir $dir\n"
gdb_expect 60 {
-re "Source directories searched.*$gdb_prompt $" {
verbose "Dir set to $subdir"
@@ -2852,11 +2991,6 @@ gdb_caching_proc allow_dap_tests {} {
return 0
}
- # ton.tcl uses "string is entier", supported starting tcl 8.6.
- if { ![tcl_version_at_least 8 6] } {
- return 0
- }
-
# With set auto-connect-native-target off, we run into:
# +++ run
# Traceback (most recent call last):
@@ -2988,6 +3122,10 @@ gdb_caching_proc allow_dlmopen_tests {} {
# Return 1 if we should allow TUI-related tests.
gdb_caching_proc allow_tui_tests {} {
+ if { [istarget *-*-mingw*] } {
+ # Avoid "Cannot enable the TUI when output is not a terminal".
+ return 0
+ }
set output [remote_exec host $::GDB "$::INTERNAL_GDBFLAGS --configuration"]
return [expr {[string first "--enable-tui" $output] != -1}]
}
@@ -4294,6 +4432,76 @@ gdb_caching_proc allow_tsx_tests {} {
return $allow_tsx_tests
}
+# Run a test on the target to check if it supports x86 shadow stack. Return 1
+# if shadow stack is enabled, 0 otherwise.
+
+gdb_caching_proc allow_ssp_tests {} {
+ global srcdir subdir gdb_prompt hex
+
+ set me "allow_ssp_tests"
+
+ if { ![istarget i?86-*-*] && ![istarget x86_64-*-* ] } {
+ verbose "$me: target known to not support shadow stack."
+ return 0
+ }
+
+ # There is no need to check the actual HW in addition to ptrace support.
+ # We need both checks and ptrace will tell us about the HW state.
+ set compile_flags "{additional_flags=-fcf-protection=return}"
+ set src { int main() { return 0; } }
+ if {![gdb_simple_compile $me $src executable $compile_flags]} {
+ return 0
+ }
+
+ save_vars { ::env(GLIBC_TUNABLES) } {
+
+ append_environment GLIBC_TUNABLES "glibc.cpu.hwcaps" "SHSTK"
+
+ # No error message, compilation succeeded so now run it via gdb.
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+ gdb_load $obj
+ if {![runto_main]} {
+ remote_file build delete $obj
+ return 0
+ }
+ set shadow_stack_disabled_re "(<unavailable>)"
+ if {[istarget *-*-linux*]} {
+ # Starting with v6.6, the Linux kernel supports CET shadow stack.
+ # Dependent on the target we can see a nullptr or "<unavailable>"
+ # when shadow stack is supported by HW and the Linux kernel but
+ # not enabled for the current thread (for example due to a lack
+ # of compiler or glibc support for -fcf-protection).
+ set shadow_stack_disabled_re "$shadow_stack_disabled_re|(.*0x0)"
+ }
+
+ set allow_ssp_tests 0
+ gdb_test_multiple "print \$pl3_ssp" "test shadow stack support" {
+ -re -wrap "(.*$hex)((?!(.*0x0)).)" {
+ verbose -log "$me: Shadow stack support detected."
+ set allow_ssp_tests 1
+ }
+ -re -wrap $shadow_stack_disabled_re {
+ # In case shadow stack is not enabled (for example due to a
+ # lack of compiler or glibc support for -fcf-protection).
+ verbose -log "$me: Shadow stack is not enabled."
+ }
+ -re -wrap "void" {
+ # In case we don't have hardware or kernel support.
+ verbose -log "$me: No shadow stack support."
+ }
+ }
+
+ gdb_exit
+ }
+
+ remote_file build delete $obj
+
+ verbose "$me: returning $allow_ssp_tests" 2
+ return $allow_ssp_tests
+}
+
# Run a test on the target to see if it supports avx512bf16. Return 1 if so,
# 0 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite.
@@ -4436,7 +4644,8 @@ gdb_caching_proc allow_lam_tests {} {
# No error message, compilation succeeded so now run it via gdb.
set allow_lam_tests 0
- clean_restart $obj
+ clean_restart
+ gdb_load $obj
gdb_run_cmd
gdb_expect {
-re ".*$inferior_exited_re with code.*${gdb_prompt} $" {
@@ -4719,7 +4928,8 @@ gdb_caching_proc allow_aarch64_sve_tests {} {
}
# Compilation succeeded so now run it via gdb.
- clean_restart $obj
+ clean_restart
+ gdb_load $obj
gdb_run_cmd
gdb_expect {
-re ".*Illegal instruction.*${gdb_prompt} $" {
@@ -4779,7 +4989,8 @@ gdb_caching_proc aarch64_initialize_sve_information { } {
return [array get supported_vl]
}
- clean_restart $test_exec
+ clean_restart
+ gdb_load $test_exec
if {![runto_main]} {
return [array get supported_vl]
@@ -4876,7 +5087,8 @@ gdb_caching_proc allow_aarch64_sme_tests {} {
}
# Compilation succeeded so now run it via gdb.
- clean_restart $obj
+ clean_restart
+ gdb_load $obj
gdb_run_cmd
gdb_expect {
-re ".*Illegal instruction.*${gdb_prompt} $" {
@@ -4936,7 +5148,8 @@ gdb_caching_proc aarch64_initialize_sme_information { } {
return [array get supported_svl]
}
- clean_restart $test_exec
+ clean_restart
+ gdb_load $test_exec
if {![runto_main]} {
return [array get supported_svl]
@@ -5030,7 +5243,8 @@ gdb_caching_proc allow_aarch64_mops_tests {} {
}
# Compilation succeeded so now run it via gdb.
- clean_restart $obj
+ clean_restart
+ gdb_load $obj
gdb_run_cmd
gdb_expect {
-re ".*$inferior_exited_re with code 01.*${gdb_prompt} $" {
@@ -5053,6 +5267,61 @@ gdb_caching_proc allow_aarch64_mops_tests {} {
return $allow_mops_tests
}
+# Run a test on the target to see if it supports AArch64 GCS extensions.
+# Return 1 if so, 0 if it does not. Note this causes a restart of GDB.
+
+gdb_caching_proc allow_aarch64_gcs_tests {} {
+ global srcdir subdir gdb_prompt inferior_exited_re
+
+ set me "allow_aarch64_gcs_tests"
+
+ if { ![is_aarch64_target]} {
+ return 0
+ }
+
+ # Compile a program that tests the GCS feature.
+ set src {
+ #include <stdbool.h>
+ #include <sys/auxv.h>
+
+ /* Feature check for Guarded Control Stack. */
+ #ifndef HWCAP_GCS
+ #define HWCAP_GCS (1ULL << 32)
+ #endif
+
+ int main (void) {
+ bool gcs_supported = getauxval (AT_HWCAP) & HWCAP_GCS;
+
+ /* Return success if GCS is supported. */
+ return !gcs_supported;
+ }
+ }
+
+ if {![gdb_simple_compile $me $src executable]} {
+ return 0
+ }
+
+ # Compilation succeeded so now run it via gdb.
+ set allow_gcs_tests 0
+ clean_restart
+ gdb_load $obj
+ gdb_run_cmd
+ gdb_expect {
+ -re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
+ verbose -log "\n$me: gcs support detected"
+ set allow_gcs_tests 1
+ }
+ -re ".*$inferior_exited_re with code 01.*${gdb_prompt} $" {
+ verbose -log "\n$me: gcs support not detected"
+ }
+ }
+ gdb_exit
+ remote_file build delete $obj
+
+ verbose "$me: returning $allow_gcs_tests" 2
+ return $allow_gcs_tests
+}
+
# A helper that compiles a test case to see if __int128 is supported.
proc gdb_int128_helper {lang} {
return [gdb_can_simple_compile "i128-for-$lang" {
@@ -5086,7 +5355,7 @@ gdb_caching_proc allow_ifunc_tests {} {
}
# Return whether we should skip tests for showing inlined functions in
-# backtraces. Requires get_compiler_info and get_debug_format.
+# backtraces. Requires get_debug_format.
proc skip_inline_frame_tests {} {
# GDB only recognizes inlining information in DWARF.
@@ -5105,7 +5374,7 @@ proc skip_inline_frame_tests {} {
}
# Return whether we should skip tests for showing variables from
-# inlined functions. Requires get_compiler_info and get_debug_format.
+# inlined functions. Requires get_debug_format.
proc skip_inline_var_tests {} {
# GDB only recognizes inlining information in DWARF.
@@ -5377,14 +5646,6 @@ gdb_caching_proc target_is_gdbserver {} {
return $is_gdbserver
}
-# N.B. compiler_info is intended to be local to this file.
-# Call test_compiler_info with no arguments to fetch its value.
-# Yes, this is counterintuitive when there's get_compiler_info,
-# but that's the current API.
-if [info exists compiler_info] {
- unset compiler_info
-}
-
# Figure out what compiler I am using.
# The result is cached so only the first invocation runs the compiler.
#
@@ -5436,8 +5697,18 @@ if [info exists compiler_info] {
# I didn't get desperate enough to try this.
#
# -- chastain 2004-01-06
+#
+# Returns "unsupported" if LANGUAGE is not supported, and "unknown" if
+# LANGUAGE is supported but extracting the information out of the
+# compiler for LANGUAGE failed. Otherwise returns the compiler we're
+# using for LANGUAGE.
proc get_compiler_info {{language "c"}} {
+ # Split to a helper procedure because gdb_caching_proc does not
+ # support optional arguments.
+ return [get_compiler_info_1 $language]
+}
+gdb_caching_proc get_compiler_info_1 {language} {
# For compiler.c, compiler.cc and compiler.F90.
global srcdir
@@ -5446,13 +5717,8 @@ proc get_compiler_info {{language "c"}} {
global outdir
global tool
- # These come from compiler.c, compiler.cc or compiler.F90.
- gdb_persistent_global compiler_info_cache
-
- if [info exists compiler_info_cache($language)] {
- # Already computed.
- return 0
- }
+ # 'compiler_info' comes from evaluating the result of
+ # preprocessing compiler.c, compiler.cc or compiler.F90.
# Choose which file to preprocess.
if { $language == "c++" } {
@@ -5463,7 +5729,7 @@ proc get_compiler_info {{language "c"}} {
set ifile "${srcdir}/lib/compiler.c"
} else {
perror "Unable to fetch compiler version for language: $language"
- return -1
+ return "unsupported"
}
# Run $ifile through the right preprocessor.
@@ -5487,7 +5753,7 @@ proc get_compiler_info {{language "c"}} {
set ifile $tofile
set cppout [ gdb_compile "${ifile}" "" preprocess [list "$language" quiet getting_compiler_info] ]
}
- eval log_file $saved_log
+ log_file {*}$saved_log
# Eval the output.
set unknown 0
@@ -5525,22 +5791,21 @@ proc get_compiler_info {{language "c"}} {
set compiler_info "unknown"
}
- set compiler_info_cache($language) $compiler_info
-
# Log what happened.
verbose -log "get_compiler_info: $compiler_info"
- return 0
+ return $compiler_info
}
-# Return the compiler_info string if no arg is provided.
-# Otherwise the argument is a glob-style expression to match against
-# compiler_info.
+# Return the compiler_info string if COMPILER is not provided.
+# Otherwise COMPILER is a glob-style expression to match against
+# compiler_info, and this returns true/false depending on whether the
+# expression matches or not.
proc test_compiler_info { {compiler ""} {language "c"} } {
- gdb_persistent_global compiler_info_cache
+ set compiler_info [get_compiler_info $language]
- if [get_compiler_info $language] {
+ if {$compiler_info == "unsupported"} {
# An error will already have been printed in this case. Just
# return a suitable result depending on how the user called
# this function.
@@ -5553,10 +5818,10 @@ proc test_compiler_info { {compiler ""} {language "c"} } {
# If no arg, return the compiler_info string.
if [string match "" $compiler] {
- return $compiler_info_cache($language)
+ return $compiler_info
}
- return [string match $compiler $compiler_info_cache($language)]
+ return [string match $compiler $compiler_info]
}
# Return true if the C compiler is GCC, otherwise, return false.
@@ -6311,6 +6576,9 @@ proc gdb_compile {source dest type options} {
}
}
+ # Automatically handle includes in testsuite/lib/.
+ auto_lappend_include_files options $source
+
cond_wrap [expr $pie != -1 || $nopie != -1] \
with_PIE_multilib_flags_filtered {
set result [target_compile $source $dest $type $options]
@@ -6846,7 +7114,20 @@ gdb_caching_proc can_spawn_for_attach {} {
set me "can_spawn_for_attach"
set src {
- #include <unistd.h>
+ #ifdef _WIN32
+ # include <windows.h>
+ #else
+ # include <unistd.h>
+ #endif
+
+ #ifdef _WIN32
+ unsigned
+ sleep (unsigned seconds)
+ {
+ Sleep (seconds * 1000);
+ return 0;
+ }
+ #endif
int
main (void)
@@ -7457,13 +7738,13 @@ proc clean_standard_output_dir {} {
}
# Directory containing the standard output files.
- set standard_output_dir [file normalize [standard_output_file ""]]
+ set standard_output_dir [build_standard_output_file ""]
# Ensure that standard_output_dir is clean, or only contains
# gdb.log / gdb.sum.
set log_file_info [split [log_file -info]]
set log_file [file normalize [lindex $log_file_info end]]
- if { $log_file == [file normalize [standard_output_file gdb.log]] } {
+ if { $log_file == [file normalize [build_standard_output_file gdb.log]] } {
# Dir already contains active gdb.log. Don't remove the dir, but
# check that it's clean otherwise.
set res [glob -directory $standard_output_dir -tails *]
@@ -7709,31 +7990,48 @@ proc default_gdb_init { test_file_name } {
proc make_gdb_parallel_path { args } {
global GDB_PARALLEL objdir
- set joiner [list "file" "join" $objdir]
+ set joiner [list $objdir]
if { [info exists GDB_PARALLEL] && $GDB_PARALLEL != "yes" } {
lappend joiner $GDB_PARALLEL
}
set joiner [concat $joiner $args]
- return [eval $joiner]
+ return [file join {*}$joiner]
}
# Turn BASENAME into a full file name in the standard output
-# directory. It is ok if BASENAME is the empty string; in this case
-# the directory is returned.
+# directory, as seen from the build machine. I.e., as seen from the
+# system driving DejaGnu. (E.g., if DejaGnu is being driven by MSYS2
+# to test native Windows GDB, the "build" file names should be file
+# names TCL understands, i.e., Unix file names.) It is OK if BASENAME
+# is the empty string; in this case the directory is returned.
-proc standard_output_file {basename} {
+proc build_standard_output_file {basename} {
global objdir subdir gdb_test_file_name
set dir [make_gdb_parallel_path outputs $subdir $gdb_test_file_name]
file mkdir $dir
- # If running on MinGW, replace /c/foo with c:/foo
- if { [ishost *-*-mingw*] } {
- set dir [exec sh -c "cd ${dir} && pwd -W"]
- }
return [file join $dir $basename]
}
-# Turn BASENAME into a file name on host.
+# Turn BASENAME into a full file name in the standard output
+# directory, as seen from a non-remote host. I.e., assuming the build
+# and the host share the filesystem. E.g., if DejaGnu is being driven
+# by MSYS2 to test native Windows GDB, the "host" file names should be
+# file names GDB understands, i.e., Windows file names. It is OK if
+# BASENAME is the empty string; in this case the directory is
+# returned.
+
+proc standard_output_file {basename} {
+ global objdir subdir gdb_test_file_name
+
+ set dir [make_gdb_parallel_path outputs $subdir $gdb_test_file_name]
+ file mkdir $dir
+ set dir [host_file_normalize $dir]
+ return [host_file_join $dir $basename]
+}
+
+# Like standard_output_file, but handles remote hosts. Turn BASENAME
+# into a file name on (potentially remote) host.
proc host_standard_output_file { basename } {
if { [is_remote host] } {
@@ -7968,7 +8266,7 @@ set temp [interp create]
if { [interp eval $temp "info procs ::unknown"] != "" } {
set old_args [interp eval $temp "info args ::unknown"]
set old_body [interp eval $temp "info body ::unknown"]
- eval proc gdb_tcl_unknown {$old_args} {$old_body}
+ proc gdb_tcl_unknown $old_args $old_body
}
interp delete $temp
unset temp
@@ -8003,11 +8301,11 @@ proc gdb_finish { } {
gdb_exit
if { [llength $cleanfiles_target] > 0 } {
- eval remote_file target delete $cleanfiles_target
+ remote_file target delete {*}$cleanfiles_target
set cleanfiles_target {}
}
if { [llength $cleanfiles_host] > 0 } {
- eval remote_file host delete $cleanfiles_host
+ remote_file host delete {*}$cleanfiles_host
set cleanfiles_host {}
}
@@ -8953,7 +9251,7 @@ proc build_executable { testname executable {sources ""} {options {debug}} } {
lappend arglist $source $options
}
- return [eval build_executable_from_specs $arglist]
+ return [build_executable_from_specs {*}$arglist]
}
# Starts fresh GDB binary and loads an optional executable into GDB.
@@ -8987,6 +9285,10 @@ proc clean_restart {{executable ""}} {
gdb_reinitialize_dir $srcdir/$subdir
if {$executable != ""} {
+ if { [file pathtype $executable] == "absolute" } {
+ error "absolute path used"
+ }
+
set binfile [standard_output_file ${executable}]
return [gdb_load ${binfile}]
}
@@ -9004,7 +9306,7 @@ proc clean_restart {{executable ""}} {
# Returns 0 on success, non-zero on failure.
proc prepare_for_testing_full {testname args} {
foreach spec $args {
- if {[eval build_executable_from_specs [list $testname] $spec] == -1} {
+ if {[build_executable_from_specs $testname {*}$spec] == -1} {
return -1
}
set executable [lindex $spec 0]
@@ -9237,7 +9539,8 @@ gdb_caching_proc target_endianness {} {
return 0
}
- clean_restart $obj
+ clean_restart
+ gdb_load $obj
if ![runto_main] {
return 0
}
@@ -9260,12 +9563,12 @@ proc relative_filename {root full} {
set len [llength $root_split]
- if {[eval file join $root_split]
- != [eval file join [lrange $full_split 0 [expr {$len - 1}]]]} {
+ if {[file join {*}$root_split]
+ != [file join {*}[lrange $full_split 0 [expr {$len - 1}]]]} {
error "$full not a subdir of $root"
}
- return [eval file join [lrange $full_split $len end]]
+ return [file join {*}[lrange $full_split $len end]]
}
# If GDB_PARALLEL exists, then set up the parallel-mode directories.
@@ -9363,7 +9666,13 @@ proc remove_core {pid {test ""}} {
}
}
-proc core_find {binfile {deletefiles {}} {arg ""}} {
+# Runs ${binfile} expecting it to crash and generate a core file.
+# If DELETEFILES is provided, remove these files after running the program.
+# If ARG is provided, pass it as a command line argument to the program.
+# If OUTPUT_FILE is provided, save the program output to it.
+# Returns the name of the core dump, or empty string if not found.
+
+proc core_find {binfile {deletefiles {}} {arg ""} {output_file "/dev/null"}} {
global objdir subdir
set destcore "$binfile.core"
@@ -9385,7 +9694,7 @@ proc core_find {binfile {deletefiles {}} {arg ""}} {
set found 0
set coredir [standard_output_file coredir.[getpid]]
file mkdir $coredir
- catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile} ${arg}; true) >/dev/null 2>&1\""
+ catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile} ${arg}; true) >${output_file} 2>&1\""
# remote_exec host "${binfile}"
set binfile_basename [file tail $binfile]
foreach i [list \
@@ -9476,7 +9785,8 @@ gdb_caching_proc target_supports_scheduler_locking {} {
return 0
}
- clean_restart $obj
+ clean_restart
+ gdb_load $obj
if ![runto_main] {
return 0
}
@@ -9602,7 +9912,7 @@ proc run_on_host { test program args } {
if {[llength $args] > 1 && [lindex $args 1] == ""} {
set args [lreplace $args 1 1 "/dev/null"]
}
- set result [eval remote_exec host [list $program] $args]
+ set result [remote_exec host $program {*}$args]
verbose "result is $result"
set status [lindex $result 0]
set output [lindex $result 1]
@@ -10406,14 +10716,14 @@ proc with_override { name override body } {
# Install the override.
set new_args [info_args_with_defaults $override]
set new_body [info body $override]
- eval proc $name {$new_args} {$new_body}
+ proc $name $new_args $new_body
# Execute body.
set code [catch {uplevel 1 $body} result]
# Restore old proc if it existed on entry, else delete it.
if { $existed } {
- eval proc $name {$old_args} {$old_body}
+ proc $name $old_args $old_body
} else {
rename $name ""
}
@@ -10971,7 +11281,8 @@ gdb_caching_proc have_epilogue_line_info {} {
return False
}
- clean_restart $obj
+ clean_restart
+ gdb_load $obj
gdb_test_multiple "info line 6" "epilogue test" {
-re -wrap ".*starts at address.*and ends at.*" {
@@ -11114,6 +11425,66 @@ proc lappend_include_file { flags file } {
}
}
+# Helper for auto_lappend_include_files that handles one source file,
+# and tracks the list of already-visited files.
+
+proc auto_lappend_include_files_1 {flags source {visited {}}} {
+ upvar $flags up_flags
+ upvar $visited up_visited
+ global srcdir
+
+ set ext [string tolower [file extension $source]]
+ if {$ext ni {".c" ".cpp" ".cc" ".h" ".s"}} {
+ return
+ }
+
+ if {[catch {open $source r} fh err]} {
+ error "Failed to open file '$source': $err"
+ }
+ set contents [read $fh]
+ close $fh
+
+ lappend up_visited $source
+
+ # Match lines like:
+ # #include "gdb_foo.h"
+ set re "^\\s*#include\\s+\"(.*)\""
+
+ foreach line [split $contents "\n"] {
+ if {[regexp $re $line -> basename]} {
+ set lib_file "$srcdir/lib/$basename"
+
+ # If already processed, skip.
+ if {[lsearch -exact $up_visited $lib_file] != -1} {
+ continue
+ }
+
+ if {![file exists $lib_file]} {
+ continue
+ }
+
+ # Append to include list, and recurse into the included
+ # file.
+ lappend_include_file up_flags $lib_file
+ auto_lappend_include_files_1 up_flags $lib_file up_visited
+ }
+ }
+}
+
+# Automatically handle includes under gdb/testsuite/lib/.
+#
+# For each source file in SOURCES, look for #include directives
+# including files that live in testsuite/lib/. For each such included
+# file, call lappend_include_file for it.
+
+proc auto_lappend_include_files {flags sources} {
+ upvar $flags up_flags
+ set visited {}
+ foreach src $sources {
+ auto_lappend_include_files_1 up_flags $src visited
+ }
+}
+
# Return a list of supported host locales.
gdb_caching_proc host_locales { } {
@@ -11225,5 +11596,46 @@ gdb_caching_proc have_builtin_trap {} {
} executable]
}
+# Return 1 if there is a startup shell. Return -1 if there's no startup shell.
+# Return -1 otherwise.
+
+gdb_caching_proc have_startup_shell {} {
+ if { [is_remote target] } {
+ # For remote debugging targets, there is no guarantee that a "shell"
+ # is used.
+ return -1
+ }
+
+
+ gdb_exit
+ gdb_start
+
+ set re_on \
+ [string_to_regexp "Use of shell to start subprocesses is on."]
+ set re_off \
+ [string_to_regexp "Use of shell to start subprocesses is off."]
+ set re_cmd_unsupported \
+ [string_to_regexp \
+ {Undefined show command: "startup-with-shell". Try "help show".}]
+
+ set supported -1
+ gdb_test_multiple "show startup-with-shell" "" {
+ -re -wrap $re_on {
+ set supported 1
+ }
+ -re -wrap $re_off {
+ set supported 0
+ }
+ -re -wrap $re_cmd_unsupported {
+ }
+ -re -wrap "" {
+ }
+ }
+
+ gdb_exit
+
+ return $supported
+}
+
# Always load compatibility stuff.
load_lib future.exp
diff --git a/gdb/testsuite/lib/gdb_watchdog.h b/gdb/testsuite/lib/gdb_watchdog.h
new file mode 100644
index 0000000..15d63e7
--- /dev/null
+++ b/gdb/testsuite/lib/gdb_watchdog.h
@@ -0,0 +1,75 @@
+/* This file is part of GDB, the GNU debugger.
+
+ Copyright 2025 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/>. */
+
+/* Set a watchdog that aborts the testcase after a timeout. */
+
+#ifndef GDB_WATCHDOG_H
+#define GDB_WATCHDOG_H
+
+/* Forward declaration to make sure the definitions have the right
+ prototype, at least in C. */
+static void gdb_watchdog (unsigned int seconds);
+
+static const char _gdb_watchdog_msg[]
+ = "gdb_watchdog: timeout expired - aborting test\n";
+
+#ifdef _WIN32
+#include <windows.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+static VOID CALLBACK
+_gdb_watchdog_timer_routine (PVOID lpParam, BOOLEAN TimerOrWaitFired)
+{
+ fputs (_gdb_watchdog_msg, stderr);
+ abort ();
+}
+
+static void
+gdb_watchdog (unsigned int seconds)
+{
+ HANDLE timer;
+
+ if (!CreateTimerQueueTimer (&timer, NULL,
+ _gdb_watchdog_timer_routine, NULL,
+ seconds * 1000, 0, 0))
+ abort ();
+}
+
+#else /* POSIX systems */
+
+#include <unistd.h>
+#include <signal.h>
+#include <stdlib.h>
+
+static void
+_gdb_sigalrm_handler (int signo)
+{
+ write (2, _gdb_watchdog_msg, sizeof (_gdb_watchdog_msg) - 1);
+ abort ();
+}
+
+static void
+gdb_watchdog (unsigned int seconds)
+{
+ signal (SIGALRM, _gdb_sigalrm_handler);
+ alarm (seconds);
+}
+
+#endif
+
+#endif /* GDB_WATCHDOG_H */
diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp
index 2389206..6ff00ba 100644
--- a/gdb/testsuite/lib/gdbserver-support.exp
+++ b/gdb/testsuite/lib/gdbserver-support.exp
@@ -125,7 +125,7 @@ proc gdb_target_cmd_ext { targetname serialport {additional_text ""} } {
# Like gdb_target_cmd_ext, but returns 0 on success, 1 on failure.
proc gdb_target_cmd { args } {
- set res [eval gdb_target_cmd_ext $args]
+ set res [gdb_target_cmd_ext {*}$args]
return [expr $res == 0 ? 0 : 1]
}
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index aba13a2..fcbcddc 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -340,7 +340,7 @@ proc default_mi_gdb_start { { flags {} } } {
# baseboard file.
#
proc mi_gdb_start { args } {
- return [eval default_mi_gdb_start $args]
+ return [default_mi_gdb_start {*}$args]
}
# Many of the tests depend on setting breakpoints at various places and
@@ -1010,14 +1010,14 @@ proc mi_run_cmd_full {use_mi_command args} {
# -exec-continue, as appropriate. ARGS are passed verbatim to
# mi_run_cmd_full.
proc mi_run_cmd {args} {
- return [eval mi_run_cmd_full 1 $args]
+ return [mi_run_cmd_full 1 {*}$args]
}
# A wrapper for mi_run_cmd_full which uses the CLI commands 'run' and
# 'continue', as appropriate. ARGS are passed verbatim to
# mi_run_cmd_full.
proc mi_run_with_cli {args} {
- return [eval mi_run_cmd_full 0 $args]
+ return [mi_run_cmd_full 0 {*}$args]
}
# Starts fresh GDB binary and loads an optional executable into GDB.
@@ -1044,6 +1044,9 @@ proc mi_clean_restart {{executable ""} {flags {}}} {
mi_gdb_reinitialize_dir $srcdir/$subdir
if {$executable != ""} {
+ if { [file pathtype $executable] == "absolute" } {
+ error "absolute path used"
+ }
set binfile [standard_output_file ${executable}]
return [mi_gdb_load ${binfile}]
}
@@ -1394,7 +1397,7 @@ proc mi_continue_to {func} {
# returns the breakpoint regexp from that procedure.
proc mi_create_breakpoint {location test args} {
- set bp [eval mi_make_breakpoint $args]
+ set bp [mi_make_breakpoint {*}$args]
mi_gdb_test "222-break-insert $location" "222\\^done,$bp" $test
return $bp
}
@@ -1403,7 +1406,7 @@ proc mi_create_breakpoint {location test args} {
# locations using mi_make_breakpoint_multi instead.
proc mi_create_breakpoint_multi {location test args} {
- set bp [eval mi_make_breakpoint_multi $args]
+ set bp [mi_make_breakpoint_multi {*}$args]
mi_gdb_test "222-break-insert $location" "222\\^done,$bp" $test
return $bp
}
@@ -1411,7 +1414,7 @@ proc mi_create_breakpoint_multi {location test args} {
# Like mi_create_breakpoint, but creates a pending breakpoint.
proc mi_create_breakpoint_pending {location test args} {
- set bp [eval mi_make_breakpoint_pending $args]
+ set bp [mi_make_breakpoint_pending {*}$args]
mi_gdb_test "222-break-insert $location" ".*\r\n222\\^done,$bp" $test
return $bp
}
@@ -2683,7 +2686,7 @@ proc mi_make_info_frame_regexp {args} {
proc mi_info_frame { test args } {
parse_some_args {{frame ""} {thread ""}}
- set re [eval mi_make_info_frame_regexp $args]
+ set re [mi_make_info_frame_regexp {*}$args]
set cmd "235-stack-info-frame"
if {$frame ne ""} {
diff --git a/gdb/testsuite/lib/selftest-support.exp b/gdb/testsuite/lib/selftest-support.exp
index e037664..af8ec6f 100644
--- a/gdb/testsuite/lib/selftest-support.exp
+++ b/gdb/testsuite/lib/selftest-support.exp
@@ -16,7 +16,7 @@
# Find a pathname to a file that we would execute if the shell was asked
# to run $arg using the current PATH.
-proc find_gdb { arg } {
+proc _selftest_find_gdb { arg } {
# If the arg directly specifies an existing executable file, then
# simply use it.
@@ -36,65 +36,163 @@ proc find_gdb { arg } {
return $arg
}
-# A helper proc that sets up for self-testing.
-# EXECUTABLE is the gdb to use.
-# FUNCTION is the function to break in, either captured_main
-# or captured_command_loop.
-# Return 0 in case of success, -1 in case of failure, and -2 in case of
-# skipping the test-case.
+# Return true if the GDB under test is installed (as opposed to a GDB in its
+# build directory).
-proc selftest_setup { executable function } {
- global gdb_prompt
- global INTERNAL_GDBFLAGS
+proc _selftest_gdb_is_installed {} {
+ # If GDB_DATA_DIRECTORY is empty, assume that it is an installed GDB. It is
+ # not a perfectly accurate check, but should be good enough.
+ return [expr {"$::GDB_DATA_DIRECTORY" == ""}]
+}
+
+# Return true if the libtool binary is present on the host.
+
+proc _selftest_has_libtool {} {
+ lassign [remote_exec host "sh -c \"command -v libtool\""] status output
+ return [expr {$status == 0}]
+}
+
+# If GDB is executed from a build tree, run libtool to obtain the real
+# executable path for EXECUTABLE, which may be a libtool wrapper. Return
+# the path on success. On failure, issue an UNTESTED test result and return
+# an empty string.
+#
+# If GDB is executed from an installed location, return EXECUTABLE unchanged.
+#
+# If libtool is not present on the host system, return EXECUTABLE unchanged.
+# The test might still work, because the GDB binary is not always a libtool
+# wrapper.
+
+proc selftest_libtool_get_real_gdb_executable { executable } {
+ if [_selftest_gdb_is_installed] {
+ return $executable
+ }
- # load yourself into the debugger
+ if ![_selftest_has_libtool] {
+ return $executable
+ }
+
+ lassign [remote_exec host libtool "--mode=execute echo -n $executable"] \
+ status executable
+
+ if { $status != 0 } {
+ untested "failed to run libtool"
+ return ""
+ }
- global gdb_file_cmd_debug_info
- set gdb_file_cmd_debug_info "unset"
+ return $executable
+}
+
+# Return true if EXECUTABLE has debug info.
+#
+# If it doesn't, or if it's not possible to determine, issue an UNTESTED test
+# result and return false.
+
+proc _selftest_check_executable_debug_info { executable } {
+ set ::gdb_file_cmd_debug_info "unset"
+ set result true
+
+ # On Cygwin (at least), gdb/gdb.exe is a libtool wrapper (which happens to
+ # be a PE executable). The real binary is gdb/.libs/gdb.exe. If we load
+ # gdb/gdb.exe, we won't see any debug info and conclude that we can't run
+ # the test. Obtain the real executable path using libtool.
+ #
+ # At the time of writing, we don't see a libtool wrapper generated on Linux.
+ # But if there was one, it would be a shell script, and it would not be
+ # possible to load it in gdb. This conversion would therefore also be
+ # necessary.
+ #
+ # If testing against an installed GDB, then there won't be a libtool
+ # wrapper, no need to convert.
+ set executable [selftest_libtool_get_real_gdb_executable $executable]
+
+ if { $executable == "" } {
+ # selftest_libtool_get_real_gdb_executable already records an UNTESTED
+ # on failure.
+ return false
+ }
- set result [gdb_load $executable]
+ gdb_start
- if {$result != 0} {
- return -1
+ if {[gdb_load $executable] != 0} {
+ untested "failed to load executable when checking for debug info"
+ set result false
}
- if {$gdb_file_cmd_debug_info != "debug"} {
+ if {$::gdb_file_cmd_debug_info != "debug"} {
untested "no debug information, skipping testcase."
- return -2
+ set result false
}
- # Set a breakpoint at $function.
+ gdb_exit
+
+ return $result
+}
+
+# A helper proc that sets up for self-testing.
+#
+# Assumes that the inferior GDB is already loaded in the top-level GDB.
+#
+# Return 0 in case of success, -1 in case of failure, and -2 in case of
+# skipping the test-case.
+
+proc _selftest_setup { } {
+ global gdb_prompt
+ global INTERNAL_GDBFLAGS
+
+ # Set a breakpoint at main
+ set function main
if { [gdb_breakpoint $function "no-message"] != 1 } {
untested "Cannot set breakpoint at $function, skipping testcase."
return -2
}
+ # Debugging on Windows shows random threads starting and exiting,
+ # interfering with the tests. Disable them, since they are not useful here.
+ gdb_test_no_output "set print thread-events off"
+
# run yourself
set description "run until breakpoint at $function"
+ set re_hs {[^\r\n]+}
+ set re_args [string cat \
+ [string_to_regexp "("] \
+ $re_hs \
+ [string_to_regexp ")"]]
+ set re_pass \
+ [multi_line \
+ "Starting program: $re_hs" \
+ ".*" \
+ [string cat "Breakpoint $::decimal, $function $re_args at" \
+ " ${re_hs}gdb.c:$re_hs"] \
+ ".*"]
+ set re_xfail \
+ [multi_line \
+ "Starting program: $re_hs" \
+ ".*" \
+ "Breakpoint $::decimal, $function $re_args$re_hs" \
+ ".*"]
gdb_test_multiple "run $INTERNAL_GDBFLAGS" "$description" {
- -re "Starting program.*Breakpoint \[0-9\]+,.*$function \\(.*\\).* at .*main.c:.*$gdb_prompt $" {
- pass "$description"
- }
- -re "Starting program.*Breakpoint \[0-9\]+,.*$function \\(.*\\).*$gdb_prompt $" {
- xfail "$description (line numbers scrambled?)"
- }
- -re "vfork: No more processes.*$gdb_prompt $" {
- fail "$description (out of virtual memory)"
- return -1
- }
- -re ".*$gdb_prompt $" {
- fail "$description"
- return -1
- }
+ -re -wrap $re_pass {
+ pass $description
+ }
+ -re -wrap $re_xfail {
+ xfail "$description (line numbers scrambled?)"
+ }
+ -re -wrap "vfork: No more processes.*" {
+ fail "$description (out of virtual memory)"
+ return -1
+ }
+ -re -wrap "" {
+ fail $description
+ return -1
+ }
}
return 0
}
-# Prepare for running a self-test by moving the GDB executable to a
-# location where we can use it as the inferior. Return the filename
-# of the new location.
+# Return the location of the gdb executable to test.
#
# If the current testing setup is not suitable for running a
# self-test, then return an empty string.
@@ -114,52 +212,54 @@ proc selftest_prepare {} {
# ... or with a stub-like server? I.e., gdbserver + "target
# remote"? In that case we won't be able to pass command line
- # arguments to GDB, and selftest_setup wants to do exactly that.
+ # arguments to GDB, and _selftest_setup wants to do exactly that.
if [use_gdb_stub] {
return
}
- # Run the test with self. Copy the file executable file in case
- # this OS doesn't like to edit its own text space.
-
- set gdb_fullpath [find_gdb $::GDB]
-
- if {[is_remote host]} {
- set xgdb x$::tool
- } else {
- set xgdb [standard_output_file x$::tool]
- }
-
- # Remove any old copy lying around.
- remote_file host delete $xgdb
-
- set filename [remote_download host $gdb_fullpath $xgdb]
-
- return $filename
+ return [_selftest_find_gdb $::GDB]
}
# A simple way to run some self-tests.
-proc do_self_tests {function body} {
+proc do_self_tests {body} {
set file [selftest_prepare]
if { $file eq "" } {
return
}
- gdb_start
+ # Check if the gdb executable has debug info.
+ if { ![_selftest_check_executable_debug_info $file] } {
+ return
+ }
+
+ # FILE might be a libtool wrapper. In order to debug the real thing, pass
+ # FILE on the command-line of the top-level gdb, and run under
+ # `libtool --mode=execute. libtool will replace FILE with the path to the
+ # real executable and set any path required for it to find its dependent
+ # libraries.
+ #
+ # If testing against an installed GDB, there won't be a libtool wrapper.
+ save_vars { ::GDB ::GDBFLAGS } {
+ if { ![_selftest_gdb_is_installed] && [_selftest_has_libtool] } {
+ set ::GDB "libtool --mode=execute $::GDB"
+ }
+
+ set ::GDBFLAGS "$::GDBFLAGS $file"
+ gdb_start
+ }
# When debugging GDB with GDB, some operations can take a relatively long
# time, especially if the build is non-optimized. Bump the timeout for the
# duration of the test.
with_timeout_factor 10 {
- set result [selftest_setup $file $function]
+ set result [_selftest_setup]
if {$result == 0} {
set result [uplevel $body]
}
}
gdb_exit
- catch "remote_file host delete $file"
if {$result == -1} {
warning "Couldn't test self"
diff --git a/gdb/testsuite/lib/trace-support.exp b/gdb/testsuite/lib/trace-support.exp
index a8d0699..8543de3 100644
--- a/gdb/testsuite/lib/trace-support.exp
+++ b/gdb/testsuite/lib/trace-support.exp
@@ -219,14 +219,14 @@ proc gdb_trace_setactions_command { actions_command testname tracepoint args } {
# gdb_trace_setactions_command.
#
proc gdb_trace_setactions { testname tracepoint args } {
- eval gdb_trace_setactions_command "actions" {$testname} {$tracepoint} $args
+ gdb_trace_setactions_command "actions" $testname $tracepoint {*}$args
}
# Define actions for a tracepoint, using the "commands" command. See
# gdb_trace_setactions_command.
#
proc gdb_trace_setcommands { testname tracepoint args } {
- eval gdb_trace_setactions_command "commands" {$testname} {$tracepoint} $args
+ gdb_trace_setactions_command "commands" $testname $tracepoint {*}$args
}
#
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index b83b8af..68fd677 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -33,1331 +33,1690 @@ namespace eval Term {
variable _resize_count
- proc _log { what } {
- verbose "+++ $what"
- }
+ variable _TERM
+ set _TERM ""
- # Call BODY, then log WHAT along with the original and new cursor position.
- proc _log_cur { what body } {
- variable _cur_row
- variable _cur_col
+ variable _alternate
+ variable _alternate_setup
+ set _alternate 0
+ set _alternate_setup 0
+}
- set orig_cur_row $_cur_row
- set orig_cur_col $_cur_col
+proc Term::_log { what } {
+ verbose "+++ $what"
+}
- set code [catch {uplevel $body} result]
+# Call BODY, then log WHAT along with the original and new cursor position.
+proc Term::_log_cur { what body } {
+ variable _cur_row
+ variable _cur_col
- _log "$what, cursor: ($orig_cur_row, $orig_cur_col) -> ($_cur_row, $_cur_col)"
+ set orig_cur_row $_cur_row
+ set orig_cur_col $_cur_col
- if { $code == 1 } {
- global errorInfo errorCode
- return -code $code -errorinfo $errorInfo -errorcode $errorCode $result
- } else {
- return -code $code $result
- }
- }
+ set code [catch {uplevel $body} result]
- # If ARG is empty, return DEF: otherwise ARG. This is useful for
- # defaulting arguments in CSIs.
- proc _default {arg def} {
- if {$arg == ""} {
- return $def
- }
- return $arg
+ _log "$what, cursor: ($orig_cur_row, $orig_cur_col) -> ($_cur_row, $_cur_col)"
+
+ if { $code == 1 } {
+ global errorInfo errorCode
+ return -code $code -errorinfo $errorInfo -errorcode $errorCode $result
+ } else {
+ return -code $code $result
}
+}
- # Erase in the line Y from SX to just before EX.
- proc _clear_in_line {sx ex y} {
- variable _attrs
- variable _chars
- set lattr [array get _attrs]
- while {$sx < $ex} {
- set _chars($sx,$y) [list " " $lattr]
- incr sx
- }
+# If ARG is empty, return DEF: otherwise ARG. This is useful for
+# defaulting arguments in CSIs.
+proc Term::_default {arg def} {
+ if {$arg == ""} {
+ return $def
}
+ return $arg
+}
- # Erase the lines from SY to just before EY.
- proc _clear_lines {sy ey} {
- variable _cols
- while {$sy < $ey} {
- _clear_in_line 0 $_cols $sy
- incr sy
- }
+# Erase in the line Y from SX to just before EX.
+proc Term::_clear_in_line {sx ex y} {
+ variable _attrs
+ variable _chars
+ set lattr [array get _attrs]
+ while {$sx < $ex} {
+ set _chars($sx,$y) [list " " $lattr]
+ incr sx
}
+}
- # Beep.
- proc _ctl_0x07 {} {
+# Erase the lines from SY to just before EY.
+proc Term::_clear_lines {sy ey} {
+ variable _cols
+ while {$sy < $ey} {
+ _clear_in_line 0 $_cols $sy
+ incr sy
}
+}
+
+# Beep.
+proc Term::_ctl_0x07 {} {
+}
+
+# Return 1 if tuiterm has the bw/auto_left_margin enabled.
+proc Term::_have_bw {} {
+ return [expr \
+ { [string equal $Term::_TERM "ansiw"] \
+ || [string equal $Term::_TERM "ansis"] }]
+}
- # Return 1 if tuiterm has the bw/auto_left_margin enabled.
- proc _have_bw {} {
- return [string equal $Term::_TERM "ansiw"]
+# Backspace.
+proc Term::_ctl_0x08 { {bw -1} } {
+ if { $bw == -1 } {
+ set bw [_have_bw]
}
+ _log_cur "Backspace, bw == $bw" {
+ variable _cur_col
+ variable _cur_row
+ variable _cols
- # Backspace.
- proc _ctl_0x08 { {bw -1} } {
- if { $bw == -1 } {
- set bw [_have_bw]
+ if { $_cur_col > 0 } {
+ # No wrapping needed.
+ incr _cur_col -1
+ return
}
- _log_cur "Backspace, bw == $bw" {
- variable _cur_col
- variable _cur_row
- variable _cols
- if { $_cur_col > 0 } {
- # No wrapping needed.
- incr _cur_col -1
- return
- }
+ if { ! $bw } {
+ # Wrapping not enabled.
+ return
+ }
- if { ! $bw } {
- # Wrapping not enabled.
- return
- }
+ if { $_cur_row == 0 } {
+ # Can't wrap.
+ return
+ }
+
+ # Wrap to previous line.
+ set _cur_col [expr $_cols - 1]
+ incr _cur_row -1
+ }
+}
+
+# Linefeed.
+proc Term::_ctl_0x0a {} {
+ _log_cur "Line feed" {
+ variable _cur_row
+ variable _rows
+ variable _cols
+ variable _chars
- if { $_cur_row == 0 } {
- # Can't wrap.
- return
+ incr _cur_row 1
+ while {$_cur_row >= $_rows} {
+ # Scroll the display contents. We scroll one line at
+ # a time here; as _cur_row was only increased by one,
+ # a single line scroll should be enough to put the
+ # cursor back on the screen. But we wrap the
+ # scrolling inside a while loop just to be on the safe
+ # side.
+ for {set y 0} {$y < [expr $_rows - 1]} {incr y} {
+ set next_y [expr $y + 1]
+ for {set x 0} {$x < $_cols} {incr x} {
+ set _chars($x,$y) $_chars($x,$next_y)
+ }
}
- # Wrap to previous line.
- set _cur_col [expr $_cols - 1]
incr _cur_row -1
}
}
+}
- # Linefeed.
- proc _ctl_0x0a {} {
- _log_cur "Line feed" {
- variable _cur_row
- variable _rows
- variable _cols
- variable _chars
-
- incr _cur_row 1
- while {$_cur_row >= $_rows} {
- # Scroll the display contents. We scroll one line at
- # a time here; as _cur_row was only increased by one,
- # a single line scroll should be enough to put the
- # cursor back on the screen. But we wrap the
- # scrolling inside a while loop just to be on the safe
- # side.
- for {set y 0} {$y < [expr $_rows - 1]} {incr y} {
- set next_y [expr $y + 1]
- for {set x 0} {$x < $_cols} {incr x} {
- set _chars($x,$y) $_chars($x,$next_y)
- }
- }
+# Carriage return.
+proc Term::_ctl_0x0d {} {
+ _log_cur "Carriage return" {
+ variable _cur_col
- incr _cur_row -1
- }
- }
+ set _cur_col 0
}
+}
- # Carriage return.
- proc _ctl_0x0d {} {
- _log_cur "Carriage return" {
- variable _cur_col
+# Designate G0 Character Set, USASCII (ESC ( B)
+#
+# https://invisible-island.net/xterm/ctlseqs/ctlseqs.html (see "ESC ( C", case C = B)
+proc Term::_esc_0x28_B {} {
+ _log "ignored: G0: USASCII"
+}
- set _cur_col 0
- }
- }
+# Designate G0 Character Set, DEC Special Character and Line Drawing Set (ESC ( 0)
+#
+# https://invisible-island.net/xterm/ctlseqs/ctlseqs.html (see "ESC ( C", case C = 0)
+proc Term::_esc_0x28_0 {} {
+ _log "ignored: G0: DEC Special Character and Line Drawing Set"
+}
+
+# DECKPAM (Application Keypad, ESC =)
+#
+# https://vt100.net/docs/vt510-rm/DECKPAM.html
+proc Term::_esc_0x3d {} {
+ _log "ignored: Application Keypad"
+}
- # Insert Character.
- #
- # https://vt100.net/docs/vt510-rm/ICH.html
- proc _csi_@ {args} {
- set n [_default [lindex $args 0] 1]
+# DECKPNM (Normal Keypad, ESC >)
+#
+# https://vt100.net/docs/vt510-rm/DECKPNM.html
+proc Term::_esc_0x3e {} {
+ _log "ignored: Normal Keypad"
+}
- _log_cur "Insert Character ($n)" {
- variable _cur_col
- variable _cur_row
- variable _cols
- variable _chars
+# Insert Character.
+#
+# https://vt100.net/docs/vt510-rm/ICH.html
+proc Term::_csi_@ {args} {
+ set n [_default [lindex $args 0] 1]
- # Move characters right of the cursor right by N positions,
- # starting with the rightmost one.
- for {set in_col [expr $_cols - $n - 1]} {$in_col >= $_cur_col} {incr in_col -1} {
- set out_col [expr $in_col + $n]
- set _chars($out_col,$_cur_row) $_chars($in_col,$_cur_row)
- }
+ _log_cur "Insert Character ($n)" {
+ variable _cur_col
+ variable _cur_row
+ variable _cols
+ variable _chars
- # Write N blank spaces starting from the cursor.
- _clear_in_line $_cur_col [expr $_cur_col + $n] $_cur_row
+ # Move characters right of the cursor right by N positions,
+ # starting with the rightmost one.
+ for {set in_col [expr $_cols - $n - 1]} {$in_col >= $_cur_col} {incr in_col -1} {
+ set out_col [expr $in_col + $n]
+ set _chars($out_col,$_cur_row) $_chars($in_col,$_cur_row)
}
- }
- # Horizontal Position Absolute.
- #
- # https://vt100.net/docs/vt510-rm/HPA.html
- proc _csi_` {args} {
- # Same as Cursor Horizontal Absolute.
- return [Term::_csi_G {*}$args]
+ # Write N blank spaces starting from the cursor.
+ _clear_in_line $_cur_col [expr $_cur_col + $n] $_cur_row
}
+}
+
+# Horizontal Position Absolute.
+#
+# https://vt100.net/docs/vt510-rm/HPA.html
+proc Term::_csi_` {args} {
+ # Same as Cursor Horizontal Absolute.
+ return [Term::_csi_G {*}$args]
+}
- # Cursor Up.
- #
- # https://vt100.net/docs/vt510-rm/CUU.html
- proc _csi_A {args} {
- set arg [_default [lindex $args 0] 1]
+# Cursor Up.
+#
+# https://vt100.net/docs/vt510-rm/CUU.html
+proc Term::_csi_A {args} {
+ set arg [_default [lindex $args 0] 1]
- _log_cur "Cursor Up ($arg)" {
- variable _cur_row
+ _log_cur "Cursor Up ($arg)" {
+ variable _cur_row
- set _cur_row [expr {max ($_cur_row - $arg, 0)}]
- }
+ set _cur_row [expr {max ($_cur_row - $arg, 0)}]
}
+}
- # Cursor Down.
- #
- # https://vt100.net/docs/vt510-rm/CUD.html
- proc _csi_B {args} {
- set arg [_default [lindex $args 0] 1]
+# Cursor Down.
+#
+# https://vt100.net/docs/vt510-rm/CUD.html
+proc Term::_csi_B {args} {
+ set arg [_default [lindex $args 0] 1]
- _log_cur "Cursor Down ($arg)" {
- variable _cur_row
- variable _rows
+ _log_cur "Cursor Down ($arg)" {
+ variable _cur_row
+ variable _rows
- set _cur_row [expr {min ($_cur_row + $arg, $_rows - 1)}]
- }
+ set _cur_row [expr {min ($_cur_row + $arg, $_rows - 1)}]
}
+}
- # Cursor Forward.
- #
- # https://vt100.net/docs/vt510-rm/CUF.html
- proc _csi_C {args} {
- set arg [_default [lindex $args 0] 1]
+# Cursor Forward.
+#
+# https://vt100.net/docs/vt510-rm/CUF.html
+proc Term::_csi_C {args} {
+ set arg [_default [lindex $args 0] 1]
- _log_cur "Cursor Forward ($arg)" {
- variable _cur_col
- variable _cols
+ _log_cur "Cursor Forward ($arg)" {
+ variable _cur_col
+ variable _cols
- set _cur_col [expr {min ($_cur_col + $arg, $_cols - 1)}]
- }
+ set _cur_col [expr {min ($_cur_col + $arg, $_cols - 1)}]
}
+}
- # Cursor Backward.
- #
- # https://vt100.net/docs/vt510-rm/CUB.html
- proc _csi_D {args} {
- set arg [_default [lindex $args 0] 1]
+# Cursor Backward.
+#
+# https://vt100.net/docs/vt510-rm/CUB.html
+proc Term::_csi_D {args} {
+ set arg [_default [lindex $args 0] 1]
- _log_cur "Cursor Backward ($arg)" {
- variable _cur_col
+ _log_cur "Cursor Backward ($arg)" {
+ variable _cur_col
- set _cur_col [expr {max ($_cur_col - $arg, 0)}]
- }
+ set _cur_col [expr {max ($_cur_col - $arg, 0)}]
}
+}
- # Cursor Next Line.
- #
- # https://vt100.net/docs/vt510-rm/CNL.html
- proc _csi_E {args} {
- set arg [_default [lindex $args 0] 1]
+# Cursor Next Line.
+#
+# https://vt100.net/docs/vt510-rm/CNL.html
+proc Term::_csi_E {args} {
+ set arg [_default [lindex $args 0] 1]
- _log_cur "Cursor Next Line ($arg)" {
- variable _cur_col
- variable _cur_row
- variable _rows
+ _log_cur "Cursor Next Line ($arg)" {
+ variable _cur_col
+ variable _cur_row
+ variable _rows
- set _cur_col 0
- set _cur_row [expr {min ($_cur_row + $arg, $_rows - 1)}]
- }
+ set _cur_col 0
+ set _cur_row [expr {min ($_cur_row + $arg, $_rows - 1)}]
}
+}
- # Cursor Previous Line.
- #
- # https://vt100.net/docs/vt510-rm/CPL.html
- proc _csi_F {args} {
- set arg [_default [lindex $args 0] 1]
+# Cursor Previous Line.
+#
+# https://vt100.net/docs/vt510-rm/CPL.html
+proc Term::_csi_F {args} {
+ set arg [_default [lindex $args 0] 1]
- _log_cur "Cursor Previous Line ($arg)" {
- variable _cur_col
- variable _cur_row
- variable _rows
+ _log_cur "Cursor Previous Line ($arg)" {
+ variable _cur_col
+ variable _cur_row
+ variable _rows
- set _cur_col 0
- set _cur_row [expr {max ($_cur_row - $arg, 0)}]
- }
+ set _cur_col 0
+ set _cur_row [expr {max ($_cur_row - $arg, 0)}]
}
+}
- # Cursor Horizontal Absolute.
- #
- # https://vt100.net/docs/vt510-rm/CHA.html
- proc _csi_G {args} {
- set arg [_default [lindex $args 0] 1]
+# Cursor Horizontal Absolute.
+#
+# https://vt100.net/docs/vt510-rm/CHA.html
+proc Term::_csi_G {args} {
+ set arg [_default [lindex $args 0] 1]
- _log_cur "Cursor Horizontal Absolute ($arg)" {
- variable _cur_col
- variable _cols
+ _log_cur "Cursor Horizontal Absolute ($arg)" {
+ variable _cur_col
+ variable _cols
- set _cur_col [expr {min ($arg, $_cols)} - 1]
- }
+ set _cur_col [expr {min ($arg, $_cols)} - 1]
}
+}
- # Cursor Position.
- #
- # https://vt100.net/docs/vt510-rm/CUP.html
- proc _csi_H {args} {
- set row [_default [lindex $args 0] 1]
- set col [_default [lindex $args 1] 1]
+# Cursor Position.
+#
+# https://vt100.net/docs/vt510-rm/CUP.html
+proc Term::_csi_H {args} {
+ set row [_default [lindex $args 0] 1]
+ set col [_default [lindex $args 1] 1]
- _log_cur "Cursor Position ($row, $col)" {
- variable _cur_col
- variable _cur_row
+ _log_cur "Cursor Position ($row, $col)" {
+ variable _cur_col
+ variable _cur_row
- set _cur_row [expr {$row - 1}]
- set _cur_col [expr {$col - 1}]
- }
+ set _cur_row [expr {$row - 1}]
+ set _cur_col [expr {$col - 1}]
}
+}
- # Cursor Horizontal Forward Tabulation.
- #
- # https://vt100.net/docs/vt510-rm/CHT.html
- proc _csi_I {args} {
- set n [_default [lindex $args 0] 1]
+# Cursor Horizontal Forward Tabulation.
+#
+# https://vt100.net/docs/vt510-rm/CHT.html
+proc Term::_csi_I {args} {
+ set n [_default [lindex $args 0] 1]
- _log_cur "Cursor Horizontal Forward Tabulation ($n)" {
- variable _cur_col
- variable _cols
+ _log_cur "Cursor Horizontal Forward Tabulation ($n)" {
+ variable _cur_col
+ variable _cols
- incr _cur_col [expr {$n * 8 - $_cur_col % 8}]
- if {$_cur_col >= $_cols} {
- set _cur_col [expr {$_cols - 1}]
- }
+ incr _cur_col [expr {$n * 8 - $_cur_col % 8}]
+ if {$_cur_col >= $_cols} {
+ set _cur_col [expr {$_cols - 1}]
}
}
+}
- # Erase in Display.
- #
- # https://vt100.net/docs/vt510-rm/ED.html
- proc _csi_J {args} {
- set arg [_default [lindex $args 0] 0]
-
- _log_cur "Erase in Display ($arg)" {
- variable _cur_col
- variable _cur_row
- variable _rows
- variable _cols
-
- if {$arg == 0} {
- # Cursor (inclusive) to end of display.
- _clear_in_line $_cur_col $_cols $_cur_row
- _clear_lines [expr {$_cur_row + 1}] $_rows
- } elseif {$arg == 1} {
- # Beginning of display to cursor (inclusive).
- _clear_lines 0 $_cur_row
- _clear_in_line 0 [expr $_cur_col + 1] $_cur_row
- } elseif {$arg == 2} {
- # Entire display.
- _clear_lines 0 $_rows
- }
+# Erase in Display.
+#
+# https://vt100.net/docs/vt510-rm/ED.html
+proc Term::_csi_J {args} {
+ set arg [_default [lindex $args 0] 0]
+
+ _log_cur "Erase in Display ($arg)" {
+ variable _cur_col
+ variable _cur_row
+ variable _rows
+ variable _cols
+
+ if {$arg == 0} {
+ # Cursor (inclusive) to end of display.
+ _clear_in_line $_cur_col $_cols $_cur_row
+ _clear_lines [expr {$_cur_row + 1}] $_rows
+ } elseif {$arg == 1} {
+ # Beginning of display to cursor (inclusive).
+ _clear_lines 0 $_cur_row
+ _clear_in_line 0 [expr $_cur_col + 1] $_cur_row
+ } elseif {$arg == 2} {
+ # Entire display.
+ _clear_lines 0 $_rows
}
}
+}
- # Erase in Line.
- #
- # https://vt100.net/docs/vt510-rm/EL.html
- proc _csi_K {args} {
- set arg [_default [lindex $args 0] 0]
+# Erase in Line.
+#
+# https://vt100.net/docs/vt510-rm/EL.html
+proc Term::_csi_K {args} {
+ set arg [_default [lindex $args 0] 0]
- _log_cur "Erase in Line ($arg)" {
- variable _cur_col
- variable _cur_row
- variable _cols
+ _log_cur "Erase in Line ($arg)" {
+ variable _cur_col
+ variable _cur_row
+ variable _cols
- if {$arg == 0} {
- # Cursor (inclusive) to end of line.
- _clear_in_line $_cur_col $_cols $_cur_row
- } elseif {$arg == 1} {
- # Beginning of line to cursor (inclusive).
- _clear_in_line 0 [expr $_cur_col + 1] $_cur_row
- } elseif {$arg == 2} {
- # Entire line.
- _clear_in_line 0 $_cols $_cur_row
- }
+ if {$arg == 0} {
+ # Cursor (inclusive) to end of line.
+ _clear_in_line $_cur_col $_cols $_cur_row
+ } elseif {$arg == 1} {
+ # Beginning of line to cursor (inclusive).
+ _clear_in_line 0 [expr $_cur_col + 1] $_cur_row
+ } elseif {$arg == 2} {
+ # Entire line.
+ _clear_in_line 0 $_cols $_cur_row
}
}
+}
- # Insert Line
- #
- # https://vt100.net/docs/vt510-rm/IL.html
- proc _csi_L {args} {
- set arg [_default [lindex $args 0] 1]
+# Insert Line
+#
+# https://vt100.net/docs/vt510-rm/IL.html
+proc Term::_csi_L {args} {
+ set arg [_default [lindex $args 0] 1]
- _log_cur "Insert Line ($arg)" {
- variable _cur_col
- variable _cur_row
- variable _rows
- variable _cols
- variable _chars
+ _log_cur "Insert Line ($arg)" {
+ variable _cur_col
+ variable _cur_row
+ variable _rows
+ variable _cols
+ variable _chars
- set y [expr $_rows - 2]
- set next_y [expr $y + $arg]
- while {$y >= $_cur_row} {
- for {set x 0} {$x < $_cols} {incr x} {
- set _chars($x,$next_y) $_chars($x,$y)
- }
- incr y -1
- incr next_y -1
+ set y [expr $_rows - 2]
+ set next_y [expr $y + $arg]
+ while {$y >= $_cur_row} {
+ for {set x 0} {$x < $_cols} {incr x} {
+ set _chars($x,$next_y) $_chars($x,$y)
}
-
- _clear_lines $_cur_row [expr $_cur_row + $arg]
+ incr y -1
+ incr next_y -1
}
+
+ _clear_lines $_cur_row [expr $_cur_row + $arg]
}
+}
- # Delete line.
- #
- # https://vt100.net/docs/vt510-rm/DL.html
- proc _csi_M {args} {
- set count [_default [lindex $args 0] 1]
+# Delete line.
+#
+# https://vt100.net/docs/vt510-rm/DL.html
+proc Term::_csi_M {args} {
+ set count [_default [lindex $args 0] 1]
- _log_cur "Delete line ($count)" {
- variable _cur_row
- variable _rows
- variable _cols
- variable _chars
+ _log_cur "Delete line ($count)" {
+ variable _cur_row
+ variable _rows
+ variable _cols
+ variable _chars
- set y $_cur_row
- set next_y [expr {$y + $count}]
- while {$next_y < $_rows} {
- for {set x 0} {$x < $_cols} {incr x} {
- set _chars($x,$y) $_chars($x,$next_y)
- }
- incr y
- incr next_y
+ set y $_cur_row
+ set next_y [expr {$y + $count}]
+ while {$next_y < $_rows} {
+ for {set x 0} {$x < $_cols} {incr x} {
+ set _chars($x,$y) $_chars($x,$next_y)
}
- _clear_lines $y $_rows
+ incr y
+ incr next_y
}
+ _clear_lines $y $_rows
}
+}
- # Delete Character.
- #
- # https://vt100.net/docs/vt510-rm/DCH.html
- proc _csi_P {args} {
- set count [_default [lindex $args 0] 1]
-
- _log_cur "Delete character ($count)" {
- variable _cur_row
- variable _cur_col
- variable _chars
- variable _cols
+# Delete Character.
+#
+# https://vt100.net/docs/vt510-rm/DCH.html
+proc Term::_csi_P {args} {
+ set count [_default [lindex $args 0] 1]
- # Move all characters right of the cursor N positions left.
- set out_col [expr $_cur_col]
- set in_col [expr $_cur_col + $count]
+ _log_cur "Delete character ($count)" {
+ variable _cur_row
+ variable _cur_col
+ variable _chars
+ variable _cols
- while {$in_col < $_cols} {
- set _chars($out_col,$_cur_row) $_chars($in_col,$_cur_row)
- incr in_col
- incr out_col
- }
+ # Move all characters right of the cursor N positions left.
+ set out_col [expr $_cur_col]
+ set in_col [expr $_cur_col + $count]
- # Clear the rest of the line.
- _clear_in_line $out_col $_cols $_cur_row
+ while {$in_col < $_cols} {
+ set _chars($out_col,$_cur_row) $_chars($in_col,$_cur_row)
+ incr in_col
+ incr out_col
}
+
+ # Clear the rest of the line.
+ _clear_in_line $out_col $_cols $_cur_row
}
+}
- # Pan Down
- #
- # https://vt100.net/docs/vt510-rm/SU.html
- proc _csi_S {args} {
- set count [_default [lindex $args 0] 1]
+# Pan Down
+#
+# https://vt100.net/docs/vt510-rm/SU.html
+proc Term::_csi_S {args} {
+ set count [_default [lindex $args 0] 1]
- _log_cur "Pan Down ($count)" {
- variable _cur_col
- variable _cur_row
- variable _cols
- variable _rows
- variable _chars
+ _log_cur "Pan Down ($count)" {
+ variable _cur_col
+ variable _cur_row
+ variable _cols
+ variable _rows
+ variable _chars
- # The following code is written without consideration for
- # the scroll margins. At this time this comment was
- # written the tuiterm library doesn't support the scroll
- # margins. If/when that changes, then the following will
- # need to be updated.
+ # The following code is written without consideration for
+ # the scroll margins. At this time this comment was
+ # written the tuiterm library doesn't support the scroll
+ # margins. If/when that changes, then the following will
+ # need to be updated.
- set dy 0
- set y $count
+ set dy 0
+ set y $count
- while {$y < $_rows} {
- for {set x 0} {$x < $_cols} {incr x} {
- set _chars($x,$dy) $_chars($x,$y)
- }
- incr y 1
- incr dy 1
+ while {$y < $_rows} {
+ for {set x 0} {$x < $_cols} {incr x} {
+ set _chars($x,$dy) $_chars($x,$y)
}
-
- _clear_lines $dy $_rows
+ incr y 1
+ incr dy 1
}
+
+ _clear_lines $dy $_rows
}
+}
- # Pan Up
- #
- # https://vt100.net/docs/vt510-rm/SD.html
- proc _csi_T {args} {
- set count [_default [lindex $args 0] 1]
+# Pan Up
+#
+# https://vt100.net/docs/vt510-rm/SD.html
+proc Term::_csi_T {args} {
+ set count [_default [lindex $args 0] 1]
- _log_cur "Pan Up ($count)" {
- variable _cur_col
- variable _cur_row
- variable _cols
- variable _rows
- variable _chars
+ _log_cur "Pan Up ($count)" {
+ variable _cur_col
+ variable _cur_row
+ variable _cols
+ variable _rows
+ variable _chars
- # The following code is written without consideration for
- # the scroll margins. At this time this comment was
- # written the tuiterm library doesn't support the scroll
- # margins. If/when that changes, then the following will
- # need to be updated.
+ # The following code is written without consideration for
+ # the scroll margins. At this time this comment was
+ # written the tuiterm library doesn't support the scroll
+ # margins. If/when that changes, then the following will
+ # need to be updated.
- set y [expr $_rows - $count]
- set dy $_rows
+ set y [expr $_rows - $count]
+ set dy $_rows
- while {$dy >= $count} {
- for {set x 0} {$x < $_cols} {incr x} {
- set _chars($x,$dy) $_chars($x,$y)
- }
- incr y -1
- incr dy -1
+ while {$dy >= $count} {
+ for {set x 0} {$x < $_cols} {incr x} {
+ set _chars($x,$dy) $_chars($x,$y)
}
-
- _clear_lines 0 $count
+ incr y -1
+ incr dy -1
}
+
+ _clear_lines 0 $count
}
+}
- # Erase chars.
- #
- # https://vt100.net/docs/vt510-rm/ECH.html
- proc _csi_X {args} {
- set n [_default [lindex $args 0] 1]
+# Erase chars.
+#
+# https://vt100.net/docs/vt510-rm/ECH.html
+proc Term::_csi_X {args} {
+ set n [_default [lindex $args 0] 1]
- _log_cur "Erase chars ($n)" {
- # Erase characters but don't move cursor.
- variable _cur_col
- variable _cur_row
- variable _attrs
- variable _chars
+ _log_cur "Erase chars ($n)" {
+ # Erase characters but don't move cursor.
+ variable _cur_col
+ variable _cur_row
+ variable _attrs
+ variable _chars
- set lattr [array get _attrs]
- set x $_cur_col
- for {set i 0} {$i < $n} {incr i} {
- set _chars($x,$_cur_row) [list " " $lattr]
- incr x
- }
+ set lattr [array get _attrs]
+ set x $_cur_col
+ for {set i 0} {$i < $n} {incr i} {
+ set _chars($x,$_cur_row) [list " " $lattr]
+ incr x
}
}
+}
- # Cursor Backward Tabulation.
- #
- # https://vt100.net/docs/vt510-rm/CBT.html
- proc _csi_Z {args} {
- set n [_default [lindex $args 0] 1]
+# Cursor Backward Tabulation.
+#
+# https://vt100.net/docs/vt510-rm/CBT.html
+proc Term::_csi_Z {args} {
+ set n [_default [lindex $args 0] 1]
- _log_cur "Cursor Backward Tabulation ($n)" {
- variable _cur_col
+ _log_cur "Cursor Backward Tabulation ($n)" {
+ variable _cur_col
- set _cur_col [expr {max (int (($_cur_col - 1) / 8) * 8 - ($n - 1) * 8, 0)}]
- }
+ set _cur_col [expr {max (int (($_cur_col - 1) / 8) * 8 - ($n - 1) * 8, 0)}]
}
+}
- # Repeat.
- #
- # https://www.xfree86.org/current/ctlseqs.html (See `(REP)`)
- proc _csi_b {args} {
- set n [_default [lindex $args 0] 1]
+# Repeat.
+#
+# https://www.xfree86.org/current/ctlseqs.html (See `(REP)`)
+proc Term::_csi_b {args} {
+ set n [_default [lindex $args 0] 1]
- _log_cur "Repeat ($n)" {
- variable _last_char
+ _log_cur "Repeat ($n)" {
+ variable _last_char
- _insert [string repeat $_last_char $n]
- }
+ _insert [string repeat $_last_char $n]
}
+}
- # Vertical Line Position Absolute.
- #
- # https://vt100.net/docs/vt510-rm/VPA.html
- proc _csi_d {args} {
- set row [_default [lindex $args 0] 1]
+# Vertical Line Position Absolute.
+#
+# https://vt100.net/docs/vt510-rm/VPA.html
+proc Term::_csi_d {args} {
+ set row [_default [lindex $args 0] 1]
- _log_cur "Vertical Line Position Absolute ($row)" {
- variable _cur_row
- variable _rows
+ _log_cur "Vertical Line Position Absolute ($row)" {
+ variable _cur_row
+ variable _rows
- set _cur_row [expr min ($row - 1, $_rows - 1)]
- }
+ set _cur_row [expr min ($row - 1, $_rows - 1)]
}
+}
- # Reset the attributes in attributes array UPVAR_NAME to the default values.
- proc _reset_attrs { upvar_name } {
- upvar $upvar_name var
- array set var {
- intensity normal
- fg default
- bg default
- underline 0
- reverse 0
- invisible 0
- blinking 0
+# Set Mode (SM, CSI h)
+#
+# https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
+proc Term::_csi_h { args } {
+ foreach item $args {
+ switch -exact -- $item {
+ 4 {
+ # Insert Mode (IRM)
+ _log "ignored: insert mode"
+ }
+ default {
+ error unsupported
+ }
}
}
+}
- # Translate the color numbers as used in proc _csi_m to a name.
- proc _color_attr { n } {
- switch -exact -- $n {
- 0 {
- return black
+# Reset Mode (RM, CSI l)
+#
+# https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
+proc Term::_csi_l { args } {
+ foreach item $args {
+ switch -exact -- $item {
+ 4 {
+ # Replace Mode (IRM)
+ _log "ignored: replace mode"
+ }
+ default {
+ error unsupported
}
+ }
+ }
+}
+
+# Set Scrolling Region (DECSTBM, CSI Ps ; Ps r)
+#
+# https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
+proc Term::_csi_r { top bottom } {
+ _log "ignored: set scrolling region"
+}
+
+# Window manipulation (XTWINOPS, CSI Ps ; Ps ; Ps t)
+#
+# https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
+proc Term::_csi_t { arg1 arg2 arg3 } {
+ if { $arg1 == 22 && $arg2 == 0 && $arg3 == 0 } {
+ _log "ignored: Save xterm icon and window title on stack"
+ return
+ }
+
+ if { $arg1 == 23 && $arg2 == 0 && $arg3 == 0 } {
+ _log "ignored: Restore xterm icon and window title from stack"
+ return
+ }
+
+ error unsupported
+}
+
+# DECSET (CSI ? h)
+#
+# https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
+proc Term::_csi_0x3f_h { args } {
+ foreach item $args {
+ switch -exact -- $item {
1 {
- return red
+ _log "ignored: Application Cursor Keys"
}
- 2 {
- return green
+ 7 {
+ _log "ignored: autowrap mode"
}
- 3 {
- return yellow
+ 1000 {
+ _log "ignored: Send Mouse X & Y on button press and release"
}
- 4 {
- return blue
+ 1006 {
+ _log "ignored: Enable SGR Mouse Mode"
}
- 5 {
- return magenta
+ 1049 {
+ _log "switch to alternate screen"
+ _set_alternate 1
}
- 6 {
- return cyan
+ default {
+ error unsupported
+ }
+ }
+ }
+}
+
+# DECRST (CSI ? l)
+#
+# https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-Mouse-Tracking
+proc Term::_csi_0x3f_l { args } {
+ foreach item $args {
+ switch -exact -- $item {
+ 1 {
+ _log "ignored: Normal Cursor Keys"
}
7 {
- return white
+ _log "ignored: no autowrap mode"
+ }
+ 1000 {
+ _log "ignored: Don't send Mouse X & Y on button press and release"
+ }
+ 1006 {
+ _log "ignored: Disable SGR Mouse Mode"
+ }
+ 1049 {
+ _log "switch from alternate screen"
+ _set_alternate 0
+ }
+ default {
+ error "unsupported"
}
- default { error "unsupported color number: $n" }
}
}
+}
- # Select Graphic Rendition.
- #
- # https://vt100.net/docs/vt510-rm/SGR.html
- proc _csi_m {args} {
- if { [llength $args] == 0 } {
- # Apply default.
- set args [list 0]
+# Reset the attributes in attributes array UPVAR_NAME to the default values.
+proc Term::_reset_attrs { upvar_name } {
+ upvar $upvar_name var
+ array set var {
+ intensity normal
+ fg default
+ bg default
+ underline 0
+ reverse 0
+ invisible 0
+ blinking 0
+ }
+}
+
+# Translate the color numbers as used in proc _csi_m to a name.
+proc Term::_color_attr { n } {
+ switch -exact -- $n {
+ 0 {
+ return black
+ }
+ 1 {
+ return red
+ }
+ 2 {
+ return green
}
+ 3 {
+ return yellow
+ }
+ 4 {
+ return blue
+ }
+ 5 {
+ return magenta
+ }
+ 6 {
+ return cyan
+ }
+ 7 {
+ return white
+ }
+ default { error "unsupported color number: $n" }
+ }
+}
- _log_cur "Select Graphic Rendition ([join $args {, }])" {
- variable _attrs
+# Select Graphic Rendition.
+#
+# https://vt100.net/docs/vt510-rm/SGR.html
+proc Term::_csi_m {args} {
+ if { [llength $args] == 0 } {
+ # Apply default.
+ set args [list 0]
+ }
- foreach item $args {
- switch -exact -- $item {
- "" - 0 {
- _reset_attrs _attrs
- }
- 1 {
- set _attrs(intensity) bold
- }
- 2 {
- set _attrs(intensity) dim
- }
- 4 {
- set _attrs(underline) 1
- }
- 5 {
- set _attrs(blinking) 1
- }
- 7 {
- set _attrs(reverse) 1
- }
- 8 {
- set _attrs(invisible) 1
- }
- 22 {
- set _attrs(intensity) normal
- }
- 24 {
- set _attrs(underline) 0
- }
- 25 {
- set _attrs(blinking) 0
- }
- 27 {
- set _attrs(reverse) 0
- }
- 28 {
- set _attrs(invisible) 0
- }
- 30 - 31 - 32 - 33 - 34 - 35 - 36 - 37 {
- set _attrs(fg) [_color_attr [expr $item - 30]]
- }
- 39 {
- set _attrs(fg) default
- }
- 40 - 41 - 42 - 43 - 44 - 45 - 46 - 47 {
- set _attrs(bg) [_color_attr [expr $item - 40]]
- }
- 49 {
- set _attrs(bg) default
- }
+ _log_cur "Select Graphic Rendition ([join $args {, }])" {
+ variable _attrs
+
+ foreach item $args {
+ switch -exact -- $item {
+ "" - 0 {
+ _reset_attrs _attrs
+ }
+ 1 {
+ set _attrs(intensity) bold
+ }
+ 2 {
+ set _attrs(intensity) dim
+ }
+ 4 {
+ set _attrs(underline) 1
+ }
+ 5 {
+ set _attrs(blinking) 1
+ }
+ 7 {
+ set _attrs(reverse) 1
+ }
+ 8 {
+ set _attrs(invisible) 1
+ }
+ 22 {
+ set _attrs(intensity) normal
+ }
+ 24 {
+ set _attrs(underline) 0
+ }
+ 25 {
+ set _attrs(blinking) 0
+ }
+ 27 {
+ set _attrs(reverse) 0
+ }
+ 28 {
+ set _attrs(invisible) 0
+ }
+ 30 - 31 - 32 - 33 - 34 - 35 - 36 - 37 {
+ set _attrs(fg) [_color_attr [expr $item - 30]]
+ }
+ 39 {
+ set _attrs(fg) default
+ }
+ 40 - 41 - 42 - 43 - 44 - 45 - 46 - 47 {
+ set _attrs(bg) [_color_attr [expr $item - 40]]
+ }
+ 49 {
+ set _attrs(bg) default
}
}
}
}
+}
+
+# Request Terminal Parameters (DECREQTPARM)
+#
+# https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
+# https://vt100.net/docs/vt100-ug/chapter3.html
+proc Term::_csi_x {} {
+ # Ignore.
+}
+
+# Insert string at the cursor location.
+proc Term::_insert {str} {
+ _log_cur "Inserted string '$str'" {
+ _log "Inserting string '$str'"
- # Insert string at the cursor location.
- proc _insert {str} {
- _log_cur "Inserted string '$str'" {
- _log "Inserting string '$str'"
-
- variable _cur_col
- variable _cur_row
- variable _rows
- variable _cols
- variable _attrs
- variable _chars
- set lattr [array get _attrs]
- foreach char [split $str {}] {
- _log_cur " Inserted char '$char'" {
- set _chars($_cur_col,$_cur_row) [list $char $lattr]
- incr _cur_col
- if {$_cur_col >= $_cols} {
- set _cur_col 0
- incr _cur_row
- if {$_cur_row >= $_rows} {
- error "FIXME scroll"
- }
+ variable _cur_col
+ variable _cur_row
+ variable _rows
+ variable _cols
+ variable _attrs
+ variable _chars
+ set lattr [array get _attrs]
+ foreach char [split $str {}] {
+ _log_cur " Inserted char '$char'" {
+ set _chars($_cur_col,$_cur_row) [list $char $lattr]
+ incr _cur_col
+ if {$_cur_col >= $_cols} {
+ set _cur_col 0
+ incr _cur_row
+ if {$_cur_row >= $_rows} {
+ error "FIXME scroll"
}
}
}
}
+
+ variable _last_char
+ set _last_char [string index $str end]
}
+}
- # Move the cursor to the (0-based) COL and ROW positions.
- proc _move_cursor { col row } {
- variable _cols
- variable _rows
- variable _cur_col
- variable _cur_row
+# Move the cursor to the (0-based) COL and ROW positions.
+proc Term::_move_cursor { col row } {
+ variable _cols
+ variable _rows
+ variable _cur_col
+ variable _cur_row
- if { $col < 0 || $col >= $_cols } {
- error "_move_cursor: invalid col value: $col"
- }
+ if { $col < 0 || $col >= $_cols } {
+ error "_move_cursor: invalid col value: $col"
+ }
- if { $row < 0 || $row >= $_rows } {
- error "_move_cursor: invalid row value: $row"
- }
+ if { $row < 0 || $row >= $_rows } {
+ error "_move_cursor: invalid row value: $row"
+ }
- set _cur_col $col
- set _cur_row $row
- }
+ set _cur_col $col
+ set _cur_row $row
+}
- # Initialize.
- proc _setup {rows cols} {
- global stty_init
- set stty_init "rows $rows columns $cols"
+# Enable or disable alternate screen.
+proc Term::_set_alternate { enable } {
+ variable _alternate
+ if { $enable == $_alternate } {
+ return
+ }
+ set _alternate $enable
- variable _rows
- variable _cols
- variable _cur_col
- variable _cur_row
- variable _attrs
- variable _resize_count
+ variable _attrs
+ variable _chars
+ variable _cur_col
+ variable _cur_row
- set _rows $rows
- set _cols $cols
- set _cur_col 0
- set _cur_row 0
- set _resize_count 0
- _reset_attrs _attrs
-
- _clear_lines 0 $_rows
- }
-
- # Accept some output from gdb and update the screen.
- # Return 1 if successful, or 0 if a timeout occurred.
- proc accept_gdb_output { } {
- global expect_out
- gdb_expect {
- -re "^\[\x07\x08\x0a\x0d\]" {
- scan $expect_out(0,string) %c val
- set hexval [format "%02x" $val]
- _log "wait_for: _ctl_0x${hexval}"
- _ctl_0x${hexval}
- }
- -re "^\x1b(\[0-9a-zA-Z\])" {
- _log "wait_for: unsupported escape"
- error "unsupported escape"
- }
- -re "^\x1b\\\[(\[0-9;\]*)(\[a-zA-Z@`\])" {
- set cmd $expect_out(2,string)
- set params [split $expect_out(1,string) ";"]
- _log "wait_for: _csi_$cmd <<<$expect_out(1,string)>>>"
- eval _csi_$cmd $params
- }
- -re "^\[^\x07\x08\x0a\x0d\x1b\]+" {
- _insert $expect_out(0,string)
- variable _last_char
- set _last_char [string index $expect_out(0,string) end]
- }
+ variable _save_attrs
+ variable _save_chars
+ variable _save_cur_col
+ variable _save_cur_row
- timeout {
- # Assume a timeout means we somehow missed the
- # expected result, and carry on.
- warning "timeout in accept_gdb_output"
- dump_screen
- return 0
- }
- }
+ variable _alternate_setup
- return 1
+ if { $_alternate_setup } {
+ set tmp $_save_chars
+ }
+ set _save_chars [array get _chars]
+ if { $_alternate_setup } {
+ array set _chars $tmp
}
- # Print arg using "verbose -log" if DEBUG_TUI_MATCHING == 1.
- proc debug_tui_matching { arg } {
- set debug 0
- if { [info exists ::DEBUG_TUI_MATCHING] } {
- set debug $::DEBUG_TUI_MATCHING
- }
+ if { $_alternate_setup } {
+ set tmp $_save_attrs
+ }
+ set _save_attrs [array get _attrs]
+ if { $_alternate_setup } {
+ array set _attrs $tmp
+ }
- if { ! $debug } {
- return
- }
+ if { $_alternate_setup } {
+ set tmp $_save_cur_col
+ }
+ set _save_cur_col $_cur_col
+ if { $_alternate_setup } {
+ set _cur_col $tmp
+ }
- verbose -log "$arg"
+ if { $_alternate_setup } {
+ set tmp $_save_cur_row
+ }
+ set _save_cur_row $_cur_row
+ if { $_alternate_setup } {
+ set _cur_row $tmp
}
- # Accept some output from gdb and update the screen. WAIT_FOR is
- # a regexp matching the line to wait for. Return 0 on timeout, 1
- # on success.
- proc wait_for {wait_for} {
- global gdb_prompt
- variable _cur_col
- variable _cur_row
+ if { ! $_alternate_setup } {
+ variable _rows
+ variable _cols
+ _setup $_rows $_cols
+ set _alternate_setup 1
+ }
+}
- set fn "wait_for"
+# Initialize.
+proc Term::_setup {rows cols} {
+ global stty_init
+ set stty_init "rows $rows columns $cols"
- set prompt_wait_for "(^|\\|)$gdb_prompt \$"
- if { $wait_for == "" } {
- set wait_for $prompt_wait_for
- }
+ variable _rows
+ variable _cols
+ variable _cur_col
+ variable _cur_row
+ variable _attrs
+ variable _resize_count
- debug_tui_matching "$fn: regexp: '$wait_for'"
+ set _rows $rows
+ set _cols $cols
+ set _cur_col 0
+ set _cur_row 0
+ set _resize_count 0
+ _reset_attrs _attrs
- while 1 {
- if { [accept_gdb_output] == 0 } {
- return 0
- }
+ _clear_lines 0 $_rows
+}
- # If the cursor appears just after the prompt, return. It
- # isn't reliable to check this only after an insertion,
- # because curses may make "unusual" redrawing decisions.
- if {$wait_for == "$prompt_wait_for"} {
- set prev [get_line $_cur_row $_cur_col]
- } else {
- set prev [get_line $_cur_row]
- }
- if {[regexp -- $wait_for $prev]} {
- debug_tui_matching "$fn: match: '$prev'"
- if {$wait_for == "$prompt_wait_for"} {
- break
- }
- set wait_for $prompt_wait_for
- debug_tui_matching "$fn: regexp prompt: '$wait_for'"
- } else {
- debug_tui_matching "$fn: mismatch: '$prev'"
- }
+# Accept some output from gdb and update the screen.
+# Return 1 if successful, or 0 if a timeout occurred.
+proc Term::accept_gdb_output { {warn 1} } {
+ global expect_out
+
+ set ctls "\x07\x08\x0a\x0d"
+ set esc "\x1b"
+ set re_ctls "\[$ctls\]"
+ set re_others "\[^$esc$ctls\]"
+ set have_esc 0
+ gdb_expect {
+ -re ^$re_ctls {
+ scan $expect_out(0,string) %c val
+ set hexval [format "%02x" $val]
+ _log "wait_for: _ctl_0x${hexval}"
+ _ctl_0x${hexval}
+ }
+ -re "^$esc" {
+ _log "wait_for: ESC"
+ set have_esc 1
+ }
+ -re "^$re_others+" {
+ _insert $expect_out(0,string)
+ }
+
+ timeout {
+ # Assume a timeout means we somehow missed the
+ # expected result, and carry on.
+ warning "timeout in accept_gdb_output"
+ dump_screen
+ return 0
}
+ }
+ if { !$have_esc } {
return 1
}
- # Accept some output from gdb and update the screen. Wait for the screen
- # region X/Y/WIDTH/HEIGTH to matches REGEXP. Return 0 on timeout, 1 on
- # success.
- proc wait_for_region_contents {x y width height regexp} {
- while 1 {
- if { [accept_gdb_output] == 0 } {
- return 0
- }
+ set re_csi [string_to_regexp "\["]
+ set have_csi 0
+ gdb_expect {
+ -re "^(\[0-9a-zA-Z\])" {
+ _log "wait_for: unsupported escape"
+ error "unsupported escape"
+ }
+ -re "^(\[\\(\])(\[a-zA-Z\])" {
+ scan $expect_out(1,string) %c val
+ set hexval [format "%02x" $val]
+ set cmd $expect_out(2,string)
+ _esc_0x${hexval}_$cmd
+ }
+ -re "^(\[=>\])" {
+ scan $expect_out(1,string) %c val
+ set hexval [format "%02x" $val]
+ _esc_0x$hexval
+ }
+ -re "^$re_csi" {
+ _log "wait_for: CSI"
+ set have_csi 1
+ }
- if { [check_region_contents_p $x $y $width $height $regexp] } {
- break
+ timeout {
+ # Assume a timeout means we somehow missed the
+ # expected result, and carry on.
+ if { $warn } {
+ warning "timeout in accept_gdb_output following ESC"
+ dump_screen
}
+ _insert "^\["
+ return 0
}
+ }
+ if { !$have_csi } {
return 1
}
- # Setup the terminal with dimensions ROWSxCOLS, TERM=ansi, and execute
- # BODY.
- proc with_tuiterm {rows cols body} {
- global env stty_init
- variable _TERM
- save_vars {env(TERM) env(NO_COLOR) stty_init} {
- if { [ishost *-*-*bsd*] } {
- setenv TERM ansiw
- } else {
- setenv TERM ansi
+ set re_csi_prefix {[?]}
+ set re_csi_args {[0-9;]}
+ set re_csi_cmd {[a-zA-Z@`]}
+ gdb_expect {
+ -re "^($re_csi_cmd)" {
+ set cmd $expect_out(1,string)
+ _log "wait_for: _csi_$cmd"
+ _csi_$cmd
+ }
+ -re "^($re_csi_args*)($re_csi_cmd)" {
+ set params [split $expect_out(1,string) ";"]
+ set cmd $expect_out(2,string)
+ _log "wait_for: _csi_$cmd <<<$params>>>"
+ _csi_$cmd {*}$params
+ }
+ -re "^($re_csi_prefix?)($re_csi_args*)($re_csi_cmd)" {
+ set prefix $expect_out(1,string)
+ set params [split $expect_out(2,string) ";"]
+ set cmd $expect_out(3,string)
+ scan $prefix %c val
+ set hexval [format "%02x" $val]
+ _log "wait_for: _csi_0x${hexval}_$cmd <<<$expect_out(1,string)>>>"
+ _csi_0x${hexval}_$cmd {*}$params
+ }
+
+ timeout {
+ # Assume a timeout means we somehow missed the
+ # expected result, and carry on.
+ if { $warn } {
+ warning "timeout in accept_gdb_output following CSI"
+ dump_screen
}
- # Save active TERM variable.
- set Term::_TERM $env(TERM)
+ _insert "^\[\["
+ return 0
+ }
+ }
- setenv NO_COLOR ""
- _setup $rows $cols
+ return 1
+}
- uplevel $body
- }
+# Print arg using "verbose -log" if DEBUG_TUI_MATCHING == 1.
+proc Term::debug_tui_matching { arg } {
+ set debug 0
+ if { [info exists ::DEBUG_TUI_MATCHING] } {
+ set debug $::DEBUG_TUI_MATCHING
}
- # Like ::clean_restart, but ensures that gdb starts in an
- # environment where the TUI can work. ROWS and COLS are the size
- # of the terminal. EXECUTABLE, if given, is passed to
- # clean_restart.
- proc clean_restart {rows cols {executable {}}} {
- with_tuiterm $rows $cols {
- save_vars { ::GDBFLAGS } {
- # Make GDB not print the directory names. Use this setting to
- # remove the differences in test runs due to varying directory
- # names.
- append ::GDBFLAGS " -ex \"set filename-display basename\""
+ if { ! $debug } {
+ return
+ }
- if {$executable == ""} {
- ::clean_restart
- } else {
- ::clean_restart $executable
- }
- }
+ verbose -log "$arg"
+}
- ::gdb_test_no_output "set pagination off"
- }
+# Accept some output from gdb and update the screen. WAIT_FOR is
+# a regexp matching the line to wait for. Return 0 on timeout, 1
+# on success.
+proc Term::wait_for {wait_for} {
+ global gdb_prompt
+ variable _cur_col
+ variable _cur_row
+
+ set fn "wait_for"
+
+ set prompt_wait_for "(^|\\|)$gdb_prompt \$"
+ if { $wait_for == "" } {
+ set wait_for $prompt_wait_for
}
- # Generate prompt on TUIterm.
- proc gen_prompt {} {
- # Generate a prompt.
- send_gdb "echo\n"
+ debug_tui_matching "$fn: regexp: '$wait_for'"
+
+ while 1 {
+ if { [accept_gdb_output] == 0 } {
+ return 0
+ }
+
+ # If the cursor appears just after the prompt, return. It
+ # isn't reliable to check this only after an insertion,
+ # because curses may make "unusual" redrawing decisions.
+ if {$wait_for == "$prompt_wait_for"} {
+ set prev [get_line $_cur_row $_cur_col]
+ } else {
+ set prev [get_line $_cur_row]
+ }
+
+ if { ![regexp -- $wait_for $prev] } {
+ debug_tui_matching "$fn: mismatch: '$prev'"
+ continue
+ }
- # Drain the output before the prompt.
- gdb_expect {
- -re "echo\r\n" {
+ if {$wait_for == "$prompt_wait_for"} {
+ # We've detected that the cursor is just after the prompt.
+ # Now check that there's nothing else on the line.
+ set prev [get_line $_cur_row]
+ if { ![regexp -- "(^|\\|)$gdb_prompt +($|\\||\\+)" $prev] } {
+ debug_tui_matching "$fn: mismatch: '$prev'"
+ continue
}
}
- # Interpret prompt using TUIterm.
- wait_for ""
- }
+ debug_tui_matching "$fn: match: '$prev'"
- # Setup ready for starting the tui, but don't actually start it.
- # Returns 1 on success, 0 if TUI tests should be skipped.
- proc prepare_for_tui {} {
- if { [is_remote host] } {
- # In clean_restart, we're using "setenv TERM ansi", which has
- # effect on build. If we have [is_remote host] == 0, so
- # build == host, then it also has effect on host. But for
- # [is_remote host] == 1, it has no effect on host.
- return 0
+ if {$wait_for == "$prompt_wait_for"} {
+ # Matched the prompt, we're done.
+ break
}
- if {![allow_tui_tests]} {
+ # Now try to match the prompt.
+ set wait_for $prompt_wait_for
+ debug_tui_matching "$fn: regexp prompt: '$wait_for'"
+ }
+
+ return 1
+}
+
+# Accept some output from gdb and update the screen. Wait for the screen
+# region X/Y/WIDTH/HEIGTH to matches REGEXP. Return 0 on timeout, 1 on
+# success.
+proc Term::wait_for_region_contents {x y width height regexp} {
+ while 1 {
+ if { [accept_gdb_output] == 0 } {
return 0
}
- gdb_test_no_output "set tui border-kind ascii"
- gdb_test_no_output "maint set tui-resize-message on"
- return 1
+ if { [check_region_contents_p $x $y $width $height $regexp] } {
+ break
+ }
}
- # Start the TUI. Returns 1 on success, 0 if TUI tests should be
- # skipped.
- proc enter_tui {} {
- if {![prepare_for_tui]} {
+ return 1
+}
+
+# Accept some output from gdb and update the screen. Wait for the current
+# screen line to match REGEXP and cursor position POS, unless POS is empty.
+# Return 0 on timeout, 1 on success.
+proc Term::wait_for_line { regexp {pos ""} } {
+ variable _cur_row
+ variable _cur_col
+ variable _cols
+
+ while 1 {
+ if { [accept_gdb_output] == 0 } {
return 0
}
- command_no_prompt_prefix "tui enable"
- return 1
- }
+ if { ![check_region_contents_p 0 $_cur_row $_cols 1 $regexp] } {
+ continue
+ }
- # Send the command CMD to gdb, then wait for a gdb prompt to be
- # seen in the TUI. CMD should not end with a newline -- that will
- # be supplied by this function.
- proc command {cmd} {
- global gdb_prompt
- send_gdb "$cmd\n"
- set str [string_to_regexp $cmd]
- set str "(^|\\|)$gdb_prompt $str"
- wait_for $str
- }
-
- # As proc command, but don't wait for an initial prompt. This is used for
- # initial terminal commands, where there's no prompt yet.
- proc command_no_prompt_prefix {cmd} {
- gen_prompt
- command $cmd
- }
-
- # Apply the attribute list in ATTRS to attributes array UPVAR_NAME.
- # Return a string annotating the changed attributes.
- proc apply_attrs { upvar_name attrs } {
- set res ""
- upvar $upvar_name var
- foreach { attr val } $attrs {
- if { $var($attr) != $val } {
- append res "<$attr:$val>"
- set var($attr) $val
- }
+ if { $pos == "" || $_cur_col == $pos } {
+ break
}
+ }
+
+ return 1
+}
+
+# In BODY, when using Term::with_tuiterm, use TERM instead of the default.
- return $res
+proc Term::with_term { term body } {
+ save_vars { Term::_TERM } {
+ set Term::_TERM $term
+ uplevel $body
}
+}
- # Return the text of screen line N. Lines are 0-based. Start at column
- # X. If C is non-empty, stop before column C. Columns are also
- # zero-based. If ATTRS, annotate with attributes.
- proc get_string {n x c {attrs 0}} {
- variable _rows
- # This can happen during resizing, if the cursor seems to
- # temporarily be off-screen.
- if {$n >= $_rows} {
- return ""
+# Setup the terminal with dimensions ROWSxCOLS, TERM=ansi, and execute
+# BODY.
+proc Term::with_tuiterm {rows cols body} {
+ global env stty_init
+ variable _TERM
+ save_vars {env(TERM) env(NO_COLOR) stty_init} {
+ if { $Term::_TERM != "" } {
+ setenv TERM $Term::_TERM
+ } elseif { [ishost *-*-*bsd*] } {
+ setenv TERM ansiw
+ } else {
+ setenv TERM ansi
}
+ # Save active TERM variable.
+ set Term::_TERM $env(TERM)
- set result ""
- variable _cols
- variable _chars
- set c [_default $c $_cols]
- if { $attrs } {
- _reset_attrs line_attrs
- }
- while {$x < $c} {
- if { $attrs } {
- set char_attrs [lindex $_chars($x,$n) 1]
- append result [apply_attrs line_attrs $char_attrs]
+ setenv NO_COLOR ""
+ _setup $rows $cols
+
+ uplevel $body
+ }
+}
+
+# Like ::clean_restart, but ensures that gdb starts in an
+# environment where the TUI can work. ROWS and COLS are the size
+# of the terminal. EXECUTABLE, if given, is passed to
+# clean_restart.
+proc Term::clean_restart {rows cols {executable {}}} {
+ with_tuiterm $rows $cols {
+ save_vars { ::GDBFLAGS } {
+ # Make GDB not print the directory names. Use this setting to
+ # remove the differences in test runs due to varying directory
+ # names.
+ append ::GDBFLAGS " -ex \"set filename-display basename\""
+
+ if {$executable == ""} {
+ ::clean_restart
+ } else {
+ ::clean_restart $executable
}
- append result [lindex $_chars($x,$n) 0]
- incr x
}
- if { $attrs } {
- _reset_attrs zero_attrs
- set char_attrs [array get zero_attrs]
- append result [apply_attrs line_attrs $char_attrs]
- }
- return $result
- }
- # Return the text of screen line N. Lines are 0-based. Start at column
- # X. If C is non-empty, stop before column C. Columns are also
- # zero-based. Annotate with attributes.
- proc get_string_with_attrs { n x c } {
- return [get_string $n $x $c 1]
+ ::gdb_test_no_output "set pagination off"
}
+}
- # Return the text of screen line N. Lines are 0-based. If C is
- # non-empty, stop before column C. Columns are also zero-based. If
- # ATTRS, annotate with attributes.
- proc get_line_1 {n c attrs} {
- return [get_string $n 0 $c $attrs]
+# Generate prompt on TUIterm.
+proc Term::gen_prompt {} {
+ # Generate a prompt.
+ send_gdb "echo\n"
+
+ # Drain the output before the prompt.
+ gdb_expect {
+ -re "echo\r\n" {
+ }
}
- # Return the text of screen line N, without attributes. Lines are
- # 0-based. If C is given, stop before column C. Columns are also
- # zero-based.
- proc get_line {n {c ""} } {
- return [get_line_1 $n $c 0]
+ # Interpret prompt using TUIterm.
+ wait_for ""
+}
+
+# Setup ready for starting the tui, but don't actually start it.
+# Returns 1 on success, 0 if TUI tests should be skipped.
+proc Term::prepare_for_tui {} {
+ if { [is_remote host] } {
+ # In clean_restart, we're using "setenv TERM ansi", which has
+ # effect on build. If we have [is_remote host] == 0, so
+ # build == host, then it also has effect on host. But for
+ # [is_remote host] == 1, it has no effect on host.
+ return 0
}
- # As get_line, but annotate with attributes.
- proc get_line_with_attrs {n {c ""}} {
- return [get_line_1 $n $c 1]
+ if {![allow_tui_tests]} {
+ return 0
}
- # Get just the character at (X, Y).
- proc get_char {x y} {
- variable _chars
- return [lindex $_chars($x,$y) 0]
+ gdb_test_no_output "set tui border-kind ascii"
+ gdb_test_no_output "maint set tui-resize-message on"
+ # When matching GDB output using Term::wait_for, the number of
+ # matching attempts in wait_for can be influenced by CLI styling.
+ # Disable it by default to avoid this.
+ gdb_test_no_output "set style enabled off"
+ return 1
+}
+
+# Start the TUI. Returns 1 on success, 0 if TUI tests should be
+# skipped.
+proc Term::enter_tui {} {
+ if {![prepare_for_tui]} {
+ return 0
}
- # Get the entire screen as a string.
- proc get_all_lines {} {
- variable _rows
- variable _cols
- variable _chars
+ command_no_prompt_prefix "tui enable"
+ return 1
+}
- set result ""
- for {set y 0} {$y < $_rows} {incr y} {
- for {set x 0} {$x < $_cols} {incr x} {
- append result [lindex $_chars($x,$y) 0]
- }
- append result "\n"
+# Send the command CMD to gdb, then wait for a gdb prompt to be
+# seen in the TUI. CMD should not end with a newline -- that will
+# be supplied by this function.
+proc Term::command {cmd} {
+ global gdb_prompt
+ send_gdb "$cmd\n"
+ set str [string_to_regexp $cmd]
+ set str "(^|\\|)$gdb_prompt $str"
+ wait_for $str
+}
+
+# As proc command, but don't wait for an initial prompt. This is used for
+# initial terminal commands, where there's no prompt yet.
+proc Term::command_no_prompt_prefix {cmd} {
+ gen_prompt
+ command $cmd
+}
+
+# Apply the attribute list in ATTRS to attributes array UPVAR_NAME.
+# Return a string annotating the changed attributes.
+proc Term::apply_attrs { upvar_name attrs } {
+ set res ""
+ upvar $upvar_name var
+ foreach { attr val } $attrs {
+ if { $var($attr) != $val } {
+ append res "<$attr:$val>"
+ set var($attr) $val
}
+ }
- return $result
+ return $res
+}
+
+# Return the text of screen line N. Lines are 0-based. Start at column
+# X. If C is non-empty, stop before column C. Columns are also
+# zero-based. If ATTRS, annotate with attributes.
+proc Term::get_string {n x c {attrs 0}} {
+ variable _rows
+ # This can happen during resizing, if the cursor seems to
+ # temporarily be off-screen.
+ if {$n >= $_rows} {
+ return ""
}
- # Get the text just before the cursor.
- proc get_current_line {} {
- variable _cur_col
- variable _cur_row
- return [get_line $_cur_row $_cur_col]
+ set result ""
+ variable _cols
+ variable _chars
+ set c [_default $c $_cols]
+ if { $attrs } {
+ _reset_attrs line_attrs
+ }
+ while {$x < $c} {
+ if { $attrs } {
+ set char_attrs [lindex $_chars($x,$n) 1]
+ append result [apply_attrs line_attrs $char_attrs]
+ }
+ append result [lindex $_chars($x,$n) 0]
+ incr x
}
+ if { $attrs } {
+ _reset_attrs zero_attrs
+ set char_attrs [array get zero_attrs]
+ append result [apply_attrs line_attrs $char_attrs]
+ }
+ return $result
+}
- # Helper function for check_box. Returns empty string if the box
- # is found, description of why not otherwise.
- proc _check_box {x y width height} {
- set x2 [expr {$x + $width - 1}]
- set y2 [expr {$y + $height - 1}]
+# Return the text of screen line N. Lines are 0-based. Start at column
+# X. If C is non-empty, stop before column C. Columns are also
+# zero-based. Annotate with attributes.
+proc Term::get_string_with_attrs { n x c } {
+ return [get_string $n $x $c 1]
+}
- verbose -log "_check_box x=$x, y=$y, x2=$x2, y2=$y2, width=$width, height=$height"
+# Return the text of screen line N. Lines are 0-based. If C is
+# non-empty, stop before column C. Columns are also zero-based. If
+# ATTRS, annotate with attributes.
+proc Term::get_line_1 {n c attrs} {
+ return [get_string $n 0 $c $attrs]
+}
- set c [get_char $x $y]
- if {$c != "+"} {
- return "ul corner is $c, not +"
- }
+# Return the text of screen line N, without attributes. Lines are
+# 0-based. If C is given, stop before column C. Columns are also
+# zero-based.
+proc Term::get_line {n {c ""} } {
+ return [get_line_1 $n $c 0]
+}
- set c [get_char $x $y2]
- if {$c != "+"} {
- return "ll corner is $c, not +"
- }
+# As get_line, but annotate with attributes.
+proc Term::get_line_with_attrs {n {c ""}} {
+ return [get_line_1 $n $c 1]
+}
- set c [get_char $x2 $y]
- if {$c != "+"} {
- return "ur corner is $c, not +"
- }
+# Get just the character at (X, Y).
+proc Term::get_char {x y} {
+ variable _chars
+ return [lindex $_chars($x,$y) 0]
+}
- set c [get_char $x2 $y2]
- if {$c != "+"} {
- return "lr corner is $c, not +"
- }
+# Get the entire screen as a string.
+proc Term::get_all_lines {} {
+ variable _rows
+ variable _cols
+ variable _chars
- # Note we do not check the full horizonal borders of the box.
- # The top will contain a title, and the bottom may as well, if
- # it is overlapped by some other border. However, at most a
- # title should appear as '+-VERY LONG TITLE-+', so we can
- # check for the '+-' on the left, and '-+' on the right.
- set c [get_char [expr {$x + 1}] $y]
- if {$c != "-"} {
- return "ul title padding is $c, not -"
+ set result ""
+ for {set y 0} {$y < $_rows} {incr y} {
+ for {set x 0} {$x < $_cols} {incr x} {
+ append result [lindex $_chars($x,$y) 0]
}
+ append result "\n"
+ }
- set c [get_char [expr {$x2 - 1}] $y]
- if {$c != "-"} {
- return "ul title padding is $c, not -"
- }
+ return $result
+}
- # Now check the vertical borders.
- for {set i [expr {$y + 1}]} {$i < $y2 - 1} {incr i} {
- set c [get_char $x $i]
- if {$c != "|"} {
- return "left side $i is $c, not |"
- }
+# Get the text just before the cursor.
+proc Term::get_current_line {} {
+ variable _cur_col
+ variable _cur_row
+ return [get_line $_cur_row $_cur_col]
+}
- set c [get_char $x2 $i]
- if {$c != "|"} {
- return "right side $i is $c, not |"
- }
- }
+# Helper function for check_box. Returns empty string if the box
+# is found, description of why not otherwise.
+proc Term::_check_box {x y width height} {
+ set x2 [expr {$x + $width - 1}]
+ set y2 [expr {$y + $height - 1}]
- return ""
+ verbose -log "_check_box x=$x, y=$y, x2=$x2, y2=$y2, width=$width, height=$height"
+
+ set c [get_char $x $y]
+ if {$c != "+"} {
+ return "ul corner is $c, not +"
}
- # Check for a box at the given coordinates.
- proc check_box {test_name x y width height} {
- dump_box $x $y $width $height
- set why [_check_box $x $y $width $height]
- if {$why == ""} {
- pass $test_name
- } else {
- fail "$test_name ($why)"
- }
+ set c [get_char $x $y2]
+ if {$c != "+"} {
+ return "ll corner is $c, not +"
}
- # Wait until a box appears at the given coordinates.
- proc wait_for_box {test_name x y width height} {
- while 1 {
- if { [accept_gdb_output] == 0 } {
- return 0
- }
+ set c [get_char $x2 $y]
+ if {$c != "+"} {
+ return "ur corner is $c, not +"
+ }
- set why [_check_box $x $y $width $height]
- if {$why == ""} {
- pass $test_name
- break
- }
- }
+ set c [get_char $x2 $y2]
+ if {$c != "+"} {
+ return "lr corner is $c, not +"
}
- # Check whether the text contents of the terminal match the
- # regular expression. Note that text styling is not considered.
- proc check_contents {test_name regexp} {
- dump_screen
- set contents [get_all_lines]
- gdb_assert {[regexp -- $regexp $contents]} $test_name
+ # Note we do not check the full horizonal borders of the box.
+ # The top will contain a title, and the bottom may as well, if
+ # it is overlapped by some other border. However, at most a
+ # title should appear as '+-VERY LONG TITLE-+', so we can
+ # check for the '+-' on the left, and '-+' on the right.
+ set c [get_char [expr {$x + 1}] $y]
+ if {$c != "-"} {
+ return "ul title padding is $c, not -"
}
- # As check_contents, but check that the text contents of the terminal does
- # not match the regular expression.
- proc check_contents_not {test_name regexp} {
- dump_screen
- set contents [get_all_lines]
- gdb_assert {![regexp -- $regexp $contents]} $test_name
+ set c [get_char [expr {$x2 - 1}] $y]
+ if {$c != "-"} {
+ return "ul title padding is $c, not -"
}
- # Get the region of the screen described by X, Y, WIDTH, and
- # HEIGHT, and separate the lines using SEP. If ATTRS is true then
- # include attribute information in the output.
- proc get_region { x y width height sep { attrs false } } {
- variable _chars
+ # Now check the vertical borders.
+ for {set i [expr {$y + 1}]} {$i < $y2 - 1} {incr i} {
+ set c [get_char $x $i]
+ if {$c != "|"} {
+ return "left side $i is $c, not |"
+ }
- if { $attrs } {
- _reset_attrs region_attrs
+ set c [get_char $x2 $i]
+ if {$c != "|"} {
+ return "right side $i is $c, not |"
}
+ }
- # Grab the contents of the box, join each line together
- # using $sep.
- set result ""
- for {set yy $y} {$yy < [expr {$y + $height}]} {incr yy} {
- if {$yy > $y} {
- # Add the end of line sequence only if this isn't the
- # first line.
- append result $sep
- }
- for {set xx $x} {$xx < [expr {$x + $width}]} {incr xx} {
- if { $attrs } {
- set char_attrs [lindex $_chars($xx,$yy) 1]
- append result [apply_attrs region_attrs $char_attrs]
- }
+ return ""
+}
- append result [get_char $xx $yy]
- }
+# Check for a box at the given coordinates.
+proc Term::check_box {test_name x y width height} {
+ dump_box $x $y $width $height
+ set why [_check_box $x $y $width $height]
+ if {$why == ""} {
+ pass $test_name
+ } else {
+ fail "$test_name ($why)"
+ }
+}
+
+# Wait until a box appears at the given coordinates.
+proc Term::wait_for_box {test_name x y width height} {
+ while 1 {
+ if { [accept_gdb_output] == 0 } {
+ return 0
}
- if { $attrs } {
- _reset_attrs zero_attrs
- set char_attrs [array get zero_attrs]
- append result [apply_attrs region_attrs $char_attrs]
+
+ set why [_check_box $x $y $width $height]
+ if {$why == ""} {
+ pass $test_name
+ break
}
- return $result
}
+}
- # Check that the region of the screen described by X, Y, WIDTH,
- # and HEIGHT match REGEXP. This is like check_contents except
- # only part of the screen is checked. This can be used to check
- # the contents within a box (though check_box_contents is a better
- # choice for boxes with a border). Return 1 if check succeeded.
- proc check_region_contents_p { x y width height regexp } {
- variable _chars
- dump_box $x $y $width $height
+# Check whether the text contents of the terminal match the
+# regular expression. Note that text styling is not considered.
+proc Term::check_contents {test_name regexp} {
+ dump_screen
+ set contents [get_all_lines]
+ gdb_assert {[regexp -- $regexp $contents]} $test_name
+}
- # Now grab the contents of the box, join each line together
- # with a '\r\n' sequence and match against REGEXP.
- set result [get_region $x $y $width $height "\r\n"]
- return [regexp -- $regexp $result]
- }
+# As check_contents, but check that the text contents of the terminal does
+# not match the regular expression.
+proc Term::check_contents_not {test_name regexp} {
+ dump_screen
+ set contents [get_all_lines]
+ gdb_assert {![regexp -- $regexp $contents]} $test_name
+}
- # Check that the region of the screen described by X, Y, WIDTH,
- # and HEIGHT match REGEXP. As check_region_contents_p, but produce
- # a pass/fail message.
- proc check_region_contents { test_name x y width height regexp } {
- set ok [check_region_contents_p $x $y $width $height $regexp]
- gdb_assert {$ok} $test_name
- }
+# Get the region of the screen described by X, Y, WIDTH, and
+# HEIGHT, and separate the lines using SEP. If ATTRS is true then
+# include attribute information in the output.
+proc Term::get_region { x y width height sep { attrs false } } {
+ variable _chars
- # Check the contents of a box on the screen. This is a little
- # like check_contents, but doesn't check the whole screen
- # contents, only the contents of a single box. This procedure
- # includes (effectively) a call to check_box to ensure there is a
- # box where expected, if there is then the contents of the box are
- # matched against REGEXP.
- proc check_box_contents {test_name x y width height regexp} {
- variable _chars
+ if { $attrs } {
+ _reset_attrs region_attrs
+ }
- dump_box $x $y $width $height
- set why [_check_box $x $y $width $height]
- if {$why != ""} {
- fail "$test_name (box check: $why)"
- return
+ # Grab the contents of the box, join each line together
+ # using $sep.
+ set result ""
+ for {set yy $y} {$yy < $y + $height} {incr yy} {
+ if {$yy > $y} {
+ # Add the end of line sequence only if this isn't the
+ # first line.
+ append result $sep
}
+ for {set xx $x} {$xx < $x + $width} {incr xx} {
+ if { $attrs } {
+ set char_attrs [lindex $_chars($xx,$yy) 1]
+ append result [apply_attrs region_attrs $char_attrs]
+ }
- check_region_contents $test_name [expr {$x + 1}] [expr {$y + 1}] \
- [expr {$width - 2}] [expr {$height - 2}] $regexp
+ append result [get_char $xx $yy]
+ }
+ }
+ if { $attrs } {
+ _reset_attrs zero_attrs
+ set char_attrs [array get zero_attrs]
+ append result [apply_attrs region_attrs $char_attrs]
}
+ return $result
+}
- # A debugging function to dump the current screen, with line
- # numbers. If ATTRS, annotate with attributes.
- proc dump_screen { {attrs 0} } {
- variable _rows
- variable _cols
- variable _cur_row
- variable _cur_col
+# Check that the region of the screen described by X, Y, WIDTH,
+# and HEIGHT match REGEXP. This is like check_contents except
+# only part of the screen is checked. This can be used to check
+# the contents within a box (though check_box_contents is a better
+# choice for boxes with a border). Return 1 if check succeeded.
+proc Term::check_region_contents_p { x y width height regexp } {
+ variable _chars
+ dump_box $x $y $width $height
- verbose -log "Screen Dump (size $_cols columns x $_rows rows, cursor at column $_cur_col, row $_cur_row):"
+ # Now grab the contents of the box, join each line together
+ # with a '\r\n' sequence and match against REGEXP.
+ set result [get_region $x $y $width $height "\r\n"]
+ return [regexp -- $regexp $result]
+}
- for {set y 0} {$y < $_rows} {incr y} {
- set fmt [format %5d $y]
- verbose -log "$fmt [get_line_1 $y {} $attrs]"
- }
+# Check that the region of the screen described by X, Y, WIDTH,
+# and HEIGHT match REGEXP. As check_region_contents_p, but produce
+# a pass/fail message.
+proc Term::check_region_contents { test_name x y width height regexp } {
+ set ok [check_region_contents_p $x $y $width $height $regexp]
+ gdb_assert {$ok} $test_name
+}
+
+# Check the contents of a box on the screen. This is a little
+# like check_contents, but doesn't check the whole screen
+# contents, only the contents of a single box. This procedure
+# includes (effectively) a call to check_box to ensure there is a
+# box where expected, if there is then the contents of the box are
+# matched against REGEXP.
+proc Term::check_box_contents {test_name x y width height regexp} {
+ variable _chars
+
+ dump_box $x $y $width $height
+ set why [_check_box $x $y $width $height]
+ if {$why != ""} {
+ fail "$test_name (box check: $why)"
+ return
}
- # As dump_screen, but with attributes annotation.
- proc dump_screen_with_attrs {} {
- return [dump_screen 1]
+ check_region_contents $test_name [expr {$x + 1}] [expr {$y + 1}] \
+ [expr {$width - 2}] [expr {$height - 2}] $regexp
+}
+
+# A debugging function to dump the current screen, with line
+# numbers. If ATTRS, annotate with attributes.
+proc Term::dump_screen { {attrs 0} } {
+ variable _rows
+ variable _cols
+ variable _cur_row
+ variable _cur_col
+
+ verbose -log "Screen Dump (size $_cols columns x $_rows rows, cursor at column $_cur_col, row $_cur_row):"
+
+ for {set y 0} {$y < $_rows} {incr y} {
+ set fmt [format %5d $y]
+ verbose -log "$fmt [get_line_1 $y {} $attrs]"
}
+}
- # A debugging function to dump a box from the current screen, with line
- # numbers.
- proc dump_box { x y width height } {
- verbose -log "Box Dump ($width x $height) @ ($x, $y):"
- set region [get_region $x $y $width $height "\n"]
- set lines [split $region "\n"]
- set nr $y
- foreach line $lines {
- set fmt [format %5d $nr]
- verbose -log "$fmt $line"
- incr nr
- }
+# As dump_screen, but with attributes annotation.
+proc Term::dump_screen_with_attrs {} {
+ return [dump_screen 1]
+}
+
+# A debugging function to dump a box from the current screen, with line
+# numbers.
+proc Term::dump_box { x y width height } {
+ verbose -log "Box Dump ($width x $height) @ ($x, $y):"
+ set region [get_region $x $y $width $height "\n"]
+ set lines [split $region "\n"]
+ set nr $y
+ foreach line $lines {
+ set fmt [format %5d $nr]
+ verbose -log "$fmt $line"
+ incr nr
}
+}
- # Resize the terminal.
- proc _do_resize {rows cols} {
- variable _chars
- variable _rows
- variable _cols
+# Resize the terminal.
+proc Term::_do_resize {rows cols} {
+ variable _chars
+ variable _rows
+ variable _cols
- set old_rows [expr {min ($_rows, $rows)}]
- set old_cols [expr {min ($_cols, $cols)}]
+ set old_rows [expr {min ($_rows, $rows)}]
+ set old_cols [expr {min ($_cols, $cols)}]
- # Copy locally.
- array set local_chars [array get _chars]
- unset _chars
+ # Copy locally.
+ array set local_chars [array get _chars]
+ unset _chars
- set _rows $rows
- set _cols $cols
- _clear_lines 0 $_rows
+ set _rows $rows
+ set _cols $cols
+ _clear_lines 0 $_rows
- for {set x 0} {$x < $old_cols} {incr x} {
- for {set y 0} {$y < $old_rows} {incr y} {
- set _chars($x,$y) $local_chars($x,$y)
- }
+ for {set x 0} {$x < $old_cols} {incr x} {
+ for {set y 0} {$y < $old_rows} {incr y} {
+ set _chars($x,$y) $local_chars($x,$y)
}
}
+}
- proc resize {rows cols {wait_for_msg 1}} {
- variable _rows
- variable _cols
- variable _resize_count
+proc Term::resize {rows cols {wait_for_msg 1}} {
+ variable _rows
+ variable _cols
+ variable _resize_count
- # expect handles each argument to stty separately. This means
- # that gdb will see SIGWINCH twice. Rather than rely on this
- # behavior (which, after all, could be changed), we make it
- # explicit here. This also simplifies waiting for the redraw.
- _do_resize $rows $_cols
- stty rows $_rows < $::gdb_tty_name
- if { $wait_for_msg } {
- wait_for "@@ resize done $_resize_count, size = ${_cols}x${rows}"
- }
- incr _resize_count
- _do_resize $_rows $cols
- stty columns $_cols < $::gdb_tty_name
- if { $wait_for_msg } {
- wait_for "@@ resize done $_resize_count, size = ${_cols}x${rows}"
- }
- incr _resize_count
- }
+ # expect handles each argument to stty separately. This means
+ # that gdb will see SIGWINCH twice. Rather than rely on this
+ # behavior (which, after all, could be changed), we make it
+ # explicit here. This also simplifies waiting for the redraw.
+ _do_resize $rows $_cols
+ stty rows $_rows < $::gdb_tty_name
+ if { $wait_for_msg } {
+ wait_for "@@ resize done $_resize_count, size = ${_cols}x${rows}"
+ }
+ incr _resize_count
+ _do_resize $_rows $cols
+ stty columns $_cols < $::gdb_tty_name
+ if { $wait_for_msg } {
+ wait_for "@@ resize done $_resize_count, size = ${_cols}x${rows}"
+ }
+ incr _resize_count
}
diff --git a/gdb/thread.c b/gdb/thread.c
index 920d8dc..b6c19f9 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -33,7 +33,6 @@
#include "regcache.h"
#include "btrace.h"
-#include <ctype.h>
#include <sys/types.h>
#include <signal.h>
#include "ui-out.h"
@@ -1808,7 +1807,7 @@ thread_apply_command_completer (cmd_list_element *ignore,
/* Check if we're past a valid thread ID list already. */
if (parser.finished ()
- && cmd > text && !isspace (cmd[-1]))
+ && cmd > text && !c_isspace (cmd[-1]))
return;
/* We're past the thread ID list, advance word point. */
@@ -1871,7 +1870,7 @@ thread_apply_command (const char *tidlist, int from_tty)
if (*cmd == '\0')
error (_("Please specify a command following the thread ID list"));
- if (tidlist == cmd || isdigit (cmd[0]))
+ if (tidlist == cmd || c_isdigit (cmd[0]))
invalid_thread_id_error (cmd);
scoped_restore_current_thread restore_thread;
diff --git a/gdb/tic6x-tdep.c b/gdb/tic6x-tdep.c
index 2ab8dac..56d3098 100644
--- a/gdb/tic6x-tdep.c
+++ b/gdb/tic6x-tdep.c
@@ -1267,7 +1267,7 @@ tic6x_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
dwarf2_frame_set_init_reg (gdbarch, tic6x_dwarf2_frame_init_reg);
/* Single stepping. */
- set_gdbarch_software_single_step (gdbarch, tic6x_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, tic6x_software_single_step);
/* Call dummy code. */
set_gdbarch_frame_align (gdbarch, tic6x_frame_align);
diff --git a/gdb/tid-parse.c b/gdb/tid-parse.c
index 4e45798..9f79fba 100644
--- a/gdb/tid-parse.c
+++ b/gdb/tid-parse.c
@@ -20,7 +20,6 @@
#include "tid-parse.h"
#include "inferior.h"
#include "gdbthread.h"
-#include <ctype.h>
/* See tid-parse.h. */
@@ -184,7 +183,7 @@ tid_range_parser::finished () const
or we are not in a range and not in front of an integer, negative
integer, convenience var or negative convenience var. */
return (*m_cur_tok == '\0'
- || !(isdigit (*m_cur_tok)
+ || !(c_isdigit (*m_cur_tok)
|| *m_cur_tok == '$'
|| *m_cur_tok == '*'));
case STATE_THREAD_RANGE:
@@ -261,7 +260,7 @@ tid_range_parser::get_tid_or_range (int *inf_num,
m_qualified = true;
p = dot + 1;
- if (isspace (*p))
+ if (c_isspace (*p))
return false;
}
else
@@ -272,7 +271,7 @@ tid_range_parser::get_tid_or_range (int *inf_num,
}
m_range_parser.init (p);
- if (p[0] == '*' && (p[1] == '\0' || isspace (p[1])))
+ if (p[0] == '*' && (p[1] == '\0' || c_isspace (p[1])))
{
/* Setup the number range parser to return numbers in the
whole [1,INT_MAX] range. */
diff --git a/gdb/top.c b/gdb/top.c
index b097683..f5b9fdc 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -69,7 +69,6 @@
#include "event-top.h"
#include <sys/stat.h>
-#include <ctype.h>
#include "ui-out.h"
#include "cli-out.h"
#include "tracepoint.h"
@@ -1312,7 +1311,7 @@ print_gdb_version (struct ui_file *stream, bool interactive)
/* Second line is a copyright notice. */
gdb_printf (stream,
- "Copyright (C) 2024 Free Software Foundation, Inc.\n");
+ "Copyright (C) 2025 Free Software Foundation, Inc.\n");
/* Following the copyright is a brief statement that the program is
free software, that users are free to copy and change it on
@@ -1596,6 +1595,11 @@ This GDB was configured as follows:\n\
--with-system-gdbinit-dir=%s%s\n\
"), SYSTEM_GDBINIT_DIR, SYSTEM_GDBINIT_DIR_RELOCATABLE ? " (relocatable)" : "");
+#ifdef SUPPORTED_BINARY_FILE_FORMATS
+ gdb_printf (stream, _("\
+ --enable-binary-file-formats=%s\n"), SUPPORTED_BINARY_FILE_FORMATS);
+#endif
+
/* We assume "relocatable" will be printed at least once, thus we always
print this text. It's a reasonably safe assumption for now. */
gdb_printf (stream, _("\n\
diff --git a/gdb/tracectf.c b/gdb/tracectf.c
index 0f80d08..c2231ff 100644
--- a/gdb/tracectf.c
+++ b/gdb/tracectf.c
@@ -28,7 +28,6 @@
#include "inferior.h"
#include "gdbthread.h"
#include "tracefile.h"
-#include <ctype.h>
#include <algorithm>
#include "gdbsupport/filestuff.h"
#include "gdbarch.h"
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index c0f1eae..879e4a6 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -208,16 +208,16 @@ set_tracepoint_num (int num)
static void
set_traceframe_context (const frame_info_ptr &trace_frame)
{
- CORE_ADDR trace_pc;
+ std::optional<CORE_ADDR> trace_pc;
struct symbol *traceframe_fun;
symtab_and_line traceframe_sal;
/* Save as globals for internal use. */
if (trace_frame != NULL
- && get_frame_pc_if_available (trace_frame, &trace_pc))
+ && (trace_pc = get_frame_pc_if_available (trace_frame)))
{
- traceframe_sal = find_pc_line (trace_pc, 0);
- traceframe_fun = find_pc_function (trace_pc);
+ traceframe_sal = find_pc_line (*trace_pc, 0);
+ traceframe_fun = find_pc_function (*trace_pc);
/* Save linenumber as "$trace_line", a debugger variable visible to
users. */
@@ -308,12 +308,12 @@ validate_trace_state_variable_name (const char *name)
/* All digits in the name is reserved for value history
references. */
- for (p = name; isdigit (*p); p++)
+ for (p = name; c_isdigit (*p); p++)
;
if (*p == '\0')
error (_("$%s is not a valid trace state variable name"), name);
- for (p = name; isalnum (*p) || *p == '_'; p++)
+ for (p = name; c_isalnum (*p) || *p == '_'; p++)
;
if (*p != '\0')
error (_("$%s is not a valid trace state variable name"), name);
@@ -339,7 +339,7 @@ trace_variable_command (const char *args, int from_tty)
error (_("Name of trace variable should start with '$'"));
name_start = p;
- while (isalnum (*p) || *p == '_')
+ while (c_isalnum (*p) || *p == '_')
p++;
std::string name (name_start, p - name_start);
@@ -689,14 +689,14 @@ validate_actionline (const char *line, tracepoint *t)
(exp->op.get ()));
sym = vvop->get_symbol ();
- if (sym->aclass () == LOC_CONST)
+ if (sym->loc_class () == LOC_CONST)
{
error (_("constant `%s' (value %s) "
"will not be collected."),
sym->print_name (),
plongest (sym->value_longest ()));
}
- else if (sym->aclass () == LOC_OPTIMIZED_OUT)
+ else if (sym->loc_class () == LOC_OPTIMIZED_OUT)
{
error (_("`%s' is optimized away "
"and cannot be collected."),
@@ -916,11 +916,11 @@ collection_list::collect_symbol (struct symbol *sym,
int treat_as_expr = 0;
len = check_typedef (sym->type ())->length ();
- switch (sym->aclass ())
+ switch (sym->loc_class ())
{
default:
gdb_printf ("%s: don't know symbol class %d\n",
- sym->print_name (), sym->aclass ());
+ sym->print_name (), sym->loc_class ());
break;
case LOC_CONST:
gdb_printf ("constant %s (value %s) will not be collected.\n",
@@ -2508,12 +2508,12 @@ info_scope_command (const char *args_in, int from_tty)
gdb_stdout);
else
{
- switch (sym->aclass ())
+ switch (sym->loc_class ())
{
default:
case LOC_UNDEF: /* Messed up symbol? */
gdb_printf ("a bogus symbol, class %d.\n",
- sym->aclass ());
+ sym->loc_class ());
count--; /* Don't count this one. */
continue;
case LOC_CONST:
diff --git a/gdb/tui/tui-disasm.c b/gdb/tui/tui-disasm.c
index 627f71c..07453b4 100644
--- a/gdb/tui/tui-disasm.c
+++ b/gdb/tui/tui-disasm.c
@@ -100,6 +100,9 @@ tui_disassemble (struct gdbarch *gdbarch,
{
bool term_out = disassembler_styling && gdb_stdout->can_emit_style_escape ();
string_file gdb_dis_out (term_out);
+ struct ui_file *stream = (addr_size == nullptr
+ ? (decltype (stream))&null_stream
+ : (decltype (stream))&gdb_dis_out);
/* Must start with an empty list. */
asm_lines.clear ();
@@ -108,11 +111,13 @@ tui_disassemble (struct gdbarch *gdbarch,
for (int i = 0; i < count; ++i)
{
tui_asm_line tal;
- CORE_ADDR orig_pc = pc;
+
+ /* Save the instruction address. */
+ tal.addr = pc;
try
{
- pc = pc + gdb_print_insn (gdbarch, pc, &gdb_dis_out, NULL);
+ pc += gdb_print_insn (gdbarch, pc, stream, NULL);
}
catch (const gdb_exception_error &except)
{
@@ -124,25 +129,24 @@ tui_disassemble (struct gdbarch *gdbarch,
return pc;
}
+ /* If that's all we need, continue. */
+ if (addr_size == nullptr)
+ {
+ asm_lines.push_back (std::move (tal));
+ continue;
+ }
+
/* Capture the disassembled instruction. */
tal.insn = gdb_dis_out.release ();
/* And capture the address the instruction is at. */
- tal.addr = orig_pc;
- print_address (gdbarch, orig_pc, &gdb_dis_out);
+ print_address (gdbarch, tal.addr, &gdb_dis_out);
tal.addr_string = gdb_dis_out.release ();
+ tal.addr_size = (term_out
+ ? len_without_escapes (tal.addr_string)
+ : tal.addr_string.size ());
- if (addr_size != nullptr)
- {
- size_t new_size;
-
- if (term_out)
- new_size = len_without_escapes (tal.addr_string);
- else
- new_size = tal.addr_string.size ();
- *addr_size = std::max (*addr_size, new_size);
- tal.addr_size = new_size;
- }
+ *addr_size = std::max (*addr_size, tal.addr_size);
asm_lines.push_back (std::move (tal));
}
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index c97e8fd..84cad93 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -319,7 +319,9 @@ tui_apply_style (WINDOW *w, ui_file_style style)
wattron (w, A_NORMAL);
wattroff (w, A_BOLD);
wattroff (w, A_DIM);
+#ifdef A_ITALIC
wattroff (w, A_ITALIC);
+#endif
wattroff (w, A_UNDERLINE);
wattroff (w, A_REVERSE);
if (last_color_pair != -1)
@@ -368,8 +370,10 @@ tui_apply_style (WINDOW *w, ui_file_style style)
gdb_assert_not_reached ("invalid intensity");
}
+#ifdef A_ITALIC
if (style.is_italic ())
wattron (w, A_ITALIC);
+#endif
if (style.is_underline ())
wattron (w, A_UNDERLINE);
diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c
index 558055d..95d20fb 100644
--- a/gdb/tui/tui-layout.c
+++ b/gdb/tui/tui-layout.c
@@ -37,7 +37,6 @@
#include "tui/tui-layout.h"
#include "tui/tui-source.h"
#include "gdb_curses.h"
-#include "gdbsupport/gdb-safe-ctype.h"
/* The layouts. */
static std::vector<std::unique_ptr<tui_layout_split>> layouts;
@@ -381,14 +380,14 @@ tui_register_window (const char *name, window_factory &&factory)
for (const char &c : name_copy)
{
- if (ISSPACE (c))
+ if (c_isspace (c))
error (_("invalid whitespace character in window name"));
- if (!ISALNUM (c) && strchr ("-_.", c) == nullptr)
+ if (!c_isalnum (c) && strchr ("-_.", c) == nullptr)
error (_("invalid character '%c' in window name"), c);
}
- if (!ISALPHA (name_copy[0]))
+ if (!c_isalpha (name_copy[0]))
error (_("window name must start with a letter, not '%c'"), name_copy[0]);
/* We already check above for all the builtin window names. If we get
diff --git a/gdb/tui/tui-status.c b/gdb/tui/tui-status.c
index c2d3873..1e09975 100644
--- a/gdb/tui/tui-status.c
+++ b/gdb/tui/tui-status.c
@@ -271,10 +271,14 @@ tui_show_frame_info (const frame_info_ptr &fi)
symtab_and_line sal = find_frame_sal (fi);
const char *func_name;
+ std::optional<CORE_ADDR> tmp_pc = get_frame_pc_if_available (fi);
/* find_frame_sal does not always set PC, but we want to ensure
that it is available in the SAL. */
- if (get_frame_pc_if_available (fi, &sal.pc))
- func_name = tui_get_function_from_frame (fi);
+ if (tmp_pc.has_value ())
+ {
+ sal.pc = *tmp_pc;
+ func_name = tui_get_function_from_frame (fi);
+ }
else
func_name = _("<unavailable>");
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index d4fbbf1..b411d07 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -45,7 +45,6 @@
#include "tui/tui-win.h"
#include "gdb_curses.h"
-#include <ctype.h>
#include "readline/readline.h"
#include <signal.h>
#include <string_view>
@@ -1041,7 +1040,7 @@ parse_scrolling_args (const char *arg,
/* Process the number of lines to scroll. */
std::string copy = arg;
buf_ptr = &copy[0];
- if (isdigit (*buf_ptr))
+ if (c_isdigit (*buf_ptr))
{
char *num_str;
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index a545c48..2fe4914 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -26,7 +26,6 @@
#include "value.h"
#include "source.h"
#include "objfiles.h"
-#include "gdbsupport/gdb-safe-ctype.h"
#include "tui/tui.h"
#include "tui/tui-data.h"
@@ -109,7 +108,7 @@ tui_copy_source_line (const char **ptr, int *length)
}
else if (c == '\t')
process_tab ();
- else if (ISCNTRL (c))
+ else if (c_iscntrl (c))
{
result.push_back ('^');
result.push_back (c + 0100);
@@ -461,7 +460,9 @@ tui_source_window_base::rerender ()
/* find_frame_sal does not always set SAL.PC, but we want to ensure
that it is available in the SAL before updating the window. */
- get_frame_pc_if_available (frame, &sal.pc);
+ std::optional<CORE_ADDR> tmp_pc = get_frame_pc_if_available (frame);
+ if (tmp_pc.has_value ())
+ sal.pc = *tmp_pc;
maybe_update (get_frame_arch (frame), sal);
update_exec_info (false);
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index 5883d6c..01aee2f 100644
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -125,6 +125,19 @@ tui_rl_switch_mode (int notused1, int notused2)
}
else
{
+ /* If we type "foo", entering it into the readline buffer
+
+ (gdb) foo
+ ^
+ and then switch to TUI and back, we may get back
+
+ (gdb) foo
+ ^
+ which is confusing because "foo" is no longer part of the
+ readline buffer. Fix this by clearing it before switching to
+ TUI. */
+ rl_clear_visible_line ();
+
/* If tui_enable throws, we'll re-prep below. */
rl_deprep_terminal ();
tui_enable ();
diff --git a/gdb/type-stack.c b/gdb/type-stack.c
index fc12e5e..b9266b8 100644
--- a/gdb/type-stack.c
+++ b/gdb/type-stack.c
@@ -20,7 +20,6 @@
#include "type-stack.h"
#include "gdbtypes.h"
-#include "parser-defs.h"
/* See type-stack.h. */
@@ -51,7 +50,7 @@ type_stack::insert (enum type_pieces tp)
/* See type-stack.h. */
void
-type_stack::insert (struct expr_builder *pstate, const char *string)
+type_stack::insert (struct gdbarch *gdbarch, const char *string)
{
union type_stack_elt element;
int slot;
@@ -67,8 +66,7 @@ type_stack::insert (struct expr_builder *pstate, const char *string)
element.piece = tp_space_identifier;
insert_into (slot, element);
element.int_val
- = address_space_name_to_type_instance_flags (pstate->gdbarch (),
- string);
+ = address_space_name_to_type_instance_flags (gdbarch, string);
insert_into (slot, element);
}
diff --git a/gdb/type-stack.h b/gdb/type-stack.h
index af5a89d..eeb2f35 100644
--- a/gdb/type-stack.h
+++ b/gdb/type-stack.h
@@ -26,34 +26,49 @@
struct type;
struct expr_builder;
-/* For parsing of complicated types.
- An array should be preceded in the list by the size of the array. */
+/* The kind of element on the stack of types and qualifiers, used for
+ parsing complicated types. */
enum type_pieces
- {
- tp_end = -1,
- tp_pointer,
- tp_reference,
- tp_rvalue_reference,
- tp_array,
- tp_function,
- tp_function_with_arguments,
- tp_const,
- tp_volatile,
- tp_space_identifier,
- tp_atomic,
- tp_restrict,
- tp_type_stack,
- tp_kind
- };
-
-/* The stack can contain either an enum type_pieces or an int. */
+{
+ /* This is returned by pop() to indicate that the stack is empty.
+ Note that it may not be pushed by the user. */
+ tp_end = -1,
+ tp_pointer,
+ tp_reference,
+ tp_rvalue_reference,
+ /* An array type, where the dimension is pushed on the stack as
+ well. */
+ tp_array,
+ tp_function,
+ /* A function with argument types; the types are also pushed on the
+ stack. */
+ tp_function_with_arguments,
+ tp_const,
+ tp_volatile,
+ /* An address space identifier. The address space is also pushed on
+ the stack. */
+ tp_space_identifier,
+ tp_atomic,
+ tp_restrict,
+ /* A separate type stack, which is also pushed onto this type
+ stack. */
+ tp_type_stack,
+ /* Fortran-specific, specifies the kind. */
+ tp_kind,
+};
+
+/* Items on the type stack. */
union type_stack_elt
- {
- enum type_pieces piece;
- int int_val;
- struct type_stack *stack_val;
- std::vector<struct type *> *typelist_val;
- };
+{
+ /* An ordinary type qualifier. */
+ enum type_pieces piece;
+ /* An integer value. Currently only used for address spaces. */
+ int int_val;
+ /* Another type stack. */
+ struct type_stack *stack_val;
+ /* A list of types. */
+ std::vector<struct type *> *typelist_val;
+};
/* The type stack is an instance of this structure. */
@@ -80,18 +95,31 @@ public:
void insert (enum type_pieces tp);
+ /* Push an ordinary element on the type stack. This can be used for
+ any element that doesn't require any extra data. */
void push (enum type_pieces tp)
{
+ /* tp_end can only be returned by this class, not pushed. The
+ others require a payload on the stack and so can only be pushed
+ by the appropriate method. */
+ gdb_assert (tp != tp_end);
+ gdb_assert (!requires_payload (tp));
type_stack_elt elt;
elt.piece = tp;
m_elements.push_back (elt);
}
- void push (int n)
+ /* Push an element and an integer value onto the stack. The integer
+ value is pushed first, followed by TP. Only piece kinds that
+ accept an integer argument are allowed. */
+ void push (enum type_pieces tp, int n)
{
+ gdb_assert (tp == tp_array || tp == tp_space_identifier || tp == tp_kind);
type_stack_elt elt;
elt.int_val = n;
m_elements.push_back (elt);
+ elt.piece = tp;
+ m_elements.push_back (elt);
}
/* Push the type stack STACK as an element on this type stack. */
@@ -101,11 +129,12 @@ public:
type_stack_elt elt;
elt.stack_val = stack;
m_elements.push_back (elt);
- push (tp_type_stack);
+ elt.piece = tp_type_stack;
+ m_elements.push_back (elt);
}
- /* Push a function type with arguments onto the global type stack.
- LIST holds the argument types. If the final item in LIST is NULL,
+ /* Push a function type with arguments onto this type stack. LIST
+ holds the argument types. If the final item in LIST is NULL,
then the function will be varargs. */
void push (std::vector<struct type *> *list)
@@ -113,35 +142,51 @@ public:
type_stack_elt elt;
elt.typelist_val = list;
m_elements.push_back (elt);
- push (tp_function_with_arguments);
+ elt.piece = tp_function_with_arguments;
+ m_elements.push_back (elt);
}
+ /* Pop the topmost element of the stack and return it.
+
+ If the stack is empty, tp_end is returned.
+
+ If the topmost element requires a payload -- for example,
+ tp_array takes an integer parameter -- then the value is returned
+ but *not* popped from the stack. Instead the appropriate
+ payload-specific pop_* method (e.g., pop_int) must then be
+ called. This somewhat odd approach ensures that the stack can't
+ be put into an invalid state. */
enum type_pieces pop ()
{
if (m_elements.empty ())
return tp_end;
type_stack_elt elt = m_elements.back ();
- m_elements.pop_back ();
+ if (!requires_payload (elt.piece))
+ m_elements.pop_back ();
return elt.piece;
}
int pop_int ()
{
- if (m_elements.empty ())
- {
- /* "Can't happen". */
- return 0;
- }
+ gdb_assert (m_elements.size () >= 2);
type_stack_elt elt = m_elements.back ();
m_elements.pop_back ();
+ type_pieces tp = elt.piece;
+ gdb_assert (tp == tp_array || tp == tp_space_identifier || tp == tp_kind);
+ elt = m_elements.back ();
+ m_elements.pop_back ();
return elt.int_val;
}
std::vector<struct type *> *pop_typelist ()
{
- gdb_assert (!m_elements.empty ());
+ gdb_assert (m_elements.size () >= 2);
type_stack_elt elt = m_elements.back ();
m_elements.pop_back ();
+ type_pieces tp = elt.piece;
+ gdb_assert (tp == tp_function_with_arguments);
+ elt = m_elements.back ();
+ m_elements.pop_back ();
return elt.typelist_val;
}
@@ -149,9 +194,13 @@ public:
struct type_stack *pop_type_stack ()
{
- gdb_assert (!m_elements.empty ());
+ gdb_assert (m_elements.size () >= 2);
type_stack_elt elt = m_elements.back ();
m_elements.pop_back ();
+ type_pieces tp = elt.piece;
+ gdb_assert (tp == tp_type_stack);
+ elt = m_elements.back ();
+ m_elements.pop_back ();
return elt.stack_val;
}
@@ -163,7 +212,7 @@ public:
stack is a tp_pointer, and the new values are inserted above the
first item. */
- void insert (struct expr_builder *pstate, const char *string);
+ void insert (struct gdbarch *gdbarch, const char *string);
/* Append the elements of the type stack FROM to the type stack
THIS. Always returns THIS. */
@@ -188,9 +237,9 @@ public:
private:
- /* A helper function for insert_type and insert_type_address_space.
- This does work of expanding the type stack and inserting the new
- element, ELEMENT, into the stack at location SLOT. */
+ /* A helper function for the insert methods. This does work of
+ expanding the type stack and inserting the new element, ELEMENT,
+ into the stack at location SLOT. */
void insert_into (int slot, union type_stack_elt element)
{
@@ -198,6 +247,14 @@ private:
m_elements.insert (m_elements.begin () + slot, element);
}
+ /* Return true if TP requires some payload element. */
+ bool requires_payload (type_pieces tp) const
+ {
+ return (tp == tp_array || tp == tp_kind || tp == tp_type_stack
+ || tp == tp_function_with_arguments
+ || tp == tp_space_identifier);
+ }
+
/* Elements on the stack. */
std::vector<union type_stack_elt> m_elements;
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index ef0c5aa..42fbf38 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -31,7 +31,6 @@
#include "cp-abi.h"
#include "typeprint.h"
#include "valprint.h"
-#include <ctype.h>
#include "cli/cli-utils.h"
#include "extension.h"
#include "completer.h"
@@ -219,7 +218,7 @@ typedef_hash_table::add_template_parameters (struct type *t)
struct decl_field *tf;
/* We only want type-valued template parameters in the hash. */
- if (TYPE_TEMPLATE_ARGUMENT (t, i)->aclass () != LOC_TYPEDEF)
+ if (TYPE_TEMPLATE_ARGUMENT (t, i)->loc_class () != LOC_TYPEDEF)
continue;
tf = XOBNEW (&m_storage, struct decl_field);
@@ -367,7 +366,7 @@ whatis_exp (const char *exp, int show)
{
int seen_one = 0;
- for (++exp; *exp && !isspace (*exp); ++exp)
+ for (++exp; *exp && !c_isspace (*exp); ++exp)
{
switch (*exp)
{
@@ -413,7 +412,7 @@ whatis_exp (const char *exp, int show)
if (!*exp && !seen_one)
error (_("flag expected"));
- if (!isspace (*exp))
+ if (!c_isspace (*exp))
error (_("expected space after format"));
exp = skip_spaces (exp);
}
diff --git a/gdb/ui-out.c b/gdb/ui-out.c
index 106a896..7683927 100644
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -586,7 +586,7 @@ ui_out::vmessage (const ui_file_style &in_style, const char *format,
for (auto &&piece : fpieces)
{
- const char *current_substring = piece.string;
+ const char *current_substring = fpieces.piece_str (piece);
gdb_assert (piece.n_int_args >= 0 && piece.n_int_args <= 2);
int intvals[2] = { 0, 0 };
diff --git a/gdb/ui-style.c b/gdb/ui-style.c
index 9a58e4d..d450c3e 100644
--- a/gdb/ui-style.c
+++ b/gdb/ui-style.c
@@ -594,7 +594,11 @@ colorsupport ()
{
std::vector<color_space> result = {color_space::MONOCHROME};
- int colors = tgetnum ("Co");
+ /* ncurses versions prior to 6.1 (and other curses
+ implementations) declare the tgetnum argument to be
+ 'char *', so we need the const_cast, since C++ will not
+ implicitly convert. */
+ int colors = tgetnum (const_cast<char*> ("Co"));
if (colors >= 8)
result.push_back (color_space::ANSI_8COLOR);
if (colors >= 16)
diff --git a/gdb/unittests/command-def-selftests.c b/gdb/unittests/command-def-selftests.c
index 0a54d31..095b57f 100644
--- a/gdb/unittests/command-def-selftests.c
+++ b/gdb/unittests/command-def-selftests.c
@@ -72,7 +72,7 @@ check_doc (struct cmd_list_element *commandlist, const char *prefix)
"first line is not terminated with a '.' character");
/* Checks the doc is not terminated with a new line. */
- if (isspace (c->doc[strlen (c->doc) - 1]))
+ if (c_isspace (c->doc[strlen (c->doc) - 1]))
broken_doc_invariant
(prefix, c->name,
"has superfluous trailing whitespace");
@@ -87,7 +87,7 @@ check_doc (struct cmd_list_element *commandlist, const char *prefix)
else
{
/* \n\n is ok, so we check that explicitly here. */
- if (isspace (nl[-1]) && nl[-1] != '\n')
+ if (c_isspace (nl[-1]) && nl[-1] != '\n')
broken_doc_invariant (prefix, c->name,
"has whitespace before a newline");
}
diff --git a/gdb/unittests/filtered_iterator-selftests.c b/gdb/unittests/filtered_iterator-selftests.c
index 49c95cb..c04cae4 100644
--- a/gdb/unittests/filtered_iterator-selftests.c
+++ b/gdb/unittests/filtered_iterator-selftests.c
@@ -125,6 +125,26 @@ test_filtered_iterator ()
SELF_CHECK (even_ints == expected_even_ints);
}
+/* Same as the above, but using pointers as the iterator base type. */
+
+static void
+test_filtered_iterator_ptr ()
+{
+ int array[] = { 4, 4, 5, 6, 7, 8, 9 };
+ std::vector<int> even_ints;
+ const std::vector<int> expected_even_ints { 4, 4, 6, 8 };
+
+ filtered_iterator<int *, even_numbers_only> iter
+ (array, array + ARRAY_SIZE (array));
+ filtered_iterator<int *, even_numbers_only> end
+ (array + ARRAY_SIZE (array), array + ARRAY_SIZE (array));
+
+ for (; iter != end; ++iter)
+ even_ints.push_back (*iter);
+
+ SELF_CHECK (even_ints == expected_even_ints);
+}
+
/* Test operator== and operator!=. */
static void
@@ -152,6 +172,34 @@ test_filtered_iterator_eq ()
SELF_CHECK (!(iter1 != iter2));
}
+
+/* Same as the above, but using pointers as the iterator base type. */
+
+static void
+test_filtered_iterator_eq_ptr ()
+{
+ int array[] = { 4, 4, 5, 6, 7, 8, 9 };
+
+ filtered_iterator<int *, even_numbers_only> iter1
+ (array, array + ARRAY_SIZE(array));
+ filtered_iterator<int *, even_numbers_only> iter2
+ (array, array + ARRAY_SIZE(array));
+
+ /* They start equal. */
+ SELF_CHECK (iter1 == iter2);
+ SELF_CHECK (!(iter1 != iter2));
+
+ /* Advance 1, now they aren't equal (despite pointing to equal values). */
+ ++iter1;
+ SELF_CHECK (!(iter1 == iter2));
+ SELF_CHECK (iter1 != iter2);
+
+ /* Advance 2, now they are equal again. */
+ ++iter2;
+ SELF_CHECK (iter1 == iter2);
+ SELF_CHECK (!(iter1 != iter2));
+}
+
} /* namespace selftests */
INIT_GDB_FILE (filtered_iterator_selftests)
@@ -160,4 +208,8 @@ INIT_GDB_FILE (filtered_iterator_selftests)
selftests::test_filtered_iterator);
selftests::register_test ("filtered_iterator_eq",
selftests::test_filtered_iterator_eq);
+ selftests::register_test ("filtered_iterator_ptr",
+ selftests::test_filtered_iterator_ptr);
+ selftests::register_test ("filtered_iterator_eq_ptr",
+ selftests::test_filtered_iterator_eq_ptr);
}
diff --git a/gdb/unittests/format_pieces-selftests.c b/gdb/unittests/format_pieces-selftests.c
index c7d8ff0..2deff0f 100644
--- a/gdb/unittests/format_pieces-selftests.c
+++ b/gdb/unittests/format_pieces-selftests.c
@@ -29,17 +29,35 @@
namespace selftests {
namespace format_pieces {
+/* Like format_piece, but with the expected string hardcoded instead of an
+ index. */
+
+struct expected_format_piece
+{
+ std::string_view str;
+ enum argclass argclass;
+ int n_int_args;
+};
+
/* Verify that parsing STR gives pieces equal to EXPECTED_PIECES. */
static void
-check (const char *str, const std::vector<format_piece> &expected_pieces,
+check (const char *str,
+ const std::vector<expected_format_piece> &expected_pieces,
bool gdb_format = false)
{
::format_pieces pieces (&str, gdb_format);
SELF_CHECK ((pieces.end () - pieces.begin ()) == expected_pieces.size ());
- SELF_CHECK (std::equal (pieces.begin (), pieces.end (),
- expected_pieces.begin ()));
+
+ for (auto it = pieces.begin (); it != pieces.end (); ++it)
+ {
+ auto &expected = expected_pieces[it - pieces.begin ()];
+
+ SELF_CHECK (expected.str == pieces.piece_str (*it));
+ SELF_CHECK (expected.argclass == it->argclass);
+ SELF_CHECK (expected.n_int_args == it->n_int_args);
+ }
}
static void
@@ -47,7 +65,7 @@ test_escape_sequences ()
{
check ("This is an escape sequence: \\e",
{
- format_piece ("This is an escape sequence: \e", literal_piece, 0),
+ {"This is an escape sequence: \e", literal_piece, 0},
});
}
@@ -58,11 +76,11 @@ test_format_specifier ()
see a trailing empty literal piece. */
check ("Hello\\t %d%llx%%d%d", /* ARI: %ll */
{
- format_piece ("Hello\t ", literal_piece, 0),
- format_piece ("%d", int_arg, 0),
- format_piece ("%" LL "x", long_long_arg, 0),
- format_piece ("%%d", literal_piece, 0),
- format_piece ("%d", int_arg, 0),
+ {"Hello\t ", literal_piece, 0},
+ {"%d", int_arg, 0},
+ {"%" LL "x", long_long_arg, 0},
+ {"%%d", literal_piece, 0},
+ {"%d", int_arg, 0},
});
}
@@ -71,13 +89,13 @@ test_gdb_formats ()
{
check ("Hello\\t \"%p[%pF%ps%*.*d%p]\"",
{
- format_piece ("Hello\\t \"", literal_piece, 0),
- format_piece ("%p[", ptr_arg, 0),
- format_piece ("%pF", ptr_arg, 0),
- format_piece ("%ps", ptr_arg, 0),
- format_piece ("%*.*d", int_arg, 2),
- format_piece ("%p]", ptr_arg, 0),
- format_piece ("\"", literal_piece, 0),
+ {"Hello\\t \"", literal_piece, 0},
+ {"%p[", ptr_arg, 0},
+ {"%pF", ptr_arg, 0},
+ {"%ps", ptr_arg, 0},
+ {"%*.*d", int_arg, 2},
+ {"%p]", ptr_arg, 0},
+ {"\"", literal_piece, 0},
}, true);
}
@@ -89,38 +107,38 @@ test_format_int_sizes ()
{
check ("Hello\\t %hu%lu%llu%zu", /* ARI: %ll */
{
- format_piece ("Hello\t ", literal_piece, 0),
- format_piece ("%hu", int_arg, 0),
- format_piece ("%lu", long_arg, 0),
- format_piece ("%" LL "u", long_long_arg, 0),
- format_piece ("%zu", size_t_arg, 0)
+ {"Hello\t ", literal_piece, 0},
+ {"%hu", int_arg, 0},
+ {"%lu", long_arg, 0},
+ {"%" LL "u", long_long_arg, 0},
+ {"%zu", size_t_arg, 0},
});
check ("Hello\\t %hx%lx%llx%zx", /* ARI: %ll */
{
- format_piece ("Hello\t ", literal_piece, 0),
- format_piece ("%hx", int_arg, 0),
- format_piece ("%lx", long_arg, 0),
- format_piece ("%" LL "x", long_long_arg, 0),
- format_piece ("%zx", size_t_arg, 0)
+ {"Hello\t ", literal_piece, 0},
+ {"%hx", int_arg, 0},
+ {"%lx", long_arg, 0},
+ {"%" LL "x", long_long_arg, 0},
+ {"%zx", size_t_arg, 0},
});
check ("Hello\\t %ho%lo%llo%zo", /* ARI: %ll */
{
- format_piece ("Hello\t ", literal_piece, 0),
- format_piece ("%ho", int_arg, 0),
- format_piece ("%lo", long_arg, 0),
- format_piece ("%" LL "o", long_long_arg, 0),
- format_piece ("%zo", size_t_arg, 0)
+ {"Hello\t ", literal_piece, 0},
+ {"%ho", int_arg, 0},
+ {"%lo", long_arg, 0},
+ {"%" LL "o", long_long_arg, 0},
+ {"%zo", size_t_arg, 0},
});
check ("Hello\\t %hd%ld%lld%zd", /* ARI: %ll */
{
- format_piece ("Hello\t ", literal_piece, 0),
- format_piece ("%hd", int_arg, 0),
- format_piece ("%ld", long_arg, 0),
- format_piece ("%" LL "d", long_long_arg, 0),
- format_piece ("%zd", size_t_arg, 0)
+ {"Hello\t ", literal_piece, 0},
+ {"%hd", int_arg, 0},
+ {"%ld", long_arg, 0},
+ {"%" LL "d", long_long_arg, 0},
+ {"%zd", size_t_arg, 0},
});
}
@@ -129,8 +147,8 @@ test_windows_formats ()
{
check ("rc%I64d",
{
- format_piece ("rc", literal_piece, 0),
- format_piece ("%I64d", long_long_arg, 0),
+ {"rc", literal_piece, 0},
+ {"%I64d", long_long_arg, 0},
});
}
diff --git a/gdb/utils.c b/gdb/utils.c
index 10d3d51..57c739e 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -17,7 +17,6 @@
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 <ctype.h>
#include "gdbsupport/gdb_wait.h"
#include "gdbsupport/scoped_signal_handler.h"
#include "event-top.h"
@@ -75,7 +74,6 @@
#include "gdbsupport/scope-exit.h"
#include "gdbarch.h"
#include "cli-out.h"
-#include "gdbsupport/gdb-safe-ctype.h"
#include "bt-utils.h"
#include "gdbsupport/buildargv.h"
#include "pager.h"
@@ -1008,7 +1006,7 @@ parse_escape (struct gdbarch *gdbarch, const char **string_ptr)
while (++count < 3)
{
c = (**string_ptr);
- if (ISDIGIT (c) && c != '8' && c != '9')
+ if (c_isdigit (c) && c != '8' && c != '9')
{
(*string_ptr)++;
i *= 8;
@@ -1702,10 +1700,25 @@ pager_file::puts (const char *linebuffer)
else if (*linebuffer == '\033'
&& skip_ansi_escape (linebuffer, &skip_bytes))
{
- m_wrap_buffer.append (linebuffer, skip_bytes);
- /* Note that we don't consider this a character, so we
+ /* We don't consider escape sequences as characters, so we
don't increment chars_printed here. */
- linebuffer += skip_bytes;
+
+ size_t style_len;
+ ui_file_style style;
+ if (style.parse (linebuffer, &style_len)
+ && style_len <= skip_bytes)
+ {
+ this->emit_style_escape (style);
+
+ linebuffer += style_len;
+ skip_bytes -= style_len;
+ }
+
+ if (skip_bytes > 0)
+ {
+ m_wrap_buffer.append (linebuffer, skip_bytes);
+ linebuffer += skip_bytes;
+ }
}
else if (*linebuffer == '\r')
{
@@ -2053,7 +2066,7 @@ fprintf_symbol (struct ui_file *stream, const char *name,
static bool
valid_identifier_name_char (int ch)
{
- return (ISALNUM (ch) || ch == '_');
+ return (c_isalnum (ch) || ch == '_');
}
/* Skip to end of token, or to END, whatever comes first. Input is
@@ -2063,7 +2076,7 @@ static const char *
cp_skip_operator_token (const char *token, const char *end)
{
const char *p = token;
- while (p != end && !ISSPACE (*p) && *p != '(')
+ while (p != end && !c_isspace (*p) && *p != '(')
{
if (valid_identifier_name_char (*p))
{
@@ -2117,9 +2130,9 @@ cp_skip_operator_token (const char *token, const char *end)
static void
skip_ws (const char *&string1, const char *&string2, const char *end_str2)
{
- while (ISSPACE (*string1))
+ while (c_isspace (*string1))
string1++;
- while (string2 < end_str2 && ISSPACE (*string2))
+ while (string2 < end_str2 && c_isspace (*string2))
string2++;
}
@@ -2183,7 +2196,7 @@ skip_template_parameter_list (const char **name)
/* Skip any whitespace that might occur after the closing of the
parameter list, but only if it is the end of parameter list. */
const char *q = p;
- while (ISSPACE (*q))
+ while (c_isspace (*q))
++q;
if (*q == '>')
p = q;
@@ -2215,8 +2228,8 @@ strncmp_iw_with_mode (const char *string1, const char *string2,
while (1)
{
if (skip_spaces
- || ((ISSPACE (*string1) && !valid_identifier_name_char (*string2))
- || (ISSPACE (*string2) && !valid_identifier_name_char (*string1))))
+ || ((c_isspace (*string1) && !valid_identifier_name_char (*string2))
+ || (c_isspace (*string2) && !valid_identifier_name_char (*string1))))
{
skip_ws (string1, string2, end_str2);
skip_spaces = false;
@@ -2249,7 +2262,7 @@ strncmp_iw_with_mode (const char *string1, const char *string2,
if (match_for_lcd != NULL && abi_start != string1)
match_for_lcd->mark_ignored_range (abi_start, string1);
- while (ISSPACE (*string1))
+ while (c_isspace (*string1))
string1++;
}
@@ -2316,9 +2329,9 @@ strncmp_iw_with_mode (const char *string1, const char *string2,
string1++;
string2++;
- while (ISSPACE (*string1))
+ while (c_isspace (*string1))
string1++;
- while (string2 < end_str2 && ISSPACE (*string2))
+ while (string2 < end_str2 && c_isspace (*string2))
string2++;
continue;
}
@@ -2418,14 +2431,13 @@ strncmp_iw_with_mode (const char *string1, const char *string2,
if (case_sensitivity == case_sensitive_on && *string1 != *string2)
break;
if (case_sensitivity == case_sensitive_off
- && (TOLOWER ((unsigned char) *string1)
- != TOLOWER ((unsigned char) *string2)))
+ && c_tolower (*string1) != c_tolower (*string2))
break;
/* If we see any non-whitespace, non-identifier-name character
(any of "()<>*&" etc.), then skip spaces the next time
around. */
- if (!ISSPACE (*string1) && !valid_identifier_name_char (*string1))
+ if (!c_isspace (*string1) && !valid_identifier_name_char (*string1))
skip_spaces = true;
string1++;
@@ -3138,16 +3150,16 @@ strcmp_iw_ordered (const char *string1, const char *string2)
while (*string1 != '\0' && *string2 != '\0')
{
- while (ISSPACE (*string1))
+ while (c_isspace (*string1))
string1++;
- while (ISSPACE (*string2))
+ while (c_isspace (*string2))
string2++;
switch (case_pass)
{
case case_sensitive_off:
- c1 = TOLOWER ((unsigned char) *string1);
- c2 = TOLOWER ((unsigned char) *string2);
+ c1 = c_tolower (*string1);
+ c2 = c_tolower (*string2);
break;
case case_sensitive_on:
c1 = *string1;
@@ -3256,17 +3268,17 @@ string_to_core_addr (const char *my_string)
{
CORE_ADDR addr = 0;
- if (my_string[0] == '0' && TOLOWER (my_string[1]) == 'x')
+ if (my_string[0] == '0' && c_tolower (my_string[1]) == 'x')
{
/* Assume that it is in hex. */
int i;
for (i = 2; my_string[i] != '\0'; i++)
{
- if (ISDIGIT (my_string[i]))
+ if (c_isdigit (my_string[i]))
addr = (my_string[i] - '0') + (addr * 16);
- else if (ISXDIGIT (my_string[i]))
- addr = (TOLOWER (my_string[i]) - 'a' + 0xa) + (addr * 16);
+ else if (c_isxdigit (my_string[i]))
+ addr = (c_tolower (my_string[i]) - 'a' + 0xa) + (addr * 16);
else
error (_("invalid hex \"%s\""), my_string);
}
@@ -3278,7 +3290,7 @@ string_to_core_addr (const char *my_string)
for (i = 0; my_string[i] != '\0'; i++)
{
- if (ISDIGIT (my_string[i]))
+ if (c_isdigit (my_string[i]))
addr = (my_string[i] - '0') + (addr * 10);
else
error (_("invalid decimal \"%s\""), my_string);
diff --git a/gdb/valops.c b/gdb/valops.c
index 88f3e32..fa87546 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -45,9 +45,6 @@
/* Local functions. */
-static int typecmp (bool staticp, bool varargs, int nargs,
- struct field t1[], const gdb::array_view<value *> t2);
-
static struct value *search_struct_field (const char *, struct value *,
struct type *, int);
@@ -1766,7 +1763,7 @@ value_string (const gdb_byte *ptr, ssize_t count, struct type *char_type)
/* See if we can pass arguments in T2 to a function which takes arguments
- of types T1. T1 is a list of NARGS arguments, and T2 is an array_view
+ of types T1. T1 is an array_view of arguments, and T2 is an array_view
of the values we're trying to pass. If some arguments need coercion of
some sort, then the coerced values are written into T2. Return value is
0 if the arguments could be matched, or the position at which they
@@ -1783,8 +1780,8 @@ value_string (const gdb_byte *ptr, ssize_t count, struct type *char_type)
requested operation is type secure, shouldn't we? FIXME. */
static int
-typecmp (bool staticp, bool varargs, int nargs,
- struct field t1[], gdb::array_view<value *> t2)
+typecmp (bool staticp, bool varargs,
+ gdb::array_view<struct field> t1, gdb::array_view<value *> t2)
{
int i;
@@ -1794,7 +1791,7 @@ typecmp (bool staticp, bool varargs, int nargs,
t2 = t2.slice (1);
for (i = 0;
- (i < nargs) && t1[i].type ()->code () != TYPE_CODE_VOID;
+ (i < t1.size ()) && t1[i].type ()->code () != TYPE_CODE_VOID;
i++)
{
struct type *tt1, *tt2;
@@ -2227,7 +2224,6 @@ search_struct_method (const char *name, struct value **arg1p,
gdb_assert (args.has_value ());
if (!typecmp (TYPE_FN_FIELD_STATIC_P (f, j),
TYPE_FN_FIELD_TYPE (f, j)->has_varargs (),
- TYPE_FN_FIELD_TYPE (f, j)->num_fields (),
TYPE_FN_FIELD_ARGS (f, j), *args))
{
if (TYPE_FN_FIELD_VIRTUAL_P (f, j))
@@ -3826,7 +3822,7 @@ value_maybe_namespace_elt (const struct type *curtype,
if (sym.symbol == NULL)
return NULL;
else if ((noside == EVAL_AVOID_SIDE_EFFECTS)
- && (sym.symbol->aclass () == LOC_TYPEDEF))
+ && (sym.symbol->loc_class () == LOC_TYPEDEF))
result = value::allocate (sym.symbol->type ());
else
result = value_of_variable (sym.symbol, sym.block);
@@ -4024,7 +4020,7 @@ value_of_this_silent (const struct language_defn *lang)
bound as the original ARRAY. */
struct value *
-value_slice (struct value *array, int lowbound, int length)
+value_slice (struct value *array, LONGEST lowbound, LONGEST length)
{
struct type *slice_range_type, *slice_type, *range_type;
LONGEST lowerbound, upperbound;
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 305faf7..b8c1c06 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -34,7 +34,6 @@
#include "gdbsupport/gdb_obstack.h"
#include "charset.h"
#include "typeprint.h"
-#include <ctype.h>
#include <algorithm>
#include "gdbsupport/byte-vector.h"
#include "cli/cli-option.h"
diff --git a/gdb/value.c b/gdb/value.c
index 82d9a86..c78bb98 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -35,7 +35,6 @@
#include "valprint.h"
#include "cli/cli-decode.h"
#include "extension.h"
-#include <ctype.h>
#include "tracepoint.h"
#include "cp-abi.h"
#include "user-regs.h"
@@ -3723,11 +3722,11 @@ value_from_history_ref (const char *h, const char **endp)
len = 2;
/* Find length of numeral string. */
- for (; isdigit (h[len]); len++)
+ for (; c_isdigit (h[len]); len++)
;
/* Make sure numeral string is not part of an identifier. */
- if (h[len] == '_' || isalpha (h[len]))
+ if (h[len] == '_' || c_isalpha (h[len]))
return NULL;
/* Now collect the index value. */
diff --git a/gdb/value.h b/gdb/value.h
index 0c7c785..b9d2809 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -1156,9 +1156,12 @@ extern struct value *address_of_variable (struct symbol *var,
extern value *value_of_register (int regnum, const frame_info_ptr &next_frame);
-/* Same as the above, but the value is not fetched. */
+/* Same as the above, but the value is not fetched. If TYPE is
+ non-nullptr, use it as the value type. Otherwise, 'register_type'
+ will be used to obtain the type. */
-extern value *value_of_register_lazy (const frame_info_ptr &next_frame, int regnum);
+extern value *value_of_register_lazy (const frame_info_ptr &next_frame,
+ int regnum, struct type *type = nullptr);
/* Return the symbol's reading requirement. */
@@ -1586,7 +1589,7 @@ extern struct value *make_cv_value (int, int, struct value *);
extern struct value *varying_to_slice (struct value *);
-extern struct value *value_slice (struct value *, int, int);
+extern struct value *value_slice (struct value *, LONGEST, LONGEST);
/* Create a complex number. The type is the complex type; the values
are cast to the underlying scalar type before the complex number is
diff --git a/gdb/version.in b/gdb/version.in
index 75e06a8..85ad8ec 100644
--- a/gdb/version.in
+++ b/gdb/version.in
@@ -1 +1 @@
-17.0.50.DATE-git \ No newline at end of file
+18.0.50.DATE-git \ No newline at end of file
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index c001d38..f74ea0c 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -2426,7 +2426,7 @@ redir_set_redirection (const char *s, int *inp, int *out, int *err)
/* cmd.exe recognizes "&N" only immediately after the redirection symbol. */
if (*s != '&')
{
- while (isspace (*s)) /* skip whitespace before file name */
+ while (c_isspace (*s)) /* skip whitespace before file name */
s++;
*d++ = ' '; /* separate file name with a single space */
}
@@ -2453,7 +2453,7 @@ redir_set_redirection (const char *s, int *inp, int *out, int *err)
s++;
*d++ = *s++;
}
- else if (isspace (*s) && !quote)
+ else if (c_isspace (*s) && !quote)
break;
else
*d++ = *s++;
@@ -2489,7 +2489,7 @@ redirect_inferior_handles (const char *cmd_orig, char *cmd,
int quote = 0;
bool retval = false;
- while (isspace (*s))
+ while (c_isspace (*s))
*d++ = *s++;
while (*s)
diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c
index 05335d2..c6f5803 100644
--- a/gdb/windows-tdep.c
+++ b/gdb/windows-tdep.c
@@ -550,43 +550,6 @@ windows_xfer_shared_library (const char* so_name, CORE_ADDR load_addr,
xml += "\"/></library>";
}
-/* Implement the "iterate_over_objfiles_in_search_order" gdbarch
- method. It searches all objfiles, starting with CURRENT_OBJFILE
- first (if not NULL).
-
- On Windows, the system behaves a little differently when two
- objfiles each define a global symbol using the same name, compared
- to other platforms such as GNU/Linux for instance. On GNU/Linux,
- all instances of the symbol effectively get merged into a single
- one, but on Windows, they remain distinct.
-
- As a result, it usually makes sense to start global symbol searches
- with the current objfile before expanding it to all other objfiles.
- This helps for instance when a user debugs some code in a DLL that
- refers to a global variable defined inside that DLL. When trying
- to print the value of that global variable, it would be unhelpful
- to print the value of another global variable defined with the same
- name, but in a different DLL. */
-
-static void
-windows_iterate_over_objfiles_in_search_order
- (gdbarch *gdbarch, iterate_over_objfiles_in_search_order_cb_ftype cb,
- objfile *current_objfile)
-{
- if (current_objfile)
- {
- if (cb (current_objfile))
- return;
- }
-
- for (objfile *objfile : current_program_space->objfiles ())
- if (objfile != current_objfile)
- {
- if (cb (objfile))
- return;
- }
-}
-
static void
show_maint_show_all_tib (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
@@ -866,15 +829,20 @@ windows_get_siginfo_type (struct gdbarch *gdbarch)
struct windows_solib_ops : target_solib_ops
{
+ using target_solib_ops::target_solib_ops;
+
void create_inferior_hook (int from_tty) const override;
+ void iterate_over_objfiles_in_search_order
+ (iterate_over_objfiles_in_search_order_cb_ftype cb,
+ objfile *current_objfile) const override;
};
/* Return a new solib_ops for Windows systems. */
static solib_ops_up
-make_windows_solib_ops ()
+make_windows_solib_ops (program_space *pspace)
{
- return std::make_unique<windows_solib_ops> ();
+ return std::make_unique<windows_solib_ops> (pspace);
}
/* Implement the "solib_create_inferior_hook" solib_ops method. */
@@ -925,6 +893,43 @@ windows_solib_ops::create_inferior_hook (int from_tty) const
}
}
+/* Implement the "iterate_over_objfiles_in_search_order" gdbarch
+ method. It searches all objfiles, starting with CURRENT_OBJFILE
+ first (if not NULL).
+
+ On Windows, the system behaves a little differently when two
+ objfiles each define a global symbol using the same name, compared
+ to other platforms such as GNU/Linux for instance. On GNU/Linux,
+ all instances of the symbol effectively get merged into a single
+ one, but on Windows, they remain distinct.
+
+ As a result, it usually makes sense to start global symbol searches
+ with the current objfile before expanding it to all other objfiles.
+ This helps for instance when a user debugs some code in a DLL that
+ refers to a global variable defined inside that DLL. When trying
+ to print the value of that global variable, it would be unhelpful
+ to print the value of another global variable defined with the same
+ name, but in a different DLL. */
+
+void
+windows_solib_ops::iterate_over_objfiles_in_search_order
+ (iterate_over_objfiles_in_search_order_cb_ftype cb,
+ objfile *current_objfile) const
+{
+ if (current_objfile)
+ {
+ if (cb (current_objfile))
+ return;
+ }
+
+ for (objfile *objfile : m_pspace->objfiles ())
+ if (objfile != current_objfile)
+ {
+ if (cb (objfile))
+ return;
+ }
+}
+
/* Common parts for gdbarch initialization for the Windows and Cygwin OS
ABIs. */
@@ -938,9 +943,6 @@ windows_init_abi_common (struct gdbarch_info info, struct gdbarch *gdbarch)
`c:\Program Files\Foo App\mydll.dll', for example. */
set_gdbarch_has_dos_based_file_system (gdbarch, 1);
- set_gdbarch_iterate_over_objfiles_in_search_order
- (gdbarch, windows_iterate_over_objfiles_in_search_order);
-
set_gdbarch_make_solib_ops (gdbarch, make_windows_solib_ops);
set_gdbarch_get_siginfo_type (gdbarch, windows_get_siginfo_type);
@@ -1160,13 +1162,11 @@ core_process_module_section (bfd *abfd, asection *sect, void *obj)
ULONGEST
windows_core_xfer_shared_libraries (struct gdbarch *gdbarch,
- gdb_byte *readbuf,
+ struct bfd &cbfd, gdb_byte *readbuf,
ULONGEST offset, ULONGEST len)
{
cpms_data data { gdbarch, "<library-list>\n", 0 };
- bfd_map_over_sections (current_program_space->core_bfd (),
- core_process_module_section,
- &data);
+ bfd_map_over_sections (&cbfd, core_process_module_section, &data);
data.xml += "</library-list>\n";
ULONGEST len_avail = data.xml.length ();
diff --git a/gdb/windows-tdep.h b/gdb/windows-tdep.h
index 87a618e..4d8e6bc 100644
--- a/gdb/windows-tdep.h
+++ b/gdb/windows-tdep.h
@@ -33,6 +33,7 @@ extern void windows_xfer_shared_library (const char* so_name,
std::string &xml);
extern ULONGEST windows_core_xfer_shared_libraries (struct gdbarch *gdbarch,
+ struct bfd &cbfd,
gdb_byte *readbuf,
ULONGEST offset,
ULONGEST len);
diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c
index 81db5d8..660a906 100644
--- a/gdb/x86-linux-nat.c
+++ b/gdb/x86-linux-nat.c
@@ -41,6 +41,7 @@
#include "nat/x86-linux.h"
#include "nat/x86-linux-dregs.h"
#include "nat/linux-ptrace.h"
+#include "x86-tdep.h"
#include "nat/x86-linux-tdesc.h"
/* linux_nat_target::low_new_fork implementation. */
@@ -97,15 +98,19 @@ const struct target_desc *
x86_linux_nat_target::read_description ()
{
/* The x86_linux_tdesc_for_tid call only reads xcr0 the first time it is
- called, the xcr0 value is stored here and reused on subsequent calls. */
- static uint64_t xcr0_storage;
+ called. Also it checks the enablement state of features which are
+ not configured in xcr0, such as CET shadow stack. Once the supported
+ features are identified, the XSTATE_BV_STORAGE value is configured
+ accordingly and preserved for subsequent calls of this function. */
+ static uint64_t xstate_bv_storage;
if (inferior_ptid == null_ptid)
return this->beneath ()->read_description ();
int tid = inferior_ptid.pid ();
- return x86_linux_tdesc_for_tid (tid, &xcr0_storage, &this->m_xsave_layout);
+ return x86_linux_tdesc_for_tid (tid, &xstate_bv_storage,
+ &this->m_xsave_layout);
}
@@ -210,6 +215,45 @@ x86_linux_get_thread_area (pid_t pid, void *addr, unsigned int *base_addr)
}
+/* See x86-linux-nat.h. */
+
+void
+x86_linux_fetch_ssp (regcache *regcache, const int tid)
+{
+ uint64_t ssp = 0x0;
+ iovec iov {&ssp, sizeof (ssp)};
+
+ /* The shadow stack may be enabled and disabled at runtime. Reading the
+ ssp might fail as shadow stack was not activated for the current
+ thread. We don't want to show a warning but silently return. The
+ register will be shown as unavailable for the user. */
+ if (ptrace (PTRACE_GETREGSET, tid, NT_X86_SHSTK, &iov) != 0)
+ return;
+
+ x86_supply_ssp (regcache, ssp);
+}
+
+/* See x86-linux-nat.h. */
+
+void
+x86_linux_store_ssp (const regcache *regcache, const int tid)
+{
+ uint64_t ssp = 0x0;
+ iovec iov {&ssp, sizeof (ssp)};
+ x86_collect_ssp (regcache, ssp);
+
+ /* Dependent on the target the ssp register can be unavailable or
+ nullptr when shadow stack is supported by HW and the Linux kernel but
+ not enabled for the current thread. In case of nullptr, GDB tries to
+ restore the shadow stack pointer after an inferior call. The ptrace
+ call with PTRACE_SETREGSET will fail here with errno ENODEV. We
+ don't want to throw an error in this case but silently continue. */
+ errno = 0;
+ if ((ptrace (PTRACE_SETREGSET, tid, NT_X86_SHSTK, &iov) != 0)
+ && (errno != ENODEV))
+ perror_with_name (_("Failed to write pl3_ssp register"));
+}
+
INIT_GDB_FILE (x86_linux_nat)
{
/* Initialize the debug register function vectors. */
diff --git a/gdb/x86-linux-nat.h b/gdb/x86-linux-nat.h
index a62cc4d..c455653 100644
--- a/gdb/x86-linux-nat.h
+++ b/gdb/x86-linux-nat.h
@@ -92,4 +92,15 @@ private:
extern ps_err_e x86_linux_get_thread_area (pid_t pid, void *addr,
unsigned int *base_addr);
+/* Fetch the value of the shadow stack pointer register from process/thread
+ TID and store it to GDB's register cache. */
+
+extern void x86_linux_fetch_ssp (regcache *regcache, const int tid);
+
+/* Read the value of the shadow stack pointer from GDB's register cache
+ and store it in the shadow stack pointer register of process/thread TID.
+ Throw an error in case of failure. */
+
+extern void x86_linux_store_ssp (const regcache *regcache, const int tid);
+
#endif /* GDB_X86_LINUX_NAT_H */
diff --git a/gdb/x86-tdep.c b/gdb/x86-tdep.c
index 6646b11..ea5226f 100644
--- a/gdb/x86-tdep.c
+++ b/gdb/x86-tdep.c
@@ -17,10 +17,31 @@
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 "i386-tdep.h"
#include "x86-tdep.h"
#include "symtab.h"
+/* See x86-tdep.h. */
+
+void
+x86_supply_ssp (regcache *regcache, const uint64_t ssp)
+{
+ i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (regcache->arch ());
+ gdb_assert (tdep != nullptr && tdep->ssp_regnum != -1);
+ regcache->raw_supply (tdep->ssp_regnum, &ssp);
+}
+
+/* See x86-tdep.h. */
+
+void
+x86_collect_ssp (const regcache *regcache, uint64_t &ssp)
+{
+ i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (regcache->arch ());
+ gdb_assert (tdep != nullptr && tdep->ssp_regnum != -1);
+ regcache->raw_collect (tdep->ssp_regnum, &ssp);
+}
+
/* Check whether NAME is included in NAMES[LO] (inclusive) to NAMES[HI]
(exclusive). */
diff --git a/gdb/x86-tdep.h b/gdb/x86-tdep.h
index 35e3905..855d04b 100644
--- a/gdb/x86-tdep.h
+++ b/gdb/x86-tdep.h
@@ -20,6 +20,15 @@
#ifndef GDB_X86_TDEP_H
#define GDB_X86_TDEP_H
+/* Fill SSP to the shadow stack pointer in GDB's REGCACHE. */
+
+extern void x86_supply_ssp (regcache *regcache, const uint64_t ssp);
+
+/* Collect the value of the shadow stack pointer in GDB's REGCACHE and
+ write it to SSP. */
+
+extern void x86_collect_ssp (const regcache *regcache, uint64_t &ssp);
+
/* Checks whether PC lies in an indirect branch thunk using registers
REGISTER_NAMES[LO] (inclusive) to REGISTER_NAMES[HI] (exclusive). */
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 70585b3..d8b99a0 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -23,7 +23,6 @@
#include <sys/types.h>
#include <fcntl.h>
-#include <ctype.h>
#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
@@ -1491,7 +1490,7 @@ process_xcoff_symbol (struct xcoff_symbol *cs, struct objfile *objfile)
sym->set_type (builtin_type (objfile)->nodebug_text_symbol);
sym->set_domain (FUNCTION_DOMAIN);
- sym->set_aclass_index (LOC_BLOCK);
+ sym->set_loc_class_index (LOC_BLOCK);
sym2 = new (&objfile->objfile_obstack) symbol (*sym);
if (cs->c_sclass == C_EXT || C_WEAKEXT)
diff --git a/gdb/xml-support.c b/gdb/xml-support.c
index 08524f8..ebf6ea6 100644
--- a/gdb/xml-support.c
+++ b/gdb/xml-support.c
@@ -21,7 +21,6 @@
#include "xml-builtin.h"
#include "xml-support.h"
#include "gdbsupport/filestuff.h"
-#include "gdbsupport/gdb-safe-ctype.h"
#include <vector>
#include <string>
@@ -430,10 +429,10 @@ gdb_xml_parser::end_element (const XML_Char *name)
body = scope->body.c_str ();
/* Strip leading and trailing whitespace. */
- while (length > 0 && ISSPACE (body[length - 1]))
+ while (length > 0 && c_isspace (body[length - 1]))
length--;
scope->body.erase (length);
- while (*body && ISSPACE (*body))
+ while (*body && c_isspace (*body))
body++;
}
diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c
index b4042f1..b63dfa0 100644
--- a/gdb/xstormy16-tdep.c
+++ b/gdb/xstormy16-tdep.c
@@ -546,14 +546,14 @@ xstormy16_find_jmp_table_entry (struct gdbarch *gdbarch, CORE_ADDR faddr)
if (!strcmp (faddr_sect->the_bfd_section->name, ".plt"))
return faddr;
- for (obj_section *osect : faddr_sect->objfile->sections ())
+ for (obj_section &osect : faddr_sect->objfile->sections ())
{
- if (!strcmp (osect->the_bfd_section->name, ".plt"))
+ if (!strcmp (osect.the_bfd_section->name, ".plt"))
{
CORE_ADDR addr, endaddr;
- addr = osect->addr ();
- endaddr = osect->endaddr ();
+ addr = osect.addr ();
+ endaddr = osect.endaddr ();
for (; addr < endaddr; addr += 2 * xstormy16_inst_size)
{
diff --git a/gdb/z80-tdep.c b/gdb/z80-tdep.c
index abba50b..c8f0038 100644
--- a/gdb/z80-tdep.c
+++ b/gdb/z80-tdep.c
@@ -962,11 +962,11 @@ z80_overlay_update_1 (struct obj_section *osect)
/* we have interest for sections with same VMA */
for (objfile *objfile : current_program_space->objfiles ())
- for (obj_section *sect : objfile->sections ())
- if (section_is_overlay (sect))
+ for (obj_section &sect : objfile->sections ())
+ if (section_is_overlay (&sect))
{
- sect->ovly_mapped = (lma == bfd_section_lma (sect->the_bfd_section));
- i |= sect->ovly_mapped; /* true, if at least one section is mapped */
+ sect.ovly_mapped = (lma == bfd_section_lma (sect.the_bfd_section));
+ i |= sect.ovly_mapped; /* true, if at least one section is mapped */
}
return i;
}
@@ -985,18 +985,18 @@ z80_overlay_update (struct obj_section *osect)
/* Update all sections, even if only one was requested. */
for (objfile *objfile : current_program_space->objfiles ())
- for (obj_section *sect : objfile->sections ())
+ for (obj_section &sect : objfile->sections ())
{
- if (!section_is_overlay (sect))
+ if (!section_is_overlay (&sect))
continue;
- asection *bsect = sect->the_bfd_section;
+ asection *bsect = sect.the_bfd_section;
bfd_vma lma = bfd_section_lma (bsect);
bfd_vma vma = bfd_section_vma (bsect);
for (int i = 0; i < cache_novly_regions; ++i)
if (cache_ovly_region_table[i][Z80_VMA] == vma)
- sect->ovly_mapped =
+ sect.ovly_mapped =
(cache_ovly_region_table[i][Z80_MAPPED_TO_LMA] == lma);
}
}
@@ -1173,7 +1173,7 @@ z80_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_skip_prologue (gdbarch, z80_skip_prologue);
set_gdbarch_inner_than (gdbarch, core_addr_lessthan); // falling stack
- set_gdbarch_software_single_step (gdbarch, z80_software_single_step);
+ set_gdbarch_get_next_pcs (gdbarch, z80_software_single_step);
set_gdbarch_breakpoint_kind_from_pc (gdbarch, z80_breakpoint_kind_from_pc);
set_gdbarch_sw_breakpoint_from_kind (gdbarch, z80_sw_breakpoint_from_kind);
set_gdbarch_insn_is_call (gdbarch, z80_insn_is_call);