aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
Diffstat (limited to 'gdb')
-rw-r--r--gdb/MAINTAINERS12
-rw-r--r--gdb/Makefile.in2
-rw-r--r--gdb/NEWS30
-rw-r--r--gdb/ada-exp.y2
-rw-r--r--gdb/ada-lang.c30
-rw-r--r--gdb/ada-lex.l2
-rw-r--r--gdb/ada-tasks.c2
-rw-r--r--gdb/addrmap.c18
-rw-r--r--gdb/addrmap.h9
-rw-r--r--gdb/alpha-tdep.h2
-rw-r--r--gdb/amd-dbgapi-target.c4
-rw-r--r--gdb/amd64-linux-nat.c2
-rw-r--r--gdb/amd64-linux-tdep.c5
-rw-r--r--gdb/amd64-tdep.c22
-rw-r--r--gdb/amd64-tdep.h2
-rw-r--r--gdb/amd64-windows-tdep.c2
-rw-r--r--gdb/arc-linux-tdep.c2
-rw-r--r--gdb/arc-tdep.c4
-rw-r--r--gdb/arch/amd64.c11
-rw-r--r--gdb/arch/i386.c7
-rw-r--r--gdb/arch/tic6x.c3
-rw-r--r--gdb/arch/x86-linux-tdesc-features.c7
-rw-r--r--gdb/arm-tdep.c8
-rw-r--r--gdb/auxv.c2
-rw-r--r--gdb/breakpoint.c174
-rw-r--r--gdb/btrace.c328
-rw-r--r--gdb/btrace.h10
-rw-r--r--gdb/c-exp.y6
-rw-r--r--gdb/cli-out.c5
-rw-r--r--gdb/cli-out.h3
-rw-r--r--gdb/cli/cli-cmds.c49
-rw-r--r--gdb/cli/cli-interp.c2
-rw-r--r--gdb/cli/cli-style.c12
-rw-r--r--gdb/cli/cli-style.h3
-rw-r--r--gdb/coffread.c97
-rw-r--r--gdb/completer.c32
-rw-r--r--gdb/config.in3
-rwxr-xr-xgdb/configure10
-rw-r--r--gdb/configure.ac7
-rwxr-xr-xgdb/contrib/ari/gdb_ari.sh2
-rw-r--r--gdb/contrib/common-misspellings.txt18
-rwxr-xr-xgdb/contrib/spellcheck.sh353
-rw-r--r--gdb/corelow.c55
-rw-r--r--gdb/cris-tdep.c6
-rw-r--r--gdb/data-directory/Makefile.in3
-rw-r--r--gdb/dbxread.c2896
-rw-r--r--gdb/dictionary.h2
-rw-r--r--gdb/disasm.c5
-rw-r--r--gdb/doc/gdb.texinfo193
-rw-r--r--gdb/dtrace-probe.c2
-rw-r--r--gdb/dwarf2/abbrev.c3
-rw-r--r--gdb/dwarf2/cooked-index.h4
-rw-r--r--gdb/dwarf2/frame.c4
-rw-r--r--gdb/dwarf2/loc.c2
-rw-r--r--gdb/dwarf2/parent-map.h6
-rw-r--r--gdb/dwarf2/read-gdb-index.c20
-rw-r--r--gdb/dwarf2/read.c319
-rw-r--r--gdb/dwarf2/read.h31
-rw-r--r--gdb/elfread.c135
-rw-r--r--gdb/eval.c13
-rw-r--r--gdb/exec.h2
-rw-r--r--gdb/expop.h20
-rw-r--r--gdb/expression.h10
-rw-r--r--gdb/extension.c2
-rw-r--r--gdb/fbsd-tdep.c1
-rw-r--r--gdb/features/Makefile2
-rw-r--r--gdb/features/btrace-conf.dtd1
-rw-r--r--gdb/features/i386/32bit-mpx.c51
-rw-r--r--gdb/features/i386/32bit-mpx.xml45
-rw-r--r--gdb/features/i386/64bit-mpx.c51
-rw-r--r--gdb/features/i386/64bit-mpx.xml44
-rw-r--r--gdb/features/mips-dsp-linux.c2
-rw-r--r--gdb/features/mips-linux.c2
-rw-r--r--gdb/features/or1k-linux.c2
-rw-r--r--gdb/features/sparc/sparc32-solaris.c2
-rw-r--r--gdb/features/sparc/sparc64-solaris.c2
-rw-r--r--gdb/frame-unwind.c12
-rw-r--r--gdb/gdb-stabs.h98
-rw-r--r--gdb/gdbtypes.c8
-rw-r--r--gdb/i386-fbsd-nat.c2
-rw-r--r--gdb/i386-linux-nat.c2
-rw-r--r--gdb/i386-linux-tdep.c67
-rw-r--r--gdb/i386-linux-tdep.h9
-rw-r--r--gdb/i386-tdep.c511
-rw-r--r--gdb/i386-tdep.h24
-rw-r--r--gdb/i387-tdep.c219
-rw-r--r--gdb/i387-tdep.h12
-rw-r--r--gdb/ia64-tdep.h2
-rw-r--r--gdb/inf-ptrace.c2
-rw-r--r--gdb/infcmd.c4
-rw-r--r--gdb/linespec.c8
-rw-r--r--gdb/linux-tdep.c124
-rw-r--r--gdb/m2-exp.y10
-rw-r--r--gdb/m2-typeprint.c1
-rw-r--r--gdb/m68k-linux-nat.c2
-rw-r--r--gdb/mdebugread.c24
-rw-r--r--gdb/memattr.c2
-rw-r--r--gdb/mi/mi-cmd-disas.c3
-rw-r--r--gdb/mi/mi-out.c13
-rw-r--r--gdb/mi/mi-out.h3
-rw-r--r--gdb/mi/mi-symbol-cmds.c2
-rw-r--r--gdb/microblaze-tdep.c2
-rw-r--r--gdb/mips-tdep.c32
-rw-r--r--gdb/nat/linux-btrace.c11
-rw-r--r--gdb/nat/x86-linux-tdesc.c6
-rw-r--r--gdb/nat/x86-xstate.c2
-rw-r--r--gdb/objc-lang.c8
-rw-r--r--gdb/objfiles.h4
-rw-r--r--gdb/osabi.c120
-rw-r--r--gdb/osabi.h45
-rw-r--r--gdb/p-exp.y4
-rw-r--r--gdb/ppc-linux-tdep.c2
-rw-r--r--gdb/ppc-netbsd-tdep.c1
-rw-r--r--gdb/procfs.c2
-rw-r--r--gdb/psymtab.c4
-rw-r--r--gdb/psymtab.h4
-rw-r--r--gdb/python/lib/gdb/dap/breakpoint.py6
-rw-r--r--gdb/python/lib/gdb/dap/varref.py1
-rw-r--r--gdb/python/lib/gdb/disassembler.py2
-rw-r--r--gdb/python/lib/gdb/printer/bound_registers.py39
-rw-r--r--gdb/python/py-arch.c8
-rw-r--r--gdb/python/py-block.c11
-rw-r--r--gdb/python/py-breakpoint.c33
-rw-r--r--gdb/python/py-cmd.c8
-rw-r--r--gdb/python/py-connection.c14
-rw-r--r--gdb/python/py-disasm.c38
-rw-r--r--gdb/python/py-event.c18
-rw-r--r--gdb/python/py-event.h2
-rw-r--r--gdb/python/py-evtregistry.c6
-rw-r--r--gdb/python/py-finishbreakpoint.c10
-rw-r--r--gdb/python/py-frame.c47
-rw-r--r--gdb/python/py-framefilter.c2
-rw-r--r--gdb/python/py-function.c6
-rw-r--r--gdb/python/py-gdb-readline.c2
-rw-r--r--gdb/python/py-inferior.c16
-rw-r--r--gdb/python/py-infthread.c14
-rw-r--r--gdb/python/py-instruction.c2
-rw-r--r--gdb/python/py-lazy-string.c10
-rw-r--r--gdb/python/py-linetable.c24
-rw-r--r--gdb/python/py-membuf.c6
-rw-r--r--gdb/python/py-mi.c5
-rw-r--r--gdb/python/py-micmd.c7
-rw-r--r--gdb/python/py-objfile.c14
-rw-r--r--gdb/python/py-param.c7
-rw-r--r--gdb/python/py-prettyprint.c5
-rw-r--r--gdb/python/py-progspace.c9
-rw-r--r--gdb/python/py-record-btrace.c16
-rw-r--r--gdb/python/py-record.c14
-rw-r--r--gdb/python/py-registers.c25
-rw-r--r--gdb/python/py-stopevent.c2
-rw-r--r--gdb/python/py-symbol.c19
-rw-r--r--gdb/python/py-symtab.c11
-rw-r--r--gdb/python/py-tui.c4
-rw-r--r--gdb/python/py-type.c57
-rw-r--r--gdb/python/py-uiout.h3
-rw-r--r--gdb/python/py-unwind.c34
-rw-r--r--gdb/python/py-utils.c31
-rw-r--r--gdb/python/py-value.c73
-rw-r--r--gdb/python/python-internal.h58
-rw-r--r--gdb/python/python.c12
-rw-r--r--gdb/quick-symbol.h13
-rw-r--r--gdb/record-btrace.c44
-rw-r--r--gdb/regcache-dump.c19
-rw-r--r--gdb/remote.c97
-rw-r--r--gdb/remote.h5
-rw-r--r--gdb/rs6000-aix-tdep.c2
-rw-r--r--gdb/rs6000-lynx178-tdep.c2
-rw-r--r--gdb/rs6000-tdep.c4
-rw-r--r--gdb/run-on-main-thread.c15
-rw-r--r--gdb/rust-lang.h2
-rw-r--r--gdb/s390-tdep.c2
-rw-r--r--gdb/ser-base.c4
-rw-r--r--gdb/sh-tdep.c4
-rw-r--r--gdb/solib-svr4.c8
-rw-r--r--gdb/source-cache.c6
-rw-r--r--gdb/source.c35
-rw-r--r--gdb/sparc-tdep.c2
-rw-r--r--gdb/stabsread.c2487
-rw-r--r--gdb/stabsread.h101
-rw-r--r--gdb/stack.c3
-rw-r--r--gdb/stubs/ia64vms-stub.c4
-rw-r--r--gdb/stubs/m32r-stub.c4
-rw-r--r--gdb/symfile-debug.c6
-rw-r--r--gdb/symfile.c6
-rw-r--r--gdb/symfile.h4
-rw-r--r--gdb/symmisc.c32
-rw-r--r--gdb/symtab.c45
-rw-r--r--gdb/symtab.h16
-rw-r--r--gdb/target-debug.h2
-rw-r--r--gdb/target-descriptions.c11
-rw-r--r--gdb/target-descriptions.h1
-rw-r--r--gdb/target.c20
-rw-r--r--gdb/target.h8
-rw-r--r--gdb/testsuite/gdb.ada/array_of_variant.exp2
-rw-r--r--gdb/testsuite/gdb.ada/arrayidx.exp3
-rw-r--r--gdb/testsuite/gdb.ada/arrayptr.exp2
-rw-r--r--gdb/testsuite/gdb.ada/big_packed_array.exp2
-rw-r--r--gdb/testsuite/gdb.ada/call_pn.exp15
-rw-r--r--gdb/testsuite/gdb.ada/complete.exp4
-rw-r--r--gdb/testsuite/gdb.ada/enum_idx_packed.exp5
-rw-r--r--gdb/testsuite/gdb.ada/exec_changed.exp2
-rw-r--r--gdb/testsuite/gdb.ada/fixed_points.exp4
-rw-r--r--gdb/testsuite/gdb.ada/fun_renaming.exp8
-rw-r--r--gdb/testsuite/gdb.ada/mod_from_name.exp5
-rw-r--r--gdb/testsuite/gdb.ada/null_array.exp3
-rw-r--r--gdb/testsuite/gdb.ada/packed_array_assign.exp2
-rw-r--r--gdb/testsuite/gdb.ada/packed_record.exp2
-rw-r--r--gdb/testsuite/gdb.ada/pckd_arr_ren.exp5
-rw-r--r--gdb/testsuite/gdb.ada/tagged-lookup.exp8
-rw-r--r--gdb/testsuite/gdb.ada/task_switch_in_core.exp2
-rw-r--r--gdb/testsuite/gdb.ada/variant_record_packed_array.exp4
-rw-r--r--gdb/testsuite/gdb.arch/e500-prologue.exp2
-rw-r--r--gdb/testsuite/gdb.arch/i386-mpx-call.c105
-rw-r--r--gdb/testsuite/gdb.arch/i386-mpx-call.exp398
-rw-r--r--gdb/testsuite/gdb.arch/i386-mpx-map.c61
-rw-r--r--gdb/testsuite/gdb.arch/i386-mpx-map.exp56
-rw-r--r--gdb/testsuite/gdb.arch/i386-mpx-sigsegv.c92
-rw-r--r--gdb/testsuite/gdb.arch/i386-mpx-sigsegv.exp64
-rw-r--r--gdb/testsuite/gdb.arch/i386-mpx-simple_segv.exp124
-rw-r--r--gdb/testsuite/gdb.arch/i386-mpx.c59
-rw-r--r--gdb/testsuite/gdb.arch/i386-mpx.exp123
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-aix-prologue.exp2
-rw-r--r--gdb/testsuite/gdb.arch/ppc64-break-on-_exit.exp2
-rw-r--r--gdb/testsuite/gdb.arch/riscv-tdesc-loading.exp2
-rw-r--r--gdb/testsuite/gdb.arch/sparc64-adi.c1
-rw-r--r--gdb/testsuite/gdb.base/attach-deleted-exec.exp24
-rw-r--r--gdb/testsuite/gdb.base/bp-cond-failure.c14
-rw-r--r--gdb/testsuite/gdb.base/bp-cond-failure.exp46
-rw-r--r--gdb/testsuite/gdb.base/break-interp.exp22
-rw-r--r--gdb/testsuite/gdb.base/call-sc.exp2
-rw-r--r--gdb/testsuite/gdb.base/checkpoint.exp50
-rw-r--r--gdb/testsuite/gdb.base/completion.exp2
-rw-r--r--gdb/testsuite/gdb.base/empty-host-env-vars.exp32
-rw-r--r--gdb/testsuite/gdb.base/filename-completion.exp387
-rw-r--r--gdb/testsuite/gdb.base/gnu-ifunc.exp2
-rw-r--r--gdb/testsuite/gdb.base/hbreak-unmapped.exp3
-rw-r--r--gdb/testsuite/gdb.base/info_sources_2.exp2
-rw-r--r--gdb/testsuite/gdb.base/killed-outside.exp2
-rw-r--r--gdb/testsuite/gdb.base/lineinc.exp2
-rw-r--r--gdb/testsuite/gdb.base/overlays.exp2
-rw-r--r--gdb/testsuite/gdb.base/reggroups.exp28
-rw-r--r--gdb/testsuite/gdb.base/remote.exp2
-rw-r--r--gdb/testsuite/gdb.base/reset-catchpoint-cond-lib.c1
-rw-r--r--gdb/testsuite/gdb.base/return.exp4
-rw-r--r--gdb/testsuite/gdb.base/scope-hw-watch-disable.exp18
-rw-r--r--gdb/testsuite/gdb.base/sigbpt.exp2
-rw-r--r--gdb/testsuite/gdb.base/signals.exp2
-rw-r--r--gdb/testsuite/gdb.base/sigrepeat.c2
-rw-r--r--gdb/testsuite/gdb.base/store.exp2
-rw-r--r--gdb/testsuite/gdb.base/structs.exp2
-rw-r--r--gdb/testsuite/gdb.base/style-logging.exp3
-rw-r--r--gdb/testsuite/gdb.base/style.exp13
-rw-r--r--gdb/testsuite/gdb.base/testenv.exp2
-rw-r--r--gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.exp2
-rw-r--r--gdb/testsuite/gdb.base/whatis-ptype-typedefs.exp2
-rw-r--r--gdb/testsuite/gdb.base/wrap-line.exp28
-rw-r--r--gdb/testsuite/gdb.btrace/event-tracing-gap.c (renamed from gdb/testsuite/gdb.arch/i386-mpx-simple_segv.c)24
-rw-r--r--gdb/testsuite/gdb.btrace/event-tracing-gap.exp75
-rw-r--r--gdb/testsuite/gdb.btrace/event-tracing.exp52
-rw-r--r--gdb/testsuite/gdb.btrace/null-deref.c26
-rw-r--r--gdb/testsuite/gdb.cp/rtti.exp2
-rw-r--r--gdb/testsuite/gdb.cp/step-and-next-inline.exp2
-rw-r--r--gdb/testsuite/gdb.cp/virtfunc.exp2
-rw-r--r--gdb/testsuite/gdb.dap/memory.exp3
-rw-r--r--gdb/testsuite/gdb.debuginfod/corefile-mapped-file-3.c1
-rw-r--r--gdb/testsuite/gdb.debuginfod/corefile-mapped-file.exp2
-rw-r--r--gdb/testsuite/gdb.dwarf2/backward-spec-inter-cu.exp3
-rw-r--r--gdb/testsuite/gdb.dwarf2/count.exp18
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-inter-cu-error-2.exp51
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp2
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-step-out-of-function-no-stmt.exp2
-rw-r--r--gdb/testsuite/gdb.dwarf2/dwz-unused-pu.exp75
-rw-r--r--gdb/testsuite/gdb.dwarf2/enum-type-c++.cc35
-rw-r--r--gdb/testsuite/gdb.dwarf2/enum-type-c++.exp67
-rw-r--r--gdb/testsuite/gdb.dwarf2/enum-type.exp50
-rw-r--r--gdb/testsuite/gdb.dwarf2/fission-reread.S2
-rw-r--r--gdb/testsuite/gdb.dwarf2/forward-spec-inter-cu.exp3
-rw-r--r--gdb/testsuite/gdb.dwarf2/gdb-index.exp8
-rw-r--r--gdb/testsuite/gdb.dwarf2/implptrconst.exp9
-rw-r--r--gdb/testsuite/gdb.dwarf2/implptrpiece.exp9
-rw-r--r--gdb/testsuite/gdb.dwarf2/multidictionary.exp2
-rw-r--r--gdb/testsuite/gdb.dwarf2/pr13961.S4
-rw-r--r--gdb/testsuite/gdb.dwarf2/pr13961.exp3
-rw-r--r--gdb/testsuite/gdb.dwarf2/self-spec.exp4
-rw-r--r--gdb/testsuite/gdb.fortran/info-types.exp6
-rw-r--r--gdb/testsuite/gdb.fortran/types.exp2
-rw-r--r--gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp10
-rw-r--r--gdb/testsuite/gdb.gdb/python-helper.exp2
-rw-r--r--gdb/testsuite/gdb.go/integers.exp2
-rw-r--r--gdb/testsuite/gdb.linespec/cp-replace-typedefs-ns-template.exp2
-rw-r--r--gdb/testsuite/gdb.linespec/cpcompletion.exp2
-rw-r--r--gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp10
-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.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.cc6
-rw-r--r--gdb/testsuite/gdb.mi/mi-complete.exp3
-rw-r--r--gdb/testsuite/gdb.mi/mi-multi-commands.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.exp4
-rw-r--r--gdb/testsuite/gdb.mi/mi-sym-info.exp3
-rw-r--r--gdb/testsuite/gdb.mi/mi-thread-bp-deleted.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-cp.cc3
-rw-r--r--gdb/testsuite/gdb.mi/mi-vla-c99.exp2
-rw-r--r--gdb/testsuite/gdb.mi/mi-vla-fortran.exp16
-rw-r--r--gdb/testsuite/gdb.modula2/builtin-procedure-adr.exp32
-rw-r--r--gdb/testsuite/gdb.multi/bp-thread-specific.exp24
-rw-r--r--gdb/testsuite/gdb.multi/inferior-specific-bp-1.c2
-rw-r--r--gdb/testsuite/gdb.multi/inferior-specific-bp-2.c5
-rw-r--r--gdb/testsuite/gdb.multi/inferior-specific-bp.exp67
-rw-r--r--gdb/testsuite/gdb.multi/multi-term-settings.c1
-rw-r--r--gdb/testsuite/gdb.multi/multi-term-settings.exp2
-rw-r--r--gdb/testsuite/gdb.opt/break-on-_exit.exp2
-rw-r--r--gdb/testsuite/gdb.pascal/floats.exp2
-rw-r--r--gdb/testsuite/gdb.pascal/integers.exp2
-rw-r--r--gdb/testsuite/gdb.pascal/types.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-arch.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-format-string.exp2
-rw-r--r--gdb/testsuite/gdb.python/py-inferior.exp3
-rw-r--r--gdb/testsuite/gdb.python/py-pp-cast.py2
-rw-r--r--gdb/testsuite/gdb.python/py-pp-maint.exp8
-rw-r--r--gdb/testsuite/gdb.python/py-pp-re-notag.py1
-rw-r--r--gdb/testsuite/gdb.python/py-prettyprint-stub.py2
-rw-r--r--gdb/testsuite/gdb.python/py-read-memory-leak.c27
-rw-r--r--gdb/testsuite/gdb.python/py-read-memory-leak.exp44
-rw-r--r--gdb/testsuite/gdb.python/py-read-memory-leak.py93
-rw-r--r--gdb/testsuite/gdb.python/python.exp9
-rw-r--r--gdb/testsuite/gdb.python/sys-exit.exp69
-rw-r--r--gdb/testsuite/gdb.reverse/func-map-to-same-line.exp4
-rw-r--r--gdb/testsuite/gdb.reverse/step-precsave.exp6
-rw-r--r--gdb/testsuite/gdb.reverse/step-reverse.exp6
-rw-r--r--gdb/testsuite/gdb.server/exit-multiple-threads.c1
-rw-r--r--gdb/testsuite/gdb.server/server-run.exp33
-rw-r--r--gdb/testsuite/gdb.testsuite/parse_options_args.exp2
-rw-r--r--gdb/testsuite/gdb.threads/create-fail.c2
-rw-r--r--gdb/testsuite/gdb.threads/fork-thread-pending.c1
-rw-r--r--gdb/testsuite/gdb.threads/interrupt-while-step-over.exp2
-rw-r--r--gdb/testsuite/gdb.threads/signal-command-handle-nopass.c19
-rw-r--r--gdb/testsuite/gdb.threads/signal-sigtrap.c17
-rw-r--r--gdb/testsuite/gdb.threads/thread-bp-deleted.exp2
-rw-r--r--gdb/testsuite/gdb.threads/thread_check.exp2
-rw-r--r--gdb/testsuite/gdb.threads/tls-sepdebug.exp13
-rw-r--r--gdb/testsuite/gdb.threads/watchpoint-fork-mt.c1
-rw-r--r--gdb/testsuite/gdb.trace/collection.exp4
-rw-r--r--gdb/testsuite/gdb.trace/entry-values.exp2
-rw-r--r--gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp2
-rw-r--r--gdb/testsuite/gdb.tui/info-win.exp2
-rw-r--r--gdb/testsuite/lib/ada.exp12
-rw-r--r--gdb/testsuite/lib/dwarf.exp2
-rw-r--r--gdb/testsuite/lib/gdb-utils.exp24
-rw-r--r--gdb/testsuite/lib/gdb.exp246
-rw-r--r--gdb/testsuite/lib/mi-support.exp2
-rw-r--r--gdb/testsuite/lib/prelink-support.exp2
-rw-r--r--gdb/testsuite/lib/selftest-support.exp2
-rw-r--r--gdb/tilegx-linux-nat.c2
-rw-r--r--gdb/top.c19
-rw-r--r--gdb/tracepoint.c16
-rw-r--r--gdb/tui/tui-source.c16
-rw-r--r--gdb/tui/tui-source.h6
-rw-r--r--gdb/tui/tui-winsource.h8
-rw-r--r--gdb/typeprint.c2
-rw-r--r--gdb/ui-out.c8
-rw-r--r--gdb/ui-out.h6
-rw-r--r--gdb/ui.c2
-rw-r--r--gdb/user-regs.c14
-rw-r--r--gdb/utils.c52
-rw-r--r--gdb/v850-tdep.c4
-rw-r--r--gdb/valops.c3
-rw-r--r--gdb/varobj.c5
370 files changed, 6952 insertions, 6922 deletions
diff --git a/gdb/MAINTAINERS b/gdb/MAINTAINERS
index 2a18bcc..b821901 100644
--- a/gdb/MAINTAINERS
+++ b/gdb/MAINTAINERS
@@ -346,7 +346,6 @@ the native maintainer when resolving ABI issues.
h8300 --target=h8300-elf
i386 --target=i386-elf
- Felix Willgerodt felix.willgerodt@intel.com
ia64 --target=ia64-linux-gnu
(--target=ia64-elf broken)
@@ -422,7 +421,6 @@ the native maintainer when resolving ABI issues.
vax --target=vax-netbsd
x86-64 --target=x86_64-linux-gnu
- Felix Willgerodt felix.willgerodt@intel.com
xstormy16 --target=xstormy16-elf
xtensa --target=xtensa-elf
@@ -473,7 +471,7 @@ SystemTap Sergio Durigan Junior sergiodj@sergiodj.net
Reverse debugging / Record and Replay / Tracing:
record
- full Guinevere Larsen blarsen@redhat.com
+ full Guinevere Larsen guinevere@redhat.com
btrace Markus T. Metzger markus.t.metzger@intel.com
@@ -606,6 +604,7 @@ Mike Frysinger vapier@gentoo.org
Gary Funck gary@intrepid.com
Martin Galvan martingalvan@sourceware.org
Chen Gang gang.chen.5i5j@gmail.com
+Klaus Gerlicher klaus.gerlicher@intel.com
Mircea Gherzan mircea.gherzan@intel.com
Paul Gilliam pgilliam@us.ibm.com
Tristan Gingold tgingold@free.fr
@@ -656,7 +655,7 @@ Jan Kratochvil jan.kratochvil@redhat.com
Maxim Kuvyrkov maxim@kugelworks.com
Pierre Langlois pierre.langlois@arm.com
Jonathan Larmour jifl@ecoscentric.com
-Guinevere Larsen blarsen@redhat.com
+Guinevere Larsen guinevere@redhat.com
Jeff Law law@redhat.com
Justin Lebar justin.lebar@gmail.com
David Lecomber david@streamline-computing.com
@@ -690,7 +689,7 @@ Chris Moller cmoller@redhat.com
Patrick Monnerat patrick@monnerat.net
Phil Muldoon pmuldoon@redhat.com
Pierre Muller muller@sourceware.org
-Gaius Mulley gaius@glam.ac.uk
+Gaius Mulley gaiusmod2@gmail.com
Masaki Muranaka monaka@monami-software.com
Joseph Myers josmyers@redhat.com
Fernando Nasser fnasser@redhat.com
@@ -790,7 +789,7 @@ Ulrich Weigand uweigand@de.ibm.com
Ken Werner ken.werner@de.ibm.com
Tim Wiederhake tim.wiederhake@intel.com
Mark Wielaard mark@klomp.org
-Felix Willgerodt felix.willgerodt@intel.com
+Felix Willgerodt felix.willgerodt@gmail.com
Nathan Williams nathanw@wasabisystems.com
Bob Wilson bob.wilson@acm.org
Jim Wilson wilson@tuliptree.org
@@ -866,6 +865,7 @@ Stan Shebs (Global) stanshebs@google.com
Joel Brobecker (Global, Ada) brobecker@adacore.com
Doug Evans (Global) dje@google.com
Yao Qi (Global) qiyao@sourceware.org
+Felix Willgerodt (amd64, i386) felix.willgerodt@gmail.com
Folks that have been caught up in a paper trail:
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index bcf1ee4..ecb323d 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -2528,7 +2528,7 @@ clean-po:
# rule has no dependencies and always regenerates gdb.pot. This is
# relatively harmless since the .po files do not directly depend on
# it. The .pot file is left in the build directory. Since GDB's
-# Makefile lacks a cannonical list of sources (missing xm, tm and nm
+# Makefile lacks a canonical list of sources (missing xm, tm and nm
# files) force this rule.
$(PACKAGE).pot: po/$(PACKAGE).pot
po/$(PACKAGE).pot: force
diff --git a/gdb/NEWS b/gdb/NEWS
index cfc9cb0..42668cb 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -3,6 +3,18 @@
*** Changes since GDB 15
+* Debugging support for Intel MPX has been removed. This includes the
+ removal of
+ ** MPX register support
+ ** the commands "show/set mpx bound" (deprecated since GDB 15)
+ ** i386 and amd64 implementation of the hooks report_signal_info and
+ get_siginfo_type.
+
+* GDB now supports printing of asynchronous events from the Intel Processor
+ Trace during 'record instruction-history', 'record function-call-history'
+ and all stepping commands. This can be controlled with the new
+ "set record btrace pt event-tracing" command.
+
* GDB now supports printing of ptwrite payloads from the Intel Processor
Trace during 'record instruction-history', 'record function-call-history'
and all stepping commands. The payload is also accessible in Python as a
@@ -53,6 +65,11 @@
* New commands
+set style line-number foreground COLOR
+set style line-number background COLOR
+set style line-number intensity VALUE
+ Control the styling of line numbers printed by GDB.
+
maintenance info inline-frames [ADDRESS]
New command which displays GDB's inline-frame information for the
current address, or for ADDRESS if specified. The output identifies
@@ -85,6 +102,11 @@ save gdb-index
it contains white space or quote characters. If the argument
contains no such special characters then quoting is not required.
+maintenance print remote-registers
+ Add an "Expedited" column to the output of the command. It indicates
+ which registers were included in the last stop reply packet received by
+ GDB.
+
* New remote packets
vFile:stat
@@ -387,7 +409,7 @@ qIsAddressTagged
* The printf command now accepts a '%V' output format which will
format an expression just as the 'print' command would. Print
- options can be placed withing '[...]' after the '%V' to modify how
+ options can be placed within '[...]' after the '%V' to modify how
the value is printed. E.g:
printf "%V", some_array
printf "%V[-array-indexes on]", some_array
@@ -6664,7 +6686,7 @@ qSupported:
target.
qXfer:auxv:read:
- Fetch an OS auxilliary vector from the remote stub. This packet is a
+ Fetch an OS auxiliary vector from the remote stub. This packet is a
more efficient replacement for qPart:auxv:read.
qXfer:memory-map:read:
@@ -7872,7 +7894,7 @@ with that. The sub-program to run is specified using the syntax
* MIPS 64 remote protocol
A long standing bug in the mips64 remote protocol where by GDB
-expected certain 32 bit registers (ex SR) to be transfered as 32
+expected certain 32 bit registers (ex SR) to be transferred as 32
instead of 64 bits has been fixed.
The command ``set remote-mips64-transfers-32bit-regs on'' has been
@@ -8628,7 +8650,7 @@ MIPS remote debugging protocol.
This version includes preliminary support for Chill, a Pascal like language
used by telecommunications companies. Chill support is also being integrated
-into the GNU compiler, but we don't know when it will be publically available.
+into the GNU compiler, but we don't know when it will be publicly available.
*** Changes in GDB-4.8:
diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index b9f84ee..ed8ed44 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -1477,7 +1477,7 @@ block_lookup (const struct block *context, const char *raw_name)
if (context == NULL
&& (syms.empty () || syms[0].symbol->aclass () != LOC_BLOCK))
- symtab = lookup_symtab (name);
+ symtab = lookup_symtab (current_program_space, name);
else
symtab = NULL;
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 0f7100d..d14a556 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -1488,7 +1488,7 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide)
if (i < len0 + 3
&& encoded[i] == 'N' && encoded[i+1] == '_' && encoded[i+2] == '_')
{
- /* Backtrack a bit up until we reach either the begining of
+ /* Backtrack a bit up until we reach either the beginning of
the encoded name, or "__". Make sure that we only find
digits or lowercase characters. */
const char *ptr = encoded + i - 1;
@@ -3698,9 +3698,11 @@ See set/show multiple-symbol."));
gdb_printf ("[%d] ", i + first_choice);
ada_print_symbol_signature (gdb_stdout, syms[i].symbol,
&type_print_raw_options);
- gdb_printf (_(" at %s:%d\n"),
- symtab_to_filename_for_display (symtab),
- syms[i].symbol->line ());
+ gdb_printf (_(" at %ps:%ps\n"),
+ styled_string (file_name_style.style (),
+ symtab_to_filename_for_display (symtab)),
+ styled_string (line_number_style.style (),
+ pulongest (syms[i].symbol->line ())));
}
else if (is_enumeral
&& syms[i].symbol->type ()->name () != NULL)
@@ -3719,9 +3721,10 @@ See set/show multiple-symbol."));
if (symtab != NULL)
gdb_printf (is_enumeral
- ? _(" in %s (enumeral)\n")
- : _(" at %s:?\n"),
- symtab_to_filename_for_display (symtab));
+ ? _(" in %ps (enumeral)\n")
+ : _(" at %ps:?\n"),
+ styled_string (file_name_style.style (),
+ symtab_to_filename_for_display (symtab)));
else
gdb_printf (is_enumeral
? _(" (enumeral)\n")
@@ -5818,8 +5821,8 @@ is_name_suffix (const char *str)
/* ??? We should not modify STR directly, as we are doing below. This
is fine in this case, but may become problematic later if we find
that this alternative did not work, and want to try matching
- another one from the begining of STR. Since we modified it, we
- won't be able to find the begining of the string anymore! */
+ another one from the beginning of STR. Since we modified it, we
+ won't be able to find the beginning of the string anymore! */
if (str[0] == 'X')
{
str += 1;
@@ -10772,7 +10775,7 @@ ada_unop_atr_operation::evaluate (struct type *expect_type,
struct type *type_arg = nullptr;
value *val = nullptr;
- if (std::get<0> (m_storage)->opcode () == OP_TYPE)
+ if (std::get<0> (m_storage)->type_p ())
{
value *tem = std::get<0> (m_storage)->evaluate (nullptr, exp,
EVAL_AVOID_SIDE_EFFECTS);
@@ -13048,7 +13051,12 @@ ada_add_global_exceptions (compiled_regex *preg,
},
NULL,
SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
- SEARCH_VAR_DOMAIN);
+ 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. */
diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l
index 136e6dd..3fe0c2e 100644
--- a/gdb/ada-lex.l
+++ b/gdb/ada-lex.l
@@ -510,7 +510,7 @@ processReal (struct parser_state *par_state, const char *num0)
encoded and the resulting name is equal to it. Similarly, if the name
starts with '<', it is copied verbatim. Otherwise, it differs
from NAME0 in that:
- + Characters between '...' are transfered verbatim to yylval.ssym.
+ + Characters between '...' are transferred verbatim to yylval.ssym.
+ Trailing "'" characters in quoted sequences are removed (a leading quote is
preserved to indicate that the name is not to be GNAT-encoded).
+ Unquoted whitespace is removed.
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index 01ee2fb..d050b26 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -266,7 +266,7 @@ struct ada_tasks_inferior_data
reference it - this number is printed beside each task in the tasks
info listing displayed by "info tasks". This number is equal to
its index in the vector + 1. Reciprocally, to compute the index
- of a task in the vector, we need to substract 1 from its number. */
+ of a task in the vector, we need to subtract 1 from its number. */
std::vector<ada_task_info> task_list;
};
diff --git a/gdb/addrmap.c b/gdb/addrmap.c
index b9a0f77..696a7dc 100644
--- a/gdb/addrmap.c
+++ b/gdb/addrmap.c
@@ -354,7 +354,9 @@ addrmap_mutable::~addrmap_mutable ()
/* See addrmap.h. */
void
-addrmap_dump (struct addrmap *map, struct ui_file *outfile, void *payload)
+addrmap_dump (struct addrmap *map, struct ui_file *outfile, void *payload,
+ gdb::function_view<void (struct ui_file *outfile,
+ const void *value)> annotate_value)
{
/* True if the previously printed addrmap entry was for PAYLOAD.
If so, we want to print the next one as well (since the next
@@ -373,10 +375,16 @@ addrmap_dump (struct addrmap *map, struct ui_file *outfile, void *payload)
addr_str = "<ends here>";
if (matches || previous_matched)
- gdb_printf (outfile, " %s%s %s\n",
- payload != nullptr ? " " : "",
- core_addr_to_string (start_addr),
- addr_str);
+ {
+ gdb_printf (outfile, " %s%s %s",
+ payload != nullptr ? " " : "",
+ core_addr_to_string (start_addr),
+ addr_str);
+ if (annotate_value != nullptr)
+ annotate_value (outfile, obj);
+
+ gdb_printf (outfile, "\n");
+ }
previous_matched = matches;
diff --git a/gdb/addrmap.h b/gdb/addrmap.h
index abd1ee3..85d4645 100644
--- a/gdb/addrmap.h
+++ b/gdb/addrmap.h
@@ -219,8 +219,13 @@ private:
/* Dump the addrmap to OUTFILE. If PAYLOAD is non-NULL, only dump any
components that map to PAYLOAD. (If PAYLOAD is NULL, the entire
- map is dumped.) */
+ map is dumped.) If ANNOTATE_VALUE is non-nullptr, call it for each
+ value. */
+
void addrmap_dump (struct addrmap *map, struct ui_file *outfile,
- void *payload);
+ void *payload,
+ gdb::function_view<void (struct ui_file *outfile,
+ const void *value)>
+ annotate_value = nullptr);
#endif /* ADDRMAP_H */
diff --git a/gdb/alpha-tdep.h b/gdb/alpha-tdep.h
index 0423abb..4554ac0 100644
--- a/gdb/alpha-tdep.h
+++ b/gdb/alpha-tdep.h
@@ -99,7 +99,7 @@ struct alpha_gdbarch_tdep : gdbarch_tdep_base
int sc_fpregs_offset = 0;
int jb_pc = 0; /* Offset to PC value in jump buffer.
- If htis is negative, longjmp support
+ If this is negative, longjmp support
will be disabled. */
size_t jb_elt_size = 0; /* And the size of each entry in the buf. */
};
diff --git a/gdb/amd-dbgapi-target.c b/gdb/amd-dbgapi-target.c
index e9c5a47..2bb79ac 100644
--- a/gdb/amd-dbgapi-target.c
+++ b/gdb/amd-dbgapi-target.c
@@ -483,12 +483,12 @@ struct amd_dbgapi_target_breakpoint : public code_breakpoint
disposition = disp_donttouch;
}
- void re_set () override;
+ void re_set (program_space *) override;
void check_status (struct bpstat *bs) override;
};
void
-amd_dbgapi_target_breakpoint::re_set ()
+amd_dbgapi_target_breakpoint::re_set (program_space *)
{
/* Nothing. */
}
diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
index 823c1f7..742fc81 100644
--- a/gdb/amd64-linux-nat.c
+++ b/gdb/amd64-linux-nat.c
@@ -79,6 +79,8 @@ static int amd64_linux_gregset32_reg_offset[] =
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
+ /* MPX is deprecated. Yet we keep this to not give the registers below
+ a new number. That could break older gdbservers. */
-1, -1, -1, -1, /* MPX registers BND0 ... BND3. */
-1, -1, /* MPX registers BNDCFGU, BNDSTATUS. */
-1, -1, -1, -1, -1, -1, -1, -1, /* k0 ... k7 (AVX512) */
diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index d7662ca..77de821 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -86,6 +86,8 @@ int amd64_linux_gregset_reg_offset[] =
-1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
+ /* MPX is deprecated. Yet we keep this to not give the registers below
+ a new number. That could break older gdbservers. */
-1, -1, -1, -1, /* MPX registers BND0 ... BND3. */
-1, -1, /* MPX registers BNDCFGU and BNDSTATUS. */
-1, -1, -1, -1, -1, -1, -1, -1, /* xmm16 ... xmm31 (AVX512) */
@@ -1816,9 +1818,6 @@ amd64_linux_init_abi_common(struct gdbarch_info info, struct gdbarch *gdbarch,
set_gdbarch_process_record (gdbarch, i386_process_record);
set_gdbarch_process_record_signal (gdbarch, amd64_linux_record_signal);
-
- set_gdbarch_get_siginfo_type (gdbarch, x86_linux_get_siginfo_type);
- set_gdbarch_report_signal_info (gdbarch, i386_linux_report_signal_info);
}
static void
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index df6b882..b63e35d 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -110,11 +110,6 @@ static const char * const amd64_ymmh_avx512_names[] =
"ymm28h", "ymm29h", "ymm30h", "ymm31h"
};
-static const char * const amd64_mpx_names[] =
-{
- "bnd0raw", "bnd1raw", "bnd2raw", "bnd3raw", "bndcfgu", "bndstatus"
-};
-
static const char * const amd64_k_names[] =
{
"k0", "k1", "k2", "k3",
@@ -1039,13 +1034,6 @@ amd64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte buf[8];
- /* BND registers can be in arbitrary values at the moment of the
- inferior call. This can cause boundary violations that are not
- due to a real bug or even desired by the user. The best to be done
- is set the BND registers to allow access to the whole memory, INIT
- state, before pushing the inferior call. */
- i387_reset_bnd_regs (gdbarch, regcache);
-
/* Pass arguments. */
sp = amd64_push_arguments (regcache, nargs, args, sp, return_method);
@@ -3196,13 +3184,6 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch,
tdep->ymm0h_regnum = AMD64_YMM0H_REGNUM;
}
- if (tdesc_find_feature (tdesc, "org.gnu.gdb.i386.mpx") != NULL)
- {
- tdep->mpx_register_names = amd64_mpx_names;
- tdep->bndcfgu_regnum = AMD64_BNDCFGU_REGNUM;
- tdep->bnd0r_regnum = AMD64_BND0R_REGNUM;
- }
-
if (tdesc_find_feature (tdesc, "org.gnu.gdb.i386.segments") != NULL)
{
tdep->fsbase_regnum = AMD64_FSBASE_REGNUM;
@@ -3377,11 +3358,10 @@ const struct target_desc *
amd64_target_description (uint64_t xcr0, bool segments)
{
static target_desc *amd64_tdescs \
- [2/*AVX*/][2/*MPX*/][2/*AVX512*/][2/*PKRU*/][2/*segments*/] = {};
+ [2/*AVX*/][2/*AVX512*/][2/*PKRU*/][2/*segments*/] = {};
target_desc **tdesc;
tdesc = &amd64_tdescs[(xcr0 & X86_XSTATE_AVX) ? 1 : 0]
- [(xcr0 & X86_XSTATE_MPX) ? 1 : 0]
[(xcr0 & X86_XSTATE_AVX512) ? 1 : 0]
[(xcr0 & X86_XSTATE_PKRU) ? 1 : 0]
[segments ? 1 : 0];
diff --git a/gdb/amd64-tdep.h b/gdb/amd64-tdep.h
index 696c65b..544ed91 100644
--- a/gdb/amd64-tdep.h
+++ b/gdb/amd64-tdep.h
@@ -66,6 +66,8 @@ enum amd64_regnum
AMD64_MXCSR_REGNUM = AMD64_XMM0_REGNUM + 16,
AMD64_YMM0H_REGNUM, /* %ymm0h */
AMD64_YMM15H_REGNUM = AMD64_YMM0H_REGNUM + 15,
+ /* MPX is deprecated. Yet we keep this to not give the registers below
+ a new number. That could break older gdbservers. */
AMD64_BND0R_REGNUM = AMD64_YMM15H_REGNUM + 1,
AMD64_BND3R_REGNUM = AMD64_BND0R_REGNUM + 3,
AMD64_BNDCFGU_REGNUM,
diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c
index 5adc7d5..29a1f60 100644
--- a/gdb/amd64-windows-tdep.c
+++ b/gdb/amd64-windows-tdep.c
@@ -324,7 +324,7 @@ amd64_windows_push_dummy_call
/* Pass "hidden" argument". */
if (return_method == return_method_struct)
{
- /* The "hidden" argument is passed throught the first argument
+ /* The "hidden" argument is passed through the first argument
register. */
const int arg_regnum = amd64_windows_dummy_call_integer_regs[0];
diff --git a/gdb/arc-linux-tdep.c b/gdb/arc-linux-tdep.c
index 01c591f..69980f9 100644
--- a/gdb/arc-linux-tdep.c
+++ b/gdb/arc-linux-tdep.c
@@ -428,7 +428,7 @@ arc_linux_software_single_step (struct regcache *regcache)
CORE_ADDR next_pc = arc_insn_get_linear_next_pc (curr_insn);
std::vector<CORE_ADDR> next_pcs;
- /* For instructions with delay slots, the fall thru is not the
+ /* For instructions with delay slots, the fall through is not the
instruction immediately after the current instruction, but the one
after that. */
if (curr_insn.has_delay_slot)
diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c
index 4fc1ea1..9adf295 100644
--- a/gdb/arc-tdep.c
+++ b/gdb/arc-tdep.c
@@ -1438,7 +1438,7 @@ arc_analyze_prologue (struct gdbarch *gdbarch, const CORE_ADDR entrypoint,
1) Store instruction for each callee-saved register (R25 - R13 + 1)
2) Two instructions for FP
3) One for BLINK
- 4) Three substract instructions for SP (for variadic args, for
+ 4) Three subtract instructions for SP (for variadic args, for
callee saved regs and for local vars) and assuming that those SUB use
long-immediate (hence double length).
5) Stores of arguments registers are considered part of prologue too
@@ -2117,7 +2117,7 @@ arc_check_tdesc_feature (struct tdesc_arch_data *tdesc_data,
return true;
}
-/* Check for the existance of "lp_start" and "lp_end" in target description.
+/* Check for the existence of "lp_start" and "lp_end" in target description.
If both are present, assume there is hardware loop support in the target.
This can be improved by looking into "lpc_size" field of "isa_config"
auxiliary register. */
diff --git a/gdb/arch/amd64.c b/gdb/arch/amd64.c
index 94d55d7..5fc9947 100644
--- a/gdb/arch/amd64.c
+++ b/gdb/arch/amd64.c
@@ -17,13 +17,13 @@
#include "amd64.h"
#include "gdbsupport/x86-xstate.h"
+#include "gdbsupport/osabi.h"
#include <stdlib.h>
#include "../features/i386/64bit-avx.c"
#include "../features/i386/64bit-avx512.c"
#include "../features/i386/64bit-core.c"
#include "../features/i386/64bit-linux.c"
-#include "../features/i386/64bit-mpx.c"
#include "../features/i386/64bit-segments.c"
#include "../features/i386/64bit-sse.c"
#include "../features/i386/pkeys.c"
@@ -46,7 +46,7 @@ amd64_create_target_description (uint64_t xcr0, bool is_x32, bool is_linux,
is_x32 ? "i386:x64-32" : "i386:x86-64");
if (is_linux)
- set_tdesc_osabi (tdesc.get (), "GNU/Linux");
+ set_tdesc_osabi (tdesc.get (), GDB_OSABI_LINUX);
#endif
long regnum = 0;
@@ -65,13 +65,6 @@ amd64_create_target_description (uint64_t xcr0, bool is_x32, bool is_linux,
if (xcr0 & X86_XSTATE_AVX)
regnum = create_feature_i386_64bit_avx (tdesc.get (), regnum);
- if (xcr0 & X86_XSTATE_MPX)
- {
- /* MPX is not available on x32. */
- gdb_assert (!is_x32);
- regnum = create_feature_i386_64bit_mpx (tdesc.get (), regnum);
- }
-
if (xcr0 & X86_XSTATE_AVX512)
regnum = create_feature_i386_64bit_avx512 (tdesc.get (), regnum);
diff --git a/gdb/arch/i386.c b/gdb/arch/i386.c
index f3165c5..2072eae 100644
--- a/gdb/arch/i386.c
+++ b/gdb/arch/i386.c
@@ -18,6 +18,7 @@
#include "i386.h"
#include "gdbsupport/tdesc.h"
#include "gdbsupport/x86-xstate.h"
+#include "gdbsupport/osabi.h"
#include <stdlib.h>
#include "../features/i386/32bit-core.c"
@@ -25,7 +26,6 @@
#include "../features/i386/32bit-sse.c"
#include "../features/i386/32bit-avx.c"
#include "../features/i386/32bit-avx512.c"
-#include "../features/i386/32bit-mpx.c"
#include "../features/i386/32bit-segments.c"
#include "../features/i386/pkeys.c"
@@ -39,7 +39,7 @@ i386_create_target_description (uint64_t xcr0, bool is_linux, bool segments)
#ifndef IN_PROCESS_AGENT
set_tdesc_architecture (tdesc.get (), "i386");
if (is_linux)
- set_tdesc_osabi (tdesc.get (), "GNU/Linux");
+ set_tdesc_osabi (tdesc.get (), GDB_OSABI_LINUX);
#endif
long regnum = 0;
@@ -59,9 +59,6 @@ i386_create_target_description (uint64_t xcr0, bool is_linux, bool segments)
if (xcr0 & X86_XSTATE_AVX)
regnum = create_feature_i386_32bit_avx (tdesc.get (), regnum);
- if (xcr0 & X86_XSTATE_MPX)
- regnum = create_feature_i386_32bit_mpx (tdesc.get (), regnum);
-
if (xcr0 & X86_XSTATE_AVX512)
regnum = create_feature_i386_32bit_avx512 (tdesc.get (), regnum);
diff --git a/gdb/arch/tic6x.c b/gdb/arch/tic6x.c
index 680a794..b8a722b 100644
--- a/gdb/arch/tic6x.c
+++ b/gdb/arch/tic6x.c
@@ -16,6 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "gdbsupport/tdesc.h"
+#include "gdbsupport/osabi.h"
#include "tic6x.h"
#include "../features/tic6x-core.c"
@@ -30,7 +31,7 @@ tic6x_create_target_description (enum c6x_feature feature)
target_desc_up tdesc = allocate_target_description ();
set_tdesc_architecture (tdesc.get (), "tic6x");
- set_tdesc_osabi (tdesc.get (), "GNU/Linux");
+ set_tdesc_osabi (tdesc.get (), GDB_OSABI_LINUX);
long regnum = 0;
diff --git a/gdb/arch/x86-linux-tdesc-features.c b/gdb/arch/x86-linux-tdesc-features.c
index ad1d919..f6eb112 100644
--- a/gdb/arch/x86-linux-tdesc-features.c
+++ b/gdb/arch/x86-linux-tdesc-features.c
@@ -65,7 +65,6 @@ static constexpr x86_xstate_feature x86_linux_all_xstate_features[] = {
{ X86_XSTATE_PKRU, true, true, true },
{ X86_XSTATE_AVX512, true, true, true },
{ X86_XSTATE_AVX, true, true, true },
- { X86_XSTATE_MPX, true, true, false },
{ X86_XSTATE_SSE, true, false, false },
{ X86_XSTATE_X87, true, false, false }
};
@@ -150,9 +149,9 @@ x86_linux_xcr0_to_tdesc_idx (uint64_t xcr0)
the target descriptions (see nat/x86-linux-tdesc.c), the feature order
represents the bit order within the generated index number.
- i386 | x87 sse mpx avx avx512 pkru
- amd64 | mpx avx avx512 pkru
- i32 | avx avx512 pkru
+ i386 | x87 sse avx avx512 pkru
+ amd64 | avx avx512 pkru
+ i32 | avx avx512 pkru
The features are ordered so that for each mode (i386, amd64, i32) the
generated index will form a continuous range. */
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 6b235a0..9c996b8 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -4857,7 +4857,7 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
si = pop_stack_item (si);
}
- /* Finally, update teh SP register. */
+ /* Finally, update the SP register. */
regcache_cooked_write_unsigned (regcache, ARM_SP_REGNUM, sp);
return sp;
@@ -12139,7 +12139,7 @@ arm_record_ld_st_imm_offset (arm_insn_decode_record *arm_insn_r)
record_buf[arm_insn_r->reg_rec_count++] = reg_dest;
/* The LDR instruction is capable of doing branching. If MOV LR, PC
- preceeds a LDR instruction having R15 as reg_base, it
+ precedes a LDR instruction having R15 as reg_base, it
emulates a branch and link instruction, and hence we need to save
CPSR and PC as well. */
if (ARM_PC_REGNUM == reg_dest)
@@ -12263,7 +12263,7 @@ arm_record_ld_st_reg_offset (arm_insn_decode_record *arm_insn_r)
if (15 == reg_src2)
{
/* If R15 was used as Rn, hence current PC+8. */
- /* Pre-indexed mode doesnt reach here ; illegal insn. */
+ /* Pre-indexed mode doesn't reach here ; illegal insn. */
u_regval[0] = u_regval[0] + 8;
}
/* Calculate target store address, Rn +/- Rm, register offset. */
@@ -12576,7 +12576,7 @@ arm_record_b_bl (arm_insn_decode_record *arm_insn_r)
/* Handle B, BL, BLX(1) insns. */
/* B simply branches so we do nothing here. */
- /* Note: BLX(1) doesnt fall here but instead it falls into
+ /* Note: BLX(1) doesn't fall here but instead it falls into
extension space. */
if (bit (arm_insn_r->arm_insn, 24))
{
diff --git a/gdb/auxv.c b/gdb/auxv.c
index 8bcd347..c831b2b 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -328,7 +328,7 @@ parse_auxv (target_ops *ops, gdbarch *gdbarch, const gdb_byte **readptr,
/* Auxiliary Vector information structure. This is used by GDB
for caching purposes for each inferior. This helps reduce the
- overhead of transfering data from a remote target to the local host. */
+ overhead of transferring data from a remote target to the local host. */
struct auxv_info
{
std::optional<gdb::byte_vector> data;
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 7fd50ba..4cf6857 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -1578,10 +1578,20 @@ breakpoint_set_thread (struct breakpoint *b, int thread)
/* If the program space has changed for this breakpoint, then
re-evaluate it's locations. */
if (old_pspace != new_pspace)
- breakpoint_re_set_one (b, new_pspace);
+ {
+ /* The breakpoint is now associated with a completely different
+ program space. Discard all of the current locations and then
+ re-set the breakpoint in the new program space, this will
+ create the new locations. */
+ b->clear_locations ();
+ breakpoint_re_set_one (b, new_pspace);
+ }
- /* Let others know the breakpoint has changed. */
- notify_breakpoint_modified (b);
+ /* If the program space didn't change, or the breakpoint didn't
+ acquire any new locations after the clear_locations call, then we
+ need to notify of the breakpoint modification now. */
+ if (old_pspace == new_pspace || !b->has_locations ())
+ notify_breakpoint_modified (b);
}
}
@@ -1625,9 +1635,20 @@ breakpoint_set_inferior (struct breakpoint *b, int inferior)
}
if (old_pspace != new_pspace)
- breakpoint_re_set_one (b, new_pspace);
+ {
+ /* The breakpoint is now associated with a completely different
+ program space. Discard all of the current locations and then
+ re-set the breakpoint in the new program space, this will
+ create the new locations. */
+ b->clear_locations ();
+ breakpoint_re_set_one (b, new_pspace);
+ }
- notify_breakpoint_modified (b);
+ /* If the program space didn't change, or the breakpoint didn't
+ acquire any new locations after the clear_locations call, then we
+ need to notify of the breakpoint modification now. */
+ if (old_pspace == new_pspace || !b->has_locations ())
+ notify_breakpoint_modified (b);
}
}
@@ -6371,7 +6392,8 @@ print_breakpoint_location (const breakpoint *b, const bp_location *loc)
if (uiout->is_mi_like_p ())
uiout->field_string ("fullname", symtab_to_fullname (loc->symtab));
- uiout->field_signed ("line", loc->line_number);
+ uiout->field_signed ("line", loc->line_number,
+ line_number_style.style ());
}
else if (loc)
{
@@ -10458,45 +10480,6 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
'wp_frame'. */
frame_id watchpoint_frame = get_frame_id (wp_frame);
- /* If the expression is "local", then set up a "watchpoint scope"
- breakpoint at the point where we've left the scope of the watchpoint
- expression. Create the scope breakpoint before the watchpoint, so
- that we will encounter it first in bpstat_stop_status. */
- if (exp_valid_block != NULL && wp_frame != NULL)
- {
- frame_id caller_frame_id = frame_unwind_caller_id (wp_frame);
-
- if (frame_id_p (caller_frame_id))
- {
- gdbarch *caller_arch = frame_unwind_caller_arch (wp_frame);
- CORE_ADDR caller_pc = frame_unwind_caller_pc (wp_frame);
-
- scope_breakpoint
- = create_internal_breakpoint (caller_arch, caller_pc,
- bp_watchpoint_scope);
-
- /* create_internal_breakpoint could invalidate WP_FRAME. */
- wp_frame = NULL;
-
- scope_breakpoint->enable_state = bp_enabled;
-
- /* Automatically delete the breakpoint when it hits. */
- scope_breakpoint->disposition = disp_del;
-
- /* Only break in the proper frame (help with recursion). */
- scope_breakpoint->frame_id = caller_frame_id;
-
- /* Set the address at which we will stop. */
- bp_location &loc = scope_breakpoint->first_loc ();
- loc.gdbarch = caller_arch;
- loc.requested_address = caller_pc;
- loc.address
- = adjust_breakpoint_address (loc.gdbarch, loc.requested_address,
- scope_breakpoint->type,
- current_program_space);
- }
- }
-
/* Now set up the breakpoint. We create all watchpoints as hardware
watchpoints here even if hardware watchpoints are turned off, a call
to update_watchpoint later in this function will cause the type to
@@ -10567,14 +10550,6 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
w->watchpoint_thread = null_ptid;
}
- if (scope_breakpoint != NULL)
- {
- /* The scope breakpoint is related to the watchpoint. We will
- need to act on them together. */
- w->related_breakpoint = scope_breakpoint;
- scope_breakpoint->related_breakpoint = w.get ();
- }
-
if (!just_location)
value_free_to_mark (mark);
@@ -10582,7 +10557,60 @@ watch_command_1 (const char *arg, int accessflag, int from_tty,
that should be inserted. */
update_watchpoint (w.get (), true /* reparse */);
+ /* If the expression is "local", then set up a "watchpoint scope"
+ breakpoint at the point where we've left the scope of the watchpoint
+ expression. Create the scope breakpoint before the watchpoint, so
+ that we will encounter it first in bpstat_stop_status. */
+ if (exp_valid_block != nullptr && wp_frame != nullptr)
+ {
+ frame_id caller_frame_id = frame_unwind_caller_id (wp_frame);
+
+ if (frame_id_p (caller_frame_id))
+ {
+ gdbarch *caller_arch = frame_unwind_caller_arch (wp_frame);
+ CORE_ADDR caller_pc = frame_unwind_caller_pc (wp_frame);
+
+ scope_breakpoint
+ = create_internal_breakpoint (caller_arch, caller_pc,
+ bp_watchpoint_scope);
+
+ /* create_internal_breakpoint could invalidate WP_FRAME. */
+ wp_frame = nullptr;
+
+ scope_breakpoint->enable_state = bp_enabled;
+
+ /* Automatically delete the breakpoint when it hits. */
+ scope_breakpoint->disposition = disp_del;
+
+ /* Only break in the proper frame (help with recursion). */
+ scope_breakpoint->frame_id = caller_frame_id;
+
+ /* Set the address at which we will stop. */
+ bp_location &loc = scope_breakpoint->first_loc ();
+ loc.gdbarch = caller_arch;
+ loc.requested_address = caller_pc;
+ loc.address
+ = adjust_breakpoint_address (loc.gdbarch, loc.requested_address,
+ scope_breakpoint->type,
+ current_program_space);
+ }
+ }
+
+ if (scope_breakpoint != nullptr)
+ {
+ /* The scope breakpoint is related to the watchpoint. We will
+ need to act on them together. */
+ w->related_breakpoint = scope_breakpoint;
+ scope_breakpoint->related_breakpoint = w.get ();
+ }
+
+ /* Verify that the scope breakpoint comes before the watchpoint in the
+ breakpoint chain. */
+ gdb_assert (scope_breakpoint == nullptr
+ || &breakpoint_chain.back () == scope_breakpoint);
+ watchpoint *watchpoint_ptr = w.get ();
install_breakpoint (internal, std::move (w), 1);
+ gdb_assert (&breakpoint_chain.back () == watchpoint_ptr);
}
/* Return count of debug registers needed to watch the given expression.
@@ -11076,7 +11104,7 @@ clear_command (const char *arg, int from_tty)
}
}
- /* Now go thru the 'found' chain and delete them. */
+ /* Now go through the 'found' chain and delete them. */
if (found.empty ())
{
if (arg)
@@ -11799,10 +11827,11 @@ code_breakpoint::say_where () const
{
const char *filename
= symtab_to_filename_for_display (bl.symtab);
- gdb_printf (": file %ps, line %d.",
+ gdb_printf (": file %ps, line %ps.",
styled_string (file_name_style.style (),
filename),
- bl.line_number);
+ styled_string (line_number_style.style (),
+ pulongest (bl.line_number)));
}
else
/* This is not ideal, but each location may have a
@@ -12832,7 +12861,7 @@ update_static_tracepoint (tracepoint *tp, struct symtab_and_line sal)
uiout->field_string ("fullname", fullname);
}
- uiout->field_signed ("line", sal2.line);
+ uiout->field_signed ("line", sal2.line, line_number_style.style ());
uiout->text ("\n");
tp->first_loc ().line_number = sal2.line;
@@ -12941,32 +12970,12 @@ update_breakpoint_locations (code_breakpoint *b,
all locations are in the same shared library, that was unloaded.
We'd like to retain the location, so that when the library is
loaded again, we don't loose the enabled/disabled status of the
- individual locations.
-
- Thread specific breakpoints will also trigger this case if the thread
- is changed to a different program space, and all of the old locations
- go out of scope. In this case we do (currently) discard the old
- locations -- we assume the change in thread is permanent and the old
- locations will never come back into scope. */
+ individual locations. */
if (all_locations_are_pending (b, filter_pspace) && sals.empty ())
- {
- if (b->thread != -1)
- b->clear_locations ();
- return;
- }
+ return;
bp_location_list existing_locations = b->steal_locations (filter_pspace);
- /* If this is a thread-specific breakpoint then any locations left on the
- breakpoint are for a program space in which the thread of interest
- does not operate. This can happen when the user changes the thread of
- a thread-specific breakpoint.
-
- We assume that the change in thread is permanent, and that the old
- locations will never be used again, so discard them now. */
- if (b->thread != -1)
- b->clear_locations ();
-
for (const auto &sal : sals)
{
struct bp_location *new_loc;
@@ -13136,9 +13145,10 @@ code_breakpoint::re_set_default (struct program_space *filter_pspace)
{
std::vector<symtab_and_line> expanded, expanded_end;
- /* If this breakpoint is thread-specific then find the program space in
- which the specific thread exists. Otherwise, for breakpoints that are
- not thread-specific THREAD_PSPACE will be nullptr. */
+ /* If this breakpoint is thread- or inferior-specific, then find the
+ program space in which this breakpoint exists. Otherwise, for
+ breakpoints that are not thread- or inferior-specific, BP_PSPACE will
+ be nullptr. */
program_space *bp_pspace
= find_program_space_for_breakpoint (this->thread, this->inferior);
diff --git a/gdb/btrace.c b/gdb/btrace.c
index ff9612d..152f6f2 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -547,31 +547,39 @@ ftrace_new_gap (struct btrace_thread_info *btinfo, int errcode,
Return the chronologically latest function segment, never NULL. */
static struct btrace_function *
-ftrace_update_function (struct btrace_thread_info *btinfo, CORE_ADDR pc)
+ftrace_update_function (struct btrace_thread_info *btinfo,
+ std::optional<CORE_ADDR> pc)
{
- struct minimal_symbol *mfun;
- struct symbol *fun;
- struct btrace_function *bfun;
+ struct minimal_symbol *mfun = nullptr;
+ struct symbol *fun = nullptr;
/* Try to determine the function we're in. We use both types of symbols
to avoid surprises when we sometimes get a full symbol and sometimes
only a minimal symbol. */
- fun = find_pc_function (pc);
- bound_minimal_symbol bmfun = lookup_minimal_symbol_by_pc (pc);
- mfun = bmfun.minsym;
+ if (pc.has_value ())
+ {
+ fun = find_pc_function (*pc);
+ bound_minimal_symbol bmfun = lookup_minimal_symbol_by_pc (*pc);
+ mfun = bmfun.minsym;
- if (fun == NULL && mfun == NULL)
- DEBUG_FTRACE ("no symbol at %s", core_addr_to_string_nz (pc));
+ if (fun == nullptr && mfun == nullptr)
+ DEBUG_FTRACE ("no symbol at %s", core_addr_to_string_nz (*pc));
+ }
/* If we didn't have a function, we create one. */
if (btinfo->functions.empty ())
return ftrace_new_function (btinfo, mfun, fun);
/* If we had a gap before, we create a function. */
- bfun = &btinfo->functions.back ();
+ btrace_function *bfun = &btinfo->functions.back ();
if (bfun->errcode != 0)
return ftrace_new_function (btinfo, mfun, fun);
+ /* If there is no valid PC, which can happen for events with a
+ suppressed IP, we can't do more than return the last bfun. */
+ if (!pc.has_value ())
+ return bfun;
+
/* Check the last instruction, if we have one.
We do this check first, since it allows us to fill in the call stack
links in addition to the normal flow links. */
@@ -605,7 +613,7 @@ ftrace_update_function (struct btrace_thread_info *btinfo, CORE_ADDR pc)
case BTRACE_INSN_CALL:
/* Ignore calls to the next instruction. They are used for PIC. */
- if (last->pc + last->size == pc)
+ if (last->pc + last->size == *pc)
break;
return ftrace_new_call (btinfo, mfun, fun);
@@ -614,10 +622,10 @@ ftrace_update_function (struct btrace_thread_info *btinfo, CORE_ADDR pc)
{
CORE_ADDR start;
- start = get_pc_function_start (pc);
+ start = get_pc_function_start (*pc);
/* A jump to the start of a function is (typically) a tail call. */
- if (start == pc)
+ if (start == *pc)
return ftrace_new_tailcall (btinfo, mfun, fun);
/* Some versions of _Unwind_RaiseException use an indirect
@@ -642,6 +650,18 @@ ftrace_update_function (struct btrace_thread_info *btinfo, CORE_ADDR pc)
break;
}
+
+ case BTRACE_INSN_AUX:
+ /* An aux insn couldn't have switched the function. But the
+ segment might not have had a symbol name resolved yet, as events
+ might not have an IP. Use the current IP in that case and update
+ the name. */
+ if (bfun->sym == nullptr && bfun->msym == nullptr)
+ {
+ bfun->sym = fun;
+ bfun->msym = mfun;
+ }
+ break;
}
}
@@ -668,6 +688,8 @@ ftrace_update_insns (struct btrace_function *bfun, const btrace_insn &insn)
if (insn.iclass == BTRACE_INSN_AUX)
bfun->flags |= BFUN_CONTAINS_AUX;
+ else
+ bfun->flags |= BFUN_CONTAINS_NON_AUX;
if (record_debug > 1)
ftrace_debug (bfun, "update insn");
@@ -1101,7 +1123,8 @@ btrace_compute_ftrace_bts (struct thread_info *tp,
break;
}
- bfun = ftrace_update_function (btinfo, pc);
+ bfun = ftrace_update_function (btinfo,
+ std::make_optional<CORE_ADDR> (pc));
/* Maintain the function level offset.
For all but the last block, we do it here. */
@@ -1211,10 +1234,10 @@ pt_btrace_insn (const struct pt_insn &insn)
static void
handle_pt_aux_insn (btrace_thread_info *btinfo, std::string &aux_str,
- CORE_ADDR ip)
+ std::optional<CORE_ADDR> pc)
{
btinfo->aux_data.emplace_back (std::move (aux_str));
- struct btrace_function *bfun = ftrace_update_function (btinfo, ip);
+ struct btrace_function *bfun = ftrace_update_function (btinfo, pc);
btrace_insn insn {{btinfo->aux_data.size () - 1}, 0,
BTRACE_INSN_AUX, 0};
@@ -1222,8 +1245,47 @@ handle_pt_aux_insn (btrace_thread_info *btinfo, std::string &aux_str,
ftrace_update_insns (bfun, insn);
}
+/* Check if the recording contains real instructions and not only auxiliary
+ instructions since the last gap (or since the beginning). */
+
+static bool
+ftrace_contains_non_aux_since_last_gap (const btrace_thread_info *btinfo)
+{
+ const std::vector<btrace_function> &functions = btinfo->functions;
+
+ std::vector<btrace_function>::const_reverse_iterator rit;
+ for (rit = functions.crbegin (); rit != functions.crend (); ++rit)
+ {
+ if (rit->errcode != 0)
+ return false;
+
+ if ((rit->flags & BFUN_CONTAINS_NON_AUX) != 0)
+ return true;
+ }
+
+ return false;
+}
#endif /* defined (HAVE_PT_INSN_EVENT) */
+#if (LIBIPT_VERSION >= 0x201)
+/* Translate an interrupt vector to a mnemonic string as defined for x86.
+ Returns nullptr if there is none. */
+
+static const char *
+decode_interrupt_vector (const uint8_t vector)
+{
+ static const char *mnemonic[]
+ = { "#de", "#db", nullptr, "#bp", "#of", "#br", "#ud", "#nm",
+ "#df", "#mf", "#ts", "#np", "#ss", "#gp", "#pf", nullptr,
+ "#mf", "#ac", "#mc", "#xm", "#ve", "#cp" };
+
+ if (vector < (sizeof (mnemonic) / sizeof (mnemonic[0])))
+ return mnemonic[vector];
+
+ return nullptr;
+}
+#endif /* defined (LIBIPT_VERSION >= 0x201) */
+
/* Handle instruction decode events (libipt-v2). */
static int
@@ -1236,6 +1298,7 @@ handle_pt_insn_events (struct btrace_thread_info *btinfo,
{
struct pt_event event;
uint64_t offset;
+ std::optional<CORE_ADDR> pc;
status = pt_insn_event (decoder, &event, sizeof (event));
if (status < 0)
@@ -1251,11 +1314,16 @@ handle_pt_insn_events (struct btrace_thread_info *btinfo,
if (event.status_update != 0)
break;
+ /* Only create a new gap if there are non-aux instructions in
+ the trace since the last gap. We could be at the beginning
+ of the recording and could already have handled one or more
+ events, like ptev_iret, that created aux insns. In that
+ case we don't want to create a gap or print a warning. */
if (event.variant.enabled.resumed == 0
- && !btinfo->functions.empty ())
+ && ftrace_contains_non_aux_since_last_gap (btinfo))
{
struct btrace_function *bfun
- = ftrace_new_gap (btinfo, BDE_PT_DISABLED, gaps);
+ = ftrace_new_gap (btinfo, BDE_PT_NON_CONTIGUOUS, gaps);
pt_insn_get_offset (decoder, &offset);
@@ -1282,7 +1350,6 @@ handle_pt_insn_events (struct btrace_thread_info *btinfo,
#if defined (HAVE_STRUCT_PT_EVENT_VARIANT_PTWRITE)
case ptev_ptwrite:
{
- uint64_t pc = 0;
std::optional<std::string> ptw_string;
/* Lookup the PC if available. The event often doesn't provide
@@ -1314,9 +1381,10 @@ handle_pt_insn_events (struct btrace_thread_info *btinfo,
}
}
- if (pc == 0)
+ if (!pc.has_value ())
warning (_("Failed to determine the PC for ptwrite."));
+
if (btinfo->ptw_callback_fun != nullptr)
ptw_string
= btinfo->ptw_callback_fun (event.variant.ptwrite.payload,
@@ -1333,6 +1401,203 @@ handle_pt_insn_events (struct btrace_thread_info *btinfo,
break;
}
#endif /* defined (HAVE_STRUCT_PT_EVENT_VARIANT_PTWRITE) */
+
+#if (LIBIPT_VERSION >= 0x201)
+ case ptev_interrupt:
+ {
+ std::string aux_string = std::string (_("interrupt: vector = "))
+ + hex_string (event.variant.interrupt.vector);
+
+ const char *decoded
+ = decode_interrupt_vector (event.variant.interrupt.vector);
+ if (decoded != nullptr)
+ aux_string += std::string (" (") + decoded + ")";
+
+ if (event.variant.interrupt.has_cr2 != 0)
+ {
+ aux_string += std::string (", cr2 = ")
+ + hex_string (event.variant.interrupt.cr2);
+ }
+
+ if (event.ip_suppressed == 0)
+ {
+ pc = event.variant.interrupt.ip;
+ aux_string += std::string (", ip = ") + hex_string (*pc);
+ }
+
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
+
+ case ptev_iret:
+ {
+ std::string aux_string = std::string (_("iret"));
+
+ if (event.ip_suppressed == 0)
+ {
+ pc = event.variant.iret.ip;
+ aux_string += std::string (": ip = ") + hex_string (*pc);
+ }
+
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
+
+ case ptev_smi:
+ {
+ std::string aux_string = std::string (_("smi"));
+
+ if (event.ip_suppressed == 0)
+ {
+ pc = event.variant.smi.ip;
+ aux_string += std::string (": ip = ") + hex_string (*pc);
+ }
+
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
+
+ case ptev_rsm:
+ {
+ std::string aux_string = std::string (_("rsm"));
+
+ if (event.ip_suppressed == 0)
+ {
+ pc = event.variant.rsm.ip;
+ aux_string += std::string (": ip = ") + hex_string (*pc);
+ }
+
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
+
+ case ptev_sipi:
+ {
+ std::string aux_string = std::string (_("sipi: vector = "))
+ + hex_string (event.variant.sipi.vector);
+
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
+
+ case ptev_init:
+ {
+ std::string aux_string = std::string (_("init"));
+
+ if (event.ip_suppressed == 0)
+ {
+ pc = event.variant.init.ip;
+ aux_string += std::string (": ip = ") + hex_string (*pc);
+ }
+
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
+
+ case ptev_vmentry:
+ {
+ std::string aux_string = std::string (_("vmentry"));
+
+ if (event.ip_suppressed == 0)
+ {
+ pc = event.variant.vmentry.ip;
+ aux_string += std::string (": ip = ") + hex_string (*pc);
+ }
+
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
+
+ case ptev_vmexit:
+ {
+ std::string aux_string = std::string (_("vmexit"));
+
+ if (event.variant.vmexit.has_vector != 0
+ || event.variant.vmexit.has_vmxr != 0
+ || event.variant.vmexit.has_vmxq != 0
+ || event.ip_suppressed != 0)
+ aux_string += std::string (":");
+
+ if (event.variant.vmexit.has_vector != 0)
+ {
+ aux_string += std::string (_(" vector = "))
+ + hex_string (event.variant.vmexit.vector);
+
+ const char* decoded = decode_interrupt_vector
+ (event.variant.vmexit.vector);
+ if (decoded != nullptr)
+ aux_string += std::string (" (") + decoded + ")";
+ }
+
+ if (event.variant.vmexit.has_vmxr != 0)
+ {
+ std::string seperator = aux_string.back () == ':' ? "" : ",";
+ aux_string += seperator + std::string (" vmxr = ")
+ + hex_string (event.variant.vmexit.vmxr);
+ }
+
+ if (event.variant.vmexit.has_vmxq != 0)
+ {
+ std::string seperator = aux_string.back () == ':' ? "" : ",";
+ aux_string += seperator + std::string (" vmxq = ")
+ + hex_string (event.variant.vmexit.vmxq);
+ }
+
+ if (event.ip_suppressed == 0)
+ {
+ pc = event.variant.vmexit.ip;
+ std::string seperator = aux_string.back () == ':' ? "" : ",";
+ aux_string += seperator + std::string (" ip = ")
+ + hex_string (*pc);
+ }
+
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
+
+ case ptev_shutdown:
+ {
+ std::string aux_string = std::string (_("shutdown"));
+
+ if (event.ip_suppressed == 0)
+ {
+ pc = event.variant.shutdown.ip;
+ aux_string += std::string (": ip = ") + hex_string (*pc);
+ }
+
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
+
+ case ptev_uintr:
+ {
+ std::string aux_string = std::string (_("uintr: vector = "))
+ + hex_string (event.variant.uintr.vector);
+
+ if (event.ip_suppressed == 0)
+ {
+ pc = event.variant.uintr.ip;
+ aux_string += std::string (", ip = ") + hex_string (*pc);
+ }
+
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
+
+ case ptev_uiret:
+ {
+ std::string aux_string = std::string (_("uiret"));
+
+ if (event.ip_suppressed == 0)
+ {
+ pc = event.variant.uiret.ip;
+ aux_string += std::string (": ip = ") + hex_string (*pc);
+ }
+
+ handle_pt_aux_insn (btinfo, aux_string, pc);
+ break;
+ }
+#endif /* defined (LIBIPT_VERSION >= 0x201) */
}
}
#endif /* defined (HAVE_PT_INSN_EVENT) */
@@ -1359,7 +1624,7 @@ handle_pt_insn_event_flags (struct btrace_thread_info *btinfo,
struct btrace_function *bfun;
uint64_t offset;
- bfun = ftrace_new_gap (btinfo, BDE_PT_DISABLED, gaps);
+ bfun = ftrace_new_gap (btinfo, BDE_PT_NON_CONTIGUOUS, gaps);
pt_insn_get_offset (decoder, &offset);
@@ -1428,7 +1693,9 @@ ftrace_add_pt (struct btrace_thread_info *btinfo,
/* Handle events indicated by flags in INSN. */
handle_pt_insn_event_flags (btinfo, decoder, insn, gaps);
- bfun = ftrace_update_function (btinfo, insn.ip);
+ bfun
+ = ftrace_update_function (btinfo,
+ std::make_optional<CORE_ADDR> (insn.ip));
/* Maintain the function level offset. */
*plevel = std::min (*plevel, bfun->level);
@@ -1966,8 +2233,8 @@ btrace_decode_error (enum btrace_format format, int errcode)
case BDE_PT_USER_QUIT:
return _("trace decode cancelled");
- case BDE_PT_DISABLED:
- return _("disabled");
+ case BDE_PT_NON_CONTIGUOUS:
+ return _("non-contiguous");
case BDE_PT_OVERFLOW:
return _("overflow");
@@ -2746,6 +3013,19 @@ pt_print_packet (const struct pt_packet *packet)
packet->payload.ptw.ip ? (" ip") : (""));
break;
#endif /* defined (LIBIPT_VERSION >= 0x200) */
+
+#if (LIBIPT_VERSION >= 0x201)
+ case ppt_cfe:
+ gdb_printf (("cfe %u: 0x%x%s"), packet->payload.cfe.type,
+ packet->payload.cfe.vector,
+ packet->payload.cfe.ip ? (" ip") : (""));
+ break;
+
+ case ppt_evd:
+ gdb_printf (("evd %u: 0x%" PRIx64 ""), packet->payload.evd.type,
+ packet->payload.evd.payload);
+ break;
+#endif /* defined (LIBIPT_VERSION >= 0x201) */
}
}
diff --git a/gdb/btrace.h b/gdb/btrace.h
index 75bc4f8..a4960f3 100644
--- a/gdb/btrace.h
+++ b/gdb/btrace.h
@@ -110,7 +110,11 @@ enum btrace_function_flag
/* Indicates that at least one auxiliary instruction is in the current
function segment. */
- BFUN_CONTAINS_AUX = (1 << 2)
+ BFUN_CONTAINS_AUX = (1 << 2),
+
+ /* Indicates that at least one instruction not of type BTRACE_INSN_AUX
+ is in the current function segment. */
+ BFUN_CONTAINS_NON_AUX = (1 << 3)
};
DEF_ENUM_FLAGS_TYPE (enum btrace_function_flag, btrace_function_flags);
@@ -131,7 +135,7 @@ enum btrace_pt_error
BDE_PT_USER_QUIT = 1,
/* Tracing was temporarily disabled. */
- BDE_PT_DISABLED,
+ BDE_PT_NON_CONTIGUOUS,
/* Trace recording overflowed. */
BDE_PT_OVERFLOW
@@ -356,7 +360,7 @@ struct btrace_thread_info
/* Function pointer to the ptwrite callback. Returns the string returned
by the ptwrite filter function. */
std::optional<std::string> (*ptw_callback_fun) (const uint64_t payload,
- const uint64_t ip,
+ std::optional<uint64_t> ip,
const void *ptw_context)
= nullptr;
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index ca411dc..645cb59 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -3087,10 +3087,8 @@ classify_name (struct parser_state *par_state, const struct block *block,
|| is_quoted_name)
{
/* See if it's a file name. */
- struct symtab *symtab;
-
- symtab = lookup_symtab (copy.c_str ());
- if (symtab)
+ if (auto symtab = lookup_symtab (current_program_space, copy.c_str ());
+ symtab != nullptr)
{
yylval.bval
= symtab->compunit ()->blockvector ()->static_block ();
diff --git a/gdb/cli-out.c b/gdb/cli-out.c
index 1c303f0..d8a542d 100644
--- a/gdb/cli-out.c
+++ b/gdb/cli-out.c
@@ -94,13 +94,14 @@ cli_ui_out::do_end (ui_out_type type)
void
cli_ui_out::do_field_signed (int fldno, int width, ui_align alignment,
- const char *fldname, LONGEST value)
+ const char *fldname, LONGEST value,
+ const ui_file_style &style)
{
if (m_suppress_output)
return;
do_field_string (fldno, width, alignment, fldname, plongest (value),
- ui_file_style ());
+ style);
}
/* output an unsigned field */
diff --git a/gdb/cli-out.h b/gdb/cli-out.h
index f17cb0c..f0654b2 100644
--- a/gdb/cli-out.h
+++ b/gdb/cli-out.h
@@ -52,7 +52,8 @@ protected:
virtual void do_begin (ui_out_type type, const char *id) override;
virtual void do_end (ui_out_type type) override;
virtual void do_field_signed (int fldno, int width, ui_align align,
- const char *fldname, LONGEST value) override;
+ const char *fldname, LONGEST value,
+ const ui_file_style &style) override;
virtual void do_field_unsigned (int fldno, int width, ui_align align,
const char *fldname, ULONGEST value)
override;
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index fd8e277..ea2e156 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -51,7 +51,6 @@
#include "cli/cli-cmds.h"
#include "cli/cli-style.h"
#include "cli/cli-utils.h"
-#include "cli/cli-style.h"
#include "extension.h"
#include "gdbsupport/pathstuff.h"
@@ -1017,16 +1016,23 @@ edit_command (const char *arg, int from_tty)
gdbarch = sal.symtab->compunit ()->objfile ()->arch ();
sym = find_pc_function (sal.pc);
if (sym)
- gdb_printf ("%s is in %s (%s:%d).\n",
- paddress (gdbarch, sal.pc),
- sym->print_name (),
- symtab_to_filename_for_display (sal.symtab),
- sal.line);
+ gdb_printf ("%ps is in %ps (%ps:%ps).\n",
+ styled_string (address_style.style (),
+ paddress (gdbarch, sal.pc)),
+ styled_string (function_name_style.style (),
+ sym->print_name ()),
+ styled_string (file_name_style.style (),
+ symtab_to_filename_for_display (sal.symtab)),
+ styled_string (line_number_style.style (),
+ pulongest (sal.line)));
else
- gdb_printf ("%s is at %s:%d.\n",
- paddress (gdbarch, sal.pc),
- symtab_to_filename_for_display (sal.symtab),
- sal.line);
+ gdb_printf ("%ps is at %ps:%ps.\n",
+ styled_string (address_style.style (),
+ paddress (gdbarch, sal.pc)),
+ styled_string (file_name_style.style (),
+ symtab_to_filename_for_display (sal.symtab)),
+ styled_string (line_number_style.style (),
+ pulongest (sal.line)));
}
/* If what was given does not imply a symtab, it must be an
@@ -1118,19 +1124,14 @@ pipe_command (const char *arg, int from_tty)
if (to_shell_command == nullptr)
error (_("Error launching \"%s\""), shell_command);
- try
- {
- stdio_file pipe_file (to_shell_command);
+ int exit_status;
+ {
+ SCOPE_EXIT { exit_status = pclose (to_shell_command); };
- execute_command_to_ui_file (&pipe_file, gdb_cmd.c_str (), from_tty);
- }
- catch (...)
- {
- pclose (to_shell_command);
- throw;
- }
+ stdio_file pipe_file (to_shell_command);
- int exit_status = pclose (to_shell_command);
+ execute_command_to_ui_file (&pipe_file, gdb_cmd.c_str (), from_tty);
+ }
if (exit_status < 0)
error (_("shell command \"%s\" failed: %s"), shell_command,
@@ -2122,9 +2123,11 @@ print_sal_location (const symtab_and_line &sal)
const char *sym_name = NULL;
if (sal.symbol != NULL)
sym_name = sal.symbol->print_name ();
- gdb_printf (_("file: \"%s\", line number: %d, symbol: \"%s\"\n"),
+ gdb_printf (_("file: \"%s\", line number: %ps, symbol: \"%s\"\n"),
symtab_to_filename_for_display (sal.symtab),
- sal.line, sym_name != NULL ? sym_name : "???");
+ styled_string (line_number_style.style (),
+ pulongest (sal.line)),
+ sym_name != NULL ? sym_name : "???");
}
/* Print a list of files and line numbers which a user may choose from
diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c
index fa5d70e..1817573 100644
--- a/gdb/cli/cli-interp.c
+++ b/gdb/cli/cli-interp.c
@@ -228,7 +228,7 @@ cli_interp::exec (const char *command_str)
interpreter which has a new ui_file for gdb_stdout, use that one
instead of the default.
- It is important that it gets reset everytime, since the user
+ It is important that it gets reset every time, since the user
could set gdb to use a different interpreter. */
ui_file *old_stream = m_cli_uiout->set_stream (gdb_stdout);
SCOPE_EXIT { m_cli_uiout->set_stream (old_stream); };
diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c
index 5928998..36a8bd9 100644
--- a/gdb/cli/cli-style.c
+++ b/gdb/cli/cli-style.c
@@ -126,6 +126,10 @@ cli_style_option disasm_comment_style ("comment", ui_file_style::WHITE,
/* See cli-style.h. */
+cli_style_option line_number_style ("line-number", ui_file_style::DIM);
+
+/* See cli-style.h. */
+
cli_style_option::cli_style_option (const char *name,
ui_file_style::basic_color fg,
ui_file_style::intensity intensity)
@@ -529,6 +533,14 @@ then this style has no effect."),
&style_disasm_show_list,
false);
+ line_number_style.add_setshow_commands (no_class, _("\
+Line number display styling.\n\
+Configure colors and display intensity for line numbers\n\
+The \"line-number\" style is used when GDB displays line numbers\n\
+coming from your source code."),
+ &style_set_list, &style_show_list,
+ false);
+
/* Setup 'disassembler address' style and 'disassembler symbol' style,
these are aliases for 'address' and 'function' styles respectively. */
add_alias_cmd ("address", address_prefix_cmds.set, no_class, 0,
diff --git a/gdb/cli/cli-style.h b/gdb/cli/cli-style.h
index 1663b4e..5052b86 100644
--- a/gdb/cli/cli-style.h
+++ b/gdb/cli/cli-style.h
@@ -145,6 +145,9 @@ extern cli_style_option tui_active_border_style;
/* The style to use for the GDB version string. */
extern cli_style_option version_style;
+/* The style for a line number. */
+extern cli_style_option line_number_style;
+
/* True if source styling is enabled. */
extern bool source_styling;
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 3e67ebd..abe150d 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -37,6 +37,7 @@
#include "block.h"
#include "dictionary.h"
#include "dwarf2/public.h"
+#include "gdb-stabs.h"
#include "coff-pe-read.h"
@@ -121,7 +122,7 @@ static unsigned local_auxesz;
static int pe_file;
/* Chain of typedefs of pointers to empty struct/union types.
- They are chained thru the SYMBOL_VALUE_CHAIN. */
+ They are chained through the SYMBOL_VALUE_CHAIN. */
static struct symbol *opaque_type_chain[HASHSIZE];
@@ -204,6 +205,98 @@ static void read_one_sym (struct coff_symbol *,
static void coff_symtab_read (minimal_symbol_reader &,
file_ptr, unsigned int, struct objfile *);
+/* Scan and build partial symbols for an coff symbol file.
+ The coff file has already been processed to get its minimal symbols.
+
+ This routine is the equivalent of dbx_symfile_init and dbx_symfile_read
+ rolled into one.
+
+ OBJFILE is the object file we are reading symbols from.
+ ADDR is the address relative to which the symbols are (e.g.
+ the base address of the text segment).
+ TEXTADDR is the address of the text section.
+ TEXTSIZE is the size of the text section.
+ STABSECTS is the list of .stab sections in OBJFILE.
+ STABSTROFFSET and STABSTRSIZE define the location in OBJFILE where the
+ .stabstr section exists.
+
+ This routine is mostly copied from dbx_symfile_init and dbx_symfile_read,
+ adjusted for coff details. */
+
+void
+coffstab_build_psymtabs (struct objfile *objfile,
+ CORE_ADDR textaddr, unsigned int textsize,
+ const std::vector<asection *> &stabsects,
+ file_ptr stabstroffset, unsigned int stabstrsize)
+{
+ int val;
+ bfd *sym_bfd = objfile->obfd.get ();
+ const char *name = bfd_get_filename (sym_bfd);
+ unsigned int stabsize;
+
+ /* Allocate struct to keep track of stab reading. */
+ dbx_objfile_data_key.emplace (objfile);
+ dbx_symfile_info *key = dbx_objfile_data_key.get (objfile);
+
+ DBX_TEXT_ADDR (objfile) = textaddr;
+ DBX_TEXT_SIZE (objfile) = textsize;
+
+#define COFF_STABS_SYMBOL_SIZE 12 /* XXX FIXME XXX */
+ DBX_SYMBOL_SIZE (objfile) = COFF_STABS_SYMBOL_SIZE;
+ DBX_STRINGTAB_SIZE (objfile) = stabstrsize;
+
+ if (stabstrsize > bfd_get_size (sym_bfd))
+ error (_("ridiculous string table size: %d bytes"), stabstrsize);
+ DBX_STRINGTAB (objfile) = (char *)
+ obstack_alloc (&objfile->objfile_obstack, stabstrsize + 1);
+ OBJSTAT (objfile, sz_strtab += stabstrsize + 1);
+
+ /* Now read in the string table in one big gulp. */
+
+ val = bfd_seek (sym_bfd, stabstroffset, SEEK_SET);
+ if (val < 0)
+ perror_with_name (name);
+ val = bfd_read (DBX_STRINGTAB (objfile), stabstrsize, sym_bfd);
+ if (val != stabstrsize)
+ perror_with_name (name);
+
+ stabsread_new_init ();
+ free_header_files ();
+ init_header_files ();
+
+ key->ctx.processing_acc_compilation = 1;
+
+ /* In a coff file, we've already installed the minimal symbols that came
+ from the coff (non-stab) symbol table, so always act like an
+ incremental load here. */
+ scoped_restore save_symbuf_sections
+ = make_scoped_restore (&key->ctx.symbuf_sections);
+ if (stabsects.size () == 1)
+ {
+ stabsize = bfd_section_size (stabsects[0]);
+ DBX_SYMCOUNT (objfile) = stabsize / DBX_SYMBOL_SIZE (objfile);
+ DBX_SYMTAB_OFFSET (objfile) = stabsects[0]->filepos;
+ }
+ else
+ {
+ DBX_SYMCOUNT (objfile) = 0;
+ for (asection *section : stabsects)
+ {
+ stabsize = bfd_section_size (section);
+ DBX_SYMCOUNT (objfile) += stabsize / DBX_SYMBOL_SIZE (objfile);
+ }
+
+ DBX_SYMTAB_OFFSET (objfile) = stabsects[0]->filepos;
+
+ key->ctx.sect_idx = 1;
+ key->ctx.symbuf_sections = &stabsects;
+ key->ctx.symbuf_left = bfd_section_size (stabsects[0]);
+ key->ctx.symbuf_read = 0;
+ }
+
+ read_stabs_symtab (objfile, 0);
+}
+
/* We are called once per section from coff_symfile_read. We
need to examine each section we are passed, check to see
if it is something we are interested in processing, and
@@ -1644,7 +1737,7 @@ process_coff_symbol (struct coff_symbol *cs,
This is not just a consequence of GDB's type
management; CC and GCC (at least through version
2.4) both output variables of either type char *
- or caddr_t with the type refering to the C_TPDEF
+ or caddr_t with the type referring to the C_TPDEF
symbol for caddr_t. If a future compiler cleans
this up it GDB is not ready for it yet, but if it
becomes ready we somehow need to disable this
diff --git a/gdb/completer.c b/gdb/completer.c
index e8f5e7b..4735aa5 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -31,6 +31,7 @@
#include "linespec.h"
#include "cli/cli-decode.h"
#include "gdbsupport/gdb_tilde_expand.h"
+#include "readline/readline.h"
/* FIXME: This is needed because of lookup_cmd_1 (). We should be
calling a hook instead so we eliminate the CLI dependency. */
@@ -258,7 +259,7 @@ gdb_completer_file_name_char_is_quoted (char *string, int eindex)
as quoted, though this might not be completely correct; the
opening and closing quotes are not themselves quoted. But so
far this doesn't seem to have caused any issues. */
- if (i >= eindex)
+ if (i > eindex)
return 1;
}
else
@@ -393,13 +394,34 @@ gdb_completer_file_name_quote_1 (const char *text, char quote_char)
the quote character surrounding TEXT, or points to the null-character if
there are no quotes around TEXT. MATCH_TYPE will be one of the readline
constants SINGLE_MATCH or MULTI_MATCH depending on if there is one or
- many completions. */
+ many completions.
+
+ We also add a trailing character, either a '/' of closing quote, if
+ MATCH_TYPE is 'SINGLE_MATCH'. We do this because readline will only
+ add this trailing character when completing at the end of a line. */
static char *
-gdb_completer_file_name_quote (char *text, int match_type ATTRIBUTE_UNUSED,
- char *quote_ptr)
+gdb_completer_file_name_quote (char *text, int match_type, char *quote_ptr)
{
- return gdb_completer_file_name_quote_1 (text, *quote_ptr);
+ char *result = gdb_completer_file_name_quote_1 (text, *quote_ptr);
+
+ if (match_type == SINGLE_MATCH)
+ {
+ /* Add trailing '/' if TEXT is a directory, otherwise add a closing
+ quote character matching *QUOTE_PTR. */
+ char c = (gdb_path_isdir (gdb_tilde_expand (text).c_str ())
+ ? '/' : *quote_ptr);
+
+ /* Reallocate RESULT adding C to the end. But only if C is
+ interesting, otherwise we can save the reallocation. */
+ if (c != '\0')
+ {
+ char buf[2] = { c, '\0' };
+ result = reconcat (result, result, buf, nullptr);
+ }
+ }
+
+ return result;
}
/* The function is used to update the completion word MATCH before
diff --git a/gdb/config.in b/gdb/config.in
index 57be033..59a5da3 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -46,6 +46,9 @@
language is requested. */
#undef ENABLE_NLS
+/* Additional targets configured into GDB. */
+#undef ENABLE_TARGETS
+
/* The .gdbearlyinit filename. */
#undef GDBEARLYINIT
diff --git a/gdb/configure b/gdb/configure
index 53eaad4..ec9bbd3 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -24828,11 +24828,19 @@ if test "${enable_targets+set}" = set; then :
yes | "") as_fn_error $? "enable-targets option must specify target names or 'all'" "$LINENO" 5
;;
no) enable_targets= ;;
- *) enable_targets=$enableval ;;
+ *)
+ enable_targets=$enableval
+
+cat >>confdefs.h <<_ACEOF
+#define ENABLE_TARGETS "$enable_targets"
+_ACEOF
+
+ ;;
esac
fi
+
# Check whether --enable-64-bit-bfd was given.
if test "${enable_64_bit_bfd+set}" = set; then :
enableval=$enable_64_bit_bfd; case $enableval in #(
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 8368fea..21f5dc8 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -184,9 +184,14 @@ AS_HELP_STRING([--enable-targets=TARGETS], [alternative target configurations]),
yes | "") AC_MSG_ERROR(enable-targets option must specify target names or 'all')
;;
no) enable_targets= ;;
- *) enable_targets=$enableval ;;
+ *)
+ enable_targets=$enableval
+ AC_DEFINE_UNQUOTED(ENABLE_TARGETS, "$enable_targets",
+ Additional targets configured into GDB. )
+ ;;
esac])
+
BFD_64_BIT
# Provide defaults for some variables set by the per-host and per-target
diff --git a/gdb/contrib/ari/gdb_ari.sh b/gdb/contrib/ari/gdb_ari.sh
index d690d29..5ed7d61 100755
--- a/gdb/contrib/ari/gdb_ari.sh
+++ b/gdb/contrib/ari/gdb_ari.sh
@@ -243,7 +243,7 @@ END {
if (seen[file] && (skipped[bug_n_file] < skip[bug_n_file])) {
# ari.*.bug: <FILE>:<LINE>: <CATEGORY>: <BUG>: <DOC>
b = file " missing " bug
- print_bug(file, 0, "", "internal", file " missing " bug, "Expecting " skip[bug_n_file] " occurances of bug " bug " in file " file ", only found " skipped[bug_n_file])
+ print_bug(file, 0, "", "internal", file " missing " bug, "Expecting " skip[bug_n_file] " occurrences of bug " bug " in file " file ", only found " skipped[bug_n_file])
}
}
}
diff --git a/gdb/contrib/common-misspellings.txt b/gdb/contrib/common-misspellings.txt
new file mode 100644
index 0000000..62e2c51
--- /dev/null
+++ b/gdb/contrib/common-misspellings.txt
@@ -0,0 +1,18 @@
+# Copyright (C) 2024 Free Software Foundation, Inc.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Common spelling mistakes.
+
+inbetween->between, in between, in-between
+sofar->so far
diff --git a/gdb/contrib/spellcheck.sh b/gdb/contrib/spellcheck.sh
new file mode 100755
index 0000000..4203333
--- /dev/null
+++ b/gdb/contrib/spellcheck.sh
@@ -0,0 +1,353 @@
+#!/bin/bash
+
+# Copyright (C) 2024 Free Software Foundation, Inc.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Script to auto-correct common spelling mistakes.
+#
+# Example usage:
+# $ ./gdb/contrib/spellcheck.sh gdb*
+
+scriptdir=$(cd "$(dirname "$0")" || exit; pwd -P)
+
+url=https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines
+cache_dir=$scriptdir/../../.git
+cache_file=wikipedia-common-misspellings.txt
+dictionary=$cache_dir/$cache_file
+local_dictionary=$scriptdir/common-misspellings.txt
+
+# Separators: space, slash, tab, colon, comma.
+declare -a grep_separators
+grep_separators=(
+ " "
+ "/"
+ " "
+ ":"
+ ","
+)
+declare -a sed_separators
+sed_separators=(
+ " "
+ "/"
+ "\t"
+ ":"
+ ","
+)
+
+join ()
+{
+ local or
+ or="$1"
+ shift
+
+ local res
+ res=""
+
+ local first
+ first=true
+
+ for item in "$@"; do
+ if $first; then
+ first=false
+ res="$item"
+ else
+ res="$res$or$item"
+ fi
+ done
+
+ echo "$res"
+}
+
+grep_or="|"
+sed_or="\|"
+grep_separator=$(join $grep_or "${grep_separators[@]}")
+sed_separator=$(join $sed_or "${sed_separators[@]}")
+
+usage ()
+{
+ echo "usage: $(basename "$0") <file|dir>+"
+}
+
+make_absolute ()
+{
+ local arg
+ arg="$1"
+
+ case "$arg" in
+ /*)
+ ;;
+ *)
+ arg=$(pwd -P)/"$arg"
+ ;;
+ esac
+
+ echo "$arg"
+}
+
+parse_args ()
+{
+ local files
+ files=$(mktemp)
+ trap 'rm -f "$files"' EXIT
+
+ if [ $# -eq -0 ]; then
+ usage
+ exit 1
+ fi
+
+ local arg
+ for arg in "$@"; do
+ if [ -f "$arg" ]; then
+ arg=$(make_absolute "$arg")
+ readlink -e "$arg" \
+ >> "$files"
+ elif [ -d "$arg" ]; then
+ arg=$(make_absolute "$arg")
+ local f
+ find "$arg" -type f -exec readlink -e {} \; \
+ >> "$files"
+ else
+ echo "Not a file or directory: $arg"
+ exit 1
+ fi
+ done
+
+ mapfile -t unique_files \
+ < <(sort -u "$files" \
+ | grep -v ChangeLog)
+
+ rm -f "$files"
+ trap "" EXIT
+}
+
+get_dictionary ()
+{
+ if [ -f "$dictionary" ]; then
+ return
+ fi
+
+ local webpage
+ webpage=$(mktemp)
+ trap 'rm -f "$webpage"' EXIT
+
+ # Download web page containing table.
+ wget $url -O "$webpage"
+
+ # Extract table from web page.
+ awk '/<pre>/,/<\/pre>/' "$webpage" \
+ | sed 's/<pre>//;s/<\/pre>//' \
+ | grep -E -v "^$" \
+ > "$dictionary"
+
+ rm -f "$webpage"
+ trap "" EXIT
+}
+
+output_local_dictionary ()
+{
+ # Filter out comments and empty lines.
+ grep -E -v \
+ "^#|^$" \
+ "$local_dictionary"
+}
+
+output_dictionaries ()
+{
+ output_local_dictionary
+ cat "$dictionary"
+}
+
+parse_dictionary ()
+{
+ # Parse dictionary.
+ mapfile -t words \
+ < <(awk -F '->' '{print $1}' <(output_dictionaries))
+ mapfile -t replacements \
+ < <(awk -F '->' '{print $2}' <(output_dictionaries))
+}
+
+find_files_matching_words ()
+{
+ local pat
+ pat=""
+ for word in "${words[@]}"; do
+ if [ "$pat" = "" ]; then
+ pat="$word"
+ else
+ pat="$pat|$word"
+ fi
+ done
+ pat="($pat)"
+
+ local sep
+ sep=$grep_separator
+
+ pat="(^|$sep)$pat($sep|$)"
+
+ grep -E \
+ -l \
+ "$pat" \
+ "$@"
+}
+
+find_files_matching_word ()
+{
+ local pat
+ pat="$1"
+ shift
+
+ local sep
+ sep=$grep_separator
+
+ pat="(^|$sep)$pat($sep|$)"
+
+ grep -E \
+ -l \
+ "$pat" \
+ "$@"
+}
+
+replace_word_in_file ()
+{
+ local word
+ word="$1"
+
+ local replacement
+ replacement="$2"
+
+ local file
+ file="$3"
+
+ local sep
+ sep=$sed_separator
+
+ # Save separator.
+ sep="\($sep\)"
+
+ local repl1 repl2 repl3
+
+ repl1="s%$sep$word$sep%\1$replacement\2%g"
+
+ repl2="s%^$word$sep%$replacement\1%"
+
+ repl3="s%$sep$word$%\1$replacement%"
+
+ sed -i \
+ "$repl1;$repl2;$repl3" \
+ "$file"
+}
+
+replace_word_in_files ()
+{
+ local word
+ word="$1"
+
+ local replacement
+ replacement="$2"
+
+ shift 2
+
+ local id
+ id="$word -> $replacement"
+
+ # Reduce set of files for sed to operate on.
+ local files_matching_word
+ declare -a files_matching_word
+ mapfile -t files_matching_word \
+ < <(find_files_matching_word "$word" "$@")
+
+ if [ ${#files_matching_word[@]} -eq 0 ]; then
+ return
+ fi
+
+ if echo "$replacement"| grep -q ","; then
+ echo "TODO: $id"
+ return
+ fi
+
+ declare -A md5sums
+
+ local changed f before after
+ changed=false
+ for f in "${files_matching_word[@]}"; do
+ if [ "${md5sums[$f]}" = "" ]; then
+ md5sums[$f]=$(md5sum "$f")
+ fi
+
+ before="${md5sums[$f]}"
+
+ replace_word_in_file \
+ "$word" \
+ "$replacement" \
+ "$f"
+
+ after=$(md5sum "$f")
+
+ if [ "$after" != "$before" ]; then
+ md5sums[$f]="$after"
+ changed=true
+ fi
+ done
+
+ if $changed; then
+ echo "$id"
+ fi
+
+ find_files_matching_word "$word" "${files_matching_word[@]}" \
+ | awk "{ printf \"TODO: $id: replacement failed: %s\n\", \$0}"
+}
+
+main ()
+{
+ declare -a unique_files
+ parse_args "$@"
+
+ get_dictionary
+
+ declare -a words
+ declare -a replacements
+ parse_dictionary
+
+ # Reduce set of files for sed to operate on.
+ local files_matching_words
+ declare -a files_matching_words
+ mapfile -t files_matching_words \
+ < <(find_files_matching_words "${unique_files[@]}")
+
+ if [ ${#files_matching_words[@]} -eq 0 ]; then
+ return
+ fi
+
+ declare -A words_done
+ local i word replacement
+ i=0
+ for word in "${words[@]}"; do
+ replacement=${replacements[$i]}
+ i=$((i + 1))
+
+ # Skip words that are already handled. This ensures that the local
+ # dictionary overrides the wiki dictionary.
+ if [ "${words_done[$word]}" == 1 ]; then
+ continue
+ fi
+ words_done[$word]=1
+
+ replace_word_in_files \
+ "$word" \
+ "$replacement" \
+ "${files_matching_words[@]}"
+ done
+}
+
+main "$@"
diff --git a/gdb/corelow.c b/gdb/corelow.c
index ab2fa74..5820ffe 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -1698,24 +1698,19 @@ get_current_core_target ()
void
core_target::info_proc_mappings (struct gdbarch *gdbarch)
{
- if (!m_core_file_mappings.empty ())
- {
- gdb_printf (_("Mapped address spaces:\n\n"));
- if (gdbarch_addr_bit (gdbarch) == 32)
- {
- gdb_printf ("\t%10s %10s %10s %10s %s\n",
- "Start Addr",
- " End Addr",
- " Size", " Offset", "objfile");
- }
- else
- {
- gdb_printf (" %18s %18s %10s %10s %s\n",
- "Start Addr",
- " End Addr",
- " Size", " Offset", "objfile");
- }
- }
+ if (m_core_file_mappings.empty ())
+ return;
+
+ gdb_printf (_("Mapped address spaces:\n\n"));
+ ui_out_emit_table emitter (current_uiout, 5, -1, "ProcMappings");
+
+ int width = gdbarch_addr_bit (gdbarch) == 32 ? 10 : 18;
+ current_uiout->table_header (width, ui_left, "start", "Start Addr");
+ current_uiout->table_header (width, ui_left, "end", "End Addr");
+ current_uiout->table_header (width, ui_left, "size", "Size");
+ current_uiout->table_header (width, ui_left, "offset", "Offset");
+ current_uiout->table_header (0, ui_left, "objfile", "File");
+ current_uiout->table_body ();
for (const target_section &tsp : m_core_file_mappings)
{
@@ -1724,20 +1719,16 @@ core_target::info_proc_mappings (struct gdbarch *gdbarch)
ULONGEST file_ofs = tsp.the_bfd_section->filepos;
const char *filename = bfd_get_filename (tsp.the_bfd_section->owner);
- if (gdbarch_addr_bit (gdbarch) == 32)
- gdb_printf ("\t%10s %10s %10s %10s %s\n",
- paddress (gdbarch, start),
- paddress (gdbarch, end),
- hex_string (end - start),
- hex_string (file_ofs),
- filename);
- else
- gdb_printf (" %18s %18s %10s %10s %s\n",
- paddress (gdbarch, start),
- paddress (gdbarch, end),
- hex_string (end - start),
- hex_string (file_ofs),
- filename);
+ ui_out_emit_tuple tuple_emitter (current_uiout, nullptr);
+ current_uiout->field_core_addr ("start", gdbarch, start);
+ current_uiout->field_core_addr ("end", gdbarch, end);
+ /* These next two aren't really addresses and so shouldn't be
+ styled as such. */
+ current_uiout->field_string ("size", paddress (gdbarch, end - start));
+ current_uiout->field_string ("offset", paddress (gdbarch, file_ofs));
+ current_uiout->field_string ("objfile", filename,
+ file_name_style.style ());
+ current_uiout->text ("\n");
}
}
diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index 769b930..8562def 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -3339,7 +3339,7 @@ get_data_from_address (unsigned short *inst, CORE_ADDR address,
return value;
}
-/* Handles the assign addresing mode for the ADD, SUB, CMP, AND, OR and MOVE
+/* Handles the assign addressing mode for the ADD, SUB, CMP, AND, OR and MOVE
instructions. The MOVE instruction is the move from source to register. */
static void
@@ -3398,7 +3398,7 @@ three_operand_add_sub_cmp_and_or_op (unsigned short inst,
inst_env->disable_interrupt = 0;
}
-/* Handles the index addresing mode for the ADD, SUB, CMP, AND, OR and MOVE
+/* Handles the index addressing mode for the ADD, SUB, CMP, AND, OR and MOVE
instructions. The MOVE instruction is the move from source to register. */
static void
@@ -3425,7 +3425,7 @@ handle_prefix_index_mode_for_aritm_op (unsigned short inst,
inst_env->disable_interrupt = 0;
}
-/* Handles the autoincrement and indirect addresing mode for the ADD, SUB,
+/* Handles the autoincrement and indirect addressing mode for the ADD, SUB,
CMP, AND OR and MOVE instruction. The MOVE instruction is the move from
source to register. */
diff --git a/gdb/data-directory/Makefile.in b/gdb/data-directory/Makefile.in
index f9472f4..1a17d23 100644
--- a/gdb/data-directory/Makefile.in
+++ b/gdb/data-directory/Makefile.in
@@ -120,8 +120,7 @@ PYTHON_FILE_LIST = \
gdb/function/as_string.py \
gdb/function/caller_is.py \
gdb/function/strfns.py \
- gdb/printer/__init__.py \
- gdb/printer/bound_registers.py
+ gdb/printer/__init__.py
@HAVE_PYTHON_TRUE@PYTHON_FILES = $(PYTHON_FILE_LIST)
@HAVE_PYTHON_FALSE@PYTHON_FILES =
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 31eb51f..1b29d6e 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -54,228 +54,15 @@
#include "aout/aout64.h"
#include "aout/stab_gnu.h"
+/* Required for the following registry. */
+#include "gdb-stabs.h"
-/* Key for dbx-associated data. */
-
-const registry<objfile>::key<dbx_symfile_info> dbx_objfile_data_key;
-
-/* We put a pointer to this structure in the read_symtab_private field
- of the psymtab. */
-
-struct symloc
- {
- /* Offset within the file symbol table of first local symbol for this
- file. */
-
- int ldsymoff;
-
- /* Length (in bytes) of the section of the symbol table devoted to
- this file's symbols (actually, the section bracketed may contain
- more than just this file's symbols). If ldsymlen is 0, the only
- reason for this thing's existence is the dependency list. Nothing
- else will happen when it is read in. */
-
- int ldsymlen;
-
- /* The size of each symbol in the symbol file (in external form). */
-
- int symbol_size;
-
- /* Further information needed to locate the symbols if they are in
- an ELF file. */
-
- int symbol_offset;
- int string_offset;
- int file_string_offset;
- enum language pst_language;
- };
-
-#define LDSYMOFF(p) (((struct symloc *)((p)->read_symtab_private))->ldsymoff)
-#define LDSYMLEN(p) (((struct symloc *)((p)->read_symtab_private))->ldsymlen)
-#define SYMLOC(p) ((struct symloc *)((p)->read_symtab_private))
-#define SYMBOL_SIZE(p) (SYMLOC(p)->symbol_size)
-#define SYMBOL_OFFSET(p) (SYMLOC(p)->symbol_offset)
-#define STRING_OFFSET(p) (SYMLOC(p)->string_offset)
-#define FILE_STRING_OFFSET(p) (SYMLOC(p)->file_string_offset)
-#define PST_LANGUAGE(p) (SYMLOC(p)->pst_language)
-
-/* The objfile we are currently reading. */
-
-static struct objfile *dbxread_objfile;
-
-/* Remember what we deduced to be the source language of this psymtab. */
-
-static enum language psymtab_language = language_unknown;
-
-/* The BFD for this file -- implicit parameter to next_symbol_text. */
-
-static bfd *symfile_bfd;
-
-/* The size of each symbol in the symbol file (in external form).
- This is set by dbx_symfile_read when building psymtabs, and by
- dbx_psymtab_to_symtab when building symtabs. */
-
-static unsigned symbol_size;
-
-/* This is the offset of the symbol table in the executable file. */
-
-static unsigned symbol_table_offset;
-
-/* This is the offset of the string table in the executable file. */
-
-static unsigned string_table_offset;
-
-/* For elf+stab executables, the n_strx field is not a simple index
- into the string table. Instead, each .o file has a base offset in
- the string table, and the associated symbols contain offsets from
- this base. The following two variables contain the base offset for
- the current and next .o files. */
-
-static unsigned int file_string_table_offset;
-static unsigned int next_file_string_table_offset;
-
-/* .o and NLM files contain unrelocated addresses which are based at
- 0. When non-zero, this flag disables some of the special cases for
- Solaris elf+stab text addresses at location 0. */
-
-static int symfile_relocatable = 0;
-
-/* When set, we are processing a .o file compiled by sun acc. This is
- misnamed; it refers to all stabs-in-elf implementations which use
- N_UNDF the way Sun does, including Solaris gcc. Hopefully all
- stabs-in-elf implementations ever invented will choose to be
- compatible. */
-
-static unsigned char processing_acc_compilation;
-
-/* The lowest text address we have yet encountered. This is needed
- because in an a.out file, there is no header field which tells us
- what address the program is actually going to be loaded at, so we
- need to make guesses based on the symbols (which *are* relocated to
- reflect the address it will be loaded at). */
-
-static unrelocated_addr lowest_text_address;
-
-/* Non-zero if there is any line number info in the objfile. Prevents
- dbx_end_psymtab from discarding an otherwise empty psymtab. */
-static int has_line_numbers;
-
-/* Complaints about the symbols we have encountered. */
-
-static void
-unknown_symtype_complaint (const char *arg1)
-{
- complaint (_("unknown symbol type %s"), arg1);
-}
-
-static void
-lbrac_mismatch_complaint (int arg1)
-{
- complaint (_("N_LBRAC/N_RBRAC symbol mismatch at symtab pos %d"), arg1);
-}
-
-static void
-repeated_header_complaint (const char *arg1, int arg2)
-{
- complaint (_("\"repeated\" header file %s not "
- "previously seen, at symtab pos %d"),
- arg1, arg2);
-}
-
-/* find_text_range --- find start and end of loadable code sections
-
- The find_text_range function finds the shortest address range that
- encloses all sections containing executable code, and stores it in
- objfile's text_addr and text_size members.
-
- dbx_symfile_read will use this to finish off the partial symbol
- table, in some cases. */
-
-static void
-find_text_range (bfd * sym_bfd, struct objfile *objfile)
-{
- asection *sec;
- int found_any = 0;
- CORE_ADDR start = 0;
- CORE_ADDR end = 0;
-
- for (sec = sym_bfd->sections; sec; sec = sec->next)
- if (bfd_section_flags (sec) & SEC_CODE)
- {
- CORE_ADDR sec_start = bfd_section_vma (sec);
- CORE_ADDR sec_end = sec_start + bfd_section_size (sec);
-
- if (found_any)
- {
- if (sec_start < start)
- start = sec_start;
- if (sec_end > end)
- end = sec_end;
- }
- else
- {
- start = sec_start;
- end = sec_end;
- }
-
- found_any = 1;
- }
-
- if (!found_any)
- error (_("Can't find any code sections in symbol file"));
-
- DBX_TEXT_ADDR (objfile) = start;
- DBX_TEXT_SIZE (objfile) = end - start;
-}
-
-
-
-/* During initial symbol readin, we need to have a structure to keep
- track of which psymtabs have which bincls in them. This structure
- is used during readin to setup the list of dependencies within each
- partial symbol table. */
-
-struct header_file_location
-{
- header_file_location (const char *name_, int instance_,
- legacy_psymtab *pst_)
- : name (name_),
- instance (instance_),
- pst (pst_)
- {
- }
-
- const char *name; /* Name of header file */
- int instance; /* See above */
- legacy_psymtab *pst; /* Partial symtab that has the
- BINCL/EINCL defs for this file. */
-};
-
-/* The list of bincls. */
-static std::vector<struct header_file_location> *bincl_list;
/* Local function prototypes. */
-static void read_ofile_symtab (struct objfile *, legacy_psymtab *);
-
-static void dbx_read_symtab (legacy_psymtab *self,
- struct objfile *objfile);
-
-static void dbx_expand_psymtab (legacy_psymtab *, struct objfile *);
-
-static void read_dbx_symtab (minimal_symbol_reader &, psymtab_storage *,
- struct objfile *);
-
-static legacy_psymtab *find_corresponding_bincl_psymtab (const char *,
- int);
-
-static const char *dbx_next_symbol_text (struct objfile *);
-
-static void fill_symbuf (bfd *);
-
static void dbx_symfile_init (struct objfile *);
static void dbx_new_init (struct objfile *);
@@ -284,128 +71,6 @@ static void dbx_symfile_read (struct objfile *, symfile_add_flags);
static void dbx_symfile_finish (struct objfile *);
-static void record_minimal_symbol (minimal_symbol_reader &,
- const char *, unrelocated_addr, int,
- struct objfile *);
-
-static void add_new_header_file (const char *, int);
-
-static void add_old_header_file (const char *, int);
-
-static void add_this_object_header_file (int);
-
-static legacy_psymtab *start_psymtab (psymtab_storage *, struct objfile *,
- const char *, unrelocated_addr, int);
-
-/* Free up old header file tables. */
-
-void
-free_header_files (void)
-{
- if (this_object_header_files)
- {
- xfree (this_object_header_files);
- this_object_header_files = NULL;
- }
- n_allocated_this_object_header_files = 0;
-}
-
-/* Allocate new header file tables. */
-
-void
-init_header_files (void)
-{
- n_allocated_this_object_header_files = 10;
- this_object_header_files = XNEWVEC (int, 10);
-}
-
-/* Add header file number I for this object file
- at the next successive FILENUM. */
-
-static void
-add_this_object_header_file (int i)
-{
- if (n_this_object_header_files == n_allocated_this_object_header_files)
- {
- n_allocated_this_object_header_files *= 2;
- this_object_header_files
- = (int *) xrealloc ((char *) this_object_header_files,
- n_allocated_this_object_header_files * sizeof (int));
- }
-
- this_object_header_files[n_this_object_header_files++] = i;
-}
-
-/* Add to this file an "old" header file, one already seen in
- a previous object file. NAME is the header file's name.
- INSTANCE is its instance code, to select among multiple
- symbol tables for the same header file. */
-
-static void
-add_old_header_file (const char *name, int instance)
-{
- struct header_file *p = HEADER_FILES (dbxread_objfile);
- int i;
-
- for (i = 0; i < N_HEADER_FILES (dbxread_objfile); i++)
- if (filename_cmp (p[i].name, name) == 0 && instance == p[i].instance)
- {
- add_this_object_header_file (i);
- return;
- }
- repeated_header_complaint (name, symnum);
-}
-
-/* Add to this file a "new" header file: definitions for its types follow.
- NAME is the header file's name.
- Most often this happens only once for each distinct header file,
- but not necessarily. If it happens more than once, INSTANCE has
- a different value each time, and references to the header file
- use INSTANCE values to select among them.
-
- dbx output contains "begin" and "end" markers for each new header file,
- but at this level we just need to know which files there have been;
- so we record the file when its "begin" is seen and ignore the "end". */
-
-static void
-add_new_header_file (const char *name, int instance)
-{
- int i;
- struct header_file *hfile;
-
- /* Make sure there is room for one more header file. */
-
- i = N_ALLOCATED_HEADER_FILES (dbxread_objfile);
-
- if (N_HEADER_FILES (dbxread_objfile) == i)
- {
- if (i == 0)
- {
- N_ALLOCATED_HEADER_FILES (dbxread_objfile) = 10;
- HEADER_FILES (dbxread_objfile) = (struct header_file *)
- xmalloc (10 * sizeof (struct header_file));
- }
- else
- {
- i *= 2;
- N_ALLOCATED_HEADER_FILES (dbxread_objfile) = i;
- HEADER_FILES (dbxread_objfile) = (struct header_file *)
- xrealloc ((char *) HEADER_FILES (dbxread_objfile),
- (i * sizeof (struct header_file)));
- }
- }
-
- /* Create an entry for this header file. */
-
- i = N_HEADER_FILES (dbxread_objfile)++;
- hfile = HEADER_FILES (dbxread_objfile) + i;
- hfile->name = xstrdup (name);
- hfile->instance = instance;
- hfile->length = 10;
- hfile->vector = XCNEWVEC (struct type *, 10);
-
- add_this_object_header_file (i);
-}
#if 0
static struct type **
@@ -425,91 +90,6 @@ explicit_lookup_type (int real_filenum, int index)
}
#endif
-static void
-record_minimal_symbol (minimal_symbol_reader &reader,
- const char *name, unrelocated_addr address, int type,
- struct objfile *objfile)
-{
- enum minimal_symbol_type ms_type;
- int section;
-
- switch (type)
- {
- case N_TEXT | N_EXT:
- ms_type = mst_text;
- section = SECT_OFF_TEXT (objfile);
- break;
- case N_DATA | N_EXT:
- ms_type = mst_data;
- section = SECT_OFF_DATA (objfile);
- break;
- case N_BSS | N_EXT:
- ms_type = mst_bss;
- section = SECT_OFF_BSS (objfile);
- break;
- case N_ABS | N_EXT:
- ms_type = mst_abs;
- section = -1;
- break;
-#ifdef N_SETV
- case N_SETV | N_EXT:
- ms_type = mst_data;
- section = SECT_OFF_DATA (objfile);
- break;
- case N_SETV:
- /* I don't think this type actually exists; since a N_SETV is the result
- of going over many .o files, it doesn't make sense to have one
- file local. */
- ms_type = mst_file_data;
- section = SECT_OFF_DATA (objfile);
- break;
-#endif
- case N_TEXT:
- case N_NBTEXT:
- case N_FN:
- case N_FN_SEQ:
- ms_type = mst_file_text;
- section = SECT_OFF_TEXT (objfile);
- break;
- case N_DATA:
- ms_type = mst_file_data;
-
- /* Check for __DYNAMIC, which is used by Sun shared libraries.
- Record it as global even if it's local, not global, so
- lookup_minimal_symbol can find it. We don't check symbol_leading_char
- because for SunOS4 it always is '_'. */
- if (strcmp ("__DYNAMIC", name) == 0)
- ms_type = mst_data;
-
- /* Same with virtual function tables, both global and static. */
- {
- const char *tempstring = name;
-
- if (*tempstring != '\0'
- && *tempstring == bfd_get_symbol_leading_char (objfile->obfd.get ()))
- ++tempstring;
- if (is_vtable_name (tempstring))
- ms_type = mst_data;
- }
- section = SECT_OFF_DATA (objfile);
- break;
- case N_BSS:
- ms_type = mst_file_bss;
- section = SECT_OFF_BSS (objfile);
- break;
- default:
- ms_type = mst_unknown;
- section = -1;
- break;
- }
-
- if ((ms_type == mst_file_text || ms_type == mst_text)
- && address < lowest_text_address)
- lowest_text_address = address;
-
- reader.record_with_info (name, address, ms_type, section);
-}
-
/* Scan and build partial symbols for a symbol file.
We have been initialized by a call to dbx_symfile_init, which
put all the relevant info into a "struct dbx_symfile_info",
@@ -518,39 +98,7 @@ record_minimal_symbol (minimal_symbol_reader &reader,
static void
dbx_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
{
- bfd *sym_bfd;
- int val;
-
- sym_bfd = objfile->obfd.get ();
-
- /* .o and .nlm files are relocatables with text, data and bss segs based at
- 0. This flag disables special (Solaris stabs-in-elf only) fixups for
- symbols with a value of 0. */
-
- symfile_relocatable = bfd_get_file_flags (sym_bfd) & HAS_RELOC;
-
- val = bfd_seek (sym_bfd, DBX_SYMTAB_OFFSET (objfile), SEEK_SET);
- if (val < 0)
- perror_with_name (objfile_name (objfile));
-
- symbol_size = DBX_SYMBOL_SIZE (objfile);
- symbol_table_offset = DBX_SYMTAB_OFFSET (objfile);
-
- scoped_free_pendings free_pending;
-
- minimal_symbol_reader reader (objfile);
-
- /* Read stabs data from executable file and define symbols. */
-
- psymbol_functions *psf = new psymbol_functions ();
- psymtab_storage *partial_symtabs = psf->get_partial_symtabs ().get ();
- objfile->qf.emplace_front (psf);
- read_dbx_symtab (reader, partial_symtabs, objfile);
-
- /* Install any minimal symbols that have been collected as the current
- minimal symbols for this objfile. */
-
- reader.install ();
+ read_stabs_symtab (objfile, symfile_flags);
}
/* Initialize anything that needs initializing when a completely new
@@ -699,2446 +247,10 @@ dbx_symfile_finish (struct objfile *objfile)
free_header_files ();
}
-dbx_symfile_info::~dbx_symfile_info ()
-{
- if (header_files != NULL)
- {
- int i = n_header_files;
- struct header_file *hfiles = header_files;
-
- while (--i >= 0)
- {
- xfree (hfiles[i].name);
- xfree (hfiles[i].vector);
- }
- xfree (hfiles);
- }
-}
-
-
-
-/* Buffer for reading the symbol table entries. */
-static struct external_nlist symbuf[4096];
-static int symbuf_idx;
-static int symbuf_end;
-
-/* Name of last function encountered. Used in Solaris to approximate
- object file boundaries. */
-static const char *last_function_name;
-
-/* The address in memory of the string table of the object file we are
- reading (which might not be the "main" object file, but might be a
- shared library or some other dynamically loaded thing). This is
- set by read_dbx_symtab when building psymtabs, and by
- read_ofile_symtab when building symtabs, and is used only by
- next_symbol_text. FIXME: If that is true, we don't need it when
- building psymtabs, right? */
-static char *stringtab_global;
-
-/* These variables are used to control fill_symbuf when the stabs
- symbols are not contiguous (as may be the case when a COFF file is
- linked using --split-by-reloc). */
-static const std::vector<asection *> *symbuf_sections;
-static size_t sect_idx;
-static unsigned int symbuf_left;
-static unsigned int symbuf_read;
-
-/* This variable stores a global stabs buffer, if we read stabs into
- memory in one chunk in order to process relocations. */
-static bfd_byte *stabs_data;
-
-/* Refill the symbol table input buffer
- and set the variables that control fetching entries from it.
- Reports an error if no data available.
- This function can read past the end of the symbol table
- (into the string table) but this does no harm. */
-
-static void
-fill_symbuf (bfd *sym_bfd)
-{
- unsigned int count;
- int nbytes;
-
- if (stabs_data)
- {
- nbytes = sizeof (symbuf);
- if (nbytes > symbuf_left)
- nbytes = symbuf_left;
- memcpy (symbuf, stabs_data + symbuf_read, nbytes);
- }
- else if (symbuf_sections == NULL)
- {
- count = sizeof (symbuf);
- nbytes = bfd_read (symbuf, count, sym_bfd);
- }
- else
- {
- if (symbuf_left <= 0)
- {
- file_ptr filepos = (*symbuf_sections)[sect_idx]->filepos;
-
- if (bfd_seek (sym_bfd, filepos, SEEK_SET) != 0)
- perror_with_name (bfd_get_filename (sym_bfd));
- symbuf_left = bfd_section_size ((*symbuf_sections)[sect_idx]);
- symbol_table_offset = filepos - symbuf_read;
- ++sect_idx;
- }
-
- count = symbuf_left;
- if (count > sizeof (symbuf))
- count = sizeof (symbuf);
- nbytes = bfd_read (symbuf, count, sym_bfd);
- }
-
- if (nbytes < 0)
- perror_with_name (bfd_get_filename (sym_bfd));
- else if (nbytes == 0)
- error (_("Premature end of file reading symbol table"));
- symbuf_end = nbytes / symbol_size;
- symbuf_idx = 0;
- symbuf_left -= nbytes;
- symbuf_read += nbytes;
-}
-
-static void
-stabs_seek (int sym_offset)
-{
- if (stabs_data)
- {
- symbuf_read += sym_offset;
- symbuf_left -= sym_offset;
- }
- else
- if (bfd_seek (symfile_bfd, sym_offset, SEEK_CUR) != 0)
- perror_with_name (bfd_get_filename (symfile_bfd));
-}
-
-#define INTERNALIZE_SYMBOL(intern, extern, abfd) \
- { \
- (intern).n_strx = bfd_h_get_32 (abfd, (extern)->e_strx); \
- (intern).n_type = bfd_h_get_8 (abfd, (extern)->e_type); \
- (intern).n_other = 0; \
- (intern).n_desc = bfd_h_get_16 (abfd, (extern)->e_desc); \
- if (bfd_get_sign_extend_vma (abfd)) \
- (intern).n_value = bfd_h_get_signed_32 (abfd, (extern)->e_value); \
- else \
- (intern).n_value = bfd_h_get_32 (abfd, (extern)->e_value); \
- }
-
-/* Invariant: The symbol pointed to by symbuf_idx is the first one
- that hasn't been swapped. Swap the symbol at the same time
- that symbuf_idx is incremented. */
-
-/* dbx allows the text of a symbol name to be continued into the
- next symbol name! When such a continuation is encountered
- (a \ at the end of the text of a name)
- call this function to get the continuation. */
-
-static const char *
-dbx_next_symbol_text (struct objfile *objfile)
-{
- struct internal_nlist nlist;
-
- if (symbuf_idx == symbuf_end)
- fill_symbuf (symfile_bfd);
-
- symnum++;
- INTERNALIZE_SYMBOL (nlist, &symbuf[symbuf_idx], symfile_bfd);
- OBJSTAT (objfile, n_stabs++);
-
- symbuf_idx++;
-
- return nlist.n_strx + stringtab_global + file_string_table_offset;
-}
-
-
-/* Given a name, value pair, find the corresponding
- bincl in the list. Return the partial symtab associated
- with that header_file_location. */
-
-static legacy_psymtab *
-find_corresponding_bincl_psymtab (const char *name, int instance)
-{
- for (const header_file_location &bincl : *bincl_list)
- if (bincl.instance == instance
- && strcmp (name, bincl.name) == 0)
- return bincl.pst;
-
- repeated_header_complaint (name, symnum);
- return (legacy_psymtab *) 0;
-}
-
-/* Set namestring based on nlist. If the string table index is invalid,
- give a fake name, and print a single error message per symbol file read,
- rather than abort the symbol reading or flood the user with messages. */
-
-static const char *
-set_namestring (struct objfile *objfile, const struct internal_nlist *nlist)
-{
- const char *namestring;
-
- if (nlist->n_strx + file_string_table_offset
- >= DBX_STRINGTAB_SIZE (objfile)
- || nlist->n_strx + file_string_table_offset < nlist->n_strx)
- {
- complaint (_("bad string table offset in symbol %d"),
- symnum);
- namestring = "<bad string table offset>";
- }
- else
- namestring = (nlist->n_strx + file_string_table_offset
- + DBX_STRINGTAB (objfile));
- return namestring;
-}
-
-static bound_minimal_symbol
-find_stab_function (const char *namestring, const char *filename,
- struct objfile *objfile)
-{
- int n;
-
- const char *colon = strchr (namestring, ':');
- if (colon == NULL)
- n = 0;
- else
- n = colon - namestring;
-
- char *p = (char *) alloca (n + 2);
- strncpy (p, namestring, n);
- p[n] = 0;
-
- bound_minimal_symbol msym
- = lookup_minimal_symbol (current_program_space, p, objfile, filename);
- if (msym.minsym == NULL)
- {
- /* Sun Fortran appends an underscore to the minimal symbol name,
- try again with an appended underscore if the minimal symbol
- was not found. */
- p[n] = '_';
- p[n + 1] = 0;
- msym
- = lookup_minimal_symbol (current_program_space, p, objfile, filename);
- }
-
- if (msym.minsym == NULL && filename != NULL)
- {
- /* Try again without the filename. */
- p[n] = 0;
- msym = lookup_minimal_symbol (current_program_space, p, objfile);
- }
- if (msym.minsym == NULL && filename != NULL)
- {
- /* And try again for Sun Fortran, but without the filename. */
- p[n] = '_';
- p[n + 1] = 0;
- msym = lookup_minimal_symbol (current_program_space, p, objfile);
- }
-
- return msym;
-}
-
-static void
-function_outside_compilation_unit_complaint (const char *arg1)
-{
- complaint (_("function `%s' appears to be defined "
- "outside of all compilation units"),
- arg1);
-}
-
-/* Setup partial_symtab's describing each source file for which
- debugging information is available. */
-
-static void
-read_dbx_symtab (minimal_symbol_reader &reader,
- psymtab_storage *partial_symtabs,
- struct objfile *objfile)
-{
- struct gdbarch *gdbarch = objfile->arch ();
- struct external_nlist *bufp = 0; /* =0 avoids gcc -Wall glitch. */
- struct internal_nlist nlist;
- CORE_ADDR text_addr;
- int text_size;
- const char *sym_name;
- int sym_len;
-
- const char *namestring;
- int nsl;
- int past_first_source_file = 0;
- CORE_ADDR last_function_start = 0;
- bfd *abfd;
- int textlow_not_set;
- int data_sect_index;
-
- /* Current partial symtab. */
- legacy_psymtab *pst;
-
- /* List of current psymtab's include files. */
- const char **psymtab_include_list;
- int includes_allocated;
- int includes_used;
-
- /* Index within current psymtab dependency list. */
- legacy_psymtab **dependency_list;
- int dependencies_used, dependencies_allocated;
-
- text_addr = DBX_TEXT_ADDR (objfile);
- text_size = DBX_TEXT_SIZE (objfile);
-
- /* FIXME. We probably want to change stringtab_global rather than add this
- while processing every symbol entry. FIXME. */
- file_string_table_offset = 0;
- next_file_string_table_offset = 0;
-
- stringtab_global = DBX_STRINGTAB (objfile);
-
- pst = (legacy_psymtab *) 0;
-
- includes_allocated = 30;
- includes_used = 0;
- psymtab_include_list = (const char **) alloca (includes_allocated *
- sizeof (const char *));
-
- dependencies_allocated = 30;
- dependencies_used = 0;
- dependency_list =
- (legacy_psymtab **) alloca (dependencies_allocated *
- sizeof (legacy_psymtab *));
-
- /* Init bincl list */
- std::vector<struct header_file_location> bincl_storage;
- scoped_restore restore_bincl_global
- = make_scoped_restore (&bincl_list, &bincl_storage);
-
- set_last_source_file (NULL);
-
- lowest_text_address = (unrelocated_addr) -1;
-
- symfile_bfd = objfile->obfd.get (); /* For next_text_symbol. */
- abfd = objfile->obfd.get ();
- symbuf_end = symbuf_idx = 0;
- next_symbol_text_func = dbx_next_symbol_text;
- textlow_not_set = 1;
- has_line_numbers = 0;
-
- /* FIXME: jimb/2003-09-12: We don't apply the right section's offset
- to global and static variables. The stab for a global or static
- variable doesn't give us any indication of which section it's in,
- so we can't tell immediately which offset in
- objfile->section_offsets we should apply to the variable's
- address.
-
- We could certainly find out which section contains the variable
- by looking up the variable's unrelocated address with
- find_pc_section, but that would be expensive; this is the
- function that constructs the partial symbol tables by examining
- every symbol in the entire executable, and it's
- performance-critical. So that expense would not be welcome. I'm
- not sure what to do about this at the moment.
-
- What we have done for years is to simply assume that the .data
- section's offset is appropriate for all global and static
- variables. Recently, this was expanded to fall back to the .bss
- section's offset if there is no .data section, and then to the
- .rodata section's offset. */
- data_sect_index = objfile->sect_index_data;
- if (data_sect_index == -1)
- data_sect_index = SECT_OFF_BSS (objfile);
- if (data_sect_index == -1)
- data_sect_index = SECT_OFF_RODATA (objfile);
-
- /* If data_sect_index is still -1, that's okay. It's perfectly fine
- for the file to have no .data, no .bss, and no .text at all, if
- it also has no global or static variables. */
-
- for (symnum = 0; symnum < DBX_SYMCOUNT (objfile); symnum++)
- {
- /* Get the symbol for this run and pull out some info. */
- QUIT; /* Allow this to be interruptable. */
- if (symbuf_idx == symbuf_end)
- fill_symbuf (abfd);
- bufp = &symbuf[symbuf_idx++];
-
- /*
- * Special case to speed up readin.
- */
- if (bfd_h_get_8 (abfd, bufp->e_type) == N_SLINE)
- {
- has_line_numbers = 1;
- continue;
- }
-
- INTERNALIZE_SYMBOL (nlist, bufp, abfd);
- OBJSTAT (objfile, n_stabs++);
-
- /* Ok. There is a lot of code duplicated in the rest of this
- switch statement (for efficiency reasons). Since I don't
- like duplicating code, I will do my penance here, and
- describe the code which is duplicated:
-
- *) The assignment to namestring.
- *) The call to strchr.
- *) The addition of a partial symbol the two partial
- symbol lists. This last is a large section of code, so
- I've embedded it in the following macro. */
-
- switch (nlist.n_type)
- {
- /*
- * Standard, external, non-debugger, symbols
- */
-
- case N_TEXT | N_EXT:
- case N_NBTEXT | N_EXT:
- goto record_it;
-
- case N_DATA | N_EXT:
- case N_NBDATA | N_EXT:
- goto record_it;
-
- case N_BSS:
- case N_BSS | N_EXT:
- case N_NBBSS | N_EXT:
- case N_SETV | N_EXT: /* FIXME, is this in BSS? */
- goto record_it;
-
- case N_ABS | N_EXT:
- record_it:
- namestring = set_namestring (objfile, &nlist);
-
- record_minimal_symbol (reader, namestring,
- unrelocated_addr (nlist.n_value),
- nlist.n_type, objfile); /* Always */
- continue;
-
- /* Standard, local, non-debugger, symbols. */
-
- case N_NBTEXT:
-
- /* We need to be able to deal with both N_FN or N_TEXT,
- because we have no way of knowing whether the sys-supplied ld
- or GNU ld was used to make the executable. Sequents throw
- in another wrinkle -- they renumbered N_FN. */
-
- case N_FN:
- case N_FN_SEQ:
- case N_TEXT:
- namestring = set_namestring (objfile, &nlist);
-
- if ((namestring[0] == '-' && namestring[1] == 'l')
- || (namestring[(nsl = strlen (namestring)) - 1] == 'o'
- && namestring[nsl - 2] == '.'))
- {
- unrelocated_addr unrel_val = unrelocated_addr (nlist.n_value);
-
- if (past_first_source_file && pst
- /* The gould NP1 uses low values for .o and -l symbols
- which are not the address. */
- && unrel_val >= pst->unrelocated_text_low ())
- {
- dbx_end_psymtab (objfile, partial_symtabs,
- pst, psymtab_include_list,
- includes_used, symnum * symbol_size,
- unrel_val > pst->unrelocated_text_high ()
- ? unrel_val : pst->unrelocated_text_high (),
- dependency_list, dependencies_used,
- textlow_not_set);
- pst = (legacy_psymtab *) 0;
- includes_used = 0;
- dependencies_used = 0;
- has_line_numbers = 0;
- }
- else
- past_first_source_file = 1;
- }
- else
- goto record_it;
- continue;
-
- case N_DATA:
- goto record_it;
-
- case N_UNDF | N_EXT:
- /* The case (nlist.n_value != 0) is a "Fortran COMMON" symbol.
- We used to rely on the target to tell us whether it knows
- where the symbol has been relocated to, but none of the
- target implementations actually provided that operation.
- So we just ignore the symbol, the same way we would do if
- we had a target-side symbol lookup which returned no match.
-
- All other symbols (with nlist.n_value == 0), are really
- undefined, and so we ignore them too. */
- continue;
-
- case N_UNDF:
- if (processing_acc_compilation && nlist.n_strx == 1)
- {
- /* Deal with relative offsets in the string table
- used in ELF+STAB under Solaris. If we want to use the
- n_strx field, which contains the name of the file,
- we must adjust file_string_table_offset *before* calling
- set_namestring(). */
- past_first_source_file = 1;
- file_string_table_offset = next_file_string_table_offset;
- next_file_string_table_offset =
- file_string_table_offset + nlist.n_value;
- if (next_file_string_table_offset < file_string_table_offset)
- error (_("string table offset backs up at %d"), symnum);
- /* FIXME -- replace error() with complaint. */
- continue;
- }
- continue;
-
- /* Lots of symbol types we can just ignore. */
-
- case N_ABS:
- case N_NBDATA:
- case N_NBBSS:
- continue;
-
- /* Keep going . . . */
-
- /*
- * Special symbol types for GNU
- */
- case N_INDR:
- case N_INDR | N_EXT:
- case N_SETA:
- case N_SETA | N_EXT:
- case N_SETT:
- case N_SETT | N_EXT:
- case N_SETD:
- case N_SETD | N_EXT:
- case N_SETB:
- case N_SETB | N_EXT:
- case N_SETV:
- continue;
-
- /*
- * Debugger symbols
- */
-
- case N_SO:
- {
- CORE_ADDR valu;
- static int prev_so_symnum = -10;
- static int first_so_symnum;
- const char *p;
- static const char *dirname_nso;
- int prev_textlow_not_set;
-
- valu = nlist.n_value;
-
- prev_textlow_not_set = textlow_not_set;
-
- /* A zero value is probably an indication for the SunPRO 3.0
- compiler. dbx_end_psymtab explicitly tests for zero, so
- don't relocate it. */
-
- if (nlist.n_value == 0
- && gdbarch_sofun_address_maybe_missing (gdbarch))
- {
- textlow_not_set = 1;
- valu = 0;
- }
- else
- textlow_not_set = 0;
-
- past_first_source_file = 1;
-
- if (prev_so_symnum != symnum - 1)
- { /* Here if prev stab wasn't N_SO. */
- first_so_symnum = symnum;
-
- if (pst)
- {
- unrelocated_addr unrel_value = unrelocated_addr (valu);
- dbx_end_psymtab (objfile, partial_symtabs,
- pst, psymtab_include_list,
- includes_used, symnum * symbol_size,
- unrel_value > pst->unrelocated_text_high ()
- ? unrel_value
- : pst->unrelocated_text_high (),
- dependency_list, dependencies_used,
- prev_textlow_not_set);
- pst = (legacy_psymtab *) 0;
- includes_used = 0;
- dependencies_used = 0;
- has_line_numbers = 0;
- }
- }
-
- prev_so_symnum = symnum;
-
- /* End the current partial symtab and start a new one. */
-
- namestring = set_namestring (objfile, &nlist);
-
- /* Null name means end of .o file. Don't start a new one. */
- if (*namestring == '\000')
- continue;
-
- /* Some compilers (including gcc) emit a pair of initial N_SOs.
- The first one is a directory name; the second the file name.
- If pst exists, is empty, and has a filename ending in '/',
- we assume the previous N_SO was a directory name. */
-
- p = lbasename (namestring);
- if (p != namestring && *p == '\000')
- {
- /* Save the directory name SOs locally, then save it into
- the psymtab when it's created below. */
- dirname_nso = namestring;
- continue;
- }
-
- /* Some other compilers (C++ ones in particular) emit useless
- SOs for non-existant .c files. We ignore all subsequent SOs
- that immediately follow the first. */
-
- if (!pst)
- {
- pst = start_psymtab (partial_symtabs, objfile,
- namestring,
- unrelocated_addr (valu),
- first_so_symnum * symbol_size);
- pst->dirname = dirname_nso;
- dirname_nso = NULL;
- }
- continue;
- }
-
- case N_BINCL:
- {
- enum language tmp_language;
-
- /* Add this bincl to the bincl_list for future EXCLs. No
- need to save the string; it'll be around until
- read_dbx_symtab function returns. */
-
- namestring = set_namestring (objfile, &nlist);
- tmp_language = deduce_language_from_filename (namestring);
-
- /* Only change the psymtab's language if we've learned
- something useful (eg. tmp_language is not language_unknown).
- In addition, to match what start_subfile does, never change
- from C++ to C. */
- if (tmp_language != language_unknown
- && (tmp_language != language_c
- || psymtab_language != language_cplus))
- psymtab_language = tmp_language;
-
- if (pst == NULL)
- {
- /* FIXME: we should not get here without a PST to work on.
- Attempt to recover. */
- complaint (_("N_BINCL %s not in entries for "
- "any file, at symtab pos %d"),
- namestring, symnum);
- continue;
- }
- bincl_list->emplace_back (namestring, nlist.n_value, pst);
-
- /* Mark down an include file in the current psymtab. */
-
- goto record_include_file;
- }
-
- case N_SOL:
- {
- enum language tmp_language;
-
- /* Mark down an include file in the current psymtab. */
- namestring = set_namestring (objfile, &nlist);
- tmp_language = deduce_language_from_filename (namestring);
-
- /* Only change the psymtab's language if we've learned
- something useful (eg. tmp_language is not language_unknown).
- In addition, to match what start_subfile does, never change
- from C++ to C. */
- if (tmp_language != language_unknown
- && (tmp_language != language_c
- || psymtab_language != language_cplus))
- psymtab_language = tmp_language;
-
- /* In C++, one may expect the same filename to come round many
- times, when code is coming alternately from the main file
- and from inline functions in other files. So I check to see
- if this is a file we've seen before -- either the main
- source file, or a previously included file.
-
- This seems to be a lot of time to be spending on N_SOL, but
- things like "break c-exp.y:435" need to work (I
- suppose the psymtab_include_list could be hashed or put
- in a binary tree, if profiling shows this is a major hog). */
- if (pst && filename_cmp (namestring, pst->filename) == 0)
- continue;
- {
- int i;
-
- for (i = 0; i < includes_used; i++)
- if (filename_cmp (namestring, psymtab_include_list[i]) == 0)
- {
- i = -1;
- break;
- }
- if (i == -1)
- continue;
- }
-
- record_include_file:
-
- psymtab_include_list[includes_used++] = namestring;
- if (includes_used >= includes_allocated)
- {
- const char **orig = psymtab_include_list;
-
- psymtab_include_list = (const char **)
- alloca ((includes_allocated *= 2) * sizeof (const char *));
- memcpy (psymtab_include_list, orig,
- includes_used * sizeof (const char *));
- }
- continue;
- }
- case N_LSYM: /* Typedef or automatic variable. */
- case N_STSYM: /* Data seg var -- static. */
- case N_LCSYM: /* BSS " */
- case N_ROSYM: /* Read-only data seg var -- static. */
- case N_NBSTS: /* Gould nobase. */
- case N_NBLCS: /* symbols. */
- case N_FUN:
- case N_GSYM: /* Global (extern) variable; can be
- data or bss (sigh FIXME). */
-
- /* Following may probably be ignored; I'll leave them here
- for now (until I do Pascal and Modula 2 extensions). */
-
- case N_PC: /* I may or may not need this; I
- suspect not. */
- case N_M2C: /* I suspect that I can ignore this here. */
- case N_SCOPE: /* Same. */
- {
- const char *p;
-
- namestring = set_namestring (objfile, &nlist);
-
- /* See if this is an end of function stab. */
- if (pst && nlist.n_type == N_FUN && *namestring == '\000')
- {
- unrelocated_addr valu;
-
- /* It's value is the size (in bytes) of the function for
- function relative stabs, or the address of the function's
- end for old style stabs. */
- valu = unrelocated_addr (nlist.n_value + last_function_start);
- if (pst->unrelocated_text_high () == unrelocated_addr (0)
- || valu > pst->unrelocated_text_high ())
- pst->set_text_high (valu);
- break;
- }
-
- p = (char *) strchr (namestring, ':');
- if (!p)
- continue; /* Not a debugging symbol. */
-
- sym_len = 0;
- sym_name = NULL; /* pacify "gcc -Werror" */
- if (psymtab_language == language_cplus)
- {
- std::string name (namestring, p - namestring);
- gdb::unique_xmalloc_ptr<char> new_name
- = cp_canonicalize_string (name.c_str ());
- if (new_name != nullptr)
- {
- sym_len = strlen (new_name.get ());
- sym_name = obstack_strdup (&objfile->objfile_obstack,
- new_name.get ());
- }
- }
- else if (psymtab_language == language_c)
- {
- std::string name (namestring, p - namestring);
- gdb::unique_xmalloc_ptr<char> new_name
- = c_canonicalize_name (name.c_str ());
- if (new_name != nullptr)
- {
- sym_len = strlen (new_name.get ());
- sym_name = obstack_strdup (&objfile->objfile_obstack,
- new_name.get ());
- }
- }
-
- if (sym_len == 0)
- {
- sym_name = namestring;
- sym_len = p - namestring;
- }
-
- /* Main processing section for debugging symbols which
- the initial read through the symbol tables needs to worry
- about. If we reach this point, the symbol which we are
- considering is definitely one we are interested in.
- p must also contain the (valid) index into the namestring
- which indicates the debugging type symbol. */
-
- switch (p[1])
- {
- case 'S':
- if (pst != nullptr)
- pst->add_psymbol (std::string_view (sym_name, sym_len), true,
- VAR_DOMAIN, LOC_STATIC,
- data_sect_index,
- psymbol_placement::STATIC,
- unrelocated_addr (nlist.n_value),
- psymtab_language,
- partial_symtabs, objfile);
- else
- complaint (_("static `%*s' appears to be defined "
- "outside of all compilation units"),
- sym_len, sym_name);
- continue;
-
- case 'G':
- /* The addresses in these entries are reported to be
- wrong. See the code that reads 'G's for symtabs. */
- if (pst != nullptr)
- pst->add_psymbol (std::string_view (sym_name, sym_len), true,
- VAR_DOMAIN, LOC_STATIC,
- data_sect_index,
- psymbol_placement::GLOBAL,
- unrelocated_addr (nlist.n_value),
- psymtab_language,
- partial_symtabs, objfile);
- else
- complaint (_("global `%*s' appears to be defined "
- "outside of all compilation units"),
- sym_len, sym_name);
- continue;
-
- case 'T':
- /* When a 'T' entry is defining an anonymous enum, it
- may have a name which is the empty string, or a
- single space. Since they're not really defining a
- symbol, those shouldn't go in the partial symbol
- table. We do pick up the elements of such enums at
- 'check_enum:', below. */
- if (p >= namestring + 2
- || (p == namestring + 1
- && namestring[0] != ' '))
- {
- if (pst != nullptr)
- pst->add_psymbol (std::string_view (sym_name, sym_len),
- true, STRUCT_DOMAIN, LOC_TYPEDEF, -1,
- psymbol_placement::STATIC,
- unrelocated_addr (0),
- psymtab_language,
- partial_symtabs, objfile);
- else
- complaint (_("enum, struct, or union `%*s' appears "
- "to be defined outside of all "
- "compilation units"),
- sym_len, sym_name);
- if (p[2] == 't')
- {
- /* Also a typedef with the same name. */
- if (pst != nullptr)
- pst->add_psymbol (std::string_view (sym_name, sym_len),
- true, VAR_DOMAIN, LOC_TYPEDEF, -1,
- psymbol_placement::STATIC,
- unrelocated_addr (0),
- psymtab_language,
- partial_symtabs, objfile);
- else
- complaint (_("typedef `%*s' appears to be defined "
- "outside of all compilation units"),
- sym_len, sym_name);
- p += 1;
- }
- }
- goto check_enum;
-
- case 't':
- if (p != namestring) /* a name is there, not just :T... */
- {
- if (pst != nullptr)
- pst->add_psymbol (std::string_view (sym_name, sym_len),
- true, VAR_DOMAIN, LOC_TYPEDEF, -1,
- psymbol_placement::STATIC,
- unrelocated_addr (0),
- psymtab_language,
- partial_symtabs, objfile);
- else
- complaint (_("typename `%*s' appears to be defined "
- "outside of all compilation units"),
- sym_len, sym_name);
- }
- check_enum:
- /* If this is an enumerated type, we need to
- add all the enum constants to the partial symbol
- table. This does not cover enums without names, e.g.
- "enum {a, b} c;" in C, but fortunately those are
- rare. There is no way for GDB to find those from the
- enum type without spending too much time on it. Thus
- to solve this problem, the compiler needs to put out the
- enum in a nameless type. GCC2 does this. */
-
- /* We are looking for something of the form
- <name> ":" ("t" | "T") [<number> "="] "e"
- {<constant> ":" <value> ","} ";". */
-
- /* Skip over the colon and the 't' or 'T'. */
- p += 2;
- /* This type may be given a number. Also, numbers can come
- in pairs like (0,26). Skip over it. */
- while ((*p >= '0' && *p <= '9')
- || *p == '(' || *p == ',' || *p == ')'
- || *p == '=')
- p++;
-
- if (*p++ == 'e')
- {
- /* The aix4 compiler emits extra crud before the members. */
- if (*p == '-')
- {
- /* Skip over the type (?). */
- while (*p != ':')
- p++;
-
- /* Skip over the colon. */
- p++;
- }
-
- /* We have found an enumerated type. */
- /* According to comments in read_enum_type
- a comma could end it instead of a semicolon.
- I don't know where that happens.
- Accept either. */
- while (*p && *p != ';' && *p != ',')
- {
- const char *q;
-
- /* Check for and handle cretinous dbx symbol name
- continuation! */
- if (*p == '\\' || (*p == '?' && p[1] == '\0'))
- p = next_symbol_text (objfile);
-
- /* Point to the character after the name
- of the enum constant. */
- for (q = p; *q && *q != ':'; q++)
- ;
- /* Note that the value doesn't matter for
- enum constants in psymtabs, just in symtabs. */
- if (pst != nullptr)
- pst->add_psymbol (std::string_view (p, q - p), true,
- VAR_DOMAIN, LOC_CONST, -1,
- psymbol_placement::STATIC,
- unrelocated_addr (0),
- psymtab_language,
- partial_symtabs, objfile);
- else
- complaint (_("enum constant `%*s' appears to be defined "
- "outside of all compilation units"),
- ((int) (q - p)), p);
- /* Point past the name. */
- p = q;
- /* Skip over the value. */
- while (*p && *p != ',')
- p++;
- /* Advance past the comma. */
- if (*p)
- p++;
- }
- }
- continue;
-
- case 'c':
- /* Constant, e.g. from "const" in Pascal. */
- if (pst != nullptr)
- pst->add_psymbol (std::string_view (sym_name, sym_len), true,
- VAR_DOMAIN, LOC_CONST, -1,
- psymbol_placement::STATIC,
- unrelocated_addr (0),
- psymtab_language,
- partial_symtabs, objfile);
- else
- complaint (_("constant `%*s' appears to be defined "
- "outside of all compilation units"),
- sym_len, sym_name);
-
- continue;
-
- case 'f':
- if (! pst)
- {
- std::string name (namestring, (p - namestring));
- function_outside_compilation_unit_complaint (name.c_str ());
- }
- /* Kludges for ELF/STABS with Sun ACC. */
- last_function_name = namestring;
- /* Do not fix textlow==0 for .o or NLM files, as 0 is a legit
- value for the bottom of the text seg in those cases. */
- if (nlist.n_value == 0
- && gdbarch_sofun_address_maybe_missing (gdbarch))
- {
- bound_minimal_symbol minsym
- = find_stab_function (namestring,
- pst ? pst->filename : NULL, objfile);
- if (minsym.minsym != NULL)
- nlist.n_value
- = CORE_ADDR (minsym.minsym->unrelocated_address ());
- }
- if (pst && textlow_not_set
- && gdbarch_sofun_address_maybe_missing (gdbarch))
- {
- pst->set_text_low (unrelocated_addr (nlist.n_value));
- textlow_not_set = 0;
- }
- /* End kludge. */
-
- /* Keep track of the start of the last function so we
- can handle end of function symbols. */
- last_function_start = nlist.n_value;
-
- /* In reordered executables this function may lie outside
- the bounds created by N_SO symbols. If that's the case
- use the address of this function as the low bound for
- the partial symbol table. */
- if (pst
- && (textlow_not_set
- || (unrelocated_addr (nlist.n_value)
- < pst->unrelocated_text_low ()
- && (nlist.n_value != 0))))
- {
- pst->set_text_low (unrelocated_addr (nlist.n_value));
- textlow_not_set = 0;
- }
- if (pst != nullptr)
- pst->add_psymbol (std::string_view (sym_name, sym_len), true,
- VAR_DOMAIN, LOC_BLOCK,
- SECT_OFF_TEXT (objfile),
- psymbol_placement::STATIC,
- unrelocated_addr (nlist.n_value),
- psymtab_language,
- partial_symtabs, objfile);
- continue;
-
- /* Global functions were ignored here, but now they
- are put into the global psymtab like one would expect.
- They're also in the minimal symbol table. */
- case 'F':
- if (! pst)
- {
- std::string name (namestring, (p - namestring));
- function_outside_compilation_unit_complaint (name.c_str ());
- }
- /* Kludges for ELF/STABS with Sun ACC. */
- last_function_name = namestring;
- /* Do not fix textlow==0 for .o or NLM files, as 0 is a legit
- value for the bottom of the text seg in those cases. */
- if (nlist.n_value == 0
- && gdbarch_sofun_address_maybe_missing (gdbarch))
- {
- bound_minimal_symbol minsym
- = find_stab_function (namestring,
- pst ? pst->filename : NULL, objfile);
- if (minsym.minsym != NULL)
- nlist.n_value
- = CORE_ADDR (minsym.minsym->unrelocated_address ());
- }
- if (pst && textlow_not_set
- && gdbarch_sofun_address_maybe_missing (gdbarch))
- {
- pst->set_text_low (unrelocated_addr (nlist.n_value));
- textlow_not_set = 0;
- }
- /* End kludge. */
-
- /* Keep track of the start of the last function so we
- can handle end of function symbols. */
- last_function_start = nlist.n_value;
-
- /* In reordered executables this function may lie outside
- the bounds created by N_SO symbols. If that's the case
- use the address of this function as the low bound for
- the partial symbol table. */
- if (pst
- && (textlow_not_set
- || (unrelocated_addr (nlist.n_value)
- < pst->unrelocated_text_low ()
- && (nlist.n_value != 0))))
- {
- pst->set_text_low (unrelocated_addr (nlist.n_value));
- textlow_not_set = 0;
- }
- if (pst != nullptr)
- pst->add_psymbol (std::string_view (sym_name, sym_len), true,
- VAR_DOMAIN, LOC_BLOCK,
- SECT_OFF_TEXT (objfile),
- psymbol_placement::GLOBAL,
- unrelocated_addr (nlist.n_value),
- psymtab_language,
- partial_symtabs, objfile);
- continue;
-
- /* Two things show up here (hopefully); static symbols of
- local scope (static used inside braces) or extensions
- of structure symbols. We can ignore both. */
- case 'V':
- case '(':
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- case '-':
- case '#': /* For symbol identification (used in live ranges). */
- continue;
-
- case ':':
- /* It is a C++ nested symbol. We don't need to record it
- (I don't think); if we try to look up foo::bar::baz,
- then symbols for the symtab containing foo should get
- read in, I think. */
- /* Someone says sun cc puts out symbols like
- /foo/baz/maclib::/usr/local/bin/maclib,
- which would get here with a symbol type of ':'. */
- continue;
-
- default:
- /* Unexpected symbol descriptor. The second and subsequent stabs
- of a continued stab can show up here. The question is
- whether they ever can mimic a normal stab--it would be
- nice if not, since we certainly don't want to spend the
- time searching to the end of every string looking for
- a backslash. */
-
- complaint (_("unknown symbol descriptor `%c'"),
- p[1]);
-
- /* Ignore it; perhaps it is an extension that we don't
- know about. */
- continue;
- }
- }
-
- case N_EXCL:
-
- namestring = set_namestring (objfile, &nlist);
-
- /* Find the corresponding bincl and mark that psymtab on the
- psymtab dependency list. */
- {
- legacy_psymtab *needed_pst =
- find_corresponding_bincl_psymtab (namestring, nlist.n_value);
-
- /* If this include file was defined earlier in this file,
- leave it alone. */
- if (needed_pst == pst)
- continue;
-
- if (needed_pst)
- {
- int i;
- int found = 0;
-
- for (i = 0; i < dependencies_used; i++)
- if (dependency_list[i] == needed_pst)
- {
- found = 1;
- break;
- }
-
- /* If it's already in the list, skip the rest. */
- if (found)
- continue;
-
- dependency_list[dependencies_used++] = needed_pst;
- if (dependencies_used >= dependencies_allocated)
- {
- legacy_psymtab **orig = dependency_list;
-
- dependency_list =
- (legacy_psymtab **)
- alloca ((dependencies_allocated *= 2)
- * sizeof (legacy_psymtab *));
- memcpy (dependency_list, orig,
- (dependencies_used
- * sizeof (legacy_psymtab *)));
-#ifdef DEBUG_INFO
- gdb_printf (gdb_stderr,
- "Had to reallocate "
- "dependency list.\n");
- gdb_printf (gdb_stderr,
- "New dependencies allocated: %d\n",
- dependencies_allocated);
-#endif
- }
- }
- }
- continue;
-
- case N_ENDM:
- /* Solaris 2 end of module, finish current partial symbol
- table. dbx_end_psymtab will set the high text address of
- PST to the proper value, which is necessary if a module
- compiled without debugging info follows this module. */
- if (pst && gdbarch_sofun_address_maybe_missing (gdbarch))
- {
- dbx_end_psymtab (objfile, partial_symtabs, pst,
- psymtab_include_list, includes_used,
- symnum * symbol_size,
- (unrelocated_addr) 0, dependency_list,
- dependencies_used, textlow_not_set);
- pst = (legacy_psymtab *) 0;
- includes_used = 0;
- dependencies_used = 0;
- has_line_numbers = 0;
- }
- continue;
-
- case N_RBRAC:
-#ifdef HANDLE_RBRAC
- HANDLE_RBRAC (nlist.n_value);
- continue;
-#endif
- case N_EINCL:
- case N_DSLINE:
- case N_BSLINE:
- case N_SSYM: /* Claim: Structure or union element.
- Hopefully, I can ignore this. */
- case N_ENTRY: /* Alternate entry point; can ignore. */
- case N_MAIN: /* Can definitely ignore this. */
- case N_CATCH: /* These are GNU C++ extensions */
- case N_EHDECL: /* that can safely be ignored here. */
- case N_LENG:
- case N_BCOMM:
- case N_ECOMM:
- case N_ECOML:
- case N_FNAME:
- case N_SLINE:
- case N_RSYM:
- case N_PSYM:
- case N_BNSYM:
- case N_ENSYM:
- case N_LBRAC:
- case N_NSYMS: /* Ultrix 4.0: symbol count */
- case N_DEFD: /* GNU Modula-2 */
- case N_ALIAS: /* SunPro F77: alias name, ignore for now. */
-
- case N_OBJ: /* Useless types from Solaris. */
- case N_OPT:
- case N_PATCH:
- /* These symbols aren't interesting; don't worry about them. */
- continue;
-
- default:
- /* If we haven't found it yet, ignore it. It's probably some
- new type we don't know about yet. */
- unknown_symtype_complaint (hex_string (nlist.n_type));
- continue;
- }
- }
-
- /* If there's stuff to be cleaned up, clean it up. */
- if (pst)
- {
- /* Don't set high text address of PST lower than it already
- is. */
- unrelocated_addr text_end
- = (unrelocated_addr
- ((lowest_text_address == (unrelocated_addr) -1
- ? text_addr
- : CORE_ADDR (lowest_text_address))
- + text_size));
-
- dbx_end_psymtab (objfile, partial_symtabs,
- pst, psymtab_include_list, includes_used,
- symnum * symbol_size,
- (text_end > pst->unrelocated_text_high ()
- ? text_end : pst->unrelocated_text_high ()),
- dependency_list, dependencies_used, textlow_not_set);
- }
-}
-
-/* Allocate and partially fill a partial symtab. It will be
- completely filled at the end of the symbol list.
-
- SYMFILE_NAME is the name of the symbol-file we are reading from, and ADDR
- is the address relative to which its symbols are (incremental) or 0
- (normal). */
-
-static legacy_psymtab *
-start_psymtab (psymtab_storage *partial_symtabs, struct objfile *objfile,
- const char *filename, unrelocated_addr textlow, int ldsymoff)
-{
- legacy_psymtab *result = new legacy_psymtab (filename, partial_symtabs,
- objfile->per_bfd, textlow);
-
- result->read_symtab_private =
- XOBNEW (&objfile->objfile_obstack, struct symloc);
- LDSYMOFF (result) = ldsymoff;
- result->legacy_read_symtab = dbx_read_symtab;
- result->legacy_expand_psymtab = dbx_expand_psymtab;
- SYMBOL_SIZE (result) = symbol_size;
- SYMBOL_OFFSET (result) = symbol_table_offset;
- STRING_OFFSET (result) = string_table_offset;
- FILE_STRING_OFFSET (result) = file_string_table_offset;
-
- /* Deduce the source language from the filename for this psymtab. */
- psymtab_language = deduce_language_from_filename (filename);
- PST_LANGUAGE (result) = psymtab_language;
-
- return result;
-}
-
-/* Close off the current usage of PST.
- Returns PST or NULL if the partial symtab was empty and thrown away.
-
- FIXME: List variables and peculiarities of same. */
-
-legacy_psymtab *
-dbx_end_psymtab (struct objfile *objfile, psymtab_storage *partial_symtabs,
- legacy_psymtab *pst,
- const char **include_list, int num_includes,
- int capping_symbol_offset, unrelocated_addr capping_text,
- legacy_psymtab **dependency_list,
- int number_dependencies,
- int textlow_not_set)
-{
- int i;
- struct gdbarch *gdbarch = objfile->arch ();
-
- if (capping_symbol_offset != -1)
- LDSYMLEN (pst) = capping_symbol_offset - LDSYMOFF (pst);
- pst->set_text_high (capping_text);
-
- /* Under Solaris, the N_SO symbols always have a value of 0,
- instead of the usual address of the .o file. Therefore,
- we have to do some tricks to fill in texthigh and textlow.
- The first trick is: if we see a static
- or global function, and the textlow for the current pst
- is not set (ie: textlow_not_set), then we use that function's
- address for the textlow of the pst. */
-
- /* Now, to fill in texthigh, we remember the last function seen
- in the .o file. Also, there's a hack in
- bfd/elf.c and gdb/elfread.c to pass the ELF st_size field
- to here via the misc_info field. Therefore, we can fill in
- a reliable texthigh by taking the address plus size of the
- last function in the file. */
-
- if (!pst->text_high_valid && last_function_name
- && gdbarch_sofun_address_maybe_missing (gdbarch))
- {
- int n;
-
- const char *colon = strchr (last_function_name, ':');
- if (colon == NULL)
- n = 0;
- else
- n = colon - last_function_name;
- char *p = (char *) alloca (n + 2);
- strncpy (p, last_function_name, n);
- p[n] = 0;
-
- bound_minimal_symbol minsym
- = lookup_minimal_symbol (current_program_space, p, objfile,
- pst->filename);
- if (minsym.minsym == NULL)
- {
- /* Sun Fortran appends an underscore to the minimal symbol name,
- try again with an appended underscore if the minimal symbol
- was not found. */
- p[n] = '_';
- p[n + 1] = 0;
- minsym = lookup_minimal_symbol (current_program_space, p, objfile,
- pst->filename);
- }
-
- if (minsym.minsym)
- pst->set_text_high
- (unrelocated_addr (CORE_ADDR (minsym.minsym->unrelocated_address ())
- + minsym.minsym->size ()));
-
- last_function_name = NULL;
- }
-
- if (!gdbarch_sofun_address_maybe_missing (gdbarch))
- ;
- /* This test will be true if the last .o file is only data. */
- else if (textlow_not_set)
- pst->set_text_low (pst->unrelocated_text_high ());
- else
- {
- /* If we know our own starting text address, then walk through all other
- psymtabs for this objfile, and if any didn't know their ending text
- address, set it to our starting address. Take care to not set our
- own ending address to our starting address. */
-
- for (partial_symtab *p1 : partial_symtabs->range ())
- if (!p1->text_high_valid && p1->text_low_valid && p1 != pst)
- p1->set_text_high (pst->unrelocated_text_low ());
- }
-
- /* End of kludge for patching Solaris textlow and texthigh. */
-
- pst->end ();
-
- pst->number_of_dependencies = number_dependencies;
- if (number_dependencies)
- {
- pst->dependencies
- = partial_symtabs->allocate_dependencies (number_dependencies);
- memcpy (pst->dependencies, dependency_list,
- number_dependencies * sizeof (legacy_psymtab *));
- }
- else
- pst->dependencies = 0;
-
- for (i = 0; i < num_includes; i++)
- {
- legacy_psymtab *subpst =
- new legacy_psymtab (include_list[i], partial_symtabs, objfile->per_bfd);
-
- subpst->read_symtab_private =
- XOBNEW (&objfile->objfile_obstack, struct symloc);
- LDSYMOFF (subpst) =
- LDSYMLEN (subpst) = 0;
-
- /* We could save slight bits of space by only making one of these,
- shared by the entire set of include files. FIXME-someday. */
- subpst->dependencies =
- partial_symtabs->allocate_dependencies (1);
- subpst->dependencies[0] = pst;
- subpst->number_of_dependencies = 1;
-
- subpst->legacy_read_symtab = pst->legacy_read_symtab;
- subpst->legacy_expand_psymtab = pst->legacy_expand_psymtab;
- }
-
- if (num_includes == 0
- && number_dependencies == 0
- && pst->empty ()
- && has_line_numbers == 0)
- {
- /* Throw away this psymtab, it's empty. */
- /* Empty psymtabs happen as a result of header files which don't have
- any symbols in them. There can be a lot of them. But this check
- is wrong, in that a psymtab with N_SLINE entries but nothing else
- is not empty, but we don't realize that. Fixing that without slowing
- things down might be tricky. */
-
- partial_symtabs->discard_psymtab (pst);
-
- /* Indicate that psymtab was thrown away. */
- pst = NULL;
- }
- return pst;
-}
-static void
-dbx_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
-{
- gdb_assert (!pst->readin);
-
- /* Read in all partial symtabs on which this one is dependent. */
- pst->expand_dependencies (objfile);
-
- if (LDSYMLEN (pst)) /* Otherwise it's a dummy. */
- {
- /* Init stuff necessary for reading in symbols */
- stabsread_init ();
- scoped_free_pendings free_pending;
- file_string_table_offset = FILE_STRING_OFFSET (pst);
- symbol_size = SYMBOL_SIZE (pst);
-
- /* Read in this file's symbols. */
- if (bfd_seek (objfile->obfd.get (), SYMBOL_OFFSET (pst), SEEK_SET) == 0)
- read_ofile_symtab (objfile, pst);
- }
- pst->readin = true;
-}
-
-/* Read in all of the symbols for a given psymtab for real.
- Be verbose about it if the user wants that. SELF is not NULL. */
-
-static void
-dbx_read_symtab (legacy_psymtab *self, struct objfile *objfile)
-{
- gdb_assert (!self->readin);
-
- if (LDSYMLEN (self) || self->number_of_dependencies)
- {
- next_symbol_text_func = dbx_next_symbol_text;
-
- {
- scoped_restore restore_stabs_data = make_scoped_restore (&stabs_data);
- gdb::unique_xmalloc_ptr<gdb_byte> data_holder;
- if (DBX_STAB_SECTION (objfile))
- {
- stabs_data
- = symfile_relocate_debug_section (objfile,
- DBX_STAB_SECTION (objfile),
- NULL);
- data_holder.reset (stabs_data);
- }
-
- self->expand_psymtab (objfile);
- }
-
- /* Match with global symbols. This only needs to be done once,
- after all of the symtabs and dependencies have been read in. */
- scan_file_globals (objfile);
- }
-}
-
-/* Read in a defined section of a specific object file's symbols. */
-
-static void
-read_ofile_symtab (struct objfile *objfile, legacy_psymtab *pst)
-{
- const char *namestring;
- struct external_nlist *bufp;
- struct internal_nlist nlist;
- unsigned char type;
- unsigned max_symnum;
- bfd *abfd;
- int sym_offset; /* Offset to start of symbols to read */
- int sym_size; /* Size of symbols to read */
- CORE_ADDR text_offset; /* Start of text segment for symbols */
- int text_size; /* Size of text segment for symbols */
-
- sym_offset = LDSYMOFF (pst);
- sym_size = LDSYMLEN (pst);
- text_offset = pst->text_low (objfile);
- text_size = pst->text_high (objfile) - pst->text_low (objfile);
- const section_offsets &section_offsets = objfile->section_offsets;
-
- dbxread_objfile = objfile;
-
- stringtab_global = DBX_STRINGTAB (objfile);
- set_last_source_file (NULL);
-
- abfd = objfile->obfd.get ();
- symfile_bfd = objfile->obfd.get (); /* Implicit param to next_text_symbol. */
- symbuf_end = symbuf_idx = 0;
- symbuf_read = 0;
- symbuf_left = sym_offset + sym_size;
-
- /* It is necessary to actually read one symbol *before* the start
- of this symtab's symbols, because the GCC_COMPILED_FLAG_SYMBOL
- occurs before the N_SO symbol.
-
- Detecting this in read_dbx_symtab
- would slow down initial readin, so we look for it here instead. */
- if (!processing_acc_compilation && sym_offset >= (int) symbol_size)
- {
- stabs_seek (sym_offset - symbol_size);
- fill_symbuf (abfd);
- bufp = &symbuf[symbuf_idx++];
- INTERNALIZE_SYMBOL (nlist, bufp, abfd);
- OBJSTAT (objfile, n_stabs++);
-
- namestring = set_namestring (objfile, &nlist);
-
- processing_gcc_compilation = 0;
- if (nlist.n_type == N_TEXT)
- {
- const char *tempstring = namestring;
-
- if (strcmp (namestring, GCC_COMPILED_FLAG_SYMBOL) == 0)
- processing_gcc_compilation = 1;
- else if (strcmp (namestring, GCC2_COMPILED_FLAG_SYMBOL) == 0)
- processing_gcc_compilation = 2;
- if (*tempstring != '\0'
- && *tempstring == bfd_get_symbol_leading_char (symfile_bfd))
- ++tempstring;
- if (startswith (tempstring, "__gnu_compiled"))
- processing_gcc_compilation = 2;
- }
- }
- else
- {
- /* The N_SO starting this symtab is the first symbol, so we
- better not check the symbol before it. I'm not this can
- happen, but it doesn't hurt to check for it. */
- stabs_seek (sym_offset);
- processing_gcc_compilation = 0;
- }
-
- if (symbuf_idx == symbuf_end)
- fill_symbuf (abfd);
- bufp = &symbuf[symbuf_idx];
- if (bfd_h_get_8 (abfd, bufp->e_type) != N_SO)
- error (_("First symbol in segment of executable not a source symbol"));
-
- max_symnum = sym_size / symbol_size;
-
- for (symnum = 0;
- symnum < max_symnum;
- symnum++)
- {
- QUIT; /* Allow this to be interruptable. */
- if (symbuf_idx == symbuf_end)
- fill_symbuf (abfd);
- bufp = &symbuf[symbuf_idx++];
- INTERNALIZE_SYMBOL (nlist, bufp, abfd);
- OBJSTAT (objfile, n_stabs++);
-
- type = bfd_h_get_8 (abfd, bufp->e_type);
-
- namestring = set_namestring (objfile, &nlist);
-
- if (type & N_STAB)
- {
- if (sizeof (nlist.n_value) > 4
- /* We are a 64-bit debugger debugging a 32-bit program. */
- && (type == N_LSYM || type == N_PSYM))
- /* We have to be careful with the n_value in the case of N_LSYM
- and N_PSYM entries, because they are signed offsets from frame
- pointer, but we actually read them as unsigned 32-bit values.
- This is not a problem for 32-bit debuggers, for which negative
- values end up being interpreted correctly (as negative
- offsets) due to integer overflow.
- But we need to sign-extend the value for 64-bit debuggers,
- or we'll end up interpreting negative values as very large
- positive offsets. */
- nlist.n_value = (nlist.n_value ^ 0x80000000) - 0x80000000;
- process_one_symbol (type, nlist.n_desc, nlist.n_value,
- namestring, section_offsets, objfile,
- PST_LANGUAGE (pst));
- }
- /* We skip checking for a new .o or -l file; that should never
- happen in this routine. */
- else if (type == N_TEXT)
- {
- /* I don't think this code will ever be executed, because
- the GCC_COMPILED_FLAG_SYMBOL usually is right before
- the N_SO symbol which starts this source file.
- However, there is no reason not to accept
- the GCC_COMPILED_FLAG_SYMBOL anywhere. */
-
- if (strcmp (namestring, GCC_COMPILED_FLAG_SYMBOL) == 0)
- processing_gcc_compilation = 1;
- else if (strcmp (namestring, GCC2_COMPILED_FLAG_SYMBOL) == 0)
- processing_gcc_compilation = 2;
- }
- else if (type & N_EXT || type == (unsigned char) N_TEXT
- || type == (unsigned char) N_NBTEXT)
- {
- /* Global symbol: see if we came across a dbx definition for
- a corresponding symbol. If so, store the value. Remove
- syms from the chain when their values are stored, but
- search the whole chain, as there may be several syms from
- different files with the same name. */
- /* This is probably not true. Since the files will be read
- in one at a time, each reference to a global symbol will
- be satisfied in each file as it appears. So we skip this
- section. */
- ;
- }
- }
-
- /* In a Solaris elf file, this variable, which comes from the value
- of the N_SO symbol, will still be 0. Luckily, text_offset, which
- comes from low text address of PST, is correct. */
- if (get_last_source_start_addr () == 0)
- set_last_source_start_addr (text_offset);
-
- /* In reordered executables last_source_start_addr may not be the
- lower bound for this symtab, instead use text_offset which comes
- from the low text address of PST, which is correct. */
- if (get_last_source_start_addr () > text_offset)
- set_last_source_start_addr (text_offset);
-
- pst->compunit_symtab = end_compunit_symtab (text_offset + text_size);
-
- end_stabs ();
-
- dbxread_objfile = NULL;
-}
-
-/* Record the namespace that the function defined by SYMBOL was
- defined in, if necessary. BLOCK is the associated block; use
- OBSTACK for allocation. */
-
-static void
-cp_set_block_scope (const struct symbol *symbol,
- struct block *block,
- struct obstack *obstack)
-{
- if (symbol->demangled_name () != NULL)
- {
- /* Try to figure out the appropriate namespace from the
- demangled name. */
-
- /* FIXME: carlton/2003-04-15: If the function in question is
- a method of a class, the name will actually include the
- name of the class as well. This should be harmless, but
- is a little unfortunate. */
-
- const char *name = symbol->demangled_name ();
- unsigned int prefix_len = cp_entire_prefix_len (name);
-
- block->set_scope (obstack_strndup (obstack, name, prefix_len),
- obstack);
- }
-}
-
-/* This handles a single symbol from the symbol-file, building symbols
- into a GDB symtab. It takes these arguments and an implicit argument.
-
- TYPE is the type field of the ".stab" symbol entry.
- DESC is the desc field of the ".stab" entry.
- VALU is the value field of the ".stab" entry.
- NAME is the symbol name, in our address space.
- SECTION_OFFSETS is a set of amounts by which the sections of this
- object file were relocated when it was loaded into memory. Note
- that these section_offsets are not the objfile->section_offsets but
- the pst->section_offsets. All symbols that refer to memory
- locations need to be offset by these amounts.
- OBJFILE is the object file from which we are reading symbols. It
- is used in end_compunit_symtab.
- LANGUAGE is the language of the symtab.
-*/
-
-void
-process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
- const section_offsets &section_offsets,
- struct objfile *objfile, enum language language)
-{
- struct gdbarch *gdbarch = objfile->arch ();
- struct context_stack *newobj;
- struct context_stack cstk;
- /* This remembers the address of the start of a function. It is
- used because in Solaris 2, N_LBRAC, N_RBRAC, and N_SLINE entries
- are relative to the current function's start address. On systems
- other than Solaris 2, this just holds the SECT_OFF_TEXT value,
- and is used to relocate these symbol types rather than
- SECTION_OFFSETS. */
- static CORE_ADDR function_start_offset;
-
- /* This holds the address of the start of a function, without the
- system peculiarities of function_start_offset. */
- static CORE_ADDR last_function_start;
-
- /* If this is nonzero, we've seen an N_SLINE since the start of the
- current function. We use this to tell us to move the first sline
- to the beginning of the function regardless of what its given
- value is. */
- static int sline_found_in_function = 1;
-
- /* If this is nonzero, we've seen a non-gcc N_OPT symbol for this
- source file. Used to detect the SunPRO solaris compiler. */
- static int n_opt_found;
-
- /* The section index for this symbol. */
- int section_index = -1;
-
- /* Something is wrong if we see real data before seeing a source
- file name. */
-
- if (get_last_source_file () == NULL && type != (unsigned char) N_SO)
- {
- /* Ignore any symbols which appear before an N_SO symbol.
- Currently no one puts symbols there, but we should deal
- gracefully with the case. A complain()t might be in order,
- but this should not be an error (). */
- return;
- }
-
- switch (type)
- {
- case N_FUN:
- case N_FNAME:
-
- if (*name == '\000')
- {
- /* This N_FUN marks the end of a function. This closes off
- the current block. */
- struct block *block;
-
- if (outermost_context_p ())
- {
- lbrac_mismatch_complaint (symnum);
- break;
- }
-
- /* The following check is added before recording line 0 at
- end of function so as to handle hand-generated stabs
- which may have an N_FUN stabs at the end of the function,
- but no N_SLINE stabs. */
- if (sline_found_in_function)
- {
- CORE_ADDR addr = last_function_start + valu;
-
- record_line
- (get_current_subfile (), 0,
- unrelocated_addr (gdbarch_addr_bits_remove (gdbarch, addr)
- - objfile->text_section_offset ()));
- }
-
- within_function = 0;
- cstk = pop_context ();
-
- /* Make a block for the local symbols within. */
- block = finish_block (cstk.name,
- cstk.old_blocks, NULL,
- cstk.start_addr, cstk.start_addr + valu);
-
- /* For C++, set the block's scope. */
- if (cstk.name->language () == language_cplus)
- cp_set_block_scope (cstk.name, block, &objfile->objfile_obstack);
-
- /* May be switching to an assembler file which may not be using
- block relative stabs, so reset the offset. */
- function_start_offset = 0;
-
- break;
- }
-
- sline_found_in_function = 0;
-
- /* Relocate for dynamic loading. */
- section_index = SECT_OFF_TEXT (objfile);
- valu += section_offsets[SECT_OFF_TEXT (objfile)];
- valu = gdbarch_addr_bits_remove (gdbarch, valu);
- last_function_start = valu;
-
- goto define_a_symbol;
-
- case N_LBRAC:
- /* This "symbol" just indicates the start of an inner lexical
- context within a function. */
-
- /* Ignore extra outermost context from SunPRO cc and acc. */
- if (n_opt_found && desc == 1)
- break;
-
- valu += function_start_offset;
-
- push_context (desc, valu);
- break;
-
- case N_RBRAC:
- /* This "symbol" just indicates the end of an inner lexical
- context that was started with N_LBRAC. */
-
- /* Ignore extra outermost context from SunPRO cc and acc. */
- if (n_opt_found && desc == 1)
- break;
-
- valu += function_start_offset;
-
- if (outermost_context_p ())
- {
- lbrac_mismatch_complaint (symnum);
- break;
- }
-
- cstk = pop_context ();
- if (desc != cstk.depth)
- lbrac_mismatch_complaint (symnum);
-
- if (*get_local_symbols () != NULL)
- {
- /* GCC development snapshots from March to December of
- 2000 would output N_LSYM entries after N_LBRAC
- entries. As a consequence, these symbols are simply
- discarded. Complain if this is the case. */
- complaint (_("misplaced N_LBRAC entry; discarding local "
- "symbols which have no enclosing block"));
- }
- *get_local_symbols () = cstk.locals;
-
- if (get_context_stack_depth () > 1)
- {
- /* This is not the outermost LBRAC...RBRAC pair in the
- function, its local symbols preceded it, and are the ones
- just recovered from the context stack. Define the block
- for them (but don't bother if the block contains no
- symbols. Should we complain on blocks without symbols?
- I can't think of any useful purpose for them). */
- if (*get_local_symbols () != NULL)
- {
- /* Muzzle a compiler bug that makes end < start.
-
- ??? Which compilers? Is this ever harmful?. */
- if (cstk.start_addr > valu)
- {
- complaint (_("block start larger than block end"));
- cstk.start_addr = valu;
- }
- /* Make a block for the local symbols within. */
- finish_block (0, cstk.old_blocks, NULL,
- cstk.start_addr, valu);
- }
- }
- else
- {
- /* This is the outermost LBRAC...RBRAC pair. There is no
- need to do anything; leave the symbols that preceded it
- to be attached to the function's own block. We need to
- indicate that we just moved outside of the function. */
- within_function = 0;
- }
-
- break;
-
- case N_FN:
- case N_FN_SEQ:
- /* This kind of symbol indicates the start of an object file.
- Relocate for dynamic loading. */
- section_index = SECT_OFF_TEXT (objfile);
- valu += section_offsets[SECT_OFF_TEXT (objfile)];
- break;
-
- case N_SO:
- /* This type of symbol indicates the start of data for one
- source file. Finish the symbol table of the previous source
- file (if any) and start accumulating a new symbol table.
- Relocate for dynamic loading. */
- section_index = SECT_OFF_TEXT (objfile);
- valu += section_offsets[SECT_OFF_TEXT (objfile)];
-
- n_opt_found = 0;
-
- if (get_last_source_file ())
- {
- /* Check if previous symbol was also an N_SO (with some
- sanity checks). If so, that one was actually the
- directory name, and the current one is the real file
- name. Patch things up. */
- if (previous_stab_code == (unsigned char) N_SO)
- {
- patch_subfile_names (get_current_subfile (), name);
- break; /* Ignore repeated SOs. */
- }
- end_compunit_symtab (valu);
- end_stabs ();
- }
-
- /* Null name means this just marks the end of text for this .o
- file. Don't start a new symtab in this case. */
- if (*name == '\000')
- break;
-
- function_start_offset = 0;
-
- start_stabs ();
- start_compunit_symtab (objfile, name, NULL, valu, language);
- record_debugformat ("stabs");
- break;
-
- case N_SOL:
- /* This type of symbol indicates the start of data for a
- sub-source-file, one whose contents were copied or included
- in the compilation of the main source file (whose name was
- given in the N_SO symbol). Relocate for dynamic loading. */
- section_index = SECT_OFF_TEXT (objfile);
- valu += section_offsets[SECT_OFF_TEXT (objfile)];
- start_subfile (name);
- break;
-
- case N_BINCL:
- push_subfile ();
- add_new_header_file (name, valu);
- start_subfile (name);
- break;
-
- case N_EINCL:
- start_subfile (pop_subfile ());
- break;
-
- case N_EXCL:
- add_old_header_file (name, valu);
- break;
-
- case N_SLINE:
- /* This type of "symbol" really just records one line-number --
- core-address correspondence. Enter it in the line list for
- this symbol table. */
-
- /* Relocate for dynamic loading and for ELF acc
- function-relative symbols. */
- valu += function_start_offset;
-
- /* GCC 2.95.3 emits the first N_SLINE stab somewhere in the
- middle of the prologue instead of right at the start of the
- function. To deal with this we record the address for the
- first N_SLINE stab to be the start of the function instead of
- the listed location. We really shouldn't to this. When
- compiling with optimization, this first N_SLINE stab might be
- optimized away. Other (non-GCC) compilers don't emit this
- stab at all. There is no real harm in having an extra
- numbered line, although it can be a bit annoying for the
- user. However, it totally screws up our testsuite.
-
- So for now, keep adjusting the address of the first N_SLINE
- stab, but only for code compiled with GCC. */
-
- if (within_function && sline_found_in_function == 0)
- {
- CORE_ADDR addr = processing_gcc_compilation == 2 ?
- last_function_start : valu;
-
- record_line
- (get_current_subfile (), desc,
- unrelocated_addr (gdbarch_addr_bits_remove (gdbarch, addr)
- - objfile->text_section_offset ()));
- sline_found_in_function = 1;
- }
- else
- record_line
- (get_current_subfile (), desc,
- unrelocated_addr (gdbarch_addr_bits_remove (gdbarch, valu)
- - objfile->text_section_offset ()));
- break;
-
- case N_BCOMM:
- common_block_start (name, objfile);
- break;
-
- case N_ECOMM:
- common_block_end (objfile);
- break;
-
- /* The following symbol types need to have the appropriate
- offset added to their value; then we process symbol
- definitions in the name. */
-
- case N_STSYM: /* Static symbol in data segment. */
- case N_LCSYM: /* Static symbol in BSS segment. */
- case N_ROSYM: /* Static symbol in read-only data segment. */
- /* HORRID HACK DEPT. However, it's Sun's furgin' fault.
- Solaris 2's stabs-in-elf makes *most* symbols relative but
- leaves a few absolute (at least for Solaris 2.1 and version
- 2.0.1 of the SunPRO compiler). N_STSYM and friends sit on
- the fence. .stab "foo:S...",N_STSYM is absolute (ld
- relocates it) .stab "foo:V...",N_STSYM is relative (section
- base subtracted). This leaves us no choice but to search for
- the 'S' or 'V'... (or pass the whole section_offsets stuff
- down ONE MORE function call level, which we really don't want
- to do). */
- {
- const char *p;
-
- /* Normal object file and NLMs have non-zero text seg offsets,
- but don't need their static syms offset in this fashion.
- XXX - This is really a crock that should be fixed in the
- solib handling code so that I don't have to work around it
- here. */
-
- if (!symfile_relocatable)
- {
- p = strchr (name, ':');
- if (p != 0 && p[1] == 'S')
- {
- /* The linker relocated it. We don't want to add a
- Sun-stabs Tfoo.foo-like offset, but we *do*
- want to add whatever solib.c passed to
- symbol_file_add as addr (this is known to affect
- SunOS 4, and I suspect ELF too). Since there is no
- Ttext.text symbol, we can get addr from the text offset. */
- section_index = SECT_OFF_TEXT (objfile);
- valu += section_offsets[SECT_OFF_TEXT (objfile)];
- goto define_a_symbol;
- }
- }
- /* Since it's not the kludge case, re-dispatch to the right
- handler. */
- switch (type)
- {
- case N_STSYM:
- goto case_N_STSYM;
- case N_LCSYM:
- goto case_N_LCSYM;
- case N_ROSYM:
- goto case_N_ROSYM;
- default:
- internal_error (_("failed internal consistency check"));
- }
- }
-
- case_N_STSYM: /* Static symbol in data segment. */
- case N_DSLINE: /* Source line number, data segment. */
- section_index = SECT_OFF_DATA (objfile);
- valu += section_offsets[SECT_OFF_DATA (objfile)];
- goto define_a_symbol;
-
- case_N_LCSYM: /* Static symbol in BSS segment. */
- case N_BSLINE: /* Source line number, BSS segment. */
- /* N_BROWS: overlaps with N_BSLINE. */
- section_index = SECT_OFF_BSS (objfile);
- valu += section_offsets[SECT_OFF_BSS (objfile)];
- goto define_a_symbol;
-
- case_N_ROSYM: /* Static symbol in read-only data segment. */
- section_index = SECT_OFF_RODATA (objfile);
- valu += section_offsets[SECT_OFF_RODATA (objfile)];
- goto define_a_symbol;
-
- case N_ENTRY: /* Alternate entry point. */
- /* Relocate for dynamic loading. */
- section_index = SECT_OFF_TEXT (objfile);
- valu += section_offsets[SECT_OFF_TEXT (objfile)];
- goto define_a_symbol;
-
- /* The following symbol types we don't know how to process.
- Handle them in a "default" way, but complain to people who
- care. */
- default:
- case N_CATCH: /* Exception handler catcher. */
- case N_EHDECL: /* Exception handler name. */
- case N_PC: /* Global symbol in Pascal. */
- case N_M2C: /* Modula-2 compilation unit. */
- /* N_MOD2: overlaps with N_EHDECL. */
- case N_SCOPE: /* Modula-2 scope information. */
- case N_ECOML: /* End common (local name). */
- case N_NBTEXT: /* Gould Non-Base-Register symbols??? */
- case N_NBDATA:
- case N_NBBSS:
- case N_NBSTS:
- case N_NBLCS:
- unknown_symtype_complaint (hex_string (type));
-
- define_a_symbol:
- [[fallthrough]];
- /* These symbol types don't need the address field relocated,
- since it is either unused, or is absolute. */
- case N_GSYM: /* Global variable. */
- case N_NSYMS: /* Number of symbols (Ultrix). */
- case N_NOMAP: /* No map? (Ultrix). */
- case N_RSYM: /* Register variable. */
- case N_DEFD: /* Modula-2 GNU module dependency. */
- case N_SSYM: /* Struct or union element. */
- case N_LSYM: /* Local symbol in stack. */
- case N_PSYM: /* Parameter variable. */
- case N_LENG: /* Length of preceding symbol type. */
- if (name)
- {
- int deftype;
- const char *colon_pos = strchr (name, ':');
-
- if (colon_pos == NULL)
- deftype = '\0';
- else
- deftype = colon_pos[1];
-
- switch (deftype)
- {
- case 'f':
- case 'F':
- /* Deal with the SunPRO 3.0 compiler which omits the
- address from N_FUN symbols. */
- if (type == N_FUN
- && valu == section_offsets[SECT_OFF_TEXT (objfile)]
- && gdbarch_sofun_address_maybe_missing (gdbarch))
- {
- bound_minimal_symbol minsym
- = find_stab_function (name, get_last_source_file (),
- objfile);
- if (minsym.minsym != NULL)
- valu = minsym.value_address ();
- }
-
- /* These addresses are absolute. */
- function_start_offset = valu;
-
- within_function = 1;
-
- if (get_context_stack_depth () > 1)
- {
- complaint (_("unmatched N_LBRAC before symtab pos %d"),
- symnum);
- break;
- }
-
- if (!outermost_context_p ())
- {
- struct block *block;
-
- cstk = pop_context ();
- /* Make a block for the local symbols within. */
- block = finish_block (cstk.name,
- cstk.old_blocks, NULL,
- cstk.start_addr, valu);
-
- /* For C++, set the block's scope. */
- if (cstk.name->language () == language_cplus)
- cp_set_block_scope (cstk.name, block,
- &objfile->objfile_obstack);
- }
-
- newobj = push_context (0, valu);
- newobj->name = define_symbol (valu, name, desc, type, objfile);
- if (newobj->name != nullptr)
- newobj->name->set_section_index (section_index);
- break;
-
- default:
- {
- struct symbol *sym = define_symbol (valu, name, desc, type,
- objfile);
- if (sym != nullptr)
- sym->set_section_index (section_index);
- }
- break;
- }
- }
- break;
-
- /* We use N_OPT to carry the gcc2_compiled flag. Sun uses it
- for a bunch of other flags, too. Someday we may parse their
- flags; for now we ignore theirs and hope they'll ignore ours. */
- case N_OPT: /* Solaris 2: Compiler options. */
- if (name)
- {
- if (strcmp (name, GCC2_COMPILED_FLAG_SYMBOL) == 0)
- {
- processing_gcc_compilation = 2;
- }
- else
- n_opt_found = 1;
- }
- break;
-
- case N_MAIN: /* Name of main routine. */
- /* FIXME: If one has a symbol file with N_MAIN and then replaces
- it with a symbol file with "main" and without N_MAIN. I'm
- not sure exactly what rule to follow but probably something
- like: N_MAIN takes precedence over "main" no matter what
- objfile it is in; If there is more than one N_MAIN, choose
- the one in the symfile_objfile; If there is more than one
- N_MAIN within a given objfile, complain() and choose
- arbitrarily. (kingdon) */
- if (name != NULL)
- set_objfile_main_name (objfile, name, language_unknown);
- break;
-
- /* The following symbol types can be ignored. */
- case N_OBJ: /* Solaris 2: Object file dir and name. */
- case N_PATCH: /* Solaris 2: Patch Run Time Checker. */
- /* N_UNDF: Solaris 2: File separator mark. */
- /* N_UNDF: -- we will never encounter it, since we only process
- one file's symbols at once. */
- case N_ENDM: /* Solaris 2: End of module. */
- case N_ALIAS: /* SunPro F77: alias name, ignore for now. */
- break;
- }
-
- /* '#' is a GNU C extension to allow one symbol to refer to another
- related symbol.
-
- Generally this is used so that an alias can refer to its main
- symbol. */
- gdb_assert (name);
- if (name[0] == '#')
- {
- /* Initialize symbol reference names and determine if this is a
- definition. If a symbol reference is being defined, go ahead
- and add it. Otherwise, just return. */
-
- const char *s = name;
- int refnum;
-
- /* If this stab defines a new reference ID that is not on the
- reference list, then put it on the reference list.
-
- We go ahead and advance NAME past the reference, even though
- it is not strictly necessary at this time. */
- refnum = symbol_reference_defined (&s);
- if (refnum >= 0)
- if (!ref_search (refnum))
- ref_add (refnum, 0, name, valu);
- name = s;
- }
-
- previous_stab_code = type;
-}
-
-/* FIXME: The only difference between this and elfstab_build_psymtabs
- is the call to install_minimal_symbols for elf, and the support for
- split sections. If the differences are really that small, the code
- should be shared. */
-
-/* Scan and build partial symbols for an coff symbol file.
- The coff file has already been processed to get its minimal symbols.
-
- This routine is the equivalent of dbx_symfile_init and dbx_symfile_read
- rolled into one.
-
- OBJFILE is the object file we are reading symbols from.
- ADDR is the address relative to which the symbols are (e.g.
- the base address of the text segment).
- TEXTADDR is the address of the text section.
- TEXTSIZE is the size of the text section.
- STABSECTS is the list of .stab sections in OBJFILE.
- STABSTROFFSET and STABSTRSIZE define the location in OBJFILE where the
- .stabstr section exists.
-
- This routine is mostly copied from dbx_symfile_init and dbx_symfile_read,
- adjusted for coff details. */
-
-void
-coffstab_build_psymtabs (struct objfile *objfile,
- CORE_ADDR textaddr, unsigned int textsize,
- const std::vector<asection *> &stabsects,
- file_ptr stabstroffset, unsigned int stabstrsize)
-{
- int val;
- bfd *sym_bfd = objfile->obfd.get ();
- const char *name = bfd_get_filename (sym_bfd);
- unsigned int stabsize;
-
- /* Allocate struct to keep track of stab reading. */
- dbx_objfile_data_key.emplace (objfile);
-
- DBX_TEXT_ADDR (objfile) = textaddr;
- DBX_TEXT_SIZE (objfile) = textsize;
-
-#define COFF_STABS_SYMBOL_SIZE 12 /* XXX FIXME XXX */
- DBX_SYMBOL_SIZE (objfile) = COFF_STABS_SYMBOL_SIZE;
- DBX_STRINGTAB_SIZE (objfile) = stabstrsize;
-
- if (stabstrsize > bfd_get_size (sym_bfd))
- error (_("ridiculous string table size: %d bytes"), stabstrsize);
- DBX_STRINGTAB (objfile) = (char *)
- obstack_alloc (&objfile->objfile_obstack, stabstrsize + 1);
- OBJSTAT (objfile, sz_strtab += stabstrsize + 1);
-
- /* Now read in the string table in one big gulp. */
-
- val = bfd_seek (sym_bfd, stabstroffset, SEEK_SET);
- if (val < 0)
- perror_with_name (name);
- val = bfd_read (DBX_STRINGTAB (objfile), stabstrsize, sym_bfd);
- if (val != stabstrsize)
- perror_with_name (name);
-
- stabsread_new_init ();
- free_header_files ();
- init_header_files ();
-
- processing_acc_compilation = 1;
-
- /* In a coff file, we've already installed the minimal symbols that came
- from the coff (non-stab) symbol table, so always act like an
- incremental load here. */
- scoped_restore save_symbuf_sections
- = make_scoped_restore (&symbuf_sections);
- if (stabsects.size () == 1)
- {
- stabsize = bfd_section_size (stabsects[0]);
- DBX_SYMCOUNT (objfile) = stabsize / DBX_SYMBOL_SIZE (objfile);
- DBX_SYMTAB_OFFSET (objfile) = stabsects[0]->filepos;
- }
- else
- {
- DBX_SYMCOUNT (objfile) = 0;
- for (asection *section : stabsects)
- {
- stabsize = bfd_section_size (section);
- DBX_SYMCOUNT (objfile) += stabsize / DBX_SYMBOL_SIZE (objfile);
- }
-
- DBX_SYMTAB_OFFSET (objfile) = stabsects[0]->filepos;
-
- sect_idx = 1;
- symbuf_sections = &stabsects;
- symbuf_left = bfd_section_size (stabsects[0]);
- symbuf_read = 0;
- }
-
- dbx_symfile_read (objfile, 0);
-}
-/* Scan and build partial symbols for an ELF symbol file.
- This ELF file has already been processed to get its minimal symbols.
-
- This routine is the equivalent of dbx_symfile_init and dbx_symfile_read
- rolled into one.
-
- OBJFILE is the object file we are reading symbols from.
- ADDR is the address relative to which the symbols are (e.g.
- the base address of the text segment).
- STABSECT is the BFD section information for the .stab section.
- STABSTROFFSET and STABSTRSIZE define the location in OBJFILE where the
- .stabstr section exists.
-
- This routine is mostly copied from dbx_symfile_init and dbx_symfile_read,
- adjusted for elf details. */
-
-void
-elfstab_build_psymtabs (struct objfile *objfile, asection *stabsect,
- file_ptr stabstroffset, unsigned int stabstrsize)
-{
- int val;
- bfd *sym_bfd = objfile->obfd.get ();
- const char *name = bfd_get_filename (sym_bfd);
-
- stabsread_new_init ();
-
- /* Allocate struct to keep track of stab reading. */
- dbx_objfile_data_key.emplace (objfile);
-
- /* Find the first and last text address. dbx_symfile_read seems to
- want this. */
- find_text_range (sym_bfd, objfile);
-
-#define ELF_STABS_SYMBOL_SIZE 12 /* XXX FIXME XXX */
- DBX_SYMBOL_SIZE (objfile) = ELF_STABS_SYMBOL_SIZE;
- DBX_SYMCOUNT (objfile)
- = bfd_section_size (stabsect) / DBX_SYMBOL_SIZE (objfile);
- DBX_STRINGTAB_SIZE (objfile) = stabstrsize;
- DBX_SYMTAB_OFFSET (objfile) = stabsect->filepos;
- DBX_STAB_SECTION (objfile) = stabsect;
-
- if (stabstrsize > bfd_get_size (sym_bfd))
- error (_("ridiculous string table size: %d bytes"), stabstrsize);
- DBX_STRINGTAB (objfile) = (char *)
- obstack_alloc (&objfile->objfile_obstack, stabstrsize + 1);
- OBJSTAT (objfile, sz_strtab += stabstrsize + 1);
-
- /* Now read in the string table in one big gulp. */
-
- val = bfd_seek (sym_bfd, stabstroffset, SEEK_SET);
- if (val < 0)
- perror_with_name (name);
- val = bfd_read (DBX_STRINGTAB (objfile), stabstrsize, sym_bfd);
- if (val != stabstrsize)
- perror_with_name (name);
-
- stabsread_new_init ();
- free_header_files ();
- init_header_files ();
-
- processing_acc_compilation = 1;
-
- symbuf_read = 0;
- symbuf_left = bfd_section_size (stabsect);
-
- scoped_restore restore_stabs_data = make_scoped_restore (&stabs_data);
- gdb::unique_xmalloc_ptr<gdb_byte> data_holder;
-
- stabs_data = symfile_relocate_debug_section (objfile, stabsect, NULL);
- if (stabs_data)
- data_holder.reset (stabs_data);
-
- /* In an elf file, we've already installed the minimal symbols that came
- from the elf (non-stab) symbol table, so always act like an
- incremental load here. dbx_symfile_read should not generate any new
- minimal symbols, since we will have already read the ELF dynamic symbol
- table and normal symbol entries won't be in the ".stab" section; but in
- case it does, it will install them itself. */
- dbx_symfile_read (objfile, 0);
-}
/* Scan and build partial symbols for a file with special sections for stabs
and stabstrings. The file has already been processed to get its minimal
@@ -3220,7 +332,7 @@ stabsect_build_psymtabs (struct objfile *objfile, char *stab_name,
/* Now, do an incremental load. */
- processing_acc_compilation = 1;
+ dbx_objfile_data_key.get (objfile)->ctx.processing_acc_compilation = 1;
dbx_symfile_read (objfile, 0);
}
diff --git a/gdb/dictionary.h b/gdb/dictionary.h
index 6f602f4..e09afb3 100644
--- a/gdb/dictionary.h
+++ b/gdb/dictionary.h
@@ -113,7 +113,7 @@ struct dict_iterator
struct mdict_iterator
{
- /* The multidictionary with whcih this iterator is associated. */
+ /* The multidictionary with which this iterator is associated. */
const struct multidictionary *mdict;
/* The iterator used to iterate through individual dictionaries. */
diff --git a/gdb/disasm.c b/gdb/disasm.c
index 7209cfc..541293a 100644
--- a/gdb/disasm.c
+++ b/gdb/disasm.c
@@ -899,7 +899,10 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch,
output includes the source specs for each line. */
if (sal.symtab != NULL)
{
- uiout->text (symtab_to_filename_for_display (sal.symtab));
+ auto filename = symtab_to_filename_for_display (sal.symtab);
+ uiout->message ("%ps",
+ styled_string (file_name_style.style (),
+ filename));
}
else
uiout->text ("unknown");
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 77a4021..554608d 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -4289,7 +4289,7 @@ includes changes in memory, registers, and even (within some limits)
system state. Effectively, it is like going back in time to the
moment when the checkpoint was saved.
-Thus, if you're stepping thru a program and you think you're
+Thus, if you're stepping through a program and you think you're
getting close to the point where things go wrong, you can save
a checkpoint. Then, if you accidentally go too far and miss
the critical statement, instead of having to restart your program
@@ -7077,33 +7077,6 @@ $1 = (void *) 0x7ffff7ff7000
Depending on target support, @code{$_siginfo} may also be writable.
-@cindex Intel MPX boundary violations
-@cindex boundary violations, Intel MPX
-On some targets, a @code{SIGSEGV} can be caused by a boundary
-violation, i.e., accessing an address outside of the allowed range.
-In those cases @value{GDBN} may displays additional information,
-depending on how @value{GDBN} has been told to handle the signal.
-With @code{handle stop SIGSEGV}, @value{GDBN} displays the violation
-kind: "Upper" or "Lower", the memory address accessed and the
-bounds, while with @code{handle nostop SIGSEGV} no additional
-information is displayed.
-
-The usual output of a segfault is:
-@smallexample
-Program received signal SIGSEGV, Segmentation fault
-0x0000000000400d7c in upper () at i386-mpx-sigsegv.c:68
-68 value = *(p + len);
-@end smallexample
-
-While a bound violation is presented as:
-@smallexample
-Program received signal SIGSEGV, Segmentation fault
-Upper bound violation while accessing address 0x7fffffffc3b3
-Bounds: [lower = 0x7fffffffc390, upper = 0x7fffffffc3a3]
-0x0000000000400d7c in upper () at i386-mpx-sigsegv.c:68
-68 value = *(p + len);
-@end smallexample
-
@node Thread Stops
@section Stopping and Starting Multi-thread Programs
@@ -7686,7 +7659,7 @@ the called function, stopping at the beginning of the @emph{last}
statement in the called function (typically a return statement).
Also, as with the @code{step} command, if non-debuggable functions are
-called, @code{reverse-step} will run thru them backward without stopping.
+called, @code{reverse-step} will run through them backward without stopping.
@kindex reverse-stepi
@kindex rsi @r{(@code{reverse-stepi})}
@@ -8116,6 +8089,16 @@ also need longer to process the branch trace data before it can be used.
Show the current setting of the requested ring buffer size for branch
tracing in Intel Processor Trace format.
+@item set record btrace pt event-tracing
+Enable or disable event tracing for branch tracing in Intel Processor
+Trace format. When enabled, events are recorded during execution as
+auxiliary information and will be printed during stepping commands and
+commands displaying the execution history. Changing this setting has no
+effect on an active recording. The default is off.
+
+@item show record btrace pt event-tracing
+Show the current setting of Intel Processor Trace event tracing.
+
@kindex info record
@item info record
Show various statistics about the recording depending on the recording
@@ -18315,6 +18298,9 @@ All Modula-2 built-in procedures also return a result, described below.
@item ABS(@var{n})
Returns the absolute value of @var{n}.
+@item ADR(@var{n})
+Returns the memory address of @var{n}.
+
@item CAP(@var{c})
If @var{c} is a lower case letter, it returns its upper case
equivalent, otherwise it returns its argument.
@@ -22879,6 +22865,19 @@ Print the number of cache hits and misses since the launch of @value{GDBN}.
@end table
+@subsection Building the index with GNU @command{gold}
+
+The GNU @command{gold} linker can write the index at link time into
+the resulting ELF file, by passing the @command{--gdb-index} flag to
+@command{gold}.
+
+This is especially helpful if you intend to build a program and immediately
+run it under @value{GDBN}. You may find that it is faster overall for
+the linker to write the index while it has the relevant information in
+memory anyways, rather than re-reloading the data from disk with
+@command{gdb-add-index}, or debugging the program without an index at
+all, especially for large programs.
+
@node Debug Names
@section Extensions to @samp{.debug_names}
@cindex index files
@@ -26793,91 +26792,6 @@ Show the current setting of the convention to return @code{struct}s
from functions.
@end table
-
-@subsubsection Intel @dfn{Memory Protection Extensions} (MPX).
-@cindex Intel Memory Protection Extensions (MPX).
-
-Memory Protection Extension (MPX) adds the bound registers @samp{BND0}
-@footnote{The register named with capital letters represent the architecture
-registers.} through @samp{BND3}. Bound registers store a pair of 64-bit values
-which are the lower bound and upper bound. Bounds are effective addresses or
-memory locations. The upper bounds are architecturally represented in 1's
-complement form. A bound having lower bound = 0, and upper bound = 0
-(1's complement of all bits set) will allow access to the entire address space.
-
-@samp{BND0} through @samp{BND3} are represented in @value{GDBN} as @samp{bnd0raw}
-through @samp{bnd3raw}. Pseudo registers @samp{bnd0} through @samp{bnd3}
-display the upper bound performing the complement of one operation on the
-upper bound value, i.e.@ when upper bound in @samp{bnd0raw} is 0 in the
-@value{GDBN} @samp{bnd0} it will be @code{0xfff@dots{}}. In this sense it
-can also be noted that the upper bounds are inclusive.
-
-As an example, assume that the register BND0 holds bounds for a pointer having
-access allowed for the range between 0x32 and 0x71. The values present on
-bnd0raw and bnd registers are presented as follows:
-
-@smallexample
- bnd0raw = @{0x32, 0xffffffff8e@}
- bnd0 = @{lbound = 0x32, ubound = 0x71@} : size 64
-@end smallexample
-
-This way the raw value can be accessed via bnd0raw@dots{}bnd3raw. Any
-change on bnd0@dots{}bnd3 or bnd0raw@dots{}bnd3raw is reflect on its
-counterpart. When the bnd0@dots{}bnd3 registers are displayed via
-Python, the display includes the memory size, in bits, accessible to
-the pointer.
-
-Bounds can also be stored in bounds tables, which are stored in
-application memory. These tables store bounds for pointers by specifying
-the bounds pointer's value along with its bounds. Evaluating and changing
-bounds located in bound tables is therefore interesting while investigating
-bugs on MPX context. @value{GDBN} provides commands for this purpose:
-
-@table @code
-@item show mpx bound @var{pointer}
-@kindex show mpx bound
-Display bounds of the given @var{pointer}.
-
-@item set mpx bound @var{pointer}, @var{lbound}, @var{ubound}
-@kindex set mpx bound
-Set the bounds of a pointer in the bound table.
-This command takes three parameters: @var{pointer} is the pointers
-whose bounds are to be changed, @var{lbound} and @var{ubound} are new values
-for lower and upper bounds respectively.
-@end table
-
-Both commands are deprecated and will be removed in future versions of
-@value{GDBN}. MPX itself was listed as removed by Intel in 2019.
-
-When you call an inferior function on an Intel MPX enabled program,
-GDB sets the inferior's bound registers to the init (disabled) state
-before calling the function. As a consequence, bounds checks for the
-pointer arguments passed to the function will always pass.
-
-This is necessary because when you call an inferior function, the
-program is usually in the middle of the execution of other function.
-Since at that point bound registers are in an arbitrary state, not
-clearing them would lead to random bound violations in the called
-function.
-
-You can still examine the influence of the bound registers on the
-execution of the called function by stopping the execution of the
-called function at its prologue, setting bound registers, and
-continuing the execution. For example:
-
-@smallexample
- $ break *upper
- Breakpoint 2 at 0x4009de: file i386-mpx-call.c, line 47.
- $ print upper (a, b, c, d, 1)
- Breakpoint 2, upper (a=0x0, b=0x6e0000005b, c=0x0, d=0x0, len=48)....
- $ print $bnd0
- @{lbound = 0x0, ubound = ffffffff@} : size -1
-@end smallexample
-
-At this last step the value of bnd0 can be changed for investigation of bound
-violations caused along the execution of the call. In order to know how to
-set the bound registers or bound table for the call consult the ABI.
-
@subsubsection x87 registers
@value{GDBN} provides access to the x87 state through the following registers:
@@ -27954,6 +27868,10 @@ if @value{GDBN} is using its builtin disassembler library for styling
(@pxref{style_disassembler_enabled,,@kbd{set style disassembler
enabled}}).
+@item line-number
+Control the styling of line numbers. By default, this style's
+intensity is dim.
+
@item variable
Control the styling of variable names. These are managed with the
@code{set style variable} family of commands. By default, this style's
@@ -42072,7 +41990,11 @@ including registers which aren't available on the target nor visible
to user; the command @code{maint print register-groups} includes the
groups that each register is a member of; and the command @code{maint
print remote-registers} includes the remote target's register numbers
-and offsets in the `G' packets.
+and offsets in the `G' packets, as well as an indication of which
+registers were included in the last stop reply packet received by
+@value{GDBN} (@pxref{Stop Reply Packets}). Please note that the list
+of registers included in a stop reply can change from one stop to the
+next.
These commands take an optional parameter, a file name to which to
write the information.
@@ -45007,6 +44929,11 @@ These are the currently defined stub features and their properties:
@tab @samp{-}
@tab Yes
+@item @samp{Qbtrace-conf:pt:event-tracing}
+@tab Yes
+@tab @samp{-}
+@tab Yes
+
@item @samp{QNonStop}
@tab No
@tab @samp{-}
@@ -45331,6 +45258,9 @@ The remote stub understands the @samp{Qbtrace-conf:pt:size} packet.
@item Qbtrace-conf:pt:ptwrite
The remote stub understands the @samp{Qbtrace-conf:pt:ptwrite} packet.
+@item Qbtrace-conf:pt:event-tracing
+The remote stub understands the @samp{Qbtrace-conf:pt:event-tracing} packet.
+
@item swbreak
The remote stub reports the @samp{swbreak} stop reason for memory
breakpoints.
@@ -45832,6 +45762,18 @@ The ptwrite config parameter has been set.
A badly formed request or an error was encountered.
@end table
+@item Qbtrace-conf:pt:event-tracing=@var{(yes|no)}
+Indicate support for event-tracing packets. This allows for backwards
+compatibility.
+
+Reply:
+@table @samp
+@item OK
+The event-tracing config parameter has been set.
+@item E.errtext
+A badly formed request or an error was encountered.
+@end table
+
@end table
@node Architecture-Specific Protocol Details
@@ -48465,15 +48407,16 @@ branch trace configuration discovery. @xref{Expat}.
The formal DTD for the branch trace configuration format is given below:
@smallexample
-<!ELEMENT btrace-conf (bts?, pt?)>
-<!ATTLIST btrace-conf version CDATA #FIXED "1.0">
+<!ELEMENT btrace-conf (bts?, pt?)>
+<!ATTLIST btrace-conf version CDATA #FIXED "1.0">
<!ELEMENT bts EMPTY>
-<!ATTLIST bts size CDATA #IMPLIED>
+<!ATTLIST bts size CDATA #IMPLIED>
<!ELEMENT pt EMPTY>
-<!ATTLIST pt size CDATA #IMPLIED>
-<!ATTLIST pt ptwrite (yes | no) #IMPLIED>
+<!ATTLIST pt size CDATA #IMPLIED>
+<!ATTLIST pt ptwrite (yes | no) #IMPLIED>
+<!ATTLIST pt event-tracing (yes | no) #IMPLIED>
@end smallexample
@include agentexpr.texi
@@ -49711,16 +49654,6 @@ describe the upper 128 bits of @sc{ymm} registers:
@samp{ymm0h} through @samp{ymm15h} for amd64
@end itemize
-The @samp{org.gnu.gdb.i386.mpx} is an optional feature representing Intel
-Memory Protection Extension (MPX). It should describe the following registers:
-
-@itemize @minus
-@item
-@samp{bnd0raw} through @samp{bnd3raw} for i386 and amd64.
-@item
-@samp{bndcfgu} and @samp{bndstatus} for i386 and amd64.
-@end itemize
-
The @samp{org.gnu.gdb.i386.linux} feature is optional. It should
describe a single register, @samp{orig_eax}.
diff --git a/gdb/dtrace-probe.c b/gdb/dtrace-probe.c
index 0f4e164..ac1b1c5 100644
--- a/gdb/dtrace-probe.c
+++ b/gdb/dtrace-probe.c
@@ -493,7 +493,7 @@ dtrace_process_dof_probe (struct objfile *objfile,
{
}
- if (expr != NULL && expr->first_opcode () == OP_TYPE)
+ if (expr != NULL && expr->type_p ())
type = expr->evaluate_type ()->type ();
args.emplace_back (type, std::move (type_str), std::move (expr));
diff --git a/gdb/dwarf2/abbrev.c b/gdb/dwarf2/abbrev.c
index bae8d8b..c30db1e 100644
--- a/gdb/dwarf2/abbrev.c
+++ b/gdb/dwarf2/abbrev.c
@@ -276,7 +276,8 @@ abbrev_table::read (struct dwarf2_section_info *section,
}
else if ((cur_abbrev->tag == DW_TAG_structure_type
|| cur_abbrev->tag == DW_TAG_class_type
- || cur_abbrev->tag == DW_TAG_union_type)
+ || cur_abbrev->tag == DW_TAG_union_type
+ || cur_abbrev->tag == DW_TAG_namespace)
&& cur_abbrev->has_children)
{
/* We have to record this as interesting, regardless of how
diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h
index 802e856..0873e7d 100644
--- a/gdb/dwarf2/cooked-index.h
+++ b/gdb/dwarf2/cooked-index.h
@@ -778,7 +778,9 @@ struct cooked_index_functions : public dwarf2_base_index_functions
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags,
- domain_search_flags domain) override;
+ domain_search_flags domain,
+ gdb::function_view<expand_symtabs_lang_matcher_ftype> lang_matcher)
+ override;
struct compunit_symtab *find_pc_sect_compunit_symtab
(struct objfile *objfile, bound_minimal_symbol msymbol,
diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c
index 79ef065..841d2d4 100644
--- a/gdb/dwarf2/frame.c
+++ b/gdb/dwarf2/frame.c
@@ -911,7 +911,7 @@ dwarf2_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
its return address. As a result the return address will
point at some random instruction, and the CFI for that
instruction is probably worthless to us. GCC's unwinder solves
- this problem by substracting 1 from the return address to get an
+ this problem by subtracting 1 from the return address to get an
address in the middle of a presumed call instruction (or the
instruction in the associated delay slot). This should only be
done for "normal" frames and not for resume-type frames (signal
@@ -1073,7 +1073,7 @@ incomplete CFI data; unspecified registers (e.g., %s) at %s"),
ULONGEST retaddr_column = fs.retaddr_column;
/* It seems rather bizarre to specify an "empty" column as
- the return adress column. However, this is exactly
+ the return address column. However, this is exactly
what GCC does on some targets. It turns out that GCC
assumes that the return address can be found in the
register corresponding to the return address column.
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 5d1a557..d515386 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -779,7 +779,7 @@ func_addr_to_tail_call_list (struct gdbarch *gdbarch, CORE_ADDR addr)
via its tail calls (incl. transitively). Throw NO_ENTRY_VALUE_ERROR if it
can call itself via tail calls.
- If a funtion can tail call itself its entry value based parameters are
+ If a function can tail call itself its entry value based parameters are
unreliable. There is no verification whether the value of some/all
parameters is unchanged through the self tail call, we expect if there is
a self tail call all the parameters can be modified. */
diff --git a/gdb/dwarf2/parent-map.h b/gdb/dwarf2/parent-map.h
index 5307d4d..6cff548 100644
--- a/gdb/dwarf2/parent-map.h
+++ b/gdb/dwarf2/parent-map.h
@@ -104,6 +104,9 @@ public:
return new (obstack) addrmap_fixed (obstack, &m_map);
}
+ /* Dump a human-readable form of this map. */
+ void dump () const;
+
private:
/* An addrmap that maps from section offsets to cooked_index_entry *. */
@@ -141,6 +144,9 @@ public:
return nullptr;
}
+ /* Dump a human-readable form of this collection of parent_maps. */
+ void dump () const;
+
private:
/* Storage for the convert maps. */
diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c
index 8cd665c..701cdec 100644
--- a/gdb/dwarf2/read-gdb-index.c
+++ b/gdb/dwarf2/read-gdb-index.c
@@ -158,7 +158,9 @@ struct dwarf2_gdb_index : public dwarf2_base_index_functions
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags,
- domain_search_flags domain) override;
+ domain_search_flags domain,
+ gdb::function_view<expand_symtabs_lang_matcher_ftype> lang_matcher)
+ override;
};
/* This dumps minimal information about the index.
@@ -187,7 +189,8 @@ dw2_expand_marked_cus
gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags,
- domain_search_flags kind)
+ domain_search_flags kind,
+ gdb::function_view<expand_symtabs_lang_matcher_ftype> lang_matcher)
{
offset_type vec_len, vec_idx;
bool global_seen = false;
@@ -268,7 +271,7 @@ dw2_expand_marked_cus
dwarf2_per_cu_data *per_cu = per_objfile->per_bfd->get_cu (cu_index);
if (!dw2_expand_symtabs_matching_one (per_cu, per_objfile, file_matcher,
- expansion_notify))
+ expansion_notify, lang_matcher))
return false;
}
@@ -283,7 +286,8 @@ dwarf2_gdb_index::expand_symtabs_matching
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags,
- domain_search_flags domain)
+ domain_search_flags domain,
+ gdb::function_view<expand_symtabs_lang_matcher_ftype> lang_matcher)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
@@ -300,7 +304,8 @@ dwarf2_gdb_index::expand_symtabs_matching
if (!dw2_expand_symtabs_matching_one (per_cu, per_objfile,
file_matcher,
- expansion_notify))
+ expansion_notify,
+ lang_matcher))
return false;
}
return true;
@@ -316,10 +321,11 @@ dwarf2_gdb_index::expand_symtabs_matching
[&] (offset_type idx)
{
if (!dw2_expand_marked_cus (per_objfile, idx, file_matcher,
- expansion_notify, search_flags, domain))
+ expansion_notify, search_flags, domain,
+ lang_matcher))
return false;
return true;
- }, per_objfile);
+ }, per_objfile, lang_matcher);
return result;
}
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index e0dcf94..ea31d8d 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -96,6 +96,7 @@
#include "run-on-main-thread.h"
#include "dwarf2/parent-map.h"
#include "dwarf2/error.h"
+#include <variant>
/* When == 1, print basic high level tracing messages.
When > 1, be more verbose.
@@ -1644,7 +1645,9 @@ struct readnow_functions : public dwarf2_base_index_functions
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags,
- domain_search_flags domain) override
+ domain_search_flags domain,
+ gdb::function_view<expand_symtabs_lang_matcher_ftype> lang_matcher)
+ override
{
return true;
}
@@ -2296,7 +2299,8 @@ dw2_expand_symtabs_matching_symbol
const lookup_name_info &lookup_name_in,
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<bool (offset_type)> match_callback,
- dwarf2_per_objfile *per_objfile)
+ dwarf2_per_objfile *per_objfile,
+ gdb::function_view<expand_symtabs_lang_matcher_ftype> lang_matcher)
{
lookup_name_info lookup_name_without_params
= lookup_name_in.make_ignore_params ();
@@ -2332,6 +2336,8 @@ dw2_expand_symtabs_matching_symbol
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
@@ -2489,7 +2495,7 @@ check_match (const char *file, int line,
if (expected_str == NULL || strcmp (expected_str, matched_name) != 0)
mismatch (expected_str, matched_name);
return true;
- }, per_objfile);
+ }, per_objfile, nullptr);
const char *expected_str
= expected_it == expected_end ? NULL : *expected_it++;
@@ -2850,19 +2856,29 @@ dw2_expand_symtabs_matching_one
(dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile,
gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
- gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify)
+ gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
+ gdb::function_view<expand_symtabs_lang_matcher_ftype> lang_matcher)
{
- if (file_matcher == NULL || per_cu->mark)
+ if (file_matcher != nullptr && !per_cu->mark)
+ return true;
+
+ if (lang_matcher != nullptr)
{
- bool symtab_was_null = !per_objfile->symtab_set_p (per_cu);
+ /* Try to skip CUs with non-matching language. */
+ per_cu->ensure_lang (per_objfile);
+ if (!per_cu->maybe_multi_language ()
+ && !lang_matcher (per_cu->lang ()))
+ return true;
+ }
- compunit_symtab *symtab
- = dw2_instantiate_symtab (per_cu, per_objfile, false);
- gdb_assert (symtab != nullptr);
+ 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 (expansion_notify != NULL && symtab_was_null)
- return expansion_notify (symtab);
- }
return true;
}
@@ -4434,6 +4450,50 @@ cooked_index_storage::eq_cutu_reader (const void *a, const void *b)
return ra->cu->per_cu->index == *rb;
}
+/* Dump MAP as parent_map. */
+
+static void
+dump_parent_map (const struct addrmap *map)
+{
+ auto_obstack temp_storage;
+
+ auto annotate_cooked_index_entry
+ = [&] (struct ui_file *outfile, const void *value)
+ {
+ const cooked_index_entry *parent_entry
+ = (const cooked_index_entry *)value;
+ if (parent_entry == nullptr)
+ return;
+
+ gdb_printf (outfile, " (0x%" PRIx64 ": %s)",
+ to_underlying (parent_entry->die_offset),
+ parent_entry->full_name (&temp_storage, false));
+ };
+
+ addrmap_dump (const_cast<addrmap *> (map), gdb_stdlog, nullptr,
+ annotate_cooked_index_entry);
+}
+
+/* See parent-map.h. */
+
+void
+parent_map::dump () const
+{
+ dump_parent_map (&m_map);
+}
+
+/* See parent-map.h. */
+
+void
+parent_map_map::dump () const
+{
+ for (const auto &iter : m_maps)
+ {
+ gdb_printf (gdb_stdlog, "map start:\n");
+ dump_parent_map (iter);
+ }
+}
+
/* An instance of this is created to index a CU. */
class cooked_indexer
@@ -4471,7 +4531,7 @@ private:
bool is_dwz,
bool for_scanning);
- /* Index DIEs in the READER starting at INFO_PTR. PARENT_ENTRY is
+ /* Index DIEs in the READER starting at INFO_PTR. PARENT is
the entry for the enclosing scope (nullptr at top level). FULLY
is true when a full scan must be done -- in some languages,
function scopes must be fully explored in order to find nested
@@ -4479,7 +4539,8 @@ private:
reading stopped. */
const gdb_byte *index_dies (cutu_reader *reader,
const gdb_byte *info_ptr,
- const cooked_index_entry *parent_entry,
+ std::variant<const cooked_index_entry *,
+ parent_map::addr_type> parent,
bool fully);
/* Scan the attributes for a given DIE and update the out
@@ -4509,7 +4570,8 @@ private:
m_die_range_map and then calling index_dies. */
const gdb_byte *recurse (cutu_reader *reader,
const gdb_byte *info_ptr,
- const cooked_index_entry *parent_entry,
+ std::variant<const cooked_index_entry *,
+ parent_map::addr_type> parent_entry,
bool fully);
/* The storage object, where the results are kept. */
@@ -4826,6 +4888,11 @@ private:
{
if (dwarf_read_debug > 0)
print_tu_stats (m_per_objfile);
+ if (dwarf_read_debug > 1)
+ {
+ dwarf_read_debug_printf_v ("Final m_all_parents_map:");
+ m_all_parents_map.dump ();
+ }
}
/* After the last DWARF-reading task has finished, this function
@@ -16063,6 +16130,10 @@ cooked_indexer::ensure_cu_exists (cutu_reader *reader,
cutu_reader new_reader (per_cu, per_objfile, nullptr, nullptr, false,
m_index_storage->get_abbrev_cache ());
+ if (new_reader.dummy_p || new_reader.comp_unit_die == nullptr
+ || !new_reader.comp_unit_die->has_children)
+ return nullptr;
+
prepare_one_comp_unit (new_reader.cu, new_reader.comp_unit_die,
language_minimal);
std::unique_ptr<cutu_reader> copy
@@ -16070,7 +16141,8 @@ cooked_indexer::ensure_cu_exists (cutu_reader *reader,
result = m_index_storage->preserve (std::move (copy));
}
- if (result->dummy_p || !result->comp_unit_die->has_children)
+ if (result->dummy_p || result->comp_unit_die == nullptr
+ || !result->comp_unit_die->has_children)
return nullptr;
if (for_scanning)
@@ -16238,7 +16310,8 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu,
want to treat them as definitions. */
if ((abbrev->tag == DW_TAG_class_type
|| abbrev->tag == DW_TAG_structure_type
- || abbrev->tag == DW_TAG_union_type)
+ || abbrev->tag == DW_TAG_union_type
+ || abbrev->tag == DW_TAG_namespace)
&& abbrev->has_children)
*flags |= IS_TYPE_DECLARATION;
else
@@ -16256,49 +16329,53 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu,
cutu_reader *new_reader
= ensure_cu_exists (reader, reader->cu->per_objfile, origin_offset,
origin_is_dwz, false);
- if (new_reader != nullptr)
- {
- const gdb_byte *new_info_ptr = (new_reader->buffer
- + to_underlying (origin_offset));
+ if (new_reader == nullptr)
+ error (_(DWARF_ERROR_PREFIX
+ "cannot follow reference to DIE at %s"
+ " [in module %s]"),
+ sect_offset_str (origin_offset),
+ bfd_get_filename (reader->abfd));
- if (*parent_entry == nullptr)
- {
- /* We only perform immediate lookups of parents for DIEs
- from earlier in this CU. This avoids any problem
- with a NULL result when when we see a reference to a
- DIE in another CU that we may or may not have
- imported locally. */
- parent_map::addr_type addr
- = parent_map::form_addr (origin_offset, origin_is_dwz);
- if (new_reader->cu != reader->cu || new_info_ptr > watermark_ptr)
- *maybe_defer = addr;
- else
- *parent_entry = m_die_range_map->find (addr);
- }
+ const gdb_byte *new_info_ptr = (new_reader->buffer
+ + to_underlying (origin_offset));
- unsigned int bytes_read;
- const abbrev_info *new_abbrev = peek_die_abbrev (*new_reader,
- new_info_ptr,
- &bytes_read);
+ if (*parent_entry == nullptr)
+ {
+ /* We only perform immediate lookups of parents for DIEs
+ from earlier in this CU. This avoids any problem
+ with a NULL result when when we see a reference to a
+ DIE in another CU that we may or may not have
+ imported locally. */
+ parent_map::addr_type addr
+ = parent_map::form_addr (origin_offset, origin_is_dwz);
+ if (new_reader->cu != reader->cu || new_info_ptr > watermark_ptr)
+ *maybe_defer = addr;
+ else
+ *parent_entry = m_die_range_map->find (addr);
+ }
- if (new_abbrev == nullptr)
- error (_(DWARF_ERROR_PREFIX
- "Unexpected null DIE at offset %s [in module %s]"),
- sect_offset_str (origin_offset),
- bfd_get_filename (new_reader->abfd));
+ unsigned int bytes_read;
+ const abbrev_info *new_abbrev = peek_die_abbrev (*new_reader,
+ new_info_ptr,
+ &bytes_read);
- new_info_ptr += bytes_read;
+ if (new_abbrev == nullptr)
+ error (_(DWARF_ERROR_PREFIX
+ "Unexpected null DIE at offset %s [in module %s]"),
+ sect_offset_str (origin_offset),
+ bfd_get_filename (new_reader->abfd));
- if (new_reader->cu == reader->cu && new_info_ptr == watermark_ptr)
- {
- /* Self-reference, we're done. */
- }
- else
- scan_attributes (scanning_per_cu, new_reader, new_info_ptr,
- new_info_ptr, new_abbrev, name, linkage_name,
- flags, nullptr, parent_entry, maybe_defer,
- is_enum_class, true);
+ new_info_ptr += bytes_read;
+
+ if (new_reader->cu == reader->cu && new_info_ptr == watermark_ptr)
+ {
+ /* Self-reference, we're done. */
}
+ else
+ scan_attributes (scanning_per_cu, new_reader, new_info_ptr,
+ new_info_ptr, new_abbrev, name, linkage_name,
+ flags, nullptr, parent_entry, maybe_defer,
+ is_enum_class, true);
}
if (!for_specification)
@@ -16393,10 +16470,16 @@ cooked_indexer::index_imported_unit (cutu_reader *reader,
const gdb_byte *
cooked_indexer::recurse (cutu_reader *reader,
const gdb_byte *info_ptr,
- const cooked_index_entry *parent_entry,
+ std::variant<const cooked_index_entry *,
+ parent_map::addr_type> parent,
bool fully)
{
- info_ptr = index_dies (reader, info_ptr, parent_entry, fully);
+ info_ptr = index_dies (reader, info_ptr, parent, fully);
+
+ if (!std::holds_alternative<const cooked_index_entry *> (parent))
+ return info_ptr;
+ const cooked_index_entry *parent_entry
+ = std::get<const cooked_index_entry *> (parent);
if (parent_entry != nullptr)
{
@@ -16417,7 +16500,8 @@ cooked_indexer::recurse (cutu_reader *reader,
const gdb_byte *
cooked_indexer::index_dies (cutu_reader *reader,
const gdb_byte *info_ptr,
- const cooked_index_entry *parent_entry,
+ std::variant<const cooked_index_entry *,
+ parent_map::addr_type> parent,
bool fully)
{
const gdb_byte *end_ptr = (reader->buffer
@@ -16444,15 +16528,20 @@ cooked_indexer::index_dies (cutu_reader *reader,
{
info_ptr = skip_one_die (reader, info_ptr, abbrev, !fully);
if (fully && abbrev->has_children)
- info_ptr = index_dies (reader, info_ptr, parent_entry, fully);
+ info_ptr = index_dies (reader, info_ptr, parent, fully);
continue;
}
const char *name = nullptr;
const char *linkage_name = nullptr;
parent_map::addr_type defer {};
+ if (std::holds_alternative<parent_map::addr_type> (parent))
+ defer = std::get<parent_map::addr_type> (parent);
cooked_index_flag flags = IS_STATIC;
sect_offset sibling {};
+ const cooked_index_entry *parent_entry = nullptr;
+ if (std::holds_alternative<const cooked_index_entry *> (parent))
+ parent_entry = std::get<const cooked_index_entry *> (parent);
const cooked_index_entry *this_parent_entry = parent_entry;
bool is_enum_class = false;
@@ -16471,12 +16560,6 @@ cooked_indexer::index_dies (cutu_reader *reader,
flags &= ~IS_STATIC;
flags |= parent_entry->flags & IS_STATIC;
}
- /* If the parent is an enum, but not an enum class, then use the
- grandparent instead. */
- if (this_parent_entry != nullptr
- && this_parent_entry->tag == DW_TAG_enumeration_type
- && !is_enum_class)
- this_parent_entry = this_parent_entry->get_parent ();
if (abbrev->tag == DW_TAG_namespace
&& m_language == language_cplus
@@ -16536,7 +16619,27 @@ cooked_indexer::index_dies (cutu_reader *reader,
break;
case DW_TAG_enumeration_type:
- info_ptr = recurse (reader, info_ptr, this_entry, fully);
+ /* We need to recurse even for an anonymous enumeration.
+ Which scope we record as the parent scope depends on
+ whether we're reading an "enum class". If so, we use
+ the enum itself as the parent, yielding names like
+ "enum_class::enumerator"; otherwise we inject the
+ names into our own parent scope. */
+ {
+ std::variant<const cooked_index_entry *,
+ parent_map::addr_type> recurse_parent;
+ if (is_enum_class)
+ {
+ gdb_assert (this_entry != nullptr);
+ recurse_parent = this_entry;
+ }
+ else if (defer != 0)
+ recurse_parent = defer;
+ else
+ recurse_parent = this_parent_entry;
+
+ info_ptr = recurse (reader, info_ptr, recurse_parent, fully);
+ }
continue;
case DW_TAG_module:
@@ -16617,7 +16720,8 @@ cooked_index_functions::expand_symtabs_matching
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags,
- domain_search_flags domain)
+ domain_search_flags domain,
+ gdb::function_view<expand_symtabs_lang_matcher_ftype> lang_matcher)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
@@ -16636,7 +16740,8 @@ cooked_index_functions::expand_symtabs_matching
if (!dw2_expand_symtabs_matching_one (per_cu, per_objfile,
file_matcher,
- expansion_notify))
+ expansion_notify,
+ lang_matcher))
return false;
}
return true;
@@ -16661,8 +16766,42 @@ cooked_index_functions::expand_symtabs_matching
symbol_name_match_type match_type
= lookup_name_without_params.match_type ();
+ std::bitset<nr_languages> unique_styles_used;
+ if (lang_matcher != nullptr)
+ for (unsigned iter = 0; iter < nr_languages; ++iter)
+ {
+ enum language lang = (enum language) iter;
+ if (!lang_matcher (lang))
+ continue;
+
+ switch (lang)
+ {
+ case language_cplus:
+ case language_rust:
+ unique_styles_used[language_cplus] = true;
+ break;
+ case language_d:
+ case language_go:
+ unique_styles_used[language_d] = true;
+ break;
+ case language_ada:
+ unique_styles_used[language_ada] = true;
+ break;
+ default:
+ unique_styles_used[language_c] = true;
+ }
+
+ if (unique_styles_used.count ()
+ == sizeof (unique_styles) / sizeof (unique_styles[0]))
+ break;
+ }
+
for (enum language lang : unique_styles)
{
+ if (lang_matcher != nullptr
+ && !unique_styles_used.test (lang))
+ continue;
+
std::vector<std::string_view> name_vec
= lookup_name_without_params.split_name (lang);
std::vector<std::string> name_str_vec (name_vec.begin (), name_vec.end ());
@@ -16693,6 +16832,15 @@ cooked_index_functions::expand_symtabs_matching
|| !entry->matches (domain))
continue;
+ if (lang_matcher != nullptr)
+ {
+ /* Try to skip CUs with non-matching language. */
+ entry->per_cu->ensure_lang (per_objfile);
+ if (!entry->per_cu->maybe_multi_language ()
+ && !lang_matcher (entry->per_cu->lang ()))
+ continue;
+ }
+
/* We've found the base name of the symbol; now walk its
parentage chain, ensuring that each component
matches. */
@@ -16761,7 +16909,7 @@ cooked_index_functions::expand_symtabs_matching
if (!dw2_expand_symtabs_matching_one (entry->per_cu, per_objfile,
file_matcher,
- expansion_notify))
+ expansion_notify, nullptr))
return false;
}
}
@@ -17762,7 +17910,7 @@ die_is_declaration (struct die_info *die, struct dwarf2_cu *cu)
which value is non-zero. However, we have to be careful with
DIEs having a DW_AT_specification attribute, because dwarf2_attr()
(via dwarf2_flag_true_p) follows this attribute. So we may
- end up accidently finding a declaration attribute that belongs
+ end up accidentally finding a declaration attribute that belongs
to a different DIE referenced by the specification attribute,
even though the given DIE does not have a declaration attribute. */
return (dwarf2_flag_true_p (die, DW_AT_declaration, cu)
@@ -20353,7 +20501,12 @@ follow_die_offset (sect_offset sect_off, int offset_in_dwz,
false, cu->lang ());
target_cu = per_objfile->get_cu (per_cu);
- gdb_assert (target_cu != nullptr);
+ if (target_cu == nullptr)
+ error (_(DWARF_ERROR_PREFIX
+ "cannot follow reference to DIE at %s"
+ " [in module %s]"),
+ sect_offset_str (sect_off),
+ objfile_name (per_objfile->objfile));
}
else if (cu->dies == NULL)
{
@@ -21461,6 +21614,24 @@ dwarf2_per_cu_data::set_lang (enum language lang,
gdb_assert (old_dw == 0 || old_dw == dw_lang);
}
+/* See read.h. */
+
+void
+dwarf2_per_cu_data::ensure_lang (dwarf2_per_objfile *per_objfile)
+{
+ if (lang (false) != language_unknown)
+ return;
+
+ cutu_reader reader (this, per_objfile);
+ if (reader.dummy_p)
+ {
+ set_lang (language_minimal, (dwarf_source_language)0);
+ return;
+ }
+
+ prepare_one_comp_unit (reader.cu, reader.comp_unit_die, language_minimal);
+}
+
/* A helper function for dwarf2_find_containing_comp_unit that returns
the index of the result, and that searches a vector. It will
return a result even if the offset in question does not actually
@@ -21624,6 +21795,14 @@ prepare_one_comp_unit (struct dwarf2_cu *cu, struct die_info *comp_unit_die,
cu->language_defn = language_def (lang);
+ /* Initialize the lto_artificial field. */
+ attr = dwarf2_attr (comp_unit_die, DW_AT_name, cu);
+ if (attr != nullptr
+ && cu->producer != nullptr
+ && strcmp (attr->as_string (), "<artificial>") == 0
+ && producer_is_gcc (cu->producer, nullptr, nullptr))
+ cu->per_cu->lto_artificial = true;
+
switch (comp_unit_die->tag)
{
case DW_TAG_compile_unit:
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index b23972b..7c42017 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -102,6 +102,7 @@ struct dwarf2_per_cu_data
is_dwz (false),
reading_dwo_directly (false),
tu_read (false),
+ lto_artificial (false),
queued (false),
m_header_read_in (false),
mark (false),
@@ -148,6 +149,11 @@ public:
This flag is only valid if is_debug_types is true. */
unsigned int tu_read : 1;
+ /* Non-zero if the CU is produced by GCC and has name "<artificial>". GCC
+ uses this to indicate that the CU does not correspond to a single source
+ file. GCC produces this type of CU during LTO. */
+ unsigned int lto_artificial : 1;
+
/* Wrap the following in struct packed instead of bitfields to avoid
data races when the bitfields end up on the same memory location
(per C++ memory model). */
@@ -324,6 +330,9 @@ public:
return l;
}
+ /* Make sure that m_lang != language_unknown. */
+ void ensure_lang (dwarf2_per_objfile *per_objfile);
+
/* Return the language of this CU, as a DWARF DW_LANG_* value. This
may be 0 in some situations. */
dwarf_source_language dw_lang () const
@@ -335,6 +344,22 @@ public:
situation LANG would be set by the importing CU. */
void set_lang (enum language lang, dwarf_source_language dw_lang);
+ /* Return true if the CU may be a multi-language CU. */
+
+ bool maybe_multi_language () const
+ {
+ enum language lang = this->lang ();
+
+ if (!lto_artificial)
+ /* Assume multi-language CUs are generated only by GCC LTO. */
+ return false;
+
+ /* If GCC mixes different languages in an artificial LTO CU, it labels it C.
+ The exception to this is when it mixes C and C++, which it labels it C++.
+ For now, we don't consider the latter a multi-language CU. */
+ return lang == language_c;
+ }
+
/* Free any cached file names. */
void free_cached_file_names ();
};
@@ -867,7 +892,8 @@ extern bool dw2_expand_symtabs_matching_one
(dwarf2_per_cu_data *per_cu,
dwarf2_per_objfile *per_objfile,
gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
- gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify);
+ gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
+ gdb::function_view<expand_symtabs_lang_matcher_ftype> lang_matcher);
/* Helper for dw2_expand_symtabs_matching that works with a
mapped_index_base instead of the containing objfile. This is split
@@ -881,7 +907,8 @@ extern bool dw2_expand_symtabs_matching_symbol
const lookup_name_info &lookup_name_in,
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<bool (offset_type)> match_callback,
- dwarf2_per_objfile *per_objfile);
+ dwarf2_per_objfile *per_objfile,
+ gdb::function_view<expand_symtabs_lang_matcher_ftype> lang_matcher);
/* If FILE_MATCHER is non-NULL, set all the
dwarf2_per_cu_quick_data::MARK of the current DWARF2_PER_OBJFILE
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 5371b99..2e68b0d 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -29,8 +29,6 @@
#include "symfile.h"
#include "objfiles.h"
#include "stabsread.h"
-#include "demangle.h"
-#include "filenames.h"
#include "probe.h"
#include "arch-utils.h"
#include "gdbtypes.h"
@@ -39,16 +37,15 @@
#include "gdbthread.h"
#include "inferior.h"
#include "regcache.h"
-#include "bcache.h"
#include "gdb_bfd.h"
#include "location.h"
#include "auxv.h"
#include "mdebugread.h"
#include "ctfread.h"
#include <string_view>
-#include "gdbsupport/scoped_fd.h"
#include "dwarf2/public.h"
#include "cli/cli-cmds.h"
+#include "gdb-stabs.h"
/* Whether ctf should always be read, or only if no dwarf is present. */
static bool always_read_ctf;
@@ -615,6 +612,8 @@ elf_rel_plt_read (minimal_symbol_reader &reader,
const size_t got_suffix_len = strlen (SYMBOL_GOT_PLT_SUFFIX);
name = bfd_asymbol_name (*relplt->relocation[reloc].sym_ptr_ptr);
+ if (!name)
+ continue;
address = relplt->relocation[reloc].address;
asection *msym_section;
@@ -1225,6 +1224,134 @@ elf_symfile_read_dwarf2 (struct objfile *objfile,
return has_dwarf2;
}
+/* find_text_range --- find start and end of loadable code sections
+
+ The find_text_range function finds the shortest address range that
+ encloses all sections containing executable code, and stores it in
+ objfile's text_addr and text_size members.
+
+ dbx_symfile_read will use this to finish off the partial symbol
+ table, in some cases. */
+
+static void
+find_text_range (bfd * sym_bfd, struct objfile *objfile)
+{
+ asection *sec;
+ int found_any = 0;
+ CORE_ADDR start = 0;
+ CORE_ADDR end = 0;
+
+ for (sec = sym_bfd->sections; sec; sec = sec->next)
+ if (bfd_section_flags (sec) & SEC_CODE)
+ {
+ CORE_ADDR sec_start = bfd_section_vma (sec);
+ CORE_ADDR sec_end = sec_start + bfd_section_size (sec);
+
+ if (found_any)
+ {
+ if (sec_start < start)
+ start = sec_start;
+ if (sec_end > end)
+ end = sec_end;
+ }
+ else
+ {
+ start = sec_start;
+ end = sec_end;
+ }
+
+ found_any = 1;
+ }
+
+ if (!found_any)
+ error (_("Can't find any code sections in symbol file"));
+
+ DBX_TEXT_ADDR (objfile) = start;
+ DBX_TEXT_SIZE (objfile) = end - start;
+}
+
+/* Scan and build partial symbols for an ELF symbol file.
+ This ELF file has already been processed to get its minimal symbols.
+
+ This routine is the equivalent of dbx_symfile_init and dbx_symfile_read
+ rolled into one.
+
+ OBJFILE is the object file we are reading symbols from.
+ ADDR is the address relative to which the symbols are (e.g.
+ the base address of the text segment).
+ STABSECT is the BFD section information for the .stab section.
+ STABSTROFFSET and STABSTRSIZE define the location in OBJFILE where the
+ .stabstr section exists.
+
+ This routine is mostly copied from dbx_symfile_init and dbx_symfile_read,
+ adjusted for elf details. */
+
+void
+elfstab_build_psymtabs (struct objfile *objfile, asection *stabsect,
+ file_ptr stabstroffset, unsigned int stabstrsize)
+{
+ int val;
+ bfd *sym_bfd = objfile->obfd.get ();
+ const char *name = bfd_get_filename (sym_bfd);
+
+ stabsread_new_init ();
+
+ /* Allocate struct to keep track of stab reading. */
+ dbx_objfile_data_key.emplace (objfile);
+ dbx_symfile_info *key = dbx_objfile_data_key.get (objfile);
+
+ /* Find the first and last text address. dbx_symfile_read seems to
+ want this. */
+ find_text_range (sym_bfd, objfile);
+
+#define ELF_STABS_SYMBOL_SIZE 12 /* XXX FIXME XXX */
+ DBX_SYMBOL_SIZE (objfile) = ELF_STABS_SYMBOL_SIZE;
+ DBX_SYMCOUNT (objfile)
+ = bfd_section_size (stabsect) / DBX_SYMBOL_SIZE (objfile);
+ DBX_STRINGTAB_SIZE (objfile) = stabstrsize;
+ DBX_SYMTAB_OFFSET (objfile) = stabsect->filepos;
+ DBX_STAB_SECTION (objfile) = stabsect;
+
+ if (stabstrsize > bfd_get_size (sym_bfd))
+ error (_("ridiculous string table size: %d bytes"), stabstrsize);
+ DBX_STRINGTAB (objfile) = (char *)
+ obstack_alloc (&objfile->objfile_obstack, stabstrsize + 1);
+ OBJSTAT (objfile, sz_strtab += stabstrsize + 1);
+
+ /* Now read in the string table in one big gulp. */
+
+ val = bfd_seek (sym_bfd, stabstroffset, SEEK_SET);
+ if (val < 0)
+ perror_with_name (name);
+ val = bfd_read (DBX_STRINGTAB (objfile), stabstrsize, sym_bfd);
+ if (val != stabstrsize)
+ perror_with_name (name);
+
+ stabsread_new_init ();
+ free_header_files ();
+ init_header_files ();
+
+ key->ctx.processing_acc_compilation = 1;
+
+ key->ctx.symbuf_read = 0;
+ key->ctx.symbuf_left = bfd_section_size (stabsect);
+
+ scoped_restore restore_stabs_data = make_scoped_restore (&key->ctx.stabs_data);
+ gdb::unique_xmalloc_ptr<gdb_byte> data_holder;
+
+ key->ctx.stabs_data = symfile_relocate_debug_section (objfile, stabsect, NULL);
+ if (key->ctx.stabs_data)
+ data_holder.reset (key->ctx.stabs_data);
+
+ /* In an elf file, we've already installed the minimal symbols that came
+ from the elf (non-stab) symbol table, so always act like an
+ incremental load here. dbx_symfile_read should not generate any new
+ minimal symbols, since we will have already read the ELF dynamic symbol
+ table and normal symbol entries won't be in the ".stab" section; but in
+ case it does, it will install them itself. */
+ read_stabs_symtab (objfile, 0);
+}
+
/* Scan and build partial symbols for a symbol file.
We have been initialized by a call to elf_symfile_init, which
currently does nothing.
diff --git a/gdb/eval.c b/gdb/eval.c
index bbf4375..457a436 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1872,18 +1872,21 @@ eval_op_postdec (struct type *expect_type, struct expression *exp,
}
}
-/* A helper function for OP_TYPE. */
+namespace expr
+{
struct value *
-eval_op_type (struct type *expect_type, struct expression *exp,
- enum noside noside, struct type *type)
+type_operation::evaluate (struct type *expect_type, struct expression *exp,
+ enum noside noside)
{
if (noside == EVAL_AVOID_SIDE_EFFECTS)
- return value::allocate (type);
+ return value::allocate (std::get<0> (m_storage));
else
error (_("Attempt to use a type name as an expression"));
}
+}
+
/* A helper function for BINOP_ASSIGN_MODIFY. */
struct value *
@@ -2102,7 +2105,7 @@ eval_op_objc_msgcall (struct type *expect_type, struct expression *exp,
/* Found a function symbol. Now we will substitute its
value in place of the message dispatcher (obj_msgSend),
- so that we call the method directly instead of thru
+ so that we call the method directly instead of through
the dispatcher. The main reason for doing this is that
we can now evaluate the return value and parameter values
according to their known data types, in case we need to
diff --git a/gdb/exec.h b/gdb/exec.h
index 0c1f604..c08cb9f 100644
--- a/gdb/exec.h
+++ b/gdb/exec.h
@@ -62,7 +62,7 @@ extern enum target_xfer_status
noted above. See memory_xfer_partial_1() in target.c for an
example.
- Return the number of bytes actually transfered, or zero when no
+ Return the number of bytes actually transferred, or zero when no
data is available for the requested range.
This function is intended to be used from target_xfer_partial
diff --git a/gdb/expop.h b/gdb/expop.h
index 2d46a9d..af031f5 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -172,9 +172,6 @@ extern struct value *eval_op_ind (struct type *expect_type,
struct expression *exp,
enum noside noside,
struct value *arg1);
-extern struct value *eval_op_type (struct type *expect_type,
- struct expression *exp,
- enum noside noside, struct type *type);
extern struct value *eval_op_alignof (struct type *expect_type,
struct expression *exp,
enum noside noside,
@@ -1560,16 +1557,16 @@ public:
value *evaluate (struct type *expect_type,
struct expression *exp,
- enum noside noside) override
- {
- return eval_op_type (expect_type, exp, noside, std::get<0> (m_storage));
- }
+ enum noside noside) override;
enum exp_opcode opcode () const override
{ return OP_TYPE; }
bool constant_p () const override
{ return true; }
+
+ bool type_p () const override
+ { return true; }
};
/* Implement the "typeof" operation. */
@@ -1593,6 +1590,9 @@ public:
enum exp_opcode opcode () const override
{ return OP_TYPEOF; }
+
+ bool type_p () const override
+ { return true; }
};
/* Implement 'decltype'. */
@@ -1638,6 +1638,9 @@ public:
enum exp_opcode opcode () const override
{ return OP_DECLTYPE; }
+
+ bool type_p () const override
+ { return true; }
};
/* Implement 'typeid'. */
@@ -1652,9 +1655,8 @@ public:
struct expression *exp,
enum noside noside) override
{
- enum exp_opcode sub_op = std::get<0> (m_storage)->opcode ();
enum noside sub_noside
- = ((sub_op == OP_TYPE || sub_op == OP_DECLTYPE || sub_op == OP_TYPEOF)
+ = (std::get<0> (m_storage)->type_p ()
? EVAL_AVOID_SIDE_EFFECTS
: noside);
diff --git a/gdb/expression.h b/gdb/expression.h
index 5bfc74c..2eb866f 100644
--- a/gdb/expression.h
+++ b/gdb/expression.h
@@ -147,6 +147,11 @@ public:
virtual bool uses_objfile (struct objfile *objfile) const
{ return false; }
+ /* Some expression nodes represent a type, not a value. This method
+ should be overridden to return 'true' in these situations. */
+ virtual bool type_p () const
+ { return false; }
+
/* Generate agent expression bytecodes for this operation. */
void generate_ax (struct expression *exp, struct agent_expr *ax,
struct axs_value *value,
@@ -215,6 +220,11 @@ struct expression
op->dump (stream, 0);
}
+ /* Call the type_p method on the outermost sub-expression of this
+ expression, and return the result. */
+ bool type_p () const
+ { return op->type_p (); }
+
/* Return true if this expression uses OBJFILE (and will become
dangling when OBJFILE is unloaded), otherwise return false.
OBJFILE must not be a separate debug info file. */
diff --git a/gdb/extension.c b/gdb/extension.c
index c488fc7..897bf25 100644
--- a/gdb/extension.c
+++ b/gdb/extension.c
@@ -680,7 +680,7 @@ static bool quit_flag;
/* The current extension language we've called out to, or
extension_language_gdb if there isn't one.
- This must be set everytime we call out to an extension language, and reset
+ This must be set every time we call out to an extension language, and reset
to the previous value when it returns. Note that the previous value may
be a different (or the same) extension language. */
static const struct extension_language_defn *active_ext_lang
diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index ac51f10..e97ff52d 100644
--- a/gdb/fbsd-tdep.c
+++ b/gdb/fbsd-tdep.c
@@ -26,7 +26,6 @@
#include "regcache.h"
#include "regset.h"
#include "gdbthread.h"
-#include "objfiles.h"
#include "xml-syscall.h"
#include <sys/socket.h>
#include <arpa/inet.h>
diff --git a/gdb/features/Makefile b/gdb/features/Makefile
index ddf4ec2..01b327c 100644
--- a/gdb/features/Makefile
+++ b/gdb/features/Makefile
@@ -222,12 +222,10 @@ FEATURE_XMLFILES = aarch64-core.xml \
i386/32bit-sse.xml \
i386/32bit-linux.xml \
i386/32bit-avx.xml \
- i386/32bit-mpx.xml \
i386/32bit-avx512.xml \
i386/32bit-segments.xml \
i386/64bit-avx512.xml \
i386/64bit-core.xml \
- i386/64bit-mpx.xml \
i386/64bit-segments.xml \
i386/64bit-avx.xml \
i386/64bit-linux.xml \
diff --git a/gdb/features/btrace-conf.dtd b/gdb/features/btrace-conf.dtd
index 87a4a84..c6f3f60 100644
--- a/gdb/features/btrace-conf.dtd
+++ b/gdb/features/btrace-conf.dtd
@@ -13,3 +13,4 @@
<!ELEMENT pt EMPTY>
<!ATTLIST pt size CDATA #IMPLIED>
<!ATTLIST pt ptwrite (yes | no) #IMPLIED>
+<!ATTLIST pt event-tracing (yes | no) #IMPLIED>
diff --git a/gdb/features/i386/32bit-mpx.c b/gdb/features/i386/32bit-mpx.c
deleted file mode 100644
index 40b34ed..0000000
--- a/gdb/features/i386/32bit-mpx.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
- Original: 32bit-mpx.xml */
-
-#include "gdbsupport/tdesc.h"
-
-static int
-create_feature_i386_32bit_mpx (struct target_desc *result, long regnum)
-{
- struct tdesc_feature *feature;
-
- feature = tdesc_create_feature (result, "org.gnu.gdb.i386.mpx");
- tdesc_type_with_fields *type_with_fields;
- type_with_fields = tdesc_create_struct (feature, "br128");
- tdesc_type *field_type;
- field_type = tdesc_named_type (feature, "uint64");
- tdesc_add_field (type_with_fields, "lbound", field_type);
- field_type = tdesc_named_type (feature, "uint64");
- tdesc_add_field (type_with_fields, "ubound_raw", field_type);
-
- type_with_fields = tdesc_create_struct (feature, "_bndstatus");
- tdesc_set_struct_size (type_with_fields, 8);
- tdesc_add_bitfield (type_with_fields, "bde", 2, 31);
- tdesc_add_bitfield (type_with_fields, "error", 0, 1);
-
- type_with_fields = tdesc_create_union (feature, "status");
- field_type = tdesc_named_type (feature, "data_ptr");
- tdesc_add_field (type_with_fields, "raw", field_type);
- field_type = tdesc_named_type (feature, "_bndstatus");
- tdesc_add_field (type_with_fields, "status", field_type);
-
- type_with_fields = tdesc_create_struct (feature, "_bndcfgu");
- tdesc_set_struct_size (type_with_fields, 8);
- tdesc_add_bitfield (type_with_fields, "base", 12, 31);
- tdesc_add_bitfield (type_with_fields, "reserved", 2, 11);
- tdesc_add_bitfield (type_with_fields, "preserved", 1, 1);
- tdesc_add_bitfield (type_with_fields, "enabled", 0, 0);
-
- type_with_fields = tdesc_create_union (feature, "cfgu");
- field_type = tdesc_named_type (feature, "data_ptr");
- tdesc_add_field (type_with_fields, "raw", field_type);
- field_type = tdesc_named_type (feature, "_bndcfgu");
- tdesc_add_field (type_with_fields, "config", field_type);
-
- tdesc_create_reg (feature, "bnd0raw", regnum++, 1, NULL, 128, "br128");
- tdesc_create_reg (feature, "bnd1raw", regnum++, 1, NULL, 128, "br128");
- tdesc_create_reg (feature, "bnd2raw", regnum++, 1, NULL, 128, "br128");
- tdesc_create_reg (feature, "bnd3raw", regnum++, 1, NULL, 128, "br128");
- tdesc_create_reg (feature, "bndcfgu", regnum++, 1, NULL, 64, "cfgu");
- tdesc_create_reg (feature, "bndstatus", regnum++, 1, NULL, 64, "status");
- return regnum;
-}
diff --git a/gdb/features/i386/32bit-mpx.xml b/gdb/features/i386/32bit-mpx.xml
deleted file mode 100644
index 81eb2ee..0000000
--- a/gdb/features/i386/32bit-mpx.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0"?>
-<!-- Copyright (C) 2013-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.mpx">
- <struct id="br128">
- <field name="lbound" type="uint64"/>
- <field name="ubound_raw" type="uint64"/>
- </struct>
-
- <struct id="_bndstatus" size="8">
- <field name="bde" start="2" end="31"/>
- <field name="error" start="0" end="1"/>
- </struct>
-
- <union id="status">
- <field name="raw" type="data_ptr"/>
- <field name="status" type="_bndstatus"/>
- </union>
-
- <struct id="_bndcfgu" size="8">
- <field name="base" start="12" end="31" />
- <field name="reserved" start="2" end="11"/>
- <!-- Explicitly set the type here, otherwise it defaults to bool.
- Perhaps this should be uint32, but the container type has size 8. -->
- <field name="preserved" start="1" end="1" type="uint64"/>
- <field name="enabled" start="0" end="0" type="uint64"/>
- </struct>
-
- <union id="cfgu">
- <field name="raw" type="data_ptr"/>
- <field name="config" type="_bndcfgu"/>
- </union>
-
- <reg name="bnd0raw" bitsize="128" type="br128"/>
- <reg name="bnd1raw" bitsize="128" type="br128"/>
- <reg name="bnd2raw" bitsize="128" type="br128"/>
- <reg name="bnd3raw" bitsize="128" type="br128"/>
- <reg name="bndcfgu" bitsize="64" type="cfgu"/>
- <reg name="bndstatus" bitsize="64" type="status"/>
-</feature>
diff --git a/gdb/features/i386/64bit-mpx.c b/gdb/features/i386/64bit-mpx.c
deleted file mode 100644
index 3eabc9d..0000000
--- a/gdb/features/i386/64bit-mpx.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
- Original: 64bit-mpx.xml */
-
-#include "gdbsupport/tdesc.h"
-
-static int
-create_feature_i386_64bit_mpx (struct target_desc *result, long regnum)
-{
- struct tdesc_feature *feature;
-
- feature = tdesc_create_feature (result, "org.gnu.gdb.i386.mpx");
- tdesc_type_with_fields *type_with_fields;
- type_with_fields = tdesc_create_struct (feature, "br128");
- tdesc_type *field_type;
- field_type = tdesc_named_type (feature, "uint64");
- tdesc_add_field (type_with_fields, "lbound", field_type);
- field_type = tdesc_named_type (feature, "uint64");
- tdesc_add_field (type_with_fields, "ubound_raw", field_type);
-
- type_with_fields = tdesc_create_struct (feature, "_bndstatus");
- tdesc_set_struct_size (type_with_fields, 8);
- tdesc_add_bitfield (type_with_fields, "bde", 2, 63);
- tdesc_add_bitfield (type_with_fields, "error", 0, 1);
-
- type_with_fields = tdesc_create_union (feature, "status");
- field_type = tdesc_named_type (feature, "data_ptr");
- tdesc_add_field (type_with_fields, "raw", field_type);
- field_type = tdesc_named_type (feature, "_bndstatus");
- tdesc_add_field (type_with_fields, "status", field_type);
-
- type_with_fields = tdesc_create_struct (feature, "_bndcfgu");
- tdesc_set_struct_size (type_with_fields, 8);
- tdesc_add_bitfield (type_with_fields, "base", 12, 63);
- tdesc_add_bitfield (type_with_fields, "reserved", 2, 11);
- tdesc_add_bitfield (type_with_fields, "preserved", 1, 1);
- tdesc_add_bitfield (type_with_fields, "enabled", 0, 0);
-
- type_with_fields = tdesc_create_union (feature, "cfgu");
- field_type = tdesc_named_type (feature, "data_ptr");
- tdesc_add_field (type_with_fields, "raw", field_type);
- field_type = tdesc_named_type (feature, "_bndcfgu");
- tdesc_add_field (type_with_fields, "config", field_type);
-
- tdesc_create_reg (feature, "bnd0raw", regnum++, 1, NULL, 128, "br128");
- tdesc_create_reg (feature, "bnd1raw", regnum++, 1, NULL, 128, "br128");
- tdesc_create_reg (feature, "bnd2raw", regnum++, 1, NULL, 128, "br128");
- tdesc_create_reg (feature, "bnd3raw", regnum++, 1, NULL, 128, "br128");
- tdesc_create_reg (feature, "bndcfgu", regnum++, 1, NULL, 64, "cfgu");
- tdesc_create_reg (feature, "bndstatus", regnum++, 1, NULL, 64, "status");
- return regnum;
-}
diff --git a/gdb/features/i386/64bit-mpx.xml b/gdb/features/i386/64bit-mpx.xml
deleted file mode 100644
index 812c78c..0000000
--- a/gdb/features/i386/64bit-mpx.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0"?>
-<!-- Copyright (C) 2013-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.mpx">
- <struct id="br128">
- <field name="lbound" type="uint64"/>
- <field name="ubound_raw" type="uint64"/>
- </struct>
-
- <struct id="_bndstatus" size="8">
- <field name="bde" start="2" end="63"/>
- <field name="error" start="0" end="1"/>
- </struct>
-
- <union id="status">
- <field name="raw" type="data_ptr"/>
- <field name="status" type="_bndstatus"/>
- </union>
-
- <struct id="_bndcfgu" size="8">
- <field name="base" start="12" end="63"/>
- <field name="reserved" start="2" end="11"/>
- <!-- Explicitly set the type here, otherwise it defaults to bool. -->
- <field name="preserved" start="1" end="1" type="uint64"/>
- <field name="enabled" start="0" end="0" type="uint64"/>
- </struct>
-
- <union id="cfgu">
- <field name="raw" type="data_ptr"/>
- <field name="config" type="_bndcfgu"/>
- </union>
-
- <reg name="bnd0raw" bitsize="128" type="br128"/>
- <reg name="bnd1raw" bitsize="128" type="br128"/>
- <reg name="bnd2raw" bitsize="128" type="br128"/>
- <reg name="bnd3raw" bitsize="128" type="br128"/>
- <reg name="bndcfgu" bitsize="64" type="cfgu"/>
- <reg name="bndstatus" bitsize="64" type="status"/>
-</feature>
diff --git a/gdb/features/mips-dsp-linux.c b/gdb/features/mips-dsp-linux.c
index d8e4028..4873037 100644
--- a/gdb/features/mips-dsp-linux.c
+++ b/gdb/features/mips-dsp-linux.c
@@ -11,7 +11,7 @@ initialize_tdesc_mips_dsp_linux (void)
target_desc_up result = allocate_target_description ();
set_tdesc_architecture (result.get (), bfd_scan_arch ("mips"));
- set_tdesc_osabi (result.get (), osabi_from_tdesc_string ("GNU/Linux"));
+ set_tdesc_osabi (result.get (), GDB_OSABI_LINUX);
struct tdesc_feature *feature;
diff --git a/gdb/features/mips-linux.c b/gdb/features/mips-linux.c
index f93eef5..5ff2e5f 100644
--- a/gdb/features/mips-linux.c
+++ b/gdb/features/mips-linux.c
@@ -11,7 +11,7 @@ initialize_tdesc_mips_linux (void)
target_desc_up result = allocate_target_description ();
set_tdesc_architecture (result.get (), bfd_scan_arch ("mips"));
- set_tdesc_osabi (result.get (), osabi_from_tdesc_string ("GNU/Linux"));
+ set_tdesc_osabi (result.get (), GDB_OSABI_LINUX);
struct tdesc_feature *feature;
diff --git a/gdb/features/or1k-linux.c b/gdb/features/or1k-linux.c
index 2473145..85a681f 100644
--- a/gdb/features/or1k-linux.c
+++ b/gdb/features/or1k-linux.c
@@ -11,7 +11,7 @@ initialize_tdesc_or1k_linux (void)
target_desc_up result = allocate_target_description ();
set_tdesc_architecture (result.get (), bfd_scan_arch ("or1k"));
- set_tdesc_osabi (result.get (), osabi_from_tdesc_string ("GNU/Linux"));
+ set_tdesc_osabi (result.get (), GDB_OSABI_LINUX);
struct tdesc_feature *feature;
diff --git a/gdb/features/sparc/sparc32-solaris.c b/gdb/features/sparc/sparc32-solaris.c
index dce9685..70affdb 100644
--- a/gdb/features/sparc/sparc32-solaris.c
+++ b/gdb/features/sparc/sparc32-solaris.c
@@ -11,7 +11,7 @@ initialize_tdesc_sparc32_solaris (void)
target_desc_up result = allocate_target_description ();
set_tdesc_architecture (result.get (), bfd_scan_arch ("sparc"));
- set_tdesc_osabi (result.get (), osabi_from_tdesc_string ("Solaris"));
+ set_tdesc_osabi (result.get (), GDB_OSABI_SOLARIS);
struct tdesc_feature *feature;
diff --git a/gdb/features/sparc/sparc64-solaris.c b/gdb/features/sparc/sparc64-solaris.c
index d030df6..98edabe 100644
--- a/gdb/features/sparc/sparc64-solaris.c
+++ b/gdb/features/sparc/sparc64-solaris.c
@@ -11,7 +11,7 @@ initialize_tdesc_sparc64_solaris (void)
target_desc_up result = allocate_target_description ();
set_tdesc_architecture (result.get (), bfd_scan_arch ("sparc:v9"));
- set_tdesc_osabi (result.get (), osabi_from_tdesc_string ("Solaris"));
+ set_tdesc_osabi (result.get (), GDB_OSABI_SOLARIS);
struct tdesc_feature *feature;
diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c
index e5f108d..fecd107 100644
--- a/gdb/frame-unwind.c
+++ b/gdb/frame-unwind.c
@@ -119,10 +119,10 @@ frame_unwind_append_unwinder (struct gdbarch *gdbarch,
}
/* Call SNIFFER from UNWINDER. If it succeeded set UNWINDER for
- THIS_FRAME and return 1. Otherwise the function keeps THIS_FRAME
- unchanged and returns 0. */
+ THIS_FRAME and return true. Otherwise the function keeps THIS_FRAME
+ unchanged and returns false. */
-static int
+static bool
frame_unwind_try_unwinder (const frame_info_ptr &this_frame, void **this_cache,
const struct frame_unwind *unwinder)
{
@@ -157,7 +157,7 @@ frame_unwind_try_unwinder (const frame_info_ptr &this_frame, void **this_cache,
thus most unwinders aren't able to determine if they're
the best fit. Keep trying. Fallback prologue unwinders
should always accept the frame. */
- return 0;
+ return false;
}
throw;
}
@@ -165,7 +165,7 @@ frame_unwind_try_unwinder (const frame_info_ptr &this_frame, void **this_cache,
if (res)
{
frame_debug_printf ("yes");
- return 1;
+ return true;
}
else
{
@@ -173,7 +173,7 @@ frame_unwind_try_unwinder (const frame_info_ptr &this_frame, void **this_cache,
/* Don't set *THIS_CACHE to NULL here, because sniffer has to do
so. */
frame_cleanup_after_sniffer (this_frame);
- return 0;
+ return false;
}
gdb_assert_not_reached ("frame_unwind_try_unwinder");
}
diff --git a/gdb/gdb-stabs.h b/gdb/gdb-stabs.h
index 3786ad6..20fb8fa 100644
--- a/gdb/gdb-stabs.h
+++ b/gdb/gdb-stabs.h
@@ -20,12 +20,108 @@
#ifndef GDB_STABS_H
#define GDB_STABS_H
+/* During initial symbol readin, we need to have a structure to keep
+ track of which psymtabs have which bincls in them. This structure
+ is used during readin to setup the list of dependencies within each
+ partial symbol table. */
+struct legacy_psymtab;
+
+struct header_file_location
+{
+ header_file_location (const char *name_, int instance_,
+ legacy_psymtab *pst_)
+ : name (name_),
+ instance (instance_),
+ pst (pst_)
+ {
+ }
+
+ const char *name; /* Name of header file */
+ int instance; /* See above */
+ legacy_psymtab *pst; /* Partial symtab that has the
+ BINCL/EINCL defs for this file. */
+};
+
/* This file exists to hold the common definitions required of most of
the symbol-readers that end up using stabs. The common use of
these `symbol-type-specific' customizations of the generic data
structures makes the stabs-oriented symbol readers able to call
each others' functions as required. */
+struct stabsread_context {
+ /* Remember what we deduced to be the source language of this psymtab. */
+ enum language psymtab_language = language_unknown;
+
+ /* The size of each symbol in the symbol file (in external form).
+ This is set by dbx_symfile_read when building psymtabs, and by
+ dbx_psymtab_to_symtab when building symtabs. */
+ unsigned symbol_size = 0;
+
+ /* This is the offset of the symbol table in the executable file. */
+ unsigned symbol_table_offset = 0;
+
+ /* This is the offset of the string table in the executable file. */
+ unsigned string_table_offset = 0;
+
+ /* For elf+stab executables, the n_strx field is not a simple index
+ into the string table. Instead, each .o file has a base offset in
+ the string table, and the associated symbols contain offsets from
+ this base. The following two variables contain the base offset for
+ the current and next .o files. */
+ unsigned int file_string_table_offset = 0;
+
+ /* .o and NLM files contain unrelocated addresses which are based at
+ 0. When non-zero, this flag disables some of the special cases for
+ Solaris elf+stab text addresses at location 0. */
+ int symfile_relocatable = 0;
+
+ /* When set, we are processing a .o file compiled by sun acc. This is
+ misnamed; it refers to all stabs-in-elf implementations which use
+ N_UNDF the way Sun does, including Solaris gcc. Hopefully all
+ stabs-in-elf implementations ever invented will choose to be
+ compatible. */
+ unsigned char processing_acc_compilation = 0;
+
+ /* The lowest text address we have yet encountered. This is needed
+ because in an a.out file, there is no header field which tells us
+ what address the program is actually going to be loaded at, so we
+ need to make guesses based on the symbols (which *are* relocated to
+ reflect the address it will be loaded at). */
+ unrelocated_addr lowest_text_address;
+
+ /* Non-zero if there is any line number info in the objfile. Prevents
+ dbx_end_psymtab from discarding an otherwise empty psymtab. */
+ int has_line_numbers = 0;
+
+ /* The list of bincls. */
+ std::vector<struct header_file_location> bincl_list;
+
+ /* Name of last function encountered. Used in Solaris to approximate
+ object file boundaries. */
+ const char *last_function_name = nullptr;
+
+ /* The address in memory of the string table of the object file we are
+ reading (which might not be the "main" object file, but might be a
+ shared library or some other dynamically loaded thing). This is
+ set by read_dbx_symtab when building psymtabs, and by
+ read_ofile_symtab when building symtabs, and is used only by
+ next_symbol_text. FIXME: If that is true, we don't need it when
+ building psymtabs, right? */
+ char *stringtab_global = nullptr;
+
+ /* These variables are used to control fill_symbuf when the stabs
+ symbols are not contiguous (as may be the case when a COFF file is
+ linked using --split-by-reloc). */
+ const std::vector<asection *> *symbuf_sections;
+ size_t sect_idx = 0;
+ unsigned int symbuf_left = 0;
+ unsigned int symbuf_read = 0;
+
+ /* This variable stores a global stabs buffer, if we read stabs into
+ memory in one chunk in order to process relocations. */
+ bfd_byte *stabs_data = nullptr;
+};
+
/* Information is passed among various dbxread routines for accessing
symbol files. A pointer to this structure is kept in the objfile,
@@ -43,6 +139,8 @@ struct dbx_symfile_info
file_ptr symtab_offset = 0; /* Offset in file to symbol table */
int symbol_size = 0; /* Bytes in a single symbol */
+ stabsread_context ctx; /* Context for the symfile being read. */
+
/* See stabsread.h for the use of the following. */
struct header_file *header_files = nullptr;
int n_header_files = 0;
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 1cf5f48..323f15d 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -631,7 +631,7 @@ address_space_name_to_type_instance_flags (struct gdbarch *gdbarch,
}
/* Identify address space identifier by type_instance_flags and return
- the string version of the adress space name. */
+ the string version of the address space name. */
const char *
address_space_type_instance_flags_to_name (struct gdbarch *gdbarch,
@@ -733,7 +733,7 @@ make_type_with_address_space (struct type *type,
If TYPEPTR and *TYPEPTR are non-zero, then *TYPEPTR points to
storage to hold the new qualified type; *TYPEPTR and TYPE must be
in the same objfile. Otherwise, allocate fresh memory for the new
- type whereever TYPE lives. If TYPEPTR is non-zero, set it to the
+ type wherever TYPE lives. If TYPEPTR is non-zero, set it to the
new type we construct. */
struct type *
@@ -1371,7 +1371,7 @@ create_array_type_with_stride (type_allocator &alloc,
undefined by setting it to zero. Although we are not expected
to trust TYPE_LENGTH in this case, setting the size to zero
allows us to avoid allocating objects of random sizes in case
- we accidently do. */
+ we accidentally do. */
result_type->set_length (0);
}
@@ -1553,7 +1553,7 @@ set_type_self_type (struct type *type, struct type *self_type)
}
/* Smash TYPE to be a type of pointers to members of SELF_TYPE with type
- TO_TYPE. A member pointer is a wierd thing -- it amounts to a
+ TO_TYPE. A member pointer is a weird thing -- it amounts to a
typed offset into a struct, e.g. "an int at offset 8". A MEMBER
TYPE doesn't include the offset (that's the value of the MEMBER
itself), but does include the structure type into which it points
diff --git a/gdb/i386-fbsd-nat.c b/gdb/i386-fbsd-nat.c
index f4538fb..d9f4067 100644
--- a/gdb/i386-fbsd-nat.c
+++ b/gdb/i386-fbsd-nat.c
@@ -254,7 +254,7 @@ i386_fbsd_nat_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
request = PT_CONTINUE;
}
- /* An addres of (caddr_t) 1 tells ptrace to continue from where it
+ /* An address of (caddr_t) 1 tells ptrace to continue from where it
was. (If GDB wanted it to start some other way, we have already
written a new PC value to the child.) */
if (ptrace (request, pid, (caddr_t) 1,
diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c
index 0e360b1..41c1113 100644
--- a/gdb/i386-linux-nat.c
+++ b/gdb/i386-linux-nat.c
@@ -259,7 +259,7 @@ fill_fpregset (const struct regcache *regcache,
#ifdef HAVE_PTRACE_GETREGS
/* Fetch all floating-point registers from process/thread TID and store
- thier values in GDB's register array. */
+ their values in GDB's register array. */
static void
fetch_fpregs (struct regcache *regcache, int tid)
diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
index 6debed2..9dec83a 100644
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -390,62 +390,6 @@ i386_canonicalize_syscall (int syscall)
#define SIG_CODE_BOUNDARY_FAULT 3
-/* i386 GNU/Linux implementation of the report_signal_info
- gdbarch hook. Displays information related to MPX bound
- violations. */
-void
-i386_linux_report_signal_info (struct gdbarch *gdbarch, struct ui_out *uiout,
- enum gdb_signal siggnal)
-{
- /* -Wmaybe-uninitialized */
- CORE_ADDR lower_bound = 0, upper_bound = 0, access = 0;
- int is_upper;
- long sig_code = 0;
-
- if (!i386_mpx_enabled () || siggnal != GDB_SIGNAL_SEGV)
- return;
-
- try
- {
- /* Sigcode evaluates if the actual segfault is a boundary violation. */
- sig_code = parse_and_eval_long ("$_siginfo.si_code\n");
-
- lower_bound
- = parse_and_eval_long ("$_siginfo._sifields._sigfault._addr_bnd._lower");
- upper_bound
- = parse_and_eval_long ("$_siginfo._sifields._sigfault._addr_bnd._upper");
- access
- = parse_and_eval_long ("$_siginfo._sifields._sigfault.si_addr");
- }
- catch (const gdb_exception_error &exception)
- {
- return;
- }
-
- /* If this is not a boundary violation just return. */
- if (sig_code != SIG_CODE_BOUNDARY_FAULT)
- return;
-
- is_upper = (access > upper_bound ? 1 : 0);
-
- uiout->text ("\n");
- if (is_upper)
- uiout->field_string ("sigcode-meaning", _("Upper bound violation"));
- else
- uiout->field_string ("sigcode-meaning", _("Lower bound violation"));
-
- uiout->text (_(" while accessing address "));
- uiout->field_core_addr ("bound-access", gdbarch, access);
-
- uiout->text (_("\nBounds: [lower = "));
- uiout->field_core_addr ("lower-bound", gdbarch, lower_bound);
-
- uiout->text (_(", upper = "));
- uiout->field_core_addr ("upper-bound", gdbarch, upper_bound);
-
- uiout->text (_("]"));
-}
-
/* Parse the arguments of current system call instruction and record
the values of the registers and memory that will be changed into
"record_arch_list". This instruction is "int 0x80" (Linux
@@ -608,6 +552,8 @@ int i386_linux_gregset_reg_offset[] =
-1, -1, -1, -1, -1, -1, -1, -1,
-1,
-1, -1, -1, -1, -1, -1, -1, -1,
+ /* MPX is deprecated. Yet we keep this to not give the registers below
+ a new number. That could break older gdbservers. */
-1, -1, -1, -1, /* MPX registers BND0 ... BND3. */
-1, -1, /* MPX registers BNDCFGU, BNDSTATUS. */
-1, -1, -1, -1, -1, -1, -1, -1, /* k0 ... k7 (AVX512) */
@@ -721,12 +667,6 @@ i386_linux_supply_xstateregset (const struct regset *regset,
i387_supply_xsave (regcache, regnum, xstateregs);
}
-struct type *
-x86_linux_get_siginfo_type (struct gdbarch *gdbarch)
-{
- return linux_get_siginfo_type_with_fields (gdbarch, LINUX_SIGINFO_FIELD_ADDR_BND);
-}
-
/* Similar to i386_collect_fpregset, but use XSAVE extended state. */
static void
@@ -1064,9 +1004,6 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_I386);
set_gdbarch_get_syscall_number (gdbarch,
i386_linux_get_syscall_number);
-
- set_gdbarch_get_siginfo_type (gdbarch, x86_linux_get_siginfo_type);
- set_gdbarch_report_signal_info (gdbarch, i386_linux_report_signal_info);
}
void _initialize_i386_linux_tdep ();
diff --git a/gdb/i386-linux-tdep.h b/gdb/i386-linux-tdep.h
index e8691cd..e169c1d 100644
--- a/gdb/i386-linux-tdep.h
+++ b/gdb/i386-linux-tdep.h
@@ -49,15 +49,6 @@ extern uint64_t i386_linux_core_read_xsave_info (bfd *abfd,
extern bool i386_linux_core_read_x86_xsave_layout (struct gdbarch *gdbarch,
x86_xsave_layout &layout);
-/* Handle and display information related to the MPX bound violation
- to the user. */
-extern void i386_linux_report_signal_info (struct gdbarch *gdbarch,
- struct ui_out *uiout,
- enum gdb_signal siggnal);
-
extern int i386_linux_gregset_reg_offset[];
-/* Return x86 siginfo type. */
-extern struct type *x86_linux_get_siginfo_type (struct gdbarch *gdbarch);
-
#endif /* i386-linux-tdep.h */
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 625ffe5..d2c3efb 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -117,23 +117,12 @@ static const char * const i386_ymmh_names[] =
"ymm4h", "ymm5h", "ymm6h", "ymm7h",
};
-static const char * const i386_mpx_names[] =
-{
- "bnd0raw", "bnd1raw", "bnd2raw", "bnd3raw", "bndcfgu", "bndstatus"
-};
static const char * const i386_pkeys_names[] =
{
"pkru"
};
-/* Register names for MPX pseudo-registers. */
-
-static const char * const i386_bnd_names[] =
-{
- "bnd0", "bnd1", "bnd2", "bnd3"
-};
-
/* Register names for MMX pseudo-registers. */
static const char * const i386_mmx_names[] =
@@ -311,21 +300,6 @@ i386_ymm_avx512_regnum_p (struct gdbarch *gdbarch, int regnum)
return regnum >= 0 && regnum < tdep->num_ymm_avx512_regs;
}
-/* BND register? */
-
-int
-i386_bnd_regnum_p (struct gdbarch *gdbarch, int regnum)
-{
- i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
- int bnd0_regnum = tdep->bnd0_regnum;
-
- if (bnd0_regnum < 0)
- return 0;
-
- regnum -= bnd0_regnum;
- return regnum >= 0 && regnum < I387_NUM_BND_REGS;
-}
-
/* SSE register? */
int
@@ -393,34 +367,6 @@ i386_fpc_regnum_p (struct gdbarch *gdbarch, int regnum)
&& regnum < I387_XMM0_REGNUM (tdep));
}
-/* BNDr (raw) register? */
-
-static int
-i386_bndr_regnum_p (struct gdbarch *gdbarch, int regnum)
-{
- i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
-
- if (I387_BND0R_REGNUM (tdep) < 0)
- return 0;
-
- regnum -= tdep->bnd0r_regnum;
- return regnum >= 0 && regnum < I387_NUM_BND_REGS;
-}
-
-/* BND control register? */
-
-static int
-i386_mpx_ctrl_regnum_p (struct gdbarch *gdbarch, int regnum)
-{
- i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
-
- if (I387_BNDCFGU_REGNUM (tdep) < 0)
- return 0;
-
- regnum -= I387_BNDCFGU_REGNUM (tdep);
- return regnum >= 0 && regnum < I387_NUM_MPX_CTRL_REGS;
-}
-
/* PKRU register? */
bool
@@ -463,8 +409,6 @@ const char *
i386_pseudo_register_name (struct gdbarch *gdbarch, int regnum)
{
i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
- if (i386_bnd_regnum_p (gdbarch, regnum))
- return i386_bnd_names[regnum - tdep->bnd0_regnum];
if (i386_mmx_regnum_p (gdbarch, regnum))
return i386_mmx_names[regnum - I387_MM0_REGNUM (tdep)];
else if (i386_ymm_regnum_p (gdbarch, regnum))
@@ -2738,13 +2682,6 @@ i386_thiscall_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
int write_pass;
int args_space = 0;
- /* BND registers can be in arbitrary values at the moment of the
- inferior call. This can cause boundary violations that are not
- due to a real bug or even desired by the user. The best to be done
- is set the BND registers to allow access to the whole memory, INIT
- state, before pushing the inferior call. */
- i387_reset_bnd_regs (gdbarch, regcache);
-
/* Determine the total space required for arguments and struct
return address in a first pass (allowing for 16-byte-aligned
arguments), then push arguments in a second pass. */
@@ -3161,43 +3098,6 @@ i387_ext_type (struct gdbarch *gdbarch)
return tdep->i387_ext_type;
}
-/* Construct type for pseudo BND registers. We can't use
- tdesc_find_type since a complement of one value has to be used
- to describe the upper bound. */
-
-static struct type *
-i386_bnd_type (struct gdbarch *gdbarch)
-{
- i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
-
-
- if (!tdep->i386_bnd_type)
- {
- struct type *t;
- const struct builtin_type *bt = builtin_type (gdbarch);
-
- /* The type we're building is described bellow: */
-#if 0
- struct __bound128
- {
- void *lbound;
- void *ubound; /* One complement of raw ubound field. */
- };
-#endif
-
- t = arch_composite_type (gdbarch,
- "__gdb_builtin_type_bound128", TYPE_CODE_STRUCT);
-
- append_composite_type_field (t, "lbound", bt->builtin_data_ptr);
- append_composite_type_field (t, "ubound", bt->builtin_data_ptr);
-
- t->set_name ("builtin_type_bound128");
- tdep->i386_bnd_type = t;
- }
-
- return tdep->i386_bnd_type;
-}
-
/* Construct vector type for pseudo ZMM registers. We can't use
tdesc_find_type since ZMM isn't described in target description. */
@@ -3364,8 +3264,6 @@ i386_mmx_type (struct gdbarch *gdbarch)
struct type *
i386_pseudo_register_type (struct gdbarch *gdbarch, int regnum)
{
- if (i386_bnd_regnum_p (gdbarch, regnum))
- return i386_bnd_type (gdbarch);
if (i386_mmx_regnum_p (gdbarch, regnum))
return i386_mmx_type (gdbarch);
else if (i386_ymm_regnum_p (gdbarch, regnum))
@@ -3425,39 +3323,7 @@ i386_pseudo_register_read_value (gdbarch *gdbarch, const frame_info_ptr &next_fr
else
{
i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
- if (i386_bnd_regnum_p (gdbarch, pseudo_reg_num))
- {
- int i = pseudo_reg_num - tdep->bnd0_regnum;
-
- /* Extract (always little endian). Read lower 128bits. */
- value *bndr_value
- = value_of_register (I387_BND0R_REGNUM (tdep) + i, next_frame);
- int size = builtin_type (gdbarch)->builtin_data_ptr->length ();
- value *result
- = value::allocate_register (next_frame, pseudo_reg_num);
-
- /* Copy the lower. */
- bndr_value->contents_copy (result, 0, 0, size);
-
- /* Copy the upper. */
- bndr_value->contents_copy (result, size, 8, size);
-
- /* If upper bytes are available, compute ones' complement. */
- if (result->bytes_available (size, size))
- {
- bfd_endian byte_order
- = gdbarch_byte_order (frame_unwind_arch (next_frame));
- gdb::array_view<gdb_byte> upper_bytes
- = result->contents_raw ().slice (size, size);
- ULONGEST upper
- = extract_unsigned_integer (upper_bytes, byte_order);
- upper = ~upper;
- store_unsigned_integer (upper_bytes, byte_order, upper);
- }
-
- return result;
- }
- else if (i386_zmm_regnum_p (gdbarch, pseudo_reg_num))
+ if (i386_zmm_regnum_p (gdbarch, pseudo_reg_num))
{
/* Which register is it, relative to zmm0. */
int i_0 = pseudo_reg_num - tdep->zmm0_regnum;
@@ -3530,33 +3396,7 @@ i386_pseudo_register_write (gdbarch *gdbarch, const frame_info_ptr &next_frame,
{
i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
- if (i386_bnd_regnum_p (gdbarch, pseudo_reg_num))
- {
- int size = builtin_type (gdbarch)->builtin_data_ptr->length ();
- bfd_endian byte_order
- = gdbarch_byte_order (current_inferior ()->arch ());
-
- /* New values from input value. */
- int reg_index = pseudo_reg_num - tdep->bnd0_regnum;
- int raw_regnum = I387_BND0R_REGNUM (tdep) + reg_index;
-
- value *bndr_value = value_of_register (raw_regnum, next_frame);
- gdb::array_view<gdb_byte> bndr_view
- = bndr_value->contents_writeable ();
-
- /* Copy lower bytes directly. */
- copy (buf.slice (0, size), bndr_view.slice (0, size));
-
- /* Convert and then copy upper bytes. */
- ULONGEST upper
- = extract_unsigned_integer (buf.slice (size, size), byte_order);
- upper = ~upper;
- store_unsigned_integer (bndr_view.slice (8, size), byte_order,
- upper);
-
- put_frame_register (next_frame, raw_regnum, bndr_view);
- }
- else if (i386_zmm_regnum_p (gdbarch, pseudo_reg_num))
+ if (i386_zmm_regnum_p (gdbarch, pseudo_reg_num))
{
/* Which register is it, relative to zmm0. */
int reg_index_0 = pseudo_reg_num - tdep->zmm0_regnum;
@@ -3627,12 +3467,6 @@ i386_ax_pseudo_register_collect (struct gdbarch *gdbarch,
ax_reg_mask (ax, I387_ST0_REGNUM (tdep) + i);
return 0;
}
- else if (i386_bnd_regnum_p (gdbarch, regnum))
- {
- regnum -= tdep->bnd0_regnum;
- ax_reg_mask (ax, I387_BND0R_REGNUM (tdep) + regnum);
- return 0;
- }
else if (i386_zmm_regnum_p (gdbarch, regnum))
{
regnum -= tdep->zmm0_regnum;
@@ -4480,9 +4314,8 @@ i386_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
const i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
int fp_regnum_p, mmx_regnum_p, xmm_regnum_p, mxcsr_regnum_p,
ymm_regnum_p, ymmh_regnum_p, ymm_avx512_regnum_p, ymmh_avx512_regnum_p,
- bndr_regnum_p, bnd_regnum_p, zmm_regnum_p, zmmh_regnum_p,
- mpx_ctrl_regnum_p, xmm_avx512_regnum_p,
- avx512_p, avx_p, sse_p, pkru_regnum_p;
+ zmm_regnum_p, zmmh_regnum_p, xmm_avx512_regnum_p, avx512_p, avx_p,
+ sse_p, pkru_regnum_p;
/* Don't include pseudo registers, except for MMX, in any register
groups. */
@@ -4542,21 +4375,6 @@ i386_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
|| zmmh_regnum_p))
return 0;
- bnd_regnum_p = i386_bnd_regnum_p (gdbarch, regnum);
- if (group == all_reggroup
- && ((bnd_regnum_p && (tdep->xcr0 & X86_XSTATE_MPX_MASK))))
- return bnd_regnum_p;
-
- bndr_regnum_p = i386_bndr_regnum_p (gdbarch, regnum);
- if (group == all_reggroup
- && ((bndr_regnum_p && (tdep->xcr0 & X86_XSTATE_MPX_MASK))))
- return 0;
-
- mpx_ctrl_regnum_p = i386_mpx_ctrl_regnum_p (gdbarch, regnum);
- if (group == all_reggroup
- && ((mpx_ctrl_regnum_p && (tdep->xcr0 & X86_XSTATE_MPX_MASK))))
- return mpx_ctrl_regnum_p;
-
if (group == general_reggroup)
return (!fp_regnum_p
&& !mmx_regnum_p
@@ -4567,9 +4385,6 @@ i386_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
&& !ymmh_regnum_p
&& !ymm_avx512_regnum_p
&& !ymmh_avx512_regnum_p
- && !bndr_regnum_p
- && !bnd_regnum_p
- && !mpx_ctrl_regnum_p
&& !zmm_regnum_p
&& !zmmh_regnum_p
&& !pkru_regnum_p);
@@ -8186,7 +8001,7 @@ i386_xcr0_from_tdesc (const struct target_desc *tdesc)
const struct tdesc_feature *feature_core;
- const struct tdesc_feature *feature_sse, *feature_avx, *feature_mpx,
+ const struct tdesc_feature *feature_sse, *feature_avx,
*feature_avx512, *feature_pkeys;
/* Get core registers. */
@@ -8200,9 +8015,6 @@ i386_xcr0_from_tdesc (const struct target_desc *tdesc)
/* Try AVX registers. */
feature_avx = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.avx");
- /* Try MPX registers. */
- feature_mpx = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.mpx");
-
/* Try AVX512 registers. */
feature_avx512 = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.avx512");
@@ -8224,9 +8036,6 @@ i386_xcr0_from_tdesc (const struct target_desc *tdesc)
xcr0 |= X86_XSTATE_AVX;
}
- if (feature_mpx)
- xcr0 |= X86_XSTATE_MPX_MASK;
-
if (feature_avx512)
{
/* AVX512 register description requires AVX register description. */
@@ -8249,8 +8058,8 @@ i386_validate_tdesc_p (i386_gdbarch_tdep *tdep,
const struct target_desc *tdesc = tdep->tdesc;
const struct tdesc_feature *feature_core;
- const struct tdesc_feature *feature_sse, *feature_avx, *feature_mpx,
- *feature_avx512, *feature_pkeys, *feature_segments;
+ const struct tdesc_feature *feature_sse, *feature_avx, *feature_avx512,
+ *feature_pkeys, *feature_segments;
int i, num_regs, valid_p;
if (! tdesc_has_registers (tdesc))
@@ -8267,9 +8076,6 @@ i386_validate_tdesc_p (i386_gdbarch_tdep *tdep,
/* Try AVX registers. */
feature_avx = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.avx");
- /* Try MPX registers. */
- feature_mpx = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.mpx");
-
/* Try AVX512 registers. */
feature_avx512 = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.avx512");
@@ -8368,23 +8174,6 @@ i386_validate_tdesc_p (i386_gdbarch_tdep *tdep,
tdep->register_names[i]);
}
- if (feature_mpx)
- {
- tdep->xcr0 |= X86_XSTATE_MPX_MASK;
-
- if (tdep->bnd0r_regnum < 0)
- {
- tdep->mpx_register_names = i386_mpx_names;
- tdep->bnd0r_regnum = I386_BND0R_REGNUM;
- tdep->bndcfgu_regnum = I386_BNDCFGU_REGNUM;
- }
-
- for (i = 0; i < I387_NUM_MPX_REGS; i++)
- valid_p &= tdesc_numbered_register (feature_mpx, tdesc_data,
- I387_BND0R_REGNUM (tdep) + i,
- tdep->mpx_register_names[i]);
- }
-
if (feature_segments)
{
if (tdep->fsbase_regnum < 0)
@@ -8448,8 +8237,6 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
const struct target_desc *tdesc;
int mm0_regnum;
int ymm0_regnum;
- int bnd0_regnum;
- int num_bnd_cooked;
x86_xsave_layout xsave_layout = target_fetch_x86_xsave_layout ();
@@ -8498,7 +8285,7 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
tdep->st0_regnum = I386_ST0_REGNUM;
- /* I386_NUM_XREGS includes %mxcsr, so substract one. */
+ /* I386_NUM_XREGS includes %mxcsr, so subtract one. */
tdep->num_xmm_regs = I386_NUM_XREGS - 1;
tdep->jb_pc_offset = -1;
@@ -8655,7 +8442,7 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
/* Even though the default ABI only includes general-purpose registers,
floating-point registers and the SSE registers, we have to leave a
- gap for the upper AVX, MPX and AVX512 registers. */
+ gap for the upper AVX, (deprecated) MPX and AVX512 registers. */
set_gdbarch_num_regs (gdbarch, I386_NUM_REGS);
set_gdbarch_gnu_triplet_regexp (gdbarch, i386_gnu_triplet_regexp);
@@ -8691,10 +8478,6 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
tdep->num_mmx_regs = 8;
tdep->num_ymm_regs = 0;
- /* No MPX registers. */
- tdep->bnd0r_regnum = -1;
- tdep->bndcfgu_regnum = -1;
-
/* No AVX512 registers. */
tdep->k0_regnum = -1;
tdep->num_zmm_regs = 0;
@@ -8731,8 +8514,6 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
}
tdep->xsave_layout = xsave_layout;
- num_bnd_cooked = (tdep->bnd0r_regnum > 0 ? I387_NUM_BND_REGS : 0);
-
/* Wire in pseudo registers. Number of pseudo registers may be
changed. */
set_gdbarch_num_pseudo_regs (gdbarch, (tdep->num_byte_regs
@@ -8740,7 +8521,6 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
+ tdep->num_dword_regs
+ tdep->num_mmx_regs
+ tdep->num_ymm_regs
- + num_bnd_cooked
+ tdep->num_ymm_avx512_regs
+ tdep->num_zmm_regs));
@@ -8794,21 +8574,14 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
else
tdep->zmm0_regnum = -1;
- bnd0_regnum = mm0_regnum;
if (tdep->num_mmx_regs != 0)
{
/* Support MMX pseudo-register if MMX hasn't been disabled. */
tdep->mm0_regnum = mm0_regnum;
- bnd0_regnum += tdep->num_mmx_regs;
}
else
tdep->mm0_regnum = -1;
- if (tdep->bnd0r_regnum > 0)
- tdep->bnd0_regnum = bnd0_regnum;
- else
- tdep-> bnd0_regnum = -1;
-
/* Hook in the legacy prologue-based unwinders last (fallback). */
if (info.bfd_arch_info->bits_per_word == 32)
{
@@ -8838,12 +8611,11 @@ const struct target_desc *
i386_target_description (uint64_t xcr0, bool segments)
{
static target_desc *i386_tdescs \
- [2/*SSE*/][2/*AVX*/][2/*MPX*/][2/*AVX512*/][2/*PKRU*/][2/*segments*/] = {};
+ [2/*SSE*/][2/*AVX*/][2/*AVX512*/][2/*PKRU*/][2/*segments*/] = {};
target_desc **tdesc;
tdesc = &i386_tdescs[(xcr0 & X86_XSTATE_SSE) ? 1 : 0]
[(xcr0 & X86_XSTATE_AVX) ? 1 : 0]
- [(xcr0 & X86_XSTATE_MPX) ? 1 : 0]
[(xcr0 & X86_XSTATE_AVX512) ? 1 : 0]
[(xcr0 & X86_XSTATE_PKRU) ? 1 : 0]
[segments ? 1 : 0];
@@ -8854,245 +8626,6 @@ i386_target_description (uint64_t xcr0, bool segments)
return *tdesc;
}
-#define MPX_BASE_MASK (~(ULONGEST) 0xfff)
-
-/* Find the bound directory base address. */
-
-static unsigned long
-i386_mpx_bd_base (void)
-{
- ULONGEST ret;
- enum register_status regstatus;
-
- regcache *rcache = get_thread_regcache (inferior_thread ());
- gdbarch *arch = rcache->arch ();
- i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (arch);
-
- regstatus = regcache_raw_read_unsigned (rcache, tdep->bndcfgu_regnum, &ret);
-
- if (regstatus != REG_VALID)
- error (_("BNDCFGU register invalid, read status %d."), regstatus);
-
- return ret & MPX_BASE_MASK;
-}
-
-int
-i386_mpx_enabled (void)
-{
- gdbarch *arch = get_current_arch ();
- i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (arch);
- const struct target_desc *tdesc = tdep->tdesc;
-
- return (tdesc_find_feature (tdesc, "org.gnu.gdb.i386.mpx") != NULL);
-}
-
-#define MPX_BD_MASK 0xfffffff00000ULL /* select bits [47:20] */
-#define MPX_BT_MASK 0x0000000ffff8 /* select bits [19:3] */
-#define MPX_BD_MASK_32 0xfffff000 /* select bits [31:12] */
-#define MPX_BT_MASK_32 0x00000ffc /* select bits [11:2] */
-
-/* Find the bound table entry given the pointer location and the base
- address of the table. */
-
-static CORE_ADDR
-i386_mpx_get_bt_entry (CORE_ADDR ptr, CORE_ADDR bd_base)
-{
- CORE_ADDR offset1;
- CORE_ADDR offset2;
- CORE_ADDR mpx_bd_mask, bd_ptr_r_shift, bd_ptr_l_shift;
- CORE_ADDR bt_mask, bt_select_r_shift, bt_select_l_shift;
- CORE_ADDR bd_entry_addr;
- CORE_ADDR bt_addr;
- CORE_ADDR bd_entry;
- struct gdbarch *gdbarch = get_current_arch ();
- struct type *data_ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
-
-
- if (gdbarch_ptr_bit (gdbarch) == 64)
- {
- mpx_bd_mask = (CORE_ADDR) MPX_BD_MASK;
- bd_ptr_r_shift = 20;
- bd_ptr_l_shift = 3;
- bt_select_r_shift = 3;
- bt_select_l_shift = 5;
- bt_mask = (CORE_ADDR) MPX_BT_MASK;
-
- if ( sizeof (CORE_ADDR) == 4)
- error (_("bound table examination not supported\
- for 64-bit process with 32-bit GDB"));
- }
- else
- {
- mpx_bd_mask = MPX_BD_MASK_32;
- bd_ptr_r_shift = 12;
- bd_ptr_l_shift = 2;
- bt_select_r_shift = 2;
- bt_select_l_shift = 4;
- bt_mask = MPX_BT_MASK_32;
- }
-
- offset1 = ((ptr & mpx_bd_mask) >> bd_ptr_r_shift) << bd_ptr_l_shift;
- bd_entry_addr = bd_base + offset1;
- bd_entry = read_memory_typed_address (bd_entry_addr, data_ptr_type);
-
- if ((bd_entry & 0x1) == 0)
- error (_("Invalid bounds directory entry at %s."),
- paddress (get_current_arch (), bd_entry_addr));
-
- /* Clearing status bit. */
- bd_entry--;
- bt_addr = bd_entry & ~bt_select_r_shift;
- offset2 = ((ptr & bt_mask) >> bt_select_r_shift) << bt_select_l_shift;
-
- return bt_addr + offset2;
-}
-
-/* Print routine for the mpx bounds. */
-
-static void
-i386_mpx_print_bounds (const CORE_ADDR bt_entry[4])
-{
- struct ui_out *uiout = current_uiout;
- LONGEST size;
- struct gdbarch *gdbarch = get_current_arch ();
- CORE_ADDR onecompl = ~((CORE_ADDR) 0);
- int bounds_in_map = ((~bt_entry[1] == 0 && bt_entry[0] == onecompl) ? 1 : 0);
-
- if (bounds_in_map == 1)
- {
- uiout->text ("Null bounds on map:");
- uiout->text (" pointer value = ");
- uiout->field_core_addr ("pointer-value", gdbarch, bt_entry[2]);
- uiout->text (".");
- uiout->text ("\n");
- }
- else
- {
- uiout->text ("{lbound = ");
- uiout->field_core_addr ("lower-bound", gdbarch, bt_entry[0]);
- uiout->text (", ubound = ");
-
- /* The upper bound is stored in 1's complement. */
- uiout->field_core_addr ("upper-bound", gdbarch, ~bt_entry[1]);
- uiout->text ("}: pointer value = ");
- uiout->field_core_addr ("pointer-value", gdbarch, bt_entry[2]);
-
- if (gdbarch_ptr_bit (gdbarch) == 64)
- size = ( (~(int64_t) bt_entry[1]) - (int64_t) bt_entry[0]);
- else
- size = ( ~((int32_t) bt_entry[1]) - (int32_t) bt_entry[0]);
-
- /* In case the bounds are 0x0 and 0xffff... the difference will be -1.
- -1 represents in this sense full memory access, and there is no need
- one to the size. */
-
- size = (size > -1 ? size + 1 : size);
- uiout->text (", size = ");
- uiout->field_string ("size", plongest (size));
-
- uiout->text (", metadata = ");
- uiout->field_core_addr ("metadata", gdbarch, bt_entry[3]);
- uiout->text ("\n");
- }
-}
-
-/* Implement the command "show mpx bound". */
-
-static void
-i386_mpx_info_bounds (const char *args, int from_tty)
-{
- CORE_ADDR bd_base = 0;
- CORE_ADDR addr;
- CORE_ADDR bt_entry_addr = 0;
- CORE_ADDR bt_entry[4];
- int i;
- struct gdbarch *gdbarch = get_current_arch ();
- struct type *data_ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
-
- if (gdbarch_bfd_arch_info (gdbarch)->arch != bfd_arch_i386
- || !i386_mpx_enabled ())
- {
- gdb_printf (_("Intel Memory Protection Extensions not "
- "supported on this target.\n"));
- return;
- }
-
- if (args == NULL)
- {
- gdb_printf (_("Address of pointer variable expected.\n"));
- return;
- }
-
- addr = parse_and_eval_address (args);
-
- bd_base = i386_mpx_bd_base ();
- bt_entry_addr = i386_mpx_get_bt_entry (addr, bd_base);
-
- memset (bt_entry, 0, sizeof (bt_entry));
-
- for (i = 0; i < 4; i++)
- bt_entry[i] = read_memory_typed_address (bt_entry_addr
- + i * data_ptr_type->length (),
- data_ptr_type);
-
- i386_mpx_print_bounds (bt_entry);
-}
-
-/* Implement the command "set mpx bound". */
-
-static void
-i386_mpx_set_bounds (const char *args, int from_tty)
-{
- CORE_ADDR bd_base = 0;
- CORE_ADDR addr, lower, upper;
- CORE_ADDR bt_entry_addr = 0;
- CORE_ADDR bt_entry[2];
- const char *input = args;
- int i;
- struct gdbarch *gdbarch = get_current_arch ();
- enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- struct type *data_ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
-
- if (gdbarch_bfd_arch_info (gdbarch)->arch != bfd_arch_i386
- || !i386_mpx_enabled ())
- error (_("Intel Memory Protection Extensions not supported\
- on this target."));
-
- if (args == NULL)
- error (_("Pointer value expected."));
-
- addr = value_as_address (parse_to_comma_and_eval (&input));
-
- if (input[0] == ',')
- ++input;
- if (input[0] == '\0')
- error (_("wrong number of arguments: missing lower and upper bound."));
- lower = value_as_address (parse_to_comma_and_eval (&input));
-
- if (input[0] == ',')
- ++input;
- if (input[0] == '\0')
- error (_("Wrong number of arguments; Missing upper bound."));
- upper = value_as_address (parse_to_comma_and_eval (&input));
-
- bd_base = i386_mpx_bd_base ();
- bt_entry_addr = i386_mpx_get_bt_entry (addr, bd_base);
- for (i = 0; i < 2; i++)
- bt_entry[i] = read_memory_typed_address (bt_entry_addr
- + i * data_ptr_type->length (),
- data_ptr_type);
- bt_entry[0] = (uint64_t) lower;
- bt_entry[1] = ~(uint64_t) upper;
-
- for (i = 0; i < 2; i++)
- write_memory_unsigned_integer (bt_entry_addr
- + i * data_ptr_type->length (),
- data_ptr_type->length (), byte_order,
- bt_entry[i]);
-}
-
-static struct cmd_list_element *mpx_set_cmdlist, *mpx_show_cmdlist;
-
void _initialize_i386_tdep ();
void
_initialize_i386_tdep ()
@@ -9121,30 +8654,6 @@ is \"default\"."),
NULL, /* FIXME: i18n: */
&setlist, &showlist);
- /* Add "mpx" prefix for the set and show commands. */
-
- add_setshow_prefix_cmd
- ("mpx", class_support,
- _("Set Intel Memory Protection Extensions specific variables."),
- _("Show Intel Memory Protection Extensions specific variables."),
- &mpx_set_cmdlist, &mpx_show_cmdlist, &setlist, &showlist);
-
- /* Add "bound" command for the show mpx commands list. */
-
- cmd_list_element *c = add_cmd ("bound", no_class, i386_mpx_info_bounds,
- "Show the memory bounds for a given array/pointer storage\
- in the bound table.",
- &mpx_show_cmdlist);
- deprecate_cmd (c, nullptr);
-
- /* Add "bound" command for the set mpx commands list. */
-
- c = add_cmd ("bound", no_class, i386_mpx_set_bounds,
- "Set the memory bounds for a given array/pointer storage\
- in the bound table.",
- &mpx_set_cmdlist);
- deprecate_cmd (c, nullptr);
-
gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_SVR4,
i386_svr4_init_abi);
diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h
index a85e0a9..82676c2 100644
--- a/gdb/i386-tdep.h
+++ b/gdb/i386-tdep.h
@@ -166,21 +166,6 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base
/* YMM16-31 register names. Only used for tdesc_numbered_register. */
const char * const *ymm16h_register_names = nullptr;
- /* Register number for %bnd0r. Set this to -1 to indicate the absence
- bound registers. */
- int bnd0r_regnum = 0;
-
- /* Register number for pseudo register %bnd0. Set this to -1 to indicate the absence
- bound registers. */
- int bnd0_regnum = 0;
-
- /* Register number for %bndcfgu. Set this to -1 to indicate the absence
- bound control registers. */
- int bndcfgu_regnum = 0;
-
- /* MPX register names. Only used for tdesc_numbered_register. */
- const char * const *mpx_register_names = nullptr;
-
/* Register number for %zmm0h. Set this to -1 to indicate the absence
of ZMM_HI256 register support. */
int zmm0h_regnum = 0;
@@ -246,7 +231,6 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base
struct type *i386_ymm_type = nullptr;
struct type *i386_zmm_type = nullptr;
struct type *i387_ext_type = nullptr;
- struct type *i386_bnd_type = nullptr;
/* Process record/replay target. */
/* The map for registers because the AMD64's registers order
@@ -298,6 +282,8 @@ enum i386_regnum
I386_MXCSR_REGNUM = 40, /* %mxcsr */
I386_YMM0H_REGNUM, /* %ymm0h */
I386_YMM7H_REGNUM = I386_YMM0H_REGNUM + 7,
+ /* MPX is deprecated. Yet we keep this to not give the registers below
+ a new number. That could break older gdbservers. */
I386_BND0R_REGNUM,
I386_BND3R_REGNUM = I386_BND0R_REGNUM + 3,
I386_BNDCFGU_REGNUM,
@@ -346,7 +332,6 @@ enum record_i386_regnum
#define I386_SSE_NUM_REGS (I386_MXCSR_REGNUM + 1)
#define I386_AVX_NUM_REGS (I386_YMM7H_REGNUM + 1)
-#define I386_MPX_NUM_REGS (I386_BNDSTATUS_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)
@@ -365,7 +350,6 @@ extern int i386_xmm_regnum_p (struct gdbarch *gdbarch, int regnum);
extern int i386_xmm_avx512_regnum_p (struct gdbarch * gdbarch, int regnum);
extern int i386_ymm_regnum_p (struct gdbarch *gdbarch, int regnum);
extern int i386_ymm_avx512_regnum_p (struct gdbarch *gdbarch, int regnum);
-extern int i386_bnd_regnum_p (struct gdbarch *gdbarch, int regnum);
extern int i386_k_regnum_p (struct gdbarch *gdbarch, int regnum);
extern int i386_zmm_regnum_p (struct gdbarch *gdbarch, int regnum);
extern int i386_zmmh_regnum_p (struct gdbarch *gdbarch, int regnum);
@@ -468,10 +452,6 @@ extern int i386_process_record (struct gdbarch *gdbarch,
extern const struct target_desc *i386_target_description (uint64_t xcr0,
bool segments);
-/* Return true iff the current target is MPX enabled. */
-extern int i386_mpx_enabled (void);
-
-
/* Functions and variables exported from i386-bsd-tdep.c. */
extern void i386bsd_init_abi (struct gdbarch_info, struct gdbarch *);
diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c
index 675ee8d..3bda888 100644
--- a/gdb/i387-tdep.c
+++ b/gdb/i387-tdep.c
@@ -818,30 +818,6 @@ static int xsave_xmm_avx512_offset[] =
(xsave + (tdep)->xsave_layout.zmm_offset \
+ xsave_xmm_avx512_offset[regnum - I387_XMM16_REGNUM (tdep)])
-/* At xsave_bndregs_offset[REGNUM] you'll find the relative offset
- within the BNDREGS region of the XSAVE extended state where the GDB
- register BND0R + REGNUM is stored. */
-
-static int xsave_bndregs_offset[] = {
- 0 * 16, /* bnd0r...bnd3r registers. */
- 1 * 16,
- 2 * 16,
- 3 * 16
-};
-
-#define XSAVE_BNDREGS_ADDR(tdep, xsave, regnum) \
- (xsave + (tdep)->xsave_layout.bndregs_offset \
- + xsave_bndregs_offset[regnum - I387_BND0R_REGNUM (tdep)])
-
-static int xsave_bndcfg_offset[] = {
- 0 * 8, /* bndcfg ... bndstatus. */
- 1 * 8,
-};
-
-#define XSAVE_BNDCFG_ADDR(tdep, xsave, regnum) \
- (xsave + (tdep)->xsave_layout.bndcfg_offset \
- + xsave_bndcfg_offset[regnum - I387_BNDCFGU_REGNUM (tdep)])
-
/* At xsave_avx512_k_offset[REGNUM] you'll find the relative offset
within the K region of the XSAVE extended state where the AVX512
opmask register K0 + REGNUM is stored. */
@@ -944,8 +920,6 @@ i387_guess_xsave_layout (uint64_t xcr0, size_t xsave_size,
{
/* Intel CPUs supporting PKRU. */
layout.avx_offset = 576;
- layout.bndregs_offset = 960;
- layout.bndcfg_offset = 1024;
layout.k_offset = 1088;
layout.zmm_h_offset = 1152;
layout.zmm_offset = 1664;
@@ -964,20 +938,14 @@ i387_guess_xsave_layout (uint64_t xcr0, size_t xsave_size,
{
/* Intel CPUs supporting AVX512. */
layout.avx_offset = 576;
- layout.bndregs_offset = 960;
- layout.bndcfg_offset = 1024;
layout.k_offset = 1088;
layout.zmm_h_offset = 1152;
layout.zmm_offset = 1664;
}
- else if (HAS_MPX (xcr0) && xsave_size == 1088)
- {
- /* Intel CPUs supporting MPX. */
- layout.avx_offset = 576;
- layout.bndregs_offset = 960;
- layout.bndcfg_offset = 1024;
- }
- else if (HAS_AVX (xcr0) && xsave_size == 832)
+ /* As MPX has been removed, we need the additional check
+ (xsave_size == 1088) to allow reading AVX registers from corefiles
+ on CPUs with MPX as the highest supported feature. */
+ else if (HAS_AVX (xcr0) && (xsave_size == 832 || xsave_size == 1088))
{
/* Intel and AMD CPUs supporting AVX. */
layout.avx_offset = 576;
@@ -1000,8 +968,6 @@ i387_fallback_xsave_layout (uint64_t xcr0)
{
/* Intel CPUs supporting PKRU. */
layout.avx_offset = 576;
- layout.bndregs_offset = 960;
- layout.bndcfg_offset = 1024;
layout.k_offset = 1088;
layout.zmm_h_offset = 1152;
layout.zmm_offset = 1664;
@@ -1012,21 +978,11 @@ i387_fallback_xsave_layout (uint64_t xcr0)
{
/* Intel CPUs supporting AVX512. */
layout.avx_offset = 576;
- layout.bndregs_offset = 960;
- layout.bndcfg_offset = 1024;
layout.k_offset = 1088;
layout.zmm_h_offset = 1152;
layout.zmm_offset = 1664;
layout.sizeof_xsave = 2688;
}
- else if (HAS_MPX (xcr0))
- {
- /* Intel CPUs supporting MPX. */
- layout.avx_offset = 576;
- layout.bndregs_offset = 960;
- layout.bndcfg_offset = 1024;
- layout.sizeof_xsave = 1088;
- }
else if (HAS_AVX (xcr0))
{
/* Intel and AMD CPUs supporting AVX. */
@@ -1082,16 +1038,14 @@ i387_supply_xsave (struct regcache *regcache, int regnum,
x87 = 0x1,
sse = 0x2,
avxh = 0x4,
- bndregs = 0x8,
- bndcfg = 0x10,
- avx512_k = 0x20,
- avx512_zmm0_h = 0x40,
- avx512_zmm16_h = 0x80,
- avx512_ymmh_avx512 = 0x100,
- avx512_xmm_avx512 = 0x200,
- pkeys = 0x400,
- all = x87 | sse | avxh | bndregs | bndcfg | avx512_k | avx512_zmm0_h
- | avx512_zmm16_h | avx512_ymmh_avx512 | avx512_xmm_avx512 | pkeys
+ avx512_k = 0x8,
+ avx512_zmm0_h = 0x10,
+ avx512_zmm16_h = 0x20,
+ avx512_ymmh_avx512 = 0x40,
+ avx512_xmm_avx512 = 0x80,
+ pkeys = 0x100,
+ all = x87 | sse | avxh | avx512_k | avx512_zmm0_h | avx512_zmm16_h
+ | avx512_ymmh_avx512 | avx512_xmm_avx512 | pkeys
} regclass;
gdb_assert (regs != NULL);
@@ -1121,12 +1075,6 @@ i387_supply_xsave (struct regcache *regcache, int regnum,
else if (regnum >= I387_YMM0H_REGNUM (tdep)
&& regnum < I387_YMMENDH_REGNUM (tdep))
regclass = avxh;
- else if (regnum >= I387_BND0R_REGNUM (tdep)
- && regnum < I387_BNDCFGU_REGNUM (tdep))
- regclass = bndregs;
- else if (regnum >= I387_BNDCFGU_REGNUM (tdep)
- && regnum < I387_MPXEND_REGNUM (tdep))
- regclass = bndcfg;
else if (regnum >= I387_XMM0_REGNUM (tdep)
&& regnum < I387_MXCSR_REGNUM (tdep))
regclass = sse;
@@ -1205,20 +1153,6 @@ i387_supply_xsave (struct regcache *regcache, int regnum,
regcache->raw_supply (regnum, XSAVE_AVXH_ADDR (tdep, regs, regnum));
return;
- case bndcfg:
- if ((clear_bv & X86_XSTATE_BNDCFG))
- regcache->raw_supply (regnum, zero);
- else
- regcache->raw_supply (regnum, XSAVE_BNDCFG_ADDR (tdep, regs, regnum));
- return;
-
- case bndregs:
- if ((clear_bv & X86_XSTATE_BNDREGS))
- regcache->raw_supply (regnum, zero);
- else
- regcache->raw_supply (regnum, XSAVE_BNDREGS_ADDR (tdep, regs, regnum));
- return;
-
case sse:
if ((clear_bv & X86_XSTATE_SSE))
regcache->raw_supply (regnum, zero);
@@ -1341,40 +1275,6 @@ i387_supply_xsave (struct regcache *regcache, int regnum,
}
}
- /* Handle the MPX registers. */
- if ((tdep->xcr0 & X86_XSTATE_BNDREGS))
- {
- if (clear_bv & X86_XSTATE_BNDREGS)
- {
- for (i = I387_BND0R_REGNUM (tdep);
- i < I387_BNDCFGU_REGNUM (tdep); i++)
- regcache->raw_supply (i, zero);
- }
- else
- {
- for (i = I387_BND0R_REGNUM (tdep);
- i < I387_BNDCFGU_REGNUM (tdep); i++)
- regcache->raw_supply (i, XSAVE_BNDREGS_ADDR (tdep, regs, i));
- }
- }
-
- /* Handle the MPX registers. */
- if ((tdep->xcr0 & X86_XSTATE_BNDCFG))
- {
- if (clear_bv & X86_XSTATE_BNDCFG)
- {
- for (i = I387_BNDCFGU_REGNUM (tdep);
- i < I387_MPXEND_REGNUM (tdep); i++)
- regcache->raw_supply (i, zero);
- }
- else
- {
- for (i = I387_BNDCFGU_REGNUM (tdep);
- i < I387_MPXEND_REGNUM (tdep); i++)
- regcache->raw_supply (i, XSAVE_BNDCFG_ADDR (tdep, regs, i));
- }
- }
-
/* Handle the XMM registers. */
if ((tdep->xcr0 & X86_XSTATE_SSE))
{
@@ -1527,16 +1427,14 @@ i387_collect_xsave (const struct regcache *regcache, int regnum,
x87 = 0x2,
sse = 0x4,
avxh = 0x8,
- bndregs = 0x10,
- bndcfg = 0x20,
- avx512_k = 0x40,
- avx512_zmm0_h = 0x80,
- avx512_zmm16_h = 0x100,
- avx512_ymmh_avx512 = 0x200,
- avx512_xmm_avx512 = 0x400,
- pkeys = 0x800,
- all = x87 | sse | avxh | bndregs | bndcfg | avx512_k | avx512_zmm0_h
- | avx512_zmm16_h | avx512_ymmh_avx512 | avx512_xmm_avx512 | pkeys
+ avx512_k = 0x10,
+ avx512_zmm0_h = 0x20,
+ avx512_zmm16_h = 0x40,
+ avx512_ymmh_avx512 = 0x80,
+ avx512_xmm_avx512 = 0x100,
+ pkeys = 0x200,
+ all = x87 | sse | avxh | avx512_k | avx512_zmm0_h | avx512_zmm16_h
+ | avx512_ymmh_avx512 | avx512_xmm_avx512 | pkeys
} regclass;
gdb_assert (tdep->st0_regnum >= I386_ST0_REGNUM);
@@ -1565,12 +1463,6 @@ i387_collect_xsave (const struct regcache *regcache, int regnum,
else if (regnum >= I387_YMM0H_REGNUM (tdep)
&& regnum < I387_YMMENDH_REGNUM (tdep))
regclass = avxh;
- else if (regnum >= I387_BND0R_REGNUM (tdep)
- && regnum < I387_BNDCFGU_REGNUM (tdep))
- regclass = bndregs;
- else if (regnum >= I387_BNDCFGU_REGNUM (tdep)
- && regnum < I387_MPXEND_REGNUM (tdep))
- regclass = bndcfg;
else if (regnum >= I387_XMM0_REGNUM (tdep)
&& regnum < I387_MXCSR_REGNUM (tdep))
regclass = sse;
@@ -1619,16 +1511,6 @@ i387_collect_xsave (const struct regcache *regcache, int regnum,
i < I387_PKEYSEND_REGNUM (tdep); i++)
memset (XSAVE_PKEYS_ADDR (tdep, regs, i), 0, 4);
- if ((clear_bv & X86_XSTATE_BNDREGS))
- for (i = I387_BND0R_REGNUM (tdep);
- i < I387_BNDCFGU_REGNUM (tdep); i++)
- memset (XSAVE_BNDREGS_ADDR (tdep, regs, i), 0, 16);
-
- if ((clear_bv & X86_XSTATE_BNDCFG))
- for (i = I387_BNDCFGU_REGNUM (tdep);
- i < I387_MPXEND_REGNUM (tdep); i++)
- memset (XSAVE_BNDCFG_ADDR (tdep, regs, i), 0, 8);
-
if ((clear_bv & X86_XSTATE_ZMM_H))
for (i = I387_ZMM0H_REGNUM (tdep); i < zmm_endlo_regnum; i++)
memset (XSAVE_AVX512_ZMM0_H_ADDR (tdep, regs, i), 0, 32);
@@ -1771,34 +1653,6 @@ i387_collect_xsave (const struct regcache *regcache, int regnum,
}
}
- /* Check if any upper MPX registers are changed. */
- if ((tdep->xcr0 & X86_XSTATE_BNDREGS))
- for (i = I387_BND0R_REGNUM (tdep);
- i < I387_BNDCFGU_REGNUM (tdep); i++)
- {
- regcache->raw_collect (i, raw);
- p = XSAVE_BNDREGS_ADDR (tdep, regs, i);
- if (memcmp (raw, p, 16))
- {
- xstate_bv |= X86_XSTATE_BNDREGS;
- memcpy (p, raw, 16);
- }
- }
-
- /* Check if any upper MPX registers are changed. */
- if ((tdep->xcr0 & X86_XSTATE_BNDCFG))
- for (i = I387_BNDCFGU_REGNUM (tdep);
- i < I387_MPXEND_REGNUM (tdep); i++)
- {
- regcache->raw_collect (i, raw);
- p = XSAVE_BNDCFG_ADDR (tdep, regs, i);
- if (memcmp (raw, p, 8))
- {
- xstate_bv |= X86_XSTATE_BNDCFG;
- memcpy (p, raw, 8);
- }
- }
-
/* Check if any upper YMM registers are changed. */
if ((tdep->xcr0 & X86_XSTATE_AVX))
for (i = I387_YMM0H_REGNUM (tdep);
@@ -1940,22 +1794,6 @@ i387_collect_xsave (const struct regcache *regcache, int regnum,
}
break;
- case bndregs:
- regcache->raw_collect (regnum, raw);
- p = XSAVE_BNDREGS_ADDR (tdep, regs, regnum);
- if (memcmp (raw, p, 16))
- {
- xstate_bv |= X86_XSTATE_BNDREGS;
- memcpy (p, raw, 16);
- }
- break;
-
- case bndcfg:
- p = XSAVE_BNDCFG_ADDR (tdep, regs, regnum);
- xstate_bv |= X86_XSTATE_BNDCFG;
- memcpy (p, raw, 8);
- break;
-
case sse:
/* This is an SSE register. */
p = FXSAVE_ADDR (tdep, regs, regnum);
@@ -2143,20 +1981,3 @@ i387_return_value (struct gdbarch *gdbarch, struct regcache *regcache)
regcache_raw_write_unsigned (regcache, I387_FTAG_REGNUM (tdep), 0x3fff);
}
-
-/* See i387-tdep.h. */
-
-void
-i387_reset_bnd_regs (struct gdbarch *gdbarch, struct regcache *regcache)
-{
- i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
-
- if (I387_BND0R_REGNUM (tdep) > 0)
- {
- gdb_byte bnd_buf[16];
-
- memset (bnd_buf, 0, 16);
- for (int i = 0; i < I387_NUM_BND_REGS; i++)
- regcache->raw_write (I387_BND0R_REGNUM (tdep) + i, bnd_buf);
- }
-}
diff --git a/gdb/i387-tdep.h b/gdb/i387-tdep.h
index 30d7694..7b2c3b1 100644
--- a/gdb/i387-tdep.h
+++ b/gdb/i387-tdep.h
@@ -37,13 +37,7 @@ struct x86_xsave_layout;
#define I387_NUM_YMM_REGS(tdep) ((tdep)->num_ymm_regs)
#define I387_YMM0H_REGNUM(tdep) ((tdep)->ymm0h_regnum)
-#define I387_BND0R_REGNUM(tdep) ((tdep)->bnd0r_regnum)
-#define I387_BNDCFGU_REGNUM(tdep) ((tdep)->bndcfgu_regnum)
-
/* Set of constants used for 32 and 64-bit. */
-#define I387_NUM_MPX_REGS 6
-#define I387_NUM_BND_REGS 4
-#define I387_NUM_MPX_CTRL_REGS 2
#define I387_NUM_K_REGS 8
#define I387_NUM_PKEYS_REGS 1
@@ -71,8 +65,6 @@ struct x86_xsave_layout;
#define I387_YMMENDH_REGNUM(tdep) \
(I387_YMM0H_REGNUM (tdep) + I387_NUM_YMM_REGS (tdep))
-#define I387_MPXEND_REGNUM(tdep) \
- (I387_BND0R_REGNUM (tdep) + I387_NUM_MPX_REGS)
#define I387_KEND_REGNUM(tdep) \
(I387_K0_REGNUM (tdep) + I387_NUM_K_REGS)
@@ -181,8 +173,4 @@ extern ULONGEST i387_xsave_get_clear_bv (struct gdbarch *gdbarch,
extern void i387_return_value (struct gdbarch *gdbarch,
struct regcache *regcache);
-/* Set all bnd registers to the INIT state. INIT state means
- all memory range can be accessed. */
-extern void i387_reset_bnd_regs (struct gdbarch *gdbarch,
- struct regcache *regcache);
#endif /* i387-tdep.h */
diff --git a/gdb/ia64-tdep.h b/gdb/ia64-tdep.h
index 64be38b..3d5b56e 100644
--- a/gdb/ia64-tdep.h
+++ b/gdb/ia64-tdep.h
@@ -156,7 +156,7 @@
/* Predicate registers: There are 64 of these 1-bit registers. We
define a single register which is used to communicate these values
to/from the target. We will somehow contrive to make it appear
- that IA64_PR0_REGNUM thru IA64_PR63_REGNUM hold the actual values. */
+ that IA64_PR0_REGNUM through IA64_PR63_REGNUM hold the actual values. */
#define IA64_PR_REGNUM 330
/* Instruction pointer: 64 bits wide. */
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index acb80af..36d6e2a 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -475,7 +475,7 @@ inf_ptrace_target::xfer_partial (enum target_object object,
case TARGET_OBJECT_AUXV:
#if defined (PT_IO) && defined (PIOD_READ_AUXV)
/* OpenBSD 4.5 has a new PIOD_READ_AUXV operation for the PT_IO
- request that allows us to read the auxilliary vector. Other
+ request that allows us to read the auxiliary vector. Other
BSD's may follow if they feel the need to support PIE. */
{
struct ptrace_io_desc piod;
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 5e9af41..74873b9 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1103,7 +1103,9 @@ jump_command (const char *arg, int from_tty)
find_pc_mapped_section (sal.pc));
if (fn != nullptr && sfn != fn)
{
- if (!query (_("Line %d is not in `%s'. Jump anyway? "), sal.line,
+ if (!query (_("Line %ps is not in `%s'. Jump anyway? "),
+ styled_string (line_number_style.style (),
+ pulongest (sal.line)),
fn->print_name ()))
{
error (_("Not confirmed."));
diff --git a/gdb/linespec.c b/gdb/linespec.c
index be85074..d525626 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -3733,15 +3733,11 @@ collect_symtabs_from_filename (const char *file,
if (pspace->executing_startup)
continue;
- set_current_program_space (pspace);
- iterate_over_symtabs (file, collector);
+ iterate_over_symtabs (pspace, file, collector);
}
}
else
- {
- set_current_program_space (search_pspace);
- iterate_over_symtabs (file, collector);
- }
+ iterate_over_symtabs (search_pspace, file, collector);
return collector.release_symtabs ();
}
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index fe880b3..65ec221 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -43,6 +43,7 @@
#include "gcore-elf.h"
#include "solib-svr4.h"
#include "memtag.h"
+#include "cli/cli-style.h"
#include <ctype.h>
#include <unordered_map>
@@ -213,7 +214,7 @@ get_linux_gdbarch_data (struct gdbarch *gdbarch)
/* Linux-specific cached data. This is used by GDB for caching
purposes for each inferior. This helps reduce the overhead of
- transfering data from a remote target to the local host. */
+ transferring data from a remote target to the local host. */
struct linux_info
{
/* Cache of the inferior's vsyscall/vDSO mapping range. Only valid
@@ -457,7 +458,7 @@ struct mapping
{
ULONGEST addr;
ULONGEST endaddr;
- std::string_view permissions;
+ std::string permissions;
ULONGEST offset;
std::string_view device;
ULONGEST inode;
@@ -484,7 +485,8 @@ read_mapping (const char *line)
const char *permissions_start = p;
while (*p && !isspace (*p))
p++;
- mapping.permissions = {permissions_start, (size_t) (p - permissions_start)};
+ mapping.permissions = std::string (permissions_start,
+ (size_t) (p - permissions_start));
mapping.offset = strtoulst (p, &p, 16);
@@ -897,51 +899,39 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args,
= target_fileio_read_stralloc (NULL, filename);
if (map != NULL)
{
- char *line;
-
gdb_printf (_("Mapped address spaces:\n\n"));
- if (gdbarch_addr_bit (gdbarch) == 32)
- {
- gdb_printf ("\t%10s %10s %10s %10s %s %s\n",
- "Start Addr", " End Addr", " Size",
- " Offset", "Perms ", "objfile");
- }
- else
- {
- gdb_printf (" %18s %18s %10s %10s %s %s\n",
- "Start Addr", " End Addr", " Size",
- " Offset", "Perms ", "objfile");
- }
+ ui_out_emit_table emitter (current_uiout, 6, -1, "ProcMappings");
+
+ int width = gdbarch_addr_bit (gdbarch) == 32 ? 10 : 18;
+ current_uiout->table_header (width, ui_left, "start", "Start Addr");
+ current_uiout->table_header (width, ui_left, "end", "End Addr");
+ current_uiout->table_header (width, ui_left, "size", "Size");
+ current_uiout->table_header (width, ui_left, "offset", "Offset");
+ current_uiout->table_header (5, ui_left, "perms", "Perms");
+ current_uiout->table_header (0, ui_left, "objfile", "File");
+ current_uiout->table_body ();
char *saveptr;
- for (line = strtok_r (map.get (), "\n", &saveptr);
- line;
- line = strtok_r (NULL, "\n", &saveptr))
+ for (const char *line = strtok_r (map.get (), "\n", &saveptr);
+ line != nullptr;
+ line = strtok_r (nullptr, "\n", &saveptr))
{
struct mapping m = read_mapping (line);
- if (gdbarch_addr_bit (gdbarch) == 32)
- {
- gdb_printf ("\t%10s %10s %10s %10s %-5.*s %s\n",
- paddress (gdbarch, m.addr),
- paddress (gdbarch, m.endaddr),
- hex_string (m.endaddr - m.addr),
- hex_string (m.offset),
- (int) m.permissions.size (),
- m.permissions.data (),
- m.filename);
- }
- else
- {
- gdb_printf (" %18s %18s %10s %10s %-5.*s %s\n",
- paddress (gdbarch, m.addr),
- paddress (gdbarch, m.endaddr),
- hex_string (m.endaddr - m.addr),
- hex_string (m.offset),
- (int) m.permissions.size (),
- m.permissions.data (),
- m.filename);
- }
+ ui_out_emit_tuple tuple_emitter (current_uiout, nullptr);
+ current_uiout->field_core_addr ("start", gdbarch, m.addr);
+ current_uiout->field_core_addr ("end", gdbarch, m.endaddr);
+ /* These next two aren't really addresses and so
+ shouldn't be styled as such. */
+ current_uiout->field_string ("size",
+ paddress (gdbarch,
+ m.endaddr - m.addr));
+ current_uiout->field_string ("offset",
+ paddress (gdbarch, m.offset));
+ current_uiout->field_string ("perms", m.permissions);
+ current_uiout->field_string ("objfile", m.filename,
+ file_name_style.style ());
+ current_uiout->text ("\n");
}
}
else
@@ -1242,42 +1232,34 @@ linux_read_core_file_mappings
static void
linux_core_info_proc_mappings (struct gdbarch *gdbarch, const char *args)
{
+ std::optional<ui_out_emit_table> emitter;
+
linux_read_core_file_mappings (gdbarch, current_program_space->core_bfd (),
- [=] (ULONGEST count)
+ [&] (ULONGEST count)
{
gdb_printf (_("Mapped address spaces:\n\n"));
- if (gdbarch_addr_bit (gdbarch) == 32)
- {
- gdb_printf ("\t%10s %10s %10s %10s %s\n",
- "Start Addr",
- " End Addr",
- " Size", " Offset", "objfile");
- }
- else
- {
- gdb_printf (" %18s %18s %10s %10s %s\n",
- "Start Addr",
- " End Addr",
- " Size", " Offset", "objfile");
- }
+ emitter.emplace (current_uiout, 5, -1, "ProcMappings");
+ int width = gdbarch_addr_bit (gdbarch) == 32 ? 10 : 18;
+ current_uiout->table_header (width, ui_left, "start", "Start Addr");
+ current_uiout->table_header (width, ui_left, "end", "End Addr");
+ current_uiout->table_header (width, ui_left, "size", "Size");
+ current_uiout->table_header (width, ui_left, "offset", "Offset");
+ current_uiout->table_header (0, ui_left, "objfile", "File");
+ current_uiout->table_body ();
},
[=] (int num, ULONGEST start, ULONGEST end, ULONGEST file_ofs,
const char *filename, const bfd_build_id *build_id)
{
- if (gdbarch_addr_bit (gdbarch) == 32)
- gdb_printf ("\t%10s %10s %10s %10s %s\n",
- paddress (gdbarch, start),
- paddress (gdbarch, end),
- hex_string (end - start),
- hex_string (file_ofs),
- filename);
- else
- gdb_printf (" %18s %18s %10s %10s %s\n",
- paddress (gdbarch, start),
- paddress (gdbarch, end),
- hex_string (end - start),
- hex_string (file_ofs),
- filename);
+ ui_out_emit_tuple tuple_emitter (current_uiout, nullptr);
+ current_uiout->field_core_addr ("start", gdbarch, start);
+ current_uiout->field_core_addr ("end", gdbarch, end);
+ /* These next two aren't really addresses and so shouldn't be
+ styled as such. */
+ current_uiout->field_string ("size", paddress (gdbarch, end - start));
+ current_uiout->field_string ("offset", paddress (gdbarch, file_ofs));
+ current_uiout->field_string ("objfile", filename,
+ file_name_style.style ());
+ current_uiout->text ("\n");
});
}
diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y
index 28005e1..2887ad2 100644
--- a/gdb/m2-exp.y
+++ b/gdb/m2-exp.y
@@ -117,7 +117,7 @@ using namespace expr;
%token <sval> TYPENAME
%token SIZE CAP ORD HIGH ABS MIN_FUNC MAX_FUNC FLOAT_FUNC VAL CHR ODD TRUNC
-%token TSIZE
+%token TSIZE ADR
%token INC DEC INCL EXCL
/* The GDB scope operator */
@@ -191,6 +191,10 @@ exp : ABS '(' exp ')'
{ error (_("ABS function is not implemented")); }
;
+exp : ADR '(' exp ')'
+ { pstate->wrap<unop_addr_operation> (); }
+ ;
+
exp : HIGH '(' exp ')'
{ pstate->wrap<m2_unop_high_operation> (); }
;
@@ -699,6 +703,7 @@ static struct keyword keytab[] =
{"IN", IN },/* Note space after IN */
{"AND", LOGICAL_AND},
{"ABS", ABS },
+ {"ADR", ADR },
{"CHR", CHR },
{"DEC", DEC },
{"NOT", NOT },
@@ -918,8 +923,9 @@ yylex (void)
std::string tmp = copy_name (yylval.sval);
struct symbol *sym;
- if (lookup_symtab (tmp.c_str ()))
+ if (lookup_symtab (current_program_space, tmp.c_str ()) != nullptr)
return BLOCKNAME;
+
sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
SEARCH_VFT, 0).symbol;
if (sym && sym->aclass () == LOC_BLOCK)
diff --git a/gdb/m2-typeprint.c b/gdb/m2-typeprint.c
index c0ae722..4ade1ce 100644
--- a/gdb/m2-typeprint.c
+++ b/gdb/m2-typeprint.c
@@ -27,7 +27,6 @@
#include "gdbcore.h"
#include "m2-lang.h"
#include "target.h"
-#include "language.h"
#include "demangle.h"
#include "c-lang.h"
#include "typeprint.h"
diff --git a/gdb/m68k-linux-nat.c b/gdb/m68k-linux-nat.c
index 7f33739..49cd491 100644
--- a/gdb/m68k-linux-nat.c
+++ b/gdb/m68k-linux-nat.c
@@ -350,7 +350,7 @@ fill_fpregset (const struct regcache *regcache,
#ifdef HAVE_PTRACE_GETREGS
/* Fetch all floating-point registers from process/thread TID and store
- thier values in GDB's register array. */
+ their values in GDB's register array. */
static void
fetch_fpregs (struct regcache *regcache, int tid)
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index f1211be..dae4e4d 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -413,7 +413,7 @@ static struct parse_stack
struct type *cur_type; /* Type we parse fields for. */
int cur_field; /* Field number in cur_type. */
- CORE_ADDR procadr; /* Start addres of this procedure. */
+ CORE_ADDR procadr; /* Start address of this procedure. */
int numargs; /* Its argument count. */
}
@@ -1319,7 +1319,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
consequence of GDB's type management; CC and GCC (at
least through version 2.4) both output variables of
either type char * or caddr_t with the type
- refering to the stTypedef symbol for caddr_t. If a future
+ referring to the stTypedef symbol for caddr_t. If a future
compiler cleans this up it GDB is not ready for it
yet, but if it becomes ready we somehow need to
disable this check (without breaking the PCC/GCC2.4
@@ -2522,14 +2522,14 @@ parse_partial_symbols (minimal_symbol_reader &reader,
/* On certain platforms, some extra label symbols can be
generated by the linker. One possible usage for this kind
- of symbols is to represent the address of the begining of a
+ of symbols is to represent the address of the beginning of a
given section. For instance, on Tru64 5.1, the address of
the _ftext label is the start address of the .text section.
The storage class of these symbols is usually directly
related to the section to which the symbol refers. For
instance, on Tru64 5.1, the storage class for the _fdata
- label is scData, refering to the .data section.
+ label is scData, referring to the .data section.
It is actually possible that the section associated to the
storage class of the label does not exist. On True64 5.1
@@ -2892,7 +2892,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
const char *basename;
/* A zero value is probably an indication for the
- SunPRO 3.0 compiler. dbx_end_psymtab explicitly tests
+ SunPRO 3.0 compiler. stabs_end_psymtab explicitly tests
for zero, so don't relocate it. */
if (sh.value == 0
@@ -3297,7 +3297,7 @@ parse_partial_symbols (minimal_symbol_reader &reader,
case N_ENDM:
/* Solaris 2 end of module, finish current partial
- symbol table. dbx_end_psymtab will set the
+ symbol table. stabs_end_psymtab will set the
high text address of PST to the proper value,
which is necessary if a module compiled without
debugging info follows this module. */
@@ -3686,14 +3686,14 @@ parse_partial_symbols (minimal_symbol_reader &reader,
}
}
- /* Link pst to FDR. dbx_end_psymtab returns NULL if the psymtab was
+ /* Link pst to FDR. stabs_end_psymtab returns NULL if the psymtab was
empty and put on the free list. */
fdr_to_pst[f_idx].pst
- = dbx_end_psymtab (objfile, partial_symtabs, save_pst,
- psymtab_include_list, includes_used,
- -1, save_pst->unrelocated_text_high (),
- dependency_list, dependencies_used,
- textlow_not_set);
+ = stabs_end_psymtab (objfile, partial_symtabs, save_pst,
+ psymtab_include_list, includes_used,
+ -1, save_pst->unrelocated_text_high (),
+ dependency_list, dependencies_used,
+ textlow_not_set);
includes_used = 0;
dependencies_used = 0;
}
diff --git a/gdb/memattr.c b/gdb/memattr.c
index 735068e..c92792e 100644
--- a/gdb/memattr.c
+++ b/gdb/memattr.c
@@ -134,7 +134,7 @@ create_user_mem_region (CORE_ADDR lo, CORE_ADDR hi,
int ix = std::distance (user_mem_region_list.begin (), it);
/* Check for an overlapping memory region. We only need to check
- in the vincinity - at most one before and one after the
+ in the vicinity - at most one before and one after the
insertion point. */
for (int i = ix - 1; i < ix + 1; i++)
{
diff --git a/gdb/mi/mi-cmd-disas.c b/gdb/mi/mi-cmd-disas.c
index 99b2ae4..a311e25 100644
--- a/gdb/mi/mi-cmd-disas.c
+++ b/gdb/mi/mi-cmd-disas.c
@@ -18,6 +18,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "arch-utils.h"
+#include "progspace.h"
#include "target.h"
#include "value.h"
#include "mi-cmds.h"
@@ -245,7 +246,7 @@ mi_cmd_disassemble (const char *command, const char *const *argv, int argc)
if (line_seen && file_seen)
{
- s = lookup_symtab (file_string);
+ s = lookup_symtab (current_program_space, file_string);
if (s == NULL)
error (_("-data-disassemble: Invalid filename."));
if (!find_line_pc (s, line_num, &start))
diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c
index ff93d2c..9ad26e7 100644
--- a/gdb/mi/mi-out.c
+++ b/gdb/mi/mi-out.c
@@ -35,8 +35,8 @@ mi_ui_out::do_table_begin (int nr_cols, int nr_rows,
const char *tblid)
{
open (tblid, ui_out_type_tuple);
- do_field_signed (-1, -1, ui_left, "nr_rows", nr_rows);
- do_field_signed (-1, -1, ui_left, "nr_cols", nr_cols);
+ do_field_signed (-1, -1, ui_left, "nr_rows", nr_rows, ui_file_style ());
+ do_field_signed (-1, -1, ui_left, "nr_cols", nr_cols, ui_file_style ());
open ("hdr", ui_out_type_list);
}
@@ -67,8 +67,8 @@ mi_ui_out::do_table_header (int width, ui_align alignment,
const std::string &col_hdr)
{
open (NULL, ui_out_type_tuple);
- do_field_signed (0, 0, ui_center, "width", width);
- do_field_signed (0, 0, ui_center, "alignment", alignment);
+ do_field_signed (0, 0, ui_center, "width", width, ui_file_style ());
+ do_field_signed (0, 0, ui_center, "alignment", alignment, ui_file_style ());
do_field_string (0, 0, ui_center, "col_name", col_name.c_str (),
ui_file_style ());
do_field_string (0, width, alignment, "colhdr", col_hdr.c_str (),
@@ -96,10 +96,11 @@ mi_ui_out::do_end (ui_out_type type)
void
mi_ui_out::do_field_signed (int fldno, int width, ui_align alignment,
- const char *fldname, LONGEST value)
+ const char *fldname, LONGEST value,
+ const ui_file_style &style)
{
do_field_string (fldno, width, alignment, fldname, plongest (value),
- ui_file_style ());
+ style);
}
/* Output an unsigned field. */
diff --git a/gdb/mi/mi-out.h b/gdb/mi/mi-out.h
index a21a34f..9ad419e 100644
--- a/gdb/mi/mi-out.h
+++ b/gdb/mi/mi-out.h
@@ -62,7 +62,8 @@ protected:
virtual void do_begin (ui_out_type type, const char *id) override;
virtual void do_end (ui_out_type type) override;
virtual void do_field_signed (int fldno, int width, ui_align align,
- const char *fldname, LONGEST value) override;
+ const char *fldname, LONGEST value,
+ const ui_file_style &style) override;
virtual void do_field_unsigned (int fldno, int width, ui_align align,
const char *fldname, ULONGEST value)
override;
diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c
index e90055f..e4d890f 100644
--- a/gdb/mi/mi-symbol-cmds.c
+++ b/gdb/mi/mi-symbol-cmds.c
@@ -41,7 +41,7 @@ mi_cmd_symbol_list_lines (const char *command, const char *const *argv,
error (_("-symbol-list-lines: Usage: SOURCE_FILENAME"));
filename = argv[0];
- s = lookup_symtab (filename);
+ s = lookup_symtab (current_program_space, filename);
if (s == NULL)
error (_("-symbol-list-lines: Unknown source file name."));
diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
index 3d768d7..609c665 100644
--- a/gdb/microblaze-tdep.c
+++ b/gdb/microblaze-tdep.c
@@ -160,7 +160,7 @@ microblaze_alloc_frame_cache (void)
/* The base of the current frame is in a frame pointer register.
This register is noted in frame_extra_info->fp_regnum.
- Note that the existance of an FP might also indicate that the
+ Note that the existence of an FP might also indicate that the
function has called alloca. */
#define MICROBLAZE_MY_FRAME_IN_FP 0x2
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index 006bc92..c00efbd 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -558,7 +558,7 @@ mips_xfer_register (struct gdbarch *gdbarch, struct regcache *regcache,
}
/* Determine if a MIPS3 or later cpu is operating in MIPS{1,2} FPU
- compatiblity mode. A return value of 1 means that we have
+ compatibility mode. A return value of 1 means that we have
physical 64-bit registers, but should treat them as 32-bit registers. */
static int
@@ -574,7 +574,7 @@ mips2_fp_compat (const frame_info_ptr &frame)
/* FIXME drow 2002-03-10: This is disabled until we can do it consistently,
in all the places we deal with FP registers. PR gdb/413. */
/* Otherwise check the FR bit in the status register - it controls
- the FP compatiblity mode. If it is clear we are in compatibility
+ the FP compatibility mode. If it is clear we are in compatibility
mode. */
if ((get_frame_register_unsigned (frame, MIPS_PS_REGNUM) & ST0_FR) == 0)
return 1;
@@ -592,7 +592,7 @@ static CORE_ADDR heuristic_proc_start (struct gdbarch *, CORE_ADDR);
static struct cmd_list_element *setmipscmdlist = NULL;
static struct cmd_list_element *showmipscmdlist = NULL;
-/* Integer registers 0 thru 31 are handled explicitly by
+/* Integer registers 0 through 31 are handled explicitly by
mips_register_name(). Processor specific registers 32 and above
are listed in the following tables. */
@@ -920,7 +920,7 @@ mips_convert_register_float_case_p (struct gdbarch *gdbarch, int regnum,
}
/* This predicate tests for the case of a value of less than 8
- bytes in width that is being transfered to or from an 8 byte
+ bytes in width that is being transferred to or from an 8 byte
general purpose register. */
static int
mips_convert_register_gpreg_case_p (struct gdbarch *gdbarch, int regnum,
@@ -1076,7 +1076,7 @@ mips_register_type (struct gdbarch *gdbarch, int regnum)
return builtin_type (gdbarch)->builtin_int32;
else if (tdep->mips64_transfers_32bit_regs_p)
/* The target, while possibly using a 64-bit register buffer,
- is only transfering 32-bits of each integer register.
+ is only transferring 32-bits of each integer register.
Reflect this in the cooked/pseudo (ABI) register value. */
return builtin_type (gdbarch)->builtin_int32;
else if (mips_abi_regsize (gdbarch) == 4)
@@ -2877,7 +2877,7 @@ mips_insn16_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
find_pc_partial_function (pc, NULL, &start_addr, NULL);
if (start_addr == 0)
start_addr = heuristic_proc_start (gdbarch, pc);
- /* We can't analyze the prologue if we couldn't find the begining
+ /* We can't analyze the prologue if we couldn't find the beginning
of the function. */
if (start_addr == 0)
return cache;
@@ -3312,7 +3312,7 @@ mips_micro_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
find_pc_partial_function (pc, NULL, &start_addr, NULL);
if (start_addr == 0)
start_addr = heuristic_proc_start (get_frame_arch (this_frame), pc);
- /* We can't analyze the prologue if we couldn't find the begining
+ /* We can't analyze the prologue if we couldn't find the beginning
of the function. */
if (start_addr == 0)
return cache;
@@ -3693,7 +3693,7 @@ mips_insn32_frame_cache (const frame_info_ptr &this_frame, void **this_cache)
find_pc_partial_function (pc, NULL, &start_addr, NULL);
if (start_addr == 0)
start_addr = heuristic_proc_start (gdbarch, pc);
- /* We can't analyze the prologue if we couldn't find the begining
+ /* We can't analyze the prologue if we couldn't find the beginning
of the function. */
if (start_addr == 0)
return cache;
@@ -4581,7 +4581,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
}
/* Now load as many as possible of the first arguments into
- registers, and push the rest onto the stack. Loop thru args
+ registers, and push the rest onto the stack. Loop through args
from first to last. */
for (argnum = 0; argnum < nargs; argnum++)
{
@@ -4754,7 +4754,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
}
/* Note!!! This is NOT an else clause. Odd sized
- structs may go thru BOTH paths. Floating point
+ structs may go through BOTH paths. Floating point
arguments will not. */
/* Write this portion of the argument to a general
purpose register. */
@@ -4975,7 +4975,7 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
}
/* Now load as many as possible of the first arguments into
- registers, and push the rest onto the stack. Loop thru args
+ registers, and push the rest onto the stack. Loop through args
from first to last. */
for (argnum = 0; argnum < nargs; argnum++)
{
@@ -5106,7 +5106,7 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
}
/* Note!!! This is NOT an else clause. Odd sized
- structs may go thru BOTH paths. */
+ structs may go through BOTH paths. */
/* Write this portion of the argument to a general
purpose register. */
if (argreg <= mips_last_arg_regnum (gdbarch))
@@ -5455,7 +5455,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
}
/* Now load as many as possible of the first arguments into
- registers, and push the rest onto the stack. Loop thru args
+ registers, and push the rest onto the stack. Loop through args
from first to last. */
for (argnum = 0; argnum < nargs; argnum++)
{
@@ -5618,7 +5618,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
}
/* Note!!! This is NOT an else clause. Odd sized
- structs may go thru BOTH paths. */
+ structs may go through BOTH paths. */
/* Write this portion of the argument to a general
purpose register. */
if (argreg <= mips_last_arg_regnum (gdbarch))
@@ -5976,7 +5976,7 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
}
/* Now load as many as possible of the first arguments into
- registers, and push the rest onto the stack. Loop thru args
+ registers, and push the rest onto the stack. Loop through args
from first to last. */
for (argnum = 0; argnum < nargs; argnum++)
{
@@ -6080,7 +6080,7 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
}
/* Note!!! This is NOT an else clause. Odd sized
- structs may go thru BOTH paths. */
+ structs may go through BOTH paths. */
/* Write this portion of the argument to a general
purpose register. */
if (argreg <= mips_last_arg_regnum (gdbarch))
diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c
index 59e8ae6..7ff12d6 100644
--- a/gdb/nat/linux-btrace.c
+++ b/gdb/nat/linux-btrace.c
@@ -686,6 +686,17 @@ linux_enable_pt (ptid_t ptid, const struct btrace_config_pt *conf)
tinfo->conf.pt.ptwrite = true;
}
+ if (conf->event_tracing)
+ {
+ if (linux_supports_pt_feature ("event_trace"))
+ {
+ tinfo->attr.config |= linux_read_pt_config_bitmask ("event");
+ tinfo->conf.pt.event_tracing = true;
+ }
+ else
+ error (_("Event tracing for record btrace pt is not supported."));
+ }
+
errno = 0;
scoped_fd fd (syscall (SYS_perf_event_open, &tinfo->attr, pid, -1, -1, 0));
if (fd.get () < 0)
diff --git a/gdb/nat/x86-linux-tdesc.c b/gdb/nat/x86-linux-tdesc.c
index c15a600..1824f57 100644
--- a/gdb/nat/x86-linux-tdesc.c
+++ b/gdb/nat/x86-linux-tdesc.c
@@ -106,12 +106,6 @@ x86_linux_tdesc_for_tid (int tid, uint64_t *xcr0_storage,
*xcr0_storage = xstateregs[(I386_LINUX_XSAVE_XCR0_OFFSET
/ sizeof (uint64_t))];
-#ifdef __x86_64__
- /* No MPX on x32. */
- if (is_64bit && is_x32)
- *xcr0_storage &= ~X86_XSTATE_MPX;
-#endif /* __x86_64__ */
-
*xsave_layout_storage
= x86_fetch_xsave_layout (*xcr0_storage, x86_xsave_length ());
}
diff --git a/gdb/nat/x86-xstate.c b/gdb/nat/x86-xstate.c
index 970dda1..ca6fbbf 100644
--- a/gdb/nat/x86-xstate.c
+++ b/gdb/nat/x86-xstate.c
@@ -56,8 +56,6 @@ x86_fetch_xsave_layout (uint64_t xcr0, int len)
x86_xsave_layout layout;
layout.sizeof_xsave = len;
layout.avx_offset = xsave_feature_offset (xcr0, X86_XSTATE_AVX_ID);
- layout.bndregs_offset = xsave_feature_offset (xcr0, X86_XSTATE_BNDREGS_ID);
- layout.bndcfg_offset = xsave_feature_offset (xcr0, X86_XSTATE_BNDCFG_ID);
layout.k_offset = xsave_feature_offset (xcr0, X86_XSTATE_K_ID);
layout.zmm_h_offset = xsave_feature_offset (xcr0, X86_XSTATE_ZMM_H_ID);
layout.zmm_offset = xsave_feature_offset (xcr0, X86_XSTATE_ZMM_ID);
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index cf78979..fa2befd 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -552,7 +552,7 @@ compare_selectors (const void *a, const void *b)
*
* Implements the "Info selectors" command. Takes an optional regexp
* arg. Lists all objective c selectors that match the regexp. Works
- * by grepping thru all symbols for objective c methods. Output list
+ * by grepping through all symbols for objective c methods. Output list
* is sorted and uniqued.
*/
@@ -601,7 +601,7 @@ info_selectors_command (const char *regexp, int from_tty)
error (_("Invalid regexp (%s): %s"), val, regexp);
}
- /* First time thru is JUST to get max length and count. */
+ /* First time through is JUST to get max length and count. */
for (objfile *objfile : current_program_space->objfiles ())
{
for (minimal_symbol *msymbol : objfile->msymbols ())
@@ -716,7 +716,7 @@ compare_classes (const void *a, const void *b)
*
* Implements the "info classes" command for objective c classes.
* Lists all objective c classes that match the optional regexp.
- * Works by grepping thru the list of objective c methods. List will
+ * Works by grepping through the list of objective c methods. List will
* be sorted and uniqued (since one class may have many methods).
* BUGS: will not list a class that has no methods.
*/
@@ -755,7 +755,7 @@ info_classes_command (const char *regexp, int from_tty)
error (_("Invalid regexp (%s): %s"), val, regexp);
}
- /* First time thru is JUST to get max length and count. */
+ /* First time through is JUST to get max length and count. */
for (objfile *objfile : current_program_space->objfiles ())
{
for (minimal_symbol *msymbol : objfile->msymbols ())
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 8b1e89c..d92570a 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -597,7 +597,9 @@ public:
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags,
- domain_search_flags domain);
+ domain_search_flags domain,
+ gdb::function_view<expand_symtabs_lang_matcher_ftype> lang_matcher
+ = nullptr);
/* See quick_symbol_functions. */
struct compunit_symtab *
diff --git a/gdb/osabi.c b/gdb/osabi.c
index 8a1efce..236d425 100644
--- a/gdb/osabi.c
+++ b/gdb/osabi.c
@@ -42,93 +42,6 @@ static const char *gdb_osabi_available_names[GDB_OSABI_INVALID + 3] = {
};
static const char *set_osabi_string;
-/* Names associated with each osabi. */
-
-struct osabi_names
-{
- /* The "pretty" name. */
-
- const char *pretty;
-
- /* The triplet regexp, or NULL if not known. */
-
- const char *regexp;
-};
-
-/* This table matches the indices assigned to enum gdb_osabi. Keep
- them in sync. */
-static const struct osabi_names gdb_osabi_names[] =
-{
- { "unknown", NULL },
- { "none", NULL },
-
- { "SVR4", NULL },
- { "GNU/Hurd", NULL },
- { "Solaris", NULL },
- { "GNU/Linux", "linux(-gnu[^-]*)?" },
- { "FreeBSD", NULL },
- { "NetBSD", NULL },
- { "OpenBSD", NULL },
- { "WindowsCE", NULL },
- { "DJGPP", NULL },
- { "Cygwin", NULL },
- { "Windows", NULL },
- { "AIX", NULL },
- { "DICOS", NULL },
- { "Darwin", NULL },
- { "OpenVMS", NULL },
- { "LynxOS178", NULL },
- { "Newlib", NULL },
- { "SDE", NULL },
- { "PikeOS", NULL },
-
- { "<invalid>", NULL }
-};
-
-const char *
-gdbarch_osabi_name (enum gdb_osabi osabi)
-{
- if (osabi >= GDB_OSABI_UNKNOWN && osabi < GDB_OSABI_INVALID)
- return gdb_osabi_names[osabi].pretty;
-
- return gdb_osabi_names[GDB_OSABI_INVALID].pretty;
-}
-
-/* See osabi.h. */
-
-const char *
-osabi_triplet_regexp (enum gdb_osabi osabi)
-{
- if (osabi >= GDB_OSABI_UNKNOWN && osabi < GDB_OSABI_INVALID)
- return gdb_osabi_names[osabi].regexp;
-
- return gdb_osabi_names[GDB_OSABI_INVALID].regexp;
-}
-
-/* Lookup the OS ABI corresponding to the specified target description
- string. */
-
-enum gdb_osabi
-osabi_from_tdesc_string (const char *name)
-{
- int i;
-
- for (i = 0; i < ARRAY_SIZE (gdb_osabi_names); i++)
- if (strcmp (name, gdb_osabi_names[i].pretty) == 0)
- {
- /* See note above: the name table matches the indices assigned
- to enum gdb_osabi. */
- enum gdb_osabi osabi = (enum gdb_osabi) i;
-
- if (osabi == GDB_OSABI_INVALID)
- return GDB_OSABI_UNKNOWN;
- else
- return osabi;
- }
-
- return GDB_OSABI_UNKNOWN;
-}
-
/* Handler for a given architecture/OS ABI pair. There should be only
one handler for a given OS ABI each architecture family. */
struct gdb_osabi_handler
@@ -611,6 +524,35 @@ generic_elf_osabi_sniffer (bfd *abfd)
return osabi;
}
+
+/* See osabi.h. */
+
+const char *
+gdbarch_osabi_enum_name (enum gdb_osabi osabi)
+{
+ switch (osabi)
+ {
+#define GDB_OSABI_DEF_FIRST(Enum, Name, Regex) \
+ case GDB_OSABI_ ## Enum: \
+ return "GDB_OSABI_" #Enum;
+
+#define GDB_OSABI_DEF(Enum, Name, Regex) \
+ case GDB_OSABI_ ## Enum: \
+ return "GDB_OSABI_" #Enum;
+
+#define GDB_OSABI_DEF_LAST(Enum, Name, Regex) \
+ case GDB_OSABI_ ## Enum: \
+ return "GDB_OSABI_" #Enum;
+
+#include "gdbsupport/osabi.def"
+
+#undef GDB_OSABI_DEF_LAST
+#undef GDB_OSABI_DEF
+#undef GDB_OSABI_DEF_FIRST
+ }
+
+ gdb_assert_not_reached ();
+}
static void
set_osabi (const char *args, int from_tty, struct cmd_list_element *c)
@@ -671,10 +613,6 @@ void _initialize_gdb_osabi ();
void
_initialize_gdb_osabi ()
{
- if (strcmp (gdb_osabi_names[GDB_OSABI_INVALID].pretty, "<invalid>") != 0)
- internal_error
- (_("_initialize_gdb_osabi: gdb_osabi_names[] is inconsistent"));
-
/* Register a generic sniffer for ELF flavoured files. */
gdbarch_register_osabi_sniffer (bfd_arch_unknown,
bfd_target_elf_flavour,
diff --git a/gdb/osabi.h b/gdb/osabi.h
index d2b1a35..2d828d5 100644
--- a/gdb/osabi.h
+++ b/gdb/osabi.h
@@ -19,35 +19,7 @@
#ifndef OSABI_H
#define OSABI_H
-/* * List of known OS ABIs. If you change this, make sure to update the
- table in osabi.c. */
-enum gdb_osabi
-{
- GDB_OSABI_UNKNOWN = 0, /* keep this zero */
- GDB_OSABI_NONE,
-
- GDB_OSABI_SVR4,
- GDB_OSABI_HURD,
- GDB_OSABI_SOLARIS,
- GDB_OSABI_LINUX,
- GDB_OSABI_FREEBSD,
- GDB_OSABI_NETBSD,
- GDB_OSABI_OPENBSD,
- GDB_OSABI_WINCE,
- GDB_OSABI_GO32,
- GDB_OSABI_CYGWIN,
- GDB_OSABI_WINDOWS,
- GDB_OSABI_AIX,
- GDB_OSABI_DICOS,
- GDB_OSABI_DARWIN,
- GDB_OSABI_OPENVMS,
- GDB_OSABI_LYNXOS178,
- GDB_OSABI_NEWLIB,
- GDB_OSABI_SDE,
- GDB_OSABI_PIKEOS,
-
- GDB_OSABI_INVALID /* keep this last */
-};
+#include "gdbsupport/osabi.h"
/* Register an OS ABI sniffer. Each arch/flavour may have more than
one sniffer. This is used to e.g. differentiate one OS's a.out from
@@ -69,26 +41,19 @@ void gdbarch_register_osabi (enum bfd_architecture, unsigned long,
/* Lookup the OS ABI corresponding to the specified BFD. */
enum gdb_osabi gdbarch_lookup_osabi (bfd *);
-/* Lookup the OS ABI corresponding to the specified target description
- string. */
-enum gdb_osabi osabi_from_tdesc_string (const char *text);
-
/* Return true if there's an OS ABI handler for INFO. */
bool has_gdb_osabi_handler (struct gdbarch_info info);
/* Initialize the gdbarch for the specified OS ABI variant. */
void gdbarch_init_osabi (struct gdbarch_info, struct gdbarch *);
-/* Return the name of the specified OS ABI. */
-const char *gdbarch_osabi_name (enum gdb_osabi);
-
-/* Return a regular expression that matches the OS part of a GNU
- configury triplet for the given OSABI. */
-const char *osabi_triplet_regexp (enum gdb_osabi osabi);
-
/* Helper routine for ELF file sniffers. This looks at ABI tag note
sections to determine the OS ABI from the note. */
void generic_elf_osabi_sniff_abi_tag_sections (bfd *, asection *,
enum gdb_osabi *);
+/* Return a string version of OSABI. This is used when generating code
+ which calls set_tdesc_osabi and an 'enum gdb_osabi' value is needed. */
+const char *gdbarch_osabi_enum_name (enum gdb_osabi osabi);
+
#endif /* OSABI_H */
diff --git a/gdb/p-exp.y b/gdb/p-exp.y
index ad7cd58..938d3cf 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp.y
@@ -614,7 +614,7 @@ block : BLOCKNAME
{
std::string copy = copy_name ($1.stoken);
struct symtab *tem =
- lookup_symtab (copy.c_str ());
+ lookup_symtab (current_program_space, copy.c_str ());
if (tem)
$$ = (tem->compunit ()->blockvector ()
->static_block ());
@@ -1520,7 +1520,7 @@ yylex (void)
no psymtabs (coff, xcoff, or some future change to blow away the
psymtabs once once symbols are read). */
if ((sym && sym->aclass () == LOC_BLOCK)
- || lookup_symtab (tmp.c_str ()))
+ || lookup_symtab (current_program_space, tmp.c_str ()))
{
yylval.ssym.sym.symbol = sym;
yylval.ssym.sym.block = NULL;
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index 3116fc1..8a5eea7 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -133,7 +133,7 @@ static solib_ops powerpc_so_ops;
(gdb) b main
Breakpoint 2 at 0x100006a0: file gdb.base/shmain.c, line 44.
- Examine the instruction (and the immediatly following instruction)
+ Examine the instruction (and the immediately following instruction)
upon which the breakpoint was placed. Note that the PLT entry
for shr1 contains zeros.
diff --git a/gdb/ppc-netbsd-tdep.c b/gdb/ppc-netbsd-tdep.c
index d8e4c42..b412030 100644
--- a/gdb/ppc-netbsd-tdep.c
+++ b/gdb/ppc-netbsd-tdep.c
@@ -28,7 +28,6 @@
#include "ppc-tdep.h"
#include "netbsd-tdep.h"
-#include "ppc-tdep.h"
#include "solib-svr4.h"
/* Register offsets from <machine/reg.h>. */
diff --git a/gdb/procfs.c b/gdb/procfs.c
index a9a26c6..c6abe3e 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -205,7 +205,7 @@ procfs_target::auxv_parse (const gdb_byte **readptr,
concerning a /proc process. There should be exactly one procinfo
for each process, and since GDB currently can debug only one
process at a time, that means there should be only one procinfo.
- All of the LWP's of a process can be accessed indirectly thru the
+ All of the LWP's of a process can be accessed indirectly through the
single process procinfo.
However, against the day when GDB may debug more than one process,
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index e25c3ab..f8c83d9 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -893,7 +893,9 @@ psymbol_functions::expand_symtabs_matching
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags,
- domain_search_flags domain)
+ domain_search_flags domain,
+ gdb::function_view<expand_symtabs_lang_matcher_ftype>
+ lang_matcher ATTRIBUTE_UNUSED)
{
/* Clear the search flags. */
for (partial_symtab *ps : partial_symbols (objfile))
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index a81526c..b23aadb 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -633,7 +633,9 @@ struct psymbol_functions : public quick_symbol_functions
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags,
- domain_search_flags kind) override;
+ domain_search_flags kind,
+ gdb::function_view<expand_symtabs_lang_matcher_ftype> 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/python/lib/gdb/dap/breakpoint.py b/gdb/python/lib/gdb/dap/breakpoint.py
index db8ac10..15055f2 100644
--- a/gdb/python/lib/gdb/dap/breakpoint.py
+++ b/gdb/python/lib/gdb/dap/breakpoint.py
@@ -208,9 +208,9 @@ def _set_breakpoints_callback(kind, specs, creator):
}
)
- # Delete any breakpoints that were not reused.
- for entry in saved_map.values():
- entry.delete()
+ # Delete any breakpoints that were not reused.
+ for entry in saved_map.values():
+ entry.delete()
return result
diff --git a/gdb/python/lib/gdb/dap/varref.py b/gdb/python/lib/gdb/dap/varref.py
index 57e84a1..0dd9879 100644
--- a/gdb/python/lib/gdb/dap/varref.py
+++ b/gdb/python/lib/gdb/dap/varref.py
@@ -18,6 +18,7 @@ from collections import defaultdict
from contextlib import contextmanager
import gdb
+import gdb.printing
from .server import client_bool_capability
from .startup import DAPException, in_gdb_thread
diff --git a/gdb/python/lib/gdb/disassembler.py b/gdb/python/lib/gdb/disassembler.py
index 72d311b..7d0e781 100644
--- a/gdb/python/lib/gdb/disassembler.py
+++ b/gdb/python/lib/gdb/disassembler.py
@@ -147,7 +147,7 @@ class maint_info_py_disassemblers_cmd(gdb.Command):
# Figure out the name of the current architecture. There
# should always be a current inferior, but if, somehow, there
# isn't, then leave curr_arch as the empty string, which will
- # not then match agaisnt any architecture in the dictionary.
+ # not then match against any architecture in the dictionary.
curr_arch = ""
if gdb.selected_inferior() is not None:
curr_arch = gdb.selected_inferior().architecture().name()
diff --git a/gdb/python/lib/gdb/printer/bound_registers.py b/gdb/python/lib/gdb/printer/bound_registers.py
deleted file mode 100644
index d00b455..0000000
--- a/gdb/python/lib/gdb/printer/bound_registers.py
+++ /dev/null
@@ -1,39 +0,0 @@
-# Pretty-printers for bounds registers.
-# Copyright (C) 2013-2024 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-import gdb
-import gdb.printing
-
-
-class MpxBound128Printer(gdb.ValuePrinter):
- """Adds size field to a mpx __gdb_builtin_type_bound128 type."""
-
- def __init__(self, val):
- self.__val = val
-
- def to_string(self):
- upper = self.__val["ubound"]
- lower = self.__val["lbound"]
- size = upper - lower
- if size > -1:
- size = size + 1
- result = "{lbound = %s, ubound = %s} : size %s" % (lower, upper, size)
- return result
-
-
-gdb.printing.add_builtin_pretty_printer(
- "mpx_bound128", "^builtin_type_bound128", MpxBound128Printer
-)
diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c
index 178efab..d73d7fc 100644
--- a/gdb/python/py-arch.c
+++ b/gdb/python/py-arch.c
@@ -199,7 +199,7 @@ archpy_disassemble (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
gdbpy_ref<> pc_obj = gdb_py_object_from_ulongest (pc);
@@ -361,11 +361,7 @@ static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
gdbpy_initialize_arch (void)
{
arch_object_type.tp_new = PyType_GenericNew;
- if (PyType_Ready (&arch_object_type) < 0)
- return -1;
-
- return gdb_pymodule_addobject (gdb_module, "Architecture",
- (PyObject *) &arch_object_type);
+ return gdbpy_type_ready (&arch_object_type);
}
GDBPY_INITIALIZE_FILE (gdbpy_initialize_arch);
diff --git a/gdb/python/py-block.c b/gdb/python/py-block.c
index 62e93d5..aeb9acb 100644
--- a/gdb/python/py-block.c
+++ b/gdb/python/py-block.c
@@ -493,19 +493,14 @@ static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
gdbpy_initialize_blocks (void)
{
block_object_type.tp_new = PyType_GenericNew;
- if (PyType_Ready (&block_object_type) < 0)
+ if (gdbpy_type_ready (&block_object_type) < 0)
return -1;
block_syms_iterator_object_type.tp_new = PyType_GenericNew;
- if (PyType_Ready (&block_syms_iterator_object_type) < 0)
+ if (gdbpy_type_ready (&block_syms_iterator_object_type) < 0)
return -1;
- if (gdb_pymodule_addobject (gdb_module, "Block",
- (PyObject *) &block_object_type) < 0)
- return -1;
-
- return gdb_pymodule_addobject (gdb_module, "BlockIterator",
- (PyObject *) &block_syms_iterator_object_type);
+ return 0;
}
GDBPY_INITIALIZE_FILE (gdbpy_initialize_blocks);
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index 013c3fa..1edd556 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -207,7 +207,7 @@ bppy_set_enabled (PyObject *self, PyObject *newvalue, void *closure)
}
catch (const gdb_exception &except)
{
- GDB_PY_SET_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (-1, except);
}
return 0;
@@ -394,7 +394,7 @@ bppy_set_task (PyObject *self, PyObject *newvalue, void *closure)
}
catch (const gdb_exception &except)
{
- GDB_PY_SET_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (-1, except);
}
if (! valid_id)
@@ -443,7 +443,7 @@ bppy_delete_breakpoint (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
Py_RETURN_NONE;
@@ -484,7 +484,7 @@ bppy_set_ignore_count (PyObject *self, PyObject *newvalue, void *closure)
}
catch (const gdb_exception &except)
{
- GDB_PY_SET_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (-1, except);
}
return 0;
@@ -613,7 +613,7 @@ bppy_set_condition (PyObject *self, PyObject *newvalue, void *closure)
}
catch (const gdb_exception &ex)
{
- GDB_PY_SET_HANDLE_EXCEPTION (ex);
+ return gdbpy_handle_gdb_exception (-1, ex);
}
return 0;
@@ -640,7 +640,7 @@ bppy_get_commands (PyObject *self, void *closure)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return host_string_to_python_string (stb.c_str ()).release ();
@@ -678,7 +678,7 @@ bppy_set_commands (PyObject *self, PyObject *newvalue, void *closure)
}
catch (const gdb_exception &ex)
{
- GDB_PY_SET_HANDLE_EXCEPTION (ex);
+ return gdbpy_handle_gdb_exception (-1, ex);
}
return 0;
@@ -1054,7 +1054,7 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
catch (const gdb_exception &except)
{
bppy_pending_object = NULL;
- GDB_PY_SET_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (-1, except);
}
BPPY_SET_REQUIRE_VALID ((gdbpy_breakpoint_object *) self);
@@ -1114,7 +1114,7 @@ gdbpy_breakpoint_init_breakpoint_type ()
if (breakpoint_object_type.tp_new == nullptr)
{
breakpoint_object_type.tp_new = PyType_GenericNew;
- if (PyType_Ready (&breakpoint_object_type) < 0)
+ if (gdbpy_type_ready (&breakpoint_object_type) < 0)
{
/* Reset tp_new back to nullptr so future calls to this function
will try calling PyType_Ready again. */
@@ -1359,10 +1359,6 @@ gdbpy_initialize_breakpoints (void)
if (!gdbpy_breakpoint_init_breakpoint_type ())
return -1;
- if (gdb_pymodule_addobject (gdb_module, "Breakpoint",
- (PyObject *) &breakpoint_object_type) < 0)
- return -1;
-
gdb::observers::breakpoint_created.attach (gdbpy_breakpoint_created,
"py-breakpoint");
gdb::observers::breakpoint_deleted.attach (gdbpy_breakpoint_deleted,
@@ -1394,14 +1390,7 @@ gdbpy_initialize_breakpoints (void)
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
gdbpy_initialize_breakpoint_locations ()
{
- if (PyType_Ready (&breakpoint_location_object_type) < 0)
- return -1;
-
- if (gdb_pymodule_addobject (gdb_module, "BreakpointLocation",
- (PyObject *) &breakpoint_location_object_type)
- < 0)
- return -1;
- return 0;
+ return gdbpy_type_ready (&breakpoint_location_object_type);
}
@@ -1595,7 +1584,7 @@ bplocpy_set_enabled (PyObject *py_self, PyObject *newvalue, void *closure)
}
catch (const gdb_exception &except)
{
- GDB_PY_SET_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (-1, except);
}
return 0;
}
diff --git a/gdb/python/py-cmd.c b/gdb/python/py-cmd.c
index e042f20..2bb9b82 100644
--- a/gdb/python/py-cmd.c
+++ b/gdb/python/py-cmd.c
@@ -541,7 +541,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_SET_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (-1, except);
}
return 0;
@@ -557,7 +557,7 @@ gdbpy_initialize_commands (void)
int i;
cmdpy_object_type.tp_new = PyType_GenericNew;
- if (PyType_Ready (&cmdpy_object_type) < 0)
+ if (gdbpy_type_ready (&cmdpy_object_type) < 0)
return -1;
/* Note: alias and user are special. */
@@ -587,10 +587,6 @@ gdbpy_initialize_commands (void)
return -1;
}
- if (gdb_pymodule_addobject (gdb_module, "Command",
- (PyObject *) &cmdpy_object_type) < 0)
- return -1;
-
invoke_cst = PyUnicode_FromString ("invoke");
if (invoke_cst == NULL)
return -1;
diff --git a/gdb/python/py-connection.c b/gdb/python/py-connection.c
index 79e2767..1fdcd73 100644
--- a/gdb/python/py-connection.c
+++ b/gdb/python/py-connection.c
@@ -287,18 +287,10 @@ connpy_get_connection_details (PyObject *self, void *closure)
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
gdbpy_initialize_connection (void)
{
- if (PyType_Ready (&connection_object_type) < 0)
+ if (gdbpy_type_ready (&connection_object_type) < 0)
return -1;
- if (gdb_pymodule_addobject (gdb_module, "TargetConnection",
- (PyObject *) &connection_object_type) < 0)
- return -1;
-
- if (PyType_Ready (&remote_connection_object_type) < 0)
- return -1;
-
- if (gdb_pymodule_addobject (gdb_module, "RemoteTargetConnection",
- (PyObject *) &remote_connection_object_type) < 0)
+ if (gdbpy_type_ready (&remote_connection_object_type) < 0)
return -1;
return 0;
@@ -431,7 +423,7 @@ connpy_send_packet (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
}
diff --git a/gdb/python/py-disasm.c b/gdb/python/py-disasm.c
index 9b9b509..7b64436 100644
--- a/gdb/python/py-disasm.c
+++ b/gdb/python/py-disasm.c
@@ -595,7 +595,7 @@ disasmpy_builtin_disassemble (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (!str.empty ())
PyErr_SetString (gdbpy_gdberror_exc, str.c_str ());
@@ -933,7 +933,7 @@ disasmpy_result_str (PyObject *self)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return PyUnicode_Decode (str.c_str (), str.size (),
@@ -1512,7 +1512,7 @@ disasmpy_addr_part_str (PyObject *self)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return PyUnicode_Decode (str.c_str (), str.size (),
@@ -1665,45 +1665,23 @@ gdbpy_initialize_disasm ()
}
disasm_info_object_type.tp_new = PyType_GenericNew;
- if (PyType_Ready (&disasm_info_object_type) < 0)
- return -1;
-
- if (gdb_pymodule_addobject (gdb_disassembler_module, "DisassembleInfo",
- (PyObject *) &disasm_info_object_type) < 0)
+ if (gdbpy_type_ready (&disasm_info_object_type, gdb_disassembler_module) < 0)
return -1;
disasm_result_object_type.tp_new = PyType_GenericNew;
- if (PyType_Ready (&disasm_result_object_type) < 0)
- return -1;
-
- if (gdb_pymodule_addobject (gdb_disassembler_module, "DisassemblerResult",
- (PyObject *) &disasm_result_object_type) < 0)
+ if (gdbpy_type_ready (&disasm_result_object_type, gdb_disassembler_module) < 0)
return -1;
disasm_part_object_type.tp_new = PyType_GenericNew;
- if (PyType_Ready (&disasm_part_object_type) < 0)
- return -1;
-
- if (gdb_pymodule_addobject (gdb_disassembler_module, "DisassemblerPart",
- (PyObject *) &disasm_part_object_type) < 0)
+ if (gdbpy_type_ready (&disasm_part_object_type, gdb_disassembler_module) < 0)
return -1;
disasm_addr_part_object_type.tp_new = PyType_GenericNew;
- if (PyType_Ready (&disasm_addr_part_object_type) < 0)
- return -1;
-
- if (gdb_pymodule_addobject (gdb_disassembler_module,
- "DisassemblerAddressPart",
- (PyObject *) &disasm_addr_part_object_type) < 0)
+ if (gdbpy_type_ready (&disasm_addr_part_object_type, gdb_disassembler_module) < 0)
return -1;
disasm_text_part_object_type.tp_new = PyType_GenericNew;
- if (PyType_Ready (&disasm_text_part_object_type) < 0)
- return -1;
-
- if (gdb_pymodule_addobject (gdb_disassembler_module,
- "DisassemblerTextPart",
- (PyObject *) &disasm_text_part_object_type) < 0)
+ if (gdbpy_type_ready (&disasm_text_part_object_type, gdb_disassembler_module) < 0)
return -1;
return 0;
diff --git a/gdb/python/py-event.c b/gdb/python/py-event.c
index 47a2997..a918136 100644
--- a/gdb/python/py-event.c
+++ b/gdb/python/py-event.c
@@ -56,25 +56,9 @@ evpy_add_attribute (PyObject *event, const char *name, PyObject *attr)
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
gdbpy_initialize_event (void)
{
- return gdbpy_initialize_event_generic (&event_object_type,
- "Event");
+ return gdbpy_type_ready (&event_object_type);
}
-/* Initialize the given event type. If BASE is not NULL it will
- be set as the types base.
- Returns 0 if initialization was successful -1 otherwise. */
-
-int
-gdbpy_initialize_event_generic (PyTypeObject *type,
- const char *name)
-{
- if (PyType_Ready (type) < 0)
- return -1;
-
- return gdb_pymodule_addobject (gdb_module, name, (PyObject *) type);
-}
-
-
/* Notify the list of listens that the given EVENT has occurred.
returns 0 if emit is successful -1 otherwise. */
diff --git a/gdb/python/py-event.h b/gdb/python/py-event.h
index 388c513..a723824 100644
--- a/gdb/python/py-event.h
+++ b/gdb/python/py-event.h
@@ -84,7 +84,5 @@ extern void evpy_dealloc (PyObject *self);
extern int evpy_add_attribute (PyObject *event,
const char *name, PyObject *attr)
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
-int gdbpy_initialize_event_generic (PyTypeObject *type, const char *name)
- CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
#endif /* PYTHON_PY_EVENT_H */
diff --git a/gdb/python/py-evtregistry.c b/gdb/python/py-evtregistry.c
index 1f486e2..7ae3997 100644
--- a/gdb/python/py-evtregistry.c
+++ b/gdb/python/py-evtregistry.c
@@ -104,11 +104,7 @@ evregpy_dealloc (PyObject *self)
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
gdbpy_initialize_eventregistry (void)
{
- if (PyType_Ready (&eventregistry_object_type) < 0)
- return -1;
-
- return gdb_pymodule_addobject (gdb_module, "EventRegistry",
- (PyObject *) &eventregistry_object_type);
+ return gdbpy_type_ready (&eventregistry_object_type);
}
/* Return the number of listeners currently connected to this
diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c
index ed3c4a5..bc53d4e 100644
--- a/gdb/python/py-finishbreakpoint.c
+++ b/gdb/python/py-finishbreakpoint.c
@@ -217,7 +217,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
}
catch (const gdb_exception &except)
{
- GDB_PY_SET_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (-1, except);
}
if (PyErr_Occurred ())
@@ -317,7 +317,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
}
catch (const gdb_exception &except)
{
- GDB_PY_SET_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (-1, except);
}
self_bpfinish->py_bp.bp->frame_id = frame_id;
@@ -439,11 +439,7 @@ gdbpy_initialize_finishbreakpoints (void)
if (!gdbpy_breakpoint_init_breakpoint_type ())
return -1;
- if (PyType_Ready (&finish_breakpoint_object_type) < 0)
- return -1;
-
- if (gdb_pymodule_addobject (gdb_module, "FinishBreakpoint",
- (PyObject *) &finish_breakpoint_object_type) < 0)
+ if (gdbpy_type_ready (&finish_breakpoint_object_type) < 0)
return -1;
gdb::observers::normal_stop.attach (bpfinishpy_handle_stop,
diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c
index 7f617fa..88646ee 100644
--- a/gdb/python/py-frame.c
+++ b/gdb/python/py-frame.c
@@ -115,7 +115,7 @@ frapy_is_valid (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (frame == NULL)
@@ -143,7 +143,7 @@ frapy_name (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (name)
@@ -177,7 +177,7 @@ frapy_type (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return gdb_py_object_from_longest (type).release ();
@@ -198,7 +198,7 @@ frapy_arch (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return gdbarch_to_arch_object (obj->gdbarch);
@@ -219,7 +219,7 @@ frapy_unwind_stop_reason (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
stop_reason = get_frame_unwind_stop_reason (frame);
@@ -244,7 +244,7 @@ frapy_pc (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return gdb_py_object_from_ulongest (pc).release ();
@@ -286,7 +286,7 @@ frapy_read_register (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return result;
@@ -308,7 +308,7 @@ frapy_block (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
for (fn_block = block;
@@ -347,7 +347,7 @@ frapy_function (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (sym)
@@ -389,7 +389,7 @@ frame_info_to_frame_object (const frame_info_ptr &frame)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return (PyObject *) frame_obj.release ();
@@ -413,7 +413,7 @@ frapy_older (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (prev)
@@ -445,7 +445,7 @@ frapy_newer (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (next)
@@ -477,7 +477,7 @@ frapy_find_sal (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return sal_obj;
@@ -537,7 +537,7 @@ frapy_read_var (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (!var)
@@ -567,7 +567,7 @@ frapy_read_var (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return result;
@@ -588,7 +588,7 @@ frapy_select (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
Py_RETURN_NONE;
@@ -609,7 +609,7 @@ frapy_level (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
Py_RETURN_NONE;
@@ -632,7 +632,7 @@ frapy_language (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
Py_RETURN_NONE;
@@ -653,7 +653,7 @@ frapy_static_link (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (link == nullptr)
@@ -676,7 +676,7 @@ gdbpy_newest_frame (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return frame_info_to_frame_object (frame);
@@ -696,7 +696,7 @@ gdbpy_selected_frame (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return frame_info_to_frame_object (frame);
@@ -761,7 +761,7 @@ static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
gdbpy_initialize_frames (void)
{
frame_object_type.tp_new = PyType_GenericNew;
- if (PyType_Ready (&frame_object_type) < 0)
+ if (gdbpy_type_ready (&frame_object_type) < 0)
return -1;
/* Note: These would probably be best exposed as class attributes of
@@ -785,8 +785,7 @@ gdbpy_initialize_frames (void)
#include "unwind_stop_reasons.def"
#undef SET
- return gdb_pymodule_addobject (gdb_module, "Frame",
- (PyObject *) &frame_object_type);
+ return 0;
}
GDBPY_INITIALIZE_FILE (gdbpy_initialize_frames);
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
index 9f9032f..daec6dd 100644
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -1007,7 +1007,7 @@ py_print_frame (PyObject *filter, frame_filter_flags flags,
out->text (":");
annotate_frame_source_line ();
- out->field_signed ("line", line);
+ out->field_signed ("line", line, line_number_style.style ());
}
}
if (out->is_mi_like_p ())
diff --git a/gdb/python/py-function.c b/gdb/python/py-function.c
index 2bbfb9d..58ae0d0 100644
--- a/gdb/python/py-function.c
+++ b/gdb/python/py-function.c
@@ -137,11 +137,7 @@ static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
gdbpy_initialize_functions (void)
{
fnpy_object_type.tp_new = PyType_GenericNew;
- if (PyType_Ready (&fnpy_object_type) < 0)
- return -1;
-
- return gdb_pymodule_addobject (gdb_module, "Function",
- (PyObject *) &fnpy_object_type);
+ return gdbpy_type_ready (&fnpy_object_type);
}
GDBPY_INITIALIZE_FILE (gdbpy_initialize_functions);
diff --git a/gdb/python/py-gdb-readline.c b/gdb/python/py-gdb-readline.c
index 14a76b4..dd0ee45 100644
--- a/gdb/python/py-gdb-readline.c
+++ b/gdb/python/py-gdb-readline.c
@@ -59,7 +59,7 @@ gdbpy_readline_wrapper (FILE *sys_stdin, FILE *sys_stdout,
/* This readline callback is called without the GIL held. */
gdbpy_gil gil;
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
/* Detect EOF (Ctrl-D). */
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index ccc3e88..60bf56d 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -412,7 +412,7 @@ infpy_threads (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
tuple = PyTuple_New (inf_obj->threads->size ());
@@ -578,7 +578,7 @@ infpy_read_memory (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
@@ -633,7 +633,7 @@ infpy_write_memory (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &ex)
{
- GDB_PY_HANDLE_EXCEPTION (ex);
+ return gdbpy_handle_gdb_exception (nullptr, ex);
}
Py_RETURN_NONE;
@@ -707,7 +707,7 @@ infpy_search_memory (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &ex)
{
- GDB_PY_HANDLE_EXCEPTION (ex);
+ return gdbpy_handle_gdb_exception (nullptr, ex);
}
if (found)
@@ -783,7 +783,7 @@ infpy_thread_from_thread_handle (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
Py_RETURN_NONE;
@@ -1009,11 +1009,7 @@ gdbpy_selected_inferior (PyObject *self, PyObject *args)
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
gdbpy_initialize_inferior (void)
{
- if (PyType_Ready (&inferior_object_type) < 0)
- return -1;
-
- if (gdb_pymodule_addobject (gdb_module, "Inferior",
- (PyObject *) &inferior_object_type) < 0)
+ if (gdbpy_type_ready (&inferior_object_type) < 0)
return -1;
gdb::observers::new_thread.attach (add_thread_object, "py-inferior");
diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c
index a17f25e..4340666 100644
--- a/gdb/python/py-infthread.c
+++ b/gdb/python/py-infthread.c
@@ -104,7 +104,7 @@ thpy_get_details (PyObject *self, void *ignore)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (extra_info == nullptr)
Py_RETURN_NONE;
@@ -212,7 +212,7 @@ thpy_get_ptid_string (PyObject *self, void *closure)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
}
@@ -245,7 +245,7 @@ thpy_switch (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
Py_RETURN_NONE;
@@ -330,7 +330,7 @@ thpy_thread_handle (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (hv.size () == 0)
@@ -412,11 +412,7 @@ gdbpy_selected_thread (PyObject *self, PyObject *args)
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
gdbpy_initialize_thread (void)
{
- if (PyType_Ready (&thread_object_type) < 0)
- return -1;
-
- return gdb_pymodule_addobject (gdb_module, "InferiorThread",
- (PyObject *) &thread_object_type);
+ return gdbpy_type_ready (&thread_object_type);
}
GDBPY_INITIALIZE_FILE (gdbpy_initialize_thread);
diff --git a/gdb/python/py-instruction.c b/gdb/python/py-instruction.c
index bc3945a..7d77572 100644
--- a/gdb/python/py-instruction.c
+++ b/gdb/python/py-instruction.c
@@ -66,7 +66,7 @@ py_insn_get_insn_type ()
py_insn_type.tp_doc = "GDB instruction object";
py_insn_type.tp_getset = py_insn_getset;
- if (PyType_Ready (&py_insn_type) < 0)
+ if (gdbpy_type_ready (&py_insn_type) < 0)
{
/* Reset the tp_new field so any subsequent calls to this
function will retry to make the type ready. */
diff --git a/gdb/python/py-lazy-string.c b/gdb/python/py-lazy-string.c
index 8779716..4898a1f 100644
--- a/gdb/python/py-lazy-string.c
+++ b/gdb/python/py-lazy-string.c
@@ -148,7 +148,7 @@ stpy_convert_to_value (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return result;
@@ -236,11 +236,7 @@ gdbpy_create_lazy_string_object (CORE_ADDR address, long length,
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
gdbpy_initialize_lazy_string (void)
{
- if (PyType_Ready (&lazy_string_object_type) < 0)
- return -1;
-
- Py_INCREF (&lazy_string_object_type);
- return 0;
+ return gdbpy_type_ready (&lazy_string_object_type);
}
/* Determine whether the printer object pointed to by OBJ is a
@@ -315,7 +311,7 @@ stpy_str (PyObject *self)
}
catch (const gdb_exception &exc)
{
- GDB_PY_HANDLE_EXCEPTION (exc);
+ return gdbpy_handle_gdb_exception (nullptr, exc);
}
return host_string_to_python_string (stream.c_str ()).release ();
diff --git a/gdb/python/py-linetable.c b/gdb/python/py-linetable.c
index e3e71f9..fc57f36 100644
--- a/gdb/python/py-linetable.c
+++ b/gdb/python/py-linetable.c
@@ -169,7 +169,7 @@ ltpy_get_pcs_for_line (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return build_line_table_tuple_from_pcs (py_line, pcs);
@@ -287,27 +287,11 @@ ltpy_dealloc (PyObject *self)
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
gdbpy_initialize_linetable (void)
{
- if (PyType_Ready (&linetable_object_type) < 0)
+ if (gdbpy_type_ready (&linetable_object_type) < 0)
return -1;
- if (PyType_Ready (&linetable_entry_object_type) < 0)
+ if (gdbpy_type_ready (&linetable_entry_object_type) < 0)
return -1;
- if (PyType_Ready (&ltpy_iterator_object_type) < 0)
- return -1;
-
- Py_INCREF (&linetable_object_type);
- Py_INCREF (&linetable_entry_object_type);
- Py_INCREF (&ltpy_iterator_object_type);
-
- if (gdb_pymodule_addobject (gdb_module, "LineTable",
- (PyObject *) &linetable_object_type) < 0)
- return -1;
-
- if (gdb_pymodule_addobject (gdb_module, "LineTableEntry",
- (PyObject *) &linetable_entry_object_type) < 0)
- return -1;
-
- if (gdb_pymodule_addobject (gdb_module, "LineTableIterator",
- (PyObject *) &ltpy_iterator_object_type) < 0)
+ if (gdbpy_type_ready (&ltpy_iterator_object_type) < 0)
return -1;
return 0;
diff --git a/gdb/python/py-membuf.c b/gdb/python/py-membuf.c
index af48d01..25ebc99 100644
--- a/gdb/python/py-membuf.c
+++ b/gdb/python/py-membuf.c
@@ -102,11 +102,7 @@ static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
gdbpy_initialize_membuf (void)
{
membuf_object_type.tp_new = PyType_GenericNew;
- if (PyType_Ready (&membuf_object_type) < 0)
- return -1;
-
- return gdb_pymodule_addobject (gdb_module, "Membuf",
- (PyObject *) &membuf_object_type);
+ return gdbpy_type_ready (&membuf_object_type);
}
GDBPY_INITIALIZE_FILE (gdbpy_initialize_membuf);
diff --git a/gdb/python/py-mi.c b/gdb/python/py-mi.c
index 0a63654..f0e28d9 100644
--- a/gdb/python/py-mi.c
+++ b/gdb/python/py-mi.c
@@ -86,7 +86,8 @@ py_ui_out::do_end (ui_out_type type)
void
py_ui_out::do_field_signed (int fldno, int width, ui_align align,
- const char *fldname, LONGEST value)
+ const char *fldname, LONGEST value,
+ const ui_file_style &style)
{
if (m_error.has_value ())
return;
@@ -168,7 +169,7 @@ gdbpy_execute_mi_command (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return uiout.result ().release ();
diff --git a/gdb/python/py-micmd.c b/gdb/python/py-micmd.c
index 54427d4..f4abf2b 100644
--- a/gdb/python/py-micmd.c
+++ b/gdb/python/py-micmd.c
@@ -447,12 +447,7 @@ static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
gdbpy_initialize_micommands ()
{
micmdpy_object_type.tp_new = PyType_GenericNew;
- if (PyType_Ready (&micmdpy_object_type) < 0)
- return -1;
-
- if (gdb_pymodule_addobject (gdb_module, "MICommand",
- (PyObject *) &micmdpy_object_type)
- < 0)
+ if (gdbpy_type_ready (&micmdpy_object_type) < 0)
return -1;
invoke_cst = PyUnicode_FromString ("invoke");
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index 6e8d5b5..6ce58a1 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -162,7 +162,7 @@ objfpy_get_build_id (PyObject *self, void *closure)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (build_id != NULL)
@@ -453,7 +453,7 @@ objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
Py_RETURN_NONE;
@@ -488,7 +488,7 @@ objfpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
Py_RETURN_NONE;
@@ -523,7 +523,7 @@ objfpy_lookup_static_symbol (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
Py_RETURN_NONE;
@@ -709,11 +709,7 @@ objfile_to_objfile_object (struct objfile *objfile)
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
gdbpy_initialize_objfile (void)
{
- if (PyType_Ready (&objfile_object_type) < 0)
- return -1;
-
- return gdb_pymodule_addobject (gdb_module, "Objfile",
- (PyObject *) &objfile_object_type);
+ return gdbpy_type_ready (&objfile_object_type);
}
GDBPY_INITIALIZE_FILE (gdbpy_initialize_objfile);
diff --git a/gdb/python/py-param.c b/gdb/python/py-param.c
index e7032f7..9741782 100644
--- a/gdb/python/py-param.c
+++ b/gdb/python/py-param.c
@@ -885,7 +885,7 @@ parmpy_init (PyObject *self, PyObject *args, PyObject *kwds)
catch (const gdb_exception &except)
{
Py_DECREF (self);
- GDB_PY_SET_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (-1, except);
}
return 0;
@@ -909,7 +909,7 @@ gdbpy_initialize_parameters (void)
int i;
parmpy_object_type.tp_new = PyType_GenericNew;
- if (PyType_Ready (&parmpy_object_type) < 0)
+ if (gdbpy_type_ready (&parmpy_object_type) < 0)
return -1;
set_doc_cst = PyUnicode_FromString ("set_doc");
@@ -927,8 +927,7 @@ gdbpy_initialize_parameters (void)
return -1;
}
- return gdb_pymodule_addobject (gdb_module, "Parameter",
- (PyObject *) &parmpy_object_type);
+ return 0;
}
GDBPY_INITIALIZE_FILE (gdbpy_initialize_parameters);
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index 368b3a3..e061ea1 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -836,10 +836,7 @@ PyTypeObject printer_object_type =
static int
gdbpy_initialize_prettyprint ()
{
- if (PyType_Ready (&printer_object_type) < 0)
- return -1;
- return gdb_pymodule_addobject (gdb_module, "ValuePrinter",
- (PyObject *) &printer_object_type);
+ return gdbpy_type_ready (&printer_object_type);
}
GDBPY_INITIALIZE_FILE (gdbpy_initialize_prettyprint);
diff --git a/gdb/python/py-progspace.c b/gdb/python/py-progspace.c
index 5bc0015..aa1e713 100644
--- a/gdb/python/py-progspace.c
+++ b/gdb/python/py-progspace.c
@@ -522,7 +522,7 @@ pspy_block_for_pc (PyObject *o, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (cust == NULL || cust->objfile () == NULL)
@@ -564,7 +564,7 @@ pspy_find_pc_line (PyObject *o, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return result;
@@ -747,11 +747,10 @@ gdbpy_initialize_pspace (void)
gdb::observers::free_program_space.attach (gdbpy_free_program_space_event,
"py-progspace");
- if (PyType_Ready (&pspace_object_type) < 0)
+ if (gdbpy_type_ready (&pspace_object_type) < 0)
return -1;
- return gdb_pymodule_addobject (gdb_module, "Progspace",
- (PyObject *) &pspace_object_type);
+ return 0;
}
GDBPY_INITIALIZE_FILE (gdbpy_initialize_pspace);
diff --git a/gdb/python/py-record-btrace.c b/gdb/python/py-record-btrace.c
index 30d0e83..bdfebf1 100644
--- a/gdb/python/py-record-btrace.c
+++ b/gdb/python/py-record-btrace.c
@@ -217,7 +217,7 @@ recpy_bt_insn_sal (PyObject *self, void *closure)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return result;
@@ -288,7 +288,7 @@ recpy_bt_insn_data (PyObject *self, void *closure)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
object = PyBytes_FromStringAndSize ((const char *) buffer.data (),
@@ -318,7 +318,7 @@ recpy_bt_insn_decoded (PyObject *self, void *closure)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return PyBytes_FromString (strfile.string ().c_str ());
@@ -810,7 +810,7 @@ recpy_bt_function_call_history (PyObject *self, void *closure)
/* Helper function that calls PTW_FILTER with PAYLOAD and IP as arguments.
Returns the string that will be printed, if there is a filter to call. */
static std::optional<std::string>
-recpy_call_filter (const uint64_t payload, const uint64_t ip,
+recpy_call_filter (const uint64_t payload, std::optional<uint64_t> ip,
const void *ptw_filter)
{
std::optional<std::string> result;
@@ -824,10 +824,10 @@ recpy_call_filter (const uint64_t payload, const uint64_t ip,
gdbpy_ref<> py_payload = gdb_py_object_from_ulongest (payload);
gdbpy_ref<> py_ip;
- if (ip == 0)
+ if (!ip.has_value ())
py_ip = gdbpy_ref<>::new_reference (Py_None);
else
- py_ip = gdb_py_object_from_ulongest (ip);
+ py_ip = gdb_py_object_from_ulongest (*ip);
gdbpy_ref<> py_result (PyObject_CallFunctionObjArgs ((PyObject *) ptw_filter,
py_payload.get (),
@@ -943,7 +943,7 @@ recpy_bt_goto (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
Py_RETURN_NONE;
@@ -1006,7 +1006,7 @@ gdbpy_initialize_btrace (void)
btpy_list_mapping_methods.mp_subscript = btpy_list_slice;
- return PyType_Ready (&btpy_list_type);
+ return gdbpy_type_ready (&btpy_list_type);
}
GDBPY_INITIALIZE_FILE (gdbpy_initialize_btrace);
diff --git a/gdb/python/py-record.c b/gdb/python/py-record.c
index 759bf30..2995dc1 100644
--- a/gdb/python/py-record.c
+++ b/gdb/python/py-record.c
@@ -653,11 +653,11 @@ gdbpy_initialize_record (void)
recpy_aux_type.tp_richcompare = recpy_element_richcompare;
recpy_aux_type.tp_hash = recpy_element_hash;
- if (PyType_Ready (&recpy_record_type) < 0
- || PyType_Ready (&recpy_insn_type) < 0
- || PyType_Ready (&recpy_func_type) < 0
- || PyType_Ready (&recpy_gap_type) < 0
- || PyType_Ready (&recpy_aux_type) < 0)
+ if (gdbpy_type_ready (&recpy_record_type) < 0
+ || gdbpy_type_ready (&recpy_insn_type) < 0
+ || gdbpy_type_ready (&recpy_func_type) < 0
+ || gdbpy_type_ready (&recpy_gap_type) < 0
+ || gdbpy_type_ready (&recpy_aux_type) < 0)
return -1;
else
return 0;
@@ -681,7 +681,7 @@ gdbpy_start_recording (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
}
@@ -713,7 +713,7 @@ gdbpy_stop_recording (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
Py_RETURN_NONE;
diff --git a/gdb/python/py-registers.c b/gdb/python/py-registers.c
index f03274c..229dd62 100644
--- a/gdb/python/py-registers.c
+++ b/gdb/python/py-registers.c
@@ -430,35 +430,22 @@ static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
gdbpy_initialize_registers ()
{
register_descriptor_object_type.tp_new = PyType_GenericNew;
- if (PyType_Ready (&register_descriptor_object_type) < 0)
- return -1;
- if (gdb_pymodule_addobject
- (gdb_module, "RegisterDescriptor",
- (PyObject *) &register_descriptor_object_type) < 0)
+ if (gdbpy_type_ready (&register_descriptor_object_type) < 0)
return -1;
reggroup_iterator_object_type.tp_new = PyType_GenericNew;
- if (PyType_Ready (&reggroup_iterator_object_type) < 0)
- return -1;
- if (gdb_pymodule_addobject
- (gdb_module, "RegisterGroupsIterator",
- (PyObject *) &reggroup_iterator_object_type) < 0)
+ if (gdbpy_type_ready (&reggroup_iterator_object_type) < 0)
return -1;
reggroup_object_type.tp_new = PyType_GenericNew;
- if (PyType_Ready (&reggroup_object_type) < 0)
- return -1;
- if (gdb_pymodule_addobject
- (gdb_module, "RegisterGroup",
- (PyObject *) &reggroup_object_type) < 0)
+ if (gdbpy_type_ready (&reggroup_object_type) < 0)
return -1;
register_descriptor_iterator_object_type.tp_new = PyType_GenericNew;
- if (PyType_Ready (&register_descriptor_iterator_object_type) < 0)
+ if (gdbpy_type_ready (&register_descriptor_iterator_object_type) < 0)
return -1;
- return (gdb_pymodule_addobject
- (gdb_module, "RegisterDescriptorIterator",
- (PyObject *) &register_descriptor_iterator_object_type));
+
+ return 0;
}
GDBPY_INITIALIZE_FILE (gdbpy_initialize_registers);
diff --git a/gdb/python/py-stopevent.c b/gdb/python/py-stopevent.c
index 47f81bd..485bbb1 100644
--- a/gdb/python/py-stopevent.c
+++ b/gdb/python/py-stopevent.c
@@ -74,7 +74,7 @@ py_print_bpstat (bpstat *bs, enum gdb_signal stop_signal)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
gdbpy_ref<> dict = uiout.result ();
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index 754420f..24b53bb 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -222,7 +222,7 @@ sympy_needs_frame (PyObject *self, void *closure)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (result)
@@ -307,7 +307,7 @@ sympy_value (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return result;
@@ -425,7 +425,7 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
}
@@ -436,7 +436,7 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
gdbpy_ref<> ret_tuple (PyTuple_New (2));
@@ -485,7 +485,7 @@ gdbpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (symbol)
@@ -553,7 +553,7 @@ gdbpy_lookup_static_symbol (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (symbol)
@@ -631,7 +631,7 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return return_list.release ();
@@ -640,7 +640,7 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw)
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
gdbpy_initialize_symbols (void)
{
- if (PyType_Ready (&symbol_object_type) < 0)
+ if (gdbpy_type_ready (&symbol_object_type) < 0)
return -1;
if (PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_UNDEF", LOC_UNDEF) < 0
@@ -685,8 +685,7 @@ gdbpy_initialize_symbols (void)
#include "sym-domains.def"
#undef SYM_DOMAIN
- return gdb_pymodule_addobject (gdb_module, "Symbol",
- (PyObject *) &symbol_object_type);
+ return 0;
}
GDBPY_INITIALIZE_FILE (gdbpy_initialize_symbols);
diff --git a/gdb/python/py-symtab.c b/gdb/python/py-symtab.c
index 7290b85..99a5094 100644
--- a/gdb/python/py-symtab.c
+++ b/gdb/python/py-symtab.c
@@ -512,19 +512,14 @@ static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
gdbpy_initialize_symtabs (void)
{
symtab_object_type.tp_new = PyType_GenericNew;
- if (PyType_Ready (&symtab_object_type) < 0)
+ if (gdbpy_type_ready (&symtab_object_type) < 0)
return -1;
sal_object_type.tp_new = PyType_GenericNew;
- if (PyType_Ready (&sal_object_type) < 0)
+ if (gdbpy_type_ready (&sal_object_type) < 0)
return -1;
- if (gdb_pymodule_addobject (gdb_module, "Symtab",
- (PyObject *) &symtab_object_type) < 0)
- return -1;
-
- return gdb_pymodule_addobject (gdb_module, "Symtab_and_line",
- (PyObject *) &sal_object_type);
+ return 0;
}
GDBPY_INITIALIZE_FILE (gdbpy_initialize_symtabs);
diff --git a/gdb/python/py-tui.c b/gdb/python/py-tui.c
index 8ad2b7d..afa6f36 100644
--- a/gdb/python/py-tui.c
+++ b/gdb/python/py-tui.c
@@ -425,7 +425,7 @@ gdbpy_register_tui_window (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
Py_RETURN_NONE;
@@ -625,7 +625,7 @@ gdbpy_initialize_tui ()
{
#ifdef TUI
gdbpy_tui_window_object_type.tp_new = PyType_GenericNew;
- if (PyType_Ready (&gdbpy_tui_window_object_type) < 0)
+ if (gdbpy_type_ready (&gdbpy_tui_window_object_type) < 0)
return -1;
#endif /* TUI */
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index c13b861..284960a 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -292,7 +292,7 @@ typy_fields_items (PyObject *self, enum gdbpy_iter_kind kind)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
gdbpy_ref<> type_holder;
@@ -456,7 +456,7 @@ typy_is_array_like (PyObject *self, void *closure)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (result)
@@ -480,7 +480,7 @@ typy_is_string_like (PyObject *self, void *closure)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (result)
@@ -501,7 +501,7 @@ typy_strip_typedefs (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return type_to_type_object (type);
@@ -522,7 +522,7 @@ typy_get_composite (struct type *type)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (!type->is_pointer_or_reference ())
@@ -592,7 +592,7 @@ typy_array_1 (PyObject *self, PyObject *args, int is_vector)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return type_to_type_object (array);
@@ -626,7 +626,7 @@ typy_pointer (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return type_to_type_object (type);
@@ -698,7 +698,7 @@ typy_reference (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return type_to_type_object (type);
@@ -732,7 +732,7 @@ typy_const (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return type_to_type_object (type);
@@ -750,7 +750,7 @@ typy_volatile (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return type_to_type_object (type);
@@ -768,7 +768,7 @@ typy_unqualified (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return type_to_type_object (type);
@@ -859,7 +859,7 @@ typy_lookup_typename (const char *type_name, const struct block *block)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return type;
@@ -913,7 +913,7 @@ typy_lookup_type (struct demangle_component *demangled,
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
}
@@ -955,7 +955,7 @@ typy_legacy_template_argument (struct type *type, const struct block *block,
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (! info)
@@ -1034,7 +1034,7 @@ typy_template_argument (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
/* We might not have DW_TAG_template_*, so try to parse the type's
@@ -1069,7 +1069,7 @@ typy_template_argument (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return result;
@@ -1093,7 +1093,7 @@ typy_repr (PyObject *self)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
auto py_typename = PyUnicode_Decode (type_name.c_str (), type_name.size (),
host_charset (), NULL);
@@ -1115,7 +1115,7 @@ typy_str (PyObject *self)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return PyUnicode_Decode (thetype.c_str (), thetype.size (),
@@ -1151,7 +1151,7 @@ typy_richcompare (PyObject *self, PyObject *other, int op)
{
/* If there is a GDB exception, a comparison is not capable
(or trusted), so exit. */
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
}
@@ -1471,7 +1471,7 @@ type_to_type_object (struct type *type)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
type_obj = PyObject_New (type_object, &type_object_type);
@@ -1526,11 +1526,11 @@ gdbpy_lookup_type (PyObject *self, PyObject *args, PyObject *kw)
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
gdbpy_initialize_types (void)
{
- if (PyType_Ready (&type_object_type) < 0)
+ if (gdbpy_type_ready (&type_object_type) < 0)
return -1;
- if (PyType_Ready (&field_object_type) < 0)
+ if (gdbpy_type_ready (&field_object_type) < 0)
return -1;
- if (PyType_Ready (&type_iterator_object_type) < 0)
+ if (gdbpy_type_ready (&type_iterator_object_type) < 0)
return -1;
for (const auto &item : pyty_codes)
@@ -1539,16 +1539,7 @@ gdbpy_initialize_types (void)
return -1;
}
- if (gdb_pymodule_addobject (gdb_module, "Type",
- (PyObject *) &type_object_type) < 0)
- return -1;
-
- if (gdb_pymodule_addobject (gdb_module, "TypeIterator",
- (PyObject *) &type_iterator_object_type) < 0)
- return -1;
-
- return gdb_pymodule_addobject (gdb_module, "Field",
- (PyObject *) &field_object_type);
+ return 0;
}
GDBPY_INITIALIZE_FILE (gdbpy_initialize_types);
diff --git a/gdb/python/py-uiout.h b/gdb/python/py-uiout.h
index a2fc90e..5f8c530 100644
--- a/gdb/python/py-uiout.h
+++ b/gdb/python/py-uiout.h
@@ -86,7 +86,8 @@ protected:
void do_end (ui_out_type type) override;
void do_field_signed (int fldno, int width, ui_align align,
- const char *fldname, LONGEST value) override;
+ const char *fldname, LONGEST value,
+ const ui_file_style &style) override;
void do_field_unsigned (int fldno, int width, ui_align align,
const char *fldname, ULONGEST value) override;
diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c
index e36768e..68deaf9 100644
--- a/gdb/python/py-unwind.c
+++ b/gdb/python/py-unwind.c
@@ -228,7 +228,7 @@ unwind_infopy_str (PyObject *self)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
}
else
@@ -378,7 +378,7 @@ unwind_infopy_add_saved_register (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
gdbpy_ref<> new_value = gdbpy_ref<>::new_reference (pyo_reg_value);
@@ -429,7 +429,7 @@ pending_framepy_str (PyObject *self)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return PyUnicode_FromFormat ("SP=%s,PC=%s", sp_str, pc_str);
@@ -456,7 +456,7 @@ pending_framepy_repr (PyObject *self)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return PyUnicode_FromFormat ("<%s level=%d, sp=%s, pc=%s>",
@@ -505,7 +505,7 @@ pending_framepy_read_register (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return result;
@@ -546,7 +546,7 @@ pending_framepy_name (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (name != nullptr)
@@ -574,7 +574,7 @@ pending_framepy_pc (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return gdb_py_object_from_ulongest (pc).release ();
@@ -601,7 +601,7 @@ pending_framepy_language (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
Py_RETURN_NONE;
@@ -628,7 +628,7 @@ pending_framepy_find_sal (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return sal_obj;
@@ -653,7 +653,7 @@ pending_framepy_block (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
for (fn_block = block;
@@ -696,7 +696,7 @@ pending_framepy_function (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (sym != nullptr)
@@ -1002,17 +1002,13 @@ gdbpy_initialize_unwind (void)
{
gdb::observers::new_architecture.attach (pyuw_on_new_gdbarch, "py-unwind");
- if (PyType_Ready (&pending_frame_object_type) < 0)
+ if (gdbpy_type_ready (&pending_frame_object_type) < 0)
return -1;
- int rc = gdb_pymodule_addobject (gdb_module, "PendingFrame",
- (PyObject *) &pending_frame_object_type);
- if (rc != 0)
- return rc;
- if (PyType_Ready (&unwind_info_object_type) < 0)
+ if (gdbpy_type_ready (&unwind_info_object_type) < 0)
return -1;
- return gdb_pymodule_addobject (gdb_module, "UnwindInfo",
- (PyObject *) &unwind_info_object_type);
+
+ return 0;
}
void _initialize_py_unwind ();
diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c
index 47f65f4..0bc18a6 100644
--- a/gdb/python/py-utils.c
+++ b/gdb/python/py-utils.c
@@ -247,7 +247,7 @@ get_addr_from_python (PyObject *obj, CORE_ADDR *addr)
}
catch (const gdb_exception &except)
{
- GDB_PY_SET_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (-1, except);
}
}
else
@@ -390,6 +390,35 @@ gdbpy_handle_exception ()
if (fetched_error.type_matches (PyExc_KeyboardInterrupt))
throw_quit ("Quit");
+ else if (fetched_error.type_matches (PyExc_SystemExit))
+ {
+ gdbpy_ref<> value = fetched_error.value ();
+ gdbpy_ref<> code (PyObject_GetAttrString (value.get (), "code"));
+ int exit_arg;
+
+ if (code.get () == Py_None)
+ {
+ /* CODE == None: exit status is 0. */
+ exit_arg = 0;
+ }
+ else if (code.get () != nullptr && PyLong_Check (code.get ()))
+ {
+ /* CODE == integer: exit status is aforementioned integer. */
+ exit_arg = PyLong_AsLong (code.get ());
+ }
+ else
+ {
+ if (code.get () == nullptr)
+ gdbpy_print_stack ();
+
+ /* Otherwise: exit status is 1, print code to stderr. */
+ if (msg != nullptr)
+ gdb_printf (gdb_stderr, "%s\n", msg.get ());
+ exit_arg = 1;
+ }
+
+ quit_force (&exit_arg, 0);
+ }
else if (! fetched_error.type_matches (gdbpy_gdberror_exc)
|| msg == NULL || *msg == '\0')
{
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index 37d5716..119bf9f 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -257,7 +257,7 @@ valpy_dereference (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return result;
@@ -300,7 +300,7 @@ valpy_referenced_value (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return result;
@@ -323,7 +323,7 @@ valpy_reference_value (PyObject *self, PyObject *args, enum type_code refcode)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return result;
@@ -369,7 +369,7 @@ valpy_to_array (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return result;
@@ -393,7 +393,7 @@ valpy_const_value (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return result;
@@ -499,7 +499,7 @@ valpy_get_dynamic_type (PyObject *self, void *closure)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (type == NULL)
@@ -605,7 +605,7 @@ valpy_lazy_string (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return str_obj;
@@ -640,7 +640,7 @@ valpy_string (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
encoding = (user_encoding && *user_encoding) ? user_encoding : la_encoding;
@@ -824,7 +824,7 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return PyUnicode_Decode (stb.c_str (), stb.size (), host_charset (), NULL);
@@ -869,7 +869,7 @@ valpy_do_cast (PyObject *self, PyObject *args, enum exp_opcode op)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return result;
@@ -921,8 +921,7 @@ valpy_assign_core (value_object *self, struct value *new_value)
}
catch (const gdb_exception &except)
{
- gdbpy_convert_exception (except);
- return false;
+ return gdbpy_handle_gdb_exception (false, except);
}
return true;
@@ -997,7 +996,7 @@ value_has_field (struct value *v, PyObject *field)
}
catch (const gdb_exception &except)
{
- GDB_PY_SET_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (-1, except);
}
return has_field;
@@ -1180,7 +1179,7 @@ valpy_getitem (PyObject *self, PyObject *key)
}
catch (const gdb_exception &ex)
{
- GDB_PY_HANDLE_EXCEPTION (ex);
+ return gdbpy_handle_gdb_exception (nullptr, ex);
}
return result;
@@ -1211,7 +1210,7 @@ valpy_call (PyObject *self, PyObject *args, PyObject *keywords)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (ftype->code () != TYPE_CODE_FUNC && ftype->code () != TYPE_CODE_METHOD
@@ -1268,7 +1267,7 @@ valpy_call (PyObject *self, PyObject *args, PyObject *keywords)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return result;
@@ -1293,7 +1292,7 @@ valpy_str (PyObject *self)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return PyUnicode_Decode (stb.c_str (), stb.size (), host_charset (), NULL);
@@ -1312,7 +1311,7 @@ valpy_get_is_optimized_out (PyObject *self, void *closure)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (opt)
@@ -1334,7 +1333,7 @@ valpy_get_is_lazy (PyObject *self, void *closure)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (opt)
@@ -1364,7 +1363,7 @@ valpy_get_bytes (PyObject *self, void *closure)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
value_obj->content_bytes
@@ -1408,7 +1407,7 @@ valpy_fetch_lazy (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
Py_RETURN_NONE;
@@ -1579,7 +1578,7 @@ valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return result;
@@ -1647,7 +1646,7 @@ valpy_negative (PyObject *self)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return result;
@@ -1674,7 +1673,7 @@ valpy_absolute (PyObject *self)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (isabs)
@@ -1709,7 +1708,7 @@ valpy_nonzero (PyObject *self)
/* This is not documented in the Python documentation, but if
this function fails, return -1 as slot_nb_nonzero does (the
default Python nonzero function). */
- GDB_PY_SET_HANDLE_EXCEPTION (ex);
+ return gdbpy_handle_gdb_exception (-1, ex);
}
return nonzero;
@@ -1729,7 +1728,7 @@ valpy_invert (PyObject *self)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return result;
@@ -1856,7 +1855,7 @@ valpy_richcompare (PyObject *self, PyObject *other, int op)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
/* In this case, the Python exception has already been set. */
@@ -1895,7 +1894,7 @@ valpy_long (PyObject *self)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (type->is_unsigned ())
@@ -1930,7 +1929,7 @@ valpy_float (PyObject *self)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return PyFloat_FromDouble (d);
@@ -2056,7 +2055,7 @@ convert_value_from_python (PyObject *obj)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return value;
@@ -2080,7 +2079,7 @@ gdbpy_history (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return result;
@@ -2107,7 +2106,7 @@ gdbpy_add_history (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return nullptr;
@@ -2152,7 +2151,7 @@ gdbpy_convenience_variable (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (result == nullptr && !found)
@@ -2198,7 +2197,7 @@ gdbpy_set_convenience_variable (PyObject *self, PyObject *args)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
Py_RETURN_NONE;
@@ -2215,11 +2214,7 @@ gdbpy_is_value_object (PyObject *obj)
static int CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
gdbpy_initialize_values (void)
{
- if (PyType_Ready (&value_object_type) < 0)
- return -1;
-
- return gdb_pymodule_addobject (gdb_module, "Value",
- (PyObject *) &value_object_type);
+ return gdbpy_type_ready (&value_object_type);
}
GDBPY_INITIALIZE_FILE (gdbpy_initialize_values);
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index bf3ab67..d723c4d 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -932,22 +932,6 @@ private:
PyGILState_STATE m_state;
};
-/* Use this in a 'catch' block to convert the exception to a Python
- exception and return nullptr. */
-#define GDB_PY_HANDLE_EXCEPTION(Exception) \
- do { \
- gdbpy_convert_exception (Exception); \
- return nullptr; \
- } while (0)
-
-/* Use this in a 'catch' block to convert the exception to a Python
- exception and return -1. */
-#define GDB_PY_SET_HANDLE_EXCEPTION(Exception) \
- do { \
- gdbpy_convert_exception (Exception); \
- return -1; \
- } while (0)
-
int gdbpy_print_python_errors_p (void);
void gdbpy_print_stack (void);
void gdbpy_print_stack_or_quit ();
@@ -1013,6 +997,18 @@ extern PyObject *gdbpy_gdberror_exc;
extern void gdbpy_convert_exception (const struct gdb_exception &)
CPYCHECKER_SETS_EXCEPTION;
+ /* Use this in a 'catch' block to convert the exception E to a Python
+ exception and return value VAL to signal that an exception occurred.
+ Typically at the use site, that value will be returned immediately. */
+
+template<typename T>
+[[nodiscard]] T
+gdbpy_handle_gdb_exception (T val, const gdb_exception &e)
+{
+ gdbpy_convert_exception (e);
+ return val;
+}
+
int get_addr_from_python (PyObject *obj, CORE_ADDR *addr)
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;
@@ -1119,4 +1115,34 @@ extern std::optional<int> gdbpy_print_insn (struct gdbarch *gdbarch,
CORE_ADDR address,
disassemble_info *info);
+/* A wrapper for PyType_Ready that also automatically registers the
+ type in the appropriate module. Returns 0 on success, -1 on error.
+ If MOD is supplied, then the type is added to that module. If MOD
+ is not supplied, the type name (tp_name field) must be of the form
+ "gdb.Mumble", and the type will be added to the gdb module. */
+
+static inline int
+gdbpy_type_ready (PyTypeObject *type, PyObject *mod = nullptr)
+{
+ if (PyType_Ready (type) < 0)
+ return -1;
+ if (mod == nullptr)
+ {
+ gdb_assert (startswith (type->tp_name, "gdb."));
+ mod = gdb_module;
+ }
+ const char *dot = strrchr (type->tp_name, '.');
+ gdb_assert (dot != nullptr);
+ return gdb_pymodule_addobject (mod, dot + 1, (PyObject *) type);
+}
+
+/* Poison PyType_Ready. Only gdbpy_type_ready should be used, to
+ avoid forgetting to register the type. See PR python/32163. */
+#undef PyType_Ready
+#ifdef __GNUC__
+# pragma GCC poison PyType_Ready
+#else
+# define PyType_Ready POISONED_PyType_Ready
+#endif
+
#endif /* PYTHON_PYTHON_INTERNAL_H */
diff --git a/gdb/python/python.c b/gdb/python/python.c
index a2ce1f6..cc06526 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -593,7 +593,7 @@ gdbpy_parameter (PyObject *self, PyObject *args)
}
catch (const gdb_exception &ex)
{
- GDB_PY_HANDLE_EXCEPTION (ex);
+ return gdbpy_handle_gdb_exception (nullptr, ex);
}
if (cmd == CMD_LIST_AMBIGUOUS)
@@ -756,7 +756,7 @@ execute_gdb_command (PyObject *self, PyObject *args, PyObject *kw)
convert the exception and continue back in Python, we should
re-enable stdin here. */
async_enable_stdin ();
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
if (to_string)
@@ -972,7 +972,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
catch (const gdb_exception &ex)
{
/* We know this will always throw. */
- GDB_PY_HANDLE_EXCEPTION (ex);
+ return gdbpy_handle_gdb_exception (nullptr, ex);
}
if (!sals.empty ())
@@ -1053,7 +1053,7 @@ gdbpy_parse_and_eval (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
return result;
@@ -1538,7 +1538,7 @@ gdbpy_write (PyObject *self, PyObject *args, PyObject *kw)
}
catch (const gdb_exception &except)
{
- GDB_PY_HANDLE_EXCEPTION (except);
+ return gdbpy_handle_gdb_exception (nullptr, except);
}
Py_RETURN_NONE;
@@ -2316,7 +2316,7 @@ init_done:
return false;
#define GDB_PY_DEFINE_EVENT_TYPE(name, py_name, doc, base) \
- if (gdbpy_initialize_event_generic (&name##_event_object_type, py_name) < 0) \
+ if (gdbpy_type_ready (&name##_event_object_type) < 0) \
return false;
#include "py-event-types.def"
#undef GDB_PY_DEFINE_EVENT_TYPE
diff --git a/gdb/quick-symbol.h b/gdb/quick-symbol.h
index d6de734..0d76e18 100644
--- a/gdb/quick-symbol.h
+++ b/gdb/quick-symbol.h
@@ -47,6 +47,11 @@ typedef bool (expand_symtabs_file_matcher_ftype) (const char *filename,
typedef bool (expand_symtabs_symbol_matcher_ftype) (const char *name);
/* Callback for quick_symbol_functions->expand_symtabs_matching
+ to match a language. */
+
+typedef bool (expand_symtabs_lang_matcher_ftype) (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. */
@@ -122,6 +127,10 @@ struct quick_symbol_functions
/* Expand 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.
+
FILE_MATCHER is called for each file in OBJFILE. The file name
is passed to it. If the matcher returns false, the file is
skipped. If FILE_MATCHER is NULL the file is not skipped. If
@@ -154,7 +163,9 @@ struct quick_symbol_functions
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags,
- domain_search_flags domain) = 0;
+ domain_search_flags domain,
+ gdb::function_view<expand_symtabs_lang_matcher_ftype> 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-btrace.c b/gdb/record-btrace.c
index 997f442..8fcf638 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -3180,6 +3180,36 @@ show_record_pt_buffer_size_value (struct ui_file *file, int from_tty,
value);
}
+
+static bool event_tracing = false;
+
+/* The "record pt event-tracing" show value function. */
+
+static void
+show_record_pt_event_tracing_value (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c,
+ const char *value)
+{
+#if (LIBIPT_VERSION >= 0x201)
+ gdb_printf (file, _("record pt event-tracing is %s.\n"), value);
+#else
+ gdb_printf (_("Event-tracing is not supported by GDB.\n"));
+#endif /* defined (LIBIPT_VERSION >= 0x201) */
+}
+
+/* The "record pt event-tracing" set value function. */
+
+static void
+set_record_pt_event_tracing_value (const char *args, int from_tty,
+ cmd_list_element *c)
+{
+#if (LIBIPT_VERSION >= 0x201)
+ record_btrace_conf.pt.event_tracing = event_tracing;
+#else
+ gdb_printf (_("Event-tracing is not supported by GDB.\n"));
+#endif /* defined (LIBIPT_VERSION >= 0x201) */
+}
+
/* Initialize btrace commands. */
void _initialize_record_btrace ();
@@ -3299,6 +3329,19 @@ to see the actual buffer size."), NULL, show_record_pt_buffer_size_value,
&set_record_btrace_pt_cmdlist,
&show_record_btrace_pt_cmdlist);
+ add_setshow_boolean_cmd ("event-tracing", no_class, &event_tracing,
+ _("Set event-tracing for record pt."),
+ _("Show event-tracing for record pt."),
+ _("\
+Use \"on\" to enable event tracing for recordings with Intel Processor Trace, \
+and \"off\" to disable it.\n\
+Without an argument, event tracing is enabled. Changing this setting has no\
+effect on an active recording."),
+ set_record_pt_event_tracing_value,
+ show_record_pt_event_tracing_value,
+ &set_record_btrace_pt_cmdlist,
+ &show_record_btrace_pt_cmdlist);
+
add_target (record_btrace_target_info, record_btrace_target_open);
bfcache = htab_create_alloc (50, bfcache_hash, bfcache_eq, NULL,
@@ -3311,4 +3354,5 @@ to see the actual buffer size."), NULL, show_record_pt_buffer_size_value,
#else
record_btrace_conf.pt.ptwrite = false;
#endif
+ record_btrace_conf.pt.event_tracing = false;
}
diff --git a/gdb/regcache-dump.c b/gdb/regcache-dump.c
index bc665dc..6b711bf 100644
--- a/gdb/regcache-dump.c
+++ b/gdb/regcache-dump.c
@@ -162,7 +162,7 @@ protected:
{
if (regnum < 0)
{
- gdb_printf (file, "Rmt Nr g/G Offset");
+ gdb_printf (file, "Rmt Nr g/G Offset Expedited");
}
else if (regnum < gdbarch_num_regs (m_gdbarch))
{
@@ -170,7 +170,12 @@ protected:
if (remote_register_number_and_offset (m_gdbarch, regnum,
&pnum, &poffset))
- gdb_printf (file, "%7d %11d", pnum, poffset);
+ {
+ if (remote_register_is_expedited (regnum))
+ gdb_printf (file, "%7d %11d yes", pnum, poffset);
+ else
+ gdb_printf (file, "%7d %11d", pnum, poffset);
+ }
}
}
};
@@ -324,9 +329,11 @@ _initialize_regcache_dump ()
"Takes an optional file parameter."),
&maintenanceprintlist);
add_cmd ("remote-registers", class_maintenance,
- maintenance_print_remote_registers, _("\
-Print the internal register configuration including remote register number "
-"and g/G packets offset.\n\
-Takes an optional file parameter."),
+ maintenance_print_remote_registers,
+ _("Print the internal register configuration including remote "
+ "register number and g/G packets offset.\n"
+ "Also prints which registers were sent in the last stop reply "
+ "packet (i.e. expedited).\n"
+ "Takes an optional file parameter."),
&maintenanceprintlist);
}
diff --git a/gdb/remote.c b/gdb/remote.c
index 2c3988c..5323491 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -364,6 +364,9 @@ enum {
/* Support for the Qbtrace-conf:pt:ptwrite packet. */
PACKET_Qbtrace_conf_pt_ptwrite,
+ /* Support for the Qbtrace-conf:pt:event-tracing packet. */
+ PACKET_Qbtrace_conf_pt_event_tracing,
+
/* Support for exec events. */
PACKET_exec_event_feature,
@@ -682,7 +685,7 @@ public: /* data */
/* FIXME: cagney/1999-09-23: Even though getpkt was called with
``forever'' still use the normal timeout mechanism. This is
- currently used by the ASYNC code to guarentee that target reads
+ currently used by the ASYNC code to guarantee that target reads
during the initial connect always time-out. Once getpkt has been
modified to return a timeout indication and, in turn
remote_wait()/wait_for_inferior() have gained a timeout parameter
@@ -693,6 +696,10 @@ public: /* data */
qSupported. */
gdb_thread_options supported_thread_options = 0;
+ /* Contains the regnums of the expedited registers in the last stop
+ reply packet. */
+ std::set<int> last_seen_expedited_registers;
+
private:
/* Asynchronous signal handle registered as event loop source for
when we have pending events ready to be passed to the core. */
@@ -1490,6 +1497,20 @@ is_remote_target (process_stratum_target *target)
return as_remote_target (target) != nullptr;
}
+/* See remote.h. */
+
+bool
+remote_register_is_expedited (int regnum)
+{
+ remote_target *rt = as_remote_target (current_inferior ()->process_target ());
+
+ if (rt == nullptr)
+ return false;
+
+ remote_state *rs = rt->get_remote_state ();
+ return rs->last_seen_expedited_registers.count (regnum) > 0;
+}
+
/* Per-program-space data key. */
static const registry<program_space>::key<char, gdb::xfree_deleter<char>>
remote_pspace_data;
@@ -3911,7 +3932,7 @@ remote_target::remote_get_threadlist (int startflag, threadref *nextthread,
/* FIXME: This is a good reason to drop the packet. */
/* Possibly, there is a duplicate response. */
/* Possibilities :
- retransmit immediatly - race conditions
+ retransmit immediately - race conditions
retransmit after timeout - yes
exit
wait for packet, then exit
@@ -5815,6 +5836,8 @@ static const struct protocol_feature remote_protocol_features[] = {
PACKET_Qbtrace_conf_pt_size },
{ "Qbtrace-conf:pt:ptwrite", PACKET_DISABLE, remote_supported_packet,
PACKET_Qbtrace_conf_pt_ptwrite },
+ { "Qbtrace-conf:pt:event-tracing", PACKET_DISABLE, remote_supported_packet,
+ PACKET_Qbtrace_conf_pt_event_tracing },
{ "vContSupported", PACKET_DISABLE, remote_supported_packet, PACKET_vContSupported },
{ "QThreadEvents", PACKET_DISABLE, remote_supported_packet, PACKET_QThreadEvents },
{ "QThreadOptions", PACKET_DISABLE, remote_supported_thread_options,
@@ -6269,7 +6292,7 @@ remote_target::open_1 (const char *name, int from_tty, int extended_p)
/* Start the remote connection. If error() or QUIT, discard this
target (we'd otherwise be in an inconsistent state) and then
- propogate the error on up the exception chain. This ensures that
+ propagate the error on up the exception chain. This ensures that
the caller doesn't stumble along blindly assuming that the
function succeeded. The CLI doesn't have this problem but other
UI's, such as MI do.
@@ -8518,6 +8541,10 @@ remote_target::process_stop_reply (stop_reply_up stop_reply,
{
*status = stop_reply->ws;
ptid_t ptid = stop_reply->ptid;
+ struct remote_state *rs = get_remote_state ();
+
+ /* Forget about last reply's expedited registers. */
+ rs->last_seen_expedited_registers.clear ();
/* If no thread/process was reported by the stub then select a suitable
thread/process. */
@@ -8544,7 +8571,10 @@ remote_target::process_stop_reply (stop_reply_up stop_reply,
stop_reply->arch);
for (cached_reg_t &reg : stop_reply->regcache)
- regcache->raw_supply (reg.num, reg.data.get ());
+ {
+ regcache->raw_supply (reg.num, reg.data.get ());
+ rs->last_seen_expedited_registers.insert (reg.num);
+ }
}
remote_thread_info *remote_thr = get_remote_thread_info (this, ptid);
@@ -13237,6 +13267,18 @@ public:
fileio_error remote_errno;
m_remote->remote_hostio_close (m_fd, &remote_errno);
}
+ catch (const gdb_exception_quit &ex)
+ {
+ /* We can't throw from a destructor, so re-set the quit flag
+ for later QUIT checking. */
+ set_quit_flag ();
+ }
+ catch (const gdb_exception_forced_quit &ex)
+ {
+ /* Like above, but (eventually) cause GDB to terminate by
+ setting sync_quit_force_run. */
+ set_force_quit_flag ();
+ }
catch (...)
{
/* Swallow exception before it escapes the dtor. If
@@ -14741,7 +14783,7 @@ parse_xml_btrace_conf_pt (struct gdb_xml_parser *parser,
std::vector<gdb_xml_value> &attributes)
{
struct btrace_config *conf;
- struct gdb_xml_value *size, *ptwrite;
+ struct gdb_xml_value *size, *ptwrite, *event_tracing;
conf = (struct btrace_config *) user_data;
conf->format = BTRACE_FORMAT_PT;
@@ -14754,12 +14796,18 @@ parse_xml_btrace_conf_pt (struct gdb_xml_parser *parser,
ptwrite = xml_find_attribute (attributes, "ptwrite");
if (ptwrite != nullptr)
conf->pt.ptwrite = (bool) *(ULONGEST *) ptwrite->value.get ();
+
+ event_tracing = xml_find_attribute (attributes, "event-tracing");
+ if (event_tracing != nullptr)
+ conf->pt.event_tracing = (bool) *(ULONGEST *) event_tracing->value.get ();
}
static const struct gdb_xml_attribute btrace_conf_pt_attributes[] = {
{ "size", GDB_XML_AF_OPTIONAL, gdb_xml_parse_attr_ulongest, NULL },
{ "ptwrite", GDB_XML_AF_OPTIONAL, gdb_xml_parse_attr_enum,
gdb_xml_enums_boolean },
+ { "event-tracing", GDB_XML_AF_OPTIONAL, gdb_xml_parse_attr_enum,
+ gdb_xml_enums_boolean },
{ NULL, GDB_XML_AF_NONE, NULL, NULL }
};
@@ -14891,6 +14939,39 @@ remote_target::btrace_sync_conf (const btrace_config *conf)
rs->btrace_config.pt.ptwrite = conf->pt.ptwrite;
}
+
+ /* Event tracing is a user setting, warn if it is set but the target
+ doesn't support it. */
+ if ((m_features.packet_support (PACKET_Qbtrace_conf_pt_event_tracing)
+ != PACKET_ENABLE)
+ && conf->pt.event_tracing)
+ warning (_("Target does not support event-tracing."));
+
+ if ((m_features.packet_support (PACKET_Qbtrace_conf_pt_event_tracing)
+ == PACKET_ENABLE)
+ && conf->pt.event_tracing != rs->btrace_config.pt.event_tracing)
+ {
+ pos = buf;
+ const char *event_tracing = conf->pt.event_tracing ? "yes" : "no";
+ const char *name
+ = packets_descriptions[PACKET_Qbtrace_conf_pt_event_tracing].name;
+ pos += xsnprintf (pos, endbuf - pos, "%s=\"%s\"", name, event_tracing);
+
+ putpkt (buf);
+ getpkt (&rs->buf, 0);
+
+ packet_result result
+ = m_features.packet_ok (buf, PACKET_Qbtrace_conf_pt_event_tracing);
+ if (result.status () == PACKET_ERROR)
+ {
+ if (buf[0] == 'E' && buf[1] == '.')
+ error (_("Failed to sync event-tracing config: %s"), buf + 2);
+ else
+ error (_("Failed to sync event-tracing config."));
+ }
+
+ rs->btrace_config.pt.event_tracing = conf->pt.event_tracing;
+ }
}
/* Read TP's btrace configuration from the target and store it into CONF. */
@@ -15246,7 +15327,7 @@ static serial_event_ftype remote_async_serial_handler;
static void
remote_async_serial_handler (struct serial *scb, void *context)
{
- /* Don't propogate error information up to the client. Instead let
+ /* Don't propagate error information up to the client. Instead let
the client find out about the error by querying the target. */
inferior_event_handler (INF_REG_EVENT);
}
@@ -16348,6 +16429,10 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL,
add_packet_config_cmd (PACKET_Qbtrace_conf_pt_ptwrite, "Qbtrace-conf:pt:ptwrite",
"btrace-conf-pt-ptwrite", 0);
+ add_packet_config_cmd (PACKET_Qbtrace_conf_pt_event_tracing,
+ "Qbtrace-conf:pt:event-tracing",
+ "btrace-conf-pt-event-tracing", 0);
+
add_packet_config_cmd (PACKET_vContSupported, "vContSupported",
"verbose-resume-supported", 0);
diff --git a/gdb/remote.h b/gdb/remote.h
index cb0a66d..bfe3c65 100644
--- a/gdb/remote.h
+++ b/gdb/remote.h
@@ -121,4 +121,9 @@ extern void send_remote_packet (gdb::array_view<const char> &buf,
extern bool is_remote_target (process_stratum_target *target);
+/* Return true if REGNUM was returned as an expedited register in the last
+ stop reply we received. */
+
+extern bool remote_register_is_expedited (int regnum);
+
#endif
diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c
index 3faefe5..3cc0232 100644
--- a/gdb/rs6000-aix-tdep.c
+++ b/gdb/rs6000-aix-tdep.c
@@ -524,7 +524,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
on PPC variants that lack them. */
gdb_assert (ppc_floating_point_unit_p (gdbarch));
- /* The first eight words of ther arguments are passed in registers.
+ /* The first eight words of the arguments are passed in registers.
Copy them appropriately. */
ii = 0;
diff --git a/gdb/rs6000-lynx178-tdep.c b/gdb/rs6000-lynx178-tdep.c
index 17244b3..a5a6bb9 100644
--- a/gdb/rs6000-lynx178-tdep.c
+++ b/gdb/rs6000-lynx178-tdep.c
@@ -56,7 +56,7 @@ rs6000_lynx178_push_dummy_call (struct gdbarch *gdbarch,
on PPC variants that lack them. */
gdb_assert (ppc_floating_point_unit_p (gdbarch));
- /* The first eight words of ther arguments are passed in registers.
+ /* The first eight words of the arguments are passed in registers.
Copy them appropriately. */
ii = 0;
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index ed6a21b..d7f9698 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -1389,7 +1389,7 @@ rs6000_fetch_instruction (struct gdbarch *gdbarch, const CORE_ADDR pc)
return op;
}
-/* GCC generates several well-known sequences of instructions at the begining
+/* GCC generates several well-known sequences of instructions at the beginning
of each function prologue when compiling with -fstack-check. If one of
such sequences starts at START_PC, then return the address of the
instruction immediately past this sequence. Otherwise, return START_PC. */
@@ -4298,7 +4298,7 @@ ppc_record_ACC_fpscr (struct regcache *regcache, ppc_gdbarch_tdep *tdep,
ACC[7][3] -> VSR[31]
NOTE:
- In ISA 3.1 the ACC is mapped on top of VSR[0] thru VSR[31].
+ In ISA 3.1 the ACC is mapped on top of VSR[0] through VSR[31].
In the future, the ACC may be implemented as an independent register file
rather than mapping on top of the VSRs. This will then require the ACC to
diff --git a/gdb/run-on-main-thread.c b/gdb/run-on-main-thread.c
index e30daba..746ea35 100644
--- a/gdb/run-on-main-thread.c
+++ b/gdb/run-on-main-thread.c
@@ -74,7 +74,20 @@ run_events (int error, gdb_client_data client_data)
{
item ();
}
- catch (...)
+ catch (const gdb_exception_forced_quit &e)
+ {
+ /* GDB is terminating, so:
+ - make sure this is propagated, and
+ - no need to keep running things, so propagate immediately. */
+ throw;
+ }
+ catch (const gdb_exception_quit &e)
+ {
+ /* Should cancelation of a runnable event cancel the execution of
+ the following one? The answer is not clear, so keep doing what
+ we've done so far: ignore this exception. */
+ }
+ catch (const gdb_exception &)
{
/* Ignore exceptions in the callback. */
}
diff --git a/gdb/rust-lang.h b/gdb/rust-lang.h
index 9ae5961..866d1ac 100644
--- a/gdb/rust-lang.h
+++ b/gdb/rust-lang.h
@@ -45,7 +45,7 @@ extern const char *rust_last_path_segment (const char *path);
/* Create a new slice type. NAME is the name of the type. ELT_TYPE
is the type of the elements of the slice. USIZE_TYPE is the Rust
- "usize" type to use. The new type is allocated whereever ELT_TYPE
+ "usize" type to use. The new type is allocated wherever ELT_TYPE
is allocated. */
extern struct type *rust_slice_type (const char *name, struct type *elt_type,
struct type *usize_type);
diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c
index 6687127..064cf68 100644
--- a/gdb/s390-tdep.c
+++ b/gdb/s390-tdep.c
@@ -1897,7 +1897,7 @@ s390_handle_arg (struct s390_arg_state *as, struct value *arg,
for S/390 ELF Application Binary Interface Supplement".
SP is the current stack pointer. We must put arguments, links,
- padding, etc. whereever they belong, and return the new stack
+ padding, etc. wherever they belong, and return the new stack
pointer value.
If STRUCT_RETURN is non-zero, then the function we're calling is
diff --git a/gdb/ser-base.c b/gdb/ser-base.c
index 81ef942..838560e 100644
--- a/gdb/ser-base.c
+++ b/gdb/ser-base.c
@@ -148,7 +148,7 @@ run_async_handler_and_reschedule (struct serial *scb)
/* FD_EVENT: This is scheduled when the input FIFO is empty (and there
is no pending error). As soon as data arrives, it is read into the
input FIFO and the client notified. The client should then drain
- the FIFO using readchar(). If the FIFO isn't immediatly emptied,
+ the FIFO using readchar(). If the FIFO isn't immediately emptied,
push_event() is used to nag the client until it is. */
static void
@@ -419,7 +419,7 @@ do_ser_base_readchar (struct serial *scb, int timeout)
pre-reads the input into that FIFO. Once that has been emptied,
further data is obtained by polling the input FD using the device
specific readchar() function. Note: reschedule() is called after
- every read. This is because there is no guarentee that the lower
+ every read. This is because there is no guarantee that the lower
level fd_event() poll_event() code (which also calls reschedule())
will be called. */
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index 050f7bf..d211265 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -1057,7 +1057,7 @@ sh_push_dummy_call_fpu (struct gdbarch *gdbarch,
/* Now load as many as possible of the first arguments into
registers, and push the rest onto the stack. There are 16 bytes
- in four registers available. Loop thru args from first to last. */
+ in four registers available. Loop through args from first to last. */
for (argnum = 0; argnum < nargs; argnum++)
{
type = args[argnum]->type ();
@@ -1195,7 +1195,7 @@ sh_push_dummy_call_nofpu (struct gdbarch *gdbarch,
/* Now load as many as possible of the first arguments into
registers, and push the rest onto the stack. There are 16 bytes
- in four registers available. Loop thru args from first to last. */
+ in four registers available. Loop through args from first to last. */
for (argnum = 0; argnum < nargs; argnum++)
{
type = args[argnum]->type ();
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 928d654..7999a8e 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -619,7 +619,7 @@ find_program_interpreter (void)
/* Scan for DESIRED_DYNTAG in .dynamic section of the target's main executable,
- found by consulting the OS auxillary vector. If DESIRED_DYNTAG is found, 1
+ found by consulting the OS auxiliary vector. If DESIRED_DYNTAG is found, 1
is returned and the corresponding PTR is set. */
static int
@@ -2355,7 +2355,7 @@ enable_break (struct svr4_info *info, int from_tty)
}
/* If we were not able to find the base address of the loader
- from our so_list, then try using the AT_BASE auxilliary entry. */
+ from our so_list, then try using the AT_BASE auxiliary entry. */
if (!load_addr_found)
if (target_auxv_search (AT_BASE, &load_addr) > 0)
{
@@ -2616,8 +2616,8 @@ svr4_exec_displacement (CORE_ADDR *displacementp)
return 0;
}
- /* Verify that the auxilliary vector describes the same file as exec_bfd, by
- comparing their program headers. If the program headers in the auxilliary
+ /* Verify that the auxiliary vector describes the same file as exec_bfd, by
+ comparing their program headers. If the program headers in the auxiliary
vector do not match the program headers in the executable, then we are
looking at a different file than the one used by the kernel - for
instance, "gdb program" connected to "gdbserver :PORT ld.so program". */
diff --git a/gdb/source-cache.c b/gdb/source-cache.c
index 2815b6e..f08c872 100644
--- a/gdb/source-cache.c
+++ b/gdb/source-cache.c
@@ -282,6 +282,12 @@ static void gnu_source_highlight_test ()
{
res = try_source_highlight (styled_prog, language_c, fullname);
}
+ catch (const gdb_exception &e)
+ {
+ if (e.reason != RETURN_ERROR)
+ throw;
+ saw_exception = true;
+ }
catch (...)
{
saw_exception = true;
diff --git a/gdb/source.c b/gdb/source.c
index b9122c4..292d2bf 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -1345,7 +1345,7 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
fields. ui_source_list is set only for CLI, not for
TUI. */
- uiout->field_signed ("line", line);
+ uiout->field_signed ("line", line, line_number_style.style ());
uiout->text ("\tin ");
uiout->field_string ("file", symtab_to_filename_for_display (s),
@@ -1386,11 +1386,15 @@ print_source_lines_base (struct symtab *s, int line, int stopline,
last_line_listed = loc->line ();
if (flags & PRINT_SOURCE_LINES_FILENAME)
{
- uiout->text (symtab_to_filename_for_display (s));
+ uiout->message ("%ps",
+ styled_string (file_name_style.style (),
+ symtab_to_filename_for_display (s)));
uiout->text (":");
}
- xsnprintf (buf, sizeof (buf), "%d\t", new_lineno++);
- uiout->text (buf);
+
+ uiout->message ("%ps\t", styled_string (line_number_style.style (),
+ pulongest (new_lineno)));
+ ++new_lineno;
while (*iter != '\0')
{
@@ -1551,9 +1555,11 @@ info_line_command (const char *arg, int from_tty)
if (start_pc == end_pc)
{
- gdb_printf ("Line %d of \"%s\"",
- sal.line,
- symtab_to_filename_for_display (sal.symtab));
+ gdb_printf ("Line %ps of \"%ps\"",
+ styled_string (line_number_style.style (),
+ pulongest (sal.line)),
+ styled_string (file_name_style.style (),
+ symtab_to_filename_for_display (sal.symtab)));
gdb_stdout->wrap_here (2);
gdb_printf (" is at address ");
print_address (gdbarch, start_pc, gdb_stdout);
@@ -1562,9 +1568,11 @@ info_line_command (const char *arg, int from_tty)
}
else
{
- gdb_printf ("Line %d of \"%s\"",
- sal.line,
- symtab_to_filename_for_display (sal.symtab));
+ gdb_printf ("Line %ps of \"%ps\"",
+ styled_string (line_number_style.style (),
+ pulongest (sal.line)),
+ styled_string (file_name_style.style (),
+ symtab_to_filename_for_display (sal.symtab)));
gdb_stdout->wrap_here (2);
gdb_printf (" starts at address ");
print_address (gdbarch, start_pc, gdb_stdout);
@@ -1589,8 +1597,11 @@ info_line_command (const char *arg, int from_tty)
/* Is there any case in which we get here, and have an address
which the user would want to see? If we have debugging symbols
and no line numbers? */
- gdb_printf (_("Line number %d is out of range for \"%s\".\n"),
- sal.line, symtab_to_filename_for_display (sal.symtab));
+ gdb_printf (_("Line number %ps is out of range for \"%ps\".\n"),
+ styled_string (line_number_style.style (),
+ pulongest (sal.line)),
+ styled_string (file_name_style.style (),
+ symtab_to_filename_for_display (sal.symtab)));
}
}
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index edbc038..e97a7d9 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -769,7 +769,7 @@ sparc_alloc_frame_cache (void)
return cache;
}
-/* GCC generates several well-known sequences of instructions at the begining
+/* GCC generates several well-known sequences of instructions at the beginning
of each function prologue when compiling with -fstack-check. If one of
such sequences starts at START_PC, then return the address of the
instruction immediately past this sequence. Otherwise, return START_PC. */
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 46536ba..e479820 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -33,6 +33,7 @@
#include "symfile.h"
#include "objfiles.h"
#include "aout/stab_gnu.h"
+#include "psymtab.h"
#include "libaout.h"
#include "aout/aout64.h"
#include "gdb-stabs.h"
@@ -46,6 +47,8 @@
#include "cp-abi.h"
#include "cp-support.h"
#include <ctype.h>
+#include "block.h"
+#include "filenames.h"
#include "stabsread.h"
@@ -61,6 +64,26 @@ int *this_object_header_files;
int n_this_object_header_files;
int n_allocated_this_object_header_files;
+/* See stabsread.h. */
+
+const registry<objfile>::key<dbx_symfile_info> dbx_objfile_data_key;
+
+dbx_symfile_info::~dbx_symfile_info ()
+{
+ if (header_files != NULL)
+ {
+ int i = n_header_files;
+ struct header_file *hfiles = header_files;
+
+ while (--i >= 0)
+ {
+ xfree (hfiles[i].name);
+ xfree (hfiles[i].vector);
+ }
+ xfree (hfiles);
+ }
+}
+
struct stabs_nextfield
{
struct stabs_nextfield *next;
@@ -165,6 +188,26 @@ void stabsread_clear_cache (void);
static const char vptr_name[] = "_vptr$";
static const char vb_name[] = "_vb$";
+void
+unknown_symtype_complaint (const char *arg1)
+{
+ complaint (_("unknown symbol type %s"), arg1);
+}
+
+void
+lbrac_mismatch_complaint (int arg1)
+{
+ complaint (_("N_LBRAC/N_RBRAC symbol mismatch at symtab pos %d"), arg1);
+}
+
+void
+repeated_header_complaint (const char *arg1, int arg2)
+{
+ complaint (_("\"repeated\" header file %s not "
+ "previously seen, at symtab pos %d"),
+ arg1, arg2);
+}
+
static void
invalid_cpp_abbrev_complaint (const char *arg1)
{
@@ -184,6 +227,14 @@ stabs_general_complaint (const char *arg1)
complaint ("%s", arg1);
}
+static void
+function_outside_compilation_unit_complaint (const char *arg1)
+{
+ complaint (_("function `%s' appears to be defined "
+ "outside of all compilation units"),
+ arg1);
+}
+
/* Make a list of forward references which haven't been defined. */
static struct type **undef_types;
@@ -491,6 +542,2440 @@ read_type_number (const char **pp, int *typenums)
}
+/* Free up old header file tables. */
+
+void
+free_header_files (void)
+{
+ if (this_object_header_files)
+ {
+ xfree (this_object_header_files);
+ this_object_header_files = NULL;
+ }
+ n_allocated_this_object_header_files = 0;
+}
+
+/* Allocate new header file tables. */
+
+void
+init_header_files (void)
+{
+ n_allocated_this_object_header_files = 10;
+ this_object_header_files = XNEWVEC (int, 10);
+}
+
+/* Close off the current usage of PST.
+ Returns PST or NULL if the partial symtab was empty and thrown away.
+
+ FIXME: List variables and peculiarities of same. */
+
+legacy_psymtab *
+stabs_end_psymtab (struct objfile *objfile, psymtab_storage *partial_symtabs,
+ legacy_psymtab *pst,
+ const char **include_list, int num_includes,
+ int capping_symbol_offset, unrelocated_addr capping_text,
+ legacy_psymtab **dependency_list,
+ int number_dependencies,
+ int textlow_not_set)
+{
+ int i;
+ struct gdbarch *gdbarch = objfile->arch ();
+ dbx_symfile_info *key = dbx_objfile_data_key. get (objfile);
+
+ if (capping_symbol_offset != -1)
+ LDSYMLEN (pst) = capping_symbol_offset - LDSYMOFF (pst);
+ pst->set_text_high (capping_text);
+
+ /* Under Solaris, the N_SO symbols always have a value of 0,
+ instead of the usual address of the .o file. Therefore,
+ we have to do some tricks to fill in texthigh and textlow.
+ The first trick is: if we see a static
+ or global function, and the textlow for the current pst
+ is not set (ie: textlow_not_set), then we use that function's
+ address for the textlow of the pst. */
+
+ /* Now, to fill in texthigh, we remember the last function seen
+ in the .o file. Also, there's a hack in
+ bfd/elf.c and gdb/elfread.c to pass the ELF st_size field
+ to here via the misc_info field. Therefore, we can fill in
+ a reliable texthigh by taking the address plus size of the
+ last function in the file. */
+
+ if (!pst->text_high_valid && key->ctx.last_function_name
+ && gdbarch_sofun_address_maybe_missing (gdbarch))
+ {
+ int n;
+
+ const char *colon = strchr (key->ctx.last_function_name, ':');
+ if (colon == NULL)
+ n = 0;
+ else
+ n = colon - key->ctx.last_function_name;
+ char *p = (char *) alloca (n + 2);
+ strncpy (p, key->ctx.last_function_name, n);
+ p[n] = 0;
+
+ bound_minimal_symbol minsym
+ = lookup_minimal_symbol (current_program_space, p, objfile,
+ pst->filename);
+ if (minsym.minsym == NULL)
+ {
+ /* Sun Fortran appends an underscore to the minimal symbol name,
+ try again with an appended underscore if the minimal symbol
+ was not found. */
+ p[n] = '_';
+ p[n + 1] = 0;
+ minsym = lookup_minimal_symbol (current_program_space, p, objfile,
+ pst->filename);
+ }
+
+ if (minsym.minsym)
+ pst->set_text_high
+ (unrelocated_addr (CORE_ADDR (minsym.minsym->unrelocated_address ())
+ + minsym.minsym->size ()));
+
+ key->ctx.last_function_name = NULL;
+ }
+
+ if (!gdbarch_sofun_address_maybe_missing (gdbarch))
+ ;
+ /* This test will be true if the last .o file is only data. */
+ else if (textlow_not_set)
+ pst->set_text_low (pst->unrelocated_text_high ());
+ else
+ {
+ /* If we know our own starting text address, then walk through all other
+ psymtabs for this objfile, and if any didn't know their ending text
+ address, set it to our starting address. Take care to not set our
+ own ending address to our starting address. */
+
+ for (partial_symtab *p1 : partial_symtabs->range ())
+ if (!p1->text_high_valid && p1->text_low_valid && p1 != pst)
+ p1->set_text_high (pst->unrelocated_text_low ());
+ }
+
+ /* End of kludge for patching Solaris textlow and texthigh. */
+
+ pst->end ();
+
+ pst->number_of_dependencies = number_dependencies;
+ if (number_dependencies)
+ {
+ pst->dependencies
+ = partial_symtabs->allocate_dependencies (number_dependencies);
+ memcpy (pst->dependencies, dependency_list,
+ number_dependencies * sizeof (legacy_psymtab *));
+ }
+ else
+ pst->dependencies = 0;
+
+ for (i = 0; i < num_includes; i++)
+ {
+ legacy_psymtab *subpst =
+ new legacy_psymtab (include_list[i], partial_symtabs, objfile->per_bfd);
+
+ subpst->read_symtab_private =
+ XOBNEW (&objfile->objfile_obstack, struct symloc);
+ LDSYMOFF (subpst) =
+ LDSYMLEN (subpst) = 0;
+
+ /* We could save slight bits of space by only making one of these,
+ shared by the entire set of include files. FIXME-someday. */
+ subpst->dependencies =
+ partial_symtabs->allocate_dependencies (1);
+ subpst->dependencies[0] = pst;
+ subpst->number_of_dependencies = 1;
+
+ subpst->legacy_read_symtab = pst->legacy_read_symtab;
+ subpst->legacy_expand_psymtab = pst->legacy_expand_psymtab;
+ }
+
+ if (num_includes == 0
+ && number_dependencies == 0
+ && pst->empty ()
+ && key->ctx.has_line_numbers == 0)
+ {
+ /* Throw away this psymtab, it's empty. */
+ /* Empty psymtabs happen as a result of header files which don't have
+ any symbols in them. There can be a lot of them. But this check
+ is wrong, in that a psymtab with N_SLINE entries but nothing else
+ is not empty, but we don't realize that. Fixing that without slowing
+ things down might be tricky. */
+
+ partial_symtabs->discard_psymtab (pst);
+
+ /* Indicate that psymtab was thrown away. */
+ pst = NULL;
+ }
+ return pst;
+}
+
+/* Set namestring based on nlist. If the string table index is invalid,
+ give a fake name, and print a single error message per symbol file read,
+ rather than abort the symbol reading or flood the user with messages. */
+
+static const char *
+set_namestring (struct objfile *objfile, const struct internal_nlist *nlist)
+{
+ const char *namestring;
+ struct dbx_symfile_info *key = dbx_objfile_data_key.get (objfile);
+
+ if (nlist->n_strx + key->ctx.file_string_table_offset
+ >= DBX_STRINGTAB_SIZE (objfile)
+ || nlist->n_strx + key->ctx.file_string_table_offset < nlist->n_strx)
+ {
+ complaint (_("bad string table offset in symbol %d"),
+ symnum);
+ namestring = "<bad string table offset>";
+ }
+ else
+ namestring = (nlist->n_strx + key->ctx.file_string_table_offset
+ + DBX_STRINGTAB (objfile));
+ return namestring;
+}
+
+static void
+stabs_seek (int sym_offset, struct objfile *objfile)
+{
+ dbx_symfile_info *key = dbx_objfile_data_key.get (objfile);
+ if (key->ctx.stabs_data)
+ {
+ key->ctx.symbuf_read += sym_offset;
+ key->ctx.symbuf_left -= sym_offset;
+ }
+ else
+ if (bfd_seek (objfile->obfd.get (), sym_offset, SEEK_CUR) != 0)
+ perror_with_name (bfd_get_filename (objfile->obfd.get ()));
+}
+
+/* Buffer for reading the symbol table entries. */
+static struct external_nlist symbuf[4096];
+static int symbuf_idx;
+static int symbuf_end;
+
+/* Refill the symbol table input buffer
+ and set the variables that control fetching entries from it.
+ Reports an error if no data available.
+ This function can read past the end of the symbol table
+ (into the string table) but this does no harm. */
+
+static void
+fill_symbuf (bfd *sym_bfd, struct objfile *objfile)
+{
+ unsigned int count;
+ int nbytes;
+ struct dbx_symfile_info *key = dbx_objfile_data_key.get (objfile);
+
+ if (key->ctx.stabs_data)
+ {
+ nbytes = sizeof (symbuf);
+ if (nbytes > key->ctx.symbuf_left)
+ nbytes = key->ctx.symbuf_left;
+ memcpy (symbuf, key->ctx.stabs_data + key->ctx.symbuf_read, nbytes);
+ }
+ else if (key->ctx.symbuf_sections == NULL)
+ {
+ count = sizeof (symbuf);
+ nbytes = bfd_read (symbuf, count, sym_bfd);
+ }
+ else
+ {
+ if (key->ctx.symbuf_left <= 0)
+ {
+ file_ptr filepos = (*key->ctx.symbuf_sections)[key->ctx.sect_idx]->filepos;
+
+ if (bfd_seek (sym_bfd, filepos, SEEK_SET) != 0)
+ perror_with_name (bfd_get_filename (sym_bfd));
+ key->ctx.symbuf_left = bfd_section_size ((*key->ctx.symbuf_sections)[key->ctx.sect_idx]);
+ key->ctx.symbol_table_offset = filepos - key->ctx.symbuf_read;
+ ++key->ctx.sect_idx;
+ }
+
+ count = key->ctx.symbuf_left;
+ if (count > sizeof (symbuf))
+ count = sizeof (symbuf);
+ nbytes = bfd_read (symbuf, count, sym_bfd);
+ }
+
+ if (nbytes < 0)
+ perror_with_name (bfd_get_filename (sym_bfd));
+ else if (nbytes == 0)
+ error (_("Premature end of file reading symbol table"));
+ symbuf_end = nbytes / key->ctx.symbol_size;
+ symbuf_idx = 0;
+ key->ctx.symbuf_left -= nbytes;
+ key->ctx.symbuf_read += nbytes;
+}
+
+/* Read in a defined section of a specific object file's symbols. */
+
+static void
+read_ofile_symtab (struct objfile *objfile, legacy_psymtab *pst)
+{
+ const char *namestring;
+ struct external_nlist *bufp;
+ struct internal_nlist nlist;
+ unsigned char type;
+ unsigned max_symnum;
+ bfd *abfd;
+ int sym_offset; /* Offset to start of symbols to read */
+ int sym_size; /* Size of symbols to read */
+ CORE_ADDR text_offset; /* Start of text segment for symbols */
+ int text_size; /* Size of text segment for symbols */
+ struct dbx_symfile_info *key = dbx_objfile_data_key.get (objfile);
+
+ sym_offset = LDSYMOFF (pst);
+ sym_size = LDSYMLEN (pst);
+ text_offset = pst->text_low (objfile);
+ text_size = pst->text_high (objfile) - pst->text_low (objfile);
+ const section_offsets &section_offsets = objfile->section_offsets;
+
+ key->ctx.stringtab_global = DBX_STRINGTAB (objfile);
+ set_last_source_file (NULL);
+
+ abfd = objfile->obfd.get ();
+ symbuf_end = symbuf_idx = 0;
+ key->ctx.symbuf_read = 0;
+ key->ctx.symbuf_left = sym_offset + sym_size;
+
+ /* It is necessary to actually read one symbol *before* the start
+ of this symtab's symbols, because the GCC_COMPILED_FLAG_SYMBOL
+ occurs before the N_SO symbol.
+
+ Detecting this in read_stabs_symtab
+ would slow down initial readin, so we look for it here instead. */
+ if (!key->ctx.processing_acc_compilation && sym_offset >= (int) key->ctx.symbol_size)
+ {
+ stabs_seek (sym_offset - key->ctx.symbol_size, objfile);
+ fill_symbuf (abfd, objfile);
+ bufp = &symbuf[symbuf_idx++];
+ INTERNALIZE_SYMBOL (nlist, bufp, abfd);
+ OBJSTAT (objfile, n_stabs++);
+
+ namestring = set_namestring (objfile, &nlist);
+
+ processing_gcc_compilation = 0;
+ if (nlist.n_type == N_TEXT)
+ {
+ const char *tempstring = namestring;
+
+ if (strcmp (namestring, GCC_COMPILED_FLAG_SYMBOL) == 0)
+ processing_gcc_compilation = 1;
+ else if (strcmp (namestring, GCC2_COMPILED_FLAG_SYMBOL) == 0)
+ processing_gcc_compilation = 2;
+ if (*tempstring != '\0'
+ && *tempstring == bfd_get_symbol_leading_char (objfile->obfd.get ()))
+ ++tempstring;
+ if (startswith (tempstring, "__gnu_compiled"))
+ processing_gcc_compilation = 2;
+ }
+ }
+ else
+ {
+ /* The N_SO starting this symtab is the first symbol, so we
+ better not check the symbol before it. I'm not this can
+ happen, but it doesn't hurt to check for it. */
+ stabs_seek (sym_offset, objfile);
+ processing_gcc_compilation = 0;
+ }
+
+ if (symbuf_idx == symbuf_end)
+ fill_symbuf (abfd, objfile);
+ bufp = &symbuf[symbuf_idx];
+ if (bfd_h_get_8 (abfd, bufp->e_type) != N_SO)
+ error (_("First symbol in segment of executable not a source symbol"));
+
+ max_symnum = sym_size / key->ctx.symbol_size;
+
+ for (symnum = 0;
+ symnum < max_symnum;
+ symnum++)
+ {
+ QUIT; /* Allow this to be interruptable. */
+ if (symbuf_idx == symbuf_end)
+ fill_symbuf (abfd, objfile);
+ bufp = &symbuf[symbuf_idx++];
+ INTERNALIZE_SYMBOL (nlist, bufp, abfd);
+ OBJSTAT (objfile, n_stabs++);
+
+ type = bfd_h_get_8 (abfd, bufp->e_type);
+
+ namestring = set_namestring (objfile, &nlist);
+
+ if (type & N_STAB)
+ {
+ if (sizeof (nlist.n_value) > 4
+ /* We are a 64-bit debugger debugging a 32-bit program. */
+ && (type == N_LSYM || type == N_PSYM))
+ /* We have to be careful with the n_value in the case of N_LSYM
+ and N_PSYM entries, because they are signed offsets from frame
+ pointer, but we actually read them as unsigned 32-bit values.
+ This is not a problem for 32-bit debuggers, for which negative
+ values end up being interpreted correctly (as negative
+ offsets) due to integer overflow.
+ But we need to sign-extend the value for 64-bit debuggers,
+ or we'll end up interpreting negative values as very large
+ positive offsets. */
+ nlist.n_value = (nlist.n_value ^ 0x80000000) - 0x80000000;
+ process_one_symbol (type, nlist.n_desc, nlist.n_value,
+ namestring, section_offsets, objfile,
+ PST_LANGUAGE (pst));
+ }
+ /* We skip checking for a new .o or -l file; that should never
+ happen in this routine. */
+ else if (type == N_TEXT)
+ {
+ /* I don't think this code will ever be executed, because
+ the GCC_COMPILED_FLAG_SYMBOL usually is right before
+ the N_SO symbol which starts this source file.
+ However, there is no reason not to accept
+ the GCC_COMPILED_FLAG_SYMBOL anywhere. */
+
+ if (strcmp (namestring, GCC_COMPILED_FLAG_SYMBOL) == 0)
+ processing_gcc_compilation = 1;
+ else if (strcmp (namestring, GCC2_COMPILED_FLAG_SYMBOL) == 0)
+ processing_gcc_compilation = 2;
+ }
+ else if (type & N_EXT || type == (unsigned char) N_TEXT
+ || type == (unsigned char) N_NBTEXT)
+ {
+ /* Global symbol: see if we came across a dbx definition for
+ a corresponding symbol. If so, store the value. Remove
+ syms from the chain when their values are stored, but
+ search the whole chain, as there may be several syms from
+ different files with the same name. */
+ /* This is probably not true. Since the files will be read
+ in one at a time, each reference to a global symbol will
+ be satisfied in each file as it appears. So we skip this
+ section. */
+ ;
+ }
+ }
+
+ /* In a Solaris elf file, this variable, which comes from the value
+ of the N_SO symbol, will still be 0. Luckily, text_offset, which
+ comes from low text address of PST, is correct. */
+ if (get_last_source_start_addr () == 0)
+ set_last_source_start_addr (text_offset);
+
+ /* In reordered executables last_source_start_addr may not be the
+ lower bound for this symtab, instead use text_offset which comes
+ from the low text address of PST, which is correct. */
+ if (get_last_source_start_addr () > text_offset)
+ set_last_source_start_addr (text_offset);
+
+ pst->compunit_symtab = end_compunit_symtab (text_offset + text_size);
+
+ end_stabs ();
+
+}
+
+static void
+dbx_expand_psymtab (legacy_psymtab *pst, struct objfile *objfile)
+{
+ gdb_assert (!pst->readin);
+ struct dbx_symfile_info *key = dbx_objfile_data_key.get (objfile);
+
+ /* Read in all partial symtabs on which this one is dependent. */
+ pst->expand_dependencies (objfile);
+
+ if (LDSYMLEN (pst)) /* Otherwise it's a dummy. */
+ {
+ /* Init stuff necessary for reading in symbols */
+ stabsread_init ();
+ scoped_free_pendings free_pending;
+ key->ctx.file_string_table_offset = FILE_STRING_OFFSET (pst);
+ key->ctx.symbol_size = SYMBOL_SIZE (pst);
+
+ /* Read in this file's symbols. */
+ if (bfd_seek (objfile->obfd.get (), SYMBOL_OFFSET (pst), SEEK_SET) == 0)
+ read_ofile_symtab (objfile, pst);
+ }
+
+ pst->readin = true;
+}
+
+/* Invariant: The symbol pointed to by symbuf_idx is the first one
+ that hasn't been swapped. Swap the symbol at the same time
+ that symbuf_idx is incremented. */
+
+/* dbx allows the text of a symbol name to be continued into the
+ next symbol name! When such a continuation is encountered
+ (a \ at the end of the text of a name)
+ call this function to get the continuation. */
+
+static const char *
+dbx_next_symbol_text (struct objfile *objfile)
+{
+ struct internal_nlist nlist;
+ dbx_symfile_info *key = dbx_objfile_data_key.get (objfile);
+
+ if (symbuf_idx == symbuf_end)
+ fill_symbuf (objfile->obfd.get (), objfile);
+
+ symnum++;
+ INTERNALIZE_SYMBOL (nlist, &symbuf[symbuf_idx], objfile->obfd.get ());
+ OBJSTAT (objfile, n_stabs++);
+
+ symbuf_idx++;
+
+ return nlist.n_strx + key->ctx.stringtab_global
+ + key->ctx.file_string_table_offset;
+}
+
+/* Read in all of the symbols for a given psymtab for real.
+ Be verbose about it if the user wants that. SELF is not NULL. */
+
+static void
+stabs_read_symtab (legacy_psymtab *self, struct objfile *objfile)
+{
+ gdb_assert (!self->readin);
+
+ if (LDSYMLEN (self) || self->number_of_dependencies)
+ {
+ next_symbol_text_func = dbx_next_symbol_text;
+ dbx_symfile_info *key = dbx_objfile_data_key.get (objfile);
+
+ {
+ scoped_restore restore_stabs_data = make_scoped_restore (&key->ctx.stabs_data);
+ gdb::unique_xmalloc_ptr<gdb_byte> data_holder;
+ if (DBX_STAB_SECTION (objfile))
+ {
+ key->ctx.stabs_data
+ = symfile_relocate_debug_section (objfile,
+ DBX_STAB_SECTION (objfile),
+ NULL);
+ data_holder.reset (key->ctx.stabs_data);
+ }
+
+ self->expand_psymtab (objfile);
+ }
+
+ /* Match with global symbols. This only needs to be done once,
+ after all of the symtabs and dependencies have been read in. */
+ scan_file_globals (objfile);
+ }
+}
+
+static void
+record_minimal_symbol (minimal_symbol_reader &reader,
+ const char *name, unrelocated_addr address, int type,
+ struct objfile *objfile)
+{
+ enum minimal_symbol_type ms_type;
+ int section;
+ struct dbx_symfile_info *key = dbx_objfile_data_key.get (objfile);
+
+ switch (type)
+ {
+ case N_TEXT | N_EXT:
+ ms_type = mst_text;
+ section = SECT_OFF_TEXT (objfile);
+ break;
+ case N_DATA | N_EXT:
+ ms_type = mst_data;
+ section = SECT_OFF_DATA (objfile);
+ break;
+ case N_BSS | N_EXT:
+ ms_type = mst_bss;
+ section = SECT_OFF_BSS (objfile);
+ break;
+ case N_ABS | N_EXT:
+ ms_type = mst_abs;
+ section = -1;
+ break;
+#ifdef N_SETV
+ case N_SETV | N_EXT:
+ ms_type = mst_data;
+ section = SECT_OFF_DATA (objfile);
+ break;
+ case N_SETV:
+ /* I don't think this type actually exists; since a N_SETV is the result
+ of going over many .o files, it doesn't make sense to have one
+ file local. */
+ ms_type = mst_file_data;
+ section = SECT_OFF_DATA (objfile);
+ break;
+#endif
+ case N_TEXT:
+ case N_NBTEXT:
+ case N_FN:
+ case N_FN_SEQ:
+ ms_type = mst_file_text;
+ section = SECT_OFF_TEXT (objfile);
+ break;
+ case N_DATA:
+ ms_type = mst_file_data;
+
+ /* Check for __DYNAMIC, which is used by Sun shared libraries.
+ Record it as global even if it's local, not global, so
+ lookup_minimal_symbol can find it. We don't check symbol_leading_char
+ because for SunOS4 it always is '_'. */
+ if (strcmp ("__DYNAMIC", name) == 0)
+ ms_type = mst_data;
+
+ /* Same with virtual function tables, both global and static. */
+ {
+ const char *tempstring = name;
+
+ if (*tempstring != '\0'
+ && *tempstring == bfd_get_symbol_leading_char (objfile->obfd.get ()))
+ ++tempstring;
+ if (is_vtable_name (tempstring))
+ ms_type = mst_data;
+ }
+ section = SECT_OFF_DATA (objfile);
+ break;
+ case N_BSS:
+ ms_type = mst_file_bss;
+ section = SECT_OFF_BSS (objfile);
+ break;
+ default:
+ ms_type = mst_unknown;
+ section = -1;
+ break;
+ }
+
+ if ((ms_type == mst_file_text || ms_type == mst_text)
+ && address < key->ctx.lowest_text_address)
+ key->ctx.lowest_text_address = address;
+
+ reader.record_with_info (name, address, ms_type, section);
+}
+
+/* Given a name, value pair, find the corresponding
+ bincl in the list. Return the partial symtab associated
+ with that header_file_location. */
+
+static legacy_psymtab *
+find_corresponding_bincl_psymtab (const char *name, int instance,
+ struct objfile* objfile)
+{
+ stabsread_context ctx = dbx_objfile_data_key.get (objfile) -> ctx;
+ for (const header_file_location &bincl : ctx.bincl_list)
+ if (bincl.instance == instance
+ && strcmp (name, bincl.name) == 0)
+ return bincl.pst;
+
+ repeated_header_complaint (name, symnum);
+ return (legacy_psymtab *) 0;
+}
+
+/* Allocate and partially fill a partial symtab. It will be
+ completely filled at the end of the symbol list.
+
+ SYMFILE_NAME is the name of the symbol-file we are reading from, and ADDR
+ is the address relative to which its symbols are (incremental) or 0
+ (normal). */
+
+static legacy_psymtab *
+start_psymtab (psymtab_storage *partial_symtabs, struct objfile *objfile,
+ const char *filename, unrelocated_addr textlow, int ldsymoff)
+{
+ legacy_psymtab *result = new legacy_psymtab (filename, partial_symtabs,
+ objfile->per_bfd, textlow);
+
+ struct dbx_symfile_info *key = dbx_objfile_data_key.get(objfile);
+
+ result->read_symtab_private =
+ XOBNEW (&objfile->objfile_obstack, struct symloc);
+ LDSYMOFF (result) = ldsymoff;
+ result->legacy_read_symtab = stabs_read_symtab;
+ result->legacy_expand_psymtab = dbx_expand_psymtab;
+ SYMBOL_SIZE (result) = key->ctx.symbol_size;
+ SYMBOL_OFFSET (result) = key->ctx.symbol_table_offset;
+ STRING_OFFSET (result) = 0; /* This used to be an uninitialized global. */
+ FILE_STRING_OFFSET (result) = key->ctx.file_string_table_offset;
+
+ /* Deduce the source language from the filename for this psymtab. */
+ key->ctx.psymtab_language = deduce_language_from_filename (filename);
+ PST_LANGUAGE (result) = key->ctx.psymtab_language;
+
+ return result;
+}
+
+/* See stabsread.h. */
+
+static void
+read_stabs_symtab_1 (minimal_symbol_reader &reader,
+ psymtab_storage *partial_symtabs,
+ struct objfile *objfile)
+{
+ struct gdbarch *gdbarch = objfile->arch ();
+ struct external_nlist *bufp = 0; /* =0 avoids gcc -Wall glitch. */
+ struct internal_nlist nlist;
+ CORE_ADDR text_addr;
+ int text_size;
+ const char *sym_name;
+ int sym_len;
+ unsigned int next_file_string_table_offset = 0;
+ struct dbx_symfile_info *dbx = dbx_objfile_data_key.get(objfile);
+
+ const char *namestring;
+ int nsl;
+ int past_first_source_file = 0;
+ CORE_ADDR last_function_start = 0;
+ bfd *abfd;
+ int textlow_not_set;
+ int data_sect_index;
+
+ /* Current partial symtab. */
+ legacy_psymtab *pst;
+
+ /* List of current psymtab's include files. */
+ const char **psymtab_include_list;
+ int includes_allocated;
+ int includes_used;
+
+ /* Index within current psymtab dependency list. */
+ legacy_psymtab **dependency_list;
+ int dependencies_used, dependencies_allocated;
+
+ text_addr = DBX_TEXT_ADDR (objfile);
+ text_size = DBX_TEXT_SIZE (objfile);
+
+ /* FIXME. We probably want to change stringtab_global rather than add this
+ while processing every symbol entry. FIXME. */
+ dbx->ctx.file_string_table_offset = 0;
+
+ dbx->ctx.stringtab_global = DBX_STRINGTAB (objfile);
+
+ pst = (legacy_psymtab *) 0;
+
+ includes_allocated = 30;
+ includes_used = 0;
+ psymtab_include_list = (const char **) alloca (includes_allocated *
+ sizeof (const char *));
+
+ dependencies_allocated = 30;
+ dependencies_used = 0;
+ dependency_list =
+ (legacy_psymtab **) alloca (dependencies_allocated *
+ sizeof (legacy_psymtab *));
+
+ /* Init bincl list */
+ std::vector<struct header_file_location> bincl_storage;
+ scoped_restore restore_bincl_global
+ = make_scoped_restore (&(dbx->ctx.bincl_list), bincl_storage);
+
+ set_last_source_file (NULL);
+
+ dbx->ctx.lowest_text_address = (unrelocated_addr) -1;
+
+ abfd = objfile->obfd.get ();
+ symbuf_end = symbuf_idx = 0;
+ next_symbol_text_func = dbx_next_symbol_text;
+ textlow_not_set = 1;
+ dbx->ctx.has_line_numbers = 0;
+
+ /* FIXME: jimb/2003-09-12: We don't apply the right section's offset
+ to global and static variables. The stab for a global or static
+ variable doesn't give us any indication of which section it's in,
+ so we can't tell immediately which offset in
+ objfile->section_offsets we should apply to the variable's
+ address.
+
+ We could certainly find out which section contains the variable
+ by looking up the variable's unrelocated address with
+ find_pc_section, but that would be expensive; this is the
+ function that constructs the partial symbol tables by examining
+ every symbol in the entire executable, and it's
+ performance-critical. So that expense would not be welcome. I'm
+ not sure what to do about this at the moment.
+
+ What we have done for years is to simply assume that the .data
+ section's offset is appropriate for all global and static
+ variables. Recently, this was expanded to fall back to the .bss
+ section's offset if there is no .data section, and then to the
+ .rodata section's offset. */
+ data_sect_index = objfile->sect_index_data;
+ if (data_sect_index == -1)
+ data_sect_index = SECT_OFF_BSS (objfile);
+ if (data_sect_index == -1)
+ data_sect_index = SECT_OFF_RODATA (objfile);
+
+ /* If data_sect_index is still -1, that's okay. It's perfectly fine
+ for the file to have no .data, no .bss, and no .text at all, if
+ it also has no global or static variables. */
+
+ for (symnum = 0; symnum < DBX_SYMCOUNT (objfile); symnum++)
+ {
+ /* Get the symbol for this run and pull out some info. */
+ QUIT; /* Allow this to be interruptable. */
+ if (symbuf_idx == symbuf_end)
+ fill_symbuf (abfd, objfile);
+ bufp = &symbuf[symbuf_idx++];
+
+ /*
+ * Special case to speed up readin.
+ */
+ if (bfd_h_get_8 (abfd, bufp->e_type) == N_SLINE)
+ {
+ dbx->ctx.has_line_numbers = 1;
+ continue;
+ }
+
+ INTERNALIZE_SYMBOL (nlist, bufp, abfd);
+ OBJSTAT (objfile, n_stabs++);
+
+ /* Ok. There is a lot of code duplicated in the rest of this
+ switch statement (for efficiency reasons). Since I don't
+ like duplicating code, I will do my penance here, and
+ describe the code which is duplicated:
+
+ *) The assignment to namestring.
+ *) The call to strchr.
+ *) The addition of a partial symbol the two partial
+ symbol lists. This last is a large section of code, so
+ I've embedded it in the following macro. */
+
+ switch (nlist.n_type)
+ {
+ /*
+ * Standard, external, non-debugger, symbols
+ */
+
+ case N_TEXT | N_EXT:
+ case N_NBTEXT | N_EXT:
+ goto record_it;
+
+ case N_DATA | N_EXT:
+ case N_NBDATA | N_EXT:
+ goto record_it;
+
+ case N_BSS:
+ case N_BSS | N_EXT:
+ case N_NBBSS | N_EXT:
+ case N_SETV | N_EXT: /* FIXME, is this in BSS? */
+ goto record_it;
+
+ case N_ABS | N_EXT:
+ record_it:
+ namestring = set_namestring (objfile, &nlist);
+
+ record_minimal_symbol (reader, namestring,
+ unrelocated_addr (nlist.n_value),
+ nlist.n_type, objfile); /* Always */
+ continue;
+
+ /* Standard, local, non-debugger, symbols. */
+
+ case N_NBTEXT:
+
+ /* We need to be able to deal with both N_FN or N_TEXT,
+ because we have no way of knowing whether the sys-supplied ld
+ or GNU ld was used to make the executable. Sequents throw
+ in another wrinkle -- they renumbered N_FN. */
+
+ case N_FN:
+ case N_FN_SEQ:
+ case N_TEXT:
+ namestring = set_namestring (objfile, &nlist);
+
+ if ((namestring[0] == '-' && namestring[1] == 'l')
+ || (namestring[(nsl = strlen (namestring)) - 1] == 'o'
+ && namestring[nsl - 2] == '.'))
+ {
+ unrelocated_addr unrel_val = unrelocated_addr (nlist.n_value);
+
+ if (past_first_source_file && pst
+ /* The gould NP1 uses low values for .o and -l symbols
+ which are not the address. */
+ && unrel_val >= pst->unrelocated_text_low ())
+ {
+ stabs_end_psymtab (objfile, partial_symtabs,
+ pst, psymtab_include_list,
+ includes_used, symnum * dbx->ctx.symbol_size,
+ unrel_val > pst->unrelocated_text_high ()
+ ? unrel_val : pst->unrelocated_text_high (),
+ dependency_list, dependencies_used,
+ textlow_not_set);
+ pst = (legacy_psymtab *) 0;
+ includes_used = 0;
+ dependencies_used = 0;
+ dbx->ctx.has_line_numbers = 0;
+ }
+ else
+ past_first_source_file = 1;
+ }
+ else
+ goto record_it;
+ continue;
+
+ case N_DATA:
+ goto record_it;
+
+ case N_UNDF | N_EXT:
+ /* The case (nlist.n_value != 0) is a "Fortran COMMON" symbol.
+ We used to rely on the target to tell us whether it knows
+ where the symbol has been relocated to, but none of the
+ target implementations actually provided that operation.
+ So we just ignore the symbol, the same way we would do if
+ we had a target-side symbol lookup which returned no match.
+
+ All other symbols (with nlist.n_value == 0), are really
+ undefined, and so we ignore them too. */
+ continue;
+
+ case N_UNDF:
+ if (dbx->ctx.processing_acc_compilation && nlist.n_strx == 1)
+ {
+ /* Deal with relative offsets in the string table
+ used in ELF+STAB under Solaris. If we want to use the
+ n_strx field, which contains the name of the file,
+ we must adjust file_string_table_offset *before* calling
+ set_namestring(). */
+ past_first_source_file = 1;
+ dbx->ctx.file_string_table_offset = next_file_string_table_offset;
+ next_file_string_table_offset =
+ dbx->ctx.file_string_table_offset + nlist.n_value;
+ if (next_file_string_table_offset < dbx->ctx.file_string_table_offset)
+ error (_("string table offset backs up at %d"), symnum);
+ /* FIXME -- replace error() with complaint. */
+ continue;
+ }
+ continue;
+
+ /* Lots of symbol types we can just ignore. */
+
+ case N_ABS:
+ case N_NBDATA:
+ case N_NBBSS:
+ continue;
+
+ /* Keep going . . . */
+
+ /*
+ * Special symbol types for GNU
+ */
+ case N_INDR:
+ case N_INDR | N_EXT:
+ case N_SETA:
+ case N_SETA | N_EXT:
+ case N_SETT:
+ case N_SETT | N_EXT:
+ case N_SETD:
+ case N_SETD | N_EXT:
+ case N_SETB:
+ case N_SETB | N_EXT:
+ case N_SETV:
+ continue;
+
+ /*
+ * Debugger symbols
+ */
+
+ case N_SO:
+ {
+ CORE_ADDR valu;
+ static int prev_so_symnum = -10;
+ static int first_so_symnum;
+ const char *p;
+ static const char *dirname_nso;
+ int prev_textlow_not_set;
+
+ valu = nlist.n_value;
+
+ prev_textlow_not_set = textlow_not_set;
+
+ /* A zero value is probably an indication for the SunPRO 3.0
+ compiler. stabs_end_psymtab explicitly tests for zero, so
+ don't relocate it. */
+
+ if (nlist.n_value == 0
+ && gdbarch_sofun_address_maybe_missing (gdbarch))
+ {
+ textlow_not_set = 1;
+ valu = 0;
+ }
+ else
+ textlow_not_set = 0;
+
+ past_first_source_file = 1;
+
+ if (prev_so_symnum != symnum - 1)
+ { /* Here if prev stab wasn't N_SO. */
+ first_so_symnum = symnum;
+
+ if (pst)
+ {
+ unrelocated_addr unrel_value = unrelocated_addr (valu);
+ stabs_end_psymtab (objfile, partial_symtabs,
+ pst, psymtab_include_list,
+ includes_used, symnum * dbx->ctx.symbol_size,
+ unrel_value > pst->unrelocated_text_high ()
+ ? unrel_value
+ : pst->unrelocated_text_high (),
+ dependency_list, dependencies_used,
+ prev_textlow_not_set);
+ pst = (legacy_psymtab *) 0;
+ includes_used = 0;
+ dependencies_used = 0;
+ dbx->ctx.has_line_numbers = 0;
+ }
+ }
+
+ prev_so_symnum = symnum;
+
+ /* End the current partial symtab and start a new one. */
+
+ namestring = set_namestring (objfile, &nlist);
+
+ /* Null name means end of .o file. Don't start a new one. */
+ if (*namestring == '\000')
+ continue;
+
+ /* Some compilers (including gcc) emit a pair of initial N_SOs.
+ The first one is a directory name; the second the file name.
+ If pst exists, is empty, and has a filename ending in '/',
+ we assume the previous N_SO was a directory name. */
+
+ p = lbasename (namestring);
+ if (p != namestring && *p == '\000')
+ {
+ /* Save the directory name SOs locally, then save it into
+ the psymtab when it's created below. */
+ dirname_nso = namestring;
+ continue;
+ }
+
+ /* Some other compilers (C++ ones in particular) emit useless
+ SOs for non-existant .c files. We ignore all subsequent SOs
+ that immediately follow the first. */
+
+ if (!pst)
+ {
+ pst = start_psymtab (partial_symtabs, objfile,
+ namestring,
+ unrelocated_addr (valu),
+ first_so_symnum * dbx->ctx.symbol_size);
+ pst->dirname = dirname_nso;
+ dirname_nso = NULL;
+ }
+ continue;
+ }
+
+ case N_BINCL:
+ {
+ enum language tmp_language;
+
+ /* Add this bincl to the bincl_list for future EXCLs. No
+ need to save the string; it'll be around until
+ read_stabs_symtab function returns. */
+
+ namestring = set_namestring (objfile, &nlist);
+ tmp_language = deduce_language_from_filename (namestring);
+
+ /* Only change the psymtab's language if we've learned
+ something useful (eg. tmp_language is not language_unknown).
+ In addition, to match what start_subfile does, never change
+ from C++ to C. */
+ if (tmp_language != language_unknown
+ && (tmp_language != language_c
+ || dbx->ctx.psymtab_language != language_cplus))
+ dbx->ctx.psymtab_language = tmp_language;
+
+ if (pst == NULL)
+ {
+ /* FIXME: we should not get here without a PST to work on.
+ Attempt to recover. */
+ complaint (_("N_BINCL %s not in entries for "
+ "any file, at symtab pos %d"),
+ namestring, symnum);
+ continue;
+ }
+ dbx->ctx.bincl_list.emplace_back (namestring, nlist.n_value, pst);
+
+ /* Mark down an include file in the current psymtab. */
+
+ goto record_include_file;
+ }
+
+ case N_SOL:
+ {
+ enum language tmp_language;
+
+ /* Mark down an include file in the current psymtab. */
+ namestring = set_namestring (objfile, &nlist);
+ tmp_language = deduce_language_from_filename (namestring);
+
+ /* Only change the psymtab's language if we've learned
+ something useful (eg. tmp_language is not language_unknown).
+ In addition, to match what start_subfile does, never change
+ from C++ to C. */
+ if (tmp_language != language_unknown
+ && (tmp_language != language_c
+ || dbx->ctx.psymtab_language != language_cplus))
+ dbx->ctx.psymtab_language = tmp_language;
+
+ /* In C++, one may expect the same filename to come round many
+ times, when code is coming alternately from the main file
+ and from inline functions in other files. So I check to see
+ if this is a file we've seen before -- either the main
+ source file, or a previously included file.
+
+ This seems to be a lot of time to be spending on N_SOL, but
+ things like "break c-exp.y:435" need to work (I
+ suppose the psymtab_include_list could be hashed or put
+ in a binary tree, if profiling shows this is a major hog). */
+ if (pst && filename_cmp (namestring, pst->filename) == 0)
+ continue;
+ {
+ int i;
+
+ for (i = 0; i < includes_used; i++)
+ if (filename_cmp (namestring, psymtab_include_list[i]) == 0)
+ {
+ i = -1;
+ break;
+ }
+ if (i == -1)
+ continue;
+ }
+
+ record_include_file:
+
+ psymtab_include_list[includes_used++] = namestring;
+ if (includes_used >= includes_allocated)
+ {
+ const char **orig = psymtab_include_list;
+
+ psymtab_include_list = (const char **)
+ alloca ((includes_allocated *= 2) * sizeof (const char *));
+ memcpy (psymtab_include_list, orig,
+ includes_used * sizeof (const char *));
+ }
+ continue;
+ }
+ case N_LSYM: /* Typedef or automatic variable. */
+ case N_STSYM: /* Data seg var -- static. */
+ case N_LCSYM: /* BSS " */
+ case N_ROSYM: /* Read-only data seg var -- static. */
+ case N_NBSTS: /* Gould nobase. */
+ case N_NBLCS: /* symbols. */
+ case N_FUN:
+ case N_GSYM: /* Global (extern) variable; can be
+ data or bss (sigh FIXME). */
+
+ /* Following may probably be ignored; I'll leave them here
+ for now (until I do Pascal and Modula 2 extensions). */
+
+ case N_PC: /* I may or may not need this; I
+ suspect not. */
+ case N_M2C: /* I suspect that I can ignore this here. */
+ case N_SCOPE: /* Same. */
+ {
+ const char *p;
+
+ namestring = set_namestring (objfile, &nlist);
+
+ /* See if this is an end of function stab. */
+ if (pst && nlist.n_type == N_FUN && *namestring == '\000')
+ {
+ unrelocated_addr valu;
+
+ /* It's value is the size (in bytes) of the function for
+ function relative stabs, or the address of the function's
+ end for old style stabs. */
+ valu = unrelocated_addr (nlist.n_value + last_function_start);
+ if (pst->unrelocated_text_high () == unrelocated_addr (0)
+ || valu > pst->unrelocated_text_high ())
+ pst->set_text_high (valu);
+ break;
+ }
+
+ p = (char *) strchr (namestring, ':');
+ if (!p)
+ continue; /* Not a debugging symbol. */
+
+ sym_len = 0;
+ sym_name = NULL; /* pacify "gcc -Werror" */
+ if (dbx->ctx.psymtab_language == language_cplus)
+ {
+ std::string name (namestring, p - namestring);
+ gdb::unique_xmalloc_ptr<char> new_name
+ = cp_canonicalize_string (name.c_str ());
+ if (new_name != nullptr)
+ {
+ sym_len = strlen (new_name.get ());
+ sym_name = obstack_strdup (&objfile->objfile_obstack,
+ new_name.get ());
+ }
+ }
+ else if (dbx->ctx.psymtab_language == language_c)
+ {
+ std::string name (namestring, p - namestring);
+ gdb::unique_xmalloc_ptr<char> new_name
+ = c_canonicalize_name (name.c_str ());
+ if (new_name != nullptr)
+ {
+ sym_len = strlen (new_name.get ());
+ sym_name = obstack_strdup (&objfile->objfile_obstack,
+ new_name.get ());
+ }
+ }
+
+ if (sym_len == 0)
+ {
+ sym_name = namestring;
+ sym_len = p - namestring;
+ }
+
+ /* Main processing section for debugging symbols which
+ the initial read through the symbol tables needs to worry
+ about. If we reach this point, the symbol which we are
+ considering is definitely one we are interested in.
+ p must also contain the (valid) index into the namestring
+ which indicates the debugging type symbol. */
+
+ switch (p[1])
+ {
+ case 'S':
+ if (pst != nullptr)
+ pst->add_psymbol (std::string_view (sym_name, sym_len), true,
+ VAR_DOMAIN, LOC_STATIC,
+ data_sect_index,
+ psymbol_placement::STATIC,
+ unrelocated_addr (nlist.n_value),
+ dbx->ctx.psymtab_language,
+ partial_symtabs, objfile);
+ else
+ complaint (_("static `%*s' appears to be defined "
+ "outside of all compilation units"),
+ sym_len, sym_name);
+ continue;
+
+ case 'G':
+ /* The addresses in these entries are reported to be
+ wrong. See the code that reads 'G's for symtabs. */
+ if (pst != nullptr)
+ pst->add_psymbol (std::string_view (sym_name, sym_len), true,
+ VAR_DOMAIN, LOC_STATIC,
+ data_sect_index,
+ psymbol_placement::GLOBAL,
+ unrelocated_addr (nlist.n_value),
+ dbx->ctx.psymtab_language,
+ partial_symtabs, objfile);
+ else
+ complaint (_("global `%*s' appears to be defined "
+ "outside of all compilation units"),
+ sym_len, sym_name);
+ continue;
+
+ case 'T':
+ /* When a 'T' entry is defining an anonymous enum, it
+ may have a name which is the empty string, or a
+ single space. Since they're not really defining a
+ symbol, those shouldn't go in the partial symbol
+ table. We do pick up the elements of such enums at
+ 'check_enum:', below. */
+ if (p >= namestring + 2
+ || (p == namestring + 1
+ && namestring[0] != ' '))
+ {
+ if (pst != nullptr)
+ pst->add_psymbol (std::string_view (sym_name, sym_len),
+ true, STRUCT_DOMAIN, LOC_TYPEDEF, -1,
+ psymbol_placement::STATIC,
+ unrelocated_addr (0),
+ dbx->ctx.psymtab_language,
+ partial_symtabs, objfile);
+ else
+ complaint (_("enum, struct, or union `%*s' appears "
+ "to be defined outside of all "
+ "compilation units"),
+ sym_len, sym_name);
+ if (p[2] == 't')
+ {
+ /* Also a typedef with the same name. */
+ if (pst != nullptr)
+ pst->add_psymbol (std::string_view (sym_name, sym_len),
+ true, VAR_DOMAIN, LOC_TYPEDEF, -1,
+ psymbol_placement::STATIC,
+ unrelocated_addr (0),
+ dbx->ctx.psymtab_language,
+ partial_symtabs, objfile);
+ else
+ complaint (_("typedef `%*s' appears to be defined "
+ "outside of all compilation units"),
+ sym_len, sym_name);
+ p += 1;
+ }
+ }
+ goto check_enum;
+
+ case 't':
+ if (p != namestring) /* a name is there, not just :T... */
+ {
+ if (pst != nullptr)
+ pst->add_psymbol (std::string_view (sym_name, sym_len),
+ true, VAR_DOMAIN, LOC_TYPEDEF, -1,
+ psymbol_placement::STATIC,
+ unrelocated_addr (0),
+ dbx->ctx.psymtab_language,
+ partial_symtabs, objfile);
+ else
+ complaint (_("typename `%*s' appears to be defined "
+ "outside of all compilation units"),
+ sym_len, sym_name);
+ }
+ check_enum:
+ /* If this is an enumerated type, we need to
+ add all the enum constants to the partial symbol
+ table. This does not cover enums without names, e.g.
+ "enum {a, b} c;" in C, but fortunately those are
+ rare. There is no way for GDB to find those from the
+ enum type without spending too much time on it. Thus
+ to solve this problem, the compiler needs to put out the
+ enum in a nameless type. GCC2 does this. */
+
+ /* We are looking for something of the form
+ <name> ":" ("t" | "T") [<number> "="] "e"
+ {<constant> ":" <value> ","} ";". */
+
+ /* Skip over the colon and the 't' or 'T'. */
+ p += 2;
+ /* This type may be given a number. Also, numbers can come
+ in pairs like (0,26). Skip over it. */
+ while ((*p >= '0' && *p <= '9')
+ || *p == '(' || *p == ',' || *p == ')'
+ || *p == '=')
+ p++;
+
+ if (*p++ == 'e')
+ {
+ /* The aix4 compiler emits extra crud before the members. */
+ if (*p == '-')
+ {
+ /* Skip over the type (?). */
+ while (*p != ':')
+ p++;
+
+ /* Skip over the colon. */
+ p++;
+ }
+
+ /* We have found an enumerated type. */
+ /* According to comments in read_enum_type
+ a comma could end it instead of a semicolon.
+ I don't know where that happens.
+ Accept either. */
+ while (*p && *p != ';' && *p != ',')
+ {
+ const char *q;
+
+ /* Check for and handle cretinous dbx symbol name
+ continuation! */
+ if (*p == '\\' || (*p == '?' && p[1] == '\0'))
+ p = next_symbol_text (objfile);
+
+ /* Point to the character after the name
+ of the enum constant. */
+ for (q = p; *q && *q != ':'; q++)
+ ;
+ /* Note that the value doesn't matter for
+ enum constants in psymtabs, just in symtabs. */
+ if (pst != nullptr)
+ pst->add_psymbol (std::string_view (p, q - p), true,
+ VAR_DOMAIN, LOC_CONST, -1,
+ psymbol_placement::STATIC,
+ unrelocated_addr (0),
+ dbx->ctx.psymtab_language,
+ partial_symtabs, objfile);
+ else
+ complaint (_("enum constant `%*s' appears to be defined "
+ "outside of all compilation units"),
+ ((int) (q - p)), p);
+ /* Point past the name. */
+ p = q;
+ /* Skip over the value. */
+ while (*p && *p != ',')
+ p++;
+ /* Advance past the comma. */
+ if (*p)
+ p++;
+ }
+ }
+ continue;
+
+ case 'c':
+ /* Constant, e.g. from "const" in Pascal. */
+ if (pst != nullptr)
+ pst->add_psymbol (std::string_view (sym_name, sym_len), true,
+ VAR_DOMAIN, LOC_CONST, -1,
+ psymbol_placement::STATIC,
+ unrelocated_addr (0),
+ dbx->ctx.psymtab_language,
+ partial_symtabs, objfile);
+ else
+ complaint (_("constant `%*s' appears to be defined "
+ "outside of all compilation units"),
+ sym_len, sym_name);
+
+ continue;
+
+ case 'f':
+ if (! pst)
+ {
+ std::string name (namestring, (p - namestring));
+ function_outside_compilation_unit_complaint (name.c_str ());
+ }
+ /* Kludges for ELF/STABS with Sun ACC. */
+ dbx->ctx.last_function_name = namestring;
+ /* Do not fix textlow==0 for .o or NLM files, as 0 is a legit
+ value for the bottom of the text seg in those cases. */
+ if (nlist.n_value == 0
+ && gdbarch_sofun_address_maybe_missing (gdbarch))
+ {
+ bound_minimal_symbol minsym
+ = find_stab_function (namestring,
+ pst ? pst->filename : NULL, objfile);
+ if (minsym.minsym != NULL)
+ nlist.n_value
+ = CORE_ADDR (minsym.minsym->unrelocated_address ());
+ }
+ if (pst && textlow_not_set
+ && gdbarch_sofun_address_maybe_missing (gdbarch))
+ {
+ pst->set_text_low (unrelocated_addr (nlist.n_value));
+ textlow_not_set = 0;
+ }
+ /* End kludge. */
+
+ /* Keep track of the start of the last function so we
+ can handle end of function symbols. */
+ last_function_start = nlist.n_value;
+
+ /* In reordered executables this function may lie outside
+ the bounds created by N_SO symbols. If that's the case
+ use the address of this function as the low bound for
+ the partial symbol table. */
+ if (pst
+ && (textlow_not_set
+ || (unrelocated_addr (nlist.n_value)
+ < pst->unrelocated_text_low ()
+ && (nlist.n_value != 0))))
+ {
+ pst->set_text_low (unrelocated_addr (nlist.n_value));
+ textlow_not_set = 0;
+ }
+ if (pst != nullptr)
+ pst->add_psymbol (std::string_view (sym_name, sym_len), true,
+ VAR_DOMAIN, LOC_BLOCK,
+ SECT_OFF_TEXT (objfile),
+ psymbol_placement::STATIC,
+ unrelocated_addr (nlist.n_value),
+ dbx->ctx.psymtab_language,
+ partial_symtabs, objfile);
+ continue;
+
+ /* Global functions were ignored here, but now they
+ are put into the global psymtab like one would expect.
+ They're also in the minimal symbol table. */
+ case 'F':
+ if (! pst)
+ {
+ std::string name (namestring, (p - namestring));
+ function_outside_compilation_unit_complaint (name.c_str ());
+ }
+ /* Kludges for ELF/STABS with Sun ACC. */
+ dbx->ctx.last_function_name = namestring;
+ /* Do not fix textlow==0 for .o or NLM files, as 0 is a legit
+ value for the bottom of the text seg in those cases. */
+ if (nlist.n_value == 0
+ && gdbarch_sofun_address_maybe_missing (gdbarch))
+ {
+ bound_minimal_symbol minsym
+ = find_stab_function (namestring,
+ pst ? pst->filename : NULL, objfile);
+ if (minsym.minsym != NULL)
+ nlist.n_value
+ = CORE_ADDR (minsym.minsym->unrelocated_address ());
+ }
+ if (pst && textlow_not_set
+ && gdbarch_sofun_address_maybe_missing (gdbarch))
+ {
+ pst->set_text_low (unrelocated_addr (nlist.n_value));
+ textlow_not_set = 0;
+ }
+ /* End kludge. */
+
+ /* Keep track of the start of the last function so we
+ can handle end of function symbols. */
+ last_function_start = nlist.n_value;
+
+ /* In reordered executables this function may lie outside
+ the bounds created by N_SO symbols. If that's the case
+ use the address of this function as the low bound for
+ the partial symbol table. */
+ if (pst
+ && (textlow_not_set
+ || (unrelocated_addr (nlist.n_value)
+ < pst->unrelocated_text_low ()
+ && (nlist.n_value != 0))))
+ {
+ pst->set_text_low (unrelocated_addr (nlist.n_value));
+ textlow_not_set = 0;
+ }
+ if (pst != nullptr)
+ pst->add_psymbol (std::string_view (sym_name, sym_len), true,
+ VAR_DOMAIN, LOC_BLOCK,
+ SECT_OFF_TEXT (objfile),
+ psymbol_placement::GLOBAL,
+ unrelocated_addr (nlist.n_value),
+ dbx->ctx.psymtab_language,
+ partial_symtabs, objfile);
+ continue;
+
+ /* Two things show up here (hopefully); static symbols of
+ local scope (static used inside braces) or extensions
+ of structure symbols. We can ignore both. */
+ case 'V':
+ case '(':
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case '-':
+ case '#': /* For symbol identification (used in live ranges). */
+ continue;
+
+ case ':':
+ /* It is a C++ nested symbol. We don't need to record it
+ (I don't think); if we try to look up foo::bar::baz,
+ then symbols for the symtab containing foo should get
+ read in, I think. */
+ /* Someone says sun cc puts out symbols like
+ /foo/baz/maclib::/usr/local/bin/maclib,
+ which would get here with a symbol type of ':'. */
+ continue;
+
+ default:
+ /* Unexpected symbol descriptor. The second and subsequent stabs
+ of a continued stab can show up here. The question is
+ whether they ever can mimic a normal stab--it would be
+ nice if not, since we certainly don't want to spend the
+ time searching to the end of every string looking for
+ a backslash. */
+
+ complaint (_("unknown symbol descriptor `%c'"),
+ p[1]);
+
+ /* Ignore it; perhaps it is an extension that we don't
+ know about. */
+ continue;
+ }
+ }
+
+ case N_EXCL:
+
+ namestring = set_namestring (objfile, &nlist);
+
+ /* Find the corresponding bincl and mark that psymtab on the
+ psymtab dependency list. */
+ {
+ legacy_psymtab *needed_pst =
+ find_corresponding_bincl_psymtab (namestring, nlist.n_value, objfile);
+
+ /* If this include file was defined earlier in this file,
+ leave it alone. */
+ if (needed_pst == pst)
+ continue;
+
+ if (needed_pst)
+ {
+ int i;
+ int found = 0;
+
+ for (i = 0; i < dependencies_used; i++)
+ if (dependency_list[i] == needed_pst)
+ {
+ found = 1;
+ break;
+ }
+
+ /* If it's already in the list, skip the rest. */
+ if (found)
+ continue;
+
+ dependency_list[dependencies_used++] = needed_pst;
+ if (dependencies_used >= dependencies_allocated)
+ {
+ legacy_psymtab **orig = dependency_list;
+
+ dependency_list =
+ (legacy_psymtab **)
+ alloca ((dependencies_allocated *= 2)
+ * sizeof (legacy_psymtab *));
+ memcpy (dependency_list, orig,
+ (dependencies_used
+ * sizeof (legacy_psymtab *)));
+#ifdef DEBUG_INFO
+ gdb_printf (gdb_stderr,
+ "Had to reallocate "
+ "dependency list.\n");
+ gdb_printf (gdb_stderr,
+ "New dependencies allocated: %d\n",
+ dependencies_allocated);
+#endif
+ }
+ }
+ }
+ continue;
+
+ case N_ENDM:
+ /* Solaris 2 end of module, finish current partial symbol
+ table. stabs_end_psymtab will set the high text address of
+ PST to the proper value, which is necessary if a module
+ compiled without debugging info follows this module. */
+ if (pst && gdbarch_sofun_address_maybe_missing (gdbarch))
+ {
+ stabs_end_psymtab (objfile, partial_symtabs, pst,
+ psymtab_include_list, includes_used,
+ symnum * dbx->ctx.symbol_size,
+ (unrelocated_addr) 0, dependency_list,
+ dependencies_used, textlow_not_set);
+ pst = (legacy_psymtab *) 0;
+ includes_used = 0;
+ dependencies_used = 0;
+ dbx->ctx.has_line_numbers = 0;
+ }
+ continue;
+
+ case N_RBRAC:
+#ifdef HANDLE_RBRAC
+ HANDLE_RBRAC (nlist.n_value);
+ continue;
+#endif
+ case N_EINCL:
+ case N_DSLINE:
+ case N_BSLINE:
+ case N_SSYM: /* Claim: Structure or union element.
+ Hopefully, I can ignore this. */
+ case N_ENTRY: /* Alternate entry point; can ignore. */
+ case N_MAIN: /* Can definitely ignore this. */
+ case N_CATCH: /* These are GNU C++ extensions */
+ case N_EHDECL: /* that can safely be ignored here. */
+ case N_LENG:
+ case N_BCOMM:
+ case N_ECOMM:
+ case N_ECOML:
+ case N_FNAME:
+ case N_SLINE:
+ case N_RSYM:
+ case N_PSYM:
+ case N_BNSYM:
+ case N_ENSYM:
+ case N_LBRAC:
+ case N_NSYMS: /* Ultrix 4.0: symbol count */
+ case N_DEFD: /* GNU Modula-2 */
+ case N_ALIAS: /* SunPro F77: alias name, ignore for now. */
+
+ case N_OBJ: /* Useless types from Solaris. */
+ case N_OPT:
+ case N_PATCH:
+ /* These symbols aren't interesting; don't worry about them. */
+ continue;
+
+ default:
+ /* If we haven't found it yet, ignore it. It's probably some
+ new type we don't know about yet. */
+ unknown_symtype_complaint (hex_string (nlist.n_type));
+ continue;
+ }
+ }
+
+ /* If there's stuff to be cleaned up, clean it up. */
+ if (pst)
+ {
+ /* Don't set high text address of PST lower than it already
+ is. */
+ unrelocated_addr text_end
+ = (unrelocated_addr
+ ((dbx->ctx.lowest_text_address == (unrelocated_addr) -1
+ ? text_addr
+ : CORE_ADDR (dbx->ctx.lowest_text_address))
+ + text_size));
+
+ stabs_end_psymtab (objfile, partial_symtabs,
+ pst, psymtab_include_list, includes_used,
+ symnum * dbx->ctx.symbol_size,
+ (text_end > pst->unrelocated_text_high ()
+ ? text_end : pst->unrelocated_text_high ()),
+ dependency_list, dependencies_used, textlow_not_set);
+ }
+}
+
+/* Scan and build partial symbols for a symbol file.
+ We have been initialized by a call to dbx_symfile_init, which
+ put all the relevant info into a "struct dbx_symfile_info",
+ hung off the objfile structure. */
+
+void
+read_stabs_symtab (struct objfile *objfile, symfile_add_flags symfile_flags)
+{
+ bfd *sym_bfd;
+ int val;
+ struct dbx_symfile_info *key = dbx_objfile_data_key.get (objfile);
+
+ sym_bfd = objfile->obfd.get ();
+
+ /* .o and .nlm files are relocatables with text, data and bss segs based at
+ 0. This flag disables special (Solaris stabs-in-elf only) fixups for
+ symbols with a value of 0. */
+
+ key->ctx.symfile_relocatable = bfd_get_file_flags (sym_bfd) & HAS_RELOC;
+
+ val = bfd_seek (sym_bfd, DBX_SYMTAB_OFFSET (objfile), SEEK_SET);
+ if (val < 0)
+ perror_with_name (objfile_name (objfile));
+
+ key->ctx.symbol_size = DBX_SYMBOL_SIZE (objfile);
+ key->ctx.symbol_table_offset = DBX_SYMTAB_OFFSET (objfile);
+
+ scoped_free_pendings free_pending;
+
+ minimal_symbol_reader reader (objfile);
+
+ /* Read stabs data from executable file and define symbols. */
+
+ psymbol_functions *psf = new psymbol_functions ();
+ psymtab_storage *partial_symtabs = psf->get_partial_symtabs ().get ();
+ objfile->qf.emplace_front (psf);
+ read_stabs_symtab_1 (reader, partial_symtabs, objfile);
+
+ /* Install any minimal symbols that have been collected as the current
+ minimal symbols for this objfile. */
+
+ reader.install ();
+}
+
+/* Record the namespace that the function defined by SYMBOL was
+ defined in, if necessary. BLOCK is the associated block; use
+ OBSTACK for allocation. */
+
+static void
+cp_set_block_scope (const struct symbol *symbol,
+ struct block *block,
+ struct obstack *obstack)
+{
+ if (symbol->demangled_name () != NULL)
+ {
+ /* Try to figure out the appropriate namespace from the
+ demangled name. */
+
+ /* FIXME: carlton/2003-04-15: If the function in question is
+ a method of a class, the name will actually include the
+ name of the class as well. This should be harmless, but
+ is a little unfortunate. */
+
+ const char *name = symbol->demangled_name ();
+ unsigned int prefix_len = cp_entire_prefix_len (name);
+
+ block->set_scope (obstack_strndup (obstack, name, prefix_len),
+ obstack);
+ }
+}
+
+bound_minimal_symbol
+find_stab_function (const char *namestring, const char *filename,
+ struct objfile *objfile)
+{
+ int n;
+
+ const char *colon = strchr (namestring, ':');
+ if (colon == NULL)
+ n = 0;
+ else
+ n = colon - namestring;
+
+ char *p = (char *) alloca (n + 2);
+ strncpy (p, namestring, n);
+ p[n] = 0;
+
+ bound_minimal_symbol msym
+ = lookup_minimal_symbol (current_program_space, p, objfile, filename);
+ if (msym.minsym == NULL)
+ {
+ /* Sun Fortran appends an underscore to the minimal symbol name,
+ try again with an appended underscore if the minimal symbol
+ was not found. */
+ p[n] = '_';
+ p[n + 1] = 0;
+ msym
+ = lookup_minimal_symbol (current_program_space, p, objfile, filename);
+ }
+
+ if (msym.minsym == NULL && filename != NULL)
+ {
+ /* Try again without the filename. */
+ p[n] = 0;
+ msym = lookup_minimal_symbol (current_program_space, p, objfile);
+ }
+ if (msym.minsym == NULL && filename != NULL)
+ {
+ /* And try again for Sun Fortran, but without the filename. */
+ p[n] = '_';
+ p[n + 1] = 0;
+ msym = lookup_minimal_symbol (current_program_space, p, objfile);
+ }
+
+ return msym;
+}
+
+/* Add header file number I for this object file
+ at the next successive FILENUM. */
+
+static void
+add_this_object_header_file (int i)
+{
+ if (n_this_object_header_files == n_allocated_this_object_header_files)
+ {
+ n_allocated_this_object_header_files *= 2;
+ this_object_header_files
+ = (int *) xrealloc ((char *) this_object_header_files,
+ n_allocated_this_object_header_files * sizeof (int));
+ }
+
+ this_object_header_files[n_this_object_header_files++] = i;
+}
+
+/* Add to this file an "old" header file, one already seen in
+ a previous object file. NAME is the header file's name.
+ INSTANCE is its instance code, to select among multiple
+ symbol tables for the same header file. */
+
+static void
+add_old_header_file (const char *name, int instance, struct objfile *objfile)
+{
+ struct header_file *p = HEADER_FILES (objfile);
+ int i;
+
+ for (i = 0; i < N_HEADER_FILES (objfile); i++)
+ if (filename_cmp (p[i].name, name) == 0 && instance == p[i].instance)
+ {
+ add_this_object_header_file (i);
+ return;
+ }
+ repeated_header_complaint (name, symnum);
+}
+
+/* Add to this file a "new" header file: definitions for its types follow.
+ NAME is the header file's name.
+ Most often this happens only once for each distinct header file,
+ but not necessarily. If it happens more than once, INSTANCE has
+ a different value each time, and references to the header file
+ use INSTANCE values to select among them.
+
+ dbx output contains "begin" and "end" markers for each new header file,
+ but at this level we just need to know which files there have been;
+ so we record the file when its "begin" is seen and ignore the "end". */
+
+static void
+add_new_header_file (const char *name, int instance, struct objfile *objfile)
+{
+ int i;
+ struct header_file *hfile;
+
+ /* Make sure there is room for one more header file. */
+
+ i = N_ALLOCATED_HEADER_FILES (objfile);
+
+ if (N_HEADER_FILES (objfile) == i)
+ {
+ if (i == 0)
+ {
+ N_ALLOCATED_HEADER_FILES (objfile) = 10;
+ HEADER_FILES (objfile) = (struct header_file *)
+ xmalloc (10 * sizeof (struct header_file));
+ }
+ else
+ {
+ i *= 2;
+ N_ALLOCATED_HEADER_FILES (objfile) = i;
+ HEADER_FILES (objfile) = (struct header_file *)
+ xrealloc ((char *) HEADER_FILES (objfile),
+ (i * sizeof (struct header_file)));
+ }
+ }
+
+ /* Create an entry for this header file. */
+
+ i = N_HEADER_FILES (objfile)++;
+ hfile = HEADER_FILES (objfile) + i;
+ hfile->name = xstrdup (name);
+ hfile->instance = instance;
+ hfile->length = 10;
+ hfile->vector = XCNEWVEC (struct type *, 10);
+
+ add_this_object_header_file (i);
+}
+
+/* See stabsread.h. */
+
+void
+process_one_symbol (int type, int desc, CORE_ADDR valu, const char *name,
+ const section_offsets &section_offsets,
+ struct objfile *objfile, enum language language)
+{
+ struct gdbarch *gdbarch = objfile->arch ();
+ struct context_stack *newobj;
+ struct context_stack cstk;
+ /* This remembers the address of the start of a function. It is
+ used because in Solaris 2, N_LBRAC, N_RBRAC, and N_SLINE entries
+ are relative to the current function's start address. On systems
+ other than Solaris 2, this just holds the SECT_OFF_TEXT value,
+ and is used to relocate these symbol types rather than
+ SECTION_OFFSETS. */
+ static CORE_ADDR function_start_offset;
+
+ /* This holds the address of the start of a function, without the
+ system peculiarities of function_start_offset. */
+ static CORE_ADDR last_function_start;
+
+ /* If this is nonzero, we've seen an N_SLINE since the start of the
+ current function. We use this to tell us to move the first sline
+ to the beginning of the function regardless of what its given
+ value is. */
+ static int sline_found_in_function = 1;
+
+ /* If this is nonzero, we've seen a non-gcc N_OPT symbol for this
+ source file. Used to detect the SunPRO solaris compiler. */
+ static int n_opt_found;
+
+ /* The section index for this symbol. */
+ int section_index = -1;
+
+ struct dbx_symfile_info *key = dbx_objfile_data_key.get (objfile);
+
+ /* Something is wrong if we see real data before seeing a source
+ file name. */
+
+ if (get_last_source_file () == NULL && type != (unsigned char) N_SO)
+ {
+ /* Ignore any symbols which appear before an N_SO symbol.
+ Currently no one puts symbols there, but we should deal
+ gracefully with the case. A complain()t might be in order,
+ but this should not be an error (). */
+ return;
+ }
+
+ switch (type)
+ {
+ case N_FUN:
+ case N_FNAME:
+
+ if (*name == '\000')
+ {
+ /* This N_FUN marks the end of a function. This closes off
+ the current block. */
+ struct block *block;
+
+ if (outermost_context_p ())
+ {
+ lbrac_mismatch_complaint (symnum);
+ break;
+ }
+
+ /* The following check is added before recording line 0 at
+ end of function so as to handle hand-generated stabs
+ which may have an N_FUN stabs at the end of the function,
+ but no N_SLINE stabs. */
+ if (sline_found_in_function)
+ {
+ CORE_ADDR addr = last_function_start + valu;
+
+ record_line
+ (get_current_subfile (), 0,
+ unrelocated_addr (gdbarch_addr_bits_remove (gdbarch, addr)
+ - objfile->text_section_offset ()));
+ }
+
+ within_function = 0;
+ cstk = pop_context ();
+
+ /* Make a block for the local symbols within. */
+ block = finish_block (cstk.name,
+ cstk.old_blocks, NULL,
+ cstk.start_addr, cstk.start_addr + valu);
+
+ /* For C++, set the block's scope. */
+ if (cstk.name->language () == language_cplus)
+ cp_set_block_scope (cstk.name, block, &objfile->objfile_obstack);
+
+ /* May be switching to an assembler file which may not be using
+ block relative stabs, so reset the offset. */
+ function_start_offset = 0;
+
+ break;
+ }
+
+ sline_found_in_function = 0;
+
+ /* Relocate for dynamic loading. */
+ section_index = SECT_OFF_TEXT (objfile);
+ valu += section_offsets[SECT_OFF_TEXT (objfile)];
+ valu = gdbarch_addr_bits_remove (gdbarch, valu);
+ last_function_start = valu;
+
+ goto define_a_symbol;
+
+ case N_LBRAC:
+ /* This "symbol" just indicates the start of an inner lexical
+ context within a function. */
+
+ /* Ignore extra outermost context from SunPRO cc and acc. */
+ if (n_opt_found && desc == 1)
+ break;
+
+ valu += function_start_offset;
+
+ push_context (desc, valu);
+ break;
+
+ case N_RBRAC:
+ /* This "symbol" just indicates the end of an inner lexical
+ context that was started with N_LBRAC. */
+
+ /* Ignore extra outermost context from SunPRO cc and acc. */
+ if (n_opt_found && desc == 1)
+ break;
+
+ valu += function_start_offset;
+
+ if (outermost_context_p ())
+ {
+ lbrac_mismatch_complaint (symnum);
+ break;
+ }
+
+ cstk = pop_context ();
+ if (desc != cstk.depth)
+ lbrac_mismatch_complaint (symnum);
+
+ if (*get_local_symbols () != NULL)
+ {
+ /* GCC development snapshots from March to December of
+ 2000 would output N_LSYM entries after N_LBRAC
+ entries. As a consequence, these symbols are simply
+ discarded. Complain if this is the case. */
+ complaint (_("misplaced N_LBRAC entry; discarding local "
+ "symbols which have no enclosing block"));
+ }
+ *get_local_symbols () = cstk.locals;
+
+ if (get_context_stack_depth () > 1)
+ {
+ /* This is not the outermost LBRAC...RBRAC pair in the
+ function, its local symbols preceded it, and are the ones
+ just recovered from the context stack. Define the block
+ for them (but don't bother if the block contains no
+ symbols. Should we complain on blocks without symbols?
+ I can't think of any useful purpose for them). */
+ if (*get_local_symbols () != NULL)
+ {
+ /* Muzzle a compiler bug that makes end < start.
+
+ ??? Which compilers? Is this ever harmful?. */
+ if (cstk.start_addr > valu)
+ {
+ complaint (_("block start larger than block end"));
+ cstk.start_addr = valu;
+ }
+ /* Make a block for the local symbols within. */
+ finish_block (0, cstk.old_blocks, NULL,
+ cstk.start_addr, valu);
+ }
+ }
+ else
+ {
+ /* This is the outermost LBRAC...RBRAC pair. There is no
+ need to do anything; leave the symbols that preceded it
+ to be attached to the function's own block. We need to
+ indicate that we just moved outside of the function. */
+ within_function = 0;
+ }
+
+ break;
+
+ case N_FN:
+ case N_FN_SEQ:
+ /* This kind of symbol indicates the start of an object file.
+ Relocate for dynamic loading. */
+ section_index = SECT_OFF_TEXT (objfile);
+ valu += section_offsets[SECT_OFF_TEXT (objfile)];
+ break;
+
+ case N_SO:
+ /* This type of symbol indicates the start of data for one
+ source file. Finish the symbol table of the previous source
+ file (if any) and start accumulating a new symbol table.
+ Relocate for dynamic loading. */
+ section_index = SECT_OFF_TEXT (objfile);
+ valu += section_offsets[SECT_OFF_TEXT (objfile)];
+
+ n_opt_found = 0;
+
+ if (get_last_source_file ())
+ {
+ /* Check if previous symbol was also an N_SO (with some
+ sanity checks). If so, that one was actually the
+ directory name, and the current one is the real file
+ name. Patch things up. */
+ if (previous_stab_code == (unsigned char) N_SO)
+ {
+ patch_subfile_names (get_current_subfile (), name);
+ break; /* Ignore repeated SOs. */
+ }
+ end_compunit_symtab (valu);
+ end_stabs ();
+ }
+
+ /* Null name means this just marks the end of text for this .o
+ file. Don't start a new symtab in this case. */
+ if (*name == '\000')
+ break;
+
+ function_start_offset = 0;
+
+ start_stabs ();
+ start_compunit_symtab (objfile, name, NULL, valu, language);
+ record_debugformat ("stabs");
+ break;
+
+ case N_SOL:
+ /* This type of symbol indicates the start of data for a
+ sub-source-file, one whose contents were copied or included
+ in the compilation of the main source file (whose name was
+ given in the N_SO symbol). Relocate for dynamic loading. */
+ section_index = SECT_OFF_TEXT (objfile);
+ valu += section_offsets[SECT_OFF_TEXT (objfile)];
+ start_subfile (name);
+ break;
+
+ case N_BINCL:
+ push_subfile ();
+ add_new_header_file (name, valu, objfile);
+ start_subfile (name);
+ break;
+
+ case N_EINCL:
+ start_subfile (pop_subfile ());
+ break;
+
+ case N_EXCL:
+ add_old_header_file (name, valu, objfile);
+ break;
+
+ case N_SLINE:
+ /* This type of "symbol" really just records one line-number --
+ core-address correspondence. Enter it in the line list for
+ this symbol table. */
+
+ /* Relocate for dynamic loading and for ELF acc
+ function-relative symbols. */
+ valu += function_start_offset;
+
+ /* GCC 2.95.3 emits the first N_SLINE stab somewhere in the
+ middle of the prologue instead of right at the start of the
+ function. To deal with this we record the address for the
+ first N_SLINE stab to be the start of the function instead of
+ the listed location. We really shouldn't to this. When
+ compiling with optimization, this first N_SLINE stab might be
+ optimized away. Other (non-GCC) compilers don't emit this
+ stab at all. There is no real harm in having an extra
+ numbered line, although it can be a bit annoying for the
+ user. However, it totally screws up our testsuite.
+
+ So for now, keep adjusting the address of the first N_SLINE
+ stab, but only for code compiled with GCC. */
+
+ if (within_function && sline_found_in_function == 0)
+ {
+ CORE_ADDR addr = processing_gcc_compilation == 2 ?
+ last_function_start : valu;
+
+ record_line
+ (get_current_subfile (), desc,
+ unrelocated_addr (gdbarch_addr_bits_remove (gdbarch, addr)
+ - objfile->text_section_offset ()));
+ sline_found_in_function = 1;
+ }
+ else
+ record_line
+ (get_current_subfile (), desc,
+ unrelocated_addr (gdbarch_addr_bits_remove (gdbarch, valu)
+ - objfile->text_section_offset ()));
+ break;
+
+ case N_BCOMM:
+ common_block_start (name, objfile);
+ break;
+
+ case N_ECOMM:
+ common_block_end (objfile);
+ break;
+
+ /* The following symbol types need to have the appropriate
+ offset added to their value; then we process symbol
+ definitions in the name. */
+
+ case N_STSYM: /* Static symbol in data segment. */
+ case N_LCSYM: /* Static symbol in BSS segment. */
+ case N_ROSYM: /* Static symbol in read-only data segment. */
+ /* HORRID HACK DEPT. However, it's Sun's furgin' fault.
+ Solaris 2's stabs-in-elf makes *most* symbols relative but
+ leaves a few absolute (at least for Solaris 2.1 and version
+ 2.0.1 of the SunPRO compiler). N_STSYM and friends sit on
+ the fence. .stab "foo:S...",N_STSYM is absolute (ld
+ relocates it) .stab "foo:V...",N_STSYM is relative (section
+ base subtracted). This leaves us no choice but to search for
+ the 'S' or 'V'... (or pass the whole section_offsets stuff
+ down ONE MORE function call level, which we really don't want
+ to do). */
+ {
+ const char *p;
+
+ /* Normal object file and NLMs have non-zero text seg offsets,
+ but don't need their static syms offset in this fashion.
+ XXX - This is really a crock that should be fixed in the
+ solib handling code so that I don't have to work around it
+ here. */
+
+ if (!key->ctx.symfile_relocatable)
+ {
+ p = strchr (name, ':');
+ if (p != 0 && p[1] == 'S')
+ {
+ /* The linker relocated it. We don't want to add a
+ Sun-stabs Tfoo.foo-like offset, but we *do*
+ want to add whatever solib.c passed to
+ symbol_file_add as addr (this is known to affect
+ SunOS 4, and I suspect ELF too). Since there is no
+ Ttext.text symbol, we can get addr from the text offset. */
+ section_index = SECT_OFF_TEXT (objfile);
+ valu += section_offsets[SECT_OFF_TEXT (objfile)];
+ goto define_a_symbol;
+ }
+ }
+ /* Since it's not the kludge case, re-dispatch to the right
+ handler. */
+ switch (type)
+ {
+ case N_STSYM:
+ goto case_N_STSYM;
+ case N_LCSYM:
+ goto case_N_LCSYM;
+ case N_ROSYM:
+ goto case_N_ROSYM;
+ default:
+ internal_error (_("failed internal consistency check"));
+ }
+ }
+
+ case_N_STSYM: /* Static symbol in data segment. */
+ case N_DSLINE: /* Source line number, data segment. */
+ section_index = SECT_OFF_DATA (objfile);
+ valu += section_offsets[SECT_OFF_DATA (objfile)];
+ goto define_a_symbol;
+
+ case_N_LCSYM: /* Static symbol in BSS segment. */
+ case N_BSLINE: /* Source line number, BSS segment. */
+ /* N_BROWS: overlaps with N_BSLINE. */
+ section_index = SECT_OFF_BSS (objfile);
+ valu += section_offsets[SECT_OFF_BSS (objfile)];
+ goto define_a_symbol;
+
+ case_N_ROSYM: /* Static symbol in read-only data segment. */
+ section_index = SECT_OFF_RODATA (objfile);
+ valu += section_offsets[SECT_OFF_RODATA (objfile)];
+ goto define_a_symbol;
+
+ case N_ENTRY: /* Alternate entry point. */
+ /* Relocate for dynamic loading. */
+ section_index = SECT_OFF_TEXT (objfile);
+ valu += section_offsets[SECT_OFF_TEXT (objfile)];
+ goto define_a_symbol;
+
+ /* The following symbol types we don't know how to process.
+ Handle them in a "default" way, but complain to people who
+ care. */
+ default:
+ case N_CATCH: /* Exception handler catcher. */
+ case N_EHDECL: /* Exception handler name. */
+ case N_PC: /* Global symbol in Pascal. */
+ case N_M2C: /* Modula-2 compilation unit. */
+ /* N_MOD2: overlaps with N_EHDECL. */
+ case N_SCOPE: /* Modula-2 scope information. */
+ case N_ECOML: /* End common (local name). */
+ case N_NBTEXT: /* Gould Non-Base-Register symbols??? */
+ case N_NBDATA:
+ case N_NBBSS:
+ case N_NBSTS:
+ case N_NBLCS:
+ unknown_symtype_complaint (hex_string (type));
+
+ define_a_symbol:
+ [[fallthrough]];
+ /* These symbol types don't need the address field relocated,
+ since it is either unused, or is absolute. */
+ case N_GSYM: /* Global variable. */
+ case N_NSYMS: /* Number of symbols (Ultrix). */
+ case N_NOMAP: /* No map? (Ultrix). */
+ case N_RSYM: /* Register variable. */
+ case N_DEFD: /* Modula-2 GNU module dependency. */
+ case N_SSYM: /* Struct or union element. */
+ case N_LSYM: /* Local symbol in stack. */
+ case N_PSYM: /* Parameter variable. */
+ case N_LENG: /* Length of preceding symbol type. */
+ if (name)
+ {
+ int deftype;
+ const char *colon_pos = strchr (name, ':');
+
+ if (colon_pos == NULL)
+ deftype = '\0';
+ else
+ deftype = colon_pos[1];
+
+ switch (deftype)
+ {
+ case 'f':
+ case 'F':
+ /* Deal with the SunPRO 3.0 compiler which omits the
+ address from N_FUN symbols. */
+ if (type == N_FUN
+ && valu == section_offsets[SECT_OFF_TEXT (objfile)]
+ && gdbarch_sofun_address_maybe_missing (gdbarch))
+ {
+ bound_minimal_symbol minsym
+ = find_stab_function (name, get_last_source_file (),
+ objfile);
+ if (minsym.minsym != NULL)
+ valu = minsym.value_address ();
+ }
+
+ /* These addresses are absolute. */
+ function_start_offset = valu;
+
+ within_function = 1;
+
+ if (get_context_stack_depth () > 1)
+ {
+ complaint (_("unmatched N_LBRAC before symtab pos %d"),
+ symnum);
+ break;
+ }
+
+ if (!outermost_context_p ())
+ {
+ struct block *block;
+
+ cstk = pop_context ();
+ /* Make a block for the local symbols within. */
+ block = finish_block (cstk.name,
+ cstk.old_blocks, NULL,
+ cstk.start_addr, valu);
+
+ /* For C++, set the block's scope. */
+ if (cstk.name->language () == language_cplus)
+ cp_set_block_scope (cstk.name, block,
+ &objfile->objfile_obstack);
+ }
+
+ newobj = push_context (0, valu);
+ newobj->name = define_symbol (valu, name, desc, type, objfile);
+ if (newobj->name != nullptr)
+ newobj->name->set_section_index (section_index);
+ break;
+
+ default:
+ {
+ struct symbol *sym = define_symbol (valu, name, desc, type,
+ objfile);
+ if (sym != nullptr)
+ sym->set_section_index (section_index);
+ }
+ break;
+ }
+ }
+ break;
+
+ /* We use N_OPT to carry the gcc2_compiled flag. Sun uses it
+ for a bunch of other flags, too. Someday we may parse their
+ flags; for now we ignore theirs and hope they'll ignore ours. */
+ case N_OPT: /* Solaris 2: Compiler options. */
+ if (name)
+ {
+ if (strcmp (name, GCC2_COMPILED_FLAG_SYMBOL) == 0)
+ {
+ processing_gcc_compilation = 2;
+ }
+ else
+ n_opt_found = 1;
+ }
+ break;
+
+ case N_MAIN: /* Name of main routine. */
+ /* FIXME: If one has a symbol file with N_MAIN and then replaces
+ it with a symbol file with "main" and without N_MAIN. I'm
+ not sure exactly what rule to follow but probably something
+ like: N_MAIN takes precedence over "main" no matter what
+ objfile it is in; If there is more than one N_MAIN, choose
+ the one in the symfile_objfile; If there is more than one
+ N_MAIN within a given objfile, complain() and choose
+ arbitrarily. (kingdon) */
+ if (name != NULL)
+ set_objfile_main_name (objfile, name, language_unknown);
+ break;
+
+ /* The following symbol types can be ignored. */
+ case N_OBJ: /* Solaris 2: Object file dir and name. */
+ case N_PATCH: /* Solaris 2: Patch Run Time Checker. */
+ /* N_UNDF: Solaris 2: File separator mark. */
+ /* N_UNDF: -- we will never encounter it, since we only process
+ one file's symbols at once. */
+ case N_ENDM: /* Solaris 2: End of module. */
+ case N_ALIAS: /* SunPro F77: alias name, ignore for now. */
+ break;
+ }
+
+ /* '#' is a GNU C extension to allow one symbol to refer to another
+ related symbol.
+
+ Generally this is used so that an alias can refer to its main
+ symbol. */
+ gdb_assert (name);
+ if (name[0] == '#')
+ {
+ /* Initialize symbol reference names and determine if this is a
+ definition. If a symbol reference is being defined, go ahead
+ and add it. Otherwise, just return. */
+
+ const char *s = name;
+ int refnum;
+
+ /* If this stab defines a new reference ID that is not on the
+ reference list, then put it on the reference list.
+
+ We go ahead and advance NAME past the reference, even though
+ it is not strictly necessary at this time. */
+ refnum = symbol_reference_defined (&s);
+ if (refnum >= 0)
+ if (!ref_search (refnum))
+ ref_add (refnum, 0, name, valu);
+ name = s;
+ }
+
+ previous_stab_code = type;
+}
+
#define VISIBILITY_PRIVATE '0' /* Stabs character for private field */
#define VISIBILITY_PROTECTED '1' /* Stabs character for protected fld */
#define VISIBILITY_PUBLIC '2' /* Stabs character for public field */
@@ -2289,7 +4774,7 @@ read_member_functions (struct stab_field_info *fip, const char **pp,
if ((*pp)[0] == 'o' && (*pp)[1] == 'p' && is_cplus_marker ((*pp)[2]))
{
- /* This is a completely wierd case. In order to stuff in the
+ /* This is a completely weird case. In order to stuff in the
names that might contain colons (the usual name delimiter),
Mike Tiemann defined a different name format which is
signalled if the identifier is "op$". In that case, the
diff --git a/gdb/stabsread.h b/gdb/stabsread.h
index 0a86840..565038a 100644
--- a/gdb/stabsread.h
+++ b/gdb/stabsread.h
@@ -1,5 +1,5 @@
-/* Include file for stabs debugging format support functions.
- Copyright (C) 1986-2024 Free Software Foundation, Inc.
+ /* Include file for stabs debugging format support functions.
+ Copyright (C) 1986-2024 Free Software Foundation, Inc.
This file is part of GDB.
@@ -54,7 +54,7 @@ extern unsigned char processing_gcc_compilation;
extern int within_function;
/* Hash table of global symbols whose values are not known yet.
- They are chained thru the SYMBOL_VALUE_CHAIN, since we don't
+ They are chained through the SYMBOL_VALUE_CHAIN, since we don't
have the correct data for that slot yet.
The use of the LOC_BLOCK code in this chain is nonstandard--
@@ -173,7 +173,7 @@ class psymtab_storage;
/* Functions exported by dbxread.c. These are not in stabsread.c because
they are only used by some stabs readers. */
-extern legacy_psymtab *dbx_end_psymtab
+extern legacy_psymtab *stabs_end_psymtab
(struct objfile *objfile, psymtab_storage *partial_symtabs,
legacy_psymtab *pst,
const char **include_list, int num_includes,
@@ -185,6 +185,12 @@ extern void process_one_symbol (int, int, CORE_ADDR, const char *,
const section_offsets &,
struct objfile *, enum language);
+/* Setup partial_symtab's describing each source file for which
+ debugging information is available. */
+
+void
+read_stabs_symtab (struct objfile *, symfile_add_flags);
+
extern void elfstab_build_psymtabs (struct objfile *objfile,
asection *stabsect,
file_ptr stabstroffset,
@@ -215,4 +221,91 @@ extern void init_header_files (void);
extern void scan_file_globals (struct objfile *objfile);
+/* Complaints about the symbols we have encountered. */
+
+void
+unknown_symtype_complaint (const char *);
+
+void
+lbrac_mismatch_complaint (int);
+
+void
+repeated_header_complaint (const char *, int);
+
+bound_minimal_symbol
+find_stab_function (const char *, const char *, struct objfile *);
+
+/* This handles a single symbol from the symbol-file, building symbols
+ into a GDB symtab. It takes these arguments and an implicit argument.
+
+ TYPE is the type field of the ".stab" symbol entry.
+ DESC is the desc field of the ".stab" entry.
+ VALU is the value field of the ".stab" entry.
+ NAME is the symbol name, in our address space.
+ SECTION_OFFSETS is a set of amounts by which the sections of this
+ object file were relocated when it was loaded into memory. Note
+ that these section_offsets are not the objfile->section_offsets but
+ the pst->section_offsets. All symbols that refer to memory
+ locations need to be offset by these amounts.
+ OBJFILE is the object file from which we are reading symbols. It
+ is used in end_compunit_symtab.
+ LANGUAGE is the language of the symtab.
+*/
+
+void
+process_one_symbol (int, int, CORE_ADDR, const char *,
+ const section_offsets &,
+ struct objfile *, enum language);
+
+#define LDSYMOFF(p) (((struct symloc *)((p)->read_symtab_private))->ldsymoff)
+#define LDSYMLEN(p) (((struct symloc *)((p)->read_symtab_private))->ldsymlen)
+#define SYMLOC(p) ((struct symloc *)((p)->read_symtab_private))
+#define SYMBOL_SIZE(p) (SYMLOC(p)->symbol_size)
+#define SYMBOL_OFFSET(p) (SYMLOC(p)->symbol_offset)
+#define STRING_OFFSET(p) (SYMLOC(p)->string_offset)
+#define FILE_STRING_OFFSET(p) (SYMLOC(p)->file_string_offset)
+#define PST_LANGUAGE(p) (SYMLOC(p)->pst_language)
+
+#define INTERNALIZE_SYMBOL(intern, extern, abfd) \
+ { \
+ (intern).n_strx = bfd_h_get_32 (abfd, (extern)->e_strx); \
+ (intern).n_type = bfd_h_get_8 (abfd, (extern)->e_type); \
+ (intern).n_other = 0; \
+ (intern).n_desc = bfd_h_get_16 (abfd, (extern)->e_desc); \
+ if (bfd_get_sign_extend_vma (abfd)) \
+ (intern).n_value = bfd_h_get_signed_32 (abfd, (extern)->e_value); \
+ else \
+ (intern).n_value = bfd_h_get_32 (abfd, (extern)->e_value); \
+ }
+
+/* We put a pointer to this structure in the read_symtab_private field
+ of the psymtab. */
+
+struct symloc
+ {
+ /* Offset within the file symbol table of first local symbol for this
+ file. */
+
+ int ldsymoff;
+
+ /* Length (in bytes) of the section of the symbol table devoted to
+ this file's symbols (actually, the section bracketed may contain
+ more than just this file's symbols). If ldsymlen is 0, the only
+ reason for this thing's existence is the dependency list. Nothing
+ else will happen when it is read in. */
+
+ int ldsymlen;
+
+ /* The size of each symbol in the symbol file (in external form). */
+
+ int symbol_size;
+
+ /* Further information needed to locate the symbols if they are in
+ an ELF file. */
+
+ int symbol_offset;
+ int string_offset;
+ int file_string_offset;
+ enum language pst_language;
+ };
#endif /* STABSREAD_H */
diff --git a/gdb/stack.c b/gdb/stack.c
index b7a102e..4a3e7e4 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -50,7 +50,6 @@
#include "linespec.h"
#include "cli/cli-utils.h"
#include "objfiles.h"
-#include "annotate.h"
#include "symfile.h"
#include "extension.h"
@@ -1418,7 +1417,7 @@ print_frame (struct ui_out *uiout,
annotate_frame_source_file_end ();
uiout->text (":");
annotate_frame_source_line ();
- uiout->field_signed ("line", sal.line);
+ uiout->field_signed ("line", sal.line, line_number_style.style ());
annotate_frame_source_end ();
}
diff --git a/gdb/stubs/ia64vms-stub.c b/gdb/stubs/ia64vms-stub.c
index e7578d8..7e08119 100644
--- a/gdb/stubs/ia64vms-stub.c
+++ b/gdb/stubs/ia64vms-stub.c
@@ -210,7 +210,7 @@ union ia64_ireg
/* Predicate registers: There are 64 of these 1-bit registers. We
define a single register which is used to communicate these values
to/from the target. We will somehow contrive to make it appear
- that IA64_PR0_REGNUM thru IA64_PR63_REGNUM hold the actual values. */
+ that IA64_PR0_REGNUM through IA64_PR63_REGNUM hold the actual values. */
#define IA64_PR_REGNUM 330
/* Instruction pointer: 64 bits wide. */
@@ -311,7 +311,7 @@ term_raw_write (const char *str, unsigned int len)
LIB$SIGNAL (status);
}
-/* Flush ther term buffer. */
+/* Flush the term buffer. */
static void
term_flush (void)
diff --git a/gdb/stubs/m32r-stub.c b/gdb/stubs/m32r-stub.c
index 8ac71f1..16be231 100644
--- a/gdb/stubs/m32r-stub.c
+++ b/gdb/stubs/m32r-stub.c
@@ -975,7 +975,7 @@ isShortBranch (unsigned char *instr)
if (instr0 == 0x1E || instr0 == 0x1F) /* JL or JMP */
if ((instr[1] & 0xF0) == 0xC0)
- return 2; /* jump thru a register */
+ return 2; /* jump through a register. */
if (instr0 == 0x7C || instr0 == 0x7D || /* BC, BNC, BL, BRA */
instr0 == 0x7E || instr0 == 0x7F)
@@ -1088,7 +1088,7 @@ branchDestination (unsigned char *instr, int branchCode)
case 1: /* RTE */
return registers[BPC] & ~3; /* pop BPC into PC */
case 2: /* JL or JMP */
- return registers[instr[1] & 0x0F] & ~3; /* jump thru a register */
+ return registers[instr[1] & 0x0F] & ~3; /* jump through a register. */
case 3: /* BC, BNC, BL, BRA (short, 8-bit relative offset) */
return (((int) instr) & ~3) + ((char) instr[1] << 2);
case 4: /* BC, BNC, BL, BRA (long, 24-bit relative offset) */
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index 0eccda2..6bf8dc3 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -376,7 +376,8 @@ objfile::expand_symtabs_matching
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags,
- domain_search_flags domain)
+ domain_search_flags domain,
+ gdb::function_view<expand_symtabs_lang_matcher_ftype> lang_matcher)
{
/* This invariant is documented in quick-functions.h. */
gdb_assert (lookup_name != nullptr || symbol_matcher == nullptr);
@@ -393,7 +394,8 @@ objfile::expand_symtabs_matching
for (const auto &iter : qf)
if (!iter->expand_symtabs_matching (this, file_matcher, lookup_name,
symbol_matcher, expansion_notify,
- search_flags, domain))
+ search_flags, domain,
+ lang_matcher))
return false;
return true;
}
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 2292eca..1502fdb 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -3759,7 +3759,8 @@ expand_symtabs_matching
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags,
- domain_search_flags domain)
+ domain_search_flags domain,
+ gdb::function_view<expand_symtabs_lang_matcher_ftype> lang_matcher)
{
for (objfile *objfile : current_program_space->objfiles ())
if (!objfile->expand_symtabs_matching (file_matcher,
@@ -3767,7 +3768,8 @@ expand_symtabs_matching
symbol_matcher,
expansion_notify,
search_flags,
- domain))
+ domain,
+ lang_matcher))
return false;
return true;
}
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 508ba48..74187c8 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -352,7 +352,9 @@ bool expand_symtabs_matching
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
block_search_flags search_flags,
- domain_search_flags kind);
+ domain_search_flags kind,
+ gdb::function_view<expand_symtabs_lang_matcher_ftype> lang_matcher
+ = nullptr);
void map_symbol_filenames (gdb::function_view<symbol_filename_ftype> fun,
bool need_fullname);
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 7f81415..a484fb2 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -377,7 +377,9 @@ static void
maintenance_print_symbols (const char *args, int from_tty)
{
struct ui_file *outfile = gdb_stdout;
- char *address_arg = NULL, *source_arg = NULL, *objfile_arg = NULL;
+ const char *address_arg = nullptr;
+ const char *source_arg = nullptr;
+ const char *objfile_arg = nullptr;
int i, outfile_idx;
dont_repeat ();
@@ -655,7 +657,7 @@ static void
maintenance_print_msymbols (const char *args, int from_tty)
{
struct ui_file *outfile = gdb_stdout;
- char *objfile_arg = NULL;
+ const char *objfile_arg = nullptr;
int i, outfile_idx;
dont_repeat ();
@@ -887,7 +889,7 @@ maintenance_check_symtabs (const char *ignore, int from_tty)
static void
maintenance_expand_symtabs (const char *args, int from_tty)
{
- char *regexp = NULL;
+ const char *regexp = nullptr;
/* We use buildargv here so that we handle spaces in the regexp
in a way that allows adding more arguments later. */
@@ -903,18 +905,25 @@ maintenance_expand_symtabs (const char *args, int from_tty)
}
}
- if (regexp)
- re_comp (regexp);
+ if (regexp == nullptr)
+ {
+ for (struct program_space *pspace : program_spaces)
+ for (objfile *objfile : pspace->objfiles ())
+ objfile->expand_all_symtabs ();
+
+ return;
+ }
+
+ re_comp (regexp);
for (struct program_space *pspace : program_spaces)
for (objfile *objfile : pspace->objfiles ())
objfile->expand_symtabs_matching
([&] (const char *filename, bool basenames)
- {
- /* KISS: Only apply the regexp to the complete file name. */
- return (!basenames
- && (regexp == NULL || re_exec (filename)));
- },
+ {
+ /* KISS: Only apply the regexp to the complete file name. */
+ return !basenames && re_exec (filename);
+ },
NULL,
NULL,
NULL,
@@ -990,7 +999,8 @@ maintenance_print_one_line_table (struct symtab *symtab, void *data)
ui_out_emit_tuple tuple_emitter (uiout, nullptr);
uiout->field_signed ("index", i);
if (item->line > 0)
- uiout->field_signed ("line", item->line);
+ uiout->field_signed ("line", item->line,
+ line_number_style.style ());
else
uiout->field_string ("line", _("END"));
uiout->field_core_addr ("rel-address", objfile->arch (),
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 3d8dcac63..a479e92 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -700,15 +700,10 @@ iterate_over_some_symtabs (const char *name,
return false;
}
-/* Check for a symtab of a specific name; first in symtabs, then in
- psymtabs. *If* there is no '/' in the name, a match after a '/'
- in the symtab filename will also work.
-
- Calls CALLBACK with each symtab that is found. If CALLBACK returns
- true, the search stops. */
+/* See symtab.h. */
void
-iterate_over_symtabs (const char *name,
+iterate_over_symtabs (program_space *pspace, const char *name,
gdb::function_view<bool (symtab *)> callback)
{
gdb::unique_xmalloc_ptr<char> real_path;
@@ -721,34 +716,28 @@ iterate_over_symtabs (const char *name,
gdb_assert (IS_ABSOLUTE_PATH (real_path.get ()));
}
- for (objfile *objfile : current_program_space->objfiles ())
- {
- if (iterate_over_some_symtabs (name, real_path.get (),
- objfile->compunit_symtabs, NULL,
- callback))
+ for (objfile *objfile : pspace->objfiles ())
+ if (iterate_over_some_symtabs (name, real_path.get (),
+ objfile->compunit_symtabs, nullptr,
+ callback))
return;
- }
- /* Same search rules as above apply here, but now we look thru the
+ /* Same search rules as above apply here, but now we look through the
psymtabs. */
-
- for (objfile *objfile : current_program_space->objfiles ())
- {
- if (objfile->map_symtabs_matching_filename (name, real_path.get (),
- callback))
- return;
- }
+ for (objfile *objfile : pspace->objfiles ())
+ if (objfile->map_symtabs_matching_filename (name, real_path.get (),
+ callback))
+ return;
}
-/* A wrapper for iterate_over_symtabs that returns the first matching
- symtab, or NULL. */
+/* See symtab.h. */
-struct symtab *
-lookup_symtab (const char *name)
+symtab *
+lookup_symtab (program_space *pspace, const char *name)
{
struct symtab *result = NULL;
- iterate_over_symtabs (name, [&] (symtab *symtab)
+ iterate_over_symtabs (pspace, name, [&] (symtab *symtab)
{
result = symtab;
return true;
@@ -3003,7 +2992,7 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
section. */
}
- /* Cust is best found sofar, save it. */
+ /* Cust is best found so far, save it. */
best_cust = cust;
best_cust_range = range;
}
@@ -6317,7 +6306,7 @@ collect_file_symbol_completion_matches (completion_tracker &tracker,
/* Go through symtabs for SRCFILE and check the externs and statics
for symbols which match. */
- iterate_over_symtabs (srcfile, [&] (symtab *s)
+ iterate_over_symtabs (current_program_space, srcfile, [&] (symtab *s)
{
add_symtab_completions (s->compunit (),
tracker, mode, lookup_name,
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 5410f41..aa86a80 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -808,7 +808,7 @@ struct minimal_symbol : public general_symbol_info
m_target_flag_2 = target_flag_2;
}
- /* Size of this symbol. dbx_end_psymtab in dbxread.c uses this
+ /* Size of this symbol. stabs_end_psymtab in stabsread.c uses this
information to calculate the end of the partial symtab based on the
address of the last symbol plus the size of the last symbol. */
@@ -2089,9 +2089,9 @@ extern const char multiple_symbols_cancel[];
const char *multiple_symbols_select_mode (void);
-/* lookup a symbol table by source file name. */
+/* Lookup a symbol table in PSPACE by source file name. */
-extern struct symtab *lookup_symtab (const char *);
+extern symtab *lookup_symtab (program_space *pspace, const char *name);
/* An object of this type is passed as the 'is_a_field_of_this'
argument to lookup_symbol and lookup_symbol_in_language. */
@@ -2808,9 +2808,15 @@ bool iterate_over_some_symtabs (const char *name,
struct compunit_symtab *after_last,
gdb::function_view<bool (symtab *)> callback);
-void iterate_over_symtabs (const char *name,
- gdb::function_view<bool (symtab *)> callback);
+/* Check in PSPACE for a symtab of a specific name; first in symtabs, then in
+ psymtabs. *If* there is no '/' in the name, a match after a '/' in the
+ symtab filename will also work.
+
+ Call CALLBACK with each symtab that is found. If CALLBACK returns
+ true, the search stops. */
+void iterate_over_symtabs (program_space *pspace, const char *name,
+ gdb::function_view<bool (symtab *)> callback);
std::vector<CORE_ADDR> find_pcs_for_symtab_line
(struct symtab *symtab, int line, const linetable_entry **best_entry);
diff --git a/gdb/target-debug.h b/gdb/target-debug.h
index bba51eb..4a4e72e 100644
--- a/gdb/target-debug.h
+++ b/gdb/target-debug.h
@@ -368,8 +368,6 @@ target_debug_print_x86_xsave_layout (const x86_xsave_layout &layout)
string_appendf (s, ", " #region "_offset=%d", layout.region##_offset);
POFFS(avx);
- POFFS(bndregs);
- POFFS(bndcfg);
POFFS(k);
POFFS(zmm_h);
POFFS(zmm);
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index d78da14..1bd22c2 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -1200,12 +1200,6 @@ set_tdesc_architecture (struct target_desc *target_desc,
/* See gdbsupport/tdesc.h. */
void
-set_tdesc_osabi (struct target_desc *target_desc, const char *name)
-{
- set_tdesc_osabi (target_desc, osabi_from_tdesc_string (name));
-}
-
-void
set_tdesc_osabi (struct target_desc *target_desc, enum gdb_osabi osabi)
{
target_desc->osabi = osabi;
@@ -1317,9 +1311,8 @@ public:
if (tdesc_osabi (e) > GDB_OSABI_UNKNOWN
&& tdesc_osabi (e) < GDB_OSABI_INVALID)
{
- gdb_printf
- (" set_tdesc_osabi (result.get (), osabi_from_tdesc_string (\"%s\"));\n",
- gdbarch_osabi_name (tdesc_osabi (e)));
+ const char *enum_name = gdbarch_osabi_enum_name (tdesc_osabi (e));
+ gdb_printf (" set_tdesc_osabi (result.get (), %s);\n", enum_name);
gdb_printf ("\n");
}
diff --git a/gdb/target-descriptions.h b/gdb/target-descriptions.h
index d708dbd..dc83db0 100644
--- a/gdb/target-descriptions.h
+++ b/gdb/target-descriptions.h
@@ -219,7 +219,6 @@ int tdesc_register_in_reggroup_p (struct gdbarch *gdbarch, int regno,
void set_tdesc_architecture (struct target_desc *,
const struct bfd_arch_info *);
-void set_tdesc_osabi (struct target_desc *, enum gdb_osabi osabi);
void set_tdesc_property (struct target_desc *,
const char *key, const char *value);
void tdesc_add_compatible (struct target_desc *,
diff --git a/gdb/target.c b/gdb/target.c
index 47f09f5..4378c05 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -1754,7 +1754,7 @@ target_xfer_partial (struct target_ops *ops,
If an error occurs, no guarantee is made about the contents of the data at
MYADDR. In particular, the caller should not depend upon partial reads
filling the buffer with good data. There is no way for the caller to know
- how much good data might have been transfered anyway. Callers that can
+ how much good data might have been transferred anyway. Callers that can
deal with partial reads should call target_read (which will retry until
it makes no progress, and then return how much was transferred). */
@@ -2575,18 +2575,12 @@ target_wait (ptid_t ptid, struct target_waitstatus *status,
if (!target_can_async_p (target))
gdb_assert ((options & TARGET_WNOHANG) == 0);
- try
- {
- gdb::observers::target_pre_wait.notify (ptid);
- ptid_t event_ptid = target->wait (ptid, status, options);
- gdb::observers::target_post_wait.notify (event_ptid);
- return event_ptid;
- }
- catch (...)
- {
- gdb::observers::target_post_wait.notify (null_ptid);
- throw;
- }
+ ptid_t event_ptid = null_ptid;
+ SCOPE_EXIT { gdb::observers::target_post_wait.notify (event_ptid); };
+ gdb::observers::target_pre_wait.notify (ptid);
+ event_ptid = target->wait (ptid, status, options);
+
+ return event_ptid;
}
/* See target.h. */
diff --git a/gdb/target.h b/gdb/target.h
index dcf68a6..6da58c7 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -134,7 +134,7 @@ enum inferior_event_type
INF_EXEC_COMPLETE,
};
-/* Target objects which can be transfered using target_read,
+/* Target objects which can be transferred using target_read,
target_write, et cetera. */
enum target_object
@@ -156,7 +156,7 @@ enum target_object
TARGET_OBJECT_CODE_MEMORY,
/* Kernel Unwind Table. See "ia64-tdep.c". */
TARGET_OBJECT_UNWIND_TABLE,
- /* Transfer auxilliary vector. */
+ /* Transfer auxiliary vector. */
TARGET_OBJECT_AUXV,
/* StackGhost cookie. See "sparc-tdep.c". */
TARGET_OBJECT_WCOOKIE,
@@ -177,7 +177,7 @@ enum target_object
/* Currently loaded libraries specific to AIX systems, in XML format. */
TARGET_OBJECT_LIBRARIES_AIX,
/* Get OS specific data. The ANNEX specifies the type (running
- processes, etc.). The data being transfered is expected to follow
+ processes, etc.). The data being transferred is expected to follow
the DTD specified in features/osdata.dtd. */
TARGET_OBJECT_OSDATA,
/* Extra signal info. Usually the contents of `siginfo_t' on unix
@@ -821,7 +821,7 @@ struct target_ops
transferring if desired. This is handled in target.c.
The interface does not support a "retry" mechanism. Instead it
- assumes that at least one addressable unit will be transfered on each
+ assumes that at least one addressable unit will be transferred on each
successful call.
NOTE: cagney/2003-10-17: The current interface can lead to
diff --git a/gdb/testsuite/gdb.ada/array_of_variant.exp b/gdb/testsuite/gdb.ada/array_of_variant.exp
index f93260a..8b83f4e 100644
--- a/gdb/testsuite/gdb.ada/array_of_variant.exp
+++ b/gdb/testsuite/gdb.ada/array_of_variant.exp
@@ -20,7 +20,7 @@ require allow_ada_tests
standard_ada_testfile p
-set old_gcc [expr [test_compiler_info {gcc-[0-7]-*}]]
+set old_gcc [gnat_version_compare <= 7]
proc gdb_test_with_xfail { cmd re re_xfail msg } {
global scenario old_gcc
diff --git a/gdb/testsuite/gdb.ada/arrayidx.exp b/gdb/testsuite/gdb.ada/arrayidx.exp
index 051e82d..bc76cd3 100644
--- a/gdb/testsuite/gdb.ada/arrayidx.exp
+++ b/gdb/testsuite/gdb.ada/arrayidx.exp
@@ -23,8 +23,7 @@ if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} {
return -1
}
-set old_gcc [expr [test_compiler_info {gcc-[0-3]-*}] \
- || [test_compiler_info {gcc-4-[0-6]-*}]]
+set old_gcc [gnat_version_compare <= {4 6}]
clean_restart ${testfile}
diff --git a/gdb/testsuite/gdb.ada/arrayptr.exp b/gdb/testsuite/gdb.ada/arrayptr.exp
index 335573b..b8c2eab 100644
--- a/gdb/testsuite/gdb.ada/arrayptr.exp
+++ b/gdb/testsuite/gdb.ada/arrayptr.exp
@@ -55,7 +55,7 @@ foreach_gnat_encoding scenario flags {all minimal} {
# GNAT >= 12.0 has the needed fix here.
set xfail_expected 0
- if {$scenario == "minimal" && ![test_compiler_info {gcc-1[2-9]-*}]} {
+ if {$scenario == "minimal" && [gnat_version_compare < 12]} {
set xfail_expected 1
}
diff --git a/gdb/testsuite/gdb.ada/big_packed_array.exp b/gdb/testsuite/gdb.ada/big_packed_array.exp
index 0078c77..33b1dfd 100644
--- a/gdb/testsuite/gdb.ada/big_packed_array.exp
+++ b/gdb/testsuite/gdb.ada/big_packed_array.exp
@@ -19,7 +19,7 @@ require allow_ada_tests
standard_ada_testfile foo_ra24_010
-set old_gcc [expr [test_compiler_info {gcc-[0-8]-*}]]
+set old_gcc [gnat_version_compare < 9]
foreach_gnat_encoding scenario flags {all minimal} {
lappend flags debug
diff --git a/gdb/testsuite/gdb.ada/call_pn.exp b/gdb/testsuite/gdb.ada/call_pn.exp
index 5d7e828..9114d30 100644
--- a/gdb/testsuite/gdb.ada/call_pn.exp
+++ b/gdb/testsuite/gdb.ada/call_pn.exp
@@ -35,7 +35,10 @@ if {![runto "foo.adb:$bp_location"]} {
# related to PR25764 - "LOC_UNRESOLVED symbol missing from partial symtab".
# Stabilize test results by ensuring that the xfail triggers for the "before"
# print.
-gdb_test_no_output "maint expand-symtabs"
+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]
# 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.
@@ -52,7 +55,10 @@ set xfail_re \
# Make sure that last_node_id is set to zero...
gdb_test_multiple "print last_node_id" "print last_node_id before calling pn" {
-re $xfail_re {
- xfail $gdb_test_name
+ if { $have_xfail } {
+ setup_xfail *-*-*
+ }
+ fail $gdb_test_name
# One of the choices will print the correct value, the other one
# <optimized out>. Since we don't known which one to choose to get
# the correct value, cancel.
@@ -74,7 +80,10 @@ gdb_test "print pn(4321)" "= 4321"
# Make sure that last_node_id now has the correct value...
gdb_test_multiple "print last_node_id" "print last_node_id after calling pn" {
-re $xfail_re {
- xfail $gdb_test_name
+ if { $have_xfail } {
+ setup_xfail *-*-*
+ }
+ fail $gdb_test_name
# Cancel
gdb_test_multiple "0" "cancel after xfail 2" {
-re -wrap "cancelled" {
diff --git a/gdb/testsuite/gdb.ada/complete.exp b/gdb/testsuite/gdb.ada/complete.exp
index 41ea8ae..6263c4e 100644
--- a/gdb/testsuite/gdb.ada/complete.exp
+++ b/gdb/testsuite/gdb.ada/complete.exp
@@ -124,7 +124,7 @@ test_gdb_complete "pck.my" \
"p pck.my_global_variable"
# A fully qualified package name
-test_gdb_complete "pck.inne" \
+test_gdb_complete "pck.inner" \
"p pck.inner.inside_variable" \
"complete fully qualified package name"
@@ -214,7 +214,7 @@ test_gdb_complete "ambiguous_f" \
test_gdb_complete "ambiguous_func" \
"p ambiguous_func"
-# Perform a test intented to verify the behavior where the number
+# Perform a test intended to verify the behavior where the number
# of possible completions is very large. The goal is not to verify
# precisely the list returned by the complete command (this depends
# on too many parameters -- targets, compiler version, runtime, etc).
diff --git a/gdb/testsuite/gdb.ada/enum_idx_packed.exp b/gdb/testsuite/gdb.ada/enum_idx_packed.exp
index d56d73b..cf70e9a 100644
--- a/gdb/testsuite/gdb.ada/enum_idx_packed.exp
+++ b/gdb/testsuite/gdb.ada/enum_idx_packed.exp
@@ -29,8 +29,9 @@ foreach_gnat_encoding scenario flags {all minimal} {
clean_restart ${testfile}-${scenario}
# GNAT 9 and 10 are known to fail.
- if {$scenario == "minimal" && ([test_compiler_info {gcc-9-*}] \
- || [test_compiler_info {gcc-10-*}])} {
+ if {$scenario == "minimal"
+ && [gnat_version_compare >= 9]
+ && [gnat_version_compare <= 10]} {
set old_compiler 1
} else {
set old_compiler 0
diff --git a/gdb/testsuite/gdb.ada/exec_changed.exp b/gdb/testsuite/gdb.ada/exec_changed.exp
index 8fb8d1c..69f386e 100644
--- a/gdb/testsuite/gdb.ada/exec_changed.exp
+++ b/gdb/testsuite/gdb.ada/exec_changed.exp
@@ -86,7 +86,7 @@ if { [gdb_start_cmd] < 0 } {
clean_restart "${binfile}$EXEEXT"
-# Ensure we don't accidently use the main symbol cache.
+# Ensure we don't accidentally use the main symbol cache.
gdb_test_no_output "mt set symbol-cache-size 0"
# Put something in the symbol lookup cache that will get looked up when
diff --git a/gdb/testsuite/gdb.ada/fixed_points.exp b/gdb/testsuite/gdb.ada/fixed_points.exp
index ceed34a..b2b3df4 100644
--- a/gdb/testsuite/gdb.ada/fixed_points.exp
+++ b/gdb/testsuite/gdb.ada/fixed_points.exp
@@ -88,12 +88,12 @@ foreach_gnat_encoding scenario flags {all minimal} {
gdb_test "print fp4_var / 1" $fp4
# This only started working in GCC 11.
- if {$scenario == "minimal" && [test_compiler_info {gcc-11-*}]} {
+ if {$scenario == "minimal" && [gnat_version_compare >= 11]} {
gdb_test "print fp5_var" " = 3e-19"
}
# This failed before GCC 10.
- if {$scenario == "all" && [test_compiler_info {gcc-10-*}]} {
+ if {$scenario == "all" && [gnat_version_compare < 10]} {
gdb_test "p Float(Another_Fixed) = Float(Another_Delta * 5)" "true" \
"value of another_fixed"
}
diff --git a/gdb/testsuite/gdb.ada/fun_renaming.exp b/gdb/testsuite/gdb.ada/fun_renaming.exp
index 08c44b7..21f80db 100644
--- a/gdb/testsuite/gdb.ada/fun_renaming.exp
+++ b/gdb/testsuite/gdb.ada/fun_renaming.exp
@@ -41,7 +41,7 @@ gdb_test_multiple $test $test {
pass $test
}
-wrap -re "No definition of \"fun_rename_test_n\" in current context\\." {
- if {[test_compiler_info {gcc-6*}]} {
+ if {[gnat_version_compare >= 6]} {
fail $test
} else {
xfail $test
@@ -55,7 +55,7 @@ gdb_test_multiple $test $test {
pass $test
}
-wrap -re "No definition of \"renamed_fun_rename_test_next\" in current context\\." {
- if {[test_compiler_info {gcc-6*}]} {
+ if {[gnat_version_compare >= 6]} {
fail $test
} else {
xfail $test
@@ -69,14 +69,14 @@ gdb_test_multiple $test $test {
pass $test
}
-wrap -re "No definition of \"pack\\.renamed_fun_rename_test_next\" in current context\\." {
- if {[test_compiler_info {gcc-6*}]} {
+ if {[gnat_version_compare >= 6]} {
fail $test
} else {
xfail $test
}
}
-wrap -re "Type <data variable, no debug info> is not a structure or union type\\." {
- if {[test_compiler_info {gcc-6*}]} {
+ if {[gnat_version_compare >= 6]} {
fail $test
} else {
xfail $test
diff --git a/gdb/testsuite/gdb.ada/mod_from_name.exp b/gdb/testsuite/gdb.ada/mod_from_name.exp
index 33bd854..99effb0 100644
--- a/gdb/testsuite/gdb.ada/mod_from_name.exp
+++ b/gdb/testsuite/gdb.ada/mod_from_name.exp
@@ -34,8 +34,9 @@ foreach_gnat_encoding scenario flags {all minimal} {
}
# GNAT 9 and 10 are known to fail.
- if {$scenario == "minimal" && ([test_compiler_info {gcc-9-*}] \
- || [test_compiler_info {gcc-10-*}])} {
+ if {$scenario == "minimal"
+ && [gnat_version_compare >= 9]
+ && [gnat_version_compare <= 10]} {
setup_kfail "minimal encodings" *-*-*
}
gdb_test "print xp" \
diff --git a/gdb/testsuite/gdb.ada/null_array.exp b/gdb/testsuite/gdb.ada/null_array.exp
index 4a04945..7fa7c19 100644
--- a/gdb/testsuite/gdb.ada/null_array.exp
+++ b/gdb/testsuite/gdb.ada/null_array.exp
@@ -28,8 +28,7 @@ clean_restart ${testfile}
set bp_location [gdb_get_line_number "START" ${testdir}/foo.adb]
runto "foo.adb:$bp_location"
-if {[test_compiler_info {gcc-[0-3]-*}]
- || [test_compiler_info {gcc-4-[0-4]-*}]} {
+if {[gnat_version_compare <= 4.4]} {
# Ada array bounds are missing in older GCCs.
setup_xfail *-*-*
}
diff --git a/gdb/testsuite/gdb.ada/packed_array_assign.exp b/gdb/testsuite/gdb.ada/packed_array_assign.exp
index ee2b395..47e48f9 100644
--- a/gdb/testsuite/gdb.ada/packed_array_assign.exp
+++ b/gdb/testsuite/gdb.ada/packed_array_assign.exp
@@ -54,7 +54,7 @@ set re \
"packed_array_assign_y => 1\\)\\)"]
# GNAT >= 12.0 has the needed fix here.
-set zeros_expected [expr {![test_compiler_info {gcc-1[2-9]-*}]}]
+set zeros_expected [gnat_version_compare >= 12]
set all_zeros \
[string_to_regexp "((packed_array_assign_w => 0, packed_array_assign_x => 0, packed_array_assign_y => 0), (packed_array_assign_w => 0, packed_array_assign_x => 0, packed_array_assign_y => 0), (packed_array_assign_w => 0, packed_array_assign_x => 0, packed_array_assign_y => 0))"]
diff --git a/gdb/testsuite/gdb.ada/packed_record.exp b/gdb/testsuite/gdb.ada/packed_record.exp
index bbba9b2..f347953 100644
--- a/gdb/testsuite/gdb.ada/packed_record.exp
+++ b/gdb/testsuite/gdb.ada/packed_record.exp
@@ -38,7 +38,7 @@ foreach_gnat_encoding scenario flags {all minimal} {
}
-re " = .*more than max-value-size.*\[\r\n\]+$gdb_prompt $" {
# GNAT >= 12.0 has the needed fix here.
- if {$scenario == "minimal" && ![test_compiler_info {gcc-1[2-9]-*}]} {
+ if {$scenario == "minimal" && [gnat_version_compare >= 12]} {
setup_kfail "minimal encodings" *-*-*
}
fail $test
diff --git a/gdb/testsuite/gdb.ada/pckd_arr_ren.exp b/gdb/testsuite/gdb.ada/pckd_arr_ren.exp
index 18bb84f..694cc23 100644
--- a/gdb/testsuite/gdb.ada/pckd_arr_ren.exp
+++ b/gdb/testsuite/gdb.ada/pckd_arr_ren.exp
@@ -32,8 +32,9 @@ foreach_gnat_encoding scenario flags {all minimal} {
runto "foo.adb:$bp_location"
# GNAT 9 and 10 are known to fail.
- if {$scenario == "minimal" && ([test_compiler_info {gcc-9-*}] \
- || [test_compiler_info {gcc-10-*}])} {
+ if {$scenario == "minimal"
+ && [gnat_version_compare >= 9]
+ && [gnat_version_compare <= 10]} {
setup_kfail "minimal encodings" *-*-*
}
gdb_test "print A2" \
diff --git a/gdb/testsuite/gdb.ada/tagged-lookup.exp b/gdb/testsuite/gdb.ada/tagged-lookup.exp
index 3803319..f1473aa 100644
--- a/gdb/testsuite/gdb.ada/tagged-lookup.exp
+++ b/gdb/testsuite/gdb.ada/tagged-lookup.exp
@@ -51,11 +51,7 @@ gdb_test_multiple "print *the_local_var" "only one CU expanded" -lbl {
-re ".symtab-create. start_subfile: name = \[^,\]*, name_for_id = \[^\r\n\]*\r\n" {
exp_continue
}
- -re -wrap ".* = \\\(n => $decimal\\\)" {
- if {$found_pck + $found_pck2 <= 1} {
- pass $gdb_test_name
- } else {
- fail $gdb_test_name
- }
+ -re -wrap "" {
+ gdb_assert {$found_pck + $found_pck2 <= 1} $gdb_test_name
}
}
diff --git a/gdb/testsuite/gdb.ada/task_switch_in_core.exp b/gdb/testsuite/gdb.ada/task_switch_in_core.exp
index 63a951c..dd63bb8 100644
--- a/gdb/testsuite/gdb.ada/task_switch_in_core.exp
+++ b/gdb/testsuite/gdb.ada/task_switch_in_core.exp
@@ -41,7 +41,7 @@ if {!$core_supported} {
return -1
}
-# Now taht the core file has been created, we can start the real
+# Now that the core file has been created, we can start the real
# part of this testcase, which is to debug using that core file.
# Restart GDB and load that core file.
diff --git a/gdb/testsuite/gdb.ada/variant_record_packed_array.exp b/gdb/testsuite/gdb.ada/variant_record_packed_array.exp
index 8f4192c..22b67cc 100644
--- a/gdb/testsuite/gdb.ada/variant_record_packed_array.exp
+++ b/gdb/testsuite/gdb.ada/variant_record_packed_array.exp
@@ -41,7 +41,7 @@ foreach_gnat_encoding scenario flags {all minimal} {
}
-re " = \\(size => 8, length => 8, buffer => warning: could not find bounds information on packed array.*$gdb_prompt $" {
# GNAT >= 11.0 has the needed fix here.
- if {$scenario == "minimal" && ![test_compiler_info {gcc-1[1-9]-*}]} {
+ if {$scenario == "minimal" && [gnat_version_compare >= 11]} {
setup_kfail "minimal encodings" *-*-*
}
fail $test
@@ -62,7 +62,7 @@ foreach_gnat_encoding scenario flags {all minimal} {
}
-re " = \\(size => 8, length => 8, buffer => warning: could not find bounds information on packed array.*$gdb_prompt $" {
# GNAT >= 11.0 has the needed fix here.
- if {$scenario == "minimal" && ![test_compiler_info {gcc-1[1-9]-*}]} {
+ if {$scenario == "minimal" && [gnat_version_compare >= 11]} {
setup_kfail "minimal encodings" *-*-*
}
fail $test
diff --git a/gdb/testsuite/gdb.arch/e500-prologue.exp b/gdb/testsuite/gdb.arch/e500-prologue.exp
index 50837ff..7732393 100644
--- a/gdb/testsuite/gdb.arch/e500-prologue.exp
+++ b/gdb/testsuite/gdb.arch/e500-prologue.exp
@@ -53,7 +53,7 @@ proc insert_breakpoint {function expected_location} {
# If we managed to get the breakpoing address, then check that
# we inserted it at the expected location by examining the
# instruction at that address (we're not interested in the insn
- # itself, but rather at the address printed at the begining of
+ # itself, but rather at the address printed at the beginning of
# the instruction).
if {$address != ""} {
gdb_test "x /i $address" \
diff --git a/gdb/testsuite/gdb.arch/i386-mpx-call.c b/gdb/testsuite/gdb.arch/i386-mpx-call.c
deleted file mode 100644
index 5949202..0000000
--- a/gdb/testsuite/gdb.arch/i386-mpx-call.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/* Test for inferior function calls MPX context.
-
- Copyright (C) 2017-2024 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#include <stdlib.h>
-#include <string.h>
-
-/* Defined size for arrays. */
-#define ARRAY_LENGTH 5
-
-
-int
-upper (int *a, int *b, int *c, int *d, int len)
-{
- int value;
-
- value = *(a + len);
- value = *(b + len);
- value = *(c + len);
- value = *(d + len);
-
- value = value - *a + 1;
- return value;
-}
-
-
-int
-lower (int *a, int *b, int *c, int *d, int len)
-{
- int value;
-
- value = *(a - len);
- value = *(b - len);
- value = *(c - len);
- value = *(d - len);
-
- value = value - *a + 1;
- return value;
-}
-
-
-char
-char_upper (char *str, int length)
-{
- char ch;
- ch = *(str + length);
-
- return ch;
-}
-
-
-char
-char_lower (char *str, int length)
-{
- char ch;
- ch = *(str - length);
-
- return ch;
-}
-
-
-int
-main (void)
-{
- int sa[ARRAY_LENGTH];
- int sb[ARRAY_LENGTH];
- int sc[ARRAY_LENGTH];
- int sd[ARRAY_LENGTH];
- int *x, *a, *b, *c, *d;
- char mchar;
- char hello[] = "Hello";
-
- x = malloc (sizeof (int) * ARRAY_LENGTH);
- a = malloc (sizeof (int) * ARRAY_LENGTH);
- b = malloc (sizeof (int) * ARRAY_LENGTH);
- c = malloc (sizeof (int) * ARRAY_LENGTH);
- d = malloc (sizeof (int) * ARRAY_LENGTH);
-
- *x = upper (sa, sb, sc, sd, 0); /* bkpt 1. */
- *x = lower (a, b, c, d, 0);
-
- mchar = char_upper (hello, 10);
- mchar = char_lower (hello, 10);
-
- free (x);
- free (a);
- free (b);
- free (c);
- free (d);
-
- return 0;
-}
diff --git a/gdb/testsuite/gdb.arch/i386-mpx-call.exp b/gdb/testsuite/gdb.arch/i386-mpx-call.exp
deleted file mode 100644
index e225484..0000000
--- a/gdb/testsuite/gdb.arch/i386-mpx-call.exp
+++ /dev/null
@@ -1,398 +0,0 @@
-# Copyright (C) 2017-2024 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
-require {is_any_target "i?86-*-*" "x86_64-*-*"}
-
-standard_testfile
-
-require supports_mpx_check_pointer_bounds have_mpx
-
-set comp_flags "-mmpx -fcheck-pointer-bounds -I${srcdir}/../nat"
-
-if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
- [list debug additional_flags=${comp_flags}]] } {
- return -1
-}
-
-if ![runto_main] {
- return -1
-}
-
-set bounds_table 0
-gdb_test_multiple "disassemble upper" "" {
- -re -wrap "bndldx.*" {
- set bounds_table 1
- }
- -re -wrap "" {
- }
-}
-
-# Convenience for returning from an inferior call that causes a BND violation.
-#
-gdb_test_no_output "set confirm off"
-
-# Convenience variable.
-#
-set bound_reg " = \\\{lbound = $hex, ubound = $hex\\\}.*"
-set int_braw_reg " = \\\{lbound = 0x0, ubound_raw = 0x0\\\}.*"
-set bndcfg_reg " = \\\{raw = $hex, config = \\\{base = $hex, reserved = $hex,\
- preserved = $hex, enabled = $hex\\\}\\\}"
-set bndstatus_reg " = \\\{raw = $hex, status = \\\{bde = $hex,\
- error = $hex\\\}\\\}"
-set u_fault [multi_line "Program received signal SIGSEGV, Segmentation fault" \
- "Upper bound violation while accessing address $hex" \
- "Bounds: \\\[lower = $hex, upper = $hex\\\]"]
-
-
-# Simplify the tests below.
-#
-proc sanity_check_bndregs {arglist} {
-
- global int_braw_reg
-
- foreach a $arglist {
- gdb_test "p /x $a" "$int_braw_reg"\
- "$a"
- }
-}
-
-# Set bnd register to have no access to memory.
-#
-proc remove_memory_access {reg} {
- global hex
-
- sanity_check_bndregs {"\$bnd0raw" "\$bnd1raw" "\$bnd2raw" "\$bnd3raw"}
-
- gdb_test "p /x $reg.lbound = $reg.ubound" "= $hex"\
- "$reg lower bound set"
- gdb_test "p /x $reg.ubound = 0" " = 0x0"\
- "$reg upper bound set"
-}
-
-
-# Prepare convenience variables for bndconfig and status
-# for posterior comparison.
-#
-proc prepare_bndcfg_bndstatus {} {
-
- global bndcfg_reg
- global bndstatus_reg
-
- gdb_test "p /x \$temp_bndcfgu = \$bndcfgu" "$bndcfg_reg"\
- "bndcfgu should not change"
-
- gdb_test "p /x \$temp_bndstatus = \$bndstatus" "$bndstatus_reg"\
- "bndstatus should not change"
-}
-
-# Compare values set for convenience variables and actual values of bndconfig
-# and bndstatus registers.
-#
-proc compare_bndstatus_with_convenience {} {
-
- gdb_test "p \$temp_bndcfgu == \$bndcfgu" "= 1"\
- "bndcfgu compare before and after"
- gdb_test "p \$temp_bndstatus == \$bndstatus" "= 1"\
- "bndstatus compare before and after"
-}
-
-# Perform an inferior call defined in func.
-#
-proc perform_a_call {func} {
-
- global inf_call_stopped
- global gdb_prompt
-
- gdb_test "p /x $func" [multi_line "The program being debugged\
- stopped while in a function called from GDB." \
- "Evaluation of the expression containing the\
- function.*" \
- ] "inferior call stopped"
-}
-
-# Perform an inferior call defined in func.
-#
-proc check_bound_violation {parm parm_type is_positive} {
-
- global u_fault bounds_table
-
- set have_bnd_violation 0
- gdb_test_multiple "continue" "continue to a bnd violation" {
- -re -wrap "Continuing\." {
- if { $bounds_table } {
- pass $gdb_test_name
- } else {
- fail $gdb_test_name
- }
- }
- -re -wrap "$u_fault.*" {
- pass $gdb_test_name
- set have_bnd_violation 1
- }
- }
- if { ! $have_bnd_violation } {
- return
- }
-
- set message "access only one position"
- if {$is_positive == 1} {
- gdb_test "p (((void *)\$_siginfo._sifields._sigfault.si_addr\
- - (void*)$parm))/sizeof($parm_type) == 1"\
- " = 1" $message
- } else {
- gdb_test "p ((void*)$parm\
- - (void *)\$_siginfo._sifields._sigfault.si_addr)\
- /sizeof($parm_type) == 1"\
- " = 1" $message
- }
- gdb_test "return" "\\\#.*main.*i386-mpx-call\\\.c:.*" "return from the fault"
-}
-
-
-# Start testing!
-#
-
-# Set up for stopping in the middle of main for calling a function in the
-# inferior.
-#
-set break "bkpt 1."
-gdb_breakpoint [gdb_get_line_number "${break}"]
-gdb_continue_to_breakpoint "${break}" ".*${break}.*"
-
-
-# Consistency:
-# default run execution of call should succeed without violations.
-#
-with_test_prefix "default_run" {
-
- gdb_test "p \$keep_bnd0_value=\$bnd0" $bound_reg\
- "store bnd0 register in a convenience variable"
-
- gdb_test "p /x upper (a, b, c, d, 0)" " = $hex"\
- "default inferior call"
-
- gdb_test "p ((\$bnd0.lbound==\$keep_bnd0_value.lbound) &&\
- (\$bnd0.ubound==\$keep_bnd0_value.ubound))" "= 1" \
- "bnd register value after and before call"
-}
-
-# Consistency: Examine bnd registers values before and after the call.
-#
-#
-with_test_prefix "verify_default_values" {
-
- prepare_bndcfg_bndstatus
-
- gdb_breakpoint "*upper"
- perform_a_call "upper (a, b, c, d, 1)"
-
- sanity_check_bndregs {"\$bnd0raw" "\$bnd1raw" "\$bnd2raw" "\$bnd3raw"}
-
- compare_bndstatus_with_convenience
-
- gdb_test_multiple "continue" "inferior call test" {
- -re ".*Continuing.\r\n$gdb_prompt " {
- pass "inferior call performed"
- }
- }
-}
-
-# Examine: Cause an upper bound violation changing BND0.
-#
-#
-with_test_prefix "upper_bnd0" {
-
- prepare_bndcfg_bndstatus
-
- gdb_breakpoint "*upper"
- perform_a_call "upper (a, b, c, d, 1)"
-
- remove_memory_access "\$bnd0"
-
- compare_bndstatus_with_convenience
-
- check_bound_violation "a" "int" 1
-}
-
-# Examine: Cause an upper bound violation changing BND1.
-#
-#
-with_test_prefix "upper_bnd1" {
-
- prepare_bndcfg_bndstatus
-
- gdb_breakpoint "*upper"
- perform_a_call "upper (a, b, c, d, 1)"
-
- remove_memory_access "\$bnd1"
-
- compare_bndstatus_with_convenience
-
- check_bound_violation "b" "int" 1
-}
-
-# Examine: Cause an upper bound violation changing BND2.
-#
-#
-with_test_prefix "upper_bnd2" {
-
- prepare_bndcfg_bndstatus
-
- gdb_breakpoint "*upper"
- perform_a_call "upper (a, b, c, d, 1)"
-
- remove_memory_access "\$bnd2"
-
- compare_bndstatus_with_convenience
-
- check_bound_violation "c" "int" 1
-}
-
-# Examine: Cause an upper bound violation changing BND3.
-#
-#
-with_test_prefix "upper_bnd3" {
- prepare_bndcfg_bndstatus
-
- gdb_breakpoint "*upper"
- perform_a_call "upper (a, b, c, d, 1)"
-
- remove_memory_access "\$bnd3"
-
- compare_bndstatus_with_convenience
-
- check_bound_violation "d" "int" 1
-}
-
-# Examine: Cause a lower bound violation changing BND0.
-#
-#
-with_test_prefix "lower_bnd0" {
-
- prepare_bndcfg_bndstatus
-
- gdb_breakpoint "*lower"
- perform_a_call "lower (a, b, c, d, 1)"
-
- remove_memory_access "\$bnd0"
-
- compare_bndstatus_with_convenience
-
- check_bound_violation "a" "int" 0
-}
-
-# Examine: Cause a lower bound violation changing BND1.
-#
-#
-with_test_prefix "lower_bnd1" {
-
- prepare_bndcfg_bndstatus
-
- gdb_breakpoint "*lower"
- perform_a_call "lower (a, b, c, d, 1)"
-
- remove_memory_access "\$bnd1"
-
- compare_bndstatus_with_convenience
-
- check_bound_violation "b" "int" 0
-}
-
-# Examine: Cause a lower bound violation changing BND2.
-#
-#
-with_test_prefix "lower_bnd2" {
-
- prepare_bndcfg_bndstatus
-
- gdb_breakpoint "*lower"
- perform_a_call "lower (a, b, c, d, 1)"
-
- remove_memory_access "\$bnd2"
-
- compare_bndstatus_with_convenience
-
- check_bound_violation "c" "int" 0
-}
-
-# Examine: Cause a lower bound violation changing BND3.
-#
-#
-with_test_prefix "lower_bnd3" {
-
- prepare_bndcfg_bndstatus
-
- gdb_breakpoint "*lower"
- perform_a_call "lower (a, b, c, d, 1)"
-
- remove_memory_access "\$bnd3"
-
- compare_bndstatus_with_convenience
-
- check_bound_violation "d" "int" 0
-}
-
-# Examine: String causing a upper bound violation changing BND0.
-#
-#
-with_test_prefix "chars_up" {
-
- prepare_bndcfg_bndstatus
-
- gdb_breakpoint "*char_upper"
- perform_a_call "char_upper (hello, 1)"
-
- remove_memory_access "\$bnd0"
-
- compare_bndstatus_with_convenience
-
- check_bound_violation "str" "char" 1
-}
-
-
-# Examine: String causing an lower bound violation changing BND0.
-#
-#
-with_test_prefix "chars_low" {
-
- prepare_bndcfg_bndstatus
-
- gdb_breakpoint "*char_lower"
- perform_a_call "char_lower (hello, 1)"
-
- remove_memory_access "\$bnd0"
-
- compare_bndstatus_with_convenience
-
- check_bound_violation "str" "char" 0
-}
-
-# Examine: String causing an lower bound violation changing BND0.
-#
-#
-with_test_prefix "chars_low_adhoc_parm" {
-
- prepare_bndcfg_bndstatus
-
- gdb_breakpoint "*char_lower"
- perform_a_call "char_lower (\"tryme\", 1)"
-
- remove_memory_access "\$bnd0"
-
- compare_bndstatus_with_convenience
-
- check_bound_violation "str" "char" 0
-}
diff --git a/gdb/testsuite/gdb.arch/i386-mpx-map.c b/gdb/testsuite/gdb.arch/i386-mpx-map.c
deleted file mode 100644
index c072e74..0000000
--- a/gdb/testsuite/gdb.arch/i386-mpx-map.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Test program for MPX map allocated bounds.
-
- Copyright 2015-2024 Free Software Foundation, Inc.
-
- Contributed by Intel Corp. <walfred.tedeschi@intel.com>
- <mircea.gherzan@intel.com>
-
- 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 <stdlib.h>
-#define SIZE 5
-
-typedef int T;
-
-void
-foo (T *p)
-{
- T *x;
-
-#if defined __GNUC__ && !defined __INTEL_COMPILER
- __bnd_store_ptr_bounds (p, &p);
-#endif
-
- x = p + SIZE - 1;
-
-#if defined __GNUC__ && !defined __INTEL_COMPILER
- __bnd_store_ptr_bounds (x, &x);
-#endif
- /* Dummy assign. */
- x = x + 1; /* after-assign */
- return;
-}
-
-int
-main (void)
-{
- T *a = NULL;
-
- a = calloc (SIZE, sizeof (T)); /* after-decl */
-#if defined __GNUC__ && !defined __INTEL_COMPILER
- __bnd_store_ptr_bounds (a, &a);
-#endif
-
- foo (a); /* after-alloc */
- free (a);
-
- return 0;
-}
diff --git a/gdb/testsuite/gdb.arch/i386-mpx-map.exp b/gdb/testsuite/gdb.arch/i386-mpx-map.exp
deleted file mode 100644
index d955187..0000000
--- a/gdb/testsuite/gdb.arch/i386-mpx-map.exp
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright 2015-2024 Free Software Foundation, Inc.
-#
-# Contributed by Intel Corp. <walfred.tedeschi@intel.com>,
-# <mircea.gherzan@intel.com>
-#
-# 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_any_target i?86-*-* x86_64-*-*}
-
-standard_testfile
-
-require supports_mpx_check_pointer_bounds have_mpx
-
-set comp_flags "-mmpx -fcheck-pointer-bounds -I${srcdir}/../nat/"
-
-if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
- [list debug nowarnings additional_flags=${comp_flags}]] } {
- return -1
-}
-
-if ![runto_main] {
- return -1
-}
-
-gdb_breakpoint [ gdb_get_line_number "after-decl" ]
-gdb_breakpoint [ gdb_get_line_number "after-alloc" ]
-gdb_breakpoint [ gdb_get_line_number "after-assign" ]
-
-gdb_test "show mpx bound 0x0" "Invalid bounds directory entry at $hex." "NULL address of the pointer"
-
-gdb_continue_to_breakpoint "after-decl" ".*after-decl.*"
-gdb_test "show mpx bound a" "Invalid bounds directory entry at $hex." "pointer instead of pointer address"
-
-gdb_continue_to_breakpoint "after-alloc" ".*after-alloc.*"
-gdb_test "show mpx bound a" "\\\{lbound = $hex, ubound = $hex\\\}: pointer value = $hex, size = \[8, 4\], metadata = 0x0+" "pointer after allocation"
-
-gdb_continue_to_breakpoint "after-assign" ".*after-assign.*"
-gdb_test "show mpx bound x" "\\\{lbound = $hex, ubound = $hex\\\}: pointer value = $hex, size = \[8, 4\], metadata = 0x0+" "pointer after assignment"
-gdb_test "set mpx bound 0x0, 0x1, 0x2" "Invalid bounds directory entry at $hex." "set mpx bound: NULL address of the pointer"
-gdb_test_no_output "set mpx bound x, 0xcafebabe, 0xdeadbeef" "set mpx bound: set bounds for a valid pointer address"
-gdb_test "show mpx bound x" "\\\{lbound = .*cafebabe, ubound = .*deadbeef\\\}: pointer value = $hex, size = $decimal, metadata = 0x0+" "set mpx bound: bounds map entry after set mpx bound"
-
-
-gdb_test "set mpx bound 0x0, 0x1 0x2" "A syntax error in expression.*" "set mpx bound: Controlling syntax error, missing comma "
-gdb_test "set mpx bound 0x0, 0x1" "Wrong number of arguments.*" "set mpx bound: Controlling syntax error, missing argument "
diff --git a/gdb/testsuite/gdb.arch/i386-mpx-sigsegv.c b/gdb/testsuite/gdb.arch/i386-mpx-sigsegv.c
deleted file mode 100644
index 54722e3..0000000
--- a/gdb/testsuite/gdb.arch/i386-mpx-sigsegv.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/* Copyright (C) 2015-2024 Free Software Foundation, Inc.
-
- Contributed by Intel Corp. <walfred.tedeschi@intel.com>
-
- 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/>. */
-
-#define OUR_SIZE 5
-
-int gx[OUR_SIZE];
-int ga[OUR_SIZE];
-int gb[OUR_SIZE];
-int gc[OUR_SIZE];
-int gd[OUR_SIZE];
-
-int
-bp1 (int value)
-{
- return 1;
-}
-
-int
-bp2 (int value)
-{
- return 1;
-}
-
-void
-upper (int * p, int * a, int * b, int * c, int * d, int len)
-{
- int value;
- value = *(p + len);
- value = *(a + len);
- value = *(b + len);
- value = *(c + len);
- value = *(d + len);
-}
-
-void
-lower (int * p, int * a, int * b, int * c, int * d, int len)
-{
- int value;
- value = *(p - len);
- value = *(a - len);
- value = *(b - len);
- value = *(c - len);
- bp2 (value);
- value = *(d - len);
-}
-
-int
-main (void)
-{
- int sx[OUR_SIZE];
- int sa[OUR_SIZE];
- int sb[OUR_SIZE];
- int sc[OUR_SIZE];
- int sd[OUR_SIZE];
- int *x, *a, *b, *c, *d;
-
- x = calloc (OUR_SIZE, sizeof (int));
- a = calloc (OUR_SIZE, sizeof (int));
- b = calloc (OUR_SIZE, sizeof (int));
- c = calloc (OUR_SIZE, sizeof (int));
- d = calloc (OUR_SIZE, sizeof (int));
-
- upper (x, a, b, c, d, OUR_SIZE + 2);
- upper (sx, sa, sb, sc, sd, OUR_SIZE + 2);
- upper (gx, ga, gb, gc, gd, OUR_SIZE + 2);
- lower (x, a, b, c, d, 1);
- lower (sx, sa, sb, sc, sd, 1);
- bp1 (*x);
- lower (gx, ga, gb, gc, gd, 1);
-
- free (x);
- free (a);
- free (b);
- free (c);
- free (d);
-
- return 0;
-}
diff --git a/gdb/testsuite/gdb.arch/i386-mpx-sigsegv.exp b/gdb/testsuite/gdb.arch/i386-mpx-sigsegv.exp
deleted file mode 100644
index 75f7e65..0000000
--- a/gdb/testsuite/gdb.arch/i386-mpx-sigsegv.exp
+++ /dev/null
@@ -1,64 +0,0 @@
-# Copyright (C) 2015-2024 Free Software Foundation, Inc.
-#
-# Contributed by Intel Corp. <walfred.tedeschi@intel.com>
-#
-# 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_any_target "i?86-*-*" "x86_64-*-*"}
-
-standard_testfile
-
-require supports_mpx_check_pointer_bounds have_mpx
-
-set comp_flags "-mmpx -fcheck-pointer-bounds -I${srcdir}/../nat/"
-
-if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
- [list debug nowarnings additional_flags=${comp_flags}]] } {
- return -1
-}
-
-if ![runto_main] {
- return -1
-}
-
-set u_fault [multi_line "Program received signal SIGSEGV, Segmentation fault" \
- "Upper bound violation while accessing address $hex" \
- "Bounds: \\\[lower = $hex, upper = $hex\\\]"]
-
-set l_fault [multi_line "Program received signal SIGSEGV, Segmentation fault" \
- "Lower bound violation while accessing address $hex" \
- "Bounds: \\\[lower = $hex, upper = $hex\\\]"]
-
-for {set i 0} {$i < 15} {incr i} {
- set message "MPX signal segv Upper: ${i}"
-
- if {[gdb_test "continue" "$u_fault.*" $message] != 0} {
- break
- }
-
- gdb_test "where" ".*#0 $hex in upper.*"\
- "$message: should be in upper"
-}
-
-for {set i 0} {$i < 15} {incr i} {
- set message "MPX signal segv Lower: ${i}"
-
- if {[gdb_test "continue" "$l_fault.*" $message] != 0} {
- break
- }
-
- gdb_test "where" ".*#0 $hex in lower.*"\
- "$message: should be in lower"
-}
diff --git a/gdb/testsuite/gdb.arch/i386-mpx-simple_segv.exp b/gdb/testsuite/gdb.arch/i386-mpx-simple_segv.exp
deleted file mode 100644
index 8a6c9dd..0000000
--- a/gdb/testsuite/gdb.arch/i386-mpx-simple_segv.exp
+++ /dev/null
@@ -1,124 +0,0 @@
-# Copyright (C) 2015-2024 Free Software Foundation, Inc.
-#
-# Contributed by Intel Corp. <walfred.tedeschi@intel.com>
-#
-# 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/>.
-
-# Testing handle setup together with boundary violation signals.
-#
-# Some states are not allowed as reported on the manual, as noprint
-# implies nostop, but nostop might print.
-#
-# Caveat: Setting the handle to nopass, ends up in a endless loop.
-
-require {is_any_target i?86-*-* x86_64-*-*}
-
-standard_testfile
-
-require supports_mpx_check_pointer_bounds have_mpx
-
-set comp_flags "-mmpx -fcheck-pointer-bounds -I${srcdir}/../nat/"
-
-if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
- [list debug nowarnings additional_flags=${comp_flags}]] } {
- return -1
-}
-
-if ![runto_main] {
- return -1
-}
-
-set violation [multi_line "Program received signal SIGSEGV, Segmentation fault" \
- "Upper bound violation while accessing address $hex" \
- "Bounds: \\\[lower = $hex, upper = $hex\\\]"]
-
-set segv_with_exit "Program received signal SIGSEGV,\
- Segmentation fault.*$inferior_exited_re.*"
-
-
-# Test handler for segmentation fault for:
-# print pass stop
-#
-set parameters "print pass stop"
-with_test_prefix "$parameters" {
- if ![runto_main] {
- return -1
- }
-
- gdb_test "handle SIGSEGV $parameters"\
- ".*SIGSEGV.*Yes.*Yes.*Yes.*Segmentation fault.*"\
- "set parameters"
-
- gdb_test "continue" ".*$violation.*" "display"
-
- gdb_test "where" ".*#0 $hex in upper.*"\
- "should be in upper"
-}
-
-# Test handler for segmentation fault for:
-# print pass nostop
-#
-set parameters "print pass nostop"
-with_test_prefix "$parameters" {
- if ![runto_main] {
- return -1
- }
-
- gdb_test "handle SIGSEGV $parameters"\
- ".*SIGSEGV.*No.*Yes.*Yes.*Segmentation fault.*"\
- "set parameters"
-
- gdb_test "continue" ".*$segv_with_exit.*" "display"
-
- gdb_test "where" "No stack." "no inferior"
-}
-
-# Test handler for segmentation fault for:
-# print nopass stop
-#
-set parameters "print nopass stop"
-with_test_prefix "$parameters" {
- if ![runto_main] {
- return -1
- }
-
- gdb_test "handle SIGSEGV $parameters"\
- ".*SIGSEGV.*Yes.*Yes.*No.*Segmentation fault.*"\
- "set parameters"
-
- gdb_test "continue" ".*$violation.*" "display"
-
- gdb_test "where" ".*#0 $hex in upper.*"\
- "should be in upper"
-}
-
-# Test handler for segmentation fault for:
-# print nopass stop
-#
-set parameters "noprint pass nostop"
-with_test_prefix "$parameters" {
- if ![runto_main] {
- return -1
- }
-
- gdb_test "handle SIGSEGV $parameters"\
- ".*SIGSEGV.*No.*No.*Yes.*Segmentation fault.*"\
- "set parameters"
-
- gdb_test "continue" "Continuing\..*$inferior_exited_re.*"\
- "Display"
-
- gdb_test "where" "No stack." "no inferior"
-}
-
diff --git a/gdb/testsuite/gdb.arch/i386-mpx.c b/gdb/testsuite/gdb.arch/i386-mpx.c
deleted file mode 100644
index 99f6744..0000000
--- a/gdb/testsuite/gdb.arch/i386-mpx.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Test program for MPX registers.
-
- Copyright 2013-2024 Free Software Foundation, Inc.
-
- This file is part of GDB.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-int
-main (void)
-{
-#ifdef __x86_64__
- asm ("mov $10, %rax\n\t"
- "mov $9, %rdx\n\t"
- "bndmk (%rax,%rdx), %bnd0\n\t"
- "mov $20, %rax\n\t"
- "mov $9, %rdx\n\t"
- "bndmk (%rax,%rdx), %bnd1\n\t"
- "mov $30, %rax\n\t"
- "mov $9, %rdx\n\t"
- "bndmk (%rax,%rdx), %bnd2\n\t"
- "mov $40, %rax\n\t"
- "mov $9, %rdx\n\t"
- "bndmk (%rax,%rdx), %bnd3\n\t"
- "bndstx %bnd3, (%rax) \n\t"
- "nop\n\t"
- );
-#else
- asm ("mov $10, %eax\n\t"
- "mov $9, %edx\n\t"
- "bndmk (%eax,%edx), %bnd0\n\t"
- "mov $20, %eax\n\t"
- "mov $9, %edx\n\t"
- "bndmk (%eax,%edx), %bnd1\n\t"
- "mov $30, %eax\n\t"
- "mov $9, %edx\n\t"
- "bndmk (%eax,%edx), %bnd2\n\t"
- "mov $40, %eax\n\t"
- "mov $9, %edx\n\t"
- "bndmk (%eax,%edx), %bnd3\n\t"
- "bndstx %bnd3, (%eax)\n\t"
- "nop\n\t"
- );
-#endif
- asm ("nop\n\t"); /* break here. */
-
- return 0;
-}
diff --git a/gdb/testsuite/gdb.arch/i386-mpx.exp b/gdb/testsuite/gdb.arch/i386-mpx.exp
deleted file mode 100644
index 9d71feb..0000000
--- a/gdb/testsuite/gdb.arch/i386-mpx.exp
+++ /dev/null
@@ -1,123 +0,0 @@
-# Copyright 2013-2024 Free Software Foundation, Inc.
-#
-# Contributed by Intel Corp. <walfred.tedeschi@intel.com>
-#
-# 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_any_target i?86-*-* x86_64-*-*}
-
-standard_testfile
-
-require {is_any_target i?86-*-* x86_64-*-*}
-
-require supports_mpx_check_pointer_bounds have_mpx
-
-set comp_flags "-mmpx -fcheck-pointer-bounds -I${srcdir}/../nat/"
-
-if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
- [list debug nowarnings additional_flags=${comp_flags}]] } {
- return -1
-}
-
-if ![runto_main] {
- return -1
-}
-
-# Test bndcfg register and bndstatus at startup
-set test_string "\\\{raw = 0x\[0-9a-f\]+, config = \\\{base = \[0-9\]+,\
-reserved = \[0-9\]+, preserved = \[0-9\]+, enabled = \[0-9\]+\\\}\\\}"
-
-gdb_test "print \$bndcfgu" $test_string "bndcfgu formating"
-gdb_test "print \$bndcfgu.config.enabled" "= 1" "test if bndstatus is enabled"
-gdb_test "print \$bndstatus" "\\\{raw = 0x0, status = \\\{bde = 0, error = 0\\\}\\\}" \
- "bndstatus formating"
-gdb_test "print \$bndstatus.raw" "= \\\(void \\\*\\\) 0x0" "bndstatus is zero by startup"
-
-# Read values from pseudo registers.
-gdb_breakpoint [ gdb_get_line_number "break here" ]
-gdb_continue_to_breakpoint "break here" ".*break here.*"
-
-set test_string ".*\\\{lbound = 0xa, ubound = 0x13\\\}.*"
-gdb_test "info register bnd0" ".*bnd0$test_string" "pure bnd0 register"
-
-set test_string ".*\\\{lbound = 0x14, ubound = 0x1d\\\}.*"
-gdb_test "info register bnd1" ".*bnd1$test_string" "pure bnd1 register"
-
-set test_string ".*\\\{lbound = 0x1e, ubound = 0x27\\\}.*"
-gdb_test "info register bnd2" ".*bnd2$test_string" "pure bnd2 register"
-
-set test_string ".*\\\{lbound = 0x28, ubound = 0x31\\\}.*"
-gdb_test "info register bnd3" ".*bnd3$test_string" "pure bnd3 register"
-
-# Read value from registers bndrs.
-
-set test_string ".*\\\{lbound = 0xa, ubound_raw = 0x\[f\]+ec\\\}.*"
-gdb_test "info register bnd0raw" ".*bnd0$test_string" "pure bnd0r register"
-
-set test_string ".*\\\{lbound = 0x14, ubound_raw = 0x\[f\]+e2\\\}.*"
-gdb_test "info register bnd1raw" ".*bnd1$test_string" "pure bnd1r register"
-
-set test_string ".*\\\{lbound = 0x1e, ubound_raw = 0x\[f\]+d8\\\}.*"
-gdb_test "info register bnd2raw" ".*bnd2$test_string" "pure bnd2r register"
-
-set test_string ".*\\\{lbound = 0x28, ubound_raw = 0x\[f\]+ce\\\}.*"
-gdb_test "info register bnd3raw" ".*bnd3$test_string" "pure bnd3r register"
-
-# Setting fields on bnds
-set test_string ".*\\\{lbound = 0xa, ubound = 0x400\\\}.*"
-gdb_test "print \$bnd0.ubound = 0x400" "= \\\(void \\\*\\\) 0x400" "set value for bnd0.ubound"
-gdb_test "print \$bnd0" "$test_string" "after setting bnd0.ubound"
-set test_string ".*\\\{lbound = 0xa, ubound_raw = 0x\[f\]+bff\\\}.*"
-gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after set bnd0.ubound"
-
-set test_string ".*\\\{lbound = 0x1, ubound = 0x400\\\}.*"
-gdb_test "print \$bnd0.lbound = 0x1" "= \\\(void \\\*\\\) 0x1" "set value for bnd0.lbound"
-gdb_test "print \$bnd0" "$test_string" "after setting bnd0.lbound"
-set test_string ".*\\\{lbound = 0x1, ubound_raw = 0x\[f\]+bff\\\}.*"
-gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after set bnd0.lbound"
-
-# Setting fields on bnd0raw.
-set test_string ".*\\\{lbound = 0x1, ubound_raw = 0x600\\\}.*"
-gdb_test "print /x \$bnd0raw.ubound_raw = 0x600" "= 0x600" "set value for bnd0raw.ubound"
-gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after setting bnd0raw.ubound"
-set test_string ".*\\\{lbound = 0x1, ubound = 0x\[f\]+9ff\\\}.*"
-gdb_test "print /x \$bnd0" "$test_string" "bnd0 after set bnd0raw.ubound"
-
-set test_string ".*\\\{lbound = 0x100, ubound_raw = 0x600\\\}.*"
-gdb_test "print /x \$bnd0raw.lbound = 0x100" "= 0x100" "set value for bnd0raw.lbound"
-gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after setting bnd0raw.lbound"
-set test_string ".*\\\{lbound = 0x100, ubound = 0x\[f\]+9ff\\\}.*"
-gdb_test "print /x \$bnd0" "$test_string" "bnd0 after set bnd0raw.lbound"
-
-# Set full value bnd raw
-set test_string ".*\\\{lbound = 0x10, ubound_raw = 0x\[f\]+cff\\\}.*"
-gdb_test "print /x \$bnd0raw = {0x10, ~0x300}" "$test_string" "set full value for bnd0raw"
-set test_string ".*\\\{lbound = 0x10, ubound = 0x300\\\}.*"
-gdb_test "print /x \$bnd0" "$test_string" "bnd0raw after setting full bnd0raw"
-
-# Set full value bnd
-set test_string ".*\\\{lbound = 0x10, ubound = 0x300\\\}.*"
-gdb_test "print /x \$bnd0 = {0x10, 0x300}" "$test_string" "set full value for bnd0"
-set test_string ".*\\\{lbound = 0x10, ubound_raw = 0x\[f\]+cff\\\}.*"
-gdb_test "print /x \$bnd0raw" "$test_string" "bnd0raw after setting full bnd0"
-
-# Test bndcfg register and bndstatus after a failure on bndstr
-gdb_test "print \$bndstatus.status.error" "= 2" "bndstatus error is 2\
-after a failure on allocating an entry"
-
-# Going to test the python extension for lenght.
-if { ![allow_python_tests] } { continue }
-# Verify if size is right
-set test_string ".*\\\: size 0x11.*"
-gdb_test "print /x \$bnd0 = {0x10, 0x20}" "$test_string" "verify size for bnd0"
diff --git a/gdb/testsuite/gdb.arch/powerpc-aix-prologue.exp b/gdb/testsuite/gdb.arch/powerpc-aix-prologue.exp
index 24c3129..ed595d4 100644
--- a/gdb/testsuite/gdb.arch/powerpc-aix-prologue.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-aix-prologue.exp
@@ -54,7 +54,7 @@ proc insert_breakpoint {function expected_location} {
# If we managed to get the breakpoing address, then check that
# we inserted it at the expected location by examining the
# instruction at that address (we're not interested in the insn
- # itself, but rather at the address printed at the begining of
+ # itself, but rather at the address printed at the beginning of
# the instruction).
if {$address != ""} {
gdb_test "x /i $address" \
diff --git a/gdb/testsuite/gdb.arch/ppc64-break-on-_exit.exp b/gdb/testsuite/gdb.arch/ppc64-break-on-_exit.exp
index d60f63e..f91bebe 100644
--- a/gdb/testsuite/gdb.arch/ppc64-break-on-_exit.exp
+++ b/gdb/testsuite/gdb.arch/ppc64-break-on-_exit.exp
@@ -18,7 +18,7 @@
# if the breakpoint is set past the syscall due to faulty prologue skipping,
# the breakpoint will not trigger.
#
-# In particular, we're trying to excercise the instruction analysis
+# In particular, we're trying to exercise the instruction analysis
# functionality of prologue skipping. If non-minimal symbols are
# read, then that functionality might not be used because f.i.
# line-info is used instead. So, we use nodebug.
diff --git a/gdb/testsuite/gdb.arch/riscv-tdesc-loading.exp b/gdb/testsuite/gdb.arch/riscv-tdesc-loading.exp
index 0e009b4..1cf9848 100644
--- a/gdb/testsuite/gdb.arch/riscv-tdesc-loading.exp
+++ b/gdb/testsuite/gdb.arch/riscv-tdesc-loading.exp
@@ -29,7 +29,7 @@ foreach filename [lsort [glob $srcdir/$subdir/riscv-tdesc-loading-*.xml]] {
}
# Currently it is expected that all of the target descriptions in
- # this test will load successfully, so we expect no additonal
+ # this test will load successfully, so we expect no additional
# output from GDB.
gdb_test_no_output "set tdesc filename $test_path" \
"check [file tail $filename]"
diff --git a/gdb/testsuite/gdb.arch/sparc64-adi.c b/gdb/testsuite/gdb.arch/sparc64-adi.c
index aee5aca..97f6a99 100644
--- a/gdb/testsuite/gdb.arch/sparc64-adi.c
+++ b/gdb/testsuite/gdb.arch/sparc64-adi.c
@@ -31,7 +31,6 @@
#include <string.h>
#include <signal.h>
#include <sys/shm.h>
-#include <errno.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
diff --git a/gdb/testsuite/gdb.base/attach-deleted-exec.exp b/gdb/testsuite/gdb.base/attach-deleted-exec.exp
index 3e31c36..1196115 100644
--- a/gdb/testsuite/gdb.base/attach-deleted-exec.exp
+++ b/gdb/testsuite/gdb.base/attach-deleted-exec.exp
@@ -45,9 +45,27 @@ clean_restart
# Attach. GDB should spot that the executable is gone and fallback to
# use /proc/PID/exe.
-gdb_test "attach $testpid" \
- "Attaching to process $decimal\r\nReading symbols from /proc/${testpid}/exe\\.\\.\\..*" \
- "attach to process with deleted executable"
+set test "attach to process with deleted executable"
+set re \
+ [multi_line \
+ "Attaching to process $decimal" \
+ "Reading symbols from (\[^\r\n\]+)[string_to_regexp ...]" \
+ ".*"]
+set filename ""
+gdb_test_multiple "attach $testpid" $test {
+ -re -wrap $re {
+ set filename $expect_out(1,string)
+ pass $gdb_test_name
+ }
+}
+
+set test "filename /proc/PID/exe"
+set re_nfs \[^\r\n\]+[string_to_regexp /.nfs]\[^\r\n\]+
+if { [regexp $re_nfs $filename] } {
+ unsupported $test
+} else {
+ gdb_assert { [string equal $filename /proc/${testpid}/exe] } $test
+}
# Cleanup.
kill_wait_spawned_process $test_spawn_id
diff --git a/gdb/testsuite/gdb.base/bp-cond-failure.c b/gdb/testsuite/gdb.base/bp-cond-failure.c
index ffab098..b742139 100644
--- a/gdb/testsuite/gdb.base/bp-cond-failure.c
+++ b/gdb/testsuite/gdb.base/bp-cond-failure.c
@@ -15,8 +15,14 @@
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 inline int __attribute__((__always_inline__))
-foo ()
+static int
+foo (int x)
+{
+ return 0;
+}
+
+static int
+foo (char c)
{
return 0; /* Multi-location breakpoint here. */
}
@@ -24,7 +30,7 @@ foo ()
static int __attribute__((noinline))
bar ()
{
- int res = foo (); /* Single-location breakpoint here. */
+ int res = foo ('1'); /* Single-location breakpoint here. */
return res;
}
@@ -34,7 +40,7 @@ main ()
{
int res = bar ();
- res = foo ();
+ res = foo (1);
return res;
}
diff --git a/gdb/testsuite/gdb.base/bp-cond-failure.exp b/gdb/testsuite/gdb.base/bp-cond-failure.exp
index a82cedd..b4c046c 100644
--- a/gdb/testsuite/gdb.base/bp-cond-failure.exp
+++ b/gdb/testsuite/gdb.base/bp-cond-failure.exp
@@ -27,7 +27,7 @@
standard_testfile
if { [prepare_for_testing "failed to prepare" ${binfile} "${srcfile}" \
- {debug}] == -1 } {
+ {debug c++}] == -1 } {
return
}
@@ -44,7 +44,7 @@ if { [is_address_zero_readable] } {
return
}
-proc run_test { cond_eval access_type lineno nloc } {
+proc run_test { cond_eval access_type bpexpr nloc } {
clean_restart ${::binfile}
if { ![runto_main] } {
@@ -56,23 +56,37 @@ proc run_test { cond_eval access_type lineno nloc } {
}
# Setup the conditional breakpoint and record its number.
- gdb_breakpoint "${::srcfile}:${lineno} if (*(${access_type} *) 0) == 0"
+ gdb_breakpoint "${bpexpr} if (*(${access_type} *) 0) == 0"
+
+ # This test aims to test that GDB displays the correct breakpoint number
+ # and location when there is an error testing a breakpoint condition,
+ # so it is important to hardcode the breakpoint number into the regex,
+ # along with the location, if applicable.
set bp_num [get_integer_valueof "\$bpnum" "*UNKNOWN*"]
if { $nloc > 1 } {
- set bp_num_pattern "${bp_num}.1"
+ # We hardcode location 2 because, for some reason, Clang will always
+ # order the debug information so we hit the second location. For
+ # simplicity the .c is ordered in such a way that GCC will also order
+ # the debug info to have us land on location 2.
+ gdb_test "continue" \
+ [multi_line \
+ "Continuing\\." \
+ "Error in testing condition for breakpoint ${bp_num}.2:" \
+ "Cannot access memory at address 0x0" \
+ "" \
+ "Breakpoint ${bp_num}.2, foo \\(c=49 ...\\) at \[^\r\n\]+:\[0-9\]+" \
+ "${::decimal}\\s+\[^\r\n\]+ breakpoint here\\. \[^\r\n\]+"]
} else {
- set bp_num_pattern "${bp_num}"
+ gdb_test "continue" \
+ [multi_line \
+ "Continuing\\." \
+ "Error in testing condition for breakpoint ${bp_num}:" \
+ "Cannot access memory at address 0x0" \
+ "" \
+ "Breakpoint ${bp_num}, bar \\(\\) at \[^\r\n\]+:\[0-9\]+" \
+ "${::decimal}\\s+\[^\r\n\]+ breakpoint here\\. \[^\r\n\]+"]
}
-
- gdb_test "continue" \
- [multi_line \
- "Continuing\\." \
- "Error in testing condition for breakpoint ${bp_num_pattern}:" \
- "Cannot access memory at address 0x0" \
- "" \
- "Breakpoint ${bp_num_pattern}, \(foo\|bar\) \\(\\) at \[^\r\n\]+:${lineno}" \
- "${::decimal}\\s+\[^\r\n\]+ breakpoint here\\. \[^\r\n\]+"]
}
# If we're using a remote target then conditions could be evaulated
@@ -101,7 +115,7 @@ gdb_test_multiple "show breakpoint condition-evaluation" "" {
}
# Where the breakpoint will be placed.
-set bp_line_multi_loc [gdb_get_line_number "Multi-location breakpoint here"]
+set bp_line_multi_loc "foo"
set bp_line_single_loc [gdb_get_line_number "Single-location breakpoint here"]
foreach_with_prefix access_type { "char" "short" "int" "long long" } {
@@ -110,7 +124,7 @@ foreach_with_prefix access_type { "char" "short" "int" "long long" } {
run_test $cond_eval $access_type $bp_line_multi_loc 2
}
with_test_prefix "single-loc" {
- run_test $cond_eval $access_type $bp_line_single_loc 1
+ run_test $cond_eval $access_type "${srcfile}:${bp_line_single_loc}" 1
}
}
}
diff --git a/gdb/testsuite/gdb.base/break-interp.exp b/gdb/testsuite/gdb.base/break-interp.exp
index 98f67ee..fd8afdd 100644
--- a/gdb/testsuite/gdb.base/break-interp.exp
+++ b/gdb/testsuite/gdb.base/break-interp.exp
@@ -495,26 +495,14 @@ proc test_ld {file ifmain trynosym displacement} {
if $ifmain {
reach $solib_bp run $displacement 3
- # Use two separate gdb_test_multiple statements to avoid timeouts due
- # to slow processing of wildcard capturing long output
- set test "info files"
set entrynohex ""
- set info_line [join [list \
- "\r\n" "\[\t\]" "0x\[0-9af\]+" " - " \
- "0x\[0-9af\]+" " @ " "0x\[0-9af\]+" \
- " is " "\[^\r\n\]+"] ""]
- gdb_test_multiple $test $test {
+ gdb_test_multiple "info files" "" -lbl {
-re "\r\n\[\t \]*Entry point:\[\t \]*0x(\[0-9a-f\]+)\r\n" {
set entrynohex $expect_out(1,string)
- gdb_test_multiple "" $test {
- -re "\r\n$gdb_prompt $" {
- pass $test
- }
- -re $info_line {
- # Avoid timeout with check-read1
- exp_continue
- }
- }
+ exp_continue
+ }
+ -re -wrap "" {
+ gdb_assert { ![string equal $entrynohex ""] } $gdb_test_name
}
}
diff --git a/gdb/testsuite/gdb.base/call-sc.exp b/gdb/testsuite/gdb.base/call-sc.exp
index c485c9b..91a4e5b 100644
--- a/gdb/testsuite/gdb.base/call-sc.exp
+++ b/gdb/testsuite/gdb.base/call-sc.exp
@@ -184,7 +184,7 @@ proc test_scalar_returns { } {
# known, both failed to print a final "source and line" and misplaced
# the frame ("No frame").
- # The test is writen so that it only reports one FAIL/PASS for the
+ # The test is written so that it only reports one FAIL/PASS for the
# entire operation. The value returned is checked further down.
# "return_value_unknown", if non-empty, records why GDB realised
# that it didn't know where the return value was.
diff --git a/gdb/testsuite/gdb.base/checkpoint.exp b/gdb/testsuite/gdb.base/checkpoint.exp
index f87f528..31b5a13 100644
--- a/gdb/testsuite/gdb.base/checkpoint.exp
+++ b/gdb/testsuite/gdb.base/checkpoint.exp
@@ -295,30 +295,48 @@ clean_restart $binfile
runto_main
gdb_breakpoint $break1_loc
-gdb_test "commands\nsilent\nif (lines % 2)\ncheckpoint\nend\n continue\nend" \
+set cmd \
+ [join \
+ [list \
+ "commands" \
+ "if (lines % 2)" \
+ " checkpoint" \
+ "else" \
+ " continue" \
+ "end" \
+ "end"] \
+ "\n"]
+gdb_test $cmd \
"" \
"set checkpoint breakpoint"
-set prev_timeout $timeout
-set timeout [expr $timeout + 120]
-verbose "Timeout now $timeout sec."
-
-gdb_breakpoint $break2_loc
-gdb_test "continue" "breakpoint 2.*" "break2 with many checkpoints"
+set nr_ok 0
+for {set iter 0} {$iter < 600} {incr iter} {
+ set ok 0
+ gdb_test_multiple "continue" "" {
+ -re -wrap "breakpoint 1.*" {
+ set ok 1
+ }
+ -re -wrap "" {
+ }
+ }
+ if { $ok } {
+ incr nr_ok
+ } else {
+ break
+ }
+}
+gdb_assert { $nr_ok == 600 } "break1 with many checkpoints"
set count 0
set msg "info checkpoints with at least 600 checkpoints"
gdb_test_multiple "info checkpoints" $msg {
- -re " $decimal process \[^\r\]*\r\n" {
+ -re "\r\n $decimal process \[^\r\]*" {
incr count
exp_continue
}
- -re "$gdb_prompt $" {
- if { $count >= 600 } {
- pass $msg
- } else {
- fail $msg
- }
+ -re -wrap "" {
+ gdb_assert { $count == 600 } $gdb_test_name
}
}
@@ -329,10 +347,6 @@ gdb_test_multiple "info checkpoints" $msg {
gdb_test "kill" "" "kill all one with many checkpoints" \
"Kill the program being debugged.*y or n. $" "y"
-# Restore old timeout
-set timeout $prev_timeout
-verbose "Timeout now $timeout sec."
-
#
# Finished: cleanup
#
diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp
index 4a0a373..57b4d1c 100644
--- a/gdb/testsuite/gdb.base/completion.exp
+++ b/gdb/testsuite/gdb.base/completion.exp
@@ -145,7 +145,7 @@ append regs_output "\n"
append regs_output [capture_command_output "mt print user-registers" \
".*Name.*Nr\[^\n]*\n"]
set all_regs {}
-foreach {- reg} [regexp -all -inline -line {^\s+(\w+)} $regs_output] {
+foreach {- reg} [regexp -all -inline -line {^\s*(\w+)} $regs_output] {
lappend all_regs $reg
}
diff --git a/gdb/testsuite/gdb.base/empty-host-env-vars.exp b/gdb/testsuite/gdb.base/empty-host-env-vars.exp
index e6e9d6e..5fab65a 100644
--- a/gdb/testsuite/gdb.base/empty-host-env-vars.exp
+++ b/gdb/testsuite/gdb.base/empty-host-env-vars.exp
@@ -21,16 +21,14 @@ require {!is_remote host}
set all_env_vars { HOME XDG_CACHE_HOME LOCALAPPDATA XDG_CONFIG_HOME }
-# Record the initial value of the index-cache directory.
+set re_pre \
+ [string_to_regexp {The directory of the index cache is "}]
+set re_post \
+ [string_to_regexp {".}]
+
+# Show the initial value of the index-cache directory.
clean_restart
-set index_cache_directory ""
-gdb_test_multiple "show index-cache directory" "" {
- -re -wrap "The directory of the index cache is \"(.*)\"\\." {
- set index_cache_directory $expect_out(1,string)
- set index_cache_directory [string_to_regexp $index_cache_directory]
- pass $gdb_test_name
- }
-}
+gdb_test "show index-cache directory" $re_pre\[^\r\n\]*$re_post
foreach_with_prefix env_var_name $all_env_vars {
# Restore the original state of the environment variable.
@@ -38,18 +36,7 @@ foreach_with_prefix env_var_name $all_env_vars {
set env($env_var_name) {}
clean_restart
- # Verify that the empty environment variable didn't affect the
- # index-cache directory setting, that we still see the initial value.
- # "HOME" is different, because if that one is unset, GDB isn't even
- # able to compute the default location. In that case, we expect it to
- # be empty.
- if { $env_var_name == "HOME" } {
- gdb_test "show index-cache directory" \
- "The directory of the index cache is \"\"\\."
- } else {
- gdb_test "show index-cache directory" \
- "The directory of the index cache is \"$index_cache_directory\"\\."
- }
+ gdb_test "show index-cache directory" $re_pre\[^\r\n\]*$re_post
}
}
@@ -69,7 +56,6 @@ with_test_prefix "all env vars" {
clean_restart
- gdb_test "show index-cache directory" \
- "The directory of the index cache is \"\"\\."
+ gdb_test "show index-cache directory" $re_pre$re_post
}
}
diff --git a/gdb/testsuite/gdb.base/filename-completion.exp b/gdb/testsuite/gdb.base/filename-completion.exp
index 95a9fba..389e2d7 100644
--- a/gdb/testsuite/gdb.base/filename-completion.exp
+++ b/gdb/testsuite/gdb.base/filename-completion.exp
@@ -113,7 +113,281 @@ proc test_gdb_complete_filename_multiple {
$testname
}
-# Run filename completetion tests for those command that accept quoting and
+# Helper proc. Returns a string containing the escape sequence to move the
+# cursor COUNT characters to the left. There's no sanity checking performed
+# on COUNT, so the user of this proc must ensure there are more than COUNT
+# characters on the current line.
+proc c_left { count } {
+ string repeat "\033\[D" $count
+}
+
+# This proc is based off of test_gdb_complete_tab_multiple in
+# completion-support.exp library. This proc however tests completing a
+# filename in the middle of a command line.
+#
+# INPUT_LINE is the line to complete, BACK_COUNT is the number of characters
+# to move the cursor left before sending tab to complete the line.
+# ADD_COMPLETED_LINE is what we expect to be unconditionally added the first
+# time tab is sent. On additional tabs COMPLETION_LIST will be displayed.
+# TESTNAME is used as expected.
+proc test_tab_complete_within_line_multiple { input_line back_count \
+ add_completed_line \
+ completion_list \
+ testname } {
+ global gdb_prompt
+
+ # After displaying the completion list the line will be reprinted, but
+ # now with ADD_COMPLETED_LINE inserted. Build the regexp to match
+ # against this expanded line. The new content will be inserted
+ # BACK_COUNT character from the end of the line.
+ set expanded_line \
+ [join [list \
+ [string range $input_line 0 end-$back_count] \
+ ${add_completed_line} \
+ [string range $input_line end-[expr $back_count - 1] end]] \
+ ""]
+ set expanded_line_re [string_to_regexp $expanded_line]
+
+ # Convert input arguments into regexp.
+ set input_line_re [string_to_regexp $input_line]
+ set add_completed_line_re [string_to_regexp $add_completed_line]
+ set completion_list_re [make_tab_completion_list_re $completion_list]
+
+ # Similar to test_tab_complete_within_line_unique, build two
+ # regexp for matching the line after the first tab. Which regexp
+ # matches will depend on the version and/or configuration of
+ # readline. This first regexp moves the cursor backwards and then
+ # inserts new content into the line.
+ set after_tab_re1 "^$input_line_re"
+ set after_tab_re1 "$after_tab_re1\\\x08{$back_count}"
+ set after_tab_re1 "$after_tab_re1${completion::bell_re}"
+ set after_tab_re1 "$after_tab_re1\\\x1b\\\x5b[string length $add_completed_line]\\\x40"
+ set after_tab_re1 "$after_tab_re1$add_completed_line_re\$"
+
+ # This second regexp moves the cursor backwards and overwrites the
+ # end of the line, then moves the cursor backwards again to the
+ # correct position within the line.
+ set after_tab_re2 "^$input_line_re"
+ set after_tab_re2 "$after_tab_re2\\\x08{$back_count}"
+ set after_tab_re2 "$after_tab_re2${completion::bell_re}"
+ set tail [string range $input_line end-[expr $back_count - 1] end]
+ set after_tab_re2 "$after_tab_re2$add_completed_line_re"
+ set after_tab_re2 "$after_tab_re2[string_to_regexp $tail]"
+ set after_tab_re2 "$after_tab_re2\\\x08{$back_count}"
+
+ send_gdb "$input_line[c_left $back_count]\t"
+ gdb_test_multiple "" "$testname (first tab)" {
+ -re "(?:(?:$after_tab_re1)|(?:$after_tab_re2))" {
+ send_gdb "\t"
+ # If we auto-completed to an ambiguous prefix, we need an
+ # extra tab to show the matches list.
+ if {$add_completed_line != ""} {
+ send_gdb "\t"
+ set maybe_bell ${completion::bell_re}
+ } else {
+ set maybe_bell ""
+ }
+ gdb_test_multiple "" "$testname (second tab)" {
+ -re "^${maybe_bell}\r\n$completion_list_re\r\n$gdb_prompt " {
+ gdb_test_multiple "" "$testname (second tab)" {
+ -re "^$expanded_line_re\\\x08{$back_count}$" {
+ pass $gdb_test_name
+ }
+ }
+ }
+ -re "${maybe_bell}\r\n.+\r\n$gdb_prompt $" {
+ fail $gdb_test_name
+ }
+ }
+ }
+ }
+
+ clear_input_line $testname
+}
+
+# Wrapper around test_gdb_complete_tab_unique to test completing a unique
+# item in the middle of a line. INPUT_LINE is the line to complete.
+# BACK_COUNT is the number of characters to move left within INPUT_LINE
+# before sending tab to perform completion. INSERT_STR is what we expect to
+# see inserted by the completion engine in GDB.
+proc test_tab_complete_within_line_unique { input_line back_count insert_str } {
+ # Build regexp for the line after completion has occurred. As
+ # completion is being performed in the middle of the line the
+ # sequence of characters we see can vary depending on which
+ # version of readline is in use, and/or how readline is
+ # configured. Currently two different approaches are covered as
+ # RE1 and RE2. Both of these regexp cover the complete possible
+ # output.
+ #
+ # In the first case we see the input line followed by some number
+ # of characters to move the cursor backwards. After this we see a
+ # control sequence that tells the terminal that some characters
+ # are going to be inserted into the middle of the line, the new
+ # characters are then emitted. The terminal itself is responsible
+ # for preserving the tail of the line, so these characters are not
+ # re-emitted.
+ set re1 [string_to_regexp $input_line]
+ set re1 $re1\\\x08{$back_count}
+ set re1 $re1\\\x1b\\\x5b[string length $insert_str]\\\x40
+ set re1 $re1[string_to_regexp $insert_str]
+
+ # In this second regexp we again start with the input line
+ # followed by the control characters to move the cursor backwards.
+ # This time though readline emits the new characters and then
+ # re-emits the tail of the original line. This new content will
+ # overwrite the original output on the terminal. Finally, control
+ # characters are emitted to move the cursor back to the correct
+ # place in the middle of the line.
+ set re2 [string_to_regexp $input_line]
+ set re2 $re2\\\x08{$back_count}
+ set re2 $re2[string_to_regexp $insert_str]
+ set tail [string range $input_line end-[expr $back_count - 1] end]
+ set re2 $re2[string_to_regexp $tail]
+ set re2 $re2\\\x08{$back_count}
+
+ # We can now perform the tab-completion, we check for either of
+ # the possible output regexp patterns.
+ test_gdb_complete_tab_unique \
+ "${input_line}[c_left $back_count]" \
+ "(?:(?:$re1)|(?:$re2))" \
+ "" \
+ "complete unique file within command line"
+}
+
+
+# Run filename completion tests for those command that accept quoting and
+# escaping of the filename argument. CMD is the initial part of the command
+# line, paths to complete will be added after CMD.
+#
+# ROOT is the base directory as returned from setup_directory_tree, though,
+# if ROOT is a sub-directory of the user's home directory ROOT might have
+# been modified to replace the $HOME prefix with a single "~" character.
+proc run_quoting_and_escaping_tests_1 { root cmd } {
+ gdb_start
+
+ # Completing 'thread apply all ...' commands uses a custom word
+ # point. At one point we had a bug where doing this would break
+ # completion of quoted filenames that contained white space.
+ test_gdb_complete_unique "thread apply all hel" \
+ "thread apply all help" " " false \
+ "complete a 'thread apply all' command"
+
+ foreach_with_prefix qc [list "" "'" "\""] {
+ test_gdb_complete_none "$cmd ${qc}${root}/xx" \
+ "expand a non-existent filename"
+
+ test_gdb_complete_unique "$cmd ${qc}${root}/a" \
+ "$cmd ${qc}${root}/aaa/" "" false \
+ "expand a unique directory name"
+
+ test_gdb_complete_unique "$cmd ${qc}${root}/cc2" \
+ "$cmd ${qc}${root}/cc2${qc}" " " false \
+ "expand a unique filename"
+
+ test_gdb_complete_filename_multiple "$cmd ${qc}${root}/" \
+ "b" "b" {
+ "bb1/"
+ "bb2/"
+ } "" "${qc}" false \
+ "expand multiple directory names"
+
+ test_gdb_complete_filename_multiple "$cmd ${qc}${root}/" \
+ "c" "c" {
+ "cc1/"
+ "cc2"
+ } "" "${qc}" false \
+ "expand mixed directory and file names"
+
+ if { $qc ne "" } {
+ set sp " "
+ } else {
+ set sp "\\ "
+ }
+
+ if { $qc eq "'" } {
+ set dq "\""
+ } else {
+ set dq "\\\""
+ }
+
+ test_gdb_complete_unique "${cmd} ${qc}${root}/bb2/dir${sp}1/" \
+ "${cmd} ${qc}${root}/bb2/dir${sp}1/unique${sp}file${qc}" " " \
+ false \
+ "expand a unique file name in a directory containing a space"
+
+ test_gdb_complete_filename_multiple "$cmd ${qc}${root}/bb2/" \
+ "d" "ir${sp}" {
+ "dir 1/"
+ "dir 2/"
+ } "" "${qc}" false \
+ "expand multiple directory names containing spaces"
+
+ test_gdb_complete_filename_multiple "${cmd} ${qc}${root}/bb2/dir${sp}2/" \
+ "f" "ile${sp}" {
+ "file 1"
+ "file 2"
+ } "" "${qc}" false \
+ "expand contents of a directory containing a space"
+
+ test_gdb_complete_filename_multiple "$cmd ${qc}${root}/aaa/" \
+ "a" "a${sp}" {
+ "aa bb"
+ "aa cc"
+ } "" "${qc}" false \
+ "expand filenames containing spaces"
+
+ test_gdb_complete_filename_multiple "$cmd ${qc}${root}/bb1/" \
+ "a" "a" {
+ "aa\"bb"
+ "aa'bb"
+ } "" "${qc}" false \
+ "expand filenames containing quotes"
+
+ test_gdb_complete_unique "$cmd ${qc}${root}/bb1/aa${dq}" \
+ "$cmd ${qc}${root}/bb1/aa${dq}bb${qc}" " " false \
+ "expand unique filename containing double quotes"
+
+ # It is not possible to include a single quote character
+ # within a single quoted string. However, GDB does not do
+ # anything smart if a user tries to do this. Avoid testing
+ # this case. Maybe in the future we'll figure a way to avoid
+ # this situation.
+ if { $qc ne "'" } {
+ if { $qc eq "" } {
+ set sq "\\'"
+ } else {
+ set sq "'"
+ }
+
+ test_gdb_complete_unique "$cmd ${qc}${root}/bb1/aa${sq}" \
+ "$cmd ${qc}${root}/bb1/aa${sq}bb${qc}" " " false \
+ "expand unique filename containing single quote"
+ }
+ }
+
+ gdb_exit
+}
+
+# Tests for completing a filename in the middle of a command line. This
+# represents a user typing out a command line then moving the cursor left
+# (e.g. with the left arrow key), editing a filename argument, and then
+# using tab completion to try and complete the filename even though there is
+# other content on the command line after the filename.
+proc run_mid_line_completion_tests { root cmd } {
+ gdb_start
+
+ test_tab_complete_within_line_unique \
+ "$cmd \"$root/bb2/dir 1/unique fi \"xxx\"" 6 "le\""
+
+ test_tab_complete_within_line_multiple \
+ "$cmd \"$root/aaa/a \"xxx\"" 6 "a " \
+ [list "aa bb" "aa cc"] \
+ "complete filename mid-line with multiple possibilities"
+
+ gdb_exit
+}
+
+# Run filename completion tests for those command that accept quoting and
# escaping of the filename argument.
#
# ROOT is the base directory as returned from setup_directory_tree, though,
@@ -127,109 +401,16 @@ proc run_quoting_and_escaping_tests { root } {
"target core" "target exec" "target tfile" \
"maint print c-tdesc" "compile file" \
"save gdb-index" "save gdb-index -dwarf-5" } {
- gdb_start
-
- # Completing 'thread apply all ...' commands uses a custom word
- # point. At one point we had a bug where doing this would break
- # completion of quoted filenames that contained white space.
- test_gdb_complete_unique "thread apply all hel" \
- "thread apply all help" " " false \
- "complete a 'thread apply all' command"
-
- foreach_with_prefix qc [list "" "'" "\""] {
- test_gdb_complete_none "$cmd ${qc}${root}/xx" \
- "expand a non-existent filename"
-
- test_gdb_complete_unique "$cmd ${qc}${root}/a" \
- "$cmd ${qc}${root}/aaa/" "" false \
- "expand a unique directory name"
-
- test_gdb_complete_unique "$cmd ${qc}${root}/cc2" \
- "$cmd ${qc}${root}/cc2${qc}" " " false \
- "expand a unique filename"
-
- test_gdb_complete_filename_multiple "$cmd ${qc}${root}/" \
- "b" "b" {
- "bb1/"
- "bb2/"
- } "" "${qc}" false \
- "expand multiple directory names"
-
- test_gdb_complete_filename_multiple "$cmd ${qc}${root}/" \
- "c" "c" {
- "cc1/"
- "cc2"
- } "" "${qc}" false \
- "expand mixed directory and file names"
-
- if { $qc ne "" } {
- set sp " "
- } else {
- set sp "\\ "
- }
-
- if { $qc eq "'" } {
- set dq "\""
- } else {
- set dq "\\\""
- }
-
- test_gdb_complete_unique "${cmd} ${qc}${root}/bb2/dir${sp}1/" \
- "${cmd} ${qc}${root}/bb2/dir${sp}1/unique${sp}file${qc}" " " \
- false \
- "expand a unique file name in a directory containing a space"
-
- test_gdb_complete_filename_multiple "$cmd ${qc}${root}/bb2/" \
- "d" "ir${sp}" {
- "dir 1/"
- "dir 2/"
- } "" "${qc}" false \
- "expand multiple directory names containing spaces"
-
- test_gdb_complete_filename_multiple "${cmd} ${qc}${root}/bb2/dir${sp}2/" \
- "f" "ile${sp}" {
- "file 1"
- "file 2"
- } "" "${qc}" false \
- "expand contents of a directory containing a space"
-
- test_gdb_complete_filename_multiple "$cmd ${qc}${root}/aaa/" \
- "a" "a${sp}" {
- "aa bb"
- "aa cc"
- } "" "${qc}" false \
- "expand filenames containing spaces"
-
- test_gdb_complete_filename_multiple "$cmd ${qc}${root}/bb1/" \
- "a" "a" {
- "aa\"bb"
- "aa'bb"
- } "" "${qc}" false \
- "expand filenames containing quotes"
-
- test_gdb_complete_unique "$cmd ${qc}${root}/bb1/aa${dq}" \
- "$cmd ${qc}${root}/bb1/aa${dq}bb${qc}" " " false \
- "expand unique filename containing double quotes"
-
- # It is not possible to include a single quote character
- # within a single quoted string. However, GDB does not do
- # anything smart if a user tries to do this. Avoid testing
- # this case. Maybe in the future we'll figure a way to avoid
- # this situation.
- if { $qc ne "'" } {
- if { $qc eq "" } {
- set sq "\\'"
- } else {
- set sq "'"
- }
-
- test_gdb_complete_unique "$cmd ${qc}${root}/bb1/aa${sq}" \
- "$cmd ${qc}${root}/bb1/aa${sq}bb${qc}" " " false \
- "expand unique filename containing single quote"
- }
+ # Try each test placing the filename as the first argument
+ # then again with a quoted string immediately after the
+ # command. This works because the filename completer will
+ # complete any number of filenames, even if the command only
+ # takes a single filename.
+ foreach_with_prefix filler { "" " \"xxx\"" " 'zzz'" " yyy"} {
+ run_quoting_and_escaping_tests_1 $root "$cmd$filler"
}
- gdb_exit
+ run_mid_line_completion_tests $root $cmd
}
}
@@ -290,7 +471,7 @@ proc run_unquoted_tests_core { root cmd { prefix "" } } {
}
-# Run filename completetion tests for a sample of commands that take an
+# Run filename completion tests for a sample of commands that take an
# unquoted, unescaped filename as an argument. Only a sample of commands
# are (currently) tested as there's a lot of commands that accept this style
# of filename argument.
diff --git a/gdb/testsuite/gdb.base/gnu-ifunc.exp b/gdb/testsuite/gdb.base/gnu-ifunc.exp
index 5bc534b..ff1d561 100644
--- a/gdb/testsuite/gdb.base/gnu-ifunc.exp
+++ b/gdb/testsuite/gdb.base/gnu-ifunc.exp
@@ -225,7 +225,7 @@ proc misc_tests {resolver_attr resolver_debug final_debug} {
return 1
}
- # The "if" condition is artifical to test regression of a former patch.
+ # The "if" condition is artificial to test regression of a former patch.
gdb_breakpoint "[gdb_get_line_number "break-at-nextcall"] if i && (int) gnu_ifunc (i) != 42"
gdb_breakpoint [gdb_get_line_number "break-at-call"]
diff --git a/gdb/testsuite/gdb.base/hbreak-unmapped.exp b/gdb/testsuite/gdb.base/hbreak-unmapped.exp
index ccb4b20..b28af6d 100644
--- a/gdb/testsuite/gdb.base/hbreak-unmapped.exp
+++ b/gdb/testsuite/gdb.base/hbreak-unmapped.exp
@@ -68,8 +68,7 @@ gdb_test "hbreak *0" "Hardware assisted breakpoint \[0-9\]+ at 0x0"
gdb_test "info break" "hw breakpoint.*y.*0x0\+\[ \t\]\+" \
"info break shows hw breakpoint"
-gdb_test_no_output "delete \$bpnum" "" "delete" \
- "delete hw breakpoint"
+gdb_test_no_output "delete \$bpnum" "delete hw breakpoint"
gdb_test "info break" "No breakpoints, watchpoints, tracepoints, or catchpoints\." \
"info break shows no breakpoints, watchpoints, tracepoints, or catchpoints"
diff --git a/gdb/testsuite/gdb.base/info_sources_2.exp b/gdb/testsuite/gdb.base/info_sources_2.exp
index aa33f38..90442d0 100644
--- a/gdb/testsuite/gdb.base/info_sources_2.exp
+++ b/gdb/testsuite/gdb.base/info_sources_2.exp
@@ -120,7 +120,7 @@ proc run_info_sources { extra_args args } {
}
}
- # Now check ARGS agaisnt the values held in INFO_SOURCES map.
+ # Now check ARGS against the values held in INFO_SOURCES map.
foreach {objfile sourcefile} $args {
# First, figure out if we're expecting SOURCEFILE to be present,
# or not.
diff --git a/gdb/testsuite/gdb.base/killed-outside.exp b/gdb/testsuite/gdb.base/killed-outside.exp
index 87bd7be..88f4afe 100644
--- a/gdb/testsuite/gdb.base/killed-outside.exp
+++ b/gdb/testsuite/gdb.base/killed-outside.exp
@@ -102,7 +102,7 @@ with_test_prefix "continue" {
}
}
-# Try stepping the program. Stepping may go through diferent code
+# Try stepping the program. Stepping may go through different code
# paths in the target backends.
with_test_prefix "stepi" {
test {
diff --git a/gdb/testsuite/gdb.base/lineinc.exp b/gdb/testsuite/gdb.base/lineinc.exp
index 1fe1390..2386113 100644
--- a/gdb/testsuite/gdb.base/lineinc.exp
+++ b/gdb/testsuite/gdb.base/lineinc.exp
@@ -70,7 +70,7 @@
# #included by a given source file in a list sorted by the line at
# which they were #included; this gives GDB the chance to detect
# multiple #inclusions at the same line, complain, and assign
-# distinct, albiet incorrect, line numbers to each #inclusion.
+# distinct, albeit incorrect, line numbers to each #inclusion.
#
# However, at one point GDB was sorting the list in reverse order,
# while the code to assign new, distinct line numbers assumed it was
diff --git a/gdb/testsuite/gdb.base/overlays.exp b/gdb/testsuite/gdb.base/overlays.exp
index 2adde30..c8730ec 100644
--- a/gdb/testsuite/gdb.base/overlays.exp
+++ b/gdb/testsuite/gdb.base/overlays.exp
@@ -150,7 +150,7 @@ if {$data_overlays} {
}
# Verify that early-mapped overlays have been bumped out
-# by later-mapped overlays layed over in the same VMA range.
+# by later-mapped overlays laid over in the same VMA range.
send_gdb "overlay list\n"
gdb_expect {
diff --git a/gdb/testsuite/gdb.base/reggroups.exp b/gdb/testsuite/gdb.base/reggroups.exp
index f96153b..56c00e5 100644
--- a/gdb/testsuite/gdb.base/reggroups.exp
+++ b/gdb/testsuite/gdb.base/reggroups.exp
@@ -27,7 +27,7 @@ if {![runto_main]} {
return 0
}
-set invalid_register_re "Invalid register .*"
+set invalid_register_re "Invalid register \[^\r\n\]*"
# Fetch all reggroups from 'maint print reggroups'.
@@ -51,6 +51,7 @@ proc fetch_reggroups {test} {
}
}
+ verbose -log "found reggroups: $reggroups"
return $reggroups
}
@@ -78,21 +79,34 @@ proc fetch_reggroup_regs {reggroup test} {
# xmm0 {v4_float = {0x0, 0x0, 0x0, 0x0}, v2_double = {0x0, ... }}
#
set regs {}
- gdb_test_multiple "info reg $reggroup" $test {
- -re "info reg $reggroup\r\n" {
+ set have_invalid_register_fail 0
+ set re_regname "\[0-9a-zA-Z_-\]+"
+ set re_hws "\[ \t\]+"
+ set re_hs "\[^\n\r\]+"
+ set re_eol "\r\n"
+ set re_lookahead_eol "(?=$re_eol)"
+ gdb_test_multiple "info reg $reggroup" $test -lbl {
+ -re "^info reg $reggroup" {
exp_continue
}
- -re "^(\[0-9a-zA-Z-\]+)\[ \t\]+(0x\[0-9a-f\]+)\[ \t\]+(\[^\n\r\]+)\r\n" {
+ -re "^${re_eol}($re_regname)$re_hws$::hex$re_hws${re_hs}$re_lookahead_eol" {
lappend regs $expect_out(1,string)
exp_continue
}
-re $invalid_register_re {
- fail "$test (unexpected invalid register response)"
+ set have_invalid_register_fail 1
+ exp_continue
}
- -re "$gdb_prompt $" {
- pass $test
+ -re -wrap "" {
+ if { $have_invalid_register_fail } {
+ fail "$test (unexpected invalid register response)"
+ } else {
+ pass $test
+ }
}
}
+
+ verbose -log "found regs in reggroup $reggroup: [join $regs]"
return $regs
}
diff --git a/gdb/testsuite/gdb.base/remote.exp b/gdb/testsuite/gdb.base/remote.exp
index 015cc56..52c4d27 100644
--- a/gdb/testsuite/gdb.base/remote.exp
+++ b/gdb/testsuite/gdb.base/remote.exp
@@ -167,7 +167,7 @@ set sizeof_random_data [get_sizeof "random_data" 48*1024]
clean_restart $binfile
#
-# Part THREE: Check the upload behavour
+# Part THREE: Check the upload behavior.
#
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.base/reset-catchpoint-cond-lib.c b/gdb/testsuite/gdb.base/reset-catchpoint-cond-lib.c
index 350c0c0..06f3c3d 100644
--- a/gdb/testsuite/gdb.base/reset-catchpoint-cond-lib.c
+++ b/gdb/testsuite/gdb.base/reset-catchpoint-cond-lib.c
@@ -20,7 +20,6 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
-#include <unistd.h>
#include <assert.h>
#include <stdlib.h>
diff --git a/gdb/testsuite/gdb.base/return.exp b/gdb/testsuite/gdb.base/return.exp
index 29de995..23016f8 100644
--- a/gdb/testsuite/gdb.base/return.exp
+++ b/gdb/testsuite/gdb.base/return.exp
@@ -15,12 +15,12 @@
# This file was written by Jeff Law. (law@cs.utah.edu)
+set allow_float_test [allow_float_test]
+
if { [prepare_for_testing "failed to prepare" "return"] } {
return -1
}
-set allow_float_test [allow_float_test]
-
proc return_tests { } {
global gdb_prompt allow_float_test
diff --git a/gdb/testsuite/gdb.base/scope-hw-watch-disable.exp b/gdb/testsuite/gdb.base/scope-hw-watch-disable.exp
index 6113770..29eb682 100644
--- a/gdb/testsuite/gdb.base/scope-hw-watch-disable.exp
+++ b/gdb/testsuite/gdb.base/scope-hw-watch-disable.exp
@@ -29,6 +29,15 @@ if {![runto_main]} {
return -1
}
+gdb_test_multiple "maint info break" "maint info break before" {
+ -re -wrap "watchpoint.*" {
+ fail $gdb_test_name
+ }
+ -re -wrap "" {
+ pass $gdb_test_name
+ }
+}
+
gdb_test "awatch a" \
"Can't set read/access watchpoint when hardware watchpoints are disabled." \
"unsuccessful attempt to create an access watchpoint"
@@ -36,5 +45,14 @@ gdb_test "rwatch b" \
"Can't set read/access watchpoint when hardware watchpoints are disabled." \
"unsuccessful attempt to create a read watchpoint"
+gdb_test_multiple "maint info break" "maint info break after" {
+ -re -wrap "watchpoint.*" {
+ fail $gdb_test_name
+ }
+ -re -wrap "" {
+ pass $gdb_test_name
+ }
+}
+
# The program continues until termination.
gdb_continue_to_end
diff --git a/gdb/testsuite/gdb.base/sigbpt.exp b/gdb/testsuite/gdb.base/sigbpt.exp
index 4855400..6f4616e 100644
--- a/gdb/testsuite/gdb.base/sigbpt.exp
+++ b/gdb/testsuite/gdb.base/sigbpt.exp
@@ -22,7 +22,7 @@
# This test is known to tickle the following problems: kernel letting
# the inferior execute both the system call, and the instruction
# following, when single-stepping a system call; kernel failing to
-# propogate the single-step state when single-stepping the sigreturn
+# propagate the single-step state when single-stepping the sigreturn
# system call, instead resuming the inferior at full speed; GDB
# doesn't know how to software single-step across a sigreturn
# instruction. Since the kernel problems can be "fixed" using
diff --git a/gdb/testsuite/gdb.base/signals.exp b/gdb/testsuite/gdb.base/signals.exp
index 38c63b5..e6bd35a 100644
--- a/gdb/testsuite/gdb.base/signals.exp
+++ b/gdb/testsuite/gdb.base/signals.exp
@@ -105,7 +105,7 @@ if {[runto_main]} {
"next to ++count #2"
sleep 2
- # ...call the function, which is immediatly interrupted
+ # ...call the function, which is immediately interrupted
gdb_test "p func1 ()" \
"Breakpoint \[0-9\]*, handler.*
diff --git a/gdb/testsuite/gdb.base/sigrepeat.c b/gdb/testsuite/gdb.base/sigrepeat.c
index 8717721..79fe648 100644
--- a/gdb/testsuite/gdb.base/sigrepeat.c
+++ b/gdb/testsuite/gdb.base/sigrepeat.c
@@ -59,7 +59,7 @@ handler (int sig)
while (1)
{
/* Wait until a signal has become pending, that way when this
- handler returns it will be immediatly delivered leading to
+ handler returns it will be immediately delivered leading to
back-to-back signals. */
sigset_t set;
sigemptyset (&set);
diff --git a/gdb/testsuite/gdb.base/store.exp b/gdb/testsuite/gdb.base/store.exp
index 9286253..2271156 100644
--- a/gdb/testsuite/gdb.base/store.exp
+++ b/gdb/testsuite/gdb.base/store.exp
@@ -196,7 +196,7 @@ proc check_field { t } {
gdb_test "continue" "register struct f_${t} u = f_${t};" \
"continue field ${t}"
- # Match either the return statement, or the line immediatly after
+ # Match either the return statement, or the line immediately after
# it. The compiler can end up merging the return statement into
# the return instruction.
gdb_test "next" "(return u;|\})" "next field ${t}"
diff --git a/gdb/testsuite/gdb.base/structs.exp b/gdb/testsuite/gdb.base/structs.exp
index 31b2bbe..7f1192d 100644
--- a/gdb/testsuite/gdb.base/structs.exp
+++ b/gdb/testsuite/gdb.base/structs.exp
@@ -296,7 +296,7 @@ proc test_struct_returns { n } {
# known, both failed to print a final "source and line" and misplaced
# the frame ("No frame").
- # The test is writen so that it only reports one FAIL/PASS for the
+ # The test is written so that it only reports one FAIL/PASS for the
# entire operation. The value returned is checked further down.
# "return_value_known", if non-zero, indicates that GDB knew where
# the return value was located.
diff --git a/gdb/testsuite/gdb.base/style-logging.exp b/gdb/testsuite/gdb.base/style-logging.exp
index 882418b..d866d36 100644
--- a/gdb/testsuite/gdb.base/style-logging.exp
+++ b/gdb/testsuite/gdb.base/style-logging.exp
@@ -41,7 +41,8 @@ with_ansi_styling_terminal {
set main_expr [style main function]
set base_file_expr [style ".*style\\.c" file]
- set file_expr "$base_file_expr:\[0-9\]"
+ set line_expr [style $decimal line-number]
+ set file_expr "$base_file_expr:$line_expr"
set arg_expr [style "arg." variable]
gdb_test "frame" \
"$main_expr.*$arg_expr.*$arg_expr.*$file_expr.*"
diff --git a/gdb/testsuite/gdb.base/style.exp b/gdb/testsuite/gdb.base/style.exp
index aff6545..d29b238 100644
--- a/gdb/testsuite/gdb.base/style.exp
+++ b/gdb/testsuite/gdb.base/style.exp
@@ -99,7 +99,8 @@ proc run_style_tests { } {
set main_expr [limited_style main function]
set base_file_expr [limited_style ".*style\\.c" file]
- set file_expr "$base_file_expr:\[0-9\]+"
+ set line_expr [limited_style $decimal line-number]
+ set file_expr "$base_file_expr:$line_expr"
set arg_expr [limited_style "arg." variable]
# On some embedded targets that don't fully support argc/argv,
@@ -109,12 +110,12 @@ proc run_style_tests { } {
gdb_test "frame" \
[multi_line \
"#0\\s+$main_expr\\s+\\($arg_expr=$decimal,\\s+$arg_expr=$hex.*\\)\\s+at\\s+$file_expr" \
- "\[0-9\]+\\s+.*return.* break here .*"]
+ "$line_expr\\s+.*return.* break here .*"]
gdb_test "info breakpoints" "$main_expr at $file_expr.*"
gdb_test_no_output "set style sources off"
gdb_test "frame" \
- "\r\n\[^\033\]*break here.*" \
+ "\r\n$line_expr\[^\033\]*break here.*" \
"frame without sources styling"
gdb_test_no_output "set style sources on"
@@ -139,18 +140,18 @@ proc run_style_tests { } {
[multi_line \
"#0\\s+$main_expr\\s+\\($arg_expr=$decimal,\\s+$arg_expr=$hex\\)" \
"\\s+at\\s+$file_expr" \
- "\[0-9\]+\\s+.*return.* break here .*"]
+ "$line_expr\\s+.*return.* break here .*"]
set re1_styled \
[multi_line \
"#0\\s+$main_expr\\s+\\($arg_expr=$decimal,\\s+" \
"\\s+$arg_expr=$hex.*\\)" \
"\\s+at\\s+$file_expr" \
- "\[0-9\]+\\s+.*return.* break here .*"]
+ "$line_expr\\s+.*return.* break here .*"]
set re2_styled \
[multi_line \
"#0\\s+$main_expr\\s+\\($arg_expr=.*" \
"\\s+$arg_expr=$hex.*\\)\\s+at\\s+$file_expr" \
- "\[0-9\]+\\s+.*return.* break here .*"]
+ "$line_expr\\s+.*return.* break here .*"]
# The length of the line containing argv containing:
# - 4 leading spaces
diff --git a/gdb/testsuite/gdb.base/testenv.exp b/gdb/testsuite/gdb.base/testenv.exp
index 847647e..908918a 100644
--- a/gdb/testsuite/gdb.base/testenv.exp
+++ b/gdb/testsuite/gdb.base/testenv.exp
@@ -68,7 +68,7 @@ proc find_env {varname} {
}
-re "$gdb_prompt $" {
# If this fails, bail out, otherwise we get stuck in
- # an infinite loop. The caller will end up emiting a
+ # an infinite loop. The caller will end up emitting a
# FAIL.
return "<fail>"
}
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 30fa12e..154514f 100644
--- a/gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.exp
+++ b/gdb/testsuite/gdb.base/watchpoint-stops-at-right-insn.exp
@@ -62,7 +62,7 @@
#
# If the target has non-continuable watchpoints, while GDB thinks it
# has continuable watchpoints, GDB will see a watchpoint trigger,
-# notice no value changed, and immediatly continue the target. Now,
+# notice no value changed, and immediately continue the target. Now,
# either the target manages to step-over the watchpoint transparently,
# and GDB thus fails to present to value change to the user, or, the
# watchpoint will keep re-triggering, with the program never making
diff --git a/gdb/testsuite/gdb.base/whatis-ptype-typedefs.exp b/gdb/testsuite/gdb.base/whatis-ptype-typedefs.exp
index ebe009a..7088299 100644
--- a/gdb/testsuite/gdb.base/whatis-ptype-typedefs.exp
+++ b/gdb/testsuite/gdb.base/whatis-ptype-typedefs.exp
@@ -55,7 +55,7 @@ proc prepare {lang} {
return 1
}
-# The following list is layed out as a table. It is composed by
+# The following list is laid out as a table. It is composed by
# sub-lists (lines), with each line representing one whatis/ptype
# test. The sub-list (line) elements (columns) are (in order):
#
diff --git a/gdb/testsuite/gdb.base/wrap-line.exp b/gdb/testsuite/gdb.base/wrap-line.exp
index b0931a3..323cd6c 100644
--- a/gdb/testsuite/gdb.base/wrap-line.exp
+++ b/gdb/testsuite/gdb.base/wrap-line.exp
@@ -19,8 +19,10 @@
# build == host.
require {!is_remote host}
-# Test both ansi (no auto-wrap) and xterm (auto-wrap).
-set terms {ansi xterm}
+# Test both ansi (no auto-wrap) and xterm (auto-wrap). Also test dumb, which
+# shows the effective behaviour on stub-termcap systems, regardless of the
+# TERM setting.
+set terms {ansi xterm dumb}
# Fill line, assuming we start after the gdb prompt.
proc fill_line { width } {
@@ -44,9 +46,11 @@ proc get_screen_width { } {
upvar gdb_width gdb_width
upvar readline_width readline_width
upvar env_width env_width
+ upvar wrap_mode wrap_mode
set gdb_width 0
set readline_width 0
set env_width 0
+ set wrap_mode ""
set re1 "Number of characters gdb thinks are in a line is ($::decimal)\[^\r\n\]*\\."
set re2 \
"Number of characters readline reports are in a line is ($::decimal)\[^\r\n\]*\\."
@@ -54,6 +58,7 @@ proc get_screen_width { } {
"Number of characters curses thinks are in a line is $::decimal\\."
set re4 \
"Number of characters environment thinks are in a line is ($::decimal) \\(COLUMNS\\)."
+ set re5 [string cat "Readline wrapping mode: (\[^\r\n]*\)\\."]
set cmd "maint info screen"
set re \
[multi_line \
@@ -61,12 +66,14 @@ proc get_screen_width { } {
$re2 \
"(?:$re3" \
")?$re4" \
- .*]
+ .* \
+ $re5]
gdb_test_multiple $cmd "" {
-re -wrap $re {
set gdb_width $expect_out(1,string)
set readline_width $expect_out(2,string)
set env_width $expect_out(3,string)
+ set wrap_mode $expect_out(4,string)
pass $gdb_test_name
}
}
@@ -79,10 +86,16 @@ proc test_wrap { width_auto_detected } {
get_screen_width
- if { $::term == "xterm" } {
+ set wrap_mode_terminal "terminal (terminal is auto wrap capable)"
+ set wrap_mode_readline \
+ "readline (terminal is not auto wrap capable, last column reserved)"
+ set have_wrap 1
+ if { $wrap_mode == $wrap_mode_terminal } {
gdb_assert { $gdb_width == $readline_width }
- } else {
+ } elseif { $wrap_mode == $wrap_mode_readline } {
gdb_assert { $gdb_width == [expr $readline_width + 1] }
+ } else {
+ set have_wrap 0
}
gdb_assert { $gdb_width == $env_width } "width"
@@ -113,7 +126,10 @@ proc test_wrap { width_auto_detected } {
gdb_test_multiple "" "wrap" {
-re $re {
- pass $gdb_test_name
+ gdb_assert {$have_wrap} $gdb_test_name
+ }
+ -re "\r<.*" {
+ gdb_assert {!$have_wrap} $gdb_test_name
}
}
diff --git a/gdb/testsuite/gdb.arch/i386-mpx-simple_segv.c b/gdb/testsuite/gdb.btrace/event-tracing-gap.c
index 6843317..b04f74d 100644
--- a/gdb/testsuite/gdb.arch/i386-mpx-simple_segv.c
+++ b/gdb/testsuite/gdb.btrace/event-tracing-gap.c
@@ -1,6 +1,6 @@
-/* Copyright (C) 2015-2024 Free Software Foundation, Inc.
+/* This testcase is part of GDB, the GNU debugger.
- Contributed by Intel Corp. <walfred.tedeschi@intel.com>
+ Copyright 2024 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,22 +15,18 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#define OUR_SIZE 5
-
-void
-upper (int * p, int len)
+static int
+square (int num)
{
- int value;
- len++; /* b0-size-test. */
- value = *(p + len);
+ return num * num; /* bp1. */
}
int
main (void)
{
- int a = 0; /* Dummy variable for debugging purposes. */
- int sx[OUR_SIZE];
- a++; /* register-eval. */
- upper (sx, OUR_SIZE + 2);
- return sx[1];
+ int a = 2;
+ int ans = 0;
+
+ ans = square (a);
+ return 0; /* bp2. */
}
diff --git a/gdb/testsuite/gdb.btrace/event-tracing-gap.exp b/gdb/testsuite/gdb.btrace/event-tracing-gap.exp
new file mode 100644
index 0000000..d33e8e8
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/event-tracing-gap.exp
@@ -0,0 +1,75 @@
+# This testcase is part of GDB, the GNU debugger.
+#
+# Copyright 2024 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test event tracing with gaps.
+
+require allow_btrace_pt_event_trace_tests
+
+standard_testfile
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
+ return -1
+}
+
+if {![runto_main]} {
+ return -1
+}
+
+gdb_test_no_output "set record btrace pt event-tracing on"
+gdb_test_no_output "record btrace pt"
+
+set bp_1 [gdb_get_line_number "bp1"]
+set bp_2 [gdb_get_line_number "bp2"]
+gdb_breakpoint $bp_1
+gdb_breakpoint $bp_2
+
+gdb_test "next"
+
+# Inferior calls and return commands will create gaps in the recording.
+gdb_test "call square (3)" [multi_line \
+ "" \
+ "Breakpoint $decimal, square \\(num=3\\) at \[^\r\n\]+:$bp_1" \
+ "$decimal.*bp1.*" \
+ "The program being debugged stopped while in a function called from GDB\\." \
+ "Evaluation of the expression containing the function" \
+ "\\(square\\) will be abandoned\\." \
+ "When the function is done executing, GDB will silently stop\\."]
+
+gdb_test "return 9" "0.*main.*" \
+ "return" \
+ "Make.*return now\\? \\(y or n\\) " "y"
+
+gdb_continue_to_breakpoint "break at bp_1" ".*$srcfile:$bp_1.*"
+gdb_continue_to_breakpoint "break at bp_2" ".*$srcfile:$bp_2.*"
+
+# We should have 2 gaps and events for each breakpoint we hit.
+# Note that due to the asynchronous nature of certain events, we use
+# gdb_test_sequence and check only for events that we can control.
+gdb_test_sequence "record function-call-history" "function-call-history" {
+ "\[0-9\]+\tmain"
+ "\\\[iret(: ip = $hex)?\\\]"
+ "\[0-9\]+\t\\\[non-contiguous\\\]"
+ "\[0-9\]+\tsquare"
+ "\\\[interrupt: vector = 0x3 \\\(#bp\\\)(, ip = 0x\[0-9a-fA-F\]+)?\\\]"
+ "\\\[iret(: ip = $hex)?\\\]"
+ "\[0-9\]+\t\\\[non-contiguous\\\]"
+ "\[0-9\]+\tmain"
+ "\[0-9\]+\tsquare"
+ "\\\[interrupt: vector = 0x3 \\\(#bp\\\)(, ip = 0x\[0-9a-fA-F\]+)?\\\]"
+ "\\\[iret(: ip = $hex)?\\\]"
+ "\[0-9\]+\tmain"
+}
diff --git a/gdb/testsuite/gdb.btrace/event-tracing.exp b/gdb/testsuite/gdb.btrace/event-tracing.exp
new file mode 100644
index 0000000..1a5eee0
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/event-tracing.exp
@@ -0,0 +1,52 @@
+# This testcase is part of GDB, the GNU debugger.
+#
+# Copyright 2024 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test basic Intel PT event tracing
+
+require allow_btrace_pt_event_trace_tests
+
+standard_testfile null-deref.c
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
+ return -1
+}
+
+if {![runto_main]} {
+ return -1
+}
+
+gdb_test_no_output "set record btrace pt event-tracing on"
+gdb_test_no_output "record btrace pt"
+
+gdb_test "continue" "Program received signal SIGSEGV, Segmentation fault.*"
+
+# Test printing of at least one INTERRUPT and one IRET event.
+# This uses test_sequence to avoid random events failing the tests.
+gdb_test_sequence "record function-call-history" "function-call-history" {
+ "\[0-9\]+\tmain"
+ "\t \\\[iret(: ip = $hex)?\\\]"
+ "\t \\\[interrupt: vector = 0xe \\\(#pf\\\)(, cr2 = 0x0)?(, ip = 0x\[0-9a-fA-F\]+)?\\\]"
+}
+
+# Test the instruction-history. Assembly can differ between compilers. To
+# avoid creating a .S file for this test we just check the event at the end.
+gdb_test "record instruction-history" \
+ "$decimal\t \\\[interrupt: vector = 0xe \\\(#pf\\\)(, cr2 = 0x0)?(, ip = $hex)?\\\]"
+
+# Test reverse stepping and replay stepping
+gdb_test "reverse-stepi" "\\\[interrupt: vector = 0xe \\\(#pf\\\)(, cr2 = 0x0)?(, ip = $hex)?\\\].*"
+gdb_test "stepi" "\\\[interrupt: vector = 0xe \\\(#pf\\\)(, cr2 = 0x0)?(, ip = $hex)?\\\].*"
diff --git a/gdb/testsuite/gdb.btrace/null-deref.c b/gdb/testsuite/gdb.btrace/null-deref.c
new file mode 100644
index 0000000..f0de31f
--- /dev/null
+++ b/gdb/testsuite/gdb.btrace/null-deref.c
@@ -0,0 +1,26 @@
+/* Copyright 2024 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <stddef.h>
+
+int
+main ()
+{
+ int a = 34;
+ int *b = NULL;
+
+ a = *b; /* BP1. */
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.cp/rtti.exp b/gdb/testsuite/gdb.cp/rtti.exp
index 9651691..5caf4d1 100644
--- a/gdb/testsuite/gdb.cp/rtti.exp
+++ b/gdb/testsuite/gdb.cp/rtti.exp
@@ -73,7 +73,7 @@ gdb_test_multiple "print *e1" "print *e1" {
# NOTE: carlton/2004-01-14: This test with an "<incomplete type>"
# message because, within rtt1.cc, GDB has no way of knowing that the
-# class is called 'n2::D2' instead of just 'D2'. This is an artifical
+# class is called 'n2::D2' instead of just 'D2'. This is an artificial
# test case, though: if we were using these classes in a more
# substantial way, G++ would emit more debug info. As is, I don't
# think there's anything that GDB can do about this case until G++
diff --git a/gdb/testsuite/gdb.cp/step-and-next-inline.exp b/gdb/testsuite/gdb.cp/step-and-next-inline.exp
index 446cd82..af1719d 100644
--- a/gdb/testsuite/gdb.cp/step-and-next-inline.exp
+++ b/gdb/testsuite/gdb.cp/step-and-next-inline.exp
@@ -26,7 +26,7 @@ proc do_test { use_header } {
if { $use_header } {
# This test will not pass due to poor debug information
- # generated by GCC (at least upto 10.x). See
+ # generated by GCC (at least up to 10.x). See
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94474
return
}
diff --git a/gdb/testsuite/gdb.cp/virtfunc.exp b/gdb/testsuite/gdb.cp/virtfunc.exp
index 9add69e..636497e 100644
--- a/gdb/testsuite/gdb.cp/virtfunc.exp
+++ b/gdb/testsuite/gdb.cp/virtfunc.exp
@@ -197,7 +197,7 @@ proc test_virtual_calls {} {
# wrong value "202"
# gcc 2.95.3 -gdwarf-2
# gcc 2.95.3 -gstabs+
- # attempt to take addres of value not located in memory
+ # attempt to take address of value not located in memory
# gcc 3.3.2 -gdwarf-2
# gcc 3.3.2 -gstabs+
#
diff --git a/gdb/testsuite/gdb.dap/memory.exp b/gdb/testsuite/gdb.dap/memory.exp
index 7082706..c4e4fb3 100644
--- a/gdb/testsuite/gdb.dap/memory.exp
+++ b/gdb/testsuite/gdb.dap/memory.exp
@@ -25,11 +25,12 @@ if {[build_executable ${testfile}.exp $testfile] == -1} {
return
}
-save_vars { env(ASAN_OPTIONS) } {
+save_vars { env(ASAN_OPTIONS) env(TSAN_OPTIONS) } {
# The request readMemory with count 18446744073709551615 triggers address
# sanitizer. Suppress the error, leaving us with just this warning:
# WARNING: AddressSanitizer failed to allocate 0xffffffffffffffff bytes
set_sanitizer ASAN_OPTIONS allocator_may_return_null 1
+ set_sanitizer TSAN_OPTIONS allocator_may_return_null 1
if {[dap_initialize] == ""} {
return
diff --git a/gdb/testsuite/gdb.debuginfod/corefile-mapped-file-3.c b/gdb/testsuite/gdb.debuginfod/corefile-mapped-file-3.c
index 45d7833..98ed952 100644
--- a/gdb/testsuite/gdb.debuginfod/corefile-mapped-file-3.c
+++ b/gdb/testsuite/gdb.debuginfod/corefile-mapped-file-3.c
@@ -17,7 +17,6 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/types.h>
-#include <sys/stat.h>
#include <unistd.h>
#include <sys/mman.h>
diff --git a/gdb/testsuite/gdb.debuginfod/corefile-mapped-file.exp b/gdb/testsuite/gdb.debuginfod/corefile-mapped-file.exp
index b5dee22..cf96b41 100644
--- a/gdb/testsuite/gdb.debuginfod/corefile-mapped-file.exp
+++ b/gdb/testsuite/gdb.debuginfod/corefile-mapped-file.exp
@@ -93,7 +93,7 @@ set ptr_address [get_hexadecimal_valueof "&library_ptr" "unknown"]
set ptr_offset "unknown"
gdb_test_multiple "info proc mappings" "" {
- -re "^\\s+($hex)\\s+($hex)\\s+$hex\\s+($hex)\[^\r\n\]+$library_filename\r\n" {
+ -re "^($hex)\\s+($hex)\\s+$hex\\s+($hex)\[^\r\n\]+$library_filename\\s*\r\n" {
set low_addr $expect_out(1,string)
set high_addr $expect_out(2,string)
set file_offset $expect_out(3,string)
diff --git a/gdb/testsuite/gdb.dwarf2/backward-spec-inter-cu.exp b/gdb/testsuite/gdb.dwarf2/backward-spec-inter-cu.exp
index 59b3db5..2f41db9 100644
--- a/gdb/testsuite/gdb.dwarf2/backward-spec-inter-cu.exp
+++ b/gdb/testsuite/gdb.dwarf2/backward-spec-inter-cu.exp
@@ -98,6 +98,7 @@ foreach_with_prefix worker_threads $worker_threads_list {
gdb_load $binfile
- gdb_test "maint print objfiles" "$eol$ws+qualified:$ws+ns::v$eol.*" \
+ 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/count.exp b/gdb/testsuite/gdb.dwarf2/count.exp
index 52deb19..096e093 100644
--- a/gdb/testsuite/gdb.dwarf2/count.exp
+++ b/gdb/testsuite/gdb.dwarf2/count.exp
@@ -124,25 +124,11 @@ Dwarf::assemble $asm_file {
}
}
-if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile}1.o \
- object {nodebug}] != "" } {
+if { [prepare_for_testing "failed to prepare" $testfile \
+ [list $srcfile $asm_file] {nodebug}] } {
return -1
}
-if { [gdb_compile $asm_file ${binfile}2.o object {nodebug}] != "" } {
- return -1
-}
-
-if { [gdb_compile [list ${binfile}1.o ${binfile}2.o] \
- "${binfile}" executable {}] != "" } {
- return -1
-}
-
-save_vars { GDBFLAGS } {
- set GDBFLAGS [concat $GDBFLAGS " -readnow"]
- clean_restart ${testfile}
-}
-
if ![runto_main] {
return -1
}
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-inter-cu-error-2.exp b/gdb/testsuite/gdb.dwarf2/dw2-inter-cu-error-2.exp
new file mode 100644
index 0000000..585fd54
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw2-inter-cu-error-2.exp
@@ -0,0 +1,51 @@
+# Copyright 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Check that GDB doesn't crash on invalid dwarf, specifically an inter-CU
+# reference pointing to a dummy CU.
+
+load_lib dwarf.exp
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+require dwarf2_support
+
+standard_testfile main.c .S
+
+# Create the DWARF.
+set asm_file [standard_output_file $srcfile2]
+Dwarf::assemble $asm_file {
+ declare_labels label1
+
+ cu {} {
+ compile_unit {{language @DW_LANG_C}} {
+ subprogram {
+ {MACRO_AT_range { main }}
+ {DW_AT_specification %$label1}
+ }
+ }
+ }
+
+ label1: cu {} {
+ }
+}
+
+if [prepare_for_testing "failed to prepare" $testfile \
+ [list $asm_file $srcfile] {nodebug}] {
+ return -1
+}
+
+gdb_assert \
+ { [regexp "DWARF Error: cannot follow reference" $gdb_file_cmd_msg] } \
+ "Error message"
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp b/gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp
index 1a3d53c..2be211f 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-ranges-base.exp
@@ -40,7 +40,7 @@ Dwarf::assemble $asm_file {
[function_range frame3 [list ${srcdir}/${subdir}/$srcfile]]
# Very simple info for this test program. We don't care about
- # this information being correct (w.r.t. funtion / argument types)
+ # this information being correct (w.r.t. function / argument types)
# just so long as the compilation using makes use of the
# .debug_ranges data then the test achieves its objective.
cu { label cu_label } {
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 a59c637..55f4373 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
@@ -19,7 +19,7 @@
#
# This sort of thing can occur in optimized code, f.i. here a slightly more
# elaborate case with another is-stmt=no entry (the one with line number 12)
-# inbetween:
+# in between:
# INDEX LINE ADDRESS IS-STMT
# 12 13 0x00000000004003ed
# 13 12 0x00000000004003f2
diff --git a/gdb/testsuite/gdb.dwarf2/dwz-unused-pu.exp b/gdb/testsuite/gdb.dwarf2/dwz-unused-pu.exp
new file mode 100644
index 0000000..1dd91ee
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dwz-unused-pu.exp
@@ -0,0 +1,75 @@
+# Copyright 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Check that a symbol from an unused PU is not accessible.
+
+load_lib dwarf.exp
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+require dwarf2_support
+
+standard_testfile main.c -dw.S
+
+# Create the DWARF.
+set asm_file [standard_output_file $srcfile2]
+Dwarf::assemble $asm_file {
+ declare_labels partial_label int_label int_label2
+
+ cu {} {
+ compile_unit {{language @DW_LANG_C}} {
+ subprogram {
+ {MACRO_AT_func { main }}
+ }
+ }
+ }
+
+ cu {} {
+ partial_unit {} {
+ int_label: base_type {
+ {name int}
+ {byte_size 4 sdata}
+ {encoding @DW_ATE_signed}
+ }
+
+ constant {
+ {name the_int}
+ {type :$int_label}
+ {const_value 99 data1}
+ }
+ }
+ }
+}
+
+if { [prepare_for_testing "failed to prepare" $testfile \
+ [list $asm_file $srcfile] {nodebug}] } {
+ return -1
+}
+
+set cmd "p the_int"
+set re \
+ [string_to_regexp \
+ {No symbol "the_int" in current context.}]
+
+# Check that the unreferenced PU is not expanded.
+gdb_test $cmd $re
+
+# This should expand all CUs and referenced PUs, but not an unreferenced PU.
+gdb_test_no_output "maint expand-symtabs"
+
+# Flush the symbol cache to do a new symbol lookup.
+gdb_test_no_output "maint flush symbol-cache"
+
+# Check that the unreferenced PU is not expanded after "maint expand-symtabs".
+gdb_test $cmd $re "$cmd, again"
diff --git a/gdb/testsuite/gdb.dwarf2/enum-type-c++.cc b/gdb/testsuite/gdb.dwarf2/enum-type-c++.cc
new file mode 100644
index 0000000..691c7fc
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/enum-type-c++.cc
@@ -0,0 +1,35 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2024 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+namespace ns {
+
+class A {
+public:
+ enum {
+ val1 = 1
+ };
+};
+
+enum class ec
+{
+ val2 = 2,
+};
+}
+
+int u1 = ns::A::val1;
+
+int u2 = (int)ns::ec::val2;
diff --git a/gdb/testsuite/gdb.dwarf2/enum-type-c++.exp b/gdb/testsuite/gdb.dwarf2/enum-type-c++.exp
new file mode 100644
index 0000000..4f9610c
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/enum-type-c++.exp
@@ -0,0 +1,67 @@
+# Copyright 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+require !readnow
+
+load_lib dwarf.exp
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+require dwarf2_support
+
+standard_testfile main.c .cc
+
+if { [prepare_for_testing "failed to prepare" $testfile \
+ [list $srcfile $srcfile2] {debug c++}] } {
+ return -1
+}
+
+require {string equal [have_index $binfile] ""}
+
+set lines [gdb_get_lines "maint print objfiles"]
+set re_ws "\[ \t\]"
+
+# Regression test for PR31900.
+set val1 ns::A::val1
+set test "val1 has a parent"
+if { [regexp val1 $lines] } {
+ set re \
+ [multi_line \
+ "" \
+ "$re_ws+qualified:$re_ws+$val1" \
+ ".*"]
+ gdb_assert {[regexp $re $lines]} $test
+
+ gdb_test "print $val1" " = $val1"
+} else {
+ # Clang doesn't emit a DIE for val1.
+ unsupported $test
+}
+
+# Regression test for PR32158.
+set val2 ns::ec::val2
+set test "val2 has correct parent"
+if { [regexp val2 $lines] } {
+ set re \
+ [multi_line \
+ "" \
+ "$re_ws+qualified:$re_ws+$val2" \
+ ".*"]
+ gdb_assert {[regexp $re $lines]} $test
+
+ gdb_test "print $val2" " = $val2"
+} else {
+ # Clang doesn't emit a DIE for val2.
+ unsupported $test
+}
diff --git a/gdb/testsuite/gdb.dwarf2/enum-type.exp b/gdb/testsuite/gdb.dwarf2/enum-type.exp
index 394d287..ec12db5 100644
--- a/gdb/testsuite/gdb.dwarf2/enum-type.exp
+++ b/gdb/testsuite/gdb.dwarf2/enum-type.exp
@@ -65,6 +65,41 @@ 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}
+ } {
+ 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_TAG_enumeration_type {
+ {DW_AT_specification :$forward}
+ } {
+ DW_TAG_enumerator {
+ {DW_AT_name val1}
+ {DW_AT_const_value 1 DW_FORM_sdata}
+ }
+ }
+
+ DW_TAG_namespace {
+ {DW_AT_name ns}
+ } {
+ forward: DW_TAG_enumeration_type {
+ {DW_AT_name e}
+ {DW_AT_type :$integer_label}
+ {DW_AT_declaration 1 flag}
+ }
+ }
+ }
+ }
}
if { [prepare_for_testing "failed to prepare" ${testfile} \
@@ -79,3 +114,18 @@ gdb_test "ptype enum EU" "type = enum EU {TWO = 2}" \
gdb_test_no_output "set lang c++"
gdb_test "ptype enum EU" "type = enum EU : unsigned int {TWO = 2}" \
"ptype EU in C++"
+
+gdb_test "p ns::val1" \
+ " = ns::val1"
+
+require !readnow
+require {string equal [have_index $binfile] ""}
+
+set re_ws "\[ \t\]"
+
+gdb_test_lines "maint print objfiles" \
+ "val1 has a parent" \
+ [multi_line \
+ "" \
+ "$re_ws+qualified:$re_ws+ns::val1" \
+ ".*"]
diff --git a/gdb/testsuite/gdb.dwarf2/fission-reread.S b/gdb/testsuite/gdb.dwarf2/fission-reread.S
index 1763fab..279f6f3 100644
--- a/gdb/testsuite/gdb.dwarf2/fission-reread.S
+++ b/gdb/testsuite/gdb.dwarf2/fission-reread.S
@@ -97,7 +97,7 @@ SYMBOL(main):
.byte 0x87
.4byte .Lskeleton_debug_line0 /* DW_AT_stmt_list */
- /* Manually inserted to have a DW_AT_specification refering to
+ /* Manually inserted to have a DW_AT_specification referring to
something and appearing ahead of it. */
.uleb128 0x8 /* DW_TAG_class_type */
.4byte .Ltu_class_type - .Ltu_start_dwo
diff --git a/gdb/testsuite/gdb.dwarf2/forward-spec-inter-cu.exp b/gdb/testsuite/gdb.dwarf2/forward-spec-inter-cu.exp
index d8367b0..b734c30 100644
--- a/gdb/testsuite/gdb.dwarf2/forward-spec-inter-cu.exp
+++ b/gdb/testsuite/gdb.dwarf2/forward-spec-inter-cu.exp
@@ -98,6 +98,7 @@ foreach_with_prefix worker_threads $worker_threads_list {
gdb_load $binfile
- gdb_test "maint print objfiles" "$eol$ws+qualified:$ws+ns::v$eol.*" \
+ 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/gdb-index.exp b/gdb/testsuite/gdb.dwarf2/gdb-index.exp
index 4e44227..23d60da 100644
--- a/gdb/testsuite/gdb.dwarf2/gdb-index.exp
+++ b/gdb/testsuite/gdb.dwarf2/gdb-index.exp
@@ -95,7 +95,13 @@ proc local_add_gdb_index { program } {
# building an index from a program already using one.
set test "check if index present"
-gdb_test_multiple "mt print objfiles ${testfile}" $test {
+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]
+gdb_test_multiple $cmd $test {
+ -re ^$cmd_re {
+ exp_continue
+ }
-re "gdb_index.*${gdb_prompt} $" {
set binfile_with_index $binfile
set host_binfile_with_index [gdb_remote_download host $binfile]
diff --git a/gdb/testsuite/gdb.dwarf2/implptrconst.exp b/gdb/testsuite/gdb.dwarf2/implptrconst.exp
index 8e6dbf0..541331c 100644
--- a/gdb/testsuite/gdb.dwarf2/implptrconst.exp
+++ b/gdb/testsuite/gdb.dwarf2/implptrconst.exp
@@ -83,18 +83,11 @@ Dwarf::assemble $asm_file {
}
}
-if { [build_executable ${testfile}.exp ${testfile} \
+if { [prepare_for_testing "failed to prepare" ${testfile} \
[list $srcfile $asm_file] {nodebug}] } {
return -1
}
-# We need --readnow because otherwise we never read in the CU we
-# created above.
-save_vars { GDBFLAGS } {
- set GDBFLAGS "$GDBFLAGS -readnow"
- clean_restart ${testfile}
-}
-
if ![runto_main] {
return -1
}
diff --git a/gdb/testsuite/gdb.dwarf2/implptrpiece.exp b/gdb/testsuite/gdb.dwarf2/implptrpiece.exp
index 585cd74..867789f 100644
--- a/gdb/testsuite/gdb.dwarf2/implptrpiece.exp
+++ b/gdb/testsuite/gdb.dwarf2/implptrpiece.exp
@@ -101,18 +101,11 @@ Dwarf::assemble $asm_file {
}
}
-if { [build_executable ${testfile}.exp ${testfile} \
+if { [prepare_for_testing "failed to prepare" ${testfile} \
[list $srcfile $asm_file] {nodebug}] } {
return -1
}
-# We need --readnow because otherwise we never read in the CU we
-# created above.
-save_vars { GDBFLAGS } {
- set GDBFLAGS "$GDBFLAGS -readnow"
- clean_restart ${testfile}
-}
-
if ![runto_main] {
return -1
}
diff --git a/gdb/testsuite/gdb.dwarf2/multidictionary.exp b/gdb/testsuite/gdb.dwarf2/multidictionary.exp
index 36c0bb4..4c7dc0e 100644
--- a/gdb/testsuite/gdb.dwarf2/multidictionary.exp
+++ b/gdb/testsuite/gdb.dwarf2/multidictionary.exp
@@ -23,7 +23,7 @@ require dwarf2_support
standard_testfile main.c .S
# Create the DWARF. This is derived from the reproducer in the bug
-# mentioned above. This DIE tree is typical of compilations wtih
+# mentioned above. This DIE tree is typical of compilations with
# LTO enabled.
set asm_file [standard_output_file $srcfile2]
diff --git a/gdb/testsuite/gdb.dwarf2/pr13961.S b/gdb/testsuite/gdb.dwarf2/pr13961.S
index 856d211..2423ee9 100644
--- a/gdb/testsuite/gdb.dwarf2/pr13961.S
+++ b/gdb/testsuite/gdb.dwarf2/pr13961.S
@@ -101,7 +101,7 @@ SYMBOL(main):
.byte 0x87
.4byte .Ldebug_line0 /* DW_AT_stmt_list */
- /* Manually inserted to have a DW_AT_specification refering to
+ /* Manually inserted to have a DW_AT_specification referring to
something and appearing ahead of it. */
.uleb128 0x8 /* DW_TAG_class_type */
.4byte .Ltu_class_type - .Ldebug_types0
@@ -185,7 +185,7 @@ SYMBOL(main):
.byte 0x3 /* DW_OP_addr */
.4byte baz
- /* Manually inserted to have a DW_AT_specification refering to
+ /* Manually inserted to have a DW_AT_specification referring to
something and appearing ahead of it. */
.uleb128 0x8 /* DW_TAG_class_type */
.4byte .Lcu_class_type - .Ldebug_info0 /* DW_AT_specification */
diff --git a/gdb/testsuite/gdb.dwarf2/pr13961.exp b/gdb/testsuite/gdb.dwarf2/pr13961.exp
index a306c45..e4ea9d0 100644
--- a/gdb/testsuite/gdb.dwarf2/pr13961.exp
+++ b/gdb/testsuite/gdb.dwarf2/pr13961.exp
@@ -36,7 +36,8 @@ gdb_test "break -q main" "Breakpoint.*at.*"
pass $testfile
# Regression test for PR symtab/30739.
-gdb_test_multiple "maint print objfiles $binfile" "no foo::foo" {
+set cmd "pipe maint print objfiles $binfile | grep foo::foo"
+gdb_test_multiple $cmd "no foo::foo" {
-re -wrap "\r\n *qualified: *foo::foo\r\n.*" {
fail $gdb_test_name
}
diff --git a/gdb/testsuite/gdb.dwarf2/self-spec.exp b/gdb/testsuite/gdb.dwarf2/self-spec.exp
index 2e8fe6b..9bb4064 100644
--- a/gdb/testsuite/gdb.dwarf2/self-spec.exp
+++ b/gdb/testsuite/gdb.dwarf2/self-spec.exp
@@ -59,8 +59,8 @@ require {string eq $index ""}
require !readnow
-gdb_test "maint print objfiles $testfile" \
- "\r\n *qualified: *c1\r\n.*" \
+gdb_test "pipe maint print objfiles $testfile | grep c1" \
+ " *qualified: *c1" \
"class c1 in cooked index"
gdb_test "maint expand-symtabs"
diff --git a/gdb/testsuite/gdb.fortran/info-types.exp b/gdb/testsuite/gdb.fortran/info-types.exp
index 52ce7ac..ad2c988 100644
--- a/gdb/testsuite/gdb.fortran/info-types.exp
+++ b/gdb/testsuite/gdb.fortran/info-types.exp
@@ -27,10 +27,8 @@ if { [prepare_for_testing "failed to prepare" $testfile \
return -1
}
-if { ![fortran_runto_main] } {
- perror "Could not run to main."
- return
-}
+# Don't run to main to avoid increasing the search scope to include
+# debug info of shared libraries like libc, libgcc, libgfortran etc.
set integer4 [fortran_int4]
set integer8 [fortran_int8]
diff --git a/gdb/testsuite/gdb.fortran/types.exp b/gdb/testsuite/gdb.fortran/types.exp
index edbf5ab..494ed1e 100644
--- a/gdb/testsuite/gdb.fortran/types.exp
+++ b/gdb/testsuite/gdb.fortran/types.exp
@@ -60,7 +60,7 @@ proc test_float_literal_types_accepted {} {
# Test various floating point formats
# this used to guess whether to look for "real*4" or
- # "real*8" based on a target config variable, but noone
+ # "real*8" based on a target config variable, but no one
# maintained it properly.
gdb_test "pt .44" "type = real\\*\[0-9\]+"
diff --git a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
index 1ec9576..64e86ac 100644
--- a/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value-sub-arbitrary.exp
@@ -27,11 +27,11 @@ if ![fortran_runto_main] {
return -1
}
-# Check VLA with arbitary length and check that elements outside of
+# Check VLA with arbitrary length and check that elements outside of
# bounds of the passed VLA can be accessed correctly.
gdb_breakpoint [gdb_get_line_number "end-of-bar"]
gdb_continue_to_breakpoint "end-of-bar"
-gdb_test "p array1(42)" " = 3" "print arbitary array1(42)"
-gdb_test "p array1(100)" " = 100" "print arbitary array1(100)"
-gdb_test "p array2(4,10)" " = 1" "print arbitary array2(4,10)"
-gdb_test "p array2(4,100)" " = 1" "print arbitary array2(4,100)"
+gdb_test "p array1(42)" " = 3" "print arbitrary array1(42)"
+gdb_test "p array1(100)" " = 100" "print arbitrary array1(100)"
+gdb_test "p array2(4,10)" " = 1" "print arbitrary array2(4,10)"
+gdb_test "p array2(4,100)" " = 1" "print arbitrary array2(4,100)"
diff --git a/gdb/testsuite/gdb.gdb/python-helper.exp b/gdb/testsuite/gdb.gdb/python-helper.exp
index 4589edc..c17523a 100644
--- a/gdb/testsuite/gdb.gdb/python-helper.exp
+++ b/gdb/testsuite/gdb.gdb/python-helper.exp
@@ -263,7 +263,7 @@ proc test_python_helper {} {
# Test the htab_t pretty-printer.
gdb_test -prompt $outer_prompt_re "print all_bfds" "htab_t with ${::decimal} elements = \\{${::hex}.*\\}"
- # Test the intrusive_list pretty-printer. A bug occured in the
+ # Test the intrusive_list pretty-printer. A bug occurred in the
# pretty-printer for lists with more than one element. Verify that
# we see both elements of the inferior_list list being printed.
gdb_test -prompt $outer_prompt_re "print inferior_list" "intrusive list of inferior = {.*, num = 1,.*, num = 2,.*}"
diff --git a/gdb/testsuite/gdb.go/integers.exp b/gdb/testsuite/gdb.go/integers.exp
index fec8422..7837542 100644
--- a/gdb/testsuite/gdb.go/integers.exp
+++ b/gdb/testsuite/gdb.go/integers.exp
@@ -66,7 +66,7 @@ gdb_test "print i + k" " = 4"
gdb_test "print j + k" " = 5"
gdb_test "print i + j + k" " = 6"
-# Test substraction
+# Test subtraction
gdb_test "print j - i" " = 1"
gdb_test "print i - j" "= -1"
gdb_test "print k -i -j" " = 0"
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 68cd11a..214242f 100644
--- a/gdb/testsuite/gdb.linespec/cp-replace-typedefs-ns-template.exp
+++ b/gdb/testsuite/gdb.linespec/cp-replace-typedefs-ns-template.exp
@@ -30,7 +30,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile \
gdb_test_no_output "set max-completions unlimited"
# Confirm that the important global namespace typedefs were indeed
-# emited in the debug info.
+# emitted in the debug info.
gdb_test "ptype NS2" "type = int"
gdb_test "ptype object" "type = struct NS1::NS2::object {.*"
gdb_test "ptype Templ1" "type = struct NS1::NS2::Templ1<unsigned int> .*"
diff --git a/gdb/testsuite/gdb.linespec/cpcompletion.exp b/gdb/testsuite/gdb.linespec/cpcompletion.exp
index 480e034..09bd9a2 100644
--- a/gdb/testsuite/gdb.linespec/cpcompletion.exp
+++ b/gdb/testsuite/gdb.linespec/cpcompletion.exp
@@ -831,7 +831,7 @@ proc_with_prefix template-class-with-method {} {
}
}
-# Test completion of a const-overloaded funtion (const-overload).
+# Test completion of a const-overloaded function (const-overload).
# Note that "const" appears after the function/method parameters.
proc_with_prefix const-overload {} {
diff --git a/gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp b/gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp
index 73b25bd..b91f915 100644
--- a/gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp
+++ b/gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp
@@ -20,6 +20,16 @@ set MIFLAGS "-i=mi"
require dwarf2_support
+# Clang reorders global assembly labels, placing them all side by side.
+# This results in having low and high PCs what have the same value for
+# the CU and all the functions (in my system, they are all 0x1130). If
+# this test is rewritten to use the dwarf assembler instead, we can enable
+# this test with clang again.
+if {[test_compiler_info {clang-*-*}]} {
+ unsupported "can't generate debug info"
+ return
+}
+
standard_testfile .S dw2-ref-missing-frame-func.c dw2-ref-missing-frame-main.c
set objsfile [standard_output_file ${testfile}.o]
set objfuncfile [standard_output_file ${testfile}-func.o]
diff --git a/gdb/testsuite/gdb.mi/mi-break-qualified.exp b/gdb/testsuite/gdb.mi/mi-break-qualified.exp
index 7543d98..20e2bb8 100644
--- a/gdb/testsuite/gdb.mi/mi-break-qualified.exp
+++ b/gdb/testsuite/gdb.mi/mi-break-qualified.exp
@@ -69,7 +69,7 @@ proc test_break_qualified {} {
-enabled "y" \
-func "$func" \
-file ".*mi-break-qualified.cc" \
- -line="$line_no"]
+ -line $line_no]
}
set loc1 [make_loc_re "NS::func\\(int\\)" $loc_ns_func_line]
diff --git a/gdb/testsuite/gdb.mi/mi-break.exp b/gdb/testsuite/gdb.mi/mi-break.exp
index bfe839d..86e7b57 100644
--- a/gdb/testsuite/gdb.mi/mi-break.exp
+++ b/gdb/testsuite/gdb.mi/mi-break.exp
@@ -313,7 +313,7 @@ proc_with_prefix test_explicit_breakpoints {} {
mi_create_breakpoint "-c \"intarg == 3\" --function callee2" \
"insert explicit conditional breakpoint in callee2" \
- -func callee2 ".*$srcfile" -line $line_callee2_body \
+ -func callee2 -file ".*$srcfile" -line $line_callee2_body \
-cond "intarg == 3"
# mi_create_breakpoint cannot deal with displaying canonical
@@ -357,7 +357,7 @@ proc_with_prefix test_forced_conditions {} {
"dprintf with forced condition"
# Define a plain breakpoint first, and a condition later.
- mi_create_breakpoint "callme" "define a bp" ""
+ mi_create_breakpoint "callme" "define a bp"
mi_gdb_test "-break-condition --force 16 bad == 42" \
"${warning}\\^done" \
"invalid condition is forced"
diff --git a/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp b/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp
index 18e19a2..305c061 100644
--- a/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp
+++ b/gdb/testsuite/gdb.mi/mi-breakpoint-changed.exp
@@ -172,7 +172,7 @@ with_test_prefix "test_insert_delete_modify" {
test_insert_delete_modify
}
-# Test 'breakpoint-modified' notification is emited when pending breakpoints are
+# Test 'breakpoint-modified' notification is emitted when pending breakpoints are
# resolved.
proc test_pending_resolved { } {
diff --git a/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.cc b/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.cc
index be1f50f..d41b55d 100644
--- a/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.cc
+++ b/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.cc
@@ -43,8 +43,7 @@ foo ()
try
{
bar ();
- }
- catch (const my_exception &ex) /* Catch 1. */
+ } catch (const my_exception &ex) /* Catch 1. */
{
if (i == 1)
throw; /* Throw 2. */
@@ -60,8 +59,7 @@ main ()
try
{
foo ();
- }
- catch (const my_exception &ex) /* Catch 2. */
+ } catch (const my_exception &ex) /* Catch 2. */
{
if (i == 1)
return 1; /* Stop here. */
diff --git a/gdb/testsuite/gdb.mi/mi-complete.exp b/gdb/testsuite/gdb.mi/mi-complete.exp
index 91564a4..7fccaa2 100644
--- a/gdb/testsuite/gdb.mi/mi-complete.exp
+++ b/gdb/testsuite/gdb.mi/mi-complete.exp
@@ -28,7 +28,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debu
mi_clean_restart $binfile
-mi_runto_main
+# Don't run to main to avoid increasing the search scope to include
+# debug info of shared libraries like glibc, libgcc, etc.
mi_gdb_test "1-complete br" \
"1\\^done,completion=\"break\",matches=\\\[.*\"break\",.*\"break-range\".*\\\],max_completions_reached=\"0\"" \
diff --git a/gdb/testsuite/gdb.mi/mi-multi-commands.exp b/gdb/testsuite/gdb.mi/mi-multi-commands.exp
index 3a2e774..028e187 100644
--- a/gdb/testsuite/gdb.mi/mi-multi-commands.exp
+++ b/gdb/testsuite/gdb.mi/mi-multi-commands.exp
@@ -103,7 +103,7 @@ proc run_test { args } {
set seen_first_message true
exp_continue
}
- -re "\r\n$mi_gdb_prompt" {
+ -re "$mi_gdb_prompt" {
gdb_assert $seen_first_message $gdb_test_name
}
}
diff --git a/gdb/testsuite/gdb.mi/mi-nsmoribund.exp b/gdb/testsuite/gdb.mi/mi-nsmoribund.exp
index ba6ff5a..270dbc1 100644
--- a/gdb/testsuite/gdb.mi/mi-nsmoribund.exp
+++ b/gdb/testsuite/gdb.mi/mi-nsmoribund.exp
@@ -50,7 +50,7 @@ set bkpt_line [gdb_get_line_number "set breakpoint here"]
mi_create_breakpoint "$srcfile:$bkpt_line" \
"breakpoint at thread_function" \
- -number 2 -function thread_function
+ -number 2 -func thread_function
mi_send_resuming_command "exec-continue --all" "resume all"
for {set i 0} {$i < $nthreads} {incr i} {
diff --git a/gdb/testsuite/gdb.mi/mi-nsthrexec.exp b/gdb/testsuite/gdb.mi/mi-nsthrexec.exp
index fdfdd05..dba7847 100644
--- a/gdb/testsuite/gdb.mi/mi-nsthrexec.exp
+++ b/gdb/testsuite/gdb.mi/mi-nsthrexec.exp
@@ -47,7 +47,7 @@ if { [mi_runto_main] < 0 } {
mi_create_breakpoint thread_execler \
"breakpoint at thread_execler" \
- -number 2 -function thread_execler
+ -number 2 -func thread_execler
# All threads should stop, except the main thread.
mi_send_resuming_command "exec-continue --all" "resume all"
diff --git a/gdb/testsuite/gdb.mi/mi-pending.exp b/gdb/testsuite/gdb.mi/mi-pending.exp
index 99dbab4..4358c18 100644
--- a/gdb/testsuite/gdb.mi/mi-pending.exp
+++ b/gdb/testsuite/gdb.mi/mi-pending.exp
@@ -66,8 +66,8 @@ mi_create_breakpoint_pending "-f pendfunc1" \
mi_gdb_test "-break-commands 1 \"print 1\" \"print 2\" \"print 3\""\
"\\^done" \
"set breakpoint commands on pending breakpoint"
-set bp [mi_make_breakpoint_pending -number 1 -disp keep -func pendfunc1 \
- -disp keep -enabled y -original-location pendfunc1 \
+set bp [mi_make_breakpoint_pending -number 1 -disp keep \
+ -enabled y -original-location pendfunc1 \
-script {\["print 1","print 2","print 3"\]}]
mi_gdb_test "-break-info 1" \
"\\^done,[mi_make_breakpoint_table [list $bp]]" \
diff --git a/gdb/testsuite/gdb.mi/mi-sym-info.exp b/gdb/testsuite/gdb.mi/mi-sym-info.exp
index 40c0644..b8db2af 100644
--- a/gdb/testsuite/gdb.mi/mi-sym-info.exp
+++ b/gdb/testsuite/gdb.mi/mi-sym-info.exp
@@ -35,7 +35,8 @@ if {[build_executable "failed to prepare" ${testfile} \
mi_clean_restart $binfile
-mi_runto_main
+# Don't run to main to avoid increasing the search scope to include
+# debug info of shared libraries like libc, libgcc, etc.
set qstr "\"\[^\"\]+\""
set fun_re \
diff --git a/gdb/testsuite/gdb.mi/mi-thread-bp-deleted.exp b/gdb/testsuite/gdb.mi/mi-thread-bp-deleted.exp
index c048aca..08c7218 100644
--- a/gdb/testsuite/gdb.mi/mi-thread-bp-deleted.exp
+++ b/gdb/testsuite/gdb.mi/mi-thread-bp-deleted.exp
@@ -73,7 +73,7 @@ foreach_mi_ui_mode mode {
# UI.
if {$mode eq "separate"} {
with_spawn_id $gdb_main_spawn_id {
- gdb_test_multiple "" "drain CLI output upto breakpoint" {
+ gdb_test_multiple "" "drain CLI output up to breakpoint" {
-re "Thread 1 \[^\r\n\]+ hit Breakpoint $decimal,\
breakpt \\(\\) at\
\[^\r\n\]+\r\n$decimal\\s+\[^\r\n\]+\r\n" {
diff --git a/gdb/testsuite/gdb.mi/mi-var-cp.cc b/gdb/testsuite/gdb.mi/mi-var-cp.cc
index e8dd325..c40bdcf 100644
--- a/gdb/testsuite/gdb.mi/mi-var-cp.cc
+++ b/gdb/testsuite/gdb.mi/mi-var-cp.cc
@@ -42,7 +42,7 @@ struct S2 : S {};
int base_in_reference_test (S2& s2)
{
/*: BEGIN: base_in_reference :*/
- return s2.i;
+ int x = s2.i + s2.j;
/*:
mi_create_varobj "S2" "s2" "create varobj for s2"
mi_list_varobj_children "S2" {
@@ -62,6 +62,7 @@ int base_in_reference_test (S2& s2)
:*/
/*: END: base_in_reference :*/
+ return x;
}
void base_in_reference_test_main ()
diff --git a/gdb/testsuite/gdb.mi/mi-vla-c99.exp b/gdb/testsuite/gdb.mi/mi-vla-c99.exp
index ee4bc26..a8a77ac 100644
--- a/gdb/testsuite/gdb.mi/mi-vla-c99.exp
+++ b/gdb/testsuite/gdb.mi/mi-vla-c99.exp
@@ -37,7 +37,7 @@ set bp_lineno [gdb_get_line_number "vla-filled"]
mi_create_breakpoint "-t vla.c:$bp_lineno" \
"insert breakpoint at line $bp_lineno after vla is filled" \
- -function func -line $bp_lineno -file ".*vla.c" -disp del
+ -func func -line $bp_lineno -file ".*vla.c" -disp del
mi_run_cmd
mi_expect_stop "breakpoint-hit" "func" "\{name=\"n\",value=\"5\"\}" \
diff --git a/gdb/testsuite/gdb.mi/mi-vla-fortran.exp b/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
index e27f0ec..6097c02 100644
--- a/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
+++ b/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
@@ -41,7 +41,7 @@ if {[mi_clean_restart $binfile]} {
set bp_lineno [gdb_get_line_number "vla1-not-allocated"]
mi_create_breakpoint "-t vla.f90:$bp_lineno" \
"insert breakpoint at line $bp_lineno (vla not allocated)" \
- -number 1 -disp del -func vla ".*vla.f90" $bp_lineno $hex
+ -number 1 -disp del -func vla
mi_run_cmd
mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
{ "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
@@ -67,7 +67,7 @@ mi_list_array_varobj_children_with_index "vla1_not_allocated" "0" "1" \
set bp_lineno [gdb_get_line_number "vla1-allocated"]
mi_create_breakpoint "-t vla.f90:$bp_lineno" \
"insert breakpoint at line $bp_lineno (vla allocated)" \
- -number 2 -disp del -func vla ".*vla.f90" $bp_lineno $hex
+ -number 2 -disp del -func vla
mi_run_cmd
mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
{ "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
@@ -92,7 +92,7 @@ mi_list_array_varobj_children_with_index "vla1_allocated" "5" "1" \
set bp_lineno [gdb_get_line_number "vla1-filled"]
mi_create_breakpoint "-t vla.f90:$bp_lineno" \
"insert breakpoint at line $bp_lineno" \
- -number 3 -disp del -func vla ".*vla.f90" $bp_lineno $hex
+ -number 3 -disp del -func vla
mi_run_cmd
mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
{ "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
@@ -103,7 +103,7 @@ mi_gdb_test "520-data-evaluate-expression vla1" \
set bp_lineno [gdb_get_line_number "vla1-modified"]
mi_create_breakpoint "-t vla.f90:$bp_lineno" \
"insert breakpoint at line $bp_lineno" \
- -number 4 -disp del -func vla ".*vla.f90" $bp_lineno $hex
+ -number 4 -disp del -func vla
mi_run_cmd
mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
{ "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
@@ -120,7 +120,7 @@ mi_gdb_test "560-data-evaluate-expression vla1(4)" \
set bp_lineno [gdb_get_line_number "vla1-deallocated"]
mi_create_breakpoint "-t vla.f90:$bp_lineno" \
"insert breakpoint at line $bp_lineno" \
- -number 5 -disp del -func vla ".*vla.f90" $bp_lineno $hex
+ -number 5 -disp del -func vla
mi_run_cmd
mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
{ "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
@@ -131,7 +131,7 @@ mi_gdb_test "570-data-evaluate-expression vla1" \
set bp_lineno [gdb_get_line_number "pvla2-not-associated"]
mi_create_breakpoint "-t vla.f90:$bp_lineno" \
"insert breakpoint at line $bp_lineno" \
- -number 6 -disp "del" -func "vla" ".*vla.f90" $bp_lineno $hex
+ -number 6 -disp "del" -func "vla"
mi_run_cmd
mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
{ "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
@@ -172,7 +172,7 @@ gdb_expect {
set bp_lineno [gdb_get_line_number "pvla2-associated"]
mi_create_breakpoint "-t vla.f90:$bp_lineno" \
"insert breakpoint at line $bp_lineno" \
- -number 7 -disp del -func vla ".*vla.f90" $bp_lineno $hex
+ -number 7 -disp del -func vla
mi_run_cmd
mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
{ "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
@@ -196,7 +196,7 @@ mi_gdb_test "593-var-evaluate-expression pvla2_associated" \
set bp_lineno [gdb_get_line_number "pvla2-set-to-null"]
mi_create_breakpoint "-t vla.f90:$bp_lineno" \
"insert breakpoint at line $bp_lineno" \
- -number 8 -disp del -func vla ".*vla.f90" $bp_lineno $hex
+ -number 8 -disp del -func vla
mi_run_cmd
mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
{ "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
diff --git a/gdb/testsuite/gdb.modula2/builtin-procedure-adr.exp b/gdb/testsuite/gdb.modula2/builtin-procedure-adr.exp
new file mode 100644
index 0000000..6588020
--- /dev/null
+++ b/gdb/testsuite/gdb.modula2/builtin-procedure-adr.exp
@@ -0,0 +1,32 @@
+# Copyright 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the gdb testsuite. It contains tests for printing
+# the elements of an unbounded array using the Modula-2 language mode of
+# gdb.
+
+standard_testfile unbounded1.c
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug quiet}]} {
+ return -1
+}
+
+if {![runto main]} {
+ return
+}
+
+gdb_test "set lang modula-2" ".*does not match.*" "switch to modula-2"
+
+gdb_test "print ADR(i)" ".*0x.*" "print the address of local variable i"
diff --git a/gdb/testsuite/gdb.multi/bp-thread-specific.exp b/gdb/testsuite/gdb.multi/bp-thread-specific.exp
index c1d8752..11dc248 100644
--- a/gdb/testsuite/gdb.multi/bp-thread-specific.exp
+++ b/gdb/testsuite/gdb.multi/bp-thread-specific.exp
@@ -32,9 +32,33 @@ if {![runto_main]} {
return -1
}
+delete_breakpoints
+
+# Create a thread-specific b/p on main.
+gdb_breakpoint "main thread 1"
+set bpnum [get_integer_valueof "\$bpnum" "INVALID" \
+ "get number for thread specific b/p on main"]
+
+# Check the b/p has a location and is displayed correctly.
+gdb_test "info breakpoints" \
+ [multi_line \
+ "" \
+ "$bpnum\\s+breakpoint\\s+keep\\s+y\\s+$hex\\s+in main at \[^\r\n\]+/$srcfile:$decimal"\
+ "\\s+stop only in thread 1"] \
+ "check thread b/p on main has a location"
+
gdb_test "add-inferior -exec ${binfile}" "Added inferior 2.*" "add inferior 2"
gdb_test "inferior 2"
+# The breakpoint should still have a location, but should now display
+# information indicating this breakpoint is only in inferior 1.
+gdb_test "info breakpoints" \
+ [multi_line \
+ "" \
+ "$bpnum\\s+breakpoint\\s+keep\\s+y\\s+$hex\\s+in main at \[^\r\n\]+/$srcfile:$decimal inf 1"\
+ "\\s+stop only in thread 1\\.1"] \
+ "check thread b/p on main still has updated correctly"
+
if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.multi/inferior-specific-bp-1.c b/gdb/testsuite/gdb.multi/inferior-specific-bp-1.c
index 59a6e32..16db062 100644
--- a/gdb/testsuite/gdb.multi/inferior-specific-bp-1.c
+++ b/gdb/testsuite/gdb.multi/inferior-specific-bp-1.c
@@ -35,7 +35,7 @@ foo (void)
static void
bar (void)
{
- global_var = 0;
+ global_var = 0; /* First location of bar. */
foo ();
}
diff --git a/gdb/testsuite/gdb.multi/inferior-specific-bp-2.c b/gdb/testsuite/gdb.multi/inferior-specific-bp-2.c
index cbae745..3a45c21 100644
--- a/gdb/testsuite/gdb.multi/inferior-specific-bp-2.c
+++ b/gdb/testsuite/gdb.multi/inferior-specific-bp-2.c
@@ -30,13 +30,14 @@ main (void)
{
int ret = baz ();
stop_breakpt ();
- return ret;
+ /* We have to call bar here, otherwise it might be optimized away. */
+ return ret + bar ();
}
static int
bar (void)
{
- return baz ();
+ return baz (); /* Second location of bar. */
}
static int
diff --git a/gdb/testsuite/gdb.multi/inferior-specific-bp.exp b/gdb/testsuite/gdb.multi/inferior-specific-bp.exp
index 52f8418..82cc924 100644
--- a/gdb/testsuite/gdb.multi/inferior-specific-bp.exp
+++ b/gdb/testsuite/gdb.multi/inferior-specific-bp.exp
@@ -62,6 +62,73 @@ gdb_test "break foo inferior 1 inferior 2" \
# Clear out any other breakpoints.
delete_breakpoints
+# Create an inferior specific breakpoint and then change the inferior
+# using the Python API. Use 'info breakpoint' to check that the
+# breakpoint was updated as we expect.
+if { [allow_python_tests] } {
+ with_test_prefix "update breakpoint inferior" {
+ # Create the b/p and grab its number.
+ gdb_breakpoint "bar inferior 1"
+ set bpnum [get_integer_valueof "\$bpnum" "INVALID" \
+ "get b/p number for breakpoint on bar"]
+
+ # Get the line number for the two locations, the first in
+ # inferior 1, the second in inferior 2.
+ set bar_lineno_1 \
+ [gdb_get_line_number "First location of bar" $srcfile]
+ set bar_lineno_2 \
+ [gdb_get_line_number "Second location of bar" $srcfile2]
+
+ # Check the b/p was created with a single location where we
+ # expect it.
+ gdb_test "info breakpoint $bpnum" \
+ [multi_line \
+ "" \
+ "$bpnum\\s+breakpoint\\s+keep\\s+y\\s+$hex\\s+in bar at \[^\r\n\]+/$srcfile:$bar_lineno_1 inf 1" \
+ "\\s+stop only in inferior 1"] \
+ "check original details for breakpoint on bar"
+
+ # Use the Python API to update the b/p's inferior.
+ gdb_test_no_output "python bp = gdb.breakpoints()\[0\]"
+ gdb_test_no_output "python bp.inferior = 2"
+
+ # We should still only have a single location, but now in
+ # inferior 2.
+ gdb_test "info breakpoint $bpnum" \
+ [multi_line \
+ "" \
+ "$bpnum\\s+breakpoint\\s+keep\\s+y\\s+$hex\\s+in bar at \[^\r\n\]+/$srcfile2:$bar_lineno_2 inf 2" \
+ "\\s+stop only in inferior 2"] \
+ "check updated details for breakpoint on bar"
+
+ # Use the Python API to remove the inferior restriction on the
+ # breakpoint.
+ gdb_test_no_output "python bp.inferior = None"
+
+ # The breakpoint should now have multiple locations.
+ gdb_test "info breakpoint $bpnum" \
+ [multi_line \
+ "" \
+ "$bpnum\\s+breakpoint\\s+keep\\s+y\\s+<MULTIPLE>\\s*" \
+ "$bpnum.1\\s+y\\s+$hex\\s+in bar at\[^\r\n\]+$srcfile:$bar_lineno_1 inf 1" \
+ "$bpnum.2\\s+y\\s+$hex\\s+in bar at\[^\r\n\]+$srcfile2:$bar_lineno_2 inf 2"] \
+ "check breakpoint bar now inferior requirement is gone"
+
+ # Finally, add the inferior requirement back.
+ gdb_test_no_output "python bp.inferior = 1"
+
+ # Check the original location and restriction is restored.
+ gdb_test "info breakpoint $bpnum" \
+ [multi_line \
+ "" \
+ "$bpnum\\s+breakpoint\\s+keep\\s+y\\s+$hex\\s+in bar at \[^\r\n\]+/$srcfile:$bar_lineno_1 inf 1" \
+ "\\s+stop only in inferior 1"] \
+ "check original details for breakpoint on bar are back"
+
+ delete_breakpoints
+ }
+}
+
# Use 'info breakpoint' to check that the inferior specific breakpoint is
# present in the breakpoint list. TESTNAME is the name used for this test,
# BP_NUMBER is the number for the breakpoint, and EXPECTED_LOC_COUNT is the
diff --git a/gdb/testsuite/gdb.multi/multi-term-settings.c b/gdb/testsuite/gdb.multi/multi-term-settings.c
index 6880206..e9e7e95 100644
--- a/gdb/testsuite/gdb.multi/multi-term-settings.c
+++ b/gdb/testsuite/gdb.multi/multi-term-settings.c
@@ -22,7 +22,6 @@
#include <stdio.h>
#include <sys/types.h>
#include <termios.h>
-#include <unistd.h>
#include <signal.h>
int
diff --git a/gdb/testsuite/gdb.multi/multi-term-settings.exp b/gdb/testsuite/gdb.multi/multi-term-settings.exp
index 59ff8ce..0aeba1f 100644
--- a/gdb/testsuite/gdb.multi/multi-term-settings.exp
+++ b/gdb/testsuite/gdb.multi/multi-term-settings.exp
@@ -94,7 +94,7 @@ proc create_inferior {which_inf inf_how} {
"attach"] == 0} {
# The program is now stopped, but if testing against
- # gdbserver, then the inferior's output emmitted before it
+ # gdbserver, then the inferior's output emitted before it
# stopped isn't flushed unless we explicitly do so,
# because it is on a different spawn_id. Do it now, to
# avoid confusing tests further below.
diff --git a/gdb/testsuite/gdb.opt/break-on-_exit.exp b/gdb/testsuite/gdb.opt/break-on-_exit.exp
index 59a1c61..59fecaa 100644
--- a/gdb/testsuite/gdb.opt/break-on-_exit.exp
+++ b/gdb/testsuite/gdb.opt/break-on-_exit.exp
@@ -18,7 +18,7 @@
# set past the syscall due to faulty prologue skipping, the breakpoint will not
# trigger.
#
-# In particular, we're trying to excercise the instruction analysis
+# In particular, we're trying to exercise the instruction analysis
# functionality of prologue skipping. If the non-minimal symbols are
# read for libc, then that functionality might not be used because f.i.
# line-info is used instead. Also, if the minimal symbols are not read
diff --git a/gdb/testsuite/gdb.pascal/floats.exp b/gdb/testsuite/gdb.pascal/floats.exp
index 3e836a3..d96fb9b 100644
--- a/gdb/testsuite/gdb.pascal/floats.exp
+++ b/gdb/testsuite/gdb.pascal/floats.exp
@@ -87,7 +87,7 @@ gdb_test "print r + (-1)" " = 0\\.2(499.*|5|500.*)"
gdb_test "print r + (-5)" " = -3\\.7(499.*|5|500.*)"
gdb_test "print r + (-10)" " = -8\\.7(499.*|5|500.*)"
-# Test substraction
+# Test subtraction
gdb_test "print r - s" " = -0\\.9(499.*|5|500.*)"
gdb_test "print r - t" " = 4\\.4(499.*|5|500.*)"
diff --git a/gdb/testsuite/gdb.pascal/integers.exp b/gdb/testsuite/gdb.pascal/integers.exp
index ec5f53c..974de6f 100644
--- a/gdb/testsuite/gdb.pascal/integers.exp
+++ b/gdb/testsuite/gdb.pascal/integers.exp
@@ -71,7 +71,7 @@ gdb_test "print i + k" " = 4"
gdb_test "print j + k" " = 5"
gdb_test "print i + j + k" " = 6"
-# Test substraction
+# Test subtraction
gdb_test "print j - i" " = 1"
gdb_test "print i - j" "= -1"
gdb_test "print k -i -j" " = 0"
diff --git a/gdb/testsuite/gdb.pascal/types.exp b/gdb/testsuite/gdb.pascal/types.exp
index 5b8d00b..262045e 100644
--- a/gdb/testsuite/gdb.pascal/types.exp
+++ b/gdb/testsuite/gdb.pascal/types.exp
@@ -59,7 +59,7 @@ proc test_float_literal_types_accepted {} {
# Test various floating point formats
# this used to guess whether to look for "real*4" or
- # "real*8" based on a target config variable, but noone
+ # "real*8" based on a target config variable, but no one
# maintained it properly.
gdb_test "pt .44" "type = double"
diff --git a/gdb/testsuite/gdb.python/py-arch.exp b/gdb/testsuite/gdb.python/py-arch.exp
index 3c58bf1..aef4186 100644
--- a/gdb/testsuite/gdb.python/py-arch.exp
+++ b/gdb/testsuite/gdb.python/py-arch.exp
@@ -28,7 +28,7 @@ if ![runto_main] {
# internal GDB assert.
gdb_py_test_silent_cmd "python empty = gdb.Architecture()" "get empty arch" 0
gdb_test "python print(repr (empty))" "<gdb\\.Architecture \\(invalid\\)>" \
- "Test empty achitecture __repr__ does not trigger an assert"
+ "Test empty architecture __repr__ does not trigger an assert"
gdb_test "python print(empty.name())" ".*Architecture is invalid.*" \
"Test empty architecture.name does not trigger an assert"
gdb_test "python print(empty.disassemble())" ".*Architecture is invalid.*" \
diff --git a/gdb/testsuite/gdb.python/py-format-string.exp b/gdb/testsuite/gdb.python/py-format-string.exp
index 9209213..d0349c5 100644
--- a/gdb/testsuite/gdb.python/py-format-string.exp
+++ b/gdb/testsuite/gdb.python/py-format-string.exp
@@ -82,7 +82,7 @@ set default_pointer_regexp "0x\[a-fA-F0-9\]+"
# A regular expression for a non-expanded C++ reference.
#
-# Stringifying a C++ reference produces an address preceeded by a "@" in
+# Stringifying a C++ reference produces an address preceded by a "@" in
# Python, but, by default, the C++ reference/class is expanded by the
# GDB print command.
set default_ref_regexp "@${default_pointer_regexp}"
diff --git a/gdb/testsuite/gdb.python/py-inferior.exp b/gdb/testsuite/gdb.python/py-inferior.exp
index ee30390..58475bd 100644
--- a/gdb/testsuite/gdb.python/py-inferior.exp
+++ b/gdb/testsuite/gdb.python/py-inferior.exp
@@ -27,12 +27,13 @@ if { [gdb_compile_pthreads ${srcdir}/${subdir}/${srcfile} ${binfile} executable
}
# Start with a fresh gdb.
-save_vars { env(ASAN_OPTIONS) } {
+save_vars { env(ASAN_OPTIONS) env(TSAN_OPTIONS) } {
# The call to gdb.selected_inferior().read_memory (0, 0xffffffffffffffff)
# triggers address sanitizer. Suppress the error, leaving us with just
# this warning:
# WARNING: AddressSanitizer failed to allocate 0xffffffffffffffff bytes
set_sanitizer ASAN_OPTIONS allocator_may_return_null 1
+ set_sanitizer TSAN_OPTIONS allocator_may_return_null 1
clean_restart ${testfile}
}
diff --git a/gdb/testsuite/gdb.python/py-pp-cast.py b/gdb/testsuite/gdb.python/py-pp-cast.py
index 6eff800..c071920 100644
--- a/gdb/testsuite/gdb.python/py-pp-cast.py
+++ b/gdb/testsuite/gdb.python/py-pp-cast.py
@@ -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/>.
+import gdb.printing
+
class PpIntPrinter(object):
def __init__(self, val):
diff --git a/gdb/testsuite/gdb.python/py-pp-maint.exp b/gdb/testsuite/gdb.python/py-pp-maint.exp
index f224ae7..1ee206c 100644
--- a/gdb/testsuite/gdb.python/py-pp-maint.exp
+++ b/gdb/testsuite/gdb.python/py-pp-maint.exp
@@ -55,7 +55,7 @@ gdb_test "print flt" " = x=<42> y=<43>" \
gdb_test "print ss" " = a=<a=<1> b=<$hex>> b=<a=<2> b=<$hex>>" \
"print ss enabled #1"
-set num_pp 7
+set num_pp 6
gdb_test "disable pretty-printer" \
"$num_pp printers disabled.*0 of $num_pp printers enabled"
@@ -75,7 +75,7 @@ gdb_test "disable pretty-printer global lookup_function_lookup_test" \
"1 printer disabled.*[expr $num_pp - 1] of $num_pp printers enabled"
gdb_test "disable pretty-printer global pp-test;.*" \
- "[expr $num_pp - 2] printers disabled.*1 of $num_pp printers enabled"
+ "[expr 5] printers disabled.*0 of $num_pp printers enabled"
gdb_test "info pretty-printer global .*function" \
{.*function_lookup_test \[disabled\].*} \
@@ -92,13 +92,13 @@ gdb_test "print ss" " = {a = {a = 1, b = $hex}, b = {a = 2, b = $hex}}" \
"print ss disabled"
gdb_test "enable pretty-printer global lookup_function_lookup_test" \
- "1 printer enabled.*2 of $num_pp printers enabled"
+ "1 printer enabled.*1 of $num_pp printers enabled"
# This doesn't enable any printers because each subprinter in the collection
# is still individually disabled. But this is still needed, to enable the
# collection itself.
gdb_test "enable pretty-printer global pp-test" \
- "0 printers enabled.*2 of $num_pp printers enabled"
+ "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"
diff --git a/gdb/testsuite/gdb.python/py-pp-re-notag.py b/gdb/testsuite/gdb.python/py-pp-re-notag.py
index 6aefad1..00bc5c7 100644
--- a/gdb/testsuite/gdb.python/py-pp-re-notag.py
+++ b/gdb/testsuite/gdb.python/py-pp-re-notag.py
@@ -16,6 +16,7 @@
from time import asctime, gmtime
import gdb # silence pyflakes
+import gdb.printing
class TimePrinter:
diff --git a/gdb/testsuite/gdb.python/py-prettyprint-stub.py b/gdb/testsuite/gdb.python/py-prettyprint-stub.py
index 565ae19..2378f55 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint-stub.py
+++ b/gdb/testsuite/gdb.python/py-prettyprint-stub.py
@@ -16,6 +16,8 @@
# This file is part of the GDB testsuite.
# It tests Python-based pretty-printing of stubs.
+import gdb.printing
+
class SPrinter:
def __init__(self, val):
diff --git a/gdb/testsuite/gdb.python/py-read-memory-leak.c b/gdb/testsuite/gdb.python/py-read-memory-leak.c
new file mode 100644
index 0000000..75035cd
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-read-memory-leak.c
@@ -0,0 +1,27 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2014-2024 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+static struct x
+{
+ char unsigned u[4096];
+} x, *px = &x;
+
+int
+main (void)
+{
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.python/py-read-memory-leak.exp b/gdb/testsuite/gdb.python/py-read-memory-leak.exp
new file mode 100644
index 0000000..52b072f
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-read-memory-leak.exp
@@ -0,0 +1,44 @@
+# Copyright (C) 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the GDB testsuite. It checks for memory leaks
+# associated with calling gdb.Inferior.read_memory().
+
+load_lib gdb-python.exp
+
+require allow_python_tests
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
+ return -1
+}
+
+if ![runto_main] {
+ return -1
+}
+
+# Skip this test if the tracemalloc module is not available.
+if { ![gdb_py_module_available "tracemalloc"] } {
+ unsupported "tracemalloc module not available"
+ return
+}
+
+set pyfile [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py]
+
+# Source the Python script, this runs the test (which is written
+# completely in Python), and either prints PASS, or throws an
+# exception.
+gdb_test "source ${pyfile}" "PASS" "source python script"
diff --git a/gdb/testsuite/gdb.python/py-read-memory-leak.py b/gdb/testsuite/gdb.python/py-read-memory-leak.py
new file mode 100644
index 0000000..430c5c2
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-read-memory-leak.py
@@ -0,0 +1,93 @@
+# Copyright (C) 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import os
+import tracemalloc
+
+import gdb
+
+# A global variable in which we store a reference to the memory buffer
+# returned from gdb.Inferior.read_memory().
+mem_buf = None
+
+
+# A global filters list, we only care about memory allocations
+# originating from this script.
+filters = [tracemalloc.Filter(True, "*" + os.path.basename(__file__))]
+
+
+# Run the test. When CLEAR is True we clear the global INF variable
+# before comparing the before and after memory allocation traces.
+# When CLEAR is False we leave INF set to reference the gdb.Inferior
+# object, thus preventing the gdb.Inferior from being deallocated.
+def test(clear):
+ global filters, mem_buf
+
+ addr = gdb.parse_and_eval("px")
+ inf = gdb.inferiors()[0]
+
+ # Start tracing, and take a snapshot of the current allocations.
+ tracemalloc.start()
+ snapshot1 = tracemalloc.take_snapshot()
+
+ # Read from the inferior, this allocate a memory buffer object.
+ mem_buf = inf.read_memory(addr, 4096)
+
+ # Possibly clear the global INF variable.
+ if clear:
+ mem_buf = None
+
+ # Now grab a second snapshot of memory allocations, and stop
+ # tracing memory allocations.
+ snapshot2 = tracemalloc.take_snapshot()
+ tracemalloc.stop()
+
+ # Filter the snapshots; we only care about allocations originating
+ # from this file.
+ snapshot1 = snapshot1.filter_traces(filters)
+ snapshot2 = snapshot2.filter_traces(filters)
+
+ # Compare the snapshots, this leaves only things that were
+ # allocated, but not deallocated since the first snapshot.
+ stats = snapshot2.compare_to(snapshot1, "traceback")
+
+ # Total up all the allocated things.
+ total = 0
+ for stat in stats:
+ total += stat.size_diff
+ return total
+
+
+# The first time we run this some global state will be allocated which
+# shows up as memory that is allocated, but not released. So, run the
+# test once and discard the result.
+test(True)
+
+# Now run the test twice, the first time we clear our global reference
+# to the memory buffer object, which should allow Python to deallocate
+# the object. The second time we hold onto the global reference,
+# preventing Python from performing the deallocation.
+bytes_with_clear = test(True)
+bytes_without_clear = test(False)
+
+# The bug that used to exist in GDB was that even when we released the
+# global reference the gdb.Inferior object would not be deallocated.
+if bytes_with_clear > 0:
+ raise gdb.GdbError("memory leak when memory buffer should be released")
+if bytes_without_clear == 0:
+ raise gdb.GdbError("memory buffer object is no longer allocated")
+
+# Print a PASS message that the test script can see.
+print("PASS")
diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp
index 175a6de..e8eb9ec 100644
--- a/gdb/testsuite/gdb.python/python.exp
+++ b/gdb/testsuite/gdb.python/python.exp
@@ -561,3 +561,12 @@ if { [use_gdb_stub] == 0 } {
}
}
}
+
+# Regression test for PR python/32163: several types were not
+# previously registered with the module, so could not be inspected
+# directly.
+foreach type {Instruction LazyString Membuf Record RecordFunctionSegment \
+ RecordGap RecordInstruction TuiWindow} {
+ gdb_test "python print(type(gdb.$type))" "<class 'type'>" \
+ "gdb.$type is registered"
+}
diff --git a/gdb/testsuite/gdb.python/sys-exit.exp b/gdb/testsuite/gdb.python/sys-exit.exp
new file mode 100644
index 0000000..3396b8d
--- /dev/null
+++ b/gdb/testsuite/gdb.python/sys-exit.exp
@@ -0,0 +1,69 @@
+# Copyright 2024 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Check that python sys.exit makes gdb exit, with the correct exit status.
+
+require allow_python_tests
+
+# Have this code in a proc avoids clashing with runtest variable exit_status.
+
+proc do_test { n {expected_exit_status ""} {msg ""}} {
+ if { $expected_exit_status == "" } {
+ set expected_exit_status $n
+ }
+
+ with_test_prefix $n {
+ clean_restart
+
+ # Regression test for PR python/31946.
+ set seen_message 0
+ gdb_test_multiple "python sys.exit ($n)" "python sys.exit" {
+ -re "\r\n$msg\r\n" {
+ set seen_message 1
+ exp_continue
+ }
+ eof {
+ set wait_status [wait -i $::gdb_spawn_id]
+ clear_gdb_spawn_id
+
+ verbose -log "GDB process exited with wait status $wait_status"
+
+ set os_error [lindex $wait_status 2]
+ set exit_status [lindex $wait_status 3]
+
+ gdb_assert \
+ { $os_error == 0 \
+ && $exit_status == $expected_exit_status } \
+ $gdb_test_name
+
+ if { $msg != "" } {
+ gdb_assert { $seen_message }
+ }
+ }
+ }
+ }
+}
+
+# Test sys.exit (<int>).
+do_test 0
+do_test 1
+do_test 2
+
+# Test sys.exit (None).
+do_test None 0
+
+# Test sys.exit (<string>).
+do_test {"Error Message"} 1 "Error Message"
+do_test {""} 1
diff --git a/gdb/testsuite/gdb.reverse/func-map-to-same-line.exp b/gdb/testsuite/gdb.reverse/func-map-to-same-line.exp
index 9949907..8f933eb 100644
--- a/gdb/testsuite/gdb.reverse/func-map-to-same-line.exp
+++ b/gdb/testsuite/gdb.reverse/func-map-to-same-line.exp
@@ -37,7 +37,7 @@ proc run_tests {} {
gdb_test_no_output "record" "turn on process record"
# This regression test verifies the reverse-step and reverse-next
- # commands work properly when executing backwards thru a source line
+ # commands work properly when executing backwards through a source line
# containing two function calls on the same source line, i.e.
# func1 (); func2 ();. This test is compiled so the dwarf info
# does not contain the line table information.
@@ -100,7 +100,7 @@ proc run_tests {} {
# the called function, stopping at the beginning of the last
# statement in the called function (typically a return statement).
# Also, as with the step command, if non-debuggable functions are
- # called, reverse-step will run thru them backward without
+ # called, reverse-step will run through them backward without
# stopping.
gdb_continue_to_breakpoint \
diff --git a/gdb/testsuite/gdb.reverse/step-precsave.exp b/gdb/testsuite/gdb.reverse/step-precsave.exp
index 9ae67b3..a3979b7 100644
--- a/gdb/testsuite/gdb.reverse/step-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/step-precsave.exp
@@ -153,7 +153,7 @@ gdb_test_multiple "stepi" "$test_message" {
}
}
-# stepi thru return of a function call
+# stepi through return of a function call
set test_message "stepi back from function call"
gdb_test_multiple "stepi" "$test_message" {
@@ -185,10 +185,10 @@ gdb_test_multiple "stepi" "$test_message" {
gdb_test_no_output "set exec-dir reverse" "set reverse execution"
-# stepi backward thru return and into a function
+# stepi backward through return and into a function
set stepi_location [gdb_get_line_number "ARRIVED IN CALLEE" "$srcfile"]
-set test_message "reverse stepi thru function return"
+set test_message "reverse stepi through function return"
gdb_test_multiple "stepi" "$test_message" {
-re "NEXTI TEST.*$gdb_prompt $" {
fail "$test_message (start statement)"
diff --git a/gdb/testsuite/gdb.reverse/step-reverse.exp b/gdb/testsuite/gdb.reverse/step-reverse.exp
index 2db73e9..a3c3b5a 100644
--- a/gdb/testsuite/gdb.reverse/step-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/step-reverse.exp
@@ -114,7 +114,7 @@ gdb_test_multiple "stepi" "$test_message" {
}
}
-# stepi thru return of a function call
+# stepi through return of a function call
set test_message "stepi back from function call"
gdb_test_multiple "stepi" "$test_message" {
@@ -145,10 +145,10 @@ gdb_test_multiple "stepi" "$test_message" {
# Set reverse execution direction
gdb_test_no_output "set exec-dir reverse" "set reverse execution"
-# stepi backward thru return and into a function
+# stepi backward through return and into a function
set stepi_location [gdb_get_line_number "ARRIVED IN CALLEE" "$srcfile"]
-set test_message "reverse stepi thru function return"
+set test_message "reverse stepi through function return"
gdb_test_multiple "stepi" "$test_message" {
-re "NEXTI TEST.*$gdb_prompt $" {
fail "$test_message (start statement)"
diff --git a/gdb/testsuite/gdb.server/exit-multiple-threads.c b/gdb/testsuite/gdb.server/exit-multiple-threads.c
index 989f1f2..5bf0fc8 100644
--- a/gdb/testsuite/gdb.server/exit-multiple-threads.c
+++ b/gdb/testsuite/gdb.server/exit-multiple-threads.c
@@ -20,7 +20,6 @@
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
-#include <pthread.h>
/* The number of threads to create. */
int thread_count = 3;
diff --git a/gdb/testsuite/gdb.server/server-run.exp b/gdb/testsuite/gdb.server/server-run.exp
index 92eb38b..af5a5f5 100644
--- a/gdb/testsuite/gdb.server/server-run.exp
+++ b/gdb/testsuite/gdb.server/server-run.exp
@@ -52,3 +52,36 @@ if { [istarget *-*-linux*] } {
gdb_breakpoint main
gdb_test "continue" "Breakpoint.* main .*" "continue to main"
+
+if { [istarget "aarch64*-*-*"]
+ || [istarget "arm*-*-*"]
+ || [istarget "csky*-*-*"]
+ || [istarget "loongarch*-*-*"]
+ || [istarget "riscv*-*-*"] } {
+ set pc_regname "pc"
+} elseif { [is_amd64_regs_target] } {
+ set pc_regname "rip"
+} elseif { [is_x86_like_target] } {
+ set pc_regname "eip"
+} elseif { [istarget "tic6x-*-*"] } {
+ set pc_regname "PC"
+}
+
+# Sending the PC register in advance is good practice. Test that this is
+# actually done for the targets where gdbserver is supposed to.
+set expedited_pc_test_name "send PC as expedited register in stop reply"
+if { [info exists pc_regname] } {
+ set seen_line false
+ gdb_test_multiple "maintenance print remote-registers" \
+ $expedited_pc_test_name -lbl {
+ -re " ${pc_regname}\[\[:space:\]\]+${decimal}.*${decimal} yes" {
+ set seen_line true
+ exp_continue
+ }
+ -re "\r\n$gdb_prompt $" {
+ gdb_assert { $seen_line } $gdb_test_name
+ }
+ }
+} else {
+ untested $expedited_pc_test_name
+}
diff --git a/gdb/testsuite/gdb.testsuite/parse_options_args.exp b/gdb/testsuite/gdb.testsuite/parse_options_args.exp
index 19ad67a..7239ef7 100644
--- a/gdb/testsuite/gdb.testsuite/parse_options_args.exp
+++ b/gdb/testsuite/gdb.testsuite/parse_options_args.exp
@@ -38,7 +38,7 @@ with_test_prefix parse_options {
with_test_prefix parse_args {
proc test2 { args } {
- parse_args {
+ parse_some_args {
{ opt1 defval1 }
{ opt2 defval2 }
{ opt3 }
diff --git a/gdb/testsuite/gdb.threads/create-fail.c b/gdb/testsuite/gdb.threads/create-fail.c
index 01633e4..e4cd27e 100644
--- a/gdb/testsuite/gdb.threads/create-fail.c
+++ b/gdb/testsuite/gdb.threads/create-fail.c
@@ -23,10 +23,8 @@
#include <errno.h>
#include <string.h>
#include <assert.h>
-#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>
-#include <assert.h>
#include <unistd.h>
/* Count the number of tasks/threads in the PID thread group. */
diff --git a/gdb/testsuite/gdb.threads/fork-thread-pending.c b/gdb/testsuite/gdb.threads/fork-thread-pending.c
index 01dcc40..a9b557a 100644
--- a/gdb/testsuite/gdb.threads/fork-thread-pending.c
+++ b/gdb/testsuite/gdb.threads/fork-thread-pending.c
@@ -21,7 +21,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
-#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
diff --git a/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp b/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp
index bb05754..89c1d06 100644
--- a/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp
+++ b/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp
@@ -67,7 +67,7 @@ proc return_if_nonzero { result } {
}
}
-# Do one iteration of "c -a& -> interrupt -a". Return zero on sucess,
+# Do one iteration of "c -a& -> interrupt -a". Return zero on success,
# and non-zero if some test fails.
proc test_one_iteration {} {
diff --git a/gdb/testsuite/gdb.threads/signal-command-handle-nopass.c b/gdb/testsuite/gdb.threads/signal-command-handle-nopass.c
index 6d82bd6..548d0d3 100644
--- a/gdb/testsuite/gdb.threads/signal-command-handle-nopass.c
+++ b/gdb/testsuite/gdb.threads/signal-command-handle-nopass.c
@@ -21,6 +21,8 @@
#include <pthread.h>
#include <signal.h>
+static pthread_barrier_t barrier;
+
void
handler (int sig)
{
@@ -35,6 +37,13 @@ thread_function (void *arg)
usleep (1);
}
+void *
+thread_function_sync (void *arg)
+{
+ pthread_barrier_wait (&barrier);
+ return thread_function (arg);
+}
+
int
main (void)
{
@@ -42,7 +51,15 @@ main (void)
int i;
signal (SIGUSR1, handler);
- pthread_create (&child_thread, NULL, thread_function, NULL);
+
+ pthread_barrier_init (&barrier, NULL, 2);
+
+ pthread_create (&child_thread, NULL, thread_function_sync, NULL);
+
+ /* Make sure that pthread_create is done once the breakpoint on
+ thread_function triggers. */
+ pthread_barrier_wait (&barrier);
+
pthread_join (child_thread, NULL);
return 0;
diff --git a/gdb/testsuite/gdb.threads/signal-sigtrap.c b/gdb/testsuite/gdb.threads/signal-sigtrap.c
index 24625ba..7c903a1 100644
--- a/gdb/testsuite/gdb.threads/signal-sigtrap.c
+++ b/gdb/testsuite/gdb.threads/signal-sigtrap.c
@@ -20,6 +20,8 @@
#include <pthread.h>
#include <signal.h>
+static pthread_barrier_t barrier;
+
void
sigtrap_handler (int sig)
{
@@ -31,6 +33,13 @@ thread_function (void *arg)
return NULL;
}
+void *
+thread_function_sync (void *arg)
+{
+ pthread_barrier_wait (&barrier);
+ return thread_function (arg);
+}
+
int
main (void)
{
@@ -38,7 +47,13 @@ main (void)
signal (SIGTRAP, sigtrap_handler);
- pthread_create (&child_thread, NULL, thread_function, NULL);
+ pthread_barrier_init (&barrier, NULL, 2);
+
+ pthread_create (&child_thread, NULL, thread_function_sync, NULL);
+
+ /* Make sure that pthread_create is done once the breakpoint on
+ thread_function triggers. */
+ pthread_barrier_wait (&barrier);
pthread_join (child_thread, NULL);
diff --git a/gdb/testsuite/gdb.threads/thread-bp-deleted.exp b/gdb/testsuite/gdb.threads/thread-bp-deleted.exp
index 5d15a29..3851f8f 100644
--- a/gdb/testsuite/gdb.threads/thread-bp-deleted.exp
+++ b/gdb/testsuite/gdb.threads/thread-bp-deleted.exp
@@ -124,7 +124,7 @@ if {$is_remote} {
#
# However, we might be too quick sending the 'info threads 99' command,
# so, if we see the output of that command without any thread exited
- # text, we wait for a short while and try again. We wait for upto 5
+ # text, we wait for a short while and try again. We wait for up to 5
# seconds (5 tries). However, this might mean on a _really_ slow
# machine that the thread still hasn't exited. I guess if we start
# seeing that then we can just update ATTEMPT_COUNT below.
diff --git a/gdb/testsuite/gdb.threads/thread_check.exp b/gdb/testsuite/gdb.threads/thread_check.exp
index 83fa86d..658f15e 100644
--- a/gdb/testsuite/gdb.threads/thread_check.exp
+++ b/gdb/testsuite/gdb.threads/thread_check.exp
@@ -47,7 +47,7 @@ if {![runto_main]} {
#
-# set breakpoint at thread fucntion tf
+# set breakpoint at thread function tf
#
gdb_test "break tf" \
"Breakpoint.*at.* file .*$srcfile, line.*" \
diff --git a/gdb/testsuite/gdb.threads/tls-sepdebug.exp b/gdb/testsuite/gdb.threads/tls-sepdebug.exp
index 14a0c45..4a322e0 100644
--- a/gdb/testsuite/gdb.threads/tls-sepdebug.exp
+++ b/gdb/testsuite/gdb.threads/tls-sepdebug.exp
@@ -65,16 +65,21 @@ if { [gdb_compile_pthreads \
}
set absdir [file dirname [standard_output_file ${binsharedbase}]]
+if { [info exists ::env(LD_LIBRARY_PATH)] } {
+ set ld_library_path $::env(LD_LIBRARY_PATH)
+} else {
+ set ld_library_path ""
+}
-foreach ld_library_path [list $absdir [relative_filename [pwd] $absdir]] \
+foreach library_path [list $absdir [relative_filename [pwd] $absdir]] \
name { absolute relative } {
with_test_prefix $name {
# Restart, but defer loading until after setting LD_LIBRARY_PATH.
clean_restart
-
- gdb_test_no_output "set env LD_LIBRARY_PATH=$ld_library_path" \
- "set env LD_LIBRARY_PATH"
+ gdb_test_no_output \
+ "set env LD_LIBRARY_PATH=$ld_library_path:$library_path" \
+ "set env LD_LIBRARY_PATH"
gdb_load ${binmainfile}
diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c b/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c
index b74a841..eb65d45 100644
--- a/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c
+++ b/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c
@@ -27,7 +27,6 @@
#include <pthread.h>
#include <asm/unistd.h>
-#include <unistd.h>
#define gettid() syscall (__NR_gettid)
/* Non-atomic `var++' should not hurt as we synchronize the threads by the STEP
diff --git a/gdb/testsuite/gdb.trace/collection.exp b/gdb/testsuite/gdb.trace/collection.exp
index b7d0f9f..9c6d3f5 100644
--- a/gdb/testsuite/gdb.trace/collection.exp
+++ b/gdb/testsuite/gdb.trace/collection.exp
@@ -161,7 +161,7 @@ proc gdb_collect_args_test { myargs msg } {
# collected. In C, an array as function parameters is a special
# case; it's just a pointer into the caller's array, and as such,
# that's what normally the debug info describes. Maybe this was
- # originaly written for a compiler where array parameters were
+ # originally written for a compiler where array parameters were
# really described as arrays in debug info.
setup_xfail "*-*-*"
@@ -250,7 +250,7 @@ proc gdb_collect_argarray_test { myargs msg } {
# are collected. In C, an array as function parameters is a
# special case; it's just a pointer into the caller's array,
# and as such, that's what normally the debug info describes.
- # Maybe this was originaly written for a compiler where array
+ # Maybe this was originally written for a compiler where array
# parameters were really described as arrays in debug info.
setup_xfail "*-*-*"
diff --git a/gdb/testsuite/gdb.trace/entry-values.exp b/gdb/testsuite/gdb.trace/entry-values.exp
index 3b358cc..82ae5a8 100644
--- a/gdb/testsuite/gdb.trace/entry-values.exp
+++ b/gdb/testsuite/gdb.trace/entry-values.exp
@@ -53,6 +53,8 @@ if { [istarget "arm*-*-*"] || [istarget "aarch64*-*-*"] } {
# returns. The only exception is JALRC, in which case execution
# resumes from `insn1' instead.
set call_insn {jalrc|[jb]al[sxr]*[ \t][^\r\n]+\r\n}
+} elseif { [istarget "riscv64*-*-*"] } {
+ set call_insn jal
} else {
set call_insn "call"
}
diff --git a/gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp b/gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp
index e6672db..dee7142 100644
--- a/gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp
+++ b/gdb/testsuite/gdb.trace/mi-tracepoint-changed.exp
@@ -148,7 +148,7 @@ proc test_reconnect { } {
}
}
-# Test 'breakpoint-modified' notification is emited when pending tracepoints are
+# Test 'breakpoint-modified' notification is emitted when pending tracepoints are
# resolved.
proc test_pending_resolved { } {
diff --git a/gdb/testsuite/gdb.tui/info-win.exp b/gdb/testsuite/gdb.tui/info-win.exp
index 36c7815..4d71f04 100644
--- a/gdb/testsuite/gdb.tui/info-win.exp
+++ b/gdb/testsuite/gdb.tui/info-win.exp
@@ -40,7 +40,7 @@ Term::command "layout h"
Term::command "winheight cmd + 3"
# As the tuiterm.exp library just waits for the prompt and command to
-# be echo'ed bcak to the screen, multiple 'info win' calls like this
+# be echo'ed back to the screen, multiple 'info win' calls like this
# have a problem. Dejagnu will send the command to gdb, but will then
# immediately see the '(gdb) info win' output from the first use
# above. This means we end up rushing ahead, and some tests might
diff --git a/gdb/testsuite/lib/ada.exp b/gdb/testsuite/lib/ada.exp
index 0544544..05151d3 100644
--- a/gdb/testsuite/lib/ada.exp
+++ b/gdb/testsuite/lib/ada.exp
@@ -188,6 +188,18 @@ proc gnatmake_version_at_least { major } {
return 1
}
+# Compare the GNAT version against L2 using version_compare. If the
+# compiler does not appear to be GCC, this will always return false.
+
+proc gnat_version_compare {op l2} {
+ set gccvers [gcc_major_version]
+ if {$gccvers == -1} {
+ return 0
+ }
+
+ return [version_compare [split $gccvers .] $op $l2]
+}
+
# Return 1 if the GNAT runtime appears to have debug info.
proc gnat_runtime_has_debug_info_1 { shared } {
diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index 995cdca..f9be6c4 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -2771,7 +2771,7 @@ namespace eval Dwarf {
# section_version n
# - section version number to emit
# default = 2
- # seg_size n - the size of the adress selector in bytes: 0, 4, or 8
+ # seg_size n - the size of the address selector in bytes: 0, 4, or 8
# default = 0
#
# LABEL is the label of the corresponding CU.
diff --git a/gdb/testsuite/lib/gdb-utils.exp b/gdb/testsuite/lib/gdb-utils.exp
index 41989da..33b56fb 100644
--- a/gdb/testsuite/lib/gdb-utils.exp
+++ b/gdb/testsuite/lib/gdb-utils.exp
@@ -64,7 +64,7 @@ proc string_list_to_regexp { args } {
# STYLE can either be the payload part of an ANSI terminal sequence,
# or a shorthand for one of the gdb standard styles: "file",
-# "function", "variable", or "address".
+# "function", "variable", "address", etc.
proc style {str style} {
switch -exact -- $style {
@@ -76,6 +76,7 @@ proc style {str style} {
address { set style 34 }
metadata { set style 2 }
version { set style "35;1" }
+ line-number { set style 2 }
none { return $str }
}
return "\033\\\[${style}m${str}\033\\\[m"
@@ -110,14 +111,31 @@ proc gdb_get_bp_addr { num } {
}
# Compare the version numbers in L1 to those in L2 using OP, and
-# return 1 if the comparison is true. OP can be "<", "<=", or "==".
-# It is ok if the lengths of the lists differ.
+# return 1 if the comparison is true. OP can be "<", "<=", ">", ">=",
+# or "==". It is ok if the lengths of the lists differ.
proc version_compare { l1 op l2 } {
switch -exact $op {
"==" -
"<=" -
"<" {}
+
+ ">=" {
+ # a >= b => b <= a
+ set x $l2
+ set l2 $l1
+ set l1 $x
+ set op "<="
+ }
+
+ ">" {
+ # a > b => b < a
+ set x $l2
+ set l2 $l1
+ set l1 $x
+ set op "<"
+ }
+
default { error "unsupported op: $op" }
}
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index c993f48..f0a8939 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -791,7 +791,7 @@ proc runto { linespec args } {
# the "at foo.c:36" output we get with -g.
# the "in func" output we get without -g.
gdb_expect {
- -re "(?:Break|Temporary break).* at .*:$decimal.*$gdb_prompt $" {
+ -re "(?:Break|Temporary break).* at .*:.*$decimal.*$gdb_prompt $" {
if { $print_pass } {
pass $test_name
}
@@ -1559,7 +1559,7 @@ proc gdb_test { args } {
global gdb_prompt
upvar timeout timeout
- parse_args {
+ parse_some_args {
{prompt ""}
{no-prompt-anchor}
{lbl}
@@ -1567,7 +1567,8 @@ proc gdb_test { args } {
{nonl}
}
- lassign $args command pattern message question response
+ set args [lassign $args command pattern message question response]
+ check_no_args_left
# Can't have a question without a response.
if { $question != "" && $response == "" || [llength $args] > 5 } {
@@ -1741,13 +1742,14 @@ if { [tcl_version_at_least 8 6 2] == 0 } {
proc gdb_test_no_output { args } {
global gdb_prompt
- parse_args {
+ parse_some_args {
{prompt ""}
{no-prompt-anchor}
{nopass}
}
- lassign $args command message
+ set args [lassign $args command message]
+ check_no_args_left
set prompt [fill_in_default_prompt $prompt [expr !${no-prompt-anchor}]]
@@ -1789,7 +1791,7 @@ proc gdb_test_no_output { args } {
proc gdb_test_sequence { args } {
global gdb_prompt
- parse_args {{prompt ""}}
+ parse_some_args {{prompt ""}}
if { $prompt == "" } {
set prompt "$gdb_prompt $"
@@ -1815,6 +1817,55 @@ proc gdb_test_sequence { args } {
}
+# Issue COMMAND, and return corresponding output lines. Helper function for
+# gdb_get_lines_no_pass and gdb_get_lines.
+
+proc gdb_get_lines_1 { command message } {
+ set no_pass [string equal $message ""]
+ set lines ""
+ set ok 0
+ gdb_test_multiple $command $message {
+ -re "\r\n(\[^\r\n\]*)(?=\r\n)" {
+ set line $expect_out(1,string)
+ if { $lines eq "" } {
+ append lines "$line"
+ } else {
+ append lines "\r\n$line"
+ }
+ exp_continue
+ }
+ -re -wrap "" {
+ append lines "\r\n"
+ set ok 1
+ if { ! $no_pass } {
+ pass $gdb_test_name
+ }
+ }
+ }
+
+ if { ! $ok } {
+ return ""
+ }
+
+ return $lines
+}
+
+# Issue COMMAND, and return corresponding output lines. Don't generate a pass.
+
+proc gdb_get_lines_no_pass { command } {
+ gdb_get_lines_1 $command ""
+}
+
+# Issue COMMAND, and return corresponding output lines. Generate a pass.
+
+proc gdb_get_lines { command {message ""} } {
+ if { $message == "" } {
+ set message [command_to_message $command]
+ }
+
+ gdb_get_lines_1 $command $message
+}
+
# Match output of COMMAND using RE. Read output line-by-line.
# Report pass/fail with MESSAGE.
# For a command foo with output:
@@ -1854,22 +1905,7 @@ proc gdb_test_lines { command message re args } {
set message [command_to_message $command]
}
- set lines ""
- gdb_test_multiple $command $message {
- -re "\r\n(\[^\r\n\]*)(?=\r\n)" {
- set line $expect_out(1,string)
- if { $lines eq "" } {
- append lines "$line"
- } else {
- append lines "\r\n$line"
- }
- exp_continue
- }
- -re -wrap "" {
- append lines "\r\n"
- }
- }
-
+ set lines [gdb_get_lines_no_pass $command]
gdb_assert { [regexp $re $lines] } $message
foreach re $re_not {
@@ -4436,6 +4472,62 @@ gdb_caching_proc allow_btrace_ptw_tests {} {
}
+# Run a test on the target to see if GDB supports event tracing on it.
+# Return 1 if so, 0 if it does not.
+
+gdb_caching_proc allow_btrace_pt_event_trace_tests {} {
+ global srcdir subdir
+ set me "allow_btrace_pt_event_trace_tests"
+ require allow_btrace_pt_tests
+
+ set src {
+ int
+ main ()
+ {
+ return 0;
+ }
+ }
+
+ if {![gdb_simple_compile $me $src executable]} {
+ return 0
+ }
+
+ gdb_exit
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+ gdb_load "$obj"
+ if ![runto_main] {
+ return 0
+ }
+
+ set allow_event_trace_tests 0
+ gdb_test_multiple "set record btrace pt event-tracing on" "$me: first check" {
+ -re -wrap "Event-tracing is not supported by GDB." {
+ }
+ -re -wrap "" {
+ set allow_event_trace_tests 1
+ }
+ }
+
+ if { $allow_event_trace_tests == 1 } {
+ gdb_test_multiple "record btrace pt" "$me: check OS support" {
+ -re -wrap "^" {
+ }
+ -re -wrap "" {
+ verbose -log "$me: Target doesn't support event tracing."
+ set allow_event_trace_tests 0
+ }
+ }
+ }
+
+ gdb_exit
+ remote_file build delete $obj
+
+ verbose "$me: returning $allow_event_trace_tests" 2
+ return $allow_event_trace_tests
+}
+
+
# Run a test on the target to see if it supports Aarch64 SVE hardware.
# Return 1 if so, 0 if it does not. Note this causes a restart of GDB.
@@ -9351,13 +9443,32 @@ proc parse_list { level listname argset prefix eval } {
# Search the caller's args variable and set variables according to the list of
# valid options described by ARGSET.
-proc parse_args { argset } {
+proc parse_some_args { argset } {
parse_list 2 args $argset "-" false
# The remaining args should be checked to see that they match the
# number of items expected to be passed into the procedure...
}
+# Check that the caller's args variable is empty.
+
+proc check_no_args_left {} {
+ # Require no remaining args.
+ upvar 1 args args
+ if { [llength $args] != 0 } {
+ error "Args left unparsed: $args"
+ }
+}
+
+# As parse_some_args, but check that no args remain after parsing.
+
+proc parse_args { argset } {
+ uplevel parse_some_args [list $argset]
+
+ # Require no remaining args.
+ uplevel check_no_args_left
+}
+
# Process the caller's options variable and set variables according
# to the list of valid options described by OPTIONSET.
@@ -9738,18 +9849,6 @@ gdb_caching_proc supports_statement_frontiers {} {
} executable "additional_flags=-gstatement-frontiers"]
}
-# Return 1 if compiler supports -mmpx -fcheck-pointer-bounds. Otherwise,
-# return 0.
-
-gdb_caching_proc supports_mpx_check_pointer_bounds {} {
- set flags "additional_flags=-mmpx additional_flags=-fcheck-pointer-bounds"
- return [gdb_can_simple_compile supports_mpx_check_pointer_bounds {
- int main () {
- return 0;
- }
- } executable $flags]
-}
-
# Return 1 if compiler supports -fcf-protection=. Otherwise,
# return 0.
@@ -10178,83 +10277,6 @@ gdb_caching_proc supports_gnuc {} {
return [gdb_simple_compile $me $src object ""]
}
-# Return 1 if target supports mpx, otherwise return 0.
-gdb_caching_proc have_mpx {} {
- global srcdir
-
- set me "have_mpx"
- if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } {
- verbose "$me: target does not support mpx, returning 0" 2
- return 0
- }
-
- # Compile a test program.
- set src {
- #include "nat/x86-cpuid.h"
-
- int main() {
- unsigned int eax, ebx, ecx, edx;
-
- if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
- return 0;
-
- if ((ecx & bit_OSXSAVE) == bit_OSXSAVE)
- {
- if (__get_cpuid_max (0, (void *)0) < 7)
- return 0;
-
- __cpuid_count (7, 0, eax, ebx, ecx, edx);
-
- if ((ebx & bit_MPX) == bit_MPX)
- return 1;
-
- }
- return 0;
- }
- }
- set compile_flags "incdir=${srcdir}/.."
- if {![gdb_simple_compile $me $src executable $compile_flags]} {
- return 0
- }
-
- set target_obj [gdb_remote_download target $obj]
- set result [remote_exec target $target_obj]
- set status [lindex $result 0]
- set output [lindex $result 1]
- if { $output != "" } {
- set status 0
- }
-
- remote_file build delete $obj
-
- if { $status == 0 } {
- verbose "$me: returning $status" 2
- return $status
- }
-
- # Compile program with -mmpx -fcheck-pointer-bounds, try to trigger
- # 'No MPX support', in other words, see if kernel supports mpx.
- set src { int main (void) { return 0; } }
- set comp_flags {}
- append comp_flags " additional_flags=-mmpx"
- append comp_flags " additional_flags=-fcheck-pointer-bounds"
- if {![gdb_simple_compile $me-2 $src executable $comp_flags]} {
- return 0
- }
-
- set target_obj [gdb_remote_download target $obj]
- set result [remote_exec target $target_obj]
- set status [lindex $result 0]
- set output [lindex $result 1]
- set status [expr ($status == 0) \
- && ![regexp "^No MPX support\r?\n" $output]]
-
- remote_file build delete $obj
-
- verbose "$me: returning $status" 2
- return $status
-}
-
# Return 1 if target supports avx, otherwise return 0.
gdb_caching_proc have_avx {} {
global srcdir
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index a79b133..3832137 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -2680,7 +2680,7 @@ proc mi_make_info_frame_regexp {args} {
# build the regexp for matching against the -stack-info-frame output.
proc mi_info_frame { test args } {
- parse_args {{frame ""} {thread ""}}
+ parse_some_args {{frame ""} {thread ""}}
set re [eval mi_make_info_frame_regexp $args]
diff --git a/gdb/testsuite/lib/prelink-support.exp b/gdb/testsuite/lib/prelink-support.exp
index 8be5067..894af39 100644
--- a/gdb/testsuite/lib/prelink-support.exp
+++ b/gdb/testsuite/lib/prelink-support.exp
@@ -57,7 +57,7 @@ proc symlink_resolve {file} {
} else {
set src2 $target
}
- verbose -log "Resolved symlink $file targetting $target as $src2"
+ verbose -log "Resolved symlink $file targeting $target as $src2"
set file $src2
set loop [expr $loop + 1]
diff --git a/gdb/testsuite/lib/selftest-support.exp b/gdb/testsuite/lib/selftest-support.exp
index 00d7e30..0d76e2f 100644
--- a/gdb/testsuite/lib/selftest-support.exp
+++ b/gdb/testsuite/lib/selftest-support.exp
@@ -100,7 +100,7 @@ proc selftest_setup { executable function } {
# self-test, then return an empty string.
proc selftest_prepare {} {
# Are we testing with a remote board? In that case, the target
- # won't have access to the GDB's auxilliary data files
+ # won't have access to the GDB's auxiliary data files
# (data-directory, etc.). It's simpler to just skip.
if { [is_remote target] || [is_remote host] } {
return
diff --git a/gdb/tilegx-linux-nat.c b/gdb/tilegx-linux-nat.c
index bbfeaef..440a5cc 100644
--- a/gdb/tilegx-linux-nat.c
+++ b/gdb/tilegx-linux-nat.c
@@ -57,7 +57,7 @@ static tilegx_linux_nat_target the_tilegx_linux_nat_target;
/* Mapping between the general-purpose registers in `struct user'
format and GDB's register array layout. Note that we map the
- first 56 registers (0 thru 55) one-to-one. GDB maps the pc to
+ first 56 registers (0 through 55) one-to-one. GDB maps the pc to
slot 64, but ptrace returns it in slot 56. */
static const int regmap[] =
{
diff --git a/gdb/top.c b/gdb/top.c
index d6bf1d4..d34e733 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -632,19 +632,9 @@ execute_fn_to_string (std::string &res, std::function<void(void)> fn,
{
string_file str_file (term_out);
- try
- {
- execute_fn_to_ui_file (&str_file, fn);
- }
- catch (...)
- {
- /* Finally. */
- res = str_file.release ();
- throw;
- }
+ SCOPE_EXIT { res = str_file.release (); };
- /* And finally. */
- res = str_file.release ();
+ execute_fn_to_ui_file (&str_file, fn);
}
/* See top.h. */
@@ -1389,6 +1379,11 @@ This GDB was configured as follows:\n\
configure --host=%s --target=%s\n\
"), host_name, target_name);
+#ifdef ENABLE_TARGETS
+ gdb_printf (stream, _("\
+ --enable-targets=%s\n"), ENABLE_TARGETS);
+#endif
+
gdb_printf (stream, _("\
--with-auto-load-dir=%s\n\
--with-auto-load-safe-path=%s\n\
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index a5a2e69..ca6f616 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -671,7 +671,7 @@ validate_actionline (const char *line, tracepoint *t)
p = strchr (p, ',');
continue;
}
- /* else fall thru, treat p as an expression and parse it! */
+ /* else fall through, treat p as an expression and parse it! */
}
tmp_p = p;
for (bp_location &loc : t->locations ())
@@ -2110,7 +2110,7 @@ tfind_1 (enum trace_find_type type, int num,
if you're in a user-defined command or especially in a
loop, then you need a way to detect that the command
failed WITHOUT aborting. This allows you to write
- scripts that search thru the trace buffer until the end,
+ scripts that search through the trace buffer until the end,
and then continue on to do something else. */
if (from_tty)
@@ -2351,8 +2351,9 @@ tfind_line_command (const char *args, int from_tty)
{
if (start_pc == end_pc)
{
- gdb_printf ("Line %d of \"%s\"",
- sal.line,
+ gdb_printf ("Line %ps of \"%s\"",
+ styled_string (line_number_style.style (),
+ pulongest (sal.line)),
symtab_to_filename_for_display (sal.symtab));
gdb_stdout->wrap_here (2);
gdb_printf (" is at address ");
@@ -2363,8 +2364,9 @@ tfind_line_command (const char *args, int from_tty)
if (sal.line > 0
&& find_line_pc_range (sal, &start_pc, &end_pc)
&& start_pc != end_pc)
- gdb_printf ("Attempting to find line %d instead.\n",
- sal.line);
+ gdb_printf ("Attempting to find line %ps instead.\n",
+ styled_string (line_number_style.style (),
+ pulongest (sal.line)));
else
error (_("Cannot find a good line."));
}
@@ -3644,7 +3646,7 @@ print_one_static_tracepoint_marker (int count,
else
uiout->field_skip ("fullname");
- uiout->field_signed ("line", sal.line);
+ uiout->field_signed ("line", sal.line, line_number_style.style ());
}
else
{
diff --git a/gdb/tui/tui-source.c b/gdb/tui/tui-source.c
index ee64e41..503fb00 100644
--- a/gdb/tui/tui-source.c
+++ b/gdb/tui/tui-source.c
@@ -32,6 +32,20 @@
#include "tui/tui-winsource.h"
#include "tui/tui-source.h"
#include "tui/tui-location.h"
+#include "tui/tui-io.h"
+#include "cli/cli-style.h"
+
+tui_source_window::tui_source_window ()
+{
+ line_number_style.changed.attach
+ (std::bind (&tui_source_window::style_changed, this),
+ m_src_observable, "tui-source");
+}
+
+tui_source_window::~tui_source_window ()
+{
+ line_number_style.changed.detach (m_src_observable);
+}
/* Function to display source in the source window. */
bool
@@ -247,5 +261,7 @@ tui_source_window::show_line_number (int offset) const
tui_left_margin_verbose ? "%0*d%c" : "%*d%c", m_digits - 1,
lineno, space);
}
+ tui_apply_style (handle.get (), line_number_style.style ());
display_string (text);
+ tui_apply_style (handle.get (), ui_file_style ());
}
diff --git a/gdb/tui/tui-source.h b/gdb/tui/tui-source.h
index f32167f..d8f7189 100644
--- a/gdb/tui/tui-source.h
+++ b/gdb/tui/tui-source.h
@@ -30,7 +30,8 @@
struct tui_source_window : public tui_source_window_base
{
- tui_source_window () = default;
+ tui_source_window ();
+ ~tui_source_window ();
DISABLE_COPY_AND_ASSIGN (tui_source_window);
@@ -81,6 +82,9 @@ private:
/* It is the resolved form as returned by symtab_to_fullname. */
gdb::unique_xmalloc_ptr<char> m_fullname;
+
+ /* A token used to register and unregister an observer. */
+ gdb::observers::token m_src_observable;
};
/* Return the instance of the source window. */
diff --git a/gdb/tui/tui-winsource.h b/gdb/tui/tui-winsource.h
index 29828c1..a262c63 100644
--- a/gdb/tui/tui-winsource.h
+++ b/gdb/tui/tui-winsource.h
@@ -189,6 +189,11 @@ public:
update_source_windows_with_addr. */
void update_source_window_with_addr (struct gdbarch *, CORE_ADDR);
+protected:
+
+ /* Called when a user style setting is changed. */
+ void style_changed ();
+
private:
/* Used for horizontal scroll. */
@@ -236,9 +241,6 @@ private:
the initial escape that sets the color will still be applied. */
void puts_to_pad_with_skip (const char *string, int skip);
- /* Called when the user "set style enabled" setting is changed. */
- void style_changed ();
-
/* A token used to register and unregister an observer. */
gdb::observers::token m_observable;
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index 2e1c5ea..274f602 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -513,7 +513,7 @@ whatis_exp (const char *exp, int show)
val = expr->evaluate_type ();
type = val->type ();
- if (show == -1 && expr->first_opcode () == OP_TYPE)
+ if (show == -1 && expr->type_p ())
{
/* The user expression names a type directly. */
diff --git a/gdb/ui-out.c b/gdb/ui-out.c
index 7e9f238..3330cc8 100644
--- a/gdb/ui-out.c
+++ b/gdb/ui-out.c
@@ -433,7 +433,8 @@ ui_out::end (ui_out_type type)
}
void
-ui_out::field_signed (const char *fldname, LONGEST value)
+ui_out::field_signed (const char *fldname, LONGEST value,
+ const ui_file_style &style)
{
int fldno;
int width;
@@ -441,7 +442,7 @@ ui_out::field_signed (const char *fldname, LONGEST value)
verify_field (&fldno, &width, &align);
- do_field_signed (fldno, width, align, fldname, value);
+ do_field_signed (fldno, width, align, fldname, value, style);
}
void
@@ -454,7 +455,8 @@ ui_out::field_fmt_signed (int input_width, ui_align input_align,
verify_field (&fldno, &width, &align);
- do_field_signed (fldno, input_width, input_align, fldname, value);
+ do_field_signed (fldno, input_width, input_align, fldname, value,
+ ui_file_style ());
}
/* See ui-out.h. */
diff --git a/gdb/ui-out.h b/gdb/ui-out.h
index ef9ce4f..f9d96de 100644
--- a/gdb/ui-out.h
+++ b/gdb/ui-out.h
@@ -182,7 +182,8 @@ class ui_out
void begin (ui_out_type type, const char *id);
void end (ui_out_type type);
- void field_signed (const char *fldname, LONGEST value);
+ void field_signed (const char *fldname, LONGEST value,
+ const ui_file_style &style = ui_file_style ());
void field_fmt_signed (int width, ui_align align, const char *fldname,
LONGEST value);
/* Like field_signed, but print an unsigned value. */
@@ -346,7 +347,8 @@ protected:
virtual void do_begin (ui_out_type type, const char *id) = 0;
virtual void do_end (ui_out_type type) = 0;
virtual void do_field_signed (int fldno, int width, ui_align align,
- const char *fldname, LONGEST value) = 0;
+ const char *fldname, LONGEST value,
+ const ui_file_style &style) = 0;
virtual void do_field_unsigned (int fldno, int width, ui_align align,
const char *fldname, ULONGEST value) = 0;
virtual void do_field_skip (int fldno, int width, ui_align align,
diff --git a/gdb/ui.c b/gdb/ui.c
index e5c7965..88a3a14 100644
--- a/gdb/ui.c
+++ b/gdb/ui.c
@@ -106,7 +106,7 @@ ui::input_interactive_p () const
/* When there is an event ready on the stdin file descriptor, instead
- of calling readline directly throught the callback function, or
+ of calling readline directly through the callback function, or
instead of calling gdb_readline_no_editing_callback, give gdb a
chance to detect errors and do something. */
diff --git a/gdb/user-regs.c b/gdb/user-regs.c
index ac04f63..2ace46e 100644
--- a/gdb/user-regs.c
+++ b/gdb/user-regs.c
@@ -222,9 +222,19 @@ maintenance_print_user_registers (const char *args, int from_tty)
struct gdb_user_regs *regs = get_user_regs (gdbarch);
regnum = gdbarch_num_cooked_regs (gdbarch);
- gdb_printf (" %-11s %3s\n", "Name", "Nr");
+ ui_out_emit_table emitter (current_uiout, 2, -1, "UserRegs");
+
+ current_uiout->table_header (11, ui_left, "name", "Name");
+ current_uiout->table_header (3, ui_left, "regnum", "Nr");
+ current_uiout->table_body ();
+
for (reg = regs->first; reg != NULL; reg = reg->next, ++regnum)
- gdb_printf (" %-11s %3d\n", reg->name, regnum);
+ {
+ ui_out_emit_tuple tuple_emitter (current_uiout, nullptr);
+ current_uiout->field_string ("name", reg->name);
+ current_uiout->field_signed ("regnum", regnum);
+ current_uiout->text ("\n");
+ }
}
void _initialize_user_regs ();
diff --git a/gdb/utils.c b/gdb/utils.c
index 07c5d3c..a1bf9e4 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -819,7 +819,9 @@ defaulted_query (const char *ctlstr, const char defchar, va_list args)
}
/* Format the question outside of the loop, to avoid reusing args. */
- std::string question = string_vprintf (ctlstr, args);
+ string_file tem (gdb_stdout->can_emit_style_escape ());
+ gdb_vprintf (&tem, ctlstr, args);
+ std::string question = tem.release ();
std::string prompt
= string_printf (_("%s%s(%s or %s) %s"),
annotation_level > 1 ? "\n\032\032pre-query\n" : "",
@@ -1282,6 +1284,14 @@ set_screen_width_and_height (int width, int height)
set_width ();
}
+/* Import termcap variable UP (instead of readline private variable
+ _rl_term_up, which we're trying to avoid, see PR build/10723). The UP
+ variable doesn't seem be part of the regular termcap interface, but rather
+ curses-specific. But if it's missing in the termcap library, then readline
+ provides a fallback version. Let's assume the fallback is not part of the
+ private readline interface. */
+extern "C" char *UP;
+
/* Implement "maint info screen". */
static void
@@ -1340,6 +1350,46 @@ maintenance_info_screen (const char *args, int from_tty)
_("Number of lines environment thinks "
"are in a page is %s (LINES).\n"),
getenv ("LINES"));
+
+ bool have_up = UP != nullptr && *UP != '\0';
+
+ /* Fetch value of readline variable horizontal-scroll-mode. */
+ const char *horizontal_scroll_mode_value
+ = rl_variable_value ("horizontal-scroll-mode");
+ bool force_horizontal_scroll_mode
+ = (horizontal_scroll_mode_value != nullptr
+ && strcmp (horizontal_scroll_mode_value, "on") == 0);
+
+ const char *mode = nullptr;
+ const char *reason = nullptr;
+ if (batch_flag)
+ {
+ mode = "unsupported";
+ reason = "gdb batch mode";
+ }
+ else if (!have_up)
+ {
+ mode = "unsupported";
+ reason = "terminal is not Cursor Up capable";
+ }
+ else if (force_horizontal_scroll_mode)
+ {
+ mode = "disabled";
+ reason = "horizontal-scroll-mode";
+ }
+ else if (readline_hidden_cols)
+ {
+ mode = "readline";
+ reason = "terminal is not auto wrap capable, last column reserved";
+ }
+ else
+ {
+ mode = "terminal";
+ reason = "terminal is auto wrap capable";
+ }
+
+ gdb_printf (gdb_stdout, _("Readline wrapping mode: %s (%s).\n"), mode,
+ reason);
}
void
diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c
index 531fdb4..de1cc6c 100644
--- a/gdb/v850-tdep.c
+++ b/gdb/v850-tdep.c
@@ -201,7 +201,7 @@ enum
E_R149_REGNUM,
E_NUM_OF_V850E2_REGS,
- /* v850e3v5 system registers, selID 1 thru 7. */
+ /* v850e3v5 system registers, selID 1 through 7. */
E_SELID_1_R0_REGNUM = E_NUM_OF_V850E2_REGS,
E_SELID_1_R31_REGNUM = E_SELID_1_R0_REGNUM + 31,
@@ -1047,7 +1047,7 @@ v850_push_dummy_call (struct gdbarch *gdbarch,
/* Now load as many as possible of the first arguments into
registers, and push the rest onto the stack. There are 16 bytes
- in four registers available. Loop thru args from first to last. */
+ in four registers available. Loop through args from first to last. */
for (argnum = 0; argnum < nargs; argnum++)
{
int len;
diff --git a/gdb/valops.c b/gdb/valops.c
index 427fbb1..88a42d3 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -40,7 +40,6 @@
#include "observable.h"
#include "objfiles.h"
#include "extension.h"
-#include "gdbtypes.h"
#include "gdbsupport/byte-vector.h"
#include "typeprint.h"
@@ -1487,7 +1486,7 @@ value_coerce_to_target (struct value *val)
nonzero lower bound.
FIXME: A previous comment here indicated that this routine should
- be substracting the array's lower bound. It's not clear to me that
+ be subtracting the array's lower bound. It's not clear to me that
this is correct. Given an array subscripting operation, it would
certainly work to do the adjustment here, essentially computing:
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 0cd0bd0..04f1fc8 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -323,10 +323,7 @@ varobj_create (const char *objname,
}
/* Don't allow variables to be created for types. */
- enum exp_opcode opcode = var->root->exp->first_opcode ();
- if (opcode == OP_TYPE
- || opcode == OP_TYPEOF
- || opcode == OP_DECLTYPE)
+ if (var->root->exp->type_p ())
{
gdb_printf (gdb_stderr, "Attempt to use a type name"
" as an expression.\n");