commit gdb for openSUSE:Factory
Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package gdb for openSUSE:Factory checked in at 2021-11-01 18:35:39 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/gdb (Old) and /work/SRC/openSUSE:Factory/.gdb.new.1890 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "gdb" Mon Nov 1 18:35:39 2021 rev:155 rq:928248 version:11.1 Changes: -------- --- /work/SRC/openSUSE:Factory/gdb/gdb.changes 2021-07-22 22:43:11.119213499 +0200 +++ /work/SRC/openSUSE:Factory/.gdb.new.1890/gdb.changes 2021-11-01 18:35:48.813339252 +0100 @@ -1,0 +2,297 @@ +Thu Oct 28 13:40:28 UTC 2021 - Tom de Vries <tdevries@suse.com> + +- Mention removed fedora patches: + * gdb-6.3-test-self-20050110.patch + * gdb-bz1219747-attach-kills.patch + * gdb-6.6-buildid-locate-core-as-arg.patch + * gdb-attach-fail-reasons-5of5.patch + * gdb-archer-pie-addons.patch + * gdb-jit-reader-multilib.patch + * gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch + * gdb-archer.patch + * gdb-config.patch + * gdb-6.8-quit-never-aborts.patch +- Mention removed patches: + * gdb-breakpoint-fix-assert-in-jit_event_handler.patch + * gdb-fix-section-matching-in-find_pc_sect_compunit.patch + * gdb-fortran-fix-print-dynamic-array.patch + * gdb-build-hardcode-with-included-regex.patch + * gdb-handle-no-upper-bound-in-value-subscript.patch + * gdb-fix-internal-error-in-process_event_stop_test.patch + * gdb-don-t-return-non-existing-path-in-debuginfod-source-query.patch + * gdb-archer-pie-addons-keep-disabled.patch + * gdb-fix-filename-in-not-in-executable-format-error.patch + * gdb-fix-use-of-invalid-pointer-in-remote-async-inferior-event-handler.patch + * gdb-breakpoints-handle-glibc-with-debuginfo-in-create_exception_master_breakpoint.patch +- Maintenance scripts: + * Add KFAILs in qa.sh. + * Add missing '-a' in gdb.log greps in qa.sh. + * Fix error handling in qa.sh. +- Patches added: + * gdb-testsuite-handle-sigill-in-two-gdb.arch-powerpc-test-cases.patch + * gdb-testsuite-work-around-skip_prologue-problems-in-gdb.threads-process-dies-while-detaching.exp.patch + +------------------------------------------------------------------- +Fri Oct 22 07:03:55 UTC 2021 - Tom de Vries <tdevries@suse.com> + +- Disable big endian powerpc. +- Maintenance scripts: + * Fix patch filtering in clean.sh. + * Add KFAIL in qa.sh. +- Patches added: + * gdb-testsuite-add-checks-to-gdb.arch-i386-sse.exp.patch + * gdb-testsuite-add-gdb.testsuite-dump-system-info.exp.patch + * gdb-testsuite-add-kfail-in-gdb.threads-fork-plus-threads.exp.patch + * gdb-testsuite-factor-out-dump_info-in-gdb.testsuite-dump-system-info.exp.patch + * gdb-testsuite-fix-fail-in-gdb.threads-fork-and-threads.exp.patch + * gdb-testsuite-fix-gdb.threads-linux-dp.exp.patch + * gdb-testsuite-fix-port-detection-in-gdb.debuginfod-fetch_src_and_symbols.exp.patch + * gdb-testsuite-handle-recursive-internal-problem-in-gdb_internal_error_resync.patch + * gdb-testsuite-handle-runto-fail-in-gdb.mi-mi-var-cp.exp.patch + * gdb-tui-fix-breakpoint-display-functionality.patch + * gdb-testsuite-Fix-gdb.threads-thread-specific-bp.exp.patch +- Patches dropped: + * fix-gdb.threads-linux-dp.exp.patch + +------------------------------------------------------------------- +Wed Oct 20 15:48:40 UTC 2021 - Tom de Vries <tdevries@suse.com> + +- Added maintenance script: + * qa.sh +- Drop 32bit packages for s390x. + +------------------------------------------------------------------- +Tue Oct 19 08:00:06 UTC 2021 - Tom de Vries <tdevries@suse.com> + +- Fix SLE-15 s390x: unresolvable, nothing provides + glibc-devel-static-32bit. +- Disable test-case gdb.base/break-interp.exp for SLE-11. + It causes a + "glibc detected *** expect: double free or corruption (out)" in + expect and a subsequent runtest abort. This might be the cause + of the package build failure due to + "Job seems to be stuck here, killed. (after 8hrs of inactivity)" +- Patches added: + * gdb-testsuite-fix-gdb.base-step-over-syscall.exp-with-m32-amd-case.patch + * gdb-testsuite-fix-gdb.ada-big_packed_array.exp-xfail-for-m32.patch + * gdb-testsuite-fix-race-in-gdb.threads-detach-step-over.exp.patch + * fix-gdb.multi-multi-term-settings.exp-race.patch + * gdb-testsuite-update-test-gdb.base-step-over-syscall.exp.patch + +------------------------------------------------------------------- +Mon Oct 18 17:46:06 UTC 2021 - Tom de Vries <tdevries@suse.com> - 11.1 + +- Rebase to 11.1 release (as in fedora 35 @ 9cd9368): + * GDB now supports general memory tagging functionality if the + underlying architecture supports the proper primitives and hooks. + Currently this is enabled only for AArch64 MTE. + * GDB will now look for the .gdbinit file in a config directory + before looking for ~/.gdbinit. The file is searched for in + the following locations: $XDG_CONFIG_HOME/gdb/gdbinit, + $HOME/.config/gdb/gdbinit, $HOME/.gdbinit. + * GDB will now load and process commands from + ~/.config/gdb/gdbearlyinit or ~/.gdbearlyinit if these files + are present. These files are processed earlier than any of + the other initialization files and can affect parts of GDB's + startup that previously had already been completed before the + initialization files were read, for example styling of the + initial GDB greeting. + * GDB now has two new options "--early-init-command" and + "--early-init-eval-command" with corresponding short options + "-eix" and "-eiex" that allow options (that would normally + appear in a gdbearlyinit file) to be passed on the command + line. + * set startup-quietly on|off + show startup-quietly + When 'on', this causes GDB to act as if "-silent" were passed + on the command line. This command needs to be added to an + early initialization file (e.g. ~/.config/gdb/gdbearlyinit) + in order to affect GDB. + * For RISC-V targets, the target feature + "org.gnu.gdb.riscv.vector" is now understood by GDB, and can + be used to describe the vector registers of a target. + * TUI windows now support mouse actions. The mouse wheel + scrolls the appropriate window. + * Key combinations that do not have a specific action on the + focused window are passed to GDB. For example, you now can + use Ctrl-Left/Ctrl-Right to move between words in the command + window regardless of which window is in focus. Previously + you would need to focus on the command window for such key + combinations to work. + * set python ignore-environment on|off + show python ignore-environment + When 'on', this causes GDB's builtin Python to ignore any + environment variables that would otherwise affect how Python + behaves. This command needs to be added to an early + initialization file (e.g. ~/.config/gdb/gdbearlyinit) in + order to affect GDB. + * set python dont-write-bytecode auto|on|off + show python dont-write-bytecode + When 'on', this causes GDB's builtin Python to not write any + byte-code (.pyc files) to disk. This command needs to be + added to an early initialization file + (e.g. ~/.config/gdb/gdbearlyinit) in order to affect GDB. + When 'off' byte-code will always be written. + When set to 'auto' (the default) Python will check the + PYTHONDONTWRITEBYTECODE environment variable. + * break [PROBE_MODIFIER] [LOCATION] [thread THREADNUM] + [-force-condition] [if CONDITION] + This command would previously refuse setting a breakpoint if + the CONDITION expression is invalid at a location. It now + accepts and defines the breakpoint if there is at least one + location at which the CONDITION is valid. The locations + for which the CONDITION is invalid, are automatically + disabled. If CONDITION is invalid at all of the locations, + setting the breakpoint is still rejected. However, the + '-force-condition' flag can be used in this case for forcing + GDB to define the breakpoint, making all the current + locations automatically disabled. This may be useful if the + user knows the condition will become meaningful at a future + location, e.g. due to a shared library load. +- Update libipt to v2.0.4. Dropped obsoleted patch: + * v1.5-libipt-static.patch +- Obsoleted fedora patches dropped: + * gdb-moribund-utrace-workaround.patch + * gdb-save-restore-file-offset-while-reading-notes-in-core-file.patch + * gdb-vla-intel-fix-print-char-array.patch + * gdb-vla-intel-fortran-strides.patch + * gdb-vla-intel-fortran-vla-strings.patch + * gdb-vla-intel-stringbt-fix.patch + * gdb-vla-intel-tests.patch +- Obsoleted fedora fixup patches dropped: + * fixup-2-gdb-archer-vla-tests.patch + * fixup-2-gdb-rhbz1156192-recursive-dlopen-test.patch + * fixup-3-gdb-archer-vla-tests.patch + * fixup-gdb-6.3-test-pie-20050107.patch + * fixup-gdb-6.3-threaded-watchpoints2-20050225.patch + * fixup-gdb-6.5-sharedlibrary-path.patch + * fixup-gdb-6.8-bz442765-threaded-exec-test.patch + * fixup-gdb-archer-vla-tests.patch + * fixup-gdb-base-gnu-ifunc-strstr-workaround-exp.patch + * fixup-gdb-btrobust.patch + * fixup-gdb-bz634108-solib_address.patch + * fixup-gdb-dts-rhel6-python-compat.patch + * fixup-gdb-gnat-dwarf-crash-3of3.patch + * fixup-gdb-rhbz1156192-recursive-dlopen-test.patch + * fixup-gdb-test-ivy-bridge.patch + * fixup-gdb-vla-intel-fortran-vla-strings.patch + * fixup-gdb-vla-intel-tests.patch +- Obsoleted patches dropped: + * amd64-linux-siginfo-include-order.patch + * gdb-powerpc-remove-512-bytes-region-limit-if-2nd-dawr-is-avaliable.patch + * gdb-support-dw-lle-start-end.patch + * gdb-symtab-fix-infinite-recursion-in-dwarf2_cu-get_builder-again.patch + * gdb-symtab-fix-language-of-frame-without-debug-info.patch + * gdb-symtab-read-cu-base-address-for-enqueued-cu.patch + * gdb-symtab-use-early-continue-in-find_pc_sect_compunit.patch + * gdb-testsuite-catch-condition-evaluation-errors-in-gdb-assert.patch + * gdb-testsuite-detect-gdb-prompt-after-monitor-exit.patch + * gdb-testsuite-disable-selftests-for-factory.patch + * gdb-testsuite-fix-control-flow-in-gdb-reverse-insn-reverse-exp.patch + * gdb-testsuite-fix-failure-in-gdb-base-step-over-no-symbols-exp.patch + * gdb-testsuite-fix-gdb-dlang-watch-loc-exp-on-ppc64.patch + * gdb-testsuite-fix-gdb-reverse-insn-reverse-x86-c-for-m32.patch + * gdb-testsuite-fix-gdb.arch-amd64-stap-three-arg-disp.s.patch + * gdb-testsuite-fix-unset-of-debuginfod_urls-in-default_gdb_init.patch + * gdb-testsuite-fix-xfail-handling-in-gdb.threads-gcore-thread.exp.patch + * gdb-testsuite-gdb-base-morestack-exp-no-clang.patch ++++ 100 more lines (skipped) ++++ between /work/SRC/openSUSE:Factory/gdb/gdb.changes ++++ and /work/SRC/openSUSE:Factory/.gdb.new.1890/gdb.changes Old: ---- amd64-linux-siginfo-include-order.patch fixup-2-gdb-archer-vla-tests.patch fixup-2-gdb-rhbz1156192-recursive-dlopen-test.patch fixup-3-gdb-archer-vla-tests.patch fixup-gdb-6.3-test-pie-20050107.patch fixup-gdb-6.3-threaded-watchpoints2-20050225.patch fixup-gdb-6.5-sharedlibrary-path.patch fixup-gdb-6.8-bz442765-threaded-exec-test.patch fixup-gdb-archer-vla-tests.patch fixup-gdb-base-gnu-ifunc-strstr-workaround-exp.patch fixup-gdb-btrobust.patch fixup-gdb-bz634108-solib_address.patch fixup-gdb-dts-rhel6-python-compat.patch fixup-gdb-gnat-dwarf-crash-3of3.patch fixup-gdb-rhbz1156192-recursive-dlopen-test.patch fixup-gdb-test-ivy-bridge.patch fixup-gdb-vla-intel-fortran-vla-strings.patch fixup-gdb-vla-intel-tests.patch gdb-10.1.tar.bz2 gdb-6.3-test-pie-20050107.patch gdb-6.3-test-self-20050110.patch gdb-6.5-bz218379-solib-trampoline-lookup-lock-fix.patch gdb-6.6-buildid-locate-core-as-arg.patch gdb-6.8-quit-never-aborts.patch gdb-archer-pie-addons-keep-disabled.patch gdb-archer-pie-addons.patch gdb-archer-vla-tests.patch gdb-archer.patch gdb-attach-fail-reasons-5of5.patch gdb-breakpoint-fix-assert-in-jit_event_handler.patch gdb-breakpoints-handle-glibc-with-debuginfo-in-create_exception_master_breakpoint.patch gdb-btrobust.patch gdb-build-hardcode-with-included-regex.patch gdb-bz1219747-attach-kills.patch gdb-config.patch gdb-don-t-return-non-existing-path-in-debuginfod-source-query.patch gdb-dts-rhel6-python-compat.patch gdb-fix-filename-in-not-in-executable-format-error.patch gdb-fix-internal-error-in-process_event_stop_test.patch gdb-fix-section-matching-in-find_pc_sect_compunit.patch gdb-fix-use-of-invalid-pointer-in-remote-async-inferior-event-handler.patch gdb-fortran-fix-print-dynamic-array.patch gdb-gnat-dwarf-crash-3of3.patch gdb-handle-no-upper-bound-in-value-subscript.patch gdb-jit-reader-multilib.patch gdb-moribund-utrace-workaround.patch gdb-powerpc-remove-512-bytes-region-limit-if-2nd-dawr-is-avaliable.patch gdb-save-restore-file-offset-while-reading-notes-in-core-file.patch gdb-support-dw-lle-start-end.patch gdb-symtab-fix-infinite-recursion-in-dwarf2_cu-get_builder-again.patch gdb-symtab-fix-language-of-frame-without-debug-info.patch gdb-symtab-read-cu-base-address-for-enqueued-cu.patch gdb-symtab-use-early-continue-in-find_pc_sect_compunit.patch gdb-testsuite-catch-condition-evaluation-errors-in-gdb-assert.patch gdb-testsuite-detect-gdb-prompt-after-monitor-exit.patch gdb-testsuite-disable-selftests-for-factory.patch gdb-testsuite-fix-control-flow-in-gdb-reverse-insn-reverse-exp.patch gdb-testsuite-fix-failure-in-gdb-base-step-over-no-symbols-exp.patch gdb-testsuite-fix-gdb-dlang-watch-loc-exp-on-ppc64.patch gdb-testsuite-fix-gdb-reverse-insn-reverse-x86-c-for-m32.patch gdb-testsuite-fix-gdb.arch-amd64-stap-three-arg-disp.s.patch gdb-testsuite-fix-unset-of-debuginfod_urls-in-default_gdb_init.patch gdb-testsuite-fix-xfail-handling-in-gdb.threads-gcore-thread.exp.patch gdb-testsuite-gdb-base-morestack-exp-no-clang.patch gdb-testsuite-gdb-tui-new-layout-exp-partly-require-tcl86.patch gdb-testsuite-handle-sigill-in-gdb-reverse-insn-reverse-exp.patch gdb-testsuite-ignore-debuginfod_urls.patch gdb-testsuite-prevent-pagination-in-gdb-internalflags.patch gdb-threads-fix-lin_thread_get_thread_signals-for-glibc-2.28.patch gdb-try-to-load-libthread_db-only-after-reading-all-shared-libraries-when-attaching.patch gdb-tui-fix-len_without_escapes-in-tui-disasm.c.patch gdb-vla-intel-fix-print-char-array.patch gdb-vla-intel-fortran-strides.patch gdb-vla-intel-fortran-vla-strings.patch gdb-vla-intel-stringbt-fix.patch gdb-vla-intel-tests.patch v1.5-libipt-static.patch v2.0.2.tar.gz New: ---- clean.sh fix-gdb.mi-new-ui-mi-sync.exp.patch fix-gdb.multi-multi-term-settings.exp-race.patch fixup-2-gdb-6.6-buildid-locate.patch fixup-gdb-glibc-strstr-workaround.patch fixup-gdb-linux_perf-bundle.patch fixup-gdb-rhbz1325795-framefilters-test.patch fixup-gdb-rhbz1553104-s390x-arch12-test.patch gdb-11.1.tar.bz2 gdb-6.3-attach-see-vdso-test.patch gdb-6.3-inferior-notification-20050721.patch gdb-6.5-gcore-buffer-limit-test.patch gdb-6.5-missed-trap-on-step-test.patch gdb-add-index.sh-fix-bashism.patch gdb-build-add-cxx_dialect-to-cxx.patch gdb-build-make-c-exp.y-work-with-bison-3.8.patch gdb-python-finishbreakpoint-update.patch gdb-rhbz1976887-field-location-kind.patch gdb-rhbz2012976-paper-over-fortran-lex-problems.patch gdb-symtab-add-call_site_eq-and-call_site_hash.patch gdb-symtab-c-ify-call_site.patch gdb-symtab-fix-htab_find_slot-call-in-read_call_site_scope.patch gdb-symtab-remove-compunit_call_site_htab.patch gdb-symtab-use-unrelocated-addresses-in-call_site.patch gdb-test-for-rhbz1976887.patch gdb-testsuite-Fix-gdb.threads-thread-specific-bp.exp.patch gdb-testsuite-add-checks-to-gdb.arch-i386-sse.exp.patch gdb-testsuite-add-gdb.testsuite-dump-system-info.exp.patch gdb-testsuite-add-kfail-in-gdb.threads-fork-plus-threads.exp.patch gdb-testsuite-add-nopie-in-two-test-cases.patch gdb-testsuite-factor-out-dump_info-in-gdb.testsuite-dump-system-info.exp.patch gdb-testsuite-fix-fail-in-gdb.base-annota1.exp.patch gdb-testsuite-fix-fail-in-gdb.threads-fork-and-threads.exp.patch gdb-testsuite-fix-fail-in-gdb.tui-corefile-run.exp.patch gdb-testsuite-fix-gdb.ada-big_packed_array.exp-xfail-for-m32.patch gdb-testsuite-fix-gdb.base-dcache-flush.exp.patch gdb-testsuite-fix-gdb.base-step-over-syscall.exp-with-m32-amd-case.patch gdb-testsuite-fix-gdb.gdb-selftest.exp.patch gdb-testsuite-fix-gdb.python-py-events.exp.patch gdb-testsuite-fix-gdb.server-server-kill.exp-with-m32.patch gdb-testsuite-fix-gdb.threads-check-libthread-db.exp-with-glibc-2.34.patch gdb-testsuite-fix-gdb.threads-linux-dp.exp.patch gdb-testsuite-fix-port-detection-in-gdb.debuginfod-fetch_src_and_symbols.exp.patch gdb-testsuite-fix-race-in-gdb.threads-detach-step-over.exp.patch gdb-testsuite-handle-recursive-internal-problem-in-gdb_internal_error_resync.patch gdb-testsuite-handle-runto-fail-in-gdb.mi-mi-var-cp.exp.patch gdb-testsuite-handle-sigill-in-two-gdb.arch-powerpc-test-cases.patch gdb-testsuite-handle-supports_memtag-in-gdb.base-gdb-caching-proc.exp.patch gdb-testsuite-prevent-compilation-fails-with-unix-fpie-pie.patch gdb-testsuite-refactor-regexp-in-gdb.base-annota1.exp.patch gdb-testsuite-support-fpie-fno-pie-pie-no-pie-in-gdb_compile_rust.patch gdb-testsuite-update-test-gdb.base-step-over-syscall.exp.patch gdb-testsuite-use-compiler-generated-instead-of-gas-generated-stabs.patch gdb-testsuite-work-around-skip_prologue-problems-in-gdb.threads-process-dies-while-detaching.exp.patch gdb-tui-fix-breakpoint-display-functionality.patch import-patches.sh qa.sh v2.0.4.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ gdb.spec ++++++ ++++ 672 lines (skipped) ++++ between /work/SRC/openSUSE:Factory/gdb/gdb.spec ++++ and /work/SRC/openSUSE:Factory/.gdb.new.1890/gdb.spec ++++++ clean.sh ++++++ #!/bin/sh dryrun=false while [ $# -gt 0 ]; do case $1 in -dryrun|--dryrun|-dry-run|--dry-run) dryrun=true ;; *) echo "Don't know how to handle arg: $1" exit 1 esac shift done first=true for f in *.patch; do if grep -q "^Patch.*[ \t]$f" gdb.spec; then continue fi if $dryrun; then if $first; then echo "Patches not mentioned in gdb.spec:" fi first=false echo "$f" continue fi ( set -x; osc remove -f "$f" ) done files=$(echo ./*~) if [ "$files" != "./*~" ]; then if $dryrun; then echo "Backup files:" echo "$files" else for f in $files; do ( set -x; rm -f "$f" ) done fi fi ++++++ fix-gdb.mi-new-ui-mi-sync.exp.patch ++++++ Fix gdb.mi/new-ui-mi-sync.exp --- gdb/testsuite/gdb.mi/new-ui-mi-sync.exp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.mi/new-ui-mi-sync.exp b/gdb/testsuite/gdb.mi/new-ui-mi-sync.exp index 887bd60abcd..18072d4e668 100644 --- a/gdb/testsuite/gdb.mi/new-ui-mi-sync.exp +++ b/gdb/testsuite/gdb.mi/new-ui-mi-sync.exp @@ -83,7 +83,11 @@ proc do_test {sync_command} { # in the separate MI UI. Note the "run" variant usually triggers # =thread-group-started/=thread-created/=library-loaded as well. with_spawn_id $gdb_main_spawn_id { - gdb_test "add-inferior" "Added inferior 2 on connection .*" + gdb_test_multiple "add-inferior" "" { + -re "\r\nAdded inferior 2 on connection .*\[\r\n\]+$gdb_prompt " { + pass $gdb_test_name + } + } } # Interrupt the program. ++++++ fix-gdb.multi-multi-term-settings.exp-race.patch ++++++ Fix gdb.multi/multi-term-settings.exp race The gdb.multi/multi-term-settings.exp testcase sometimes fails like so: Running /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.multi/multi-term-settings.exp ... FAIL: gdb.multi/multi-term-settings.exp: inf1_how=attach: inf2_how=attach: stop with control-c (SIGINT) It's easier to reproduce if you stress the machine at the same time, like e.g.: $ stress -c 24 Looking at gdb.log, we see: (gdb) attach 60422 Attaching to program: build/gdb/testsuite/outputs/gdb.multi/multi-term-settings/multi-term-settings, process 60422 [New Thread 60422.60422] Reading symbols from /lib/x86_64-linux-gnu/libc.so.6... Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libc-2.31.so... Reading symbols from /lib64/ld-linux-x86-64.so.2... (No debugging symbols found in /lib64/ld-linux-x86-64.so.2) 0x00007f2fc2485334 in __GI___clock_nanosleep (clock_id=<optimized out>, clock_id@entry <mailto:clock_id@entry>=0, flags=flags@entry <mailto:flags@entry>=0, req=req@entry <mailto:req@entry>=0x7ffe23126940, rem=rem@entry <mailto:rem@entry>=0x0) at ../sysdeps/unix/sysv/linux/clock_nanosleep.c:78 78 ../sysdeps/unix/sysv/linux/clock_nanosleep.c: No such file or directory. (gdb) PASS: gdb.multi/multi-term-settings.exp: inf1_how=attach: inf2_how=attach: inf2: attach set schedule-multiple on (gdb) PASS: gdb.multi/multi-term-settings.exp: inf1_how=attach: inf2_how=attach: set schedule-multiple on info inferiors Num Description Connection Executable 1 process 60404 1 (extended-remote localhost:2349) build/gdb/testsuite/outputs/gdb.multi/multi-term-settings/multi-term-settings * 2 process 60422 1 (extended-remote localhost:2349) build/gdb/testsuite/outputs/gdb.multi/multi-term-settings/multi-term-settings (gdb) PASS: gdb.multi/multi-term-settings.exp: inf1_how=attach: inf2_how=attach: info inferiors pid=60422, count=46 pid=60422, count=47 pid=60422, count=48 pid=60422, count=49 pid=60422, count=50 pid=60422, count=51 pid=60422, count=52 pid=60422, count=53 pid=60422, count=54 pid=60422, count=55 pid=60422, count=56 pid=60422, count=57 pid=60422, count=58 pid=60422, count=59 pid=60422, count=60 pid=60422, count=61 pid=60422, count=62 pid=60422, count=63 pid=60422, count=64 pid=60422, count=65 pid=60422, count=66 pid=60422, count=67 pid=60422, count=68 pid=60422, count=69 pid=60404, count=54 pid=60404, count=55 pid=60404, count=56 pid=60404, count=57 pid=60404, count=58 PASS: gdb.multi/multi-term-settings.exp: inf1_how=attach: inf2_how=attach: continue Quit (gdb) FAIL: gdb.multi/multi-term-settings.exp: inf1_how=attach: inf2_how=attach: stop with control-c (SIGINT) If you look at the testcase's sources, you'll see that the intention is to resumes the program with "continue", wait to see a few of those "pid=..., count=..." lines, and then interrupt the program with Ctrl-C. But somehow, that resulted in GDB printing "Quit", instead of the Ctrl-C stopping the program with SIGINT. Here's what is happening: #1 - those "pid=..., count=..." lines we see above weren't actually output by the inferior after it has been continued (see #1). Note that "inf1_how" and "inf2_how" are "attach". What happened is that those "pid=..., count=..." lines were output by the inferiors _before_ they were attached to. We see them at that point instead of earlier, because that's where the testcase reads from the inferiors' spawn_ids. #2 - The testcase mistakenly thinks those "pid=..., count=..." lines happened after the continue was processed by GDB, meaning it has waited enough, and so sends the Ctrl-C. GDB hasn't yet passed the terminal to the inferior, so the Ctrl-C results in that Quit. The fix here is twofold: #1 - flush inferior output right after attaching #2 - consume the "Continuing" printed by "continue", indicating the inferior has the terminal. This is the same as done throughout the testsuite to handle this exact problem of sending Ctrl-C too soon. gdb/testsuite/ChangeLog: yyyy-mm-dd Pedro Alves <pedro@palves.net <mailto:pedro@palves.net>> * gdb.multi/multi-term-settings.exp (create_inferior): Flush inferior output. (coretest): Use $gdb_test_name. After issuing "continue", wait for "Continuing". Change-Id: Iba7671dfe1eee6b98d29cfdb05a1b9aa2f9defb9 --- gdb/testsuite/gdb.multi/multi-term-settings.exp | 40 +++++++++++++++++++++---- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/gdb/testsuite/gdb.multi/multi-term-settings.exp b/gdb/testsuite/gdb.multi/multi-term-settings.exp index 20ec03d94b3..dcc6f2ece0f 100644 --- a/gdb/testsuite/gdb.multi/multi-term-settings.exp +++ b/gdb/testsuite/gdb.multi/multi-term-settings.exp @@ -95,6 +95,22 @@ proc create_inferior {which_inf inf_how} { if {[gdb_test "attach $testpid" \ "Attaching to program: .*, process $testpid.*(in|at).*" \ "attach"] == 0} { + + # The program is now stopped, but if testing against + # gdbserver, then the inferior's output emmitted 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. + gdb_test_multiple "" "flush inferior output" { + -timeout 1 + -i $test_spawn_id -re "pid=" { + exp_continue + } + timeout { + pass $gdb_test_name + } + } + return $test_spawn_id } } else { @@ -179,9 +195,9 @@ proc coretest {inf1_how inf2_how} { uplevel 1 { if {$count1 >= 3 && $count2 >= 3} { if $expect_ttou { - fail "$test (expected SIGTTOU)" + fail "$gdb_test_name (expected SIGTTOU)" } else { - pass $test + pass $gdb_test_name } } else { exp_continue @@ -195,8 +211,20 @@ proc coretest {inf1_how inf2_how} { set count1 0 set count2 0 - set test "continue" - gdb_test_multiple $test $test { + # We're going to interrupt with Ctrl-C. For this to work we must + # be sure to consume the "Continuing." message first, or GDB may + # still own the terminal. Also, note that in the attach case, we + # flushed inferior output right after attaching, so that we're + # sure that the "pid=" lines we see are emitted by the inferior + # after it is continued, instead of having been emitted before it + # was attached to. + gdb_test_multiple "continue" "continue, hand over terminal" { + -re "Continuing" { + pass $gdb_test_name + } + } + + gdb_test_multiple "" "continue" { -i $infs_spawn_ids -re "pid=$pid1, count=" { incr count1 pass_or_exp_continue @@ -207,9 +235,9 @@ proc coretest {inf1_how inf2_how} { } -i $gdb_spawn_id -re "received signal SIGTTOU.*$gdb_prompt " { if $expect_ttou { - pass "$test (expected SIGTTOU)" + pass "$gdb_test_name (expected SIGTTOU)" } else { - fail "$test (SIGTTOU)" + fail "$gdb_test_name (SIGTTOU)" } } } ++++++ fixup-2-gdb-6.6-buildid-locate.patch ++++++ fixup-2-gdb-6.6-buildid-locate.patch --- gdb/testsuite/lib/gdb.exp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index e2ce31cc553..2b94f79d132 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -131,7 +131,8 @@ if ![info exists INTERNAL_GDBFLAGS] { "-nx" \ "-data-directory $BUILD_DATA_DIRECTORY" \ {-iex "set height 0"} \ - {-iex "set width 0"}]] + {-iex "set width 0"} \ + {-iex "set build-id-verbose 0"}]] } # The variable gdb_prompt is a regexp which matches the gdb prompt. ++++++ fixup-gdb-6.6-buildid-locate.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.053340533 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.053340533 +0100 @@ -1,20 +1,23 @@ -[gdb/testsuite] Fixup buildid-locate +fixup-gdb-6.6-buildid-locate.patch --- - gdb/testsuite/gdb.base/gdbinit-history.exp | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) + gdb/build-id.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) -diff --git a/gdb/testsuite/gdb.base/gdbinit-history.exp b/gdb/testsuite/gdb.base/gdbinit-history.exp -index baa1b49153..1e9eabbb73 100644 ---- a/gdb/testsuite/gdb.base/gdbinit-history.exp -+++ b/gdb/testsuite/gdb.base/gdbinit-history.exp -@@ -181,7 +181,8 @@ proc test_empty_history_filename { } { - global env - global gdb_prompt +diff --git a/gdb/build-id.c b/gdb/build-id.c +index 830098688d5..a1920ab5a09 100644 +--- a/gdb/build-id.c ++++ b/gdb/build-id.c +@@ -1314,10 +1314,10 @@ find_separate_debug_file_by_buildid (struct objfile *objfile, + return std::string (); + } -- set common_history [list "set height 0" "set width 0"] -+ set common_history [list "set height 0" "set width 0" \ -+ "set build-id-verbose 0"] +-extern void _initialize_build_id (void); ++void _initialize_build_id (); - set test_dir [standard_output_file history_test] - remote_exec host "mkdir -p $test_dir" + void +-_initialize_build_id (void) ++_initialize_build_id () + { + add_setshow_zinteger_cmd ("build-id-verbose", no_class, &build_id_verbose, + _("\ ++++++ fixup-gdb-glibc-strstr-workaround.patch ++++++ fixup-gdb-glibc-strstr-workaround.patch --- gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp b/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp index 889f8c6f584..052bd84d420 100644 --- a/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp +++ b/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp @@ -68,7 +68,7 @@ gdb_test_multiple $test $test { set addr $expect_out(1,string) pass "$test (fixed glibc)" } - -re " = {char \\*\\(const char \\*, const char \\*\\)} 0x\[0-9a-f\]+ <strstr>\r\n$gdb_prompt $" { + -re " = {char \\*\\(const char \\*, const char \\*\\)} 0x\[0-9a-f\]+ <(__GI_)?strstr>\r\n$gdb_prompt $" { untested "$test (gnu-ifunc not in use by glibc)" return 0 } ++++++ fixup-gdb-linux_perf-bundle.patch ++++++ diff --git a/gdb/gdb.c b/gdb/gdb.c index 82e9e6da210..b5e28445630 100644 --- a/gdb/gdb.c +++ b/gdb/gdb.c @@ -20,19 +20,11 @@ #include "main.h" #include "interps.h" -#ifdef PERF_ATTR_SIZE_VER5_BUNDLE -extern "C" void __libipt_init(void); -#endif - int main (int argc, char **argv) { struct captured_main_args args; -#ifdef PERF_ATTR_SIZE_VER5_BUNDLE - __libipt_init(); -#endif - memset (&args, 0, sizeof args); args.argc = argc; args.argv = argv; ++++++ fixup-gdb-rhbz1325795-framefilters-test.patch ++++++ fixup-gdb-rhbz1325795-framefilters-test.patch --- gdb/testsuite/gdb.python/py-framefilter-thread.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.python/py-framefilter-thread.exp b/gdb/testsuite/gdb.python/py-framefilter-thread.exp index 71f97463372..156a4d7bbf3 100644 --- a/gdb/testsuite/gdb.python/py-framefilter-thread.exp +++ b/gdb/testsuite/gdb.python/py-framefilter-thread.exp @@ -39,7 +39,7 @@ gdb_breakpoint [gdb_get_line_number "Backtrace end breakpoint"] gdb_continue_to_breakpoint "Backtrace end breakpoint" # #2 0x00007ffff75f228d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113^M -gdb_test "bt no-filters" " in (\\.?_*clone|thread_start) \[^\r\n\]*" "bt no-filters" +gdb_test "bt no-filters" " in (\\.?_*clone3?|thread_start) \[^\r\n\]*" "bt no-filters" # #2 0x00007ffff75f228d in 941595343737041 () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113^M # vs. ++++++ fixup-gdb-rhbz1553104-s390x-arch12-test.patch ++++++ fixup-gdb-rhbz1553104-s390x-arch12-test.patch --- gdb/testsuite/gdb.arch/s390x-arch12.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.arch/s390x-arch12.exp b/gdb/testsuite/gdb.arch/s390x-arch12.exp index 4e902ff960d..246c1e1c69a 100644 --- a/gdb/testsuite/gdb.arch/s390x-arch12.exp +++ b/gdb/testsuite/gdb.arch/s390x-arch12.exp @@ -20,7 +20,7 @@ set testfile "s390x-arch12" set uufile "${srcdir}/${subdir}/${testfile}.o.uu" -set ofile "${srcdir}/${subdir}/${testfile}.o" +set ofile [standard_output_file ${testfile}.o] if { [catch "system \"uudecode -o ${ofile} ${uufile}\"" ] != 0 } { untested "failed uudecode" ++++++ gdb-10.1.tar.bz2 -> gdb-11.1.tar.bz2 ++++++ /work/SRC/openSUSE:Factory/gdb/gdb-10.1.tar.bz2 /work/SRC/openSUSE:Factory/.gdb.new.1890/gdb-11.1.tar.bz2 differ: char 11, line 1 ++++++ gdb-6.3-attach-see-vdso-test.patch ++++++ From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 From: Fedora GDB patches <invalid@email.com> Date: Fri, 27 Oct 2017 21:07:50 +0200 Subject: gdb-6.3-attach-see-vdso-test.patch ;; Test kernel VDSO decoding while attaching to an i386 process. ;;=fedoratest diff --git a/gdb/testsuite/gdb.base/attach-see-vdso.c b/gdb/testsuite/gdb.base/attach-see-vdso.c new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/attach-see-vdso.c @@ -0,0 +1,25 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2007 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include <unistd.h> + +int main () +{ + pause (); + return 1; +} diff --git a/gdb/testsuite/gdb.base/attach-see-vdso.exp b/gdb/testsuite/gdb.base/attach-see-vdso.exp new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/attach-see-vdso.exp @@ -0,0 +1,77 @@ +# Copyright 2007 + +# 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# This file was created by Jan Kratochvil <jan.kratochvil@redhat.com>. + +# This test only works on Linux +if { ![istarget "*-*-linux-gnu*"] } { + return 0 +} + +if {[use_gdb_stub]} { + untested "skipping test because of use_gdb_stub" + return -1 +} + +set testfile "attach-see-vdso" +set srcfile ${testfile}.c +set binfile [standard_output_file ${testfile}] +set escapedbinfile [string_to_regexp [standard_output_file ${testfile}]] + +# The kernel VDSO is used for the syscalls returns only on i386 (not x86_64). +# +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-m32}] != "" } { + gdb_suppress_entire_file "Testcase nonthraded compile failed, so all tests in this file will automatically fail." +} + +if [get_compiler_info ${binfile}] { + return -1 +} + +# Start the program running and then wait for a bit, to be sure +# that it can be attached to. + +set testpid [eval exec $binfile &] + +# Avoid some race: +sleep 2 + +# Start with clean gdb +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +# Never call: gdb_load ${binfile} +# as the former problem would not reproduce otherwise. + +set test "attach" +gdb_test_multiple "attach $testpid" "$test" { + -re "Attaching to process $testpid\r?\n.*$gdb_prompt $" { + pass "$test" + } +} + +gdb_test "bt" "#0 *0x\[0-9a-f\]* in \[^?\].*" "backtrace decodes VDSO" + +# Exit and detach the process. + +gdb_exit + +# Make sure we don't leave a process around to confuse +# the next test run (and prevent the compile by keeping +# the text file busy), in case the "set should_exit" didn't +# work. + +remote_exec build "kill -9 ${testpid}" ++++++ gdb-6.3-bz140532-ppc-unwinding-test.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.117340570 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.117340570 +0100 @@ -24,7 +24,7 @@ + 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ @@ -107,7 +107,7 @@ + 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ @@ -210,7 +210,7 @@ + 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ @@ -237,15 +237,15 @@ +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Test unwinding fixes of the PPC platform, specifically on the coping with BCL +# jump of the PIE code. ++++++ gdb-6.3-bz202689-exec-from-pthread-test.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.125340574 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.129340576 +0100 @@ -73,15 +73,15 @@ +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu ++++++ gdb-6.3-gstack-20050411.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.137340581 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.137340581 +0100 @@ -16,7 +16,7 @@ diff --git a/gdb/Makefile.in b/gdb/Makefile.in --- a/gdb/Makefile.in +++ b/gdb/Makefile.in -@@ -1726,7 +1726,7 @@ info install-info clean-info dvi pdf install-pdf html install-html: force +@@ -1753,7 +1753,7 @@ info install-info clean-info dvi pdf install-pdf html install-html: force install: all @$(MAKE) $(FLAGS_TO_PASS) install-only @@ -25,7 +25,7 @@ transformed_name=`t='$(program_transform_name)'; \ echo gdb | sed -e "$$t"` ; \ if test "x$$transformed_name" = x; then \ -@@ -1775,7 +1775,25 @@ install-guile: +@@ -1802,7 +1802,25 @@ install-guile: install-python: $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(GDB_DATADIR)/python/gdb @@ -52,7 +52,7 @@ transformed_name=`t='$(program_transform_name)'; \ echo gdb | sed -e $$t` ; \ if test "x$$transformed_name" = x; then \ -@@ -1798,6 +1816,18 @@ uninstall: force $(CONFIG_UNINSTALL) +@@ -1825,6 +1843,18 @@ uninstall: force $(CONFIG_UNINSTALL) fi @$(MAKE) DO=uninstall "DODIRS=$(SUBDIRS)" $(FLAGS_TO_PASS) subdir_do @@ -67,7 +67,7 @@ + fi ; \ + rm -f $(DESTDIR)$(bindir)/$$transformed_name$(EXEEXT) \ + $(DESTDIR)$(man1dir)/$$transformed_name.1 -+ ++ # The C++ name parser can be built standalone for testing. test-cp-name-parser.o: cp-name-parser.c $(COMPILE) -DTEST_CPNAMES cp-name-parser.c @@ -109,7 +109,7 @@ + +# Run GDB, strip out unwanted noise. +# --readnever is no longer used since .gdb_index is now in use. -+$GDB --quiet -nx $GDBARGS /proc/$1/exe $1 <<EOF 2>&1 | ++$GDB --quiet -nx $GDBARGS /proc/$1/exe $1 <<EOF 2>&1 | +set width 0 +set height 0 +set pagination no @@ -153,7 +153,7 @@ + /* Use the most simple notification not to get caught by attach on exiting + the function. */ + write (1, msg, strlen (msg)); -+ ++ + for (;;); +} + ++++++ gdb-6.3-inferior-notification-20050721.patch ++++++ From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 From: Jeff Johnston <jjohnstn@redhat.com> Date: Fri, 27 Oct 2017 21:07:50 +0200 Subject: gdb-6.3-inferior-notification-20050721.patch ;; Notify observers that the inferior has been created ;;=fedoratest 2005-07-21 Jeff Johnston <jjohnstn@redhat.com> * gdb.base/attach-32.exp: New test for attaching in 32-bit mode on 64-bit systems. * gdb.base/attach-32.c: Ditto. * gdb.base/attach-32b.c: Ditto. 2007-12-26 Jan Kratochvil <jan.kratochvil@redhat.com> * gdb.base/attach-32.exp: Fix forgotten $GDBFLAGS as set. diff --git a/gdb/testsuite/gdb.base/attach-32.c b/gdb/testsuite/gdb.base/attach-32.c new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/attach-32.c @@ -0,0 +1,20 @@ +/* This program is intended to be started outside of gdb, and then + attached to by gdb. Thus, it simply spins in a loop. The loop + is exited when & if the variable 'should_exit' is non-zero. (It + is initialized to zero in this program, so the loop will never + exit unless/until gdb sets the variable to non-zero.) + */ +#include <stdio.h> + +int should_exit = 0; + +int main () +{ + int local_i = 0; + + while (! should_exit) + { + local_i++; + } + return 0; +} diff --git a/gdb/testsuite/gdb.base/attach-32.exp b/gdb/testsuite/gdb.base/attach-32.exp new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/attach-32.exp @@ -0,0 +1,246 @@ +# Copyright 2005 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# This test was based on attach.exp and modified for 32/64 bit Linux systems. */ + +# On HP-UX 11.0, this test is causing a process running the program +# "attach" to be left around spinning. Until we figure out why, I am +# commenting out the test to avoid polluting tiamat (our 11.0 nightly +# test machine) with these processes. RT +# +# Setting the magic bit in the target app should work. I added a +# "kill", and also a test for the R3 register warning. JB +if { ![istarget "x86_64*-*linux*"] + && ![istarget "powerpc64*-*linux*"]} { + return 0 +} + +# are we on a target board +if {[use_gdb_stub]} { + untested "skipping test because of use_gdb_stub" + return -1 +} + +set testfile "attach-32" +set srcfile ${testfile}.c +set srcfile2 ${testfile}b.c +set binfile [standard_output_file ${testfile}] +set binfile2 [standard_output_file ${testfile}b] +set escapedbinfile [string_to_regexp [standard_output_file ${testfile}]] + +#execute_anywhere "rm -f ${binfile} ${binfile2}" +remote_exec build "rm -f ${binfile} ${binfile2}" +# For debugging this test +# +#log_user 1 + +# build the first test case +# +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "additional_flags=-m32"]] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +# Build the in-system-call test + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable [list debug "additional_flags=-m32"]] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if [get_compiler_info ${binfile}] { + return -1 +} + +proc do_attach_tests {} { + global gdb_prompt + global binfile + global escapedbinfile + global srcfile + global testfile + global objdir + global subdir + global timeout + global testpid + + # Verify that we can "see" the variable "should_exit" in the + # program, and that it is zero. + + gdb_test "print should_exit" " = 0" "after attach-32, print should_exit" + + # Verify that we can modify the variable "should_exit" in the + # program. + + gdb_test "set should_exit=1" "" "after attach-32, set should_exit" + + # Verify that the modification really happened. + + send_gdb "tbreak 19\n" + gdb_expect { + -re "reakpoint .*at.*$srcfile, line 19.*$gdb_prompt $" { + pass "after attach-32, set tbreak postloop" + } + -re "$gdb_prompt $" { + fail "after attach-32, set tbreak postloop" + } + timeout { + fail "(timeout) after attach-32, set tbreak postloop" + } + } + send_gdb "continue\n" + gdb_expect { + -re "main.*at.*$srcfile:19.*$gdb_prompt $" { + pass "after attach-32, reach tbreak postloop" + } + -re "$gdb_prompt $" { + fail "after attach-32, reach tbreak postloop" + } + timeout { + fail "(timeout) after attach-32, reach tbreak postloop" + } + } + + # Allow the test process to exit, to cleanup after ourselves. + + gdb_test "continue" {\[Inferior .* exited normally\]} "after attach-32, exit" + + # Make sure we don't leave a process around to confuse + # the next test run (and prevent the compile by keeping + # the text file busy), in case the "set should_exit" didn't + # work. + + remote_exec build "kill -9 ${testpid}" + + # Start the program running and then wait for a bit, to be sure + # that it can be attached to. + + set testpid [eval exec $binfile &] + exec sleep 2 + if { [istarget "*-*-cygwin*"] } { + # testpid is the Cygwin PID, GDB uses the Windows PID, which might be + # different due to the way fork/exec works. + set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ] + } + + # Verify that we can attach to the process, and find its a.out + # when we're cd'd to some directory that doesn't contain the + # a.out. (We use the source path set by the "dir" command.) + + gdb_test "dir ${objdir}/${subdir}" "Source directories searched: .*" \ + "set source path" + + gdb_test "cd /tmp" "Working directory /tmp." \ + "cd away from process working directory" + + # Explicitly flush out any knowledge of the previous attachment. + + set test "before attach-32-3, flush symbols" + gdb_test_multiple "symbol" "$test" { + -re "Discard symbol table from.*y or n. $" { + gdb_test "y" "No symbol file now." \ + "$test" + } + -re "No symbol file now.*$gdb_prompt $" { + pass "$test" + } + } + + gdb_test "exec" "No executable file now." \ + "before attach-32-3, flush exec" + + gdb_test "attach $testpid" \ + "Attaching to process $testpid.*Reading symbols from $escapedbinfile.*main.*at .*" \ + "attach-32 when process' a.out not in cwd" + + set test "after attach-32-3, exit" + gdb_test_multiple "kill" "$test" { + -re "Kill the program being debugged.*y or n. $" { + gdb_test "y" "" "$test" + } + } + + # Another "don't leave a process around" + remote_exec build "kill -9 ${testpid}" +} + +proc do_call_attach_tests {} { + global gdb_prompt + global binfile2 + global testpid + + # See if other registers are problems + + set test "info other register" + gdb_test_multiple "i r r3" "$test" { + -re "warning: reading register.*$gdb_prompt $" { + fail "$test" + } + -re "r3.*$gdb_prompt $" { + pass "$test" + } + } + + # Get rid of the process + + gdb_test "p should_exit = 1" + gdb_test "c" {\[Inferior .* exited normally\]} + + # Be paranoid + + remote_exec build "kill -9 ${testpid}" +} + + +# Start with a fresh gdb + +gdb_exit +set testpid [eval exec $binfile &] +exec sleep 3 +if { [istarget "*-*-cygwin*"] } { + # testpid is the Cygwin PID, GDB uses the Windows PID, which might be + # different due to the way fork/exec works. + set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ] +} + +set GDBFLAGS_orig $GDBFLAGS +set GDBFLAGS "-iex \"set height 0\" --pid=$testpid" +gdb_start +set GDBFLAGS $GDBFLAGS_orig + +gdb_reinitialize_dir $srcdir/$subdir + +# This is a test of gdb's ability to attach to a running process. + +do_attach_tests + +# Test attaching when the target is inside a system call + +gdb_exit +set testpid [eval exec $binfile2 &] +exec sleep 3 +if { [istarget "*-*-cygwin*"] } { + # testpid is the Cygwin PID, GDB uses the Windows PID, which might be + # different due to the way fork/exec works. + set testpid [ exec ps -e | gawk "{ if (\$1 == $testpid) print \$4; }" ] +} + +set GDBFLAGS_orig $GDBFLAGS +set GDBFLAGS "-iex \"set height 0\" --pid=$testpid" +gdb_start +set GDBFLAGS $GDBFLAGS_orig + +gdb_reinitialize_dir $srcdir/$subdir +do_call_attach_tests + +return 0 diff --git a/gdb/testsuite/gdb.base/attach-32b.c b/gdb/testsuite/gdb.base/attach-32b.c new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/attach-32b.c @@ -0,0 +1,24 @@ +/* This program is intended to be started outside of gdb, and then + attached to by gdb. Thus, it simply spins in a loop. The loop + is exited when & if the variable 'should_exit' is non-zero. (It + is initialized to zero in this program, so the loop will never + exit unless/until gdb sets the variable to non-zero.) + */ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> + +int should_exit = 0; + +int main () +{ + int local_i = 0; + + sleep( 10 ); /* System call causes register fetch to fail */ + /* This is a known HPUX "feature" */ + while (! should_exit) + { + local_i++; + } + return (0); +} ++++++ gdb-6.3-inheritancetest-20050726.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.153340590 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.153340590 +0100 @@ -17,7 +17,7 @@ new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.cp/b146835.cc -@@ -0,0 +1,32 @@ +@@ -0,0 +1,31 @@ +#include "b146835.h" +#include <iostream> + @@ -49,7 +49,6 @@ + F f; + f.foo(); +} -+ diff --git a/gdb/testsuite/gdb.cp/b146835.exp b/gdb/testsuite/gdb.cp/b146835.exp new file mode 100644 --- /dev/null @@ -71,7 +70,7 @@ +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Check that GDB can properly print an inherited member variable +# (Bugzilla 146835) ++++++ gdb-6.3-mapping-zero-inode-test.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.161340595 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.161340595 +0100 @@ -150,15 +150,15 @@ +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Test GDB's handling of gcore for mapping with a name but zero inode. + ++++++ gdb-6.3-test-dtorfix-20050121.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.169340599 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.169340599 +0100 @@ -131,7 +131,7 @@ +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Check that GDB can break at multiple forms of constructors. + @@ -160,7 +160,7 @@ +# Break on the various forms of the A::A constructor. +# " (2 locations)" is displayed depending on G++ version. +gdb_test "break A\:\:A" "Breakpoint 2 at .*" "breaking on A::A" -+ ++ +# Verify that we break for the A constructor two times +# Once for new A and once for new B +gdb_continue_to_breakpoint "First line A" ++++++ gdb-6.3-test-movedir-20050125.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.181340607 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.181340607 +0100 @@ -16,7 +16,7 @@ new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/move-dir.c -@@ -0,0 +1,10 @@ +@@ -0,0 +1,9 @@ +#include <stdio.h> +#include <stdlib.h> +#include "move-dir.h" @@ -26,7 +26,6 @@ + printf ("%s\n", hw);; + other(); +} -+ diff --git a/gdb/testsuite/gdb.base/move-dir.exp b/gdb/testsuite/gdb.base/move-dir.exp new file mode 100644 --- /dev/null @@ -39,15 +38,15 @@ +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +set testfile "move-dir" +set srcfile ${testfile}.c @@ -93,11 +92,10 @@ new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/move-dir.h -@@ -0,0 +1,7 @@ +@@ -0,0 +1,6 @@ +#include <stdlib.h> + +void other() { + const char* ostring = "other"; + printf ("%s\n", ostring);; +} -+ ++++++ gdb-6.3-threaded-watchpoints2-20050225.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.189340611 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.189340611 +0100 @@ -54,7 +54,7 @@ new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.threads/watchthreads-threaded.c -@@ -0,0 +1,66 @@ +@@ -0,0 +1,65 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2002, 2003, 2004, 2005 Free Software Foundation, Inc. @@ -72,8 +72,8 @@ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, -+ Boston, MA 02111-1307, USA. -+ ++ Boston, MA 02111-1307, USA. ++ + This file is copied from schedlock.c. */ + +#include <stdio.h> @@ -120,7 +120,6 @@ + + pthread_exit(NULL); +} -+ diff --git a/gdb/testsuite/gdb.threads/watchthreads-threaded.exp b/gdb/testsuite/gdb.threads/watchthreads-threaded.exp new file mode 100644 --- /dev/null @@ -142,7 +141,7 @@ +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Check that GDB can support multiple watchpoints across threads. + @@ -213,9 +212,9 @@ + { set args_2 1; set test_flag 1 } + -re "Hardware watchpoint 4: args\\\[3\\\].*Old value = 0.*New value = 1.*main \\\(\\\) at .*watchthreads-threaded.c:$init_line.*$gdb_prompt $" + { set args_3 1; set test_flag 1 } -+ -re "Hardware watchpoint 3: args\\\[2\\\].*Old value = $args_2.*New value = [expr $args_2+1].*in thread_function \\\(arg=0x2\\\) at .*watchthreads-threaded.c:$inc_line.*$gdb_prompt $" ++ -re "Hardware watchpoint 3: args\\\[2\\\].*Old value = $args_2.*New value = [expr $args_2+1].*thread_function \\\(arg=0x2\\\) at .*watchthreads-threaded.c:$inc_line.*$gdb_prompt $" + { set args_2 [expr $args_2+1]; set test_flag 1 } -+ -re "Hardware watchpoint 4: args\\\[3\\\].*Old value = $args_3.*New value = [expr $args_3+1].*in thread_function \\\(arg=0x3\\\) at .*watchthreads-threaded.c:$inc_line.*$gdb_prompt $" ++ -re "Hardware watchpoint 4: args\\\[3\\\].*Old value = $args_3.*New value = [expr $args_3+1].*thread_function \\\(arg=0x3\\\) at .*watchthreads-threaded.c:$inc_line.*$gdb_prompt $" + { set args_3 [expr $args_3+1]; set test_flag 1 } + } + # If we fail above, don't bother continuing loop @@ -232,7 +231,7 @@ +# Verify that we hit first watchpoint in child thread. +set message "watchpoint on args\[2\] hit in thread" +if { $args_2 > 1 } { -+ pass $message ++ pass $message +} else { + fail $message +} @@ -240,15 +239,15 @@ +# Verify that we hit second watchpoint in child thread. +set message "watchpoint on args\[3\] hit in thread" +if { $args_3 > 1 } { -+ pass $message ++ pass $message +} else { -+ fail $message ++ fail $message +} + +# Verify that all watchpoint hits are accounted for. +set message "combination of threaded watchpoints = 30 + initial values" +if { [expr $args_2+$args_3] == [expr [expr 30+$init_args_2]+$init_args_3] } { -+ pass $message ++ pass $message +} else { -+ fail $message ++ fail $message +} ++++++ gdb-6.5-bz109921-DW_AT_decl_file-test.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.197340615 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.197340615 +0100 @@ -42,7 +42,7 @@ + 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, @@ -66,12 +66,12 @@ +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -86,7 +86,7 @@ + && ![istarget *-*-openbsd*] + && ![istarget arm-*-eabi*] + && ![istarget powerpc-*-eabi*]} { -+ return 0 ++ return 0 +} + +set testfile "dw2-included" @@ -125,7 +125,7 @@ + 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, ++++++ gdb-6.5-bz185337-resolve-tls-without-debuginfo-v2.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.205340620 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.205340620 +0100 @@ -44,17 +44,17 @@ diff --git a/gdb/printcmd.c b/gdb/printcmd.c --- a/gdb/printcmd.c +++ b/gdb/printcmd.c -@@ -1210,6 +1210,10 @@ print_command_1 (const char *args, int voidprint) +@@ -1306,6 +1306,10 @@ process_print_command_args (const char *args, value_print_options *print_opts, if (exp != nullptr && *exp) { + /* '*((int *(*) (void)) __errno_location) ()' is incompatible with + function descriptors. */ -+ if (target_has_execution && strcmp (exp, "errno") == 0) ++ if (target_has_execution () && strcmp (exp, "errno") == 0) + exp = "*(*(int *(*)(void)) __errno_location) ()"; - expression_up expr = parse_expression (exp); - val = evaluate_expression (expr.get ()); - } + /* VOIDPRINT is true to indicate that we do want to print a void + value, so invert it for parse_expression. */ + expression_up expr = parse_expression (exp, nullptr, !voidprint); diff --git a/gdb/testsuite/gdb.dwarf2/dw2-errno.c b/gdb/testsuite/gdb.dwarf2/dw2-errno.c new file mode 100644 --- /dev/null ++++++ gdb-6.5-bz218379-ppc-solib-trampoline-test.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.213340625 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.217340627 +0100 @@ -26,7 +26,7 @@ + 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -45,22 +45,27 @@ new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/step-over-trampoline.exp -@@ -0,0 +1,54 @@ +@@ -0,0 +1,59 @@ +# Copyright 2006 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 2 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, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ ++if {[use_gdb_stub]} { ++ untested "skipping test because of use_gdb_stub" ++ return -1 ++} + +if $tracelevel then { + strace $tracelevel ++++++ gdb-6.5-bz243845-stale-testing-zombie-test.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.221340630 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.225340631 +0100 @@ -10,26 +10,27 @@ new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/tracefork-zombie.exp -@@ -0,0 +1,75 @@ +@@ -0,0 +1,76 @@ +# Copyright 2007 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +# are we on a target board -+if [is_remote target] then { -+ return 0 ++if {[use_gdb_stub]} { ++ untested "skipping test because of use_gdb_stub" ++ return -1 +} + +# Start the program running and then wait for a bit, to be sure ++++++ gdb-6.5-gcore-buffer-limit-test.patch ++++++ From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 From: Fedora GDB patches <invalid@email.com> Date: Fri, 27 Oct 2017 21:07:50 +0200 Subject: gdb-6.5-gcore-buffer-limit-test.patch ;; Test gcore memory and time requirements for large inferiors. ;;=fedoratest diff --git a/gdb/testsuite/gdb.base/gcore-excessive-memory.c b/gdb/testsuite/gdb.base/gcore-excessive-memory.c new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/gcore-excessive-memory.c @@ -0,0 +1,37 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2008 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@prep.ai.mit.edu */ + +#include <unistd.h> +#include <stdlib.h> + +#define MEGS 64 + +int main() +{ + void *mem; + + mem = malloc (MEGS * 1024ULL * 1024ULL); + + for (;;) + sleep (1); + + return 0; +} diff --git a/gdb/testsuite/gdb.base/gcore-excessive-memory.exp b/gdb/testsuite/gdb.base/gcore-excessive-memory.exp new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/gcore-excessive-memory.exp @@ -0,0 +1,99 @@ +# Copyright 2008 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +if {[use_gdb_stub]} { + untested "skipping test because of use_gdb_stub" + return -1 +} + +set testfile gcore-excessive-memory +set srcfile ${testfile}.c +set shfile [standard_output_file ${testfile}-gdb.sh] +set corefile [standard_output_file ${testfile}.core] +set binfile [standard_output_file ${testfile}] +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + untested "Couldn't compile test program" + return -1 +} + +set f [open "|getconf PAGESIZE" "r"] +gets $f pagesize +close $f + +set pid_of_bin [eval exec $binfile &] +sleep 2 + +# Get things started. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +set pid_of_gdb [exp_pid -i [board_info host fileid]] + +gdb_test "attach $pid_of_bin" "Attaching to .*" "attach" +gdb_test "up 99" "in main .*" "verify we can get to main" + +proc memory_v_pages_get {} { + global pid_of_gdb pagesize + set fd [open "/proc/$pid_of_gdb/statm"] + gets $fd line + close $fd + # number of pages of virtual memory + scan $line "%d" drs + return $drs +} + +set pages_found [memory_v_pages_get] + +# It must be definitely less than `MEGS' of `gcore-excessive-memory.c'. +set mb_gcore_reserve 4 +verbose -log "pages_found = $pages_found, mb_gcore_reserve = $mb_gcore_reserve" +set kb_found [expr $pages_found * $pagesize / 1024] +set kb_permit [expr $kb_found + 1 * 1024 + $mb_gcore_reserve * 1024] +verbose -log "kb_found = $kb_found, kb_permit = $kb_permit" + +# Create the ulimit wrapper. +set f [open $shfile "w"] +puts $f "#! /bin/sh" +puts $f "ulimit -v $kb_permit" +puts $f "exec $GDB \"\$@\"" +close $f +remote_exec host "chmod +x $shfile" + +gdb_exit +set GDBold $GDB +set GDB "$shfile" +gdb_start +set GDB $GDBold + +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +set pid_of_gdb [exp_pid -i [board_info host fileid]] + +gdb_test "attach $pid_of_bin" "Attaching to .*" "attach" +gdb_test "up 99" "in main .*" "verify we can get to main" + +verbose -log "kb_found before gcore = [expr [memory_v_pages_get] * $pagesize / 1024]" + +gdb_test "gcore $corefile" "Saved corefile \[^\n\r\]*" "Save the core file" + +verbose -log "kb_found after gcore = [expr [memory_v_pages_get] * $pagesize / 1024]" + +# Cleanup. +exec kill -9 $pid_of_bin ++++++ gdb-6.5-ia64-libunwind-leak-test.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.237340638 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.237340638 +0100 @@ -24,7 +24,7 @@ + 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -44,22 +44,27 @@ new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/unwind-leak.exp -@@ -0,0 +1,83 @@ +@@ -0,0 +1,88 @@ +# Copyright 2007 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 2 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, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ ++if {[use_gdb_stub]} { ++ untested "skipping test because of use_gdb_stub" ++ return -1 ++} + +set testfile unwind-leak +set srcfile ${testfile}.c @@ -104,7 +109,7 @@ +verbose -log "cycles = $cycles, permit_kb = $permit_kb" + +set fail 0 -+set test "breakpoint stop/continue cycles" ++set test "breakpoint stop/continue cycles" +for {set i $cycles} {$i > 0} {set i [expr {$i - 1}]} { + gdb_test_multiple "continue" $test { + -re "Breakpoint 2, main .*alarm .*.*${gdb_prompt} $" { ++++++ gdb-6.5-last-address-space-byte-test.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.245340643 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.245340643 +0100 @@ -17,15 +17,15 @@ +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +if $tracelevel then { + strace $tracelevel ++++++ gdb-6.5-missed-trap-on-step-test.patch ++++++ From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 From: Fedora GDB patches <invalid@email.com> Date: Fri, 27 Oct 2017 21:07:50 +0200 Subject: gdb-6.5-missed-trap-on-step-test.patch ;; Test hiding unexpected breakpoints on intentional step commands. ;;=fedoratest Fix has been committed to: gdb-6.6-scheduler_locking-step-sw-watchpoints2.patch diff --git a/gdb/testsuite/gdb.base/watchpoint-during-step.c b/gdb/testsuite/gdb.base/watchpoint-during-step.c new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/watchpoint-during-step.c @@ -0,0 +1,30 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2007 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@prep.ai.mit.edu */ + +static int var; + +int main() +{ + var = 1; + var = 2; + var = 3; + return 0; +} diff --git a/gdb/testsuite/gdb.base/watchpoint-during-step.exp b/gdb/testsuite/gdb.base/watchpoint-during-step.exp new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/watchpoint-during-step.exp @@ -0,0 +1,44 @@ +# Copyright 2007 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +set testfile watchpoint-during-step +set srcfile ${testfile}.c +set binfile [standard_output_file ${testfile}] +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + untested "Couldn't compile test program" + return -1 +} + +# Get things started. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +runto_main + +gdb_breakpoint [gdb_get_line_number "var = 2"] +gdb_continue_to_breakpoint "Find the first var set" + +gdb_test "step" ".*var = 3;" "Step to the next var set" + +gdb_test "watch var" "atchpoint .*: var" "Set the watchpoint" + +# Here is the target point. Be careful to not have breakpoint set on the line +# we step from as in this case it is a valid upstream KFAIL gdb/38 + +gdb_test "step" ".*Old value = 2.*New value = 3.*" "Catch the watchpoint" ++++++ gdb-6.5-readline-long-line-crash-test.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.261340653 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.261340653 +0100 @@ -12,22 +12,22 @@ new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/readline-overflow.exp -@@ -0,0 +1,104 @@ +@@ -0,0 +1,96 @@ +# Copyright 2006 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 2 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, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu @@ -46,20 +46,12 @@ + +global env + -+save_vars { env(INPUTRC) env(GDBHISTFILE) env(HISTSIZE) TERM timeout } { ++save_vars { env(GDBHISTFILE) env(HISTSIZE) TERM timeout } { + # The arrow key test relies on the standard VT100 bindings, so + # make sure that an appropriate terminal is selected. The same + # bug doesn't show up if we use ^P / ^N instead. + setenv TERM vt100 + -+ # Don't let a .inputrc file or an existing setting of INPUTRC mess up -+ # the test results. Even if /dev/null doesn't exist on the particular -+ # platform, the readline library will use the default setting just by -+ # failing to open the file. OTOH, opening /dev/null successfully will -+ # also result in the default settings being used since nothing will be -+ # read from this file. -+ set env(INPUTRC) "/dev/null" -+ + set timeout 600 + + set env(GDBHISTFILE) "${srcdir}/${subdir}/gdb_history" ++++++ gdb-6.5-section-num-fixup-test.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.269340656 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.269340656 +0100 @@ -24,7 +24,7 @@ + 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -51,7 +51,7 @@ + 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -68,22 +68,27 @@ new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/datalib.exp -@@ -0,0 +1,51 @@ +@@ -0,0 +1,56 @@ +# Copyright 2008 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 2 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, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ ++if {[use_gdb_stub]} { ++ untested "skipping test because of use_gdb_stub" ++ return -1 ++} + +set testfile datalib +set srcfilemain ${testfile}-main.c ++++++ gdb-6.5-sharedlibrary-path.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.277340661 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.281340664 +0100 @@ -33,7 +33,7 @@ new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.threads/tls-sepdebug-main.c -@@ -0,0 +1,25 @@ +@@ -0,0 +1,31 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2006 Free Software Foundation, Inc. @@ -47,7 +47,7 @@ + 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -55,9 +55,15 @@ + Please email any bugs, comments, and/or additions to this file to: + bug-gdb@prep.ai.mit.edu */ + ++#include <pthread.h> ++ ++extern __thread int var; ++ +int main() +{ -+ return 0; ++ /* Ensure we link against pthreads even with --as-needed. */ ++ pthread_testcancel(); ++ return var; +} diff --git a/gdb/testsuite/gdb.threads/tls-sepdebug-shared.c b/gdb/testsuite/gdb.threads/tls-sepdebug-shared.c new file mode 100644 @@ -77,7 +83,7 @@ + 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -90,22 +96,29 @@ new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.threads/tls-sepdebug.exp -@@ -0,0 +1,87 @@ +@@ -0,0 +1,94 @@ +# Copyright 2006 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 2 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, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++ ++# This test uses gdb_exit and gdb_start, which are not supported ++# on non-extended-remote sessions. ++if {[use_gdb_stub]} { ++ untested "skipping test because of stub" ++ return 0 ++} + +if $tracelevel then { + strace $tracelevel @@ -158,22 +171,22 @@ + gdb_exit + gdb_start + ###gdb_reinitialize_dir $srcdir/$subdir -+ ++ + gdb_test "set env LD_LIBRARY_PATH=$ld_library_path" \ + "" \ + "set env LD_LIBRARY_PATH is $name" -+ ++ + gdb_load ${binmainfile} -+ ++ + # For C programs, "start" should stop in main(). -+ ++ + gdb_test "start" \ + "main \\(\\) at .*${srcmainfile}.*" \ + "start" -+ ++ + # Check for: Cannot find shared library `/usr/lib/debug/lib/libc-2.4.90.so.debug' in dynamic linker's load module list + # as happens with TLS variables and `separate_debug_objfile_backlink'. -+ ++ + gdb_test "print var" \ + "\\\$1 = \[0-9\].*" \ + "print TLS variable from a shared library with $name-directory separate debug info file" ++++++ gdb-6.6-buildid-locate-rpm-scl.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.289340668 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.289340668 +0100 @@ -98,7 +98,7 @@ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c -@@ -3025,6 +3025,16 @@ read_gdb_index_from_buffer (const char *filename, +@@ -2801,6 +2801,16 @@ read_gdb_index_from_buffer (const char *filename, "set use-deprecated-index-sections on". */ if (version < 6 && !deprecated_ok) { @@ -115,7 +115,7 @@ static int warning_printed = 0; if (!warning_printed) { -@@ -3036,6 +3046,10 @@ to use the section anyway."), +@@ -2812,6 +2822,10 @@ to use the section anyway."), warning_printed = 1; } return 0; ++++++ gdb-6.6-buildid-locate-rpm.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.301340675 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.301340675 +0100 @@ -14,7 +14,7 @@ +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# serial 1 (pkg-config-0.24) -+# ++# +# Copyright �� 2004 Scott James Remnant <scott@netsplit.com>. +# +# This program is free software; you can redistribute it and/or modify @@ -133,11 +133,11 @@ +See the pkg-config man page for more details.]) + +if test $pkg_failed = yes; then -+ AC_MSG_RESULT([no]) ++ AC_MSG_RESULT([no]) + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` -+ else ++ else + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` + fi + # Put the nasty error message in config.log where it belongs @@ -154,7 +154,7 @@ +_PKG_TEXT])[]dnl + ]) +elif test $pkg_failed = untried; then -+ AC_MSG_RESULT([no]) ++ AC_MSG_RESULT([no]) + m4_default([$4], [AC_MSG_FAILURE( +[The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full @@ -336,7 +336,7 @@ + + /* Already failed the initialization before? */ + if (init_tried) -+ return 0; ++ return 0; + init_tried = 1; + +#ifdef DLOPEN_LIBRPM @@ -696,7 +696,7 @@ /* Define to 1 if translation of program messages to the user's native language is requested. */ #undef ENABLE_NLS -@@ -247,6 +250,9 @@ +@@ -246,6 +249,9 @@ /* Define if you have the mpfr library. */ #undef HAVE_LIBMPFR @@ -709,7 +709,7 @@ diff --git a/gdb/configure b/gdb/configure --- a/gdb/configure +++ b/gdb/configure -@@ -769,6 +769,11 @@ PKG_CONFIG +@@ -771,6 +771,11 @@ PKG_CONFIG HAVE_NATIVE_GCORE_TARGET TARGET_OBS subdirs @@ -721,7 +721,7 @@ GDB_DATADIR DEBUGDIR MAKEINFO_EXTRA_FLAGS -@@ -873,6 +878,7 @@ with_gdb_datadir +@@ -876,6 +881,7 @@ with_gdb_datadir with_relocated_sources with_auto_load_dir with_auto_load_safe_path @@ -729,7 +729,7 @@ enable_targets enable_64_bit_bfd enable_gdbmi -@@ -949,6 +955,8 @@ PKG_CONFIG_PATH +@@ -953,6 +959,8 @@ PKG_CONFIG_PATH PKG_CONFIG_LIBDIR DEBUGINFOD_CFLAGS DEBUGINFOD_LIBS @@ -738,7 +738,7 @@ YACC YFLAGS XMKMF' -@@ -1621,6 +1629,8 @@ Optional Packages: +@@ -1625,6 +1633,8 @@ Optional Packages: do not restrict auto-loaded files locations --with-debuginfod Enable debuginfo lookups with debuginfod (auto/yes/no) @@ -747,7 +747,7 @@ --with-libunwind-ia64 use libunwind frame unwinding for ia64 targets --with-curses use the curses library instead of the termcap library -@@ -1702,6 +1712,8 @@ Some influential environment variables: +@@ -1705,6 +1715,8 @@ Some influential environment variables: C compiler flags for DEBUGINFOD, overriding pkg-config DEBUGINFOD_LIBS linker flags for DEBUGINFOD, overriding pkg-config @@ -756,7 +756,7 @@ YACC The `Yet Another Compiler Compiler' implementation to use. Defaults to the first program found out of: `bison -y', `byacc', `yacc'. -@@ -6666,6 +6678,494 @@ _ACEOF +@@ -6616,6 +6628,494 @@ _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_safe_path" >&5 $as_echo "$with_auto_load_safe_path" >&6; } @@ -1148,7 +1148,7 @@ + + +if test $pkg_failed = yes; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then @@ -1166,7 +1166,7 @@ + + HAVE_LIBRPM=false +elif test $pkg_failed = untried; then -+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + HAVE_LIBRPM=false +else @@ -1254,7 +1254,7 @@ diff --git a/gdb/configure.ac b/gdb/configure.ac --- a/gdb/configure.ac +++ b/gdb/configure.ac -@@ -143,6 +143,199 @@ AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir, +@@ -153,6 +153,199 @@ AC_DEFINE_DIR(AUTO_LOAD_SAFE_PATH, escape_dir, [Directories safe to hold auto-loaded files.]) AC_MSG_RESULT([$with_auto_load_safe_path]) @@ -1450,14 +1450,14 @@ + fi + fi +fi -+ ++ AC_CONFIG_SUBDIRS(testsuite) # Check whether to support alternative target configurations diff --git a/gdb/event-top.c b/gdb/event-top.c --- a/gdb/event-top.c +++ b/gdb/event-top.c -@@ -42,6 +42,7 @@ +@@ -41,6 +41,7 @@ #include "gdbsupport/gdb_select.h" #include "gdbsupport/gdb-sigmask.h" #include "async-event.h" @@ -1465,7 +1465,7 @@ /* readline include files. */ #include "readline/readline.h" -@@ -364,6 +365,8 @@ display_gdb_prompt (const char *new_prompt) +@@ -363,6 +364,8 @@ display_gdb_prompt (const char *new_prompt) /* Reset the nesting depth used when trace-commands is set. */ reset_command_nest_depth (); @@ -1489,11 +1489,11 @@ diff --git a/gdb/symfile.h b/gdb/symfile.h --- a/gdb/symfile.h +++ b/gdb/symfile.h -@@ -560,6 +560,7 @@ extern void generic_load (const char *args, int from_tty); +@@ -342,6 +342,7 @@ extern void generic_load (const char *args, int from_tty); /* build-id support. */ extern struct bfd_build_id *build_id_addr_get (CORE_ADDR addr); extern void debug_print_missing (const char *binary, const char *debug); +extern void debug_flush_missing (void); #define BUILD_ID_MAIN_EXECUTABLE_FILENAME _("the main executable file") - /* From dwarf2read.c */ + /* From minidebug.c. */ ++++++ gdb-6.6-buildid-locate-solib-missing-ids.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.309340679 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.309340679 +0100 @@ -14,7 +14,7 @@ diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c -@@ -1340,14 +1340,27 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm, +@@ -1350,14 +1350,28 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm, } { @@ -38,13 +38,14 @@ + not do any build-id checking of the libraries. There may be missing + build-ids dumped in the core file and we would map all the libraries + to the only existing file loaded that time - the executable. */ -+ if (symfile_objfile != NULL -+ && (symfile_objfile->flags & OBJF_BUILD_ID_CORE_LOADED) != 0) ++ if (current_program_space->symfile_object_file != NULL ++ && (current_program_space->symfile_object_file->flags ++ & OBJF_BUILD_ID_CORE_LOADED) != 0) + build_id = build_id_addr_get (li->l_ld); if (build_id != NULL) { char *name, *build_id_filename; -@@ -1362,23 +1375,7 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm, +@@ -1372,23 +1386,7 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm, xfree (name); } else @@ -60,8 +61,8 @@ - instead) if the on-disk files no longer match the - running program version. */ - -- if (symfile_objfile != NULL -- && (symfile_objfile->flags +- if (current_program_space->symfile_object_file != NULL +- && (current_program_space->symfile_object_file->flags - & OBJF_BUILD_ID_CORE_LOADED) != 0) - newobj->so_name[0] = 0; - } ++++++ gdb-6.6-buildid-locate.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.317340684 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.317340684 +0100 @@ -9,7 +9,7 @@ diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h --- a/bfd/libbfd-in.h +++ b/bfd/libbfd-in.h -@@ -121,7 +121,7 @@ static inline char * +@@ -115,7 +115,7 @@ static inline char * bfd_strdup (const char *str) { size_t len = strlen (str) + 1; @@ -21,7 +21,7 @@ diff --git a/bfd/libbfd.h b/bfd/libbfd.h --- a/bfd/libbfd.h +++ b/bfd/libbfd.h -@@ -126,7 +126,7 @@ static inline char * +@@ -120,7 +120,7 @@ static inline char * bfd_strdup (const char *str) { size_t len = strlen (str) + 1; @@ -540,18 +540,18 @@ + /* There can be multiple build-id symlinks pointing to real files + with the same build-id (such as hard links). Some of the real + files may not be installed. */ ++ ++ string_appendf (link, ".%u", seqno); ++ } - /* We expect to be silent on the non-existing files. */ - gdb_bfd_ref_ptr debug_bfd = gdb_bfd_open (filename.get (), gnutarget); -+ string_appendf (link, ".%u", seqno); -+ } ++ ret_link = link; - if (debug_bfd == NULL) - { - if (separate_debug_file_debug) - printf_unfiltered (_(" no, unable to open.\n")); -+ ret_link = link; -+ + struct stat statbuf_trash; + + /* `access' automatically dereferences LINK. */ @@ -574,11 +574,11 @@ + + continue; + } - -- return {}; ++ + /* We expect to be silent on the non-existing files. */ + gdb_bfd_ref_ptr debug_bfd = gdb_bfd_open (filename.get (), gnutarget, -1); -+ + +- return {}; + if (debug_bfd == NULL) + { + if (separate_debug_file_debug) @@ -699,7 +699,7 @@ +{ + gdb_bfd_ref_ptr abfd; + char *result; -+ ++ + abfd = build_id_to_exec_bfd (build_id->size, build_id->data, link_return); + if (abfd == NULL) + return NULL; @@ -890,7 +890,7 @@ + char *build_id_filename_cstr = NULL; gdb_bfd_ref_ptr abfd (build_id_to_debug_bfd (build_id->size, - build_id->data)); -+ build_id->data, ++ build_id->data, + (!build_id_filename_return ? NULL : &build_id_filename_cstr))); + if (build_id_filename_return) + { @@ -906,7 +906,7 @@ /* Prevent looping on a stripped .debug file. */ if (abfd != NULL && filename_cmp (bfd_get_filename (abfd.get ()), -@@ -223,3 +897,21 @@ find_separate_debug_file_by_buildid (struct objfile *objfile) +@@ -223,3 +897,22 @@ find_separate_debug_file_by_buildid (struct objfile *objfile) return std::string (); } @@ -926,7 +926,8 @@ + show_build_id_verbose, + &setlist, &showlist); + -+ gdb::observers::executable_changed.attach (debug_print_executable_changed); ++ gdb::observers::executable_changed.attach (debug_print_executable_changed, ++ "build-id"); +} diff --git a/gdb/build-id.h b/gdb/build-id.h --- a/gdb/build-id.h @@ -950,7 +951,7 @@ extern gdb_bfd_ref_ptr build_id_to_debug_bfd (size_t build_id_len, - const bfd_byte *build_id); + const bfd_byte *build_id, -+ char **link_return); ++ char **link_return = NULL); + +extern char *build_id_to_filename (const struct bfd_build_id *build_id, + char **link_return); @@ -978,9 +979,9 @@ diff --git a/gdb/coffread.c b/gdb/coffread.c --- a/gdb/coffread.c +++ b/gdb/coffread.c -@@ -709,7 +709,8 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) +@@ -710,7 +710,8 @@ coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) /* Try to add separate debug file if no symbols table found. */ - if (!objfile_has_partial_symbols (objfile)) + if (!objfile->has_partial_symbols ()) { - std::string debugfile = find_separate_debug_file_by_buildid (objfile); + std::string debugfile = find_separate_debug_file_by_buildid (objfile, @@ -1002,7 +1003,7 @@ #include "inferior.h" #include "infrun.h" #include "symtab.h" -@@ -362,6 +366,8 @@ add_to_thread_list (bfd *abfd, asection *asect, void *reg_sect_arg) +@@ -356,6 +360,8 @@ add_to_thread_list (asection *asect, asection *reg_sect) switch_to_thread (thr); /* Yes, make it current. */ } @@ -1011,7 +1012,7 @@ /* Issue a message saying we have no core to debug, if FROM_TTY. */ static void -@@ -398,19 +404,25 @@ core_file_command (const char *filename, int from_tty) +@@ -392,19 +398,26 @@ core_file_command (const char *filename, int from_tty) static void locate_exec_from_corefile_build_id (bfd *abfd, int from_tty) { @@ -1031,16 +1032,17 @@ exec_file_attach (bfd_get_filename (execbfd.get ()), from_tty); symbol_file_add_main (bfd_get_filename (execbfd.get ()), symfile_add_flag (from_tty ? SYMFILE_VERBOSE : 0)); -+ if (symfile_objfile != NULL) -+ symfile_objfile->flags |= OBJF_BUILD_ID_CORE_LOADED; ++ if (current_program_space->symfile_object_file != NULL) ++ current_program_space->symfile_object_file->flags |= ++ OBJF_BUILD_ID_CORE_LOADED; } + else + debug_print_missing (BUILD_ID_MAIN_EXECUTABLE_FILENAME, build_id_filename); } /* See gdbcore.h. */ -@@ -1189,4 +1201,11 @@ _initialize_corelow () - maintenance_print_core_file_backed_mappings, +@@ -1209,4 +1222,11 @@ _initialize_corelow () + maintenance_print_core_file_backed_mappings, _("Print core file's file-backed mappings."), &maintenanceprintlist); + @@ -1054,7 +1056,7 @@ diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo -@@ -21074,6 +21074,27 @@ information files. +@@ -21415,6 +21415,27 @@ information files. @end table @@ -1107,16 +1109,7 @@ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c -@@ -2218,7 +2218,7 @@ dwarf2_get_dwz_file (dwarf2_per_bfd *per_bfd) - } - - if (dwz_bfd == NULL) -- dwz_bfd = build_id_to_debug_bfd (buildid_len, buildid); -+ dwz_bfd = build_id_to_debug_bfd (buildid_len, buildid, NULL); - - if (dwz_bfd == nullptr) - { -@@ -5980,7 +5980,7 @@ get_gdb_index_contents_from_section (objfile *obj, T *section_owner) +@@ -5447,7 +5447,7 @@ get_gdb_index_contents_from_section (objfile *obj, T *section_owner) static gdb::array_view<const gdb_byte> get_gdb_index_contents_from_cache (objfile *obj, dwarf2_per_bfd *dwarf2_per_bfd) { @@ -1125,7 +1118,7 @@ if (build_id == nullptr) return {}; -@@ -5993,7 +5993,7 @@ get_gdb_index_contents_from_cache (objfile *obj, dwarf2_per_bfd *dwarf2_per_bfd) +@@ -5460,7 +5460,7 @@ get_gdb_index_contents_from_cache (objfile *obj, dwarf2_per_bfd *dwarf2_per_bfd) static gdb::array_view<const gdb_byte> get_gdb_index_contents_from_cache_dwz (objfile *obj, dwz_file *dwz) { @@ -1137,7 +1130,7 @@ diff --git a/gdb/elfread.c b/gdb/elfread.c --- a/gdb/elfread.c +++ b/gdb/elfread.c -@@ -1298,7 +1298,9 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) +@@ -1272,7 +1272,9 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) && objfile->separate_debug_objfile == NULL && objfile->separate_debug_objfile_backlink == NULL) { @@ -1148,7 +1141,7 @@ if (debugfile.empty ()) debugfile = find_separate_debug_file_by_debuglink (objfile); -@@ -1313,7 +1315,7 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) +@@ -1287,7 +1289,7 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) else { has_dwarf2 = false; @@ -1157,7 +1150,7 @@ if (build_id != nullptr) { -@@ -1338,6 +1340,10 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) +@@ -1312,6 +1314,10 @@ elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags) has_dwarf2 = true; } } @@ -1171,16 +1164,16 @@ diff --git a/gdb/exec.c b/gdb/exec.c --- a/gdb/exec.c +++ b/gdb/exec.c -@@ -264,7 +264,7 @@ validate_exec_file (int from_tty) - reopen_exec_file (); +@@ -237,7 +237,7 @@ validate_exec_file (int from_tty) current_exec_file = get_exec_file (0); -- const bfd_build_id *exec_file_build_id = build_id_bfd_get (exec_bfd); -+ const bfd_build_id *exec_file_build_id = build_id_bfd_shdr_get (exec_bfd); + const bfd_build_id *exec_file_build_id +- = build_id_bfd_get (current_program_space->exec_bfd ()); ++ = build_id_bfd_shdr_get (current_program_space->exec_bfd ()); if (exec_file_build_id != nullptr) { /* Prepend the target prefix, to force gdb_bfd_open to open the -@@ -277,7 +277,7 @@ validate_exec_file (int from_tty) +@@ -250,7 +250,7 @@ validate_exec_file (int from_tty) if (abfd != nullptr) { const bfd_build_id *target_exec_file_build_id @@ -1192,7 +1185,7 @@ diff --git a/gdb/objfiles.h b/gdb/objfiles.h --- a/gdb/objfiles.h +++ b/gdb/objfiles.h -@@ -714,6 +714,10 @@ struct objfile +@@ -812,6 +812,10 @@ struct objfile bool skip_jit_symbol_lookup = false; }; @@ -1235,7 +1228,7 @@ static struct link_map_offsets *svr4_fetch_link_map_offsets (void); static int svr4_have_link_map_offsets (void); -@@ -1338,9 +1339,51 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm, +@@ -1348,9 +1349,51 @@ svr4_read_so_list (svr4_info *info, CORE_ADDR lm, CORE_ADDR prev_lm, continue; } @@ -1277,8 +1270,8 @@ + instead) if the on-disk files no longer match the + running program version. */ + -+ if (symfile_objfile != NULL -+ && (symfile_objfile->flags ++ if (current_program_space->symfile_object_file != NULL ++ && (current_program_space->symfile_object_file->flags + & OBJF_BUILD_ID_CORE_LOADED) != 0) + newobj->so_name[0] = 0; + } @@ -1293,7 +1286,7 @@ diff --git a/gdb/source.c b/gdb/source.c --- a/gdb/source.c +++ b/gdb/source.c -@@ -1165,7 +1165,7 @@ open_source_file (struct symtab *s) +@@ -1178,7 +1178,7 @@ open_source_file (struct symtab *s) srcpath += s->filename; } @@ -1305,9 +1298,9 @@ diff --git a/gdb/symfile.h b/gdb/symfile.h --- a/gdb/symfile.h +++ b/gdb/symfile.h -@@ -550,12 +550,18 @@ void expand_symtabs_matching - void map_symbol_filenames (symbol_filename_ftype *fun, void *data, - int need_fullname); +@@ -332,12 +332,18 @@ bool expand_symtabs_matching + void map_symbol_filenames (gdb::function_view<symbol_filename_ftype> fun, + bool need_fullname); + /* Target-agnostic function to load the sections of an executable into memory. @@ -1321,9 +1314,9 @@ +extern void debug_print_missing (const char *binary, const char *debug); +#define BUILD_ID_MAIN_EXECUTABLE_FILENAME _("the main executable file") + - /* From dwarf2read.c */ + /* From minidebug.c. */ - /* Names for a dwarf2 debugging section. The field NORMAL is the normal + extern gdb_bfd_ref_ptr find_separate_debug_file_in_section (struct objfile *); diff --git a/gdb/testsuite/gdb.base/corefile.exp b/gdb/testsuite/gdb.base/corefile.exp --- a/gdb/testsuite/gdb.base/corefile.exp +++ b/gdb/testsuite/gdb.base/corefile.exp @@ -1361,6 +1354,19 @@ + gdb_test "info files" "Local exec file:\r\n\[ \t\]*`[string_to_regexp $debugdir/$buildid]', file type .*" + pass $wholetest +} +diff --git a/gdb/testsuite/gdb.base/gdbinit-history.exp b/gdb/testsuite/gdb.base/gdbinit-history.exp +--- a/gdb/testsuite/gdb.base/gdbinit-history.exp ++++ b/gdb/testsuite/gdb.base/gdbinit-history.exp +@@ -185,7 +185,8 @@ proc test_empty_history_filename { } { + global env + global gdb_prompt + +- set common_history [list "set height 0" "set width 0"] ++ set common_history [list "set height 0" "set width 0" \ ++ "set build-id-verbose 0"] + + set test_dir [standard_output_file history_test] + remote_exec host "mkdir -p $test_dir" diff --git a/gdb/testsuite/gdb.base/new-ui-pending-input.exp b/gdb/testsuite/gdb.base/new-ui-pending-input.exp --- a/gdb/testsuite/gdb.base/new-ui-pending-input.exp +++ b/gdb/testsuite/gdb.base/new-ui-pending-input.exp @@ -1375,7 +1381,7 @@ diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp -@@ -2011,6 +2011,17 @@ proc default_gdb_start { } { +@@ -2130,6 +2130,17 @@ proc default_gdb_start { } { } } @@ -1396,7 +1402,7 @@ diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp -@@ -308,6 +308,16 @@ proc default_mi_gdb_start { args } { +@@ -322,6 +322,16 @@ proc default_mi_gdb_start { args } { warning "Couldn't set the width to 0." } } ++++++ gdb-6.6-bz229517-gcore-without-terminal.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.325340688 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.329340691 +0100 @@ -79,15 +79,15 @@ +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu ++++++ gdb-6.6-bz230000-power6-disassembly-test.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.337340696 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.337340696 +0100 @@ -31,7 +31,7 @@ +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Test PowerPC Power6 instructions disassembly. + ++++++ gdb-6.6-bz237572-ppc-atomic-sequence-test.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.345340700 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.345340700 +0100 @@ -29,7 +29,7 @@ + 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, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, @@ -202,12 +202,12 @@ +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ ++++++ gdb-6.8-bz442765-threaded-exec-test.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.357340707 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.357340707 +0100 @@ -175,7 +175,7 @@ +gdb_load ${binfile_nothreads} -gdb_run_cmd -+gdb_run_cmd ${binfile_nothreads} ${binfile_threads} 0 ++gdb_run_cmd [list ${binfile_nothreads} ${binfile_threads} 0] gdb_test_multiple {} "Program exited" { -re "\r\n\\\[Inferior .* exited normally\\\]\r\n$gdb_prompt $" { ++++++ gdb-add-index.sh-fix-bashism.patch ++++++ [gdb-add-index.sh] Fix bashism --- gdb/contrib/gdb-add-index.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gdb/contrib/gdb-add-index.sh b/gdb/contrib/gdb-add-index.sh index 734110caa3b..00d3ae8b0ae 100755 --- a/gdb/contrib/gdb-add-index.sh +++ b/gdb/contrib/gdb-add-index.sh @@ -38,7 +38,9 @@ fi file="$1" if test -L "$file"; then - if ! command -v readlink >/dev/null 2>&1; then + target=$(readlink "$file") + st=$? + if [ $st -eq 127 ]; then echo "$myname: 'readlink' missing. Failed to follow symlink $1." 1>&2 exit 1 fi ++++++ gdb-build-add-cxx_dialect-to-cxx.patch ++++++ [gdb/build] Add CXX_DIALECT to CXX Say we use a gcc version that (while supporting c++11) does not support c++11 by default, and needs an -std setting to enable it. If gdb would use the default AX_CXX_COMPILE_STDCXX from autoconf-archive, then we'd have: ... CXX="g++ -std=gnu++11" ... That mechanism however has the following problem (quoting from commit 0bcda685399): ... the top level Makefile passes CXX down to subdirs, and that overrides whatever gdb/Makefile may set CXX to. The result would be that a make invocation from the build/gdb/ directory would use "g++ -std=gnu++11" as expected, while a make invocation at the top level would not. ... Commit 0bcda685399 fixes this by using a custom AX_CXX_COMPILE_STDCXX which does: ... CXX=g++ CXX_DIALECT=-std=gnu++11 ... The problem reported in PR28318 is that using the custom instead of the default AX_CXX_COMPILE_STDCXX makes the configure test for std::thread support fail. We could simply add $CXX_DIALECT to the test for std::thread support, but that would have to be repeated for each added c++ support test. Instead, fix this by doing: ... CXX="g++ -std=gnu++11" CXX_DIALECT=-std=gnu++11 ... This is somewhat awkward, since it results in -std=gnu++11 occuring twice in some situations: ... $ touch src/gdb/dwarf2/read.c $ ( cd build/gdb; make V=1 dwarf2/read.o ) g++-4.8 -std=gnu++11 -x c++ -std=gnu++11 ... ... However, both settings are needed: - the switch in CXX for the std::thread tests (and other tests) - the switch in CXX_DIALECT so it can be appended in Makefiles, to counteract the fact that the top-level Makefile overrides CXX The code added in gdb/ax_cxx_compile_stdcxx.m4 is copied from the default AX_CXX_COMPILE_STDCXX from autoconf-archive. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28318 gdb/ChangeLog: 2021-10-04 Tom de Vries <tdevries@suse.de> PR build/28318 * ax_cxx_compile_stdcxx.m4: Add CXX_DIALECT to CXX. * configure: Regenerate. gdbserver/ChangeLog: 2021-10-04 Tom de Vries <tdevries@suse.de> PR build/28318 * configure: Regenerate. gdbsupport/ChangeLog: 2021-10-04 Tom de Vries <tdevries@suse.de> PR build/28318 * configure: Regenerate. --- gdb/ax_cxx_compile_stdcxx.m4 | 8 ++++++++ gdb/configure | 8 ++++++++ gdbserver/configure | 8 ++++++++ gdbsupport/configure | 8 ++++++++ 7 files changed, 48 insertions(+) diff --git a/gdb/ax_cxx_compile_stdcxx.m4 b/gdb/ax_cxx_compile_stdcxx.m4 index 413755a2e88..29d8e10bcc4 100644 --- a/gdb/ax_cxx_compile_stdcxx.m4 +++ b/gdb/ax_cxx_compile_stdcxx.m4 @@ -94,6 +94,10 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl CXX="$ac_save_CXX"]) if eval test x\$$cachevar = xyes; then CXX_DIALECT="$switch" + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi ac_success=yes break fi @@ -118,6 +122,10 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl CXX="$ac_save_CXX"]) if eval test x\$$cachevar = xyes; then CXX_DIALECT="$switch" + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi ac_success=yes break fi diff --git a/gdb/configure b/gdb/configure index 5d89635c043..6d4c2b17ed2 100755 --- a/gdb/configure +++ b/gdb/configure @@ -5841,6 +5841,10 @@ eval ac_res=\$$cachevar $as_echo "$ac_res" >&6; } if eval test x\$$cachevar = xyes; then CXX_DIALECT="$switch" + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi ac_success=yes break fi @@ -6160,6 +6164,10 @@ eval ac_res=\$$cachevar $as_echo "$ac_res" >&6; } if eval test x\$$cachevar = xyes; then CXX_DIALECT="$switch" + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi ac_success=yes break fi diff --git a/gdbserver/configure b/gdbserver/configure index b227167e270..f05c1a9b976 100755 --- a/gdbserver/configure +++ b/gdbserver/configure @@ -5625,6 +5625,10 @@ eval ac_res=\$$cachevar $as_echo "$ac_res" >&6; } if eval test x\$$cachevar = xyes; then CXX_DIALECT="$switch" + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi ac_success=yes break fi @@ -5944,6 +5948,10 @@ eval ac_res=\$$cachevar $as_echo "$ac_res" >&6; } if eval test x\$$cachevar = xyes; then CXX_DIALECT="$switch" + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi ac_success=yes break fi diff --git a/gdbsupport/configure b/gdbsupport/configure index a9dd02c5b72..ae6047865ae 100755 --- a/gdbsupport/configure +++ b/gdbsupport/configure @@ -6520,6 +6520,10 @@ eval ac_res=\$$cachevar $as_echo "$ac_res" >&6; } if eval test x\$$cachevar = xyes; then CXX_DIALECT="$switch" + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi ac_success=yes break fi @@ -6839,6 +6843,10 @@ eval ac_res=\$$cachevar $as_echo "$ac_res" >&6; } if eval test x\$$cachevar = xyes; then CXX_DIALECT="$switch" + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi ac_success=yes break fi ++++++ gdb-build-make-c-exp.y-work-with-bison-3.8.patch ++++++ Make c-exp.y work with Bison 3.8+ When using Bison 3.8, we get this error: ../../gdb/c-exp.y:3455:1: error: ���void c_print_token(FILE*, int, YYSTYPE)��� defined but not used [-Werror=unused-function] That's because bison 3.8 removed YYPRINT support: https://savannah.gnu.org/forum/forum.php?forum_id=10047 Accordingly, this patch only defines that function for Bison < 3.8. --- gdb/c-exp.y | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 93b10f05b7d..9b4b88accfe 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -167,7 +167,7 @@ static struct stoken operator_stoken (const char *); static struct stoken typename_stoken (const char *); static void check_parameter_typelist (std::vector<struct type *> *); -#ifdef YYBISON +#if defined(YYBISON) && YYBISON < 30800 static void c_print_token (FILE *file, int type, YYSTYPE value); #define YYPRINT(FILE, TYPE, VALUE) c_print_token (FILE, TYPE, VALUE) #endif @@ -3446,7 +3446,8 @@ c_parse (struct parser_state *par_state) return result; } -#ifdef YYBISON +#if defined(YYBISON) && YYBISON < 30800 + /* This is called via the YYPRINT macro when parser debugging is enabled. It prints a token's value. */ ++++++ gdb-bz601887-dwarf4-rh-test.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.389340725 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.389340725 +0100 @@ -233,11 +233,11 @@ + && ![istarget *-*-openbsd*] + && ![istarget arm-*-eabi*] + && ![istarget powerpc-*-eabi*]} { -+ return 0 ++ return 0 +} + +if {![istarget x86_64-*]} { -+ return 0 ++ return 0 +} + +set testfile "rh-dwarf4-x86_64" ++++++ gdb-bz634108-solib_address.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.397340730 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.401340733 +0100 @@ -38,4 +38,4 @@ +# Skip all tests if Python scripting is not enabled. +if { [skip_python_tests] } { continue } + -+gdb_test "python print gdb.solib_name(-1)" "None" "gdb.solib_name exists" ++gdb_test "python print (gdb.solib_name(-1))" "None" "gdb.solib_name exists" ++++++ gdb-ccache-workaround.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.409340737 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.409340737 +0100 @@ -9,8 +9,8 @@ diff --git a/gdb/testsuite/gdb.base/macscp.exp b/gdb/testsuite/gdb.base/macscp.exp --- a/gdb/testsuite/gdb.base/macscp.exp +++ b/gdb/testsuite/gdb.base/macscp.exp -@@ -25,6 +25,14 @@ if { [test_compiler_info "gcc-*"] || [test_compiler_info "clang-*"] } { - lappend options additional_flags=-g3 +@@ -27,6 +27,14 @@ if { [test_compiler_info "gcc-*"] } { + lappend options additional_flags=-fdebug-macro } +# Workaround ccache making lineno non-zero for command-line definitions. ++++++ gdb-container-rh-pkg.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.417340741 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.417340741 +0100 @@ -9,7 +9,7 @@ diff --git a/gdb/remote.c b/gdb/remote.c --- a/gdb/remote.c +++ b/gdb/remote.c -@@ -14031,7 +14031,17 @@ remote_target::pid_to_exec_file (int pid) +@@ -14290,7 +14290,17 @@ remote_target::pid_to_exec_file (int pid) char *annex = NULL; if (packet_support (PACKET_qXfer_exec_file) != PACKET_ENABLE) ++++++ gdb-fedora-libncursesw.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.429340748 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.429340748 +0100 @@ -12,7 +12,7 @@ diff --git a/gdb/configure b/gdb/configure --- a/gdb/configure +++ b/gdb/configure -@@ -9649,6 +9649,7 @@ if test x"$prefer_curses" = xyes; then +@@ -9544,6 +9544,7 @@ if test x"$prefer_curses" = xyes; then # search /usr/local/include, if ncurses is installed in /usr/local. A # default installation of ncurses on alpha*-dec-osf* will lead to such # a situation. @@ -20,7 +20,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing waddstr" >&5 $as_echo_n "checking for library containing waddstr... " >&6; } if ${ac_cv_search_waddstr+:} false; then : -@@ -9673,7 +9674,7 @@ return waddstr (); +@@ -9568,7 +9569,7 @@ return waddstr (); return 0; } _ACEOF @@ -29,7 +29,7 @@ if test -z "$ac_lib"; then ac_res="none required" else -@@ -9747,6 +9748,7 @@ case $host_os in +@@ -9642,6 +9643,7 @@ case $host_os in esac # These are the libraries checked by Readline. @@ -37,7 +37,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tgetent" >&5 $as_echo_n "checking for library containing tgetent... " >&6; } if ${ac_cv_search_tgetent+:} false; then : -@@ -9771,7 +9773,7 @@ return tgetent (); +@@ -9666,7 +9668,7 @@ return tgetent (); return 0; } _ACEOF @@ -49,7 +49,7 @@ diff --git a/gdb/configure.ac b/gdb/configure.ac --- a/gdb/configure.ac +++ b/gdb/configure.ac -@@ -712,7 +712,8 @@ if test x"$prefer_curses" = xyes; then +@@ -736,7 +736,8 @@ if test x"$prefer_curses" = xyes; then # search /usr/local/include, if ncurses is installed in /usr/local. A # default installation of ncurses on alpha*-dec-osf* will lead to such # a situation. @@ -59,7 +59,7 @@ if test "$ac_cv_search_waddstr" != no; then curses_found=yes -@@ -754,7 +755,8 @@ case $host_os in +@@ -778,7 +779,8 @@ case $host_os in esac # These are the libraries checked by Readline. ++++++ gdb-fix-selftest-fails-with-gdb-build-with-O2-flto.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.437340753 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.437340753 +0100 @@ -1,11 +1,5 @@ Fix selftest FAILs with gdb build with -O2 -flto ---- - gdb/complaints.h | 5 +++-- - gdb/main.c | 5 +++++ - gdb/testsuite/gdb.gdb/selftest.exp | 2 +- - 3 files changed, 9 insertions(+), 3 deletions(-) - diff --git a/gdb/complaints.h b/gdb/complaints.h index 6ad056d257..cac09ff573 100644 --- a/gdb/complaints.h @@ -39,16 +33,3 @@ static void captured_main (void *data) { -diff --git a/gdb/testsuite/gdb.gdb/selftest.exp b/gdb/testsuite/gdb.gdb/selftest.exp -index 43043e58ea..992d79f5cf 100644 ---- a/gdb/testsuite/gdb.gdb/selftest.exp -+++ b/gdb/testsuite/gdb.gdb/selftest.exp -@@ -143,7 +143,7 @@ proc test_with_self { } { - setup_xfail "i*86-pc-linuxaout-gnu" - set description "backtrace through signal handler" - gdb_test_multiple "backtrace" "$description" { -- -re "#0.*(read|poll).*in main \\(.*\\) at .*gdb\\.c.*$gdb_prompt $" { -+ -re "#0.*(read|poll).* main \\(.*\\) at .*gdb\\.c.*$gdb_prompt $" { - pass "$description" - } - } ++++++ gdb-fortran-frame-string.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.449340759 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.449340759 +0100 @@ -39,15 +39,15 @@ +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 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, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +standard_testfile .f90 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } { @@ -67,7 +67,7 @@ + +# Fix rejected upstream: +# https://sourceware.org/ml/gdb-patches/2014-07/msg00768.html -+setup_kfail "rejected" *-*-* ++setup_kfail "rejected" *-*-* +gdb_test "frame" { \(s='foo', .*} diff --git a/gdb/testsuite/gdb.fortran/fortran-frame-string.f90 b/gdb/testsuite/gdb.fortran/fortran-frame-string.f90 new file mode 100644 ++++++ gdb-gcore-bash.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.457340764 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.461340767 +0100 @@ -6,5 +6,5 @@ -#!/usr/bin/env bash +#!/bin/bash - # Copyright (C) 2003-2020 Free Software Foundation, Inc. + # Copyright (C) 2003-2021 Free Software Foundation, Inc. ++++++ gdb-glibc-strstr-workaround.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.469340771 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.469340771 +0100 @@ -10,7 +10,7 @@ new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/gnu-ifunc-strstr-workaround.exp -@@ -0,0 +1,115 @@ +@@ -0,0 +1,119 @@ +# Copyright (C) 2012 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify @@ -56,6 +56,10 @@ + untested "$test (no DWARF)" + return 0 + } ++ -re "type = <unknown return type> \\(\\)\r\n$gdb_prompt $" { ++ untested "$test (no DWARF)" ++ return 0 ++ } +} + +set addr "" @@ -124,5 +128,5 @@ + } +} + -+gdb_test {print strstr("abc","b")} { = 0x[0-9a-f]+ "bc"} -+gdb_test {print strstr("def","e")} { = 0x[0-9a-f]+ "ef"} ++gdb_test {print (char *)strstr("abc","b")} { = 0x[0-9a-f]+ "bc"} ++gdb_test {print (char *)strstr("def","e")} { = 0x[0-9a-f]+ "ef"} ++++++ gdb-lineno-makeup-test.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.485340780 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.489340782 +0100 @@ -64,10 +64,10 @@ + +/* DW_AT_low_pc-DW_AT_high_pc should cover the function without line number + information (.debug_line) so we cannot use an external object file. -+ ++ + It must not be just a label as it would alias on the next function even for + correct GDB. Therefore some stub data must be placed there. -+ ++ + We need to provide a real stub function body as at least s390 + (s390_analyze_prologue) would skip the whole body till reaching `main'. */ + ++++++ gdb-linux_perf-bundle.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.497340787 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.497340787 +0100 @@ -213,7 +213,7 @@ diff --git a/gdbsupport/common.m4 b/gdbsupport/common.m4 --- a/gdbsupport/common.m4 +++ b/gdbsupport/common.m4 -@@ -145,7 +145,7 @@ AC_DEFUN([GDB_AC_COMMON], [ +@@ -135,7 +135,7 @@ AC_DEFUN([GDB_AC_COMMON], [ AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ #include <linux/perf_event.h> #ifndef PERF_ATTR_SIZE_VER5 ++++++ gdb-physname-pr11734-test.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.517340799 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.517340799 +0100 @@ -12,7 +12,7 @@ new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.cp/pr11734-1.cc -@@ -0,0 +1,30 @@ +@@ -0,0 +1,29 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 Free Software Foundation, Inc. @@ -42,12 +42,11 @@ + p->foo (); + return 0; +} -+ diff --git a/gdb/testsuite/gdb.cp/pr11734-2.cc b/gdb/testsuite/gdb.cp/pr11734-2.cc new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.cp/pr11734-2.cc -@@ -0,0 +1,27 @@ +@@ -0,0 +1,26 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 Free Software Foundation, Inc. @@ -74,12 +73,11 @@ +pr11734::foo(void) +{ +} -+ diff --git a/gdb/testsuite/gdb.cp/pr11734-3.cc b/gdb/testsuite/gdb.cp/pr11734-3.cc new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.cp/pr11734-3.cc -@@ -0,0 +1,27 @@ +@@ -0,0 +1,26 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 Free Software Foundation, Inc. @@ -106,12 +104,11 @@ +pr11734::foo (int a) +{ +} -+ diff --git a/gdb/testsuite/gdb.cp/pr11734-4.cc b/gdb/testsuite/gdb.cp/pr11734-4.cc new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.cp/pr11734-4.cc -@@ -0,0 +1,27 @@ +@@ -0,0 +1,26 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 Free Software Foundation, Inc. @@ -138,7 +135,6 @@ +pr11734::foo (char *a) +{ +} -+ diff --git a/gdb/testsuite/gdb.cp/pr11734.exp b/gdb/testsuite/gdb.cp/pr11734.exp new file mode 100644 --- /dev/null @@ -203,7 +199,7 @@ new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.cp/pr11734.h -@@ -0,0 +1,28 @@ +@@ -0,0 +1,27 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 Free Software Foundation, Inc. @@ -231,4 +227,3 @@ + void foo (int); + void foo (char *); +}; -+ ++++++ gdb-ppc-power7-test.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.529340805 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.529340805 +0100 @@ -25,7 +25,7 @@ +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Test PowerPC Power7 instructions disassembly. + @@ -48,7 +48,7 @@ +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${objfile} -+ ++ + +# Disassemble the function. + ++++++ gdb-python-finishbreakpoint-update.patch ++++++ [gdb/python] FinishBreakPoint update I. Consider the python gdb.FinishBreakpoint class, an extension of the gdb.Breakpoint class. It sets a temporary breakpoint on the return address of a frame. This type of breakpoints is thread-specific. II. If the FinishBreakpoint is hit, it is deleted, and the method return_value can be used to get the value returned by the function. Let's demonstrate this: ... $ cat -n test.c 1 int foo (int a) { return a + 2; } 2 int main () { return foo (1); } $ gcc -g test.c $ gdb -q -batch a.out -ex "set trace-commands on" -ex "tbreak foo" -ex run \ -ex "python bp = gdb.FinishBreakpoint()" -ex "info breakpoints" \ -ex continue -ex "info breakpoints" -ex "python print (bp.return_value)" +tbreak foo Temporary breakpoint 1 at 0x40049e: file test.c, line 1. +run Temporary breakpoint 1, foo (a=1) at test.c:1 1 int foo (int a) { return a + 2; } +python bp = gdb.FinishBreakpoint() Temporary breakpoint 2 at 0x4004b4: file test.c, line 2. +info breakpoints Num Type Disp Enb Address What 2 breakpoint del y 0x004004b4 in main at test.c:2 thread 1 stop only in thread 1 +continue Temporary breakpoint 2, 0x004004b4 in main () at test.c:2 2 int main () { return foo (1); } +info breakpoints No breakpoints or watchpoints. +python print (bp.return_value) 3 ... III. Another possibility is that the FinishBreakpoint is not hit, because the function did not terminate, f.i. because of longjmp, C++ exceptions, or GDB return command. Let's demonstrate this, using C++ exceptions: ... $ cat -n test.c 1 int foo (int a) { throw 1; return a + 2; } 2 int main () { 3 try { return foo (1); } catch (...) {}; 4 return 1; 5 } $ g++ -g test.c $ gdb -q -batch a.out -ex "set trace-commands on" -ex "tbreak foo" -ex run \ -ex "python bp = gdb.FinishBreakpoint()" -ex "info breakpoints" \ -ex continue -ex "info breakpoints" -ex "python print (bp.return_value)" +tbreak foo Temporary breakpoint 1 at 0x400712: file test.c, line 1. +run Temporary breakpoint 1, foo (a=1) at test.c:1 1 int foo (int a) { throw 1; return a + 2; } +python bp = gdb.FinishBreakpoint() Temporary breakpoint 2 at 0x400742: file test.c, line 3. +info breakpoints Num Type Disp Enb Address What 2 breakpoint del y 0x00400742 in main() at test.c:3 thread 1 stop only in thread 1 +continue [Inferior 1 (process 25269) exited with code 01] Thread-specific breakpoint 2 deleted - thread 1 no longer in the thread list. +info breakpoints No breakpoints or watchpoints. +python print (bp.return_value) None ... Indeed, we do not hit the FinishBreakpoint. Instead, it's deleted when the thread disappears, like any other thread-specific breakpoint. I think this is a bug: the deletion is meant to be handled by FinishBreakpoint itself. IV. Fix aforementioned bug by: - adding an observer of the thread_exit event in FinishBreakpoint - making sure that this observer is called before the remove_threaded_breakpoints observer of that same event. This changes the behaviour to: ... +continue [Inferior 1 (process 30256) exited with code 01] +info breakpoints No breakpoints or watchpoints. +python print (bp.return_value) None ... V. An out_of_scope callback can be defined to make this more verbose: ... $ cat fbp.py class FBP(gdb.FinishBreakpoint): def __init__(self): gdb.FinishBreakpoint.__init__(self) def out_of_scope(self): try: frame = gdb.selected_frame () sal = frame.find_sal () print ("out_of_scope triggered at %s:%s" % (sal.symtab.fullname(), sal.line)) except gdb.error as e: print ("out_of_scope triggered at thread/inferior exit") ... and using that gets us: ... +continue [Inferior 1 (process 30742) exited with code 01] out_of_scope triggered at thread/inferior exit +info breakpoints No breakpoints or watchpoints. +python print (bp.return_value) None ... VI. This out_of_scope event can be triggered earlier than inferior/thread exit. Let's demonstrate this: ... $ cat -n test.c 1 int bar (int a) { throw 1; return a + 2; } 2 int foo (int a) { 3 int res = a; 4 try 5 { 6 res += bar (1); 7 } 8 catch (...) 9 { 10 } 11 return res; 12 } 13 int main () { 14 int res = 0; 15 res += foo (1); 16 res += 2; 17 return res * 2; 18 } $ g++ -g test.c $ gdb -q -batch -ex "source fbp.py" a.out -ex "set trace-commands on" \ -ex "tbreak bar" -ex run -ex "python bp = FBP()" -ex "info breakpoints" \ -ex "tbreak 16" -ex continue -ex "info breakpoints" \ -ex "python print (bp.return_value)" +tbreak bar Temporary breakpoint 1 at 0x400712: file test.c, line 1. +run Temporary breakpoint 1, bar (a=1) at test.c:1 1 int bar (int a) { throw 1; return a + 2; } +python bp = FBP() Temporary breakpoint 2 at 0x40074f: file test.c, line 6. +info breakpoints Num Type Disp Enb Address What 2 breakpoint del y 0x0040074f in foo(int) at test.c:6 thread 1 stop only in thread 1 +tbreak 16 Temporary breakpoint 3 at 0x400784: file test.c, line 16. +continue Temporary breakpoint 3, main () at test.c:16 16 res += 2; out_of_scope triggered at /home/vries/gdb_versions/devel/test.c:16 +info breakpoints No breakpoints or watchpoints. +python print (bp.return_value) None ... Note that the out_of_scope event triggers at the breakpoint we set at test.c:16. If we'd set that breakpoint at line 17, the out_of_scope event would trigger at line 17 instead. Also note that it can't be triggered earlier, say by setting the breakpoint in foo at line 11. We would get instead "out_of_scope triggered at thread/inferior exit". VII. Now consider a reduced version of src/gdb/testsuite/gdb.python/py-finish-breakpoint2.cc: ... $ cat -n test.c 1 #include <iostream> 2 3 void 4 throw_exception_1 (int e) 5 { 6 throw new int (e); 7 } 8 9 int 10 main (void) 11 { 12 int i; 13 try 14 { 15 throw_exception_1 (10); 16 } 17 catch (const int *e) 18 { 19 std::cerr << "Exception #" << *e << std::endl; 20 } 21 i += 1; 22 23 return i; 24 } $ g++ -g test.c ... Now let's try to see if the FinishBreakPoint triggers: ... $ gdb -q -batch -ex "source fbp.py" a.out -ex "set trace-commands on" \ -ex "tbreak throw_exception_1" -ex run -ex "python bp = FBP()" \ -ex "info breakpoints" -ex continue -ex "info breakpoints" \ -ex "python print (bp.return_value)" +tbreak throw_exception_1 Temporary breakpoint 1 at 0x400bd5: file test.c, line 6. +run Temporary breakpoint 1, throw_exception_1 (e=10) at test.c:6 6 throw new int (e); +python bp = FBP() Temporary breakpoint 2 at 0x400c2f: file test.c, line 21. +info breakpoints Num Type Disp Enb Address What 2 breakpoint del y 0x00400c2f in main() at test.c:21 thread 1 stop only in thread 1 +continue Exception #10 Temporary breakpoint 2, main () at test.c:21 21 i += 1; +info breakpoints No breakpoints or watchpoints. +python print (bp.return_value) None ... Surprisingly, it did. The explanation is that FinishBreakPoint is really a frame-return-address breakpoint, and that address happens to be at line 21, which is still executed after the throw in throw_exception_1. Interestingly, with -m32 the FinishBreakPoint doesn't trigger, because the frame-return-address happens to be an instruction which is part of line 15. VIII. In conclusion, the FinishBreakpoint is a frame-return-address breakpoint. After being set, either: - it triggers, or - an out-of-scope event will be generated. If an out-of-scope event is generated, it will be due to incomplete function termination. OTOH, incomplete function termination does not guarantee an out-of-scope event instead of hitting the breakpoint. IX. The documentation states that 'A finish breakpoint is a temporary breakpoint set at the return address of a frame, based on the finish command'. It's indeed somewhat similar to the finish command, at least in the sense that both may stop at the frame-return-address. But the finish command can accurately detect function termination. And the finish command will stop at any other address that is the first address not in the original function. The documentation needs updating to accurately describe what it does. X. A better implementation of a finish breakpoint would be one that borrows from the finish command implementation. That one: - installs a thread_fsm, and - continues A finish breakpoint would do the same minus the continue, but it requires gdb to handle multiple thread_fsms at a time (because other commands may wish to install their own thread_fsm), which AFAICT is not supported yet. XI. This patch repairs a minor part of the functionality, and updates documentation and test-cases to match actual behaviour. The question remains how useful the functionality is, as it is now ( see f.i. discussion at https://sourceware.org/pipermail/gdb-patches/2021-January/175290.html ). Perhaps it would be better to deprecate this in a follow-up patch in some form or another, say by disabling it by default and introducing a maintenance command that switches it on, with the warning that it is deprecated. Tested on x86_64-linux with native and target board unix/-m32, by rebuilding and running the test-cases: - gdb.python/py-finish-breakpoint.exp - gdb.python/py-finish-breakpoint2.exp --- gdb/breakpoint.c | 10 ++++++++++ gdb/doc/python.texi | 6 ++++-- gdb/python/py-finishbreakpoint.c | 21 +++++++++++++++++++++ gdb/testsuite/gdb.python/py-finish-breakpoint2.exp | 16 +++++++++++++--- 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index dbbea6b8bff..64a9a3d394f 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -15452,6 +15452,10 @@ initialize_breakpoint_ops (void) static struct cmd_list_element *enablebreaklist = NULL; +#if HAVE_PYTHON +extern gdb::observers::token bpfinishpy_handle_thread_exit_observer_token; +#endif + /* See breakpoint.h. */ cmd_list_element *commands_cmd_element = nullptr; @@ -16065,6 +16069,12 @@ This is useful for formatted output in user-defined commands.")); gdb::observers::about_to_proceed.attach (breakpoint_about_to_proceed, "breakpoint"); +#if HAVE_PYTHON + gdb::observers::thread_exit.attach + (remove_threaded_breakpoints, "breakpoint", + { &bpfinishpy_handle_thread_exit_observer_token }); +#else gdb::observers::thread_exit.attach (remove_threaded_breakpoints, "breakpoint"); +#endif } diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi index f4865b3d6a6..17a67800ba2 100644 --- a/gdb/doc/python.texi +++ b/gdb/doc/python.texi @@ -5698,7 +5698,7 @@ attribute is @code{None}. This attribute is writable. @tindex gdb.FinishBreakpoint A finish breakpoint is a temporary breakpoint set at the return address of -a frame, based on the @code{finish} command. @code{gdb.FinishBreakpoint} +a frame. @code{gdb.FinishBreakpoint} extends @code{gdb.Breakpoint}. The underlying breakpoint will be disabled and deleted when the execution will run out of the breakpoint scope (i.e.@: @code{Breakpoint.stop} or @code{FinishBreakpoint.out_of_scope} triggered). @@ -5717,7 +5717,9 @@ details about this argument. In some circumstances (e.g.@: @code{longjmp}, C@t{++} exceptions, @value{GDBN} @code{return} command, @dots{}), a function may not properly terminate, and thus never hit the finish breakpoint. When @value{GDBN} notices such a -situation, the @code{out_of_scope} callback will be triggered. +situation, the @code{out_of_scope} callback will be triggered. Note +though that improper function termination does not guarantee that the +finish breakpoint is not hit. You may want to sub-class @code{gdb.FinishBreakpoint} and override this method: diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c index 1d8373d807e..a881103fdad 100644 --- a/gdb/python/py-finishbreakpoint.c +++ b/gdb/python/py-finishbreakpoint.c @@ -398,6 +398,24 @@ bpfinishpy_handle_exit (struct inferior *inf) bpfinishpy_detect_out_scope_cb (bp, nullptr); } +/* Attached to `thread_exit' notifications, triggers all the necessary out of + scope notifications. */ + +static void +bpfinishpy_handle_thread_exit (struct thread_info *tp, int ignore) +{ + gdbpy_enter enter_py (target_gdbarch (), current_language); + + for (breakpoint *bp : all_breakpoints_safe ()) + { + if (tp->global_num == bp->thread) + bpfinishpy_detect_out_scope_cb (bp, nullptr); + } +} + +extern gdb::observers::token bpfinishpy_handle_thread_exit_observer_token; +gdb::observers::token bpfinishpy_handle_thread_exit_observer_token; + /* Initialize the Python finish breakpoint code. */ int @@ -414,6 +432,9 @@ gdbpy_initialize_finishbreakpoints (void) "py-finishbreakpoint"); gdb::observers::inferior_exit.attach (bpfinishpy_handle_exit, "py-finishbreakpoint"); + gdb::observers::thread_exit.attach + (bpfinishpy_handle_thread_exit, + bpfinishpy_handle_thread_exit_observer_token, "py-finishbreakpoint"); return 0; } diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp b/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp index 58e086ad3b4..46c39d0d108 100644 --- a/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp +++ b/gdb/testsuite/gdb.python/py-finish-breakpoint2.exp @@ -50,10 +50,20 @@ gdb_test "continue" "Breakpoint .*throw_exception_1.*" "run to exception 1" gdb_test "python print (len(gdb.breakpoints()))" "3" "check BP count" gdb_test "python ExceptionFinishBreakpoint(gdb.newest_frame())" \ "init ExceptionFinishBreakpoint" "set FinishBP after the exception" -gdb_test "continue" ".*stopped at ExceptionFinishBreakpoint.*" "check FinishBreakpoint in catch()" -gdb_test "python print (len(gdb.breakpoints()))" "3" "check finish BP removal" -gdb_test "continue" ".*Breakpoint.* throw_exception_1.*" "continue to second exception" +gdb_test_multiple "continue" "continue after setting FinishBreakpoint" { + -re -wrap ".*stopped at ExceptionFinishBreakpoint.*" { + pass "$gdb_test_name (scenario 1, triggered)" + gdb_test "python print (len(gdb.breakpoints()))" "3" \ + "check finish BP removal" + gdb_test "continue" ".*Breakpoint.* throw_exception_1.*" \ + "continue to second exception" + } + -re -wrap ".*Breakpoint.* throw_exception_1.*" { + pass "$gdb_test_name (scenario 2, not triggered)" + } +} + gdb_test "python ExceptionFinishBreakpoint(gdb.newest_frame())" \ "init ExceptionFinishBreakpoint" "set FinishBP after the exception again" gdb_test "continue" ".*exception did not finish.*" "FinishBreakpoint with exception thrown not caught" ++++++ gdb-rhbz1156192-recursive-dlopen-test.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.549340817 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.549340817 +0100 @@ -81,7 +81,7 @@ new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen.c -@@ -0,0 +1,124 @@ +@@ -0,0 +1,125 @@ +/* Testcase for recursive dlopen calls. + + Copyright (C) 2014 Free Software Foundation, Inc. @@ -178,6 +178,7 @@ + /* Called recursively. */ + result = malloc (size); + /* Restore new hooks. */ ++ old_malloc_hook = __malloc_hook; + __malloc_hook = custom_malloc_hook; + return result; +} @@ -210,7 +211,7 @@ new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.base/gdb-rhbz1156192-recursive-dlopen.exp -@@ -0,0 +1,137 @@ +@@ -0,0 +1,157 @@ +# Copyright 2014 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify @@ -226,8 +227,12 @@ +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + -+if { [skip_shlib_tests] } { -+ return 0 ++if {[skip_shlib_tests]} { ++ untested "skipping shlib tests" ++ return 0 ++} elseif {[use_gdb_stub]} { ++ untested "skipping tests because of stub" ++ return 0 +} + +# Library foo @@ -262,6 +267,21 @@ + return -1 +} + ++set supported 0 ++gdb_test_multiple "run" "initial trial run" { ++ -re -wrap "exited normally.*" { ++ set supported 1 ++ pass $gdb_test_name ++ } ++ -re -wrap "exited with code.*" { ++ untested "failed at $gdb_test_name" ++ } ++} ++ ++if { $supported == 0 } { ++ return -1 ++} ++ +proc do_test { has_libfoo has_libbar } { + global hex binfile_lib2 binfile_lib1 gdb_prompt + set libbar_match "[string_to_regexp $binfile_lib2]" @@ -314,6 +334,7 @@ + gdb_test_no_output "set stop-on-solib-events 1" "setting stop-on-solib-events" + + gdb_run_cmd ++ gdb_test "" "Wait for first prompt" + foreach l $solib_event_order { + incr pass + with_test_prefix "pass #$pass" { ++++++ gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.561340824 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.561340824 +0100 @@ -73,7 +73,7 @@ +set test "rwatch aligned.var4" +if [istarget "s390*-*-*"] { + gdb_test $test {Target does not support this type of hardware watchpoint\.} -+ untested "s390* does not support hw read watchpoint" ++ untested "s390* does not support hw read watchpoint" + return +} +gdb_test $test "Hardware read watchpoint \[0-9\]+: aligned.var4" ++++++ gdb-rhbz1350436-type-printers-error.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.569340828 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.569340828 +0100 @@ -42,22 +42,24 @@ diff --git a/gdb/testsuite/gdb.python/py-typeprint.py b/gdb/testsuite/gdb.python/py-typeprint.py --- a/gdb/testsuite/gdb.python/py-typeprint.py +++ b/gdb/testsuite/gdb.python/py-typeprint.py -@@ -15,7 +15,7 @@ +@@ -15,8 +15,7 @@ import gdb +- -class Recognizer(object): +class StringRecognizer(object): def __init__(self): self.enabled = True -@@ -30,6 +30,26 @@ class StringTypePrinter(object): +@@ -32,7 +31,27 @@ class StringTypePrinter(object): self.enabled = True def instantiate(self): - return Recognizer() + return StringRecognizer() + gdb.type_printers.append(StringTypePrinter()) + +class OtherRecognizer(object): ++++++ gdb-rhbz1398387-tab-crash-test.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.577340833 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.581340836 +0100 @@ -428,7 +428,7 @@ + +if { ![istarget x86_64-*-* ] || ![is_lp64_target] } { + return -+} ++} + +standard_testfile + ++++++ gdb-rhbz1976887-field-location-kind.patch ++++++ From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= <ahajkova@redhat.com> Date: Wed, 29 Sep 2021 10:58:50 +0200 Subject: gdb-rhbz1976887-field-location-kind.patch ;;Backport upstream patch which fixes internal-error: Unexpected ;;type field location kind (RHBZ 1976887). gdbtypes.c: Add the case for FIELD_LOC_KIND_DWARF_BLOCK The case for FIELD_LOC_KIND_DWARF_BLOCK was missing for switch TYPE_FIELD_LOC_KIND. Thas caused an internal-error under some circumstances. Fixes bug 28030. diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -5571,6 +5571,10 @@ copy_type_recursive (struct objfile *objfile, xstrdup (TYPE_FIELD_STATIC_PHYSNAME (type, i))); break; + case FIELD_LOC_KIND_DWARF_BLOCK: + SET_FIELD_DWARF_BLOCK (new_type->field (i), + TYPE_FIELD_DWARF_BLOCK (type, i)); + break; default: internal_error (__FILE__, __LINE__, _("Unexpected type field location kind: %d"), ++++++ gdb-rhbz2012976-paper-over-fortran-lex-problems.patch ++++++ From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 From: Kevin Buettner <kevinb@redhat.com> Date: Mon, 11 Oct 2021 11:22:04 -0700 Subject: gdb-rhbz2012976-paper-over-fortran-lex-problems.patch ;; Backport gdb.fortran testsuite changes in order to avoid Fortran ;; lexical analyzer bug. [gdb/testsuite] Fix FAIL in gdb.mi/mi-var-child-f.exp When running test-case gdb.mi/mi-var-child-f.exp on openSUSE Tumbleweed (with glibc 2.34) I run into: ... (gdb) ^M PASS: gdb.mi/mi-var-child-f.exp: mi runto prog_array Expecting: ^(-var-create array \* array[^M ]+)?(\^done,name="array",numchild="[0-9]+",value=".*",type=.*,has_more="0"[^M ]+[(]gdb[)] ^M [ ]*) -var-create array * array^M &"Attempt to use a type name as an expression.\n"^M ^error,msg="-var-create: unable to create variable object"^M (gdb) ^M FAIL: gdb.mi/mi-var-child-f.exp: create local variable array (unexpected output) ... The problem is that the name array is used both: - as the name for a local variable - as the name of a type in glibc, in file malloc/dynarray-skeleton.c, as included by nss/nss_files/files-hosts.c. Fix this by ignoring the shared lib symbols. Likewise in a couple of other fortran tests. Tested on x86_64-linux. diff --git a/gdb/testsuite/gdb.fortran/allocated.exp b/gdb/testsuite/gdb.fortran/allocated.exp --- a/gdb/testsuite/gdb.fortran/allocated.exp +++ b/gdb/testsuite/gdb.fortran/allocated.exp @@ -25,11 +25,17 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \ return -1 } +# Avoid shared lib symbols. +gdb_test_no_output "set auto-solib-add off" + if ![fortran_runto_main] { untested "could not run to main" return -1 } +# Avoid libc symbols, in particular the 'array' type. +gdb_test_no_output "nosharedlibrary" + # Set all the breakpoints. for { set i 1 } { $i < 6 } { incr i } { gdb_breakpoint [gdb_get_line_number "Breakpoint $i"] diff --git a/gdb/testsuite/gdb.fortran/array-slices-bad.exp b/gdb/testsuite/gdb.fortran/array-slices-bad.exp --- a/gdb/testsuite/gdb.fortran/array-slices-bad.exp +++ b/gdb/testsuite/gdb.fortran/array-slices-bad.exp @@ -25,11 +25,17 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \ return -1 } +# Avoid shared lib symbols. +gdb_test_no_output "set auto-solib-add off" + if ![fortran_runto_main] { untested "could not run to main" return -1 } +# Avoid libc symbols, in particular the 'array' type. +gdb_test_no_output "nosharedlibrary" + # gdb_breakpoint [gdb_get_line_number "Display Message Breakpoint"] gdb_breakpoint [gdb_get_line_number "First Breakpoint"] gdb_breakpoint [gdb_get_line_number "Second Breakpoint"] diff --git a/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp b/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp --- a/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp +++ b/gdb/testsuite/gdb.fortran/array-slices-sub-slices.exp @@ -25,11 +25,17 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \ return -1 } +# Avoid shared lib symbols. +gdb_test_no_output "set auto-solib-add off" + if ![fortran_runto_main] { untested "could not run to main" return -1 } +# Avoid libc symbols, in particular the 'array' type. +gdb_test_no_output "nosharedlibrary" + # gdb_breakpoint [gdb_get_line_number "Display Message Breakpoint"] gdb_breakpoint [gdb_get_line_number "Stop Here"] gdb_breakpoint [gdb_get_line_number "Final Breakpoint"] diff --git a/gdb/testsuite/gdb.fortran/array-slices.exp b/gdb/testsuite/gdb.fortran/array-slices.exp --- a/gdb/testsuite/gdb.fortran/array-slices.exp +++ b/gdb/testsuite/gdb.fortran/array-slices.exp @@ -55,11 +55,17 @@ proc run_test { repack } { clean_restart ${binfile} + # Avoid shared lib symbols. + gdb_test_no_output "set auto-solib-add off" + if ![fortran_runto_main] { untested "could not run to main" return -1 } + # Avoid libc symbols, in particular the 'array' type. + gdb_test_no_output "nosharedlibrary" + gdb_test_no_output "set fortran repack-array-slices $repack" # gdb_breakpoint [gdb_get_line_number "Display Message Breakpoint"] diff --git a/gdb/testsuite/gdb.fortran/lbound-ubound.exp b/gdb/testsuite/gdb.fortran/lbound-ubound.exp --- a/gdb/testsuite/gdb.fortran/lbound-ubound.exp +++ b/gdb/testsuite/gdb.fortran/lbound-ubound.exp @@ -25,12 +25,17 @@ if {[prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \ return -1 } +# Avoid shared lib symbols. +gdb_test_no_output "set auto-solib-add off" if ![fortran_runto_main] { untested "could not run to main" return -1 } +# Avoid libc symbols, in particular the 'array' type. +gdb_test_no_output "nosharedlibrary" + gdb_breakpoint [gdb_get_line_number "Test Breakpoint"] gdb_breakpoint [gdb_get_line_number "Final Breakpoint"] diff --git a/gdb/testsuite/gdb.fortran/subarray.exp b/gdb/testsuite/gdb.fortran/subarray.exp --- a/gdb/testsuite/gdb.fortran/subarray.exp +++ b/gdb/testsuite/gdb.fortran/subarray.exp @@ -27,16 +27,17 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} { return -1 } -gdb_exit -gdb_start -gdb_reinitialize_dir $srcdir/$subdir -gdb_load ${binfile} +# Avoid shared lib symbols. +gdb_test_no_output "set auto-solib-add off" if ![fortran_runto_main] then { perror "couldn't run to main" continue } +# Avoid libc symbols, in particular the 'array' type. +gdb_test_no_output "nosharedlibrary" + # Try to set breakpoint at the last write statement. set bp_location [gdb_get_line_number "str(:)"] diff --git a/gdb/testsuite/gdb.mi/mi-var-child-f.exp b/gdb/testsuite/gdb.mi/mi-var-child-f.exp --- a/gdb/testsuite/gdb.mi/mi-var-child-f.exp +++ b/gdb/testsuite/gdb.mi/mi-var-child-f.exp @@ -36,8 +36,14 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ mi_gdb_reinitialize_dir $srcdir/$subdir mi_gdb_load ${binfile} +# Avoid shared lib symbols. +mi_gdb_test "-gdb-set auto-solib-add off" "\\^done" + mi_runto prog_array +# Avoid libc symbols, in particular the 'array' type. +mi_gdb_test "nosharedlibrary" ".*\\^done" + mi_create_varobj "array" "array" "create local variable array" ++++++ gdb-symtab-add-call_site_eq-and-call_site_hash.patch ++++++ [gdb/symtab] Add call_site_eq and call_site_hash In commit b4c919f7525 "[gdb/symtab] Fix htab_find_slot call in read_call_site_scope" , I removed the comment: ... It must be the first field as we overload core_addr_hash and core_addr_eq for it. ... for field pc of struct call_site. However, this was not tested, and when indeed moving field pc to the second location, we run into a testsuite failure in gdb.trace/entry-values.exp. This is caused by core_addr_eq (the eq_f function for the htab) being called with a pointer to the pc field (as passed into htab_find_slot) and a pointer to a hash table element. Now that pc is no longer the first field, the pointer to hash table element no longer points to the pc field. This could be fixed by simply reinstating the comment, but we're trying to get rid of this kind of tricks that make refactoring more difficult. Instead, fix this by: - reverting commit b4c919f7525, apart from the comment removal, such that we're passing a pointer to element to htab_find_slot - updating the htab_find_slot call in compunit_symtab::find_call_site in a similar manner - adding a call_site_eq and call_site_hash, and using these in the hash table instead of core_addr_eq and core_addr_hash. Tested on x86_64-linux, both with and without a trigger patch that moves pc to the second location in struct call_site. --- gdb/dwarf2/read.c | 7 ++++--- gdb/gdbtypes.h | 15 +++++++++++++++ gdb/symtab.c | 5 ++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index d3742bbce8c..7def1e246c4 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -13287,7 +13287,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) struct gdbarch *gdbarch = objfile->arch (); CORE_ADDR pc, baseaddr; struct attribute *attr; - struct call_site *call_site; + struct call_site *call_site, call_site_local; void **slot; int nparams; struct die_info *child_die; @@ -13312,10 +13312,11 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) pc = gdbarch_adjust_dwarf2_addr (gdbarch, pc); if (cu->call_site_htab == NULL) - cu->call_site_htab = htab_create_alloc_ex (16, core_addr_hash, core_addr_eq, + cu->call_site_htab = htab_create_alloc_ex (16, call_site_hash, call_site_eq, NULL, &objfile->objfile_obstack, hashtab_obstack_allocate, NULL); - slot = htab_find_slot (cu->call_site_htab, &pc, INSERT); + call_site_local.pc = pc; + slot = htab_find_slot (cu->call_site_htab, &call_site_local, INSERT); if (*slot != NULL) { complaint (_("Duplicate PC %s for DW_TAG_call_site " diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index f2e077c70a2..77d1e66a6b1 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1806,6 +1806,21 @@ struct call_site struct call_site_parameter parameter[1]; }; +static inline int +call_site_eq (const void *a_, const void *b_) +{ + const struct call_site *a = (const call_site *)a_; + const struct call_site *b = (const call_site *)b_; + return core_addr_eq (&a->pc, &b->pc); +} + +static inline hashval_t +call_site_hash (const void *a_) +{ + const struct call_site *a = (const call_site *)a_; + return core_addr_hash (&a->pc); +} + /* The type-specific info for TYPE_CODE_FIXED_POINT types. */ struct fixed_point_type_info diff --git a/gdb/symtab.c b/gdb/symtab.c index 1d30c8fc7a8..fe430edadb2 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -334,10 +334,13 @@ search_domain_name (enum search_domain e) call_site * compunit_symtab::find_call_site (CORE_ADDR pc) const { + struct call_site call_site_local; if (m_call_site_htab == nullptr) return nullptr; - void **slot = htab_find_slot (m_call_site_htab, &pc, NO_INSERT); + call_site_local.pc = pc; + void **slot + = htab_find_slot (m_call_site_htab, &call_site_local, NO_INSERT); if (slot == nullptr) return nullptr; ++++++ gdb-symtab-c-ify-call_site.patch ++++++ [gdb/symtab] C++-ify call_site - add constructor - add member function call_site::pc () Tested on x86_64-linux. Co-Authored-By: Tom de Vries <tdevries@suse.de> --- gdb/dwarf2/frame-tailcall.c | 4 +-- gdb/dwarf2/loc.c | 18 ++++++------ gdb/dwarf2/read.c | 27 +++++++++--------- gdb/gdbtypes.c | 9 ++++++ gdb/gdbtypes.h | 67 +++++++++++++++++++++++++++++---------------- gdb/symtab.c | 3 +- 6 files changed, 77 insertions(+), 51 deletions(-) diff --git a/gdb/dwarf2/frame-tailcall.c b/gdb/dwarf2/frame-tailcall.c index f112b4ecca4..9fe498b0924 100644 --- a/gdb/dwarf2/frame-tailcall.c +++ b/gdb/dwarf2/frame-tailcall.c @@ -240,14 +240,14 @@ pretend_pc (struct frame_info *this_frame, struct tailcall_cache *cache) gdb_assert (next_levels >= 0); if (next_levels < chain->callees) - return chain->call_site[chain->length - next_levels - 1]->pc; + return chain->call_site[chain->length - next_levels - 1]->pc (); next_levels -= chain->callees; /* Otherwise CHAIN->CALLEES are already covered by CHAIN->CALLERS. */ if (chain->callees != chain->length) { if (next_levels < chain->callers) - return chain->call_site[chain->callers - next_levels - 1]->pc; + return chain->call_site[chain->callers - next_levels - 1]->pc (); next_levels -= chain->callers; } diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index d57cdc165ba..83b5fe1ac88 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -920,10 +920,10 @@ call_site_to_target_addr (struct gdbarch *call_site_gdbarch, { struct bound_minimal_symbol msym; - msym = lookup_minimal_symbol_by_pc (call_site->pc - 1); + msym = lookup_minimal_symbol_by_pc (call_site->pc () - 1); throw_error (NO_ENTRY_VALUE_ERROR, _("DW_AT_call_target is not specified at %s in %s"), - paddress (call_site_gdbarch, call_site->pc), + paddress (call_site_gdbarch, call_site->pc ()), (msym.minsym == NULL ? "???" : msym.minsym->print_name ())); @@ -932,12 +932,12 @@ call_site_to_target_addr (struct gdbarch *call_site_gdbarch, { struct bound_minimal_symbol msym; - msym = lookup_minimal_symbol_by_pc (call_site->pc - 1); + msym = lookup_minimal_symbol_by_pc (call_site->pc () - 1); throw_error (NO_ENTRY_VALUE_ERROR, _("DW_AT_call_target DWARF block resolving " "requires known frame which is currently not " "available at %s in %s"), - paddress (call_site_gdbarch, call_site->pc), + paddress (call_site_gdbarch, call_site->pc ()), (msym.minsym == NULL ? "???" : msym.minsym->print_name ())); @@ -966,11 +966,11 @@ call_site_to_target_addr (struct gdbarch *call_site_gdbarch, msym = lookup_minimal_symbol (physname, NULL, NULL); if (msym.minsym == NULL) { - msym = lookup_minimal_symbol_by_pc (call_site->pc - 1); + msym = lookup_minimal_symbol_by_pc (call_site->pc () - 1); throw_error (NO_ENTRY_VALUE_ERROR, _("Cannot find function \"%s\" for a call site target " "at %s in %s"), - physname, paddress (call_site_gdbarch, call_site->pc), + physname, paddress (call_site_gdbarch, call_site->pc ()), (msym.minsym == NULL ? "???" : msym.minsym->print_name ())); @@ -1076,7 +1076,7 @@ func_verify_no_selftailcall (struct gdbarch *gdbarch, CORE_ADDR verify_addr) static void tailcall_dump (struct gdbarch *gdbarch, const struct call_site *call_site) { - CORE_ADDR addr = call_site->pc; + CORE_ADDR addr = call_site->pc (); struct bound_minimal_symbol msym = lookup_minimal_symbol_by_pc (addr - 1); fprintf_unfiltered (gdb_stdlog, " %s(%s)", paddress (gdbarch, addr), @@ -1252,7 +1252,7 @@ call_site_find_chain_1 (struct gdbarch *gdbarch, CORE_ADDR caller_pc, if (target_call_site) { - if (addr_hash.insert (target_call_site->pc).second) + if (addr_hash.insert (target_call_site->pc ()).second) { /* Successfully entered TARGET_CALL_SITE. */ @@ -1271,7 +1271,7 @@ call_site_find_chain_1 (struct gdbarch *gdbarch, CORE_ADDR caller_pc, call_site = chain.back (); chain.pop_back (); - size_t removed = addr_hash.erase (call_site->pc); + size_t removed = addr_hash.erase (call_site->pc ()); gdb_assert (removed == 1); target_call_site = call_site->tail_call_next; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 7def1e246c4..59ce3cf2b45 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -13287,7 +13287,6 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) struct gdbarch *gdbarch = objfile->arch (); CORE_ADDR pc, baseaddr; struct attribute *attr; - struct call_site *call_site, call_site_local; void **slot; int nparams; struct die_info *child_die; @@ -13312,10 +13311,11 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) pc = gdbarch_adjust_dwarf2_addr (gdbarch, pc); if (cu->call_site_htab == NULL) - cu->call_site_htab = htab_create_alloc_ex (16, call_site_hash, call_site_eq, - NULL, &objfile->objfile_obstack, + cu->call_site_htab = htab_create_alloc_ex (16, call_site::hash, + call_site::eq, NULL, + &objfile->objfile_obstack, hashtab_obstack_allocate, NULL); - call_site_local.pc = pc; + struct call_site call_site_local (pc, nullptr, nullptr); slot = htab_find_slot (cu->call_site_htab, &call_site_local, INSERT); if (*slot != NULL) { @@ -13345,14 +13345,16 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) nparams++; } - call_site - = ((struct call_site *) - obstack_alloc (&objfile->objfile_obstack, - sizeof (*call_site) - + (sizeof (*call_site->parameter) * (nparams - 1)))); + struct call_site *call_site + = new (XOBNEWVAR (&objfile->objfile_obstack, + struct call_site, + sizeof (*call_site) + sizeof (call_site->parameter[0]) * nparams)) + struct call_site (pc, cu->per_cu, per_objfile); *slot = call_site; - memset (call_site, 0, sizeof (*call_site) - sizeof (*call_site->parameter)); - call_site->pc = pc; + + /* We never call the destructor of call_site, so we must ensure it is + trivially destructible. */ + gdb_static_assert(std::is_trivially_destructible<struct call_site>::value); if (dwarf2_flag_true_p (die, DW_AT_call_tail_call, cu) || dwarf2_flag_true_p (die, DW_AT_GNU_tail_call, cu)) @@ -13473,9 +13475,6 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) "block nor reference, for DIE %s [in module %s]"), sect_offset_str (die->sect_off), objfile_name (objfile)); - call_site->per_cu = cu->per_cu; - call_site->per_objfile = per_objfile; - for (child_die = die->child; child_die && child_die->tag; child_die = child_die->sibling) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 05ce646bc59..1b3ed1b32ed 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -37,6 +37,7 @@ #include "cp-support.h" #include "bcache.h" #include "dwarf2/loc.h" +#include "dwarf2/read.h" #include "gdbcore.h" #include "floatformat.h" #include "f-lang.h" @@ -6301,6 +6302,14 @@ objfile_type (struct objfile *objfile) return objfile_type; } +/* See gdbtypes.h. */ + +CORE_ADDR +call_site::pc () const +{ + return m_pc; +} + void _initialize_gdbtypes (); void _initialize_gdbtypes () diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 77d1e66a6b1..a071188ffa1 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1775,52 +1775,71 @@ struct call_site_parameter struct call_site { - /* Address of the first instruction after this call. */ - - CORE_ADDR pc; + call_site (CORE_ADDR pc, dwarf2_per_cu_data *per_cu, + dwarf2_per_objfile *per_objfile) + : per_cu (per_cu), per_objfile (per_objfile), m_pc (pc) + {} + + static int + eq (const call_site *a, const call_site *b) + { + return core_addr_eq (&a->m_pc, &b->m_pc); + } + + static hashval_t + hash (const call_site *a) + { + return core_addr_hash (&a->m_pc); + } + + static int + eq (const void *a, const void *b) + { + return eq ((const call_site *)a, (const call_site *)b); + } + + static hashval_t + hash (const void *a) + { + return hash ((const call_site *)a); + } + + /* Return the address of the first instruction after this call. */ + + CORE_ADDR pc () const; /* * List successor with head in FUNC_TYPE.TAIL_CALL_LIST. */ - struct call_site *tail_call_next; + struct call_site *tail_call_next = nullptr; /* * Describe DW_AT_call_target. Missing attribute uses FIELD_LOC_KIND_DWARF_BLOCK with FIELD_DWARF_BLOCK == NULL. */ - struct call_site_target target; + struct call_site_target target {}; /* * Size of the PARAMETER array. */ - unsigned parameter_count; + unsigned parameter_count = 0; /* * CU of the function where the call is located. It gets used for DWARF blocks execution in the parameter array below. */ - dwarf2_per_cu_data *per_cu; + dwarf2_per_cu_data *const per_cu = nullptr; /* objfile of the function where the call is located. */ - dwarf2_per_objfile *per_objfile; + dwarf2_per_objfile *const per_objfile = nullptr; + private: + /* Address of the first instruction after this call. */ + const CORE_ADDR m_pc; + + public: /* * Describe DW_TAG_call_site's DW_TAG_formal_parameter. */ - struct call_site_parameter parameter[1]; + struct call_site_parameter parameter[]; }; -static inline int -call_site_eq (const void *a_, const void *b_) -{ - const struct call_site *a = (const call_site *)a_; - const struct call_site *b = (const call_site *)b_; - return core_addr_eq (&a->pc, &b->pc); -} - -static inline hashval_t -call_site_hash (const void *a_) -{ - const struct call_site *a = (const call_site *)a_; - return core_addr_hash (&a->pc); -} - /* The type-specific info for TYPE_CODE_FIXED_POINT types. */ struct fixed_point_type_info diff --git a/gdb/symtab.c b/gdb/symtab.c index fe430edadb2..14cc2b5bd8d 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -334,11 +334,10 @@ search_domain_name (enum search_domain e) call_site * compunit_symtab::find_call_site (CORE_ADDR pc) const { - struct call_site call_site_local; if (m_call_site_htab == nullptr) return nullptr; - call_site_local.pc = pc; + struct call_site call_site_local (pc, nullptr, nullptr); void **slot = htab_find_slot (m_call_site_htab, &call_site_local, NO_INSERT); if (slot == nullptr) ++++++ gdb-symtab-fix-htab_find_slot-call-in-read_call_site_scope.patch ++++++ [gdb/symtab] Fix htab_find_slot call in read_call_site_scope In read_call_site_scope we have: ... call_site_local.pc = pc; slot = htab_find_slot (cu->call_site_htab, &call_site_local, INSERT); ... The call passes a call_site pointer as element. OTOH, the hashtab is created using hash_f == core_addr_hash and eq_f == core_addr_eq, so the element will be accessed through a CORE_ADDR pointer. This is not wrong (at least in C), given that pc is the first field in call_site. Nevertheless, as in call_site_for_pc, make the htab_find_slot call match the used hash_f and eq_f by using &pc instead: ... slot = htab_find_slot (cu->call_site_htab, &pc, INSERT); ... Tested on x86_64-linux. Co-Authored-By: Tom de Vries <tdevries@suse.de> --- gdb/dwarf2/read.c | 5 ++--- gdb/gdbtypes.h | 4 +--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 0ce39eb9274..892d31dddf3 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -13287,7 +13287,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) struct gdbarch *gdbarch = objfile->arch (); CORE_ADDR pc, baseaddr; struct attribute *attr; - struct call_site *call_site, call_site_local; + struct call_site *call_site; void **slot; int nparams; struct die_info *child_die; @@ -13315,8 +13315,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) cu->call_site_htab = htab_create_alloc_ex (16, core_addr_hash, core_addr_eq, NULL, &objfile->objfile_obstack, hashtab_obstack_allocate, NULL); - call_site_local.pc = pc; - slot = htab_find_slot (cu->call_site_htab, &call_site_local, INSERT); + slot = htab_find_slot (cu->call_site_htab, &pc, INSERT); if (*slot != NULL) { complaint (_("Duplicate PC %s for DW_TAG_call_site " diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 0cc00e74a20..f2e077c70a2 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1775,9 +1775,7 @@ struct call_site_parameter struct call_site { - /* * Address of the first instruction after this call. It must be - the first field as we overload core_addr_hash and core_addr_eq - for it. */ + /* Address of the first instruction after this call. */ CORE_ADDR pc; ++++++ gdb-symtab-remove-compunit_call_site_htab.patch ++++++ [gdb/symtab] Remove COMPUNIT_CALL_SITE_HTAB Remove macro COMPUNIT_CALL_SITE_HTAB, and provide access to the htab using member functions: - compunit_symtab::find_call_site - compunit_symtab::set_call_site_htab Tested on x86_64-linux. Co-Authored-By: Tom de Vries <tdevries@suse.de> --- gdb/block.c | 10 +++++----- gdb/dwarf2/read.c | 2 +- gdb/symtab.c | 24 ++++++++++++++++++++++++ gdb/symtab.h | 9 +++++++-- 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/gdb/block.c b/gdb/block.c index 4cb95731396..90c0c5b3250 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -225,15 +225,15 @@ struct call_site * call_site_for_pc (struct gdbarch *gdbarch, CORE_ADDR pc) { struct compunit_symtab *cust; - void **slot = NULL; + call_site *cs = nullptr; /* -1 as tail call PC can be already after the compilation unit range. */ cust = find_pc_compunit_symtab (pc - 1); - if (cust != NULL && COMPUNIT_CALL_SITE_HTAB (cust) != NULL) - slot = htab_find_slot (COMPUNIT_CALL_SITE_HTAB (cust), &pc, NO_INSERT); + if (cust != nullptr) + cs = cust->find_call_site (pc); - if (slot == NULL) + if (cs == nullptr) { struct bound_minimal_symbol msym = lookup_minimal_symbol_by_pc (pc); @@ -247,7 +247,7 @@ call_site_for_pc (struct gdbarch *gdbarch, CORE_ADDR pc) : msym.minsym->print_name ())); } - return (struct call_site *) *slot; + return cs; } /* Return the blockvector immediately containing the innermost lexical block diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 892d31dddf3..d3742bbce8c 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -9457,7 +9457,7 @@ process_full_comp_unit (dwarf2_cu *cu, enum language pretend_language) if (gcc_4_minor >= 5) cust->epilogue_unwind_valid = 1; - cust->call_site_htab = cu->call_site_htab; + cust->set_call_site_htab (cu->call_site_htab); } per_objfile->set_symtab (cu->per_cu, cust); diff --git a/gdb/symtab.c b/gdb/symtab.c index fa3f42207ec..1d30c8fc7a8 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -331,6 +331,30 @@ search_domain_name (enum search_domain e) /* See symtab.h. */ +call_site * +compunit_symtab::find_call_site (CORE_ADDR pc) const +{ + if (m_call_site_htab == nullptr) + return nullptr; + + void **slot = htab_find_slot (m_call_site_htab, &pc, NO_INSERT); + if (slot == nullptr) + return nullptr; + + return (call_site *) *slot; +} + +/* See symtab.h. */ + +void +compunit_symtab::set_call_site_htab (htab_t call_site_htab) +{ + gdb_assert (m_call_site_htab == nullptr); + m_call_site_htab = call_site_htab; +} + +/* See symtab.h. */ + struct symtab * compunit_primary_filetab (const struct compunit_symtab *cust) { diff --git a/gdb/symtab.h b/gdb/symtab.h index 471ae9ef448..78ac84527ae 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1443,6 +1443,12 @@ struct symtab struct compunit_symtab { + /* Set m_call_site_htab. */ + void set_call_site_htab (htab_t call_site_htab); + + /* Find call_site info for PC. */ + call_site *find_call_site (CORE_ADDR pc) const; + /* Unordered chain of all compunit symtabs of this objfile. */ struct compunit_symtab *next; @@ -1497,7 +1503,7 @@ struct compunit_symtab unsigned int epilogue_unwind_valid : 1; /* struct call_site entries for this compilation unit or NULL. */ - htab_t call_site_htab; + htab_t m_call_site_htab; /* The macro table for this symtab. Like the blockvector, this is shared between different symtabs in a given compilation unit. @@ -1530,7 +1536,6 @@ struct compunit_symtab #define COMPUNIT_BLOCK_LINE_SECTION(cust) ((cust)->block_line_section) #define COMPUNIT_LOCATIONS_VALID(cust) ((cust)->locations_valid) #define COMPUNIT_EPILOGUE_UNWIND_VALID(cust) ((cust)->epilogue_unwind_valid) -#define COMPUNIT_CALL_SITE_HTAB(cust) ((cust)->call_site_htab) #define COMPUNIT_MACRO_TABLE(cust) ((cust)->macro_table) /* A range adapter to allowing iterating over all the file tables ++++++ gdb-symtab-use-unrelocated-addresses-in-call_site.patch ++++++ [gdb/symtab] Use unrelocated addresses in call_site Consider test-case gdb.trace/entry-values.exp with target board unix/-fPIE/-pie. Using this command we have an abbreviated version, and can see the correct @entry values for foo: ... $ gdb -q -batch outputs/gdb.trace/entry-values/entry-values \ -ex start \ -ex "break foo" \ -ex "set print entry-values both" \ -ex continue Temporary breakpoint 1 at 0x679 Temporary breakpoint 1, 0x0000555555554679 in main () Breakpoint 2 at 0x55555555463e Breakpoint 2, 0x000055555555463e in foo (i=0, i@entry=2, j=2, j@entry=3) ... Now, let's try the same again, but run directly to foo rather than stopping at main: ... $ gdb -q -batch outputs/gdb.trace/entry-values/entry-values \ -ex "break foo" \ -ex "set print entry-values both" \ -ex run Breakpoint 1 at 0x63e Breakpoint 1, 0x000055555555463e in foo (i=0, i@entry=<optimized out>, \ j=2, j@entry=<optimized out>) ... So, what explains the difference? Noteworthy, this is a dwarf assembly test-case, with debug info for foo and bar, but not for main. In the first case: - we run to main - this does not trigger expanding debug info, because there's none for main - we set a breakpoint at foo - this triggers expanding debug info. Relocated addresses are used in call_site info (because the exec is started) - we continue to foo, and manage to find the call_site info In the second case: - we set a breakpoint at foo - this triggers expanding debug info. Unrelocated addresses are used in call_site info (because the exec is not started) - we run to foo - this triggers objfile_relocate1, but it doesn't update the call_site info addresses - we don't manage to find the call_site info We could fix this by adding the missing call_site relocation in objfile_relocate1. This solution however is counter-trend in the sense that we're trying to work towards the situation where when starting two instances of an executable, we need only one instance of debug information, implying the use of unrelocated addresses. So, fix this instead by using unrelocated addresses in call_site info. Tested on x86_64-linux. This fixes all remaining unix/-fno-PIE/-no-pie vs unix/-fPIE/-pie regressions, like f.i. PR24892. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=24892 Co-Authored-By: Tom de Vries <tdevries@suse.de> --- gdb/dwarf2/loc.c | 9 ++++++++- gdb/dwarf2/read.c | 4 +++- gdb/gdbtypes.c | 5 ++++- gdb/gdbtypes.h | 10 +++++----- gdb/symtab.c | 6 +++++- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index 83b5fe1ac88..ba94780cc75 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -979,7 +979,14 @@ call_site_to_target_addr (struct gdbarch *call_site_gdbarch, } case FIELD_LOC_KIND_PHYSADDR: - return FIELD_STATIC_PHYSADDR (call_site->target); + { + dwarf2_per_objfile *per_objfile = call_site->per_objfile; + compunit_symtab *cust = per_objfile->get_symtab (call_site->per_cu); + int sect_idx = COMPUNIT_BLOCK_LINE_SECTION (cust); + CORE_ADDR delta = per_objfile->objfile->section_offsets[sect_idx]; + + return FIELD_STATIC_PHYSADDR (call_site->target) + delta; + } default: internal_error (__FILE__, __LINE__, _("invalid call site target kind")); diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 59ce3cf2b45..e73c0855fc1 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -13309,6 +13309,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) } pc = attr->as_address () + baseaddr; pc = gdbarch_adjust_dwarf2_addr (gdbarch, pc); + pc -= baseaddr; if (cu->call_site_htab == NULL) cu->call_site_htab = htab_create_alloc_ex (16, call_site::hash, @@ -13465,7 +13466,8 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) sect_offset_str (die->sect_off), objfile_name (objfile)); else { - lowpc = gdbarch_adjust_dwarf2_addr (gdbarch, lowpc + baseaddr); + lowpc = (gdbarch_adjust_dwarf2_addr (gdbarch, lowpc + baseaddr) + - baseaddr); SET_FIELD_PHYSADDR (call_site->target, lowpc); } } diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 1b3ed1b32ed..f1efbb98720 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -6307,7 +6307,10 @@ objfile_type (struct objfile *objfile) CORE_ADDR call_site::pc () const { - return m_pc; + compunit_symtab *cust = this->per_objfile->get_symtab (this->per_cu); + CORE_ADDR delta + = this->per_objfile->objfile->section_offsets[COMPUNIT_BLOCK_LINE_SECTION (cust)]; + return m_unrelocated_pc + delta; } void _initialize_gdbtypes (); diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index a071188ffa1..8b1fd75bccf 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1777,19 +1777,19 @@ struct call_site { call_site (CORE_ADDR pc, dwarf2_per_cu_data *per_cu, dwarf2_per_objfile *per_objfile) - : per_cu (per_cu), per_objfile (per_objfile), m_pc (pc) + : per_cu (per_cu), per_objfile (per_objfile), m_unrelocated_pc (pc) {} static int eq (const call_site *a, const call_site *b) { - return core_addr_eq (&a->m_pc, &b->m_pc); + return core_addr_eq (&a->m_unrelocated_pc, &b->m_unrelocated_pc); } static hashval_t hash (const call_site *a) { - return core_addr_hash (&a->m_pc); + return core_addr_hash (&a->m_unrelocated_pc); } static int @@ -1831,8 +1831,8 @@ struct call_site dwarf2_per_objfile *const per_objfile = nullptr; private: - /* Address of the first instruction after this call. */ - const CORE_ADDR m_pc; + /* Unrelocated address of the first instruction after this call. */ + const CORE_ADDR m_unrelocated_pc; public: /* * Describe DW_TAG_call_site's DW_TAG_formal_parameter. */ diff --git a/gdb/symtab.c b/gdb/symtab.c index 14cc2b5bd8d..17607fb447b 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -337,7 +337,11 @@ compunit_symtab::find_call_site (CORE_ADDR pc) const if (m_call_site_htab == nullptr) return nullptr; - struct call_site call_site_local (pc, nullptr, nullptr); + CORE_ADDR delta + = this->objfile->section_offsets[COMPUNIT_BLOCK_LINE_SECTION (this)]; + CORE_ADDR unrelocated_pc = pc - delta; + + struct call_site call_site_local (unrelocated_pc, nullptr, nullptr); void **slot = htab_find_slot (m_call_site_htab, &call_site_local, NO_INSERT); if (slot == nullptr) ++++++ gdb-test-dw2-aranges.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.649340874 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.649340874 +0100 @@ -203,7 +203,7 @@ + && ![istarget *-*-openbsd*] + && ![istarget arm-*-eabi*] + && ![istarget powerpc-*-eabi*]} { -+ return 0 ++ return 0 +} + +set testfile "dw2-aranges" ++++++ gdb-test-for-rhbz1976887.patch ++++++ From FEDORA_PATCHES Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandra=20H=C3=A1jkov=C3=A1?= <ahajkova@redhat.com> Date: Wed, 29 Sep 2021 11:14:51 +0200 Subject: gdb-test-for-rhbz1976887.patch ;; Backport test for RHBZ 1976887 (Kevin Buettner). Test case reproducing PR28030 bug The original reproducer for PR28030 required use of a specific compiler version - gcc-c++-11.1.1-3.fc34 is mentioned in the PR, though it seems probable that other gcc versions might also be able to reproduce the bug as well. This commit introduces a test case which, using the DWARF assembler, provides a reproducer which is independent of the compiler version. (Well, it'll work with whatever compilers the DWARF assembler works with.) To the best of my knowledge, it's also the first test case which uses the DWARF assembler to provide debug info for a shared object. That being the case, I provided more than the usual commentary which should allow this case to be used as a template when a combo shared library / DWARF assembler test case is required in the future. I provide some details regarding the bug in a comment near the beginning of locexpr-dml.exp. This problem was difficult to reproduce; I found myself constantly referring to the backtrace while trying to figure out what (else) I might be missing while trying to create a reproducer. Below is a partial backtrace which I include for posterity. #0 internal_error ( file=0xc50110 "/ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/gdbtypes.c", line=5575, fmt=0xc520c0 "Unexpected type field location kind: %d") at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdbsupport/errors.cc:51 #1 0x00000000006ef0c5 in copy_type_recursive (objfile=0x1635930, type=0x274c260, copied_types=0x30bb290) at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/gdbtypes.c:5575 #2 0x00000000006ef382 in copy_type_recursive (objfile=0x1635930, type=0x274ca10, copied_types=0x30bb290) at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/gdbtypes.c:5602 #3 0x0000000000a7409a in preserve_one_value (value=0x24269f0, objfile=0x1635930, copied_types=0x30bb290) at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/value.c:2529 #4 0x000000000072012a in gdbscm_preserve_values ( extlang=0xc55720 <extension_language_guile>, objfile=0x1635930, copied_types=0x30bb290) at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/guile/scm-value.c:94 #5 0x00000000006a3f82 in preserve_ext_lang_values (objfile=0x1635930, copied_types=0x30bb290) at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/extension.c:568 #6 0x0000000000a7428d in preserve_values (objfile=0x1635930) at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/value.c:2579 #7 0x000000000082d514 in objfile::~objfile (this=0x1635930, __in_chrg=<optimized out>) at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/objfiles.c:549 #8 0x0000000000831cc8 in std::_Sp_counted_ptr<objfile*, (__gnu_cxx::_Lock_policy)2>::_M_dispose (this=0x1654580) at /usr/include/c++/11/bits/shared_ptr_base.h:348 #9 0x00000000004e6617 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0x1654580) at /usr/include/c++/11/bits/shared_ptr_base.h:168 #10 0x00000000004e1d2f in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count (this=0x190bb88, __in_chrg=<optimized out>) at /usr/include/c++/11/bits/shared_ptr_base.h:705 #11 0x000000000082feee in std::__shared_ptr<objfile, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr (this=0x190bb80, __in_chrg=<optimized out>) at /usr/include/c++/11/bits/shared_ptr_base.h:1154 #12 0x000000000082ff0a in std::shared_ptr<objfile>::~shared_ptr ( this=0x190bb80, __in_chrg=<optimized out>) at /usr/include/c++/11/bits/shared_ptr.h:122 #13 0x000000000085ed7e in __gnu_cxx::new_allocator<std::_List_node<std::shared_ptr<objfile> > >::destroy<std::shared_ptr<objfile> > (this=0x114bc00, __p=0x190bb80) at /usr/include/c++/11/ext/new_allocator.h:168 #14 0x000000000085e88d in std::allocator_traits<std::allocator<std::_List_node<std::shared_ptr<objfile> > > >::destroy<std::shared_ptr<objfile> > (__a=..., __p=0x190bb80) at /usr/include/c++/11/bits/alloc_traits.h:531 #15 0x000000000085e50c in std::__cxx11::list<std::shared_ptr<objfile>, std::allocator<std::shared_ptr<objfile> > >::_M_erase (this=0x114bc00, __position= std::shared_ptr<objfile> (expired, weak count 1) = {get() = 0x1635930}) at /usr/include/c++/11/bits/stl_list.h:1925 #16 0x000000000085df0e in std::__cxx11::list<std::shared_ptr<objfile>, std::allocator<std::shared_ptr<objfile> > >::erase (this=0x114bc00, __position= std::shared_ptr<objfile> (expired, weak count 1) = {get() = 0x1635930}) at /usr/include/c++/11/bits/list.tcc:158 #17 0x000000000085c748 in program_space::remove_objfile (this=0x114bbc0, objfile=0x1635930) at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/progspace.c:210 #18 0x000000000082d3ae in objfile::unlink (this=0x1635930) at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/objfiles.c:487 #19 0x000000000082e68c in objfile_purge_solibs () at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/objfiles.c:875 #20 0x000000000092dd37 in no_shared_libraries (ignored=0x0, from_tty=1) at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/solib.c:1236 #21 0x00000000009a37fe in target_pre_inferior (from_tty=1) at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/target.c:2496 #22 0x00000000007454d6 in run_command_1 (args=0x0, from_tty=1, run_how=RUN_NORMAL) at /ironwood1/sourceware-git/f34-pr28030/bld/../../worktree-pr28030/gdb/infcmd.c:437 I'll note a few points regarding this backtrace: Frame #1 is where the internal error occurs. It's caused by an unhandled case for FIELD_LOC_KIND_DWARF_BLOCK. The fix for this bug adds support for this case. Frame #22 - it's a partial backtrace - shows that GDB is attempting to (re)run the program. You can see the exact command sequence that was used for reproducing this problem in the PR (at https://sourceware.org/bugzilla/show_bug.cgi?id=28030), but in a nutshell, after starting the program and advancing to the appropriate source line, GDB was asked to step into libstdc++; a "finish" command was issued, returning a value. The fact that a value was returned is very important. GDB was then used to step back into libstdc++. A breakpoint was set on a source line in the library after which a "run" command was issued. Frame #19 shows a call to objfile_purge_solibs. It's aptly named. Frame #7 is a call to the destructor for one of the objfile solibs; it turned out to be the one for libstdc++. Frames #6 thru #3 show various value preservation frames. If you look at preserve_values() in gdb/value.c, the value history is preserved first, followed by internal variables, followed by values for the extension languages (python and guile). diff --git a/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location-lib.c b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location-lib.c new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location-lib.c @@ -0,0 +1,48 @@ +/* Copyright (C) 2021 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include "locexpr-data-member-location.h" + +struct A g_A = {3, 4}; +struct B g_B = { {8, 9}, 10, 11 }; + +B * +foo () +{ /* foo prologue */ + asm ("foo_label: .globl foo_label"); + return &g_B; /* foo return */ +} /* foo end */ + +B * +bar (B *v) +{ /* bar prologue */ + asm ("bar_label: .globl bar_label"); + return v; /* bar return */ +} /* bar end */ + +/* Some of the DWARF assembler procs (e.g. function_range) compile + this file, expecting it to be a complete program with a main() + function. When IS_SHAREDLIB is NOT defined, we have main() as + defined below. */ + +#ifndef IS_SHAREDLIB +int +main () +{ + B *b = foo (); +} +#endif diff --git a/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location-main.c b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location-main.c new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location-main.c @@ -0,0 +1,27 @@ +/* Copyright (C) 2021 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include "locexpr-data-member-location.h" + +int +main (void) +{ + B *v1; + v1 = bar (foo ()); + + return 0; +} diff --git a/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp @@ -0,0 +1,349 @@ +# Copyright 2021 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# This test case uses the DWARF assembler to reproduce the problem +# described by PR28030. The bug turned out to be that +# FIELD_LOC_KIND_DWARF_BLOCK was not handled when recursively copying +# a value's type when preserving the value history during the freeing +# up of objfiles associated with a shared object. (Yes, figuring out +# how to make this happen in a concise test case turned out to be +# challenging.) +# +# The following elements proved to be necessary for reproducing the +# problem: +# +# 1) A location expression needed to be used with +# DW_AT_data_member_location rather than a simple offset. +# Moreover, this location expression needed to use opcodes +# which GDB's DWARF reader could not convert to a simple +# offset. (Note, however, that GDB could probably be improved +# to handle the opcodes chosen for this test; if decode_locdesc() +# in dwarf2/read.c is ever updated to handle both DW_OP_pick and +# DW_OP_drop, then this test could end up passing even if +# the bug it's intended to test has not been fixed.) +# +# 2) The debug info containing the above DWARF info needed +# to be associated with a shared object since the problem +# occurred while GDB was preserving values during the +# purging of shared objects. +# +# 3) After performing some simple gdb commands, the program is +# run again. In the course of running the objfile destructor +# associated with the shared object, values are preserved +# along with their types. As noted earlier, it was during +# the recursive type copy that the bug was observed. +# +# Therefore, due to #2 above, this test case creates debug info +# which is then used by a shared object. + +# This test can't be run on targets lacking shared library support. +if [skip_shlib_tests] { + return 0 +} + +load_lib dwarf.exp + +# This test can only be run on targets which support DWARF-2 and use gas. +if ![dwarf2_support] { + return 0 +} + +# gdb_test_file_name is the name of this file without the .exp +# extension. Use it to form basenames for the main program +# and shared object. +set main_basename ${::gdb_test_file_name}-main +set lib_basename ${::gdb_test_file_name}-lib + +# We're generating DWARF assembly for the shared object; therefore, +# the source file for the library / shared object must be listed first +# (in the standard_testfile invocation) since ${srcfile} is used by +# get_func_info (for determining the start, end, and length of a +# function). +# +# The output of Dwarf::assemble will be placed in $lib_basename.S +# which will be ${srcfile3} after the execution of standard_testfile. + +standard_testfile $lib_basename.c $main_basename.c $lib_basename.S + +set libsrc "${::srcdir}/${::subdir}/${::srcfile}" +set lib_so [standard_output_file ${lib_basename}.so] +set asm_file [standard_output_file ${::srcfile3}] + +# We need to know the size of some types in order to write some of the +# debugging info that we're about to generate. For that, we ask GDB +# by debugging the shared object associated with this test case. + +# Compile the shared library: -DIS_SHAREDLIB prevents main() from +# being defined. Note that debugging symbols will be present for +# this compilation. +if {[gdb_compile_shlib $libsrc $lib_so \ + {additional_flags=-DIS_SHAREDLIB debug}] != ""} { + untested "failed to compile shared library" + return +} + +# Start a fresh GDB and load the shared library. +clean_restart $lib_so + +# Using our running GDB session, determine sizes of several types. +set long_size [get_sizeof "long" -1] +set addr_size [get_sizeof "void *" -1] +set struct_A_size [get_sizeof "g_A" -1] +set struct_B_size [get_sizeof "g_B" -1] + +if { $long_size == -1 || $addr_size == -1 \ + || $struct_A_size == -1 || $struct_B_size == -1} { + perror "Can't determine type sizes" + return +} + +# Retrieve struct offset of MBR in struct TP +proc get_offsetof { tp mbr } { + return [get_integer_valueof "&((${tp} *) 0)->${mbr}" -1] +} + +# Use running GDB session to get struct offsets +set A_a [get_offsetof A a] +set A_x [get_offsetof A x] +set B_a [get_offsetof B a] +set B_b [get_offsetof B b] +set B_x2 [get_offsetof B x2] + +# Create the DWARF. +Dwarf::assemble ${asm_file} { + declare_labels L + + # Find start, end, and length of functions foo and bar. + # These calls to get_func_info will create and set variables + # foo_start, bar_start, foo_end, bar_end, foo_len, and + # bar_len. + # + # In order to get the right answers, get_func_info (and, + # underneath, function_range) should use the same compiler flags + # as those used to make a shared object. For any targets that get + # this far, -fpic is probably correct. + # + # Also, it should be noted that IS_SHAREDLIB is NOT defined as one + # of the additional flags. Not defining IS_SHAREDLIB will cause a + # main() to be defined for the compilation of the shared library + # source file which happens as a result of using get_func_info; + # this is currently required in order to this facility. + set flags {additional_flags=-fpic debug} + get_func_info foo $flags + get_func_info bar $flags + + cu {} { + DW_TAG_compile_unit { + {DW_AT_language @DW_LANG_C_plus_plus} + {name ${::srcfile}} + {stmt_list $L DW_FORM_sec_offset} + } { + declare_labels int_label class_A_label class_B_label \ + B_ptr_label + + int_label: DW_TAG_base_type { + {DW_AT_byte_size ${::long_size} DW_FORM_udata} + {DW_AT_encoding @DW_ATE_signed} + {DW_AT_name "int"} + } + + class_A_label: DW_TAG_class_type { + {DW_AT_name "A"} + {DW_AT_byte_size ${::struct_A_size} DW_FORM_sdata} + } { + DW_TAG_member { + {DW_AT_name "a"} + {DW_AT_type :$int_label} + {DW_AT_data_member_location ${::A_a} DW_FORM_udata} + } + DW_TAG_member { + {DW_AT_name "x"} + {DW_AT_type :$int_label} + {DW_AT_data_member_location ${::A_x} DW_FORM_udata} + } + } + + class_B_label: DW_TAG_class_type { + {DW_AT_name "B"} + {DW_AT_byte_size ${::struct_B_size} DW_FORM_sdata} + } { + # While there are easier / better ways to specify an + # offset used by DW_AT_data_member_location than that + # used below, we need a location expression here in + # order to reproduce the bug. Moreover, this location + # expression needs to use opcodes that aren't handled + # by decode_locdesc() in dwarf2/read.c; if we use + # opcodes that _are_ handled by that function, the + # location expression will be converted into a simple + # offset - which will then (again) not reproduce the + # bug. At the time that this test was written, + # neither DW_OP_pick nor DW_OP_drop were being handled + # by decode_locdesc(); this is why those opcodes were + # chosen. + DW_TAG_inheritance { + {DW_AT_type :$class_A_label} + {DW_AT_data_member_location { + DW_OP_constu ${::B_a} + DW_OP_plus + DW_OP_pick 0 + DW_OP_drop} SPECIAL_expr} + {DW_AT_accessibility 1 DW_FORM_data1} + } + DW_TAG_member { + {DW_AT_name "b"} + {DW_AT_type :$int_label} + {DW_AT_data_member_location ${::B_b} DW_FORM_udata} + } + DW_TAG_member { + {DW_AT_name "x2"} + {DW_AT_type :$int_label} + {DW_AT_data_member_location ${::B_x2} DW_FORM_udata} + } + } + + B_ptr_label: DW_TAG_pointer_type { + {DW_AT_type :$class_B_label} + {DW_AT_byte_size ${::addr_size} DW_FORM_sdata} + } + + DW_TAG_variable { + {DW_AT_name "g_A"} + {DW_AT_type :$class_A_label} + {DW_AT_external 1 flag} + {DW_AT_location {DW_OP_addr [gdb_target_symbol "g_A"]} \ + SPECIAL_expr} + } + + DW_TAG_variable { + {DW_AT_name "g_B"} + {DW_AT_type :$class_B_label} + {DW_AT_external 1 flag} + {DW_AT_location {DW_OP_addr [gdb_target_symbol "g_B"]} \ + SPECIAL_expr} + } + + # We can't use MACRO_AT for the definitions of foo and bar + # because it doesn't provide a way to pass the appropriate + # flags. Therefore, we list the name, low_pc, and high_pc + # explicitly. + DW_TAG_subprogram { + {DW_AT_name foo} + {DW_AT_low_pc $foo_start DW_FORM_addr} + {DW_AT_high_pc $foo_end DW_FORM_addr} + {DW_AT_type :${B_ptr_label}} + {DW_AT_external 1 flag} + } + + DW_TAG_subprogram { + {DW_AT_name bar} + {DW_AT_low_pc $bar_start DW_FORM_addr} + {DW_AT_high_pc $bar_end DW_FORM_addr} + {DW_AT_type :${B_ptr_label}} + {DW_AT_external 1 flag} + } { + DW_TAG_formal_parameter { + {DW_AT_name v} + {DW_AT_type :${B_ptr_label}} + } + } + } + } + + lines {version 2} L { + include_dir "${::srcdir}/${::subdir}" + file_name "${::srcfile}" 1 + + # Generate a line table program. + program { + {DW_LNE_set_address $foo_start} + {line [gdb_get_line_number "foo prologue"]} + {DW_LNS_copy} + {DW_LNE_set_address foo_label} + {line [gdb_get_line_number "foo return"]} + {DW_LNS_copy} + {line [gdb_get_line_number "foo end"]} + {DW_LNS_copy} + {DW_LNE_set_address $foo_end} + {DW_LNS_advance_line 1} + {DW_LNS_copy} + {DW_LNE_end_sequence} + + {DW_LNE_set_address $bar_start} + {line [gdb_get_line_number "bar prologue"]} + {DW_LNS_copy} + {DW_LNE_set_address bar_label} + {line [gdb_get_line_number "bar return"]} + {DW_LNS_copy} + {line [gdb_get_line_number "bar end"]} + {DW_LNS_copy} + {DW_LNE_set_address $bar_end} + {DW_LNS_advance_line 1} + {DW_LNS_copy} + {DW_LNE_end_sequence} + } + } +} + +# Compile the shared object again, but this time include / use the +# DWARF info that we've created above. Note that (again) +# -DIS_SHAREDLIB is used to prevent inclusion of main() in the shared +# object. Also note the use of the "nodebug" option. Any debugging +# information that we need will be provided by the DWARF info created +# above. +if {[gdb_compile_shlib [list $libsrc $asm_file] $lib_so \ + {additional_flags=-DIS_SHAREDLIB nodebug}] != ""} { + untested "failed to compile shared library" + return +} + +# Compile the main program for use with the shared object. +if [prepare_for_testing "failed to prepare" ${testfile} \ + ${::srcfile2} [list debug shlib=$lib_so]] { + return -1 +} + +# Do whatever is necessary to make sure that the shared library is +# loaded for remote targets. +gdb_load_shlib ${lib_so} + +if ![runto_main] then { + fail "can't run to main" + return +} + +# Step into foo so that we can finish out of it. +gdb_test "step" "foo .. at .* foo end.*" "step into foo" + +# Finishing out of foo will create a value that will later need to +# be preserved when restarting the program. +gdb_test "finish" "= \\(class B \\*\\) ${::hex} .*" "finish out of foo" + +# Dereferencing and printing the return value isn't necessary +# for reproducing the bug, but we should make sure that the +# return value is what we expect it to be. +gdb_test "p *$" { = {<A> = {a = 8, x = 9}, b = 10, x2 = 11}} \ + "dereference return value" + +# The original PR28030 reproducer stepped back into the shared object, +# so we'll do the same here: +gdb_test "step" "bar \\(.*" "step into bar" + +# We don't want a clean restart here since that will be too clean. +# The original reproducer for PR28030 set a breakpoint in the shared +# library and then restarted via "run". The command below does roughly +# the same thing. It's at this step that an internal error would +# occur for PR28030. The "message" argument tells runto to turn on +# the printing of PASSes while runto is doing its job. +runto "bar" message diff --git a/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.h b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.h new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.h @@ -0,0 +1,30 @@ +/* Copyright (C) 2021 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/>. */ + +typedef struct A { + long a; + long x; +} A; + +typedef struct B { + A a; + long b; + long x2; +} B; + +extern B *foo (); +extern B *bar (B *v); ++++++ gdb-test-ivy-bridge.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.665340883 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.665340883 +0100 @@ -57,21 +57,21 @@ + vcvtps2ph $0x2,%ymm4,%xmm4 + vcvtps2ph $0x2,%ymm8,(%r8) + vcvtps2ph $0x2,%xmm4,%xmm4 -+ vcvtps2ph $0x2,%xmm4,(%rcx) ++ vcvtps2ph $0x2,%xmm4,(%rcx) + + .intel_syntax noprefix + vcvtph2ps ymm4,xmm4 + vcvtph2ps ymm8,XMMWORD PTR [r8] + vcvtph2ps ymm4,[rcx] + vcvtph2ps xmm6,xmm4 -+ vcvtph2ps xmm4,QWORD PTR [rcx] ++ vcvtph2ps xmm4,QWORD PTR [rcx] + vcvtph2ps xmm4,[rcx] + vcvtps2ph xmm4,ymm4,0x2 -+ vcvtps2ph XMMWORD PTR [rcx],ymm4,0x2 -+ vcvtps2ph [rcx],ymm4,0x2 ++ vcvtps2ph XMMWORD PTR [rcx],ymm4,0x2 ++ vcvtps2ph [rcx],ymm4,0x2 + vcvtps2ph xmm4,xmm4,0x2 -+ vcvtps2ph QWORD PTR [r8],xmm8,0x2 -+ vcvtps2ph [rcx],xmm4,0x2 ++ vcvtps2ph QWORD PTR [r8],xmm8,0x2 ++ vcvtps2ph [rcx],xmm4,0x2 + +/* gas/i386/x86-64-fsgs.s */ + .att_syntax prefix @@ -80,34 +80,34 @@ + rdfsbase %r8d + rdfsbase %r8 + rdgsbase %ebx -+ rdgsbase %rbx -+ rdgsbase %r8d -+ rdgsbase %r8 -+ wrfsbase %ebx -+ wrfsbase %rbx -+ wrfsbase %r8d -+ wrfsbase %r8 -+ wrgsbase %ebx -+ wrgsbase %rbx -+ wrgsbase %r8d -+ wrgsbase %r8 ++ rdgsbase %rbx ++ rdgsbase %r8d ++ rdgsbase %r8 ++ wrfsbase %ebx ++ wrfsbase %rbx ++ wrfsbase %r8d ++ wrfsbase %r8 ++ wrgsbase %ebx ++ wrgsbase %rbx ++ wrgsbase %r8d ++ wrgsbase %r8 + + .intel_syntax noprefix -+ rdfsbase ebx -+ rdfsbase rbx -+ rdfsbase r8d ++ rdfsbase ebx ++ rdfsbase rbx ++ rdfsbase r8d + rdfsbase r8 -+ rdgsbase ebx -+ rdgsbase rbx -+ rdgsbase r8d ++ rdgsbase ebx ++ rdgsbase rbx ++ rdgsbase r8d + rdgsbase r8 -+ wrfsbase ebx -+ wrfsbase rbx -+ wrfsbase r8d ++ wrfsbase ebx ++ wrfsbase rbx ++ wrfsbase r8d + wrfsbase r8 -+ wrgsbase ebx -+ wrgsbase rbx -+ wrgsbase r8d ++ wrgsbase ebx ++ wrgsbase rbx ++ wrgsbase r8d + wrgsbase r8 diff --git a/gdb/testsuite/gdb.arch/amd64-ivy-bridge.exp b/gdb/testsuite/gdb.arch/amd64-ivy-bridge.exp new file mode 100644 @@ -136,7 +136,7 @@ +set testfile amd64-ivy-bridge +set test compilation +if [prepare_for_testing ${testfile}.exp ${testfile}.x ${testfile}.S [list debug "additional_flags=-m64 -nostdlib"]] { -+ fail $test ++ unsupported $test + return -1 +} +pass $test @@ -288,7 +288,7 @@ new file mode 100644 --- /dev/null +++ b/gdb/testsuite/gdb.arch/i386-ivy-bridge.S -@@ -0,0 +1,67 @@ +@@ -0,0 +1,66 @@ +/* Copyright 2011 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify @@ -325,23 +325,23 @@ + vcvtph2ps %xmm4,%xmm6 + vcvtph2ps (%ecx),%xmm4 + vcvtps2ph $0x2,%ymm4,%xmm4 -+ vcvtps2ph $0x2,%ymm4,(%ecx) ++ vcvtps2ph $0x2,%ymm4,(%ecx) + vcvtps2ph $0x2,%xmm4,%xmm4 -+ vcvtps2ph $0x2,%xmm4,(%ecx) ++ vcvtps2ph $0x2,%xmm4,(%ecx) + + .intel_syntax noprefix + vcvtph2ps ymm4,xmm4 + vcvtph2ps ymm4,XMMWORD PTR [ecx] + vcvtph2ps ymm4,[ecx] + vcvtph2ps xmm6,xmm4 -+ vcvtph2ps xmm4,QWORD PTR [ecx] ++ vcvtph2ps xmm4,QWORD PTR [ecx] + vcvtph2ps xmm4,[ecx] + vcvtps2ph xmm4,ymm4,0x2 -+ vcvtps2ph XMMWORD PTR [ecx],ymm4,0x2 -+ vcvtps2ph [ecx],ymm4,0x2 ++ vcvtps2ph XMMWORD PTR [ecx],ymm4,0x2 ++ vcvtps2ph [ecx],ymm4,0x2 + vcvtps2ph xmm4,xmm4,0x2 -+ vcvtps2ph QWORD PTR [ecx],xmm4,0x2 -+ vcvtps2ph [ecx],xmm4,0x2 ++ vcvtps2ph QWORD PTR [ecx],xmm4,0x2 ++ vcvtps2ph [ecx],xmm4,0x2 + +/* gas/i386/fsgs.s */ + .att_syntax prefix @@ -351,11 +351,10 @@ + wrgsbase %ebx + + .intel_syntax noprefix -+ rdfsbase ebx -+ rdgsbase ebx -+ wrfsbase ebx -+ wrgsbase ebx -+ ++ rdfsbase ebx ++ rdgsbase ebx ++ wrfsbase ebx ++ wrgsbase ebx diff --git a/gdb/testsuite/gdb.arch/i386-ivy-bridge.exp b/gdb/testsuite/gdb.arch/i386-ivy-bridge.exp new file mode 100644 --- /dev/null ++++++ gdb-test-pid0-core.patch ++++++ --- /var/tmp/diff_new_pack.vTGfIi/_old 2021-11-01 18:35:51.673340888 +0100 +++ /var/tmp/diff_new_pack.vTGfIi/_new 2021-11-01 18:35:51.673340888 +0100 @@ -45,22 +45,22 @@ +++ b/gdb/testsuite/gdb.arch/x86_64-pid0-core.exp @@ -0,0 +1,46 @@ +# This testcase is part of GDB, the GNU debugger. -+# ++# +# Copyright 2010 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 2 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, write to the Free Software -+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ++# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Some kernel core files have PID 0 - for the idle task. + ++++++ gdb-testsuite-Fix-gdb.threads-thread-specific-bp.exp.patch ++++++ [gdb/testsuite] Fix gdb.threads/thread-specific-bp.exp On OBS I ran into a failure in test-case gdb.threads/thread-specific-bp.exp: ... (gdb) PASS: gdb.threads/thread-specific-bp.exp: non-stop: continue to end info breakpoint^M Num Type Disp Enb Address What^M 1 breakpoint keep y 0x0000555555555167 in main at $src:36^M breakpoint already hit 1 time^M 2 breakpoint keep y 0x0000555555555151 in start at $src:23^M breakpoint already hit 1 time^M 3 breakpoint keep y 0x0000555555555167 in main at $src:36 thread 2^M stop only in thread 2^M 4 breakpoint keep y 0x000055555555515c in end at $src:29^M breakpoint already hit 1 time^M (gdb) [Thread 0x7ffff7db1640 (LWP 19984) exited]^M Thread-specific breakpoint 3 deleted - thread 2 no longer in the thread list.^M FAIL: gdb.threads/thread-specific-bp.exp: non-stop: \ thread-specific breakpoint was deleted (timeout) ... Fix this by waiting for the "[Thread 0x7ffff7db1640 (LWP 19984) exited]" message before issuing the "info breakpoint command". Tested on x86_64-linux. --- gdb/testsuite/gdb.threads/thread-specific-bp.exp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/gdb/testsuite/gdb.threads/thread-specific-bp.exp b/gdb/testsuite/gdb.threads/thread-specific-bp.exp index 331f9470c22..ceb2c25b066 100644 --- a/gdb/testsuite/gdb.threads/thread-specific-bp.exp +++ b/gdb/testsuite/gdb.threads/thread-specific-bp.exp @@ -87,9 +87,24 @@ proc check_thread_specific_breakpoint {mode} { set cmd "continue" } set test "continue to end" - gdb_test_multiple "$cmd" $test { - -re "Breakpoint .* end .* at .*\r\n$gdb_prompt " { - pass $test + set thread_exited 0 + set prompt 0 + gdb_test_multiple "$cmd" $test -lbl { + -re "\\\[Thread \[^\r\n\]* exited](?=\r\n)" { + if { $prompt } { + pass $gdb_test_name + } else { + set thread_exited 1 + exp_continue + } + } + -re -wrap "" { + if { $thread_exited } { + pass $gdb_test_name + } else { + set prompt 1 + exp_continue + } } } ++++++ gdb-testsuite-add-checks-to-gdb.arch-i386-sse.exp.patch ++++++ [gdb/testsuite] Add checks to gdb.arch/i386-sse.exp In test-case gdb.arch/i386-sse.exp, add the steps marked with "(added)": - verify data array (added) - initialize regs from data array - verify regs - modify regs - verify modified regs (added) - write back regs to data array - verify updated data array This in the hope to catch more information about failures in this test-case reported in PR28504. Also use gdb_test_no_output instead of gdb_test for the "modify regs" step. Tested on x86_64-linux. --- gdb/testsuite/gdb.arch/i386-sse.exp | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/gdb/testsuite/gdb.arch/i386-sse.exp b/gdb/testsuite/gdb.arch/i386-sse.exp index fca90256505..57f62694e6e 100644 --- a/gdb/testsuite/gdb.arch/i386-sse.exp +++ b/gdb/testsuite/gdb.arch/i386-sse.exp @@ -64,17 +64,26 @@ gdb_expect { } } -gdb_test "break [gdb_get_line_number "first breakpoint here"]" \ - "Breakpoint .* at .*i386-sse.c.*" \ - "set first breakpoint in main" -gdb_continue_to_breakpoint "continue to first breakpoint in main" - if [is_amd64_regs_target] { set nr_regs 16 } else { set nr_regs 8 } +# Verify data array. +for { set r 0 } { $r < $nr_regs } { incr r } { + gdb_test "print data\[$r\]" \ + ".. = \\{f = \\{$r, $r.25, $r.5, $r.75\\}\\}.*" \ + "check contents of data\[$r\]" +} + +# Initialize regs from data array. +gdb_test "break [gdb_get_line_number "first breakpoint here"]" \ + "Breakpoint .* at .*i386-sse.c.*" \ + "set first breakpoint in main" +gdb_continue_to_breakpoint "continue to first breakpoint in main" + +# Verify regs. for { set r 0 } { $r < $nr_regs } { incr r } { gdb_test "print \$xmm$r.v4_float" \ ".. = \\{$r, $r.25, $r.5, $r.75\\}.*" \ @@ -84,17 +93,27 @@ for { set r 0 } { $r < $nr_regs } { incr r } { "check int8 contents of %xmm$r" } +# Modify regs. for { set r 0 } { $r < $nr_regs } { incr r } { - gdb_test "set var \$xmm$r.v4_float\[0\] = $r + 10" "" "set %xmm$r" + gdb_test_no_output "set var \$xmm$r.v4_float\[0\] = $r + 10" "set %xmm$r" } +# Verify modified regs. +for { set r 0 } { $r < $nr_regs } { incr r } { + gdb_test "print \$xmm$r.v4_float" \ + ".. = \\{[expr $r + 10], $r.25, $r.5, $r.75\\}.*" \ + "check contents of %xmm$r" +} + +# Write back regs to data array. gdb_test "break [gdb_get_line_number "second breakpoint here"]" \ "Breakpoint .* at .*i386-sse.c.*" \ "set second breakpoint in main" gdb_continue_to_breakpoint "continue to second breakpoint in main" +# Verify updated data array. for { set r 0 } { $r < $nr_regs } { incr r } { gdb_test "print data\[$r\]" \ ".. = \\{f = \\{[expr $r + 10], $r.25, $r.5, $r.75\\}\\}.*" \ - "check contents of data\[$r\]" + "check contents of updated data\[$r\]" } ++++++ gdb-testsuite-add-gdb.testsuite-dump-system-info.exp.patch ++++++ [gdb/testsuite] Add gdb.testsuite/dump-system-info.exp When interpreting the testsuite results, it's often relevant what kind of machine the testsuite ran on. On a local machine one can just do /proc/cpuinfo, but in case of running tests using a remote system that distributes test runs to other remote systems that are not directly accessible, that's not possible. Fix this by dumping /proc/cpuinfo into the gdb.log, as well as lsb_release -a and uname -a. We could do this at the start of each test run, by putting it into unix.exp or some such. However, this might be too verbose, so we choose to put it into its own test-case, such that it get triggered in a full testrun, but not when running one or a subset of tests. We put the test-case into the gdb.testsuite directory, which is currently the only place in the testsuite where we do not test gdb. [ Though perhaps this could be put into a new gdb.info directory, since the test-case doesn't actually test the testsuite. ] Tested on x86_64-linux. --- gdb/testsuite/gdb.testsuite/dump-system-info.exp | 48 ++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/gdb/testsuite/gdb.testsuite/dump-system-info.exp b/gdb/testsuite/gdb.testsuite/dump-system-info.exp new file mode 100644 index 00000000000..bf181469bd5 --- /dev/null +++ b/gdb/testsuite/gdb.testsuite/dump-system-info.exp @@ -0,0 +1,48 @@ +# Copyright 2021 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/>. + +# The purpose of this test-case is to dump /proc/cpuinfo and similar system +# info into gdb.log. + +# Check if /proc/cpuinfo is available. +set res [remote_exec target "test -r /proc/cpuinfo"] +set status [lindex $res 0] +set output [lindex $res 1] + +if { $status == 0 && $output == "" } { + verbose -log "Cpuinfo available, dumping:" + remote_exec target "cat /proc/cpuinfo" +} else { + verbose -log "Cpuinfo not available" +} + +set res [remote_exec target "lsb_release -a"] +set status [lindex $res 0] +set output [lindex $res 1] + +if { $status == 0 } { + verbose -log "lsb_release -a availabe, dumping:\n$output" +} else { + verbose -log "lsb_release -a not available" +} + +set res [remote_exec target "uname -a"] +set status [lindex $res 0] +set output [lindex $res 1] + +if { $status == 0 } { + verbose -log "uname -a availabe, dumping:\n$output" +} else { + verbose -log "uname -a not available" +} ++++++ gdb-testsuite-add-kfail-in-gdb.threads-fork-plus-threads.exp.patch ++++++ [gdb/testsuite] Add KFAIL in gdb.threads/fork-plus-threads.exp When running test-case gdb.threads/fork-and-threads.exp on a VM with openSUSE Tumbleweed, with the VM bound to 1 cpu with 75% execution cap, I get: ... (gdb) info inferiors^M Num Description Connection Executable ^M * 1 <null> fork-plus-threads ^M 11 <null> fork-plus-threads ^M (gdb) FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: \ only inferior 1 left ... The test checks that all removable inferiors are indeed removed from the inferior list after exit, and evidently this didn't happen for inferior 11 (which is added by fork rather than a user command, and therefore removable). I've investigated why that is that case, and it's because its refcount didn't drop to 0. This seems like a bug to me, so add a KFAIL for this. Tested on x86_64-linux. --- gdb/testsuite/gdb.threads/fork-plus-threads.exp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/gdb/testsuite/gdb.threads/fork-plus-threads.exp b/gdb/testsuite/gdb.threads/fork-plus-threads.exp index c8e179938c6..5b2b0909a65 100644 --- a/gdb/testsuite/gdb.threads/fork-plus-threads.exp +++ b/gdb/testsuite/gdb.threads/fork-plus-threads.exp @@ -119,9 +119,21 @@ proc do_test { detach-on-fork } { gdb_test "info threads" "No threads\." \ "no threads left" - gdb_test "info inferiors" \ - "Num\[ \t\]+Description\[ \t\]+Connection\[ \t\]+Executable\[ \t\]+\r\n\\* 1 \[^\r\n\]+" \ - "only inferior 1 left" + set re \ + [multi_line \ + "Num\[ \t\]+Description\[ \t\]+Connection\[ \t\]+Executable\[ \t\]+" \ + "\\* 1 \[^\r\n\]+"] + gdb_test_multiple "info inferiors" "only inferior 1 left" { + -re -wrap $re { + pass $gdb_test_name + } + -re -wrap $re.* { + if { ${detach-on-fork} == "off" } { + setup_kfail "threads/26272" *-*-* + } + fail $gdb_test_name + } + } } foreach_with_prefix detach-on-fork {"on" "off"} { ++++++ gdb-testsuite-add-nopie-in-two-test-cases.patch ++++++ [gdb/testsuite] Add nopie in two test-cases When running test-case gdb.dwarf2/dw2-restrict.exp on openSUSE Leap 15.2 with gcc-PIE installed (switching compiler default to -fPIE/-pie), I get: ... gdb compile failed, ld: outputs/gdb.dwarf2/dw2-restrict/dw2-restrict0.o: \ warning: relocation in read-only section `.text' ld: warning: creating DT_TEXTREL in a PIE UNTESTED: gdb.dwarf2/dw2-restrict.exp: failed to prepare ... This is due to using a hardcoded .S file that was generated with -fno-PIE. Fix this by adding the missing nopie. Likewise in gdb.arch/amd64-tailcall-noret.exp. Tested on x86_64-linux. --- gdb/testsuite/gdb.arch/amd64-tailcall-noret.exp | 2 ++ gdb/testsuite/gdb.dwarf2/dw2-restrict.exp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.arch/amd64-tailcall-noret.exp b/gdb/testsuite/gdb.arch/amd64-tailcall-noret.exp index c68abce61e3..fb1d5695a11 100644 --- a/gdb/testsuite/gdb.arch/amd64-tailcall-noret.exp +++ b/gdb/testsuite/gdb.arch/amd64-tailcall-noret.exp @@ -25,6 +25,8 @@ if [info exists COMPILE] { return } +lappend opts nopie + if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } { return -1 } diff --git a/gdb/testsuite/gdb.dwarf2/dw2-restrict.exp b/gdb/testsuite/gdb.dwarf2/dw2-restrict.exp index 6f98b6cfb18..2a46510c7a3 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-restrict.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-restrict.exp @@ -27,7 +27,8 @@ if {![istarget x86_64-*] || ![is_lp64_target]} { standard_testfile .S -if {[prepare_for_testing "failed to prepare" $testfile $srcfile {nodebug}]} { +if {[prepare_for_testing "failed to prepare" $testfile $srcfile \ + {nodebug nopie}]} { return -1 } ++++++ gdb-testsuite-factor-out-dump_info-in-gdb.testsuite-dump-system-info.exp.patch ++++++ [gdb/testsuite] Factor out dump_info in gdb.testsuite/dump-system-info.exp Factor out new proc dump_info in test-case gdb.testsuite/dump-system-info.exp, and in the process: - fix a few typos - remove unnecessary "test -r /proc/cpuinfo" Tested on x86_64-linux. Co-Authored-By: Pedro Alves <pedro@palves.net> --- gdb/testsuite/gdb.testsuite/dump-system-info.exp | 42 +++++++++--------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/gdb/testsuite/gdb.testsuite/dump-system-info.exp b/gdb/testsuite/gdb.testsuite/dump-system-info.exp index bf181469bd5..1831479265c 100644 --- a/gdb/testsuite/gdb.testsuite/dump-system-info.exp +++ b/gdb/testsuite/gdb.testsuite/dump-system-info.exp @@ -15,34 +15,24 @@ # The purpose of this test-case is to dump /proc/cpuinfo and similar system # info into gdb.log. -# Check if /proc/cpuinfo is available. -set res [remote_exec target "test -r /proc/cpuinfo"] -set status [lindex $res 0] -set output [lindex $res 1] -if { $status == 0 && $output == "" } { - verbose -log "Cpuinfo available, dumping:" - remote_exec target "cat /proc/cpuinfo" -} else { - verbose -log "Cpuinfo not available" -} - -set res [remote_exec target "lsb_release -a"] -set status [lindex $res 0] -set output [lindex $res 1] +proc dump_info {cmd {what ""}} { -if { $status == 0 } { - verbose -log "lsb_release -a availabe, dumping:\n$output" -} else { - verbose -log "lsb_release -a not available" -} + if {$what == ""} { + set what $cmd + } -set res [remote_exec target "uname -a"] -set status [lindex $res 0] -set output [lindex $res 1] + set res [remote_exec target $cmd] + set status [lindex $res 0] + set output [lindex $res 1] -if { $status == 0 } { - verbose -log "uname -a availabe, dumping:\n$output" -} else { - verbose -log "uname -a not available" + if { $status == 0 } { + verbose -log "$what available, dumping:\n$output" + } else { + verbose -log "$what not available" + } } + +dump_info "cat /proc/cpuinfo" "Cpuinfo" +dump_info "uname -a" +dump_info "lsb_release -a" ++++++ gdb-testsuite-fix-fail-in-gdb.base-annota1.exp.patch ++++++ [gdb/testsuite] Fix FAIL in gdb.base/annota1.exp On openSUSE tumbleweed I run into: ... FAIL: gdb.base/annota1.exp: run until main breakpoint (timeout) ... due to a message related to libthread_db: ... ^Z^Zstarting^M [Thread debugging using libthread_db enabled]^M Using host libthread_db library "/lib64/libthread_db.so.1".^M ^M ^Z^Zframes-invalid^M ... which is not matched by the regexp. Fix this by updating the regexp. Tested on x86_64-linux. --- gdb/testsuite/gdb.base/annota1.exp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.base/annota1.exp b/gdb/testsuite/gdb.base/annota1.exp index 6e30c164ec9..046e942a321 100644 --- a/gdb/testsuite/gdb.base/annota1.exp +++ b/gdb/testsuite/gdb.base/annota1.exp @@ -138,6 +138,10 @@ set warning_gdb_index_re \ "to use the section anyway\\."] set reading_re \ "Reading \[^\r\n\]+" +set libthread_db_re \ + [multi_line \ + "\\\[Thread debugging using libthread_db enabled\\\]" \ + "Using host libthread_db library \[^\r\n\]+"] set run_re \ [list \ @@ -145,7 +149,7 @@ set run_re \ "\(\(\r\n$reading_re\)|\(\r\n$warning_slow_re\)\)*" \ "\(\r\n$warning_gdb_index_re\)?" \ "\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)*\r\n\r\n" \ - "\032\032starting\(\(\r\n$reading_re\)|\(\r\n$warning_slow_re\)\)*" \ + "\032\032starting\(\(\r\n$reading_re\)|\(\r\n$warning_slow_re\)|\r\n$libthread_db_re\)*" \ "\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)*\r\n\r\n" \ "\032\032breakpoint 1\r\n\r\n" \ "Breakpoint 1, \r\n" \ ++++++ gdb-testsuite-fix-fail-in-gdb.threads-fork-and-threads.exp.patch ++++++ [gdb/testsuite] Fix FAIL in gdb.threads/fork-and-threads.exp As reported in PR26272, when running test-case gdb.threads/fork-and-threads.exp on a VM with openSUSE Tumbleweed, with the VM bound to 1 cpu with 75% execution cap, I get: ... [Inferior 1 (process 21928) exited normally]PASS: \ gdb.threads/fork-plus-threads.exp: detach-on-fork=off: inferior 1 exited PASS: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: \ no failure to remove breakpoints PASS: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: \ no spurious thread stop ^M info threads^M Id Target Id Frame ^M 11.11 Thread 0x7ffff3470700 (LWP 22041) (running)^M ^M No selected thread. See `help thread'.^M (gdb) FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: \ no threads left [Inferior 11 (process 21990) exited normally]^M info inferiors^M Num Description Connection Executable ^M * 1 <null> fork-plus-threads ^M 11 <null> fork-plus-threads ^M (gdb) FAIL: gdb.threads/fork-plus-threads.exp: detach-on-fork=off: \ only inferior 1 left (the program exited) ... The initial process (inferior 1) creates 10 child processes, and then waits on the child processes. Consequently, the initial process is also the last process to exit. However, in the log above we see: ... [Inferior 1 (process 21928) exited normally] ... [Inferior 11 (process 21990) exited normally] ... This seems counter-intuitive: if inferior 1 is the last to exit, shouldn't we see it last? However, looking at the debug infrun log: ... [infrun] fetch_inferior_event: enter [infrun] scoped_disable_commit_resumed: reason=handling event [infrun] do_target_wait: Found 2 inferiors, starting at #0 [infrun] random_pending_event_thread: None found. [infrun] print_target_wait_results: target_wait (-1.0.0 [process -1], status) = [infrun] print_target_wait_results: 17202.17202.0 [Thread 0x7ffff7c79740 (LWP 17202)], [infrun] print_target_wait_results: status->kind = exited, status = 0 [infrun] handle_inferior_event: status->kind = exited, status = 0 [Inferior 1 (process 17202) exited normally] [infrun] stop_waiting: stop_waiting [infrun] reset: reason=handling event [infrun] maybe_set_commit_resumed_all_targets: enabling commit-resumed for target native [infrun] maybe_call_commit_resumed_all_targets: calling commit_resumed for target native [infrun] fetch_inferior_event: exit [infrun] fetch_inferior_event: enter [infrun] scoped_disable_commit_resumed: reason=handling event [infrun] random_pending_event_thread: None found. [infrun] print_target_wait_results: target_wait (-1.0.0 [process -1], status) = [infrun] print_target_wait_results: 17215.17215.0 [Thread 0x7ffff7c79740 (LWP 17215)], [infrun] print_target_wait_results: status->kind = exited, status = 0 [infrun] handle_inferior_event: status->kind = exited, status = 0 [Inferior 11 (process 17215) exited normally] ... this seems plausible. Doing a waitpid with a pid of -1 will wait for any child process, and if both inferior 1 and 11 have exited, and not yet been reaped, waitpid may return any of the two. Fix the first FAIL by waiting for all inferiors to exit, rather than waiting for inferior 1 to exit, assuming it's the last. Tested on x86_64-linux. --- gdb/testsuite/gdb.threads/fork-plus-threads.exp | 31 ++++++++++++++----------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/gdb/testsuite/gdb.threads/fork-plus-threads.exp b/gdb/testsuite/gdb.threads/fork-plus-threads.exp index 7fe3c603bcd..8540fbf3082 100644 --- a/gdb/testsuite/gdb.threads/fork-plus-threads.exp +++ b/gdb/testsuite/gdb.threads/fork-plus-threads.exp @@ -33,6 +33,7 @@ proc do_test { detach-on-fork } { global GDBFLAGS global srcfile testfile global gdb_prompt + global decimal set saved_gdbflags $GDBFLAGS set GDBFLAGS [concat $GDBFLAGS " -ex \"set non-stop on\""] @@ -51,6 +52,12 @@ proc do_test { detach-on-fork } { } gdb_test_no_output "set detach-on-fork ${detach-on-fork}" + if { ${detach-on-fork} == "on" } { + set expected_exits 1 + } else { + set expected_exits 11 + } + set test "continue &" gdb_test_multiple $test $test { -re "$gdb_prompt " { @@ -77,26 +84,22 @@ proc do_test { detach-on-fork } { set saw_cannot_remove_breakpoints 0 set saw_thread_stopped 0 - set test "inferior 1 exited" - gdb_test_multiple "" $test { - -re "Cannot remove breakpoints" { + set nr_exits 0 + gdb_test_multiple "" "last inferior exited" -lbl { + -re "^\r\nCannot remove breakpoints \[^\r\n\]+\\.(?=\r\n)" { set saw_cannot_remove_breakpoints 1 exp_continue } - -re "Thread \[^\r\n\]+ stopped\\." { + -re "^\r\n\\\[Thread \[^\r\n\]+ stopped\\.(?=\r\n)" { set saw_thread_stopped 1 exp_continue } - -re "(Thread|LWP) \[^\r\n\]+ exited" { - # Avoid timeout with check-read1 - exp_continue - } - -re "New (Thread|LWP) \[^\r\n\]+" { - # Avoid timeout with check-read1 - exp_continue - } - -re "Inferior 1 \(\[^\r\n\]+\) exited normally" { - pass $test + -re "^\r\n\\\[Inferior $decimal \(\[^\r\n\]+\) exited normally\\\](?=\r\n)" { + incr nr_exits + if { $nr_exits < $expected_exits } { + exp_continue + } + pass $gdb_test_name } } ++++++ gdb-testsuite-fix-fail-in-gdb.tui-corefile-run.exp.patch ++++++ [gdb/testsuite] Fix FAIL in gdb.tui/corefile-run.exp When running test-case gdb.tui/corefile-run.exp on openSUSE Tumbleweed, I run into: ... PASS: gdb.tui/corefile-run.exp: load corefile FAIL: gdb.tui/corefile-run.exp: run until the end ... What's going on is easier to see when also doing dump_screen if check_contents passes, and inspecting state at the preceding PASS: ... +-------------------------------------------------------------------------+ exec No process In: L?? PC: ?? [New LWP 16629] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Core was generated by `/data/gdb_versions/devel/build/gdb/testsuite/output s/gdb.tui/corefile-run/corefi'. Program terminated with signal SIGTRAP, Trace/breakpoint trap. #0 main () --Type <RET> for more, q to quit, c to continue without paging-- ... The problem is that we're getting a pagination prompt, and the subsequent run command is interpreted as an answer to that prompt. Fix this by: - detecting the gdb prompt in response to "load corefile", such that we detect the failure earlier, and - doing a "set pagination off" in Term::clean_restart. Tested on x86_64-linux. --- gdb/testsuite/gdb.tui/corefile-run.exp | 2 +- gdb/testsuite/lib/tuiterm.exp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.tui/corefile-run.exp b/gdb/testsuite/gdb.tui/corefile-run.exp index d53149fb648..b3da6d1e67c 100644 --- a/gdb/testsuite/gdb.tui/corefile-run.exp +++ b/gdb/testsuite/gdb.tui/corefile-run.exp @@ -55,7 +55,7 @@ gdb_assert {![string match "No Source Available" $text]} \ "initial source listing" Term::command "core-file $core" -Term::check_contents "load corefile" "21 *return 0" +Term::check_contents "load corefile" "21 *return 0.*$gdb_prompt .*" Term::command "run" Term::check_contents "run until the end" \ diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp index 222583f291f..ad5cbb72ea5 100644 --- a/gdb/testsuite/lib/tuiterm.exp +++ b/gdb/testsuite/lib/tuiterm.exp @@ -595,6 +595,7 @@ namespace eval Term { } else { ::clean_restart $executable } + ::gdb_test_no_output "set pagination off" } } ++++++ gdb-testsuite-fix-gdb.ada-big_packed_array.exp-xfail-for-m32.patch ++++++ [gdb/testsuite] Fix gdb.ada/big_packed_array.exp xfail for -m32 With test-case gdb.ada/big_packed_array.exp and target board unix/-m32 I run into: ... (gdb) print bad^M $2 = (0 => 0 <repeats 24 times>, 160)^M (gdb) FAIL: gdb.ada/big_packed_array.exp: scenario=minimal: print bad ... The problem is that while the variable is an array of 196 bits (== 24.5 bytes), the debug information describes it as 25 unsigned char. This is PR gcc/101643, and the test-case contains an xfail for this, which catches only: ... (gdb) print bad^M $2 = (0 => 0 <repeats 25 times>)^M ... Fix this by updating the xfail pattern. Tested on x86_64-linux. --- gdb/testsuite/gdb.ada/big_packed_array.exp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gdb/testsuite/gdb.ada/big_packed_array.exp b/gdb/testsuite/gdb.ada/big_packed_array.exp index 32ff0dd3e1c..e62f053166b 100644 --- a/gdb/testsuite/gdb.ada/big_packed_array.exp +++ b/gdb/testsuite/gdb.ada/big_packed_array.exp @@ -43,6 +43,7 @@ foreach_with_prefix scenario {all minimal} { set re "= \\(false <repeats 196 times>\\)" set re_xfail "= \\(0 => 0 <repeats 25 times>\\)" + set re_xfail2 "= \\(0 => 0 <repeats 24 times>, ($decimal)\\)" gdb_test_multiple "print bad" "" { -re -wrap $re { pass $gdb_test_name @@ -54,5 +55,14 @@ foreach_with_prefix scenario {all minimal} { } fail $gdb_test_name } + -re -wrap $re_xfail2 { + set last $expect_out(1,string) + if { $have_xfail && [string is integer $last] \ + && [expr ($last & 0xf) == 0] } { + # gcc/101643 + setup_xfail *-*-* + } + fail $gdb_test_name + } } } ++++++ gdb-testsuite-fix-gdb.base-dcache-flush.exp.patch ++++++ [gdb/testsuite] Fix gdb.base/dcache-flush.exp When running test-case gdb.base/dcache-flush.exp on ubuntu 18.04.5, I run into: ... (gdb) PASS: gdb.base/dcache-flush.exp: p var2 info dcache^M Dcache 4096 lines of 64 bytes each.^M Contains data for Thread 0x7ffff7fc6b80 (LWP 3551)^M Line 0: address 0x7fffffffd4c0 [47 hits]^M Line 1: address 0x7fffffffd500 [31 hits]^M Line 2: address 0x7fffffffd5c0 [7 hits]^M Cache state: 3 active lines, 85 hits^M (gdb) FAIL: gdb.base/dcache-flush.exp: check dcache before flushing ... The regexp expects "Contains data for process $decimal". This is another case of thread_db_target::pid_to_str being used. Fix this by updating the regexp. Tested on x86_64-linux. --- gdb/testsuite/gdb.base/dcache-flush.exp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.base/dcache-flush.exp b/gdb/testsuite/gdb.base/dcache-flush.exp index 4ac10b9fab1..ff59b2bb7ae 100644 --- a/gdb/testsuite/gdb.base/dcache-flush.exp +++ b/gdb/testsuite/gdb.base/dcache-flush.exp @@ -34,7 +34,7 @@ gdb_test "p var2" " = 3" gdb_test "info dcache" \ [multi_line \ "Dcache $decimal lines of $decimal bytes each." \ - "Contains data for process $decimal" \ + "Contains data for (process $decimal|Thread \[^\r\n\]*)" \ "Line 0: address $hex \[$decimal hits\].*" \ "Cache state: $decimal active lines, $decimal hits" ] \ "check dcache before flushing" @@ -58,7 +58,7 @@ with_test_prefix "refilling" { gdb_test "info dcache" \ [multi_line \ "Dcache $decimal lines of $decimal bytes each." \ - "Contains data for process $decimal" \ + "Contains data for (process $decimal|Thread \[^\r\n\]*)" \ "Line 0: address $hex \[$decimal hits\].*" \ "Cache state: $decimal active lines, $decimal hits" ] \ "check dcache before refilling" ++++++ gdb-testsuite-fix-gdb.base-step-over-syscall.exp-with-m32-amd-case.patch ++++++ [gdb/testsuite] Fix gdb.base/step-over-syscall.exp with -m32, AMD case On an OBS machine with openSUSE Leap 15.2 and target board unix/-m32 I run into: ... (gdb) x/2i $pc^M => 0xf7fd5155 <__kernel_vsyscall+5>: syscall ^M 0xf7fd5157 <__kernel_vsyscall+7>: int $0x80^M (gdb) PASS: gdb.base/step-over-syscall.exp: fork: displaced=off: \ pc before/after syscall instruction stepi^M [Detaching after fork from child process 19924]^M 0xf7fd5159 in __kernel_vsyscall ()^M 1: x/i $pc^M => 0xf7fd5159 <__kernel_vsyscall+9>: pop %ebp^M (gdb) PASS: gdb.base/step-over-syscall.exp: fork: displaced=off: stepi fork insn print /x $pc^M $2 = 0xf7fd5159^M (gdb) PASS: gdb.base/step-over-syscall.exp: fork: displaced=off: pc after stepi FAIL: gdb.base/step-over-syscall.exp: fork: displaced=off: \ pc after stepi matches insn addr a fter syscall ... This is essentially a duplicate of the problem solved by commit 14852123287 "[gdb/testsuite] Fix gdb.base/step-over-syscall.exp with -m32", only here the insn before "int $0x80" is syscall instead of sysenter. The background here is that we're executing this code in the linux kernel (from ./arch/x86/entry/vdso/vdso32/system_call.S): ... #define SYSENTER_SEQUENCE "movl %esp, %ebp; sysenter" #define SYSCALL_SEQUENCE "movl %ecx, %ebp; syscall" /* If SYSENTER (Intel) or SYSCALL32 (AMD) is available, use it. */ ALTERNATIVE_2 "", SYSENTER_SEQUENCE, X86_FEATURE_SYSENTER32, \ SYSCALL_SEQUENCE, X86_FEATURE_SYSCALL32 ALTERNATIVE "", SYSENTER_SEQUENCE, X86_FEATURE_SEP ... and depending on the active feature, we either have sysenter or syscall. Fix this by recognizing the "syscall", "int $0x80" sequence. Tested on x86_64-linux. --- gdb/testsuite/gdb.base/step-over-syscall.exp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gdb/testsuite/gdb.base/step-over-syscall.exp b/gdb/testsuite/gdb.base/step-over-syscall.exp index ecfb7be481d..a4821d7cd5a 100644 --- a/gdb/testsuite/gdb.base/step-over-syscall.exp +++ b/gdb/testsuite/gdb.base/step-over-syscall.exp @@ -162,12 +162,13 @@ proc setup { syscall } { } # If we encounter a sequence: - # 0xf7fd5155 <__kernel_vsyscall+5>: sysenter + # 0xf7fd5155 <__kernel_vsyscall+5>: sysenter / syscall # 0xf7fd5157 <__kernel_vsyscall+7>: int $0x80 # 0xf7fd5159 <__kernel_vsyscall+9>: pop %ebp - # then a stepi at sysenter will step over the int insn, so make sure - # next_insn_addr points after the int insn. - if { $actual_syscall_insn == "sysenter" } { + # then a stepi at sysenter/syscall will step over the int insn, + # so make sure next_insn_addr points after the int insn. + if { $actual_syscall_insn == "sysenter" + || $actual_syscall_insn == "syscall" } { set test "pc after sysenter instruction" set re_int_insn "\[ \t\]*int\[ \t\]\[^\r\n\]*" set re [multi_line \ ++++++ gdb-testsuite-fix-gdb.gdb-selftest.exp.patch ++++++ [gdb/testsuite] Fix gdb.gdb/selftest.exp With a gdb build with CFLAGS "-O2 -g -flto=auto", I run into: ... #7 gdb_main (args=0x7fffffffd220) at src/gdb/main.c:1368^M #8 main (argc=<optimized out>, argv=<optimized out>) at src/gdb/gdb.c:32^M (gdb) FAIL: gdb.gdb/selftest.exp: backtrace through signal handler ... which means that this regexp in proc test_with_self fails: ... -re "#0.*(read|poll).*in main \\(.*\\) at .*gdb\\.c.*$gdb_prompt $" { ... The problem is that gdb_main has been inlined into main, and consequently the backtrace uses: ... #x <fn> ... ... instead of ... #x <address> in <fn> ... ... Fix this by updating the regexp to not require "in" before " main". Tested on x86_64-linux. --- gdb/testsuite/gdb.gdb/selftest.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.gdb/selftest.exp b/gdb/testsuite/gdb.gdb/selftest.exp index bee3010bca1..35b06e53e90 100644 --- a/gdb/testsuite/gdb.gdb/selftest.exp +++ b/gdb/testsuite/gdb.gdb/selftest.exp @@ -143,7 +143,7 @@ proc test_with_self { } { setup_xfail "i*86-pc-linuxaout-gnu" set description "backtrace through signal handler" gdb_test_multiple "backtrace" "$description" { - -re "#0.*(read|poll).*in main \\(.*\\) at .*gdb\\.c.*$gdb_prompt $" { + -re "#0.*(read|poll).* main \\(.*\\) at .*gdb\\.c.*$gdb_prompt $" { pass "$description" } } ++++++ gdb-testsuite-fix-gdb.python-py-events.exp.patch ++++++ [gdb/testsuite] Fix gdb.python/py-events.exp With test-case gdb.python/py-events.exp on ubuntu 18.04.5 we run into: ... (gdb) info threads^M Id Target Id Frame ^M * 1 Thread 0x7ffff7fc3740 (LWP 31467) "py-events" do_nothing () at \ src/gdb/testsuite/gdb.python/py-events-shlib.c:19^M (gdb) FAIL: gdb.python/py-events.exp: get current thread ... The info thread commands uses "Thread" instead of "process" because libpthread is already loaded: ... new objfile name: /lib/x86_64-linux-gnu/libdl.so.2^M [Thread debugging using libthread_db enabled]^M Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".^M event type: new_objfile^M new objfile name: /lib/x86_64-linux-gnu/libpthread.so.0^M ... and consequently thread_db_target::pid_to_str is used. Fix this by parsing the "Thread" expression. Tested on x86_64-linux. --- gdb/testsuite/gdb.python/py-events.exp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.python/py-events.exp b/gdb/testsuite/gdb.python/py-events.exp index 753709361f5..d6dc9fd4252 100644 --- a/gdb/testsuite/gdb.python/py-events.exp +++ b/gdb/testsuite/gdb.python/py-events.exp @@ -82,9 +82,13 @@ delete_breakpoints # Test inferior call events gdb_test_multiple "info threads" "get current thread" { - -re "\[^\n\r\]*process (\[0-9\]+)\[^\n\r\]*do_nothing.*$gdb_prompt $" { + -re -wrap "process ($decimal)\[^\n\r\]*do_nothing.*" { set process_id $expect_out(1,string) - pass "get current thread" + pass $gdb_test_name + } + -re -wrap "Thread $hex \\(LWP ($decimal)\\)\[^\n\r\]*do_nothing.*" { + set process_id $expect_out(1,string) + pass $gdb_test_name } } ++++++ gdb-testsuite-fix-gdb.server-server-kill.exp-with-m32.patch ++++++ [gdb/testsuite] Fix gdb.server/server-kill.exp with -m32 When running test-case gdb.server/server-kill.exp with target board unix/-m32, I run into: ... 0xf7fd6b20 in _start () from /lib/ld-linux.so.2^M (gdb) Executing on target: kill -9 13082 (timeout = 300) builtin_spawn -ignore SIGHUP kill -9 13082^M bt^M (gdb) FAIL: gdb.server/server-kill.exp: kill_pid_of=server: test_unwind_syms: bt ... The test-case expects the backtrace command to trigger remote communication, which then should result in a "Remote connection closed" or similar. However, no remote communication is triggered, because we hit the "Check that this frame is unwindable" case in get_prev_frame_always_1. We don't hit this problem in the kill_pid_of=inferior case, because there we run to main before doing the backtrace. Fix this by doing the same in the kill_pid_of=server case. Tested on x86_64-linux. --- gdb/testsuite/gdb.server/server-kill.exp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gdb/testsuite/gdb.server/server-kill.exp b/gdb/testsuite/gdb.server/server-kill.exp index 655821cc6f9..4125e5bf92d 100644 --- a/gdb/testsuite/gdb.server/server-kill.exp +++ b/gdb/testsuite/gdb.server/server-kill.exp @@ -69,11 +69,13 @@ proc prepare {} { gdbserver_run "" - if { $::kill_pid_of == "inferior" } { - # Continue past server_pid assignment. - gdb_breakpoint ${srcfile}:[gdb_get_line_number "i = 0;"] - gdb_continue_to_breakpoint "after server_pid assignment" + # Continue past server_pid assignment. We do this for both scenarios, + # to avoid doing a backtrace from _start, which may not trigger remote + # communication. + gdb_breakpoint ${srcfile}:[gdb_get_line_number "i = 0;"] + gdb_continue_to_breakpoint "after server_pid assignment" + if { $::kill_pid_of == "inferior" } { # Get the pid of GDBServer. set test "p server_pid" set server_pid 0 ++++++ gdb-testsuite-fix-gdb.threads-check-libthread-db.exp-with-glibc-2.34.patch ++++++ [gdb/testsuite] Fix gdb.threads/check-libthread-db.exp with glibc 2.34 When running test-case gdb.threads/check-libthread-db.exp on openSUSE Tumbleweed (with glibc 2.34) I get: ... (gdb) continue^M Continuing.^M [Thread debugging using libthread_db enabled]^M Using host libthread_db library "/lib64/libthread_db.so.1".^M Stopped due to shared library event:^M Inferior loaded /lib64/libm.so.6^M /lib64/libc.so.6^M (gdb) FAIL: gdb.threads/check-libthread-db.exp: user-initiated check: continue ... The check expect the inferior to load libpthread, but since glibc 2.34 libpthread has been integrated into glibc, and consequently it's no longer a dependency: ... $ ldd outputs/gdb.threads/check-libthread-db/check-libthread-db linux-vdso.so.1 (0x00007ffe4cae4000) libm.so.6 => /lib64/libm.so.6 (0x00007f167c77c000) libc.so.6 => /lib64/libc.so.6 (0x00007f167c572000) /lib64/ld-linux-x86-64.so.2 (0x00007f167c86e000) ... Fix this by updating the regexp to expect libpthread or libc. Tested on x86_64-linux. --- gdb/testsuite/gdb.threads/check-libthread-db.exp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.threads/check-libthread-db.exp b/gdb/testsuite/gdb.threads/check-libthread-db.exp index 6ecf40db6a9..423c29978c8 100644 --- a/gdb/testsuite/gdb.threads/check-libthread-db.exp +++ b/gdb/testsuite/gdb.threads/check-libthread-db.exp @@ -58,7 +58,9 @@ with_test_prefix "user-initiated check" { # User-initiated check with NPTL possibly uninitialized. gdb_test "continue" \ - ".*Stopped due to shared library event.*Inferior loaded .*libpthread.*" + [multi_line \ + "Stopped due to shared library event:" \ + " Inferior loaded .*(libpthread|libc).*"] gdb_test_sequence "maint check libthread-db" \ "libpthread.so possibly not initialized" \ ++++++ gdb-testsuite-fix-gdb.threads-linux-dp.exp.patch ++++++ [gdb/testsuite] Fix gdb.threads/linux-dp.exp On openSUSE Tumbleweed with glibc-debuginfo installed I get: ... (gdb) PASS: gdb.threads/linux-dp.exp: continue to breakpoint: thread 5's print where^M #0 print_philosopher (n=3, left=33 '!', right=33 '!') at linux-dp.c:105^M #1 0x0000000000401628 in philosopher (data=0x40537c) at linux-dp.c:148^M #2 0x00007ffff7d56b37 in start_thread (arg=<optimized out>) \ at pthread_create.c:435^M #3 0x00007ffff7ddb640 in clone3 () \ at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81^M (gdb) PASS: gdb.threads/linux-dp.exp: first thread-specific breakpoint hit ... while without debuginfo installed I get instead: ... (gdb) PASS: gdb.threads/linux-dp.exp: continue to breakpoint: thread 5's print where^M #0 print_philosopher (n=3, left=33 '!', right=33 '!') at linux-dp.c:105^M #1 0x0000000000401628 in philosopher (data=0x40537c) at linux-dp.c:148^M #2 0x00007ffff7d56b37 in start_thread () from /lib64/libc.so.6^M #3 0x00007ffff7ddb640 in clone3 () from /lib64/libc.so.6^M (gdb) FAIL: gdb.threads/linux-dp.exp: first thread-specific breakpoint hit ... The problem is that the regexp used: ... "\(from .*libpthread\|at pthread_create\|in pthread_create\)" ... expects the 'from' part to match libpthread, but in glibc 2.34 libpthread has been merged into libc. Fix this by updating the regexp. Tested on x86_64-linux. --- gdb/testsuite/gdb.threads/linux-dp.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.threads/linux-dp.exp b/gdb/testsuite/gdb.threads/linux-dp.exp index 099971dca39..b01e87fa9ea 100644 --- a/gdb/testsuite/gdb.threads/linux-dp.exp +++ b/gdb/testsuite/gdb.threads/linux-dp.exp @@ -226,7 +226,7 @@ gdb_continue_to_breakpoint "thread 5's print" # If you do have debug info, the output obviously depends more on the # exact library in use; under NPTL, you get: # #2 0x0012b7fc in start_thread (arg=0x21) at pthread_create.c:264 -gdb_test "where" "print_philosopher.*philosopher.* \(from .*libpthread\|at pthread_create\|in pthread_create\).*" \ +gdb_test "where" "print_philosopher.*philosopher.* \(from .*libpthread\|at pthread_create\|in pthread_create|from .*libc\\.\).*" \ "first thread-specific breakpoint hit" # Make sure it's catching the right thread. Try hitting the ++++++ gdb-testsuite-fix-port-detection-in-gdb.debuginfod-fetch_src_and_symbols.exp.patch ++++++ [gdb/testsuite] Fix port detection in gdb.debuginfod/fetch_src_and_symbols.exp On OBS I ran into this failure with test-case gdb.debuginfod/fetch_src_and_symbols.exp: ... Failed to listen for connections: Address already in use^M [Thu Oct 21 11:48:49 2021] (559/559): started http server on IPv6 port=8000^M ... FAIL: gdb.debuginfod/fetch_src_and_symbols.exp: local_url: find port timeout ... The test-case is trying to start debuginfod on a port to see if it's available, and it handles either this message: "started http server on IPv4 IPv6 port=$port" meaning success, or: "failed to bind to port" meaning failure, in which case the debuginfod instance is killed, and we try the next port. The test-case only uses the v4 address 127.0.0.1, so fix this by: - accepting "started http server on IPv4 port=$port" - rejecting "started http server on IPv6 port=$port" Tested on x86_64-linux. --- gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp index 81d4791eb6d..bb0c0c7ff29 100644 --- a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp +++ b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp @@ -180,12 +180,17 @@ proc local_url { } { spawn debuginfod -vvvv -d $db -p $port -F $debugdir expect { "started http server on IPv4 IPv6 port=$port" { set found 1 } - "failed to bind to port" { kill_wait_spawned_process $spawn_id } + "started http server on IPv4 port=$port" { set found 1 } + "started http server on IPv6 port=$port" {} + "failed to bind to port" {} timeout { fail "find port timeout" return -1 } } + if { ! $found } { + kill_wait_spawned_process $spawn_id + } } set metrics [list "ready 1" \ ++++++ gdb-testsuite-fix-race-in-gdb.threads-detach-step-over.exp.patch ++++++ [gdb/testsuite] Fix race in gdb.threads/detach-step-over.exp On OBS with openSUSE Leap 15.2 and target board unix/m32, I run into: ... FAIL: gdb.threads/detach-step-over.exp: \ breakpoint-condition-evaluation=host: target-non-stop=off: non-stop=off: \ displaced=off: iter 1: all threads running ... I can easily reproduce this by doing: ... # Wait a bit, to give time for the threads to hit the # breakpoint. - sleep 1 set running_count 0 set interrupted 0 ... Fix this by counting the running threads in a loop. Tested on x86_64-linux. --- gdb/testsuite/gdb.threads/detach-step-over.exp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.threads/detach-step-over.exp b/gdb/testsuite/gdb.threads/detach-step-over.exp index 27718551188..9c5f98efeef 100644 --- a/gdb/testsuite/gdb.threads/detach-step-over.exp +++ b/gdb/testsuite/gdb.threads/detach-step-over.exp @@ -203,7 +203,8 @@ proc test {condition_eval target_non_stop non_stop displaced} { set running_count 0 set interrupted 0 - gdb_test_multiple "info threads" "all threads running" { + set running_expected [expr ($n_threads + 1) * 2] + gdb_test_multiple "info threads" "threads running" { -re "\\(running\\)" { incr running_count exp_continue @@ -225,9 +226,28 @@ proc test {condition_eval target_non_stop non_stop displaced} { } } -re "$gdb_prompt $" { - gdb_assert {$running_count == ($n_threads + 1) * 2} $gdb_test_name } } + if { $interrupted == 0 } { + while { $running_count < $running_expected } { + sleep 1 + set prev_running_count $running_count + set running_count 0 + gdb_test_multiple "info threads" "threads running" { + -re "\\(running\\)" { + incr running_count + exp_continue + } + -re "$gdb_prompt $" { + } + } + if { $running_count == $prev_running_count } { + break + } + } + gdb_assert {$running_count == $running_expected} \ + "all threads running" + } gdb_test "detach" "Detaching from.*" ++++++ gdb-testsuite-handle-recursive-internal-problem-in-gdb_internal_error_resync.patch ++++++ [gdb/testsuite] Handle recursive internal problem in gdb_internal_error_resync I came across this problem when testing gdb.base/gdb-sigterm.exp on a machine with a pre-release version of glib-2.34 installed: A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) Recursive internal problem. FAIL: gdb.base/gdb-sigterm.exp: expect eof #0 (GDB internal error) Resyncing due to internal error. ERROR: : spawn id exp11 not open while executing "expect { -i exp11 -timeout 10 -re "Quit this debugging session\\? \\(y or n\\) $" { send_gdb "n\n" answer incr count } -re "Create..." ("uplevel" body line 1) invoked from within "uplevel $body" NONE : spawn id exp11 not open ERROR: Could not resync from internal error (timeout) gdb.base/gdb-sigterm.exp: expect eof #0: stepped 9 times UNRESOLVED: gdb.base/gdb-sigterm.exp: 50 SIGTERM passes I don't have a problem with the latter ERROR nor the UNRESOLVED messages. However the first ERROR regarding the exp11 spawn id not being open is not especially useful. This commit handles the "Recursive internal problem" case, avoiding the problematic ERROR shown above. With this commit in place, the log messages look like this instead: A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) Recursive internal problem. FAIL: gdb.base/gdb-sigterm.exp: expect eof #15 (GDB internal error) Resyncing due to internal error. ERROR: Could not resync from internal error (recursive internal problem) gdb.base/gdb-sigterm.exp: expect eof #15: stepped 12 times UNRESOLVED: gdb.base/gdb-sigterm.exp: 50 SIGTERM passes gdb/testsuite/ChangeLog: * lib/gdb.exp (gdb_internal_error_resync): Handle "Recursive internal problem". --- gdb/testsuite/lib/gdb.exp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index dbf4016aca1..7a8332dd573 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -756,6 +756,10 @@ proc gdb_internal_error_resync {} { set count 0 while {$count < 10} { gdb_expect { + -re "Recursive internal problem\\." { + perror "Could not resync from internal error (recursive internal problem)" + return 0 + } -re "Quit this debugging session\\? \\(y or n\\) $" { send_gdb "n\n" answer incr count ++++++ gdb-testsuite-handle-runto-fail-in-gdb.mi-mi-var-cp.exp.patch ++++++ [gdb/testsuite] Handle runto fail in gdb.mi/mi-var-cp.exp On OBS I ran into: ... PASS: gdb.mi/mi-var-cp.exp: run to mi-var-cp.cc:81 (set breakpoint) UNRESOLVED: gdb.mi/mi-var-cp.exp: unable to start target ... followed by 81 FAILs and two more UNRESOLVEDs. I didn't manage to reproduce this, but I did notice that the initial problem causing the UNRESOLVED caused all subsequent UNRESOLVEDs and FAILs. I emulated the problem by commenting out the send_gdb "run\n" in mi_run_cmd_full. Fix this by: - handling mi_run_cmd failure in mi_get_inline_test - handling mi_run_inline_test failure in gdb.mi/mi-var-cp.exp, and other test-cases using mi_get_inline_test Tested on x86_64-linux. --- gdb/testsuite/gdb.mi/mi-var-child.exp | 4 +++- gdb/testsuite/gdb.mi/mi-var-cmd.exp | 18 ++++++++++++++---- gdb/testsuite/gdb.mi/mi-var-cp.exp | 18 +++++++++++++----- gdb/testsuite/gdb.mi/mi-var-rtti.exp | 22 +++++++++++++++------- gdb/testsuite/lib/mi-support.exp | 6 +++++- 5 files changed, 50 insertions(+), 18 deletions(-) diff --git a/gdb/testsuite/gdb.mi/mi-var-child.exp b/gdb/testsuite/gdb.mi/mi-var-child.exp index 8632fe26cf8..63cea065c3f 100644 --- a/gdb/testsuite/gdb.mi/mi-var-child.exp +++ b/gdb/testsuite/gdb.mi/mi-var-child.exp @@ -1205,7 +1205,9 @@ mi_varobj_update * {psnp->ptrs.0.next.next.long_ptr} \ mi_prepare_inline_tests $srcfile -mi_run_inline_test child_deletion +if { [mi_run_inline_test child_deletion] < 0 } { + return -1 +} mi_gdb_exit diff --git a/gdb/testsuite/gdb.mi/mi-var-cmd.exp b/gdb/testsuite/gdb.mi/mi-var-cmd.exp index fe0826d480d..fbf57aa25ac 100644 --- a/gdb/testsuite/gdb.mi/mi-var-cmd.exp +++ b/gdb/testsuite/gdb.mi/mi-var-cmd.exp @@ -587,14 +587,24 @@ proc set_frozen {varobjs flag} { } mi_prepare_inline_tests $srcfile -mi_run_inline_test frozen -mi_run_inline_test bitfield +set inline_tests { + frozen + bitfield +} + +# Needs to be last, following tests rely on this. +lappend inline_tests floating + +foreach inline_test $inline_tests { + if { [mi_run_inline_test $inline_test] < 0 } { + return -1 + } +} # Since the inline test framework does not really work with -# function calls, first to inline tests and then do the reminder +# function calls, first to inline tests and then do the remainder # manually. -mi_run_inline_test floating set do_at_tests_callee_breakpoint [gdb_get_line_number "breakpoint inside callee"] mi_gdb_test "-break-insert var-cmd.c:$do_at_tests_callee_breakpoint" ".*" \ "inside breakpoint inside callee" diff --git a/gdb/testsuite/gdb.mi/mi-var-cp.exp b/gdb/testsuite/gdb.mi/mi-var-cp.exp index 4e8abe8d961..8fdd0f863a7 100644 --- a/gdb/testsuite/gdb.mi/mi-var-cp.exp +++ b/gdb/testsuite/gdb.mi/mi-var-cp.exp @@ -38,11 +38,19 @@ mi_gdb_load ${binfile} mi_prepare_inline_tests $srcfile -mi_run_inline_test reference_update -mi_run_inline_test base_in_reference -mi_run_inline_test reference_to_pointer -mi_run_inline_test reference_to_struct -mi_run_inline_test path_expression +set inline_tests { + reference_update + base_in_reference + reference_to_pointer + reference_to_struct + path_expression +} + +foreach inline_test $inline_tests { + if { [mi_run_inline_test $inline_test] < 0 } { + return -1 + } +} set lineno [gdb_get_line_number "/* anonymous_structs_and_unions */"] mi_create_breakpoint "$srcfile:$lineno" \ diff --git a/gdb/testsuite/gdb.mi/mi-var-rtti.exp b/gdb/testsuite/gdb.mi/mi-var-rtti.exp index b574e5c4edb..a0a2e132aaf 100644 --- a/gdb/testsuite/gdb.mi/mi-var-rtti.exp +++ b/gdb/testsuite/gdb.mi/mi-var-rtti.exp @@ -109,13 +109,21 @@ proc check_new_derived_with_rtti {var_name var_type testname} { "delete varobj for ${var_name} (with RTTI) in $testname" } -mi_run_inline_test use_rtti_for_ptr -mi_run_inline_test use_rtti_for_ref -mi_run_inline_test use_rtti_for_ptr_child -mi_run_inline_test use_rtti_for_ref_child -mi_run_inline_test use_rtti_with_multiple_inheritence -mi_run_inline_test type_update_when_use_rtti -mi_run_inline_test skip_type_update_when_not_use_rtti +set inline_tests { + use_rtti_for_ptr + use_rtti_for_ref + use_rtti_for_ptr_child + use_rtti_for_ref_child + use_rtti_with_multiple_inheritence + type_update_when_use_rtti + skip_type_update_when_not_use_rtti +} + +foreach inline_test $inline_tests { + if { [mi_run_inline_test $inline_test] < 0 } { + return -1 + } +} mi_gdb_exit return 0 diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp index 288c651d4d4..28e23b11005 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -1945,7 +1945,9 @@ proc mi_run_inline_test { testcase } { if {$first==1} { # Start the program afresh. mi_tbreak "$mi_autotest_source:$line" - mi_run_cmd + if { [mi_run_cmd] < 0 } { + return -1 + } set line_now [mi_get_stop_line "$testcase: step to $line"] set first 0 } elseif {$line_now!=$line} { @@ -1972,6 +1974,8 @@ proc mi_run_inline_test { testcase } { # will need more experience to be sure. eval $statements } + + return 0 } proc get_mi_thread_list {name} { ++++++ gdb-testsuite-handle-sigill-in-two-gdb.arch-powerpc-test-cases.patch ++++++ [gdb/testsuite] Handle SIGILL in two gdb.arch powerpc test-cases On powerpc64le-linux, with test-case gdb.arch/powerpc-addpcis.exp I run into SIGILL: ... (gdb) PASS: gdb.arch/powerpc-addpcis.exp: get hexadecimal valueof "$r3" stepi^M ^M Program terminated with signal SIGILL, Illegal instruction.^M The program no longer exists.^M (gdb) PASS: gdb.arch/powerpc-addpcis.exp: set r4 ... because it's a power9 insn, and I'm running on a power8 machine. Fix this by handling the SIGILL. Likewise in gdb.arch/powerpc-lnia.exp. Tested on powerpc64le-linux. --- gdb/testsuite/gdb.arch/powerpc-addpcis.exp | 14 +++++++++++++- gdb/testsuite/gdb.arch/powerpc-lnia.exp | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.arch/powerpc-addpcis.exp b/gdb/testsuite/gdb.arch/powerpc-addpcis.exp index d1bc7f49ce6..ff7052ce475 100644 --- a/gdb/testsuite/gdb.arch/powerpc-addpcis.exp +++ b/gdb/testsuite/gdb.arch/powerpc-addpcis.exp @@ -50,7 +50,19 @@ gdb_breakpoint $bp1 gdb_breakpoint $bp2 gdb_breakpoint $bp3 -gdb_test "stepi" "" "set r3 " +set insn_supported 1 +gdb_test_multiple "stepi" "set r3" { + -re "Program received signal SIGILL, Illegal instruction\\..*" { + set insn_supported 0 + } + -re -wrap "" { + pass $gdb_test_name + } +} +if { ! $insn_supported } { + unsupported "illegal instruction" + return +} set check_r3 [get_hexadecimal_valueof "\$r3" "default0"] gdb_test "stepi" "" "set r4" set check_r4 [get_hexadecimal_valueof "\$r4" "default0"] diff --git a/gdb/testsuite/gdb.arch/powerpc-lnia.exp b/gdb/testsuite/gdb.arch/powerpc-lnia.exp index 0f56d834046..4ab4f8d92be 100644 --- a/gdb/testsuite/gdb.arch/powerpc-lnia.exp +++ b/gdb/testsuite/gdb.arch/powerpc-lnia.exp @@ -54,7 +54,19 @@ gdb_breakpoint $bp3 # single-step through the lnia instructions, and retrieve the # register values as we proceed. -gdb_test "stepi" "" "set r3" +set insn_supported 1 +gdb_test_multiple "stepi" "set r3" { + -re "Program received signal SIGILL, Illegal instruction\\..*" { + set insn_supported 0 + } + -re -wrap "" { + pass $gdb_test_name + } +} +if { ! $insn_supported } { + unsupported "illegal instruction" + return +} set check_r3 [get_hexadecimal_valueof "\$r3" "default0"] gdb_test "stepi" "" "set r4" set check_r4 [get_hexadecimal_valueof "\$r4" "default0"] ++++++ gdb-testsuite-handle-supports_memtag-in-gdb.base-gdb-caching-proc.exp.patch ++++++ [gdb/testsuite] Handle supports_memtag in gdb.base/gdb-caching-proc.exp In test-case gdb.base/gdb-caching-proc.exp, we run all procs declared with gdb_caching_proc. Some of these require a gdb instance, some not. We could just do a clean_restart every time, but that would amount to 44 gdb restarts. We try to minimize this by doing this only for the few procs that need it, and hardcoding those in the test-case. For those procs, we do a clean_restart, execute the proc, and then do a gdb_exit, to make sure the gdb instance doesn't linger such that we detect procs that need a gdb instance but are not listed in the test-case. However, that doesn't work in the case of gnat_runtime_has_debug_info. This proc doesn't require a gdb instance because it starts its own. But it doesn't clean up the gdb instance, and since it's not listed, the test-case doesn't clean up the gdb instance eiter. Consequently, the proc supports_memtag (which should be listed, but isn't) uses the gdb instance started by gnat_runtime_has_debug_info rather than throwing an error. Well, unless gnat_runtime_has_debug_info fails before starting a gdb instance, in which case we do run into the error. Fix this by: - doing gdb_exit unconditionally - fixing the resulting error by adding supports_memtag in the test-case to the "needing gdb instance" list Tested on x86_64-linux. --- gdb/testsuite/gdb.base/gdb-caching-proc.exp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gdb/testsuite/gdb.base/gdb-caching-proc.exp b/gdb/testsuite/gdb.base/gdb-caching-proc.exp index 82675dfc061..a3f08f5db32 100644 --- a/gdb/testsuite/gdb.base/gdb-caching-proc.exp +++ b/gdb/testsuite/gdb.base/gdb-caching-proc.exp @@ -85,6 +85,7 @@ proc test_file { file } { switch $procname { "is_address_zero_readable" { set setup_gdb 1 } "target_is_gdbserver" { set setup_gdb 1 } + "supports_memtag" { set setup_gdb 1 } default {set setup_gdb 0 } } @@ -94,9 +95,7 @@ proc test_file { file } { test_proc $procname - if { $setup_gdb } { - gdb_exit - } + gdb_exit } } } ++++++ gdb-testsuite-prevent-compilation-fails-with-unix-fpie-pie.patch ++++++ [gdb/testsuite] Prevent compilation fails with unix/-fPIE/-pie A regular test-case will produce an executable, and depending on the compiler default, it will be a PIE or not. A test-case can force one or the other using the pie and nopie options. However, when running with target board unix/-fPIE/-pie, the nopie option will have no effect, and likewise for target board unix/-fno-PIE/-no-pie and the pie option. When say we run test-case gdb.base/attach-pie-noexec.exp, which passes the pie option with target board unix/-fno-PIE/-no-pie we get: ... Running src/gdb/testsuite/gdb.base/attach-pie-noexec.exp ... gdb compile failed, pie failed to generate PIE executable === gdb Summary === # of untested testcases 1 ... However, this works only when we actually manage to generate an executable. There are other test-cases, like f.i. gdb.arch/amd64-disp-step.exp that specify nopie, but will generate a compilation failure with target board unix/-fPIE/-pie due to using a hard-coded .S file: ... Running src/gdb/testsuite/gdb.arch/amd64-disp-step.exp ... gdb compile failed, ld: outputs/gdb.arch/amd64-disp-step/amd64-disp-step0.o: \ relocation R_X86_64_32S against `.text' can not be used when making a PIE \ object; recompile with -fPIE collect2: error: ld returned 1 exit status === gdb Summary === # of untested testcases 1 ... Hide this compilation error by: - adding a gdb_caching_proc pie_forced, and - using it in gdb_compile to bail out before even trying compilation such that we simply have: ... UNTESTED: gdb.arch/amd64-disp-step.exp: failed to prepare ... Likewise, add nopie_forced. Tested on x86_64-linux. --- gdb/testsuite/lib/gdb.exp | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 2b94f79d132..dbf4016aca1 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4407,6 +4407,17 @@ proc gdb_compile {source dest type options} { lappend options "$flag" } + if { $pie != -1 && [nopie_forced] } { + set result "pie unsupported" + verbose -log "gdb_compile: $result" + return $result + } + if { $nopie != -1 && [pie_forced] } { + set result "nopie unsupported" + verbose -log "gdb_compile: $result" + return $result + } + if { $type == "executable" } { if { ([istarget "*-*-mingw*"] || [istarget "*-*-*djgpp"] @@ -7928,6 +7939,48 @@ gdb_caching_proc have_fuse_ld_gold { return [gdb_simple_compile $me $src executable $flags] } +# Helper function for pie_forced. +proc pie_forced_0 { } { return 0 } + +# Return 1 if nopie fails to prevent a PIE, 0 if nopie prevented a PIE, +# and -1 if an error occurred. +gdb_caching_proc pie_forced { + set me "pie_forced" + set src { int main() { return 0; } } + # gdb_compile calls pie_forced when nopie is passed, so pretend it + # returns 0, to allow us to find out the actual pie_forced value. + with_override pie_forced pie_forced_0 { + gdb_simple_compile $me $src executable nopie + } + set res [exec_is_pie $obj] + if { $res == -1 } { + return -1 + } + set res [expr $res == 1] + return $res +} + +# Helper function for nopie_forced. +proc nopie_forced_0 {} { return 0 } + +# Return 1 if pie fails to generated a PIE, 0 if pie generated a PIE, +# and -1 if an error occurred. +gdb_caching_proc nopie_forced { + set me "nopie_forced" + set src { int main() { return 0; } } + # gdb_compile calls nopie_forced when pie is passed, so pretend it + # returns 0, to allow us to find out the actual nopie_forced value. + with_override nopie_forced nopie_forced_0 { + gdb_simple_compile $me $src executable pie + } + set res [exec_is_pie $obj] + if { $res == -1 } { + return -1 + } + set res [expr $res == 0] + return $res +} + # Return 1 if compiler supports scalar_storage_order attribute, otherwise # return 0. gdb_caching_proc supports_scalar_storage_order_attribute { ++++++ gdb-testsuite-refactor-regexp-in-gdb.base-annota1.exp.patch ++++++ [gdb/testsuite] Refactor regexp in gdb.base/annota1.exp Refactor regexp in gdb.base/annota1.exp to reduce indentation and repetition. Tested on x86_64-linux. --- gdb/testsuite/gdb.base/annota1.exp | 56 ++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/gdb/testsuite/gdb.base/annota1.exp b/gdb/testsuite/gdb.base/annota1.exp index 383a0f4e607..6e30c164ec9 100644 --- a/gdb/testsuite/gdb.base/annota1.exp +++ b/gdb/testsuite/gdb.base/annota1.exp @@ -129,29 +129,43 @@ gdb_test_multiple "info break" "breakpoint info" { #exp_internal 1 set binexp [string_to_regexp $binfile] -set run_re [join [list "\r\n\032\032post-prompt\r\nStarting program: $binexp " \ - "\(\(\r\nReading \[^\r\n\]+\)|\(\r\nwarning: File transfers from remote targets can be slow\[^\r\n\]+\)\)*" \ - "\(\r\nwarning: Skipping \[^\r\n\]+ .gdb_index section in \[^\r\n\]+\r\nDo \"set use-deprecated-index-sections on\" before the file is read\r\nto use the section anyway\\.\)?" \ - "\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)*\r\n\r\n" \ - "\032\032starting\(\(\r\nReading \[^\r\n\]+\)|\(\r\nwarning: File transfers from remote targets can be slow\[^\r\n\]+\)\)*" \ - "\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)*\r\n\r\n" \ - "\032\032breakpoint 1\r\n\r\n" \ - "Breakpoint 1, \r\n" \ - "\032\032frame-begin 0 $hex\r\n\r\n" \ - "\032\032frame-function-name\r\n" \ - "main\r\n" \ - "\032\032frame-args\r\n \\(\\)\r\n" \ - "\032\032frame-source-begin\r\n at \r\n" \ - "\032\032frame-source-file\r\n.*annota1.c\r\n" \ - "\032\032frame-source-file-end\r\n:\r\n" \ - "\032\032frame-source-line\r\n$main_line\r\n" \ - "\032\032frame-source-end\r\n\r\n\r\n" \ - "\032\032source.*$srcfile:$main_line:.*:beg:$hex\r\n\r\n" \ - "\032\032frame-end\r\n\r\n" \ - "\032\032stopped.*$gdb_prompt$" ] "" ] +set warning_slow_re \ + "warning: File transfers from remote targets can be slow\[^\r\n\]+" +set warning_gdb_index_re \ + [multi_line \ + "warning: Skipping \[^\r\n\]+ .gdb_index section in \[^\r\n\]+" \ + "Do \"set use-deprecated-index-sections on\" before the file is read" \ + "to use the section anyway\\."] +set reading_re \ + "Reading \[^\r\n\]+" + +set run_re \ + [list \ + "\r\n\032\032post-prompt\r\nStarting program: $binexp " \ + "\(\(\r\n$reading_re\)|\(\r\n$warning_slow_re\)\)*" \ + "\(\r\n$warning_gdb_index_re\)?" \ + "\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)*\r\n\r\n" \ + "\032\032starting\(\(\r\n$reading_re\)|\(\r\n$warning_slow_re\)\)*" \ + "\(\(\r\n\r\n\032\032frames-invalid\)|\(\r\n\r\n\032\032breakpoints-invalid\)\)*\r\n\r\n" \ + "\032\032breakpoint 1\r\n\r\n" \ + "Breakpoint 1, \r\n" \ + "\032\032frame-begin 0 $hex\r\n\r\n" \ + "\032\032frame-function-name\r\n" \ + "main\r\n" \ + "\032\032frame-args\r\n \\(\\)\r\n" \ + "\032\032frame-source-begin\r\n at \r\n" \ + "\032\032frame-source-file\r\n.*annota1.c\r\n" \ + "\032\032frame-source-file-end\r\n:\r\n" \ + "\032\032frame-source-line\r\n$main_line\r\n" \ + "\032\032frame-source-end\r\n\r\n\r\n" \ + "\032\032source.*$srcfile:$main_line:.*:beg:$hex\r\n\r\n" \ + "\032\032frame-end\r\n\r\n" \ + "\032\032stopped"] + +set run_re [join $run_re ""] gdb_test_multiple "run" "run until main breakpoint" { - -re $run_re { + -re $run_re.*$gdb_prompt$ { pass $gdb_test_name } } ++++++ gdb-testsuite-support-fpie-fno-pie-pie-no-pie-in-gdb_compile_rust.patch ++++++ [gdb/testsuite] Support -fPIE/-fno-PIE/-pie/-no-pie in gdb_compile_rust When running gdb.rust/*.exp test-cases with target board unix/-fPIE/-pie, I run into: ... builtin_spawn -ignore SIGHUP rustc --color never gdb.rust/watch.rs \ -g -lm -fPIE -pie -o outputs/gdb.rust/watch/watch^M error: Unrecognized option: 'f'^M ^M compiler exited with status 1 ... The problem is that -fPIE and -fpie are gcc options, but for rust we use rustc, which has different compilation options. Fix this by translating the gcc options to rustc options in gdb_compile_rust, similar to how that is done for ada in target_compile_ada_from_dir. Likewise for unix/-fno-PIE/-no-pie. Tested on x86_64-linux, with: - native - unix/-fPIE/-pie - unix/-fno-PIE/-no-pie specifically, on openSUSE Leap 15.2 both with package gcc-PIE: - installed (making gcc default to PIE) - uninstalled (making gcc default to non-PIE). and rustc 1.52.1. --- gdb/testsuite/lib/rust-support.exp | 47 +++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/gdb/testsuite/lib/rust-support.exp b/gdb/testsuite/lib/rust-support.exp index 2896ac82453..2f78d6dde0e 100644 --- a/gdb/testsuite/lib/rust-support.exp +++ b/gdb/testsuite/lib/rust-support.exp @@ -27,13 +27,54 @@ proc set_lang_rust {} { } proc gdb_compile_rust {sources dest options} { + set res -1 + if {[llength $sources] > 1} { error "gdb rust setup can only compile one source file at a time" } - if {[gdb_compile [lindex $sources 0] $dest executable $options] != ""} { - return -1 + + global board + set board [target_info name] + set multilib_flags_orig [board_info $board multilib_flags] + set multilib_flags {} + foreach op $multilib_flags_orig { + # Pretend rustc supports -pie/-no-pie/-fPIE/-fno-PIE. + switch $op { + "-pie" - "-no-pie" { + # Pass it to linker. + lappend multilib_flags -C link-arg=$op + } + "-fno-PIE" { + # Translate to rustc codegen equivalent. + + # The rustc documentation insists that we should use static + # here, but that causes segfaults leading to: + # UNTESTED: gdb.rust/rawids.exp: could not run to breakpoint + # UNTESTED: gdb.rust/pp.exp: could not run to breakpoint + # Instead, we use dynamic-no-pic which does seem to work. + lappend multilib_flags -C relocation-model=dynamic-no-pic + } + "-fPIE" { + # Translate to rustc codegen equivalent. + lappend multilib_flags -C relocation-model=pic + } + default { + # Pass unmodified. + lappend multilib_flags $op + } + } + } + + save_target_board_info { multilib_flags } { + unset_board_info multilib_flags + set_board_info multilib_flags "$multilib_flags" + if {[gdb_compile [lindex $sources 0] $dest executable \ + $options] == ""} { + set res "" + } } - return "" + + return $res } # Return the version of LLVM used by the Rust compiler. Note that ++++++ gdb-testsuite-update-test-gdb.base-step-over-syscall.exp.patch ++++++ gdb/testsuite: update test gdb.base/step-over-syscall.exp I was looking at PR gdb/19675 and the related test gdb.base/step-over-syscall.exp. This test includes a call to kfail when we are testing a displaced step over a clone syscall. While looking at the test I removed the call to kfail and ran the test, and was surprised that the test passed. I ran the test a few times and it does sometimes fail, but mostly it passed fine. PR gdb/19675 describes how, when we displaced step over a clone, the new thread is created with a $pc in the displaced step buffer. GDB then fails to "fix" this $pc (for the new thread), and the thread will be set running with its current $pc value. This means that the new thread will just start executing from whatever happens to be after the displaced stepping buffer. In the original PR gdb/19675 bug report Yao Qi was seeing the new thread cause a segfault, the problem is, what actually happens is totally undefined. On my machine, I'm seeing the new thread reenter main, it then starts trying to run the test again (in the new thread). This just happens to be safe enough (in this simple test) that most of the time the inferior doesn't crash. In this commit I try to make the test slightly more likely to fail by doing a couple of things. First, I added a static variable to main, this is set true when the first thread enters main, if a second thread ever enters main then I force an abort. Second, when the test is finishing I want to ensure that the new threads have had a chance to do "something bad" if they are going to. So I added a global counter, as each thread starts successfully it decrements the counter. The main thread does not proceed to the final marker function (where GDB has placed a breakpoint) until all threads have started successfully. This means that if the newly created thread doesn't successfully enter clone_fn then the counter will never reach zero and the test will timeout. With these two changes my hope is that the test should fail more reliably, and so, I have also changed the test to call setup_kfail before the specific steps that we expect to misbehave instead of just calling kfail and skipping parts of the test completely. The benefit of this is that if/when we fix GDB this test will start to KPASS and we'll know to update this test to remove the setup_kfail call. --- gdb/testsuite/gdb.base/step-over-clone.c | 39 ++++++++++++++++ gdb/testsuite/gdb.base/step-over-syscall.exp | 69 +++++++++++++++++++++++----- 2 files changed, 97 insertions(+), 11 deletions(-) diff --git a/gdb/testsuite/gdb.base/step-over-clone.c b/gdb/testsuite/gdb.base/step-over-clone.c index 581bf5fdde5..ef6fd922eb1 100644 --- a/gdb/testsuite/gdb.base/step-over-clone.c +++ b/gdb/testsuite/gdb.base/step-over-clone.c @@ -19,6 +19,7 @@ #include <stdlib.h> #include <unistd.h> #include <sched.h> +#include <pthread.h> static void marker () @@ -26,9 +27,22 @@ marker () #define STACK_SIZE 0x1000 +/* These are used to signal that the threads have started correctly. The + GLOBAL_THREAD_COUNT is set to the number of threads in main, then + decremented (under a lock) in each new thread. */ +pthread_mutex_t global_lock = PTHREAD_MUTEX_INITIALIZER; +int global_thread_count = 0; + static int clone_fn (void *unused) { + /* Signal that this thread has started correctly. */ + if (pthread_mutex_lock (&global_lock) != 0) + abort (); + global_thread_count--; + if (pthread_mutex_unlock (&global_lock) != 0) + abort (); + return 0; } @@ -38,9 +52,21 @@ main (void) int i, pid; unsigned char *stack[6]; + /* Due to bug gdb/19675 the cloned thread _might_ try to reenter main + (this depends on where the displaced instruction is placed for + execution). However, if we do reenter main then lets ensure we fail + hard rather then just silently executing the code below. */ + static int started = 0; + if (!started) + started = 1; + else + abort (); + for (i = 0; i < (sizeof (stack) / sizeof (stack[0])); i++) stack[i] = malloc (STACK_SIZE); + global_thread_count = (sizeof (stack) / sizeof (stack[0])); + for (i = 0; i < (sizeof (stack) / sizeof (stack[0])); i++) { pid = clone (clone_fn, stack[i] + STACK_SIZE, CLONE_FILES | CLONE_VM, @@ -50,5 +76,18 @@ main (void) for (i = 0; i < (sizeof (stack) / sizeof (stack[0])); i++) free (stack[i]); + /* Set an alarm so we don't end up stuck waiting for threads that might + never start correctly. */ + alarm (120); + + /* Now wait for all the threads to start up. */ + while (global_thread_count != 0) + { + /* Force memory barrier so GLOBAL_THREAD_COUNT will be refetched. */ + asm volatile ("" ::: "memory"); + sleep (1); + } + + /* Call marker, this is what GDB is waiting for. */ marker (); } diff --git a/gdb/testsuite/gdb.base/step-over-syscall.exp b/gdb/testsuite/gdb.base/step-over-syscall.exp index a4821d7cd5a..7e9746e8dd9 100644 --- a/gdb/testsuite/gdb.base/step-over-syscall.exp +++ b/gdb/testsuite/gdb.base/step-over-syscall.exp @@ -41,11 +41,50 @@ if { [istarget "i\[34567\]86-*-linux*"] || [istarget "x86_64-*-linux*"] } { return -1 } -proc_with_prefix check_pc_after_cross_syscall { syscall syscall_insn_next_addr } { +proc_with_prefix check_pc_after_cross_syscall { displaced syscall syscall_insn_next_addr } { + global gdb_prompt + set syscall_insn_next_addr_found [get_hexadecimal_valueof "\$pc" "0"] + # After the 'stepi' we expect thread 1 to still be selected. + # However, when displaced stepping over a clone bug gdb/19675 + # means this might not be the case. + # + # Which thread we end up in depends on a race between the original + # thread-1, and the new thread (created by the clone), so we can't + # guarantee which thread we will be in at this point. + # + # For the fork/vfork syscalls, which are correctly handled by + # displaced stepping we will always be in thread-1 or the original + # process at this point. + set curr_thread "unknown" + gdb_test_multiple "info threads" "" { + -re "Id\\s+Target Id\\s+Frame\\s*\r\n" { + exp_continue + } + -re "^\\* (\\d+)\\s+\[^\r\n\]+\r\n" { + set curr_thread $expect_out(1,string) + exp_continue + } + -re "^\\s+\\d+\\s+\[^\r\n\]+\r\n" { + exp_continue + } + -re "$gdb_prompt " { + } + } + + # If we are displaced stepping over a clone, and we ended up in + # the wrong thread then the following check of the $pc value will + # fail. + if { $displaced == "on" && $syscall == "clone" && $curr_thread != 1 } { + # GDB doesn't support stepping over clone syscall with + # displaced stepping. + setup_kfail "*-*-*" "gdb/19675" + } + gdb_assert {$syscall_insn_next_addr != 0 \ - && $syscall_insn_next_addr == $syscall_insn_next_addr_found} \ + && $syscall_insn_next_addr == $syscall_insn_next_addr_found \ + && $curr_thread == 1} \ "single step over $syscall final pc" } @@ -204,7 +243,12 @@ proc step_over_syscall { syscall } { set testfile "step-over-$syscall" - if [build_executable ${testfile}.exp ${testfile} ${testfile}.c {debug}] { + set options [list debug] + if { $syscall == "clone" } { + lappend options "pthreads" + } + + if [build_executable ${testfile}.exp ${testfile} ${testfile}.c $options] { untested "failed to compile" return -1 } @@ -214,13 +258,6 @@ proc step_over_syscall { syscall } { continue } - if { $displaced == "on" && $syscall == "clone" } { - # GDB doesn't support stepping over clone syscall with - # displaced stepping. - kfail "gdb/19675" "single step over clone" - continue - } - set ret [setup $syscall] set syscall_insn_addr [lindex $ret 0] @@ -257,12 +294,22 @@ proc step_over_syscall { syscall } { if {[gdb_test "stepi" "x/i .*=>.*" "single step over $syscall"] != 0} { return -1 } - check_pc_after_cross_syscall $syscall $syscall_insn_next_addr + check_pc_after_cross_syscall $displaced $syscall $syscall_insn_next_addr # Delete breakpoint syscall insns to avoid interference to other syscalls. delete_breakpoints gdb_test "break marker" "Breakpoint.*at.* file .*${testfile}.c, line.*" + + # If we are displaced stepping over a clone syscall then + # we expect the following check to fail. See also the + # code in check_pc_after_cross_syscall. + if { $displaced == "on" && $syscall == "clone" } { + # GDB doesn't support stepping over clone syscall with + # displaced stepping. + setup_kfail "*-*-*" "gdb/19675" + } + gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, marker \\(\\) at.*" \ "continue to marker ($syscall)" } ++++++ gdb-testsuite-use-compiler-generated-instead-of-gas-generated-stabs.patch ++++++ [gdb/testsuite] Use compiler-generated instead of gas-generated stabs The test-case gdb.dwarf2/dw2-ranges.exp is the only one in the gdb testsuite that uses gas-generated stabs. While the use seems natural alongside the use of gas-generated dwarf in the same test-case, there are a few known issues, filed on the gdb side as: - PR symtab/12497 - "stabs: PIE relocation does not work" - PR symtab/28221 - "[readnow, stabs] FAIL: gdb.dwarf2/dw2-ranges.exp: \ info line func" and on the gas side as: - PR gas/28233 - "[gas, --gstabs] Generate stabs more similar to gcc" The test-case contains a KFAIL for PR12497, but it's outdated and fails to trigger. The intention of the test-case is to test gas-generated dwarf, and using gcc-generated stabs instead of gas-generated stabs works fine. Supporting compiler-generated stabs is already a corner-case for gdb, and there's no current commitment/incentive to support/workaround gas-generated stabs, which can be considered a corner-case of a corner-case. Work around these problem by using compiler-generated stabs in the test-case. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2021-08-22 Tom de Vries <tdevries@suse.de> * gdb.dwarf2/dw2-ranges.exp: Use compiler-generated stabs. --- gdb/testsuite/gdb.dwarf2/dw2-ranges.exp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/gdb/testsuite/gdb.dwarf2/dw2-ranges.exp b/gdb/testsuite/gdb.dwarf2/dw2-ranges.exp index 8566e0034cf..288fc941afa 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-ranges.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-ranges.exp @@ -35,7 +35,6 @@ if !$gcc_compiled { standard_testfile .c -2.c -3.c set asmfile [standard_output_file ${testfile}.s] set asmfile2 [standard_output_file ${testfile}2.s] -set asmfile3 [standard_output_file ${testfile}3.s] set objfile [standard_output_file ${testfile}.o] set objfile2 [standard_output_file ${testfile}2.o] set objfile3 [standard_output_file ${testfile}3.o] @@ -55,8 +54,7 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${asmfile2}" assembly {}] != # STABS compilation is intentional as it tests the STABS lookup where is no # partial_symtab->psymtabs_addrmap supported for that CU (Compilation Unit) in # a file containing psymtabs_addrmap-supporting DWARF CUs. -if {[gdb_compile "${srcdir}/${subdir}/${srcfile3}" "${asmfile3}" assembly {}] != "" - || [gdb_compile "${asmfile3}" "${objfile3}" object {additional_flags=-gstabs}] != "" } { +if {[gdb_compile "${srcdir}/${subdir}/${srcfile3}" "${objfile3}" object {additional_flags=-gstabs}] != "" } { return -1 } @@ -82,12 +80,5 @@ gdb_test "info line func" "Line \[0-9\]* of .* starts at address .* and ends at gdb_test "info line main2" "Line \[0-9\]* of .* starts at address .* and ends at .*" gdb_test "info line func2" "Line \[0-9\]* of .* starts at address .* and ends at .*" -set test "info line main3" -gdb_test_multiple $test $test { - -re "Line \[0-9\]* of .* starts at address .* and ends at .*\r\n$gdb_prompt $" { - pass $test - } - -re "Line \[0-9\]* of .* is at address .* but contains no code\\.\r\n$gdb_prompt $" { - kfail symtab/12497 $test - } -} +gdb_test "info line main3" \ + "Line \[0-9\]* of .* starts at address .* and ends at .*" ++++++ gdb-testsuite-work-around-skip_prologue-problems-in-gdb.threads-process-dies-while-detaching.exp.patch ++++++ [gdb/testsuite] Work around skip_prologue problems in gdb.threads/process-dies-while-detaching.exp On powerpc64le-linux, I run into: ... [Inferior 1 (process 5156) exited normally]^M (gdb) FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: \ detach: detach: continue to breakpoint: _exit (the program exited) ... What happens is the following: - a breakpoint is set on _exit, - a continue is issued - the continue is supposed to hit the breakpoint, but instead the program exits. I traced this down to the breakpoint on _exit being set too far from function entry. This is caused by the skip_prologue function (in rs6000-tdep.c) optimistically ignoring insns it doesn't recognize. In particular, it walks past the system call instruction "sc" which initiates the actual exit. While this needs fixing, we don't want to be testing this behaviour in this test-case. [ Initially I tried to fix it by setting a breakpoint on "*_exit" instead, but that one only sets one location. The breakpoint on "_exit" sets two locations, one in /lib64/libc.so.6 and one in /lib64/ld64.so.2. I tried on x86_64 and there the breakpoint on "*_exit" mapped to the /lib64/libc.so.6 location, and the test-case passed. But on powerpc it mapped to the /lib64/ld64.so.2 location and I still got the same failures. ] Fix this by setting two breakpoints on the calls to _exit and exit instead. Tested on x86_64-linux and powerpc64le-linux. --- gdb/testsuite/gdb.threads/process-dies-while-detaching.c | 4 ++-- gdb/testsuite/gdb.threads/process-dies-while-detaching.exp | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gdb/testsuite/gdb.threads/process-dies-while-detaching.c b/gdb/testsuite/gdb.threads/process-dies-while-detaching.c index 502b4622614..c4c0b0a648b 100644 --- a/gdb/testsuite/gdb.threads/process-dies-while-detaching.c +++ b/gdb/testsuite/gdb.threads/process-dies-while-detaching.c @@ -46,7 +46,7 @@ void * thread_function (void *arg) { pthread_barrier_wait (&start_threads_barrier); - _exit (0); + _exit (0); /* Exit in thread. */ } /* The fork child's entry point. */ @@ -63,7 +63,7 @@ child_function (void) pthread_create (&threads[i], NULL, thread_function, NULL); pthread_barrier_wait (&start_threads_barrier); - exit (0); + exit (0); /* Exit in child. */ } /* This is defined by the .exp file if testing the multi-process diff --git a/gdb/testsuite/gdb.threads/process-dies-while-detaching.exp b/gdb/testsuite/gdb.threads/process-dies-while-detaching.exp index ac1aad26ec5..458d3bbeb56 100644 --- a/gdb/testsuite/gdb.threads/process-dies-while-detaching.exp +++ b/gdb/testsuite/gdb.threads/process-dies-while-detaching.exp @@ -126,8 +126,12 @@ proc detach_and_expect_exit {inf_output_re test} { # Run to _exit in the child. proc continue_to_exit_bp {} { - gdb_breakpoint "_exit" temporary - gdb_continue_to_breakpoint "_exit" ".*_exit.*" + set line [gdb_get_line_number "Exit in child"] + gdb_breakpoint $line temporary + set line [gdb_get_line_number "Exit in thread"] + gdb_breakpoint $line temporary + gdb_continue_to_breakpoint "exit" ".*exit.*" + delete_breakpoints } # If testing single-process, simply detach from the process. ++++++ gdb-tui-fix-breakpoint-display-functionality.patch ++++++ [gdb/tui] Fix breakpoint display functionality In commit 81e6b8eb208 "Make tui-winsource not use breakpoint_chain", a loop body was transformed into a lambda function body: ... - for (bp = breakpoint_chain; - bp != NULL; - bp = bp->next) + iterate_over_breakpoints ([&] (breakpoint *bp) -> bool ... and consequently: - a continue was replaced by a return, and - a final return was added. Then in commit 240edef62f0 "gdb: remove iterate_over_breakpoints function", we transformed back to a loop body: ... - iterate_over_breakpoints ([&] (breakpoint *bp) -> bool + for (breakpoint *bp : all_breakpoints ()) ... but without reverting the changes that introduced the two returns. Consequently, breakpoints no longer show up in the tui source window. Fix this by reverting the changes that introduced the two returns. Build on x86_64-linux, tested with all .exp test-cases that contain tuiterm_env. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28483 gdb/ChangeLog: 2021-10-22 Tom de Vries <tdevries@suse.de> PR tui/28483 * tui/tui-winsource.c (tui_source_window_base::update_breakpoint_info): Fix returns in loop body. gdb/testsuite/ChangeLog: 2021-10-22 Tom de Vries <tdevries@suse.de> PR tui/28483 * gdb.tui/break.exp: New file. --- gdb/testsuite/gdb.tui/break.exp | 37 +++++++++++++++++++++++++++++++++++++ gdb/tui/tui-winsource.c | 3 +-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.tui/break.exp b/gdb/testsuite/gdb.tui/break.exp new file mode 100644 index 00000000000..de4821c570a --- /dev/null +++ b/gdb/testsuite/gdb.tui/break.exp @@ -0,0 +1,37 @@ +# Copyright 2021 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/>. + +# Verify that breakpoint marker is shown. + +tuiterm_env + +standard_testfile tui-layout.c + +if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} { + return -1 +} + +Term::clean_restart 24 80 $testfile +if {![Term::enter_tui]} { + unsupported "TUI not supported" + return +} + +set text [Term::get_all_lines] +gdb_assert {![string match "No Source Available" $text]} \ + "initial source listing" + +Term::command "b main" +Term::check_contents "break marker present" "\\|b\\+" diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index afd51e95980..955b68901fe 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -460,7 +460,7 @@ tui_source_window_base::update_breakpoint_info for (breakpoint *bp : all_breakpoints ()) { if (bp == being_deleted) - return false; + continue; for (bp_location *loc : bp->locations ()) { @@ -478,7 +478,6 @@ tui_source_window_base::update_breakpoint_info mode |= TUI_BP_HARDWARE; } } - return false; } if (line->break_mode != mode) ++++++ import-patches.sh ++++++ #!/bin/sh # Invoke as: # $ ./import-patches.sh [ --dry-run ] <n> <dir>/00*.patch dryrun=false case "$1" in -dryrun|-dry-run|--dryrun|--dry-run) dryrun=true shift ;; esac n="$1" shift files="$*" rm -Rf tmp.patches mkdir tmp.patches tmp= for f in $files; do dir=$(dirname "$f") f=$(basename "$f") orig_f="$f" # Remove numeric prefix. f=$(echo "$f" \ | sed 's/^[0-9]*-//') # To lowercase. f=$(echo "$f" \ | tr '[:upper:]' '[:lower:]') # Fix patch.patch. f=$(echo "$f" \ | sed 's/\.patch\.patch/.patch/') # Copy. cp "$dir"/"$orig_f" tmp.patches/"$f" tmp="$tmp $f" done files="$tmp" i=$n for f in $files; do printf "Patch%-11s%s\n" "$i:" "$f" i=$((i + 1)) done i=$n for f in $files; do echo "%patch$i -p1" i=$((i + 1)) done if $dryrun; then exit fi for f in $files; do mv tmp.patches/"$f" . osc add "$f" done rmdir tmp.patches ++++++ qa.sh ++++++ #!/bin/bash if [ $# -eq 0 ]; then echo "usage: $0 <1-5> [dir]" echo "Verify remote results at:" echo " ./binaries-testsuite.distro.arch/gdb-testresults" echo "1: gdb.sum: Check for 'FAIL: .* internal error' (all configs)" echo "2: gdb.sum: Check for 'ERROR:' (all configs)" echo "3: gdb.log: Check for 'internal-error:' (all configs)" echo "4: gdb.sum: Check FAIL and ERROR (known clean configs)" echo "Verify local results at:" echo " \$dir" echo "5: gdb.sum: Check FAIL and ERROR" exit 1 fi n="$1" shift if [ "$n" = "5" ]; then dir="$1" shift fi echo_line () { for n in "$@"; do echo "$n" done } join () { local char char="$1" shift local res res="" local first first=true for elem in "$@"; do if $first; then first=false else res+="$char" fi res+="$elem" done echo "$res" } report_sum () { local sum sum="$1" echo echo "$sum:" if [ ! -f "$sum" ]; then echo "MISSING" return fi kfail_re=$(join "|" "${kfail[@]}") echo FAILs: grep ^FAIL: "$sum" \ | grep -E -v "$kfail_re" echo ERROR COUNT: grep -c ^ERROR: "$sum" } kfail=( # https://sourceware.org/bugzilla/show_bug.cgi?id=26971 "FAIL: gdb.arch/amd64-init-x87-values.exp: check_x87_regs_around_init: check post FLD1 value of .fop" "FAIL: gdb.arch/amd64-init-x87-values.exp: check_x87_regs_around_init: check post FLD1 value of .fioff" # https://sourceware.org/bugzilla/show_bug.cgi?id=24845 "FAIL: gdb.base/step-over-syscall.exp: clone: displaced=off: single step over clone" # https://sourceware.org/bugzilla/show_bug.cgi?id=19436#c1 "FAIL: gdb.cp/no-dmgl-verbose.exp: setting breakpoint at 'f\(std::string\)'" # https://sourceware.org/bugzilla/show_bug.cgi?id=25504 "FAIL: gdb.threads/process-dies-while-detaching.exp: single-process: continue: .*: continue" # https://sourceware.org/bugzilla/show_bug.cgi?id=28065 "FAIL: gdb.threads/access-mem-running-thread-exit.exp:" # https://sourceware.org/bugzilla/show_bug.cgi?id=27813 "FAIL: gdb.cp/cpcompletion.exp:" # https://sourceware.org/bugzilla/show_bug.cgi?id=25503 "FAIL: gdb.threads/signal-while-stepping-over-bp-other-thread.exp: step \(pattern 3\)" # https://sourceware.org/bugzilla/show_bug.cgi?id=26915 "FAIL: gdb.threads/schedlock.exp: schedlock=off: cmd=next: call_function=0: other threads ran - unlocked" "FAIL: gdb.threads/schedlock.exp: schedlock=off: cmd=step: other threads ran - unlocked" # https://sourceware.org/bugzilla/show_bug.cgi?id=28479 "FAIL: gdb.mi/mi-nonstop.exp: wait for thread exit \(timeout\)" # https://sourceware.org/bugzilla/show_bug.cgi?id=26284 # https://sourceware.org/bugzilla/show_bug.cgi?id=28275 # https://sourceware.org/bugzilla/show_bug.cgi?id=28343 "FAIL: gdb.threads/detach-step-over.exp: .*internal error" # https://sourceware.org/bugzilla/show_bug.cgi?id=26363 "FAIL: gdb.xml/tdesc-reload.exp: .*internal error" # https://sourceware.org/bugzilla/show_bug.cgi?id=26761 "FAIL: gdb.base/gdb-sigterm.exp: .*internal error" ) kfail_factory=( # https://sourceware.org/bugzilla/show_bug.cgi?id=27027 # https://sourceware.org/bugzilla/show_bug.cgi?id=28464 "FAIL: gdb.ada/mi_var_access.exp: Create varobj \(unexpected output\)" # https://sourceware.org/bugzilla/show_bug.cgi?id=28463 "FAIL: gdb.ada/set_pckd_arr_elt.exp: scenario=minimal: print va.t\(1\) := 15" "FAIL: gdb.ada/set_pckd_arr_elt.exp: scenario=minimal: continue to update_small for va.t" # https://sourceware.org/bugzilla/show_bug.cgi?id=28108 "FAIL: gdb.base/langs.exp: up to foo in langs.exp" "FAIL: gdb.base/langs.exp: up to cppsub_ in langs.exp" "FAIL: gdb.base/langs.exp: up to fsub in langs.exp" # https://sourceware.org/bugzilla/show_bug.cgi?id=27539 "FAIL: gdb.cp/typeid.exp: before starting: print &typeid\(i\)" "FAIL: gdb.cp/typeid.exp: before starting: print &typeid\(i\) == &typeid\(typeof\(i\)\)" "FAIL: gdb.cp/typeid.exp: before starting: print &typeid\(cp\)" "FAIL: gdb.cp/typeid.exp: before starting: print &typeid\(cp\) == &typeid\(typeof\(cp\)\)" "FAIL: gdb.cp/typeid.exp: before starting: print &typeid\(ccp\)" "FAIL: gdb.cp/typeid.exp: before starting: print &typeid\(ccp\) == &typeid\(typeof\(ccp\)\)" # https://sourceware.org/bugzilla/show_bug.cgi?id=28461 "FAIL: gdb.reverse/fstatat-reverse.exp: continue to breakpoint: marker2" # https://sourceware.org/pipermail/gdb-patches/2021-October/182449.html "FAIL: gdb.threads/current-lwp-dead.exp: continue to breakpoint: fn_return" # Similar error message to the one above, see if fixing that one fixes this. "FAIL: gdb.threads/clone-new-thread-event.exp: catch SIGUSR1" # https://sourceware.org/bugzilla/show_bug.cgi?id=27238 "FAIL: gdb.go/package.exp: setting breakpoint at package2.Foo" "FAIL: gdb.go/package.exp: going to first breakpoint \(the program exited\)" # https://sourceware.org/bugzilla/show_bug.cgi?id=28468 "FAIL: gdb.threads/signal-command-handle-nopass.exp: step-over (yes|no): signal SIGUSR1" # https://sourceware.org/bugzilla/show_bug.cgi?id=28477 "FAIL: gdb.base/step-over-syscall.exp: clone: displaced=off: continue to marker \(clone\)" # https://sourceware.org/bugzilla/show_bug.cgi?id=28478 "FAIL: gdb.gdb/selftest.exp: backtrace through signal handler" # https://sourceware.org/bugzilla/show_bug.cgi?id=26867 "FAIL: gdb.threads/signal-sigtrap.exp: sigtrap thread 1: signal SIGTRAP reaches handler" # https://sourceware.org/bugzilla/show_bug.cgi?id=28510 FAIL: gdb.debuginfod/fetch_src_and_symbols.exp: local_url: br main FAIL: gdb.debuginfod/fetch_src_and_symbols.exp: local_url: l ) case $n in 1) # 'FAIL: .* internal error' in gdb.sum. # Test fail due to internal error. # kfail_re=$(join "|" "${kfail[@]}") grep "^FAIL:.*internal error" binaries-testsuite*/gdb-testresults/*.sum \ | grep -E -v "$kfail_re" ;; 2) # 'ERROR:' in gdb.sum. # A dejagnu or tcl ERROR, may hide real problems. # kfail+=( # https://sourceware.org/bugzilla/show_bug.cgi?id=28355 "openSUSE_Factory_ARM.aarch64.*UNRESOLVED: gdb.server/.*.exp: (ensure inferior is running|set sysroot remote)" # https://sourceware.org/bugzilla/show_bug.cgi?id=28323 "SLE-12.x86_64.*gdb.ada/mi_dyn_arr.exp" ) kfail_re=$(join "|" "${kfail[@]}") grep -A1 "ERROR:.*no longer" binaries-testsuite*/gdb-testresults/*.sum \ | grep -E -v "ERROR|\--" | grep -E -v "$kfail_re" ;; 3) # 'internal-error' in gdb.log # Catch all internal-errors, not just the ones reported by dejagnu. # kfail+=( # https://sourceware.org/bugzilla/show_bug.cgi?id=26284 "infrun.c:[0-9]*: internal-error: int finish_step_over\(.*\): Assertion \`ecs->event_thread->control.trap_expected' failed." # https://sourceware.org/bugzilla/show_bug.cgi?id=26363 ".i586.*i386-linux-nat.c:[0-9]*: internal-error: Got request for bad register number 41." # https://sourceware.org/bugzilla/show_bug.cgi?id=26761 "thread.c:[0-9]*: internal-error: .* inferior_thread\(\): Assertion \`current_thread_ \!= nullptr' failed." # https://sourceware.org/bugzilla/show_bug.cgi?id=19675 "linux-nat.c:[0-9]*: internal-error: wait returned unexpected status" ) kfail_re=$(join "|" "${kfail[@]}") grep -a -H internal-error: binaries-testsuite.*/gdb-testresults/*.log \ | grep -a -v "maint.c:[0-9]" \ | grep -a -E -v "$kfail_re" ;; 4) sums=() # Note: below we avoid gdb-x86_64-suse-linux-m32.sum (the pie variant). # That one hasn't been cleaned up. # Known clean config: Leap 15.1 x86_64. config=openSUSE_Leap_15.1.x86_64/gdb-testresults sums+=("$config/gdb-x86_64-suse-linux-m64.-fno-PIE.-no-pie.sum" "$config/gdb-x86_64-suse-linux-m64.sum" "$config/gdb-x86_64-suse-linux-m32.-fno-PIE.-no-pie.sum") # Known clean config: Leap 15.2 x86_64. config=openSUSE_Leap_15.2.x86_64/gdb-testresults sums+=("$config/gdb-x86_64-suse-linux-m64.-fno-PIE.-no-pie.sum" "$config/gdb-x86_64-suse-linux-m64.sum" "$config/gdb-x86_64-suse-linux-m32.-fno-PIE.-no-pie.sum") # Known clean config: Leap 15.3 x86_64 config=openSUSE_Leap_15.3.x86_64/gdb-testresults sums+=("$config/gdb-x86_64-suse-linux-m64.-fno-PIE.-no-pie.sum" "$config/gdb-x86_64-suse-linux-m64.sum" "$config/gdb-x86_64-suse-linux-m32.-fno-PIE.-no-pie.sum") # Known clean config: SLE 15 x86_64. config=SLE-15.x86_64/gdb-testresults sums+=("$config/gdb-x86_64-suse-linux-m64.-fno-PIE.-no-pie.sum" "$config/gdb-x86_64-suse-linux-m64.sum" "$config/gdb-x86_64-suse-linux-m32.-fno-PIE.-no-pie.sum") # Known cleanish config: Factory x86_64. config=openSUSE_Factory.x86_64/gdb-testresults sums+=("$config/gdb-x86_64-suse-linux-m64.-fno-PIE.-no-pie.sum" "$config/gdb-x86_64-suse-linux-m64.sum" "$config/gdb-x86_64-suse-linux-m32.-fno-PIE.-no-pie.sum") kfail+=("${kfail_factory[@]}") for sum in "${sums[@]}"; do sum=binaries-testsuite.$sum report_sum "$sum" done ;; 5) sums=() mapfile -t < <(echo_line "$dir"/*-m64.-fno-PIE.-no-pie.sum) sums+=("${MAPFILE[@]}") mapfile -t < <(echo_line "$dir"/*-m64.sum) sums+=("${MAPFILE[@]}") mapfile -t < <(echo_line "$dir"/*-m32.-fno-PIE.-no-pie.sum) sums+=("${MAPFILE[@]}") # Assume this is factory. kfail+=("${kfail_factory[@]}") for sum in "${sums[@]}"; do report_sum "$sum" done ;; *) echo "Don't know how to handle arg: $n" exit 1 ;; esac ++++++ v2.0.2.tar.gz -> v2.0.4.tar.gz ++++++ ++++ 5128 lines of diff (skipped)
participants (1)
-
Source-Sync